Commits

izdubar committed 002ea3d

fix for invalid background when rendering guiMsgBox (deletion warning of VMC items)

Comments (0)

Files changed (5)

 
 /// Dialog display
 int diaExecuteDialog(struct UIItem *ui, int uiId, short inMenu, int (*updater)(void));
+void diaRenderUI(struct UIItem *ui, short inMenu, struct UIItem *cur, int haveFocus);
 int diaShowKeyb(char* text, int maxLen);
 void diaSetEnabled(struct UIItem* ui, int id, int enabled);
 int diaGetInt(struct UIItem* ui, int id, int *value);
 #include "include/iosupport.h"
 #include "include/usbld.h"
 #include "include/texcache.h"
+#include "include/dialogs.h"
 
 typedef enum {
 	// Informs gui that init is over and main gui can be rendered
 
 int guiShowCompatConfig(int id, item_list_t *support);
 int guiShowKeyboard(char* value, int maxLength);
-int guiMsgBox(const char* text, int addAccept);
+int guiMsgBox(const char* text, int addAccept, struct UIItem *ui);
 
 void guiUpdateScrollSpeed(void);
 void guiUpdateScreenScale(void);
 
 /// returns true if the item is controllable (e.g. a value can be changed on it)
 static int diaIsControllable(struct UIItem *ui) {
-	if (ui->type == UI_OK) // TODO strange ...
-		return 1;
-
-	return (ui->enabled && (ui->type > UI_OK));
+	return (ui->enabled && (ui->type >= UI_OK));
 }
 
 /// returns true if the given item should be preceded with nextline
 }
 
 /// renders whole ui screen (for given dialog setup)
