diff --git a/ModConfigMenu/ModConfigMenu/Src/ModConfigMenu/Classes/MCM_OptionsScreen.uc b/ModConfigMenu/ModConfigMenu/Src/ModConfigMenu/Classes/MCM_OptionsScreen.uc index 2b199ef..6ed6fea 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,20 @@ 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); + } + else + { + TmpSetting.PageID = -1; + } + } + } simulated function OnRemoved() @@ -441,6 +467,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 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