Moved button-buttons inside button-panel
This commit is contained in:
parent
aaeadc2e97
commit
cbd356adff
3 changed files with 75 additions and 58 deletions
|
@ -241,6 +241,8 @@ typedef struct _ui_ {
|
|||
|
||||
// Button panel
|
||||
GraphicConfig ButtonPanel; /// Button panel background
|
||||
Button* ButtonButtons; /// Button panel buttons
|
||||
int NumButtonButtons; /// Number of button panel buttons
|
||||
int ButtonPanelX; /// Button panel screen X position
|
||||
int ButtonPanelY; /// Button panel screen Y position
|
||||
|
||||
|
@ -289,9 +291,6 @@ typedef struct _ui_ {
|
|||
int StatusLineTextY; /// status line screen text Y position
|
||||
int StatusLineFont; /// Status line font
|
||||
|
||||
Button* ButtonButtons; /// Button panel buttons
|
||||
int NumButtonButtons; /// Number of button panel buttons
|
||||
|
||||
// Offsets for 640x480 center used by menus
|
||||
int Offset640X; /// Offset for 640x480 X position
|
||||
int Offset480Y; /// Offset for 640x480 Y position
|
||||
|
|
|
@ -694,9 +694,9 @@ local void CclParseInfoText(SCM list, InfoText* text)
|
|||
}
|
||||
|
||||
/**
|
||||
** Parse info panel icon
|
||||
** Parse icon
|
||||
*/
|
||||
local void CclParseInfoIcon(SCM list, Button* icon)
|
||||
local void CclParseIcon(SCM list, Button* icon)
|
||||
{
|
||||
SCM value;
|
||||
|
||||
|
@ -749,7 +749,7 @@ local void CclParseSelected(SCM list, UI* ui)
|
|||
value = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
ui->SingleSelectedButton = calloc(1, sizeof(Button));
|
||||
CclParseInfoIcon(value, ui->SingleSelectedButton);
|
||||
CclParseIcon(value, ui->SingleSelectedButton);
|
||||
} else {
|
||||
errl("Unsupported tag", value);
|
||||
}
|
||||
|
@ -781,7 +781,7 @@ local void CclParseSelected(SCM list, UI* ui)
|
|||
while (!gh_null_p(slist)) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
CclParseInfoIcon(value, &ui->SelectedButtons[i++]);
|
||||
CclParseIcon(value, &ui->SelectedButtons[i++]);
|
||||
}
|
||||
} else {
|
||||
errl("Unsupported tag", value);
|
||||
|
@ -823,7 +823,7 @@ local void CclParseTraining(SCM list, UI* ui)
|
|||
value = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
ui->SingleTrainingButton = calloc(1, sizeof(Button));
|
||||
CclParseInfoIcon(value, ui->SingleTrainingButton);
|
||||
CclParseIcon(value, ui->SingleTrainingButton);
|
||||
} else {
|
||||
errl("Unsupported tag", value);
|
||||
}
|
||||
|
@ -855,7 +855,7 @@ local void CclParseTraining(SCM list, UI* ui)
|
|||
while (!gh_null_p(slist)) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
CclParseInfoIcon(value, &ui->TrainingButtons[i++]);
|
||||
CclParseIcon(value, &ui->TrainingButtons[i++]);
|
||||
}
|
||||
} else {
|
||||
errl("Unsupported tag", value);
|
||||
|
@ -890,7 +890,7 @@ local void CclParseUpgrading(SCM list, UI* ui)
|
|||
value = gh_car(list);
|
||||
list = gh_cdr(list);
|
||||
ui->UpgradingButton = calloc(1, sizeof(Button));
|
||||
CclParseInfoIcon(value, ui->UpgradingButton);
|
||||
CclParseIcon(value, ui->UpgradingButton);
|
||||
} else {
|
||||
errl("Unsupported tag", value);
|
||||
}
|
||||
|
@ -920,7 +920,7 @@ local void CclParseResearching(SCM list, UI* ui)
|
|||
value = gh_car(list);
|
||||
list = gh_cdr(list);
|
||||
ui->ResearchingButton = calloc(1, sizeof(Button));
|
||||
CclParseInfoIcon(value, ui->ResearchingButton);
|
||||
CclParseIcon(value, ui->ResearchingButton);
|
||||
} else {
|
||||
errl("Unsupported tag", value);
|
||||
}
|
||||
|
@ -959,7 +959,7 @@ local void CclParseTransporting(SCM list, UI* ui)
|
|||
while (!gh_null_p(sublist)) {
|
||||
value = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
CclParseInfoIcon(value, &ui->TransportingButtons[i++]);
|
||||
CclParseIcon(value, &ui->TransportingButtons[i++]);
|
||||
}
|
||||
} else {
|
||||
errl("Unsupported tag", value);
|
||||
|
@ -967,6 +967,24 @@ local void CclParseTransporting(SCM list, UI* ui)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Parse button panel icons section
|
||||
*/
|
||||
local void CclParseButtonIcons(SCM list, UI* ui)
|
||||
{
|
||||
SCM value;
|
||||
int i;
|
||||
|
||||
ui->NumButtonButtons = gh_length(list);
|
||||
ui->ButtonButtons = calloc(ui->NumButtonButtons, sizeof(Button));
|
||||
i = 0;
|
||||
while (!gh_null_p(list)) {
|
||||
value = gh_car(list);
|
||||
list = gh_cdr(list);
|
||||
CclParseIcon(value, &ui->ButtonButtons[i++]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Define the look+feel of the user interface.
|
||||
**
|
||||
|
@ -1270,9 +1288,38 @@ local SCM CclDefineUI(SCM list)
|
|||
} else if (gh_eq_p(value, gh_symbol2scm("button-panel"))) {
|
||||
sublist = gh_car(list);
|
||||
list = gh_cdr(list);
|
||||
ui->ButtonPanel.File = SCM_PopNewStr(&sublist);
|
||||
ui->ButtonPanelX = SCM_PopInt(&sublist);
|
||||
ui->ButtonPanelY = 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->ButtonPanel.File = gh_scm2newstr(value, NULL);
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("pos"))) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
ui->ButtonPanelX = gh_scm2int(gh_car(value));
|
||||
ui->ButtonPanelY = gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else {
|
||||
errl("Unsupported tag", value);
|
||||
}
|
||||
}
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("icons"))) {
|
||||
value = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
CclParseButtonIcons(value, ui);
|
||||
} else {
|
||||
errl("Unsupported tag", value);
|
||||
}
|
||||
}
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("map-area"))) {
|
||||
int w;
|
||||
int h;
|
||||
|
@ -1449,38 +1496,6 @@ local SCM CclDefineUI(SCM list)
|
|||
errl("Unsupported tag", value);
|
||||
}
|
||||
}
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("button-buttons"))) {
|
||||
SCM slist;
|
||||
SCM sslist;
|
||||
Button* b;
|
||||
|
||||
slist = gh_car(list);
|
||||
list = gh_cdr(list);
|
||||
while (!gh_null_p(slist)) {
|
||||
sslist = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
ui->NumButtonButtons++;
|
||||
ui->ButtonButtons = realloc(ui->ButtonButtons,
|
||||
ui->NumButtonButtons * sizeof(*ui->ButtonButtons));
|
||||
b = &ui->ButtonButtons[ui->NumButtonButtons - 1];
|
||||
while (!gh_null_p(sslist)) {
|
||||
value = gh_car(sslist);
|
||||
sslist = gh_cdr(sslist);
|
||||
if (gh_eq_p(value, gh_symbol2scm("pos"))) {
|
||||
value = gh_car(sslist);
|
||||
sslist = gh_cdr(sslist);
|
||||
b->X = gh_scm2int(gh_car(value));
|
||||
b->Y = gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("size"))) {
|
||||
value = gh_car(sslist);
|
||||
sslist = gh_cdr(sslist);
|
||||
b->Width = gh_scm2int(gh_car(value));
|
||||
b->Height = gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else {
|
||||
errl("Unsupported tag", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("cursors"))) {
|
||||
sublist = gh_car(list);
|
||||
list = gh_cdr(list);
|
||||
|
|
|
@ -488,8 +488,19 @@ local void SaveUi(CLFile* file, const UI* ui)
|
|||
|
||||
CLprintf(file, ")\n"); // 'info-panel
|
||||
|
||||
CLprintf(file, "\n 'button-panel (list \"%s\" %d %d)",
|
||||
ui->ButtonPanel.File, ui->ButtonPanelX, ui->ButtonPanelY);
|
||||
CLprintf(file, "\n 'button-panel (list\n");
|
||||
CLprintf(file, "\n 'panel (list\n");
|
||||
CLprintf(file, "\n 'file \"%s\"\n", ui->ButtonPanel.File);
|
||||
CLprintf(file, "\n 'pos '(%d %d))",
|
||||
ui->ButtonPanelX, ui->ButtonPanelY);
|
||||
CLprintf(file, "\n 'icons (list\n");
|
||||
for (i = 0; i < ui->NumButtonButtons; ++i) {
|
||||
CLprintf(file, "\n (list 'pos '(%d %d) 'size '(%d %d))",
|
||||
ui->ButtonButtons[i].X, ui->ButtonButtons[i].Y,
|
||||
ui->ButtonButtons[i].Width, ui->ButtonButtons[i].Height);
|
||||
}
|
||||
CLprintf(file, ")");
|
||||
CLprintf(file, ")\n");
|
||||
|
||||
CLprintf(file, "\n 'map-area (list");
|
||||
CLprintf(file, "\n 'pos '(%3d %3d)",
|
||||
|
@ -557,15 +568,7 @@ local void SaveUi(CLFile* file, const UI* ui)
|
|||
MenuButtonStyle(ui->NetworkDiplomacyButton.Button));
|
||||
CLprintf(file, ")\n");
|
||||
|
||||
CLprintf(file, "\n 'button-buttons '(");
|
||||
for (i = 0; i < ui->NumButtonButtons; ++i) {
|
||||
CLprintf(file, "\n (pos (%3d %3d) size (%d %d))",
|
||||
ui->ButtonButtons[i].X, ui->ButtonButtons[i].Y,
|
||||
ui->ButtonButtons[i].Width, ui->ButtonButtons[i].Height);
|
||||
}
|
||||
CLprintf(file, ")");
|
||||
|
||||
CLprintf(file, "\n\n 'cursors '(");
|
||||
CLprintf(file, "\n 'cursors '(");
|
||||
CLprintf(file, "\n point %s", ui->Point.Name);
|
||||
CLprintf(file, "\n glass %s", ui->Glass.Name);
|
||||
CLprintf(file, "\n cross %s", ui->Cross.Name);
|
||||
|
|
Loading…
Reference in a new issue