Skip to content

Commit

Permalink
A bunch of cleanup and work from when I didn't have net access...
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Dec 20, 2006
1 parent ba5ee75 commit de9795c
Show file tree
Hide file tree
Showing 12 changed files with 527 additions and 198 deletions.
48 changes: 31 additions & 17 deletions CMakeLists.txt
Expand Up @@ -71,16 +71,6 @@ IF(CMAKE_COMPILER_IS_GNUCC)
ENDIF(MOJOSETUP_IS_GCC4)
ENDIF(CMAKE_COMPILER_IS_GNUCC)

SET(MOJOSETUP_SRCS
buildver.c
mojosetup.c
misc.c
gui.c
fileio.c
archive_zip.c
lua_glue.c
)

SET(ZLIB_SRCS
zlib123/adler32.c
zlib123/compress.c
Expand Down Expand Up @@ -125,6 +115,30 @@ SET(LUA_SRCS
lua-5.1.1/src/linit.c
)

SET(LUA_PARSER_SRCS
lua-5.1.1/src/lparser.c
lua-5.1.1/src/llex.c
lua-5.1.1/src/lcode.c
)

SET(MOJOSETUP_SRCS
buildver.c
mojosetup.c
misc.c
gui.c
fileio.c
archive_zip.c
lua_glue.c
${LUA_SRCS}
)

SET(MOJOLUAC_SRCS
${LUA_SRCS}
${LUA_PARSER_SRCS}
lua-5.1.1/src/luac.c
lua-5.1.1/src/print.c
)

# Disabling the parser cuts the Lua binary bits by about 35% (about 30 kbytes
# uncompressed on amd64 Linux), plus .luac files are almost always smaller
# than the original scripts. The downside is you (and end users in the field)
Expand All @@ -134,13 +148,9 @@ SET(LUA_SRCS
# must save every single byte in the download.
OPTION(MOJOSETUP_LUA_PARSER "Bigger binary but scripts don't need to be compiled." TRUE)
IF(MOJOSETUP_LUA_PARSER)
SET(LUA_SRCS ${LUA_SRCS}
lua-5.1.1/src/lparser.c
lua-5.1.1/src/llex.c
lua-5.1.1/src/lcode.c
)
SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} ${LUA_PARSER_SRCS})
ELSE(MOJOSETUP_LUA_PARSER)
SET(LUA_SRCS ${LUA_SRCS} lua-5.1.1/etc/noparser.c)
SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} lua-5.1.1/etc/noparser.c)
ADD_DEFINITIONS(-DDISABLE_LUA_PARSER=1)
ENDIF(MOJOSETUP_LUA_PARSER)

Expand Down Expand Up @@ -243,8 +253,12 @@ IF(UNIX AND NOT MACOSX)
ENDIF(HAVE_LIBM)
ENDIF(UNIX AND NOT MACOSX)

OPTION(MOJOSETUP_BUILD_LUAC "Build separate Lua compiler" TRUE)
IF(MOJOSETUP_BUILD_LUAC)
ADD_EXECUTABLE(mojoluac ${MOJOLUAC_SRCS})
ENDIF(MOJOSETUP_BUILD_LUAC)

ADD_EXECUTABLE(mojosetup ${MOJOSETUP_SRCS} ${LUA_SRCS} ${OPTIONAL_SRCS})
ADD_EXECUTABLE(mojosetup ${MOJOSETUP_SRCS} ${OPTIONAL_SRCS})
TARGET_LINK_LIBRARIES(mojosetup ${OPTIONAL_LIBS})

# end of CMakeLists.txt ...
Expand Down
2 changes: 1 addition & 1 deletion fileio.c
Expand Up @@ -108,7 +108,7 @@ MojoInput *MojoInput_newFromArchivePath(MojoArchive *ar, const char *fname)
char *fullpath = xstrdup(fname);
char *file = strrchr(fullpath, '/');
char *path = fullpath;
if (path != NULL)
if (file != NULL)
*(file++) = '\0';
else
{
Expand Down
18 changes: 12 additions & 6 deletions gui.h
Expand Up @@ -37,8 +37,10 @@ struct MojoGui
void (*deinit)(void);
void (*msgbox)(const char *title, const char *text);
boolean (*promptyn)(const char *title, const char *text);
boolean (*startgui)(const char *title, const char *splash);
void (*endgui)(void);
boolean (*start)(const char *title, const char *splash);
void (*stop)(void);
boolean (*readme)(const char *name, const uint8 *data, size_t len,
boolean can_go_back, boolean can_go_forward);
};

