1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-04 13:46:44 +02:00

Show previous window instead of Home after closing a window

This commit is contained in:
jfreegman
2021-01-25 20:07:07 -05:00
parent 7abf6388f8
commit 35aa6922d6
2 changed files with 58 additions and 5 deletions

View File

@ -32,6 +32,7 @@
#include "game_snake.h"
#include "line_info.h"
#include "misc_tools.h"
#include "windows.h"
extern struct Winthread Winthread;
@ -144,6 +145,12 @@ void game_kill(ToxWindow *self)
del_window(self);
}
static void game_init_abort(const ToxWindow *parent, ToxWindow *self)
{
game_kill(self);
set_active_window_index(parent->index);
}
static void game_toggle_pause(GameData *game)
{
GameStatus status = game->status;
@ -234,11 +241,12 @@ int game_initialize(const ToxWindow *parent, Tox *m, GameType type, uint32_t id,
if (game->is_multiplayer) {
if (parent->type != WINDOW_TYPE_CHAT) {
game_kill(self);
game_init_abort(parent, self);
return -3;
}
if (get_friend_connection_status(parent->num) == TOX_CONNECTION_NONE) {
game_init_abort(parent, self);
return -2;
}
@ -259,14 +267,14 @@ int game_initialize(const ToxWindow *parent, Tox *m, GameType type, uint32_t id,
game->friend_number = parent->num;
if (game->window == NULL) {
game_kill(self);
game_init_abort(parent, self);
return -4;
}
int init_ret = game_initialize_type(game, multiplayer_data, length);
if (init_ret < 0) {
game_kill(self);
game_init_abort(parent, self);
return init_ret;
}
@ -680,7 +688,6 @@ void game_onDraw(ToxWindow *self, Tox *m)
}
default: {
fprintf(stderr, "Unknown game status: %d\n", game->status);
break;
}
}