summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/screen/screen_choiceArena.c94
1 files changed, 74 insertions, 20 deletions
diff --git a/src/screen/screen_choiceArena.c b/src/screen/screen_choiceArena.c
index 7bc6ce4..a1b725b 100644
--- a/src/screen/screen_choiceArena.c
+++ b/src/screen/screen_choiceArena.c
@@ -28,8 +28,21 @@ static widget_t *image_backgorund;
static widget_t *button_play;
static widget_t *button_back;
-
-static list_t *listWidgetButtonimage;
+static widget_t *button_next;
+static widget_t *button_prev;
+
+//static list_t *listWidgetButtonimage; // map buttons to be showed and handled - well, show_map_buttons is used instead
+static list_t *listAllWidgetButtonimage; // all map buttons
+static int handled_map_button_group; // 0 - first 6 buttons, 1 - second 6 buttons, ....
+static void activateHandledMapButtonGroup();
+static struct show_map_buttons {
+ // geez, it'd be nicer to used two lists
+ // but how the hell is list_t supposed to be used?! :-)
+ int min; // see activateHandledMapButtonGroup for desc
+ int max; //
+ int next; // 0: max is last item+1 in listAllWidgetButtonimage, otherwise 1
+ int prev; // 0: min is first item in listAllWidgetButtonimage, otherwise 1
+} show_map_buttons = { 0,0,0,0 } ;
static arenaFile_t *currentArena;
static void hotkey_escape()
@@ -54,12 +67,11 @@ void drawScreenChoiceArena()
drawWidgetButton(button_play);
drawWidgetButton(button_back);
+ if (show_map_buttons.next) { drawWidgetButton(button_next); }
+ if (show_map_buttons.prev) { drawWidgetButton(button_prev); }
- for (i = 0; i < listWidgetButtonimage->count; i++) {
- widget_t *this;
-
- this = (widget_t *) listWidgetButtonimage->list[i];
- drawWidgetButtonimage(this);
+ for (i = show_map_buttons.min ; i < show_map_buttons.max; i++) {
+ drawWidgetButtonimage((widget_t*)listAllWidgetButtonimage->list[i]);
}
}
@@ -69,12 +81,11 @@ void eventScreenChoiceArena()
eventWidgetButton(button_play);
eventWidgetButton(button_back);
+ if (show_map_buttons.next) { eventWidgetButton(button_next); }
+ if (show_map_buttons.prev) { eventWidgetButton(button_prev); }
- for (i = 0; i < listWidgetButtonimage->count; i++) {
- widget_t *this;
-
- this = (widget_t *) listWidgetButtonimage->list[i];
- eventWidgetButtonimage(this);
+ for (i = show_map_buttons.min ; i < show_map_buttons.max; i++) {
+ eventWidgetButtonimage((widget_t*)listAllWidgetButtonimage->list[i]);
}
}
@@ -90,10 +101,10 @@ static void eventWidgetButtonImage(void *p)
buttonimage = (widget_t *) (p);
- for (i = 0; i < listWidgetButtonimage->count; i++) {
+ for (i = show_map_buttons.min; i < show_map_buttons.max; i++) {
widget_t *this;
- this = (widget_t *) (listWidgetButtonimage->list[i]);
+ this = (widget_t *) (listAllWidgetButtonimage->list[i]);
if (buttonimage == this) {
setWidgetButtonimageActive(this, TRUE);
@@ -118,7 +129,7 @@ void setChoiceArena(arenaFile_t * arenaFile)
currentArena = arenaFile;
if (id >= 0) {
- widget_buttonimage = (widget_t *) listWidgetButtonimage->list[id];
+ widget_buttonimage = (widget_t *) listAllWidgetButtonimage->list[id];
setWidgetButtonimageActive(widget_buttonimage, TRUE);
}
}
@@ -136,6 +147,36 @@ static void eventWidget(void *p)
if (button == button_back) {
setScreen("gameType");
}
+ if (button == button_next) {
+ if (show_map_buttons.next) {
+ handled_map_button_group++;
+ activateHandledMapButtonGroup();
+ }
+ }
+ if (button == button_prev) {
+ if (show_map_buttons.prev) {
+ handled_map_button_group--;
+ activateHandledMapButtonGroup();
+ }
+ }
+}
+
+// groups of 6 map buttons to be shown and handled
+// the group is set by static global variable handled_map_button_group
+// sets static global show_map_buttons.min to index of first button to be drawn in listAllButtonimage
+// and show_map_buttons.max to index of last button to be drawn+1 in listAllButtonimage
+static void activateHandledMapButtonGroup(void) {
+ int min = handled_map_button_group * 6;
+ min = min < 0 ? 0 : min;
+ min = min <= getArenaCount() ? min : getArenaCount();
+ int max = min+6 <= getArenaCount() ? min+6 : getArenaCount();
+
+ if (min) { show_map_buttons.prev = 1; }
+ else { show_map_buttons.prev = 0; }
+ if (max < getArenaCount()) { show_map_buttons.next = 1; }
+ else { show_map_buttons.next = 0; }
+ show_map_buttons.min = min;
+ show_map_buttons.max = max;
}
void initScreenChoiceArena()
@@ -149,7 +190,10 @@ void initScreenChoiceArena()
button_back = newWidgetButton(_("back"), 100, WINDOW_SIZE_Y - 100, eventWidget);
button_play = newWidgetButton(_("play"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget);
- listWidgetButtonimage = newList();
+ button_prev = newWidgetButton(_("prev maps"), 250, WINDOW_SIZE_Y - 100, eventWidget);
+ button_next = newWidgetButton(_("next maps"), WINDOW_SIZE_X-350, WINDOW_SIZE_Y - 100, eventWidget);
+
+ listAllWidgetButtonimage = newList();
currentArena = NULL;
for (i = 0; i < getArenaCount(); i++) {
@@ -162,8 +206,13 @@ void initScreenChoiceArena()
image = loadImageFromArena(arenaFile, getArenaImage(arenaFile),
IMAGE_GROUP_BASE, "none", IMAGE_NO_ALPHA);
- x = 100 + 200 * (i - 3 * (i / 3));
- y = 150 + 200 * (i / 3);
+ // only 6 map buttons can be shown at once;
+ // set buttons' positions in each group to the corresponding values
+ // handled_map_button_group and activateHandledMapButtonGroup is used
+ // to choose group to be shown and handled
+ int pos = i % 6 ;
+ x = 100 + 200 * (pos - 3 * (pos / 3));
+ y = 150 + 200 * (pos / 3);
widget_buttonimage = newWidgetButtonimage(image, x, y, eventWidgetButtonImage);
/*
@@ -172,7 +221,9 @@ void initScreenChoiceArena()
widget_buttonimage->active = 1;
}
*/
- addList(listWidgetButtonimage, widget_buttonimage);
+ addList(listAllWidgetButtonimage, widget_buttonimage);
+ handled_map_button_group = 0;
+ activateHandledMapButtonGroup();
}
registerScreen( newScreen("chiceArena", startScreenChoiceArena,
@@ -187,5 +238,8 @@ void quitScreenChoiceArena()
destroyWidgetButton(button_play);
destroyWidgetButton(button_back);
- destroyListItem(listWidgetButtonimage, destroyWidgetButtonimage);
+ destroyWidgetButton(button_next);
+ destroyWidgetButton(button_prev);
+
+ destroyListItem(listAllWidgetButtonimage, destroyWidgetButtonimage);
}