typedef const MojoGui* (*MojoGuiEntryPoint)(int revision,
Expand Down Expand Up @@ -66,8 +68,11 @@ static boolean MojoGui_##module##_init(void); \
static void MojoGui_##module##_deinit(void); \
static void MojoGui_##module##_msgbox(const char *title, const char *text); \
static boolean MojoGui_##module##_promptyn(const char *t1, const char *t2); \
static boolean MojoGui_##module##_startgui(const char *t, const char *s); \
static void MojoGui_##module##_endgui(void); \
static boolean MojoGui_##module##_start(const char *t, const char *s); \
static void MojoGui_##module##_stop(void); \
static boolean MojoGui_##module##_readme(const char *name, const uint8 *data, \
size_t len, boolean can_go_back, \
boolean can_go_forward); \
const MojoGui *MojoGuiPlugin_##module(int rev, const MojoSetupEntryPoints *e) \
{ \
if (rev == MOJOGUI_INTERFACE_REVISION) { \
Expand All @@ -78,8 +83,9 @@ const MojoGui *MojoGuiPlugin_##module(int rev, const MojoSetupEntryPoints *e) \
MojoGui_##module##_deinit, \
MojoGui_##module##_msgbox, \
MojoGui_##module##_promptyn, \
MojoGui_##module##_startgui, \
MojoGui_##module##_endgui, \
MojoGui_##module##_start, \
MojoGui_##module##_stop, \
MojoGui_##module##_readme, \
}; \
entry = e; \
return &retval; \
Expand Down
18 changes: 14 additions & 4 deletions gui/gui_macosx.c
Expand Up @@ -121,16 +121,26 @@ static boolean MojoGui_macosx_promptyn(const char *title, const char *text)
return do_promptyn(title, text, true);
}

static boolean MojoGui_macosx_startgui(const char *title, const char *splash)

static boolean MojoGui_macosx_start(const char *title, const char *splash)
{
return false; // !!! FIXME
} // MojoGui_macosx_startgui
} // MojoGui_macosx_start


static void MojoGui_macosx_endgui(void)
static void MojoGui_macosx_stop(void)
{
// no-op.
} // MojoGui_macosx_endgui
} // MojoGui_macosx_stop


static boolean MojoGui_macosx_readme(const char *name, const uint8 *data,
size_t len, boolean can_go_back,
boolean can_go_forward)
{
STUBBED("macosx readme");
return true;
} // MojoGui_macosx_readme

// end of gui_macosx.c ...

58 changes: 39 additions & 19 deletions gui/gui_stdio.c
Expand Up @@ -32,41 +32,61 @@ static void MojoGui_stdio_msgbox(const char *title, const char *text)
{
printf(entry->_("NOTICE: %s\n[hit enter]"), text);
fflush(stdout);
if (!feof(stdin))
getchar();
}
getchar();
} // MojoGui_stdio_msgbox

static boolean MojoGui_stdio_promptyn(const char *title, const char *text)
{
if (feof(stdin))
return 0;

while (1)
else
{
int c;
printf(entry->_("%s\n[y/n]"), text);
fflush(stdout);
c = toupper(getchar());
if (c == 'N') // !!! FIXME: localize?
return 0;
else if (c == 'Y')
return 1;
} // while
const char *localized_no = entry->_("N");
const char *localized_yes = entry->_("Y");
char buf[128];
size_t len = 0;
while (1)
{
printf(entry->_("%s\n[y/n]: "), text);
fflush(stdout);

if (fgets(buf, sizeof (buf), stdin) == NULL)
return 0;

len = strlen(buf) - 1;
while ( (len >= 0) && ((buf[len] == '\n') || (buf[len] == '\r')) )
buf[len--] = '\0';

if (strcasecmp(buf, localized_no) == 0)
return 0;
else if (strcasecmp(buf, localized_yes) == 0)
return 1;
} // while
} // else

return 0;
}
} // MojoGui_stdio_promptyn

static boolean MojoGui_stdio_startgui(const char *title, const char *splash)
static boolean MojoGui_stdio_start(const char *title, const char *splash)
{
printf("%s\n", title);
return true;
} // MojoGui_stdio_startgui
} // MojoGui_stdio_start


static void MojoGui_stdio_endgui(void)
static void MojoGui_stdio_stop(void)
{
// no-op.
} // MojoGui_stdio_endgui
} // MojoGui_stdio_stop


static boolean MojoGui_stdio_readme(const char *name, const uint8 *data,
size_t len, boolean can_go_back,
boolean can_go_forward)
{
printf("%s\n%s\n", name, (const char *) data);
return true;
} // MojoGui_stdio_readme

