summaryrefslogtreecommitdiff
path: root/src/screen
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-06-28 16:38:35 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-06-28 16:38:35 +0000
commit2d776fcd61be168e1ff0ff2e4a5e71835e7cea19 (patch)
tree7cf274897bf540d5332d446f583ffd066e4e2e1d /src/screen
parentb877ae23ac5d380ab3aa48d7724045cf4883b186 (diff)
- prekopanie adresarovej struktury, prva cast
git-svn-id: http://opensvn.csie.org/tuxanci_ng@77 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/screen')
-rw-r--r--src/screen/Makefile29
-rw-r--r--src/screen/screen_analyze.c179
-rw-r--r--src/screen/screen_analyze.h25
-rw-r--r--src/screen/screen_choiceArena.c172
-rw-r--r--src/screen/screen_choiceArena.h17
-rw-r--r--src/screen/screen_credits.c134
-rw-r--r--src/screen/screen_credits.h20
-rw-r--r--src/screen/screen_gameType.c256
-rw-r--r--src/screen/screen_gameType.h17
-rw-r--r--src/screen/screen_mainMenu.c128
-rw-r--r--src/screen/screen_mainMenu.h15
-rw-r--r--src/screen/screen_setting.c532
-rw-r--r--src/screen/screen_setting.h20
-rw-r--r--src/screen/screen_table.c240
-rw-r--r--src/screen/screen_table.h17
-rw-r--r--src/screen/screen_world.c603
-rw-r--r--src/screen/screen_world.h31
17 files changed, 2435 insertions, 0 deletions
diff --git a/src/screen/Makefile b/src/screen/Makefile
new file mode 100644
index 0000000..41c8ae1
--- /dev/null
+++ b/src/screen/Makefile
@@ -0,0 +1,29 @@
+
+all: screen_analyze.o screen_credits.o screen_gameType.o screen_choiceArena.o screen_mainMenu.o screen_setting.o screen_table.o screen_world.o
+
+screen_analyze.o: screen_analyze.c screen_analyze.h
+ $(CC) $(CFLAGS) -o screen_analyze.o -c screen_analyze.c
+
+screen_credits.o: screen_credits.c screen_credits.h
+ $(CC) $(CFLAGS) -o screen_credits.o -c screen_credits.c
+
+screen_gameType.o: screen_gameType.c screen_gameType.h
+ $(CC) $(CFLAGS) -o screen_gameType.o -c screen_gameType.c
+
+screen_mainMenu.o: screen_mainMenu.c screen_mainMenu.h
+ $(CC) $(CFLAGS) -o screen_mainMenu.o -c screen_mainMenu.c
+
+screen_setting.o: screen_setting.c screen_setting.h
+ $(CC) $(CFLAGS) -o screen_setting.o -c screen_setting.c
+
+screen_table.o: screen_table.c screen_table.h
+ $(CC) $(CFLAGS) -o screen_table.o -c screen_table.c
+
+screen_world.o: screen_world.c screen_world.h
+ $(CC) $(CFLAGS) -o screen_world.o -c screen_world.c
+
+
+clean:
+ rm -rf *.o
+
+
diff --git a/src/screen/screen_analyze.c b/src/screen/screen_analyze.c
new file mode 100644
index 0000000..c1b8258
--- /dev/null
+++ b/src/screen/screen_analyze.c
@@ -0,0 +1,179 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#include "base/main.h"
+#include "base/list.h"
+
+#include "client/interface.h"
+#include "client/screen.h"
+#include "client/image.h"
+
+#ifndef NO_SOUND
+#include "audio/music.h"
+#endif
+
+#include "screen/screen_mainMenu.h"
+#include "screen/screen_analyze.h"
+
+#include "widget/widget_label.h"
+#include "widget/widget_button.h"
+#include "widget/widget_image.h"
+
+static widget_image_t *image_backgorund;
+
+static list_t *listWidgetLabelName;
+static list_t *listWidgetLabelScore;
+static list_t *listAnalyze;
+static widget_label_t *widgetLabelMsg;
+
+static widget_button_t *button_ok;
+
+static analyze_t* newAnalyze(char *name, int score)
+{
+ analyze_t *new;
+
+ new = malloc( sizeof(analyze_t) );
+ new->name = strdup(name);
+ new->score = score;
+
+ return new;
+}
+
+static void destroyAnalyze(analyze_t *p)
+{
+ free(p->name);
+ free(p);
+}
+
+void startScreenAnalyze()
+{
+#ifndef NO_SOUND
+ playMusic("menu", MUSIC_GROUP_BASE);
+#endif
+}
+
+void drawScreenAnalyze()
+{
+ widget_label_t *this;
+ int i;
+
+ drawWidgetImage(image_backgorund);
+
+ for( i = 0 ; i < listWidgetLabelName->count ; i++ )
+ {
+ this = (widget_label_t *)(listWidgetLabelName->list[i]);
+ drawWidgetLabel(this);
+ }
+
+ for( i = 0 ; i < listWidgetLabelScore->count ; i++ )
+ {
+ this = (widget_label_t *)(listWidgetLabelScore->list[i]);
+ drawWidgetLabel(this);
+ }
+
+ drawWidgetLabel(widgetLabelMsg);
+ drawWidgetButton(button_ok);
+}
+
+void eventScreenAnalyze()
+{
+ eventWidgetButton(button_ok);
+}
+
+void stopScreenAnalyze()
+{
+ destroyWidgetLabel(widgetLabelMsg);
+ widgetLabelMsg = newWidgetLabel("", WINDOW_SIZE_X / 2 , 250, WIDGET_LABEL_CENTER);
+}
+
+static void eventWidget(void *p)
+{
+ widget_button_t *button;
+
+ button = (widget_button_t *)(p);
+
+ if( button == button_ok )
+ {
+ setScreen("mainMenu");
+ }
+}
+
+void restartAnalyze()
+{
+ destroyListItem(listWidgetLabelName, destroyWidgetLabel);
+ destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
+ destroyListItem(listAnalyze, destroyAnalyze);
+
+ listWidgetLabelName = newList();
+ listWidgetLabelScore = newList();
+ listAnalyze = newList();
+}
+
+void addAnalyze(char *name, int score)
+{
+ addList(listAnalyze, newAnalyze(name, score) );
+}
+
+void setMsgToAnalyze(char *msg)
+{
+ destroyWidgetLabel(widgetLabelMsg);
+ widgetLabelMsg = newWidgetLabel(msg, WINDOW_SIZE_X / 2 , 250, WIDGET_LABEL_CENTER);
+}
+
+void endAnalyze()
+{
+ int i;
+
+ for( i = 0 ; i < listAnalyze->count ; i++ )
+ {
+ analyze_t *this;
+ char *str;
+
+ this = (analyze_t *)(listAnalyze->list[i]);
+
+ addList(listWidgetLabelName, newWidgetLabel(this->name,
+ 100, 200 + 20*i, WIDGET_LABEL_LEFT) );
+
+ str = getString(this->score);
+
+ addList(listWidgetLabelScore, newWidgetLabel(str,
+ WINDOW_SIZE_X - 100, 200 + 20*i, WIDGET_LABEL_RIGHT) );
+
+ free(str);
+ }
+}
+
+void initScreenAnalyze()
+{
+ SDL_Surface *image;
+
+ image = getImage(IMAGE_GROUP_BASE, "screen_main");
+ image_backgorund = newWidgetImage(0, 0, image);
+
+ listWidgetLabelName = newList();
+ listWidgetLabelScore = newList();
+ listAnalyze = newList();
+
+ button_ok = newWidgetButton("OK", WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2,
+ WINDOW_SIZE_Y-100, eventWidget);
+
+ registerScreen( newScreen("analyze", startScreenAnalyze, eventScreenAnalyze,
+ drawScreenAnalyze, stopScreenAnalyze) );
+
+ widgetLabelMsg = newWidgetLabel("", WINDOW_SIZE_X / 2 , 250, WIDGET_LABEL_CENTER);
+}
+
+void quitScreenAnalyze()
+{
+ destroyWidgetImage(image_backgorund);
+
+ destroyListItem(listWidgetLabelName, destroyWidgetLabel);
+ destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
+ destroyListItem(listAnalyze, destroyAnalyze);
+
+ destroyWidgetButton(button_ok);
+ destroyWidgetLabel(widgetLabelMsg);
+}
+
diff --git a/src/screen/screen_analyze.h b/src/screen/screen_analyze.h
new file mode 100644
index 0000000..b6a9875
--- /dev/null
+++ b/src/screen/screen_analyze.h
@@ -0,0 +1,25 @@
+
+#ifndef SCREEN_ANALYZE_H
+
+#define SCREEN_ANALYZE_H
+
+#include "base/main.h"
+
+typedef struct analyze_struct
+{
+ char *name;
+ int score;
+} analyze_t;
+
+extern void startScreenAnalyze();
+extern void drawScreenAnalyze();
+extern void eventScreenAnalyze();
+extern void stopScreenAnalyze();
+extern void restartAnalyze();
+extern void addAnalyze(char *name, int score);
+extern void setMsgToAnalyze(char *msg);
+extern void endAnalyze();
+extern void initScreenAnalyze();
+extern void quitScreenAnalyze();
+
+#endif
diff --git a/src/screen/screen_choiceArena.c b/src/screen/screen_choiceArena.c
new file mode 100644
index 0000000..629f1ba
--- /dev/null
+++ b/src/screen/screen_choiceArena.c
@@ -0,0 +1,172 @@
+
+#include <stdio.h>
+#include <assert.h>
+
+#include "base/main.h"
+#include "base/list.h"
+#include "base/arenaFile.h"
+
+#include "client/language.h"
+#include "client/interface.h"
+#include "client/screen.h"
+#include "client/image.h"
+
+#ifndef NO_SOUND
+#include "audio/music.h"
+#endif
+
+#include "screen/screen_mainMenu.h"
+#include "screen/screen_choiceArena.h"
+
+#include "widget/widget_label.h"
+#include "widget/widget_button.h"
+#include "widget/widget_image.h"
+#include "widget/widget_buttonimage.h"
+
+static widget_image_t *image_backgorund;
+
+static widget_button_t *button_play;
+static widget_button_t *button_back;
+
+static list_t *listWidgetButtonimage;
+static int choiceArenaId;
+
+void startScreenChoiceArena()
+{
+#ifndef NO_SOUND
+ playMusic("menu", MUSIC_GROUP_BASE);
+#endif
+}
+
+void drawScreenChoiceArena()
+{
+ int i;
+
+ drawWidgetImage(image_backgorund);
+
+ drawWidgetButton(button_play);
+ drawWidgetButton(button_back);
+
+ for( i = 0 ; i < listWidgetButtonimage->count ; i++ )
+ {
+ widget_buttonimage_t *this;
+ this = (widget_buttonimage_t *) listWidgetButtonimage->list[i];
+ drawWidgetButtonimage(this);
+ }
+}
+
+void eventScreenChoiceArena()
+{
+ int i;
+
+ eventWidgetButton(button_play);
+ eventWidgetButton(button_back);
+
+ for( i = 0 ; i < listWidgetButtonimage->count ; i++ )
+ {
+ widget_buttonimage_t *this;
+ this = (widget_buttonimage_t *) listWidgetButtonimage->list[i];
+ eventWidgetButtonimage(this);
+ }
+}
+
+void stopScreenChoiceArena()
+{
+}
+
+static void eventWidgetButtonImage(void *p)
+{
+ widget_buttonimage_t *buttonimage;
+ int i;
+
+ buttonimage = (widget_buttonimage_t *)(p);
+
+ for( i = 0 ; i < listWidgetButtonimage->count ; i++ )
+ {
+ widget_buttonimage_t *this;
+
+ this = (widget_buttonimage_t *)(listWidgetButtonimage->list[i]);
+
+ if( buttonimage == this )
+ {
+ this->active = 1;
+ choiceArenaId = i;
+ }
+ else
+ {
+ this->active = 0;
+ }
+ }
+}
+
+int getChoiceArenaId()
+{
+ return choiceArenaId;
+}
+
+static void eventWidget(void *p)
+{
+ widget_button_t *button;
+
+ button = (widget_button_t *)(p);
+
+ if( button == button_play )
+ {
+ setScreen("world");
+ }
+
+ if( button == button_back )
+ {
+ setScreen("gameType");
+ }
+}
+
+void initScreenChoiceArena()
+{
+ SDL_Surface *image;
+ int i;
+
+ image = getImage(IMAGE_GROUP_BASE, "screen_main");
+ image_backgorund = newWidgetImage(0, 0, image);
+
+ button_back = newWidgetButton(getMyText("BACK"), 100, WINDOW_SIZE_Y-100, eventWidget);
+ button_play = newWidgetButton(getMyText("PLAY"), WINDOW_SIZE_X-200, WINDOW_SIZE_Y-100, eventWidget);
+
+ listWidgetButtonimage = newList();
+ choiceArenaId = 0;
+
+ for( i = 0 ; i < getArenaCount() ; i++ )
+ {
+ SDL_Surface *image;
+ widget_buttonimage_t *widget_buttonimage;
+ int x, y;
+
+ image = addImageData(getArenaImage(i), IMAGE_NO_ALPHA, "none", IMAGE_GROUP_BASE);
+
+ 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);
+}
diff --git a/src/screen/screen_choiceArena.h b/src/screen/screen_choiceArena.h
new file mode 100644
index 0000000..0437aa1
--- /dev/null
+++ b/src/screen/screen_choiceArena.h
@@ -0,0 +1,17 @@
+
+#ifndef SCREEN_CHOICE_ARENA
+
+#define SCREEN_CHOICE_ARENA
+
+#include "base/main.h"
+
+#define SCREENSHOT_ARENA_WIDTH 160
+#define SCREENSHOT_ARENA_HEIGHT 107
+
+extern void drawScreenChoiceArena();
+extern void eventScreenChoiceArena();
+extern int getChoiceArenaId();
+extern void initScreenChoiceArena();
+extern void quitScreenChoiceArena();
+
+#endif
diff --git a/src/screen/screen_credits.c b/src/screen/screen_credits.c
new file mode 100644
index 0000000..3f6cf84
--- /dev/null
+++ b/src/screen/screen_credits.c
@@ -0,0 +1,134 @@
+
+#include <stdio.h>
+#include <assert.h>
+
+#include "base/main.h"
+#include "base/list.h"
+#include "base/textFile.h"
+
+#include "client/language.h"
+#include "client/interface.h"
+#include "client/screen.h"
+#include "client/image.h"
+
+#ifndef NO_SOUND
+#include "audio/music.h"
+#endif
+
+#include "screen/screen_credits.h"
+
+#include "widget/widget_image.h"
+#include "widget/widget_label.h"
+#include "widget/widget_button.h"
+
+static widget_image_t *image_backgorund;
+static widget_button_t *button_back;
+static list_t *listWidgetLabel;
+static textFile_t *textFile;
+static int offset;
+
+void startScreenCredits()
+{
+#ifndef NO_SOUND
+ playMusic("menu", MUSIC_GROUP_BASE);
+#endif
+ offset = 0;
+}
+
+void drawScreenCredits()
+{
+ int i;
+
+ drawWidgetImage(image_backgorund);
+
+ drawWidgetButton(button_back);
+
+ for( i = 0 ; i < listWidgetLabel->count ; i++ )
+ {
+ int z;
+
+ widget_label_t *this;
+ this = (widget_label_t *)listWidgetLabel->list[i];
+
+ z = this->y;
+ this->y += offset;
+
+ if( this->y > SCREEN_CREDITS_OFFSET_MIN && this->y < SCREEN_CREDITS_OFFSET_MAX )
+ {
+ drawWidgetLabel(this);
+ }
+
+ this->y = z;
+ }
+
+}
+
+void eventScreenCredits()
+{
+ eventWidgetButton(button_back);
+
+ offset -= SCREEN_CREDITS_OFFSET_SPEED;
+
+ if( offset < SCREEN_CREDITS_OFFSET_RESTART )
+ {
+ offset = 0;
+ }
+
+ //printf("offset = %d\n", offset);
+}
+
+void stopScreenCredits()
+{
+}
+
+static void eventWidget(void *p)
+{
+ widget_button_t *button;
+
+ button = (widget_button_t *)(p);
+
+ if( button == button_back )
+ {
+ setScreen("mainMenu");
+ }
+}
+
+void initScreenCredits()
+{
+ SDL_Surface *image;
+ int i;
+
+ image = getImage(IMAGE_GROUP_BASE, "screen_main");
+ image_backgorund = newWidgetImage(0, 0, image);
+
+ button_back = newWidgetButton(getMyText("BACK"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, WINDOW_SIZE_Y-80, eventWidget);
+
+ listWidgetLabel = newList();
+ accessExistFile(PATH_DATA SCREEN_CREDITS_FILE);
+ textFile = loadTextFile(PATH_DATA SCREEN_CREDITS_FILE);
+
+ for( i = 0 ; i < textFile->text->count ; i++ )
+ {
+ widget_label_t *label;
+ char *line;
+
+ line = (char *)textFile->text->list[i];
+ label = newWidgetLabel(line, WINDOW_SIZE_X/2, (WINDOW_SIZE_Y-100)+i*20,
+ WIDGET_LABEL_CENTER);
+
+ addList(listWidgetLabel, label);
+ }
+
+ registerScreen( newScreen("credits", startScreenCredits, eventScreenCredits,
+ drawScreenCredits, stopScreenCredits) );
+}
+
+void quitScreenCredits()
+{
+ destroyWidgetImage(image_backgorund);
+
+ destroyWidgetButton(button_back);
+ destroyListItem(listWidgetLabel, destroyWidgetLabel);
+ destroyTextFile(textFile);
+}
+
diff --git a/src/screen/screen_credits.h b/src/screen/screen_credits.h
new file mode 100644
index 0000000..2bbce80
--- /dev/null
+++ b/src/screen/screen_credits.h
@@ -0,0 +1,20 @@
+
+#ifndef SCREEN_CREDITS_H
+
+#define SCREEN_CREDITS_H
+
+#define SCREEN_CREDITS_FILE "credits.en"
+
+#define SCREEN_CREDITS_OFFSET_MIN 130
+#define SCREEN_CREDITS_OFFSET_MAX WINDOW_SIZE_Y-120
+#define SCREEN_CREDITS_OFFSET_RESTART -1000
+#define SCREEN_CREDITS_OFFSET_SPEED 2
+
+extern void startScreenCredits();
+extern void drawScreenCredits();
+extern void eventScreenCredits();
+extern void stopScreenCredits();
+extern void initScreenCredits();
+extern void quitScreenCredits();
+
+#endif
diff --git a/src/screen/screen_gameType.c b/src/screen/screen_gameType.c
new file mode 100644
index 0000000..5545fc1
--- /dev/null
+++ b/src/screen/screen_gameType.c
@@ -0,0 +1,256 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#include "base/main.h"
+#include "base/list.h"
+#include "base/net_multiplayer.h"
+#include "base/tux.h"
+
+#include "client/language.h"
+#include "client/interface.h"
+#include "client/screen.h"
+#include "client/image.h"
+
+#ifndef NO_SOUND
+#include "audio/music.h"
+#endif
+
+#include "screen/screen_gameType.h"
+#include "screen/screen_setting.h"
+
+#include "widget/widget_label.h"
+#include "widget/widget_button.h"
+#include "widget/widget_image.h"
+#include "widget/widget_textfield.h"
+#include "widget/widget_check.h"
+
+static widget_image_t *image_backgorund;
+
+static widget_button_t *button_back;
+static widget_button_t *button_play;
+
+static widget_label_t *label_none;
+static widget_label_t *label_server;
+static widget_label_t *label_client;
+
+static widget_label_t *label_ip;
+static widget_label_t *label_port;
+
+static widget_check_t *check_none;
+static widget_check_t *check_server;
+static widget_check_t *check_client;
+
+static widget_textfield_t *textfield_ip;
+static widget_textfield_t *textfield_port;
+
+void startScreenGameType()
+{
+#ifndef NO_SOUND
+ playMusic("menu", MUSIC_GROUP_BASE);
+#endif
+}
+
+void drawScreenGameType()
+{
+ drawWidgetImage(image_backgorund);
+
+ drawWidgetLabel(label_none);
+ drawWidgetLabel(label_server);
+ drawWidgetLabel(label_client);
+
+ if( check_none->status == FALSE )
+ {
+ drawWidgetLabel(label_port);
+ drawWidgetTextfield(textfield_port);
+ drawWidgetLabel(label_ip);
+ drawWidgetTextfield(textfield_ip);
+ }
+
+ drawWidgetCheck(check_none);
+ drawWidgetCheck(check_server);
+ drawWidgetCheck(check_client);
+
+ drawWidgetButton(button_back);
+ drawWidgetButton(button_play);
+}
+
+void eventScreenGameType()
+{
+ eventWidgetCheck(check_none);
+ eventWidgetCheck(check_server);
+ eventWidgetCheck(check_client);
+
+ eventWidgetTextfield(textfield_ip);
+ eventWidgetTextfield(textfield_port);
+
+ eventWidgetButton(button_back);
+ eventWidgetButton(button_play);
+}
+
+void stopScreenGameType()
+{
+}
+
+static void eventWidget(void *p)
+{
+ widget_button_t *button;
+ widget_check_t *check;
+
+ button = (widget_button_t *)(p);
+ check = (widget_check_t *)(p);
+
+ if( check == check_none )
+ {
+ check_none->status = TRUE;
+ check_server->status = FALSE;
+ check_client->status = FALSE;
+ return;
+ }
+
+ if( check == check_server )
+ {
+ check_none->status = FALSE;
+ check_server->status = TRUE;
+ check_client->status = FALSE;
+ return;
+ }
+
+ if( check == check_client )
+ {
+ check_none->status = FALSE;
+ check_server->status = FALSE;
+ check_client->status = TRUE;
+ return;
+ }
+
+ if( button == button_back )
+ {
+ setScreen("mainMenu");
+ }
+
+ if( button == button_play )
+ {
+ if( getSettingGameType() == NET_GAME_TYPE_CLIENT )
+ {
+ setScreen("world");
+ }
+ else
+ {
+ setScreen("chiceArena");
+ }
+ }
+}
+
+void initScreenGameType()
+{
+ SDL_Surface *image;
+
+ image = getImage(IMAGE_GROUP_BASE, "screen_main");
+ image_backgorund = newWidgetImage(0, 0, image);
+
+ button_back = newWidgetButton(getMyText("BACK"), 100, WINDOW_SIZE_Y-100, eventWidget);
+ button_play = newWidgetButton(getMyText("PLAY"), WINDOW_SIZE_X-200, WINDOW_SIZE_Y-100, eventWidget);
+
+ check_none = newWidgetCheck(100, 150, FALSE, eventWidget);
+ check_server = newWidgetCheck(100, 200, FALSE, eventWidget);
+ check_client = newWidgetCheck(100, 250, FALSE, eventWidget);
+
+ if( isParamFlag("--server") )
+ {
+ check_server->status = TRUE;
+ }
+ else if( isParamFlag("--client") )
+ {
+ check_client->status = TRUE;
+ }
+ else
+ {
+ check_none->status = TRUE;
+ }
+
+ label_none = newWidgetLabel(getMyText("NONE"), 130, 145, WIDGET_LABEL_LEFT);
+ label_server = newWidgetLabel(getMyText("SERVER"), 130, 195, WIDGET_LABEL_LEFT);
+ label_client = newWidgetLabel(getMyText("CLIENT"), 130, 245, WIDGET_LABEL_LEFT);
+
+ label_ip = newWidgetLabel(getMyText("IP_ADDR"), 300, 145, WIDGET_LABEL_LEFT);
+ label_port = newWidgetLabel(getMyText("NET_PORT"), 300, 245, WIDGET_LABEL_LEFT);
+
+ textfield_ip = newWidgetTextfield(getParamElse("--ip", "127.0.0.1"), 300, 180);
+ textfield_port = newWidgetTextfield(getParamElse("--port", "2200"), 300, 280);
+
+ registerScreen( newScreen("gameType", startScreenGameType, eventScreenGameType,
+ drawScreenGameType, stopScreenGameType) );
+}
+
+int getSettingGameType()
+{
+ if( check_none->status == TRUE )
+ {
+ return NET_GAME_TYPE_NONE;
+ }
+
+ if( check_server->status == TRUE )
+ {
+ return NET_GAME_TYPE_SERVER;
+ }
+
+ if( check_client->status == TRUE )
+ {
+ return NET_GAME_TYPE_CLIENT;
+ }
+
+ assert( ! "Chyba pri zistvani type hry !" );
+
+ return -1;
+}
+
+char* getSettingIP()
+{
+ return textfield_ip->text;
+}
+
+int getSettingPort()
+{
+ return atoi( textfield_port->text );
+}
+
+int getSettingProto()
+{
+ if( strstr(textfield_ip->text, ".") != NULL )
+ {
+ return PROTO_UDPv4;
+ }
+
+ if( strstr(textfield_ip->text, ":") != NULL )
+ {
+ return PROTO_UDPv6;
+ }
+
+ printf("IP protokol unknown !\n");
+ return -1;
+}
+
+void quitScreenGameType()
+{
+ destroyWidgetImage(image_backgorund);
+
+ destroyWidgetLabel(label_none);
+ destroyWidgetLabel(label_server);
+ destroyWidgetLabel(label_client);
+
+ destroyWidgetLabel(label_ip);
+ destroyWidgetLabel(label_port);
+
+ destroyWidgetTextfield(textfield_ip);
+ destroyWidgetTextfield(textfield_port);
+
+ destroyWidgetButton(button_back);
+ destroyWidgetButton(button_play);
+
+ destroyWidgetCheck(check_none);
+ destroyWidgetCheck(check_server);
+ destroyWidgetCheck(check_client);
+}
+
diff --git a/src/screen/screen_gameType.h b/src/screen/screen_gameType.h
new file mode 100644
index 0000000..93d38ee
--- /dev/null
+++ b/src/screen/screen_gameType.h
@@ -0,0 +1,17 @@
+
+#ifndef SCREEN_GAME_TYPE
+
+#define SCREEN_GAME_TYPE
+
+#include "base/main.h"
+
+extern void drawScreenGameType();
+extern void eventScreenGameType();
+extern void initScreenGameType();
+extern int getSettingGameType();
+extern char* getSettingIP();
+extern int getSettingPort();
+extern int getSettingProto();
+extern void quitScreenGameType();
+
+#endif
diff --git a/src/screen/screen_mainMenu.c b/src/screen/screen_mainMenu.c
new file mode 100644
index 0000000..bd3886f
--- /dev/null
+++ b/src/screen/screen_mainMenu.c
@@ -0,0 +1,128 @@
+
+#include <stdio.h>
+#include <assert.h>
+
+#include "base/main.h"
+
+#include "client/game.h"
+#include "client/interface.h"
+#include "client/language.h"
+#include "client/screen.h"
+#include "client/image.h"
+
+#ifndef NO_SOUND
+#include "audio/music.h"
+#endif
+
+#include "screen/screen_mainMenu.h"
+#include "screen/screen_setting.h"
+
+#include "widget/widget_label.h"
+#include "widget/widget_button.h"
+#include "widget/widget_textfield.h"
+#include "widget/widget_check.h"
+#include "widget/widget_image.h"
+
+static widget_image_t *image_backgorund;
+
+static widget_button_t *button_play;
+static widget_button_t *button_setting;
+static widget_button_t *button_table;
+static widget_button_t *button_credits;
+static widget_button_t *button_end;
+
+void startScreenMainMenu()
+{
+#ifndef NO_SOUND
+ playMusic("menu", MUSIC_GROUP_BASE);
+#endif
+}
+
+void drawScreenMainMenu()
+{
+ drawWidgetImage(image_backgorund);
+
+ drawWidgetButton(button_play);
+ drawWidgetButton(button_setting);
+ drawWidgetButton(button_table);
+ drawWidgetButton(button_credits);
+ drawWidgetButton(button_end);
+}
+
+void eventScreenMainMenu()
+{
+ eventWidgetButton(button_play);
+ eventWidgetButton(button_setting);
+ eventWidgetButton(button_table);
+ eventWidgetButton(button_credits);
+ eventWidgetButton(button_end);
+}
+
+void stopScreenMainMenu()
+{
+}
+
+static void eventWidget(void *p)
+{
+ widget_button_t *button;
+
+ button = (widget_button_t *)(p);
+
+ if( button == button_play )
+ {
+ setScreen("gameType");
+ }
+
+ if( button == button_setting )
+ {
+ setScreen("setting");
+ }
+
+ if( button == button_table )
+ {
+ setScreen("table");
+ }
+
+ if( button == button_credits )
+ {
+ setScreen("credits");
+ }
+
+ if( button == button_end )
+ {
+ quitGame();
+ }
+}
+
+void initScreenMainMenu()
+{
+ SDL_Surface *image;
+
+ image = addImageData("screen_main.png", IMAGE_NO_ALPHA, "screen_main", IMAGE_GROUP_BASE);
+ image_backgorund = newWidgetImage(0, 0, image);
+
+ button_play = newWidgetButton(getMyText("PLAY"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, 200, eventWidget);
+ button_setting = newWidgetButton(getMyText("SETTING"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, 250, eventWidget);
+ button_table = newWidgetButton(getMyText("TABLE"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, 300, eventWidget);
+ button_credits = newWidgetButton(getMyText("CREDITS"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, 350, eventWidget);
+ button_end = newWidgetButton(getMyText("END"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, 400, eventWidget);
+
+#ifndef NO_SOUND
+ addMusic("menu.ogg", "menu", MUSIC_GROUP_BASE);
+#endif
+
+ registerScreen( newScreen("mainMenu", startScreenMainMenu, eventScreenMainMenu,
+ drawScreenMainMenu, stopScreenMainMenu) );
+}
+
+void quitScreenMainMenu()
+{
+ destroyWidgetImage(image_backgorund);
+
+ destroyWidgetButton(button_play);
+ destroyWidgetButton(button_setting);
+ destroyWidgetButton(button_table);
+ destroyWidgetButton(button_credits);
+ destroyWidgetButton(button_end);
+}
+
diff --git a/src/screen/screen_mainMenu.h b/src/screen/screen_mainMenu.h
new file mode 100644
index 0000000..c04e65f
--- /dev/null
+++ b/src/screen/screen_mainMenu.h
@@ -0,0 +1,15 @@
+
+#ifndef SCREEN_MIAN_MENU_H
+
+#define SCREEN_MIAN_MENU_H
+
+#include "base/main.h"
+
+extern void startScreenMainMenu();
+extern void drawScreenMainMenu();
+extern void eventScreenMainMenu();
+extern void stopScreenMainMenu();
+extern void initScreenMainMenu();
+extern void quitScreenMainMenu();
+
+#endif
diff --git a/src/screen/screen_setting.c b/src/screen/screen_setting.c
new file mode 100644
index 0000000..fd1388d
--- /dev/null
+++ b/src/screen/screen_setting.c
@@ -0,0 +1,532 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#include "base/main.h"
+#include "base/list.h"
+#include "base/tux.h"
+#include "base/textFile.h"
+#include "base/director.h"
+#include "base/homeDirector.h"
+
+#include "client/configFile.h"
+#include "client/language.h"
+#include "client/interface.h"
+#include "client/screen.h"
+#include "client/image.h"
+
+#ifndef NO_SOUND
+#include "audio/music.h"
+#include "audio/sound.h"
+#endif
+
+#include "screen/screen_mainMenu.h"
+#include "screen/screen_setting.h"
+
+#include "widget/widget_label.h"
+#include "widget/widget_button.h"
+#include "widget/widget_image.h"
+#include "widget/widget_textfield.h"
+#include "widget/widget_check.h"
+#include "widget/widget_select.h"
+
+static widget_image_t *image_backgorund;
+
+static widget_button_t *button_back;
+
+static widget_label_t *label_count_round;
+static widget_label_t *label_name_player1;
+static widget_label_t *label_name_player2;
+static widget_label_t *label_ai;
+
+#ifndef NO_SOUND
+static widget_label_t *label_music;
+static widget_label_t *label_sound;
+#endif
+
+static widget_check_t *check[ITEM_COUNT];
+#ifndef NO_SOUND
+static widget_check_t *check_music;
+static widget_check_t *check_sound;
+#endif
+
+static widget_image_t *image_gun_dual_revolver;
+static widget_image_t *image_gun_scatter;
+static widget_image_t *image_gun_tommy;
+static widget_image_t *image_gun_lasser;
+static widget_image_t *image_gun_mine;
+static widget_image_t *image_gun_bombball;
+
+static widget_image_t *image_bonus_speed;
+static widget_image_t *image_bonus_shot;
+static widget_image_t *image_bonus_teleport;
+static widget_image_t *image_bonus_ghost;
+static widget_image_t *image_bonus_4x;
+static widget_image_t *image_bonus_hidden;
+
+static widget_textfield_t *textfield_count_cound;
+static widget_textfield_t *textfield_name_player1;
+static widget_textfield_t *textfield_name_player2;
+
+static widget_select_t *select_ai;
+
+static textFile_t *configFile;
+
+void startScreenSetting()
+{
+#ifndef NO_SOUND
+ playMusic("menu", MUSIC_GROUP_BASE);
+#endif
+}
+
+void drawScreenSetting()
+{
+ int i;
+
+ drawWidgetImage(image_backgorund);
+
+ drawWidgetLabel(label_count_round);
+ drawWidgetLabel(label_name_player1);
+ drawWidgetLabel(label_name_player2);
+ drawWidgetLabel(label_ai);
+
+#ifndef NO_SOUND
+ drawWidgetLabel(label_music);
+ drawWidgetLabel(label_sound);
+#endif
+
+ drawWidgetTextfield(textfield_count_cound);
+ drawWidgetTextfield(textfield_name_player1);
+ drawWidgetTextfield(textfield_name_player2);
+
+ drawWidgetImage(image_gun_dual_revolver);
+ drawWidgetImage(image_gun_scatter);
+ drawWidgetImage(image_gun_tommy);
+ drawWidgetImage(image_gun_lasser);
+ drawWidgetImage(image_gun_mine);
+ drawWidgetImage(image_gun_bombball);
+
+ drawWidgetImage(image_bonus_speed);
+ drawWidgetImage(image_bonus_shot);
+ drawWidgetImage(image_bonus_teleport);
+ drawWidgetImage(image_bonus_ghost);
+ drawWidgetImage(image_bonus_4x);
+ drawWidgetImage(image_bonus_hidden);
+
+#ifndef NO_SOUND
+ drawWidgetCheck(check_music);
+ drawWidgetCheck(check_sound);
+#endif
+
+ for( i = GUN_DUAL_SIMPLE ; i <= GUN_BOMBBALL ; i++ )
+ {
+ drawWidgetCheck(check[i]);
+ }
+
+ for( i = BONUS_SPEED ; i <= BONUS_HIDDEN ; i++ )
+ {
+ drawWidgetCheck(check[i]);
+ }
+
+ drawWidgetSelect(select_ai);
+
+ drawWidgetButton(button_back);
+}
+
+void eventScreenSetting()
+{
+ int i;
+/*
+ int x, y;
+
+ getMousePosition(&x, &y);
+
+ if( isMouseClicked() )
+ {
+ printf("x = %d y = %d\n", x, y);
+ }
+*/
+ eventWidgetTextfield(textfield_count_cound);
+ eventWidgetTextfield(textfield_name_player1);
+ eventWidgetTextfield(textfield_name_player2);
+
+#ifndef NO_SOUND
+ eventWidgetCheck(check_music);
+ eventWidgetCheck(check_sound);
+#endif
+
+ for( i = GUN_DUAL_SIMPLE ; i <= GUN_BOMBBALL ; i++ )
+ {
+ eventWidgetCheck(check[i]);
+ }
+
+ for( i = BONUS_SPEED ; i <= BONUS_HIDDEN ; i++ )
+ {
+ eventWidgetCheck(check[i]);
+ }
+
+ eventWidgetSelect(select_ai);
+
+ eventWidgetButton(button_back);
+}
+
+void stopScreenSetting()
+{
+}
+
+static void eventWidget(void *p)
+{
+ widget_button_t *button;
+ widget_check_t *check;
+
+ button = (widget_button_t *)(p);
+ check = (widget_check_t *)(p);
+
+ if( button == button_back )
+ {
+ setScreen("mainMenu");
+ }
+
+#ifndef NO_SOUND
+ if( check == check_music )
+ {
+ setMusicActive( check_music->status );
+ }
+
+ if( check == check_sound )
+ {
+ setSoundActive( check_sound->status );
+ }
+#endif
+}
+
+static void initSettingFile()
+{
+ char path[STR_PATH_SIZE];
+ char val[STR_SIZE];
+
+ sprintf(path, "%s/tuxanci-ng.conf", getHomeDirector());
+
+ configFile = loadTextFile(path);
+
+ if( configFile == NULL )
+ {
+ fprintf(stderr, "Don't load %s\n", path);
+ fprintf(stderr, "I create %s\n", path);
+
+ configFile = newTextFile(path);
+ }
+
+ if( configFile == NULL )
+ {
+ fprintf(stderr, "Don't create %s\n", path);
+ return;
+ }
+
+ loadValueFromConfigFile(configFile, "COUNT_ROUND", val, STR_SIZE, "15");
+ strcpy(textfield_count_cound->text, val);
+ loadValueFromConfigFile(configFile, "NAME_PLAYER_RIGHT", val, STR_SIZE, "name1");
+ strcpy(textfield_name_player1->text, val);
+ loadValueFromConfigFile(configFile, "NAME_PLAYER_LEFT", val, STR_SIZE, "name2");
+ strcpy(textfield_name_player2->text, val);
+
+ loadValueFromConfigFile(configFile, "GUN_DUAL_SIMPLE", val, STR_SIZE, "YES");
+ check[GUN_DUAL_SIMPLE]->status = isYesOrNO(val);
+ loadValueFromConfigFile(configFile, "GUN_SCATTER", val, STR_SIZE, "YES");
+ check[GUN_SCATTER]->status = isYesOrNO(val);
+ loadValueFromConfigFile(configFile, "GUN_TOMMY", val, STR_SIZE, "YES");
+ check[GUN_TOMMY]->status = isYesOrNO(val);
+ loadValueFromConfigFile(configFile, "GUN_LASSER", val, STR_SIZE, "YES");
+ check[GUN_LASSER]->status = isYesOrNO(val);
+ loadValueFromConfigFile(configFile, "GUN_MINE", val, STR_SIZE, "YES");
+ check[GUN_MINE]->status = isYesOrNO(val);
+ loadValueFromConfigFile(configFile, "GUN_BOMBBALL", val, STR_SIZE, "YES");
+ check[GUN_BOMBBALL]->status = isYesOrNO(val);
+
+ loadValueFromConfigFile(configFile, "BONUS_SPEED", val, STR_SIZE, "YES");
+ check[BONUS_SPEED]->status = isYesOrNO(val);
+ loadValueFromConfigFile(configFile, "BONUS_SHOT", val, STR_SIZE, "YES");
+ check[BONUS_SHOT]->status = isYesOrNO(val);
+ loadValueFromConfigFile(configFile, "BONUS_TELEPORT", val, STR_SIZE, "YES");
+ check[BONUS_TELEPORT]->status = isYesOrNO(val);
+ loadValueFromConfigFile(configFile, "BONUS_GHOST", val, STR_SIZE, "YES");
+ check[BONUS_GHOST]->status = isYesOrNO(val);
+ loadValueFromConfigFile(configFile, "BONUS_4X", val, STR_SIZE, "YES");
+ check[BONUS_4X]->status = isYesOrNO(val);
+ loadValueFromConfigFile(configFile, "BONUS_HIDDEN", val, STR_SIZE, "YES");
+ check[BONUS_HIDDEN]->status = isYesOrNO(val);
+
+#ifndef NO_SOUND
+ loadValueFromConfigFile(configFile, "MUSIC", val, STR_SIZE, "YES");
+ check_music->status = isYesOrNO(val);
+
+ loadValueFromConfigFile(configFile, "SOUND", val, STR_SIZE, "YES");
+ check_sound->status = isYesOrNO(val);
+#endif
+
+ saveTextFile(configFile);
+}
+
+static void saveAndDestroyConfigFile()
+{
+ if( configFile == NULL )
+ {
+ fprintf(stderr, "i can't save configure, "
+ "because config file not created !\n");
+
+ return;
+ }
+
+ setValueInConfigFile(configFile, "COUNT_ROUND", textfield_count_cound->text );
+ setValueInConfigFile(configFile, "NAME_PLAYER_RIGHT", textfield_name_player1->text );
+ setValueInConfigFile(configFile, "NAME_PLAYER_LEFT", textfield_name_player2->text );
+
+ setValueInConfigFile(configFile, "GUN_DUAL_SIMPLE", getYesOrNo(check[GUN_DUAL_SIMPLE]->status) );
+ setValueInConfigFile(configFile, "GUN_SCATTER", getYesOrNo(check[GUN_SCATTER]->status) );
+ setValueInConfigFile(configFile, "GUN_TOMMY", getYesOrNo(check[GUN_TOMMY]->status) );
+ setValueInConfigFile(configFile, "GUN_LASSER", getYesOrNo(check[GUN_LASSER]->status) );
+ setValueInConfigFile(configFile, "GUN_MINE", getYesOrNo(check[GUN_MINE]->status) );
+ setValueInConfigFile(configFile, "GUN_BOMBBALL", getYesOrNo(check[GUN_BOMBBALL]->status) );
+ setValueInConfigFile(configFile, "BONUS_SPEED", getYesOrNo(check[BONUS_SPEED]->status) );
+ setValueInConfigFile(configFile, "BONUS_SHOT", getYesOrNo(check[BONUS_SHOT]->status) );
+ setValueInConfigFile(configFile, "BONUS_TELEPORT", getYesOrNo(check[BONUS_TELEPORT]->status) );
+ setValueInConfigFile(configFile, "BONUS_GHOST", getYesOrNo(check[BONUS_GHOST]->status) );
+ setValueInConfigFile(configFile, "BONUS_4X", getYesOrNo(check[BONUS_4X]->status) );
+ setValueInConfigFile(configFile, "BONUS_HIDDEN", getYesOrNo(check[BONUS_HIDDEN]->status) );
+
+#ifndef NO_SOUND
+ setValueInConfigFile(configFile, "MUSIC", getYesOrNo(check_music->status) );
+ setValueInConfigFile(configFile, "SOUND", getYesOrNo(check_sound->status) );
+#endif
+
+ saveTextFile(configFile);
+ destroyTextFile(configFile);
+}
+
+static void findModulesAI()
+{
+ director_t *listModules;
+ int i;
+
+ listModules = loadDirector(PATH_MODULES);
+
+ for( i = 0 ; i < listModules->list->count ; i++)
+ {
+ char *line;
+
+ line = (char *)listModules->list->list[i];
+
+ if( strstr(line,"AI") != NULL &&
+ strstr(line,".so") != NULL )
+ {
+ addToWidgetSelect(select_ai, line);
+ }
+ }
+
+ destroyDirector(listModules);
+}
+
+void initScreenSetting()
+{
+ SDL_Surface *image;
+ int i;
+
+ image = getImage(IMAGE_GROUP_BASE, "screen_main");
+ image_backgorund = newWidgetImage(0, 0, image);
+
+ button_back = newWidgetButton(getMyText("BACK"), WINDOW_SIZE_X-200, WINDOW_SIZE_Y-100, eventWidget);
+
+ label_count_round = newWidgetLabel(getMyText("COUNT_ROUND"), 100, WINDOW_SIZE_Y-200, WIDGET_LABEL_LEFT);
+ label_name_player1 = newWidgetLabel(getMyText("NAME_PLAYER1"), 100, WINDOW_SIZE_Y-160, WIDGET_LABEL_LEFT);
+ label_name_player2 = newWidgetLabel(getMyText("NAME_PLAYER2"), 100, WINDOW_SIZE_Y-120, WIDGET_LABEL_LEFT);
+ label_ai = newWidgetLabel("AI :", 430, 400, WIDGET_LABEL_LEFT);
+
+ textfield_count_cound = newWidgetTextfield(getParamElse("--count", "15"), 110+label_count_round->w, WINDOW_SIZE_Y-200);
+
+ textfield_name_player1 = newWidgetTextfield(getParamElse("--name1", "name1"), 110+label_name_player1->w, WINDOW_SIZE_Y-160);
+ textfield_name_player2 = newWidgetTextfield(getParamElse("--name2", "name2"), 110+label_name_player2->w, WINDOW_SIZE_Y-120);
+
+#ifndef NO_SOUND
+ label_music = newWidgetLabel(getMyText("MUSIC"), 100, WINDOW_SIZE_Y-85, WIDGET_LABEL_LEFT);
+ check_music = newWidgetCheck(label_music->x + label_music->w + 10,
+ WINDOW_SIZE_Y-80, isMusicActive() , eventWidget);
+ label_sound = newWidgetLabel(getMyText("SOUND"), check_music->x + WIDGET_CHECK_WIDTH + 10,
+ WINDOW_SIZE_Y-85, WIDGET_LABEL_LEFT);
+ check_sound = newWidgetCheck(label_sound->x + label_sound->w + 10,
+ WINDOW_SIZE_Y-80, isSoundActive() , eventWidget);
+#endif
+
+ for( i = GUN_DUAL_SIMPLE ; i <= GUN_BOMBBALL ; i++ )
+ {
+ int x = 0;
+ int y = 0;
+
+ if( i >= GUN_DUAL_SIMPLE && i <= GUN_TOMMY )
+ {
+ x = 100;
+ y = 200 + ( i - GUN_DUAL_SIMPLE ) * 50;
+ }
+
+ if( i >= GUN_LASSER && i <= GUN_BOMBBALL )
+ {
+ x = 250;
+ y = 200 + ( i - GUN_LASSER ) * 50;
+ }
+
+ check[i] = newWidgetCheck(x, y, TRUE, NULL);
+ }
+
+ for( i = BONUS_SPEED ; i <= BONUS_HIDDEN ; i++ )
+ {
+ int x = 0;
+ int y = 0;
+
+ if( i >= BONUS_SPEED && i <= BONUS_TELEPORT )
+ {
+ x = 430;
+ y = 200 + ( i - BONUS_SPEED ) * 50;
+ }
+
+ if( i >= BONUS_GHOST && i <= BONUS_HIDDEN )
+ {
+ x = 580;
+ y = 200 + ( i - BONUS_GHOST ) * 50;
+ }
+
+ check[i] = newWidgetCheck(x, y, TRUE, NULL);
+ }
+
+ image_gun_dual_revolver = newWidgetImage(110 + WIDGET_CHECK_WIDTH, 200, getImage(IMAGE_GROUP_BASE, "panel_dual"));
+ image_gun_scatter = newWidgetImage(110 + WIDGET_CHECK_WIDTH, 250, getImage(IMAGE_GROUP_BASE, "panel_scatter"));
+ image_gun_tommy = newWidgetImage(110 + WIDGET_CHECK_WIDTH, 300, getImage(IMAGE_GROUP_BASE, "panel_tommy"));
+ image_gun_lasser = newWidgetImage(260 + WIDGET_CHECK_WIDTH, 200, getImage(IMAGE_GROUP_BASE, "panel_lasser"));
+ image_gun_mine = newWidgetImage(260 + WIDGET_CHECK_WIDTH, 250, getImage(IMAGE_GROUP_BASE, "panel_mine"));
+ image_gun_bombball = newWidgetImage(260 + WIDGET_CHECK_WIDTH, 300, getImage(IMAGE_GROUP_BASE, "panel_bombball"));
+
+ image_bonus_speed = newWidgetImage(430 + WIDGET_CHECK_WIDTH, 200, getImage(IMAGE_GROUP_BASE, "panel_speed"));;
+ image_bonus_shot = newWidgetImage(430 + WIDGET_CHECK_WIDTH, 250, getImage(IMAGE_GROUP_BASE, "panel_shot"));;
+ image_bonus_teleport = newWidgetImage(430 + WIDGET_CHECK_WIDTH, 300, getImage(IMAGE_GROUP_BASE, "panel_teleport"));;
+ image_bonus_ghost = newWidgetImage(580 + WIDGET_CHECK_WIDTH, 200, getImage(IMAGE_GROUP_BASE, "panel_ghost"));;
+ image_bonus_4x = newWidgetImage(580 + WIDGET_CHECK_WIDTH, 250, getImage(IMAGE_GROUP_BASE, "panel_4x"));;
+ image_bonus_hidden = newWidgetImage(580 + WIDGET_CHECK_WIDTH, 300, getImage(IMAGE_GROUP_BASE, "panel_hidden"));;
+
+ registerScreen( newScreen("setting", startScreenSetting, eventScreenSetting,
+ drawScreenSetting, stopScreenSetting) );
+
+ initSettingFile();
+
+ select_ai = newWidgetSelect(label_ai->x, label_ai->y+40, eventWidget);
+ addToWidgetSelect(select_ai, "none");
+ findModulesAI();
+
+#ifndef NO_SOUND
+ eventWidget(check_music);
+ eventWidget(check_sound);
+#endif
+}
+
+void getSettingNameRight(char *s)
+{
+ strcpy(s, textfield_name_player1->text);
+}
+
+void getSettingNameLeft(char *s)
+{
+ strcpy(s, textfield_name_player2->text);
+}
+
+void getSettingCountRound(int *n)
+{
+ *n = atoi( textfield_count_cound->text );
+}
+
+char* getSettingAI()
+{
+ return (char *) select_ai->list->list[ select_ai->select ];
+}
+
+bool_t isSettingAnyItem()
+{
+ int i;
+
+ for( i = GUN_DUAL_SIMPLE ; i <= GUN_BOMBBALL ; i++ )
+ {
+ if( check[i]->status == TRUE )
+ {
+ return TRUE;
+ }
+ }
+
+ for( i = BONUS_SPEED ; i <= BONUS_HIDDEN ; i++ )
+ {
+ if( check[i]->status == TRUE )
+ {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+bool_t isSettingItem(int item)
+{
+ return check[item]->status;
+}
+
+void quitScreenSetting()
+{
+ int i;
+
+ saveAndDestroyConfigFile();
+
+ destroyWidgetImage(image_backgorund);
+
+ destroyWidgetLabel(label_count_round);
+ destroyWidgetLabel(label_name_player1);
+ destroyWidgetLabel(label_name_player2);
+ destroyWidgetLabel(label_ai);
+
+#ifndef NO_SOUND
+ destroyWidgetLabel(label_music);
+ destroyWidgetLabel(label_sound);
+#endif
+
+ destroyWidgetTextfield(textfield_count_cound);
+ destroyWidgetTextfield(textfield_name_player1);
+ destroyWidgetTextfield(textfield_name_player2);
+
+ destroyWidgetImage(image_gun_dual_revolver);
+ destroyWidgetImage(image_gun_scatter);
+ destroyWidgetImage(image_gun_tommy);
+ destroyWidgetImage(image_gun_lasser);
+ destroyWidgetImage(image_gun_mine);
+ destroyWidgetImage(image_gun_bombball);
+
+ destroyWidgetImage(image_bonus_speed);
+ destroyWidgetImage(image_bonus_shot);
+ destroyWidgetImage(image_bonus_teleport);
+ destroyWidgetImage(image_bonus_ghost);
+ destroyWidgetImage(image_bonus_4x);
+ destroyWidgetImage(image_bonus_hidden);
+
+#ifndef NO_SOUND
+ destroyWidgetCheck(check_music);
+ destroyWidgetCheck(check_sound);
+#endif
+
+ for( i = GUN_DUAL_SIMPLE ; i <= GUN_BOMBBALL ; i++ )
+ {
+ destroyWidgetCheck(check[i]);
+ }
+
+ for( i = BONUS_SPEED ; i <= BONUS_HIDDEN ; i++ )
+ {
+ destroyWidgetCheck(check[i]);
+ }
+
+ destroyWidgetSelect(select_ai);
+
+ destroyWidgetButton(button_back);
+}
+
diff --git a/src/screen/screen_setting.h b/src/screen/screen_setting.h
new file mode 100644
index 0000000..5b0bae3
--- /dev/null
+++ b/src/screen/screen_setting.h
@@ -0,0 +1,20 @@
+
+#ifndef SCREEN_SETTING
+
+#define SCREEN_SETTING
+
+#include "base/main.h"
+
+extern void initScreenSetting();
+extern void drawScreenSetting();
+extern void eventScreenSetting();
+extern void getSettingNameRight(char *s);
+extern void getSettingNameLeft(char *s);
+extern void getSettingCountRound(int *n);
+extern char* getSettingAI();
+extern bool_t isSettingAnyItem();
+extern bool_t isSettingItem(int item);
+extern void quitScreenSetting();
+
+#endif
+
diff --git a/src/screen/screen_table.c b/src/screen/screen_table.c
new file mode 100644
index 0000000..df1b7d5
--- /dev/null
+++ b/src/screen/screen_table.c
@@ -0,0 +1,240 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#include "base/main.h"
+#include "base/list.h"
+#include "base/textFile.h"
+#include "base/homeDirector.h"
+
+#include "client/language.h"
+#include "client/interface.h"
+#include "client/screen.h"
+#include "client/image.h"
+
+#ifndef NO_SOUND
+#include "audio/music.h"
+#endif
+
+#include "screen/screen_table.h"
+
+#include "widget/widget_image.h"
+#include "widget/widget_label.h"
+#include "widget/widget_button.h"
+
+static widget_image_t *image_backgorund;
+static widget_button_t *button_back;
+
+static list_t *listWidgetLabelNumer;
+static list_t *listWidgetLabelName;
+static list_t *listWidgetLabelScore;
+
+static textFile_t *textFile;
+
+void startScreenTable()
+{
+#ifndef NO_SOUND
+ playMusic("menu", MUSIC_GROUP_BASE);
+#endif
+}
+
+void drawScreenTable()
+{
+ int i;
+
+ drawWidgetImage(image_backgorund);
+
+ drawWidgetButton(button_back);
+
+ for( i = 0 ; i < listWidgetLabelNumer->count ; i++ )
+ {
+ widget_label_t *this;
+ this = (widget_label_t *)listWidgetLabelNumer->list[i];
+ drawWidgetLabel(this);
+ }
+
+ for( i = 0 ; i < listWidgetLabelName->count ; i++ )
+ {
+ widget_label_t *this;
+ this = (widget_label_t *)listWidgetLabelName->list[i];
+ drawWidgetLabel(this);
+ }
+
+ for( i = 0 ; i < listWidgetLabelScore->count ; i++ )
+ {
+ widget_label_t *this;
+ this = (widget_label_t *)listWidgetLabelScore->list[i];
+ drawWidgetLabel(this);
+ }
+}
+
+void eventScreenTable()
+{
+ eventWidgetButton(button_back);
+}
+
+void stopScreenTable()
+{
+}
+
+static void eventWidget(void *p)
+{
+ widget_button_t *button;
+
+ button = (widget_button_t *)(p);
+
+ if( button == button_back )
+ {
+ setScreen("mainMenu");
+ }
+}
+
+static void setWidgetLabel()
+{
+ int i;
+
+ if( textFile == NULL )
+ {
+ fprintf(stderr, "File %s not loaded !",
+ SCREEN_TABLE_FILE_HIGHSCORE_NAME);
+
+ return;
+ }
+
+ if( listWidgetLabelNumer != NULL ||
+ listWidgetLabelName != NULL ||
+ listWidgetLabelScore != NULL )
+ {
+ destroyListItem(listWidgetLabelNumer, destroyWidgetLabel);
+ destroyListItem(listWidgetLabelName, destroyWidgetLabel);
+ destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
+ }
+
+ listWidgetLabelNumer = newList();
+ listWidgetLabelName = newList();
+ listWidgetLabelScore = newList();
+
+ for( i = 0 ; i < SCREEN_TABLE_MAX_PLAYERS ; i++ )
+ {
+ widget_label_t *label;
+ char name[STR_NAME_SIZE];
+ char score[STR_NUM_SIZE];
+ char num[STR_NUM_SIZE];
+ char *line;
+
+ line = (char *) textFile->text->list[i];
+
+ sscanf(line, "%s %s", name, score);
+ sprintf(num, "%2d)", i+1);
+
+ label = newWidgetLabel(num, WINDOW_SIZE_X/2 - 100, 200 + i * 20, WIDGET_LABEL_LEFT);
+ addList(listWidgetLabelNumer, label);
+
+ label = newWidgetLabel(name, WINDOW_SIZE_X/2, 200 + i * 20, WIDGET_LABEL_CENTER);
+ addList(listWidgetLabelName, label);
+
+ label = newWidgetLabel(score, WINDOW_SIZE_X/2 + 80, 200 + i * 20, WIDGET_LABEL_LEFT);
+ addList(listWidgetLabelScore, label);
+ }
+}
+
+static void loadHighscoreFile()
+{
+ char path[STR_PATH_SIZE];
+ int i;
+
+ sprintf(path, "%s/" SCREEN_TABLE_FILE_HIGHSCORE_NAME , getHomeDirector());
+ textFile = loadTextFile(path);
+
+ if( textFile == NULL )
+ {
+ fprintf(stderr, "I can't load %s !\n", path);
+ fprintf(stderr, "I create %s\n", path);
+ textFile = newTextFile(path);
+ }
+ else
+ {
+ return;
+ }
+
+ if( textFile == NULL )
+ {
+ fprintf(stderr, "I can't create %s !\n", path);
+ return;
+ }
+
+ for( i = 0 ; i < SCREEN_TABLE_MAX_PLAYERS ; i++ )
+ {
+ addList(textFile->text, strdup("no_name 0") );
+ }
+
+ saveTextFile(textFile);
+}
+
+int addPlayerInHighScore(char *name, int score)
+{
+ int i;
+
+ for( i = 0 ; i < SCREEN_TABLE_MAX_PLAYERS ; i++ )
+ {
+ char *line;
+ char thisName[STR_NAME_SIZE];
+ int thisCore;
+
+ line = (char *) textFile->text->list[i];
+ sscanf(line, "%s %d", thisName, &thisCore);
+
+ if( score >= thisCore )
+ {
+ char new[STR_SIZE];
+
+ sprintf(new, "%s %d", name, score);
+ insList(textFile->text, i, strdup(new) );
+ delListItem(textFile->text, SCREEN_TABLE_MAX_PLAYERS, free);
+ setWidgetLabel();
+
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+void initScreenTable()
+{
+ SDL_Surface *image;
+
+
+ image = addImageData("screen_table.png", IMAGE_NO_ALPHA, "screen_table", IMAGE_GROUP_BASE);
+ image_backgorund = newWidgetImage(0, 0, image);
+
+ button_back = newWidgetButton(getMyText("BACK"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2,
+ WINDOW_SIZE_Y-100, eventWidget);
+
+ loadHighscoreFile();
+ listWidgetLabelNumer = NULL;
+ listWidgetLabelName = NULL;
+ listWidgetLabelScore = NULL;
+ setWidgetLabel();
+
+ registerScreen( newScreen("table", startScreenTable, eventScreenTable,
+ drawScreenTable, stopScreenTable) );
+}
+
+void quitScreenTable()
+{
+ destroyWidgetImage(image_backgorund);
+
+ destroyWidgetButton(button_back);
+ destroyListItem(listWidgetLabelNumer, destroyWidgetLabel);
+ destroyListItem(listWidgetLabelName, destroyWidgetLabel);
+ destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
+
+ if( textFile != NULL )
+ {
+ saveTextFile(textFile);
+ destroyTextFile(textFile);
+ }
+}
+
diff --git a/src/screen/screen_table.h b/src/screen/screen_table.h
new file mode 100644
index 0000000..d16cbbb
--- /dev/null
+++ b/src/screen/screen_table.h
@@ -0,0 +1,17 @@
+
+#ifndef SCREEN_TABLE_H
+
+#define SCREEN_TABLE_H
+
+#define SCREEN_TABLE_MAX_PLAYERS 10
+#define SCREEN_TABLE_FILE_HIGHSCORE_NAME "highscore"
+
+extern void startScreenTable();
+extern void drawScreenTable();
+extern void eventScreenTable();
+extern void stopScreenTable();
+extern int addPlayerInHighScore(char *name, int score);
+extern void initScreenTable();
+extern void quitScreenTable();
+
+#endif
diff --git a/src/screen/screen_world.c b/src/screen/screen_world.c
new file mode 100644
index 0000000..296c31f
--- /dev/null
+++ b/src/screen/screen_world.c
@@ -0,0 +1,603 @@
+
+#include <stdio.h>
+#include <assert.h>
+
+#include "base/main.h"
+#include "base/list.h"
+#include "base/tux.h"
+#include "base/item.h"
+#include "base/shot.h"
+#include "base/gun.h"
+#include "base/myTimer.h"
+#include "base/net_multiplayer.h"
+#include "base/arena.h"
+#include "base/arenaFile.h"
+#include "base/proto.h"
+#include "base/modules.h"
+#include "base/idManager.h"
+
+#include "client/interface.h"
+#include "client/keytable.h"
+#include "client/layer.h"
+#include "client/image.h"
+//#include "client/heightScore.h"
+#include "client/term.h"
+#include "client/font.h"
+#include "client/panel.h"
+
+#ifndef NO_SOUND
+#include "audio/music.h"
+#include "audio/sound.h"
+#endif
+
+#include "client/screen.h"
+#include "screen/screen_world.h"
+#include "screen/screen_analyze.h"
+#include "screen/screen_setting.h"
+#include "screen/screen_gameType.h"
+#include "screen/screen_choiceArena.h"
+#include "screen/screen_table.h"
+
+
+static arena_t *arena;
+static int count;
+static int max_count;
+static my_time_t lastServerLag;
+static bool_t isScreenWorldInit = FALSE;
+static bool_t isEndWorld;
+
+static tux_t *tuxWithControlRightKeyboard;
+static tux_t *tuxWithControlLeftKeyboard;
+
+bool_t isScreenWorldInicialized()
+{
+ return isScreenWorldInit;
+}
+
+void setGameType()
+{
+ int ret = 0;
+
+ ret = initNetMuliplayer( getSettingGameType(), getSettingIP(), getSettingPort(), getSettingProto() );
+
+ if( ret != 0 )
+ {
+ fprintf(stderr, "Chyba inicalizacie sieti !\n");
+ setWorldEnd();
+ }
+}
+
+void setWorldArena(int id)
+{
+ arena = getArena(id);
+
+#ifndef NO_SOUND
+ playMusic(arena->music, MUSIC_GROUP_USER);
+#endif
+}
+
+void setMaxCountRound(int n)
+{
+ max_count = n;
+}
+
+void setLagServer(my_time_t lag)
+{
+ lastServerLag = lag;
+}
+
+void setWorldEnd()
+{
+ isEndWorld = TRUE;
+}
+
+static void timer_endArena()
+{
+ if( getNetTypeGame() != NET_GAME_TYPE_CLIENT )
+ {
+ setWorldEnd();
+ return;
+ }
+}
+
+void countRoundInc()
+{
+ if( count == WORLD_COUNT_ROUND_UNLIMITED ||
+ count >= max_count )
+ {
+ return;
+ }
+
+ count++;
+ //printf("count %d/%d\n", count, max_count);
+
+ if( count >= max_count )
+ {
+ printf("count %d ending\n", count);
+#ifndef NO_SOUND
+ playSound("end", SOUND_GROUP_BASE);
+#endif
+ addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_endArena, NULL, TIMER_END_ARENA);
+ }
+}
+
+void prepareArena()
+{
+ tux_t *tux;
+
+ //printf("getSettingAI = %s\n", getSettingAI());
+
+ switch( getNetTypeGame() )
+ {
+ case NET_GAME_TYPE_NONE :
+ setWorldArena( getChoiceArenaId() );
+ addNewItem(arena->spaceItem, ID_UNKNOWN);
+ getSettingCountRound(&max_count);
+
+ tux = newTux();
+ tux->control = TUX_CONTROL_KEYBOARD_RIGHT;
+ tuxWithControlRightKeyboard = tux;
+ getSettingNameRight(tux->name);
+ addObjectToSpace(arena->spaceTux, tux);
+
+ tux = newTux();
+ tux->control = TUX_CONTROL_KEYBOARD_LEFT;
+ tuxWithControlLeftKeyboard = tux;
+ getSettingNameLeft(tux->name);
+ addObjectToSpace(arena->spaceTux, tux);
+
+ if( strcmp(getSettingAI(), "none") != 0 )
+ {
+ loadModule( getSettingAI() );
+ tux->control = TUX_CONTROL_AI;
+ }
+ break;
+
+ case NET_GAME_TYPE_SERVER :
+ setWorldArena( getChoiceArenaId() );
+ addNewItem(arena->spaceItem, ID_UNKNOWN);
+ getSettingCountRound(&max_count);
+
+ tux = newTux();
+ tux->control = TUX_CONTROL_KEYBOARD_RIGHT;
+ tuxWithControlRightKeyboard = tux;
+ getSettingNameRight(tux->name);
+ addObjectToSpace(arena->spaceTux, tux);
+ break;
+
+ case NET_GAME_TYPE_CLIENT :
+ break;
+ }
+}
+
+/*
+static void drawServerLag()
+{
+ char msg[STR_SIZE];
+
+ if( lastServerLag == LAG_SERVER_UNKNOWN )
+ {
+ sprintf(msg, "lag server: unknown");
+ }
+ else
+ {
+ sprintf(msg, "lag server: %d", lastServerLag);
+ }
+
+ drawFont(msg, WINDOW_SIZE_X-150, 20, COLOR_WHITE);
+
+}
+*/
+
+void drawWorld()
+{
+ if( arena != NULL )
+ {
+ drawArena(arena);
+ drawPanel(arena->spaceTux->list);
+ }
+
+ drawTerm();
+}
+
+static void netAction(tux_t *tux, int action)
+{
+ if( getSettingGameType() == NET_GAME_TYPE_SERVER )
+ {
+ proto_send_event_server(PROTO_SEND_ALL_SEES_TUX, NULL, tux , action);
+ }
+
+ if( getSettingGameType() == NET_GAME_TYPE_CLIENT )
+ {
+ proto_send_event_client(action);
+ }
+}
+
+static void control_keyboard_right(tux_t *tux)
+{
+ static int lastKey = 0;
+ int countKey;
+ Uint8 *mapa;
+ mapa = SDL_GetKeyState(NULL);
+
+ assert( tux != NULL );
+ assert( mapa != NULL );
+
+ countKey = 0;
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_UP)] == SDL_PRESSED )countKey++;
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_RIGHT)] == SDL_PRESSED )countKey++;
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_LEFT)] == SDL_PRESSED )countKey++;
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_DOWN)] == SDL_PRESSED )countKey++;
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_UP)] == SDL_PRESSED )
+ {
+ if(countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_UP) )goto tuUp;
+
+ if( countKey == 1 )lastKey = getKey(KEY_TUX_RIGHT_MOVE_UP);
+ netAction(tux, TUX_UP);
+ actionTux(tux, TUX_UP);
+ return;
+
+ tuUp:;
+ }
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_RIGHT)] == SDL_PRESSED )
+ {
+ if(countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_RIGHT) )goto tuRight;
+
+ if( countKey == 1 )lastKey = getKey(KEY_TUX_RIGHT_MOVE_RIGHT);
+ netAction(tux, TUX_RIGHT);
+ actionTux(tux, TUX_RIGHT);
+ return;
+
+ tuRight:;
+
+ }
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_LEFT)] == SDL_PRESSED )
+ {
+ if(countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_LEFT) )goto tuLeft;
+
+ if( countKey == 1 )lastKey = getKey(KEY_TUX_RIGHT_MOVE_LEFT);
+ netAction(tux, TUX_LEFT);
+ actionTux(tux, TUX_LEFT);
+ return;
+
+ tuLeft:;
+ }
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_DOWN)] == SDL_PRESSED )
+ {
+ if(countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_DOWN) )goto tuDown;
+
+ if( countKey == 1 )lastKey = getKey(KEY_TUX_RIGHT_MOVE_DOWN);
+ netAction(tux, TUX_DOWN);
+ actionTux(tux, TUX_DOWN);
+ return;
+
+ tuDown:;
+ }
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_SHOOT)] == SDL_PRESSED && tux->isCanShot == TRUE )
+ {
+ netAction(tux, TUX_SHOT);
+ actionTux(tux, TUX_SHOT);
+ return;
+ }
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_SWITCH_WEAPON)] == SDL_PRESSED )
+ {
+ if( tux->isCanSwitchGun == TRUE )
+ {
+ netAction(tux, TUX_SWITCH_GUN);
+ actionTux(tux, TUX_SWITCH_GUN);
+ return;
+ }
+ }
+}
+
+static void control_keyboard_left(tux_t *tux)
+{
+ static int lastKey = 0;
+ int countKey;
+ Uint8 *mapa;
+ mapa = SDL_GetKeyState(NULL);
+
+ assert( tux != NULL );
+ assert( mapa != NULL );
+
+ countKey = 0;
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_UP)] == SDL_PRESSED )countKey++;
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_RIGHT)] == SDL_PRESSED )countKey++;
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_LEFT)] == SDL_PRESSED )countKey++;
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_DOWN)] == SDL_PRESSED )countKey++;
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_UP)] == SDL_PRESSED )
+ {
+ if(countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_UP) )goto tuUp;
+
+ if( countKey == 1 )lastKey = getKey(KEY_TUX_LEFT_MOVE_UP);
+ actionTux(tux, TUX_UP);
+ return;
+
+ tuUp:;
+ }
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_RIGHT)] == SDL_PRESSED )
+ {
+ if(countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_RIGHT) )goto tuRight;
+
+ if( countKey == 1 )lastKey = getKey(KEY_TUX_LEFT_MOVE_RIGHT);
+ actionTux(tux, TUX_RIGHT);
+ return;
+
+ tuRight:;
+
+ }
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_LEFT)] == SDL_PRESSED )
+ {
+ if(countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_LEFT) )goto tuLeft;
+
+ if( countKey == 1 )lastKey = getKey(KEY_TUX_LEFT_MOVE_LEFT);
+ actionTux(tux, TUX_LEFT);
+ return;
+
+ tuLeft:;
+ }
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_DOWN)] == SDL_PRESSED )
+ {
+ if(countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_DOWN) )goto tuDown;
+
+ if( countKey == 1 )lastKey = getKey(KEY_TUX_LEFT_MOVE_DOWN);
+ actionTux(tux, TUX_DOWN);
+ return;
+
+ tuDown:;
+ }
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_SHOOT)] == SDL_PRESSED && tux->isCanShot == TRUE )
+ {
+ actionTux(tux, TUX_SHOT);
+ return;
+ }
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_SWITCH_WEAPON)] == SDL_PRESSED )
+ {
+ if( tux->isCanSwitchGun == TRUE )
+ {
+ actionTux(tux, TUX_SWITCH_GUN);
+ return;
+ }
+ }
+/*
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_UP)] == SDL_PRESSED )actionTux(tux, TUX_UP);
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_RIGHT)] == SDL_PRESSED )actionTux(tux, TUX_RIGHT);
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_LEFT)] == SDL_PRESSED )actionTux(tux, TUX_LEFT);
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_DOWN)] == SDL_PRESSED )actionTux(tux, TUX_DOWN);
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_SHOOT)] == SDL_PRESSED )actionTux(tux, TUX_SHOT);
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_SWITCH_WEAPON)] == SDL_PRESSED )
+ {
+ if( tux->isCanSwitchGun == TRUE )
+ {
+ actionTux(tux, TUX_SWITCH_GUN);
+ }
+ }
+*/
+}
+
+static void eventEsc()
+{
+ Uint8 *mapa;
+ mapa = SDL_GetKeyState(NULL);
+
+ if( mapa[(SDLKey)SDLK_ESCAPE] == SDL_PRESSED )
+ {
+ isEndWorld = TRUE;
+ setWorldEnd();
+ return;
+ }
+}
+
+static void eventEnd()
+{
+ if( isEndWorld == TRUE )
+ {
+ setScreen("analyze");
+ return;
+ }
+}
+
+tux_t* getControlTux(int control_type)
+{
+ switch(control_type)
+ {
+ case TUX_CONTROL_KEYBOARD_RIGHT :
+ return tuxWithControlRightKeyboard;
+ break;
+ case TUX_CONTROL_KEYBOARD_LEFT :
+ return tuxWithControlLeftKeyboard;
+ break;
+ }
+
+ return NULL;
+}
+
+void setControlTux(tux_t *tux, int control_type)
+{
+ switch(control_type)
+ {
+ case TUX_CONTROL_KEYBOARD_RIGHT :
+ tuxWithControlRightKeyboard = tux;
+ break;
+ case TUX_CONTROL_KEYBOARD_LEFT :
+ tuxWithControlLeftKeyboard = tux;
+ break;
+ }
+}
+
+void tuxControl(tux_t *p)
+{
+ assert( p != NULL );
+
+ if( p->status != TUX_STATUS_ALIVE )
+ {
+ return;
+ }
+
+ switch( p->control )
+ {
+ case TUX_CONTROL_NONE :
+ assert( ! "Tux nema definovane ovladanie !" );
+ break;
+
+ case TUX_CONTROL_KEYBOARD_LEFT :
+ control_keyboard_left(p);
+ break;
+
+ case TUX_CONTROL_KEYBOARD_RIGHT :
+ control_keyboard_right(p);
+ break;
+ }
+}
+
+void eventWorld()
+{
+ if( arena == NULL )
+ {
+ eventNetMultiplayer();
+ eventEnd();
+ eventEsc();
+ return;
+ }
+
+ eventNetMultiplayer();
+
+ eventArena(arena);
+ //eventModule();
+
+ eventTerm();
+ eventEnd();
+ eventEsc();
+}
+
+void startWorld()
+{
+ arena = NULL;
+ isEndWorld = FALSE;
+
+ count = 0;
+ lastServerLag = LAG_SERVER_UNKNOWN;
+
+ initListID();
+ initModule();
+ setGameType();
+ initTerm();
+ prepareArena();
+}
+
+static void setAnalyze()
+{
+ int i;
+ tux_t *tux;
+
+ restartAnalyze();
+
+ for( i = 0 ; i < arena->spaceTux->list->count ; i++ )
+ {
+ tux = (tux_t *)(arena->spaceTux->list->list[i]);
+ addAnalyze(tux->name, tux->score);
+ }
+
+ endAnalyze();
+}
+
+static void setTable()
+{
+ tux_t *tuxRight;
+ tux_t *tuxLeft;
+
+ if( getSettingGameType() != NET_GAME_TYPE_NONE )
+ {
+ return;
+ }
+
+ tuxRight = getControlTux(TUX_CONTROL_KEYBOARD_RIGHT);
+ tuxLeft = getControlTux(TUX_CONTROL_KEYBOARD_LEFT);
+
+ if( tuxRight->score > tuxLeft->score )
+ {
+ addPlayerInHighScore(tuxRight->name, tuxRight->score);
+ }
+
+ if( tuxLeft->score > tuxRight->score )
+ {
+ addPlayerInHighScore(tuxLeft->name, tuxLeft->score);
+ }
+}
+
+void stoptWorld()
+{
+ if( arena != NULL )
+ {
+ setTable();
+ setAnalyze();
+ }
+
+ quitNetMultiplayer();
+
+ if( arena != NULL )
+ {
+ destroyArena(arena);
+ }
+
+#ifndef NO_SOUND
+ stopMusic();
+#endif
+ delAllImageInGroup(IMAGE_GROUP_USER);
+
+#ifndef NO_SOUND
+ delAllMusicInGroup(MUSIC_GROUP_USER);
+#endif
+ quitModule();
+ quitTerm();
+ quitListID();
+}
+
+void initWorld()
+{
+ assert( isImageInicialized() == TRUE );
+ assert( isTuxInicialized() == TRUE );
+ assert( isShotInicialized() == TRUE );
+ assert( isPanelInicialized() == TRUE );
+ assert( isScreenInicialized() == TRUE );
+
+ registerScreen( newScreen("world", startWorld, eventWorld, drawWorld, stoptWorld) );
+
+#ifndef NO_SOUND
+ addSound("dead.ogg", "dead", SOUND_GROUP_BASE);
+ addSound("explozion.ogg", "explozion", SOUND_GROUP_BASE);
+ addSound("gun_lasser.ogg", "gun_lasser", SOUND_GROUP_BASE);
+ addSound("gun_revolver.ogg", "gun_revolver", SOUND_GROUP_BASE);
+ addSound("gun_scatter.ogg", "gun_scatter", SOUND_GROUP_BASE);
+ addSound("gun_tommy.ogg", "gun_tommy", SOUND_GROUP_BASE);
+ addSound("put_mine.ogg", "put_mine", SOUND_GROUP_BASE);
+ addSound("teleport.ogg", "teleport", SOUND_GROUP_BASE);
+ addSound("item_bonus.ogg", "item_bonus", SOUND_GROUP_BASE);
+ addSound("item_gun.ogg", "item_gun", SOUND_GROUP_BASE);
+ addSound("switch_gun.ogg", "switch_gun", SOUND_GROUP_BASE);
+ addSound("end.ogg", "end", SOUND_GROUP_BASE);
+#endif
+
+ isScreenWorldInit = TRUE;
+}
+
+void quitWorld()
+{
+ printf("quit world\n");
+ isScreenWorldInit = FALSE;
+}
diff --git a/src/screen/screen_world.h b/src/screen/screen_world.h
new file mode 100644
index 0000000..270d144
--- /dev/null
+++ b/src/screen/screen_world.h
@@ -0,0 +1,31 @@
+
+#ifndef SCREEN_WORLD_H
+
+#define SCREEN_WORLD_H
+
+#include "base/main.h"
+#include "base/myTimer.h"
+#include "base/tux.h"
+#include "base/arena.h"
+
+#define TIMER_END_ARENA 5000
+#define WORLD_COUNT_ROUND_UNLIMITED -1
+#define LAG_SERVER_UNKNOWN -1
+
+extern bool_t isScreenWorldInicialized();
+extern void initWorld();
+extern void setWorldArena(int id);
+extern void setLagServer(my_time_t lag);
+extern void countRoundInc();
+extern void setWorldEnd();
+extern void setMaxCountRound(int n);
+extern tux_t* getControlTux(int control_type);
+extern void setControlTux(tux_t *tux, int control_type);
+extern void tuxControl(tux_t *p);
+extern void drawWorld();
+extern void eventWorld();
+extern void startArena();
+extern void stopArena();
+extern void quitWorld();
+
+#endif