Rewrote menu-panel
This commit is contained in:
parent
cbd356adff
commit
587458cdff
5 changed files with 144 additions and 113 deletions
|
@ -905,11 +905,11 @@ global void EditorUpdateDisplay(void)
|
|||
//
|
||||
// Menu button
|
||||
//
|
||||
if (TheUI.MenuButtonGraphic.Graphic) {
|
||||
VideoDrawSub(TheUI.MenuButtonGraphic.Graphic, 0, 0,
|
||||
TheUI.MenuButtonGraphic.Graphic->Width,
|
||||
TheUI.MenuButtonGraphic.Graphic->Height,
|
||||
TheUI.MenuButtonGraphicX, TheUI.MenuButtonGraphicY);
|
||||
if (TheUI.MenuPanel.Graphic) {
|
||||
VideoDrawSub(TheUI.MenuPanel.Graphic, 0, 0,
|
||||
TheUI.MenuPanel.Graphic->Width,
|
||||
TheUI.MenuPanel.Graphic->Height,
|
||||
TheUI.MenuPanelX, TheUI.MenuPanelY);
|
||||
}
|
||||
DrawMenuButton(TheUI.MenuButton.Button,
|
||||
(ButtonAreaUnderCursor == ButtonAreaMenu
|
||||
|
|
|
@ -255,10 +255,10 @@ typedef struct _ui_ {
|
|||
// Map* attributes of Viewport are unused here:
|
||||
Viewport MapArea; /// geometry of the whole map area
|
||||
|
||||
// The menu button graphic
|
||||
GraphicConfig MenuButtonGraphic; /// menu button background
|
||||
int MenuButtonGraphicX; /// menu button screen X position
|
||||
int MenuButtonGraphicY; /// menu button screen Y position
|
||||
// The menu panel
|
||||
GraphicConfig MenuPanel; /// menu panel background
|
||||
int MenuPanelX; /// menu panel screen X position
|
||||
int MenuPanelY; /// menu panel screen Y position
|
||||
|
||||
/// Menu buttons
|
||||
struct {
|
||||
|
|
|
@ -266,11 +266,11 @@ global void DebugTestDisplay(void)
|
|||
*/
|
||||
local void DrawMenuButtonArea(void)
|
||||
{
|
||||
if (TheUI.MenuButtonGraphic.Graphic) {
|
||||
VideoDrawSub(TheUI.MenuButtonGraphic.Graphic, 0, 0,
|
||||
TheUI.MenuButtonGraphic.Graphic->Width,
|
||||
TheUI.MenuButtonGraphic.Graphic->Height,
|
||||
TheUI.MenuButtonGraphicX, TheUI.MenuButtonGraphicY);
|
||||
if (TheUI.MenuPanel.Graphic) {
|
||||
VideoDrawSub(TheUI.MenuPanel.Graphic, 0, 0,
|
||||
TheUI.MenuPanel.Graphic->Width,
|
||||
TheUI.MenuPanel.Graphic->Height,
|
||||
TheUI.MenuPanelX, TheUI.MenuPanelY);
|
||||
}
|
||||
if (NetworkFildes == (Socket)-1) {
|
||||
if (TheUI.MenuButton.X != -1) {
|
||||
|
|
|
@ -1072,9 +1072,9 @@ local SCM CclDefineUI(SCM list)
|
|||
ui->ButtonPanelX = -1;
|
||||
ui->ButtonPanelY = -1;
|
||||
|
||||
ui->MenuButtonGraphic.File = NULL;
|
||||
ui->MenuButtonGraphicX = -1;
|
||||
ui->MenuButtonGraphicY = -1;
|
||||
ui->MenuPanel.File = NULL;
|
||||
ui->MenuPanelX = -1;
|
||||
ui->MenuPanelY = -1;
|
||||
|
||||
ui->MinimapPanel.File = NULL;
|
||||
ui->MinimapPanelX = -1;
|
||||
|
@ -1350,9 +1350,124 @@ local SCM CclDefineUI(SCM list)
|
|||
} else if (gh_eq_p(value, gh_symbol2scm("menu-panel"))) {
|
||||
sublist = gh_car(list);
|
||||
list = gh_cdr(list);
|
||||
ui->MenuButtonGraphic.File = SCM_PopNewStr(&sublist);
|
||||
ui->MenuButtonGraphicX = SCM_PopInt(&sublist);
|
||||
ui->MenuButtonGraphicY = SCM_PopInt(&sublist);
|
||||
while (!gh_null_p(sublist)) {
|
||||
value = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
if (gh_eq_p(value, gh_symbol2scm("panel"))) {
|
||||
SCM slist;
|
||||
|
||||
slist = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
while (!gh_null_p(slist)) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
if (gh_eq_p(value, gh_symbol2scm("file"))) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
ui->MenuPanel.File = gh_scm2newstr(value, NULL);
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("pos"))) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
ui->MenuPanelX = gh_scm2int(gh_car(value));
|
||||
ui->MenuPanelY = gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else {
|
||||
errl("Unsupported tag", value);
|
||||
}
|
||||
}
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("menu-button"))) {
|
||||
SCM slist;
|
||||
|
||||
slist = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
while (!gh_null_p(slist)) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
if (gh_eq_p(value, gh_symbol2scm("pos"))) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
ui->MenuButton.X = gh_scm2int(gh_car(value));
|
||||
ui->MenuButton.Y = gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("size"))) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
ui->MenuButton.Width = gh_scm2int(gh_car(value));
|
||||
ui->MenuButton.Height = gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("caption"))) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
ui->MenuButton.Text = gh_scm2newstr(value, NULL);
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("style"))) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
ui->MenuButton.Button = scm2buttonid(value);
|
||||
} else {
|
||||
errl("Unsupported tag", value);
|
||||
}
|
||||
}
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("network-menu-button"))) {
|
||||
SCM slist;
|
||||
|
||||
slist = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
while (!gh_null_p(slist)) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
if (gh_eq_p(value, gh_symbol2scm("pos"))) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
ui->NetworkMenuButton.X = gh_scm2int(gh_car(value));
|
||||
ui->NetworkMenuButton.Y = gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("size"))) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
ui->NetworkMenuButton.Width = gh_scm2int(gh_car(value));
|
||||
ui->NetworkMenuButton.Height = gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("caption"))) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
ui->NetworkMenuButton.Text = gh_scm2newstr(value, NULL);
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("style"))) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
ui->NetworkMenuButton.Button = scm2buttonid(value);
|
||||
} else {
|
||||
errl("Unsupported tag", value);
|
||||
}
|
||||
}
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("network-diplomacy-button"))) {
|
||||
SCM slist;
|
||||
|
||||
slist = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
while (!gh_null_p(slist)) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
if (gh_eq_p(value, gh_symbol2scm("pos"))) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
ui->NetworkDiplomacyButton.X = gh_scm2int(gh_car(value));
|
||||
ui->NetworkDiplomacyButton.Y = gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("size"))) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
ui->NetworkDiplomacyButton.Width = gh_scm2int(gh_car(value));
|
||||
ui->NetworkDiplomacyButton.Height = gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("caption"))) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
ui->NetworkDiplomacyButton.Text = gh_scm2newstr(value, NULL);
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("style"))) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
ui->NetworkDiplomacyButton.Button = scm2buttonid(value);
|
||||
} else {
|
||||
errl("Unsupported tag", value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
errl("Unsupported tag", value);
|
||||
}
|
||||
}
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("minimap"))) {
|
||||
sublist = gh_car(list);
|
||||
list = gh_cdr(list);
|
||||
|
@ -1412,90 +1527,6 @@ local SCM CclDefineUI(SCM list)
|
|||
errl("Unsupported tag", value);
|
||||
}
|
||||
}
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("menu-button"))) {
|
||||
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("pos"))) {
|
||||
value = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
ui->MenuButton.X = gh_scm2int(gh_car(value));
|
||||
ui->MenuButton.Y = gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("size"))) {
|
||||
value = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
ui->MenuButton.Width = gh_scm2int(gh_car(value));
|
||||
ui->MenuButton.Height = gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("caption"))) {
|
||||
value = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
ui->MenuButton.Text = gh_scm2newstr(value, NULL);
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("style"))) {
|
||||
value = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
ui->MenuButton.Button = scm2buttonid(value);
|
||||
} else {
|
||||
errl("Unsupported tag", value);
|
||||
}
|
||||
}
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("network-menu-button"))) {
|
||||
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("pos"))) {
|
||||
value = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
ui->NetworkMenuButton.X = gh_scm2int(gh_car(value));
|
||||
ui->NetworkMenuButton.Y = gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("size"))) {
|
||||
value = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
ui->NetworkMenuButton.Width = gh_scm2int(gh_car(value));
|
||||
ui->NetworkMenuButton.Height = gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("caption"))) {
|
||||
value = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
ui->NetworkMenuButton.Text = gh_scm2newstr(value, NULL);
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("style"))) {
|
||||
value = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
ui->NetworkMenuButton.Button = scm2buttonid(value);
|
||||
} else {
|
||||
errl("Unsupported tag", value);
|
||||
}
|
||||
}
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("network-diplomacy-button"))) {
|
||||
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("pos"))) {
|
||||
value = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
ui->NetworkDiplomacyButton.X = gh_scm2int(gh_car(value));
|
||||
ui->NetworkDiplomacyButton.Y = gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("size"))) {
|
||||
value = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
ui->NetworkDiplomacyButton.Width = gh_scm2int(gh_car(value));
|
||||
ui->NetworkDiplomacyButton.Height = gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("caption"))) {
|
||||
value = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
ui->NetworkDiplomacyButton.Text = gh_scm2newstr(value, NULL);
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("style"))) {
|
||||
value = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
ui->NetworkDiplomacyButton.Button = scm2buttonid(value);
|
||||
} else {
|
||||
errl("Unsupported tag", value);
|
||||
}
|
||||
}
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("cursors"))) {
|
||||
sublist = gh_car(list);
|
||||
list = gh_cdr(list);
|
||||
|
|
|
@ -239,12 +239,12 @@ global void LoadUserInterface(void)
|
|||
TheUI.ButtonPanel.Graphic->Height);
|
||||
#endif
|
||||
}
|
||||
if (TheUI.MenuButtonGraphic.File) {
|
||||
TheUI.MenuButtonGraphic.Graphic = LoadGraphic(TheUI.MenuButtonGraphic.File);
|
||||
if (TheUI.MenuPanel.File) {
|
||||
TheUI.MenuPanel.Graphic = LoadGraphic(TheUI.MenuPanel.File);
|
||||
#ifdef USE_OPENGL
|
||||
MakeTexture(TheUI.MenuButtonGraphic.Graphic,
|
||||
TheUI.MenuButtonGraphic.Graphic->Width,
|
||||
TheUI.MenuButtonGraphic.Graphic->Height);
|
||||
MakeTexture(TheUI.MenuPanel.Graphic,
|
||||
TheUI.MenuPanel.Graphic->Width,
|
||||
TheUI.MenuPanel.Graphic->Height);
|
||||
#endif
|
||||
}
|
||||
if (TheUI.MinimapPanel.File) {
|
||||
|
@ -512,8 +512,8 @@ local void SaveUi(CLFile* file, const UI* ui)
|
|||
|
||||
CLprintf(file, " ; Menu button background\n");
|
||||
CLprintf(file, " 'menu-panel (list \"%s\" %d %d)\n",
|
||||
ui->MenuButtonGraphic.File, ui->MenuButtonGraphicX,
|
||||
ui->MenuButtonGraphicY);
|
||||
ui->MenuPanel.File, ui->MenuPanelX,
|
||||
ui->MenuPanelY);
|
||||
|
||||
CLprintf(file, " 'minimap (list\n");
|
||||
CLprintf(file, " 'file \"%s\"\n", ui->MinimapPanel.File);
|
||||
|
@ -706,7 +706,7 @@ global void CleanUI(UI* ui)
|
|||
free(ui->ButtonPanel.File);
|
||||
|
||||
// Menu Button
|
||||
free(ui->MenuButtonGraphic.File);
|
||||
free(ui->MenuPanel.File);
|
||||
|
||||
// Minimap
|
||||
free(ui->MinimapPanel.File);
|
||||
|
@ -776,7 +776,7 @@ global void CleanUserInterface(void)
|
|||
|
||||
VideoSaveFree(TheUI.InfoPanel.Graphic);
|
||||
VideoSaveFree(TheUI.ButtonPanel.Graphic);
|
||||
VideoSaveFree(TheUI.MenuButtonGraphic.Graphic);
|
||||
VideoSaveFree(TheUI.MenuPanel.Graphic);
|
||||
VideoSaveFree(TheUI.MinimapPanel.Graphic);
|
||||
VideoSaveFree(TheUI.StatusLine.Graphic);
|
||||
|
||||
|
|
Loading…
Reference in a new issue