mirror of
https://github.com/LHY0125/Gobang-Game.git
synced 2026-05-10 02:19:46 +08:00
refactor(gui): 拆分大型 GUI 模块为多个功能文件
将单一的 gui.c 文件拆分为 gui_core.c、gui_draw.c、gui_game.c 和 gui_replay.c,并引入 gui_internal.h 作为内部头文件。更新 Makefile 以包含新的源文件。同时修复了复盘模式中主菜单的隐藏时机,并改进了记录文件的加载逻辑以更安全地处理 CSV 解析。 - 提取核心 GUI 初始化、事件循环和坐标转换到 gui_core.c - 分离绘图功能(棋盘、棋子)到 gui_draw.c - 将游戏逻辑(PvP/PvE)移动到 gui_game.c - 独立复盘功能到 gui_replay.c,优化文件选择流程 - 修复 btn_replay_cb 中过早隐藏主菜单的问题 - 增强 load_game_from_file 的健壮性,使用 sscanf 替代 fscanf 并改进行处理
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
#ifndef GUI_INTERNAL_H
|
||||
#define GUI_INTERNAL_H
|
||||
|
||||
#include <iup.h>
|
||||
|
||||
// 全局变量声明 (在 gui_core.c 中定义)
|
||||
extern Ihandle *dlg;
|
||||
extern Ihandle *board_canvas;
|
||||
extern Ihandle *lbl_player;
|
||||
extern Ihandle *lbl_status;
|
||||
extern int gui_loop_running;
|
||||
extern int gui_game_mode; // 0: PvP, 1: PvE, 2: Replay
|
||||
extern int replay_total_steps; // 复盘总步数
|
||||
|
||||
// 绘图函数 (在 gui_draw.c 中定义)
|
||||
void set_draw_color(Ihandle *ih, unsigned char r, unsigned char g, unsigned char b);
|
||||
void draw_board_iup(Ihandle *ih);
|
||||
void draw_stones_iup(Ihandle *ih);
|
||||
|
||||
// 核心功能 (在 gui_core.c 中定义)
|
||||
void update_ui_labels();
|
||||
int screen_to_board(int screen_x, int screen_y, int *board_x, int *board_y);
|
||||
|
||||
// 游戏窗口 (在 gui_game.c 中定义)
|
||||
void create_game_window();
|
||||
int action_cb(Ihandle *ih);
|
||||
int button_cb(Ihandle *ih, int button, int pressed, int x, int y, char *status);
|
||||
int k_any_cb(Ihandle *ih, int c);
|
||||
int btn_back_cb(Ihandle *ih);
|
||||
int btn_undo_cb(Ihandle *ih);
|
||||
int btn_save_cb(Ihandle *ih);
|
||||
|
||||
// 复盘功能 (在 gui_replay.c 中定义)
|
||||
void select_replay_file_gui();
|
||||
int btn_replay_prev_cb(Ihandle *ih);
|
||||
int btn_replay_next_cb(Ihandle *ih);
|
||||
int btn_replay_sel_ok_cb(Ihandle *ih);
|
||||
int btn_replay_sel_cancel_cb(Ihandle *ih);
|
||||
|
||||
#endif // GUI_INTERNAL_H
|
||||
Reference in New Issue
Block a user