Skip to content

Commit

Permalink
WIP: Add AUTO_TOURNAMENT
Browse files Browse the repository at this point in the history
  • Loading branch information
mrannanj committed Nov 3, 2024
1 parent 85828d8 commit 764c63c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/game/game_state_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ enum
NET_MODE_NONE,
NET_MODE_SERVER,
NET_MODE_CLIENT,
NET_MODE_LOBBY
NET_MODE_LOBBY,
AUTO_TOURNAMENT,
};

typedef struct scene_t scene;
Expand Down
2 changes: 2 additions & 0 deletions src/game/scenes/mainmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ int mainmenu_create(scene *scene) {
} else if(scene->gs->net_mode == NET_MODE_SERVER) {
component_action(guiframe_find(local->frame, NETWORK_BUTTON_ID), ACT_PUNCH);
component_action(guiframe_find(local->frame, NETWORK_LISTEN_BUTTON_ID), ACT_PUNCH);
} else if(scene->gs->net_mode == AUTO_TOURNAMENT) {
component_action(guiframe_find(local->frame, TOURNAMENT_BUTTON_ID), ACT_PUNCH);
}

// clear it, so this only happens the first time
Expand Down
4 changes: 3 additions & 1 deletion src/game/scenes/mainmenu/menu_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ component *menu_main_create(scene *s) {
component *menu = menu_create(11);
menu_attach(menu, textbutton_create(&tconf, "ONE PLAYER GAME", NULL, COM_ENABLED, mainmenu_1v1, s));
menu_attach(menu, textbutton_create(&tconf, "TWO PLAYER GAME", NULL, COM_ENABLED, mainmenu_1v2, s));
menu_attach(menu, textbutton_create(&tconf, "TOURNAMENT PLAY", NULL, COM_ENABLED, mainmenu_mechlab, s));
component *tournament = textbutton_create(&tconf, "TOURNAMENT PLAY", NULL, COM_ENABLED, mainmenu_mechlab, s);
widget_set_id(tournament, TOURNAMENT_BUTTON_ID);
menu_attach(menu, tournament);
component *net = textbutton_create(&tconf, "NETWORK PLAY", NULL, COM_ENABLED, mainmenu_enter_network, s);
widget_set_id(net, NETWORK_BUTTON_ID);
menu_attach(menu, net);
Expand Down
2 changes: 2 additions & 0 deletions src/game/scenes/mainmenu/menu_widget_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
#define NETWORK_CONNECT_IP_BUTTON_ID 103
#define NETWORK_LOBBY_BUTTON_ID 104

#define TOURNAMENT_BUTTON_ID 200

#endif // MENU_WIDGET_IDS_H
5 changes: 4 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,14 @@ int main(int argc, char *argv[]) {
struct arg_lit *vers = arg_lit0("v", "version", "print version information and exit");
struct arg_lit *listen = arg_lit0("l", "listen", "Start a network game server");
struct arg_lit *headless = arg_lit0("H", "headless", "Run headless tests");
struct arg_lit *tournament = arg_lit0("T", "tournament", "Enter tournament menu");
struct arg_str *connect = arg_str0("c", "connect", "<host>", "Connect to a remote game");
struct arg_str *trace = arg_str0("t", "trace", "<file>", "Trace netplay events to file");
struct arg_int *port = arg_int0("p", "port", "<port>", "Port to connect or listen (default: 2097)");
struct arg_file *play = arg_file0("P", "play", "<file>", "Play an existing recfile");
struct arg_file *rec = arg_file0("R", "rec", "<file>", "Record a new recfile");
struct arg_end *end = arg_end(30);
void *argtable[] = {help, vers, listen, headless, connect, trace, port, play, rec, end};
void *argtable[] = {help, vers, listen, headless, tournament, connect, trace, port, play, rec, end};
const char *progname = "openomf";

// Make sure everything got allocated
Expand Down Expand Up @@ -129,6 +130,8 @@ int main(int argc, char *argv[]) {
} else if(listen->count > 0) {
init_flags.net_mode = NET_MODE_SERVER;
listen_port = 2097;
} else if(tournament->count > 0) {
init_flags.net_mode = AUTO_TOURNAMENT;
} else if(play->count > 0) {
strncpy(init_flags.rec_file, play->filename[0], 254);
} else if(rec->count > 0) {
Expand Down

0 comments on commit 764c63c

Please sign in to comment.