Skip to content

Commit 4cc3bed

Browse files
committed
NavHelp mainly
1 parent 1be1aa3 commit 4cc3bed

5 files changed

Lines changed: 222 additions & 28 deletions

File tree

ModConfigMenu/ModConfigMenu/Src/ModConfigMenu/Classes/MCM_OptionsScreen.uc

Lines changed: 179 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,14 @@ var array<MCM_SettingsPanel> SettingsPanels;
3939
var array<MCM_SettingsPanel> ShowQueue;
4040
var UIButton SaveAndExitButton;
4141
var UIButton CancelButton;
42+
var UITextTooltip ActiveTooltip;
43+
var float SBOffset, ScrollHeight;
4244

4345
var int CurrentGameMode;
46+
var UINavigationHelp NavHelp;
47+
var ConsoleOptionAttentionType AttentionType;
48+
var UIMechaListItem MechaListItem;
49+
var int MechaListItemType; //enum EUILineItemType found in UIMechaListItem;
4450

4551
// Pawn hiding code thanks to Patrick-Seymour
4652
var bool SoldierVisible;
@@ -101,6 +107,9 @@ simulated function OnInit()
101107
`log("MCM Core: hiding soldier guy on main menu for visibility.");
102108
HideSoldierIfMainMenu();
103109
}
110+
111+
NavHelp = Spawn(class'UINavigationHelp',self).InitNavHelp();
112+
UpdateNavHelp();
104113
}
105114

106115
simulated function OnRemoved()
@@ -141,7 +150,7 @@ simulated function CreateSkeleton()
141150
// Save and exit button
142151
SaveAndExitButton = Spawn(class'UIButton', Container);
143152
SaveAndExitButton.bAnimateOnInit = false;
144-
SaveAndExitButton.InitButton(, m_strSaveAndExit, OnSaveAndExit, eUIButtonStyle_HOTLINK_BUTTON);
153+
SaveAndExitButton.InitButton(, class'UIOptionsPCScreen'.default.m_strSaveAndExit, OnSaveAndExit, eUIButtonStyle_HOTLINK_BUTTON);
145154
SaveAndExitButton.SetGamepadIcon(class'UIUtilities_Input'.const.ICON_X_SQUARE);
146155
SaveAndExitButton.SetPosition(Container.width - 190, Container.height - 40); //Relative to this screen panel
147156
SaveAndExitButton.DisableNavigation();
@@ -150,7 +159,7 @@ simulated function CreateSkeleton()
150159
{
151160
CancelButton = Spawn(class'UIButton', Container);
152161
SaveAndExitButton.bAnimateOnInit = false;
153-
CancelButton.InitButton(, m_strCancel, OnCancel);
162+
CancelButton.InitButton(, class'UIUtilities_Text'.default.m_strGenericCancel, OnCancel);
154163
CancelButton.SetPosition(Container.width - 190 - 170, Container.height - 40); //Relative to this screen panel
155164
CancelButton.DisableNavigation();
156165
}
@@ -191,6 +200,105 @@ event Tick(float DeltaTime)
191200
Super.Tick(DeltaTime);
192201
}
193202

203+
simulated function UpdateNavHelp( bool bWipeButtons = false )
204+
{
205+
NavHelp.ClearButtonHelp();
206+
NavHelp.bIsVerticalHelp = true; //bsg-hlee (05.05.17): Stacking the B button at the bottom left nav help to match the rest of the main menu screens.
207+
NavHelp.AddBackButton(GoBack);
208+
209+
if (`ISCONTROLLERACTIVE)
210+
{
211+
//determines if focus is on the RIGHT column
212+
if (AttentionType == COAT_DETAILS)
213+
{
214+
switch(MechaListItemType)
215+
{
216+
case EUILineItemType_Slider:
217+
NavHelp.AddLeftHelp(class'UIUtilities_Text'.default.m_strGenericAdjust, class'UIUtilities_Input'.const.ICON_DPAD_HORIZONTAL);
218+
break;
219+
case EUILineItemType_Checkbox:
220+
NavHelp.AddLeftHelp(class'UIUtilities_Text'.default.m_strGenericToggle, class'UIUtilities_Input'.static.GetAdvanceButtonIcon());
221+
break;
222+
case EUILineItemType_Spinner:
223+
NavHelp.AddLeftHelp(class'UIUtilities_Text'.default.m_strGenericSelect, class'UIUtilities_Input'.const.ICON_DPAD_HORIZONTAL);
224+
break;
225+
case EUILineItemType_Dropdown:
226+
case EUILineItemType_Button:
227+
NavHelp.AddSelectNavHelp();
228+
break;
229+
}
230+
// </workshop>
231+
}
232+
else //COAT_CATEGORIES
233+
NavHelp.AddSelectNavHelp();
234+
}
235+
236+
}
237+
238+
simulated function OnSelectionChanged(UIList ContainerList, int ItemIndex)
239+
{
240+
UpdateMechItemNavHelp(ContainerList, ItemIndex); //INS: - JTA 2016/3/18
241+
242+
if(`ISCONTROLLERACTIVE)
243+
{
244+
if (ActiveTooltip != none)
245+
{
246+
if (`PRES.m_eUIMode != eUIMode_Shell)
247+
{
248+
ActiveTooltip.HideTooltip();
249+
}
250+
251+
XComPresentationLayerBase(Owner).m_kTooltipMgr.DeactivateTooltip(ActiveTooltip, true);
252+
ActiveTooltip = none;
253+
}
254+
255+
if (MechaListItem != none)
256+
{
257+
if (MechaListItem.BG.bHasTooltip)
258+
{
259+
ActiveTooltip = UITextTooltip(Movie.Pres.m_kTooltipMgr.GetTooltipByID(MechaListItem.BG.CachedTooltipId));
260+
if (ActiveTooltip != none)
261+
{
262+
ActiveTooltip.SetFollowMouse(false);
263+
ActiveTooltip.SetTooltipPosition(950.0, MechaListItem.Y - SBOffset + 180);
264+
ActiveTooltip.SetDelay(0);
265+
ActiveTooltip.ShowTooltip();
266+
XComPresentationLayerBase(Owner).m_kTooltipMgr.ActivateTooltip(ActiveTooltip);
267+
}
268+
}
269+
}
270+
}
271+
}
272+
273+
function OnScrollPercentChanged( float newPercent )
274+
{
275+
SBOffset = newPercent * ScrollHeight;
276+
if (ActiveTooltip != none)
277+
{
278+
ActiveTooltip.SetTooltipPosition(950.0, MechaListItem.Y - SBOffset + 180);
279+
}
280+
}
281+
282+
//Determines if a change is necessary in the Navhelp
283+
//Mr. Nice: Also stash MechaListItem in properties, useful elsewhere!
284+
simulated function UpdateMechItemNavHelp(UIList ContainerList, int Index)
285+
{
286+
local int NewMechaListItemType; //enum EUILineItemType found in UIMechaListItem;
287+
288+
if(AttentionType == COAT_CATEGORIES) return; // Mr. Nice: Will get "spurious" Update when backing out
289+
//Checks to see if the selected list item is the same as the previously selected list item (to determine if we need to refresh the navhelp)
290+
MechaListItem = UIMechaListItem(ContainerList.GetSelectedItem());
291+
if(MechaListItem != None)
292+
{
293+
NewMechaListItemType = int(MechaListItem.Type);
294+
if(NewMechaListItemType != MechaListItemType)
295+
{
296+
MechaListItemType = NewMechaListItemType;
297+
UpdateNavHelp();
298+
}
299+
}
300+
}
301+
194302
// Special button handlers ========================================================================
195303