// end of gui_stdio.c ...

100 changes: 67 additions & 33 deletions lua/config.lua
@@ -1,64 +1,98 @@
-- This is a setup file. Lines that start with "--" are comments.
-- This config file is actually just lua code. Even though you'll only
-- This config file is actually just Lua code. Even though you'll only
-- need a small subset of the language, there's a lot of flexibility
-- available to you if you need it. http://www.lua.org/
--
-- All functionality supplied by the installer is encapsulated in the
-- "MojoSetup" table, so you can use any other symbol name without
-- All functionality supplied by the installer is encapsulated in either the
-- "Setup" or "MojoSetup" table, so you can use any other symbol name without
-- namespace clashes, assuming it's not a Lua keyword or a symbol supplied
-- by the standard lua libraries.
--
-- So here's the actual configuration...we used loki_setup's xml schema
-- as a rough guideline.

MojoSetup.Install
Setup.Install
{
product = "mygame";
desc = "My Game";
version = "1.0";
splash = "splash.jpg";
splashpos = "top";
superuser = false;
appbundle = true;
reinstall = true;
nouninstall = true;
product = "mygame",
desc = "My Game",
version = "1.0",
splash = "splash.jpg",
splashpos = "top",
superuser = false,
appbundle = true,
reinstall = true,
nouninstall = true,

-- Things that are Capitalized are internal functions we supply.
-- Things named Setup.Something are internal functions we supply.
-- Generally these return the table you pass to them, but they
-- may sanitize the values, add defaults, and verify the data.

-- End User License Agreement(s). You can specify multiple files.
MojoSetup.Eula { keepdirs = true, filename = "MyGame/MyGame_EULA.txt" };
MojoSetup.Eula { keepdirs = true, filename = "MyGame/PunkBuster_EULA.txt" };
-- Also, Note the "translate" call.
Setup.Eula
{
name = "My Game License",
ui_stdio = MojoSetup.translate("MyGame_EULA.txt"),
ui_gnome = MojoSetup.translate("MyGame_EULA.html"),
ui_macosx = MojoSetup.translate("MyGame_EULA.html"),
ui_generic = MojoSetup.translate("MyGame_EULA.mtf"),
},

Setup.Eula
{
name = "Punkbuster License",
ui_stdio = MojoSetup.translate("PunkBuster_EULA.txt"),
ui_gnome = MojoSetup.translate("PunkBuster_EULA.html"),
ui_macosx = MojoSetup.translate("PunkBuster_EULA.html"),
ui_generic = MojoSetup.translate("PunkBuster_EULA.mtf"),
},

-- README file(s) to show and install. Note the "translate" call.
MojoSetup.Readme { filename = MojoSetup.translate("README.txt") };
-- README file(s) to show and install.
Setup.Readme
{
name = "My Game README",
ui_stdio = MojoSetup.translate("README.txt"),
ui_gnome = MojoSetup.translate("README.html"),
ui_macosx = MojoSetup.translate("README.html"),
ui_generic = MojoSetup.translate("README.mtf"),
},

-- Specify media (discs) we may need for this install and how to find them.
MojoSetup.Media { id = "cd1", name = "MyGame CD 1", uniquefile = "Sound/blip.wav" };
MojoSetup.Media { id = "cd2", name = "MyGame CD 2", uniquefile = "Maps/town.map" };
Setup.Media
{
id = "cd1",
name = "MyGame CD 1",
uniquefile = "Sound/blip.wav"
},

Setup.Media
{
id = "cd2",
name = "MyGame CD 2",
uniquefile = "Maps/town.map"
},

-- Specify chunks to install...optional or otherwise.
MojoSetup.Option
Setup.Option
{
required = true;
size = "600M";
description = "Base Install";
required = true,
size = "600M",
description = "Base Install",

-- File(s) to install.
MojoSetup.File
Setup.File
{
cdromid = "cd1";
dst = "MyGame/MyGame.app";
unpackarchives = true;
src = { "Maps/Maps.zip", "Sounds/*.wav", "Graphics/*" };
cdromid = "cd1",
dst = "MyGame/MyGame.app",
unpackarchives = true,
src = { "Maps/Maps.zip", "Sounds/*.wav", "Graphics/*" },

-- You can optionally assign a lua function...we'll call this for
-- each file to see if we should avoid installing it.
filter = function(fn) return fn == "Graphics/dontinstall.jpg" end;
};
};
};
filter = function(fn) return fn == "Graphics/dontinstall.jpg" end
},
},
}

-- end of config.lua ...

0 comments on commit de9795c

Please sign in to comment.