PXX2 refactoring + Popups refactoring
This commit is contained in:
@@ -37,7 +37,7 @@ void onModelCustomScriptMenu(const char *result)
|
||||
POPUP_WARNING(STR_NO_SCRIPTS_ON_SD);
|
||||
}
|
||||
}
|
||||
else if (result) {
|
||||
else if (result != STR_EXIT) {
|
||||
// The user choosed a lua file in the list
|
||||
copySelection(sd.file, result, sizeof(sd.file));
|
||||
memset(sd.inputs, 0, sizeof(sd.inputs));
|
||||
|
||||
@@ -73,7 +73,7 @@ void onTelemetryScriptFileSelectionMenu(const char *result)
|
||||
POPUP_WARNING(STR_NO_SCRIPTS_ON_SD);
|
||||
}
|
||||
}
|
||||
else if (result) {
|
||||
else if (result != STR_EXIT) {
|
||||
// The user choosed a file in the list
|
||||
memcpy(g_model.frsky.screens[screenIndex].script.file, result, sizeof(g_model.frsky.screens[screenIndex].script.file));
|
||||
storageDirty(EE_MODEL);
|
||||
|
||||
@@ -56,7 +56,7 @@ void onModelSelectMenu(const char * result)
|
||||
SET_WARNING_INFO(modelHeaders[sub].name, sizeof(g_model.header.name), ZCHAR);
|
||||
}
|
||||
#if defined(SDCARD)
|
||||
else if (result) {
|
||||
else if (result != STR_EXIT) {
|
||||
// The user choosed a file on SD to restore
|
||||
storageCheck(true);
|
||||
POPUP_WARNING(eeRestoreModel(sub, (char *)result));
|
||||
|
||||
@@ -276,7 +276,7 @@ enum MenuModelSetupItems {
|
||||
|
||||
void onPXX2BindMenu(const char * result)
|
||||
{
|
||||
if (result) {
|
||||
if (result != STR_EXIT) {
|
||||
reusableBuffer.moduleSetup.pxx2.bindSelectedReceiverIndex = (result - reusableBuffer.moduleSetup.pxx2.bindCandidateReceiversNames[0]) / sizeof(reusableBuffer.moduleSetup.pxx2.bindCandidateReceiversNames[0]);
|
||||
reusableBuffer.moduleSetup.pxx2.bindStep = BIND_RX_NAME_SELECTED;
|
||||
}
|
||||
|
||||
@@ -57,12 +57,12 @@ void onCustomFunctionsFileSelectionMenu(const char * result)
|
||||
strcpy(directory, SOUNDS_PATH);
|
||||
strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2);
|
||||
}
|
||||
if (!sdListFiles(directory, func==FUNC_PLAY_SCRIPT ? SCRIPTS_EXT : SOUNDS_EXT, sizeof(cfn->play.name), NULL)) {
|
||||
if (!sdListFiles(directory, func==FUNC_PLAY_SCRIPT ? SCRIPTS_EXT : SOUNDS_EXT, sizeof(cfn->play.name), nullptr)) {
|
||||
POPUP_WARNING(func==FUNC_PLAY_SCRIPT ? STR_NO_SCRIPTS_ON_SD : STR_NO_SOUNDS_ON_SD);
|
||||
POPUP_MENU_UNSET_BSS_FLAG();
|
||||
}
|
||||
}
|
||||
else if (result) {
|
||||
else if (result != STR_EXIT) {
|
||||
// The user choosed a file in the list
|
||||
memcpy(cfn->play.name, result, sizeof(cfn->play.name));
|
||||
storageDirty(eeFlags);
|
||||
@@ -96,7 +96,7 @@ void onAdjustGvarSourceLongEnterPress(const char * result)
|
||||
CFN_PARAM(cfn) = 0;
|
||||
storageDirty(EE_MODEL);
|
||||
}
|
||||
else if (result) {
|
||||
else if (result != STR_EXIT) {
|
||||
onSourceLongEnterPress(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ void onModelCustomScriptMenu(const char *result)
|
||||
POPUP_WARNING(STR_NO_SCRIPTS_ON_SD);
|
||||
}
|
||||
}
|
||||
else if (result) {
|
||||
else if (result != STR_EXIT) {
|
||||
// The user choosed a lua file in the list
|
||||
copySelection(sd.file, result, sizeof(sd.file));
|
||||
memset(sd.inputs, 0, sizeof(sd.inputs));
|
||||
|
||||
@@ -72,7 +72,7 @@ void onTelemetryScriptFileSelectionMenu(const char *result)
|
||||
POPUP_WARNING(STR_NO_SCRIPTS_ON_SD);
|
||||
}
|
||||
}
|
||||
else if (result) {
|
||||
else if (result != STR_EXIT) {
|
||||
// The user choosed a file in the list
|
||||
memcpy(g_model.frsky.screens[screenIndex].script.file, result, sizeof(g_model.frsky.screens[screenIndex].script.file));
|
||||
storageDirty(EE_MODEL);
|
||||
|
||||
@@ -55,7 +55,7 @@ void onModelSelectMenu(const char * result)
|
||||
POPUP_CONFIRMATION(STR_DELETEMODEL, nullptr);
|
||||
SET_WARNING_INFO(nametmp, sizeof(g_model.header.name), 0);
|
||||
}
|
||||
else if (result) {
|
||||
else if (result != STR_EXIT) {
|
||||
// The user choosed a file on SD to restore
|
||||
storageCheck(true);
|
||||
POPUP_WARNING(eeRestoreModel(sub, (char *)result));
|
||||
|
||||
@@ -148,7 +148,7 @@ void onModelSetupBitmapMenu(const char * result)
|
||||
POPUP_WARNING(STR_NO_BITMAPS_ON_SD);
|
||||
}
|
||||
}
|
||||
else if (result) {
|
||||
else if (result != STR_EXIT) {
|
||||
// The user choosed a bmp file in the list
|
||||
copySelection(g_model.header.bitmap, result, sizeof(g_model.header.bitmap));
|
||||
memcpy(modelHeaders[g_eeGeneral.currModel].bitmap, g_model.header.bitmap, sizeof(g_model.header.bitmap));
|
||||
|
||||
@@ -56,7 +56,7 @@ void onCustomFunctionsFileSelectionMenu(const char * result)
|
||||
POPUP_WARNING(func==FUNC_PLAY_SCRIPT ? STR_NO_SCRIPTS_ON_SD : STR_NO_SOUNDS_ON_SD);
|
||||
}
|
||||
}
|
||||
else if (result) {
|
||||
else if (result != STR_EXIT) {
|
||||
// The user choosed a file in the list
|
||||
memcpy(cfn->play.name, result, sizeof(cfn->play.name));
|
||||
storageDirty(eeFlags);
|
||||
@@ -129,7 +129,7 @@ void onAdjustGvarSourceLongEnterPress(const char * result)
|
||||
CFN_PARAM(cfn) = 0;
|
||||
storageDirty(EE_MODEL);
|
||||
}
|
||||
else if (result) {
|
||||
else if (result != STR_EXIT) {
|
||||
onSourceLongEnterPress(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ void onModelCustomScriptMenu(const char *result)
|
||||
POPUP_WARNING(STR_NO_SCRIPTS_ON_SD);
|
||||
}
|
||||
}
|
||||
else if (result) {
|
||||
else if (result != STR_EXIT) {
|
||||
// The user choosed a lua file in the list
|
||||
copySelection(sd.file, result, sizeof(sd.file));
|
||||
memset(sd.inputs, 0, sizeof(sd.inputs));
|
||||
|
||||
@@ -151,7 +151,7 @@ void onModelSetupBitmapMenu(const char * result)
|
||||
POPUP_WARNING(STR_NO_BITMAPS_ON_SD);
|
||||
}
|
||||
}
|
||||
else if (result) {
|
||||
else if (result != STR_EXIT) {
|
||||
// The user choosed a bmp file in the list
|
||||
copySelection(g_model.header.bitmap, result, sizeof(g_model.header.bitmap));
|
||||
storageDirty(EE_MODEL);
|
||||
|
||||
@@ -56,7 +56,7 @@ void onCustomFunctionsFileSelectionMenu(const char * result)
|
||||
POPUP_WARNING(func==FUNC_PLAY_SCRIPT ? STR_NO_SCRIPTS_ON_SD : STR_NO_SOUNDS_ON_SD);
|
||||
}
|
||||
}
|
||||
else if (result) {
|
||||
else if (result != STR_EXIT) {
|
||||
// The user choosed a file in the list
|
||||
memcpy(cf->play.name, result, sizeof(cf->play.name));
|
||||
storageDirty(eeFlags);
|
||||
@@ -128,7 +128,7 @@ void onAdjustGvarSourceLongEnterPress(const char * result)
|
||||
CFN_PARAM(cfn) = 0;
|
||||
storageDirty(EE_MODEL);
|
||||
}
|
||||
else if (result) {
|
||||
else if (result != STR_EXIT) {
|
||||
onSourceLongEnterPress(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ void onZoneOptionFileSelectionMenu(const char * result)
|
||||
POPUP_WARNING(STR_NO_BITMAPS_ON_SD);
|
||||
}
|
||||
}
|
||||
else if (result) {
|
||||
else if (result != STR_EXIT) {
|
||||
fileSelectionDone = true;
|
||||
memcpy(fileSelection, result, sizeof(fileSelection));
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ void showMessageBox(const char * title)
|
||||
|
||||
const char * runPopupMenu(event_t event)
|
||||
{
|
||||
const char * result = NULL;
|
||||
const char * result = nullptr;
|
||||
|
||||
uint8_t display_count = min<uint8_t>(popupMenuItemsCount, MENU_MAX_DISPLAY_LINES);
|
||||
uint8_t y = LCD_H / 2 - (popupMenuTitle ? 0 : 3) - (display_count * FH / 2);
|
||||
@@ -149,7 +149,11 @@ const char * runPopupMenu(event_t event)
|
||||
#endif
|
||||
case EVT_KEY_BREAK(KEY_ENTER):
|
||||
result = popupMenuItems[s_menu_item + (popupMenuOffsetType == MENU_OFFSET_INTERNAL ? popupMenuOffset : 0)];
|
||||
// no break
|
||||
popupMenuItemsCount = 0;
|
||||
s_menu_item = 0;
|
||||
popupMenuOffset = 0;
|
||||
popupMenuTitle = nullptr;
|
||||
break;
|
||||
|
||||
#if defined(CASE_EVT_ROTARY_LONG)
|
||||
CASE_EVT_ROTARY_LONG
|
||||
@@ -158,6 +162,7 @@ const char * runPopupMenu(event_t event)
|
||||
#endif
|
||||
|
||||
case EVT_KEY_BREAK(KEY_EXIT):
|
||||
result = STR_EXIT;
|
||||
popupMenuItemsCount = 0;
|
||||
s_menu_item = 0;
|
||||
popupMenuOffset = 0;
|
||||
|
||||
Reference in New Issue
Block a user