summaryrefslogtreecommitdiff
path: root/src/screen
diff options
context:
space:
mode:
Diffstat (limited to 'src/screen')
-rw-r--r--src/screen/CMakeLists.txt7
-rw-r--r--src/screen/analyze.c186
-rw-r--r--src/screen/analyze.h22
-rw-r--r--src/screen/browser.c759
-rw-r--r--src/screen/browser.h30
-rw-r--r--src/screen/choiceArena.c265
-rw-r--r--src/screen/choiceArena.h17
-rw-r--r--src/screen/credits.c162
-rw-r--r--src/screen/credits.h18
-rw-r--r--src/screen/downArena.c386
-rw-r--r--src/screen/downArena.h20
-rw-r--r--src/screen/gameType.c416
-rw-r--r--src/screen/gameType.h19
-rw-r--r--src/screen/mainMenu.c149
-rw-r--r--src/screen/mainMenu.h13
-rw-r--r--src/screen/setting.c511
-rw-r--r--src/screen/setting.h21
-rw-r--r--src/screen/settingKeys.c392
-rw-r--r--src/screen/settingKeys.h28
-rw-r--r--src/screen/table.c228
-rw-r--r--src/screen/table.h15
-rw-r--r--src/screen/world.c536
-rw-r--r--src/screen/world.h29
23 files changed, 0 insertions, 4229 deletions
diff --git a/src/screen/CMakeLists.txt b/src/screen/CMakeLists.txt
deleted file mode 100644
index 2e93cef..0000000
--- a/src/screen/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-###############################################################################
-# tuxanci/src/*/CMakeLists.txt
-###############################################################################
-# Generate source_code files from .c files we find in directory
-###############################################################################
-MacroAddSources()
-###############################################################################
diff --git a/src/screen/analyze.c b/src/screen/analyze.c
deleted file mode 100644
index 450da41..0000000
--- a/src/screen/analyze.c
+++ /dev/null
@@ -1,186 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-
-#include "interface.h"
-#include "screen.h"
-#include "image.h"
-#include "hotKey.h"
-
-#ifndef NO_SOUND
-#include "music.h"
-#endif
-
-#include "mainMenu.h"
-#include "analyze.h"
-
-#include "widget.h"
-#include "widget_label.h"
-#include "widget_button.h"
-#include "widget_image.h"
-
-static widget_t *image_backgorund;
-
-static list_t *listWidgetLabelName;
-static list_t *listWidgetLabelScore;
-static list_t *listAnalyze;
-static widget_t *widgetLabelMsg;
-
-static widget_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);
-}
-
-static void hotkey_escape()
-{
- screen_set("mainMenu");
-}
-
-void analyze_start()
-{
-#ifndef NO_SOUND
- music_play("menu", MUSIC_GROUP_BASE);
-#endif
-
- hot_key_register(SDLK_ESCAPE, hotkey_escape);
-}
-
-void analyze_draw()
-{
- widget_t *this;
- int i;
-
- wid_image_draw(image_backgorund);
-
- for (i = 0; i < listWidgetLabelName->count; i++) {
- this = (widget_t *) listWidgetLabelName->list[i];
- label_draw(this);
- }
-
- for (i = 0; i < listWidgetLabelScore->count; i++) {
- this = (widget_t *) listWidgetLabelScore->list[i];
- label_draw(this);
- }
-
- label_draw(widgetLabelMsg);
- button_draw(button_ok);
-}
-
-void analyze_event()
-{
- button_event(button_ok);
-}
-
-void analyze_stop()
-{
- label_destroy(widgetLabelMsg);
- widgetLabelMsg = label_new("", WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER);
-
- hot_key_unregister(SDLK_ESCAPE);
-}
-
-static void eventWidget(void *p)
-{
- widget_t *button;
-
- button = (widget_t *) p;
-
- if (button == button_ok) {
- screen_set("mainMenu");
- }
-}
-
-void analyze_restart()
-{
- list_destroy_item(listWidgetLabelName, label_destroy);
- list_destroy_item(listWidgetLabelScore, label_destroy);
- list_destroy_item(listAnalyze, destroyAnalyze);
-
- listWidgetLabelName = list_new();
- listWidgetLabelScore = list_new();
- listAnalyze = list_new();
-}
-
-void analyze_add(char *name, int score)
-{
- list_add(listAnalyze, newAnalyze(name, score));
-}
-
-void analyze_set_msg(char *msg)
-{
- label_destroy(widgetLabelMsg);
- widgetLabelMsg = label_new(msg, WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER);
-}
-
-void analyze_end()
-{
- int i;
-
- for (i = 0; i < listAnalyze->count; i++) {
- analyze_t *this;
- char *str;
-
- this = (analyze_t *) listAnalyze->list[i];
-
- list_add(listWidgetLabelName, label_new(this->name,
- 100, 200 + 20 * i,
- WIDGET_LABEL_LEFT));
-
- str = getString(this->score);
-
- list_add(listWidgetLabelScore, label_new(str,
- WINDOW_SIZE_X - 100, 200 + 20 * i,
- WIDGET_LABEL_RIGHT));
-
- free(str);
- }
-}
-
-void analyze_init()
-{
- image_t *image;
-
- image = image_get(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = wid_image_new(0, 0, image);
-
- listWidgetLabelName = list_new();
- listWidgetLabelScore = list_new();
- listAnalyze = list_new();
-
- button_ok = button_new(_("OK"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2,
- WINDOW_SIZE_Y - 100, eventWidget);
-
- screen_register(screen_new("analyze", analyze_start, analyze_event,
- analyze_draw, analyze_stop));
-
- widgetLabelMsg = label_new("", WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER);
-}
-
-void analyze_quit()
-{
- wid_image_destroy(image_backgorund);
-
- list_destroy_item(listWidgetLabelName, label_destroy);
- list_destroy_item(listWidgetLabelScore, label_destroy);
- list_destroy_item(listAnalyze, destroyAnalyze);
-
- button_destroy(button_ok);
- label_destroy(widgetLabelMsg);
-}
diff --git a/src/screen/analyze.h b/src/screen/analyze.h
deleted file mode 100644
index 2fc2b7b..0000000
--- a/src/screen/analyze.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef SCREEN_ANALYZE_H
-#define SCREEN_ANALYZE_H
-
-#include "main.h"
-
-typedef struct analyze_struct {
- char *name;
- int score;
-} analyze_t;
-
-extern void analyze_start();
-extern void analyze_draw();
-extern void analyze_event();
-extern void analyze_stop();
-extern void analyze_restart();
-extern void analyze_add(char *name, int score);
-extern void analyze_set_msg(char *msg);
-extern void analyze_end();
-extern void analyze_init();
-extern void analyze_quit();
-
-#endif /* SCREEN_ANALYZE_H */
diff --git a/src/screen/browser.c b/src/screen/browser.c
deleted file mode 100644
index c826ce2..0000000
--- a/src/screen/browser.c
+++ /dev/null
@@ -1,759 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-#include "textFile.h"
-#include "homeDirector.h"
-#include "net_multiplayer.h"
-
-#include "interface.h"
-#include "screen.h"
-#include "image.h"
-#include "hotKey.h"
-
-#ifndef __WIN32__
-#include <sys/socket.h>
-#include <sys/select.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#else /* __WIN32__ */
-#include <windows.h>
-#include <wininet.h>
-#endif /* __WIN32__ */
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#include "udp.h"
-#include "dns.h"
-
-extern int errno;
-
-#ifndef NO_SOUND
-#include "music.h"
-#endif /* NO_SOUND */
-
-#include "gameType.h"
-#include "browser.h"
-
-#include "widget.h"
-#include "widget_image.h"
-#include "widget_label.h"
-#include "widget_button.h"
-#include "widget_select.h"
-
-#define SERVER_TIMEOUT 200
-
-static widget_t *image_backgorund;
-
-static widget_t *button_play;
-static widget_t *button_back;
-static widget_t *button_refresh;
-static widget_t *button_reload;
-
-static widget_t *label_server;
-static widget_t *label_version;
-static widget_t *label_address;
-static widget_t *label_arena;
-static widget_t *label_players;
-static widget_t *label_ping;
-
-static widget_t *select_server;
-
-static server_t server_list;
-
-/* function prototypes */
-static int LoadServers();
-static int RefreshServers();
-static server_t *server_getcurr();
-static void clear_server_list();
-
-static void hotkey_escape()
-{
- screen_set("gameType");
-}
-
-void browser_start()
-{
-#ifndef NO_SOUND
- music_play("menu", MUSIC_GROUP_BASE);
-#endif /* NO_SOUND */
-
- hot_key_register(SDLK_ESCAPE, hotkey_escape);
-
- LoadServers();
-}
-
-void browser_draw()
-{
- wid_image_draw(image_backgorund);
-
- label_draw(label_server);
- label_draw(label_version);
- label_draw(label_address);
- label_draw(label_arena);
- label_draw(label_players);
- label_draw(label_ping);
-
- select_draw(select_server);
-
- button_draw(button_play);
- button_draw(button_back);
- button_draw(button_refresh);
- button_draw(button_reload);
-}
-
-void browser_event()
-{
- select_event(select_server);
-
- button_event(button_play);
- button_event(button_back);
- button_event(button_refresh);
- button_event(button_reload);
-}
-
-void browser_stop()
-{
- select_remove_all(select_server);
-
- hot_key_unregister(SDLK_ESCAPE);
-
- clear_server_list();
-}
-
-static void eventWidget(void *p)
-{
- widget_t *button;
-
- button = (widget_t *) p;
-
- if (button == button_play) {
- server_t *server = server_getcurr();
-
- if (!server) {
- return;
- }
-
- /* server is offline */
- if (!server->state) {
- return;
- }
-
- struct in_addr srv;
- srv.s_addr = server->ip;
-
- char *address = (char *) inet_ntoa(srv);
-
- setSettingGameType(NET_GAME_TYPE_CLIENT);
- game_type_set_ip(address);
- game_type_set_port(server->port);
-
- screen_set("world");
- }
-
- if (button == button_back) {
- screen_set("gameType");
- }
-
- if (button == button_refresh) {
- RefreshServers();
- }
-
- if (button == button_reload) {
- LoadServers();
- }
-}
-
-server_t *server_getcurr()
-{
- int i = 0;
- server_t *server;
-
- for (server = server_list.next; server != &server_list; server = server->next) {
- if (i == select_get_index(select_server)) {
- return server;
- }
-
- i++;
- }
-
- return 0;
-}
-
-int server_getinfo(server_t *server)
-{
- struct sockaddr_in srv;
- int mySocket;
-
- if ((mySocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
- return -1;
- }
-#ifndef __WIN32__
- /* let's make the socket non-blocking */
- int oldFlag = fcntl(mySocket, F_GETFL, 0);
- if (fcntl(mySocket, F_SETFL, oldFlag | O_NONBLOCK) == -1) {
- return -1;
- }
-#else /* __WIN32__ */
- unsigned long arg = 1;
- /* Operation is FIONBIO. Parameter is pointer on non-zero number */
- if (ioctlsocket(mySocket, FIONBIO, &arg) == SOCKET_ERROR) {
- WSACleanup();
- return -1;
- }
-#endif /* __WIN32__ */
-
- struct timeval tv;
-
- fd_set myset;
- FD_ZERO(&myset);
- FD_SET(mySocket, &myset);
-
- tv.tv_sec = 2;
- tv.tv_usec = 0;
-
- srv.sin_family = AF_INET;
- srv.sin_port = htons(server->port);
- srv.sin_addr.s_addr = server->ip;
-
- if (connect(mySocket, (struct sockaddr *) &srv, sizeof(srv)) == -1) {
-#ifndef __WIN32__
- if (errno != EINPROGRESS) {
- return -1;
- }
-#else /* __WIN32__ */
- if (WSAGetLastError() != WSAEWOULDBLOCK) {
- WSACleanup();
- return -1;
- }
-#endif /* __WIN32__ */
- }
-
- int ret = select(mySocket + 1, NULL, &myset, NULL, &tv);
-
- if (ret == -1) {
- return 0;
- }
-
- if (ret == 0) {
- return -2;
- }
-
- char request[8];
- memcpy(request, "status\n", 7);
-
- int r = send(mySocket, request, 7, 0);
-
- if (r == -1) {
- return -2;
- }
-
- FD_ZERO(&myset);
- FD_SET(mySocket, &myset);
- tv.tv_sec = 1;
- tv.tv_usec = 0;
-
- char *str = (char *) malloc(sizeof(char) * 257);
-
- if (!str) {
- return -1;
- }
-
- while (1) {
- int sel = select(mySocket + 1, &myset, NULL, NULL, &tv);
-
- if (sel == 0) {
- free(str);
-#ifndef __WIN32__
- close(mySocket);
-#else /* __WIN32__ */
- closesocket(mySocket);
- WSACleanup();
-#endif /* __WIN32__ */
- return -2;
- }
-
- if (sel == -1) {
- free(str);
-#ifndef __WIN32__
- close(mySocket);
-#else /* __WIN32__ */
- closesocket(mySocket);
- WSACleanup();
-#endif /* __WIN32__ */
- return -2;
- }
-
- if ((ret = recv(mySocket, str, 256, 0)) == -1) {
- free(str);
-#ifndef __WIN32__
- close(mySocket);
-#else /* __WIN32__ */
- closesocket(mySocket);
- WSACleanup();
-#endif /* __WIN32__ */
- return -1;
- }
-
- if (ret > 0) {
- break;
- }
- }
-
-#ifndef __WIN32__
- close(mySocket);
-#else /* __WIN32__ */
- closesocket(mySocket);
- WSACleanup();
-#endif /* __WIN32__ */
-
- server->ping = 1000 - (tv.tv_usec / 1000);
- /*
- ["name: F\n"] >= svn82
- "version: svnX\n"
- "clients: N\n"
- "maxclients: M\n"
- "uptime: D\n"
- */
-
- int i = 0;
-
- while (i < ret) {
- if (str[i] == '\n') {
- str[i] = '\0';
- }
-
- i++;
- }
-
- unsigned name = 0;
-
- /* get server's name */
- if (strstr(str, "name: ")) {
- name = 1;
- }
-
- int len = 0;
-
- if (name) {
- len = strlen(str);
- if (!strncmp(str, "name: ", 6)) {
- unsigned name_len = strlen(str + 6);
- server->name = (char *) malloc(sizeof(char) * (name_len + 2));
-
- if (!server->name) {
- return 0;
- }
-
- memcpy(server->name, str + 6, name_len + 1);
- server->name[name_len + 1] = '\0';
- }
- }
-
- /* HACK */
- if (!name) {
- len = -1;
- }
-
- /* get server's version */
- if (!strncmp(str + len + 1, "version: ", 9)) {
- unsigned ver_len = strlen(str + len + 10);
- server->version = (char *) malloc(sizeof(char) * (ver_len + 2));
-
- if (!server->version) {
- return 0;
- }
-
- memcpy(server->version, str + len + 10, ver_len + 1);
- server->version[ver_len + 1] = '\0';
- }
-
- len += strlen(str + len + 1) + 1;
-
- /* get server's connected clients count */
- if (!strncmp(str + len + 1, "clients: ", 9)) {
- server->clients = atoi(str + len + 10);
- }
-
- len += strlen(str + len + 1) + 1;
-
- /* get server's maximum connected clients count */
- if (!strncmp(str + len + 1, "maxclients: ", 12)) {
- server->maxclients = atoi(str + len + 13);
- }
-
- len += strlen(str + len + 1) + 1;
-
- /* get server's uptime */
- if (!strncmp(str + len + 1, "uptime: ", 8)) {
- server->uptime = atoi(str + len + 9);
- }
-
- len += strlen(str + len + 1) + 1;
-
- /* get server's arena */
- if (!strncmp(str + len + 1, "arena: ", 7)) {
- unsigned arena_len = strlen(str + len + 9);
- server->arena = (char *) malloc(sizeof(char) * (arena_len + 2));
-
- if (!server->arena) {
- return 0;
- }
-
- memcpy(server->arena, str + len + 8, arena_len + 1);
- server->arena[arena_len + 1] = '\0';
- }
-
-
- free(str);
-
- server->state = 1;
-
- return 1;
-}
-
-/*
- * Get server list
- */
-static int LoadServers()
-{
-#ifndef __WIN32__
- int s;
-#else /* __WIN32__ */
- SOCKET s;
-#endif /* __WIN32__ */
-
- char buf[1025];
-
- /* first of all ensure the server list is empty */
- clear_server_list();
- select_remove_all(select_server);
-
- /* TODO: TCP macro */
- struct sockaddr_in server;
- char *master_server_ip;
-
- master_server_ip = dns_resolv(NET_MASTER_SERVER_DOMAIN);
-
- if (master_server_ip == NULL) {
- warning("Did not obtained IP of the MasterServer");
- return -1;
- }
-
- server.sin_family = AF_INET;
- server.sin_port = htons(NET_MASTER_PORT);
- server.sin_addr.s_addr = inet_addr(master_server_ip);
-
- free(master_server_ip);
-
- if ((s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
- warning("Unable to open socket for connection to MasterServer");
- return -1;
- }
-
- /* Set to nonblocking socket mode */
-#ifndef __WIN32__
- int oldFlag = fcntl(s, F_GETFL, 0);
- if (fcntl(s, F_SETFL, oldFlag | O_NONBLOCK) == -1) {
- return -1;
- }
-#else /* __WIN32__ */
- unsigned long arg = 1;
- /* Operation is FIONBIO. Parameter is pointer on non-zero number. */
- if (ioctlsocket(s, FIONBIO, &arg) == SOCKET_ERROR) {
- WSACleanup();
- return -1;
- }
-#endif /* __WIN32__ */
-
- if (connect(s, (struct sockaddr *) &server, sizeof(server)) == -1) {
-#ifndef __WIN32__
- if (errno != EINPROGRESS) {
- return -1;
- }
-#else /* __WIN32__ */
- if (WSAGetLastError() != WSAEWOULDBLOCK) {
- WSACleanup();
- return -1;
- }
-#endif /* __WIN32__ */
- }
-
- struct timeval tv;
-
- fd_set myset;
-
- FD_ZERO(&myset);
- FD_SET(s, &myset);
-
- tv.tv_sec = 3;
- tv.tv_usec = 0;
-
- int ret = select(s + 1, NULL, &myset, NULL, &tv);
-
- if (ret == -1) {
- return 0;
- } else if (ret == 0) {
- return -2;
- }
-
- /* send request for server list */
- send(s, "l", 1, 0);
-
- FD_ZERO(&myset);
- FD_SET(s, &myset);
-
- ret = select(s + 1, &myset, NULL, NULL, &tv);
-
- if (ret == -1) {
- return 0;
- } else if (ret == 0) {
- return -2;
- }
-
- int len = recv(s, buf, 1024, 0);
-
-#ifndef __WIN32__
- close(s);
-#else /* __WIN32__ */
- closesocket(s);
- WSACleanup();
-#endif /* __WIN32__ */
-
- if (len <= 0) {
- return 0;
- }
-
- int i = 0;
- char list[256];
-
- struct in_addr srv;
-
- typedef struct {
- unsigned port;
- unsigned ip;
- } response_head;
-
- for (;;) {
- response_head *header = (response_head *) ((char *) buf + i);
-
- server_t *ctx;
-
- /* alloc and init context */
- ctx = (server_t *) malloc(sizeof(server_t));
-
- ctx->ip = header->ip;
- ctx->port = header->port;
- ctx->name = 0;
- ctx->version = 0;
- ctx->arena = 0;
-
- ret = server_getinfo(ctx);
-
- srv.s_addr = ctx->ip;
-
- char *address = (char *) inet_ntoa(srv);
-
- memset(list, ' ', 254);
- list[255] = '\0';
-
- if (ret == 1) {
- /*sprintf (list, "%s (%s) - %s:%d - %s - %d/%d - %dms", ctx->name ? ctx->name : "Unknown", ctx->version, address, ctx->port,
- ctx->arena ? ctx->arena : "Unknown", ctx->clients, ctx->maxclients, ctx->ping); */
-
- if (ctx->name) {
- memcpy(list, ctx->name, strlen(ctx->name));
- } else {
- memcpy(list, "Unknown", 7);
- }
-
- memcpy(list + 30, ctx->version, strlen(ctx->version));
-
- unsigned a_len = strlen(address);
- memcpy(list + 38, address, a_len);
- memcpy(list + 38 + a_len, ":", 1);
-
- sprintf(buf, "%d", ctx->port);
-
- memcpy(list + 39 + a_len, buf, strlen(buf));
-
- memcpy(list + 60, ctx->arena, strlen(ctx->arena));
-
- sprintf(buf, "%d/%d", ctx->clients, ctx->maxclients);
-
- memcpy(list + 75, buf, strlen(buf));
-
- sprintf(buf, "%dms", ctx->ping);
-
- memcpy(list + 83, buf, strlen(buf));
- }
-
- select_add(select_server, list);
-
- /* add server to server list */
- ctx->next = &server_list;
- ctx->prev = server_list.prev;
- ctx->prev->next = ctx;
- ctx->next->prev = ctx;
-
- i += sizeof(response_head) + 1;
-
- if (buf[i - 1] != '\n' || (i + 1) > len) {
- break;
- }
- }
-
- return 1;
-}
-
-static int RefreshServers()
-{
- select_remove_all(select_server);
-
- struct in_addr srv;
-
- server_t *server;
- for (server = server_list.next; server != &server_list; server = server->next) {
- if (server->name) {
- free(server->name);
- }
-
- if (server->version) {
- free(server->version);
- }
-
- if (server->arena) {
- free(server->arena);
- }
-
- server->name = 0;
- server->version = 0;
- server->arena = 0;
-
- char list[256];
- char buf[32];
-
- int ret = server_getinfo(server);
-
- srv.s_addr = server->ip;
-
- char *address = (char *) inet_ntoa(srv);
-
- if (ret == 1) {
- memset(list, ' ', 254);
- list[255] = '\0';
-
- if (server->name) {
- memcpy(list, server->name, strlen(server->name));
- } else {
- memcpy(list, "Unknown", 7);
- }
-
- memcpy(list + 30, server->version, strlen(server->version));
-
- unsigned a_len = strlen(address);
- memcpy(list + 38, address, a_len);
- memcpy(list + 38 + a_len, ":", 1);
-
- sprintf(buf, "%d", server->port);
-
- memcpy(list + 39 + a_len, buf, strlen(buf));
-
- memcpy(list + 60, server->arena, strlen(server->arena));
-
- sprintf(buf, "%d/%d", server->clients, server->maxclients);
-
- memcpy(list + 75, buf, strlen(buf));
-
- sprintf(buf, "%dms", server->ping);
-
- memcpy(list + 83, buf, strlen(buf));
-
- select_add(select_server, list);
- }
- }
-
- return 1;
-}
-
-void browser_init()
-{
- image_t *image;
-
- image = image_get(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = wid_image_new(0, 0, image);
-
- button_back = button_new(_("Back"), 100, WINDOW_SIZE_Y - 100, eventWidget);
- button_play = button_new(_("Play"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100,
- eventWidget);
- button_refresh = button_new(_("Refresh"),
- WINDOW_SIZE_X / 2 - 130, WINDOW_SIZE_Y - 100,
- eventWidget);
- button_reload = button_new(_("Reload"),
- WINDOW_SIZE_X / 2 + 35, WINDOW_SIZE_Y - 100,
- eventWidget);
-
- label_server = label_new(_("Server"), 120, 145, WIDGET_LABEL_LEFT);
- label_version = label_new(_("Version"), 290, 145, WIDGET_LABEL_LEFT);
- label_address = label_new(_("IP"), 400, 145, WIDGET_LABEL_LEFT);
- label_arena = label_new(_("Arena"), 550, 145, WIDGET_LABEL_LEFT);
- label_players = label_new(_("Clients"), 645, 145, WIDGET_LABEL_LEFT);
- label_ping = label_new(_("Ping"), 720, 145, WIDGET_LABEL_LEFT);
-
- select_server = select_new(50, label_server->y + 40, eventWidget);
-
- screen_register(screen_new("browser", browser_start, browser_event,
- browser_draw, browser_stop));
-
- server_list.next = &server_list;
- server_list.prev = &server_list;
-}
-
-void browser_quit()
-{
- wid_image_destroy(image_backgorund);
-
- button_destroy(button_play);
- button_destroy(button_back);
- button_destroy(button_refresh);
- button_destroy(button_reload);
-
- label_destroy(label_server);
- label_destroy(label_version);
- label_destroy(label_address);
- label_destroy(label_arena);
- label_destroy(label_players);
- label_destroy(label_ping);
-
- select_destroy(select_server);
-}
-
-static void clear_server_list()
-{
- server_t *server;
-
- for (server = server_list.next; server != &server_list; server = server_list.next) {
- server->next->prev = server->prev;
- server->prev->next = server->next;
-
- if (server->name) {
- free(server->name);
- }
-
- if (server->version) {
- free(server->version);
- }
-
- if (server->arena) {
- free(server->arena);
- }
-
- free(server);
- }
-}
diff --git a/src/screen/browser.h b/src/screen/browser.h
deleted file mode 100644
index 76c0e42..0000000
--- a/src/screen/browser.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef SCREEN_BROWSER_H
-#define SCREEN_BROWSER_H
-
-typedef struct server_context {
- struct server_context *next, *prev;
-
- unsigned char state;
-
- unsigned char ping;
-
- unsigned ip;
- unsigned port;
-
- char *name;
-
- char *version;
- unsigned char clients;
- unsigned char maxclients;
- unsigned uptime;
- char *arena;
-} server_t;
-
-extern void browser_start();
-extern void browser_draw();
-extern void browser_event();
-extern void browser_stop();
-extern void browser_init();
-extern void browser_quit();
-
-#endif /* SCREEN_BROWSER_H */
diff --git a/src/screen/choiceArena.c b/src/screen/choiceArena.c
deleted file mode 100644
index d8c1a24..0000000
--- a/src/screen/choiceArena.c
+++ /dev/null
@@ -1,265 +0,0 @@
-#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"
-#include "config.h"
-
-#ifndef NO_SOUND
-#include "music.h"
-#endif
-
-#include "mainMenu.h"
-#include "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 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 now */
-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 use two lists
- but how the hell list_t is supposed to be used?! :-) */
- int min; /* see activateHandledMapButtonGroup for description */
- 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()
-{
- screen_set("gameType");
-}
-
-void screen_startChoiceArena()
-{
-#ifndef NO_SOUND
- music_play("menu", MUSIC_GROUP_BASE);
-#endif
-
- hot_key_register(SDLK_ESCAPE, hotkey_escape);
-}
-
-void choice_arena_draw()
-{
- int i;
-
- wid_image_draw(image_backgorund);
-
- button_draw(button_play);
- button_draw(button_back);
- if (show_map_buttons.next) { button_draw(button_next); }
- if (show_map_buttons.prev) { button_draw(button_prev); }
-
- for (i = show_map_buttons.min; i < show_map_buttons.max; i++) {
- button_image_draw((widget_t *) listAllWidgetButtonimage->list[i]);
- }
-}
-
-void choice_arena_event()
-{
- int i;
-
- button_event(button_play);
- button_event(button_back);
- if (show_map_buttons.next) { button_event(button_next); }
- if (show_map_buttons.prev) { button_event(button_prev); }
-
- for (i = show_map_buttons.min ; i < show_map_buttons.max; i++) {
- button_image_event((widget_t *) listAllWidgetButtonimage->list[i]);
- }
-}
-
-void stopScreenChoiceArena()
-{
- hot_key_unregister(SDLK_ESCAPE);
-}
-
-static void button_eventImage(void *p)
-{
- widget_t *buttonimage;
- int i;
-
- buttonimage = (widget_t *) p;
-
- for (i = show_map_buttons.min; i < show_map_buttons.max; i++) {
- widget_t *this;
-
- this = (widget_t *) listAllWidgetButtonimage->list[i];
-
- if (buttonimage == this) {
- button_image_set_active(this, TRUE);
- currentArena = arena_file_get(i);
- } else {
- button_image_set_active(this, FALSE);
- }
- }
-}
-
-arenaFile_t *choice_arena_get()
-{
- return currentArena;
-}
-
-void choice_arena_set(arenaFile_t *arenaFile)
-{
- widget_t *widget_buttonimage;
- int id;
-
- id = arena_file_get_id(arenaFile);
- currentArena = arenaFile;
-
- if (id >= 0) {
- widget_buttonimage = (widget_t *) listAllWidgetButtonimage->list[id];
- button_image_set_active(widget_buttonimage, TRUE);
- }
-}
-
-static void eventWidget(void *p)
-{
- widget_t *button;
-
- button = (widget_t *) p;
-
- if (button == button_play) {
- screen_set("world");
- }
-
- if (button == button_back) {
- screen_set("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 <= arena_file_get_count() ? min : arena_file_get_count();
- int max = min + 6 <= arena_file_get_count() ? min + 6 : arena_file_get_count();
-
- if (min) {
- show_map_buttons.prev = 1;
- } else {
- show_map_buttons.prev = 0;
- }
-
- if (max < arena_file_get_count()) {
- show_map_buttons.next = 1;
- } else {
- show_map_buttons.next = 0;
- }
-
- show_map_buttons.min = min;
- show_map_buttons.max = max;
-}
-
-void choice_arena_init()
-{
- image_t *image;
- int i;
-
- image = image_get(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = wid_image_new(0, 0, image);
-
- button_back = button_new(_("Back"), 100, WINDOW_SIZE_Y - 100, eventWidget);
- button_play = button_new(_("Play"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget);
-
- button_prev = button_new(_("Previous arenas"), 250, WINDOW_SIZE_Y - 100, eventWidget);
- button_next = button_new(_("Next arenas"), WINDOW_SIZE_X - 350, WINDOW_SIZE_Y - 100, eventWidget);
-
- listAllWidgetButtonimage = list_new();
- currentArena = NULL;
-
- for (i = 0; i < arena_file_get_count(); i++) {
- widget_t *widget_buttonimage;
- arenaFile_t *arenaFile;
- int x, y;
-
- arenaFile = arena_file_get(i);
- /*image = image_add(arena_file_get_image(i), IMAGE_NO_ALPHA, "none", IMAGE_GROUP_BASE);*/
- image = arena_file_load_image(arenaFile, arena_file_get_image(arenaFile),
- IMAGE_GROUP_BASE, "none", IMAGE_NO_ALPHA);
-
- /*
- 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 = button_image_new(image, x, y, button_eventImage);
-/*
- if (i == choiceArenaId) {
- widget_buttonimage->active = 1;
- }
-*/
- list_add(listAllWidgetButtonimage, widget_buttonimage);
- handled_map_button_group = 0;
- activateHandledMapButtonGroup();
- }
-
- screen_register(screen_new("chiceArena", screen_startChoiceArena,
- choice_arena_event, choice_arena_draw,
- stopScreenChoiceArena));
-
- choice_arena_set(arena_file_get_file_format_net_name(config_get_str_value(CFG_ARENA)));
-}
-
-void choice_arena_quit()
-{
- if (choice_arena_get() != NULL) {
- config_set_str_value(CFG_ARENA, arena_file_get_net_name(choice_arena_get()));
- }
-
- wid_image_destroy(image_backgorund);
-
- button_destroy(button_play);
- button_destroy(button_back);
-
- button_destroy(button_next);
- button_destroy(button_prev);
-
- list_destroy_item(listAllWidgetButtonimage, button_image_destroy);
-}
diff --git a/src/screen/choiceArena.h b/src/screen/choiceArena.h
deleted file mode 100644
index c0adacd..0000000
--- a/src/screen/choiceArena.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef SCREEN_CHOICE_ARENA_H
-#define SCREEN_CHOICE_ARENA_H
-
-#include "main.h"
-#include "arenaFile.h"
-
-#define SCREENSHOT_ARENA_WIDTH 160
-#define SCREENSHOT_ARENA_HEIGHT 107
-
-extern void choice_arena_draw();
-extern void choice_arena_event();
-extern arenaFile_t *choice_arena_get();
-extern void choice_arena_set(arenaFile_t *arenaFile);
-extern void choice_arena_init();
-extern void choice_arena_quit();
-
-#endif /* SCREEN_CHOICE_ARENA_H */
diff --git a/src/screen/credits.c b/src/screen/credits.c
deleted file mode 100644
index cb8704e..0000000
--- a/src/screen/credits.c
+++ /dev/null
@@ -1,162 +0,0 @@
-#include <stdio.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-#include "textFile.h"
-
-#include "interface.h"
-#include "screen.h"
-#include "image.h"
-#include "hotKey.h"
-
-#ifndef NO_SOUND
-#include "music.h"
-#endif
-
-#include "credits.h"
-
-#include "widget.h"
-#include "widget_image.h"
-#include "widget_label.h"
-#include "widget_button.h"
-
-static widget_t *image_backgorund;
-static widget_t *button_back;
-static list_t *listWidgetLabel;
-static textFile_t *textFile;
-static int offset;
-static int creditExists;
-
-static void hotkey_escape()
-{
- screen_set("mainMenu");
-}
-
-void scredits_start()
-{
-#ifndef NO_SOUND
- music_play("menu", MUSIC_GROUP_BASE);
-#endif
- offset = 0;
-
- hot_key_register(SDLK_ESCAPE, hotkey_escape);
-}
-
-void scredits_draw()
-{
- int i;
-
- wid_image_draw(image_backgorund);
-
- button_draw(button_back);
-
- for (i = 0; i < listWidgetLabel->count; i++) {
- int z;
-
- widget_t *this;
-
- this = (widget_t *) listWidgetLabel->list[i];
-
- z = this->y;
- this->y += offset;
-
- if (this->y > SCREEN_CREDITS_OFFSET_MIN && this->y < SCREEN_CREDITS_OFFSET_MAX) {
- label_draw(this);
- }
-
- this->y = z;
- }
-
-}
-
-void scredits_event()
-{
- button_event(button_back);
-
- offset -= SCREEN_CREDITS_OFFSET_SPEED;
-
- if (offset < SCREEN_CREDITS_OFFSET_RESTART) {
- offset = 0;
- }
-
- /*printf("offset = %d\n", offset);*/
-}
-
-void scredits_stop()
-{
- hot_key_unregister(SDLK_ESCAPE);
-}
-
-static void eventWidget(void *p)
-{
- widget_t *button;
-
- button = (widget_t *) p;
-
- if (button == button_back) {
- screen_set("mainMenu");
- }
-}
-
-void scredits_init()
-{
- image_t *image;
- int i;
-
- image = image_get(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = wid_image_new(0, 0, image);
-
- button_back = button_new(_("Back"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2,
- WINDOW_SIZE_Y - 80, eventWidget);
-
- listWidgetLabel = list_new();
-
- if (tryExistFile(PATH_DOC SCREEN_CREDITS_FILE) == 0) {
- creditExists = 1;
- textFile = text_file_load(PATH_DOC SCREEN_CREDITS_FILE);
-
- for (i = 0; i < textFile->text->count; i++) {
- widget_t *label;
- char *line;
-
- line = (char *) textFile->text->list[i];
-
- label = label_new(line, WINDOW_SIZE_X / 3 - WINDOW_SIZE_X / 4,
- (WINDOW_SIZE_Y - 100) + i * 20,
- WIDGET_LABEL_LEFT);
-
- list_add(listWidgetLabel, label);
- }
- } else {
- for (i = 0; i < 5; i++) {
- creditExists = 0;
- widget_t *label;
- char line[STR_SIZE];
-
- sprintf(line, _("[Error] Credits file not found [%s]: %s\n"),
- PATH_DOC, SCREEN_CREDITS_FILE);
-
- label = label_new(line, WINDOW_SIZE_X / 2,
- (WINDOW_SIZE_Y - 100) + i * 20,
- WIDGET_LABEL_CENTER);
-
- list_add(listWidgetLabel, label);
- }
- }
-
- screen_register(screen_new("credits", scredits_start, scredits_event,
- scredits_draw, scredits_stop));
-}
-
-void scredits_quit()
-{
- wid_image_destroy(image_backgorund);
-
- button_destroy(button_back);
- list_destroy_item(listWidgetLabel, label_destroy);
-
- if (creditExists) {
- text_file_destroy(textFile);
- }
-}
diff --git a/src/screen/credits.h b/src/screen/credits.h
deleted file mode 100644
index 827b9c1..0000000
--- a/src/screen/credits.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef SCREEN_CREDITS_H
-#define SCREEN_CREDITS_H
-
-#define SCREEN_CREDITS_FILE "AUTHORS"
-
-#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 scredits_start();
-extern void scredits_draw();
-extern void scredits_event();
-extern void scredits_stop();
-extern void scredits_init();
-extern void scredits_quit();
-
-#endif /* SCREEN_CREDITS_H */
diff --git a/src/screen/downArena.c b/src/screen/downArena.c
deleted file mode 100644
index ac211a9..0000000
--- a/src/screen/downArena.c
+++ /dev/null
@@ -1,386 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-#include "buffer.h"
-#include "textFile.h"
-#include "arenaFile.h"
-#include "homeDirector.h"
-
-#include "interface.h"
-#include "screen.h"
-#include "image.h"
-
-#include "net_multiplayer.h"
-#include "udp.h"
-#include "tcp.h"
-
-#include "widget.h"
-#include "widget_image.h"
-#include "widget_label.h"
-#include "widget_button.h"
-
-#include "setting.h"
-#include "downArena.h"
-#include "gameType.h"
-
-static sock_udp_t *sock_server_udp;
-static sock_tcp_t *sock_server_tcp;
-
-static widget_t *image_backgorund;
-static widget_t *button_back;
-static widget_t *label_status;
-
-static char str_status[STR_PROTO_SIZE];
-static char arenaNetName[STR_SIZE];
-
-static int status_tcp_socket;
-static buffer_t *recvBuffer;
-static buffer_t *sendBuffer;
-
-static char path[STR_PATH_SIZE];
-static FILE *file;
-static int fileSize;
-static int fileOffset;
-
-static my_time_t timeSendMsg;
-static int countSendMsg;
-
-static void setStatusString(char *s)
-{
- printf("status -> %s\n", s);
- label_destroy(label_status);
- label_status = label_new(s, WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER);
-}
-
-static void connectToDownServer()
-{
- char status[STR_SIZE];
- char msg[STR_PROTO_SIZE];
-
- sock_server_tcp = sock_tcp_connect(public_server_get_settingIP(), public_server_get_settingPort());
-
- if (sock_server_tcp == NULL) {
- sprintf(status, _("Error! Unable to connect to [%s]:%d download server"),
- public_server_get_settingIP(), public_server_get_settingPort());
- setStatusString(status);
- return;
- }
-
- sock_tcp_set_non_block(sock_server_tcp);
-
- recvBuffer = buffer_new(DOWN_ARENA_BUFFER_SIZE);
- sendBuffer = buffer_new(DOWN_ARENA_BUFFER_SIZE);
- status_tcp_socket = DOWN_SERVER_STATUS_OK;
-
- file = NULL;
- countSendMsg = 0;
- timeSendMsg = timer_get_current_time();
-
- sprintf(msg, "GETARENA %s\n", arenaNetName);
-
- buffer_append(sendBuffer, msg, strlen(msg));
-
- sprintf(status, _("Connecting to [%s]:%d download server"),
- public_server_get_settingIP(), public_server_get_settingPort());
- setStatusString(status);
-}
-
-static void closeConnectFromDownServer()
-{
- sock_tcp_close(sock_server_tcp);
- buffer_destroy(recvBuffer);
- buffer_destroy(sendBuffer);
- sock_server_tcp = NULL;
- recvBuffer = NULL;
- sendBuffer = NULL;
-}
-
-static void sendStatusToGameServer()
-{
- char *msg = "status\n";
-
- if (countSendMsg > DOWN_ARENA_MAX_SEND_MSG_STATUS) {
- char status[STR_SIZE];
- sprintf(status, _("Error! Game server [%s]:%d is off"),
- public_server_get_settingIP(), public_server_get_settingPort());
- setStatusString(status);
- return;
- }
-
- timeSendMsg = timer_get_current_time();
- countSendMsg++;
- printf("countSendMsg = %d\n", countSendMsg++);
-
- if (sock_udp_write(sock_server_udp, sock_server_udp, msg, strlen(msg)) < 0) {
- char status[STR_SIZE];
- sprintf(status, _("Error! Unable to send message to [%s]:%d game server"),
- public_server_get_settingIP(), public_server_get_settingPort());
- setStatusString(status);
- }
-}
-
-void down_arena_start()
-{
- char status[STR_SIZE];
-
- strcpy(str_status, "none");
- memset(arenaNetName, 0, STR_SIZE);
-
- sock_server_udp = sock_udp_connect(public_server_get_settingIP(), public_server_get_settingPort());
-
- if (sock_server_udp == NULL) {
- sprintf(status, _("Error! Unable to connect to [%s]:%d game server"),
- public_server_get_settingIP(), public_server_get_settingPort());
- setStatusString(status);
- return;
- }
-
- sock_udp_set_non_block(sock_server_udp);
-
- sprintf(status, _("Connecting to [%s]:%d game server"),
- public_server_get_settingIP(), public_server_get_settingPort());
- setStatusString(status);
-
- sendStatusToGameServer();
-}
-
-void down_arena_draw()
-{
- wid_image_draw(image_backgorund);
- label_draw(label_status);
- button_draw(button_back);
-}
-
-static void proto_ok(char *line)
-{
- /*printf("line = %s\n", line);*/
- fileSize = atoi(line + 3);
- fileOffset = 0;
-
- sprintf(path, "%s/%s.zip", home_director_get(), arenaNetName);
- /*printf("path = %s\n", path);*/
- file = fopen(path, "wb");
-}
-
-static void proto_err(char *line)
-{
- /*printf("line = %s\n", line);*/
- setStatusString(line + 4);
- closeConnectFromDownServer();
-}
-
-static void eventProto(char *line)
-{
- if (strncmp(line, "OK", 2) == 0) {
- proto_ok(line);
- }
-
- if (strncmp(line, "ERR", 3) == 0) {
- proto_err(line);
- }
-}
-
-static int downArenaFile()
-{
- char status[STR_SIZE];
- void *data;
- int len;
-
- len = buffer_get_size(recvBuffer);
- data = buffer_get_data(recvBuffer);
- buffer_cut(recvBuffer, len);
-
- fwrite(data, len, 1, file);
- fileOffset += len;
-
- sprintf(status, _("Downloading: %d/%d"), fileOffset, fileSize);
- setStatusString(status);
-
- return len;
-}
-
-static int eventRecvBuffer()
-{
- char buffer[STR_PROTO_SIZE];
- char line[STR_PROTO_SIZE];
- int ret;
-
- memset(buffer, 0, STR_PROTO_SIZE);
-
- ret = sock_tcp_read(sock_server_tcp, buffer, STR_PROTO_SIZE - 1);
- /*if (ret <= 0) printf("sock_tcp_read = %d\n", ret);*/
-
- if (ret < 0) {
- return -1;
- }
-
- if (buffer_append(recvBuffer, buffer, ret) < 0) {
- char status[STR_SIZE];
- sprintf(status, _("Error! Receiving buffer is full"));
- setStatusString(status);
- closeConnectFromDownServer();
- return -1;
- }
-
- if (file == NULL && buffer_get_line(recvBuffer, line, STR_PROTO_SIZE) >= 0) {
- eventProto(line);
- return ret;
- }
-
- if (file != NULL) {
- return downArenaFile();
- }
-
- return -1;
-}
-
-static int eventSendBuffer()
-{
- void *data;
- int len;
- int res;
-
- len = buffer_get_size(sendBuffer);
-
- if (len == 0) {
- return -1;
- }
-
- data = buffer_get_data(sendBuffer);
-
- res = sock_tcp_write(sock_server_tcp, data, len);
-
- if (res < 0) {
- return -1;
- }
-
- buffer_cut(sendBuffer, res);
- return res;
-}
-
-static void readArenaFromStatus()
-{
- const char *str_arena = "arena: ";
-
- char *offset_begin;
- char *offset_end;
-
- offset_begin = strstr(str_status, str_arena);
-
- if (offset_begin != NULL) {
- offset_begin += strlen(str_arena);
- offset_end = strstr(offset_begin, "\n");
-
- if (offset_end != NULL) {
- sock_udp_close(sock_server_udp);
- sock_server_udp = NULL;
- strncpy(arenaNetName, offset_begin, offset_end - offset_begin);
-
- if (arena_file_get_file_format_net_name(arenaNetName) != NULL) {
- screen_set("world");
- return;
- }
-
- connectToDownServer();
-
- debug("arenaNetName: %s", arenaNetName);
- }
- }
-}
-
-static void eventStatus()
-{
- if (timer_get_current_time() - timeSendMsg > DOWN_ARENA_MAX_TIEMOUT_LIMIT) {
- sendStatusToGameServer();
- }
-
- if (sock_udp_read(sock_server_udp, sock_server_udp, str_status, STR_PROTO_SIZE - 1) > 0) {
- /*printf("str_status = %s\n", str_status);*/
- readArenaFromStatus();
- }
-}
-
-void down_arena_event()
-{
- int i;
-
- if (strcmp(str_status, "none") == 0) {
- eventStatus();
- }
-
- if (recvBuffer != NULL) {
- for (i = 0; i < DOWN_ARENA_COUNT_READ_SOCKET; i++) {
- if (eventRecvBuffer() <= 0) {
- break;
- }
- }
- }
-
- if (sendBuffer != NULL) {
- eventSendBuffer();
- }
-
- if (file != NULL && fileSize == fileOffset && fileSize > 0) {
- fclose(file);
- file = NULL;
- closeConnectFromDownServer();
- arena_file_load(path);
- screen_set("world");
- }
-
- button_event(button_back);
-}
-
-void down_arena_stop()
-{
- if (file != NULL) {
- unlink(path);
- }
-
- if (sock_server_tcp != NULL) {
- closeConnectFromDownServer();
- }
-
- if (sock_server_udp != NULL) {
- sock_udp_close(sock_server_udp);
- }
-
-}
-
-static void eventWidget(void *p)
-{
- widget_t *button;
-
- button = (widget_t *) p;
-
- if (button == button_back) {
- screen_set("mainMenu");
- }
-}
-
-void down_arena_init()
-{
- image_t *image;
-
- image = image_get(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = wid_image_new(0, 0, image);
-
- button_back = button_new(_("Back"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2,
- WINDOW_SIZE_Y - 80, eventWidget);
-
- label_status = label_new(_("none"), WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER);
-
- screen_register(screen_new("downArena", down_arena_start, down_arena_event,
- down_arena_draw, down_arena_stop));
-}
-
-void down_arena_quit()
-{
- wid_image_destroy(image_backgorund);
- button_destroy(button_back);
- label_destroy(label_status);
-}
diff --git a/src/screen/downArena.h b/src/screen/downArena.h
deleted file mode 100644
index 444210c..0000000
--- a/src/screen/downArena.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef SCREEN_DOWN_ARENA_H
-#define SCREEN_DOWN_ARENA_H
-
-#define DOWN_SERVER_STATUS_OK 0
-#define DOWN_SERVER_STATUS_ZOMBIE 1
-
-#define DOWN_ARENA_BUFFER_SIZE 4096
-
-#define DOWN_ARENA_MAX_SEND_MSG_STATUS 10
-#define DOWN_ARENA_MAX_TIEMOUT_LIMIT 500
-#define DOWN_ARENA_COUNT_READ_SOCKET 100
-
-extern void down_arena_start();
-extern void down_arena_draw();
-extern void down_arena_event();
-extern void down_arena_stop();
-extern void down_arena_init();
-extern void down_arena_quit();
-
-#endif /* SCREEN_DOWN_ARENA_H */
diff --git a/src/screen/gameType.c b/src/screen/gameType.c
deleted file mode 100644
index e173ab2..0000000
--- a/src/screen/gameType.c
+++ /dev/null
@@ -1,416 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-#include "director.h"
-#include "homeDirector.h"
-#include "net_multiplayer.h"
-#include "tux.h"
-
-#include "interface.h"
-#include "screen.h"
-#include "image.h"
-#include "hotKey.h"
-#include "config.h"
-
-#ifndef NO_SOUND
-#include "music.h"
-#endif /* NO_SOUND */
-
-#include "gameType.h"
-#include "setting.h"
-
-#include "widget.h"
-#include "widget_label.h"
-#include "widget_button.h"
-#include "widget_image.h"
-#include "widget_textfield.h"
-#include "widget_choicegroup.h"
-#include "widget_check.h"
-#include "widget_select.h"
-
-static widget_t *image_backgorund;
-
-static widget_t *button_back;
-static widget_t *button_play;
-static widget_t *button_browser;
-
-static widget_t *label_none;
-static widget_t *label_server;
-static widget_t *label_client;
-static widget_t *label_load_session;
-
-static widget_t *label_ip;
-static widget_t *label_port;
-static widget_t *label_session;
-
-static list_t *listChoiceGroup;
-static widget_t *check_none;
-static widget_t *check_server;
-static widget_t *check_client;
-static widget_t *check_load_session;
-
-static widget_t *textfield_ip;
-static widget_t *textfield_port;
-
-static widget_t *selectSession;
-
-static void loadSession(widget_t *p)
-{
- director_t *director;
- int i;
-
- director = director_load(home_director_get());
-
- select_remove_all(p);
-
- if (director == NULL) {
- return;
- }
-
- for (i = 0; i < director->list->count; i++) {
- char *line;
-
- line = director->list->list[i];
-
- if (strstr(line, ".sav") != NULL) {
- select_add(p, line);
- }
- }
-
- director_destroy(director);
-}
-
-static void hotkey_escape()
-{
- screen_set("mainMenu");
-}
-
-void screen_startGameType()
-{
-#ifndef NO_SOUND
- music_play("menu", MUSIC_GROUP_BASE);
-#endif /* NO_SOUND */
-
-/*
- choiceGroup_set_status(check_none, TRUE);
- choiceGroup_set_status(check_server, FALSE);
- choiceGroup_set_status(check_client, FALSE);
- choiceGroup_set_status(check_load_session, FALSE);
-*/
-
- loadSession(selectSession);
-
- hot_key_register(SDLK_ESCAPE, hotkey_escape);
-}
-
-void game_type_draw()
-{
- int i;
-
- wid_image_draw(image_backgorund);
-
- for (i = 0; i < listChoiceGroup->count; i++) {
- widget_t *this;
-
- this = (widget_t *) listChoiceGroup->list[i];
- choice_group_draw(this);
- }
-
- label_draw(label_none);
- label_draw(label_server);
- label_draw(label_client);
- label_draw(label_load_session);
-
- if (choice_group_get_status(check_server) == TRUE || choice_group_get_status(check_client) == TRUE) {
- label_draw(label_port);
- text_field_draw(textfield_port);
- label_draw(label_ip);
- text_field_draw(textfield_ip);
- }
-
- if (choice_group_get_status(check_load_session) == TRUE) {
- label_draw(label_session);
- select_draw(selectSession);
- }
-/*
- if (check_server->status == TRUE) {
- game_type_set_ip(getParamElse("--ip", "127.0.0.1"));
- game_type_set_port(atoi(getParamElse("--port", "2200")));
- }
-*/
-
- if (choice_group_get_status(check_client) == TRUE) {
- button_draw(button_browser);
- }
-
- button_draw(button_back);
- button_draw(button_play);
-}
-
-void game_type_event()
-{
- int i;
-
- for (i = 0; i < listChoiceGroup->count; i++) {
- widget_t *this;
-
- this = (widget_t *) listChoiceGroup->list[i];
- choice_group_event(this);
- }
-
- if (choice_group_get_status(check_server) == TRUE || choice_group_get_status(check_client) == TRUE) {
- text_field_event(textfield_ip);
- text_field_event(textfield_port);
- }
-
- if (choice_group_get_status(check_load_session) == TRUE) {
- select_event(selectSession);
- }
-
- button_event(button_back);
- button_event(button_play);
-
- if (choice_group_get_status(check_client) == TRUE) {
- button_event(button_browser);
- }
-}
-
-void stopScreenGameType()
-{
- hot_key_unregister(SDLK_ESCAPE);
-}
-
-static void eventWidget(void *p)
-{
- widget_t *button;
-
- button = (widget_t *) p;
-
- if (button == button_back) {
- screen_set("mainMenu");
- return;
- }
-
- if (button == button_play) {
- char *str;
-
- str = game_type_load_session();
-
- if (str != NULL) {
- screen_set("world");
- return;
- }
-
- if (public_server_get_settingGameType() == NET_GAME_TYPE_CLIENT) {
- screen_set("downArena");
- } else {
- screen_set("chiceArena");
- }
-
- return;
- }
-
- if (button == button_browser) {
- screen_set("browser");
- return;
- }
-}
-
-void game_type_init()
-{
- image_t *image;
-
- image = image_get(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = wid_image_new(0, 0, image);
-
- button_back = button_new(_("Back"), 100, WINDOW_SIZE_Y - 100, eventWidget);
- button_play = button_new(_("Play"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget);
- button_browser = button_new(_("Browser"), 300, 345, eventWidget);
-
- listChoiceGroup = list_new();
- check_none = choice_group_new(100, 150, FALSE, listChoiceGroup, eventWidget);
- check_server = choice_group_new(100, 200, FALSE, listChoiceGroup, eventWidget);
- check_client = choice_group_new(100, 250, FALSE, listChoiceGroup, eventWidget);
- check_load_session = choice_group_new(100, 300, FALSE, listChoiceGroup, eventWidget);
-
- if (strcmp(config_get_str_value(CFG_GAME_TYPE), "server") == 0) {
- choiceGroup_set_status(check_server, TRUE);
- } else if (strcmp(config_get_str_value(CFG_GAME_TYPE), "client") == 0) {
- choiceGroup_set_status(check_client, TRUE);
- } else if (strcmp(config_get_str_value(CFG_GAME_TYPE), "none") == 0) {
- choiceGroup_set_status(check_none, TRUE);
- } else {
- choiceGroup_set_status(check_load_session, TRUE);
- }
-
- label_none = label_new(_("Local game"), 130, 145, WIDGET_LABEL_LEFT);
- label_server = label_new(_("Set up a server"), 130, 195, WIDGET_LABEL_LEFT);
- label_client = label_new(_("Network game"), 130, 245, WIDGET_LABEL_LEFT);
- label_load_session = label_new(_("Load saved game"), 130, 295, WIDGET_LABEL_LEFT);
-
- label_ip = label_new(_("IP"), 300, 145, WIDGET_LABEL_LEFT);
- label_port = label_new(_("Port"), 300, 245, WIDGET_LABEL_LEFT);
- label_session = label_new(_("Load saved game:"), 300, 145, WIDGET_LABEL_LEFT);
-
- textfield_ip = text_field_new(config_get_str_value(CFG_NET_IP),
- WIDGET_TEXTFIELD_FILTER_IP_OR_DOMAIN,
- 300, 180);
-
- textfield_port = text_field_new(config_get_str_value(CFG_NET_PORT),
- WIDGET_TEXTFIELD_FILTER_NUM, 300, 280);
-
- selectSession = select_new(300, 185, eventWidget);
-
- screen_register(screen_new("gameType", screen_startGameType, game_type_event,
- game_type_draw, stopScreenGameType));
-}
-
-int setSettingGameType(int status)
-{
- if (status == NET_GAME_TYPE_NONE) {
- choiceGroup_set_status(check_none, TRUE);
- return 0;
- }
-
- if (status == NET_GAME_TYPE_SERVER) {
- choiceGroup_set_status(check_server, TRUE);
- return 0;
- }
-
- if (status == NET_GAME_TYPE_CLIENT) {
- choiceGroup_set_status(check_client, TRUE);
- return 0;
- }
-
- return -1;
-}
-
-int public_server_get_settingGameType()
-{
- if (choice_group_get_status(check_none) == TRUE || choice_group_get_status(check_load_session) == TRUE) {
- return NET_GAME_TYPE_NONE;
- }
-
- if (choice_group_get_status(check_server) == TRUE) {
- return NET_GAME_TYPE_SERVER;
- }
-
- if (choice_group_get_status(check_client) == TRUE) {
- return NET_GAME_TYPE_CLIENT;
- }
-
- fatal("Unknown game type");
-
- return -1;
-}
-
-char *game_type_load_session()
-{
- if (choice_group_get_status(check_load_session) == TRUE) {
- return select_get_item(selectSession);
- }
-
- return NULL;
-}
-
-int game_type_set_ip(char *address)
-{
- char str[STR_SIZE];
-
- strcpy(str, address);
- text_field_set_text(textfield_ip, str);
-
- return 1;
-}
-
-char *public_server_get_settingIP()
-{
- return text_field_get_text(textfield_ip);
-}
-
-int game_type_set_port(int port)
-{
- char str[STR_SIZE];
-
- sprintf(str, "%d", port);
- text_field_set_text(textfield_port, str);
-
- return 0;
-}
-
-int public_server_get_settingPort()
-{
- return atoi(text_field_get_text(textfield_port));
-}
-
-int public_server_get_settingProto()
-{
- if (strstr(text_field_get_text(textfield_ip), ".") != NULL) {
- return PROTO_UDPv4;
- }
-
- if (strstr(text_field_get_text(textfield_ip), ":") != NULL) {
- return PROTO_UDPv6;
- }
-
- debug("Unknown version of IP protocol");
-
- return -1;
-}
-
-static void save_config()
-{
- if (choice_group_get_status(check_none) == TRUE) {
- config_set_str_value(CFG_GAME_TYPE, "none");
- }
-
- if (choice_group_get_status(check_server) == TRUE) {
- config_set_str_value(CFG_GAME_TYPE, "server");
- }
-
- if (choice_group_get_status(check_client) == TRUE) {
- config_set_str_value(CFG_GAME_TYPE, "client");
- }
-
- if (choice_group_get_status(check_load_session) == TRUE) {
- config_set_str_value(CFG_GAME_TYPE, "session");
- }
-
- config_set_str_value(CFG_NET_IP, text_field_get_text(textfield_ip));
- config_set_str_value(CFG_NET_PORT, text_field_get_text(textfield_port));
-}
-
-void game_type_quit()
-{
- save_config();
-
- wid_image_destroy(image_backgorund);
-
- label_destroy(label_none);
- label_destroy(label_server);
- label_destroy(label_client);
- label_destroy(label_load_session);
-
- label_destroy(label_ip);
- label_destroy(label_port);
- label_destroy(label_session);
-
- text_field_destroy(textfield_ip);
- text_field_destroy(textfield_port);
-
- select_destroy(selectSession);
-
- button_destroy(button_back);
- button_destroy(button_play);
- button_destroy(button_browser);
-
- choice_group_destroy(check_none);
- choice_group_destroy(check_server);
- choice_group_destroy(check_client);
- choice_group_destroy(check_load_session);
-
- list_destroy(listChoiceGroup);
-}
diff --git a/src/screen/gameType.h b/src/screen/gameType.h
deleted file mode 100644
index 49cf008..0000000
--- a/src/screen/gameType.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef SCREEN_GAME_TYPE_H
-#define SCREEN_GAME_TYPE_H
-
-#include "main.h"
-
-extern void game_type_draw();
-extern void game_type_event();
-extern void game_type_init();
-extern int setSettingGameType(int status);
-extern int public_server_get_settingGameType();
-extern char *game_type_load_session();
-extern int game_type_set_ip(char *address);
-extern char *public_server_get_settingIP();
-extern int game_type_set_port(int port);
-extern int public_server_get_settingPort();
-extern int public_server_get_settingProto();
-extern void game_type_quit();
-
-#endif /* SCREEN_GAME_TYPE_H */
diff --git a/src/screen/mainMenu.c b/src/screen/mainMenu.c
deleted file mode 100644
index 147ef59..0000000
--- a/src/screen/mainMenu.c
+++ /dev/null
@@ -1,149 +0,0 @@
-#include <stdio.h>
-#include <assert.h>
-
-#include "main.h"
-
-#include "game.h"
-#include "interface.h"
-#include "screen.h"
-#include "image.h"
-#include "hotKey.h"
-
-#ifndef NO_SOUND
-#include "music.h"
-#endif
-
-#include "mainMenu.h"
-#include "setting.h"
-
-#include "widget.h"
-#include "widget_label.h"
-#include "widget_button.h"
-#include "widget_textfield.h"
-#include "widget_check.h"
-#include "widget_image.h"
-#include "widget_container.h"
-
-static widget_t *image_backgorund;
-
-static widget_t *widget_container;
-static widget_t *button_play;
-static widget_t *button_setting;
-static widget_t *button_table;
-static widget_t *button_credits;
-static widget_t *button_end;
-
-static void hotkey_escape()
-{
- game_quit();
-}
-
-void main_menu_start()
-{
-#ifndef NO_SOUND
- music_play("menu", MUSIC_GROUP_BASE);
-#endif
-
- hot_key_register(SDLK_ESCAPE, hotkey_escape);
-}
-
-void main_menu_draw()
-{
- wid_image_draw(image_backgorund);
-
- widget_container_draw(widget_container);
-/*
- button_draw(button_play);
- button_draw(button_setting);
- button_draw(button_table);
- button_draw(button_credits);
- button_draw(button_end);
-*/
-}
-
-void main_menu_event()
-{
- widget_container_event(widget_container);
-/*
- button_event(button_play);
- button_event(button_setting);
- button_event(button_table);
- button_event(button_credits);
- button_event(button_end);
-*/
-}
-
-void main_menu_stop()
-{
- hot_key_unregister(SDLK_ESCAPE);
-}
-
-static void eventWidget(void *p)
-{
- widget_t *button;
-
- button = (widget_t *) p;
-
- if (button == button_play) {
- screen_set("gameType");
- }
-
- if (button == button_setting) {
- screen_set("setting");
- }
-
- if (button == button_table) {
- screen_set("table");
- }
-
- if (button == button_credits) {
- screen_set("credits");
- }
-
- if (button == button_end) {
- game_quit();
- }
-}
-
-void main_menu_init()
-{
- image_t *image;
-
- image = image_add("screen_main.png", IMAGE_NO_ALPHA,
- "screen_main", IMAGE_GROUP_BASE);
- image_backgorund = wid_image_new(0, 0, image);
-
- widget_container = widget_container_new(WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, 200, WIDGET_BUTTON_WIDTH, 300);
-
- button_play = button_new(_("Start game"), WIDGET_NONE_VALUE, WIDGET_NONE_VALUE, eventWidget);
- button_setting = button_new(_("Settings"), WIDGET_NONE_VALUE, WIDGET_NONE_VALUE, eventWidget);
- button_table = button_new(_("Highscore"), WIDGET_NONE_VALUE, WIDGET_NONE_VALUE, eventWidget);
- button_credits = button_new(_("Credits"), WIDGET_NONE_VALUE, WIDGET_NONE_VALUE, eventWidget);
- button_end = button_new(_("Quit game"), WIDGET_NONE_VALUE, WIDGET_NONE_VALUE, eventWidget);
-
- widget_container_add(widget_container, button_play);
- widget_container_add(widget_container, button_setting);
- widget_container_add(widget_container, button_table);
- widget_container_add(widget_container, button_credits);
- widget_container_add(widget_container, button_end);
-
- widget_set_layout_table(widget_container, 1, 5, 0, 50);
-
-#ifndef NO_SOUND
- music_add("menu.ogg", "menu", MUSIC_GROUP_BASE);
-#endif
-
- screen_register(screen_new("mainMenu", main_menu_start, main_menu_event,
- main_menu_draw, main_menu_stop));
-}
-
-void main_menu_quit()
-{
- wid_image_destroy(image_backgorund);
-
- button_destroy(button_play);
- button_destroy(button_setting);
- button_destroy(button_table);
- button_destroy(button_credits);
- button_destroy(button_end);
-}
diff --git a/src/screen/mainMenu.h b/src/screen/mainMenu.h
deleted file mode 100644
index 99249b4..0000000
--- a/src/screen/mainMenu.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef SCREEN_MAIN_MENU_H
-#define SCREEN_MAIN_MENU_H
-
-#include "main.h"
-
-extern void main_menu_start();
-extern void main_menu_draw();
-extern void main_menu_event();
-extern void main_menu_stop();
-extern void main_menu_init();
-extern void main_menu_quit();
-
-#endif /* SCREEN_MAIN_MENU_H */
diff --git a/src/screen/setting.c b/src/screen/setting.c
deleted file mode 100644
index 2e1b615..0000000
--- a/src/screen/setting.c
+++ /dev/null
@@ -1,511 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-#include "tux.h"
-#include "textFile.h"
-#include "director.h"
-#include "homeDirector.h"
-#include "arenaFile.h"
-#include "config.h"
-
-#include "configFile.h"
-#include "interface.h"
-#include "screen.h"
-#include "image.h"
-#include "hotKey.h"
-
-#ifndef NO_SOUND
-#include "music.h"
-#include "sound.h"
-#endif
-
-#include "mainMenu.h"
-#include "setting.h"
-#include "settingKeys.h"
-#include "settingKeys.h"
-#include "choiceArena.h"
-
-#include "widget.h"
-#include "widget_label.h"
-#include "widget_button.h"
-#include "widget_image.h"
-#include "widget_textfield.h"
-#include "widget_check.h"
-#include "widget_select.h"
-#include "widget_statusbar.h"
-
-static widget_t *image_backgorund;
-
-static widget_t *button_back;
-static widget_t *button_keys; /* setting of keycontrols */
-
-static widget_t *label_count_round;
-static widget_t *label_name_player1;
-static widget_t *label_name_player2;
-static widget_t *label_ai;
-
-#ifndef NO_SOUND
-static widget_t *label_music;
-static widget_t *label_sound;
-#endif
-
-static widget_t *label_weapons;
-static widget_t *label_bonuses;
-
-static widget_t *check[ITEM_COUNT];
-#ifndef NO_SOUND
-static widget_t *check_music;
-static widget_t *check_sound;
-#endif
-
-static widget_t *image_gun_dual_revolver;
-static widget_t *image_gun_scatter;
-static widget_t *image_gun_tommy;
-static widget_t *image_gun_lasser;
-static widget_t *image_gun_mine;
-static widget_t *image_gun_bombball;
-
-static widget_t *image_bonus_speed;
-static widget_t *image_bonus_shot;
-static widget_t *image_bonus_teleport;
-static widget_t *image_bonus_ghost;
-static widget_t *image_bonus_4x;
-static widget_t *image_bonus_hidden;
-
-static widget_t *textfield_count_cound;
-static widget_t *textfield_name_player1;
-static widget_t *textfield_name_player2;
-
-static widget_t *check_ai;
-
-static widget_t *statusbar;
-
-static void hotkey_escape()
-{
- screen_set("mainMenu");
-}
-
-void screen_startSetting()
-{
-#ifndef NO_SOUND
- music_play("menu", MUSIC_GROUP_BASE);
-#endif
-
- hot_key_register(SDLK_ESCAPE, hotkey_escape);
-}
-
-void setting_draw()
-{
- int i;
-
- wid_image_draw(image_backgorund);
-
- label_draw(label_weapons);
- label_draw(label_bonuses);
-
- label_draw(label_count_round);
- label_draw(label_name_player1);
- label_draw(label_ai);
-
-#ifndef NO_SOUND
- label_draw(label_music);
- label_draw(label_sound);
-#endif
-
- text_field_draw(textfield_count_cound);
- text_field_draw(textfield_name_player1);
-
- if (check_get_status(check_ai) == FALSE) {
- label_draw(label_name_player2);
- text_field_draw(textfield_name_player2);
- }
-
- wid_image_draw(image_gun_dual_revolver);
- wid_image_draw(image_gun_scatter);
- wid_image_draw(image_gun_tommy);
- wid_image_draw(image_gun_lasser);
- wid_image_draw(image_gun_mine);
- wid_image_draw(image_gun_bombball);
-
- wid_image_draw(image_bonus_speed);
- wid_image_draw(image_bonus_shot);
- wid_image_draw(image_bonus_teleport);
- wid_image_draw(image_bonus_ghost);
- wid_image_draw(image_bonus_4x);
- wid_image_draw(image_bonus_hidden);
-
-#ifndef NO_SOUND
- check_draw(check_music);
- check_draw(check_sound);
-#endif
-
- for (i = GUN_DUAL_SIMPLE; i <= GUN_BOMBBALL; i++) {
- check_draw(check[i]);
- }
-
- for (i = BONUS_SPEED; i <= BONUS_HIDDEN; i++) {
- check_draw(check[i]);
- }
-
- check_draw(check_ai);
-
- statusbar_draw(statusbar);
-
- button_draw(button_back);
- button_draw(button_keys);
-}
-
-void setting_event()
-{
- int i;
-
- text_field_event(textfield_count_cound);
- text_field_event(textfield_name_player1);
-
- if (check_get_status(check_ai) == FALSE) {
- text_field_event(textfield_name_player2);
- }
-
-#ifndef NO_SOUND
- check_event(check_music);
- check_event(check_sound);
-#endif
-
- for (i = GUN_DUAL_SIMPLE; i <= GUN_BOMBBALL; i++) {
- check_event(check[i]);
- }
-
- for (i = BONUS_SPEED; i <= BONUS_HIDDEN; i++) {
- check_event(check[i]);
- }
-
- check_event(check_ai);
-
- statusbar_event(statusbar);
-
- button_event(button_back);
- button_event(button_keys);
-}
-
-void stopScreenSetting()
-{
- hot_key_unregister(SDLK_ESCAPE);
-}
-
-static void eventWidget(void *p)
-{
- widget_t *my_button;
- widget_t *my_check;
-
- my_button = (widget_t *) p;
- my_check = (widget_t *) p;
-
- if (my_button == button_back) {
- screen_set("mainMenu");
- }
-
- if (my_button == button_keys) {
- screen_set("settingKeys");
- }
-
-#ifndef NO_SOUND
- if (my_check == check_music) {
- music_set_active(check_get_status(check_music));
- }
-
- if (my_check == check_sound) {
- sound_set_active(check_get_status(check_sound));
- }
-#endif
-}
-
-static void initSettingFile()
-{
- text_field_set_text(textfield_count_cound, get_string_static(config_get_int_value(CFG_COUNT_ROUND)));
- text_field_set_text(textfield_name_player1, config_get_str_value(CFG_NAME_RIGHT));
- text_field_set_text(textfield_name_player2, config_get_str_value(CFG_NAME_LEFT));
-
- check_set_status(check[GUN_DUAL_SIMPLE], config_get_int_value(CFG_GUN_DUAL_SIMPLE));
- check_set_status(check[GUN_SCATTER], config_get_int_value(CFG_GUN_SCATTER));
- check_set_status(check[GUN_TOMMY], config_get_int_value(CFG_GUN_TOMMY));
- check_set_status(check[GUN_LASSER], config_get_int_value(CFG_GUN_LASSER));
- check_set_status(check[GUN_MINE], config_get_int_value(CFG_GUN_MINE));
- check_set_status(check[GUN_BOMBBALL], config_get_int_value(CFG_GUN_BOMBBALL));
-
- check_set_status(check[BONUS_SPEED], config_get_int_value(CFG_BONUS_SPEED));
- check_set_status(check[BONUS_SHOT], config_get_int_value(CFG_BONUS_SHOT));
- check_set_status(check[BONUS_TELEPORT], config_get_int_value(CFG_BONUS_TELEPORT));
- check_set_status(check[BONUS_GHOST], config_get_int_value(CFG_BONUS_GHOST));
- check_set_status(check[BONUS_4X], config_get_int_value(CFG_BONUS_4X));
- check_set_status(check[BONUS_HIDDEN], config_get_int_value(CFG_BONUS_HIDDEN));
-
- check_set_status(check_ai, config_get_int_value(CFG_AI));
-
-#ifndef NO_SOUND
- check_set_status(check_music, config_get_int_value(CFG_MUSIC));
- check_set_status(check_sound, config_get_int_value(CFG_SOUND));
-#endif
-}
-
-static void saveAndDestroyConfigFile()
-{
- config_set_int_value(CFG_COUNT_ROUND, atoi(text_field_get_text(textfield_count_cound)));
- config_set_str_value(CFG_NAME_RIGHT, text_field_get_text(textfield_name_player1));
- config_set_str_value(CFG_NAME_LEFT, text_field_get_text(textfield_name_player2));
-
- config_set_int_value(CFG_GUN_DUAL_SIMPLE, check_get_status(check[GUN_DUAL_SIMPLE]));
- config_set_int_value(CFG_GUN_SCATTER, check_get_status(check[GUN_SCATTER]));
- config_set_int_value(CFG_GUN_TOMMY, check_get_status(check[GUN_TOMMY]));
- config_set_int_value(CFG_GUN_LASSER, check_get_status(check[GUN_LASSER]));
- config_set_int_value(CFG_GUN_MINE, check_get_status(check[GUN_MINE]));
- config_set_int_value(CFG_GUN_BOMBBALL, check_get_status(check[GUN_BOMBBALL]));
- config_set_int_value(CFG_BONUS_SPEED, check_get_status(check[BONUS_SPEED]));
- config_set_int_value(CFG_BONUS_SHOT, check_get_status(check[BONUS_SHOT]));
- config_set_int_value(CFG_BONUS_TELEPORT, check_get_status(check[BONUS_TELEPORT]));
- config_set_int_value(CFG_BONUS_GHOST, check_get_status(check[BONUS_GHOST]));
- config_set_int_value(CFG_BONUS_4X, check_get_status(check[BONUS_4X]));
- config_set_int_value(CFG_BONUS_HIDDEN, check_get_status(check[BONUS_HIDDEN]));
-
- config_set_int_value(CFG_AI, check_get_status(check_ai));
-
-#ifndef NO_SOUND
- config_set_int_value(CFG_MUSIC, check_get_status(check_music));
- config_set_int_value(CFG_SOUND, check_get_status(check_sound));
-#endif
-}
-
-void setting_init()
-{
- image_t *image;
- int i;
-
- image = image_get(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = wid_image_new(0, 0, image);
-
- button_back = button_new(_("Back"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget);
-
- button_keys = button_new(_("Controls"), WINDOW_SIZE_X - 200,
- button_back->y - WIDGET_BUTTON_HEIGHT - 10, eventWidget);
-
-#ifndef NO_SOUND
- label_music = label_new(_("Music:"), 100, WINDOW_SIZE_Y - 85, WIDGET_LABEL_LEFT);
-
- check_music = check_new(label_music->x + label_music->w + 10, WINDOW_SIZE_Y - 80,
- music_is_active(), eventWidget);
- label_sound = label_new(_("Sound:"), check_music->x + WIDGET_CHECK_WIDTH + 10,
- WINDOW_SIZE_Y - 85, WIDGET_LABEL_LEFT);
-
- check_sound = check_new(label_sound->x + label_sound->w + 10, WINDOW_SIZE_Y - 80,
- sound_is_active(), eventWidget);
-
- label_ai = label_new(_("AI:"), check_sound->x + WIDGET_CHECK_WIDTH + 10,
- WINDOW_SIZE_Y - 85, WIDGET_LABEL_LEFT);
-#else
- label_ai = label_new(_("AI:"), 100, WINDOW_SIZE_Y - 85, WIDGET_LABEL_LEFT);
-#endif
-
- check_ai = check_new(label_ai->x + label_ai->w + 10, WINDOW_SIZE_Y - 80, FALSE, eventWidget);
-
- label_count_round = label_new(_("No. of rounds:"), 100, WINDOW_SIZE_Y - 200, WIDGET_LABEL_LEFT);
- label_name_player1 = label_new(_("Player 1:"), 100, WINDOW_SIZE_Y - 160, WIDGET_LABEL_LEFT);
- label_name_player2 = label_new(_("Player 2:"), 100, WINDOW_SIZE_Y - 120, WIDGET_LABEL_LEFT);
-
- textfield_count_cound = text_field_new(getParamElse("--count", "15"),
- WIDGET_TEXTFIELD_FILTER_NUM,
- 110 + label_count_round->w,
- WINDOW_SIZE_Y - 200);
-
- textfield_name_player1 = text_field_new(getParamElse("--name1", NAME_PLAYER_RIGHT),
- WIDGET_TEXTFIELD_FILTER_ALPHANUM,
- 110 + label_count_round->w, WINDOW_SIZE_Y - 160);
-
- textfield_name_player2 = text_field_new(getParamElse("--name2", NAME_PLAYER_LEFT),
- WIDGET_TEXTFIELD_FILTER_ALPHANUM,
- 110 + label_count_round->w, WINDOW_SIZE_Y - 120);
-
- label_weapons = label_new(_("Weapons:"), 100, 160, WIDGET_LABEL_LEFT);
- label_bonuses = label_new(_("Bonuses:"), 430, 160, WIDGET_LABEL_LEFT);
-
- 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] = check_new(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] = check_new(x, y, TRUE, NULL);
- }
-
- image_gun_dual_revolver = wid_image_new(110 + WIDGET_CHECK_WIDTH, 200, image_get(IMAGE_GROUP_BASE, "panel_dual"));
- image_gun_scatter = wid_image_new(110 + WIDGET_CHECK_WIDTH, 250, image_get(IMAGE_GROUP_BASE, "panel_scatter"));
- image_gun_tommy = wid_image_new(110 + WIDGET_CHECK_WIDTH, 300, image_get(IMAGE_GROUP_BASE, "panel_tommy"));
- image_gun_lasser = wid_image_new(260 + WIDGET_CHECK_WIDTH, 200,image_get(IMAGE_GROUP_BASE, "panel_lasser"));
- image_gun_mine = wid_image_new(260 + WIDGET_CHECK_WIDTH, 250, image_get(IMAGE_GROUP_BASE, "panel_mine"));
- image_gun_bombball = wid_image_new(260 + WIDGET_CHECK_WIDTH, 300, image_get(IMAGE_GROUP_BASE, "panel_bombball"));
- image_bonus_speed = wid_image_new(430 + WIDGET_CHECK_WIDTH, 200, image_get(IMAGE_GROUP_BASE, "panel_speed"));;
- image_bonus_shot = wid_image_new(430 + WIDGET_CHECK_WIDTH, 250, image_get(IMAGE_GROUP_BASE, "panel_shot"));;
- image_bonus_teleport = wid_image_new(430 + WIDGET_CHECK_WIDTH, 300, image_get(IMAGE_GROUP_BASE, "panel_teleport"));;
- image_bonus_ghost = wid_image_new(580 + WIDGET_CHECK_WIDTH, 200, image_get(IMAGE_GROUP_BASE, "panel_ghost"));;
- image_bonus_4x = wid_image_new(580 + WIDGET_CHECK_WIDTH, 250, image_get(IMAGE_GROUP_BASE, "panel_4x"));;
- image_bonus_hidden = wid_image_new(580 + WIDGET_CHECK_WIDTH, 300, image_get(IMAGE_GROUP_BASE, "panel_hidden"));;
-
- statusbar = statusbar_new(400, 350);
- statusbar_add(statusbar, check[GUN_DUAL_SIMPLE], _("Dual simple gun"));
- statusbar_add(statusbar, check[GUN_SCATTER], _("Scatter"));
- statusbar_add(statusbar, check[GUN_TOMMY], _("Tommy"));
- statusbar_add(statusbar, check[GUN_LASSER], _("Laser beam"));
- statusbar_add(statusbar, check[GUN_MINE], _("Mine"));
- statusbar_add(statusbar, check[GUN_BOMBBALL], _("Bomb ball"));
-
- statusbar_add(statusbar, check[BONUS_SPEED], _("Speed bonus"));
- statusbar_add(statusbar, check[BONUS_SHOT], _("Infinite ammo"));
- statusbar_add(statusbar, check[BONUS_TELEPORT], _("Unkillable bonus"));
- statusbar_add(statusbar, check[BONUS_GHOST], _("No-walls bonus"));
- statusbar_add(statusbar, check[BONUS_4X], _("1 shot to 4 directions bonus"));
- statusbar_add(statusbar, check[BONUS_HIDDEN], _("Unvisibility bonus"));
-
- screen_register(screen_new("setting", screen_startSetting, setting_event,
- setting_draw, stopScreenSetting));
-
- initSettingFile();
-
-#ifndef NO_SOUND
- eventWidget(check_music);
- eventWidget(check_sound);
-#endif
-}
-
-void public_server_get_setting_name_right(char *s)
-{
- strcpy(s, text_field_get_text(textfield_name_player1));
-}
-
-void public_server_get_settingNameLeft(char *s)
-{
- if (check_get_status(check_ai)) {
- strcpy(s, NAME_AI);
- } else {
- strcpy(s, text_field_get_text(textfield_name_player2));
- }
-}
-
-void public_server_get_settingCountRound(int *n)
-{
- *n = atoi(text_field_get_text(textfield_count_cound));
-}
-
-bool_t setting_is_ai()
-{
- return check_get_status(check_ai);
-}
-
-bool_t setting_is_any_item()
-{
- int i;
-
- for (i = GUN_DUAL_SIMPLE; i <= GUN_BOMBBALL; i++) {
- if (check_get_status(check[i]) == TRUE) {
- return TRUE;
- }
- }
-
- for (i = BONUS_SPEED; i < BONUS_HIDDEN; i++) {
- if (check_get_status(check[i]) == TRUE) {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-bool_t setting_is_item(int item)
-{
- return check_get_status(check[item]);
-}
-
-void setting_quit()
-{
- int i;
-
- saveAndDestroyConfigFile();
-
- wid_image_destroy(image_backgorund);
-
- label_destroy(label_weapons);
- label_destroy(label_bonuses);
-
- label_destroy(label_count_round);
- label_destroy(label_name_player1);
- label_destroy(label_ai);
-
-#ifndef NO_SOUND
- label_destroy(label_music);
- label_destroy(label_sound);
-#endif
- label_destroy(label_name_player2);
- text_field_destroy(textfield_name_player2);
-
- text_field_destroy(textfield_name_player1);
- text_field_destroy(textfield_count_cound);
-
- wid_image_destroy(image_gun_dual_revolver);
- wid_image_destroy(image_gun_scatter);
- wid_image_destroy(image_gun_tommy);
- wid_image_destroy(image_gun_lasser);
- wid_image_destroy(image_gun_mine);
- wid_image_destroy(image_gun_bombball);
-
- wid_image_destroy(image_bonus_speed);
- wid_image_destroy(image_bonus_shot);
- wid_image_destroy(image_bonus_teleport);
- wid_image_destroy(image_bonus_ghost);
- wid_image_destroy(image_bonus_4x);
- wid_image_destroy(image_bonus_hidden);
-
-#ifndef NO_SOUND
- check_destroy(check_music);
- check_destroy(check_sound);
-#endif
-
- check_destroy(check_ai);
-
- for (i = GUN_DUAL_SIMPLE; i <= GUN_BOMBBALL; i++) {
- check_destroy(check[i]);
- }
-
- for (i = BONUS_SPEED; i <= BONUS_HIDDEN; i++) {
- check_destroy(check[i]);
- }
-
- statusbar_destroy(statusbar);
-
- button_destroy(button_back);
- button_destroy(button_keys);
-}
diff --git a/src/screen/setting.h b/src/screen/setting.h
deleted file mode 100644
index c29e6a9..0000000
--- a/src/screen/setting.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef SCREEN_SETTING_H
-#define SCREEN_SETTING_H
-
-#include "main.h"
-
-#define NAME_AI "TuxBot"
-#define NAME_PLAYER_RIGHT "Name1"
-#define NAME_PLAYER_LEFT "Name2"
-
-extern void setting_init();
-extern void setting_draw();
-extern void setting_event();
-extern void public_server_get_setting_name_right(char *s);
-extern void public_server_get_settingNameLeft(char *s);
-extern void public_server_get_settingCountRound(int *n);
-extern bool_t setting_is_ai();
-extern bool_t setting_is_any_item();
-extern bool_t setting_is_item(int item);
-extern void setting_quit();
-
-#endif /* SCREEN_SETTING_H */
diff --git a/src/screen/settingKeys.c b/src/screen/settingKeys.c
deleted file mode 100644
index da74b7b..0000000
--- a/src/screen/settingKeys.c
+++ /dev/null
@@ -1,392 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-#include "tux.h"
-#include "textFile.h"
-#include "director.h"
-#include "homeDirector.h"
-
-#include "configFile.h"
-#include "interface.h"
-#include "screen.h"
-#include "image.h"
-#include "hotKey.h"
-
-#ifndef NO_SOUND
-#include "music.h"
-#include "sound.h"
-#endif
-
-#include "mainMenu.h"
-#include "setting.h"
-#include "settingKeys.h"
-
-#include "widget.h"
-#include "widget_button.h"
-#include "widget_image.h"
-#include "widget_catchkey.h"
-#include "widget_label.h"
-
-static int keytable[KEY_LENGTH];
-
-static textFile_t *keycontrolFile;
-static widget_t *image_backgorund;
-static widget_t *button_back;
-
-/* key names */
-static widget_t *tux_right;
-static widget_t *tux_right_keyup;
-static widget_t *tux_right_keydown;
-static widget_t *tux_right_keyleft;
-static widget_t *tux_right_keyright;
-static widget_t *tux_right_keyswitch;
-static widget_t *tux_right_keyfire;
-
-static widget_t *tux_left;
-static widget_t *tux_left_keyup;
-static widget_t *tux_left_keydown;
-
-static widget_t *tux_left_keyleft;
-static widget_t *tux_left_keyright;
-static widget_t *tux_left_keyswitch;
-static widget_t *tux_left_keyfire;
-
-/* key values */
-static widget_t *tux_right_keyup_val;
-static widget_t *tux_right_keydown_val;
-static widget_t *tux_right_keyleft_val;
-static widget_t *tux_right_keyright_val;
-static widget_t *tux_right_keyswitch_val;
-static widget_t *tux_right_keyfire_val;
-static widget_t *tux_left_keyup_val;
-static widget_t *tux_left_keydown_val;
-static widget_t *tux_left_keyleft_val;
-static widget_t *tux_left_keyright_val;
-static widget_t *tux_left_keyswitch_val;
-static widget_t *tux_left_keyfire_val;
-
-
-/* TODO: add key images
- * possible variant will be reusing widget_image for current widget_label so there won't
- * be key names but only images
- */
-
-static void hotkey_escape()
-{
- screen_set("setting");
-}
-
-void screen_startSettingKeys()
-{
-#ifndef NO_SOUND
- music_play("menu", MUSIC_GROUP_BASE);
-#endif
-
- hot_key_register(SDLK_ESCAPE, hotkey_escape);
-}
-
-static void setKeytableFromConfigFile(textFile_t *configFile)
-{
- char val[STR_SIZE];
-
- loadValueFromConfigFile(configFile, "TUX_RIGHT_MOVE_UP", val, STR_SIZE, "273");
- keytable[KEY_TUX_RIGHT_MOVE_UP] = atoi(val);
-
- loadValueFromConfigFile(configFile, "TUX_RIGHT_MOVE_RIGHT", val, STR_SIZE, "275");
- keytable[KEY_TUX_RIGHT_MOVE_RIGHT] = atoi(val);
-
- loadValueFromConfigFile(configFile, "TUX_RIGHT_MOVE_LEFT", val, STR_SIZE, "276");
- keytable[KEY_TUX_RIGHT_MOVE_LEFT] = atoi(val);
-
- loadValueFromConfigFile(configFile, "TUX_RIGHT_MOVE_DOWN", val, STR_SIZE, "274");
- keytable[KEY_TUX_RIGHT_MOVE_DOWN] = atoi(val);
-
- loadValueFromConfigFile(configFile, "TUX_RIGHT_SHOOT", val, STR_SIZE, "48");
- keytable[KEY_TUX_RIGHT_SHOOT] = atoi(val);
-
- loadValueFromConfigFile(configFile, "TUX_RIGHT_SWITCH_WEAPON", val, STR_SIZE, "49");
- keytable[KEY_TUX_RIGHT_SWITCH_WEAPON] = atoi(val);
-
- loadValueFromConfigFile(configFile, "TUX_LEFT_MOVE_UP", val, STR_SIZE, "119");
- keytable[KEY_TUX_LEFT_MOVE_UP] = atoi(val);
-
- loadValueFromConfigFile(configFile, "TUX_LEFT_MOVE_RIGHT", val, STR_SIZE, "100");
- keytable[KEY_TUX_LEFT_MOVE_RIGHT] = atoi(val);
-
- loadValueFromConfigFile(configFile, "TUX_LEFT_MOVE_LEFT", val, STR_SIZE, "97");
- keytable[KEY_TUX_LEFT_MOVE_LEFT] = atoi(val);
-
- loadValueFromConfigFile(configFile, "TUX_LEFT_MOVE_DOWN", val, STR_SIZE, "115");
- keytable[KEY_TUX_LEFT_MOVE_DOWN] = atoi(val);
-
- loadValueFromConfigFile(configFile, "TUX_LEFT_SHOOT", val, STR_SIZE, "113");
- keytable[KEY_TUX_LEFT_SHOOT] = atoi(val);
-
- loadValueFromConfigFile(configFile, "TUX_LEFT_SWITCH_WEAPON", val, STR_SIZE, "9");
- keytable[KEY_TUX_LEFT_SWITCH_WEAPON] = atoi(val);
-}
-
-void key_table_init()
-{
- char path[STR_PATH_SIZE];
-
- sprintf(path, "%s%skeycontrol.conf", home_director_get(), PATH_SEPARATOR);
-
- keycontrolFile = text_file_load(path);
-
- if (keycontrolFile == NULL) {
- error("Unable to load config file [%s]", path);
- debug("Creating config file [%s]", path);
-
- keycontrolFile = text_file_new(path);
-
- if (keycontrolFile == NULL) {
- error("Unable to create config file [%s]", path);
- return;
- }
- }
-
- setKeytableFromConfigFile(keycontrolFile);
-}
-
-int key_table_get_key(int n)
-{
- /*printf("keytable[n] = %d\n", keytable[n]);*/
- return keytable[n];
-}
-
-void setting_key_draw()
-{
- wid_image_draw(image_backgorund);
-
- button_draw(button_back);
-
- /* key names */
- label_draw(tux_right);
- label_draw(tux_left);
- label_draw(tux_right_keyup);
- label_draw(tux_right_keydown);
- label_draw(tux_right_keyleft);
- label_draw(tux_right_keyright);
- label_draw(tux_right_keyswitch);
- label_draw(tux_right_keyfire);
- label_draw(tux_left_keyup);
- label_draw(tux_left_keydown);
- label_draw(tux_left_keyleft);
- label_draw(tux_left_keyright);
- label_draw(tux_left_keyswitch);
- label_draw(tux_left_keyfire);
-
- /* key values */
- catch_key_draw(tux_right_keyup_val);
- catch_key_draw(tux_right_keydown_val);
- catch_key_draw(tux_right_keyleft_val);
- catch_key_draw(tux_right_keyright_val);
- catch_key_draw(tux_right_keyswitch_val);
- catch_key_draw(tux_right_keyfire_val);
- catch_key_draw(tux_left_keyup_val);
- catch_key_draw(tux_left_keydown_val);
- catch_key_draw(tux_left_keyleft_val);
- catch_key_draw(tux_left_keyright_val);
- catch_key_draw(tux_left_keyswitch_val);
- catch_key_draw(tux_left_keyfire_val);
-}
-
-static void refreshKeytable()
-{
- keytable[6] = catch_key_get(tux_left_keyup_val);
- keytable[9] = catch_key_get(tux_left_keydown_val);
- keytable[8] = catch_key_get(tux_left_keyleft_val);
- keytable[7] = catch_key_get(tux_left_keyright_val);
- keytable[10] = catch_key_get(tux_left_keyfire_val);
- keytable[11] = catch_key_get(tux_left_keyswitch_val);
-
- keytable[0] = catch_key_get(tux_right_keyup_val);
- keytable[3] = catch_key_get(tux_right_keydown_val);
- keytable[2] = catch_key_get(tux_right_keyleft_val);
- keytable[1] = catch_key_get(tux_right_keyright_val);
- keytable[4] = catch_key_get(tux_right_keyfire_val);
- keytable[5] = catch_key_get(tux_right_keyswitch_val);
-}
-
-static void eventWidget(void *p)
-{
- widget_t *button;
- widget_t *catcher;
-
- button = (widget_t *) p;
- catcher = (widget_t *) p;
-
- if (button == button_back) {
- screen_set("setting");
- }
-
- /* events on value */
- if ((catcher == tux_left_keyup_val) ||
- (catcher == tux_left_keydown_val) ||
- (catcher == tux_left_keyleft_val) ||
- (catcher == tux_left_keyright_val) ||
- (catcher == tux_left_keyfire_val) ||
- (catcher == tux_left_keyswitch_val) ||
- (catcher == tux_right_keyup_val) ||
- (catcher == tux_right_keydown_val) ||
- (catcher == tux_right_keyleft_val) ||
- (catcher == tux_right_keyright_val) ||
- (catcher == tux_right_keyswitch_val) ||
- (catcher == tux_right_keyfire_val)) {
- /* draw press any key picture
- this will be done by widget catchkey
- check if there is no other key with new value (what to revert if yes?)
- */
-
- refreshKeytable();
- }
-
-}
-
-void setting_key_event()
-{
- button_event(button_back);
-
- catch_key_event(tux_right_keyup_val);
- catch_key_event(tux_right_keydown_val);
- catch_key_event(tux_right_keyleft_val);
- catch_key_event(tux_right_keyright_val);
- catch_key_event(tux_right_keyswitch_val);
- catch_key_event(tux_right_keyfire_val);
-
- catch_key_event(tux_left_keyup_val);
- catch_key_event(tux_left_keydown_val);
- catch_key_event(tux_left_keyleft_val);
- catch_key_event(tux_left_keyright_val);
- catch_key_event(tux_left_keyswitch_val);
- catch_key_event(tux_left_keyfire_val);
-}
-
-void stopScreenSettingKeys()
-{
- hot_key_unregister(SDLK_ESCAPE);
-}
-
-void setting_key_int()
-{
- key_table_init();
-
- image_t *image = image_get(IMAGE_GROUP_BASE, "screen_main");
-
- image_backgorund = wid_image_new(0, 0, image);
-
- button_back = button_new(_("Back"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget);
-
- tux_left = label_new(_("Player 2"), WINDOW_SIZE_X / 4, 150, WIDGET_LABEL_CENTER);
- tux_left_keyup = label_new(_("Up:"), 50, tux_left->y + 50, WIDGET_LABEL_LEFT);
- tux_left_keydown = label_new(_("Down:"), tux_left_keyup->x, tux_left_keyup->y + 20, WIDGET_LABEL_LEFT);
- tux_left_keyleft = label_new(_("Left:"), tux_left_keyup->x, tux_left_keydown->y + 20, WIDGET_LABEL_LEFT);
- tux_left_keyright = label_new(_("Right:"), tux_left_keyup->x, tux_left_keyleft->y + 20, WIDGET_LABEL_LEFT);
- tux_left_keyfire = label_new(_("Fire:"), tux_left_keyup->x, tux_left_keyright->y + 20, WIDGET_LABEL_LEFT);
- tux_left_keyswitch = label_new(_("Switch gun:"), tux_left_keyup->x, tux_left_keyfire->y + 20, WIDGET_LABEL_LEFT);
- tux_right = label_new(_("Player 1"), WINDOW_SIZE_X / 2 + WINDOW_SIZE_X / 4, tux_left->y, WIDGET_LABEL_CENTER);
- tux_right_keyup = label_new(_("Up:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x, tux_left->y + 50, WIDGET_LABEL_LEFT);
- tux_right_keydown = label_new(_("Down:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x, tux_left_keyup->y + 20, WIDGET_LABEL_LEFT);
- tux_right_keyleft = label_new(_("Left:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x, tux_right_keydown->y + 20, WIDGET_LABEL_LEFT);
- tux_right_keyright = label_new(_("Right:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x, tux_right_keyleft->y + 20, WIDGET_LABEL_LEFT);
- tux_right_keyfire = label_new(_("Fire:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x, tux_left_keyright->y + 20, WIDGET_LABEL_LEFT);
- tux_right_keyswitch = label_new(_("Switch gun:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x, tux_left_keyfire->y + 20, WIDGET_LABEL_LEFT);
-
- tux_left_keyup_val = catch_key_new(keytable[6], tux_left_keyup->x + 200, tux_left->y + 55, eventWidget);
- tux_left_keydown_val = catch_key_new(keytable[9], tux_left_keyup_val->x, tux_left_keyup->y + 25, eventWidget);
- tux_left_keyleft_val = catch_key_new(keytable[8], tux_left_keyup_val->x, tux_left_keydown->y + 25, eventWidget);
- tux_left_keyright_val = catch_key_new(keytable[7], tux_left_keyup_val->x, tux_left_keyleft->y + 25, eventWidget);
- tux_left_keyfire_val = catch_key_new(keytable[10], tux_left_keyup_val->x, tux_left_keyright->y + 25, eventWidget);
- tux_left_keyswitch_val = catch_key_new(keytable[11], tux_left_keyup_val->x, tux_left_keyfire->y + 25, eventWidget);
- tux_right_keyup_val = catch_key_new(keytable[0], WINDOW_SIZE_X / 2 + tux_left_keyup_val->x, tux_left->y + 55, eventWidget);
- tux_right_keydown_val = catch_key_new(keytable[3], WINDOW_SIZE_X / 2 + tux_left_keyup_val->x, tux_left_keyup->y + 25, eventWidget);
- tux_right_keyleft_val = catch_key_new(keytable[2], WINDOW_SIZE_X / 2 + tux_left_keyup_val->x, tux_right_keydown->y + 25, eventWidget);
- tux_right_keyright_val = catch_key_new(keytable[1], WINDOW_SIZE_X / 2 + tux_left_keyup_val->x, tux_right_keyleft->y + 25, eventWidget);
- tux_right_keyfire_val = catch_key_new(keytable[4], WINDOW_SIZE_X / 2 + tux_left_keyup_val->x, tux_left_keyright->y + 25, eventWidget);
- tux_right_keyswitch_val = catch_key_new(keytable[5], WINDOW_SIZE_X / 2 + tux_left_keyup_val->x, tux_left_keyfire->y + 25, eventWidget);
-
- screen_register(screen_new("settingKeys", screen_startSettingKeys, setting_key_event, setting_key_draw, stopScreenSettingKeys));
-}
-
-void key_table_quit()
-{
- text_file_destroy(keycontrolFile);
-}
-
-void saveKeyTable(textFile_t *configFile)
-{
- char str[STR_SIZE];
-
- sprintf(str, "%d", catch_key_get(tux_left_keyup_val));
- setValueInConfigFile(configFile, "TUX_LEFT_MOVE_UP", str);
- sprintf(str, "%d", catch_key_get(tux_left_keydown_val));
- setValueInConfigFile(configFile, "TUX_LEFT_MOVE_DOWN", str);
- sprintf(str, "%d", catch_key_get(tux_left_keyleft_val));
- setValueInConfigFile(configFile, "TUX_LEFT_MOVE_LEFT", str);
- sprintf(str, "%d", catch_key_get(tux_left_keyright_val));
- setValueInConfigFile(configFile, "TUX_LEFT_MOVE_RIGHT", str);
- sprintf(str, "%d", catch_key_get(tux_left_keyfire_val));
- setValueInConfigFile(configFile, "TUX_LEFT_SHOOT", str);
- sprintf(str, "%d", catch_key_get(tux_left_keyswitch_val));
- setValueInConfigFile(configFile, "TUX_LEFT_SWITCH_WEAPON", str);
-
- sprintf(str, "%d", catch_key_get(tux_right_keyup_val));
- setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_UP", str);
- sprintf(str, "%d", catch_key_get(tux_right_keydown_val));
- setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_DOWN", str);
- sprintf(str, "%d", catch_key_get(tux_right_keyleft_val));
- setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_LEFT", str);
- sprintf(str, "%d", catch_key_get(tux_right_keyright_val));
- setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_RIGHT", str);
- sprintf(str, "%d", catch_key_get(tux_right_keyfire_val));
- setValueInConfigFile(configFile, "TUX_RIGHT_SHOOT", str);
- sprintf(str, "%d", catch_key_get(tux_right_keyswitch_val));
- setValueInConfigFile(configFile, "TUX_RIGHT_SWITCH_WEAPON", str);
-
- text_file_save(configFile);
-}
-
-void setting_key_quit()
-{
- saveKeyTable(keycontrolFile);
-
- key_table_quit();
-
- wid_image_destroy(image_backgorund);
-
- /* key names */
- label_destroy(tux_right);
- label_destroy(tux_left);
- label_destroy(tux_right_keyup);
- label_destroy(tux_right_keydown);
- label_destroy(tux_right_keyleft);
- label_destroy(tux_right_keyright);
- label_destroy(tux_right_keyswitch);
- label_destroy(tux_right_keyfire);
- label_destroy(tux_left_keyup);
- label_destroy(tux_left_keydown);
- label_destroy(tux_left_keyright);
- label_destroy(tux_left_keyleft);
- label_destroy(tux_left_keyswitch);
- label_destroy(tux_left_keyfire);
-
- /* key values */
- catch_key_destroy(tux_right_keyup_val);
- catch_key_destroy(tux_right_keydown_val);
- catch_key_destroy(tux_right_keyleft_val);
- catch_key_destroy(tux_right_keyright_val);
- catch_key_destroy(tux_right_keyswitch_val);
- catch_key_destroy(tux_right_keyfire_val);
- catch_key_destroy(tux_left_keyup_val);
- catch_key_destroy(tux_left_keydown_val);
- catch_key_destroy(tux_left_keyleft_val);
- catch_key_destroy(tux_left_keyright_val);
- catch_key_destroy(tux_left_keyswitch_val);
- catch_key_destroy(tux_left_keyfire_val);
-
- button_destroy(button_back);
-}
diff --git a/src/screen/settingKeys.h b/src/screen/settingKeys.h
deleted file mode 100644
index c7d6c66..0000000
--- a/src/screen/settingKeys.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef SCREEN_SETTING_KEYS_H
-#define SCREEN_SETTING_KEYS_H
-
-#define KEY_TUX_RIGHT_MOVE_UP 0
-#define KEY_TUX_RIGHT_MOVE_RIGHT 1
-#define KEY_TUX_RIGHT_MOVE_LEFT 2
-#define KEY_TUX_RIGHT_MOVE_DOWN 3
-#define KEY_TUX_RIGHT_SHOOT 4
-#define KEY_TUX_RIGHT_SWITCH_WEAPON 5
-#define KEY_TUX_LEFT_MOVE_UP 6
-#define KEY_TUX_LEFT_MOVE_RIGHT 7
-#define KEY_TUX_LEFT_MOVE_LEFT 8
-#define KEY_TUX_LEFT_MOVE_DOWN 9
-#define KEY_TUX_LEFT_SHOOT 10
-#define KEY_TUX_LEFT_SWITCH_WEAPON 11
-#define KEY_LENGTH 12
-
-#include "main.h"
-
-extern void setting_key_int();
-extern void setting_key_draw();
-extern void setting_key_event();
-extern void setting_key_quit();
-extern void key_table_init();
-extern int key_table_get_key(int n);
-extern void key_table_quit();
-
-#endif /* SCREEN_SETTING_KEYS_H */
diff --git a/src/screen/table.c b/src/screen/table.c
deleted file mode 100644
index 34b4680..0000000
--- a/src/screen/table.c
+++ /dev/null
@@ -1,228 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-#include "textFile.h"
-#include "homeDirector.h"
-
-#include "interface.h"
-#include "screen.h"
-#include "image.h"
-#include "hotKey.h"
-
-#ifndef NO_SOUND
-#include "music.h"
-#endif
-
-#include "table.h"
-
-#include "widget_image.h"
-#include "widget_label.h"
-#include "widget_button.h"
-
-static widget_t *image_backgorund;
-static widget_t *button_back;
-
-static list_t *listWidgetLabelNumer;
-static list_t *listWidgetLabelName;
-static list_t *listWidgetLabelScore;
-
-static textFile_t *textFile;
-
-static void hotkey_escape()
-{
- screen_set("mainMenu");
-}
-
-void table_start()
-{
-#ifndef NO_SOUND
- music_play("menu", MUSIC_GROUP_BASE);
-#endif
-
- hot_key_register(SDLK_ESCAPE, hotkey_escape);
-}
-
-void table_draw()
-{
- int i;
-
- wid_image_draw(image_backgorund);
-
- button_draw(button_back);
-
- for (i = 0; i < listWidgetLabelNumer->count; i++) {
- widget_t *this;
- this = (widget_t *) listWidgetLabelNumer->list[i];
- label_draw(this);
- }
-
- for (i = 0; i < listWidgetLabelName->count; i++) {
- widget_t *this;
- this = (widget_t *) listWidgetLabelName->list[i];
- label_draw(this);
- }
-
- for (i = 0; i < listWidgetLabelScore->count; i++) {
- widget_t *this;
- this = (widget_t *) listWidgetLabelScore->list[i];
- label_draw(this);
- }
-}
-
-void table_event()
-{
- button_event(button_back);
-}
-
-void table_stop()
-{
- hot_key_unregister(SDLK_ESCAPE);
-}
-
-static void eventWidget(void *p)
-{
- widget_t *button;
-
- button = (widget_t *) p;
-
- if (button == button_back) {
- screen_set("mainMenu");
- }
-}
-
-static void setWidgetLabel()
-{
- int i;
-
- if (textFile == NULL) {
- error("Didn't load the high score file [%s]", SCREEN_TABLE_FILE_HIGHSCORE_NAME);
-
- return;
- }
-
- if (listWidgetLabelNumer != NULL ||
- listWidgetLabelName != NULL ||
- listWidgetLabelScore != NULL) {
- list_destroy_item(listWidgetLabelNumer, label_destroy);
- list_destroy_item(listWidgetLabelName, label_destroy);
- list_destroy_item(listWidgetLabelScore, label_destroy);
- }
-
- listWidgetLabelNumer = list_new();
- listWidgetLabelName = list_new();
- listWidgetLabelScore = list_new();
-
- for (i = 0; i < SCREEN_TABLE_MAX_PLAYERS; i++) {
- widget_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 = label_new(num, WINDOW_SIZE_X / 2 - 100, 200 + i * 20, WIDGET_LABEL_LEFT);
- list_add(listWidgetLabelNumer, label);
-
- label = label_new(name, WINDOW_SIZE_X / 2, 200 + i * 20, WIDGET_LABEL_CENTER);
- list_add(listWidgetLabelName, label);
-
- label = label_new(score, WINDOW_SIZE_X / 2 + 80, 200 + i * 20, WIDGET_LABEL_LEFT);
- list_add(listWidgetLabelScore, label);
- }
-}
-
-static void loadHighscoreFile()
-{
- char path[STR_PATH_SIZE];
- int i;
-
- sprintf(path, "%s%s%s", home_director_get(), PATH_SEPARATOR, SCREEN_TABLE_FILE_HIGHSCORE_NAME);
- textFile = text_file_load(path);
-
- if (textFile == NULL) {
- error("Unable to load the high score file [%s]", path);
- debug("Creating the high score file [%s]", path);
- textFile = text_file_new(path);
- } else {
- return;
- }
-
- if (textFile == NULL) {
- error("Unable to create the high score file [%s]", path);
- return;
- }
-
- for (i = 0; i < SCREEN_TABLE_MAX_PLAYERS; i++) {
- list_add(textFile->text, strdup("--- 0"));
- }
-
- text_file_save(textFile);
-}
-
-int table_add(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);
- list_ins(textFile->text, i, strdup(new));
- list_del_item(textFile->text, SCREEN_TABLE_MAX_PLAYERS, free);
- setWidgetLabel();
-
- return 0;
- }
- }
-
- return -1;
-}
-
-void table_init()
-{
- image_t *image;
-
- image = image_add("screen_table.png", IMAGE_NO_ALPHA, "screen_table", IMAGE_GROUP_BASE);
- image_backgorund = wid_image_new(0, 0, image);
-
- button_back = button_new(_("Back"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2,
- WINDOW_SIZE_Y - 100, eventWidget);
-
- loadHighscoreFile();
- listWidgetLabelNumer = NULL;
- listWidgetLabelName = NULL;
- listWidgetLabelScore = NULL;
- setWidgetLabel();
-
- screen_register(screen_new("table", table_start, table_event, table_draw, table_stop));
-}
-
-void table_quit()
-{
- wid_image_destroy(image_backgorund);
-
- button_destroy(button_back);
- list_destroy_item(listWidgetLabelNumer, label_destroy);
- list_destroy_item(listWidgetLabelName, label_destroy);
- list_destroy_item(listWidgetLabelScore, label_destroy);
-
- if (textFile != NULL) {
- text_file_save(textFile);
- text_file_destroy(textFile);
- }
-}
diff --git a/src/screen/table.h b/src/screen/table.h
deleted file mode 100644
index 7940ee9..0000000
--- a/src/screen/table.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef SCREEN_TABLE_H
-#define SCREEN_TABLE_H
-
-#define SCREEN_TABLE_MAX_PLAYERS 10
-#define SCREEN_TABLE_FILE_HIGHSCORE_NAME "highscore"
-
-extern void table_start();
-extern void table_draw();
-extern void table_event();
-extern void table_stop();
-extern int table_add(char *name, int score);
-extern void table_init();
-extern void table_quit();
-
-#endif /* SCREEN_TABLE_H */
diff --git a/src/screen/world.c b/src/screen/world.c
deleted file mode 100644
index 90d10a1..0000000
--- a/src/screen/world.c
+++ /dev/null
@@ -1,536 +0,0 @@
-#include <stdio.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-#include "tux.h"
-#include "item.h"
-#include "shot.h"
-#include "gun.h"
-#include "myTimer.h"
-#include "net_multiplayer.h"
-#include "arena.h"
-#include "arenaFile.h"
-#include "proto.h"
-#include "modules.h"
-#include "idManager.h"
-#include "serverSendMsg.h"
-
-#include "interface.h"
-#include "layer.h"
-#include "image.h"
-#include "font.h"
-
-#include "hotKey.h"
-#include "panel.h"
-#include "radar.h"
-#include "chat.h"
-#include "pauza.h"
-#include "term.h"
-#include "saveDialog.h"
-#include "yes_no_dialog.h"
-#include "saveLoad.h"
-
-#ifndef NO_SOUND
-#include "music.h"
-#include "sound.h"
-#endif /* NO_SOUND */
-
-#include "screen.h"
-#include "world.h"
-#include "analyze.h"
-#include "setting.h"
-#include "gameType.h"
-#include "settingKeys.h"
-#include "choiceArena.h"
-#include "table.h"
-#include "control.h"
-
-static arena_t *arena;
-static bool_t isScreenWorldInit = FALSE;
-static bool_t isEndWorld;
-
-static tux_t *tuxWithControlRightKeyboard;
-static tux_t *tuxWithControlLeftKeyboard;
-
-static control_t *control_tux_right;
-static control_t *control_tux_left;
-
-bool_t world_is_inicialized()
-{
- return isScreenWorldInit;
-}
-
-void setGameType()
-{
- int ret = 0;
-
- ret = net_multiplayer_init(public_server_get_settingGameType(), public_server_get_settingIP(),
- public_server_get_settingPort(), public_server_get_settingProto());
-
- if (ret != 0) {
- error("Unable to initialize network");
- world_do_end();
- }
-}
-
-void world_set_arena(arenaFile_t *arenaFile)
-{
- arena = arena_file_get_arena(arenaFile);
-
-#ifndef NO_SOUND
- music_play(arena->music, MUSIC_GROUP_USER);
-#endif /* NO_SOUND */
-}
-
-void world_do_end()
-{
- isEndWorld = TRUE;
-}
-
-static void timer_endArena()
-{
- if (net_multiplayer_get_game_type() != NET_GAME_TYPE_CLIENT) {
- world_do_end();
- return;
- }
-}
-
-void world_inc_round()
-{
- if (arena->max_countRound == WORLD_COUNT_ROUND_UNLIMITED ||
- arena->countRound >= arena->max_countRound) {
- return;
- }
-
- arena->countRound++;
- /*printf("count %d/%d\n", count, max_count);*/
-
- if (arena->countRound >= arena->max_countRound) {
- /*printf("count %d ending\n", count);*/
-#ifndef NO_SOUND
- sound_play("end", SOUND_GROUP_BASE);
-#endif /* NO_SOUND */
- timer_add_task(arena_get_current()->listTimer, TIMER_ONE, timer_endArena, NULL, TIMER_END_ARENA);
- }
-}
-
-bool_t world_is_match_end()
-{
- if (arena->max_countRound == WORLD_COUNT_ROUND_UNLIMITED) {
- return FALSE;
- }
-
- return (arena->countRound >= arena->max_countRound);
-}
-
-void prepareArena()
-{
- tux_t *tux;
- char name[STR_NAME_SIZE];
-
- /*printf("public_server_get_settingAI = %s\n", public_server_get_settingAI());*/
- arena_set_current(NULL);
- tuxWithControlRightKeyboard = NULL;
- tuxWithControlLeftKeyboard = NULL;
-
- control_tux_right = NULL;
- control_tux_left = NULL;
-
- if (game_type_load_session() != NULL) {
- load_arena(game_type_load_session());
- return;
- }
-
- switch (net_multiplayer_get_game_type()) {
- case NET_GAME_TYPE_NONE:
- world_set_arena(choice_arena_get());
- item_add_new_item(arena->spaceItem, ID_UNKNOWN);
- public_server_get_settingCountRound(&arena->max_countRound);
-
- tux = tux_new();
-
- world_set_control_tux(tux, TUX_CONTROL_KEYBOARD_RIGHT);
- public_server_get_setting_name_right(name);
- tux_set_name(tux, name);
- space_add(arena->spaceTux, tux);
-
- tux = tux_new();
-
- world_set_control_tux(tux, TUX_CONTROL_KEYBOARD_LEFT);
- public_server_get_settingNameLeft(name);
- tux_set_name(tux, name);
- space_add(arena->spaceTux, tux);
-
- if (setting_is_ai()) {
- tux->control = TUX_CONTROL_AI;
-
- if (module_load("libmodAI") != 0) {
- tux->control = TUX_CONTROL_KEYBOARD_LEFT;
- }
- }
- /*printf("game_type_load_session = %s\n", game_type_load_session());*/
-
- break;
-
- case NET_GAME_TYPE_SERVER:
- world_set_arena(choice_arena_get());
- item_add_new_item(arena->spaceItem, ID_UNKNOWN);
- public_server_get_settingCountRound(&arena->max_countRound);
-
- tux = tux_new();
-
- world_set_control_tux(tux, TUX_CONTROL_KEYBOARD_RIGHT);
- public_server_get_setting_name_right(name);
- tux_set_name(tux, name);
- space_add(arena->spaceTux, tux);
- break;
-
- case NET_GAME_TYPE_CLIENT:
- break;
- }
-}
-
-void world_draw()
-{
- if (arena != NULL) {
- arena_draw(arena);
- panel_draw(tuxWithControlRightKeyboard, tuxWithControlLeftKeyboard);
-
- if (arena->w > WINDOW_SIZE_X || arena->h > WINDOW_SIZE_Y) {
- radar_draw(arena);
- }
- }
-
- chat_draw();
- pauza_draw();
- term_draw();
- save_dialog_draw();
- yes_no_dialog_draw();
-}
-
-static void netAction(tux_t *tux, int action)
-{
- if (public_server_get_settingGameType() == NET_GAME_TYPE_SERVER) {
- proto_send_event_server(PROTO_SEND_ALL_SEES_TUX, NULL, tux, action);
- }
-
- if (public_server_get_settingGameType() == NET_GAME_TYPE_CLIENT) {
- proto_send_event_client(action);
- }
-}
-
-static void control_keyboard(tux_t *tux, control_t *control)
-{
- switch (control_get_key_route(control)) {
- case CONTROL_UP:
- netAction(tux, TUX_UP);
- tux_action(tux, TUX_UP);
- break;
- case CONTROL_RIGHT:
- netAction(tux, TUX_RIGHT);
- tux_action(tux, TUX_RIGHT);
- break;
- case CONTROL_LEFT:
- netAction(tux, TUX_LEFT);
- tux_action(tux, TUX_LEFT);
- break;
- case CONTROL_DOWN:
- netAction(tux, TUX_DOWN);
- tux_action(tux, TUX_DOWN);
- break;
- }
-
- switch (control_get_key_action(control)) {
- case CONTROL_SHOT:
- if (tux->isCanShot == TRUE) {
- netAction(tux, TUX_SHOT);
- tux_action(tux, TUX_SHOT);
- }
- break;
- case CONTROL_SWITCH:
- if (tux->isCanSwitchGun == TRUE) {
- netAction(tux, TUX_SWITCH_GUN);
- tux_action(tux, TUX_SWITCH_GUN);
- }
- break;
- }
-}
-
-static void eventEnd()
-{
- if (isEndWorld == TRUE) {
- screen_set("analyze");
- return;
- }
-}
-
-tux_t *world_get_control_tux(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 world_set_control_tux(tux_t *tux, int control_type)
-{
- switch (control_type) {
- case TUX_CONTROL_KEYBOARD_RIGHT:
- tuxWithControlRightKeyboard = tux;
- tux->control = control_type;
-
- control_tux_right = control_new(
- key_table_get_key(KEY_TUX_RIGHT_MOVE_UP),
- key_table_get_key(KEY_TUX_RIGHT_MOVE_RIGHT),
- key_table_get_key(KEY_TUX_RIGHT_MOVE_LEFT),
- key_table_get_key(KEY_TUX_RIGHT_MOVE_DOWN),
- key_table_get_key(KEY_TUX_RIGHT_SHOOT),
- key_table_get_key(KEY_TUX_RIGHT_SWITCH_WEAPON)
- );
-
- break;
- case TUX_CONTROL_KEYBOARD_LEFT:
- tuxWithControlLeftKeyboard = tux;
- tux->control = control_type;
-
- control_tux_left = control_new(
- key_table_get_key(KEY_TUX_LEFT_MOVE_UP),
- key_table_get_key(KEY_TUX_LEFT_MOVE_RIGHT),
- key_table_get_key(KEY_TUX_LEFT_MOVE_LEFT),
- key_table_get_key(KEY_TUX_LEFT_MOVE_DOWN),
- key_table_get_key(KEY_TUX_LEFT_SHOOT),
- key_table_get_key(KEY_TUX_LEFT_SWITCH_WEAPON)
- );
-
- break;
- }
-}
-
-void world_tux_control(tux_t *p)
-{
- assert(p != NULL);
-
- if (p->status != TUX_STATUS_ALIVE) {
- return;
- }
-
- switch (p->control) {
- case TUX_CONTROL_NONE:
- fatal("Controls not defined");
- break;
-
- case TUX_CONTROL_KEYBOARD_RIGHT:
- if (chat_is_active() == FALSE) {
- control_keyboard(tuxWithControlRightKeyboard, control_tux_right);
- }
- break;
-
- case TUX_CONTROL_KEYBOARD_LEFT:
- if (chat_is_active() == FALSE) {
- control_keyboard(tuxWithControlLeftKeyboard, control_tux_left);
- }
- break;
- }
-}
-
-void world_event()
-{
- tux_t *thisTux;
-
- if (arena == NULL) {
- net_multiplayer_event();
- eventEnd();
- return;
- }
-
- net_multiplayer_event();
-
- if (pauza_is_active() == FALSE &&
- save_dialog_is_active() == FALSE &&
- yes_no_dialog_is_active() == FALSE) {
- arena_event(arena);
- /*module_event();*/
- }
-
- thisTux = world_get_control_tux(TUX_CONTROL_KEYBOARD_RIGHT);
-
- radar_add(thisTux->id, thisTux->x, thisTux->y, RADAR_TYPE_YOU);
-
- thisTux = world_get_control_tux(TUX_CONTROL_KEYBOARD_LEFT);
-
- if (thisTux != NULL) {
- radar_add(thisTux->id, thisTux->x, thisTux->y, RADAR_TYPE_TUX);
- }
-
- eventEnd();
- chat_event();
- pauza_event();
- term_event();
- save_dialog_event();
- yes_no_dialog_event();
-}
-
-void dialog_yes(void *p)
-{
- world_do_end();
-}
-
-void dialog_no(void *p)
-{
-}
-
-static void hotkey_escape()
-{
- yes_no_dialog_set(_("Do you really want to quit the game?"), dialog_yes, dialog_no, NULL);
- yes_no_dialog_set_active(TRUE);
- /*world_do_end();*/
-}
-
-void startWorld()
-{
- arena = NULL;
- isEndWorld = FALSE;
-
- hot_key_register(SDLK_ESCAPE, hotkey_escape);
- arena_init();
- id_init_list();
- radar_init();
- pauza_init();
- term_init();
-
- setGameType();
-
- yes_no_dialog_init();
-
- if (net_multiplayer_get_game_type() == NET_GAME_TYPE_NONE) {
- save_dialog_init();
- }
-
- module_init();
- chat_init();
- prepareArena();
-}
-
-static void action_analyze(space_t *space, tux_t *tux, void *p)
-{
- analyze_add(tux->name, tux->score);
-}
-
-static void setAnalyze()
-{
- analyze_restart();
-
- space_action(arena->spaceTux, action_analyze, NULL);
-
- analyze_end();
-}
-
-static void setTable()
-{
- tux_t *tuxRight;
- tux_t *tuxLeft;
-
- if (public_server_get_settingGameType() != NET_GAME_TYPE_NONE) {
- return;
- }
-
- tuxRight = world_get_control_tux(TUX_CONTROL_KEYBOARD_RIGHT);
- tuxLeft = world_get_control_tux(TUX_CONTROL_KEYBOARD_LEFT);
-
- if (tuxRight->score > tuxLeft->score) {
- table_add(tuxRight->name, tuxRight->score);
- }
-
- if (tuxLeft->score > tuxRight->score) {
- table_add(tuxLeft->name, tuxLeft->score);
- }
-}
-
-void stoptWorld()
-{
- if (arena != NULL) {
- setTable();
- setAnalyze();
- }
-
- hot_key_unregister(SDLK_ESCAPE);
- arena_quit();
-
- radar_quit();
- pauza_quit();
- term_quit();
-
- yes_no_dialog_quit();
-
- if (net_multiplayer_get_game_type() == NET_GAME_TYPE_NONE) {
- save_dialog_quit();
- }
-
- if (control_tux_right != NULL) {
- control_destroy(control_tux_right);
- }
-
- if (control_tux_left != NULL) {
- control_destroy(control_tux_left);
- }
-
-#ifndef NO_SOUND
- music_stop();
-#endif /* NO_SOUND */
- image_del_all_image_in_group(IMAGE_GROUP_USER);
-
-#ifndef NO_SOUND
- music_del_all_in_group(MUSIC_GROUP_USER);
-#endif /* NO_SOUND */
- module_quit();
- chat_quit();
-
- net_multiplayer_quit();
-
- if (arena != NULL) {
- arena_destroy(arena);
- }
-
- id_quit_list();
-}
-
-void world_init()
-{
- assert(image_is_inicialized() == TRUE);
- assert(tux_is_inicialized() == TRUE);
- assert(shot_is_inicialized() == TRUE);
- assert(panel_is_inicialized() == TRUE);
- assert(screen_is_inicialized() == TRUE);
-
- screen_register(screen_new("world", startWorld, world_event, world_draw, stoptWorld));
-
-#ifndef NO_SOUND
- sound_add("dead.ogg", "dead", SOUND_GROUP_BASE);
- sound_add("explozion.ogg", "explozion", SOUND_GROUP_BASE);
- sound_add("gun_lasser.ogg", "gun_lasser", SOUND_GROUP_BASE);
- sound_add("gun_revolver.ogg", "gun_revolver", SOUND_GROUP_BASE);
- sound_add("gun_scatter.ogg", "gun_scatter", SOUND_GROUP_BASE);
- sound_add("gun_tommy.ogg", "gun_tommy", SOUND_GROUP_BASE);
- sound_add("put_mine.ogg", "put_mine", SOUND_GROUP_BASE);
- sound_add("teleport.ogg", "teleport", SOUND_GROUP_BASE);
- sound_add("item_bonus.ogg", "item_bonus", SOUND_GROUP_BASE);
- sound_add("item_gun.ogg", "item_gun", SOUND_GROUP_BASE);
- sound_add("switch_gun.ogg", "switch_gun", SOUND_GROUP_BASE);
- sound_add("end.ogg", "end", SOUND_GROUP_BASE);
-#endif /* NO_SOUND */
-
- isScreenWorldInit = TRUE;
-}
-
-void world_quit()
-{
- debug("Shutting down the world screen");
- isScreenWorldInit = FALSE;
-}
diff --git a/src/screen/world.h b/src/screen/world.h
deleted file mode 100644
index f64ac93..0000000
--- a/src/screen/world.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef SCREEN_WORLD_H
-#define SCREEN_WORLD_H
-
-#include "main.h"
-#include "myTimer.h"
-#include "tux.h"
-#include "arenaFile.h"
-#include "arena.h"
-
-#define TIMER_END_ARENA 5000
-#define WORLD_COUNT_ROUND_UNLIMITED -1
-#define LAG_SERVER_UNKNOWN -1
-
-extern bool_t world_is_inicialized();
-extern void world_init();
-extern void world_set_arena(arenaFile_t *arenaFile);
-extern void world_do_end();
-extern void world_inc_round();
-extern bool_t world_is_match_end();
-extern tux_t *world_get_control_tux(int control_type);
-extern void world_set_control_tux(tux_t *tux, int control_type);
-extern void world_tux_control(tux_t *p);
-extern void world_draw();
-extern void world_event();
-extern void world_start();
-extern void world_stop();
-extern void world_quit();
-
-#endif /* SCREEN_WORLD_H */