-static void diaRenderUI(struct UIItem *ui, short inMenu, struct UIItem *cur, int haveFocus) {
-	rmStartFrame();
-	
+void diaRenderUI(struct UIItem *ui, short inMenu, struct UIItem *cur, int haveFocus) {
 	if (inMenu)
 		gTheme->drawAltBackground();
 	else
 	if ((cur != NULL) && (!haveFocus) && (cur->hintId != -1)) {
 		diaDrawHint(cur->hintId);
 	}
-	
-	// flip display
-	rmEndFrame();
 }
 
 /// sets the ui item value to the default again
 	// okay, we have the first selectable item
 	// we can proceed with rendering etc. etc.
 	while (1) {
+		rmStartFrame();
 		diaRenderUI(ui, inMenu, cur, haveFocus);
+		rmEndFrame();
 		
 		readPads();
 		
 #include "include/lang.h"
 #include "include/themes.h"
 #include "include/pad.h"
-#include "include/dialogs.h"
 #include "include/util.h"
 #include "include/config.h"
 #include "include/system.h"
 	void (*handleInput)(void);
 	void (*renderScreen)(void);
 	void (*renderBackground)(void);
+	short inMenu;
 } gui_screen_handler_t;
 
 // forward decls.
 static gui_screen_handler_t mainScreenHandler = {
 	&guiMainHandleInput,
 	&guiMainRender,
-	&guiMainBackground
+	&guiMainBackground,
+	0
 };
 
 static gui_screen_handler_t menuScreenHandler = {
 	&guiMenuHandleInput,
 	&guiMenuRender,
-	&guiMenuBackground
+	&guiMenuBackground,
+	1
 };
 
 static gui_screen_handler_t *screenHandler = &menuScreenHandler;
 			}
 		}
 		else if (result == VMC_BUTTON_DELETE) {
-			if (guiMsgBox(_l(_STR_DELETE_WARNING), 1)) {
+			if (guiMsgBox(_l(_STR_DELETE_WARNING), 1, diaVMC)) {
 				support->itemCheckVMC(vmc, -1);
 				diaSetString(diaVMC, VMC_NAME, "");
 				break;
 			if (sysGetDiscID(hexDiscID) >= 0)
 				diaSetString(diaCompatConfig, COMPAT_GAMEID, hexDiscID);
 			else
-				guiMsgBox(_l(_STR_ERROR_LOADING_ID), 0);
+				guiMsgBox(_l(_STR_ERROR_LOADING_ID), 0, NULL);
 		}
 #ifdef VMC
 		else if (result == COMPAT_VMC1_DEFINE) {
 		
 		if (gNetworkStartup < 0) {
 			gNetworkStartup = 0;
-			guiMsgBox(_l(_STR_NETWORK_STARTUP_ERROR), 0);
+			guiMsgBox(_l(_STR_NETWORK_STARTUP_ERROR), 0, NULL);
 		}
 		
 		struct gui_update_list_t* td = gUpdateList;
 	fntSetAspectRatio(wideScreenScale, 1.0f);
 }
 
-int guiMsgBox(const char* text, int addAccept) {
+int guiMsgBox(const char* text, int addAccept, struct UIItem *ui) {
 	int terminate = 0;
 	while(!terminate) {
 		guiStartFrame();
 		if(getKeyOn(KEY_CIRCLE)) 
 			terminate = 1;
 		else if(getKeyOn(KEY_CROSS))
-					terminate = 2;
+			terminate = 2;
 		
-		guiShow();
+		if (ui)
+			diaRenderUI(ui, screenHandler->inMenu, NULL, 0);
+		else
+			guiShow();
 		
 		rmDrawRect(0, 0, ALIGN_NONE, DIM_INF, DIM_INF, gColDarker);
 
 			if (id >= 0) {
 				int result = support->itemLaunch(id);
 				if (result == ERROR_FRAGMENTED)
-					guiMsgBox(_l(_STR_ERR_FRAGMENTED), 0);
+					guiMsgBox(_l(_STR_ERR_FRAGMENTED), 0, NULL);
 				else if (result == ERROR_FILE_INVALID)
-					guiMsgBox(_l(_STR_ERR_FILE_INVALID), 0);
+					guiMsgBox(_l(_STR_ERR_FILE_INVALID), 0, NULL);
 				else if (result == ERROR_ETH_INIT)
-					guiMsgBox(_l(_STR_NETWORK_STARTUP_ERROR), 0);
+					guiMsgBox(_l(_STR_NETWORK_STARTUP_ERROR), 0, NULL);
 			}
 		}
 		else { 
 		}
 	}
 	else
-		guiMsgBox("NULL Support object. Please report", 0);
+		guiMsgBox("NULL Support object. Please report", 0, NULL);
 }
 
 static void itemExecTriangle(struct menu_item_t *self, int id) {
 		}
 	}
 	else
-		guiMsgBox("NULL Support object. Please report", 0);
+		guiMsgBox("NULL Support object. Please report", 0, NULL);
 }
 
 static void itemExecSquare(struct menu_item_t *self, int id) {
 
 	if (support) {
 		if (support->itemDelete) {
-			if (guiMsgBox(_l(_STR_DELETE_WARNING), 1)) {
+			if (guiMsgBox(_l(_STR_DELETE_WARNING), 1, NULL)) {
 				support->itemDelete(id);
 				gFrameCounter = UPDATE_FRAME_COUNT;
 			}
 		}
 	}
 	else
-		guiMsgBox("NULL Support object. Please report", 0);
+		guiMsgBox("NULL Support object. Please report", 0, NULL);
 }
 
 static void itemExecCircle(struct menu_item_t *self, int id) {
 		}
 	}
 	else
-		guiMsgBox("NULL Support object. Please report", 0);
+		guiMsgBox("NULL Support object. Please report", 0, NULL);
 }
 
 static void initMenuForListSupport(opl_io_module_t* item, int startMode) {
 	
 	if (showUI) {
 		if (lscret)
-			guiMsgBox(_l(_STR_SETTINGS_SAVED), 0);
+			guiMsgBox(_l(_STR_SETTINGS_SAVED), 0, NULL);
 		else
-			guiMsgBox(_l(_STR_ERROR_SAVING_SETTINGS), 0);
+			guiMsgBox(_l(_STR_ERROR_SAVING_SETTINGS), 0, NULL);
 	}
 	
 	return lscret;