summaryrefslogtreecommitdiff
path: root/src/screen
diff options
context:
space:
mode:
authorTomas Chvatal (scarabeus) <tomas.chvatal@gmail.com>2008-10-22 22:51:24 +0200
committerTomas Chvatal (scarabeus) <tomas.chvatal@gmail.com>2008-10-22 22:51:24 +0200
commit44daf03024fbf7cbffa10349044786f6ab784821 (patch)
treefe311eb22e2d853dfc18fde1a9e55d21815f4f82 /src/screen
parente12753d2ec9db83ec08bb9db63902a82fb245cdd (diff)
Revert "X"
This reverts commit e12753d2ec9db83ec08bb9db63902a82fb245cdd.
Diffstat (limited to 'src/screen')
-rw-r--r--src/screen/screen_analyze.c189
-rw-r--r--src/screen/screen_analyze.c~180
-rw-r--r--src/screen/screen_browser.c885
-rw-r--r--src/screen/screen_browser.c~716
-rw-r--r--src/screen/screen_choiceArena.c226
-rw-r--r--src/screen/screen_choiceArena.c~193
-rw-r--r--src/screen/screen_credits.c190
-rw-r--r--src/screen/screen_credits.c~154
-rw-r--r--src/screen/screen_downArena.c512
-rw-r--r--src/screen/screen_downArena.c~382
-rw-r--r--src/screen/screen_gameType.c534
-rw-r--r--src/screen/screen_gameType.c~412
-rw-r--r--src/screen/screen_mainMenu.c153
-rw-r--r--src/screen/screen_mainMenu.c~128
-rw-r--r--src/screen/screen_setting.c798
-rw-r--r--src/screen/screen_setting.c~553
-rw-r--r--src/screen/screen_settingKeys.c677
-rw-r--r--src/screen/screen_settingKeys.c~332
-rw-r--r--src/screen/screen_table.c343
-rw-r--r--src/screen/screen_table.c~238
-rw-r--r--src/screen/screen_world.c947
-rw-r--r--src/screen/screen_world.c~623
22 files changed, 2601 insertions, 6764 deletions
diff --git a/src/screen/screen_analyze.c b/src/screen/screen_analyze.c
index 5f14c7e..ee42a90 100644
--- a/src/screen/screen_analyze.c
+++ b/src/screen/screen_analyze.c
@@ -31,165 +31,150 @@ static widget_t *widgetLabelMsg;
static widget_t *button_ok;
-static analyze_t *
-newAnalyze(char *name, int score)
+static analyze_t* newAnalyze(char *name, int score)
{
- analyze_t *new;
+ analyze_t *new;
- new = malloc(sizeof(analyze_t));
- new->name = strdup(name);
- new->score = score;
+ new = malloc( sizeof(analyze_t) );
+ new->name = strdup(name);
+ new->score = score;
- return new;
+ return new;
}
-static void
-destroyAnalyze(analyze_t * p)
+static void destroyAnalyze(analyze_t *p)
{
- free(p->name);
- free(p);
+ free(p->name);
+ free(p);
}
-void
-startScreenAnalyze()
+void startScreenAnalyze()
{
#ifndef NO_SOUND
- playMusic("menu", MUSIC_GROUP_BASE);
+ playMusic("menu", MUSIC_GROUP_BASE);
#endif
}
-void
-drawScreenAnalyze()
+void drawScreenAnalyze()
{
- widget_t *this;
- int i;
+ widget_t *this;
+ int i;
- drawWidgetImage(image_backgorund);
+ drawWidgetImage(image_backgorund);
- for (i = 0; i < listWidgetLabelName->count; i++) {
- this = (widget_t *) (listWidgetLabelName->list[i]);
- drawWidgetLabel(this);
- }
+ for( i = 0 ; i < listWidgetLabelName->count ; i++ )
+ {
+ this = (widget_t *)(listWidgetLabelName->list[i]);
+ drawWidgetLabel(this);
+ }
- for (i = 0; i < listWidgetLabelScore->count; i++) {
- this = (widget_t *) (listWidgetLabelScore->list[i]);
- drawWidgetLabel(this);
- }
+ for( i = 0 ; i < listWidgetLabelScore->count ; i++ )
+ {
+ this = (widget_t *)(listWidgetLabelScore->list[i]);
+ drawWidgetLabel(this);
+ }
- drawWidgetLabel(widgetLabelMsg);
- drawWidgetButton(button_ok);
+ drawWidgetLabel(widgetLabelMsg);
+ drawWidgetButton(button_ok);
}
-void
-eventScreenAnalyze()
+void eventScreenAnalyze()
{
- eventWidgetButton(button_ok);
+ eventWidgetButton(button_ok);
}
-void
-stopScreenAnalyze()
+void stopScreenAnalyze()
{
- destroyWidgetLabel(widgetLabelMsg);
- widgetLabelMsg =
- newWidgetLabel("", WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER);
+ destroyWidgetLabel(widgetLabelMsg);
+ widgetLabelMsg = newWidgetLabel("", WINDOW_SIZE_X / 2 , 250, WIDGET_LABEL_CENTER);
}
-static void
-eventWidget(void *p)
+static void eventWidget(void *p)
{
- widget_t *button;
-
- button = (widget_t *) (p);
-
- if (button == button_ok) {
- setScreen("mainMenu");
- }
+ widget_t *button;
+
+ button = (widget_t *)(p);
+
+ if( button == button_ok )
+ {
+ setScreen("mainMenu");
+ }
}
-void
-restartAnalyze()
+void restartAnalyze()
{
- destroyListItem(listWidgetLabelName, destroyWidgetLabel);
- destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
- destroyListItem(listAnalyze, destroyAnalyze);
+ destroyListItem(listWidgetLabelName, destroyWidgetLabel);
+ destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
+ destroyListItem(listAnalyze, destroyAnalyze);
- listWidgetLabelName = newList();
- listWidgetLabelScore = newList();
- listAnalyze = newList();
+ listWidgetLabelName = newList();
+ listWidgetLabelScore = newList();
+ listAnalyze = newList();
}
-void
-addAnalyze(char *name, int score)
+void addAnalyze(char *name, int score)
{
- addList(listAnalyze, newAnalyze(name, score));
+ addList(listAnalyze, newAnalyze(name, score) );
}
-void
-setMsgToAnalyze(char *msg)
+void setMsgToAnalyze(char *msg)
{
- destroyWidgetLabel(widgetLabelMsg);
- widgetLabelMsg =
- newWidgetLabel(msg, WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER);
+ destroyWidgetLabel(widgetLabelMsg);
+ widgetLabelMsg = newWidgetLabel(msg, WINDOW_SIZE_X / 2 , 250, WIDGET_LABEL_CENTER);
}
-void
-endAnalyze()
+void endAnalyze()
{
- int i;
+ int i;
- for (i = 0; i < listAnalyze->count; i++) {
- analyze_t *this;
- char *str;
+ for( i = 0 ; i < listAnalyze->count ; i++ )
+ {
+ analyze_t *this;
+ char *str;
- this = (analyze_t *) (listAnalyze->list[i]);
+ this = (analyze_t *)(listAnalyze->list[i]);
- addList(listWidgetLabelName, newWidgetLabel(this->name,
- 100, 200 + 20 * i,
- WIDGET_LABEL_LEFT));
+ addList(listWidgetLabelName, newWidgetLabel(this->name,
+ 100, 200 + 20*i, WIDGET_LABEL_LEFT) );
- str = getString(this->score);
+ str = getString(this->score);
- addList(listWidgetLabelScore, newWidgetLabel(str,
- WINDOW_SIZE_X - 100,
- 200 + 20 * i,
- WIDGET_LABEL_RIGHT));
+ addList(listWidgetLabelScore, newWidgetLabel(str,
+ WINDOW_SIZE_X - 100, 200 + 20*i, WIDGET_LABEL_RIGHT) );
- free(str);
- }
+ free(str);
+ }
}
-void
-initScreenAnalyze()
+void initScreenAnalyze()
{
- image_t *image;
+ image_t *image;
- image = getImage(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = newWidgetImage(0, 0, image);
+ image = getImage(IMAGE_GROUP_BASE, "screen_main");
+ image_backgorund = newWidgetImage(0, 0, image);
- listWidgetLabelName = newList();
- listWidgetLabelScore = newList();
- listAnalyze = newList();
+ listWidgetLabelName = newList();
+ listWidgetLabelScore = newList();
+ listAnalyze = newList();
- button_ok =
- newWidgetButton("OK", WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2,
- WINDOW_SIZE_Y - 100, eventWidget);
+ button_ok = newWidgetButton("OK", WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2,
+ WINDOW_SIZE_Y-100, eventWidget);
- registerScreen(newScreen("analyze", startScreenAnalyze, eventScreenAnalyze,
- drawScreenAnalyze, stopScreenAnalyze));
+ registerScreen( newScreen("analyze", startScreenAnalyze, eventScreenAnalyze,
+ drawScreenAnalyze, stopScreenAnalyze) );
- widgetLabelMsg =
- newWidgetLabel("", WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER);
+ widgetLabelMsg = newWidgetLabel("", WINDOW_SIZE_X / 2 , 250, WIDGET_LABEL_CENTER);
}
-void
-quitScreenAnalyze()
+void quitScreenAnalyze()
{
- destroyWidgetImage(image_backgorund);
+ destroyWidgetImage(image_backgorund);
- destroyListItem(listWidgetLabelName, destroyWidgetLabel);
- destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
- destroyListItem(listAnalyze, destroyAnalyze);
+ destroyListItem(listWidgetLabelName, destroyWidgetLabel);
+ destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
+ destroyListItem(listAnalyze, destroyAnalyze);
- destroyWidgetButton(button_ok);
- destroyWidgetLabel(widgetLabelMsg);
+ destroyWidgetButton(button_ok);
+ destroyWidgetLabel(widgetLabelMsg);
}
+
diff --git a/src/screen/screen_analyze.c~ b/src/screen/screen_analyze.c~
deleted file mode 100644
index ee42a90..0000000
--- a/src/screen/screen_analyze.c~
+++ /dev/null
@@ -1,180 +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"
-
-#ifndef NO_SOUND
-#include "music.h"
-#endif
-
-#include "screen_mainMenu.h"
-#include "screen_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);
-}
-
-void startScreenAnalyze()
-{
-#ifndef NO_SOUND
- playMusic("menu", MUSIC_GROUP_BASE);
-#endif
-}
-
-void drawScreenAnalyze()
-{
- widget_t *this;
- int i;
-
- drawWidgetImage(image_backgorund);
-
- for( i = 0 ; i < listWidgetLabelName->count ; i++ )
- {
- this = (widget_t *)(listWidgetLabelName->list[i]);
- drawWidgetLabel(this);
- }
-
- for( i = 0 ; i < listWidgetLabelScore->count ; i++ )
- {
- this = (widget_t *)(listWidgetLabelScore->list[i]);
- drawWidgetLabel(this);
- }
-
- drawWidgetLabel(widgetLabelMsg);
- drawWidgetButton(button_ok);
-}
-
-void eventScreenAnalyze()
-{
- eventWidgetButton(button_ok);
-}
-
-void stopScreenAnalyze()
-{
- destroyWidgetLabel(widgetLabelMsg);
- widgetLabelMsg = newWidgetLabel("", WINDOW_SIZE_X / 2 , 250, WIDGET_LABEL_CENTER);
-}
-
-static void eventWidget(void *p)
-{
- widget_t *button;
-
- button = (widget_t *)(p);
-
- if( button == button_ok )
- {
- setScreen("mainMenu");
- }
-}
-
-void restartAnalyze()
-{
- destroyListItem(listWidgetLabelName, destroyWidgetLabel);
- destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
- destroyListItem(listAnalyze, destroyAnalyze);
-
- listWidgetLabelName = newList();
- listWidgetLabelScore = newList();
- listAnalyze = newList();
-}
-
-void addAnalyze(char *name, int score)
-{
- addList(listAnalyze, newAnalyze(name, score) );
-}
-
-void setMsgToAnalyze(char *msg)
-{
- destroyWidgetLabel(widgetLabelMsg);
- widgetLabelMsg = newWidgetLabel(msg, WINDOW_SIZE_X / 2 , 250, WIDGET_LABEL_CENTER);
-}
-
-void endAnalyze()
-{
- int i;
-
- for( i = 0 ; i < listAnalyze->count ; i++ )
- {
- analyze_t *this;
- char *str;
-
- this = (analyze_t *)(listAnalyze->list[i]);
-
- addList(listWidgetLabelName, newWidgetLabel(this->name,
- 100, 200 + 20*i, WIDGET_LABEL_LEFT) );
-
- str = getString(this->score);
-
- addList(listWidgetLabelScore, newWidgetLabel(str,
- WINDOW_SIZE_X - 100, 200 + 20*i, WIDGET_LABEL_RIGHT) );
-
- free(str);
- }
-}
-
-void initScreenAnalyze()
-{
- image_t *image;
-
- image = getImage(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = newWidgetImage(0, 0, image);
-
- listWidgetLabelName = newList();
- listWidgetLabelScore = newList();
- listAnalyze = newList();
-
- button_ok = newWidgetButton("OK", WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2,
- WINDOW_SIZE_Y-100, eventWidget);
-
- registerScreen( newScreen("analyze", startScreenAnalyze, eventScreenAnalyze,
- drawScreenAnalyze, stopScreenAnalyze) );
-
- widgetLabelMsg = newWidgetLabel("", WINDOW_SIZE_X / 2 , 250, WIDGET_LABEL_CENTER);
-}
-
-void quitScreenAnalyze()
-{
- destroyWidgetImage(image_backgorund);
-
- destroyListItem(listWidgetLabelName, destroyWidgetLabel);
- destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
- destroyListItem(listAnalyze, destroyAnalyze);
-
- destroyWidgetButton(button_ok);
- destroyWidgetLabel(widgetLabelMsg);
-}
-
diff --git a/src/screen/screen_browser.c b/src/screen/screen_browser.c
index a6abe05..9d82ffe 100644
--- a/src/screen/screen_browser.c
+++ b/src/screen/screen_browser.c
@@ -68,666 +68,649 @@ static widget_t *select_server;
static server_t server_list;
/* function prototypes */
-static int LoadServers();
-static int RefreshServers();
-static server_t *server_getcurr();
+static int LoadServers ();
+static int RefreshServers ();
+static server_t *server_getcurr ();
-void
-startScreenBrowser()
+void startScreenBrowser()
{
#ifndef NO_SOUND
- playMusic("menu", MUSIC_GROUP_BASE);
+ playMusic("menu", MUSIC_GROUP_BASE);
#endif
- LoadServers();
+ LoadServers ();
}
-void
-drawScreenBrowser()
+void drawScreenBrowser()
{
- drawWidgetImage(image_backgorund);
+ drawWidgetImage(image_backgorund);
- drawWidgetLabel(label_server);
- drawWidgetLabel(label_version);
- drawWidgetLabel(label_address);
- drawWidgetLabel(label_arena);
- drawWidgetLabel(label_players);
- drawWidgetLabel(label_ping);
+ drawWidgetLabel(label_server);
+ drawWidgetLabel(label_version);
+ drawWidgetLabel(label_address);
+ drawWidgetLabel(label_arena);
+ drawWidgetLabel(label_players);
+ drawWidgetLabel(label_ping);
- drawWidgetSelect(select_server);
+ drawWidgetSelect(select_server);
- drawWidgetButton(button_play);
- drawWidgetButton(button_back);
- drawWidgetButton(button_refresh);
+ drawWidgetButton(button_play);
+ drawWidgetButton(button_back);
+ drawWidgetButton(button_refresh);
}
-void
-eventScreenBrowser()
+void eventScreenBrowser()
{
- eventWidgetSelect(select_server);
+ eventWidgetSelect(select_server);
- eventWidgetButton(button_play);
- eventWidgetButton(button_back);
- eventWidgetButton(button_refresh);
+ eventWidgetButton(button_play);
+ eventWidgetButton(button_back);
+ eventWidgetButton(button_refresh);
}
-void
-stopScreenBrowser()
+void stopScreenBrowser()
{
- unsigned i = 0;
- server_t *server;
+ unsigned i = 0;
+ server_t *server;
- //destroyListItem(select_server->list, free);
- //select_server->list = newList();
- removeAllFromWidgetSelect(select_server);
+ //destroyListItem(select_server->list, free);
+ //select_server->list = newList();
+ removeAllFromWidgetSelect(select_server);
- while (1) {
- i = 0;
- for (server = server_list.next; server != &server_list;
- server = server->next) {
- server->next->prev = server->prev;
- server->prev->next = server->next;
+ while (1) {
+ i = 0;
+ for (server = server_list.next; server != &server_list; server = server->next) {
+ server->next->prev = server->prev;
+ server->prev->next = server->next;
- if (server->name)
- free(server->name);
+ if (server->name)
+ free (server->name);
- if (server->version)
- free(server->version);
+ if (server->version)
+ free (server->version);
- if (server->arena)
- free(server->arena);
+ if (server->arena)
+ free (server->arena);
- free(server);
+ free (server);
- i++;
- break;
- }
+ i ++;
+ break;
+ }
- if (!i)
- return;
- }
+ if (!i)
+ return;
+ }
}
-static void
-eventWidget(void *p)
+static void eventWidget(void *p)
{
- widget_t *button;
+ widget_t *button;
+
+ button = (widget_t *)(p);
- button = (widget_t *) (p);
+ if( button == button_play )
+ {
+ server_t *server = server_getcurr ();
- if (button == button_play) {
- server_t *server = server_getcurr();
+ if (!server)
+ return;
- if (!server)
- return;
+ /* server je offline */
+ if (!server->state)
+ return;
- /* server je offline */
- if (!server->state)
- return;
+ struct in_addr srv;
+ srv.s_addr = server->ip;
- struct in_addr srv;
- srv.s_addr = server->ip;
+ char *address = (char *) inet_ntoa (srv);
- char *address = (char *) inet_ntoa(srv);
+ setSettingGameType (NET_GAME_TYPE_CLIENT);
+ setSettingIP(address);
+ setSettingPort(server->port);
- setSettingGameType(NET_GAME_TYPE_CLIENT);
- setSettingIP(address);
- setSettingPort(server->port);
+ setScreen("world");
+ }
- setScreen("world");
- }
+ if( button == button_back )
+ {
+ setScreen("gameType");
+ }
- if (button == button_back) {
- setScreen("gameType");
- }
-
- if (button == button_refresh) {
- RefreshServers();
- }
+ if( button == button_refresh )
+ {
+ RefreshServers ();
+ }
}
-server_t *
-server_getcurr()
+server_t *server_getcurr ()
{
- unsigned i = 0;
- server_t *server;
+ unsigned i = 0;
+ server_t *server;
- for (server = server_list.next; server != &server_list;
- server = server->next) {
- if (i == getWidgetSelectIndex(select_server))
- return server;
+ for (server = server_list.next; server != &server_list; server = server->next) {
+ if (i == getWidgetSelectIndex(select_server))
+ return server;
- i++;
- }
+ i ++;
+ }
- return 0;
+ return 0;
}
-int
-server_getinfo(server_t * server)
+int server_getinfo (server_t *server)
{
- struct sockaddr_in srv;
- int mySocket;
+ struct sockaddr_in srv;
+ int mySocket;
- if ((mySocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
- return -1;
- }
+ if ((mySocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
+ return -1;
+ }
#ifndef __WIN32__
- // Lets make socket non-blocking
- int oldFlag = fcntl(mySocket, F_GETFL, 0);
- if (fcntl(mySocket, F_SETFL, oldFlag | O_NONBLOCK) == -1) {
- return -1;
- }
+ // Lets make socket non-blocking
+ int oldFlag = fcntl (mySocket, F_GETFL, 0);
+ if (fcntl (mySocket, F_SETFL, oldFlag | O_NONBLOCK) == -1) {
+ return -1;
+ }
#else
- unsigned long arg = 1;
- // Operation is FIONBIO. Parameter is pointer on non-zero number.
- if (ioctlsocket(mySocket, FIONBIO, &arg) == SOCKET_ERROR) {
- WSACleanup();
- return -1;
- }
+ 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
- struct timeval tv;
+ struct timeval tv;
- fd_set myset;
- FD_ZERO(&myset);
- FD_SET(mySocket, &myset);
+ fd_set myset;
+ FD_ZERO(&myset);
+ FD_SET(mySocket, &myset);
- tv.tv_sec = 2;
- tv.tv_usec = 0;
+ 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;
+ 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) {
+ if (connect (mySocket, (struct sockaddr *) &srv, sizeof (srv)) == -1) {
#ifndef __WIN32__
- if (errno != EINPROGRESS)
- return -1;
+ if (errno != EINPROGRESS)
+ return -1;
#else
- if (WSAGetLastError() != WSAEWOULDBLOCK) {
- WSACleanup();
- return -1;
- }
+ if (WSAGetLastError() != WSAEWOULDBLOCK) {
+ WSACleanup();
+ return -1;
+ }
#endif
- }
+ }
- int ret = select(mySocket + 1, NULL, &myset, NULL, &tv);
+ int ret = select (mySocket+1, NULL, &myset, NULL, &tv);
- if (ret == -1)
- return 0;
+ if (ret == -1)
+ return 0;
- if (ret == 0)
- return -2;
+ if (ret == 0)
+ return -2;
- char request[8];
- memcpy(request, "status\n", 7);
+ char request[8];
+ memcpy (request, "status\n", 7);
- int r = send(mySocket, request, 7, 0);
+ int r = send (mySocket, request, 7, 0);
- if (r == -1)
- return -2;
+ if (r == -1)
+ return -2;
- FD_ZERO(&myset);
- FD_SET(mySocket, &myset);
- tv.tv_sec = 1;
- tv.tv_usec = 0;
+ FD_ZERO(&myset);
+ FD_SET(mySocket, &myset);
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
- char *str = (char *) malloc(sizeof(char) * 257);
+ char *str = (char *) malloc (sizeof (char) * 257);
- if (!str)
- return -1;
+ if (!str)
+ return -1;
- while (1) {
- int sel = select(mySocket + 1, &myset, NULL, NULL, &tv);
+ while (1) {
+ int sel = select (mySocket + 1, &myset, NULL, NULL, &tv);
- if (sel == 0) {
- free(str);
+ if (sel == 0) {
+ free (str);
#ifndef __WIN32__
- close(mySocket);
+ close (mySocket);
#else
- closesocket(mySocket);
- WSACleanup();
+ closesocket (mySocket);
+ WSACleanup();
#endif
- return -2;
- }
+ return -2;
+ }
- if (sel == -1) {
- free(str);
+ if (sel == -1) {
+ free (str);
#ifndef __WIN32__
- close(mySocket);
+ close (mySocket);
#else
- closesocket(mySocket);
- WSACleanup();
+ closesocket (mySocket);
+ WSACleanup();
#endif
- return -2;
- }
-
- if ((ret = recv(mySocket, str, 256, 0)) == -1) {
- free(str);
+ return -2;
+ }
+
+ if ((ret = recv(mySocket, str, 256, 0)) == -1) {
+ free (str);
#ifndef __WIN32__
- close(mySocket);
+ close (mySocket);
#else
- closesocket(mySocket);
- WSACleanup();
+ closesocket (mySocket);
+ WSACleanup();
#endif
- return -1;
- }
-
- if (ret > 0)
- break;
- }
+ return -1;
+ }
+
+ if (ret > 0)
+ break;
+ }
#ifndef __WIN32__
- close(mySocket);
+ close (mySocket);
#else
- closesocket(mySocket);
- WSACleanup();
+ closesocket (mySocket);
+ WSACleanup();
#endif
- server->ping = 1000 - (tv.tv_usec / 1000);
- /*
- ["name: F\n"] >= svn82
- "version: svnX\n"
- "clients: N\n"
- "maxclients: M\n"
- "uptime: D\n"
- */
-
- unsigned i = 0;
-
- while (i < ret) {
- if (str[i] == '\n')
- str[i] = '\0';
-
- i++;
- }
+ server->ping = 1000 - (tv.tv_usec/1000);
+ /*
+ ["name: F\n"] >= svn82
+ "version: svnX\n"
+ "clients: N\n"
+ "maxclients: M\n"
+ "uptime: D\n"
+ */
- unsigned name = 0;
+ unsigned i = 0;
- if (strstr(str, "name: "))
- name = 1;
+ while (i < ret) {
+ if (str[i] == '\n')
+ str[i] = '\0';
- int len = 0;
+ i ++;
+ }
- 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));
+ unsigned name = 0;
- if (!server->name)
- return 0;
+ if (strstr (str, "name: "))
+ name = 1;
- memcpy(server->name, str + 6, name_len + 1);
- server->name[name_len + 1] = '\0';
- }
- }
+ int len = 0;
- /* HACK */
- if (!name)
- len = -1;
+ 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';
+ }
+ }
- if (!strncmp(str + len + 1, "version: ", 9)) {
- unsigned ver_len = strlen(str + len + 10);
- server->version = (char *) malloc(sizeof(char) * (ver_len + 2));
+ /* HACK */
+ if (!name)
+ len = -1;
- if (!server->version)
- return 0;
+ 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';
+ }
- memcpy(server->version, str + len + 10, ver_len + 1);
- server->version[ver_len + 1] = '\0';
- }
+ len += strlen (str+len+1) + 1;
- len += strlen(str + len + 1) + 1;
+ if (!strncmp (str+len+1, "clients: ", 9))
+ server->clients = atoi (str+len+10);
- if (!strncmp(str + len + 1, "clients: ", 9))
- server->clients = atoi(str + len + 10);
+ len += strlen (str+len+1) + 1;
- len += strlen(str + len + 1) + 1;
+ if (!strncmp (str+len+1, "maxclients: ", 12))
+ server->maxclients = atoi (str+len+13);
- if (!strncmp(str + len + 1, "maxclients: ", 12))
- server->maxclients = atoi(str + len + 13);
+ len += strlen (str+len+1) + 1;
+
- len += strlen(str + len + 1) + 1;
+ if (!strncmp (str+len+1, "uptime: ", 8))
+ server->uptime = atoi (str+len+9);
+ len += strlen (str+len+1) + 1;
+
- if (!strncmp(str + len + 1, "uptime: ", 8))
- server->uptime = atoi(str + len + 9);
+ 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';
+ }
- len += strlen(str + len + 1) + 1;
+ free (str);
- if (!strncmp(str + len + 1, "arena: ", 7)) {
- unsigned arena_len = strlen(str + len + 9);
- server->arena = (char *) malloc(sizeof(char) * (arena_len + 2));
+ server->state = 1;
- 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;
+ return 1;
}
-static int
-LoadServers()
+static int LoadServers ()
// Get server list
{
#ifndef __WIN32__
- int s;
+ int s;
#else
- SOCKET s;
+ SOCKET s;
#endif
- char buf[1025];
-
- /* TODO: dodelat TCP makro */
- struct sockaddr_in server;
- char *master_server_ip;
+ char buf[1025];
- master_server_ip = getIPFormDNS(NET_MASTER_SERVER_DOMAIN);
+ /* TODO: dodelat TCP makro */
+ struct sockaddr_in server;
+ char *master_server_ip;
- //printf("master_server_ip = %s\n", master_server_ip);
+ master_server_ip = getIPFormDNS (NET_MASTER_SERVER_DOMAIN);
- if (master_server_ip == NULL) // master server is down
- {
- return -1;
- }
+ //printf("master_server_ip = %s\n", master_server_ip);
- server.sin_family = AF_INET;
- server.sin_port = htons(NET_MASTER_PORT);
- server.sin_addr.s_addr = inet_addr(master_server_ip);
+ if( master_server_ip == NULL ) // master server is down
+ {
+ 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);
- free(master_server_ip);
-
- if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0)
- return 0;
+ if ((s = socket (AF_INET, SOCK_STREAM, 0)) < 0)
+ return 0;
#ifndef __WIN32__
- // Lets make socket non-blocking
- int oldFlag = fcntl(s, F_GETFL, 0);
- if (fcntl(s, F_SETFL, oldFlag | O_NONBLOCK) == -1) {
- return -1;
- }
+ // Lets make socket non-blocking
+ int oldFlag = fcntl (s, F_GETFL, 0);
+ if (fcntl (s, F_SETFL, oldFlag | O_NONBLOCK) == -1) {
+ return -1;
+ }
#else
- unsigned long arg = 1;
- // Operation is FIONBIO. Parameter is pointer on non-zero number.
- if (ioctlsocket(s, FIONBIO, &arg) == SOCKET_ERROR) {
- WSACleanup();
- return -1;
- }
+ 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
- if (connect(s, (struct sockaddr *) &server, sizeof(server)) == -1) {
+ if (connect (s, (struct sockaddr *) &server, sizeof (server)) == -1) {
#ifndef __WIN32__
- if (errno != EINPROGRESS)
- return -1;
+ if (errno != EINPROGRESS)
+ return -1;
#else
- if (WSAGetLastError() != WSAEWOULDBLOCK) {
- WSACleanup();
- return -1;
- }
+ if (WSAGetLastError() != WSAEWOULDBLOCK) {
+ WSACleanup();
+ return -1;
+ }
#endif
- }
+ }
- struct timeval tv;
+ struct timeval tv;
- fd_set myset;
+ fd_set myset;
- FD_ZERO(&myset);
- FD_SET(s, &myset);
+ FD_ZERO(&myset);
+ FD_SET(s, &myset);
- tv.tv_sec = 3;
- tv.tv_usec = 0;
+ tv.tv_sec = 3;
+ tv.tv_usec = 0;
- int ret = select(s + 1, NULL, &myset, NULL, &tv);
+ int ret = select (s+1, NULL, &myset, NULL, &tv);
- if (ret == -1)
- return 0;
+ if (ret == -1)
+ return 0;
- if (ret == 0)
- return -2;
+ if (ret == 0)
+ return -2;
- /* send request for server list */
- send(s, "l", 1, 0);
+ /* send request for server list */
+ send (s, "l", 1, 0);
- FD_ZERO(&myset);
- FD_SET(s, &myset);
+ FD_ZERO(&myset);
+ FD_SET(s, &myset);
- ret = select(s + 1, &myset, NULL, NULL, &tv);
+ ret = select (s+1, &myset, NULL, NULL, &tv);
- if (ret == -1)
- return 0;
+ if (ret == -1)
+ return 0;
- if (ret == 0)
- return -2;
+ if (ret == 0)
+ return -2;
- int len = recv(s, buf, 1024, 0);
+ int len = recv (s, buf, 1024, 0);
#ifndef __WIN32__
- close(s);
+ close (s);
#else
- closesocket(s);
- WSACleanup();
+ closesocket (s);
+ WSACleanup();
#endif
- if (len <= 0)
- return 0;
-
- unsigned i = 0;
- char list[256];
-
- struct in_addr srv;
+ if (len <= 0)
+ return 0;
- typedef struct
- {
- unsigned port;
- unsigned ip;
- } response_head;
+ unsigned i = 0;
+ char list[256];
- while (1) {
- response_head *header = (response_head *) ((char *) buf + i);
+ struct in_addr srv;
- server_t *ctx;
+ typedef struct {
+ unsigned port;
+ unsigned ip;
+ } response_head;
- // alloc and init context
- ctx = (server_t *) malloc(sizeof(server_t));
+ while (1) {
+ response_head *header = (response_head *) ((char *) buf + i);
- ctx->ip = header->ip;
- ctx->port = header->port;
- ctx->name = 0;
- ctx->version = 0;
- ctx->arena = 0;
+ 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;
- int ret = server_getinfo(ctx);
+ int ret = server_getinfo (ctx);
- srv.s_addr = ctx->ip;
+ srv.s_addr = ctx->ip;
- char *address = (char *) inet_ntoa(srv);
+ char *address = (char *) inet_ntoa (srv);
- memset(list, ' ', 254);
- list[255] = '\0';
+ 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 (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);
+ if (ctx->name)
+ memcpy (list, ctx->name, strlen (ctx->name));
+ else
+ memcpy (list, "Unknown", 7);
- memcpy(list + 30, ctx->version, strlen(ctx->version));
+ 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);
+ unsigned a_len = strlen (address);
+ memcpy (list+38, address, a_len);
+ memcpy (list+38+a_len, ":", 1);
- sprintf(buf, "%d", ctx->port);
+ sprintf (buf, "%d", ctx->port);
- memcpy(list + 39 + a_len, buf, strlen(buf));
+ memcpy (list+39+a_len, buf, strlen (buf));
- memcpy(list + 60, ctx->arena, strlen(ctx->arena));
+ memcpy (list+60, ctx->arena, strlen (ctx->arena));
- sprintf(buf, "%d/%d", ctx->clients, ctx->maxclients);
+ sprintf (buf, "%d/%d", ctx->clients, ctx->maxclients);
- memcpy(list + 75, buf, strlen(buf));
+ memcpy (list+75, buf, strlen (buf));
- sprintf(buf, "%dms", ctx->ping);
+ sprintf (buf, "%dms", ctx->ping);
- memcpy(list + 83, buf, strlen(buf));
- }
+ memcpy (list+83, buf, strlen (buf));
+ }
- addToWidgetSelect(select_server, list);
+ addToWidgetSelect(select_server, list);
- // add into list
- ctx->next = &server_list;
- ctx->prev = server_list.prev;
- ctx->prev->next = ctx;
- ctx->next->prev = ctx;
+ // add into list
+ ctx->next = &server_list;
+ ctx->prev = server_list.prev;
+ ctx->prev->next = ctx;
+ ctx->next->prev = ctx;
- i += sizeof(response_head) + 1;
+ i += sizeof (response_head) + 1;
- if (buf[i - 1] != '\n' || (i + 1) > len)
- break;
- }
+ if (buf[i-1] != '\n' || (i+1) > len)
+ break;
+ }
- return 1;
+ return 1;
}
-static int
-RefreshServers()
+static int RefreshServers ()
{
/*
destroyListItem(select_server->list, free);
select_server->list = newList();
*/
- removeAllFromWidgetSelect(select_server);
+ removeAllFromWidgetSelect(select_server);
- struct in_addr srv;
+ struct in_addr srv;
- server_t *server;
- for (server = server_list.next; server != &server_list;
- server = server->next) {
- if (server->name)
- free(server->name);
+ 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->version)
+ free (server->version);
- if (server->arena)
- free(server->arena);
+ if (server->arena)
+ free (server->arena);
- server->name = 0;
- server->version = 0;
- server->arena = 0;
+ server->name = 0;
+ server->version = 0;
+ server->arena = 0;
- char list[256];
- char buf[32];
+ char list[256];
+ char buf[32];
+
+ int ret = server_getinfo (server);
- int ret = server_getinfo(server);
+ srv.s_addr = server->ip;
- srv.s_addr = server->ip;
+ char *address = (char *) inet_ntoa (srv);
+
+ if (ret == 1) {
+ memset (list, ' ', 254);
+ list[255] = '\0';
- char *address = (char *) inet_ntoa(srv);
+ if (server->name)
+ memcpy (list, server->name, strlen (server->name));
+ else
+ memcpy (list, "Unknown", 7);
- if (ret == 1) {
- memset(list, ' ', 254);
- list[255] = '\0';
+ memcpy (list+30, server->version, strlen (server->version));
- if (server->name)
- memcpy(list, server->name, strlen(server->name));
- else
- memcpy(list, "Unknown", 7);
+ unsigned a_len = strlen (address);
+ memcpy (list+38, address, a_len);
+ memcpy (list+38+a_len, ":", 1);
- memcpy(list + 30, server->version, strlen(server->version));
+ sprintf (buf, "%d", server->port);
- unsigned a_len = strlen(address);
- memcpy(list + 38, address, a_len);
- memcpy(list + 38 + a_len, ":", 1);
+ memcpy (list+39+a_len, buf, strlen (buf));
- sprintf(buf, "%d", server->port);
+ memcpy (list+60, server->arena, strlen (server->arena));
- memcpy(list + 39 + a_len, buf, strlen(buf));
+ sprintf (buf, "%d/%d", server->clients, server->maxclients);
- memcpy(list + 60, server->arena, strlen(server->arena));
+ memcpy (list+75, buf, strlen (buf));
- sprintf(buf, "%d/%d", server->clients, server->maxclients);
+ sprintf (buf, "%dms", server->ping);
- memcpy(list + 75, buf, strlen(buf));
+ memcpy (list+83, buf, strlen (buf));
+ }
- sprintf(buf, "%dms", server->ping);
+ addToWidgetSelect(select_server, list);
- memcpy(list + 83, buf, strlen(buf));
- }
+ }
- addToWidgetSelect(select_server, list);
-
- }
-
- return 1;
+ return 1;
}
-void
-initScreenBrowser()
+void initScreenBrowser()
{
- image_t *image;
-
- image = getImage(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = newWidgetImage(0, 0, image);
-
- button_back =
- newWidgetButton(_("back"), 100, WINDOW_SIZE_Y - 100, eventWidget);
- button_play =
- newWidgetButton(_("Play"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100,
- eventWidget);
- button_refresh =
- newWidgetButton(_("Refresh"), WINDOW_SIZE_X / 2 - 50,
- WINDOW_SIZE_Y - 100, eventWidget);
-
- label_server = newWidgetLabel(_("server"), 120, 145, WIDGET_LABEL_LEFT);
- label_version = newWidgetLabel(_("version"), 290, 145, WIDGET_LABEL_LEFT);
- label_address = newWidgetLabel(_("IP"), 400, 145, WIDGET_LABEL_LEFT);
- label_arena = newWidgetLabel(_("arena"), 550, 145, WIDGET_LABEL_LEFT);
- label_players = newWidgetLabel(_("clients"), 645, 145, WIDGET_LABEL_LEFT);
- label_ping = newWidgetLabel(_("ping"), 720, 145, WIDGET_LABEL_LEFT);
-
- select_server = newWidgetSelect(50, label_server->y + 40, eventWidget);
-
- registerScreen(newScreen("browser", startScreenBrowser, eventScreenBrowser,
- drawScreenBrowser, stopScreenBrowser));
-
- server_list.next = &server_list;
- server_list.prev = &server_list;
+ image_t *image;
+
+ image = getImage(IMAGE_GROUP_BASE, "screen_main");
+ image_backgorund = newWidgetImage(0, 0, image);
+
+ button_back = newWidgetButton(_("back"), 100, WINDOW_SIZE_Y-100, eventWidget);
+ button_play = newWidgetButton(_("Play"), WINDOW_SIZE_X-200, WINDOW_SIZE_Y-100, eventWidget);
+ button_refresh = newWidgetButton(_("Refresh"), WINDOW_SIZE_X/2-50, WINDOW_SIZE_Y-100, eventWidget);
+
+ label_server = newWidgetLabel(_("server"), 120, 145, WIDGET_LABEL_LEFT);
+ label_version = newWidgetLabel(_("version"), 290, 145, WIDGET_LABEL_LEFT);
+ label_address = newWidgetLabel(_("IP"), 400, 145, WIDGET_LABEL_LEFT);
+ label_arena = newWidgetLabel(_("arena"), 550, 145, WIDGET_LABEL_LEFT);
+ label_players = newWidgetLabel(_("clients"), 645, 145, WIDGET_LABEL_LEFT);
+ label_ping = newWidgetLabel(_("ping"), 720, 145, WIDGET_LABEL_LEFT);
+
+ select_server = newWidgetSelect(50, label_server->y+40, eventWidget);
+
+ registerScreen( newScreen("browser", startScreenBrowser, eventScreenBrowser,
+ drawScreenBrowser, stopScreenBrowser) );
+
+ server_list.next = &server_list;
+ server_list.prev = &server_list;
}
-void
-quitScreenBrowser()
+void quitScreenBrowser()
{
- destroyWidgetImage(image_backgorund);
+ destroyWidgetImage(image_backgorund);
- destroyWidgetButton(button_play);
- destroyWidgetButton(button_back);
- destroyWidgetButton(button_refresh);
+ destroyWidgetButton(button_play);
+ destroyWidgetButton(button_back);
+ destroyWidgetButton(button_refresh);
- destroyWidgetLabel(label_server);
- destroyWidgetLabel(label_version);
- destroyWidgetLabel(label_address);
- destroyWidgetLabel(label_arena);
- destroyWidgetLabel(label_players);
- destroyWidgetLabel(label_ping);
+ destroyWidgetLabel(label_server);
+ destroyWidgetLabel(label_version);
+ destroyWidgetLabel(label_address);
+ destroyWidgetLabel(label_arena);
+ destroyWidgetLabel(label_players);
+ destroyWidgetLabel(label_ping);
- destroyWidgetSelect(select_server);
+ destroyWidgetSelect(select_server);
}
diff --git a/src/screen/screen_browser.c~ b/src/screen/screen_browser.c~
deleted file mode 100644
index 9d82ffe..0000000
--- a/src/screen/screen_browser.c~
+++ /dev/null
@@ -1,716 +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"
-
-
-#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
-#include <windows.h>
-#include <wininet.h>
-#endif
-
-#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
-
-#include "screen_gameType.h"
-#include "screen_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 *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 ();
-
-
-void startScreenBrowser()
-{
-#ifndef NO_SOUND
- playMusic("menu", MUSIC_GROUP_BASE);
-#endif
-
- LoadServers ();
-}
-
-void drawScreenBrowser()
-{
- drawWidgetImage(image_backgorund);
-
- drawWidgetLabel(label_server);
- drawWidgetLabel(label_version);
- drawWidgetLabel(label_address);
- drawWidgetLabel(label_arena);
- drawWidgetLabel(label_players);
- drawWidgetLabel(label_ping);
-
- drawWidgetSelect(select_server);
-
- drawWidgetButton(button_play);
- drawWidgetButton(button_back);
- drawWidgetButton(button_refresh);
-}
-
-void eventScreenBrowser()
-{
- eventWidgetSelect(select_server);
-
- eventWidgetButton(button_play);
- eventWidgetButton(button_back);
- eventWidgetButton(button_refresh);
-}
-
-void stopScreenBrowser()
-{
- unsigned i = 0;
- server_t *server;
-
- //destroyListItem(select_server->list, free);
- //select_server->list = newList();
- removeAllFromWidgetSelect(select_server);
-
- while (1) {
- i = 0;
- for (server = server_list.next; server != &server_list; server = server->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);
-
- i ++;
- break;
- }
-
- if (!i)
- return;
- }
-}
-
-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 je 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);
- setSettingIP(address);
- setSettingPort(server->port);
-
- setScreen("world");
- }
-
- if( button == button_back )
- {
- setScreen("gameType");
- }
-
- if( button == button_refresh )
- {
- RefreshServers ();
- }
-}
-
-server_t *server_getcurr ()
-{
- unsigned i = 0;
- server_t *server;
-
- for (server = server_list.next; server != &server_list; server = server->next) {
- if (i == getWidgetSelectIndex(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__
- // Lets make socket non-blocking
- int oldFlag = fcntl (mySocket, F_GETFL, 0);
- if (fcntl (mySocket, F_SETFL, oldFlag | O_NONBLOCK) == -1) {
- return -1;
- }
-#else
- 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
-
- 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
- if (WSAGetLastError() != WSAEWOULDBLOCK) {
- WSACleanup();
- return -1;
- }
-#endif
- }
-
- 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
- closesocket (mySocket);
- WSACleanup();
-#endif
- return -2;
- }
-
- if (sel == -1) {
- free (str);
-#ifndef __WIN32__
- close (mySocket);
-#else
- closesocket (mySocket);
- WSACleanup();
-#endif
- return -2;
- }
-
- if ((ret = recv(mySocket, str, 256, 0)) == -1) {
- free (str);
-#ifndef __WIN32__
- close (mySocket);
-#else
- closesocket (mySocket);
- WSACleanup();
-#endif
- return -1;
- }
-
- if (ret > 0)
- break;
- }
-
-#ifndef __WIN32__
- close (mySocket);
-#else
- closesocket (mySocket);
- WSACleanup();
-#endif
-
- server->ping = 1000 - (tv.tv_usec/1000);
- /*
- ["name: F\n"] >= svn82
- "version: svnX\n"
- "clients: N\n"
- "maxclients: M\n"
- "uptime: D\n"
- */
-
- unsigned i = 0;
-
- while (i < ret) {
- if (str[i] == '\n')
- str[i] = '\0';
-
- i ++;
- }
-
- unsigned name = 0;
-
- 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;
-
- 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;
-
-
- if (!strncmp (str+len+1, "clients: ", 9))
- server->clients = atoi (str+len+10);
-
- len += strlen (str+len+1) + 1;
-
-
- if (!strncmp (str+len+1, "maxclients: ", 12))
- server->maxclients = atoi (str+len+13);
-
- len += strlen (str+len+1) + 1;
-
-
- if (!strncmp (str+len+1, "uptime: ", 8))
- server->uptime = atoi (str+len+9);
-
- len += strlen (str+len+1) + 1;
-
-
- 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;
-}
-
-static int LoadServers ()
-// Get server list
-{
-#ifndef __WIN32__
- int s;
-#else
- SOCKET s;
-#endif
-
- char buf[1025];
-
- /* TODO: dodelat TCP makro */
- struct sockaddr_in server;
- char *master_server_ip;
-
- master_server_ip = getIPFormDNS (NET_MASTER_SERVER_DOMAIN);
-
- //printf("master_server_ip = %s\n", master_server_ip);
-
- if( master_server_ip == NULL ) // master server is down
- {
- 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, 0)) < 0)
- return 0;
-
-#ifndef __WIN32__
- // Lets make socket non-blocking
- int oldFlag = fcntl (s, F_GETFL, 0);
- if (fcntl (s, F_SETFL, oldFlag | O_NONBLOCK) == -1) {
- return -1;
- }
-#else
- 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
-
- if (connect (s, (struct sockaddr *) &server, sizeof (server)) == -1) {
-#ifndef __WIN32__
- if (errno != EINPROGRESS)
- return -1;
-#else
- if (WSAGetLastError() != WSAEWOULDBLOCK) {
- WSACleanup();
- return -1;
- }
-#endif
- }
-
- 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;
-
- 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;
-
- if (ret == 0)
- return -2;
-
- int len = recv (s, buf, 1024, 0);
-
-#ifndef __WIN32__
- close (s);
-#else
- closesocket (s);
- WSACleanup();
-#endif
-
- if (len <= 0)
- return 0;
-
- unsigned i = 0;
- char list[256];
-
- struct in_addr srv;
-
- typedef struct {
- unsigned port;
- unsigned ip;
- } response_head;
-
- while (1) {
- 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;
-
- int 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));
- }
-
- addToWidgetSelect(select_server, list);
-
- // add into 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 ()
-{
-/*
- destroyListItem(select_server->list, free);
- select_server->list = newList();
-*/
- removeAllFromWidgetSelect(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));
- }
-
- addToWidgetSelect(select_server, list);
-
- }
-
- return 1;
-}
-
-void initScreenBrowser()
-{
- image_t *image;
-
- image = getImage(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = newWidgetImage(0, 0, image);
-
- button_back = newWidgetButton(_("back"), 100, WINDOW_SIZE_Y-100, eventWidget);
- button_play = newWidgetButton(_("Play"), WINDOW_SIZE_X-200, WINDOW_SIZE_Y-100, eventWidget);
- button_refresh = newWidgetButton(_("Refresh"), WINDOW_SIZE_X/2-50, WINDOW_SIZE_Y-100, eventWidget);
-
- label_server = newWidgetLabel(_("server"), 120, 145, WIDGET_LABEL_LEFT);
- label_version = newWidgetLabel(_("version"), 290, 145, WIDGET_LABEL_LEFT);
- label_address = newWidgetLabel(_("IP"), 400, 145, WIDGET_LABEL_LEFT);
- label_arena = newWidgetLabel(_("arena"), 550, 145, WIDGET_LABEL_LEFT);
- label_players = newWidgetLabel(_("clients"), 645, 145, WIDGET_LABEL_LEFT);
- label_ping = newWidgetLabel(_("ping"), 720, 145, WIDGET_LABEL_LEFT);
-
- select_server = newWidgetSelect(50, label_server->y+40, eventWidget);
-
- registerScreen( newScreen("browser", startScreenBrowser, eventScreenBrowser,
- drawScreenBrowser, stopScreenBrowser) );
-
- server_list.next = &server_list;
- server_list.prev = &server_list;
-}
-
-void quitScreenBrowser()
-{
- destroyWidgetImage(image_backgorund);
-
- destroyWidgetButton(button_play);
- destroyWidgetButton(button_back);
- destroyWidgetButton(button_refresh);
-
- destroyWidgetLabel(label_server);
- destroyWidgetLabel(label_version);
- destroyWidgetLabel(label_address);
- destroyWidgetLabel(label_arena);
- destroyWidgetLabel(label_players);
- destroyWidgetLabel(label_ping);
-
- destroyWidgetSelect(select_server);
-}
diff --git a/src/screen/screen_choiceArena.c b/src/screen/screen_choiceArena.c
index b604eb5..b6c66b5 100644
--- a/src/screen/screen_choiceArena.c
+++ b/src/screen/screen_choiceArena.c
@@ -29,169 +29,165 @@ static widget_t *button_play;
static widget_t *button_back;
static list_t *listWidgetButtonimage;
-static arenaFile_t *currentArena;
+static arenaFile_t* currentArena;
-void
-startScreenChoiceArena()
+void startScreenChoiceArena()
{
#ifndef NO_SOUND
- playMusic("menu", MUSIC_GROUP_BASE);
+ playMusic("menu", MUSIC_GROUP_BASE);
#endif
}
-void
-drawScreenChoiceArena()
+void drawScreenChoiceArena()
{
- int i;
+ int i;
- drawWidgetImage(image_backgorund);
+ drawWidgetImage(image_backgorund);
- drawWidgetButton(button_play);
- drawWidgetButton(button_back);
+ drawWidgetButton(button_play);
+ drawWidgetButton(button_back);
- for (i = 0; i < listWidgetButtonimage->count; i++) {
- widget_t *this;
- this = (widget_t *) listWidgetButtonimage->list[i];
- drawWidgetButtonimage(this);
- }
+ for( i = 0 ; i < listWidgetButtonimage->count ; i++ )
+ {
+ widget_t *this;
+ this = (widget_t *) listWidgetButtonimage->list[i];
+ drawWidgetButtonimage(this);
+ }
}
-void
-eventScreenChoiceArena()
+void eventScreenChoiceArena()
{
- int i;
+ int i;
- eventWidgetButton(button_play);
- eventWidgetButton(button_back);
+ eventWidgetButton(button_play);
+ eventWidgetButton(button_back);
- for (i = 0; i < listWidgetButtonimage->count; i++) {
- widget_t *this;
- this = (widget_t *) listWidgetButtonimage->list[i];
- eventWidgetButtonimage(this);
- }
+ for( i = 0 ; i < listWidgetButtonimage->count ; i++ )
+ {
+ widget_t *this;
+ this = (widget_t *) listWidgetButtonimage->list[i];
+ eventWidgetButtonimage(this);
+ }
}
-void
-stopScreenChoiceArena()
+void stopScreenChoiceArena()
{
}
-static void
-eventWidgetButtonImage(void *p)
+static void eventWidgetButtonImage(void *p)
{
- widget_t *buttonimage;
- int i;
+ widget_t *buttonimage;
+ int i;
- buttonimage = (widget_t *) (p);
+ buttonimage = (widget_t *)(p);
- for (i = 0; i < listWidgetButtonimage->count; i++) {
- widget_t *this;
+ for( i = 0 ; i < listWidgetButtonimage->count ; i++ )
+ {
+ widget_t *this;
- this = (widget_t *) (listWidgetButtonimage->list[i]);
-
- if (buttonimage == this) {
- setWidgetButtonimageActive(this, TRUE);
- currentArena = getArenaFile(i);
- }
- else {
- setWidgetButtonimageActive(this, FALSE);
- }
- }
+ this = (widget_t *)(listWidgetButtonimage->list[i]);
+
+ if( buttonimage == this )
+ {
+ setWidgetButtonimageActive(this, TRUE);
+ currentArena = getArenaFile(i);
+ }
+ else
+ {
+ setWidgetButtonimageActive(this, FALSE);
+ }
+ }
}
-arenaFile_t *
-getChoiceArena()
+arenaFile_t* getChoiceArena()
{
- return currentArena;
+ return currentArena;
}
-void
-setChoiceArena(arenaFile_t * arenaFile)
+void setChoiceArena(arenaFile_t *arenaFile)
{
- widget_t *widget_buttonimage;
- int id;
+ widget_t *widget_buttonimage;
+ int id;
- id = getArenaFileID(arenaFile);
- currentArena = arenaFile;
+ id = getArenaFileID(arenaFile);
+ currentArena = arenaFile;
- if (id >= 0) {
- widget_buttonimage = (widget_t *) listWidgetButtonimage->list[id];
- setWidgetButtonimageActive(widget_buttonimage, TRUE);
- }
+ if( id >= 0 )
+ {
+ widget_buttonimage = (widget_t *)listWidgetButtonimage->list[id];
+ setWidgetButtonimageActive(widget_buttonimage, TRUE);
+ }
}
-static void
-eventWidget(void *p)
+static void eventWidget(void *p)
{
- widget_t *button;
-
- button = (widget_t *) (p);
-
- if (button == button_play) {
- setScreen("world");
- }
-
- if (button == button_back) {
- setScreen("gameType");
- }
+ widget_t *button;
+
+ button = (widget_t *)(p);
+
+ if( button == button_play )
+ {
+ setScreen("world");
+ }
+
+ if( button == button_back )
+ {
+ setScreen("gameType");
+ }
}
-void
-initScreenChoiceArena()
+void initScreenChoiceArena()
{
- image_t *image;
- int i;
-
- image = getImage(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = newWidgetImage(0, 0, image);
-
- button_back =
- newWidgetButton(_("back"), 100, WINDOW_SIZE_Y - 100, eventWidget);
- button_play =
- newWidgetButton(_("play"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100,
- eventWidget);
-
- listWidgetButtonimage = newList();
- currentArena = NULL;
-
- for (i = 0; i < getArenaCount(); i++) {
- widget_t *widget_buttonimage;
- arenaFile_t *arenaFile;
- int x, y;
-
- arenaFile = getArenaFile(i);
- //image = addImageData(getArenaImage(i), IMAGE_NO_ALPHA, "none", IMAGE_GROUP_BASE);
- image = loadImageFromArena(arenaFile,
- getArenaImage(arenaFile),
- IMAGE_GROUP_BASE, "none", IMAGE_NO_ALPHA);
-
- x = 100 + 200 * (i - 3 * (i / 3));
- y = 150 + 200 * (i / 3);
-
- widget_buttonimage = newWidgetButtonimage(image,
- x, y, eventWidgetButtonImage);
+ image_t *image;
+ int i;
+
+ image = getImage(IMAGE_GROUP_BASE, "screen_main");
+ image_backgorund = newWidgetImage(0, 0, image);
+
+ button_back = newWidgetButton(_("back"), 100, WINDOW_SIZE_Y-100, eventWidget);
+ button_play = newWidgetButton(_("play"), WINDOW_SIZE_X-200, WINDOW_SIZE_Y-100, eventWidget);
+
+ listWidgetButtonimage = newList();
+ currentArena = NULL;
+
+ for( i = 0 ; i < getArenaCount() ; i++ )
+ {
+ widget_t *widget_buttonimage;
+ arenaFile_t* arenaFile;
+ int x, y;
+
+ arenaFile = getArenaFile(i);
+ //image = addImageData(getArenaImage(i), IMAGE_NO_ALPHA, "none", IMAGE_GROUP_BASE);
+ image = loadImageFromArena(arenaFile,
+ getArenaImage(arenaFile),
+ IMAGE_GROUP_BASE,
+ "none",
+ IMAGE_NO_ALPHA);
+
+ x = 100 + 200 * ( i - 3 * ( i/3 ) );
+ y = 150 + 200 * ( i/3 );
+
+ widget_buttonimage = newWidgetButtonimage(image,
+ x, y, eventWidgetButtonImage);
/*
if( i == choiceArenaId )
{
widget_buttonimage->active = 1;
}
*/
- addList(listWidgetButtonimage, widget_buttonimage);
- }
+ addList( listWidgetButtonimage, widget_buttonimage);
+ }
- registerScreen(newScreen
- ("chiceArena", startScreenChoiceArena,
- eventScreenChoiceArena, drawScreenChoiceArena,
- stopScreenChoiceArena));
+ registerScreen( newScreen("chiceArena", startScreenChoiceArena, eventScreenChoiceArena,
+ drawScreenChoiceArena, stopScreenChoiceArena) );
}
-void
-quitScreenChoiceArena()
+void quitScreenChoiceArena()
{
- destroyWidgetImage(image_backgorund);
+ destroyWidgetImage(image_backgorund);
- destroyWidgetButton(button_play);
- destroyWidgetButton(button_back);
+ destroyWidgetButton(button_play);
+ destroyWidgetButton(button_back);
- destroyListItem(listWidgetButtonimage, destroyWidgetButtonimage);
+ destroyListItem(listWidgetButtonimage, destroyWidgetButtonimage);
}
diff --git a/src/screen/screen_choiceArena.c~ b/src/screen/screen_choiceArena.c~
deleted file mode 100644
index b6c66b5..0000000
--- a/src/screen/screen_choiceArena.c~
+++ /dev/null
@@ -1,193 +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"
-
-#ifndef NO_SOUND
-#include "music.h"
-#endif
-
-#include "screen_mainMenu.h"
-#include "screen_choiceArena.h"
-
-#include "widget.h"
-#include "widget_label.h"
-#include "widget_button.h"
-#include "widget_image.h"
-#include "widget_buttonimage.h"
-
-static widget_t *image_backgorund;
-
-static widget_t *button_play;
-static widget_t *button_back;
-
-static list_t *listWidgetButtonimage;
-static arenaFile_t* currentArena;
-
-void startScreenChoiceArena()
-{
-#ifndef NO_SOUND
- playMusic("menu", MUSIC_GROUP_BASE);
-#endif
-}
-
-void drawScreenChoiceArena()
-{
- int i;
-
- drawWidgetImage(image_backgorund);
-
- drawWidgetButton(button_play);
- drawWidgetButton(button_back);
-
- for( i = 0 ; i < listWidgetButtonimage->count ; i++ )
- {
- widget_t *this;
- this = (widget_t *) listWidgetButtonimage->list[i];
- drawWidgetButtonimage(this);
- }
-}
-
-void eventScreenChoiceArena()
-{
- int i;
-
- eventWidgetButton(button_play);
- eventWidgetButton(button_back);
-
- for( i = 0 ; i < listWidgetButtonimage->count ; i++ )
- {
- widget_t *this;
- this = (widget_t *) listWidgetButtonimage->list[i];
- eventWidgetButtonimage(this);
- }
-}
-
-void stopScreenChoiceArena()
-{
-}
-
-static void eventWidgetButtonImage(void *p)
-{
- widget_t *buttonimage;
- int i;
-
- buttonimage = (widget_t *)(p);
-
- for( i = 0 ; i < listWidgetButtonimage->count ; i++ )
- {
- widget_t *this;
-
- this = (widget_t *)(listWidgetButtonimage->list[i]);
-
- if( buttonimage == this )
- {
- setWidgetButtonimageActive(this, TRUE);
- currentArena = getArenaFile(i);
- }
- else
- {
- setWidgetButtonimageActive(this, FALSE);
- }
- }
-}
-
-arenaFile_t* getChoiceArena()
-{
- return currentArena;
-}
-
-void setChoiceArena(arenaFile_t *arenaFile)
-{
- widget_t *widget_buttonimage;
- int id;
-
- id = getArenaFileID(arenaFile);
- currentArena = arenaFile;
-
- if( id >= 0 )
- {
- widget_buttonimage = (widget_t *)listWidgetButtonimage->list[id];
- setWidgetButtonimageActive(widget_buttonimage, TRUE);
- }
-}
-
-static void eventWidget(void *p)
-{
- widget_t *button;
-
- button = (widget_t *)(p);
-
- if( button == button_play )
- {
- setScreen("world");
- }
-
- if( button == button_back )
- {
- setScreen("gameType");
- }
-}
-
-void initScreenChoiceArena()
-{
- image_t *image;
- int i;
-
- image = getImage(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = newWidgetImage(0, 0, image);
-
- button_back = newWidgetButton(_("back"), 100, WINDOW_SIZE_Y-100, eventWidget);
- button_play = newWidgetButton(_("play"), WINDOW_SIZE_X-200, WINDOW_SIZE_Y-100, eventWidget);
-
- listWidgetButtonimage = newList();
- currentArena = NULL;
-
- for( i = 0 ; i < getArenaCount() ; i++ )
- {
- widget_t *widget_buttonimage;
- arenaFile_t* arenaFile;
- int x, y;
-
- arenaFile = getArenaFile(i);
- //image = addImageData(getArenaImage(i), IMAGE_NO_ALPHA, "none", IMAGE_GROUP_BASE);
- image = loadImageFromArena(arenaFile,
- getArenaImage(arenaFile),
- IMAGE_GROUP_BASE,
- "none",
- IMAGE_NO_ALPHA);
-
- x = 100 + 200 * ( i - 3 * ( i/3 ) );
- y = 150 + 200 * ( i/3 );
-
- widget_buttonimage = newWidgetButtonimage(image,
- x, y, eventWidgetButtonImage);
-/*
- if( i == choiceArenaId )
- {
- widget_buttonimage->active = 1;
- }
-*/
- addList( listWidgetButtonimage, widget_buttonimage);
- }
-
- registerScreen( newScreen("chiceArena", startScreenChoiceArena, eventScreenChoiceArena,
- drawScreenChoiceArena, stopScreenChoiceArena) );
-}
-
-void quitScreenChoiceArena()
-{
- destroyWidgetImage(image_backgorund);
-
- destroyWidgetButton(button_play);
- destroyWidgetButton(button_back);
-
- destroyListItem(listWidgetButtonimage, destroyWidgetButtonimage);
-}
diff --git a/src/screen/screen_credits.c b/src/screen/screen_credits.c
index 67e39eb..0d65c07 100644
--- a/src/screen/screen_credits.c
+++ b/src/screen/screen_credits.c
@@ -28,131 +28,127 @@ static textFile_t *textFile;
static int offset;
static int creditExists;
-void
-startScreenCredits()
+void startScreenCredits()
{
#ifndef NO_SOUND
- playMusic("menu", MUSIC_GROUP_BASE);
+ playMusic("menu", MUSIC_GROUP_BASE);
#endif
- offset = 0;
+ offset = 0;
}
-void
-drawScreenCredits()
+void drawScreenCredits()
{
- int i;
+ int i;
- drawWidgetImage(image_backgorund);
+ drawWidgetImage(image_backgorund);
- drawWidgetButton(button_back);
+ drawWidgetButton(button_back);
- for (i = 0; i < listWidgetLabel->count; i++) {
- int z;
+ for( i = 0 ; i < listWidgetLabel->count ; i++ )
+ {
+ int z;
- widget_t *this;
- this = (widget_t *) listWidgetLabel->list[i];
+ widget_t *this;
+ this = (widget_t *)listWidgetLabel->list[i];
+
+ z = this->y;
+ this->y += offset;
- z = this->y;
- this->y += offset;
+ if( this->y > SCREEN_CREDITS_OFFSET_MIN && this->y < SCREEN_CREDITS_OFFSET_MAX )
+ {
+ drawWidgetLabel(this);
+ }
- if (this->y > SCREEN_CREDITS_OFFSET_MIN
- && this->y < SCREEN_CREDITS_OFFSET_MAX) {
- drawWidgetLabel(this);
- }
-
- this->y = z;
- }
+ this->y = z;
+ }
}
-void
-eventScreenCredits()
+void eventScreenCredits()
{
- eventWidgetButton(button_back);
-
- offset -= SCREEN_CREDITS_OFFSET_SPEED;
+ eventWidgetButton(button_back);
+
+ offset -= SCREEN_CREDITS_OFFSET_SPEED;
- if (offset < SCREEN_CREDITS_OFFSET_RESTART) {
- offset = 0;
- }
+ if( offset < SCREEN_CREDITS_OFFSET_RESTART )
+ {
+ offset = 0;
+ }
- //printf("offset = %d\n", offset);
+ //printf("offset = %d\n", offset);
}
-void
-stopScreenCredits()
+void stopScreenCredits()
{
}
-static void
-eventWidget(void *p)
+static void eventWidget(void *p)
{
- widget_t *button;
-
- button = (widget_t *) (p);
-
- if (button == button_back) {
- setScreen("mainMenu");
- }
+ widget_t *button;
+
+ button = (widget_t *)(p);
+
+ if( button == button_back )
+ {
+ setScreen("mainMenu");
+ }
}
-void
-initScreenCredits()
+void initScreenCredits()
{
- image_t *image;
- int i;
-
- image = getImage(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = newWidgetImage(0, 0, image);
-
- button_back =
- newWidgetButton(_("back"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2,
- WINDOW_SIZE_Y - 80, eventWidget);
-
- listWidgetLabel = newList();
-
- if (tryExistFile(PATH_DOC SCREEN_CREDITS_FILE) == 0) {
- creditExists = 1;
- textFile = loadTextFile(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 = newWidgetLabel(line, WINDOW_SIZE_X / 2 - WINDOW_SIZE_X / 4,
- (WINDOW_SIZE_Y - 100) + i * 20,
- WIDGET_LABEL_LEFT);
-
- addList(listWidgetLabel, label);
- }
- }
- else {
- for (i = 0; i < 5; i++) {
- creditExists = 0;
- widget_t *label;
- char line[STR_SIZE];
- sprintf(line, _("Credit file not found... %s/%s"), PATH_DOC,
- SCREEN_CREDITS_FILE);
- label =
- newWidgetLabel(line, WINDOW_SIZE_X / 2,
- (WINDOW_SIZE_Y - 100) + i * 20,
- WIDGET_LABEL_CENTER);
-
- addList(listWidgetLabel, label);
- }
- }
-
- registerScreen(newScreen("credits", startScreenCredits, eventScreenCredits,
- drawScreenCredits, stopScreenCredits));
+ image_t *image;
+ int i;
+
+ image = getImage(IMAGE_GROUP_BASE, "screen_main");
+ image_backgorund = newWidgetImage(0, 0, image);
+
+ button_back = newWidgetButton(_("back"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, WINDOW_SIZE_Y-80, eventWidget);
+
+ listWidgetLabel = newList();
+
+ if( tryExistFile(PATH_DOC SCREEN_CREDITS_FILE) == 0 )
+ {
+ creditExists = 1;
+ textFile = loadTextFile(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 = newWidgetLabel(line, WINDOW_SIZE_X/2-WINDOW_SIZE_X/4,
+ (WINDOW_SIZE_Y-100)+i*20, WIDGET_LABEL_LEFT);
+
+ addList(listWidgetLabel, label);
+ }
+ }
+ else
+ {
+ for( i = 0 ; i < 5 ; i++ )
+ {
+ creditExists = 0;
+ widget_t *label;
+ char line[STR_SIZE];
+ sprintf(line, _("Credit file not found... %s/%s"),PATH_DOC,SCREEN_CREDITS_FILE);
+ label = newWidgetLabel(line, WINDOW_SIZE_X/2, (WINDOW_SIZE_Y-100)+i*20,
+ WIDGET_LABEL_CENTER);
+
+ addList(listWidgetLabel, label);
+ }
+ }
+
+ registerScreen( newScreen("credits", startScreenCredits, eventScreenCredits,
+ drawScreenCredits, stopScreenCredits) );
}
-void
-quitScreenCredits()
+void quitScreenCredits()
{
- destroyWidgetImage(image_backgorund);
-
- destroyWidgetButton(button_back);
- destroyListItem(listWidgetLabel, destroyWidgetLabel);
- if (creditExists) {
- destroyTextFile(textFile);
- }
+ destroyWidgetImage(image_backgorund);
+
+ destroyWidgetButton(button_back);
+ destroyListItem(listWidgetLabel, destroyWidgetLabel);
+ if( creditExists )
+ {
+ destroyTextFile(textFile);
+ }
}
+
diff --git a/src/screen/screen_credits.c~ b/src/screen/screen_credits.c~
deleted file mode 100644
index 0d65c07..0000000
--- a/src/screen/screen_credits.c~
+++ /dev/null
@@ -1,154 +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"
-
-#ifndef NO_SOUND
-#include "music.h"
-#endif
-
-#include "screen_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;
-
-void startScreenCredits()
-{
-#ifndef NO_SOUND
- playMusic("menu", MUSIC_GROUP_BASE);
-#endif
- offset = 0;
-}
-
-void drawScreenCredits()
-{
- int i;
-
- drawWidgetImage(image_backgorund);
-
- drawWidgetButton(button_back);
-
- for( i = 0 ; i < listWidgetLabel->count ; i++ )
- {
- int z;
-
- widget_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 )
- {
- drawWidgetLabel(this);
- }
-
- this->y = z;
- }
-
-}
-
-void eventScreenCredits()
-{
- eventWidgetButton(button_back);
-
- offset -= SCREEN_CREDITS_OFFSET_SPEED;
-
- if( offset < SCREEN_CREDITS_OFFSET_RESTART )
- {
- offset = 0;
- }
-
- //printf("offset = %d\n", offset);
-}
-
-void stopScreenCredits()
-{
-}
-
-static void eventWidget(void *p)
-{
- widget_t *button;
-
- button = (widget_t *)(p);
-
- if( button == button_back )
- {
- setScreen("mainMenu");
- }
-}
-
-void initScreenCredits()
-{
- image_t *image;
- int i;
-
- image = getImage(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = newWidgetImage(0, 0, image);
-
- button_back = newWidgetButton(_("back"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, WINDOW_SIZE_Y-80, eventWidget);
-
- listWidgetLabel = newList();
-
- if( tryExistFile(PATH_DOC SCREEN_CREDITS_FILE) == 0 )
- {
- creditExists = 1;
- textFile = loadTextFile(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 = newWidgetLabel(line, WINDOW_SIZE_X/2-WINDOW_SIZE_X/4,
- (WINDOW_SIZE_Y-100)+i*20, WIDGET_LABEL_LEFT);
-
- addList(listWidgetLabel, label);
- }
- }
- else
- {
- for( i = 0 ; i < 5 ; i++ )
- {
- creditExists = 0;
- widget_t *label;
- char line[STR_SIZE];
- sprintf(line, _("Credit file not found... %s/%s"),PATH_DOC,SCREEN_CREDITS_FILE);
- label = newWidgetLabel(line, WINDOW_SIZE_X/2, (WINDOW_SIZE_Y-100)+i*20,
- WIDGET_LABEL_CENTER);
-
- addList(listWidgetLabel, label);
- }
- }
-
- registerScreen( newScreen("credits", startScreenCredits, eventScreenCredits,
- drawScreenCredits, stopScreenCredits) );
-}
-
-void quitScreenCredits()
-{
- destroyWidgetImage(image_backgorund);
-
- destroyWidgetButton(button_back);
- destroyListItem(listWidgetLabel, destroyWidgetLabel);
- if( creditExists )
- {
- destroyTextFile(textFile);
- }
-}
-
diff --git a/src/screen/screen_downArena.c b/src/screen/screen_downArena.c
index 7404b49..19887fd 100644
--- a/src/screen/screen_downArena.c
+++ b/src/screen/screen_downArena.c
@@ -50,365 +50,333 @@ static int fileOffset;
static my_time_t timeSendMsg;
static int countSendMsg;
-static void
-setStatusString(char *s)
+static void setStatusString(char *s)
{
- //printf("status -> %s\n", s);
- destroyWidgetLabel(label_status);
- label_status =
- newWidgetLabel(s, WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER);
+ //printf("status -> %s\n", s);
+ destroyWidgetLabel(label_status);
+ label_status = newWidgetLabel(s, WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER);
}
-static void
-connectToDownServer()
+static void connectToDownServer()
{
- char status[STR_SIZE];
- char msg[STR_PROTO_SIZE];
+ char status[STR_SIZE];
+ char msg[STR_PROTO_SIZE];
- sock_server_tcp =
- connectTcpSocket(getSettingIP(), getSettingPort(), PROTO_TCPv4);
+ sock_server_tcp = connectTcpSocket(getSettingIP(), getSettingPort(), PROTO_TCPv4);
- if (sock_server_tcp == NULL) {
- sprintf(status, "I do not connect to %s %d TCP down server",
- getSettingIP(), getSettingPort());
- setStatusString(status);
- return;
- }
+ if (sock_server_tcp == NULL) {
+ sprintf(status, "I do not connect to %s %d TCP down server", getSettingIP(), getSettingPort());
+ setStatusString(status);
+ return;
+ }
- setTcpSockNonBlock(sock_server_tcp);
+ setTcpSockNonBlock(sock_server_tcp);
- recvBuffer = newBuffer(DOWN_ARENA_BUFFER_SIZE);
- sendBuffer = newBuffer(DOWN_ARENA_BUFFER_SIZE);
- status_tcp_socket = DOWN_SERVER_STATUS_OK;
+ recvBuffer = newBuffer(DOWN_ARENA_BUFFER_SIZE);
+ sendBuffer = newBuffer(DOWN_ARENA_BUFFER_SIZE);
+ status_tcp_socket = DOWN_SERVER_STATUS_OK;
- file = NULL;
- countSendMsg = 0;
- timeSendMsg = getMyTime();
+ file = NULL;
+ countSendMsg = 0;
+ timeSendMsg = getMyTime();
- sprintf(msg, "GETARENA %s\n", arenaNetName);
+ sprintf(msg, "GETARENA %s\n", arenaNetName);
- addBuffer(sendBuffer, msg, strlen(msg));
+ addBuffer(sendBuffer, msg, strlen(msg));
- sprintf(status, "Connect to %s %d TCP down server", getSettingIP(),
- getSettingPort());
- setStatusString(status);
+ sprintf(status, "Connect to %s %d TCP down server", getSettingIP(), getSettingPort());
+ setStatusString(status);
}
-static void
-closeConnectFromDownServer()
+static void closeConnectFromDownServer()
{
- closeTcpSocket(sock_server_tcp);
- destroyBuffer(recvBuffer);
- destroyBuffer(sendBuffer);
- sock_server_tcp = NULL;
- recvBuffer = NULL;
- sendBuffer = NULL;
+ closeTcpSocket(sock_server_tcp);
+ destroyBuffer(recvBuffer);
+ destroyBuffer(sendBuffer);
+ sock_server_tcp = NULL;
+ recvBuffer = NULL;
+ sendBuffer = NULL;
}
-static void
-sendStatusToGameServer()
+static void sendStatusToGameServer()
{
- char *msg = "status\n";
-
- if (countSendMsg > DOWN_ARENA_MAX_SEND_MSG_STATUS) {
- char status[STR_SIZE];
- sprintf(status, "Game server %s %d is down", getSettingIP(),
- getSettingPort());
- setStatusString(status);
- return;
- }
-
- timeSendMsg = getMyTime();
- countSendMsg++;
- printf("countSendMsg = %d\n", countSendMsg++);
-
- if (writeUdpSocket(sock_server_udp, sock_server_udp, msg, strlen(msg)) < 0) {
- char status[STR_SIZE];
- sprintf(status, "I do not send message to %s %d UDP game server",
- getSettingIP(), getSettingPort());
- setStatusString(status);
- }
+ char *msg = "status\n";
+
+ if (countSendMsg > DOWN_ARENA_MAX_SEND_MSG_STATUS) {
+ char status[STR_SIZE];
+ sprintf(status, "Game server %s %d is down", getSettingIP(), getSettingPort());
+ setStatusString(status);
+ return;
+ }
+
+ timeSendMsg = getMyTime();
+ countSendMsg++;
+ printf("countSendMsg = %d\n", countSendMsg++);
+
+ if (writeUdpSocket(sock_server_udp, sock_server_udp, msg, strlen(msg)) < 0) {
+ char status[STR_SIZE];
+ sprintf(status, "I do not send message to %s %d UDP game server", getSettingIP(), getSettingPort());
+ setStatusString(status);
+ }
}
-void
-startScreenDownArena()
+void startScreenDownArena()
{
- char status[STR_SIZE];
+ char status[STR_SIZE];
- strcpy(str_status, "none");
- memset(arenaNetName, 0, STR_SIZE);
+ strcpy(str_status, "none");
+ memset(arenaNetName, 0, STR_SIZE);
- sock_server_udp =
- connectUdpSocket(getSettingIP(), getSettingPort(), PROTO_UDPv4);
+ sock_server_udp = connectUdpSocket(getSettingIP(), getSettingPort(), PROTO_UDPv4);
- if (sock_server_udp == NULL) {
- sprintf(status, "I do not connect to %s %d UDP game server",
- getSettingIP(), getSettingPort());
- setStatusString(status);
- return;
- }
+ if (sock_server_udp == NULL) {
+ sprintf(status, "I do not connect to %s %d UDP game server", getSettingIP(), getSettingPort());
+ setStatusString(status);
+ return;
+ }
- setUdpSockNonBlock(sock_server_udp);
+ setUdpSockNonBlock(sock_server_udp);
- sprintf(status, "Connect to %s %d UDP game server", getSettingIP(),
- getSettingPort());
- setStatusString(status);
+ sprintf(status, "Connect to %s %d UDP game server", getSettingIP(), getSettingPort());
+ setStatusString(status);
- sendStatusToGameServer();
+ sendStatusToGameServer();
}
-void
-drawScreenDownArena()
+void drawScreenDownArena()
{
- drawWidgetImage(image_backgorund);
- drawWidgetLabel(label_status);
- drawWidgetButton(button_back);
+ drawWidgetImage(image_backgorund);
+ drawWidgetLabel(label_status);
+ drawWidgetButton(button_back);
}
-static void
-proto_ok(char *line)
+static void proto_ok(char *line)
{
- //printf("line = %s\n", line);
- fileSize = atoi(line + 3);
- fileOffset = 0;
+ //printf("line = %s\n", line);
+ fileSize = atoi(line+3);
+ fileOffset = 0;
- sprintf(path, "%s/%s.zip", getHomeDirector(), arenaNetName);
- //printf("path = %s\n", path);
- file = fopen(path, "wb");
+ sprintf(path, "%s/%s.zip", getHomeDirector(), arenaNetName);
+ //printf("path = %s\n", path);
+ file = fopen(path, "wb");
}
-static void
-proto_err(char *line)
+static void proto_err(char *line)
{
- //printf("line = %s\n", line);
- setStatusString(line + 4);
- closeConnectFromDownServer();
+ //printf("line = %s\n", line);
+ setStatusString(line+4);
+ closeConnectFromDownServer();
}
-static void
-eventProto(char *line)
+static void eventProto(char *line)
{
- if (strncmp(line, "OK", 2) == 0) {
- proto_ok(line);
- }
+ if (strncmp(line, "OK", 2) == 0) {
+ proto_ok(line);
+ }
- if (strncmp(line, "ERR", 3) == 0) {
- proto_err(line);
- }
+ if (strncmp(line, "ERR", 3) == 0) {
+ proto_err(line);
+ }
}
-static int
-downArenaFile()
+static int downArenaFile()
{
- char status[STR_SIZE];
- void *data;
- int len;
+ char status[STR_SIZE];
+ void *data;
+ int len;
- len = getBufferSize(recvBuffer);
- data = getBufferData(recvBuffer);
- cutBuffer(recvBuffer, len);
+ len = getBufferSize(recvBuffer);
+ data = getBufferData(recvBuffer);
+ cutBuffer(recvBuffer, len);
- fwrite(data, len, 1, file);
- fileOffset += len;
+ fwrite(data, len, 1, file);
+ fileOffset += len;
- sprintf(status, "I down %d / %d", fileOffset, fileSize);
- setStatusString(status);
+ sprintf(status, "I down %d / %d", fileOffset, fileSize);
+ setStatusString(status);
- return len;
+ return len;
}
-static int
-eventRecvBuffer()
+static int eventRecvBuffer()
{
- char buffer[STR_PROTO_SIZE];
- char line[STR_PROTO_SIZE];
- int ret;
-
- memset(buffer, 0, STR_PROTO_SIZE);
-
- ret = readTcpSocket(sock_server_tcp, buffer, STR_PROTO_SIZE - 1);
- //if (ret <= 0) printf("readTcpSocket = %d\n", ret);
-
- if (ret < 0) {
- return -1;
- }
-
- if (addBuffer(recvBuffer, buffer, ret) < 0) {
- char status[STR_SIZE];
- sprintf(status, "Error -- recv buffer is full");
- setStatusString(status);
- closeConnectFromDownServer();
- return -1;
- }
-
- if (file == NULL && getBufferLine(recvBuffer, line, STR_PROTO_SIZE) >= 0) {
- eventProto(line);
- return ret;
- }
-
- if (file != NULL) {
- return downArenaFile();
- }
-
- return -1;
+ char buffer[STR_PROTO_SIZE];
+ char line[STR_PROTO_SIZE];
+ int ret;
+
+ memset(buffer, 0, STR_PROTO_SIZE);
+
+ ret = readTcpSocket(sock_server_tcp, buffer, STR_PROTO_SIZE-1);
+ //if (ret <= 0) printf("readTcpSocket = %d\n", ret);
+
+ if (ret < 0) {
+ return -1;
+ }
+
+ if (addBuffer(recvBuffer, buffer, ret) < 0) {
+ char status[STR_SIZE];
+ sprintf(status, "Error -- recv buffer is full");
+ setStatusString(status);
+ closeConnectFromDownServer();
+ return -1;
+ }
+
+ if (file == NULL && getBufferLine(recvBuffer, line, STR_PROTO_SIZE) >= 0) {
+ eventProto(line);
+ return ret;
+ }
+
+ if (file != NULL) {
+ return downArenaFile();
+ }
+
+ return -1;
}
-static int
-eventSendBuffer()
+static int eventSendBuffer()
{
- void *data;
- int len;
- int res;
+ void *data;
+ int len;
+ int res;
- len = getBufferSize(sendBuffer);
+ len = getBufferSize(sendBuffer);
- if (len == 0) {
- return -1;
- }
+ if (len == 0) {
+ return -1;
+ }
- data = getBufferData(sendBuffer);
+ data = getBufferData(sendBuffer);
- res = writeTcpSocket(sock_server_tcp, data, len);
+ res = writeTcpSocket(sock_server_tcp, data, len);
- if (res < 0) {
- return -1;
- }
+ if (res < 0) {
+ return -1;
+ }
- cutBuffer(sendBuffer, res);
- return res;
+ cutBuffer(sendBuffer, res);
+ return res;
}
-static void
-readArenaFromStatus()
+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) {
- closeUdpSocket(sock_server_udp);
- sock_server_udp = NULL;
- strncpy(arenaNetName, offset_begin, offset_end - offset_begin);
-
- if (getArenaFileFormNetName(arenaNetName) != NULL) {
- setScreen("world");
- return;
- }
-
- connectToDownServer();
-
- printf("arenaNetName = >>%s<<\n", arenaNetName);
- }
- }
+ 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) {
+ closeUdpSocket(sock_server_udp);
+ sock_server_udp = NULL;
+ strncpy(arenaNetName, offset_begin, offset_end-offset_begin);
+
+ if( getArenaFileFormNetName(arenaNetName) != NULL )
+ {
+ setScreen("world");
+ return;
+ }
+
+ connectToDownServer();
+
+ printf("arenaNetName = >>%s<<\n", arenaNetName);
+ }
+ }
}
-static void
-eventStatus()
+static void eventStatus()
{
- if (getMyTime() - timeSendMsg > DOWN_ARENA_MAX_TIEMOUT_LIMIT) {
- sendStatusToGameServer();
- }
-
- if (readUdpSocket
- (sock_server_udp, sock_server_udp, str_status,
- STR_PROTO_SIZE - 1) > 0) {
- //printf("str_status = %s\n", str_status);
- readArenaFromStatus();
- }
+ if (getMyTime() - timeSendMsg > DOWN_ARENA_MAX_TIEMOUT_LIMIT) {
+ sendStatusToGameServer();
+ }
+
+ if (readUdpSocket(sock_server_udp, sock_server_udp, str_status, STR_PROTO_SIZE - 1) > 0) {
+ //printf("str_status = %s\n", str_status);
+ readArenaFromStatus();
+ }
}
-void
-eventScreenDownArena()
+void eventScreenDownArena()
{
- 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();
- loadArenaFile(path);
- setScreen("world");
- }
-
- eventWidgetButton(button_back);
+ 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();
+ loadArenaFile(path);
+ setScreen("world");
+ }
+
+ eventWidgetButton(button_back);
}
-void
-stopScreenDownArena()
+void stopScreenDownArena()
{
- if (file != NULL) {
- unlink(path);
- }
+ if (file != NULL) {
+ unlink(path);
+ }
- if (sock_server_tcp != NULL) {
- closeConnectFromDownServer();
- }
+ if (sock_server_tcp != NULL) {
+ closeConnectFromDownServer();
+ }
- if (sock_server_udp != NULL) {
- closeUdpSocket(sock_server_udp);
- }
+ if (sock_server_udp != NULL) {
+ closeUdpSocket(sock_server_udp);
+ }
}
-static void
-eventWidget(void *p)
+static void eventWidget(void *p)
{
- widget_t *button;
+ widget_t *button;
+
+ button = (widget_t *)(p);
- button = (widget_t *) (p);
-
- if (button == button_back) {
- setScreen("mainMenu");
- }
+ if (button == button_back) {
+ setScreen("mainMenu");
+ }
}
-void
-initScreenDownArena()
+void initScreenDownArena()
{
- image_t *image;
+ image_t *image;
- image = getImage(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = newWidgetImage(0, 0, image);
+ image = getImage(IMAGE_GROUP_BASE, "screen_main");
+ image_backgorund = newWidgetImage(0, 0, image);
- button_back =
- newWidgetButton(_("back"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2,
- WINDOW_SIZE_Y - 80, eventWidget);
+ button_back = newWidgetButton(_("back"), WINDOW_SIZE_X / 2 -WIDGET_BUTTON_WIDTH / 2, WINDOW_SIZE_Y - 80, eventWidget);
- label_status =
- newWidgetLabel("none", WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER);
+ label_status = newWidgetLabel("none", WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER);
- registerScreen(newScreen
- ("downArena", startScreenDownArena, eventScreenDownArena,
- drawScreenDownArena, stopScreenDownArena));
+ registerScreen(newScreen("downArena", startScreenDownArena, eventScreenDownArena,
+ drawScreenDownArena, stopScreenDownArena) );
}
-void
-quitScreenDownArena()
+void quitScreenDownArena()
{
- destroyWidgetImage(image_backgorund);
- destroyWidgetButton(button_back);
- destroyWidgetLabel(label_status);
+ destroyWidgetImage(image_backgorund);
+ destroyWidgetButton(button_back);
+ destroyWidgetLabel(label_status);
}
+
diff --git a/src/screen/screen_downArena.c~ b/src/screen/screen_downArena.c~
deleted file mode 100644
index 19887fd..0000000
--- a/src/screen/screen_downArena.c~
+++ /dev/null
@@ -1,382 +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 "screen_setting.h"
-#include "screen_downArena.h"
-#include "screen_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);
- destroyWidgetLabel(label_status);
- label_status = newWidgetLabel(s, WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER);
-}
-
-static void connectToDownServer()
-{
- char status[STR_SIZE];
- char msg[STR_PROTO_SIZE];
-
- sock_server_tcp = connectTcpSocket(getSettingIP(), getSettingPort(), PROTO_TCPv4);
-
- if (sock_server_tcp == NULL) {
- sprintf(status, "I do not connect to %s %d TCP down server", getSettingIP(), getSettingPort());
- setStatusString(status);
- return;
- }
-
- setTcpSockNonBlock(sock_server_tcp);
-
- recvBuffer = newBuffer(DOWN_ARENA_BUFFER_SIZE);
- sendBuffer = newBuffer(DOWN_ARENA_BUFFER_SIZE);
- status_tcp_socket = DOWN_SERVER_STATUS_OK;
-
- file = NULL;
- countSendMsg = 0;
- timeSendMsg = getMyTime();
-
- sprintf(msg, "GETARENA %s\n", arenaNetName);
-
- addBuffer(sendBuffer, msg, strlen(msg));
-
- sprintf(status, "Connect to %s %d TCP down server", getSettingIP(), getSettingPort());
- setStatusString(status);
-}
-
-static void closeConnectFromDownServer()
-{
- closeTcpSocket(sock_server_tcp);
- destroyBuffer(recvBuffer);
- destroyBuffer(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, "Game server %s %d is down", getSettingIP(), getSettingPort());
- setStatusString(status);
- return;
- }
-
- timeSendMsg = getMyTime();
- countSendMsg++;
- printf("countSendMsg = %d\n", countSendMsg++);
-
- if (writeUdpSocket(sock_server_udp, sock_server_udp, msg, strlen(msg)) < 0) {
- char status[STR_SIZE];
- sprintf(status, "I do not send message to %s %d UDP game server", getSettingIP(), getSettingPort());
- setStatusString(status);
- }
-}
-
-void startScreenDownArena()
-{
- char status[STR_SIZE];
-
- strcpy(str_status, "none");
- memset(arenaNetName, 0, STR_SIZE);
-
- sock_server_udp = connectUdpSocket(getSettingIP(), getSettingPort(), PROTO_UDPv4);
-
- if (sock_server_udp == NULL) {
- sprintf(status, "I do not connect to %s %d UDP game server", getSettingIP(), getSettingPort());
- setStatusString(status);
- return;
- }
-
- setUdpSockNonBlock(sock_server_udp);
-
- sprintf(status, "Connect to %s %d UDP game server", getSettingIP(), getSettingPort());
- setStatusString(status);
-
- sendStatusToGameServer();
-}
-
-void drawScreenDownArena()
-{
- drawWidgetImage(image_backgorund);
- drawWidgetLabel(label_status);
- drawWidgetButton(button_back);
-}
-
-static void proto_ok(char *line)
-{
- //printf("line = %s\n", line);
- fileSize = atoi(line+3);
- fileOffset = 0;
-
- sprintf(path, "%s/%s.zip", getHomeDirector(), 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 = getBufferSize(recvBuffer);
- data = getBufferData(recvBuffer);
- cutBuffer(recvBuffer, len);
-
- fwrite(data, len, 1, file);
- fileOffset += len;
-
- sprintf(status, "I down %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 = readTcpSocket(sock_server_tcp, buffer, STR_PROTO_SIZE-1);
- //if (ret <= 0) printf("readTcpSocket = %d\n", ret);
-
- if (ret < 0) {
- return -1;
- }
-
- if (addBuffer(recvBuffer, buffer, ret) < 0) {
- char status[STR_SIZE];
- sprintf(status, "Error -- recv buffer is full");
- setStatusString(status);
- closeConnectFromDownServer();
- return -1;
- }
-
- if (file == NULL && getBufferLine(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 = getBufferSize(sendBuffer);
-
- if (len == 0) {
- return -1;
- }
-
- data = getBufferData(sendBuffer);
-
- res = writeTcpSocket(sock_server_tcp, data, len);
-
- if (res < 0) {
- return -1;
- }
-
- cutBuffer(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) {
- closeUdpSocket(sock_server_udp);
- sock_server_udp = NULL;
- strncpy(arenaNetName, offset_begin, offset_end-offset_begin);
-
- if( getArenaFileFormNetName(arenaNetName) != NULL )
- {
- setScreen("world");
- return;
- }
-
- connectToDownServer();
-
- printf("arenaNetName = >>%s<<\n", arenaNetName);
- }
- }
-}
-
-static void eventStatus()
-{
- if (getMyTime() - timeSendMsg > DOWN_ARENA_MAX_TIEMOUT_LIMIT) {
- sendStatusToGameServer();
- }
-
- if (readUdpSocket(sock_server_udp, sock_server_udp, str_status, STR_PROTO_SIZE - 1) > 0) {
- //printf("str_status = %s\n", str_status);
- readArenaFromStatus();
- }
-}
-
-void eventScreenDownArena()
-{
- 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();
- loadArenaFile(path);
- setScreen("world");
- }
-
- eventWidgetButton(button_back);
-}
-
-void stopScreenDownArena()
-{
- if (file != NULL) {
- unlink(path);
- }
-
- if (sock_server_tcp != NULL) {
- closeConnectFromDownServer();
- }
-
- if (sock_server_udp != NULL) {
- closeUdpSocket(sock_server_udp);
- }
-
-}
-
-static void eventWidget(void *p)
-{
- widget_t *button;
-
- button = (widget_t *)(p);
-
- if (button == button_back) {
- setScreen("mainMenu");
- }
-}
-
-void initScreenDownArena()
-{
- image_t *image;
-
- image = getImage(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = newWidgetImage(0, 0, image);
-
- button_back = newWidgetButton(_("back"), WINDOW_SIZE_X / 2 -WIDGET_BUTTON_WIDTH / 2, WINDOW_SIZE_Y - 80, eventWidget);
-
- label_status = newWidgetLabel("none", WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER);
-
- registerScreen(newScreen("downArena", startScreenDownArena, eventScreenDownArena,
- drawScreenDownArena, stopScreenDownArena) );
-}
-
-void quitScreenDownArena()
-{
- destroyWidgetImage(image_backgorund);
- destroyWidgetButton(button_back);
- destroyWidgetLabel(label_status);
-}
-
diff --git a/src/screen/screen_gameType.c b/src/screen/screen_gameType.c
index ebc1c04..d755072 100644
--- a/src/screen/screen_gameType.c
+++ b/src/screen/screen_gameType.c
@@ -56,355 +56,357 @@ static widget_t *textfield_port;
static widget_t *selectSession;
-static void
-loadSession(widget_t * p)
+static void loadSession(widget_t *p)
{
- director_t *director;
- int i;
+ director_t *director;
+ int i;
- director = loadDirector(getHomeDirector());
+ director = loadDirector(getHomeDirector());
- removeAllFromWidgetSelect(p);
+ removeAllFromWidgetSelect(p);
- if (director == NULL) {
- return;
- }
+ if( director == NULL )
+ {
+ return;
+ }
- for (i = 0; i < director->list->count; i++) {
- char *line;
+ for( i = 0 ; i < director->list->count ; i++ )
+ {
+ char *line;
- line = director->list->list[i];
+ line = director->list->list[i];
- if (strstr(line, ".sav") != NULL) {
- addToWidgetSelect(p, line);
- }
- }
+ if( strstr(line, ".sav") != NULL )
+ {
+ addToWidgetSelect(p, line);
+ }
+ }
- destroyDirector(director);
+ destroyDirector(director);
}
-void
-startScreenGameType()
+void startScreenGameType()
{
#ifndef NO_SOUND
- playMusic("menu", MUSIC_GROUP_BASE);
+ playMusic("menu", MUSIC_GROUP_BASE);
#endif
- setWidgetChoiceStatus(check_none, TRUE);
- setWidgetChoiceStatus(check_server, FALSE);
- setWidgetChoiceStatus(check_client, FALSE);
- setWidgetChoiceStatus(check_load_session, FALSE);
+ setWidgetChoiceStatus(check_none, TRUE);
+ setWidgetChoiceStatus(check_server, FALSE);
+ setWidgetChoiceStatus(check_client, FALSE);
+ setWidgetChoiceStatus(check_load_session, FALSE);
- loadSession(selectSession);
+ loadSession(selectSession);
}
-void
-drawScreenGameType()
+void drawScreenGameType()
{
- int i;
-
- drawWidgetImage(image_backgorund);
-
- for (i = 0; i < listChoiceGroup->count; i++) {
- widget_t *this;
-
- this = (widget_t *) listChoiceGroup->list[i];
- drawWidgetChoicegroup(this);
- }
-
- drawWidgetLabel(label_none);
- drawWidgetLabel(label_server);
- drawWidgetLabel(label_client);
- drawWidgetLabel(label_load_session);
-
- if (getWidgetChoiceStatus(check_server) == TRUE
- || getWidgetChoiceStatus(check_client) == TRUE) {
- drawWidgetLabel(label_port);
- drawWidgetTextfield(textfield_port);
- drawWidgetLabel(label_ip);
- drawWidgetTextfield(textfield_ip);
- }
-
- if (getWidgetChoiceStatus(check_load_session) == TRUE) {
- drawWidgetLabel(label_session);
- drawWidgetSelect(selectSession);
- }
+ int i;
+
+ drawWidgetImage(image_backgorund);
+
+ for( i = 0 ; i < listChoiceGroup->count ; i++ )
+ {
+ widget_t *this;
+
+ this = (widget_t *)listChoiceGroup->list[i];
+ drawWidgetChoicegroup(this);
+ }
+
+ drawWidgetLabel(label_none);
+ drawWidgetLabel(label_server);
+ drawWidgetLabel(label_client);
+ drawWidgetLabel(label_load_session);
+
+ if( getWidgetChoiceStatus(check_server) == TRUE || getWidgetChoiceStatus(check_client) == TRUE )
+ {
+ drawWidgetLabel(label_port);
+ drawWidgetTextfield(textfield_port);
+ drawWidgetLabel(label_ip);
+ drawWidgetTextfield(textfield_ip);
+ }
+
+ if( getWidgetChoiceStatus(check_load_session) == TRUE )
+ {
+ drawWidgetLabel(label_session);
+ drawWidgetSelect(selectSession);
+ }
#if 0
- if (check_server->status == TRUE) {
- setSettingIP(getParamElse("--ip", "127.0.0.1"));
- setSettingPort(atoi(getParamElse("--port", "2200")));
- }
+ if( check_server->status == TRUE )
+ {
+ setSettingIP (getParamElse ("--ip", "127.0.0.1"));
+ setSettingPort (atoi (getParamElse("--port", "2200")));
+ }
#endif
- if (getWidgetChoiceStatus(check_client) == TRUE)
- drawWidgetButton(button_browser);
-
- drawWidgetButton(button_back);
- drawWidgetButton(button_play);
+ if( getWidgetChoiceStatus(check_client) == TRUE )
+ drawWidgetButton(button_browser);
+
+ drawWidgetButton(button_back);
+ drawWidgetButton(button_play);
}
-void
-eventScreenGameType()
+void eventScreenGameType()
{
- int i;
+ int i;
- for (i = 0; i < listChoiceGroup->count; i++) {
- widget_t *this;
+ for( i = 0 ; i < listChoiceGroup->count ; i++ )
+ {
+ widget_t *this;
- this = (widget_t *) listChoiceGroup->list[i];
- eventWidgetChoicegroup(this);
- }
+ this = (widget_t *)listChoiceGroup->list[i];
+ eventWidgetChoicegroup(this);
+ }
- if (getWidgetChoiceStatus(check_server) == TRUE
- || getWidgetChoiceStatus(check_client) == TRUE) {
- eventWidgetTextfield(textfield_ip);
- eventWidgetTextfield(textfield_port);
- }
+ if( getWidgetChoiceStatus(check_server) == TRUE || getWidgetChoiceStatus(check_client) == TRUE )
+ {
+ eventWidgetTextfield(textfield_ip);
+ eventWidgetTextfield(textfield_port);
+ }
- if (getWidgetChoiceStatus(check_load_session) == TRUE) {
- eventWidgetSelect(selectSession);
- }
+ if( getWidgetChoiceStatus(check_load_session) == TRUE )
+ {
+ eventWidgetSelect(selectSession);
+ }
- eventWidgetButton(button_back);
- eventWidgetButton(button_play);
+ eventWidgetButton(button_back);
+ eventWidgetButton(button_play);
- if (getWidgetChoiceStatus(check_client) == TRUE)
- eventWidgetButton(button_browser);
+ if( getWidgetChoiceStatus(check_client) == TRUE )
+ eventWidgetButton(button_browser);
}
-void
-stopScreenGameType()
+void stopScreenGameType()
{
}
-static void
-eventWidget(void *p)
+static void eventWidget(void *p)
{
- widget_t *button;
-
- button = (widget_t *) (p);
-
- if (button == button_back) {
- setScreen("mainMenu");
- }
-
- if (button == button_play) {
- char *str;
-
- str = getGemeTypeLoadSession();
-
- if (str != NULL) {
- setScreen("world");
- return;
- }
-
- if (getSettingGameType() == NET_GAME_TYPE_CLIENT) {
- setScreen("downArena");
- //setScreen("world");
- }
- else {
- setScreen("chiceArena");
- }
- }
-
- if (button == button_browser) {
- setScreen("browser");
- }
+ widget_t *button;
+
+ button = (widget_t *)(p);
+
+ if( button == button_back )
+ {
+ setScreen("mainMenu");
+ }
+
+ if( button == button_play )
+ {
+ char *str;
+
+ str = getGemeTypeLoadSession();
+
+ if( str != NULL )
+ {
+ setScreen("world");
+ return;
+ }
+
+ if( getSettingGameType() == NET_GAME_TYPE_CLIENT )
+ {
+ setScreen("downArena");
+ //setScreen("world");
+ }
+ else
+ {
+ setScreen("chiceArena");
+ }
+ }
+
+ if( button == button_browser )
+ {
+ setScreen("browser");
+ }
}
-void
-initScreenGameType()
+void initScreenGameType()
{
- image_t *image;
-
- image = getImage(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = newWidgetImage(0, 0, image);
-
- button_back =
- newWidgetButton(_("back"), 100, WINDOW_SIZE_Y - 100, eventWidget);
- button_play =
- newWidgetButton(_("play"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100,
- eventWidget);
- button_browser = newWidgetButton(_("browser"), 300, 345, eventWidget);
-
- listChoiceGroup = newList();
- check_none =
- newWidgetChoicegroup(100, 150, FALSE, listChoiceGroup, eventWidget);
- check_server =
- newWidgetChoicegroup(100, 200, FALSE, listChoiceGroup, eventWidget);
- check_client =
- newWidgetChoicegroup(100, 250, FALSE, listChoiceGroup, eventWidget);
- check_load_session =
- newWidgetChoicegroup(100, 300, FALSE, listChoiceGroup, eventWidget);
-
- if (isParamFlag("--server")) {
- setWidgetChoiceStatus(check_server, TRUE);
- }
- else if (isParamFlag("--client")) {
- setWidgetChoiceStatus(check_client, TRUE);
- }
- else {
- setWidgetChoiceStatus(check_none, TRUE);
- }
-
- label_none = newWidgetLabel(_("Local game"), 130, 145, WIDGET_LABEL_LEFT);
- label_server =
- newWidgetLabel(_("Set up a server"), 130, 195, WIDGET_LABEL_LEFT);
- label_client =
- newWidgetLabel(_("Network game"), 130, 245, WIDGET_LABEL_LEFT);
- label_load_session =
- newWidgetLabel("load session", 130, 295, WIDGET_LABEL_LEFT);
-
- label_ip = newWidgetLabel(_("IP"), 300, 145, WIDGET_LABEL_LEFT);
- label_port = newWidgetLabel(_("port"), 300, 245, WIDGET_LABEL_LEFT);
- label_session =
- newWidgetLabel("load session :", 300, 145, WIDGET_LABEL_LEFT);
-
- textfield_ip = newWidgetTextfield(getParamElse("--ip", "127.0.0.1"),
- WIDGET_TEXTFIELD_FILTER_IP_OR_DOMAIN,
- 300, 180);
-
- textfield_port = newWidgetTextfield(getParamElse("--port", "2200"),
- WIDGET_TEXTFIELD_FILTER_NUM, 300, 280);
-
- selectSession = newWidgetSelect(300, 185, eventWidget);
-
- registerScreen(newScreen
- ("gameType", startScreenGameType, eventScreenGameType,
- drawScreenGameType, stopScreenGameType));
+ image_t *image;
+
+ image = getImage(IMAGE_GROUP_BASE, "screen_main");
+ image_backgorund = newWidgetImage(0, 0, image);
+
+ button_back = newWidgetButton(_("back"), 100, WINDOW_SIZE_Y-100, eventWidget);
+ button_play = newWidgetButton(_("play"), WINDOW_SIZE_X-200, WINDOW_SIZE_Y-100, eventWidget);
+ button_browser = newWidgetButton(_("browser"), 300, 345, eventWidget);
+
+ listChoiceGroup = newList();
+ check_none = newWidgetChoicegroup(100, 150, FALSE, listChoiceGroup, eventWidget);
+ check_server = newWidgetChoicegroup(100, 200, FALSE, listChoiceGroup, eventWidget);
+ check_client = newWidgetChoicegroup(100, 250, FALSE, listChoiceGroup, eventWidget);
+ check_load_session = newWidgetChoicegroup(100, 300, FALSE, listChoiceGroup, eventWidget);
+
+ if( isParamFlag("--server") )
+ {
+ setWidgetChoiceStatus(check_server, TRUE);
+ }
+ else if( isParamFlag("--client") )
+ {
+ setWidgetChoiceStatus(check_client, TRUE);
+ }
+ else
+ {
+ setWidgetChoiceStatus(check_none, TRUE);
+ }
+
+ label_none = newWidgetLabel(_("Local game"), 130, 145, WIDGET_LABEL_LEFT);
+ label_server = newWidgetLabel(_("Set up a server"), 130, 195, WIDGET_LABEL_LEFT);
+ label_client = newWidgetLabel(_("Network game"), 130, 245, WIDGET_LABEL_LEFT);
+ label_load_session = newWidgetLabel("load session", 130, 295, WIDGET_LABEL_LEFT);
+
+ label_ip = newWidgetLabel(_("IP"), 300, 145, WIDGET_LABEL_LEFT);
+ label_port = newWidgetLabel(_("port"), 300, 245, WIDGET_LABEL_LEFT);
+ label_session = newWidgetLabel("load session :", 300, 145, WIDGET_LABEL_LEFT);
+
+ textfield_ip = newWidgetTextfield(
+ getParamElse("--ip", "127.0.0.1"),
+ WIDGET_TEXTFIELD_FILTER_IP_OR_DOMAIN,
+ 300, 180);
+
+ textfield_port = newWidgetTextfield(
+ getParamElse("--port", "2200"),
+ WIDGET_TEXTFIELD_FILTER_NUM,
+ 300, 280);
+
+ selectSession = newWidgetSelect(300, 185, eventWidget);
+
+ registerScreen( newScreen("gameType", startScreenGameType, eventScreenGameType,
+ drawScreenGameType, stopScreenGameType) );
}
-int
-setSettingGameType(int status)
+int setSettingGameType(int status)
{
- if (status == NET_GAME_TYPE_NONE) {
- setWidgetChoiceStatus(check_none, TRUE);
- return 0;
- }
-
- if (status == NET_GAME_TYPE_SERVER) {
- setWidgetChoiceStatus(check_server, TRUE);
- return 0;
- }
-
- if (status == NET_GAME_TYPE_CLIENT) {
- setWidgetChoiceStatus(check_client, TRUE);
- return 0;
- }
-
- return -1;
+ if( status == NET_GAME_TYPE_NONE )
+ {
+ setWidgetChoiceStatus(check_none, TRUE);
+ return 0;
+ }
+
+ if( status == NET_GAME_TYPE_SERVER )
+ {
+ setWidgetChoiceStatus(check_server, TRUE);
+ return 0;
+ }
+
+ if( status == NET_GAME_TYPE_CLIENT )
+ {
+ setWidgetChoiceStatus(check_client, TRUE);
+ return 0;
+ }
+
+ return -1;
}
-int
-getSettingGameType()
+int getSettingGameType()
{
- if (getWidgetChoiceStatus(check_none) == TRUE ||
- getWidgetChoiceStatus(check_load_session) == TRUE) {
- return NET_GAME_TYPE_NONE;
- }
+ if( getWidgetChoiceStatus(check_none) == TRUE ||
+ getWidgetChoiceStatus(check_load_session) == TRUE )
+ {
+ return NET_GAME_TYPE_NONE;
+ }
- if (getWidgetChoiceStatus(check_server) == TRUE) {
- return NET_GAME_TYPE_SERVER;
- }
+ if( getWidgetChoiceStatus(check_server) == TRUE )
+ {
+ return NET_GAME_TYPE_SERVER;
+ }
- if (getWidgetChoiceStatus(check_client) == TRUE) {
- return NET_GAME_TYPE_CLIENT;
- }
+ if( getWidgetChoiceStatus(check_client) == TRUE )
+ {
+ return NET_GAME_TYPE_CLIENT;
+ }
- assert(!_("Unknown game type!"));
+ assert( ! _("Unknown game type!") );
- return -1;
+ return -1;
}
-char *
-getGemeTypeLoadSession()
+char* getGemeTypeLoadSession()
{
- if (getWidgetChoiceStatus(check_load_session) == TRUE) {
- return getWidgetSelectItem(selectSession);
- }
+ if( getWidgetChoiceStatus(check_load_session) == TRUE )
+ {
+ return getWidgetSelectItem(selectSession);
+ }
- return NULL;
+ return NULL;
}
-int
-setSettingIP(char *address)
+int setSettingIP(char *address)
{
- char str[STR_SIZE];
+ char str[STR_SIZE];
- strcpy(str, address);
- setWidgetTextFiledText(textfield_ip, str);
+ strcpy (str, address);
+ setWidgetTextFiledText(textfield_ip, str);
- return 1;
+ return 1;
}
-char *
-getSettingIP()
+char* getSettingIP()
{
- return getTextFromWidgetTextfield(textfield_ip);
+ return getTextFromWidgetTextfield(textfield_ip);
}
-int
-setSettingPort(int port)
+int setSettingPort(int port)
{
- char str[STR_SIZE];
+ char str[STR_SIZE];
- sprintf(str, "%d", port);
- setWidgetTextFiledText(textfield_port, str);
+ sprintf (str, "%d", port);
+ setWidgetTextFiledText(textfield_port, str);
- return 0;
+ return 0;
}
-int
-getSettingPort()
+int getSettingPort()
{
- return atoi(getTextFromWidgetTextfield(textfield_port));
+ return atoi( getTextFromWidgetTextfield(textfield_port) );
}
-int
-getSettingProto()
+int getSettingProto()
{
- if (strstr(getTextFromWidgetTextfield(textfield_ip), ".") != NULL) {
- return PROTO_UDPv4;
- }
-
- if (strstr(getTextFromWidgetTextfield(textfield_ip), ":") != NULL) {
- return PROTO_UDPv6;
- }
+ if( strstr(getTextFromWidgetTextfield(textfield_ip), ".") != NULL )
+ {
+ return PROTO_UDPv4;
+ }
+
+ if( strstr(getTextFromWidgetTextfield(textfield_ip), ":") != NULL )
+ {
+ return PROTO_UDPv6;
+ }
#ifdef DEBUG
- printf(_("Unknown IP protocol!\n"));
+ printf(_("Unknown IP protocol!\n"));
#endif
- return -1;
+ return -1;
}
-void
-quitScreenGameType()
+void quitScreenGameType()
{
- destroyWidgetImage(image_backgorund);
+ destroyWidgetImage(image_backgorund);
- destroyWidgetLabel(label_none);
- destroyWidgetLabel(label_server);
- destroyWidgetLabel(label_client);
- destroyWidgetLabel(label_load_session);
+ destroyWidgetLabel(label_none);
+ destroyWidgetLabel(label_server);
+ destroyWidgetLabel(label_client);
+ destroyWidgetLabel(label_load_session);
- destroyWidgetLabel(label_ip);
- destroyWidgetLabel(label_port);
- destroyWidgetLabel(label_session);
+ destroyWidgetLabel(label_ip);
+ destroyWidgetLabel(label_port);
+ destroyWidgetLabel(label_session);
- destroyWidgetTextfield(textfield_ip);
- destroyWidgetTextfield(textfield_port);
+ destroyWidgetTextfield(textfield_ip);
+ destroyWidgetTextfield(textfield_port);
- destroyWidgetSelect(selectSession);
+ destroyWidgetSelect(selectSession);
- destroyWidgetButton(button_back);
- destroyWidgetButton(button_play);
- destroyWidgetButton(button_browser);
+ destroyWidgetButton(button_back);
+ destroyWidgetButton(button_play);
+ destroyWidgetButton(button_browser);
- destroyWidgetChoicegroup(check_none);
- destroyWidgetChoicegroup(check_server);
- destroyWidgetChoicegroup(check_client);
- destroyWidgetChoicegroup(check_load_session);
-
- destroyList(listChoiceGroup);
+ destroyWidgetChoicegroup(check_none);
+ destroyWidgetChoicegroup(check_server);
+ destroyWidgetChoicegroup(check_client);
+ destroyWidgetChoicegroup(check_load_session);
+
+ destroyList(listChoiceGroup);
}
+
diff --git a/src/screen/screen_gameType.c~ b/src/screen/screen_gameType.c~
deleted file mode 100644
index d755072..0000000
--- a/src/screen/screen_gameType.c~
+++ /dev/null
@@ -1,412 +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"
-
-#ifndef NO_SOUND
-#include "music.h"
-#endif
-
-#include "screen_gameType.h"
-#include "screen_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 = loadDirector(getHomeDirector());
-
- removeAllFromWidgetSelect(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 )
- {
- addToWidgetSelect(p, line);
- }
- }
-
- destroyDirector(director);
-}
-
-void startScreenGameType()
-{
-#ifndef NO_SOUND
- playMusic("menu", MUSIC_GROUP_BASE);
-#endif
-
- setWidgetChoiceStatus(check_none, TRUE);
- setWidgetChoiceStatus(check_server, FALSE);
- setWidgetChoiceStatus(check_client, FALSE);
- setWidgetChoiceStatus(check_load_session, FALSE);
-
- loadSession(selectSession);
-}
-
-void drawScreenGameType()
-{
- int i;
-
- drawWidgetImage(image_backgorund);
-
- for( i = 0 ; i < listChoiceGroup->count ; i++ )
- {
- widget_t *this;
-
- this = (widget_t *)listChoiceGroup->list[i];
- drawWidgetChoicegroup(this);
- }
-
- drawWidgetLabel(label_none);
- drawWidgetLabel(label_server);
- drawWidgetLabel(label_client);
- drawWidgetLabel(label_load_session);
-
- if( getWidgetChoiceStatus(check_server) == TRUE || getWidgetChoiceStatus(check_client) == TRUE )
- {
- drawWidgetLabel(label_port);
- drawWidgetTextfield(textfield_port);
- drawWidgetLabel(label_ip);
- drawWidgetTextfield(textfield_ip);
- }
-
- if( getWidgetChoiceStatus(check_load_session) == TRUE )
- {
- drawWidgetLabel(label_session);
- drawWidgetSelect(selectSession);
- }
-
-#if 0
- if( check_server->status == TRUE )
- {
- setSettingIP (getParamElse ("--ip", "127.0.0.1"));
- setSettingPort (atoi (getParamElse("--port", "2200")));
- }
-#endif
-
- if( getWidgetChoiceStatus(check_client) == TRUE )
- drawWidgetButton(button_browser);
-
- drawWidgetButton(button_back);
- drawWidgetButton(button_play);
-
-}
-
-void eventScreenGameType()
-{
- int i;
-
- for( i = 0 ; i < listChoiceGroup->count ; i++ )
- {
- widget_t *this;
-
- this = (widget_t *)listChoiceGroup->list[i];
- eventWidgetChoicegroup(this);
- }
-
- if( getWidgetChoiceStatus(check_server) == TRUE || getWidgetChoiceStatus(check_client) == TRUE )
- {
- eventWidgetTextfield(textfield_ip);
- eventWidgetTextfield(textfield_port);
- }
-
- if( getWidgetChoiceStatus(check_load_session) == TRUE )
- {
- eventWidgetSelect(selectSession);
- }
-
- eventWidgetButton(button_back);
- eventWidgetButton(button_play);
-
- if( getWidgetChoiceStatus(check_client) == TRUE )
- eventWidgetButton(button_browser);
-}
-
-void stopScreenGameType()
-{
-}
-
-static void eventWidget(void *p)
-{
- widget_t *button;
-
- button = (widget_t *)(p);
-
- if( button == button_back )
- {
- setScreen("mainMenu");
- }
-
- if( button == button_play )
- {
- char *str;
-
- str = getGemeTypeLoadSession();
-
- if( str != NULL )
- {
- setScreen("world");
- return;
- }
-
- if( getSettingGameType() == NET_GAME_TYPE_CLIENT )
- {
- setScreen("downArena");
- //setScreen("world");
- }
- else
- {
- setScreen("chiceArena");
- }
- }
-
- if( button == button_browser )
- {
- setScreen("browser");
- }
-}
-
-void initScreenGameType()
-{
- image_t *image;
-
- image = getImage(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = newWidgetImage(0, 0, image);
-
- button_back = newWidgetButton(_("back"), 100, WINDOW_SIZE_Y-100, eventWidget);
- button_play = newWidgetButton(_("play"), WINDOW_SIZE_X-200, WINDOW_SIZE_Y-100, eventWidget);
- button_browser = newWidgetButton(_("browser"), 300, 345, eventWidget);
-
- listChoiceGroup = newList();
- check_none = newWidgetChoicegroup(100, 150, FALSE, listChoiceGroup, eventWidget);
- check_server = newWidgetChoicegroup(100, 200, FALSE, listChoiceGroup, eventWidget);
- check_client = newWidgetChoicegroup(100, 250, FALSE, listChoiceGroup, eventWidget);
- check_load_session = newWidgetChoicegroup(100, 300, FALSE, listChoiceGroup, eventWidget);
-
- if( isParamFlag("--server") )
- {
- setWidgetChoiceStatus(check_server, TRUE);
- }
- else if( isParamFlag("--client") )
- {
- setWidgetChoiceStatus(check_client, TRUE);
- }
- else
- {
- setWidgetChoiceStatus(check_none, TRUE);
- }
-
- label_none = newWidgetLabel(_("Local game"), 130, 145, WIDGET_LABEL_LEFT);
- label_server = newWidgetLabel(_("Set up a server"), 130, 195, WIDGET_LABEL_LEFT);
- label_client = newWidgetLabel(_("Network game"), 130, 245, WIDGET_LABEL_LEFT);
- label_load_session = newWidgetLabel("load session", 130, 295, WIDGET_LABEL_LEFT);
-
- label_ip = newWidgetLabel(_("IP"), 300, 145, WIDGET_LABEL_LEFT);
- label_port = newWidgetLabel(_("port"), 300, 245, WIDGET_LABEL_LEFT);
- label_session = newWidgetLabel("load session :", 300, 145, WIDGET_LABEL_LEFT);
-
- textfield_ip = newWidgetTextfield(
- getParamElse("--ip", "127.0.0.1"),
- WIDGET_TEXTFIELD_FILTER_IP_OR_DOMAIN,
- 300, 180);
-
- textfield_port = newWidgetTextfield(
- getParamElse("--port", "2200"),
- WIDGET_TEXTFIELD_FILTER_NUM,
- 300, 280);
-
- selectSession = newWidgetSelect(300, 185, eventWidget);
-
- registerScreen( newScreen("gameType", startScreenGameType, eventScreenGameType,
- drawScreenGameType, stopScreenGameType) );
-}
-
-int setSettingGameType(int status)
-{
- if( status == NET_GAME_TYPE_NONE )
- {
- setWidgetChoiceStatus(check_none, TRUE);
- return 0;
- }
-
- if( status == NET_GAME_TYPE_SERVER )
- {
- setWidgetChoiceStatus(check_server, TRUE);
- return 0;
- }
-
- if( status == NET_GAME_TYPE_CLIENT )
- {
- setWidgetChoiceStatus(check_client, TRUE);
- return 0;
- }
-
- return -1;
-}
-
-int getSettingGameType()
-{
- if( getWidgetChoiceStatus(check_none) == TRUE ||
- getWidgetChoiceStatus(check_load_session) == TRUE )
- {
- return NET_GAME_TYPE_NONE;
- }
-
- if( getWidgetChoiceStatus(check_server) == TRUE )
- {
- return NET_GAME_TYPE_SERVER;
- }
-
- if( getWidgetChoiceStatus(check_client) == TRUE )
- {
- return NET_GAME_TYPE_CLIENT;
- }
-
- assert( ! _("Unknown game type!") );
-
- return -1;
-}
-
-char* getGemeTypeLoadSession()
-{
- if( getWidgetChoiceStatus(check_load_session) == TRUE )
- {
- return getWidgetSelectItem(selectSession);
- }
-
- return NULL;
-}
-
-int setSettingIP(char *address)
-{
- char str[STR_SIZE];
-
- strcpy (str, address);
- setWidgetTextFiledText(textfield_ip, str);
-
- return 1;
-}
-
-char* getSettingIP()
-{
- return getTextFromWidgetTextfield(textfield_ip);
-}
-
-int setSettingPort(int port)
-{
- char str[STR_SIZE];
-
- sprintf (str, "%d", port);
- setWidgetTextFiledText(textfield_port, str);
-
- return 0;
-}
-
-int getSettingPort()
-{
- return atoi( getTextFromWidgetTextfield(textfield_port) );
-}
-
-int getSettingProto()
-{
- if( strstr(getTextFromWidgetTextfield(textfield_ip), ".") != NULL )
- {
- return PROTO_UDPv4;
- }
-
- if( strstr(getTextFromWidgetTextfield(textfield_ip), ":") != NULL )
- {
- return PROTO_UDPv6;
- }
-#ifdef DEBUG
- printf(_("Unknown IP protocol!\n"));
-#endif
- return -1;
-}
-
-void quitScreenGameType()
-{
- destroyWidgetImage(image_backgorund);
-
- destroyWidgetLabel(label_none);
- destroyWidgetLabel(label_server);
- destroyWidgetLabel(label_client);
- destroyWidgetLabel(label_load_session);
-
- destroyWidgetLabel(label_ip);
- destroyWidgetLabel(label_port);
- destroyWidgetLabel(label_session);
-
- destroyWidgetTextfield(textfield_ip);
- destroyWidgetTextfield(textfield_port);
-
- destroyWidgetSelect(selectSession);
-
- destroyWidgetButton(button_back);
- destroyWidgetButton(button_play);
- destroyWidgetButton(button_browser);
-
- destroyWidgetChoicegroup(check_none);
- destroyWidgetChoicegroup(check_server);
- destroyWidgetChoicegroup(check_client);
- destroyWidgetChoicegroup(check_load_session);
-
- destroyList(listChoiceGroup);
-}
-
diff --git a/src/screen/screen_mainMenu.c b/src/screen/screen_mainMenu.c
index a1b4793..46cfb5e 100644
--- a/src/screen/screen_mainMenu.c
+++ b/src/screen/screen_mainMenu.c
@@ -31,117 +31,98 @@ static widget_t *button_table;
static widget_t *button_credits;
static widget_t *button_end;
-void
-startScreenMainMenu()
+void startScreenMainMenu()
{
#ifndef NO_SOUND
- playMusic("menu", MUSIC_GROUP_BASE);
+ playMusic("menu", MUSIC_GROUP_BASE);
#endif
}
-void
-drawScreenMainMenu()
+void drawScreenMainMenu()
{
- drawWidgetImage(image_backgorund);
+ drawWidgetImage(image_backgorund);
- drawWidgetButton(button_play);
- drawWidgetButton(button_setting);
- drawWidgetButton(button_table);
- drawWidgetButton(button_credits);
- drawWidgetButton(button_end);
+ drawWidgetButton(button_play);
+ drawWidgetButton(button_setting);
+ drawWidgetButton(button_table);
+ drawWidgetButton(button_credits);
+ drawWidgetButton(button_end);
}
-void
-eventScreenMainMenu()
+void eventScreenMainMenu()
{
- eventWidgetButton(button_play);
- eventWidgetButton(button_setting);
- eventWidgetButton(button_table);
- eventWidgetButton(button_credits);
- eventWidgetButton(button_end);
+ eventWidgetButton(button_play);
+ eventWidgetButton(button_setting);
+ eventWidgetButton(button_table);
+ eventWidgetButton(button_credits);
+ eventWidgetButton(button_end);
}
-void
-stopScreenMainMenu()
+void stopScreenMainMenu()
{
}
-static void
-eventWidget(void *p)
+static void eventWidget(void *p)
{
- widget_t *button;
-
- button = (widget_t *) (p);
-
- if (button == button_play) {
- setScreen("gameType");
- }
-
- if (button == button_setting) {
- setScreen("setting");
- }
-
- if (button == button_table) {
- setScreen("table");
- }
-
- if (button == button_credits) {
- setScreen("credits");
- }
-
- if (button == button_end) {
- quitGame();
- }
+ widget_t *button;
+
+ button = (widget_t *)(p);
+
+ if( button == button_play )
+ {
+ setScreen("gameType");
+ }
+
+ if( button == button_setting )
+ {
+ setScreen("setting");
+ }
+
+ if( button == button_table )
+ {
+ setScreen("table");
+ }
+
+ if( button == button_credits )
+ {
+ setScreen("credits");
+ }
+
+ if( button == button_end )
+ {
+ quitGame();
+ }
}
-void
-initScreenMainMenu()
+void initScreenMainMenu()
{
- image_t *image;
-
- image =
- addImageData("screen_main.png", IMAGE_NO_ALPHA, "screen_main",
- IMAGE_GROUP_BASE);
- image_backgorund = newWidgetImage(0, 0, image);
-
- button_play =
- newWidgetButton(_("Start game"),
- WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, 200,
- eventWidget);
- button_setting =
- newWidgetButton(_("Settings"),
- WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, 250,
- eventWidget);
- button_table =
- newWidgetButton(_("Highscore"),
- WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, 300,
- eventWidget);
- button_credits =
- newWidgetButton(_("Credits"),
- WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, 350,
- eventWidget);
- button_end =
- newWidgetButton(_("Quit game"),
- WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, 400,
- eventWidget);
+ image_t *image;
+
+ image = addImageData("screen_main.png", IMAGE_NO_ALPHA, "screen_main", IMAGE_GROUP_BASE);
+ image_backgorund = newWidgetImage(0, 0, image);
+
+ button_play = newWidgetButton(_("Start game"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, 200, eventWidget);
+ button_setting = newWidgetButton(_("Settings"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, 250, eventWidget);
+ button_table = newWidgetButton(_("Highscore"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, 300, eventWidget);
+ button_credits = newWidgetButton(_("Credits"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, 350, eventWidget);
+ button_end = newWidgetButton(_("Quit game"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, 400, eventWidget);
#ifndef NO_SOUND
- addMusic("menu.ogg", "menu", MUSIC_GROUP_BASE);
+ addMusic("menu.ogg", "menu", MUSIC_GROUP_BASE);
#endif
- registerScreen(newScreen
- ("mainMenu", startScreenMainMenu, eventScreenMainMenu,
- drawScreenMainMenu, stopScreenMainMenu));
+ registerScreen( newScreen("mainMenu", startScreenMainMenu, eventScreenMainMenu,
+ drawScreenMainMenu, stopScreenMainMenu) );
}
-void
-quitScreenMainMenu()
+void quitScreenMainMenu()
{
- destroyWidgetImage(image_backgorund);
+ destroyWidgetImage(image_backgorund);
- destroyWidgetButton(button_play);
- destroyWidgetButton(button_setting);
- destroyWidgetButton(button_table);
- destroyWidgetButton(button_credits);
- destroyWidgetButton(button_end);
+ destroyWidgetButton(button_play);
+ destroyWidgetButton(button_setting);
+ destroyWidgetButton(button_table);
+ destroyWidgetButton(button_credits);
+ destroyWidgetButton(button_end);
}
+
diff --git a/src/screen/screen_mainMenu.c~ b/src/screen/screen_mainMenu.c~
deleted file mode 100644
index 46cfb5e..0000000
--- a/src/screen/screen_mainMenu.c~
+++ /dev/null
@@ -1,128 +0,0 @@
-
-#include <stdio.h>
-#include <assert.h>
-
-#include "main.h"
-
-#include "game.h"
-#include "interface.h"
-#include "screen.h"
-#include "image.h"
-
-#ifndef NO_SOUND
-#include "music.h"
-#endif
-
-#include "screen_mainMenu.h"
-#include "screen_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"
-
-static widget_t *image_backgorund;
-
-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;
-
-void startScreenMainMenu()
-{
-#ifndef NO_SOUND
- playMusic("menu", MUSIC_GROUP_BASE);
-#endif
-}
-
-void drawScreenMainMenu()
-{
- drawWidgetImage(image_backgorund);
-
- drawWidgetButton(button_play);
- drawWidgetButton(button_setting);
- drawWidgetButton(button_table);
- drawWidgetButton(button_credits);
- drawWidgetButton(button_end);
-}
-
-void eventScreenMainMenu()
-{
- eventWidgetButton(button_play);
- eventWidgetButton(button_setting);
- eventWidgetButton(button_table);
- eventWidgetButton(button_credits);
- eventWidgetButton(button_end);
-}
-
-void stopScreenMainMenu()
-{
-}
-
-static void eventWidget(void *p)
-{
- widget_t *button;
-
- button = (widget_t *)(p);
-
- if( button == button_play )
- {
- setScreen("gameType");
- }
-
- if( button == button_setting )
- {
- setScreen("setting");
- }
-
- if( button == button_table )
- {
- setScreen("table");
- }
-
- if( button == button_credits )
- {
- setScreen("credits");
- }
-
- if( button == button_end )
- {
- quitGame();
- }
-}
-
-void initScreenMainMenu()
-{
- image_t *image;
-
- image = addImageData("screen_main.png", IMAGE_NO_ALPHA, "screen_main", IMAGE_GROUP_BASE);
- image_backgorund = newWidgetImage(0, 0, image);
-
- button_play = newWidgetButton(_("Start game"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, 200, eventWidget);
- button_setting = newWidgetButton(_("Settings"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, 250, eventWidget);
- button_table = newWidgetButton(_("Highscore"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, 300, eventWidget);
- button_credits = newWidgetButton(_("Credits"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, 350, eventWidget);
- button_end = newWidgetButton(_("Quit game"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, 400, eventWidget);
-
-#ifndef NO_SOUND
- addMusic("menu.ogg", "menu", MUSIC_GROUP_BASE);
-#endif
-
- registerScreen( newScreen("mainMenu", startScreenMainMenu, eventScreenMainMenu,
- drawScreenMainMenu, stopScreenMainMenu) );
-}
-
-void quitScreenMainMenu()
-{
- destroyWidgetImage(image_backgorund);
-
- destroyWidgetButton(button_play);
- destroyWidgetButton(button_setting);
- destroyWidgetButton(button_table);
- destroyWidgetButton(button_credits);
- destroyWidgetButton(button_end);
-}
-
diff --git a/src/screen/screen_setting.c b/src/screen/screen_setting.c
index a5193ba..c79acaf 100644
--- a/src/screen/screen_setting.c
+++ b/src/screen/screen_setting.c
@@ -38,7 +38,7 @@
static widget_t *image_backgorund;
static widget_t *button_back;
-static widget_t *button_keys; // setting of keycontrols
+static widget_t *button_keys; // setting of keycontrols
static widget_t *label_count_round;
static widget_t *label_name_player1;
@@ -78,534 +78,476 @@ static widget_t *check_ai;
static textFile_t *configFile;
-void
-startScreenSetting()
+void startScreenSetting()
{
#ifndef NO_SOUND
- playMusic("menu", MUSIC_GROUP_BASE);
+ playMusic("menu", MUSIC_GROUP_BASE);
#endif
}
-void
-drawScreenSetting()
+void drawScreenSetting()
{
- int i;
+ int i;
- drawWidgetImage(image_backgorund);
-
- drawWidgetLabel(label_count_round);
- drawWidgetLabel(label_name_player1);
- drawWidgetLabel(label_ai);
+ drawWidgetImage(image_backgorund);
+
+ drawWidgetLabel(label_count_round);
+ drawWidgetLabel(label_name_player1);
+ drawWidgetLabel(label_ai);
#ifndef NO_SOUND
- drawWidgetLabel(label_music);
- drawWidgetLabel(label_sound);
+ drawWidgetLabel(label_music);
+ drawWidgetLabel(label_sound);
#endif
- drawWidgetTextfield(textfield_count_cound);
- drawWidgetTextfield(textfield_name_player1);
-
- if (getWidgetCheckStatus(check_ai) == FALSE) {
- drawWidgetLabel(label_name_player2);
- drawWidgetTextfield(textfield_name_player2);
- }
-
- drawWidgetImage(image_gun_dual_revolver);
- drawWidgetImage(image_gun_scatter);
- drawWidgetImage(image_gun_tommy);
- drawWidgetImage(image_gun_lasser);
- drawWidgetImage(image_gun_mine);
- drawWidgetImage(image_gun_bombball);
-
- drawWidgetImage(image_bonus_speed);
- drawWidgetImage(image_bonus_shot);
- drawWidgetImage(image_bonus_teleport);
- drawWidgetImage(image_bonus_ghost);
- drawWidgetImage(image_bonus_4x);
- drawWidgetImage(image_bonus_hidden);
+ drawWidgetTextfield(textfield_count_cound);
+ drawWidgetTextfield(textfield_name_player1);
+
+ if ( getWidgetCheckStatus(check_ai) == FALSE )
+ {
+ drawWidgetLabel(label_name_player2);
+ drawWidgetTextfield(textfield_name_player2);
+ }
+
+ drawWidgetImage(image_gun_dual_revolver);
+ drawWidgetImage(image_gun_scatter);
+ drawWidgetImage(image_gun_tommy);
+ drawWidgetImage(image_gun_lasser);
+ drawWidgetImage(image_gun_mine);
+ drawWidgetImage(image_gun_bombball);
+
+ drawWidgetImage(image_bonus_speed);
+ drawWidgetImage(image_bonus_shot);
+ drawWidgetImage(image_bonus_teleport);
+ drawWidgetImage(image_bonus_ghost);
+ drawWidgetImage(image_bonus_4x);
+ drawWidgetImage(image_bonus_hidden);
#ifndef NO_SOUND
- drawWidgetCheck(check_music);
- drawWidgetCheck(check_sound);
+ drawWidgetCheck(check_music);
+ drawWidgetCheck(check_sound);
#endif
- for (i = GUN_DUAL_SIMPLE; i <= GUN_BOMBBALL; i++) {
- drawWidgetCheck(check[i]);
- }
+ for( i = GUN_DUAL_SIMPLE ; i <= GUN_BOMBBALL ; i++ )
+ {
+ drawWidgetCheck(check[i]);
+ }
- for (i = BONUS_SPEED; i <= BONUS_HIDDEN; i++) {
- drawWidgetCheck(check[i]);
- }
+ for( i = BONUS_SPEED ; i <= BONUS_HIDDEN ; i++ )
+ {
+ drawWidgetCheck(check[i]);
+ }
- drawWidgetCheck(check_ai);
+ drawWidgetCheck(check_ai);
- drawWidgetButton(button_back);
- drawWidgetButton(button_keys);
+ drawWidgetButton(button_back);
+ drawWidgetButton(button_keys);
}
-void
-eventScreenSetting()
+void eventScreenSetting()
{
- int i;
+ int i;
- eventWidgetTextfield(textfield_count_cound);
- eventWidgetTextfield(textfield_name_player1);
+ eventWidgetTextfield(textfield_count_cound);
+ eventWidgetTextfield(textfield_name_player1);
- if (getWidgetCheckStatus(check_ai) == FALSE) {
- eventWidgetTextfield(textfield_name_player2);
- }
+ if ( getWidgetCheckStatus(check_ai) == FALSE )
+ {
+ eventWidgetTextfield(textfield_name_player2);
+ }
#ifndef NO_SOUND
- eventWidgetCheck(check_music);
- eventWidgetCheck(check_sound);
+ eventWidgetCheck(check_music);
+ eventWidgetCheck(check_sound);
#endif
- for (i = GUN_DUAL_SIMPLE; i <= GUN_BOMBBALL; i++) {
- eventWidgetCheck(check[i]);
- }
+ for( i = GUN_DUAL_SIMPLE ; i <= GUN_BOMBBALL ; i++ )
+ {
+ eventWidgetCheck(check[i]);
+ }
- for (i = BONUS_SPEED; i <= BONUS_HIDDEN; i++) {
- eventWidgetCheck(check[i]);
- }
+ for( i = BONUS_SPEED ; i <= BONUS_HIDDEN ; i++ )
+ {
+ eventWidgetCheck(check[i]);
+ }
- eventWidgetCheck(check_ai);
+ eventWidgetCheck(check_ai);
- eventWidgetButton(button_back);
- eventWidgetButton(button_keys);
+ eventWidgetButton(button_back);
+ eventWidgetButton(button_keys);
}
-void
-stopScreenSetting()
+void stopScreenSetting()
{
}
-static void
-eventWidget(void *p)
+static void eventWidget(void *p)
{
- widget_t *button;
- widget_t *check;
-
- button = (widget_t *) (p);
- check = (widget_t *) (p);
-
- if (button == button_back) {
- setScreen("mainMenu");
- }
- if (button == button_keys) {
- setScreen("settingKeys");
- }
+ widget_t *button;
+ widget_t *check;
+
+ button = (widget_t *)(p);
+ check = (widget_t *)(p);
+
+ if( button == button_back )
+ {
+ setScreen("mainMenu");
+ }
+ if( button == button_keys )
+ {
+ setScreen("settingKeys");
+ }
#ifndef NO_SOUND
- if (check == check_music) {
- setMusicActive(getWidgetCheckStatus(check_music));
- }
-
- if (check == check_sound) {
- setSoundActive(getWidgetCheckStatus(check_sound));
- }
+ if( check == check_music )
+ {
+ setMusicActive( getWidgetCheckStatus(check_music) );
+ }
+
+ if( check == check_sound )
+ {
+ setSoundActive( getWidgetCheckStatus(check_sound) );
+ }
#endif
}
-static void
-initSettingFile()
+static void initSettingFile()
{
- char path[STR_PATH_SIZE];
- char val[STR_SIZE];
-
- sprintf(path, "%s/tuxanci.conf", getHomeDirector());
-
- configFile = loadTextFile(path);
-
- if (configFile == NULL) {
- fprintf(stderr, _("I am unable to load: \"%s\" !\n"), path);
- fprintf(stderr, _("Creating: \"%s\"\n"), path);
-
- configFile = newTextFile(path);
- }
-
- if (configFile == NULL) {
- fprintf(stderr, _("I was unable to create: \"%s\" !\n"), path);
- return;
- }
-
- loadValueFromConfigFile(configFile, "COUNT_ROUND", val, STR_SIZE, "15");
- setWidgetTextFiledText(textfield_count_cound, val);
-
- loadValueFromConfigFile(configFile, "NAME_PLAYER_RIGHT", val, STR_SIZE,
- NAME_PLAYER_RIGHT);
- setWidgetTextFiledText(textfield_name_player1, val);
-
- loadValueFromConfigFile(configFile, "NAME_PLAYER_LEFT", val, STR_SIZE,
- NAME_PLAYER_LEFT);
- setWidgetTextFiledText(textfield_name_player2, val);
-
- loadValueFromConfigFile(configFile, "GUN_DUAL_SIMPLE", val, STR_SIZE,
- "YES");
- setWidgetCheckStatus(check[GUN_DUAL_SIMPLE], isYesOrNO(val));
- loadValueFromConfigFile(configFile, "GUN_SCATTER", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[GUN_SCATTER], isYesOrNO(val));
- loadValueFromConfigFile(configFile, "GUN_TOMMY", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[GUN_TOMMY], isYesOrNO(val));
- loadValueFromConfigFile(configFile, "GUN_LASSER", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[GUN_LASSER], isYesOrNO(val));
- loadValueFromConfigFile(configFile, "GUN_MINE", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[GUN_MINE], isYesOrNO(val));
- loadValueFromConfigFile(configFile, "GUN_BOMBBALL", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[GUN_BOMBBALL], isYesOrNO(val));
-
- loadValueFromConfigFile(configFile, "BONUS_SPEED", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[BONUS_SPEED], isYesOrNO(val));
- loadValueFromConfigFile(configFile, "BONUS_SHOT", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[BONUS_SHOT], isYesOrNO(val));
- loadValueFromConfigFile(configFile, "BONUS_TELEPORT", val, STR_SIZE,
- "YES");
- setWidgetCheckStatus(check[BONUS_TELEPORT], isYesOrNO(val));
- loadValueFromConfigFile(configFile, "BONUS_GHOST", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[BONUS_GHOST], isYesOrNO(val));
- loadValueFromConfigFile(configFile, "BONUS_4X", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[BONUS_4X], isYesOrNO(val));
- loadValueFromConfigFile(configFile, "BONUS_HIDDEN", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[BONUS_HIDDEN], isYesOrNO(val));
-
- loadValueFromConfigFile(configFile, "AI", val, STR_SIZE, "NO");
- setWidgetCheckStatus(check_ai, isYesOrNO(val));
+ char path[STR_PATH_SIZE];
+ char val[STR_SIZE];
+
+ sprintf(path, "%s/tuxanci.conf", getHomeDirector());
+
+ configFile = loadTextFile(path);
+
+ if( configFile == NULL )
+ {
+ fprintf(stderr, _("I am unable to load: \"%s\" !\n"), path);
+ fprintf(stderr, _("Creating: \"%s\"\n"), path);
+
+ configFile = newTextFile(path);
+ }
+
+ if( configFile == NULL )
+ {
+ fprintf(stderr, _("I was unable to create: \"%s\" !\n"), path);
+ return;
+ }
+
+ loadValueFromConfigFile(configFile, "COUNT_ROUND", val, STR_SIZE, "15");
+ setWidgetTextFiledText(textfield_count_cound, val);
+
+ loadValueFromConfigFile(configFile, "NAME_PLAYER_RIGHT", val, STR_SIZE, NAME_PLAYER_RIGHT);
+ setWidgetTextFiledText(textfield_name_player1, val);
+
+ loadValueFromConfigFile(configFile, "NAME_PLAYER_LEFT", val, STR_SIZE, NAME_PLAYER_LEFT);
+ setWidgetTextFiledText(textfield_name_player2, val);
+
+ loadValueFromConfigFile(configFile, "GUN_DUAL_SIMPLE", val, STR_SIZE, "YES");
+ setWidgetCheckStatus(check[GUN_DUAL_SIMPLE], isYesOrNO(val));
+ loadValueFromConfigFile(configFile, "GUN_SCATTER", val, STR_SIZE, "YES");
+ setWidgetCheckStatus(check[GUN_SCATTER], isYesOrNO(val));
+ loadValueFromConfigFile(configFile, "GUN_TOMMY", val, STR_SIZE, "YES");
+ setWidgetCheckStatus(check[GUN_TOMMY], isYesOrNO(val));
+ loadValueFromConfigFile(configFile, "GUN_LASSER", val, STR_SIZE, "YES");
+ setWidgetCheckStatus(check[GUN_LASSER], isYesOrNO(val));
+ loadValueFromConfigFile(configFile, "GUN_MINE", val, STR_SIZE, "YES");
+ setWidgetCheckStatus(check[GUN_MINE], isYesOrNO(val));
+ loadValueFromConfigFile(configFile, "GUN_BOMBBALL", val, STR_SIZE, "YES");
+ setWidgetCheckStatus(check[GUN_BOMBBALL], isYesOrNO(val));
+
+ loadValueFromConfigFile(configFile, "BONUS_SPEED", val, STR_SIZE, "YES");
+ setWidgetCheckStatus(check[BONUS_SPEED], isYesOrNO(val));
+ loadValueFromConfigFile(configFile, "BONUS_SHOT", val, STR_SIZE, "YES");
+ setWidgetCheckStatus(check[BONUS_SHOT], isYesOrNO(val));
+ loadValueFromConfigFile(configFile, "BONUS_TELEPORT", val, STR_SIZE, "YES");
+ setWidgetCheckStatus(check[BONUS_TELEPORT], isYesOrNO(val));
+ loadValueFromConfigFile(configFile, "BONUS_GHOST", val, STR_SIZE, "YES");
+ setWidgetCheckStatus(check[BONUS_GHOST], isYesOrNO(val));
+ loadValueFromConfigFile(configFile, "BONUS_4X", val, STR_SIZE, "YES");
+ setWidgetCheckStatus(check[BONUS_4X], isYesOrNO(val));
+ loadValueFromConfigFile(configFile, "BONUS_HIDDEN", val, STR_SIZE, "YES");
+ setWidgetCheckStatus(check[BONUS_HIDDEN], isYesOrNO(val));
+
+ loadValueFromConfigFile(configFile, "AI", val, STR_SIZE, "NO");
+ setWidgetCheckStatus(check_ai, isYesOrNO(val));
#ifndef NO_SOUND
- loadValueFromConfigFile(configFile, "MUSIC", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check_music, isYesOrNO(val));
+ loadValueFromConfigFile(configFile, "MUSIC", val, STR_SIZE, "YES");
+ setWidgetCheckStatus(check_music, isYesOrNO(val));
- loadValueFromConfigFile(configFile, "SOUND", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check_sound, isYesOrNO(val));
+ loadValueFromConfigFile(configFile, "SOUND", val, STR_SIZE, "YES");
+ setWidgetCheckStatus(check_sound, isYesOrNO(val));
#endif
- loadValueFromConfigFile(configFile, "ARENA", val, STR_SIZE, "FAGN");
- setChoiceArena(getArenaFileFormNetName(val));
+ loadValueFromConfigFile(configFile, "ARENA", val, STR_SIZE, "FAGN");
+ setChoiceArena( getArenaFileFormNetName(val) );
- saveTextFile(configFile);
+ saveTextFile(configFile);
}
-static void
-saveAndDestroyConfigFile()
+static void saveAndDestroyConfigFile()
{
- if (configFile == NULL) {
- fprintf(stderr,
- _
- ("I am unable to save configure file, because config file was not initialised!\n"));
-
- return;
- }
-
- setValueInConfigFile(configFile, "COUNT_ROUND",
- getTextFromWidgetTextfield(textfield_count_cound));
- setValueInConfigFile(configFile, "NAME_PLAYER_RIGHT",
- getTextFromWidgetTextfield(textfield_name_player1));
- setValueInConfigFile(configFile, "NAME_PLAYER_LEFT",
- getTextFromWidgetTextfield(textfield_name_player2));
-
- setValueInConfigFile(configFile, "GUN_DUAL_SIMPLE",
- getYesOrNo(getWidgetCheckStatus
- (check[GUN_DUAL_SIMPLE])));
- setValueInConfigFile(configFile, "GUN_SCATTER",
- getYesOrNo(getWidgetCheckStatus(check[GUN_SCATTER])));
- setValueInConfigFile(configFile, "GUN_TOMMY",
- getYesOrNo(getWidgetCheckStatus(check[GUN_TOMMY])));
- setValueInConfigFile(configFile, "GUN_LASSER",
- getYesOrNo(getWidgetCheckStatus(check[GUN_LASSER])));
- setValueInConfigFile(configFile, "GUN_MINE",
- getYesOrNo(getWidgetCheckStatus(check[GUN_MINE])));
- setValueInConfigFile(configFile, "GUN_BOMBBALL",
- getYesOrNo(getWidgetCheckStatus
- (check[GUN_BOMBBALL])));
-
- setValueInConfigFile(configFile, "BONUS_SPEED",
- getYesOrNo(getWidgetCheckStatus(check[BONUS_SPEED])));
- setValueInConfigFile(configFile, "BONUS_SHOT",
- getYesOrNo(getWidgetCheckStatus(check[BONUS_SHOT])));
- setValueInConfigFile(configFile, "BONUS_TELEPORT",
- getYesOrNo(getWidgetCheckStatus
- (check[BONUS_TELEPORT])));
- setValueInConfigFile(configFile, "BONUS_GHOST",
- getYesOrNo(getWidgetCheckStatus(check[BONUS_GHOST])));
- setValueInConfigFile(configFile, "BONUS_4X",
- getYesOrNo(getWidgetCheckStatus(check[BONUS_4X])));
- setValueInConfigFile(configFile, "BONUS_HIDDEN",
- getYesOrNo(getWidgetCheckStatus
- (check[BONUS_HIDDEN])));
-
- setValueInConfigFile(configFile, "AI",
- getYesOrNo(getWidgetCheckStatus(check_ai)));
+ if( configFile == NULL )
+ {
+ fprintf(stderr, _("I am unable to save configure file, because config file was not initialised!\n"));
+
+ return;
+ }
+
+ setValueInConfigFile(configFile, "COUNT_ROUND", getTextFromWidgetTextfield(textfield_count_cound));
+ setValueInConfigFile(configFile, "NAME_PLAYER_RIGHT", getTextFromWidgetTextfield(textfield_name_player1));
+ setValueInConfigFile(configFile, "NAME_PLAYER_LEFT", getTextFromWidgetTextfield(textfield_name_player2));
+
+ setValueInConfigFile(configFile, "GUN_DUAL_SIMPLE", getYesOrNo(getWidgetCheckStatus(check[GUN_DUAL_SIMPLE])));
+ setValueInConfigFile(configFile, "GUN_SCATTER", getYesOrNo(getWidgetCheckStatus(check[GUN_SCATTER])));
+ setValueInConfigFile(configFile, "GUN_TOMMY", getYesOrNo(getWidgetCheckStatus(check[GUN_TOMMY])));
+ setValueInConfigFile(configFile, "GUN_LASSER", getYesOrNo(getWidgetCheckStatus(check[GUN_LASSER])));
+ setValueInConfigFile(configFile, "GUN_MINE", getYesOrNo(getWidgetCheckStatus(check[GUN_MINE])));
+ setValueInConfigFile(configFile, "GUN_BOMBBALL", getYesOrNo(getWidgetCheckStatus(check[GUN_BOMBBALL])));
+
+ setValueInConfigFile(configFile, "BONUS_SPEED", getYesOrNo(getWidgetCheckStatus(check[BONUS_SPEED])));
+ setValueInConfigFile(configFile, "BONUS_SHOT", getYesOrNo(getWidgetCheckStatus(check[BONUS_SHOT])));
+ setValueInConfigFile(configFile, "BONUS_TELEPORT", getYesOrNo(getWidgetCheckStatus(check[BONUS_TELEPORT])));
+ setValueInConfigFile(configFile, "BONUS_GHOST", getYesOrNo(getWidgetCheckStatus(check[BONUS_GHOST])));
+ setValueInConfigFile(configFile, "BONUS_4X", getYesOrNo(getWidgetCheckStatus(check[BONUS_4X])));
+ setValueInConfigFile(configFile, "BONUS_HIDDEN", getYesOrNo(getWidgetCheckStatus(check[BONUS_HIDDEN])));
+
+ setValueInConfigFile(configFile, "AI", getYesOrNo(getWidgetCheckStatus(check_ai)));
#ifndef NO_SOUND
- setValueInConfigFile(configFile, "MUSIC",
- getYesOrNo(getWidgetCheckStatus(check_music)));
- setValueInConfigFile(configFile, "SOUND",
- getYesOrNo(getWidgetCheckStatus(check_sound)));
+ setValueInConfigFile(configFile, "MUSIC", getYesOrNo(getWidgetCheckStatus(check_music)));
+ setValueInConfigFile(configFile, "SOUND", getYesOrNo(getWidgetCheckStatus(check_sound)));
#endif
- setValueInConfigFile(configFile, "ARENA",
- getArenaNetName(getChoiceArena()));
- //TODO
+ setValueInConfigFile(configFile, "ARENA", getArenaNetName(getChoiceArena()));
+ //TODO
- saveTextFile(configFile);
- destroyTextFile(configFile);
+ saveTextFile(configFile);
+ destroyTextFile(configFile);
}
-void
-initScreenSetting()
+void initScreenSetting()
{
- image_t *image;
- int i;
+ image_t *image;
+ int i;
- image = getImage(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = newWidgetImage(0, 0, image);
+ image = getImage(IMAGE_GROUP_BASE, "screen_main");
+ image_backgorund = newWidgetImage(0, 0, image);
- button_back =
- newWidgetButton(_("back"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100,
- eventWidget);
- button_keys =
- newWidgetButton(_("controls"), WINDOW_SIZE_X - 200,
- button_back->y - WIDGET_BUTTON_HEIGHT - 10,
- eventWidget);
+ button_back = newWidgetButton(_("back"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget);
+ button_keys = newWidgetButton(_("controls"), WINDOW_SIZE_X - 200, button_back->y - WIDGET_BUTTON_HEIGHT - 10, eventWidget);
#ifndef NO_SOUND
- label_music =
- newWidgetLabel(_("Music:"), 100, WINDOW_SIZE_Y - 85, WIDGET_LABEL_LEFT);
- check_music =
- newWidgetCheck(label_music->x + label_music->w + 10, WINDOW_SIZE_Y - 80,
- isMusicActive(), eventWidget);
- label_sound =
- newWidgetLabel(_("Sound:"), check_music->x + WIDGET_CHECK_WIDTH + 10,
- WINDOW_SIZE_Y - 85, WIDGET_LABEL_LEFT);
- check_sound =
- newWidgetCheck(label_sound->x + label_sound->w + 10, WINDOW_SIZE_Y - 80,
- isSoundActive(), eventWidget);
- label_ai =
- newWidgetLabel("AI:", check_sound->x + WIDGET_CHECK_WIDTH + 10,
- WINDOW_SIZE_Y - 85, WIDGET_LABEL_LEFT);
+ label_music = newWidgetLabel(_("Music:"), 100, WINDOW_SIZE_Y-85, WIDGET_LABEL_LEFT);
+ check_music = newWidgetCheck(label_music->x + label_music->w + 10,
+ WINDOW_SIZE_Y-80, isMusicActive() , eventWidget);
+ label_sound = newWidgetLabel(_("Sound:"), check_music->x + WIDGET_CHECK_WIDTH + 10,
+ WINDOW_SIZE_Y-85, WIDGET_LABEL_LEFT);
+ check_sound = newWidgetCheck(label_sound->x + label_sound->w + 10,
+ WINDOW_SIZE_Y-80, isSoundActive() , eventWidget);
+ label_ai = newWidgetLabel("AI:", check_sound->x + WIDGET_CHECK_WIDTH + 10, WINDOW_SIZE_Y-85, WIDGET_LABEL_LEFT);
#else
- label_ai =
- newWidgetLabel("AI:", 100, WINDOW_SIZE_Y - 85, WIDGET_LABEL_LEFT);
+ label_ai = newWidgetLabel("AI:", 100, WINDOW_SIZE_Y-85, WIDGET_LABEL_LEFT);
#endif
- check_ai =
- newWidgetCheck(label_ai->x + label_ai->w + 10, WINDOW_SIZE_Y - 80,
- FALSE, eventWidget);
-
- label_count_round =
- newWidgetLabel(_("No. of rounds:"), 100, WINDOW_SIZE_Y - 200,
- WIDGET_LABEL_LEFT);
- label_name_player1 =
- newWidgetLabel(_("Player 1:"), 100, WINDOW_SIZE_Y - 160,
- WIDGET_LABEL_LEFT);
- label_name_player2 =
- newWidgetLabel(_("Player 2:"), 100, WINDOW_SIZE_Y - 120,
- WIDGET_LABEL_LEFT);
-
- textfield_count_cound = newWidgetTextfield(getParamElse("--count", "15"),
- WIDGET_TEXTFIELD_FILTER_NUM,
- 110 + label_count_round->w,
- WINDOW_SIZE_Y - 200);
-
- textfield_name_player1 =
- newWidgetTextfield(getParamElse("--name1", NAME_PLAYER_RIGHT),
- WIDGET_TEXTFIELD_FILTER_ALPHANUM,
- 110 + label_count_round->w, WINDOW_SIZE_Y - 160);
-
- textfield_name_player2 =
- newWidgetTextfield(getParamElse("--name2", NAME_PLAYER_LEFT),
- WIDGET_TEXTFIELD_FILTER_ALPHANUM,
- 110 + label_count_round->w, WINDOW_SIZE_Y - 120);
-
- for (i = GUN_DUAL_SIMPLE; i <= GUN_BOMBBALL; i++) {
- int x = 0;
- int y = 0;
-
- if (i >= GUN_DUAL_SIMPLE && i <= GUN_TOMMY) {
- x = 100;
- y = 200 + (i - GUN_DUAL_SIMPLE) * 50;
- }
-
- if (i >= GUN_LASSER && i <= GUN_BOMBBALL) {
- x = 250;
- y = 200 + (i - GUN_LASSER) * 50;
- }
-
- check[i] = newWidgetCheck(x, y, TRUE, NULL);
- }
-
- for (i = BONUS_SPEED; i <= BONUS_HIDDEN; i++) {
- int x = 0;
- int y = 0;
-
- if (i >= BONUS_SPEED && i <= BONUS_TELEPORT) {
- x = 430;
- y = 200 + (i - BONUS_SPEED) * 50;
- }
-
- if (i >= BONUS_GHOST && i <= BONUS_HIDDEN) {
- x = 580;
- y = 200 + (i - BONUS_GHOST) * 50;
- }
-
- check[i] = newWidgetCheck(x, y, TRUE, NULL);
- }
-
- image_gun_dual_revolver =
- newWidgetImage(110 + WIDGET_CHECK_WIDTH, 200,
- getImage(IMAGE_GROUP_BASE, "panel_dual"));
- image_gun_scatter =
- newWidgetImage(110 + WIDGET_CHECK_WIDTH, 250,
- getImage(IMAGE_GROUP_BASE, "panel_scatter"));
- image_gun_tommy =
- newWidgetImage(110 + WIDGET_CHECK_WIDTH, 300,
- getImage(IMAGE_GROUP_BASE, "panel_tommy"));
- image_gun_lasser =
- newWidgetImage(260 + WIDGET_CHECK_WIDTH, 200,
- getImage(IMAGE_GROUP_BASE, "panel_lasser"));
- image_gun_mine =
- newWidgetImage(260 + WIDGET_CHECK_WIDTH, 250,
- getImage(IMAGE_GROUP_BASE, "panel_mine"));
- image_gun_bombball =
- newWidgetImage(260 + WIDGET_CHECK_WIDTH, 300,
- getImage(IMAGE_GROUP_BASE, "panel_bombball"));
-
- image_bonus_speed =
- newWidgetImage(430 + WIDGET_CHECK_WIDTH, 200,
- getImage(IMAGE_GROUP_BASE, "panel_speed"));;
- image_bonus_shot =
- newWidgetImage(430 + WIDGET_CHECK_WIDTH, 250,
- getImage(IMAGE_GROUP_BASE, "panel_shot"));;
- image_bonus_teleport =
- newWidgetImage(430 + WIDGET_CHECK_WIDTH, 300,
- getImage(IMAGE_GROUP_BASE, "panel_teleport"));;
- image_bonus_ghost =
- newWidgetImage(580 + WIDGET_CHECK_WIDTH, 200,
- getImage(IMAGE_GROUP_BASE, "panel_ghost"));;
- image_bonus_4x =
- newWidgetImage(580 + WIDGET_CHECK_WIDTH, 250,
- getImage(IMAGE_GROUP_BASE, "panel_4x"));;
- image_bonus_hidden =
- newWidgetImage(580 + WIDGET_CHECK_WIDTH, 300,
- getImage(IMAGE_GROUP_BASE, "panel_hidden"));;
-
- registerScreen(newScreen("setting", startScreenSetting, eventScreenSetting,
- drawScreenSetting, stopScreenSetting));
-
- initSettingFile();
+ check_ai = newWidgetCheck(label_ai->x + label_ai->w + 10, WINDOW_SIZE_Y-80, FALSE, eventWidget);
+
+ label_count_round = newWidgetLabel(_("No. of rounds:"), 100, WINDOW_SIZE_Y-200, WIDGET_LABEL_LEFT);
+ label_name_player1 = newWidgetLabel(_("Player 1:"), 100, WINDOW_SIZE_Y-160, WIDGET_LABEL_LEFT);
+ label_name_player2 = newWidgetLabel(_("Player 2:"), 100, WINDOW_SIZE_Y-120, WIDGET_LABEL_LEFT);
+
+ textfield_count_cound = newWidgetTextfield(
+ getParamElse("--count", "15"),
+ WIDGET_TEXTFIELD_FILTER_NUM,
+ 110+label_count_round->w,
+ WINDOW_SIZE_Y-200);
+
+ textfield_name_player1 = newWidgetTextfield(
+ getParamElse("--name1", NAME_PLAYER_RIGHT),
+ WIDGET_TEXTFIELD_FILTER_ALPHANUM,
+ 110+label_count_round->w,
+ WINDOW_SIZE_Y-160);
+
+ textfield_name_player2 = newWidgetTextfield(
+ getParamElse("--name2", NAME_PLAYER_LEFT),
+ WIDGET_TEXTFIELD_FILTER_ALPHANUM,
+ 110+label_count_round->w,
+ WINDOW_SIZE_Y-120);
+
+ for( i = GUN_DUAL_SIMPLE ; i <= GUN_BOMBBALL ; i++ )
+ {
+ int x = 0;
+ int y = 0;
+
+ if( i >= GUN_DUAL_SIMPLE && i <= GUN_TOMMY )
+ {
+ x = 100;
+ y = 200 + ( i - GUN_DUAL_SIMPLE ) * 50;
+ }
+
+ if( i >= GUN_LASSER && i <= GUN_BOMBBALL )
+ {
+ x = 250;
+ y = 200 + ( i - GUN_LASSER ) * 50;
+ }
+
+ check[i] = newWidgetCheck(x, y, TRUE, NULL);
+ }
+
+ for( i = BONUS_SPEED ; i <= BONUS_HIDDEN ; i++ )
+ {
+ int x = 0;
+ int y = 0;
+
+ if( i >= BONUS_SPEED && i <= BONUS_TELEPORT )
+ {
+ x = 430;
+ y = 200 + ( i - BONUS_SPEED ) * 50;
+ }
+
+ if( i >= BONUS_GHOST && i <= BONUS_HIDDEN )
+ {
+ x = 580;
+ y = 200 + ( i - BONUS_GHOST ) * 50;
+ }
+
+ check[i] = newWidgetCheck(x, y, TRUE, NULL);
+ }
+
+ image_gun_dual_revolver = newWidgetImage(110 + WIDGET_CHECK_WIDTH, 200, getImage(IMAGE_GROUP_BASE, "panel_dual"));
+ image_gun_scatter = newWidgetImage(110 + WIDGET_CHECK_WIDTH, 250, getImage(IMAGE_GROUP_BASE, "panel_scatter"));
+ image_gun_tommy = newWidgetImage(110 + WIDGET_CHECK_WIDTH, 300, getImage(IMAGE_GROUP_BASE, "panel_tommy"));
+ image_gun_lasser = newWidgetImage(260 + WIDGET_CHECK_WIDTH, 200, getImage(IMAGE_GROUP_BASE, "panel_lasser"));
+ image_gun_mine = newWidgetImage(260 + WIDGET_CHECK_WIDTH, 250, getImage(IMAGE_GROUP_BASE, "panel_mine"));
+ image_gun_bombball = newWidgetImage(260 + WIDGET_CHECK_WIDTH, 300, getImage(IMAGE_GROUP_BASE, "panel_bombball"));
+
+ image_bonus_speed = newWidgetImage(430 + WIDGET_CHECK_WIDTH, 200, getImage(IMAGE_GROUP_BASE, "panel_speed"));;
+ image_bonus_shot = newWidgetImage(430 + WIDGET_CHECK_WIDTH, 250, getImage(IMAGE_GROUP_BASE, "panel_shot"));;
+ image_bonus_teleport = newWidgetImage(430 + WIDGET_CHECK_WIDTH, 300, getImage(IMAGE_GROUP_BASE, "panel_teleport"));;
+ image_bonus_ghost = newWidgetImage(580 + WIDGET_CHECK_WIDTH, 200, getImage(IMAGE_GROUP_BASE, "panel_ghost"));;
+ image_bonus_4x = newWidgetImage(580 + WIDGET_CHECK_WIDTH, 250, getImage(IMAGE_GROUP_BASE, "panel_4x"));;
+ image_bonus_hidden = newWidgetImage(580 + WIDGET_CHECK_WIDTH, 300, getImage(IMAGE_GROUP_BASE, "panel_hidden"));;
+
+ registerScreen( newScreen("setting", startScreenSetting, eventScreenSetting,
+ drawScreenSetting, stopScreenSetting) );
+
+ initSettingFile();
#ifndef NO_SOUND
- eventWidget(check_music);
- eventWidget(check_sound);
+ eventWidget(check_music);
+ eventWidget(check_sound);
#endif
}
-void
-getSettingNameRight(char *s)
+void getSettingNameRight(char *s)
{
- strcpy(s, getTextFromWidgetTextfield(textfield_name_player1));
+ strcpy(s, getTextFromWidgetTextfield(textfield_name_player1));
}
-void
-getSettingNameLeft(char *s)
+void getSettingNameLeft(char *s)
{
- if (getWidgetCheckStatus(check_ai)) {
- strcpy(s, NAME_AI);
- }
- else {
- strcpy(s, getTextFromWidgetTextfield(textfield_name_player2));
- }
+ if( getWidgetCheckStatus(check_ai) )
+ {
+ strcpy(s, NAME_AI);
+ }
+ else
+ {
+ strcpy(s, getTextFromWidgetTextfield(textfield_name_player2));
+ }
}
-void
-getSettingCountRound(int *n)
+void getSettingCountRound(int *n)
{
- *n = atoi(getTextFromWidgetTextfield(textfield_count_cound));
+ *n = atoi( getTextFromWidgetTextfield(textfield_count_cound) );
}
-bool_t
-isSettingAI()
+bool_t isSettingAI()
{
- return getWidgetCheckStatus(check_ai);
+ return getWidgetCheckStatus(check_ai);
}
-bool_t
-isSettingAnyItem()
+bool_t isSettingAnyItem()
{
- int i;
-
- for (i = GUN_DUAL_SIMPLE; i <= GUN_BOMBBALL; i++) {
- if (getWidgetCheckStatus(check[i]) == TRUE) {
- return TRUE;
- }
- }
-
- for (i = BONUS_SPEED; i < BONUS_HIDDEN; i++) {
- if (getWidgetCheckStatus(check[i]) == TRUE) {
- return TRUE;
- }
- }
-
- return FALSE;
+ int i;
+
+ for( i = GUN_DUAL_SIMPLE ; i <= GUN_BOMBBALL ; i++ )
+ {
+ if( getWidgetCheckStatus(check[i]) == TRUE )
+ {
+ return TRUE;
+ }
+ }
+
+ for( i = BONUS_SPEED ; i < BONUS_HIDDEN ; i++ )
+ {
+ if( getWidgetCheckStatus(check[i]) == TRUE )
+ {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
}
-bool_t
-isSettingItem(int item)
+bool_t isSettingItem(int item)
{
- return getWidgetCheckStatus(check[item]);
+ return getWidgetCheckStatus(check[item]);
}
-void
-quitScreenSetting()
+void quitScreenSetting()
{
- int i;
+ int i;
- saveAndDestroyConfigFile();
+ saveAndDestroyConfigFile();
- destroyWidgetImage(image_backgorund);
+ destroyWidgetImage(image_backgorund);
- destroyWidgetLabel(label_count_round);
- destroyWidgetLabel(label_name_player1);
- destroyWidgetLabel(label_ai);
+ destroyWidgetLabel(label_count_round);
+ destroyWidgetLabel(label_name_player1);
+ destroyWidgetLabel(label_ai);
#ifndef NO_SOUND
- destroyWidgetLabel(label_music);
- destroyWidgetLabel(label_sound);
+ destroyWidgetLabel(label_music);
+ destroyWidgetLabel(label_sound);
#endif
- destroyWidgetLabel(label_name_player2);
- destroyWidgetTextfield(textfield_name_player2);
-
- destroyWidgetTextfield(textfield_name_player1);
- destroyWidgetTextfield(textfield_count_cound);
-
- destroyWidgetImage(image_gun_dual_revolver);
- destroyWidgetImage(image_gun_scatter);
- destroyWidgetImage(image_gun_tommy);
- destroyWidgetImage(image_gun_lasser);
- destroyWidgetImage(image_gun_mine);
- destroyWidgetImage(image_gun_bombball);
-
- destroyWidgetImage(image_bonus_speed);
- destroyWidgetImage(image_bonus_shot);
- destroyWidgetImage(image_bonus_teleport);
- destroyWidgetImage(image_bonus_ghost);
- destroyWidgetImage(image_bonus_4x);
- destroyWidgetImage(image_bonus_hidden);
+ destroyWidgetLabel(label_name_player2);
+ destroyWidgetTextfield(textfield_name_player2);
+
+ destroyWidgetTextfield(textfield_name_player1);
+ destroyWidgetTextfield(textfield_count_cound);
+
+ destroyWidgetImage(image_gun_dual_revolver);
+ destroyWidgetImage(image_gun_scatter);
+ destroyWidgetImage(image_gun_tommy);
+ destroyWidgetImage(image_gun_lasser);
+ destroyWidgetImage(image_gun_mine);
+ destroyWidgetImage(image_gun_bombball);
+
+ destroyWidgetImage(image_bonus_speed);
+ destroyWidgetImage(image_bonus_shot);
+ destroyWidgetImage(image_bonus_teleport);
+ destroyWidgetImage(image_bonus_ghost);
+ destroyWidgetImage(image_bonus_4x);
+ destroyWidgetImage(image_bonus_hidden);
#ifndef NO_SOUND
- destroyWidgetCheck(check_music);
- destroyWidgetCheck(check_sound);
+ destroyWidgetCheck(check_music);
+ destroyWidgetCheck(check_sound);
#endif
- destroyWidgetCheck(check_ai);
+ destroyWidgetCheck(check_ai);
- for (i = GUN_DUAL_SIMPLE; i <= GUN_BOMBBALL; i++) {
- destroyWidgetCheck(check[i]);
- }
+ for( i = GUN_DUAL_SIMPLE ; i <= GUN_BOMBBALL ; i++ )
+ {
+ destroyWidgetCheck(check[i]);
+ }
- for (i = BONUS_SPEED; i <= BONUS_HIDDEN; i++) {
- destroyWidgetCheck(check[i]);
- }
+ for( i = BONUS_SPEED ; i <= BONUS_HIDDEN ; i++ )
+ {
+ destroyWidgetCheck(check[i]);
+ }
- destroyWidgetButton(button_back);
- destroyWidgetButton(button_keys);
+ destroyWidgetButton(button_back);
+ destroyWidgetButton(button_keys);
}
diff --git a/src/screen/screen_setting.c~ b/src/screen/screen_setting.c~
deleted file mode 100644
index c79acaf..0000000
--- a/src/screen/screen_setting.c~
+++ /dev/null
@@ -1,553 +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 "configFile.h"
-#include "interface.h"
-#include "screen.h"
-#include "image.h"
-
-#ifndef NO_SOUND
-#include "music.h"
-#include "sound.h"
-#endif
-
-#include "screen_mainMenu.h"
-#include "screen_setting.h"
-#include "screen_settingKeys.h"
-#include "screen_settingKeys.h"
-#include "screen_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"
-
-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 *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 textFile_t *configFile;
-
-void startScreenSetting()
-{
-#ifndef NO_SOUND
- playMusic("menu", MUSIC_GROUP_BASE);
-#endif
-}
-
-void drawScreenSetting()
-{
- int i;
-
- drawWidgetImage(image_backgorund);
-
- drawWidgetLabel(label_count_round);
- drawWidgetLabel(label_name_player1);
- drawWidgetLabel(label_ai);
-
-#ifndef NO_SOUND
- drawWidgetLabel(label_music);
- drawWidgetLabel(label_sound);
-#endif
-
- drawWidgetTextfield(textfield_count_cound);
- drawWidgetTextfield(textfield_name_player1);
-
- if ( getWidgetCheckStatus(check_ai) == FALSE )
- {
- drawWidgetLabel(label_name_player2);
- drawWidgetTextfield(textfield_name_player2);
- }
-
- drawWidgetImage(image_gun_dual_revolver);
- drawWidgetImage(image_gun_scatter);
- drawWidgetImage(image_gun_tommy);
- drawWidgetImage(image_gun_lasser);
- drawWidgetImage(image_gun_mine);
- drawWidgetImage(image_gun_bombball);
-
- drawWidgetImage(image_bonus_speed);
- drawWidgetImage(image_bonus_shot);
- drawWidgetImage(image_bonus_teleport);
- drawWidgetImage(image_bonus_ghost);
- drawWidgetImage(image_bonus_4x);
- drawWidgetImage(image_bonus_hidden);
-
-#ifndef NO_SOUND
- drawWidgetCheck(check_music);
- drawWidgetCheck(check_sound);
-#endif
-
- for( i = GUN_DUAL_SIMPLE ; i <= GUN_BOMBBALL ; i++ )
- {
- drawWidgetCheck(check[i]);
- }
-
- for( i = BONUS_SPEED ; i <= BONUS_HIDDEN ; i++ )
- {
- drawWidgetCheck(check[i]);
- }
-
- drawWidgetCheck(check_ai);
-
- drawWidgetButton(button_back);
- drawWidgetButton(button_keys);
-}
-
-void eventScreenSetting()
-{
- int i;
-
- eventWidgetTextfield(textfield_count_cound);
- eventWidgetTextfield(textfield_name_player1);
-
- if ( getWidgetCheckStatus(check_ai) == FALSE )
- {
- eventWidgetTextfield(textfield_name_player2);
- }
-
-#ifndef NO_SOUND
- eventWidgetCheck(check_music);
- eventWidgetCheck(check_sound);
-#endif
-
- for( i = GUN_DUAL_SIMPLE ; i <= GUN_BOMBBALL ; i++ )
- {
- eventWidgetCheck(check[i]);
- }
-
- for( i = BONUS_SPEED ; i <= BONUS_HIDDEN ; i++ )
- {
- eventWidgetCheck(check[i]);
- }
-
- eventWidgetCheck(check_ai);
-
- eventWidgetButton(button_back);
- eventWidgetButton(button_keys);
-}
-
-void stopScreenSetting()
-{
-}
-
-static void eventWidget(void *p)
-{
- widget_t *button;
- widget_t *check;
-
- button = (widget_t *)(p);
- check = (widget_t *)(p);
-
- if( button == button_back )
- {
- setScreen("mainMenu");
- }
- if( button == button_keys )
- {
- setScreen("settingKeys");
- }
-
-#ifndef NO_SOUND
- if( check == check_music )
- {
- setMusicActive( getWidgetCheckStatus(check_music) );
- }
-
- if( check == check_sound )
- {
- setSoundActive( getWidgetCheckStatus(check_sound) );
- }
-#endif
-}
-
-static void initSettingFile()
-{
- char path[STR_PATH_SIZE];
- char val[STR_SIZE];
-
- sprintf(path, "%s/tuxanci.conf", getHomeDirector());
-
- configFile = loadTextFile(path);
-
- if( configFile == NULL )
- {
- fprintf(stderr, _("I am unable to load: \"%s\" !\n"), path);
- fprintf(stderr, _("Creating: \"%s\"\n"), path);
-
- configFile = newTextFile(path);
- }
-
- if( configFile == NULL )
- {
- fprintf(stderr, _("I was unable to create: \"%s\" !\n"), path);
- return;
- }
-
- loadValueFromConfigFile(configFile, "COUNT_ROUND", val, STR_SIZE, "15");
- setWidgetTextFiledText(textfield_count_cound, val);
-
- loadValueFromConfigFile(configFile, "NAME_PLAYER_RIGHT", val, STR_SIZE, NAME_PLAYER_RIGHT);
- setWidgetTextFiledText(textfield_name_player1, val);
-
- loadValueFromConfigFile(configFile, "NAME_PLAYER_LEFT", val, STR_SIZE, NAME_PLAYER_LEFT);
- setWidgetTextFiledText(textfield_name_player2, val);
-
- loadValueFromConfigFile(configFile, "GUN_DUAL_SIMPLE", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[GUN_DUAL_SIMPLE], isYesOrNO(val));
- loadValueFromConfigFile(configFile, "GUN_SCATTER", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[GUN_SCATTER], isYesOrNO(val));
- loadValueFromConfigFile(configFile, "GUN_TOMMY", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[GUN_TOMMY], isYesOrNO(val));
- loadValueFromConfigFile(configFile, "GUN_LASSER", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[GUN_LASSER], isYesOrNO(val));
- loadValueFromConfigFile(configFile, "GUN_MINE", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[GUN_MINE], isYesOrNO(val));
- loadValueFromConfigFile(configFile, "GUN_BOMBBALL", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[GUN_BOMBBALL], isYesOrNO(val));
-
- loadValueFromConfigFile(configFile, "BONUS_SPEED", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[BONUS_SPEED], isYesOrNO(val));
- loadValueFromConfigFile(configFile, "BONUS_SHOT", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[BONUS_SHOT], isYesOrNO(val));
- loadValueFromConfigFile(configFile, "BONUS_TELEPORT", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[BONUS_TELEPORT], isYesOrNO(val));
- loadValueFromConfigFile(configFile, "BONUS_GHOST", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[BONUS_GHOST], isYesOrNO(val));
- loadValueFromConfigFile(configFile, "BONUS_4X", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[BONUS_4X], isYesOrNO(val));
- loadValueFromConfigFile(configFile, "BONUS_HIDDEN", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check[BONUS_HIDDEN], isYesOrNO(val));
-
- loadValueFromConfigFile(configFile, "AI", val, STR_SIZE, "NO");
- setWidgetCheckStatus(check_ai, isYesOrNO(val));
-
-#ifndef NO_SOUND
- loadValueFromConfigFile(configFile, "MUSIC", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check_music, isYesOrNO(val));
-
- loadValueFromConfigFile(configFile, "SOUND", val, STR_SIZE, "YES");
- setWidgetCheckStatus(check_sound, isYesOrNO(val));
-#endif
-
- loadValueFromConfigFile(configFile, "ARENA", val, STR_SIZE, "FAGN");
- setChoiceArena( getArenaFileFormNetName(val) );
-
- saveTextFile(configFile);
-}
-
-static void saveAndDestroyConfigFile()
-{
- if( configFile == NULL )
- {
- fprintf(stderr, _("I am unable to save configure file, because config file was not initialised!\n"));
-
- return;
- }
-
- setValueInConfigFile(configFile, "COUNT_ROUND", getTextFromWidgetTextfield(textfield_count_cound));
- setValueInConfigFile(configFile, "NAME_PLAYER_RIGHT", getTextFromWidgetTextfield(textfield_name_player1));
- setValueInConfigFile(configFile, "NAME_PLAYER_LEFT", getTextFromWidgetTextfield(textfield_name_player2));
-
- setValueInConfigFile(configFile, "GUN_DUAL_SIMPLE", getYesOrNo(getWidgetCheckStatus(check[GUN_DUAL_SIMPLE])));
- setValueInConfigFile(configFile, "GUN_SCATTER", getYesOrNo(getWidgetCheckStatus(check[GUN_SCATTER])));
- setValueInConfigFile(configFile, "GUN_TOMMY", getYesOrNo(getWidgetCheckStatus(check[GUN_TOMMY])));
- setValueInConfigFile(configFile, "GUN_LASSER", getYesOrNo(getWidgetCheckStatus(check[GUN_LASSER])));
- setValueInConfigFile(configFile, "GUN_MINE", getYesOrNo(getWidgetCheckStatus(check[GUN_MINE])));
- setValueInConfigFile(configFile, "GUN_BOMBBALL", getYesOrNo(getWidgetCheckStatus(check[GUN_BOMBBALL])));
-
- setValueInConfigFile(configFile, "BONUS_SPEED", getYesOrNo(getWidgetCheckStatus(check[BONUS_SPEED])));
- setValueInConfigFile(configFile, "BONUS_SHOT", getYesOrNo(getWidgetCheckStatus(check[BONUS_SHOT])));
- setValueInConfigFile(configFile, "BONUS_TELEPORT", getYesOrNo(getWidgetCheckStatus(check[BONUS_TELEPORT])));
- setValueInConfigFile(configFile, "BONUS_GHOST", getYesOrNo(getWidgetCheckStatus(check[BONUS_GHOST])));
- setValueInConfigFile(configFile, "BONUS_4X", getYesOrNo(getWidgetCheckStatus(check[BONUS_4X])));
- setValueInConfigFile(configFile, "BONUS_HIDDEN", getYesOrNo(getWidgetCheckStatus(check[BONUS_HIDDEN])));
-
- setValueInConfigFile(configFile, "AI", getYesOrNo(getWidgetCheckStatus(check_ai)));
-
-#ifndef NO_SOUND
- setValueInConfigFile(configFile, "MUSIC", getYesOrNo(getWidgetCheckStatus(check_music)));
- setValueInConfigFile(configFile, "SOUND", getYesOrNo(getWidgetCheckStatus(check_sound)));
-#endif
-
- setValueInConfigFile(configFile, "ARENA", getArenaNetName(getChoiceArena()));
- //TODO
-
- saveTextFile(configFile);
- destroyTextFile(configFile);
-}
-
-void initScreenSetting()
-{
- image_t *image;
- int i;
-
- image = getImage(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = newWidgetImage(0, 0, image);
-
- button_back = newWidgetButton(_("back"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget);
- button_keys = newWidgetButton(_("controls"), WINDOW_SIZE_X - 200, button_back->y - WIDGET_BUTTON_HEIGHT - 10, eventWidget);
-
-#ifndef NO_SOUND
- label_music = newWidgetLabel(_("Music:"), 100, WINDOW_SIZE_Y-85, WIDGET_LABEL_LEFT);
- check_music = newWidgetCheck(label_music->x + label_music->w + 10,
- WINDOW_SIZE_Y-80, isMusicActive() , eventWidget);
- label_sound = newWidgetLabel(_("Sound:"), check_music->x + WIDGET_CHECK_WIDTH + 10,
- WINDOW_SIZE_Y-85, WIDGET_LABEL_LEFT);
- check_sound = newWidgetCheck(label_sound->x + label_sound->w + 10,
- WINDOW_SIZE_Y-80, isSoundActive() , eventWidget);
- label_ai = newWidgetLabel("AI:", check_sound->x + WIDGET_CHECK_WIDTH + 10, WINDOW_SIZE_Y-85, WIDGET_LABEL_LEFT);
-#else
- label_ai = newWidgetLabel("AI:", 100, WINDOW_SIZE_Y-85, WIDGET_LABEL_LEFT);
-#endif
-
- check_ai = newWidgetCheck(label_ai->x + label_ai->w + 10, WINDOW_SIZE_Y-80, FALSE, eventWidget);
-
- label_count_round = newWidgetLabel(_("No. of rounds:"), 100, WINDOW_SIZE_Y-200, WIDGET_LABEL_LEFT);
- label_name_player1 = newWidgetLabel(_("Player 1:"), 100, WINDOW_SIZE_Y-160, WIDGET_LABEL_LEFT);
- label_name_player2 = newWidgetLabel(_("Player 2:"), 100, WINDOW_SIZE_Y-120, WIDGET_LABEL_LEFT);
-
- textfield_count_cound = newWidgetTextfield(
- getParamElse("--count", "15"),
- WIDGET_TEXTFIELD_FILTER_NUM,
- 110+label_count_round->w,
- WINDOW_SIZE_Y-200);
-
- textfield_name_player1 = newWidgetTextfield(
- getParamElse("--name1", NAME_PLAYER_RIGHT),
- WIDGET_TEXTFIELD_FILTER_ALPHANUM,
- 110+label_count_round->w,
- WINDOW_SIZE_Y-160);
-
- textfield_name_player2 = newWidgetTextfield(
- getParamElse("--name2", NAME_PLAYER_LEFT),
- WIDGET_TEXTFIELD_FILTER_ALPHANUM,
- 110+label_count_round->w,
- WINDOW_SIZE_Y-120);
-
- for( i = GUN_DUAL_SIMPLE ; i <= GUN_BOMBBALL ; i++ )
- {
- int x = 0;
- int y = 0;
-
- if( i >= GUN_DUAL_SIMPLE && i <= GUN_TOMMY )
- {
- x = 100;
- y = 200 + ( i - GUN_DUAL_SIMPLE ) * 50;
- }
-
- if( i >= GUN_LASSER && i <= GUN_BOMBBALL )
- {
- x = 250;
- y = 200 + ( i - GUN_LASSER ) * 50;
- }
-
- check[i] = newWidgetCheck(x, y, TRUE, NULL);
- }
-
- for( i = BONUS_SPEED ; i <= BONUS_HIDDEN ; i++ )
- {
- int x = 0;
- int y = 0;
-
- if( i >= BONUS_SPEED && i <= BONUS_TELEPORT )
- {
- x = 430;
- y = 200 + ( i - BONUS_SPEED ) * 50;
- }
-
- if( i >= BONUS_GHOST && i <= BONUS_HIDDEN )
- {
- x = 580;
- y = 200 + ( i - BONUS_GHOST ) * 50;
- }
-
- check[i] = newWidgetCheck(x, y, TRUE, NULL);
- }
-
- image_gun_dual_revolver = newWidgetImage(110 + WIDGET_CHECK_WIDTH, 200, getImage(IMAGE_GROUP_BASE, "panel_dual"));
- image_gun_scatter = newWidgetImage(110 + WIDGET_CHECK_WIDTH, 250, getImage(IMAGE_GROUP_BASE, "panel_scatter"));
- image_gun_tommy = newWidgetImage(110 + WIDGET_CHECK_WIDTH, 300, getImage(IMAGE_GROUP_BASE, "panel_tommy"));
- image_gun_lasser = newWidgetImage(260 + WIDGET_CHECK_WIDTH, 200, getImage(IMAGE_GROUP_BASE, "panel_lasser"));
- image_gun_mine = newWidgetImage(260 + WIDGET_CHECK_WIDTH, 250, getImage(IMAGE_GROUP_BASE, "panel_mine"));
- image_gun_bombball = newWidgetImage(260 + WIDGET_CHECK_WIDTH, 300, getImage(IMAGE_GROUP_BASE, "panel_bombball"));
-
- image_bonus_speed = newWidgetImage(430 + WIDGET_CHECK_WIDTH, 200, getImage(IMAGE_GROUP_BASE, "panel_speed"));;
- image_bonus_shot = newWidgetImage(430 + WIDGET_CHECK_WIDTH, 250, getImage(IMAGE_GROUP_BASE, "panel_shot"));;
- image_bonus_teleport = newWidgetImage(430 + WIDGET_CHECK_WIDTH, 300, getImage(IMAGE_GROUP_BASE, "panel_teleport"));;
- image_bonus_ghost = newWidgetImage(580 + WIDGET_CHECK_WIDTH, 200, getImage(IMAGE_GROUP_BASE, "panel_ghost"));;
- image_bonus_4x = newWidgetImage(580 + WIDGET_CHECK_WIDTH, 250, getImage(IMAGE_GROUP_BASE, "panel_4x"));;
- image_bonus_hidden = newWidgetImage(580 + WIDGET_CHECK_WIDTH, 300, getImage(IMAGE_GROUP_BASE, "panel_hidden"));;
-
- registerScreen( newScreen("setting", startScreenSetting, eventScreenSetting,
- drawScreenSetting, stopScreenSetting) );
-
- initSettingFile();
-
-#ifndef NO_SOUND
- eventWidget(check_music);
- eventWidget(check_sound);
-#endif
-}
-
-void getSettingNameRight(char *s)
-{
- strcpy(s, getTextFromWidgetTextfield(textfield_name_player1));
-}
-
-void getSettingNameLeft(char *s)
-{
- if( getWidgetCheckStatus(check_ai) )
- {
- strcpy(s, NAME_AI);
- }
- else
- {
- strcpy(s, getTextFromWidgetTextfield(textfield_name_player2));
- }
-}
-
-void getSettingCountRound(int *n)
-{
- *n = atoi( getTextFromWidgetTextfield(textfield_count_cound) );
-}
-
-bool_t isSettingAI()
-{
- return getWidgetCheckStatus(check_ai);
-}
-
-bool_t isSettingAnyItem()
-{
- int i;
-
- for( i = GUN_DUAL_SIMPLE ; i <= GUN_BOMBBALL ; i++ )
- {
- if( getWidgetCheckStatus(check[i]) == TRUE )
- {
- return TRUE;
- }
- }
-
- for( i = BONUS_SPEED ; i < BONUS_HIDDEN ; i++ )
- {
- if( getWidgetCheckStatus(check[i]) == TRUE )
- {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-bool_t isSettingItem(int item)
-{
- return getWidgetCheckStatus(check[item]);
-}
-
-void quitScreenSetting()
-{
- int i;
-
- saveAndDestroyConfigFile();
-
- destroyWidgetImage(image_backgorund);
-
- destroyWidgetLabel(label_count_round);
- destroyWidgetLabel(label_name_player1);
- destroyWidgetLabel(label_ai);
-
-#ifndef NO_SOUND
- destroyWidgetLabel(label_music);
- destroyWidgetLabel(label_sound);
-#endif
- destroyWidgetLabel(label_name_player2);
- destroyWidgetTextfield(textfield_name_player2);
-
- destroyWidgetTextfield(textfield_name_player1);
- destroyWidgetTextfield(textfield_count_cound);
-
- destroyWidgetImage(image_gun_dual_revolver);
- destroyWidgetImage(image_gun_scatter);
- destroyWidgetImage(image_gun_tommy);
- destroyWidgetImage(image_gun_lasser);
- destroyWidgetImage(image_gun_mine);
- destroyWidgetImage(image_gun_bombball);
-
- destroyWidgetImage(image_bonus_speed);
- destroyWidgetImage(image_bonus_shot);
- destroyWidgetImage(image_bonus_teleport);
- destroyWidgetImage(image_bonus_ghost);
- destroyWidgetImage(image_bonus_4x);
- destroyWidgetImage(image_bonus_hidden);
-
-#ifndef NO_SOUND
- destroyWidgetCheck(check_music);
- destroyWidgetCheck(check_sound);
-#endif
-
- destroyWidgetCheck(check_ai);
-
- for( i = GUN_DUAL_SIMPLE ; i <= GUN_BOMBBALL ; i++ )
- {
- destroyWidgetCheck(check[i]);
- }
-
- for( i = BONUS_SPEED ; i <= BONUS_HIDDEN ; i++ )
- {
- destroyWidgetCheck(check[i]);
- }
-
- destroyWidgetButton(button_back);
- destroyWidgetButton(button_keys);
-}
diff --git a/src/screen/screen_settingKeys.c b/src/screen/screen_settingKeys.c
index 6080570..d40db6d 100644
--- a/src/screen/screen_settingKeys.c
+++ b/src/screen/screen_settingKeys.c
@@ -2,7 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
-
+
#include "main.h"
#include "list.h"
#include "tux.h"
@@ -16,410 +16,317 @@
#ifndef NO_SOUND
#include "music.h"
#include "sound.h"
-#endif /* */
+#endif
#include "screen_mainMenu.h"
#include "screen_setting.h"
#include "screen_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;
+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;
-
+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;
-
+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;
+
//static widget_t *catcher;
// todo add key images
// possible variant will be reusing widget_image for current widget_label so there wont
// be key names but only images
- void
-startScreenSettingKeys()
-{
-
+
+void startScreenSettingKeys()
+{
#ifndef NO_SOUND
- playMusic("menu", MUSIC_GROUP_BASE);
-
-#endif /* */
-} 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
-
-initKeyTable()
-{
- char path[STR_PATH_SIZE];
-
+ playMusic("menu", MUSIC_GROUP_BASE);
+#endif
+}
+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 initKeyTable()
+{
+ char path[STR_PATH_SIZE];
/*
int i;
-*/
- sprintf(path, "%s/keycontrol.conf", getHomeDirector());
- keycontrolFile = loadTextFile(path);
- if (keycontrolFile == NULL) {
- fprintf(stderr, _("I was unable to load file: %s\n"), path);
- fprintf(stderr, _("I try to create file: %s\n"), path);
- keycontrolFile = newTextFile(path);
- }
- if (keycontrolFile == NULL) {
- fprintf(stderr, _("I was unable to create file: %s\n"), path);
- return;
- }
- setKeytableFromConfigFile(keycontrolFile);
-
+*/
+ sprintf(path, "%s/keycontrol.conf", getHomeDirector());
+ keycontrolFile = loadTextFile(path);
+ if (keycontrolFile == NULL) {
+ fprintf(stderr, _("I was unable to load file: %s\n"), path);
+ fprintf(stderr, _("I try to create file: %s\n"), path);
+ keycontrolFile = newTextFile(path);
+ }
+ if (keycontrolFile == NULL) {
+ fprintf(stderr, _("I was unable to create file: %s\n"), path);
+ return;
+ }
+ setKeytableFromConfigFile(keycontrolFile);
/*
for( i = 0 ; i < KEY_LENGTH ; i++)
{
printf("keytable[%d] = %d\n", i, keytable[i]);
}
-*/
-}
- int
-getKey(int n)
-{
-
-// printf("keytable[n] = %d\n", keytable[n]);
- return keytable[n];
- }
- void
-drawScreenSettingKeys()
-{
- drawWidgetImage(image_backgorund);
- drawWidgetButton(button_back);
-
- // key names
- drawWidgetLabel(tux_right);
- drawWidgetLabel(tux_left);
- drawWidgetLabel(tux_right_keyup);
- drawWidgetLabel(tux_right_keydown);
- drawWidgetLabel(tux_right_keyleft);
- drawWidgetLabel(tux_right_keyright);
- drawWidgetLabel(tux_right_keyswitch);
- drawWidgetLabel(tux_right_keyfire);
- drawWidgetLabel(tux_left_keyup);
- drawWidgetLabel(tux_left_keydown);
- drawWidgetLabel(tux_left_keyleft);
- drawWidgetLabel(tux_left_keyright);
- drawWidgetLabel(tux_left_keyswitch);
- drawWidgetLabel(tux_left_keyfire);
-
- // key values
- drawWidgetCatchkey(tux_right_keyup_val);
- drawWidgetCatchkey(tux_right_keydown_val);
- drawWidgetCatchkey(tux_right_keyleft_val);
- drawWidgetCatchkey(tux_right_keyright_val);
- drawWidgetCatchkey(tux_right_keyswitch_val);
- drawWidgetCatchkey(tux_right_keyfire_val);
- drawWidgetCatchkey(tux_left_keyup_val);
- drawWidgetCatchkey(tux_left_keydown_val);
- drawWidgetCatchkey(tux_left_keyleft_val);
- drawWidgetCatchkey(tux_left_keyright_val);
- drawWidgetCatchkey(tux_left_keyswitch_val);
- drawWidgetCatchkey(tux_left_keyfire_val);
- } static void
-
-refreshKeytable()
-{
- keytable[6] = getWidgetCatchKey(tux_left_keyup_val);
- keytable[9] = getWidgetCatchKey(tux_left_keydown_val);
- keytable[8] = getWidgetCatchKey(tux_left_keyleft_val);
- keytable[7] = getWidgetCatchKey(tux_left_keyright_val);
- keytable[10] = getWidgetCatchKey(tux_left_keyfire_val);
- keytable[11] = getWidgetCatchKey(tux_left_keyswitch_val);
- keytable[0] = getWidgetCatchKey(tux_right_keyup_val);
- keytable[3] = getWidgetCatchKey(tux_right_keydown_val);
- keytable[2] = getWidgetCatchKey(tux_right_keyleft_val);
- keytable[1] = getWidgetCatchKey(tux_right_keyright_val);
- keytable[4] = getWidgetCatchKey(tux_right_keyfire_val);
- keytable[5] = getWidgetCatchKey(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)
- setScreen("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
-eventScreenSettingKeys()
-{
- eventWidgetButton(button_back);
- eventWidgetCatchkey(tux_right_keyup_val);
- eventWidgetCatchkey(tux_right_keydown_val);
- eventWidgetCatchkey(tux_right_keyleft_val);
- eventWidgetCatchkey(tux_right_keyright_val);
- eventWidgetCatchkey(tux_right_keyswitch_val);
- eventWidgetCatchkey(tux_right_keyfire_val);
- eventWidgetCatchkey(tux_left_keyup_val);
- eventWidgetCatchkey(tux_left_keydown_val);
- eventWidgetCatchkey(tux_left_keyleft_val);
- eventWidgetCatchkey(tux_left_keyright_val);
- eventWidgetCatchkey(tux_left_keyswitch_val);
- eventWidgetCatchkey(tux_left_keyfire_val);
- } void
-
-stopScreenSettingKeys()
-{
- } void
-
-initScreenSettingKeys()
-{
- image_t * image;
- initKeyTable();
- image = getImage(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = newWidgetImage(0, 0, image);
- button_back =
- newWidgetButton(_("Back"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100,
- eventWidget);
- tux_left =
- newWidgetLabel(_("Player 2"), WINDOW_SIZE_X / 4, 150,
- WIDGET_LABEL_CENTER);
- tux_left_keyup =
- newWidgetLabel(_("Up"), 50, tux_left->y + 50, WIDGET_LABEL_LEFT);
- tux_left_keydown =
- newWidgetLabel(_("Down:"), tux_left_keyup->x, tux_left_keyup->y + 20,
- WIDGET_LABEL_LEFT);
- tux_left_keyleft =
- newWidgetLabel(_("Left:"), tux_left_keyup->x, tux_left_keydown->y + 20,
- WIDGET_LABEL_LEFT);
- tux_left_keyright =
- newWidgetLabel(_("Right:"), tux_left_keyup->x, tux_left_keyleft->y + 20,
- WIDGET_LABEL_LEFT);
- tux_left_keyfire =
- newWidgetLabel(_("Fire gun:"), tux_left_keyup->x,
- tux_left_keyright->y + 20, WIDGET_LABEL_LEFT);
- tux_left_keyswitch =
- newWidgetLabel(_("Switch gun:"), tux_left_keyup->x,
- tux_left_keyfire->y + 20, WIDGET_LABEL_LEFT);
- tux_right =
- newWidgetLabel(_("Player 1"), WINDOW_SIZE_X / 2 + WINDOW_SIZE_X / 4,
- tux_left->y, WIDGET_LABEL_CENTER);
- tux_right_keyup =
- newWidgetLabel(_("Up:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x,
- tux_left->y + 50, WIDGET_LABEL_LEFT);
- tux_right_keydown =
- newWidgetLabel(_("Down:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x,
- tux_left_keyup->y + 20, WIDGET_LABEL_LEFT);
- tux_right_keyleft =
- newWidgetLabel(_("Left:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x,
- tux_right_keydown->y + 20, WIDGET_LABEL_LEFT);
- tux_right_keyright =
- newWidgetLabel(_("Right:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x,
- tux_right_keyleft->y + 20, WIDGET_LABEL_LEFT);
- tux_right_keyfire =
- newWidgetLabel(_("Fire gun:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x,
- tux_left_keyright->y + 20, WIDGET_LABEL_LEFT);
- tux_right_keyswitch =
- newWidgetLabel(_("Switch gun:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x,
- tux_left_keyfire->y + 20, WIDGET_LABEL_LEFT);
- tux_left_keyup_val =
- newWidgetCatchkey(keytable[6], tux_left_keyup->x + 200,
- tux_left->y + 50, eventWidget);
- tux_left_keydown_val =
- newWidgetCatchkey(keytable[9], tux_left_keyup_val->x,
- tux_left_keyup->y + 20, eventWidget);
- tux_left_keyleft_val =
- newWidgetCatchkey(keytable[8], tux_left_keyup_val->x,
- tux_left_keydown->y + 20, eventWidget);
- tux_left_keyright_val =
- newWidgetCatchkey(keytable[7], tux_left_keyup_val->x,
- tux_left_keyleft->y + 20, eventWidget);
- tux_left_keyfire_val =
- newWidgetCatchkey(keytable[10], tux_left_keyup_val->x,
- tux_left_keyright->y + 20, eventWidget);
- tux_left_keyswitch_val =
- newWidgetCatchkey(keytable[11], tux_left_keyup_val->x,
- tux_left_keyfire->y + 20, eventWidget);
- tux_right_keyup_val =
- newWidgetCatchkey(keytable[0],
- WINDOW_SIZE_X / 2 + tux_left_keyup_val->x,
- tux_left->y + 50, eventWidget);
- tux_right_keydown_val =
- newWidgetCatchkey(keytable[3],
- WINDOW_SIZE_X / 2 + tux_left_keyup_val->x,
- tux_left_keyup->y + 20, eventWidget);
- tux_right_keyleft_val =
- newWidgetCatchkey(keytable[2],
- WINDOW_SIZE_X / 2 + tux_left_keyup_val->x,
- tux_right_keydown->y + 20, eventWidget);
- tux_right_keyright_val =
- newWidgetCatchkey(keytable[1],
- WINDOW_SIZE_X / 2 + tux_left_keyup_val->x,
- tux_right_keyleft->y + 20, eventWidget);
- tux_right_keyfire_val =
- newWidgetCatchkey(keytable[4],
- WINDOW_SIZE_X / 2 + tux_left_keyup_val->x,
- tux_left_keyright->y + 20, eventWidget);
- tux_right_keyswitch_val =
- newWidgetCatchkey(keytable[5],
- WINDOW_SIZE_X / 2 + tux_left_keyup_val->x,
- tux_left_keyfire->y + 20, eventWidget);
- registerScreen(newScreen
- ("settingKeys", startScreenSettingKeys,
- eventScreenSettingKeys, drawScreenSettingKeys,
- stopScreenSettingKeys));
- } void
-
-quitKeyTable()
-{
- destroyTextFile(keycontrolFile);
- } void
-
-saveKeyTable(textFile_t * configFile)
-{
- char str[STR_SIZE];
- sprintf(str, "%d", getWidgetCatchKey(tux_left_keyup_val));
- setValueInConfigFile(configFile, "TUX_LEFT_MOVE_UP", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_left_keydown_val));
- setValueInConfigFile(configFile, "TUX_LEFT_MOVE_DOWN", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_left_keyleft_val));
- setValueInConfigFile(configFile, "TUX_LEFT_MOVE_LEFT", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_left_keyright_val));
- setValueInConfigFile(configFile, "TUX_LEFT_MOVE_RIGHT", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_left_keyfire_val));
- setValueInConfigFile(configFile, "TUX_LEFT_SHOOT", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_left_keyswitch_val));
- setValueInConfigFile(configFile, "TUX_LEFT_SWITCH_WEAPON", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_right_keyup_val));
- setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_UP", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_right_keydown_val));
- setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_DOWN", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_right_keyleft_val));
- setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_LEFT", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_right_keyright_val));
- setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_RIGHT", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_right_keyfire_val));
- setValueInConfigFile(configFile, "TUX_RIGHT_SHOOT", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_right_keyswitch_val));
- setValueInConfigFile(configFile, "TUX_RIGHT_SWITCH_WEAPON", str);
- saveTextFile(configFile);
- } void
-
-quitScreenSettingKeys()
-{
- saveKeyTable(keycontrolFile);
- quitKeyTable();
-
- // key names
- destroyWidgetImage(image_backgorund);
- destroyWidgetLabel(tux_right);
- destroyWidgetLabel(tux_left);
- destroyWidgetLabel(tux_right_keyup);
- destroyWidgetLabel(tux_right_keydown);
- destroyWidgetLabel(tux_right_keyleft);
- destroyWidgetLabel(tux_right_keyright);
- destroyWidgetLabel(tux_right_keyswitch);
- destroyWidgetLabel(tux_right_keyfire);
- destroyWidgetLabel(tux_left_keyup);
- destroyWidgetLabel(tux_left_keydown);
- destroyWidgetLabel(tux_left_keyright);
- destroyWidgetLabel(tux_left_keyleft);
- destroyWidgetLabel(tux_left_keyswitch);
- destroyWidgetLabel(tux_left_keyfire);
-
- // key values
- destroyWidgetCatchkey(tux_right_keyup_val);
- destroyWidgetCatchkey(tux_right_keydown_val);
- destroyWidgetCatchkey(tux_right_keyleft_val);
- destroyWidgetCatchkey(tux_right_keyright_val);
- destroyWidgetCatchkey(tux_right_keyswitch_val);
- destroyWidgetCatchkey(tux_right_keyfire_val);
- destroyWidgetCatchkey(tux_left_keyup_val);
- destroyWidgetCatchkey(tux_left_keydown_val);
- destroyWidgetCatchkey(tux_left_keyleft_val);
- destroyWidgetCatchkey(tux_left_keyright_val);
- destroyWidgetCatchkey(tux_left_keyswitch_val);
- destroyWidgetCatchkey(tux_left_keyfire_val);
- destroyWidgetButton(button_back);
- }
+*/
+}
+int getKey(int n)
+{
+// printf("keytable[n] = %d\n", keytable[n]);
+ return keytable[n];
+}
+void drawScreenSettingKeys()
+{
+ drawWidgetImage(image_backgorund);
+ drawWidgetButton(button_back);
+ // key names
+ drawWidgetLabel(tux_right);
+ drawWidgetLabel(tux_left);
+ drawWidgetLabel(tux_right_keyup);
+ drawWidgetLabel(tux_right_keydown);
+ drawWidgetLabel(tux_right_keyleft);
+ drawWidgetLabel(tux_right_keyright);
+ drawWidgetLabel(tux_right_keyswitch);
+ drawWidgetLabel(tux_right_keyfire);
+ drawWidgetLabel(tux_left_keyup);
+ drawWidgetLabel(tux_left_keydown);
+ drawWidgetLabel(tux_left_keyleft);
+ drawWidgetLabel(tux_left_keyright);
+ drawWidgetLabel(tux_left_keyswitch);
+ drawWidgetLabel(tux_left_keyfire);
+ // key values
+ drawWidgetCatchkey(tux_right_keyup_val);
+ drawWidgetCatchkey(tux_right_keydown_val);
+ drawWidgetCatchkey(tux_right_keyleft_val);
+ drawWidgetCatchkey(tux_right_keyright_val);
+ drawWidgetCatchkey(tux_right_keyswitch_val);
+ drawWidgetCatchkey(tux_right_keyfire_val);
+ drawWidgetCatchkey(tux_left_keyup_val);
+ drawWidgetCatchkey(tux_left_keydown_val);
+ drawWidgetCatchkey(tux_left_keyleft_val);
+ drawWidgetCatchkey(tux_left_keyright_val);
+ drawWidgetCatchkey(tux_left_keyswitch_val);
+ drawWidgetCatchkey(tux_left_keyfire_val);
+}
+static void refreshKeytable()
+{
+ keytable[6] = getWidgetCatchKey(tux_left_keyup_val);
+ keytable[9] = getWidgetCatchKey(tux_left_keydown_val);
+ keytable[8] = getWidgetCatchKey(tux_left_keyleft_val);
+ keytable[7] = getWidgetCatchKey(tux_left_keyright_val);
+ keytable[10] = getWidgetCatchKey(tux_left_keyfire_val);
+ keytable[11] = getWidgetCatchKey(tux_left_keyswitch_val);
+ keytable[0] = getWidgetCatchKey(tux_right_keyup_val);
+ keytable[3] = getWidgetCatchKey(tux_right_keydown_val);
+ keytable[2] = getWidgetCatchKey(tux_right_keyleft_val);
+ keytable[1] = getWidgetCatchKey(tux_right_keyright_val);
+ keytable[4] = getWidgetCatchKey(tux_right_keyfire_val);
+ keytable[5] = getWidgetCatchKey(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)
+ setScreen("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 eventScreenSettingKeys()
+{
+ eventWidgetButton(button_back);
+ eventWidgetCatchkey(tux_right_keyup_val);
+ eventWidgetCatchkey(tux_right_keydown_val);
+ eventWidgetCatchkey(tux_right_keyleft_val);
+ eventWidgetCatchkey(tux_right_keyright_val);
+ eventWidgetCatchkey(tux_right_keyswitch_val);
+ eventWidgetCatchkey(tux_right_keyfire_val);
+ eventWidgetCatchkey(tux_left_keyup_val);
+ eventWidgetCatchkey(tux_left_keydown_val);
+ eventWidgetCatchkey(tux_left_keyleft_val);
+ eventWidgetCatchkey(tux_left_keyright_val);
+ eventWidgetCatchkey(tux_left_keyswitch_val);
+ eventWidgetCatchkey(tux_left_keyfire_val);
+}
+void stopScreenSettingKeys()
+{
+}
+void initScreenSettingKeys()
+{
+ image_t *image;
+
+ initKeyTable();
+ image = getImage(IMAGE_GROUP_BASE, "screen_main");
+ image_backgorund = newWidgetImage(0, 0, image);
+ button_back = newWidgetButton(_("Back"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget);
+ tux_left = newWidgetLabel(_("Player 2"), WINDOW_SIZE_X/4, 150, WIDGET_LABEL_CENTER);
+ tux_left_keyup = newWidgetLabel(_("Up"), 50, tux_left->y+50, WIDGET_LABEL_LEFT);
+ tux_left_keydown = newWidgetLabel(_("Down:"), tux_left_keyup->x, tux_left_keyup->y + 20, WIDGET_LABEL_LEFT);
+ tux_left_keyleft = newWidgetLabel(_("Left:"), tux_left_keyup->x, tux_left_keydown->y + 20, WIDGET_LABEL_LEFT);
+ tux_left_keyright = newWidgetLabel(_("Right:"), tux_left_keyup->x, tux_left_keyleft->y + 20, WIDGET_LABEL_LEFT);
+ tux_left_keyfire = newWidgetLabel(_("Fire gun:"), tux_left_keyup->x, tux_left_keyright->y + 20, WIDGET_LABEL_LEFT);
+ tux_left_keyswitch = newWidgetLabel(_("Switch gun:"), tux_left_keyup->x, tux_left_keyfire->y + 20, WIDGET_LABEL_LEFT);
+ tux_right = newWidgetLabel(_("Player 1"), WINDOW_SIZE_X/2 + WINDOW_SIZE_X/4, tux_left->y, WIDGET_LABEL_CENTER);
+ tux_right_keyup = newWidgetLabel(_("Up:"), WINDOW_SIZE_X/2 + tux_left_keyup->x, tux_left->y+50, WIDGET_LABEL_LEFT);
+ tux_right_keydown = newWidgetLabel(_("Down:"), WINDOW_SIZE_X/2 + tux_left_keyup->x, tux_left_keyup->y + 20, WIDGET_LABEL_LEFT);
+ tux_right_keyleft = newWidgetLabel(_("Left:"), WINDOW_SIZE_X/2 + tux_left_keyup->x, tux_right_keydown->y + 20, WIDGET_LABEL_LEFT);
+ tux_right_keyright = newWidgetLabel(_("Right:"), WINDOW_SIZE_X/2 + tux_left_keyup->x, tux_right_keyleft->y + 20, WIDGET_LABEL_LEFT);
+ tux_right_keyfire = newWidgetLabel(_("Fire gun:"), WINDOW_SIZE_X/2 + tux_left_keyup->x, tux_left_keyright->y + 20, WIDGET_LABEL_LEFT);
+ tux_right_keyswitch = newWidgetLabel(_("Switch gun:"), WINDOW_SIZE_X/2 + tux_left_keyup->x, tux_left_keyfire->y + 20, WIDGET_LABEL_LEFT);
+ tux_left_keyup_val = newWidgetCatchkey(keytable[6], tux_left_keyup->x+200, tux_left->y+50, eventWidget);
+ tux_left_keydown_val = newWidgetCatchkey(keytable[9], tux_left_keyup_val->x, tux_left_keyup->y + 20, eventWidget);
+ tux_left_keyleft_val = newWidgetCatchkey(keytable[8], tux_left_keyup_val->x, tux_left_keydown->y + 20, eventWidget);
+ tux_left_keyright_val = newWidgetCatchkey(keytable[7], tux_left_keyup_val->x, tux_left_keyleft->y + 20, eventWidget);
+ tux_left_keyfire_val = newWidgetCatchkey(keytable[10], tux_left_keyup_val->x, tux_left_keyright->y + 20, eventWidget);
+ tux_left_keyswitch_val = newWidgetCatchkey(keytable[11], tux_left_keyup_val->x, tux_left_keyfire->y + 20, eventWidget);
+ tux_right_keyup_val = newWidgetCatchkey(keytable[0], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_left->y+50, eventWidget);
+ tux_right_keydown_val = newWidgetCatchkey(keytable[3], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_left_keyup->y + 20, eventWidget);
+ tux_right_keyleft_val = newWidgetCatchkey(keytable[2], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_right_keydown->y + 20, eventWidget);
+ tux_right_keyright_val = newWidgetCatchkey(keytable[1], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_right_keyleft->y + 20, eventWidget);
+ tux_right_keyfire_val = newWidgetCatchkey(keytable[4], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_left_keyright->y + 20, eventWidget);
+ tux_right_keyswitch_val = newWidgetCatchkey(keytable[5], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_left_keyfire->y + 20, eventWidget);
+ registerScreen(newScreen("settingKeys", startScreenSettingKeys, eventScreenSettingKeys,
+ drawScreenSettingKeys, stopScreenSettingKeys));
+}
+void quitKeyTable()
+{
+ destroyTextFile(keycontrolFile);
+}
+void saveKeyTable(textFile_t *configFile) {
+ char str[STR_SIZE];
+
+ sprintf(str,"%d", getWidgetCatchKey(tux_left_keyup_val));
+ setValueInConfigFile(configFile, "TUX_LEFT_MOVE_UP", str);
+ sprintf(str,"%d", getWidgetCatchKey(tux_left_keydown_val));
+ setValueInConfigFile(configFile, "TUX_LEFT_MOVE_DOWN", str);
+ sprintf(str,"%d", getWidgetCatchKey(tux_left_keyleft_val));
+ setValueInConfigFile(configFile, "TUX_LEFT_MOVE_LEFT", str);
+ sprintf(str,"%d", getWidgetCatchKey(tux_left_keyright_val));
+ setValueInConfigFile(configFile, "TUX_LEFT_MOVE_RIGHT", str);
+ sprintf(str,"%d", getWidgetCatchKey(tux_left_keyfire_val));
+ setValueInConfigFile(configFile, "TUX_LEFT_SHOOT", str);
+ sprintf(str,"%d", getWidgetCatchKey(tux_left_keyswitch_val));
+ setValueInConfigFile(configFile, "TUX_LEFT_SWITCH_WEAPON", str);
+ sprintf(str,"%d", getWidgetCatchKey(tux_right_keyup_val));
+ setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_UP", str);
+ sprintf(str,"%d", getWidgetCatchKey(tux_right_keydown_val));
+ setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_DOWN", str);
+ sprintf(str,"%d", getWidgetCatchKey(tux_right_keyleft_val));
+ setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_LEFT", str);
+ sprintf(str,"%d", getWidgetCatchKey(tux_right_keyright_val));
+ setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_RIGHT", str);
+ sprintf(str,"%d", getWidgetCatchKey(tux_right_keyfire_val));
+ setValueInConfigFile(configFile, "TUX_RIGHT_SHOOT", str);
+ sprintf(str,"%d", getWidgetCatchKey(tux_right_keyswitch_val));
+ setValueInConfigFile(configFile, "TUX_RIGHT_SWITCH_WEAPON", str);
+ saveTextFile(configFile);
+}
+void quitScreenSettingKeys()
+{
+ saveKeyTable(keycontrolFile);
+ quitKeyTable();
+ // key names
+ destroyWidgetImage(image_backgorund);
+ destroyWidgetLabel(tux_right);
+ destroyWidgetLabel(tux_left);
+ destroyWidgetLabel(tux_right_keyup);
+ destroyWidgetLabel(tux_right_keydown);
+ destroyWidgetLabel(tux_right_keyleft);
+ destroyWidgetLabel(tux_right_keyright);
+ destroyWidgetLabel(tux_right_keyswitch);
+ destroyWidgetLabel(tux_right_keyfire);
+ destroyWidgetLabel(tux_left_keyup);
+ destroyWidgetLabel(tux_left_keydown);
+ destroyWidgetLabel(tux_left_keyright);
+ destroyWidgetLabel(tux_left_keyleft);
+ destroyWidgetLabel(tux_left_keyswitch);
+ destroyWidgetLabel(tux_left_keyfire);
+ // key values
+ destroyWidgetCatchkey(tux_right_keyup_val);
+ destroyWidgetCatchkey(tux_right_keydown_val);
+ destroyWidgetCatchkey(tux_right_keyleft_val);
+ destroyWidgetCatchkey(tux_right_keyright_val);
+ destroyWidgetCatchkey(tux_right_keyswitch_val);
+ destroyWidgetCatchkey(tux_right_keyfire_val);
+ destroyWidgetCatchkey(tux_left_keyup_val);
+ destroyWidgetCatchkey(tux_left_keydown_val);
+ destroyWidgetCatchkey(tux_left_keyleft_val);
+ destroyWidgetCatchkey(tux_left_keyright_val);
+ destroyWidgetCatchkey(tux_left_keyswitch_val);
+ destroyWidgetCatchkey(tux_left_keyfire_val);
+ destroyWidgetButton(button_back);
+}
diff --git a/src/screen/screen_settingKeys.c~ b/src/screen/screen_settingKeys.c~
deleted file mode 100644
index d40db6d..0000000
--- a/src/screen/screen_settingKeys.c~
+++ /dev/null
@@ -1,332 +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"
-#ifndef NO_SOUND
-#include "music.h"
-#include "sound.h"
-#endif
-#include "screen_mainMenu.h"
-#include "screen_setting.h"
-#include "screen_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;
-
-//static widget_t *catcher;
-// todo add key images
-// possible variant will be reusing widget_image for current widget_label so there wont
-// be key names but only images
-
-void startScreenSettingKeys()
-{
-#ifndef NO_SOUND
- playMusic("menu", MUSIC_GROUP_BASE);
-#endif
-}
-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 initKeyTable()
-{
- char path[STR_PATH_SIZE];
-/*
- int i;
-*/
- sprintf(path, "%s/keycontrol.conf", getHomeDirector());
- keycontrolFile = loadTextFile(path);
- if (keycontrolFile == NULL) {
- fprintf(stderr, _("I was unable to load file: %s\n"), path);
- fprintf(stderr, _("I try to create file: %s\n"), path);
- keycontrolFile = newTextFile(path);
- }
- if (keycontrolFile == NULL) {
- fprintf(stderr, _("I was unable to create file: %s\n"), path);
- return;
- }
- setKeytableFromConfigFile(keycontrolFile);
-/*
- for( i = 0 ; i < KEY_LENGTH ; i++)
- {
- printf("keytable[%d] = %d\n", i, keytable[i]);
- }
-*/
-}
-int getKey(int n)
-{
-// printf("keytable[n] = %d\n", keytable[n]);
- return keytable[n];
-}
-void drawScreenSettingKeys()
-{
- drawWidgetImage(image_backgorund);
- drawWidgetButton(button_back);
- // key names
- drawWidgetLabel(tux_right);
- drawWidgetLabel(tux_left);
- drawWidgetLabel(tux_right_keyup);
- drawWidgetLabel(tux_right_keydown);
- drawWidgetLabel(tux_right_keyleft);
- drawWidgetLabel(tux_right_keyright);
- drawWidgetLabel(tux_right_keyswitch);
- drawWidgetLabel(tux_right_keyfire);
- drawWidgetLabel(tux_left_keyup);
- drawWidgetLabel(tux_left_keydown);
- drawWidgetLabel(tux_left_keyleft);
- drawWidgetLabel(tux_left_keyright);
- drawWidgetLabel(tux_left_keyswitch);
- drawWidgetLabel(tux_left_keyfire);
- // key values
- drawWidgetCatchkey(tux_right_keyup_val);
- drawWidgetCatchkey(tux_right_keydown_val);
- drawWidgetCatchkey(tux_right_keyleft_val);
- drawWidgetCatchkey(tux_right_keyright_val);
- drawWidgetCatchkey(tux_right_keyswitch_val);
- drawWidgetCatchkey(tux_right_keyfire_val);
- drawWidgetCatchkey(tux_left_keyup_val);
- drawWidgetCatchkey(tux_left_keydown_val);
- drawWidgetCatchkey(tux_left_keyleft_val);
- drawWidgetCatchkey(tux_left_keyright_val);
- drawWidgetCatchkey(tux_left_keyswitch_val);
- drawWidgetCatchkey(tux_left_keyfire_val);
-}
-static void refreshKeytable()
-{
- keytable[6] = getWidgetCatchKey(tux_left_keyup_val);
- keytable[9] = getWidgetCatchKey(tux_left_keydown_val);
- keytable[8] = getWidgetCatchKey(tux_left_keyleft_val);
- keytable[7] = getWidgetCatchKey(tux_left_keyright_val);
- keytable[10] = getWidgetCatchKey(tux_left_keyfire_val);
- keytable[11] = getWidgetCatchKey(tux_left_keyswitch_val);
- keytable[0] = getWidgetCatchKey(tux_right_keyup_val);
- keytable[3] = getWidgetCatchKey(tux_right_keydown_val);
- keytable[2] = getWidgetCatchKey(tux_right_keyleft_val);
- keytable[1] = getWidgetCatchKey(tux_right_keyright_val);
- keytable[4] = getWidgetCatchKey(tux_right_keyfire_val);
- keytable[5] = getWidgetCatchKey(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)
- setScreen("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 eventScreenSettingKeys()
-{
- eventWidgetButton(button_back);
- eventWidgetCatchkey(tux_right_keyup_val);
- eventWidgetCatchkey(tux_right_keydown_val);
- eventWidgetCatchkey(tux_right_keyleft_val);
- eventWidgetCatchkey(tux_right_keyright_val);
- eventWidgetCatchkey(tux_right_keyswitch_val);
- eventWidgetCatchkey(tux_right_keyfire_val);
- eventWidgetCatchkey(tux_left_keyup_val);
- eventWidgetCatchkey(tux_left_keydown_val);
- eventWidgetCatchkey(tux_left_keyleft_val);
- eventWidgetCatchkey(tux_left_keyright_val);
- eventWidgetCatchkey(tux_left_keyswitch_val);
- eventWidgetCatchkey(tux_left_keyfire_val);
-}
-void stopScreenSettingKeys()
-{
-}
-void initScreenSettingKeys()
-{
- image_t *image;
-
- initKeyTable();
- image = getImage(IMAGE_GROUP_BASE, "screen_main");
- image_backgorund = newWidgetImage(0, 0, image);
- button_back = newWidgetButton(_("Back"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget);
- tux_left = newWidgetLabel(_("Player 2"), WINDOW_SIZE_X/4, 150, WIDGET_LABEL_CENTER);
- tux_left_keyup = newWidgetLabel(_("Up"), 50, tux_left->y+50, WIDGET_LABEL_LEFT);
- tux_left_keydown = newWidgetLabel(_("Down:"), tux_left_keyup->x, tux_left_keyup->y + 20, WIDGET_LABEL_LEFT);
- tux_left_keyleft = newWidgetLabel(_("Left:"), tux_left_keyup->x, tux_left_keydown->y + 20, WIDGET_LABEL_LEFT);
- tux_left_keyright = newWidgetLabel(_("Right:"), tux_left_keyup->x, tux_left_keyleft->y + 20, WIDGET_LABEL_LEFT);
- tux_left_keyfire = newWidgetLabel(_("Fire gun:"), tux_left_keyup->x, tux_left_keyright->y + 20, WIDGET_LABEL_LEFT);
- tux_left_keyswitch = newWidgetLabel(_("Switch gun:"), tux_left_keyup->x, tux_left_keyfire->y + 20, WIDGET_LABEL_LEFT);
- tux_right = newWidgetLabel(_("Player 1"), WINDOW_SIZE_X/2 + WINDOW_SIZE_X/4, tux_left->y, WIDGET_LABEL_CENTER);
- tux_right_keyup = newWidgetLabel(_("Up:"), WINDOW_SIZE_X/2 + tux_left_keyup->x, tux_left->y+50, WIDGET_LABEL_LEFT);
- tux_right_keydown = newWidgetLabel(_("Down:"), WINDOW_SIZE_X/2 + tux_left_keyup->x, tux_left_keyup->y + 20, WIDGET_LABEL_LEFT);
- tux_right_keyleft = newWidgetLabel(_("Left:"), WINDOW_SIZE_X/2 + tux_left_keyup->x, tux_right_keydown->y + 20, WIDGET_LABEL_LEFT);
- tux_right_keyright = newWidgetLabel(_("Right:"), WINDOW_SIZE_X/2 + tux_left_keyup->x, tux_right_keyleft->y + 20, WIDGET_LABEL_LEFT);
- tux_right_keyfire = newWidgetLabel(_("Fire gun:"), WINDOW_SIZE_X/2 + tux_left_keyup->x, tux_left_keyright->y + 20, WIDGET_LABEL_LEFT);
- tux_right_keyswitch = newWidgetLabel(_("Switch gun:"), WINDOW_SIZE_X/2 + tux_left_keyup->x, tux_left_keyfire->y + 20, WIDGET_LABEL_LEFT);
- tux_left_keyup_val = newWidgetCatchkey(keytable[6], tux_left_keyup->x+200, tux_left->y+50, eventWidget);
- tux_left_keydown_val = newWidgetCatchkey(keytable[9], tux_left_keyup_val->x, tux_left_keyup->y + 20, eventWidget);
- tux_left_keyleft_val = newWidgetCatchkey(keytable[8], tux_left_keyup_val->x, tux_left_keydown->y + 20, eventWidget);
- tux_left_keyright_val = newWidgetCatchkey(keytable[7], tux_left_keyup_val->x, tux_left_keyleft->y + 20, eventWidget);
- tux_left_keyfire_val = newWidgetCatchkey(keytable[10], tux_left_keyup_val->x, tux_left_keyright->y + 20, eventWidget);
- tux_left_keyswitch_val = newWidgetCatchkey(keytable[11], tux_left_keyup_val->x, tux_left_keyfire->y + 20, eventWidget);
- tux_right_keyup_val = newWidgetCatchkey(keytable[0], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_left->y+50, eventWidget);
- tux_right_keydown_val = newWidgetCatchkey(keytable[3], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_left_keyup->y + 20, eventWidget);
- tux_right_keyleft_val = newWidgetCatchkey(keytable[2], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_right_keydown->y + 20, eventWidget);
- tux_right_keyright_val = newWidgetCatchkey(keytable[1], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_right_keyleft->y + 20, eventWidget);
- tux_right_keyfire_val = newWidgetCatchkey(keytable[4], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_left_keyright->y + 20, eventWidget);
- tux_right_keyswitch_val = newWidgetCatchkey(keytable[5], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_left_keyfire->y + 20, eventWidget);
- registerScreen(newScreen("settingKeys", startScreenSettingKeys, eventScreenSettingKeys,
- drawScreenSettingKeys, stopScreenSettingKeys));
-}
-void quitKeyTable()
-{
- destroyTextFile(keycontrolFile);
-}
-void saveKeyTable(textFile_t *configFile) {
- char str[STR_SIZE];
-
- sprintf(str,"%d", getWidgetCatchKey(tux_left_keyup_val));
- setValueInConfigFile(configFile, "TUX_LEFT_MOVE_UP", str);
- sprintf(str,"%d", getWidgetCatchKey(tux_left_keydown_val));
- setValueInConfigFile(configFile, "TUX_LEFT_MOVE_DOWN", str);
- sprintf(str,"%d", getWidgetCatchKey(tux_left_keyleft_val));
- setValueInConfigFile(configFile, "TUX_LEFT_MOVE_LEFT", str);
- sprintf(str,"%d", getWidgetCatchKey(tux_left_keyright_val));
- setValueInConfigFile(configFile, "TUX_LEFT_MOVE_RIGHT", str);
- sprintf(str,"%d", getWidgetCatchKey(tux_left_keyfire_val));
- setValueInConfigFile(configFile, "TUX_LEFT_SHOOT", str);
- sprintf(str,"%d", getWidgetCatchKey(tux_left_keyswitch_val));
- setValueInConfigFile(configFile, "TUX_LEFT_SWITCH_WEAPON", str);
- sprintf(str,"%d", getWidgetCatchKey(tux_right_keyup_val));
- setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_UP", str);
- sprintf(str,"%d", getWidgetCatchKey(tux_right_keydown_val));
- setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_DOWN", str);
- sprintf(str,"%d", getWidgetCatchKey(tux_right_keyleft_val));
- setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_LEFT", str);
- sprintf(str,"%d", getWidgetCatchKey(tux_right_keyright_val));
- setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_RIGHT", str);
- sprintf(str,"%d", getWidgetCatchKey(tux_right_keyfire_val));
- setValueInConfigFile(configFile, "TUX_RIGHT_SHOOT", str);
- sprintf(str,"%d", getWidgetCatchKey(tux_right_keyswitch_val));
- setValueInConfigFile(configFile, "TUX_RIGHT_SWITCH_WEAPON", str);
- saveTextFile(configFile);
-}
-void quitScreenSettingKeys()
-{
- saveKeyTable(keycontrolFile);
- quitKeyTable();
- // key names
- destroyWidgetImage(image_backgorund);
- destroyWidgetLabel(tux_right);
- destroyWidgetLabel(tux_left);
- destroyWidgetLabel(tux_right_keyup);
- destroyWidgetLabel(tux_right_keydown);
- destroyWidgetLabel(tux_right_keyleft);
- destroyWidgetLabel(tux_right_keyright);
- destroyWidgetLabel(tux_right_keyswitch);
- destroyWidgetLabel(tux_right_keyfire);
- destroyWidgetLabel(tux_left_keyup);
- destroyWidgetLabel(tux_left_keydown);
- destroyWidgetLabel(tux_left_keyright);
- destroyWidgetLabel(tux_left_keyleft);
- destroyWidgetLabel(tux_left_keyswitch);
- destroyWidgetLabel(tux_left_keyfire);
- // key values
- destroyWidgetCatchkey(tux_right_keyup_val);
- destroyWidgetCatchkey(tux_right_keydown_val);
- destroyWidgetCatchkey(tux_right_keyleft_val);
- destroyWidgetCatchkey(tux_right_keyright_val);
- destroyWidgetCatchkey(tux_right_keyswitch_val);
- destroyWidgetCatchkey(tux_right_keyfire_val);
- destroyWidgetCatchkey(tux_left_keyup_val);
- destroyWidgetCatchkey(tux_left_keydown_val);
- destroyWidgetCatchkey(tux_left_keyleft_val);
- destroyWidgetCatchkey(tux_left_keyright_val);
- destroyWidgetCatchkey(tux_left_keyswitch_val);
- destroyWidgetCatchkey(tux_left_keyfire_val);
- destroyWidgetButton(button_back);
-}
diff --git a/src/screen/screen_table.c b/src/screen/screen_table.c
index 31c0baf..f4c981c 100644
--- a/src/screen/screen_table.c
+++ b/src/screen/screen_table.c
@@ -31,211 +31,208 @@ static list_t *listWidgetLabelScore;
static textFile_t *textFile;
-void
-startScreenTable()
+void startScreenTable()
{
#ifndef NO_SOUND
- playMusic("menu", MUSIC_GROUP_BASE);
+ playMusic("menu", MUSIC_GROUP_BASE);
#endif
}
-void
-drawScreenTable()
+void drawScreenTable()
{
- int i;
-
- drawWidgetImage(image_backgorund);
-
- drawWidgetButton(button_back);
-
- for (i = 0; i < listWidgetLabelNumer->count; i++) {
- widget_t *this;
- this = (widget_t *) listWidgetLabelNumer->list[i];
- drawWidgetLabel(this);
- }
-
- for (i = 0; i < listWidgetLabelName->count; i++) {
- widget_t *this;
- this = (widget_t *) listWidgetLabelName->list[i];
- drawWidgetLabel(this);
- }
-
- for (i = 0; i < listWidgetLabelScore->count; i++) {
- widget_t *this;
- this = (widget_t *) listWidgetLabelScore->list[i];
- drawWidgetLabel(this);
- }
+ int i;
+
+ drawWidgetImage(image_backgorund);
+
+ drawWidgetButton(button_back);
+
+ for( i = 0 ; i < listWidgetLabelNumer->count ; i++ )
+ {
+ widget_t *this;
+ this = (widget_t *)listWidgetLabelNumer->list[i];
+ drawWidgetLabel(this);
+ }
+
+ for( i = 0 ; i < listWidgetLabelName->count ; i++ )
+ {
+ widget_t *this;
+ this = (widget_t *)listWidgetLabelName->list[i];
+ drawWidgetLabel(this);
+ }
+
+ for( i = 0 ; i < listWidgetLabelScore->count ; i++ )
+ {
+ widget_t *this;
+ this = (widget_t *)listWidgetLabelScore->list[i];
+ drawWidgetLabel(this);
+ }
}
-void
-eventScreenTable()
+void eventScreenTable()
{
- eventWidgetButton(button_back);
+ eventWidgetButton(button_back);
}
-void
-stopScreenTable()
+void stopScreenTable()
{
}
-static void
-eventWidget(void *p)
+static void eventWidget(void *p)
{
- widget_t *button;
-
- button = (widget_t *) (p);
-
- if (button == button_back) {
- setScreen("mainMenu");
- }
+ widget_t *button;
+
+ button = (widget_t *)(p);
+
+ if( button == button_back )
+ {
+ setScreen("mainMenu");
+ }
}
-static void
-setWidgetLabel()
+static void setWidgetLabel()
{
- int i;
-
- if (textFile == NULL) {
- fprintf(stderr, _("Highscore file: \"%s\" was not loaded!"),
- SCREEN_TABLE_FILE_HIGHSCORE_NAME);
-
- return;
- }
-
- if (listWidgetLabelNumer != NULL ||
- listWidgetLabelName != NULL || listWidgetLabelScore != NULL) {
- destroyListItem(listWidgetLabelNumer, destroyWidgetLabel);
- destroyListItem(listWidgetLabelName, destroyWidgetLabel);
- destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
- }
-
- listWidgetLabelNumer = newList();
- listWidgetLabelName = newList();
- listWidgetLabelScore = newList();
-
- for (i = 0; i < SCREEN_TABLE_MAX_PLAYERS; i++) {
- widget_t *label;
- char name[STR_NAME_SIZE];
- char score[STR_NUM_SIZE];
- char num[STR_NUM_SIZE];
- char *line;
-
- line = (char *) textFile->text->list[i];
-
- sscanf(line, "%s %s", name, score);
- sprintf(num, "%2d)", i + 1);
-
- label =
- newWidgetLabel(num, WINDOW_SIZE_X / 2 - 100, 200 + i * 20,
- WIDGET_LABEL_LEFT);
- addList(listWidgetLabelNumer, label);
-
- label =
- newWidgetLabel(name, WINDOW_SIZE_X / 2, 200 + i * 20,
- WIDGET_LABEL_CENTER);
- addList(listWidgetLabelName, label);
-
- label =
- newWidgetLabel(score, WINDOW_SIZE_X / 2 + 80, 200 + i * 20,
- WIDGET_LABEL_LEFT);
- addList(listWidgetLabelScore, label);
- }
+ int i;
+
+ if( textFile == NULL )
+ {
+ fprintf(stderr, _("Highscore file: \"%s\" was not loaded!"),
+ SCREEN_TABLE_FILE_HIGHSCORE_NAME);
+
+ return;
+ }
+
+ if( listWidgetLabelNumer != NULL ||
+ listWidgetLabelName != NULL ||
+ listWidgetLabelScore != NULL )
+ {
+ destroyListItem(listWidgetLabelNumer, destroyWidgetLabel);
+ destroyListItem(listWidgetLabelName, destroyWidgetLabel);
+ destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
+ }
+
+ listWidgetLabelNumer = newList();
+ listWidgetLabelName = newList();
+ listWidgetLabelScore = newList();
+
+ for( i = 0 ; i < SCREEN_TABLE_MAX_PLAYERS ; i++ )
+ {
+ widget_t *label;
+ char name[STR_NAME_SIZE];
+ char score[STR_NUM_SIZE];
+ char num[STR_NUM_SIZE];
+ char *line;
+
+ line = (char *) textFile->text->list[i];
+
+ sscanf(line, "%s %s", name, score);
+ sprintf(num, "%2d)", i+1);
+
+ label = newWidgetLabel(num, WINDOW_SIZE_X/2 - 100, 200 + i * 20, WIDGET_LABEL_LEFT);
+ addList(listWidgetLabelNumer, label);
+
+ label = newWidgetLabel(name, WINDOW_SIZE_X/2, 200 + i * 20, WIDGET_LABEL_CENTER);
+ addList(listWidgetLabelName, label);
+
+ label = newWidgetLabel(score, WINDOW_SIZE_X/2 + 80, 200 + i * 20, WIDGET_LABEL_LEFT);
+ addList(listWidgetLabelScore, label);
+ }
}
-static void
-loadHighscoreFile()
+static void loadHighscoreFile()
{
- char path[STR_PATH_SIZE];
- int i;
-
- sprintf(path, "%s/" SCREEN_TABLE_FILE_HIGHSCORE_NAME, getHomeDirector());
- textFile = loadTextFile(path);
-
- if (textFile == NULL) {
- fprintf(stderr, _("I am unable to load: \"%s\" !\n"), path);
- fprintf(stderr, _("Creating: \"%s\"\n"), path);
- textFile = newTextFile(path);
- }
- else {
- return;
- }
-
- if (textFile == NULL) {
- fprintf(stderr, _("I was unable to create: \"%s\" !\n"), path);
- return;
- }
-
- for (i = 0; i < SCREEN_TABLE_MAX_PLAYERS; i++) {
- addList(textFile->text, strdup("no_name 0"));
- }
-
- saveTextFile(textFile);
+ char path[STR_PATH_SIZE];
+ int i;
+
+ sprintf(path, "%s/" SCREEN_TABLE_FILE_HIGHSCORE_NAME , getHomeDirector());
+ textFile = loadTextFile(path);
+
+ if( textFile == NULL )
+ {
+ fprintf(stderr, _("I am unable to load: \"%s\" !\n"), path);
+ fprintf(stderr, _("Creating: \"%s\"\n"), path);
+ textFile = newTextFile(path);
+ }
+ else
+ {
+ return;
+ }
+
+ if( textFile == NULL )
+ {
+ fprintf(stderr, _("I was unable to create: \"%s\" !\n"), path);
+ return;
+ }
+
+ for( i = 0 ; i < SCREEN_TABLE_MAX_PLAYERS ; i++ )
+ {
+ addList(textFile->text, strdup("no_name 0") );
+ }
+
+ saveTextFile(textFile);
}
-int
-addPlayerInHighScore(char *name, int score)
+int addPlayerInHighScore(char *name, int score)
{
- int i;
-
- for (i = 0; i < SCREEN_TABLE_MAX_PLAYERS; i++) {
- char *line;
- char thisName[STR_NAME_SIZE];
- int thisCore;
-
- line = (char *) textFile->text->list[i];
- sscanf(line, "%s %d", thisName, &thisCore);
-
- if (score >= thisCore) {
- char new[STR_SIZE];
-
- sprintf(new, "%s %d", name, score);
- insList(textFile->text, i, strdup(new));
- delListItem(textFile->text, SCREEN_TABLE_MAX_PLAYERS, free);
- setWidgetLabel();
-
- return 0;
- }
- }
-
- return -1;
+ int i;
+
+ for( i = 0 ; i < SCREEN_TABLE_MAX_PLAYERS ; i++ )
+ {
+ char *line;
+ char thisName[STR_NAME_SIZE];
+ int thisCore;
+
+ line = (char *) textFile->text->list[i];
+ sscanf(line, "%s %d", thisName, &thisCore);
+
+ if( score >= thisCore )
+ {
+ char new[STR_SIZE];
+
+ sprintf(new, "%s %d", name, score);
+ insList(textFile->text, i, strdup(new) );
+ delListItem(textFile->text, SCREEN_TABLE_MAX_PLAYERS, free);
+ setWidgetLabel();
+
+ return 0;
+ }
+ }
+
+ return -1;
}
-void
-initScreenTable()
+void initScreenTable()
{
- image_t *image;
+ image_t *image;
- image =
- addImageData("screen_table.png", IMAGE_NO_ALPHA, "screen_table",
- IMAGE_GROUP_BASE);
- image_backgorund = newWidgetImage(0, 0, image);
+ image = addImageData("screen_table.png", IMAGE_NO_ALPHA, "screen_table", IMAGE_GROUP_BASE);
+ image_backgorund = newWidgetImage(0, 0, image);
- button_back =
- newWidgetButton(_("back"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2,
- WINDOW_SIZE_Y - 100, eventWidget);
+ button_back = newWidgetButton(_("back"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2,
+ WINDOW_SIZE_Y-100, eventWidget);
- loadHighscoreFile();
- listWidgetLabelNumer = NULL;
- listWidgetLabelName = NULL;
- listWidgetLabelScore = NULL;
- setWidgetLabel();
+ loadHighscoreFile();
+ listWidgetLabelNumer = NULL;
+ listWidgetLabelName = NULL;
+ listWidgetLabelScore = NULL;
+ setWidgetLabel();
- registerScreen(newScreen("table", startScreenTable, eventScreenTable,
- drawScreenTable, stopScreenTable));
+ registerScreen( newScreen("table", startScreenTable, eventScreenTable,
+ drawScreenTable, stopScreenTable) );
}
-void
-quitScreenTable()
+void quitScreenTable()
{
- destroyWidgetImage(image_backgorund);
-
- destroyWidgetButton(button_back);
- destroyListItem(listWidgetLabelNumer, destroyWidgetLabel);
- destroyListItem(listWidgetLabelName, destroyWidgetLabel);
- destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
-
- if (textFile != NULL) {
- saveTextFile(textFile);
- destroyTextFile(textFile);
- }
+ destroyWidgetImage(image_backgorund);
+
+ destroyWidgetButton(button_back);
+ destroyListItem(listWidgetLabelNumer, destroyWidgetLabel);
+ destroyListItem(listWidgetLabelName, destroyWidgetLabel);
+ destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
+
+ if( textFile != NULL )
+ {
+ saveTextFile(textFile);
+ destroyTextFile(textFile);
+ }
}
+
diff --git a/src/screen/screen_table.c~ b/src/screen/screen_table.c~
deleted file mode 100644
index f4c981c..0000000
--- a/src/screen/screen_table.c~
+++ /dev/null
@@ -1,238 +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"
-
-#ifndef NO_SOUND
-#include "music.h"
-#endif
-
-#include "screen_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;
-
-void startScreenTable()
-{
-#ifndef NO_SOUND
- playMusic("menu", MUSIC_GROUP_BASE);
-#endif
-}
-
-void drawScreenTable()
-{
- int i;
-
- drawWidgetImage(image_backgorund);
-
- drawWidgetButton(button_back);
-
- for( i = 0 ; i < listWidgetLabelNumer->count ; i++ )
- {
- widget_t *this;
- this = (widget_t *)listWidgetLabelNumer->list[i];
- drawWidgetLabel(this);
- }
-
- for( i = 0 ; i < listWidgetLabelName->count ; i++ )
- {
- widget_t *this;
- this = (widget_t *)listWidgetLabelName->list[i];
- drawWidgetLabel(this);
- }
-
- for( i = 0 ; i < listWidgetLabelScore->count ; i++ )
- {
- widget_t *this;
- this = (widget_t *)listWidgetLabelScore->list[i];
- drawWidgetLabel(this);
- }
-}
-
-void eventScreenTable()
-{
- eventWidgetButton(button_back);
-}
-
-void stopScreenTable()
-{
-}
-
-static void eventWidget(void *p)
-{
- widget_t *button;
-
- button = (widget_t *)(p);
-
- if( button == button_back )
- {
- setScreen("mainMenu");
- }
-}
-
-static void setWidgetLabel()
-{
- int i;
-
- if( textFile == NULL )
- {
- fprintf(stderr, _("Highscore file: \"%s\" was not loaded!"),
- SCREEN_TABLE_FILE_HIGHSCORE_NAME);
-
- return;
- }
-
- if( listWidgetLabelNumer != NULL ||
- listWidgetLabelName != NULL ||
- listWidgetLabelScore != NULL )
- {
- destroyListItem(listWidgetLabelNumer, destroyWidgetLabel);
- destroyListItem(listWidgetLabelName, destroyWidgetLabel);
- destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
- }
-
- listWidgetLabelNumer = newList();
- listWidgetLabelName = newList();
- listWidgetLabelScore = newList();
-
- for( i = 0 ; i < SCREEN_TABLE_MAX_PLAYERS ; i++ )
- {
- widget_t *label;
- char name[STR_NAME_SIZE];
- char score[STR_NUM_SIZE];
- char num[STR_NUM_SIZE];
- char *line;
-
- line = (char *) textFile->text->list[i];
-
- sscanf(line, "%s %s", name, score);
- sprintf(num, "%2d)", i+1);
-
- label = newWidgetLabel(num, WINDOW_SIZE_X/2 - 100, 200 + i * 20, WIDGET_LABEL_LEFT);
- addList(listWidgetLabelNumer, label);
-
- label = newWidgetLabel(name, WINDOW_SIZE_X/2, 200 + i * 20, WIDGET_LABEL_CENTER);
- addList(listWidgetLabelName, label);
-
- label = newWidgetLabel(score, WINDOW_SIZE_X/2 + 80, 200 + i * 20, WIDGET_LABEL_LEFT);
- addList(listWidgetLabelScore, label);
- }
-}
-
-static void loadHighscoreFile()
-{
- char path[STR_PATH_SIZE];
- int i;
-
- sprintf(path, "%s/" SCREEN_TABLE_FILE_HIGHSCORE_NAME , getHomeDirector());
- textFile = loadTextFile(path);
-
- if( textFile == NULL )
- {
- fprintf(stderr, _("I am unable to load: \"%s\" !\n"), path);
- fprintf(stderr, _("Creating: \"%s\"\n"), path);
- textFile = newTextFile(path);
- }
- else
- {
- return;
- }
-
- if( textFile == NULL )
- {
- fprintf(stderr, _("I was unable to create: \"%s\" !\n"), path);
- return;
- }
-
- for( i = 0 ; i < SCREEN_TABLE_MAX_PLAYERS ; i++ )
- {
- addList(textFile->text, strdup("no_name 0") );
- }
-
- saveTextFile(textFile);
-}
-
-int addPlayerInHighScore(char *name, int score)
-{
- int i;
-
- for( i = 0 ; i < SCREEN_TABLE_MAX_PLAYERS ; i++ )
- {
- char *line;
- char thisName[STR_NAME_SIZE];
- int thisCore;
-
- line = (char *) textFile->text->list[i];
- sscanf(line, "%s %d", thisName, &thisCore);
-
- if( score >= thisCore )
- {
- char new[STR_SIZE];
-
- sprintf(new, "%s %d", name, score);
- insList(textFile->text, i, strdup(new) );
- delListItem(textFile->text, SCREEN_TABLE_MAX_PLAYERS, free);
- setWidgetLabel();
-
- return 0;
- }
- }
-
- return -1;
-}
-
-void initScreenTable()
-{
- image_t *image;
-
- image = addImageData("screen_table.png", IMAGE_NO_ALPHA, "screen_table", IMAGE_GROUP_BASE);
- image_backgorund = newWidgetImage(0, 0, image);
-
- button_back = newWidgetButton(_("back"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2,
- WINDOW_SIZE_Y-100, eventWidget);
-
- loadHighscoreFile();
- listWidgetLabelNumer = NULL;
- listWidgetLabelName = NULL;
- listWidgetLabelScore = NULL;
- setWidgetLabel();
-
- registerScreen( newScreen("table", startScreenTable, eventScreenTable,
- drawScreenTable, stopScreenTable) );
-}
-
-void quitScreenTable()
-{
- destroyWidgetImage(image_backgorund);
-
- destroyWidgetButton(button_back);
- destroyListItem(listWidgetLabelNumer, destroyWidgetLabel);
- destroyListItem(listWidgetLabelName, destroyWidgetLabel);
- destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
-
- if( textFile != NULL )
- {
- saveTextFile(textFile);
- destroyTextFile(textFile);
- }
-}
-
diff --git a/src/screen/screen_world.c b/src/screen/screen_world.c
index 6485d1a..cdf66ab 100644
--- a/src/screen/screen_world.c
+++ b/src/screen/screen_world.c
@@ -53,580 +53,571 @@ static bool_t isEndWorld;
static tux_t *tuxWithControlRightKeyboard;
static tux_t *tuxWithControlLeftKeyboard;
-bool_t
-isScreenWorldInicialized()
+bool_t isScreenWorldInicialized()
{
- return isScreenWorldInit;
+ return isScreenWorldInit;
}
-void
-setGameType()
+void setGameType()
{
- int ret = 0;
+ int ret = 0;
- ret =
- initNetMuliplayer(getSettingGameType(), getSettingIP(),
- getSettingPort(), getSettingProto());
+ ret = initNetMuliplayer( getSettingGameType(), getSettingIP(), getSettingPort(), getSettingProto() );
- if (ret != 0) {
- fprintf(stderr, _("Network initialization error!\n"));
- setWorldEnd();
- }
+ if( ret != 0 )
+ {
+ fprintf(stderr, _("Network initialization error!\n"));
+ setWorldEnd();
+ }
}
-void
-setWorldArena(arenaFile_t * arenaFile)
+void setWorldArena(arenaFile_t *arenaFile)
{
- arena = getArena(arenaFile);
+ arena = getArena(arenaFile);
#ifndef NO_SOUND
- playMusic(arena->music, MUSIC_GROUP_USER);
+ playMusic(arena->music, MUSIC_GROUP_USER);
#endif
}
-void
-setWorldEnd()
+void setWorldEnd()
{
- isEndWorld = TRUE;
+ isEndWorld = TRUE;
}
-static void
-timer_endArena()
+static void timer_endArena()
{
- if (getNetTypeGame() != NET_GAME_TYPE_CLIENT) {
- setWorldEnd();
- return;
- }
+ if( getNetTypeGame() != NET_GAME_TYPE_CLIENT )
+ {
+ setWorldEnd();
+ return;
+ }
}
-void
-countRoundInc()
+void countRoundInc()
{
- 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);
+ 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
- playSound("end", SOUND_GROUP_BASE);
+ playSound("end", SOUND_GROUP_BASE);
#endif
- addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_endArena,
- NULL, TIMER_END_ARENA);
- }
+ addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_endArena, NULL, TIMER_END_ARENA);
+ }
}
-void
-prepareArena()
+void prepareArena()
{
- tux_t *tux;
- char name[STR_NAME_SIZE];
-
- //printf("getSettingAI = %s\n", getSettingAI());
- setCurrentArena(NULL);
- tuxWithControlRightKeyboard = NULL;
- tuxWithControlLeftKeyboard = NULL;
-
- if (getGemeTypeLoadSession() != NULL) {
- loadArena(getGemeTypeLoadSession());
- return;
- }
-
- switch (getNetTypeGame()) {
- case NET_GAME_TYPE_NONE:
- setWorldArena(getChoiceArena());
- addNewItem(arena->spaceItem, ID_UNKNOWN);
- getSettingCountRound(&arena->max_countRound);
-
- tux = newTux();
- tux->control = TUX_CONTROL_KEYBOARD_RIGHT;
- tuxWithControlRightKeyboard = tux;
- getSettingNameRight(name);
- tuxSetName(tux, name);
- addObjectToSpace(arena->spaceTux, tux);
-
- tux = newTux();
- tux->control = TUX_CONTROL_KEYBOARD_LEFT;
- tuxWithControlLeftKeyboard = tux;
- getSettingNameLeft(name);
- tuxSetName(tux, name);
- addObjectToSpace(arena->spaceTux, tux);
-
- if (isSettingAI()) {
- tux->control = TUX_CONTROL_AI;
-
- if (loadModule("libmodAI") != 0) {
- tux->control = TUX_CONTROL_KEYBOARD_LEFT;
- }
- }
-
- //printf("getGemeTypeLoadSession = %s\n", getGemeTypeLoadSession());
-
- break;
-
- case NET_GAME_TYPE_SERVER:
- setWorldArena(getChoiceArena());
- addNewItem(arena->spaceItem, ID_UNKNOWN);
- getSettingCountRound(&arena->max_countRound);
-
- tux = newTux();
- tux->control = TUX_CONTROL_KEYBOARD_RIGHT;
- tuxWithControlRightKeyboard = tux;
- getSettingNameRight(name);
- tuxSetName(tux, name);
- addObjectToSpace(arena->spaceTux, tux);
- break;
-
- case NET_GAME_TYPE_CLIENT:
- break;
- }
+ tux_t *tux;
+ char name[STR_NAME_SIZE];
+
+ //printf("getSettingAI = %s\n", getSettingAI());
+ setCurrentArena(NULL);
+ tuxWithControlRightKeyboard = NULL;
+ tuxWithControlLeftKeyboard = NULL;
+
+ if( getGemeTypeLoadSession() != NULL )
+ {
+ loadArena(getGemeTypeLoadSession());
+ return;
+ }
+
+ switch( getNetTypeGame() )
+ {
+ case NET_GAME_TYPE_NONE :
+ setWorldArena( getChoiceArena() );
+ addNewItem(arena->spaceItem, ID_UNKNOWN);
+ getSettingCountRound(&arena->max_countRound);
+
+ tux = newTux();
+ tux->control = TUX_CONTROL_KEYBOARD_RIGHT;
+ tuxWithControlRightKeyboard = tux;
+ getSettingNameRight(name);
+ tuxSetName(tux, name);
+ addObjectToSpace(arena->spaceTux, tux);
+
+ tux = newTux();
+ tux->control = TUX_CONTROL_KEYBOARD_LEFT;
+ tuxWithControlLeftKeyboard = tux;
+ getSettingNameLeft(name);
+ tuxSetName(tux, name);
+ addObjectToSpace(arena->spaceTux, tux);
+
+ if( isSettingAI() )
+ {
+ tux->control = TUX_CONTROL_AI;
+
+ if( loadModule("libmodAI") != 0 )
+ {
+ tux->control = TUX_CONTROL_KEYBOARD_LEFT;
+ }
+ }
+
+ //printf("getGemeTypeLoadSession = %s\n", getGemeTypeLoadSession());
+
+ break;
+
+ case NET_GAME_TYPE_SERVER :
+ setWorldArena( getChoiceArena() );
+ addNewItem(arena->spaceItem, ID_UNKNOWN);
+ getSettingCountRound(&arena->max_countRound);
+
+ tux = newTux();
+ tux->control = TUX_CONTROL_KEYBOARD_RIGHT;
+ tuxWithControlRightKeyboard = tux;
+ getSettingNameRight(name);
+ tuxSetName(tux, name);
+ addObjectToSpace(arena->spaceTux, tux);
+ break;
+
+ case NET_GAME_TYPE_CLIENT :
+ break;
+ }
}
-void
-drawWorld()
+void drawWorld()
{
- if (arena != NULL) {
- drawArena(arena);
- drawPanel(tuxWithControlRightKeyboard, tuxWithControlLeftKeyboard);
-
- if (arena->w > WINDOW_SIZE_X || arena->h > WINDOW_SIZE_Y) {
- drawRadar(arena);
- }
- }
-
- drawChat();
- drawPauza();
- drawTerm();
- drawSaveDialog();
+ if( arena != NULL )
+ {
+ drawArena(arena);
+ drawPanel(tuxWithControlRightKeyboard, tuxWithControlLeftKeyboard);
+
+ if( arena->w > WINDOW_SIZE_X || arena->h > WINDOW_SIZE_Y )
+ {
+ drawRadar(arena);
+ }
+ }
+
+ drawChat();
+ drawPauza();
+ drawTerm();
+ drawSaveDialog();
}
-static void
-netAction(tux_t * tux, int action)
+static void netAction(tux_t *tux, int action)
{
- if (getSettingGameType() == NET_GAME_TYPE_SERVER) {
- proto_send_event_server(PROTO_SEND_ALL_SEES_TUX, NULL, tux, action);
- }
-
- if (getSettingGameType() == NET_GAME_TYPE_CLIENT) {
- proto_send_event_client(action);
- }
+ if( getSettingGameType() == NET_GAME_TYPE_SERVER )
+ {
+ proto_send_event_server(PROTO_SEND_ALL_SEES_TUX, NULL, tux , action);
+ }
+
+ if( getSettingGameType() == NET_GAME_TYPE_CLIENT )
+ {
+ proto_send_event_client(action);
+ }
}
-static void
-control_keyboard_right(tux_t * tux)
+static void control_keyboard_right(tux_t *tux)
{
- static int lastKey = 0;
- int countKey;
- Uint8 *mapa;
- mapa = SDL_GetKeyState(NULL);
-
- assert(tux != NULL);
- assert(mapa != NULL);
-
- countKey = 0;
-
- if (mapa[(SDLKey) getKey(KEY_TUX_RIGHT_MOVE_UP)] == SDL_PRESSED)
- countKey++;
- if (mapa[(SDLKey) getKey(KEY_TUX_RIGHT_MOVE_RIGHT)] == SDL_PRESSED)
- countKey++;
- if (mapa[(SDLKey) getKey(KEY_TUX_RIGHT_MOVE_LEFT)] == SDL_PRESSED)
- countKey++;
- if (mapa[(SDLKey) getKey(KEY_TUX_RIGHT_MOVE_DOWN)] == SDL_PRESSED)
- countKey++;
-
- if (mapa[(SDLKey) getKey(KEY_TUX_RIGHT_SWITCH_WEAPON)] == SDL_PRESSED
- && tux->isCanSwitchGun == TRUE) {
- netAction(tux, TUX_SWITCH_GUN);
- actionTux(tux, TUX_SWITCH_GUN);
- return;
- }
-
- if (mapa[(SDLKey) getKey(KEY_TUX_RIGHT_SHOOT)] == SDL_PRESSED
- && tux->isCanShot == TRUE) {
- netAction(tux, TUX_SHOT);
- actionTux(tux, TUX_SHOT);
- return;
- }
-
- if (mapa[(SDLKey) getKey(KEY_TUX_RIGHT_MOVE_UP)] == SDL_PRESSED) {
- if (countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_UP))
- goto tuUp;
-
- if (countKey == 1)
- lastKey = getKey(KEY_TUX_RIGHT_MOVE_UP);
- netAction(tux, TUX_UP);
- actionTux(tux, TUX_UP);
- return;
-
- tuUp:;
- }
-
- if (mapa[(SDLKey) getKey(KEY_TUX_RIGHT_MOVE_RIGHT)] == SDL_PRESSED) {
- if (countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_RIGHT))
- goto tuRight;
-
- if (countKey == 1)
- lastKey = getKey(KEY_TUX_RIGHT_MOVE_RIGHT);
- netAction(tux, TUX_RIGHT);
- actionTux(tux, TUX_RIGHT);
- return;
-
- tuRight:;
-
- }
-
- if (mapa[(SDLKey) getKey(KEY_TUX_RIGHT_MOVE_LEFT)] == SDL_PRESSED) {
- if (countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_LEFT))
- goto tuLeft;
-
- if (countKey == 1)
- lastKey = getKey(KEY_TUX_RIGHT_MOVE_LEFT);
- netAction(tux, TUX_LEFT);
- actionTux(tux, TUX_LEFT);
- return;
-
- tuLeft:;
- }
-
- if (mapa[(SDLKey) getKey(KEY_TUX_RIGHT_MOVE_DOWN)] == SDL_PRESSED) {
- if (countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_DOWN))
- goto tuDown;
-
- if (countKey == 1)
- lastKey = getKey(KEY_TUX_RIGHT_MOVE_DOWN);
- netAction(tux, TUX_DOWN);
- actionTux(tux, TUX_DOWN);
- return;
-
- tuDown:;
- }
+ static int lastKey = 0;
+ int countKey;
+ Uint8 *mapa;
+ mapa = SDL_GetKeyState(NULL);
+
+ assert( tux != NULL );
+ assert( mapa != NULL );
+
+ countKey = 0;
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_UP)] == SDL_PRESSED )countKey++;
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_RIGHT)] == SDL_PRESSED )countKey++;
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_LEFT)] == SDL_PRESSED )countKey++;
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_DOWN)] == SDL_PRESSED )countKey++;
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_SWITCH_WEAPON)] == SDL_PRESSED && tux->isCanSwitchGun == TRUE )
+ {
+ netAction(tux, TUX_SWITCH_GUN);
+ actionTux(tux, TUX_SWITCH_GUN);
+ return;
+ }
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_SHOOT)] == SDL_PRESSED && tux->isCanShot == TRUE )
+ {
+ netAction(tux, TUX_SHOT);
+ actionTux(tux, TUX_SHOT);
+ return;
+ }
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_UP)] == SDL_PRESSED )
+ {
+ if(countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_UP) )goto tuUp;
+
+ if( countKey == 1 )lastKey = getKey(KEY_TUX_RIGHT_MOVE_UP);
+ netAction(tux, TUX_UP);
+ actionTux(tux, TUX_UP);
+ return;
+
+ tuUp:;
+ }
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_RIGHT)] == SDL_PRESSED )
+ {
+ if(countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_RIGHT) )goto tuRight;
+
+ if( countKey == 1 )lastKey = getKey(KEY_TUX_RIGHT_MOVE_RIGHT);
+ netAction(tux, TUX_RIGHT);
+ actionTux(tux, TUX_RIGHT);
+ return;
+
+ tuRight:;
+
+ }
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_LEFT)] == SDL_PRESSED )
+ {
+ if(countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_LEFT) )goto tuLeft;
+
+ if( countKey == 1 )lastKey = getKey(KEY_TUX_RIGHT_MOVE_LEFT);
+ netAction(tux, TUX_LEFT);
+ actionTux(tux, TUX_LEFT);
+ return;
+
+ tuLeft:;
+ }
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_DOWN)] == SDL_PRESSED )
+ {
+ if(countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_DOWN) )goto tuDown;
+
+ if( countKey == 1 )lastKey = getKey(KEY_TUX_RIGHT_MOVE_DOWN);
+ netAction(tux, TUX_DOWN);
+ actionTux(tux, TUX_DOWN);
+ return;
+
+ tuDown:;
+ }
}
-static void
-control_keyboard_left(tux_t * tux)
+static void control_keyboard_left(tux_t *tux)
{
- static int lastKey = 0;
- int countKey;
- Uint8 *mapa;
- mapa = SDL_GetKeyState(NULL);
-
- assert(tux != NULL);
- assert(mapa != NULL);
-
- countKey = 0;
-
- if (mapa[(SDLKey) getKey(KEY_TUX_LEFT_MOVE_UP)] == SDL_PRESSED)
- countKey++;
- if (mapa[(SDLKey) getKey(KEY_TUX_LEFT_MOVE_RIGHT)] == SDL_PRESSED)
- countKey++;
- if (mapa[(SDLKey) getKey(KEY_TUX_LEFT_MOVE_LEFT)] == SDL_PRESSED)
- countKey++;
- if (mapa[(SDLKey) getKey(KEY_TUX_LEFT_MOVE_DOWN)] == SDL_PRESSED)
- countKey++;
-
- if (mapa[(SDLKey) getKey(KEY_TUX_LEFT_SWITCH_WEAPON)] == SDL_PRESSED) {
- if (tux->isCanSwitchGun == TRUE) {
- actionTux(tux, TUX_SWITCH_GUN);
- return;
- }
- }
-
- if (mapa[(SDLKey) getKey(KEY_TUX_LEFT_SHOOT)] == SDL_PRESSED
- && tux->isCanShot == TRUE) {
- actionTux(tux, TUX_SHOT);
- return;
- }
-
- if (mapa[(SDLKey) getKey(KEY_TUX_LEFT_MOVE_UP)] == SDL_PRESSED) {
- if (countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_UP))
- goto tuUp;
-
- if (countKey == 1)
- lastKey = getKey(KEY_TUX_LEFT_MOVE_UP);
- actionTux(tux, TUX_UP);
- return;
-
- tuUp:;
- }
-
- if (mapa[(SDLKey) getKey(KEY_TUX_LEFT_MOVE_RIGHT)] == SDL_PRESSED) {
- if (countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_RIGHT))
- goto tuRight;
-
- if (countKey == 1)
- lastKey = getKey(KEY_TUX_LEFT_MOVE_RIGHT);
- actionTux(tux, TUX_RIGHT);
- return;
-
- tuRight:;
-
- }
-
- if (mapa[(SDLKey) getKey(KEY_TUX_LEFT_MOVE_LEFT)] == SDL_PRESSED) {
- if (countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_LEFT))
- goto tuLeft;
-
- if (countKey == 1)
- lastKey = getKey(KEY_TUX_LEFT_MOVE_LEFT);
- actionTux(tux, TUX_LEFT);
- return;
-
- tuLeft:;
- }
-
- if (mapa[(SDLKey) getKey(KEY_TUX_LEFT_MOVE_DOWN)] == SDL_PRESSED) {
- if (countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_DOWN))
- goto tuDown;
-
- if (countKey == 1)
- lastKey = getKey(KEY_TUX_LEFT_MOVE_DOWN);
- actionTux(tux, TUX_DOWN);
- return;
-
- tuDown:;
- }
+ static int lastKey = 0;
+ int countKey;
+ Uint8 *mapa;
+ mapa = SDL_GetKeyState(NULL);
+
+ assert( tux != NULL );
+ assert( mapa != NULL );
+
+ countKey = 0;
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_UP)] == SDL_PRESSED )countKey++;
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_RIGHT)] == SDL_PRESSED )countKey++;
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_LEFT)] == SDL_PRESSED )countKey++;
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_DOWN)] == SDL_PRESSED )countKey++;
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_SWITCH_WEAPON)] == SDL_PRESSED )
+ {
+ if( tux->isCanSwitchGun == TRUE )
+ {
+ actionTux(tux, TUX_SWITCH_GUN);
+ return;
+ }
+ }
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_SHOOT)] == SDL_PRESSED && tux->isCanShot == TRUE )
+ {
+ actionTux(tux, TUX_SHOT);
+ return;
+ }
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_UP)] == SDL_PRESSED )
+ {
+ if(countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_UP) )goto tuUp;
+
+ if( countKey == 1 )lastKey = getKey(KEY_TUX_LEFT_MOVE_UP);
+ actionTux(tux, TUX_UP);
+ return;
+
+ tuUp:;
+ }
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_RIGHT)] == SDL_PRESSED )
+ {
+ if(countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_RIGHT) )goto tuRight;
+
+ if( countKey == 1 )lastKey = getKey(KEY_TUX_LEFT_MOVE_RIGHT);
+ actionTux(tux, TUX_RIGHT);
+ return;
+
+ tuRight:;
+
+ }
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_LEFT)] == SDL_PRESSED )
+ {
+ if(countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_LEFT) )goto tuLeft;
+
+ if( countKey == 1 )lastKey = getKey(KEY_TUX_LEFT_MOVE_LEFT);
+ actionTux(tux, TUX_LEFT);
+ return;
+
+ tuLeft:;
+ }
+
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_DOWN)] == SDL_PRESSED )
+ {
+ if(countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_DOWN) )goto tuDown;
+
+ if( countKey == 1 )lastKey = getKey(KEY_TUX_LEFT_MOVE_DOWN);
+ actionTux(tux, TUX_DOWN);
+ return;
+
+ tuDown:;
+ }
}
-static void
-eventEnd()
+static void eventEnd()
{
- if (isEndWorld == TRUE) {
- setScreen("analyze");
- return;
- }
+ if( isEndWorld == TRUE )
+ {
+ setScreen("analyze");
+ return;
+ }
}
-tux_t *
-getControlTux(int control_type)
+tux_t* getControlTux(int control_type)
{
- switch (control_type) {
- case TUX_CONTROL_KEYBOARD_RIGHT:
- return tuxWithControlRightKeyboard;
- break;
- case TUX_CONTROL_KEYBOARD_LEFT:
- return tuxWithControlLeftKeyboard;
- break;
- }
-
- return NULL;
+ switch(control_type)
+ {
+ case TUX_CONTROL_KEYBOARD_RIGHT :
+ return tuxWithControlRightKeyboard;
+ break;
+ case TUX_CONTROL_KEYBOARD_LEFT :
+ return tuxWithControlLeftKeyboard;
+ break;
+ }
+
+ return NULL;
}
-void
-setControlTux(tux_t * tux, int control_type)
+void setControlTux(tux_t *tux, int control_type)
{
- switch (control_type) {
- case TUX_CONTROL_KEYBOARD_RIGHT:
- tuxWithControlRightKeyboard = tux;
- break;
- case TUX_CONTROL_KEYBOARD_LEFT:
- tuxWithControlLeftKeyboard = tux;
- break;
- }
+ switch(control_type)
+ {
+ case TUX_CONTROL_KEYBOARD_RIGHT :
+ tuxWithControlRightKeyboard = tux;
+ break;
+ case TUX_CONTROL_KEYBOARD_LEFT :
+ tuxWithControlLeftKeyboard = tux;
+ break;
+ }
}
-void
-tuxControl(tux_t * p)
+void tuxControl(tux_t *p)
{
- assert(p != NULL);
-
- if (p->status != TUX_STATUS_ALIVE) {
- return;
- }
-
- switch (p->control) {
- case TUX_CONTROL_NONE:
- assert(!_("Tux has not defined controls!"));
- break;
-
- case TUX_CONTROL_KEYBOARD_LEFT:
- if (isChatActive() == FALSE) {
- control_keyboard_left(p);
- }
- break;
-
- case TUX_CONTROL_KEYBOARD_RIGHT:
- if (isChatActive() == FALSE) {
- control_keyboard_right(p);
- }
- break;
- }
+ assert( p != NULL );
+
+ if( p->status != TUX_STATUS_ALIVE )
+ {
+ return;
+ }
+
+ switch( p->control )
+ {
+ case TUX_CONTROL_NONE :
+ assert( ! _("Tux has not defined controls!") );
+ break;
+
+ case TUX_CONTROL_KEYBOARD_LEFT :
+ if( isChatActive() == FALSE)
+ {
+ control_keyboard_left(p);
+ }
+ break;
+
+ case TUX_CONTROL_KEYBOARD_RIGHT :
+ if( isChatActive() == FALSE)
+ {
+ control_keyboard_right(p);
+ }
+ break;
+ }
}
-void
-eventWorld()
+void eventWorld()
{
- tux_t *thisTux;
-
- if (arena == NULL) {
- eventNetMultiplayer();
- eventEnd();
- return;
- }
-
- eventNetMultiplayer();
-
- if (isPauzeActive() == FALSE && isSaveDialogActive() == FALSE) {
- eventArena(arena);
- //eventModule();
- }
-
- thisTux = getControlTux(TUX_CONTROL_KEYBOARD_RIGHT);
-
- addToRadar(thisTux->id, thisTux->x, thisTux->y, RADAR_TYPE_YOU);
-
- thisTux = getControlTux(TUX_CONTROL_KEYBOARD_LEFT);
-
- if (thisTux != NULL) {
- addToRadar(thisTux->id, thisTux->x, thisTux->y, RADAR_TYPE_TUX);
- }
-
- eventEnd();
- eventChat();
- eventPauza();
- eventTerm();
- eventSaveDialog();
+ tux_t *thisTux;
+
+ if( arena == NULL )
+ {
+ eventNetMultiplayer();
+ eventEnd();
+ return;
+ }
+
+ eventNetMultiplayer();
+
+ if( isPauzeActive() == FALSE && isSaveDialogActive() == FALSE )
+ {
+ eventArena(arena);
+ //eventModule();
+ }
+
+ thisTux = getControlTux(TUX_CONTROL_KEYBOARD_RIGHT);
+
+ addToRadar(thisTux->id,
+ thisTux->x,
+ thisTux->y,
+ RADAR_TYPE_YOU);
+
+ thisTux = getControlTux(TUX_CONTROL_KEYBOARD_LEFT);
+
+ if( thisTux != NULL )
+ {
+ addToRadar(thisTux->id,
+ thisTux->x,
+ thisTux->y,
+ RADAR_TYPE_TUX);
+ }
+
+ eventEnd();
+ eventChat();
+ eventPauza();
+ eventTerm();
+ eventSaveDialog();
}
-static void
-hotkey_escape()
+static void hotkey_escape()
{
- setWorldEnd();
+ setWorldEnd();
}
-void
-startWorld()
+void startWorld()
{
- arena = NULL;
- isEndWorld = FALSE;
-
- registerHotKey(SDLK_ESCAPE, hotkey_escape);
- initArena();
- initListID();
- initRadar();
- initPauza();
- initTerm();
- initSaveDialog();
-
- initModule();
- setGameType();
- initChat();
- prepareArena();
+ arena = NULL;
+ isEndWorld = FALSE;
+
+ registerHotKey(SDLK_ESCAPE, hotkey_escape);
+ initArena();
+ initListID();
+ initRadar();
+ initPauza();
+ initTerm();
+ initSaveDialog();
+
+ initModule();
+ setGameType();
+ initChat();
+ prepareArena();
}
-static void
-action_analyze(space_t * space, tux_t * tux, void *p)
+static void action_analyze(space_t *space, tux_t *tux, void *p)
{
- addAnalyze(tux->name, tux->score);
+ addAnalyze(tux->name, tux->score);
}
-static void
-setAnalyze()
+static void setAnalyze()
{
- restartAnalyze();
+ restartAnalyze();
- actionSpace(arena->spaceTux, action_analyze, NULL);
+ actionSpace(arena->spaceTux, action_analyze, NULL);
- endAnalyze();
+ endAnalyze();
}
-static void
-setTable()
+static void setTable()
{
- tux_t *tuxRight;
- tux_t *tuxLeft;
-
- if (getSettingGameType() != NET_GAME_TYPE_NONE) {
- return;
- }
-
- tuxRight = getControlTux(TUX_CONTROL_KEYBOARD_RIGHT);
- tuxLeft = getControlTux(TUX_CONTROL_KEYBOARD_LEFT);
-
- if (tuxRight->score > tuxLeft->score) {
- addPlayerInHighScore(tuxRight->name, tuxRight->score);
- }
-
- if (tuxLeft->score > tuxRight->score) {
- addPlayerInHighScore(tuxLeft->name, tuxLeft->score);
- }
+ tux_t *tuxRight;
+ tux_t *tuxLeft;
+
+ if( getSettingGameType() != NET_GAME_TYPE_NONE )
+ {
+ return;
+ }
+
+ tuxRight = getControlTux(TUX_CONTROL_KEYBOARD_RIGHT);
+ tuxLeft = getControlTux(TUX_CONTROL_KEYBOARD_LEFT);
+
+ if( tuxRight->score > tuxLeft->score )
+ {
+ addPlayerInHighScore(tuxRight->name, tuxRight->score);
+ }
+
+ if( tuxLeft->score > tuxRight->score )
+ {
+ addPlayerInHighScore(tuxLeft->name, tuxLeft->score);
+ }
}
-void
-stoptWorld()
+void stoptWorld()
{
- if (arena != NULL) {
- setTable();
- setAnalyze();
- }
+ if( arena != NULL )
+ {
+ setTable();
+ setAnalyze();
+ }
- unregisterHotKey(SDLK_ESCAPE);
- quitArena();
+ unregisterHotKey(SDLK_ESCAPE);
+ quitArena();
- quitNetMultiplayer();
+ quitNetMultiplayer();
- if (arena != NULL) {
- destroyArena(arena);
- }
+ if( arena != NULL )
+ {
+ destroyArena(arena);
+ }
- quitRadar();
- quitPauza();
- quitTerm();
- quitSaveDialog();
+ quitRadar();
+ quitPauza();
+ quitTerm();
+ quitSaveDialog();
#ifndef NO_SOUND
- stopMusic();
+ stopMusic();
#endif
- delAllImageInGroup(IMAGE_GROUP_USER);
+ delAllImageInGroup(IMAGE_GROUP_USER);
#ifndef NO_SOUND
- delAllMusicInGroup(MUSIC_GROUP_USER);
+ delAllMusicInGroup(MUSIC_GROUP_USER);
#endif
- quitModule();
- quitChat();
- quitListID();
+ quitModule();
+ quitChat();
+ quitListID();
}
-void
-initWorld()
+void initWorld()
{
- assert(isImageInicialized() == TRUE);
- assert(isTuxInicialized() == TRUE);
- assert(isShotInicialized() == TRUE);
- assert(isPanelInicialized() == TRUE);
- assert(isScreenInicialized() == TRUE);
+ assert( isImageInicialized() == TRUE );
+ assert( isTuxInicialized() == TRUE );
+ assert( isShotInicialized() == TRUE );
+ assert( isPanelInicialized() == TRUE );
+ assert( isScreenInicialized() == TRUE );
- registerScreen(newScreen
- ("world", startWorld, eventWorld, drawWorld, stoptWorld));
+ registerScreen( newScreen("world", startWorld, eventWorld, drawWorld, stoptWorld) );
#ifndef NO_SOUND
- addSound("dead.ogg", "dead", SOUND_GROUP_BASE);
- addSound("explozion.ogg", "explozion", SOUND_GROUP_BASE);
- addSound("gun_lasser.ogg", "gun_lasser", SOUND_GROUP_BASE);
- addSound("gun_revolver.ogg", "gun_revolver", SOUND_GROUP_BASE);
- addSound("gun_scatter.ogg", "gun_scatter", SOUND_GROUP_BASE);
- addSound("gun_tommy.ogg", "gun_tommy", SOUND_GROUP_BASE);
- addSound("put_mine.ogg", "put_mine", SOUND_GROUP_BASE);
- addSound("teleport.ogg", "teleport", SOUND_GROUP_BASE);
- addSound("item_bonus.ogg", "item_bonus", SOUND_GROUP_BASE);
- addSound("item_gun.ogg", "item_gun", SOUND_GROUP_BASE);
- addSound("switch_gun.ogg", "switch_gun", SOUND_GROUP_BASE);
- addSound("end.ogg", "end", SOUND_GROUP_BASE);
+ addSound("dead.ogg", "dead", SOUND_GROUP_BASE);
+ addSound("explozion.ogg", "explozion", SOUND_GROUP_BASE);
+ addSound("gun_lasser.ogg", "gun_lasser", SOUND_GROUP_BASE);
+ addSound("gun_revolver.ogg", "gun_revolver", SOUND_GROUP_BASE);
+ addSound("gun_scatter.ogg", "gun_scatter", SOUND_GROUP_BASE);
+ addSound("gun_tommy.ogg", "gun_tommy", SOUND_GROUP_BASE);
+ addSound("put_mine.ogg", "put_mine", SOUND_GROUP_BASE);
+ addSound("teleport.ogg", "teleport", SOUND_GROUP_BASE);
+ addSound("item_bonus.ogg", "item_bonus", SOUND_GROUP_BASE);
+ addSound("item_gun.ogg", "item_gun", SOUND_GROUP_BASE);
+ addSound("switch_gun.ogg", "switch_gun", SOUND_GROUP_BASE);
+ addSound("end.ogg", "end", SOUND_GROUP_BASE);
#endif
- isScreenWorldInit = TRUE;
+ isScreenWorldInit = TRUE;
}
-void
-quitWorld()
+void quitWorld()
{
#ifdef DEBUG
- printf(_("Quitting screen world\n"));
+ printf(_("Quitting screen world\n"));
#endif
- isScreenWorldInit = FALSE;
+ isScreenWorldInit = FALSE;
}
diff --git a/src/screen/screen_world.c~ b/src/screen/screen_world.c~
deleted file mode 100644
index cdf66ab..0000000
--- a/src/screen/screen_world.c~
+++ /dev/null
@@ -1,623 +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 "saveLoad.h"
-
-#ifndef NO_SOUND
-#include "music.h"
-#include "sound.h"
-#endif
-
-#include "screen.h"
-#include "screen_world.h"
-#include "screen_analyze.h"
-#include "screen_setting.h"
-#include "screen_gameType.h"
-#include "screen_settingKeys.h"
-#include "screen_choiceArena.h"
-#include "screen_table.h"
-
-
-static arena_t *arena;
-static bool_t isScreenWorldInit = FALSE;
-static bool_t isEndWorld;
-
-static tux_t *tuxWithControlRightKeyboard;
-static tux_t *tuxWithControlLeftKeyboard;
-
-bool_t isScreenWorldInicialized()
-{
- return isScreenWorldInit;
-}
-
-void setGameType()
-{
- int ret = 0;
-
- ret = initNetMuliplayer( getSettingGameType(), getSettingIP(), getSettingPort(), getSettingProto() );
-
- if( ret != 0 )
- {
- fprintf(stderr, _("Network initialization error!\n"));
- setWorldEnd();
- }
-}
-
-void setWorldArena(arenaFile_t *arenaFile)
-{
- arena = getArena(arenaFile);
-
-#ifndef NO_SOUND
- playMusic(arena->music, MUSIC_GROUP_USER);
-#endif
-}
-
-void setWorldEnd()
-{
- isEndWorld = TRUE;
-}
-
-static void timer_endArena()
-{
- if( getNetTypeGame() != NET_GAME_TYPE_CLIENT )
- {
- setWorldEnd();
- return;
- }
-}
-
-void countRoundInc()
-{
- 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
- playSound("end", SOUND_GROUP_BASE);
-#endif
- addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_endArena, NULL, TIMER_END_ARENA);
- }
-}
-
-void prepareArena()
-{
- tux_t *tux;
- char name[STR_NAME_SIZE];
-
- //printf("getSettingAI = %s\n", getSettingAI());
- setCurrentArena(NULL);
- tuxWithControlRightKeyboard = NULL;
- tuxWithControlLeftKeyboard = NULL;
-
- if( getGemeTypeLoadSession() != NULL )
- {
- loadArena(getGemeTypeLoadSession());
- return;
- }
-
- switch( getNetTypeGame() )
- {
- case NET_GAME_TYPE_NONE :
- setWorldArena( getChoiceArena() );
- addNewItem(arena->spaceItem, ID_UNKNOWN);
- getSettingCountRound(&arena->max_countRound);
-
- tux = newTux();
- tux->control = TUX_CONTROL_KEYBOARD_RIGHT;
- tuxWithControlRightKeyboard = tux;
- getSettingNameRight(name);
- tuxSetName(tux, name);
- addObjectToSpace(arena->spaceTux, tux);
-
- tux = newTux();
- tux->control = TUX_CONTROL_KEYBOARD_LEFT;
- tuxWithControlLeftKeyboard = tux;
- getSettingNameLeft(name);
- tuxSetName(tux, name);
- addObjectToSpace(arena->spaceTux, tux);
-
- if( isSettingAI() )
- {
- tux->control = TUX_CONTROL_AI;
-
- if( loadModule("libmodAI") != 0 )
- {
- tux->control = TUX_CONTROL_KEYBOARD_LEFT;
- }
- }
-
- //printf("getGemeTypeLoadSession = %s\n", getGemeTypeLoadSession());
-
- break;
-
- case NET_GAME_TYPE_SERVER :
- setWorldArena( getChoiceArena() );
- addNewItem(arena->spaceItem, ID_UNKNOWN);
- getSettingCountRound(&arena->max_countRound);
-
- tux = newTux();
- tux->control = TUX_CONTROL_KEYBOARD_RIGHT;
- tuxWithControlRightKeyboard = tux;
- getSettingNameRight(name);
- tuxSetName(tux, name);
- addObjectToSpace(arena->spaceTux, tux);
- break;
-
- case NET_GAME_TYPE_CLIENT :
- break;
- }
-}
-
-void drawWorld()
-{
- if( arena != NULL )
- {
- drawArena(arena);
- drawPanel(tuxWithControlRightKeyboard, tuxWithControlLeftKeyboard);
-
- if( arena->w > WINDOW_SIZE_X || arena->h > WINDOW_SIZE_Y )
- {
- drawRadar(arena);
- }
- }
-
- drawChat();
- drawPauza();
- drawTerm();
- drawSaveDialog();
-}
-
-static void netAction(tux_t *tux, int action)
-{
- if( getSettingGameType() == NET_GAME_TYPE_SERVER )
- {
- proto_send_event_server(PROTO_SEND_ALL_SEES_TUX, NULL, tux , action);
- }
-
- if( getSettingGameType() == NET_GAME_TYPE_CLIENT )
- {
- proto_send_event_client(action);
- }
-}
-
-static void control_keyboard_right(tux_t *tux)
-{
- static int lastKey = 0;
- int countKey;
- Uint8 *mapa;
- mapa = SDL_GetKeyState(NULL);
-
- assert( tux != NULL );
- assert( mapa != NULL );
-
- countKey = 0;
-
- if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_UP)] == SDL_PRESSED )countKey++;
- if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_RIGHT)] == SDL_PRESSED )countKey++;
- if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_LEFT)] == SDL_PRESSED )countKey++;
- if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_DOWN)] == SDL_PRESSED )countKey++;
-
- if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_SWITCH_WEAPON)] == SDL_PRESSED && tux->isCanSwitchGun == TRUE )
- {
- netAction(tux, TUX_SWITCH_GUN);
- actionTux(tux, TUX_SWITCH_GUN);
- return;
- }
-
- if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_SHOOT)] == SDL_PRESSED && tux->isCanShot == TRUE )
- {
- netAction(tux, TUX_SHOT);
- actionTux(tux, TUX_SHOT);
- return;
- }
-
- if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_UP)] == SDL_PRESSED )
- {
- if(countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_UP) )goto tuUp;
-
- if( countKey == 1 )lastKey = getKey(KEY_TUX_RIGHT_MOVE_UP);
- netAction(tux, TUX_UP);
- actionTux(tux, TUX_UP);
- return;
-
- tuUp:;
- }
-
- if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_RIGHT)] == SDL_PRESSED )
- {
- if(countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_RIGHT) )goto tuRight;
-
- if( countKey == 1 )lastKey = getKey(KEY_TUX_RIGHT_MOVE_RIGHT);
- netAction(tux, TUX_RIGHT);
- actionTux(tux, TUX_RIGHT);
- return;
-
- tuRight:;
-
- }
-
- if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_LEFT)] == SDL_PRESSED )
- {
- if(countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_LEFT) )goto tuLeft;
-
- if( countKey == 1 )lastKey = getKey(KEY_TUX_RIGHT_MOVE_LEFT);
- netAction(tux, TUX_LEFT);
- actionTux(tux, TUX_LEFT);
- return;
-
- tuLeft:;
- }
-
- if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_DOWN)] == SDL_PRESSED )
- {
- if(countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_DOWN) )goto tuDown;
-
- if( countKey == 1 )lastKey = getKey(KEY_TUX_RIGHT_MOVE_DOWN);
- netAction(tux, TUX_DOWN);
- actionTux(tux, TUX_DOWN);
- return;
-
- tuDown:;
- }
-}
-
-static void control_keyboard_left(tux_t *tux)
-{
- static int lastKey = 0;
- int countKey;
- Uint8 *mapa;
- mapa = SDL_GetKeyState(NULL);
-
- assert( tux != NULL );
- assert( mapa != NULL );
-
- countKey = 0;
-
- if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_UP)] == SDL_PRESSED )countKey++;
- if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_RIGHT)] == SDL_PRESSED )countKey++;
- if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_LEFT)] == SDL_PRESSED )countKey++;
- if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_DOWN)] == SDL_PRESSED )countKey++;
-
- if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_SWITCH_WEAPON)] == SDL_PRESSED )
- {
- if( tux->isCanSwitchGun == TRUE )
- {
- actionTux(tux, TUX_SWITCH_GUN);
- return;
- }
- }
-
- if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_SHOOT)] == SDL_PRESSED && tux->isCanShot == TRUE )
- {
- actionTux(tux, TUX_SHOT);
- return;
- }
-
- if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_UP)] == SDL_PRESSED )
- {
- if(countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_UP) )goto tuUp;
-
- if( countKey == 1 )lastKey = getKey(KEY_TUX_LEFT_MOVE_UP);
- actionTux(tux, TUX_UP);
- return;
-
- tuUp:;
- }
-
- if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_RIGHT)] == SDL_PRESSED )
- {
- if(countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_RIGHT) )goto tuRight;
-
- if( countKey == 1 )lastKey = getKey(KEY_TUX_LEFT_MOVE_RIGHT);
- actionTux(tux, TUX_RIGHT);
- return;
-
- tuRight:;
-
- }
-
- if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_LEFT)] == SDL_PRESSED )
- {
- if(countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_LEFT) )goto tuLeft;
-
- if( countKey == 1 )lastKey = getKey(KEY_TUX_LEFT_MOVE_LEFT);
- actionTux(tux, TUX_LEFT);
- return;
-
- tuLeft:;
- }
-
- if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_DOWN)] == SDL_PRESSED )
- {
- if(countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_DOWN) )goto tuDown;
-
- if( countKey == 1 )lastKey = getKey(KEY_TUX_LEFT_MOVE_DOWN);
- actionTux(tux, TUX_DOWN);
- return;
-
- tuDown:;
- }
-}
-
-static void eventEnd()
-{
- if( isEndWorld == TRUE )
- {
- setScreen("analyze");
- return;
- }
-}
-
-tux_t* getControlTux(int control_type)
-{
- switch(control_type)
- {
- case TUX_CONTROL_KEYBOARD_RIGHT :
- return tuxWithControlRightKeyboard;
- break;
- case TUX_CONTROL_KEYBOARD_LEFT :
- return tuxWithControlLeftKeyboard;
- break;
- }
-
- return NULL;
-}
-
-void setControlTux(tux_t *tux, int control_type)
-{
- switch(control_type)
- {
- case TUX_CONTROL_KEYBOARD_RIGHT :
- tuxWithControlRightKeyboard = tux;
- break;
- case TUX_CONTROL_KEYBOARD_LEFT :
- tuxWithControlLeftKeyboard = tux;
- break;
- }
-}
-
-void tuxControl(tux_t *p)
-{
- assert( p != NULL );
-
- if( p->status != TUX_STATUS_ALIVE )
- {
- return;
- }
-
- switch( p->control )
- {
- case TUX_CONTROL_NONE :
- assert( ! _("Tux has not defined controls!") );
- break;
-
- case TUX_CONTROL_KEYBOARD_LEFT :
- if( isChatActive() == FALSE)
- {
- control_keyboard_left(p);
- }
- break;
-
- case TUX_CONTROL_KEYBOARD_RIGHT :
- if( isChatActive() == FALSE)
- {
- control_keyboard_right(p);
- }
- break;
- }
-}
-
-void eventWorld()
-{
- tux_t *thisTux;
-
- if( arena == NULL )
- {
- eventNetMultiplayer();
- eventEnd();
- return;
- }
-
- eventNetMultiplayer();
-
- if( isPauzeActive() == FALSE && isSaveDialogActive() == FALSE )
- {
- eventArena(arena);
- //eventModule();
- }
-
- thisTux = getControlTux(TUX_CONTROL_KEYBOARD_RIGHT);
-
- addToRadar(thisTux->id,
- thisTux->x,
- thisTux->y,
- RADAR_TYPE_YOU);
-
- thisTux = getControlTux(TUX_CONTROL_KEYBOARD_LEFT);
-
- if( thisTux != NULL )
- {
- addToRadar(thisTux->id,
- thisTux->x,
- thisTux->y,
- RADAR_TYPE_TUX);
- }
-
- eventEnd();
- eventChat();
- eventPauza();
- eventTerm();
- eventSaveDialog();
-
-}
-
-static void hotkey_escape()
-{
- setWorldEnd();
-}
-
-void startWorld()
-{
- arena = NULL;
- isEndWorld = FALSE;
-
- registerHotKey(SDLK_ESCAPE, hotkey_escape);
- initArena();
- initListID();
- initRadar();
- initPauza();
- initTerm();
- initSaveDialog();
-
- initModule();
- setGameType();
- initChat();
- prepareArena();
-}
-
-static void action_analyze(space_t *space, tux_t *tux, void *p)
-{
- addAnalyze(tux->name, tux->score);
-}
-
-static void setAnalyze()
-{
- restartAnalyze();
-
- actionSpace(arena->spaceTux, action_analyze, NULL);
-
- endAnalyze();
-}
-
-static void setTable()
-{
- tux_t *tuxRight;
- tux_t *tuxLeft;
-
- if( getSettingGameType() != NET_GAME_TYPE_NONE )
- {
- return;
- }
-
- tuxRight = getControlTux(TUX_CONTROL_KEYBOARD_RIGHT);
- tuxLeft = getControlTux(TUX_CONTROL_KEYBOARD_LEFT);
-
- if( tuxRight->score > tuxLeft->score )
- {
- addPlayerInHighScore(tuxRight->name, tuxRight->score);
- }
-
- if( tuxLeft->score > tuxRight->score )
- {
- addPlayerInHighScore(tuxLeft->name, tuxLeft->score);
- }
-}
-
-void stoptWorld()
-{
- if( arena != NULL )
- {
- setTable();
- setAnalyze();
- }
-
- unregisterHotKey(SDLK_ESCAPE);
- quitArena();
-
- quitNetMultiplayer();
-
- if( arena != NULL )
- {
- destroyArena(arena);
- }
-
- quitRadar();
- quitPauza();
- quitTerm();
- quitSaveDialog();
-
-
-#ifndef NO_SOUND
- stopMusic();
-#endif
- delAllImageInGroup(IMAGE_GROUP_USER);
-
-#ifndef NO_SOUND
- delAllMusicInGroup(MUSIC_GROUP_USER);
-#endif
- quitModule();
- quitChat();
- quitListID();
-}
-
-void initWorld()
-{
- assert( isImageInicialized() == TRUE );
- assert( isTuxInicialized() == TRUE );
- assert( isShotInicialized() == TRUE );
- assert( isPanelInicialized() == TRUE );
- assert( isScreenInicialized() == TRUE );
-
- registerScreen( newScreen("world", startWorld, eventWorld, drawWorld, stoptWorld) );
-
-#ifndef NO_SOUND
- addSound("dead.ogg", "dead", SOUND_GROUP_BASE);
- addSound("explozion.ogg", "explozion", SOUND_GROUP_BASE);
- addSound("gun_lasser.ogg", "gun_lasser", SOUND_GROUP_BASE);
- addSound("gun_revolver.ogg", "gun_revolver", SOUND_GROUP_BASE);
- addSound("gun_scatter.ogg", "gun_scatter", SOUND_GROUP_BASE);
- addSound("gun_tommy.ogg", "gun_tommy", SOUND_GROUP_BASE);
- addSound("put_mine.ogg", "put_mine", SOUND_GROUP_BASE);
- addSound("teleport.ogg", "teleport", SOUND_GROUP_BASE);
- addSound("item_bonus.ogg", "item_bonus", SOUND_GROUP_BASE);
- addSound("item_gun.ogg", "item_gun", SOUND_GROUP_BASE);
- addSound("switch_gun.ogg", "switch_gun", SOUND_GROUP_BASE);
- addSound("end.ogg", "end", SOUND_GROUP_BASE);
-#endif
-
- isScreenWorldInit = TRUE;
-}
-
-void quitWorld()
-{
-#ifdef DEBUG
- printf(_("Quitting screen world\n"));
-#endif
- isScreenWorldInit = FALSE;
-}