From dc96e1ac94ed8c0c8eb4eb1976773dce12a2d590 Mon Sep 17 00:00:00 2001 From: bountygiver Date: Wed, 31 May 2017 14:56:52 -0400 Subject: [PATCH 1/3] Added config based custom settings page --- .../Classes/MCM_OptionsScreen.uc | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/ModConfigMenu/ModConfigMenu/Src/ModConfigMenu/Classes/MCM_OptionsScreen.uc b/ModConfigMenu/ModConfigMenu/Src/ModConfigMenu/Classes/MCM_OptionsScreen.uc index 2b199ef..142373b 100755 --- a/ModConfigMenu/ModConfigMenu/Src/ModConfigMenu/Classes/MCM_OptionsScreen.uc +++ b/ModConfigMenu/ModConfigMenu/Src/ModConfigMenu/Classes/MCM_OptionsScreen.uc @@ -1,6 +1,7 @@ class MCM_OptionsScreen extends UIScreen implements(MCM_API, MCM_API_Instance) config(ModConfigMenu) dependson(UIDialogueBox); + var config int PANEL_X; var config int PANEL_Y; var config int TABLIST_WIDTH; @@ -15,6 +16,16 @@ var config int FOOTER_HEIGHT; // Save and Exit button. Allows for bigger menu. var config bool SHOW_SOLDIER; +// +struct CustomSettingsPage +{ + var string TabLabel; + var string ScreenClass; + var eGameMode ShowInGameMode; + var int PageID; // PageID will be overwritten when initializing tabs, so don't assign one in config +}; +var config array CustomPages; + // Needs major version match and requested minor version needs to be <= actual minor version. var config int API_MAJOR_VERSION; var config int API_MINOR_VERSION; @@ -91,6 +102,7 @@ simulated function UpdateGameMode() simulated function OnInit() { + local CustomSettingsPage TmpSetting; super.OnInit(); `log("MCM Core: On Init Called."); @@ -100,6 +112,16 @@ simulated function OnInit() `log("MCM Core: hiding soldier guy on main menu for visibility."); HideSoldierIfMainMenu(); } + + // Iterate through all custom settings + foreach CustomPages(TmpSetting) + { + if (TmpSetting.ShowInGameMode == CurrentGameMode) + { + NewConfigSettingsPage(TmpSetting); + } + } + } simulated function OnRemoved() @@ -441,6 +463,58 @@ function bool RegisterClientMod(int major, int minor, delegate ScreenClass; + `log("MCM Tab clicked: " $ string(PageID)); + + Caller.SetChecked(false); + + // Now choose the panel. + foreach CustomPages(TmpSetting) + { + if (TmpSetting.PageID == PageID) + { + `log("MCM: Found correct panel, showing screen" @ TmpSetting.ScreenClass); + ScreenClass = class(DynamicLoadObject(TmpSetting.ScreenClass, class'Class')); + if (ScreenClass != none) + { + Movie.Stack.Push(PC.Pres.Spawn(ScreenClass, PC.Pres)); + } + } + } + + // Refresh the button. This is important if we're cancelling a tab change. + foreach SettingsTabs(TmpButton) + { + if (TmpButton.SettingsPageID == SelectedPageID) + { + TmpButton.SetChecked(true); + } + else + { + TmpButton.SetChecked(false); + } + } +} + +function int NewConfigSettingsPage(out CustomSettingsPage CustomSetting) +{ + local MCM_SettingsTab Item; + + CustomSetting.PageID = SettingsPageCounter; + SettingsPageCounter++; + + Item = Spawn(class'MCM_SettingsTab', TabsList.ItemContainer).InitSettingsTab(CustomSetting.PageID, CustomSetting.TabLabel); + Item.OnClickHandler = CustomScreenTabClickedHandler; + + return CustomSetting.PageID; +} + // Defaults ====================================================================================== defaultproperties From 89c52c557d5835e44a7936075b8fe35a926cff4e Mon Sep 17 00:00:00 2001 From: bountygiver Date: Wed, 31 May 2017 15:12:25 -0400 Subject: [PATCH 2/3] Updated documentation for config based custom screen class --- documentation/advanced.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/documentation/advanced.md b/documentation/advanced.md index 85ebd61..f17f4b3 100644 --- a/documentation/advanced.md +++ b/documentation/advanced.md @@ -103,6 +103,20 @@ your custom settings page. You will have to implement your own saving/cancelling An example of how to use `NewCustomSettingsPage` can be found in the `MCM_CustomPageTest.uc` and `MC_CustomPageTestUI.uc` files in the `ModConfigMenu` project. +### Custom Settings Pages by ini config + +You may also add new custom settings pages through ini config without using MCM_API. + +To add a custom page entry, create the file `XComModConfigMenu.ini` with the following contents: + +``` +[ModConfigMenu.MCM_OptionsScreen] ++CustomPages=(TabLabel="Mod Name", ScreenClass="YourMod.YourOptionsScreen", ShowInGameMode=eGameMode_MainMenu) +``` + +Where `TabLabel` will be the name that appears on the left of the menu. `ScreenClass` will be the class of your custom options screen (Note that you need to include your mod package name to avoid class name conflicts). And `ShowInGameMode` will be the options menu screen your custom page will show up in, the available values can be found in the next section, you will need to repeat the line for each menu you want the custom page to show up on. + + ### Limit options for main menu / Avenger screen / In-mission screen MCM will tell you about the game mode through the handler you passed into the version check. You can see an example in From af89803037aae4ed81c5213d4c9cef60491f7c4e Mon Sep 17 00:00:00 2001 From: bountygiver Date: Fri, 2 Jun 2017 13:51:01 -0400 Subject: [PATCH 3/3] Fixed a bug where disabled menus still occupy the previous pageID causing multiple custom screens to be opened --- .../Src/ModConfigMenu/Classes/MCM_OptionsScreen.uc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ModConfigMenu/ModConfigMenu/Src/ModConfigMenu/Classes/MCM_OptionsScreen.uc b/ModConfigMenu/ModConfigMenu/Src/ModConfigMenu/Classes/MCM_OptionsScreen.uc index 142373b..6ed6fea 100755 --- a/ModConfigMenu/ModConfigMenu/Src/ModConfigMenu/Classes/MCM_OptionsScreen.uc +++ b/ModConfigMenu/ModConfigMenu/Src/ModConfigMenu/Classes/MCM_OptionsScreen.uc @@ -120,6 +120,10 @@ simulated function OnInit() { NewConfigSettingsPage(TmpSetting); } + else + { + TmpSetting.PageID = -1; + } } }