Interim checking after first menu save cleanup..

Also unglobalized menu invalidate area handling.
This commit is contained in:
ariclone 2002-06-13 17:17:03 +00:00
parent 6dd09d9a53
commit fcb969ef14
4 changed files with 56 additions and 32 deletions

View file

@ -251,21 +251,15 @@ typedef struct _menus_ {
----------------------------------------------------------------------------*/
extern const char *CurrentMenu; /// Currently processed menu
extern int MenuRedrawX; /// X coordinate of menu to redraw
extern int MenuRedrawY; /// Y coordinate of menu to redraw
extern int MenuRedrawW; /// Width of menu to redraw
extern int MenuRedrawH; /// Height of menu to redraw
extern char ScenSelectFullPath[1024]; /// Full path to currently selected map
extern MapInfo *ScenSelectPudInfo; /// MapInfo of currently selected map
#define MENUS_MAXMENU 128 /// FIXME: wrong place, docu
#define MENUS_MAXFUNC 128 /// FIXME: wrong place, docu
/// FIXME: docu
global hashtable(Menu*,MENUS_MAXMENU) MenuHash;
extern hashtable(Menu*,MENUS_MAXMENU) MenuHash;
/// FIXME: docu
typedef char char30[30];
global hashtable(void*,MENUS_MAXFUNC) MenuFuncHash;
global hashtable(char30,MENUS_MAXFUNC) MenuFuncHash2;
extern hashtable(void*,MENUS_MAXFUNC) MenuFuncHash;
/*----------------------------------------------------------------------------
-- Functions
@ -282,15 +276,18 @@ extern void DrawMenu(const char *MenuId);
/// Draw menu button
extern void DrawMenuButton(MenuButtonId button,unsigned flags,unsigned w,unsigned h,unsigned x,unsigned y,const int font,const unsigned char *text);
/// Set menu backgound and draw it
global void MenusSetBackground(void);
extern void MenusSetBackground(void);
/// Draw and process a menu
extern void ProcessMenu(const char *MenuId, int Loop);
/// End the current menu
global void EndMenu(void);
extern void EndMenu(void);
/// Find a menu by id
global Menu *FindMenu(const char *MenuId);
extern Menu *FindMenu(const char *MenuId);
/// The scenario path received from server, Update the client menu.
/// Invalidate previously redrawn menu areas
extern void InvalidateMenuAreas(void);
/// The scenario path received from server, Update the client menu
extern int NetClientSelectScenario(void);
/// State info received from server, Update the client menu.
extern void NetClientUpdateState(void);

View file

@ -653,10 +653,7 @@ global void UpdateDisplay(void)
,TheUI.StatusLine.Graphic->Height);
}
if( MustRedraw&RedrawMenu ) {
InvalidateAreaAndCheckCursor(
MenuRedrawX,MenuRedrawY
,MenuRedrawW,MenuRedrawH);
MustRedraw&=~RedrawMenu;
InvalidateMenuAreas();
}
// And now as very last.. checking if the cursor needs a refresh

View file

@ -77,23 +77,23 @@ global struct {
#endif
;
/**
** The background picture used by menus
*/
local Graphic *Menusbgnd;
/**
** The currently processed menu
*/
global const char *CurrentMenu = NULL;
/**
** The background picture used by menus
*/
local Graphic *Menusbgnd;
/**
** X, Y, Width, and Height of menu are to redraw
*/
global int MenuRedrawX;
global int MenuRedrawY;
global int MenuRedrawW;
global int MenuRedrawH;
local int MenuRedrawX;
local int MenuRedrawY;
local int MenuRedrawW;
local int MenuRedrawH;
local int MenuButtonUnderCursor = -1;
local int MenuButtonCurSel = -1;
@ -105,22 +105,32 @@ local int MenuButtonCurSel = -1;
/**
** Find a menu by ident.
**
** @param menu_id Unique identifier for the menu.
** @param MenuId Unique identifier for the menu.
**
** @return Pointer to the menu, NULL if menu is not found.
*/
global Menu* FindMenu(const char* menu_id)
global Menu *FindMenu(const char *MenuId)
{
Menu **menu;
if (!(menu = (Menu **) hash_find(MenuHash, (char *)menu_id))) {
DebugLevel0Fn("Menu `%s' not found, probably a bug.\n" _C_ menu_id);
if (!(menu = (Menu **) hash_find(MenuHash, (char *)MenuId))) {
DebugLevel0Fn("Menu `%s' not found, probably a bug.\n" _C_ MenuId);
return NULL;
} else {
return *menu;
}
}
/**
** Invalidate previously redrawn menu areas.
*/
global void InvalidateMenuAreas(void)
{
InvalidateAreaAndCheckCursor(
MenuRedrawX,MenuRedrawY,MenuRedrawW,MenuRedrawH);
MustRedraw&=~RedrawMenu;
}
/**
** Set menu backgound and draw it.
*/

View file

@ -8,7 +8,7 @@
// T H E W A R B E G I N S
// FreeCraft - A free fantasy real time strategy game engine
//
/**@name menus.c - The menu buttons. */
/**@name menus.c - The menu function code. */
//
// (c) Copyright 1999-2002 by Andreas Arens
//
@ -66,7 +66,8 @@
#include "libcda.h"
#endif
//#define OLD_MENU /// CCL menus not used
//#define OLD_MENU /// CCL menus not used
//#define SAVE_MENU_CCL /// SAVE (REWRITE!) the menus.ccl file
/*----------------------------------------------------------------------------
-- Prototypes for local functions
@ -258,6 +259,11 @@ global void SaveMenus(FILE* file);
-- Variables
----------------------------------------------------------------------------*/
#ifdef SAVE_MENU_CCL
typedef char char30[30];
extern hashtable(char30,MENUS_MAXFUNC) MenuFuncHash2;
#endif
/// Name, Version, Copyright FIXME: move to headerfile
extern char NameLine[];
@ -2134,14 +2140,22 @@ global Menu Menus[] = {
-- Functions
----------------------------------------------------------------------------*/
#ifdef SAVE_MENU_CCL
#define HASHADD(x,y) { \
*(void **)hash_add(MenuFuncHash,(y)) = (void *)(x); \
sprintf(buf,"%p",(x)); \
strcpy((char*)hash_add(MenuFuncHash2,buf), (y)); \
}
#else
#define HASHADD(x,y) { \
*(void **)hash_add(MenuFuncHash,(y)) = (void *)(x); \
}
#endif
global void InitMenuFuncHash(void) {
#ifdef SAVE_MENU_CCL
char buf[10];
#endif
HASHADD(NULL,"null");
@ -6575,15 +6589,19 @@ global void InitMenuFunctions(void)
//
#endif
#if 0
#ifdef OLD_MENU
#ifdef SAVE_MENU_CCL
{
FILE *fd=fopen("menus.ccl","w");
SaveMenus(fd);
fclose(fd);
}
#endif
#endif
}
#ifdef OLD_MENU
#ifdef SAVE_MENU_CCL
char *menu_names[] = {
"menu-game",
"menu-victory",
@ -6902,5 +6920,7 @@ global void SaveMenus(FILE* file)
fprintf(file,"\n\n");
}
}
#endif /// SAVE_MENU_CCL
#endif
//@}