196304
simulated function OnSaveAndExit(UIButton kButton)
@@ -217,6 +325,44 @@ simulated function OnCancel(UIButton kButton)
217325
CloseScreen();
218326
}
219327

328+
function GoBack()
329+
{
330+
local UIList List;
331+
332+
switch(AttentionType)
333+
{
334+
case COAT_CATEGORIES:
335+
OnCancel(none);
336+
break;
337+
338+
case COAT_DETAILS:
339+
if(MechaListItemType == EUILineItemType_Dropdown && MechaListItem.Dropdown.isOpen)
340+
{
341+
MechaListItem.Dropdown.BackOut();
342+
}
343+
else
344+
{
345+
AttentionType = COAT_CATEGORIES;
346+
TabsList.SetSelectedNavigation();
347+
MechaListItem.OnLoseFocus();
348+
List = UIList(MechaListItem.GetParent(class'UIList'));
349+
List.SetSelectedIndex(0);
350+
if (List.Scrollbar !=none)
351+
{
352+
List.Scrollbar.SetThumbAtPercent(0);
353+
}
354+
if (ActiveTooltip != none)
355+
{
356+
Movie.Pres.m_kTooltipMgr.DeactivateTooltip(ActiveTooltip, true);
357+
ActiveTooltip = none;
358+
}
359+
UpdateNavHelp();
360+
}
361+
Movie.Pres.PlayUISound(eSUISound_MenuClose); //bsg-crobinson (5.9.17): Add close menu sound on back
362+
break;
363+
}
364+
}
365+
220366
simulated function CloseScreen()
221367
{
222368
Super.CloseScreen();
@@ -233,19 +379,28 @@ simulated function bool OnUnrealCommand(int cmd, int arg)
233379

234380
switch( cmd )
235381
{
382+
case class'UIUtilities_Input'.const.FXS_R_MOUSE_DOWN:
383+
OnCancel(none);
384+
return true;
385+
236386
case class'UIUtilities_Input'.const.FXS_BUTTON_B:
237387
case class'UIUtilities_Input'.const.FXS_KEY_ESCAPE:
238-
case class'UIUtilities_Input'.const.FXS_R_MOUSE_DOWN:
239-
if(TabsList.bIsFocused)
240-
{
241-
OnCancel(none);
242-
}
243-
else
388+
GoBack();
389+
return true;
390+
391+
case class'UIUtilities_Input'.const.FXS_ARROW_DOWN:
392+
case class'UIUtilities_Input'.const.FXS_DPAD_DOWN:
393+
case class'UIUtilities_Input'.const.FXS_VIRTUAL_LSTICK_DOWN:
394+
case class'UIUtilities_Input'.const.FXS_ARROW_UP:
395+
case class'UIUtilities_Input'.const.FXS_DPAD_UP:
396+
case class'UIUtilities_Input'.const.FXS_VIRTUAL_LSTICK_UP:
397+
if(MechaListItemType == EUILineItemType_Dropdown && MechaListItem.Dropdown.isOpen)
244398
{
245-
Movie.Pres.PlayUISound(eSUISound_MenuClose);
246-
TabsList.SetSelectedNavigation();
399+
// Mr. Nice: Let the dropdown handle it, will get consumed by the UIList otherwise
400+
return MechaListItem.OnUnrealCommand(cmd, arg);
247401
}
248-
return true;
402+
break;
403+
249404
case class'UIUtilities_Input'.const.FXS_BUTTON_X:
250405
OnSaveAndExit(none);
251406
return true;
@@ -364,10 +519,8 @@ simulated function ChoosePanelByPageID(int PageID)
364519
else
365520
{
366521
`log("MCM: Found correct panel, showing.");
367-
Movie.Pres.PlayUISound(eSUISound_MenuSelect);
368-
TmpPage.SetSelectedNavigation();
369522
TmpPage.Show();
370-
TabsList.OnLoseFocus();
523+
SelectSettingsPanel(TmpPage);
371524
}
372525
}
373526

@@ -392,14 +545,21 @@ simulated function ChoosePanelByPageID(int PageID)
392545
if (TmpPage.GetPageID() == SelectedPageID)
393546
{
394547
`log("MCM: Found correct panel, navigating.");
395-
Movie.Pres.PlayUISound(eSUISound_MenuSelect);
396-
TmpPage.SetSelectedNavigation();
397-
TabsList.OnLoseFocus();
548+
SelectSettingsPanel(TmpPage);
398549
}
399550
}
400551
}
401552
}
402553

