Changeset View
Standalone View
binaries/data/mods/public/gui/common/tab_buttons.js
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/** | /** | ||||
* Show next/previous panel. | * Show next/previous panel. | ||||
* @param direction - +1/-1 for forward/backward. | * @param direction - +1/-1 for forward/backward. | ||||
*/ | */ | ||||
function selectNextTab(direction) | function selectNextTab(direction) | ||||
{ | { | ||||
if (g_TabCategorySelected == undefined) | |||||
elexis: Is the if-statement unavoidable? | |||||
bbAuthorUnsubmitted Not Done Inline Actionsno bb: no | |||||
g_TabCategorySelected = direction > 0 ? -1 : 0; | |||||
Not Done Inline Actionssemicolon by vulcan bb: semicolon by vulcan | |||||
Not Done Inline Actionsthis bugged actually, needs to be move to the onPress function bb: this bugged actually, needs to be move to the onPress function | |||||
selectPanel((g_TabCategorySelected + direction + g_TabCategoryCount) % g_TabCategoryCount); | selectPanel((g_TabCategorySelected + direction + g_TabCategoryCount) % g_TabCategoryCount); | ||||
} | } | ||||
function selectPanel(category) | function selectPanel(category) | ||||
{ | { | ||||
Not Done Inline ActionsI meant the condition actually, i.e. if the special case for undefined is avoidable, i.e. always have a tab selected but having the hidden state in a separate variable. Not sure if it improves this line. elexis: I meant the condition actually, i.e. if the special case for undefined is avoidable, i.e. | |||||
Not Done Inline ActionsCould work if we have the hotkey moving the tab on based on the last selected tab, but don't like that since imo when no tab is selected the hotkeys should move to the lower/upper tab, and with that behaviour we need some check here (could be another variable, but doesn't change the existence of a check) and storing the tab index when it actually doesn't exist seems useless to me, so putted undefined in since that comes more closer to the visual. no strong opinion on if/ternary bb: Could work if we have the hotkey moving the tab on based on the last selected tab, but don't… | |||||
g_TabCategorySelected = category; | g_TabCategorySelected = category; | ||||
Engine.GetGUIObjectByName("tabButtons").children.forEach((button, j) => { | Engine.GetGUIObjectByName("tabButtons").children.forEach((button, j) => { | ||||
button.sprite = category == j ? "ModernTabVerticalForeground" : "ModernTabVerticalBackground"; | button.sprite = category == j ? "ModernTabVerticalForeground" : "ModernTabVerticalBackground"; | ||||
}); | }); | ||||
g_OnSelectTab(category); | g_OnSelectTab(category); | ||||
} | } |
Is the if-statement unavoidable?