From 5ba72a224c3ede99a7b7977ce19d958dd374f1d3 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Fri, 3 Apr 2020 13:36:42 +0200 Subject: [PATCH] Menu: Filter through the gameinfo defined types to clean up the mess other people like to put in it. --- src/menu-fn/m_customgame.cpp | 17 ++++++++++++++++- src/menu-fn/m_main.cpp | 8 ++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/menu-fn/m_customgame.cpp b/src/menu-fn/m_customgame.cpp index c89a3fa5..03759ec0 100644 --- a/src/menu-fn/m_customgame.cpp +++ b/src/menu-fn/m_customgame.cpp @@ -108,7 +108,22 @@ void games_init(void) games[id].cldll = (int)stof(argv(i+1)); break; case "gameinfo_type": - games[id].type = argv(i+1); + switch (strtolower(argv(i+1))) { + case "multiplayer_only": + case "mp": + case "multi": + case "multiplayer": + games[id].type = "Multiplayer"; + break; + case "singleplayer_only": + case "sp": + case "single": + case "singleplayer": + games[id].type = "Singleplayer"; + break; + default: + games[id].type = "Both"; + } break; case "gameinfo_hlversion": games[id].hlversion = argv(i+1); diff --git a/src/menu-fn/m_main.cpp b/src/menu-fn/m_main.cpp index 6ef915d4..924179f2 100644 --- a/src/menu-fn/m_main.cpp +++ b/src/menu-fn/m_main.cpp @@ -140,7 +140,7 @@ void menu_main_init(void) main_btnNewGame = spawn(CMainButton); main_btnNewGame.SetImage(BTN_NEWGAME); - if (games[gameinfo_current].type != "multiplayer_only") { + if (games[gameinfo_current].type != "Multiplayer") { main_btnNewGame.SetExecute(btn_newgame_start); } main_btnNewGame.SetPos(70,208); @@ -148,7 +148,7 @@ void menu_main_init(void) main_btnTraining = spawn(CMainButton); main_btnTraining.SetImage(BTN_TRAINING); - if (games[gameinfo_current].type != "multiplayer_only") { + if (games[gameinfo_current].type != "Multiplayer") { main_btnTraining.SetExecute(btn_training); } main_btnTraining.SetPos(70,236); @@ -162,7 +162,7 @@ void menu_main_init(void) main_btnLoadGame = spawn(CMainButton); main_btnLoadGame.SetImage(BTN_LOADGAME); - if (games[gameinfo_current].type != "multiplayer_only") { + if (games[gameinfo_current].type != "Multiplayer") { // Loadgame disabled } main_btnLoadGame.SetPos(70,292); @@ -171,7 +171,7 @@ void menu_main_init(void) main_btnMultiplayer = spawn(CMainButton); main_btnMultiplayer.SetImage(BTN_MULTIPLAYER); main_btnMultiplayer.SetPos(70,320); - if (games[gameinfo_current].type != "singleplayer_only") { + if (games[gameinfo_current].type != "Singleplayer") { main_btnMultiplayer.SetExecute(btn_multiplayer_start); } Widget_Add(fn_main, main_btnMultiplayer);