move some more old definition-related stuff to defs files
This commit is contained in:
parent
f1b6b7996a
commit
7290c0b2f7
2 changed files with 404 additions and 396 deletions
src/ui
|
@ -1698,8 +1698,409 @@ global Menu Menus[] = {
|
|||
NULL,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
** Initialize the old style menu data
|
||||
*/
|
||||
local void InitOldMenuData(void)
|
||||
{
|
||||
// There go all my Gnuish compile time inits -
|
||||
// Why is ANSI C so dumb that it cannot
|
||||
// even initialize unions sanely?
|
||||
InitGameMenuItems();
|
||||
InitVictoryMenuItems();
|
||||
InitLostMenuItems();
|
||||
InitTipsMenuItems();
|
||||
InitObjectivesMenuItems();
|
||||
InitEndScenarioMenuItems();
|
||||
InitScenSelectMenuItems();
|
||||
InitPrgStartMenuItems();
|
||||
InitCustomGameMenuItems();
|
||||
InitEnterNameMenuItems();
|
||||
InitEnterServerIPMenuItems();
|
||||
InitNetCreateJoinMenuItems();
|
||||
InitNetMultiSetupMenuItems();
|
||||
InitNetMultiClientMenuItems();
|
||||
InitNetErrorMenuItems();
|
||||
InitConnectingMenuItems();
|
||||
InitCampaignSelectMenuItems();
|
||||
InitCampaignContMenuItems();
|
||||
InitSoundOptionsMenuItems();
|
||||
InitPreferencesMenuItems();
|
||||
InitSpeedSettingsMenuItems();
|
||||
InitGameOptionsMenuItems();
|
||||
InitHelpMenuItems();
|
||||
InitKeystrokeHelpMenuItems();
|
||||
InitSaveGameMenuItems();
|
||||
InitLoadGameMenuItems();
|
||||
InitConfirmSaveMenuItems();
|
||||
InitConfirmDeleteMenuItems();
|
||||
InitEditorSelectMenuItems();
|
||||
InitEditorLoadMapMenuItems();
|
||||
InitEditorMenuItems();
|
||||
InitEditorMapPropertiesMenuItems();
|
||||
InitEditorPlayerPropertiesMenuItems();
|
||||
|
||||
*(Menu **)hash_add(MenuHash,"menu-game") = Menus + 0;
|
||||
*(Menu **)hash_add(MenuHash,"menu-victory") = Menus + 1;
|
||||
*(Menu **)hash_add(MenuHash,"menu-defeated") = Menus + 2;
|
||||
*(Menu **)hash_add(MenuHash,"menu-select-scenario") = Menus + 3;
|
||||
*(Menu **)hash_add(MenuHash,"menu-program-start") = Menus + 4;
|
||||
*(Menu **)hash_add(MenuHash,"menu-custom-game") = Menus + 5;
|
||||
*(Menu **)hash_add(MenuHash,"menu-enter-name") = Menus + 6;
|
||||
*(Menu **)hash_add(MenuHash,"menu-create-join-menu") = Menus + 7;
|
||||
*(Menu **)hash_add(MenuHash,"menu-multi-setup") = Menus + 8;
|
||||
*(Menu **)hash_add(MenuHash,"menu-enter-server") = Menus + 9;
|
||||
*(Menu **)hash_add(MenuHash,"menu-net-multi-client") = Menus + 10;
|
||||
*(Menu **)hash_add(MenuHash,"menu-net-connecting") = Menus + 11;
|
||||
*(Menu **)hash_add(MenuHash,"menu-campaign-select") = Menus + 12;
|
||||
*(Menu **)hash_add(MenuHash,"menu-campaign-continue") = Menus + 13;
|
||||
*(Menu **)hash_add(MenuHash,"menu-objectives") = Menus + 14;
|
||||
*(Menu **)hash_add(MenuHash,"menu-end-scenario") = Menus + 15;
|
||||
*(Menu **)hash_add(MenuHash,"menu-sound-options") = Menus + 16;
|
||||
*(Menu **)hash_add(MenuHash,"menu-preferences") = Menus + 17;
|
||||
*(Menu **)hash_add(MenuHash,"menu-settings-speed") = Menus + 18;
|
||||
*(Menu **)hash_add(MenuHash,"menu-game-options") = Menus + 19;
|
||||
*(Menu **)hash_add(MenuHash,"menu-net-error") = Menus + 20;
|
||||
*(Menu **)hash_add(MenuHash,"menu-tips") = Menus + 21;
|
||||
*(Menu **)hash_add(MenuHash,"menu-help") = Menus + 22;
|
||||
*(Menu **)hash_add(MenuHash,"menu-keystroke-help") = Menus + 23;
|
||||
*(Menu **)hash_add(MenuHash,"menu-save-game") = Menus + 24;
|
||||
*(Menu **)hash_add(MenuHash,"menu-load-game") = Menus + 25;
|
||||
*(Menu **)hash_add(MenuHash,"menu-save-confirm") = Menus + 26;
|
||||
*(Menu **)hash_add(MenuHash,"menu-delete-confirm") = Menus + 27;
|
||||
*(Menu **)hash_add(MenuHash,"menu-editor-select") = Menus + 28;
|
||||
*(Menu **)hash_add(MenuHash,"menu-editor-load-map") = Menus + 29;
|
||||
*(Menu **)hash_add(MenuHash,"menu-editor") = Menus + 30;
|
||||
*(Menu **)hash_add(MenuHash,"menu-editor-map-properties") = Menus + 31;
|
||||
*(Menu **)hash_add(MenuHash,"menu-editor-player-properties") = Menus + 32;
|
||||
}
|
||||
#endif /// OLD_MENU
|
||||
|
||||
|
||||
#ifdef SAVE_MENU_CCL
|
||||
char *menu_names[] = {
|
||||
"menu-game",
|
||||
"menu-victory",
|
||||
"menu-defeated",
|
||||
"menu-select-scenario",
|
||||
"menu-program-start",
|
||||
"menu-global-options",
|
||||
"menu-custom-game",
|
||||
"menu-enter-name",
|
||||
"menu-create-join-menu",
|
||||
"menu-multi-setup",
|
||||
"menu-enter-server",
|
||||
"menu-net-multi-client",
|
||||
"menu-net-connecting",
|
||||
"menu-campaign-select",
|
||||
"menu-campaign-continue",
|
||||
"menu-objectives",
|
||||
"menu-end-scenario",
|
||||
"menu-sound-options",
|
||||
"menu-preferences",
|
||||
"menu-settings-speed",
|
||||
"menu-game-options",
|
||||
"menu-net-error",
|
||||
"menu-tips",
|
||||
"menu-help",
|
||||
"menu-keystroke-help",
|
||||
"menu-save-game",
|
||||
"menu-load-game",
|
||||
"menu-save-confirm",
|
||||
"menu-delete-confirm",
|
||||
"menu-editor-select",
|
||||
"menu-editor-load-map",
|
||||
"menu-editor",
|
||||
"menu-editor-map-properties",
|
||||
"menu-editor-player-properties",
|
||||
};
|
||||
|
||||
char *menu_flags[] = {
|
||||
"",
|
||||
"'flags '(active)",
|
||||
"'flags '(clicked)",
|
||||
"",
|
||||
"'flags '(selected)",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"'flags '(disabled)",
|
||||
};
|
||||
|
||||
char *images[] = {
|
||||
"none",
|
||||
"panel1",
|
||||
"panel2",
|
||||
"panel3",
|
||||
"panel4",
|
||||
"panel5",
|
||||
};
|
||||
|
||||
char *font_names[] = {
|
||||
"small",
|
||||
"game",
|
||||
"large",
|
||||
"smallTitle",
|
||||
"largeTitle",
|
||||
};
|
||||
|
||||
char *text_flags[] = {
|
||||
"none",
|
||||
"center",
|
||||
"right",
|
||||
"",
|
||||
"left",
|
||||
};
|
||||
|
||||
char *gem_state[] = {
|
||||
"unchecked",
|
||||
"passive",
|
||||
"invisible",
|
||||
"",
|
||||
"checked",
|
||||
};
|
||||
|
||||
local char *hotkey2str(int key, char *buf)
|
||||
{
|
||||
if (!key) {
|
||||
buf[0] = '\0';
|
||||
} else if (('a' <= key && key <= 'z') || ('A' <= key && key <= 'Z')) {
|
||||
buf[0] = key;
|
||||
buf[1] = '\0';
|
||||
} else if (KeyCodeF1 <= key && key <= KeyCodeF12) {
|
||||
buf[0] = 'f';
|
||||
if (key >= KeyCodeF10) {
|
||||
buf[1] = '1';
|
||||
buf[2] = key-10-KeyCodeF1+1 + '0';
|
||||
buf[3] = '\0';
|
||||
} else {
|
||||
buf[1] = key-KeyCodeF1+1 + '0';
|
||||
buf[2] = '\0';
|
||||
}
|
||||
} else if (key == '\033') {
|
||||
strcpy(buf,"esc");
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
local char *button_style(int style)
|
||||
{
|
||||
switch (style) {
|
||||
case MBUTTON_MAIN:
|
||||
return "main";
|
||||
case MBUTTON_GM_HALF:
|
||||
return "gm-half";
|
||||
case MBUTTON_132:
|
||||
return "132";
|
||||
case MBUTTON_GM_FULL:
|
||||
return "gm-full";
|
||||
case MBUTTON_GEM_ROUND:
|
||||
return "gem-round";
|
||||
case MBUTTON_GEM_SQUARE:
|
||||
return "gem-square";
|
||||
case MBUTTON_UP_ARROW:
|
||||
return "up-arrow";
|
||||
case MBUTTON_DOWN_ARROW:
|
||||
return "down-arrow";
|
||||
case MBUTTON_LEFT_ARROW:
|
||||
return "left-arrow";
|
||||
case MBUTTON_RIGHT_ARROW:
|
||||
return "right-arrow";
|
||||
case MBUTTON_S_KNOB:
|
||||
return "s-knob";
|
||||
case MBUTTON_S_VCONT:
|
||||
return "s-vcont";
|
||||
case MBUTTON_S_HCONT:
|
||||
return "s-hcont";
|
||||
case MBUTTON_PULLDOWN:
|
||||
return "pulldown";
|
||||
case MBUTTON_VTHIN:
|
||||
return "vthin";
|
||||
case MBUTTON_FOLDER:
|
||||
return "folder";
|
||||
}
|
||||
fprintf(stderr,"button_style not found: %d\n", style);
|
||||
return "";
|
||||
}
|
||||
|
||||
global void SaveMenus(FILE* file)
|
||||
{
|
||||
Menu *menu;
|
||||
int i, j, n;
|
||||
int OffsetX, OffsetY;
|
||||
char hotkey[10];
|
||||
char func[10];
|
||||
char func2[10];
|
||||
char func3[10];
|
||||
char initfunc[40];
|
||||
char exitfunc[40];
|
||||
char netaction[40];
|
||||
|
||||
OffsetX = (VideoWidth - 640) / 2;
|
||||
OffsetY = (VideoHeight - 480) / 2;
|
||||
|
||||
fprintf(file,"\n;;; -----------------------------------------\n");
|
||||
fprintf(file,";;; $Id$\n\n");
|
||||
|
||||
for (i=0; i<sizeof(menu_names)/sizeof(*menu_names); ++i) {
|
||||
menu = FindMenu(menu_names[i]);
|
||||
if (!menu) {
|
||||
abort();
|
||||
}
|
||||
fprintf(file,";;\n;; %s\n;;\n", menu_names[i]);
|
||||
if (menu->netaction) {
|
||||
sprintf(func,"%p",menu->netaction);
|
||||
sprintf(netaction," 'netaction '%s",(char*)hash_find(MenuFuncHash2,func));
|
||||
} else {
|
||||
netaction[0] = '\0';
|
||||
}
|
||||
fprintf(file,"(define-menu 'name '%s 'geometry '(%d %d %d %d)\n"
|
||||
" 'image '%s 'default '%d%s)\n",
|
||||
menu_names[i],
|
||||
menu->x - OffsetX, menu->y - OffsetY,
|
||||
menu->xsize, menu->ysize,
|
||||
images[menu->image],
|
||||
menu->defsel,
|
||||
netaction);
|
||||
for (j=0; j<menu->nitems; ++j) {
|
||||
if (menu->items[j].initfunc) {
|
||||
sprintf(func,"%p",menu->items[j].initfunc);
|
||||
sprintf(initfunc," 'init '%s",(char*)hash_find(MenuFuncHash2,func));
|
||||
} else {
|
||||
initfunc[0] = '\0';
|
||||
}
|
||||
if (menu->items[j].exitfunc) {
|
||||
sprintf(func,"%p",menu->items[j].exitfunc);
|
||||
sprintf(exitfunc," 'exit '%s",(char*)hash_find(MenuFuncHash2,func));
|
||||
} else {
|
||||
exitfunc[0] = '\0';
|
||||
}
|
||||
|
||||
fprintf(file,"(define-menu-item 'pos (list %d %d) 'font '%s %s%s%s\n",
|
||||
menu->items[j].xofs, menu->items[j].yofs,
|
||||
font_names[menu->items[j].font],
|
||||
menu_flags[menu->items[j].flags],
|
||||
initfunc,
|
||||
exitfunc);
|
||||
switch (menu->items[j].mitype) {
|
||||
case MI_TYPE_TEXT:
|
||||
fprintf(file," 'text '(\"%s\" %s)\n",
|
||||
menu->items[j].d.text.text ? (char*)menu->items[j].d.text.text : "null",
|
||||
text_flags[menu->items[j].d.text.tflags]);
|
||||
break;
|
||||
case MI_TYPE_BUTTON:
|
||||
sprintf(func,"%p",menu->items[j].d.button.handler);
|
||||
fprintf(file," 'button '(size (%d %d)\n"
|
||||
" caption \"%s\"\n"
|
||||
" hotkey \"%s\"\n"
|
||||
" func %s\n"
|
||||
" style %s)\n",
|
||||
menu->items[j].d.button.xsize,
|
||||
menu->items[j].d.button.ysize,
|
||||
menu->items[j].d.button.text ? menu->items[j].d.button.text : "null",
|
||||
hotkey2str(menu->items[j].d.button.hotkey,hotkey),
|
||||
(char*)hash_find(MenuFuncHash2,func),
|
||||
button_style(menu->items[j].d.button.button));
|
||||
break;
|
||||
case MI_TYPE_PULLDOWN:
|
||||
sprintf(func,"%p",menu->items[j].d.pulldown.action);
|
||||
fprintf(file," 'pulldown '(size (%d %d)\n"
|
||||
" style %s\n"
|
||||
" func %s\n",
|
||||
menu->items[j].d.pulldown.xsize,
|
||||
menu->items[j].d.pulldown.ysize,
|
||||
button_style(menu->items[j].d.pulldown.button),
|
||||
(char*)hash_find(MenuFuncHash2,func));
|
||||
fprintf(file," options (");
|
||||
for (n=0; n<menu->items[j].d.pulldown.noptions; ++n) {
|
||||
fprintf(file,"\"%s\" ", menu->items[j].d.pulldown.options[n]);
|
||||
}
|
||||
|
||||
fprintf(file,")\n"
|
||||
" default %d\n"
|
||||
" current %d)\n",
|
||||
menu->items[j].d.pulldown.defopt,
|
||||
menu->items[j].d.pulldown.curopt);
|
||||
break;
|
||||
case MI_TYPE_LISTBOX:
|
||||
sprintf(func,"%p",menu->items[j].d.listbox.action);
|
||||
sprintf(func2,"%p",menu->items[j].d.listbox.retrieveopt);
|
||||
sprintf(func3,"%p",menu->items[j].d.listbox.handler);
|
||||
fprintf(file," 'listbox '(size (%d %d)\n"
|
||||
" style %s\n"
|
||||
" func %s\n"
|
||||
" retopt %s\n"
|
||||
" handler %s\n"
|
||||
" nlines %d)\n",
|
||||
menu->items[j].d.listbox.xsize,
|
||||
menu->items[j].d.listbox.ysize,
|
||||
button_style(menu->items[j].d.listbox.button),
|
||||
(char*)hash_find(MenuFuncHash2,func),
|
||||
(char*)hash_find(MenuFuncHash2,func2),
|
||||
(char*)hash_find(MenuFuncHash2,func3),
|
||||
menu->items[j].d.listbox.nlines);
|
||||
break;
|
||||
case MI_TYPE_VSLIDER:
|
||||
sprintf(func,"%p",menu->items[j].d.vslider.action);
|
||||
sprintf(func2,"%p",menu->items[j].d.vslider.handler);
|
||||
fprintf(file," 'vslider '(size (%d %d)\n"
|
||||
" func %s\n"
|
||||
" handler %s)\n",
|
||||
menu->items[j].d.vslider.xsize,
|
||||
menu->items[j].d.vslider.ysize,
|
||||
(char*)hash_find(MenuFuncHash2,func),
|
||||
(char*)hash_find(MenuFuncHash2,func2));
|
||||
break;
|
||||
case MI_TYPE_DRAWFUNC:
|
||||
sprintf(func,"%p",menu->items[j].d.drawfunc.draw);
|
||||
fprintf(file," 'drawfunc '%s\n",
|
||||
(char*)hash_find(MenuFuncHash2,func));
|
||||
break;
|
||||
case MI_TYPE_INPUT:
|
||||
sprintf(func,"%p",menu->items[j].d.input.action);
|
||||
fprintf(file," 'input '(size (%d %d)\n"
|
||||
" func %s\n"
|
||||
" style %s)\n",
|
||||
menu->items[j].d.input.xsize,
|
||||
menu->items[j].d.input.ysize,
|
||||
(char*)hash_find(MenuFuncHash2,func),
|
||||
button_style(menu->items[j].d.input.button));
|
||||
break;
|
||||
case MI_TYPE_GEM:
|
||||
sprintf(func,"%p",menu->items[j].d.gem.action);
|
||||
fprintf(file," 'gem '(size (%d %d)\n"
|
||||
" state %s\n"
|
||||
" func %s\n"
|
||||
" style %s)\n",
|
||||
menu->items[j].d.gem.xsize,
|
||||
menu->items[j].d.gem.ysize,
|
||||
gem_state[menu->items[j].d.gem.state],
|
||||
(char*)hash_find(MenuFuncHash2,func),
|
||||
button_style(menu->items[j].d.gem.button));
|
||||
break;
|
||||
case MI_TYPE_HSLIDER:
|
||||
sprintf(func,"%p",menu->items[j].d.hslider.action);
|
||||
sprintf(func2,"%p",menu->items[j].d.hslider.handler);
|
||||
fprintf(file," 'hslider '(size (%d %d)\n"
|
||||
" func %s\n"
|
||||
" handler %s)\n",
|
||||
menu->items[j].d.hslider.xsize,
|
||||
menu->items[j].d.hslider.ysize,
|
||||
(char*)hash_find(MenuFuncHash2,func),
|
||||
(char*)hash_find(MenuFuncHash2,func2));
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
fprintf(file," 'menu '%s)\n",menu_names[i]);
|
||||
}
|
||||
fprintf(file,"\n\n");
|
||||
}
|
||||
}
|
||||
#endif /// SAVE_MENU_CCL
|
||||
|
||||
|
||||
/// Offsets into NetMultiSetupMenuItems
|
||||
#define SERVER_PLAYER_STATE 5
|
||||
#define SERVER_PLAYER_READY 30
|
||||
|
|
399
src/ui/menus.cpp
399
src/ui/menus.cpp
|
@ -255,8 +255,6 @@ local void EditorEnterMapDescriptionAction(Menuitem *mi, int key);
|
|||
local void EditorMapPropertiesOk(void);
|
||||
local void EditorQuitMenu(void);
|
||||
|
||||
global void SaveMenus(FILE* file);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Variables
|
||||
----------------------------------------------------------------------------*/
|
||||
|
@ -4847,84 +4845,15 @@ local void MoveButtons(void)
|
|||
global void InitMenuData(void)
|
||||
{
|
||||
#ifdef OLD_MENU
|
||||
// There go all my Gnuish compile time inits -
|
||||
// Why is ANSI C so dumb that it cannot
|
||||
// even initialize unions sanely?
|
||||
InitGameMenuItems();
|
||||
InitVictoryMenuItems();
|
||||
InitLostMenuItems();
|
||||
InitTipsMenuItems();
|
||||
InitObjectivesMenuItems();
|
||||
InitEndScenarioMenuItems();
|
||||
InitScenSelectMenuItems();
|
||||
InitPrgStartMenuItems();
|
||||
InitCustomGameMenuItems();
|
||||
InitEnterNameMenuItems();
|
||||
InitEnterServerIPMenuItems();
|
||||
InitNetCreateJoinMenuItems();
|
||||
InitNetMultiSetupMenuItems();
|
||||
InitNetMultiClientMenuItems();
|
||||
InitNetErrorMenuItems();
|
||||
InitConnectingMenuItems();
|
||||
InitCampaignSelectMenuItems();
|
||||
InitCampaignContMenuItems();
|
||||
InitSoundOptionsMenuItems();
|
||||
InitPreferencesMenuItems();
|
||||
InitSpeedSettingsMenuItems();
|
||||
InitGameOptionsMenuItems();
|
||||
InitHelpMenuItems();
|
||||
InitKeystrokeHelpMenuItems();
|
||||
InitSaveGameMenuItems();
|
||||
InitLoadGameMenuItems();
|
||||
InitConfirmSaveMenuItems();
|
||||
InitConfirmDeleteMenuItems();
|
||||
InitEditorSelectMenuItems();
|
||||
InitEditorLoadMapMenuItems();
|
||||
InitEditorMenuItems();
|
||||
InitEditorMapPropertiesMenuItems();
|
||||
InitEditorPlayerPropertiesMenuItems();
|
||||
InitOldMenuData();
|
||||
#endif
|
||||
|
||||
// FIXME: Get rid of this..
|
||||
InitNetMultiButtonStorage();
|
||||
|
||||
if (VideoWidth != 640) {
|
||||
MoveButtons();
|
||||
}
|
||||
|
||||
#ifdef OLD_MENU
|
||||
*(Menu **)hash_add(MenuHash,"menu-game") = Menus + 0;
|
||||
*(Menu **)hash_add(MenuHash,"menu-victory") = Menus + 1;
|
||||
*(Menu **)hash_add(MenuHash,"menu-defeated") = Menus + 2;
|
||||
*(Menu **)hash_add(MenuHash,"menu-select-scenario") = Menus + 3;
|
||||
*(Menu **)hash_add(MenuHash,"menu-program-start") = Menus + 4;
|
||||
*(Menu **)hash_add(MenuHash,"menu-custom-game") = Menus + 5;
|
||||
*(Menu **)hash_add(MenuHash,"menu-enter-name") = Menus + 6;
|
||||
*(Menu **)hash_add(MenuHash,"menu-create-join-menu") = Menus + 7;
|
||||
*(Menu **)hash_add(MenuHash,"menu-multi-setup") = Menus + 8;
|
||||
*(Menu **)hash_add(MenuHash,"menu-enter-server") = Menus + 9;
|
||||
*(Menu **)hash_add(MenuHash,"menu-net-multi-client") = Menus + 10;
|
||||
*(Menu **)hash_add(MenuHash,"menu-net-connecting") = Menus + 11;
|
||||
*(Menu **)hash_add(MenuHash,"menu-campaign-select") = Menus + 12;
|
||||
*(Menu **)hash_add(MenuHash,"menu-campaign-continue") = Menus + 13;
|
||||
*(Menu **)hash_add(MenuHash,"menu-objectives") = Menus + 14;
|
||||
*(Menu **)hash_add(MenuHash,"menu-end-scenario") = Menus + 15;
|
||||
*(Menu **)hash_add(MenuHash,"menu-sound-options") = Menus + 16;
|
||||
*(Menu **)hash_add(MenuHash,"menu-preferences") = Menus + 17;
|
||||
*(Menu **)hash_add(MenuHash,"menu-settings-speed") = Menus + 18;
|
||||
*(Menu **)hash_add(MenuHash,"menu-game-options") = Menus + 19;
|
||||
*(Menu **)hash_add(MenuHash,"menu-net-error") = Menus + 20;
|
||||
*(Menu **)hash_add(MenuHash,"menu-tips") = Menus + 21;
|
||||
*(Menu **)hash_add(MenuHash,"menu-help") = Menus + 22;
|
||||
*(Menu **)hash_add(MenuHash,"menu-keystroke-help") = Menus + 23;
|
||||
*(Menu **)hash_add(MenuHash,"menu-save-game") = Menus + 24;
|
||||
*(Menu **)hash_add(MenuHash,"menu-load-game") = Menus + 25;
|
||||
*(Menu **)hash_add(MenuHash,"menu-save-confirm") = Menus + 26;
|
||||
*(Menu **)hash_add(MenuHash,"menu-delete-confirm") = Menus + 27;
|
||||
*(Menu **)hash_add(MenuHash,"menu-editor-select") = Menus + 28;
|
||||
*(Menu **)hash_add(MenuHash,"menu-editor-load-map") = Menus + 29;
|
||||
*(Menu **)hash_add(MenuHash,"menu-editor") = Menus + 30;
|
||||
*(Menu **)hash_add(MenuHash,"menu-editor-map-properties") = Menus + 31;
|
||||
*(Menu **)hash_add(MenuHash,"menu-editor-player-properties") = Menus + 32;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4970,326 +4899,4 @@ global void InitMenuFunctions(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef SAVE_MENU_CCL
|
||||
char *menu_names[] = {
|
||||
"menu-game",
|
||||
"menu-victory",
|
||||
"menu-defeated",
|
||||
"menu-select-scenario",
|
||||
"menu-program-start",
|
||||
"menu-global-options",
|
||||
"menu-custom-game",
|
||||
"menu-enter-name",
|
||||
"menu-create-join-menu",
|
||||
"menu-multi-setup",
|
||||
"menu-enter-server",
|
||||
"menu-net-multi-client",
|
||||
"menu-net-connecting",
|
||||
"menu-campaign-select",
|
||||
"menu-campaign-continue",
|
||||
"menu-objectives",
|
||||
"menu-end-scenario",
|
||||
"menu-sound-options",
|
||||
"menu-preferences",
|
||||
"menu-settings-speed",
|
||||
"menu-game-options",
|
||||
"menu-net-error",
|
||||
"menu-tips",
|
||||
"menu-help",
|
||||
"menu-keystroke-help",
|
||||
"menu-save-game",
|
||||
"menu-load-game",
|
||||
"menu-save-confirm",
|
||||
"menu-delete-confirm",
|
||||
"menu-editor-select",
|
||||
"menu-editor-load-map",
|
||||
"menu-editor",
|
||||
"menu-editor-map-properties",
|
||||
"menu-editor-player-properties",
|
||||
};
|
||||
|
||||
char *menu_flags[] = {
|
||||
"",
|
||||
"'flags '(active)",
|
||||
"'flags '(clicked)",
|
||||
"",
|
||||
"'flags '(selected)",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"'flags '(disabled)",
|
||||
};
|
||||
|
||||
char *images[] = {
|
||||
"none",
|
||||
"panel1",
|
||||
"panel2",
|
||||
"panel3",
|
||||
"panel4",
|
||||
"panel5",
|
||||
};
|
||||
|
||||
char *font_names[] = {
|
||||
"small",
|
||||
"game",
|
||||
"large",
|
||||
"smallTitle",
|
||||
"largeTitle",
|
||||
};
|
||||
|
||||
char *text_flags[] = {
|
||||
"none",
|
||||
"center",
|
||||
"right",
|
||||
"",
|
||||
"left",
|
||||
};
|
||||
|
||||
char *gem_state[] = {
|
||||
"unchecked",
|
||||
"passive",
|
||||
"invisible",
|
||||
"",
|
||||
"checked",
|
||||
};
|
||||
|
||||
local char *hotkey2str(int key, char *buf)
|
||||
{
|
||||
if (!key) {
|
||||
buf[0] = '\0';
|
||||
} else if (('a' <= key && key <= 'z') || ('A' <= key && key <= 'Z')) {
|
||||
buf[0] = key;
|
||||
buf[1] = '\0';
|
||||
} else if (KeyCodeF1 <= key && key <= KeyCodeF12) {
|
||||
buf[0] = 'f';
|
||||
if (key >= KeyCodeF10) {
|
||||
buf[1] = '1';
|
||||
buf[2] = key-10-KeyCodeF1+1 + '0';
|
||||
buf[3] = '\0';
|
||||
} else {
|
||||
buf[1] = key-KeyCodeF1+1 + '0';
|
||||
buf[2] = '\0';
|
||||
}
|
||||
} else if (key == '\033') {
|
||||
strcpy(buf,"esc");
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
local char *button_style(int style)
|
||||
{
|
||||
switch (style) {
|
||||
case MBUTTON_MAIN:
|
||||
return "main";
|
||||
case MBUTTON_GM_HALF:
|
||||
return "gm-half";
|
||||
case MBUTTON_132:
|
||||
return "132";
|
||||
case MBUTTON_GM_FULL:
|
||||
return "gm-full";
|
||||
case MBUTTON_GEM_ROUND:
|
||||
return "gem-round";
|
||||
case MBUTTON_GEM_SQUARE:
|
||||
return "gem-square";
|
||||
case MBUTTON_UP_ARROW:
|
||||
return "up-arrow";
|
||||
case MBUTTON_DOWN_ARROW:
|
||||
return "down-arrow";
|
||||
case MBUTTON_LEFT_ARROW:
|
||||
return "left-arrow";
|
||||
case MBUTTON_RIGHT_ARROW:
|
||||
return "right-arrow";
|
||||
case MBUTTON_S_KNOB:
|
||||
return "s-knob";
|
||||
case MBUTTON_S_VCONT:
|
||||
return "s-vcont";
|
||||
case MBUTTON_S_HCONT:
|
||||
return "s-hcont";
|
||||
case MBUTTON_PULLDOWN:
|
||||
return "pulldown";
|
||||
case MBUTTON_VTHIN:
|
||||
return "vthin";
|
||||
case MBUTTON_FOLDER:
|
||||
return "folder";
|
||||
}
|
||||
fprintf(stderr,"button_style not found: %d\n", style);
|
||||
return "";
|
||||
}
|
||||
|
||||
global void SaveMenus(FILE* file)
|
||||
{
|
||||
Menu *menu;
|
||||
int i, j, n;
|
||||
int OffsetX, OffsetY;
|
||||
char hotkey[10];
|
||||
char func[10];
|
||||
char func2[10];
|
||||
char func3[10];
|
||||
char initfunc[40];
|
||||
char exitfunc[40];
|
||||
char netaction[40];
|
||||
|
||||
OffsetX = (VideoWidth - 640) / 2;
|
||||
OffsetY = (VideoHeight - 480) / 2;
|
||||
|
||||
fprintf(file,"\n;;; -----------------------------------------\n");
|
||||
fprintf(file,";;; $Id$\n\n");
|
||||
|
||||
for (i=0; i<sizeof(menu_names)/sizeof(*menu_names); ++i) {
|
||||
menu = FindMenu(menu_names[i]);
|
||||
if (!menu) {
|
||||
abort();
|
||||
}
|
||||
fprintf(file,";;\n;; %s\n;;\n", menu_names[i]);
|
||||
if (menu->netaction) {
|
||||
sprintf(func,"%p",menu->netaction);
|
||||
sprintf(netaction," 'netaction '%s",(char*)hash_find(MenuFuncHash2,func));
|
||||
} else {
|
||||
netaction[0] = '\0';
|
||||
}
|
||||
fprintf(file,"(define-menu 'name '%s 'geometry '(%d %d %d %d)\n"
|
||||
" 'image '%s 'default '%d%s)\n",
|
||||
menu_names[i],
|
||||
menu->x - OffsetX, menu->y - OffsetY,
|
||||
menu->xsize, menu->ysize,
|
||||
images[menu->image],
|
||||
menu->defsel,
|
||||
netaction);
|
||||
for (j=0; j<menu->nitems; ++j) {
|
||||
if (menu->items[j].initfunc) {
|
||||
sprintf(func,"%p",menu->items[j].initfunc);
|
||||
sprintf(initfunc," 'init '%s",(char*)hash_find(MenuFuncHash2,func));
|
||||
} else {
|
||||
initfunc[0] = '\0';
|
||||
}
|
||||
if (menu->items[j].exitfunc) {
|
||||
sprintf(func,"%p",menu->items[j].exitfunc);
|
||||
sprintf(exitfunc," 'exit '%s",(char*)hash_find(MenuFuncHash2,func));
|
||||
} else {
|
||||
exitfunc[0] = '\0';
|
||||
}
|
||||
|
||||
fprintf(file,"(define-menu-item 'pos (list %d %d) 'font '%s %s%s%s\n",
|
||||
menu->items[j].xofs, menu->items[j].yofs,
|
||||
font_names[menu->items[j].font],
|
||||
menu_flags[menu->items[j].flags],
|
||||
initfunc,
|
||||
exitfunc);
|
||||
switch (menu->items[j].mitype) {
|
||||
case MI_TYPE_TEXT:
|
||||
fprintf(file," 'text '(\"%s\" %s)\n",
|
||||
menu->items[j].d.text.text ? (char*)menu->items[j].d.text.text : "null",
|
||||
text_flags[menu->items[j].d.text.tflags]);
|
||||
break;
|
||||
case MI_TYPE_BUTTON:
|
||||
sprintf(func,"%p",menu->items[j].d.button.handler);
|
||||
fprintf(file," 'button '(size (%d %d)\n"
|
||||
" caption \"%s\"\n"
|
||||
" hotkey \"%s\"\n"
|
||||
" func %s\n"
|
||||
" style %s)\n",
|
||||
menu->items[j].d.button.xsize,
|
||||
menu->items[j].d.button.ysize,
|
||||
menu->items[j].d.button.text ? menu->items[j].d.button.text : "null",
|
||||
hotkey2str(menu->items[j].d.button.hotkey,hotkey),
|
||||
(char*)hash_find(MenuFuncHash2,func),
|
||||
button_style(menu->items[j].d.button.button));
|
||||
break;
|
||||
case MI_TYPE_PULLDOWN:
|
||||
sprintf(func,"%p",menu->items[j].d.pulldown.action);
|
||||
fprintf(file," 'pulldown '(size (%d %d)\n"
|
||||
" style %s\n"
|
||||
" func %s\n",
|
||||
menu->items[j].d.pulldown.xsize,
|
||||
menu->items[j].d.pulldown.ysize,
|
||||
button_style(menu->items[j].d.pulldown.button),
|
||||
(char*)hash_find(MenuFuncHash2,func));
|
||||
fprintf(file," options (");
|
||||
for (n=0; n<menu->items[j].d.pulldown.noptions; ++n) {
|
||||
fprintf(file,"\"%s\" ", menu->items[j].d.pulldown.options[n]);
|
||||
}
|
||||
|
||||
fprintf(file,")\n"
|
||||
" default %d\n"
|
||||
" current %d)\n",
|
||||
menu->items[j].d.pulldown.defopt,
|
||||
menu->items[j].d.pulldown.curopt);
|
||||
break;
|
||||
case MI_TYPE_LISTBOX:
|
||||
sprintf(func,"%p",menu->items[j].d.listbox.action);
|
||||
sprintf(func2,"%p",menu->items[j].d.listbox.retrieveopt);
|
||||
sprintf(func3,"%p",menu->items[j].d.listbox.handler);
|
||||
fprintf(file," 'listbox '(size (%d %d)\n"
|
||||
" style %s\n"
|
||||
" func %s\n"
|
||||
" retopt %s\n"
|
||||
" handler %s\n"
|
||||
" nlines %d)\n",
|
||||
menu->items[j].d.listbox.xsize,
|
||||
menu->items[j].d.listbox.ysize,
|
||||
button_style(menu->items[j].d.listbox.button),
|
||||
(char*)hash_find(MenuFuncHash2,func),
|
||||
(char*)hash_find(MenuFuncHash2,func2),
|
||||
(char*)hash_find(MenuFuncHash2,func3),
|
||||
menu->items[j].d.listbox.nlines);
|
||||
break;
|
||||
case MI_TYPE_VSLIDER:
|
||||
sprintf(func,"%p",menu->items[j].d.vslider.action);
|
||||
sprintf(func2,"%p",menu->items[j].d.vslider.handler);
|
||||
fprintf(file," 'vslider '(size (%d %d)\n"
|
||||
" func %s\n"
|
||||
" handler %s)\n",
|
||||
menu->items[j].d.vslider.xsize,
|
||||
menu->items[j].d.vslider.ysize,
|
||||
(char*)hash_find(MenuFuncHash2,func),
|
||||
(char*)hash_find(MenuFuncHash2,func2));
|
||||
break;
|
||||
case MI_TYPE_DRAWFUNC:
|
||||
sprintf(func,"%p",menu->items[j].d.drawfunc.draw);
|
||||
fprintf(file," 'drawfunc '%s\n",
|
||||
(char*)hash_find(MenuFuncHash2,func));
|
||||
break;
|
||||
case MI_TYPE_INPUT:
|
||||
sprintf(func,"%p",menu->items[j].d.input.action);
|
||||
fprintf(file," 'input '(size (%d %d)\n"
|
||||
" func %s\n"
|
||||
" style %s)\n",
|
||||
menu->items[j].d.input.xsize,
|
||||
menu->items[j].d.input.ysize,
|
||||
(char*)hash_find(MenuFuncHash2,func),
|
||||
button_style(menu->items[j].d.input.button));
|
||||
break;
|
||||
case MI_TYPE_GEM:
|
||||
sprintf(func,"%p",menu->items[j].d.gem.action);
|
||||
fprintf(file," 'gem '(size (%d %d)\n"
|
||||
" state %s\n"
|
||||
" func %s\n"
|
||||
" style %s)\n",
|
||||
menu->items[j].d.gem.xsize,
|
||||
menu->items[j].d.gem.ysize,
|
||||
gem_state[menu->items[j].d.gem.state],
|
||||
(char*)hash_find(MenuFuncHash2,func),
|
||||
button_style(menu->items[j].d.gem.button));
|
||||
break;
|
||||
case MI_TYPE_HSLIDER:
|
||||
sprintf(func,"%p",menu->items[j].d.hslider.action);
|
||||
sprintf(func2,"%p",menu->items[j].d.hslider.handler);
|
||||
fprintf(file," 'hslider '(size (%d %d)\n"
|
||||
" func %s\n"
|
||||
" handler %s)\n",
|
||||
menu->items[j].d.hslider.xsize,
|
||||
menu->items[j].d.hslider.ysize,
|
||||
(char*)hash_find(MenuFuncHash2,func),
|
||||
(char*)hash_find(MenuFuncHash2,func2));
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
fprintf(file," 'menu '%s)\n",menu_names[i]);
|
||||
}
|
||||
fprintf(file,"\n\n");
|
||||
}
|
||||
}
|
||||
#endif /// SAVE_MENU_CCL
|
||||
|
||||
//@}
|
||||
|
|
Loading…
Add table
Reference in a new issue