summaryrefslogtreecommitdiff
path: root/src/screen/screen_choiceArena.c
diff options
context:
space:
mode:
authorTomas Chvatal <scarabeus@gentoo.org>2009-02-07 17:52:36 +0100
committerTomas Chvatal <scarabeus@gentoo.org>2009-02-07 17:52:36 +0100
commitdc1bd4d1dcf8713bc5be0e9a154d44b43f71ddf8 (patch)
treeb0372c2abc47ac869f654acc786131740ee146a9 /src/screen/screen_choiceArena.c
parenteecde9b1f70397367f3f0dea4c47f27064f13fc0 (diff)
Revert "Revert "Revert "First pass renaming sreen and widgets."""
This reverts commit 87821f04c9565450d8e724be76993ae5ea2c20c4.
Diffstat (limited to 'src/screen/screen_choiceArena.c')
-rw-r--r--src/screen/screen_choiceArena.c191
1 files changed, 191 insertions, 0 deletions
diff --git a/src/screen/screen_choiceArena.c b/src/screen/screen_choiceArena.c
new file mode 100644
index 0000000..7bc6ce4
--- /dev/null
+++ b/src/screen/screen_choiceArena.c
@@ -0,0 +1,191 @@
+
+#include <stdio.h>
+#include <assert.h>
+
+#include "main.h"
+#include "list.h"
+#include "arenaFile.h"
+
+#include "interface.h"
+#include "screen.h"
+#include "image.h"
+#include "hotKey.h"
+
+#ifndef NO_SOUND
+# include "music.h"
+#endif
+
+#include "screen_mainMenu.h"
+#include "screen_choiceArena.h"
+
+#include "widget.h"
+#include "widget_label.h"
+#include "widget_button.h"
+#include "widget_image.h"
+#include "widget_buttonimage.h"
+
+static widget_t *image_backgorund;
+
+static widget_t *button_play;
+static widget_t *button_back;
+
+static list_t *listWidgetButtonimage;
+static arenaFile_t *currentArena;
+
+static void hotkey_escape()
+{
+ setScreen("gameType");
+}
+
+void startScreenChoiceArena()
+{
+#ifndef NO_SOUND
+ playMusic("menu", MUSIC_GROUP_BASE);
+#endif
+
+ registerHotKey(SDLK_ESCAPE, hotkey_escape);
+}
+
+void drawScreenChoiceArena()
+{
+ int i;
+
+ drawWidgetImage(image_backgorund);
+
+ drawWidgetButton(button_play);
+ drawWidgetButton(button_back);
+
+ for (i = 0; i < listWidgetButtonimage->count; i++) {
+ widget_t *this;
+
+ this = (widget_t *) listWidgetButtonimage->list[i];
+ drawWidgetButtonimage(this);
+ }
+}
+
+void eventScreenChoiceArena()
+{
+ int i;
+
+ eventWidgetButton(button_play);
+ eventWidgetButton(button_back);
+
+ for (i = 0; i < listWidgetButtonimage->count; i++) {
+ widget_t *this;
+
+ this = (widget_t *) listWidgetButtonimage->list[i];
+ eventWidgetButtonimage(this);
+ }
+}
+
+void stopScreenChoiceArena()
+{
+ unregisterHotKey(SDLK_ESCAPE);
+}
+
+static void eventWidgetButtonImage(void *p)
+{
+ widget_t *buttonimage;
+ int i;
+
+ buttonimage = (widget_t *) (p);
+
+ for (i = 0; i < listWidgetButtonimage->count; i++) {
+ widget_t *this;
+
+ this = (widget_t *) (listWidgetButtonimage->list[i]);
+
+ if (buttonimage == this) {
+ setWidgetButtonimageActive(this, TRUE);
+ currentArena = getArenaFile(i);
+ } else {
+ setWidgetButtonimageActive(this, FALSE);
+ }
+ }
+}
+
+arenaFile_t *getChoiceArena()
+{
+ return currentArena;
+}
+
+void setChoiceArena(arenaFile_t * arenaFile)
+{
+ widget_t *widget_buttonimage;
+ int id;
+
+ id = getArenaFileID(arenaFile);
+ currentArena = arenaFile;
+
+ if (id >= 0) {
+ widget_buttonimage = (widget_t *) listWidgetButtonimage->list[id];
+ setWidgetButtonimageActive(widget_buttonimage, TRUE);
+ }
+}
+
+static void eventWidget(void *p)
+{
+ widget_t *button;
+
+ button = (widget_t *) (p);
+
+ if (button == button_play) {
+ setScreen("world");
+ }
+
+ if (button == button_back) {
+ setScreen("gameType");
+ }
+}
+
+void initScreenChoiceArena()
+{
+ image_t *image;
+ int i;
+
+ image = getImage(IMAGE_GROUP_BASE, "screen_main");
+ image_backgorund = newWidgetImage(0, 0, image);
+
+ 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();
+ currentArena = NULL;
+
+ for (i = 0; i < getArenaCount(); i++) {
+ widget_t *widget_buttonimage;
+ arenaFile_t *arenaFile;
+ int x, y;
+
+ arenaFile = getArenaFile(i);
+ //image = addImageData(getArenaImage(i), IMAGE_NO_ALPHA, "none", IMAGE_GROUP_BASE);
+ image = loadImageFromArena(arenaFile, getArenaImage(arenaFile),
+ IMAGE_GROUP_BASE, "none", IMAGE_NO_ALPHA);
+
+ x = 100 + 200 * (i - 3 * (i / 3));
+ y = 150 + 200 * (i / 3);
+
+ widget_buttonimage = newWidgetButtonimage(image, x, y, eventWidgetButtonImage);
+/*
+ if( i == choiceArenaId )
+ {
+ widget_buttonimage->active = 1;
+ }
+*/
+ addList(listWidgetButtonimage, widget_buttonimage);
+ }
+
+ registerScreen( newScreen("chiceArena", startScreenChoiceArena,
+ eventScreenChoiceArena, drawScreenChoiceArena,
+ stopScreenChoiceArena));
+}
+
+void quitScreenChoiceArena()
+{
+ destroyWidgetImage(image_backgorund);
+
+ destroyWidgetButton(button_play);
+ destroyWidgetButton(button_back);
+
+ destroyListItem(listWidgetButtonimage, destroyWidgetButtonimage);
+}