Commits

crazyc  committed 195700e Merge

prepare for fork merge

  • Participants
  • Parent commits 10b2808, 2d88926

Comments (0)

Files changed (10)

File Makefile

File contents unchanged.

File include/dia.h

 };
 
 /// Dialog display
-int diaExecuteDialog(struct UIItem *ui, short inMenu, int (*updater)(void));
+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);

File include/dialogs.h

 
 #define COMPAT_MODE_COUNT		8
 
-#define COMPAT_GAME				100
-#define COMPAT_MODE_BASE		101
+#define COMPAT_MODE_BASE		200
+#define COMPAT_GAME				101
 #define COMPAT_GAMEID			102
 #define COMPAT_SAVE				103
 #define COMPAT_TEST				104

File include/gui.h

 #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
 	padRestoreSettings(diaPadSettings);
 }
 
-int diaExecuteDialog(struct UIItem *ui, short inMenu, int (*updater)(void)) {
+static struct UIItem* diaFindByID(struct UIItem* ui, int id) {
+	while (ui->type != UI_TERMINATOR) {
+		if (ui->id == id)
+			return ui;
+
+		ui++;
+	}
+
+	return NULL;
+}
+
+int diaExecuteDialog(struct UIItem *ui, int uiId, short inMenu, int (*updater)(void)) {
 	rmGetScreenExtents(&screenWidth, &screenHeight);
 	
-	struct UIItem *cur = diaGetFirstControl(ui);
+	struct UIItem *cur = NULL;
+	if (uiId != -1)
+		cur = diaFindByID(ui, uiId);
+
+	if (!cur)
+		cur = diaGetFirstControl(ui);
 	
 	// what? no controllable item? Exit!
 	if (cur == ui)
 	// okay, we have the first selectable item
 	// we can proceed with rendering etc. etc.
 	while (1) {
+		rmStartFrame();
 		diaRenderUI(ui, inMenu, cur, haveFocus);
+		rmEndFrame();
 		
 		readPads();
 		
 	}
 }
 
-static struct UIItem* diaFindByID(struct UIItem* ui, int id) {
-	while (ui->type != UI_TERMINATOR) {
-		if (ui->id == id)
-			return ui;
-			
-		ui++;
-	}
-	
-	return NULL;
-}
-
 void diaSetEnabled(struct UIItem* ui, int id, int enabled) {
 	struct UIItem *item = diaFindByID(ui, id);
 

File src/fntsys.c

 	
 	gCharHeight = 16;
 	
-	// TODO: error = FT_Set_Char_Size(face, 0, gCharHeight*64, 300, 300);
-	error = FT_Set_Pixel_Sizes( face, 
-				    0, // pixel_width 
-				    gCharHeight ); // pixel_height
-	
+	error = FT_Set_Char_Size(face, 0, gCharHeight * 16, 300, 300);
+	/*error = FT_Set_Pixel_Sizes( face,
+		0, // pixel_width
+		gCharHeight ); // pixel_height*/
+
 	if ( error ) { 
 		// just report over the ps2link
 		LOG("Freetype: Error setting font pixel size with %x!\n", error);
 		// SleepThread();
-	} 
+	}
 }
 
 /** Terminates the font rendering system */
 #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;
 	diaSetInt(diaConfig, CFG_ETHMODE, gETHStartMode);
 	diaSetInt(diaConfig, CFG_APPMODE, gAPPStartMode);
 
-	int ret = diaExecuteDialog(diaConfig, 1, NULL);
+	int ret = diaExecuteDialog(diaConfig, -1, 1, NULL);
 	if (ret) {
 		diaGetInt(diaConfig, CFG_EXITTO, &gExitMode);
 		diaGetInt(diaConfig, CFG_DEBUG, &gDisableDebug);
 	diaSetInt(diaUIConfig, UICFG_COVERART, gEnableArt);
 	diaSetInt(diaUIConfig, UICFG_WIDESCREEN, gWideScreen);
 
-	int ret = diaExecuteDialog(diaUIConfig, 1, NULL);
+	int ret = diaExecuteDialog(diaUIConfig, -1, 1, NULL);
 	if (ret) {
 		int themeID = -1, langID = -1;
 		diaGetInt(diaUIConfig, UICFG_SCROLL, &gScrollSpeed);
 	diaSetString(diaIPConfig, 21, gPCPassword);
 
 	// show dialog
-	if (diaExecuteDialog(diaIPConfig, 1, NULL)) {
+	if (diaExecuteDialog(diaIPConfig, -1, 1, NULL)) {
 		// Ok pressed, store values
 		for (i = 0; i < 4; ++i) {
 			diaGetInt(diaIPConfig, 2 + i, &ps2_ip[i]);
 			}
 		}
 		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;
 			size = guiRefreshVMCConfig(support, vmc);
 		}
 
-		result = diaExecuteDialog(diaVMC, 0, &guiVMCUpdater);
+		result = diaExecuteDialog(diaVMC, result, 0, &guiVMCUpdater);
 
 		if ((result == 0) && (vmc_operation == OPERATION_CREATE))
 			break;
 
 	diaSetLabel(diaCompatConfig, COMPAT_GAME, support->itemGetName(id));
 
-	int i, result;
+	int i, result = -1;
 	for (i = 0; i < COMPAT_MODE_COUNT; ++i)
 		diaSetInt(diaCompatConfig, COMPAT_MODE_BASE + i, (compatMode & (1 << i)) > 0 ? 1 : 0);
 
 			diaSetLabel(diaCompatConfig, COMPAT_VMC2_ACTION, _l(_STR_USE_GENERIC));
 #endif
 
-		result = diaExecuteDialog(diaCompatConfig, 0, NULL);
+		result = diaExecuteDialog(diaCompatConfig, result, 0, NULL);
 
 		if (result == COMPAT_LOADFROMDISC) {
 			char hexDiscID[15];
 			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;

File src/supportbase.c

 	fio_dirent_t record;
 
 	if ((fd = fioDopen(path)) > 0) {
-		while (fioDread(fd, &record) > 0)
+		while (fioDread(fd, &record) > 0) {
 			if ((size = isValidIsoName(record.name)) > 0) {
 				struct game_list_t *next = (struct game_list_t*)malloc(sizeof(struct game_list_t));
 				
 
 				count++;
 			}
+		}
 		fioDclose(fd);
 	}
 
 	if (fd >= 0) {
 		unsigned int realSize = getFileSize(fd);
 
-		if (*size > 0 && *size != realSize) {
+		if ((*size > 0) && (*size != realSize)) {
 			LOG("Invalid filesize, expected: %d, got: %d\n", *size, realSize);
 			fioClose(fd);
 			return NULL;
 		else
 			buffer = malloc(realSize);
 
-                if (!buffer) {
-                	LOG("readFile: Failed allocation of %d bytes", realSize);
-                	*size = 0;
-                } else {
-		        fioRead(fd, buffer, realSize);
+		if (!buffer) {
+			LOG("readFile: Failed allocation of %d bytes", realSize);
+			*size = 0;
+		} else {
+			fioRead(fd, buffer, realSize);
 			fioClose(fd);
 			*size = realSize;
 		}