554+
simulated function SelectSettingsPanel(MCM_SettingsPanel Tab)
555+
{
556+
Movie.Pres.PlayUISound(eSUISound_MenuSelect);
557+
AttentionType = COAT_DETAILS;
558+
Tab.SetSelectedNavigation();
559+
UpdateMechItemNavHelp(Tab.SettingsList, 0);
560+
ScrollHeight = Tab.SettingsList.TotalItemSize - Tab.SettingsList.Height - 55;
561+
}
562+
403563
simulated function TabClickedHandler(MCM_SettingsTab Caller, int PageID)
404564
{
405565
`log("MCM Tab clicked: " $ string(PageID));
@@ -424,10 +584,11 @@ function MCM_API_SettingsPage MakeSettingsPage(string TabLabel, int PageID)
424584
{
425585
local MCM_SettingsPanel SP;
426586
SP = Spawn(class'MCM_SettingsPanel', Container);
587+
SP.OptionsScreen = self;
427588
SP.InitPanel();
428589
SP.SettingsPageID = PageID;
429590
SP.SetPosition(TABLIST_WIDTH + OPTIONS_MARGIN, HEADER_HEIGHT);
430-
591+
431592
SP.SetPageTitle(TabLabel);
432593

433594
// By default do not show the panel.

ModConfigMenu/ModConfigMenu/Src/ModConfigMenu/Classes/MCM_SettingBase.uc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,17 @@ simulated function string GetHoverTooltip()
7777
// For example, if you don't want to allow tweaking during a mission.
7878
simulated function SetEditable(bool IsEditable)
7979
{
80-
SetDisabled(!IsEditable);
80+
// Mr. Nice: SetDisabled kills the tooltip unless you pass it again!
81+
SetDisabled(!IsEditable, DisplayTooltip);
82+
if(IsEditable)
83+
{
84+
EnableNavigation();
85+
MCM_SettingsPanel(GetParent(class'MCM_SettingsPanel')).NavSort();
86+
}
87+
else
88+
{
89+
DisableNavigation();
90+
}
8191
}
8292
8393
// Retrieves underlying setting type. Defined as an int to make setting types more extensible to support

ModConfigMenu/ModConfigMenu/Src/ModConfigMenu/Classes/MCM_SettingGroup.uc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function TriggerSaveEvents()
4040

4141
function AddSetting(MCM_SettingFacade Instance)
4242
{
43-
if (UiInstantiated)
43+
if (ParentPanel.ShowCalled || UiInstantiated)
4444
{
4545
`log("MCM: Error: Cannot add more settings after ShowSettings() has been called.");
4646
}

