[Horus] Model Select bugfixes

This commit is contained in:
Bertrand Songis
2016-06-07 20:35:17 +02:00
parent 06bef98a05
commit e3d22300ed
+21 -3
View File
@@ -125,6 +125,12 @@ void onModelSelectMenu(const char * result)
} }
else if (result == STR_CHANGE_CATEGORY) { else if (result == STR_CHANGE_CATEGORY) {
}
else if (result == STR_CREATE_MODEL) {
storageCheck(true);
currentModel = modelslist.currentModel = modelslist.addModel(currentCategory, createModel());
selectMode = MODE_SELECT_MODEL;
setCurrentModel(currentCategory->size() - 1);
} }
else if (result == STR_DUPLICATE_MODEL) { else if (result == STR_DUPLICATE_MODEL) {
char duplicatedFilename[LEN_MODEL_FILENAME+1]; char duplicatedFilename[LEN_MODEL_FILENAME+1];
@@ -146,22 +152,32 @@ void initModelsList()
modelslist.load(); modelslist.load();
categoriesVerticalOffset = 0; categoriesVerticalOffset = 0;
bool found = false;
int index = 0; int index = 0;
for (std::list<ModelsCategory *>::iterator it = modelslist.categories.begin(); it != modelslist.categories.end(); ++it, ++index) { for (std::list<ModelsCategory *>::iterator it = modelslist.categories.begin(); it != modelslist.categories.end(); ++it, ++index) {
if (*it == modelslist.currentCategory) { if (*it == modelslist.currentCategory) {
setCurrentCategory(index); setCurrentCategory(index);
found = true;
break; break;
} }
} }
if (!found) {
setCurrentCategory(0);
}
modelsVerticalOffset = 0; modelsVerticalOffset = 0;
found = false;
index = 0; index = 0;
for (ModelsCategory::iterator it = currentCategory->begin(); it != currentCategory->end(); ++it, ++index) { for (ModelsCategory::iterator it = currentCategory->begin(); it != currentCategory->end(); ++it, ++index) {
if (*it == modelslist.currentModel) { if (*it == modelslist.currentModel) {
setCurrentModel(index); setCurrentModel(index);
found = true;
break; break;
} }
} }
if (!found) {
setCurrentModel(0);
}
} }
bool menuModelSelect(evt_t event) bool menuModelSelect(evt_t event)
@@ -174,8 +190,8 @@ bool menuModelSelect(evt_t event)
event = EVT_REFRESH; event = EVT_REFRESH;
if (modelIndex > 0) { if (modelIndex > 0) {
modelIndex--; modelIndex--;
setCurrentModel(modelIndex);
} }
setCurrentModel(modelIndex);
} }
switch(event) { switch(event) {
@@ -232,13 +248,15 @@ bool menuModelSelect(evt_t event)
if (currentModel != modelslist.currentModel) { if (currentModel != modelslist.currentModel) {
POPUP_MENU_ADD_ITEM(STR_SELECT_MODEL); POPUP_MENU_ADD_ITEM(STR_SELECT_MODEL);
} }
POPUP_MENU_ADD_ITEM(STR_CREATE_MODEL);
POPUP_MENU_ADD_ITEM(STR_DUPLICATE_MODEL); POPUP_MENU_ADD_ITEM(STR_DUPLICATE_MODEL);
} }
// POPUP_MENU_ADD_SD_ITEM(STR_BACKUP_MODEL); // POPUP_MENU_ADD_SD_ITEM(STR_BACKUP_MODEL);
// POPUP_MENU_ADD_ITEM(STR_MOVE_MODEL); // POPUP_MENU_ADD_ITEM(STR_MOVE_MODEL);
POPUP_MENU_ADD_ITEM(STR_CHANGE_CATEGORY); POPUP_MENU_ADD_ITEM(STR_CHANGE_CATEGORY);
POPUP_MENU_ADD_ITEM(STR_DELETE_MODEL); if (currentModel != modelslist.currentModel) {
// POPUP_MENU_ADD_ITEM(STR_CREATE_MODEL); POPUP_MENU_ADD_ITEM(STR_DELETE_MODEL);
}
// POPUP_MENU_ADD_ITEM(STR_RESTORE_MODEL); // POPUP_MENU_ADD_ITEM(STR_RESTORE_MODEL);
POPUP_MENU_START(onModelSelectMenu); POPUP_MENU_START(onModelSelectMenu);
} }