r377 - trunk
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sat Nov 24 03:04:38 EST 2007
Author: icculus
Date: 2007-11-24 03:04:37 -0500 (Sat, 24 Nov 2007)
New Revision: 377
Modified:
trunk/gui.h
trunk/gui_gtkplus2.c
trunk/gui_macosx.c
trunk/gui_ncurses.c
trunk/gui_stdio.c
trunk/gui_www.c
trunk/lua_glue.c
Log:
Hooked up splash loading code.
Modified: trunk/gui.h
===================================================================
--- trunk/gui.h 2007-11-24 06:18:58 UTC (rev 376)
+++ trunk/gui.h 2007-11-24 08:04:37 UTC (rev 377)
@@ -55,11 +55,31 @@
};
+typedef enum
+{
+ MOJOGUI_SPLASH_NONE,
+ MOJOGUI_SPLASH_TOP,
+ MOJOGUI_SPLASH_LEFT,
+ MOJOGUI_SPLASH_RIGHT,
+ MOJOGUI_SPLASH_BOTTOM,
+ MOJOGUI_SPLASH_BACKGROUND,
+} MojoGuiSplashPos;
+
+typedef struct MojoGuiSplash MojoGuiSplash;
+struct MojoGuiSplash
+{
+ const uint8 *rgba; // framebuffer.
+ uint32 w; // width in pixels.
+ uint32 h; // height in pixels.
+ MojoGuiSplashPos position; // where to put the splash.
+};
+
+
#define MOJOGUI_ENTRY_POINT MojoSetup_Gui_GetInterface
#define MOJOGUI_ENTRY_POINT_STR DEFINE_TO_STR(MOJOGUI_ENTRY_POINT)
// Increment this value when MojoGui's structure changes.
-#define MOJOGUI_INTERFACE_REVISION 2
+#define MOJOGUI_INTERFACE_REVISION 3
typedef struct MojoGui MojoGui;
struct MojoGui
@@ -71,7 +91,7 @@
void (*msgbox)(const char *title, const char *text);
boolean (*promptyn)(const char *title, const char *text, boolean def);
MojoGuiYNAN (*promptynan)(const char *title, const char *text, boolean def);
- boolean (*start)(const char *title, const char *splash);
+ boolean (*start)(const char *title, const MojoGuiSplash *splash);
void (*stop)(void);
int (*readme)(const char *name, const uint8 *data, size_t len,
boolean can_back, boolean can_fwd);
@@ -113,7 +133,8 @@
boolean d); \
static MojoGuiYNAN MojoGui_##module##_promptynan(const char *t1, \
const char *t2, boolean d); \
-static boolean MojoGui_##module##_start(const char *t, const char *s); \
+static boolean MojoGui_##module##_start(const char *t, \
+ const MojoGuiSplash *splash); \
static void MojoGui_##module##_stop(void); \
static int MojoGui_##module##_readme(const char *name, const uint8 *data, \
size_t len, boolean can_back, \
Modified: trunk/gui_gtkplus2.c
===================================================================
--- trunk/gui_gtkplus2.c 2007-11-24 06:18:58 UTC (rev 376)
+++ trunk/gui_gtkplus2.c 2007-11-24 08:04:37 UTC (rev 377)
@@ -459,7 +459,8 @@
} // create_gtkwindow
-static boolean MojoGui_gtkplus2_start(const char *title, const char *splash)
+static boolean MojoGui_gtkplus2_start(const char *title,
+ const MojoGuiSplash *splash)
{
gtkwindow = create_gtkwindow(title);
return (gtkwindow != NULL);
Modified: trunk/gui_macosx.c
===================================================================
--- trunk/gui_macosx.c 2007-11-24 06:18:58 UTC (rev 376)
+++ trunk/gui_macosx.c 2007-11-24 08:04:37 UTC (rev 377)
@@ -146,7 +146,8 @@
} // MojoGui_macosx_promptynan
-static boolean MojoGui_macosx_start(const char *title, const char *splash)
+static boolean MojoGui_macosx_start(const char *title,
+ const MojoGuiSplash *splash)
{
return true; // !!! FIXME
} // MojoGui_macosx_start
Modified: trunk/gui_ncurses.c
===================================================================
--- trunk/gui_ncurses.c 2007-11-24 06:18:58 UTC (rev 376)
+++ trunk/gui_ncurses.c 2007-11-24 08:04:37 UTC (rev 377)
@@ -699,7 +699,8 @@
} // MojoGui_ncurses_promptynan
-static boolean MojoGui_ncurses_start(const char *_title, const char *splash)
+static boolean MojoGui_ncurses_start(const char *_title,
+ const MojoGuiSplash *splash)
{
free(title);
title = entry->xstrdup(_title);
Modified: trunk/gui_stdio.c
===================================================================
--- trunk/gui_stdio.c 2007-11-24 06:18:58 UTC (rev 376)
+++ trunk/gui_stdio.c 2007-11-24 08:04:37 UTC (rev 377)
@@ -192,7 +192,8 @@
} // MojoGui_stdio_promptynan
-static boolean MojoGui_stdio_start(const char *title, const char *splash)
+static boolean MojoGui_stdio_start(const char *title,
+ const MojoGuiSplash *splash)
{
printf("%s\n", title);
return true;
Modified: trunk/gui_www.c
===================================================================
--- trunk/gui_www.c 2007-11-24 06:18:58 UTC (rev 376)
+++ trunk/gui_www.c 2007-11-24 08:04:37 UTC (rev 377)
@@ -793,7 +793,8 @@
} // MojoGui_www_promptynan
-static boolean MojoGui_www_start(const char *title, const char *splash)
+static boolean MojoGui_www_start(const char *title,
+ const MojoGuiSplash *splash)
{
return true;
} // MojoGui_www_start
Modified: trunk/lua_glue.c
===================================================================
--- trunk/lua_glue.c 2007-11-24 06:18:58 UTC (rev 376)
+++ trunk/lua_glue.c 2007-11-24 08:04:37 UTC (rev 377)
@@ -947,11 +947,51 @@
} // luahook_movefile
+static void prepareSplash(MojoGuiSplash *splash, const char *fname)
+{
+ MojoInput *io = NULL;
+ int64 len = 0;
+
+ memset(splash, '\0', sizeof (*splash));
+
+ if (fname == NULL)
+ return;
+
+ io = MojoInput_newFromArchivePath(GBaseArchive, fname);
+ if (io == NULL)
+ return;
+
+ len = io->length(io);
+ if ((len > 0) && (len < 0xFFFFFFFF))
+ {
+ const uint32 size = (uint32) len;
+ uint8 *data = (uint8 *) xmalloc(size);
+ if (io->read(io, data, size) == len)
+ {
+ splash->rgba = decodeImage(data, size, &splash->w, &splash->h);
+ if (splash->rgba != NULL)
+ splash->position = MOJOGUI_SPLASH_TOP; // !!! FIXME: others?
+ } // if
+ free(data);
+ } // if
+
+ io->close(io);
+} // prepareSplash
+
+
static int luahook_gui_start(lua_State *L)
{
const char *title = luaL_checkstring(L, 1);
- const char *splash = lua_tostring(L, 2);
- return retvalBoolean(L, GGui->start(title, splash));
+ const char *splashfname = lua_tostring(L, 2);
+ boolean rc = false;
+ MojoGuiSplash splash;
+
+ prepareSplash(&splash, splashfname);
+ rc = GGui->start(title, &splash);
+ if (splash.rgba != NULL)
+ free((void *) splash.rgba);
+
+ return retvalBoolean(L, rc);
} // luahook_gui_start
More information about the mojosetup-commits
mailing list