Menu button graphics are now configurable

This commit is contained in:
jsalmon3 2003-02-01 04:57:52 +00:00
parent 7558154dac
commit 364a6881b2
7 changed files with 98 additions and 28 deletions

View file

@ -179,6 +179,8 @@
<DD></DD>
<DT><A HREF="ui.html#define-menu">define-menu</A></DT>
<DD></DD>
<DT><A HREF="ui.html#define-menu-graphics">define-menu-graphics</A></DT>
<DD></DD>
<DT><A HREF="ui.html#define-menu-item">define-menu-item</A></DT>
<DD></DD>
<DT><A HREF="game.html#define-missile-type">define-missile-type</A></DT>

View file

@ -47,6 +47,7 @@
<A HREF="#define-font">define-font</A>
<A HREF="#define-font-colors">define-font-colors</A>
<A HREF="#define-menu">define-menu</A>
<A HREF="#define-menu-graphics">define-menu-graphics</A>
<A HREF="#define-menu-item">define-menu-item</A>
<A HREF="#define-new-ui">define-new-ui</A>
<A HREF="#define-ui">define-ui</A>
@ -276,6 +277,40 @@ and 'large-title.
<A HREF="../../data/ccl/menus.ccl"> $LIBARYPATH/ccl/menus.ccl </A>
<A NAME="define-menu-graphics"></A>
<H3>define-menu-graphics</H3>
<H4>Description</H4>
Define the menu graphics for each of the races.
<H4>Syntax</H4>
<CODE>(define-menu-graphics '(file filename size (w h)) ...)</CODE>
<DL>
<DT>filename</DT>
<DD>Path to the file containing the menu graphics.
</DD>
<DT>w,h</DT>
<DD>Width and height of an image in the menu graphic.
</DD>
</DL>
<H4>Example</H4>
<PRE>
(define-menu-graphics
'(file "ui/buttons 1.png" size (300 144))
'(file "ui/buttons 2.png" size (300 144)))
</PRE>
<P>Defines the menu graphics for all races.
<H4>Used</H4>
<A HREF="../../data/ccl/menus.ccl"> $LIBARYPATH/ccl/menus.ccl </A>
<A NAME="define-menu-item"></A>
<H3>define-menu-item</H3>

View file

@ -54,14 +54,6 @@
extern void DoScrollArea(enum _scroll_state_ state, int fast);
// FIXME: export+import the structure correct
extern struct {
const char* File[PlayerMaxRaces]; /// Resource filename one for each race
int Width; /// Width of button
int Height; /// Height of button
Graphic* Sprite; /// Sprite : FILLED
} MenuButtonGfx;
/*----------------------------------------------------------------------------
-- Defines
----------------------------------------------------------------------------*/

View file

@ -248,12 +248,23 @@ typedef struct _menus_ {
void (*netaction)(void); /// network action callback
} Menu;
/**
** Struct which specifies the buttons gfx
*/
typedef struct _menu_graphics_ {
char* File[PlayerMaxRaces]; /// resource filename one for each race
int Width[PlayerMaxRaces]; /// Width of button
int Height[PlayerMaxRaces]; /// Height of button
Graphic* Sprite; /// sprite : FILLED
} MenuGraphics;
/*----------------------------------------------------------------------------
-- Variables
----------------------------------------------------------------------------*/
extern int GuiGameStarted; /// Game Started?
extern Menu *CurrentMenu; /// Currently processed menu
extern MenuGraphics MenuButtonGfx; /// Menu button graphics
extern MapInfo *MenuMapInfo; /// MapInfo of map used in gui menus
extern char MenuMapFullPath[1024]; /// Full path to currently selected map

View file

@ -369,7 +369,7 @@ enum PlayerRaces {
PlayerRaceOrc =1, /// belongs to orc
PlayerRaceNeutral =2, /// belongs to none
PlayerMaxRaces =2 /// maximal races supported
PlayerMaxRaces =3 /// maximal races supported
};
/**

View file

@ -76,24 +76,10 @@
local EventCallback callbacks;
/// Struct which specifies the buttons gfx
global struct {
/// resource filename one for each race
const char* File[PlayerMaxRaces];
/// Width of button
int Width, Height;
/// sprite : FILLED
Graphic* Sprite;
} MenuButtonGfx
#ifndef laterUSE_CCL
= {
{ "ui/buttons 1.png" ,"ui/buttons 2.png" },
300, 7632,
NULL
}
#endif
;
/**
** Menu button graphics
*/
global MenuGraphics MenuButtonGfx;
/**
** The currently processed menu
@ -1925,6 +1911,8 @@ global void InitMenus(int race)
static int last_race = -1;
const char *file;
char *buf;
int width;
int height;
InitMenuData();
@ -1950,7 +1938,9 @@ global void InitMenus(int race)
file = MenuButtonGfx.File[race];
buf = alloca(strlen(file) + 9 + 1);
file = strcat(strcpy(buf, "graphics/"), file);
MenuButtonGfx.Sprite = LoadSprite(file, 300, 144); // 50/53 images!
width = MenuButtonGfx.Width[race];
height = MenuButtonGfx.Height[race];
MenuButtonGfx.Sprite = LoadSprite(file, width, height);
InitMenuFunctions();
CurrentMenu = NULL;

View file

@ -2962,6 +2962,45 @@ local SCM CclDefineMenuItem(SCM list)
return SCM_UNSPECIFIED;
}
/**
** Define menu graphics
**
** @param list List describing the menu.
*/
local SCM CclDefineMenuGraphics(SCM list)
{
SCM sublist;
SCM value;
int i;
i = 0;
while( !gh_null_p(list) ) {
sublist=gh_car(list);
list=gh_cdr(list);
while( !gh_null_p(sublist) ) {
value=gh_car(sublist);
sublist=gh_cdr(sublist);
if( gh_eq_p(value,gh_symbol2scm("file")) ) {
value=gh_car(sublist);
sublist=gh_cdr(sublist);
if( MenuButtonGfx.File[i] ) {
free(MenuButtonGfx.File[i]);
}
MenuButtonGfx.File[i]=gh_scm2newstr(value,NULL);
} else if( gh_eq_p(value,gh_symbol2scm("size")) ) {
SCM sublist2;
sublist2=gh_car(sublist);
sublist=gh_cdr(sublist);
MenuButtonGfx.Width[i]=gh_scm2int(gh_car(sublist2));
sublist2=gh_cdr(sublist2);
MenuButtonGfx.Height[i]=gh_scm2int(gh_car(sublist2));
}
}
++i;
}
return SCM_UNSPECIFIED;
}
/**
** Define a button.
@ -3451,6 +3490,7 @@ global void UserInterfaceCclRegister(void)
gh_new_procedureN("define-menu-item",CclDefineMenuItem);
gh_new_procedureN("define-menu",CclDefineMenu);
gh_new_procedureN("define-menu-graphics",CclDefineMenuGraphics);
//
// Correct named functions