ModConfigMenu/ModConfigMenu/Src/ModConfigMenu/Classes/MCM_SettingsPanel.uc

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ var localized string m_strApplyButton;
1414
var int SettingsPageID;
1515

1616
var UIList SettingsList;
17-
17+
var MCM_OptionsScreen OptionsScreen;
18+
var bool NavSortEnabled; // Mr. Nice: When controls are made editable *after* the page has instantiated,
19+
// then the Navigation Order must be sorted to match the list (ie visual) order.
20+
var bool ShowCalled;
21+
1822
var MCM_UISettingSeparator TitleLine;
1923
var UIButton ResetButton;
2024
var string Title;
@@ -40,7 +44,8 @@ simulated function UIPanel InitPanel(optional name InitName, optional name InitL
4044
// Necessary to make sure dropdowns don't run past the bottom.
4145
//SettingsList.ScrollbarPadding = 500;
4246
SettingsList.SetSelectedNavigation();
43-
SettingsList.Navigator.LoopSelection = true;
47+
SettingsList.OnSelectionChanged = OptionsScreen.OnSelectionChanged;
48+
//SettingsList.Navigator.LoopSelection = true;
4449

4550
// Delay spawning of title line to make sure topmost "line" is also last layer.
4651
// See ShowSettings();
@@ -55,7 +60,7 @@ simulated function UIPanel InitPanel(optional name InitName, optional name InitL
5560
//SettingItemStartY = TitleLine.Height;
5661

5762
ResetButton = Spawn(class'UIButton', self);
58-
ResetButton.InitButton(, m_strResetButton, OnResetClicked, eUIButtonStyle_HOTLINK_BUTTON);
63+
ResetButton.InitButton(, Caps(class'UIPhotoboothBase'.default.m_CategoryReset), OnResetClicked, eUIButtonStyle_HOTLINK_BUTTON);
5964
ResetButton.SetPosition(RESET_BUTTON_X, PANEL_HEIGHT - FOOTER_HEIGHT + 3); //Relative to this screen panel
6065
ResetButton.SetGamepadIcon(class'UIUtilities_Input'.const.ICON_BACK_SELECT);
6166
ResetButton.Hide();
@@ -102,8 +107,7 @@ simulated function bool OnUnrealCommand(int cmd, int arg)
102107
OnResetClicked(none);
103108
return true;
104109
}
105-
106-
return super.OnUnrealCommand(cmd, arg);
110+
return false;
107111
}
108112

