Skip to content

Commit

Permalink
Squashing changes from MrNiceUK/ControllerSupport to prepare for reba…
Browse files Browse the repository at this point in the history
…se against main branch
  • Loading branch information
MrNiceUK authored and andrewgu committed Jul 10, 2021
1 parent be25923 commit d3b3e2a
Show file tree
Hide file tree
Showing 29 changed files with 888 additions and 400 deletions.
4 changes: 2 additions & 2 deletions ModConfigMenu/ModConfigMenu.XCOM_sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Global
Default|XCOM 2 = Default|XCOM 2
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3F350978-33E7-493A-993B-92C1B54BF591}.Debug|XCOM 2.ActiveCfg = Debug|XCOM 2
{3F350978-33E7-493A-993B-92C1B54BF591}.Debug|XCOM 2.Build.0 = Debug|XCOM 2
{3F350978-33E7-493A-993B-92C1B54BF591}.Debug|XCOM 2.ActiveCfg = Default|XCOM 2
{3F350978-33E7-493A-993B-92C1B54BF591}.Debug|XCOM 2.Build.0 = Default|XCOM 2
{3F350978-33E7-493A-993B-92C1B54BF591}.Default|XCOM 2.ActiveCfg = Default|XCOM 2
{3F350978-33E7-493A-993B-92C1B54BF591}.Default|XCOM 2.Build.0 = Default|XCOM 2
EndGlobalSection
Expand Down
1 change: 1 addition & 0 deletions ModConfigMenu/ModConfigMenu/Localization/ModConfigMenu.int
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ m_strSaveAndExit="Save and Exit"
m_strCancel="Cancel"
m_strTitle="Mod Settings"
m_strSubtitle=""
m_strScroll="SCROLL"

[MCM_SettingsPanel]
m_strResetButton="Reset"
Expand Down
6 changes: 6 additions & 0 deletions ModConfigMenu/ModConfigMenu/ModConfigMenu.x2proj
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ For full details on using this mod, troubleshooting, or even building your own m
<Content Include="Src\ModConfigMenu\Classes\MCM_TestHarnessListener.uc">
<SubType>Content</SubType>
</Content>
<Content Include="Src\ModConfigMenu\Classes\MCM_UIButton.uc">
<SubType>Content</SubType>
</Content>
<Content Include="Src\ModConfigMenu\Classes\MCM_UIListItemSpinner.uc">
<SubType>Content</SubType>
</Content>
<Content Include="Src\ModConfigMenu\Classes\MCM_UISettingSeparator.uc">
<SubType>Content</SubType>
</Content>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
class MCM_Button extends MCM_SettingBase implements(MCM_API_Button) config(ModConfigMenu);

var delegate<VoidSettingHandler> ClickHandler;
var delegate<MCM_API_SettingsGroup.VoidSettingHandler> ClickHandler;

var MCM_API_Setting ParentFacade;

delegate VoidSettingHandler(MCM_API_Setting Setting);

