mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 00:43:01 +01:00
Show previous window instead of Home after closing a window
This commit is contained in:
parent
7abf6388f8
commit
35aa6922d6
@ -32,6 +32,7 @@
|
|||||||
#include "game_snake.h"
|
#include "game_snake.h"
|
||||||
#include "line_info.h"
|
#include "line_info.h"
|
||||||
#include "misc_tools.h"
|
#include "misc_tools.h"
|
||||||
|
#include "windows.h"
|
||||||
|
|
||||||
extern struct Winthread Winthread;
|
extern struct Winthread Winthread;
|
||||||
|
|
||||||
@ -144,6 +145,12 @@ void game_kill(ToxWindow *self)
|
|||||||
del_window(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)
|
static void game_toggle_pause(GameData *game)
|
||||||
{
|
{
|
||||||
GameStatus status = game->status;
|
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 (game->is_multiplayer) {
|
||||||
if (parent->type != WINDOW_TYPE_CHAT) {
|
if (parent->type != WINDOW_TYPE_CHAT) {
|
||||||
game_kill(self);
|
game_init_abort(parent, self);
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_friend_connection_status(parent->num) == TOX_CONNECTION_NONE) {
|
if (get_friend_connection_status(parent->num) == TOX_CONNECTION_NONE) {
|
||||||
|
game_init_abort(parent, self);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,14 +267,14 @@ int game_initialize(const ToxWindow *parent, Tox *m, GameType type, uint32_t id,
|
|||||||
game->friend_number = parent->num;
|
game->friend_number = parent->num;
|
||||||
|
|
||||||
if (game->window == NULL) {
|
if (game->window == NULL) {
|
||||||
game_kill(self);
|
game_init_abort(parent, self);
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
|
|
||||||
int init_ret = game_initialize_type(game, multiplayer_data, length);
|
int init_ret = game_initialize_type(game, multiplayer_data, length);
|
||||||
|
|
||||||
if (init_ret < 0) {
|
if (init_ret < 0) {
|
||||||
game_kill(self);
|
game_init_abort(parent, self);
|
||||||
return init_ret;
|
return init_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -680,7 +688,6 @@ void game_onDraw(ToxWindow *self, Tox *m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
fprintf(stderr, "Unknown game status: %d\n", game->status);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1476,6 +1476,30 @@ static int chess_get_display_colour(ChessColour p_colour, int tile_colour)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void chess_move_curs_up_left(ChessState *state)
|
||||||
|
{
|
||||||
|
chess_move_curs_left(state);
|
||||||
|
chess_move_curs_up(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void chess_move_curs_up_right(ChessState *state)
|
||||||
|
{
|
||||||
|
chess_move_curs_right(state);
|
||||||
|
chess_move_curs_up(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void chess_move_curs_down_left(ChessState *state)
|
||||||
|
{
|
||||||
|
chess_move_curs_left(state);
|
||||||
|
chess_move_curs_down(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void chess_move_curs_down_right(ChessState *state)
|
||||||
|
{
|
||||||
|
chess_move_curs_right(state);
|
||||||
|
chess_move_curs_down(state);
|
||||||
|
}
|
||||||
|
|
||||||
static void chess_draw_board_coords_white(WINDOW *win, const Board *board)
|
static void chess_draw_board_coords_white(WINDOW *win, const Board *board)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < CHESS_BOARD_COLUMNS; ++i) {
|
for (size_t i = 0; i < CHESS_BOARD_COLUMNS; ++i) {
|
||||||
@ -1728,7 +1752,29 @@ void chess_cb_on_keypress(GameData *game, int key, void *cb_data)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '\r': {
|
case KEY_HOME: {
|
||||||
|
chess_move_curs_up_left(state);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case KEY_END: {
|
||||||
|
chess_move_curs_down_left(state);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case KEY_PPAGE: {
|
||||||
|
chess_move_curs_up_right(state);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case KEY_NPAGE: {
|
||||||
|
chess_move_curs_down_right(state);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case '\r':
|
||||||
|
/* Intentional fallthrough */
|
||||||
|
case ' ': {
|
||||||
chess_do_input(game, state);
|
chess_do_input(game, state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user