Skip to content

Commit

Permalink
Bunch more work on GUI options wankery.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Dec 27, 2006
1 parent c26454e commit 86074bf
Show file tree
Hide file tree
Showing 7 changed files with 436 additions and 246 deletions.
16 changes: 16 additions & 0 deletions gui.h
Expand Up @@ -22,6 +22,17 @@ typedef enum
* Abstract GUI interfaces.
*/

typedef struct MojoGuiSetupOptions MojoGuiSetupOptions;
struct MojoGuiSetupOptions
{
const char *description;
boolean value;
boolean is_group_parent;
uint64 size;
MojoGuiSetupOptions *next_sibling;
MojoGuiSetupOptions *child;
};

#define MOJOGUI_ENTRY_POINT MojoSetup_Gui_GetInterface
#define MOJOGUI_ENTRY_POINT_STR DEFINE_TO_STR(MOJOGUI_ENTRY_POINT)

Expand All @@ -41,6 +52,8 @@ struct MojoGui
void (*stop)(void);
boolean (*readme)(const char *name, const uint8 *data, size_t len,
boolean can_go_back, boolean can_go_forward);
boolean (*options)(MojoGuiSetupOptions *opts,
boolean can_go_back, boolean can_go_forward);
};

typedef const MojoGui* (*MojoGuiEntryPoint)(int revision,
Expand Down Expand Up @@ -73,6 +86,8 @@ 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); \
static boolean MojoGui_##module##_options(MojoGuiSetupOptions *opts, \
boolean can_go_back, boolean can_go_forward); \
const MojoGui *MojoGuiPlugin_##module(int rev, const MojoSetupEntryPoints *e) \
{ \
if (rev == MOJOGUI_INTERFACE_REVISION) { \
Expand All @@ -86,6 +101,7 @@ const MojoGui *MojoGuiPlugin_##module(int rev, const MojoSetupEntryPoints *e) \
MojoGui_##module##_start, \
MojoGui_##module##_stop, \
MojoGui_##module##_readme, \
MojoGui_##module##_options, \
}; \
entry = e; \
return &retval; \
Expand Down
10 changes: 10 additions & 0 deletions gui/gui_macosx.c
Expand Up @@ -142,5 +142,15 @@ static boolean MojoGui_macosx_readme(const char *name, const uint8 *data,
return true;
} // MojoGui_macosx_readme


static boolean MojoGui_macosx_options(MojoGuiSetupOptions *opts,
boolean can_go_back, boolean can_go_forward)
{
// !!! FIXME: write me.
STUBBED("macosx options");
return true;
} // MojoGui_macosx_options


// end of gui_macosx.c ...

32 changes: 32 additions & 0 deletions gui/gui_stdio.c
Expand Up @@ -88,5 +88,37 @@ static boolean MojoGui_stdio_readme(const char *name, const uint8 *data,
return true;
} // MojoGui_stdio_readme


static void print_options(MojoGuiSetupOptions *opts, int *line, int level)
{
if (opts != NULL)
{
int i;
int spacing = 1;
if (opts->is_group_parent)
spacing += 10;
else
printf("%2d [%c]", *line, opts->value ? 'X' : ' ');

for (i = 0; i < (level + spacing); i++)
putchar(' ');

puts(opts->description);

(*line)++;
print_options(opts->child, line, level+1);
print_options(opts->next_sibling, line, level);
} // if
} // print_options


static boolean MojoGui_stdio_options(MojoGuiSetupOptions *opts,
boolean can_go_back, boolean can_go_forward)
{
int line = 0;
print_options(opts, &line, 0);
return true;
} // MojoGui_stdio_options

// end of gui_stdio.c ...

57 changes: 38 additions & 19 deletions lua/config.lua
Expand Up @@ -11,17 +11,13 @@
-- So here's the actual configuration...we used loki_setup's xml schema
-- as a rough guideline.

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

-- Things named Setup.Something are internal functions we supply.
-- Generally these return the table you pass to them, but they
Expand All @@ -31,28 +27,28 @@ Setup.Install
-- Also, Note the "translate" call.
Setup.Eula
{
name = "My Game License",
description = "My Game License",
ui_stdio = MojoSetup.translate("MyGame_EULA.txt"),
ui_gnome = MojoSetup.translate("MyGame_EULA.html"),
ui_gtkplus = MojoSetup.translate("MyGame_EULA.html"),
ui_macosx = MojoSetup.translate("MyGame_EULA.html"),
ui_generic = MojoSetup.translate("MyGame_EULA.mtf"),
},

Setup.Eula
{
name = "Punkbuster License",
description = "Punkbuster License",
ui_stdio = MojoSetup.translate("PunkBuster_EULA.txt"),
ui_gnome = MojoSetup.translate("PunkBuster_EULA.html"),
ui_gtkplus = 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.
Setup.Readme
{
name = "My Game README",
description = "My Game README",
ui_stdio = MojoSetup.translate("README.txt"),
ui_gnome = MojoSetup.translate("README.html"),
ui_gtkplus = MojoSetup.translate("README.html"),
ui_macosx = MojoSetup.translate("README.html"),
ui_generic = MojoSetup.translate("README.mtf"),
},
Expand All @@ -61,36 +57,59 @@ Setup.Install
Setup.Media
{
id = "cd1",
name = "MyGame CD 1",
description = "MyGame CD 1",
uniquefile = "Sound/blip.wav"
},

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

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

-- File(s) to install.
Setup.File
{
cdromid = "cd1",
dst = "MyGame/MyGame.app",
mediaid = "cd1",
destination = "MyGame/MyGame.app",
unpackarchives = true,
src = { "Maps/Maps.zip", "Sounds/*.wav", "Graphics/*" },
source = { "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
},

-- Radio buttons.
Setup.OptionGroup
{
disabled = false,
description = "Language",
Setup.Option
{
value = string.match(MojoSetup.locale, "^en_") ~= nil,
size = "10M",
description = "English",
Setup.File { source="Lang/English.zip" },
},
Setup.Option
{
value = string.match(MojoSetup.locale, "^fr_") ~= nil,
size = "10M",
description = "French",
Setup.File { source="Lang/French.zip" },
},
},
},
}

Expand Down

0 comments on commit 86074bf

Please sign in to comment.