simulated function MCM_SettingBase InitSettingsItem(name _Name, eSettingType _Type, optional string _Label = "", optional string _Tooltip = "")
{
Expand All @@ -14,7 +13,7 @@ simulated function MCM_SettingBase InitSettingsItem(name _Name, eSettingType _Ty
}

// Fancy init process
simulated function MCM_Button InitButton(name _SettingName, MCM_API_Setting _ParentFacade, string _Label, string _Tooltip, string _ButtonLabel, delegate<VoidSettingHandler> _OnClick)
simulated function MCM_Button InitButton(name _SettingName, MCM_API_Setting _ParentFacade, string _Label, string _Tooltip, string _ButtonLabel, delegate<MCM_API_SettingsGroup.VoidSettingHandler> _OnClick)
{
super.InitSettingsItem(_SettingName, eSettingType_Button, _Label, _Tooltip);

Expand Down Expand Up @@ -42,4 +41,9 @@ function SimulateClick()
{
ClickHandler(ParentFacade);
}
}

simulated function bool OnUnrealCommand(int cmd, int arg)
{
return Super(UIMechaListItem).OnUnrealCommand(cmd, arg);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ var MCM_SettingGroup ParentGroup;

var string ButtonLabel;

var delegate<VoidSettingHandler> ClickHandler;
var delegate<MCM_API_SettingsGroup.VoidSettingHandler> ClickHandler;

var MCM_Button uiInstance;

delegate VoidSettingHandler(MCM_API_Setting _Setting);

simulated function MCM_ButtonFacade InitButtonFacade(name _Name, string _Label, string _Tooltip, string _ButtonLabel,
delegate<VoidSettingHandler> _OnClick, MCM_SettingGroup _ParentGroup)
delegate<MCM_API_SettingsGroup.VoidSettingHandler> _OnClick, MCM_SettingGroup _ParentGroup)
{
SettingName = _Name;
Label = _Label;
Expand All @@ -40,7 +39,6 @@ simulated function UIMechaListItem InstantiateUI(UIList parent)
{
uiInstance = Spawn(class'MCM_Button', parent.itemContainer).InitButton(SettingName, self, Label, Tooltip, ButtonLabel, ClickHandler);
uiInstance.Show();
uiInstance.EnableNavigation();
uiInstance.SetEditable(Editable);

return uiInstance;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
class MCM_Checkbox extends MCM_SettingBase implements(MCM_API_Checkbox) config(ModConfigMenu);

var MCM_API_Setting ParentFacade;
var delegate<BoolSettingHandler> ChangeHandler;

delegate BoolSettingHandler(MCM_API_Setting _Setting, bool _SettingValue);
var delegate<MCM_API_SettingsGroup.BoolSettingHandler> ChangeHandler;

simulated function MCM_SettingBase InitSettingsItem(name _Name, eSettingType _Type, optional string _Label = "", optional string _Tooltip = "")
{
Expand All @@ -13,7 +11,7 @@ simulated function MCM_SettingBase InitSettingsItem(name _Name, eSettingType _Ty
}

// Fancy init process
simulated function MCM_Checkbox InitCheckbox(name _SettingName, MCM_API_Setting _ParentFacade, string _Label, string _Tooltip, bool initiallyChecked, delegate<BoolSettingHandler> _OnChange)
simulated function MCM_Checkbox InitCheckbox(name _SettingName, MCM_API_Setting _ParentFacade, string _Label, string _Tooltip, bool initiallyChecked, delegate<MCM_API_SettingsGroup.BoolSettingHandler> _OnChange)
{
super.InitSettingsItem(_SettingName, eSettingType_Checkbox, _Label, _Tooltip);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ var MCM_SettingGroup ParentGroup;

var bool Checked;

var delegate<BoolSettingHandler> ChangeHandler;
var delegate<BoolSettingHandler> SaveHandler;
var delegate<MCM_API_SettingsGroup.BoolSettingHandler> ChangeHandler;
var delegate<MCM_API_SettingsGroup.BoolSettingHandler> SaveHandler;

var MCM_Checkbox uiInstance;

delegate BoolSettingHandler(MCM_API_Setting _Setting, bool _SettingValue);

simulated function MCM_CheckboxFacade InitCheckboxFacade(name _Name, string _Label, string _Tooltip, bool _Checked,
delegate<BoolSettingHandler> _OnChange, delegate<BoolSettingHandler> _OnSave,
delegate<MCM_API_SettingsGroup.BoolSettingHandler> _OnChange, delegate<MCM_API_SettingsGroup.BoolSettingHandler> _OnSave,
MCM_SettingGroup _ParentGroup)
{
SettingName = _Name;
Expand All @@ -43,7 +41,6 @@ simulated function UIMechaListItem InstantiateUI(UIList parent)
{
uiInstance = Spawn(class'MCM_Checkbox', parent.itemContainer).InitCheckbox(SettingName, self, Label, Tooltip, Checked, ChangeHandler);
uiInstance.Show();
uiInstance.EnableNavigation();
uiInstance.SetEditable(Editable);

return uiInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ class MCM_CustomPageTest extends Object config(ModConfigMenuTestHarness);

`include(ModConfigMenu/Src/ModConfigMenuAPI/MCM_API_Includes.uci)

delegate CustomSettingsPageCallback(UIScreen ParentScreen, int PageID);

//event OnInit(UIScreen Screen)
function OnInit(UIScreen Screen)
{
Expand Down
108 changes: 24 additions & 84 deletions ModConfigMenu/ModConfigMenu/Src/ModConfigMenu/Classes/MCM_Dropdown.uc
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
class MCM_Dropdown extends MCM_SettingBase implements(MCM_API_Dropdown) config(ModConfigMenu);

var delegate<StringSettingHandler> ChangeHandler;
var delegate<MCM_API_SettingsGroup.StringSettingHandler> ChangeHandler;

var MCM_API_Setting ParentFacade;
var array<string> DropdownOptions;
var int DropdownSelection;
var bool TmpSuppressEvent;

delegate StringSettingHandler(MCM_API_Setting Setting, string _SettingValue);

simulated function MCM_SettingBase InitSettingsItem(name _Name, eSettingType _Type, optional string _Label = "", optional string _Tooltip = "")
{
`log("Don't call InitSettingsItem directly in subclass of MCM_SettingBase.");
Expand All @@ -18,18 +15,20 @@ simulated function MCM_SettingBase InitSettingsItem(name _Name, eSettingType _Ty

// Fancy init process
simulated function MCM_Dropdown InitDropdown(name _SettingName, MCM_API_Setting _ParentFacade, string _Label, string _Tooltip, array<string> _Options, string _Selection,
delegate<StringSettingHandler> _OnChange)
delegate<MCM_API_SettingsGroup.StringSettingHandler> _OnChange)
{
super.InitSettingsItem(_SettingName, eSettingType_Checkbox, _Label, _Tooltip);

ChangeHandler = _OnChange;
ParentFacade = _ParentFacade;

CloneOptionsList(_Options);
DropdownSelection = GetSelectionIndex(_Options, _Selection);
DropdownOptions = _Options;

TmpSuppressEvent = true;
UpdateDataDropdown(_Label, _Options, DropdownSelection, DropdownChangedCallback);
UpdateDataDropdown(_Label, _Options, _Options.find(_Selection), DropdownChangedCallback);
Dropdown.OnMouseEventDelegate = MouseSoundCheck;
// Need to tweak text boundary limits
Desc.SetWidth(width - 340);
TmpSuppressEvent = false;

SetHoverTooltip(_Tooltip);
Expand All @@ -39,100 +38,29 @@ simulated function MCM_Dropdown InitDropdown(name _SettingName, MCM_API_Setting

// Helpers

function CloneOptionsList(array<string> OptionsList)
{
local int iter;
DropdownOptions.Length = 0;
for (iter = 0; iter < OptionsList.Length; iter++)
{
DropdownOptions.AddItem(OptionsList[iter]);
}
}

function int GetSelectionIndex(array<string> OptionsList, string SelectedOption)
{
local int iter;
for (iter = 0; iter < OptionsList.Length; iter++)
{
if (SelectedOption == OptionsList[iter])
return iter;
}

return -1;
}

function DropdownChangedCallback(UIDropdown DropdownControl)
{
DropdownSelection = DropdownControl.SelectedItem;

if (ChangeHandler != none && !TmpSuppressEvent)
{
ChangeHandler(ParentFacade, DropdownControl.GetSelectedItemText());
}
}

// Need to tweak text boundary limits

simulated function UIMechaListItem UpdateDataDropdown(string _Desc,
array<String> Data,
int SelectedIndex,
delegate<OnDropdownSelectionChangedCallback> _OnSelectionChange,
optional delegate<OnClickDelegate> _OnClickDelegate = none)
{
local int i;

SetWidgetType(EUILineItemType_Dropdown);
if(Dropdown != none)
{
Dropdown.Remove();
Dropdown = none;
}

if( Dropdown == none )
{
Dropdown = Spawn(class'UIDropdown', self);
Dropdown.bIsNavigable = false;
Dropdown.InitDropdown('DropdownMC');
Dropdown.SetPosition(width - 308, 24);
}

Dropdown.Clear();

for(i = 0; i < Data.Length; ++i)
{
Dropdown.AddItem(Data[i]);
}

Dropdown.SetLabel("");
Dropdown.SetSelected(SelectedIndex);
Dropdown.Show();

//Desc.SetWidth(width - 308);
Desc.SetWidth(width - 340);
Desc.SetHTMLText(_Desc);
Desc.Show();

OnClickDelegate = _OnClickDelegate;
Dropdown.OnItemSelectedDelegate = _OnSelectionChange;
return self;
}

// MCM_API_Dropdown implementation ===========================================================================

function string GetValue()
{
return DropdownOptions[DropdownSelection];
return Dropdown.GetSelectedItemText();
}

function SetValue(string Selection, bool SuppressEvent)
{
local int index;

index = GetSelectionIndex(DropdownOptions, Selection);
index = DropdownOptions.find(Selection);
// If found.
if (index >= 0)
{
DropdownSelection = index;
TmpSuppressEvent = SuppressEvent;
Dropdown.SetSelected(index);
TmpSuppressEvent = false;
Expand All @@ -141,11 +69,10 @@ function SetValue(string Selection, bool SuppressEvent)

function SetOptions(array<string> NewOptions, string InitialSelection, bool SuppressEvent)
{
CloneOptionsList(NewOptions);
DropdownSelection = GetSelectionIndex(NewOptions, InitialSelection);
DropdownOptions = NewOptions;

TmpSuppressEvent = SuppressEvent;
UpdateDataDropdown(GetLabel(), NewOptions, DropdownSelection, DropdownChangedCallback);
UpdateDataDropdown(GetLabel(), NewOptions, NewOptions.find(InitialSelection), DropdownChangedCallback);
TmpSuppressEvent = false;

SetHoverTooltip(DisplayTooltip);
Expand All @@ -163,4 +90,17 @@ simulated function SetEditable(bool IsEditable)
{
Dropdown.Hide();
}
}

simulated function MouseSoundCheck(UIPanel Panel, int Cmd)
{
if(cmd == class'UIUtilities_Input'.const.FXS_L_MOUSE_UP)
{
Movie.Pres.PlayUISound(eSUISound_MenuSelect);
}
}

simulated function UIPanel ProcessMouseEvents(optional delegate<OnMouseEventDelegate> MouseEventDelegate = MouseSoundCheck)
{
return Super.ProcessMouseEvents(MouseEventDelegate);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ var MCM_SettingGroup ParentGroup;
var array<string> Options;
var int SelectionIndex;

var delegate<StringSettingHandler> ChangeHandler;
var delegate<StringSettingHandler> SaveHandler;
var delegate<MCM_API_SettingsGroup.StringSettingHandler> ChangeHandler;
var delegate<MCM_API_SettingsGroup.StringSettingHandler> SaveHandler;

var MCM_Dropdown uiInstance;

delegate StringSettingHandler(MCM_API_Setting Setting, string _SettingValue);

simulated function MCM_DropdownFacade InitDropdownFacade(name _Name, string _Label, string _Tooltip,
array<string> _Options, string _Selection,
delegate<StringSettingHandler> _OnChange, delegate<StringSettingHandler> _OnSave,
delegate<MCM_API_SettingsGroup.StringSettingHandler> _OnChange, delegate<MCM_API_SettingsGroup.StringSettingHandler> _OnSave,
MCM_SettingGroup _ParentGroup)
{
SettingName = _Name;
Expand Down Expand Up @@ -77,7 +75,6 @@ function UIMechaListItem InstantiateUI(UIList Parent)
{
uiInstance = Spawn(class'MCM_Dropdown', parent.itemContainer).InitDropdown(SettingName, self, Label, Tooltip, Options, Options[SelectionIndex], ChangeHandler);
uiInstance.Show();
uiInstance.EnableNavigation();
uiInstance.SetEditable(Editable);

return uiInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ simulated function MCM_GroupLabelSeparator InstantiateUI(UIList Parent)
// Smaller text too.
Instance.UpdateTitle(GetFormattedLabel());
Instance.Show();
Instance.EnableNavigation();

return Instance;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ defaultproperties
DESC_Y = 0;

bProcessesMouseEvents = true;
bShouldPlayGenericUIAudioEvents = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@ simulated function MCM_Label InitLabel(name _SettingName, MCM_API_Setting _Paren
return self;
}

// No special methods in MCM_API_Label.
// No special methods in MCM_API_Label.

defaultproperties
{
bIsNavigable = false
bShouldPlayGenericUIAudioEvents = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ simulated function UIMechaListItem InstantiateUI(UIList parent)
{
uiInstance = Spawn(class'MCM_Label', parent.itemContainer).InitLabel(SettingName, self, Label, Tooltip);
uiInstance.Show();
uiInstance.EnableNavigation();
uiInstance.SetEditable(Editable);

return uiInstance;
Expand Down
Loading

0 comments on commit d3b3e2a

Please sign in to comment.