109113
// Helpers for MCM_OptionsScreen ================================================================
@@ -215,7 +219,8 @@ function OnSettingsLineInitialized(UIPanel NextItem)
215219
// Does this matter? Can do some flagging so the SettingGroups don't accept more controls immediately if it does....
216220
function ShowSettings()
217221
{
218-
MCM_OptionsScreen(ParentPanel.ParentPanel).ShowQueue.AddItem(self);
222+
ShowCalled = true;
223+
MCM_OptionsScreen(GetParent(class'MCM_OptionsScreen')).ShowQueue.AddItem(self);
219224
}
220225

221226
function RealShowSettings()
@@ -226,7 +231,7 @@ function RealShowSettings()
226231

227232
// Adds padding at bottom to make sure that bottom options are visisble.
228233
bottomPadding = Spawn(class'UIImage', SettingsList.itemContainer);
229-
bottomPadding.bProcessesMouseEvents = true;
234+
//bottomPadding.bProcessesMouseEvents = true;
230235
bottomPadding.InitImage('MCMBottomPadding',"img:///MCM.gfx.Transparent");
231236
bottomPadding.SetWidth(548);
232237
bottomPadding.SetHeight(150);
@@ -243,6 +248,24 @@ function RealShowSettings()
243248
TitleLine.SetY(0);
244249
TitleLine.Show();
245250
SettingsList.MoveItemToTop(TitleLine);
251+
if (SettingsList.Scrollbar != none)
252+
{
253+
SettingsList.Scrollbar.NotifyPercentChange(OptionsScreen.OnScrollPercentChanged);
254+
}
255+
NavSortEnabled = true;
256+
}
257+
258+
function NavSort()
259+
{
260+
if(NavSortEnabled)
261+
{
262+
SettingsList.Navigator.NavigableControls.Sort(ListIndexOrder);
263+
}
264+
}
265+
266+
function int ListIndexOrder(UIPanel FirstItem, UIPanel SecondItem)
267+
{
268+
return SettingsList.GetItemIndex(SecondItem) - SettingsList.GetItemIndex(FirstItem);
246269
}
247270

248271
defaultproperties

0 commit comments

Comments
 (0)