frontend options fix

This commit is contained in:
eray orçunus 2020-05-29 20:29:18 +03:00
parent 9acf27fc53
commit 9adde91b3a
2 changed files with 22 additions and 9 deletions

View File

@ -412,6 +412,9 @@ CMenuManager::ThingsToDoBeforeGoingBack()
if (option.returnPrevPageFunc) if (option.returnPrevPageFunc)
option.returnPrevPageFunc(); option.returnPrevPageFunc();
if (option.type == FEOPTION_DYNAMIC)
option.buttonPressFunc(FEOPTION_ACTION_FOCUSLOSS);
if (option.onlyApplyOnEnter) if (option.onlyApplyOnEnter)
option.displayedValue = *option.value; option.displayedValue = *option.value;
} }
@ -1205,8 +1208,7 @@ CMenuManager::Draw()
} else if (option.type == FEOPTION_DYNAMIC) { } else if (option.type == FEOPTION_DYNAMIC) {
if (option.drawFunc) { if (option.drawFunc) {
option.drawFunc(unicodeTemp, &isOptionDisabled); rightText = option.drawFunc(&isOptionDisabled);
rightText = unicodeTemp;
} }
} }
} else } else
@ -1291,14 +1293,15 @@ CMenuManager::Draw()
if (!CFont::Details.centre) if (!CFont::Details.centre)
CFont::SetRightJustifyOn(); CFont::SetRightJustifyOn();
if(!strcmp(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName, "FED_RES") if(textLayer == 1)
&& !m_bGameNotLoaded && textLayer == 1 if(!strcmp(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName, "FED_RES")
&& !m_bGameNotLoaded
#ifdef CUSTOM_FRONTEND_OPTIONS #ifdef CUSTOM_FRONTEND_OPTIONS
|| isOptionDisabled || isOptionDisabled
#endif #endif
) { )
CFont::SetColor(CRGBA(155, 117, 6, FadeIn(255))); CFont::SetColor(CRGBA(155, 117, 6, FadeIn(255)));
}
CFont::PrintString(MENU_X_RIGHT_ALIGNED(columnWidth - textLayer), itemY, rightText); CFont::PrintString(MENU_X_RIGHT_ALIGNED(columnWidth - textLayer), itemY, rightText);
} }
if (i == m_nCurrOption && itemsAreSelectable){ if (i == m_nCurrOption && itemsAreSelectable){
@ -1345,6 +1348,7 @@ CMenuManager::Draw()
FrontendOption &option = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[i].m_TargetMenu]; FrontendOption &option = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[i].m_TargetMenu];
if (option.onlyApplyOnEnter && m_nCurrOption != i) if (option.onlyApplyOnEnter && m_nCurrOption != i)
option.displayedValue = *option.value; option.displayedValue = *option.value;
} }
#endif #endif
@ -4318,6 +4322,7 @@ CMenuManager::ProcessButtonPresses(void)
} }
#endif #endif
int prevOption = m_nCurrOption;
if (goDown && (m_nCurrScreen != MENUPAGE_MULTIPLAYER_FIND_GAME)) { if (goDown && (m_nCurrScreen != MENUPAGE_MULTIPLAYER_FIND_GAME)) {
m_nCurrOption++; m_nCurrOption++;
if (m_nCurrOption == NUM_MENUROWS || (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action == MENUACTION_NOTHING)) { if (m_nCurrOption == NUM_MENUROWS || (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action == MENUACTION_NOTHING)) {
@ -4334,6 +4339,13 @@ CMenuManager::ProcessButtonPresses(void)
m_nCurrOption--; m_nCurrOption--;
} }
} }
#ifdef CUSTOM_FRONTEND_OPTIONS
if (m_nCurrOption != prevOption && aScreens[m_nCurrScreen].m_aEntries[prevOption].m_Action == MENUACTION_TRIGGERFUNC) {
FrontendOption &option = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[prevOption].m_TargetMenu];
if (option.type == FEOPTION_DYNAMIC)
option.buttonPressFunc(FEOPTION_ACTION_FOCUSLOSS);
}
#endif
if (optionSelected) { if (optionSelected) {
int option = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action; int option = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action;

View File

@ -21,6 +21,7 @@
#define FEOPTION_ACTION_LEFT 0 #define FEOPTION_ACTION_LEFT 0
#define FEOPTION_ACTION_RIGHT 1 #define FEOPTION_ACTION_RIGHT 1
#define FEOPTION_ACTION_SELECT 2 #define FEOPTION_ACTION_SELECT 2
#define FEOPTION_ACTION_FOCUSLOSS 3
void RemoveCustomFrontendOptions(); void RemoveCustomFrontendOptions();
void CustomFrontendOptionsPopulate(); void CustomFrontendOptionsPopulate();
@ -32,7 +33,7 @@ typedef void (*ReturnPrevPageFunc)();
typedef void (*ChangeFunc)(int8 displayedValue); // called before updating the value typedef void (*ChangeFunc)(int8 displayedValue); // called before updating the value
// for dynamic options // for dynamic options
typedef void (*DrawFunc)(wchar* out, bool* disabled); // parameters should be set by user, both is allocated. disabled option will be dark yellow typedef wchar* (*DrawFunc)(bool* disabled); // should return pointer to right text. *disabled = true will make it dark yellow
typedef void (*ButtonPressFunc)(int8 action); // see FEOPTION_ACTIONs above typedef void (*ButtonPressFunc)(int8 action); // see FEOPTION_ACTIONs above
struct FrontendOption struct FrontendOption