summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/chat.c14
-rw-r--r--src/client/client.c8
-rw-r--r--src/client/configFile.c11
-rw-r--r--src/client/font.c2
-rw-r--r--src/client/image.c4
-rw-r--r--src/client/interface.c5
-rw-r--r--src/client/keyboardBuffer.c4
-rw-r--r--src/client/layer.c22
-rw-r--r--src/client/panel.c83
-rw-r--r--src/client/pauza.c9
-rw-r--r--src/client/radar.c18
-rw-r--r--src/client/saveDialog.c45
-rw-r--r--src/client/screen.c5
-rw-r--r--src/client/term.c60
-rw-r--r--src/net/tcp.c17
-rw-r--r--src/net/udp.c34
-rw-r--r--src/screen/screen_analyze.c30
-rw-r--r--src/screen/screen_choiceArena.c25
-rw-r--r--src/screen/screen_downArena.c10
-rw-r--r--src/screen/screen_gameType.c51
-rw-r--r--src/screen/screen_mainMenu.c30
-rw-r--r--src/screen/screen_setting.c205
-rw-r--r--src/screen/screen_settingKeys.c847
-rw-r--r--src/screen/screen_table.c31
-rw-r--r--src/screen/screen_world.c68
-rw-r--r--src/widget/widget.c2
-rw-r--r--src/widget/widget_button.c28
-rw-r--r--src/widget/widget_buttonimage.c6
-rw-r--r--src/widget/widget_catchkey.c8
-rw-r--r--src/widget/widget_check.c16
-rw-r--r--src/widget/widget_choicegroup.c16
-rw-r--r--src/widget/widget_label.c19
-rw-r--r--src/widget/widget_select.c8
-rw-r--r--src/widget/widget_textfield.c93
34 files changed, 897 insertions, 937 deletions
diff --git a/src/client/chat.c b/src/client/chat.c
index ceb4796..a6cc094 100644
--- a/src/client/chat.c
+++ b/src/client/chat.c
@@ -47,8 +47,7 @@ static void hotkey_chat()
void initChat()
{
- g_chat =
- addImageData("chat.png", IMAGE_NO_ALPHA, "chat", IMAGE_GROUP_USER);
+ g_chat = addImageData("chat.png", IMAGE_NO_ALPHA, "chat", IMAGE_GROUP_USER);
listText = newList();
strcpy(line, "");
@@ -70,8 +69,7 @@ void drawChat()
return;
}
- drawImage(g_chat,
- CHAT_LOCATION_X, CHAT_LOCATION_Y,
+ drawImage(g_chat, CHAT_LOCATION_X, CHAT_LOCATION_Y,
0, 0, CHAT_SIZE_X, CHAT_SIZE_Y);
for (i = 0; i < listText->count; i++) {
@@ -79,9 +77,8 @@ void drawChat()
s = (char *) listText->list[i];
- drawFontMaxSize(s,
- CHAT_LOCATION_X + 5, CHAT_LOCATION_Y + 5 + i * 20,
- CHAT_SIZE_X - 10, 20, COLOR_WHITE);
+ drawFontMaxSize(s, CHAT_LOCATION_X + 5, CHAT_LOCATION_Y + 5 + i * 20,
+ CHAT_SIZE_X - 10, 20, COLOR_WHITE);
}
strcpy(str, line);
@@ -96,8 +93,7 @@ void drawChat()
timeBlick = 0;
}
- drawFont(str, CHAT_LOCATION_X + 5,
- (CHAT_LOCATION_Y + 5) + (CHAT_MAX_LINES * 20), COLOR_WHITE);
+ drawFont(str, CHAT_LOCATION_X + 5, (CHAT_LOCATION_Y + 5) + (CHAT_MAX_LINES * 20), COLOR_WHITE);
}
static void processMessageKey(SDL_keysym keysym)
diff --git a/src/client/client.c b/src/client/client.c
index 11d8018..e92a238 100644
--- a/src/client/client.c
+++ b/src/client/client.c
@@ -157,8 +157,7 @@ void sendServer(char *msg)
#endif
if (sock_server_udp != NULL) {
- ret =
- writeUdpSocket(sock_server_udp, sock_server_udp, msg, strlen(msg));
+ ret = writeUdpSocket(sock_server_udp, sock_server_udp, msg, strlen(msg));
}
if (ret < 0) {
@@ -176,15 +175,14 @@ static int eventServerSelect()
ret = -1;
if (sock_server_udp != NULL) {
- ret =
- readUdpSocket(sock_server_udp, sock_server_udp, buffer,
- STR_PROTO_SIZE - 1);
+ ret = readUdpSocket(sock_server_udp, sock_server_udp, buffer, STR_PROTO_SIZE - 1);
}
if (ret < 0) {
errorWithServer();
return ret;
}
+
#ifdef SUPPORT_TRAFFIC
traffic_down += ret;
#endif
diff --git a/src/client/configFile.c b/src/client/configFile.c
index afdbf9f..74509fe 100644
--- a/src/client/configFile.c
+++ b/src/client/configFile.c
@@ -30,18 +30,22 @@ int getValue(char *line, char *env, char *val, int len)
strcpy(clone_env, env);
offset_env = strstr(line, clone_env);
+
if (offset_env == NULL)
return -1;
offset_val_begin = strchr(offset_env, '"');
+
if (offset_val_begin == NULL)
return -1;
offset_val_end = strchr(offset_val_begin + 1, '"');
+
if (offset_val_end == NULL)
return -1;
val_len = (int) (offset_val_end - (offset_val_begin + 1));
+
if (val_len > len - 1)
val_len = len - 1;
@@ -63,14 +67,17 @@ char *setValue(char *line, char *env, char *val)
strcpy(clone_env, env);
offset_env = strstr(line, clone_env);
+
if (offset_env == NULL)
return NULL;
offset_val_begin = strchr(offset_env, '"');
+
if (offset_val_begin == NULL)
return NULL;
offset_val_end = strchr(offset_val_begin + 1, '"');
+
if (offset_val_end == NULL)
return NULL;
@@ -124,9 +131,7 @@ int setValueInConfigFile(textFile_t * textFile, char *env, char *val)
return -1;
}
-void
-loadValueFromConfigFile(textFile_t * textFile, char *env, char *val, int len,
- char *butVal)
+void loadValueFromConfigFile(textFile_t * textFile, char *env, char *val, int len, char *butVal)
{
strcpy(val, butVal);
diff --git a/src/client/font.c b/src/client/font.c
index 3473a1d..52963b6 100644
--- a/src/client/font.c
+++ b/src/client/font.c
@@ -74,10 +74,8 @@ void drawFontMaxSize(char *s, int x, int y, int w, int h, int r, int g, int b)
assert(s != NULL);
-
text = TTF_RenderUTF8_Blended(g_font, s, font_color);
-
my_w = text->w;
if (my_w > w) {
diff --git a/src/client/image.c b/src/client/image.c
index e5b0c3e..711d8b4 100644
--- a/src/client/image.c
+++ b/src/client/image.c
@@ -53,9 +53,7 @@ static SDL_Surface *loadImage(const char *filename, int alpha)
return NULL;
}
- if ((ret =
- (alpha) ? SDL_DisplayFormatAlpha(tmp) : SDL_DisplayFormat(tmp)) ==
- NULL) {
+ if ((ret = (alpha) ? SDL_DisplayFormatAlpha(tmp) : SDL_DisplayFormat(tmp)) == NULL) {
fprintf(stderr, "%s\n", SDL_GetError());
SDL_FreeSurface(tmp);
return NULL;
diff --git a/src/client/interface.c b/src/client/interface.c
index d64ba36..33c4001 100644
--- a/src/client/interface.c
+++ b/src/client/interface.c
@@ -70,9 +70,7 @@ void hotkey_screen()
fprintf(stderr, _("Unable to switch to FULLSCREEN mode!\n"));
SDL_FreeSurface(screen);
- screen =
- SDL_SetVideoMode(WINDOW_SIZE_X, WINDOW_SIZE_Y, WIN_BPP,
- g_win_flags);
+ screen = SDL_SetVideoMode(WINDOW_SIZE_X, WINDOW_SIZE_Y, WIN_BPP, g_win_flags);
if (screen == NULL) {
fprintf(stderr, _("Unable to switch to WINDOW mode! Error: %s\n"),
@@ -216,7 +214,6 @@ void printPressAnyKey()
}
-
int hack_slow()
{
static time_t lastTime = 0;
diff --git a/src/client/keyboardBuffer.c b/src/client/keyboardBuffer.c
index 4c24e9b..0454bdb 100644
--- a/src/client/keyboardBuffer.c
+++ b/src/client/keyboardBuffer.c
@@ -66,8 +66,7 @@ bool_t pushKeyToKeyboardBuffer(SDL_keysym key)
assert(keyboardBuffer != NULL);
if (keyboardBuffer->count >= keyboardBuffer->size) {
- fprintf(stderr, _("Keyboard Buffer overrun! Dropping key: %02x\n"),
- key.sym);
+ fprintf(stderr, _("Keyboard Buffer overrun! Dropping key: %02x\n"), key.sym);
return FALSE;
}
@@ -100,6 +99,7 @@ SDL_keysym popKeyFromKeyboardBuffer()
keyboardBuffer->buff[keyboardBuffer->begin] = emptyKey;
keyboardBuffer->begin++;
+
if (keyboardBuffer->begin >= keyboardBuffer->size) {
keyboardBuffer->begin = 0;
}
diff --git a/src/client/layer.c b/src/client/layer.c
index c1ca8db..983a9c8 100644
--- a/src/client/layer.c
+++ b/src/client/layer.c
@@ -39,8 +39,7 @@ void initLayer()
* layer - on which layer to draw
* (0 - under tuxanci | 1 - same as tuxanci | 2 - over tuxancami)
*/
-void
-addLayer(image_t * img, int x, int y, int px, int py, int w, int h, int player)
+void addLayer(image_t * img, int x, int y, int px, int py, int w, int h, int player)
{
layer_t *new;
layer_t *actual;
@@ -89,6 +88,7 @@ addLayer(image_t * img, int x, int y, int px, int py, int w, int h, int player)
return;
};
};
+
if (i >= listLayer->count)
break;
@@ -134,15 +134,15 @@ void drawLayerCenter(int x, int y)
for (i = 0; i < listLayer->count; i++) {
this = (layer_t *) listLayer->list[i];
- if (this->x + this->w < screen_x || this->x > screen_x + WINDOW_SIZE_X
- || this->y + this->h < screen_y
- || this->y > screen_y + WINDOW_SIZE_Y) {
+ if (this->x + this->w < screen_x ||
+ this->x > screen_x + WINDOW_SIZE_X ||
+ this->y + this->h < screen_y ||
+ this->y > screen_y + WINDOW_SIZE_Y) {
continue;
}
//count++;
- drawImage(this->image,
- this->x - screen_x, this->y - screen_y,
+ drawImage(this->image, this->x - screen_x, this->y - screen_y,
this->px, this->py, this->w, this->h);
//printf("%d %d\n", this->x - screen_x, this->y - screen_y);
@@ -164,9 +164,10 @@ void drawLayerSplit(int local_x, int local_y, int x, int y, int w, int h)
this = (layer_t *) listLayer->list[i];
if (this->x + this->w < x || this->x > x + w ||
- this->y + this->h < y || this->y > y + h) {
+ this->y + this->h < y || this->y > y + h) {
continue;
}
+
//count++;
if (local_x + (this->x - x) < local_x) {
@@ -197,9 +198,8 @@ void drawLayerSplit(int local_x, int local_y, int x, int y, int w, int h)
this->h -= (local_y + (this->y - y) + this->h) - (local_y + h);
}
- drawImage(this->image,
- local_x + (this->x - x), local_y + (this->y - y),
- this->px, this->py, this->w, this->h);
+ drawImage(this->image, local_x + (this->x - x), local_y + (this->y - y),
+ this->px, this->py, this->w, this->h);
//printf("%d %d\n", this->x - screen_x, this->y - screen_y);
}
diff --git a/src/client/panel.c b/src/client/panel.c
index ea87c1a..b7d0360 100644
--- a/src/client/panel.c
+++ b/src/client/panel.c
@@ -29,55 +29,22 @@ void initPanel()
assert(isImageInicialized() == TRUE);
assert(isInterfaceInicialized() == TRUE);
- g_panel =
- addImageData("panel.png", IMAGE_ALPHA, "panel", IMAGE_GROUP_BASE);
- g_shot =
- addImageData("panel_shot.png", IMAGE_ALPHA, "panel_image_shot",
- IMAGE_GROUP_BASE);
- g_bonus =
- addImageData("graf.bonus.png", IMAGE_ALPHA, "panel_graf_bonus",
- IMAGE_GROUP_BASE);
-
- g_icon[GUN_SIMPLE] =
- addImageData("icon.gun.simple.png", IMAGE_ALPHA, "panel_gun",
- IMAGE_GROUP_BASE);
- g_icon[GUN_DUAL_SIMPLE] =
- addImageData("icon.gun.dual.simple.png", IMAGE_ALPHA, "panel_dual",
- IMAGE_GROUP_BASE);
- g_icon[GUN_TOMMY] =
- addImageData("icon.gun.tommy.png", IMAGE_ALPHA, "panel_tommy",
- IMAGE_GROUP_BASE);
- g_icon[GUN_SCATTER] =
- addImageData("icon.gun.scatter.png", IMAGE_ALPHA, "panel_scatter",
- IMAGE_GROUP_BASE);
- g_icon[GUN_LASSER] =
- addImageData("icon.gun.lasser.png", IMAGE_ALPHA, "panel_lasser",
- IMAGE_GROUP_BASE);
- g_icon[GUN_MINE] =
- addImageData("icon.gun.mine.png", IMAGE_ALPHA, "panel_mine",
- IMAGE_GROUP_BASE);
- g_icon[GUN_BOMBBALL] =
- addImageData("icon.gun.bombball.png", IMAGE_ALPHA, "panel_bombball",
- IMAGE_GROUP_BASE);
-
- g_icon[BONUS_SPEED] =
- addImageData("icon.bonus.speed.png", IMAGE_ALPHA, "panel_speed",
- IMAGE_GROUP_BASE);
- g_icon[BONUS_SHOT] =
- addImageData("icon.bonus.shot.png", IMAGE_ALPHA, "panel_shot",
- IMAGE_GROUP_BASE);
- g_icon[BONUS_TELEPORT] =
- addImageData("icon.bonus.teleport.png", IMAGE_ALPHA, "panel_teleport",
- IMAGE_GROUP_BASE);
- g_icon[BONUS_GHOST] =
- addImageData("icon.bonus.ghost.png", IMAGE_ALPHA, "panel_ghost",
- IMAGE_GROUP_BASE);
- g_icon[BONUS_4X] =
- addImageData("icon.bonus.4x.png", IMAGE_ALPHA, "panel_4x",
- IMAGE_GROUP_BASE);
- g_icon[BONUS_HIDDEN] =
- addImageData("icon.bonus.hidden.png", IMAGE_ALPHA, "panel_hidden",
- IMAGE_GROUP_BASE);
+ g_panel = addImageData("panel.png", IMAGE_ALPHA, "panel", IMAGE_GROUP_BASE);
+ g_shot = addImageData("panel_shot.png", IMAGE_ALPHA, "panel_image_shot",IMAGE_GROUP_BASE);
+ g_bonus = addImageData("graf.bonus.png", IMAGE_ALPHA, "panel_graf_bonus", IMAGE_GROUP_BASE);
+ g_icon[GUN_SIMPLE] = addImageData("icon.gun.simple.png", IMAGE_ALPHA, "panel_gun", IMAGE_GROUP_BASE);
+ g_icon[GUN_DUAL_SIMPLE] = addImageData("icon.gun.dual.simple.png", IMAGE_ALPHA, "panel_dual", IMAGE_GROUP_BASE);
+ g_icon[GUN_TOMMY] = addImageData("icon.gun.tommy.png", IMAGE_ALPHA, "panel_tommy", IMAGE_GROUP_BASE);
+ g_icon[GUN_SCATTER] = addImageData("icon.gun.scatter.png", IMAGE_ALPHA, "panel_scatter", IMAGE_GROUP_BASE);
+ g_icon[GUN_LASSER] = addImageData("icon.gun.lasser.png", IMAGE_ALPHA, "panel_lasser", IMAGE_GROUP_BASE);
+ g_icon[GUN_MINE] = addImageData("icon.gun.mine.png", IMAGE_ALPHA, "panel_mine", IMAGE_GROUP_BASE);
+ g_icon[GUN_BOMBBALL] = addImageData("icon.gun.bombball.png", IMAGE_ALPHA, "panel_bombball", IMAGE_GROUP_BASE);
+ g_icon[BONUS_SPEED] = addImageData("icon.bonus.speed.png", IMAGE_ALPHA, "panel_speed", IMAGE_GROUP_BASE);
+ g_icon[BONUS_SHOT] = addImageData("icon.bonus.shot.png", IMAGE_ALPHA, "panel_shot", IMAGE_GROUP_BASE);
+ g_icon[BONUS_TELEPORT] = addImageData("icon.bonus.teleport.png", IMAGE_ALPHA, "panel_teleport", IMAGE_GROUP_BASE);
+ g_icon[BONUS_GHOST] = addImageData("icon.bonus.ghost.png", IMAGE_ALPHA, "panel_ghost", IMAGE_GROUP_BASE);
+ g_icon[BONUS_4X] = addImageData("icon.bonus.4x.png", IMAGE_ALPHA, "panel_4x", IMAGE_GROUP_BASE);
+ g_icon[BONUS_HIDDEN] = addImageData("icon.bonus.hidden.png", IMAGE_ALPHA, "panel_hidden", IMAGE_GROUP_BASE);
isPanelInit = TRUE;
}
@@ -96,14 +63,12 @@ static void drawScore(tux_t * tux_right, tux_t * tux_left)
}
getTextSize(strScoreLine, &w, &h);
- drawFont(strScoreLine, PANEL_SCORE_LOCATION_X, PANEL_SCORE_LOCATION_Y,
- COLOR_WHITE);
+ drawFont(strScoreLine, PANEL_SCORE_LOCATION_X, PANEL_SCORE_LOCATION_Y, COLOR_WHITE);
}
static void drawShot(int n, int x, int y)
{
- drawImage(g_shot, x, y, n * PANEL_SHOT_WIDTH, 0, PANEL_SHOT_WIDTH,
- PANEL_SHOT_HEIGHT);
+ drawImage(g_shot, x, y, n * PANEL_SHOT_WIDTH, 0, PANEL_SHOT_WIDTH, PANEL_SHOT_HEIGHT);
}
static void drawShotInfo(tux_t * tux, int x, int y)
@@ -129,14 +94,12 @@ static void drawShotInfo(tux_t * tux, int x, int y)
static void drawGunInfo(tux_t * tux, int x, int y)
{
- drawImage(g_icon[tux->gun], x, y, 0, 0,
- g_icon[tux->gun]->w, g_icon[tux->gun]->h);
+ drawImage(g_icon[tux->gun], x, y, 0, 0, g_icon[tux->gun]->w, g_icon[tux->gun]->h);
}
static void drawBonusInfo(tux_t * tux, int x, int y)
{
- drawImage(g_icon[tux->bonus], x, y, 0, 0, g_icon[tux->bonus]->w,
- g_icon[tux->bonus]->h);
+ drawImage(g_icon[tux->bonus], x, y, 0, 0, g_icon[tux->bonus]->w, g_icon[tux->bonus]->h);
}
static void drawGrafBonus(tux_t * tux, int x, int y)
@@ -180,13 +143,11 @@ static void drawTuxLeft(tux_t * tux)
void drawPanel(tux_t * tux_right, tux_t * tux_left)
{
- drawImage(g_panel, PANEL_LOCATION_X, PANEL_LOCATION_Y, 0, 0, g_panel->w,
- g_panel->h);
+ drawImage(g_panel, PANEL_LOCATION_X, PANEL_LOCATION_Y, 0, 0, g_panel->w, g_panel->h);
drawScore(tux_right, tux_left);
if (isRecivedNewMsg()) {
- drawFont("recived new msg", PANEL_LOCATION_X, PANEL_LOCATION_Y,
- COLOR_WHITE);
+ drawFont("recived new msg", PANEL_LOCATION_X, PANEL_LOCATION_Y, COLOR_WHITE);
}
drawTuxRight(tux_right);
diff --git a/src/client/pauza.c b/src/client/pauza.c
index 6003d51..eb346dc 100644
--- a/src/client/pauza.c
+++ b/src/client/pauza.c
@@ -31,8 +31,7 @@ static void hotkey_pauze()
void initPauza()
{
- g_pauza =
- addImageData("pauza.png", IMAGE_ALPHA, "pauza", IMAGE_GROUP_USER);
+ g_pauza = addImageData("pauza.png", IMAGE_ALPHA, "pauza", IMAGE_GROUP_USER);
activePauza = FALSE;
registerHotKey(SDLK_p, hotkey_pauze);
@@ -42,9 +41,9 @@ void drawPauza()
{
if (activePauza) {
drawImage(g_pauza,
- WINDOW_SIZE_X / 2 - g_pauza->w / 2,
- WINDOW_SIZE_Y / 2 - g_pauza->h / 2,
- 0, 0, g_pauza->w, g_pauza->h);
+ WINDOW_SIZE_X / 2 - g_pauza->w / 2,
+ WINDOW_SIZE_Y / 2 - g_pauza->h / 2,
+ 0, 0, g_pauza->w, g_pauza->h);
}
}
diff --git a/src/client/radar.c b/src/client/radar.c
index 990f8cb..b45d80f 100644
--- a/src/client/radar.c
+++ b/src/client/radar.c
@@ -81,8 +81,7 @@ void initRadar()
assert(isImageInicialized() == TRUE);
assert(isInterfaceInicialized() == TRUE);
- g_radar =
- addImageData("radar.png", IMAGE_NO_ALPHA, "radar", IMAGE_GROUP_USER);
+ g_radar = addImageData("radar.png", IMAGE_NO_ALPHA, "radar", IMAGE_GROUP_USER);
listRadar = newList();
}
@@ -90,8 +89,7 @@ void drawRadar(arena_t * arena)
{
int i;
- drawImage(g_radar, RADAR_LOCATION_X, RADAR_LOCATION_Y, 0, 0,
- RADAR_SIZE_X + 2, RADAR_SIZE_Y + 2);
+ drawImage(g_radar, RADAR_LOCATION_X, RADAR_LOCATION_Y, 0, 0, RADAR_SIZE_X + 2, RADAR_SIZE_Y + 2);
for (i = 0; i < listRadar->count; i++) {
radar_item_t *thisRadarItem;
@@ -99,15 +97,13 @@ void drawRadar(arena_t * arena)
thisRadarItem = (radar_item_t *) listRadar->list[i];
- x = (((float) RADAR_SIZE_X) / ((float) arena->w)) *
- ((float) thisRadarItem->x);
- y = (((float) RADAR_SIZE_Y) / ((float) arena->h)) *
- ((float) thisRadarItem->y);
+ x = (((float) RADAR_SIZE_X) / ((float) arena->w)) * ((float) thisRadarItem->x);
+
+ y = (((float) RADAR_SIZE_Y) / ((float) arena->h)) * ((float) thisRadarItem->y);
if (x >= 0 && x <= RADAR_SIZE_X && y >= 0 && y <= RADAR_SIZE_Y) {
- drawImage(g_radar,
- RADAR_LOCATION_X + 1 + x, RADAR_LOCATION_Y + 1 + y,
- 2 * thisRadarItem->type, RADAR_SIZE_Y + 2, 2, 2);
+ drawImage(g_radar, RADAR_LOCATION_X + 1 + x, RADAR_LOCATION_Y + 1 + y,
+ 2 * thisRadarItem->type, RADAR_SIZE_Y + 2, 2, 2);
}
}
}
diff --git a/src/client/saveDialog.c b/src/client/saveDialog.c
index d154791..1c832e7 100644
--- a/src/client/saveDialog.c
+++ b/src/client/saveDialog.c
@@ -46,8 +46,7 @@ static void eventWidget(void *p)
button = (widget_t *) p;
if (button == widgetButtonSave) {
- saveArena(getTextFromWidgetTextfield(widgetTextFieldName),
- getCurrentArena());
+ saveArena(getTextFromWidgetTextfield(widgetTextFieldName), getCurrentArena());
switchTerm();
}
@@ -67,27 +66,23 @@ void initSaveDialog()
g_background = getImage(IMAGE_GROUP_BASE, "screen_main");
- widgetLabelMsg = newWidgetLabel("name",
- SAVE_DIALOG_LOCATIN_X + 20,
- SAVE_DIALOG_LOCATIN_Y + 20,
- WIDGET_LABEL_LEFT);
+ widgetLabelMsg = newWidgetLabel("name", SAVE_DIALOG_LOCATIN_X + 20,
+ SAVE_DIALOG_LOCATIN_Y + 20,
+ WIDGET_LABEL_LEFT);
- widgetTextFieldName = newWidgetTextfield("noname",
- WIDGET_TEXTFIELD_FILTER_ALPHANUM,
- widgetLabelMsg->x +
- widgetLabelMsg->w + 10,
- widgetLabelMsg->y);
+ widgetTextFieldName = newWidgetTextfield("noname", WIDGET_TEXTFIELD_FILTER_ALPHANUM,
+ widgetLabelMsg->x +
+ widgetLabelMsg->w + 10,
+ widgetLabelMsg->y);
- widgetButtonSave = newWidgetButton("Save",
- SAVE_DIALOG_LOCATIN_X + 20,
- SAVE_DIALOG_LOCATIN_Y + 60,
- eventWidget);
+ widgetButtonSave = newWidgetButton("Save", SAVE_DIALOG_LOCATIN_X + 20,
+ SAVE_DIALOG_LOCATIN_Y + 60,
+ eventWidget);
- widgetButtonBack = newWidgetButton("Back",
- SAVE_DIALOG_LOCATIN_X + 20 +
- WIDGET_BUTTON_WIDTH + 20,
- SAVE_DIALOG_LOCATIN_Y + 60,
- eventWidget);
+ widgetButtonBack = newWidgetButton("Back", SAVE_DIALOG_LOCATIN_X + 20 +
+ WIDGET_BUTTON_WIDTH + 20,
+ SAVE_DIALOG_LOCATIN_Y + 60,
+ eventWidget);
registerHotKey(SDLK_F2, hotkey_saveDialog);
}
@@ -104,10 +99,12 @@ void drawSaveDialog()
}
drawImage(g_background,
- SAVE_DIALOG_LOCATIN_X,
- SAVE_DIALOG_LOCATIN_Y,
- SAVE_DIALOG_LOCATIN_X,
- SAVE_DIALOG_LOCATIN_Y, SAVE_DIALOG_SIZE_X, SAVE_DIALOG_SIZE_Y);
+ SAVE_DIALOG_LOCATIN_X,
+ SAVE_DIALOG_LOCATIN_Y,
+ SAVE_DIALOG_LOCATIN_X,
+ SAVE_DIALOG_LOCATIN_Y,
+ SAVE_DIALOG_SIZE_X,
+ SAVE_DIALOG_SIZE_Y);
drawWidgetLabel(widgetLabelMsg);
drawWidgetTextfield(widgetTextFieldName);
diff --git a/src/client/screen.c b/src/client/screen.c
index 52e8e3f..71d48d8 100644
--- a/src/client/screen.c
+++ b/src/client/screen.c
@@ -24,9 +24,8 @@ bool_t isScreenInicialized()
return isScreenInit;
}
-screen_t *newScreen(char *name,
- void (*fce_start) (), void (*fce_event) (),
- void (*fce_draw) (), void (*fce_stop) ())
+screen_t *newScreen(char *name, void (*fce_start) (), void (*fce_event) (),
+ void (*fce_draw) (), void (*fce_stop) ())
{
screen_t *new;
diff --git a/src/client/term.c b/src/client/term.c
index 5266c53..4a1991c 100644
--- a/src/client/term.c
+++ b/src/client/term.c
@@ -30,22 +30,22 @@ void initTerm()
static char *getStrGun(int gun)
{
switch (gun) {
- case GUN_SIMPLE:
- return "revolver";
- case GUN_DUAL_SIMPLE:
- return "dual revolver";
- case GUN_SCATTER:
- return "scatter";
- case GUN_TOMMY:
- return "tommy";
- case GUN_LASSER:
- return "lasser";
- case GUN_MINE:
- return "mine";
- case GUN_BOMBBALL:
- return "bombball";
- default:
- return "none";
+ case GUN_SIMPLE:
+ return "revolver";
+ case GUN_DUAL_SIMPLE:
+ return "dual revolver";
+ case GUN_SCATTER:
+ return "scatter";
+ case GUN_TOMMY:
+ return "tommy";
+ case GUN_LASSER:
+ return "lasser";
+ case GUN_MINE:
+ return "mine";
+ case GUN_BOMBBALL:
+ return "bombball";
+ default:
+ return "none";
}
return "gun_unknow";
@@ -54,20 +54,20 @@ static char *getStrGun(int gun)
static char *getStrBonus(int bonus)
{
switch (bonus) {
- case BONUS_SPEED:
- return "speed";
- case BONUS_SHOT:
- return "shot";
- case BONUS_TELEPORT:
- return "teleport";
- case BONUS_GHOST:
- return "ghost";
- case BONUS_4X:
- return "4X";
- case BONUS_HIDDEN:
- return "hidden";
- default:
- return "none";
+ case BONUS_SPEED:
+ return "speed";
+ case BONUS_SHOT:
+ return "shot";
+ case BONUS_TELEPORT:
+ return "teleport";
+ case BONUS_GHOST:
+ return "ghost";
+ case BONUS_4X:
+ return "4X";
+ case BONUS_HIDDEN:
+ return "hidden";
+ default:
+ return "none";
}
return "bonus_unknow";
diff --git a/src/net/tcp.c b/src/net/tcp.c
index ca11eb3..d8a40d8 100644
--- a/src/net/tcp.c
+++ b/src/net/tcp.c
@@ -55,6 +55,7 @@ sock_tcp_t *bindTcpSocket(char *address, int port, int proto)
if (new->proto == PROTO_TCPv4) {
new->sock = socket(AF_INET, SOCK_STREAM, 0);
}
+
#ifdef SUPPORT_IPv6
if (new->proto == PROTO_TCPv6) {
new->sock = socket(AF_INET6, SOCK_STREAM, 0);
@@ -114,15 +115,13 @@ sock_tcp_t *getTcpNewClient(sock_tcp_t * p)
if (new->proto == PROTO_TCPv4) {
client_len = sizeof(new->sockAddr);
- new->sock = accept(p->sock, (struct sockaddr *) &new->sockAddr,
- (socklen_t *) & client_len);
+ new->sock = accept(p->sock, (struct sockaddr *) &new->sockAddr, (socklen_t *) & client_len);
}
#ifdef SUPPORT_IPv6
if (new->proto == PROTO_TCPv6) {
client_len = sizeof(new->sockAddr6);
- new->sock = accept(p->sock, (struct sockaddr *) &new->sockAddr6,
- (socklen_t *) & client_len);
+ new->sock = accept(p->sock, (struct sockaddr *) &new->sockAddr6, (socklen_t *) & client_len);
}
#endif
@@ -186,6 +185,7 @@ sock_tcp_t *connectTcpSocket(char *ip, int port, int proto)
if (new->proto == PROTO_TCPv4) {
new->sock = socket(AF_INET, SOCK_STREAM, 0);
}
+
#ifdef SUPPORT_IPv6
if (new->proto == PROTO_TCPv6) {
new->sock = socket(AF_INET6, SOCK_STREAM, 0);
@@ -206,6 +206,7 @@ sock_tcp_t *connectTcpSocket(char *ip, int port, int proto)
len = sizeof(new->sockAddr);
ret = connect(new->sock, (struct sockaddr *) &new->sockAddr, len);
}
+
#ifdef SUPPORT_IPv6
if (new->proto == PROTO_TCPv6) {
new->sockAddr6.sin6_family = AF_INET6;
@@ -235,10 +236,10 @@ int disableNagle(sock_tcp_t * p)
int result;
result = setsockopt(p->sock, /* socket affected */
- IPPROTO_TCP, /* set option at TCP level */
- TCP_NODELAY, /* name of option */
- (char *) &flag, /* the cast is historical cruft */
- sizeof(int)); /* length of option value */
+ IPPROTO_TCP, /* set option at TCP level */
+ TCP_NODELAY, /* name of option */
+ (char *) &flag, /* the cast is historical cruft */
+ sizeof(int)); /* length of option value */
#if 0
if (result < 0) {
diff --git a/src/net/udp.c b/src/net/udp.c
index 99fa19e..68e943f 100644
--- a/src/net/udp.c
+++ b/src/net/udp.c
@@ -57,6 +57,7 @@ sock_udp_t *bindUdpSocket(char *address, int port, int proto)
if (new->proto == PROTO_UDPv4) {
new->sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
}
+
#ifdef SUPPORT_IPv6
if (new->proto == PROTO_UDPv6) {
new->sock = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
@@ -79,9 +80,7 @@ sock_udp_t *bindUdpSocket(char *address, int port, int proto)
new->sockAddr.sin_port = htons(port);
new->sockAddr.sin_addr.s_addr = inet_addr(address);
- res =
- bind(new->sock, (struct sockaddr *) &(new->sockAddr),
- sizeof(new->sockAddr));
+ res = bind(new->sock, (struct sockaddr *) &(new->sockAddr), sizeof(new->sockAddr));
}
#ifdef SUPPORT_IPv6
if (new->proto == PROTO_UDPv6) {
@@ -89,9 +88,7 @@ sock_udp_t *bindUdpSocket(char *address, int port, int proto)
new->sockAddr6.sin6_port = htons(port);
inet_pton(AF_INET6, address, &(new->sockAddr6.sin6_addr));
- res =
- bind(new->sock, (struct sockaddr *) &(new->sockAddr6),
- sizeof(new->sockAddr6));
+ res = bind(new->sock, (struct sockaddr *) &(new->sockAddr6), sizeof(new->sockAddr6));
}
#endif
@@ -121,6 +118,7 @@ sock_udp_t *connectUdpSocket(char *address, int port, int proto)
if (new->proto == PROTO_UDPv4) {
new->sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
}
+
#ifdef SUPPORT_IPv6
if (new->proto == PROTO_UDPv6) {
new->sock = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
@@ -188,23 +186,23 @@ int readUdpSocket(sock_udp_t * src, sock_udp_t * dst, void *address, int len)
addrlen = sizeof(src->sockAddr);
#ifndef __WIN32
- size =
- recvfrom(src->sock, address, len, 0,
- (struct sockaddr *) &dst->sockAddr,
- (socklen_t *) & addrlen);
+ size = recvfrom(src->sock, address, len, 0,
+ (struct sockaddr *) &dst->sockAddr,
+ (socklen_t *) & addrlen);
#else
size =
recvfrom(src->sock, address, len, 0,
- (struct sockaddr *) &dst->sockAddr, (int *) &addrlen);
+ (struct sockaddr *) &dst->sockAddr, (int *) &addrlen);
#endif
}
+
#ifdef SUPPORT_IPv6
if (dst->proto == PROTO_UDPv6) {
addrlen = sizeof(src->sockAddr6);
size = recvfrom(src->sock, address, len, 0,
- (struct sockaddr *) &dst->sockAddr6,
- (socklen_t *) & addrlen);
+ (struct sockaddr *) &dst->sockAddr6,
+ (socklen_t *) & addrlen);
}
#endif
@@ -238,17 +236,15 @@ int writeUdpSocket(sock_udp_t * src, sock_udp_t * dst, void *address, int len)
if (dst->proto == PROTO_UDPv4) {
addrlen = sizeof(src->sockAddr);
- size =
- sendto(src->sock, address, len, 0,
- (struct sockaddr *) &dst->sockAddr, addrlen);
+ size = sendto(src->sock, address, len, 0,
+ (struct sockaddr *) &dst->sockAddr, addrlen);
}
#ifdef SUPPORT_IPv6
if (dst->proto == PROTO_UDPv6) {
addrlen = sizeof(src->sockAddr6);
- size =
- sendto(src->sock, address, len, 0,
- (struct sockaddr *) &dst->sockAddr6, addrlen);
+ size = sendto(src->sock, address, len, 0,
+ (struct sockaddr *) &dst->sockAddr6, addrlen);
}
#endif
diff --git a/src/screen/screen_analyze.c b/src/screen/screen_analyze.c
index b52ca77..df2ea75 100644
--- a/src/screen/screen_analyze.c
+++ b/src/screen/screen_analyze.c
@@ -84,8 +84,7 @@ void eventScreenAnalyze()
void stopScreenAnalyze()
{
destroyWidgetLabel(widgetLabelMsg);
- widgetLabelMsg =
- newWidgetLabel("", WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER);
+ widgetLabelMsg = newWidgetLabel("", WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER);
}
static void eventWidget(void *p)
@@ -118,8 +117,7 @@ void addAnalyze(char *name, int score)
void setMsgToAnalyze(char *msg)
{
destroyWidgetLabel(widgetLabelMsg);
- widgetLabelMsg =
- newWidgetLabel(msg, WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER);
+ widgetLabelMsg = newWidgetLabel(msg, WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER);
}
void endAnalyze()
@@ -132,16 +130,13 @@ void endAnalyze()
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);
- 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);
}
@@ -158,16 +153,13 @@ void initScreenAnalyze()
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()
diff --git a/src/screen/screen_choiceArena.c b/src/screen/screen_choiceArena.c
index c269f62..969c350 100644
--- a/src/screen/screen_choiceArena.c
+++ b/src/screen/screen_choiceArena.c
@@ -49,6 +49,7 @@ void drawScreenChoiceArena()
for (i = 0; i < listWidgetButtonimage->count; i++) {
widget_t *this;
+
this = (widget_t *) listWidgetButtonimage->list[i];
drawWidgetButtonimage(this);
}
@@ -63,6 +64,7 @@ void eventScreenChoiceArena()
for (i = 0; i < listWidgetButtonimage->count; i++) {
widget_t *this;
+
this = (widget_t *) listWidgetButtonimage->list[i];
eventWidgetButtonimage(this);
}
@@ -135,11 +137,8 @@ void initScreenChoiceArena()
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_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;
@@ -151,16 +150,13 @@ void initScreenChoiceArena()
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);
+ 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);
+ widget_buttonimage = newWidgetButtonimage(image, x, y, eventWidgetButtonImage);
/*
if( i == choiceArenaId )
{
@@ -170,10 +166,9 @@ void initScreenChoiceArena()
addList(listWidgetButtonimage, widget_buttonimage);
}
- registerScreen(newScreen
- ("chiceArena", startScreenChoiceArena,
- eventScreenChoiceArena, drawScreenChoiceArena,
- stopScreenChoiceArena));
+ registerScreen( newScreen("chiceArena", startScreenChoiceArena,
+ eventScreenChoiceArena, drawScreenChoiceArena,
+ stopScreenChoiceArena));
}
void quitScreenChoiceArena()
diff --git a/src/screen/screen_downArena.c b/src/screen/screen_downArena.c
index 737543d..94b2387 100644
--- a/src/screen/screen_downArena.c
+++ b/src/screen/screen_downArena.c
@@ -373,16 +373,14 @@ void initScreenDownArena()
image_backgorund = newWidgetImage(0, 0, image);
button_back =
- newWidgetButton(_("back"),
- WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2,
- WINDOW_SIZE_Y - 80, eventWidget);
+ 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));
+ registerScreen( newScreen("downArena", startScreenDownArena, eventScreenDownArena,
+ drawScreenDownArena, stopScreenDownArena));
}
void quitScreenDownArena()
diff --git a/src/screen/screen_gameType.c b/src/screen/screen_gameType.c
index ccfbe15..84fb4eb 100644
--- a/src/screen/screen_gameType.c
+++ b/src/screen/screen_gameType.c
@@ -114,8 +114,7 @@ void drawScreenGameType()
drawWidgetLabel(label_client);
drawWidgetLabel(label_load_session);
- if (getWidgetChoiceStatus(check_server) == TRUE
- || getWidgetChoiceStatus(check_client) == TRUE) {
+ if (getWidgetChoiceStatus(check_server) == TRUE || getWidgetChoiceStatus(check_client) == TRUE) {
drawWidgetLabel(label_port);
drawWidgetTextfield(textfield_port);
drawWidgetLabel(label_ip);
@@ -152,8 +151,7 @@ void eventScreenGameType()
eventWidgetChoicegroup(this);
}
- if (getWidgetChoiceStatus(check_server) == TRUE
- || getWidgetChoiceStatus(check_client) == TRUE) {
+ if (getWidgetChoiceStatus(check_server) == TRUE || getWidgetChoiceStatus(check_client) == TRUE) {
eventWidgetTextfield(textfield_ip);
eventWidgetTextfield(textfield_port);
}
@@ -213,22 +211,15 @@ void initScreenGameType()
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_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);
+ 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);
@@ -239,30 +230,25 @@ void initScreenGameType()
}
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_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);
+ 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);
+ WIDGET_TEXTFIELD_FILTER_IP_OR_DOMAIN,
+ 300, 180);
textfield_port = newWidgetTextfield(getParamElse("--port", "6800"),
- WIDGET_TEXTFIELD_FILTER_NUM, 300, 280);
+ WIDGET_TEXTFIELD_FILTER_NUM, 300, 280);
selectSession = newWidgetSelect(300, 185, eventWidget);
- registerScreen(newScreen
- ("gameType", startScreenGameType, eventScreenGameType,
- drawScreenGameType, stopScreenGameType));
+ registerScreen( newScreen("gameType", startScreenGameType, eventScreenGameType,
+ drawScreenGameType, stopScreenGameType));
}
int setSettingGameType(int status)
@@ -287,8 +273,7 @@ int setSettingGameType(int status)
int getSettingGameType()
{
- if (getWidgetChoiceStatus(check_none) == TRUE ||
- getWidgetChoiceStatus(check_load_session) == TRUE) {
+ if (getWidgetChoiceStatus(check_none) == TRUE || getWidgetChoiceStatus(check_load_session) == TRUE) {
return NET_GAME_TYPE_NONE;
}
diff --git a/src/screen/screen_mainMenu.c b/src/screen/screen_mainMenu.c
index 580bfab..0bb50d7 100644
--- a/src/screen/screen_mainMenu.c
+++ b/src/screen/screen_mainMenu.c
@@ -98,34 +98,18 @@ void initScreenMainMenu()
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);
+ 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));
+ registerScreen( newScreen("mainMenu", startScreenMainMenu, eventScreenMainMenu,
+ drawScreenMainMenu, stopScreenMainMenu));
}
void quitScreenMainMenu()
diff --git a/src/screen/screen_setting.c b/src/screen/screen_setting.c
index 06adda3..4e19978 100644
--- a/src/screen/screen_setting.c
+++ b/src/screen/screen_setting.c
@@ -151,6 +151,7 @@ void eventScreenSetting()
if (getWidgetCheckStatus(check_ai) == FALSE) {
eventWidgetTextfield(textfield_name_player2);
}
+
#ifndef NO_SOUND
eventWidgetCheck(check_music);
eventWidgetCheck(check_sound);
@@ -185,9 +186,11 @@ static void eventWidget(void *p)
if (button == button_back) {
setScreen("mainMenu");
}
+
if (button == button_keys) {
setScreen("settingKeys");
}
+
#ifndef NO_SOUND
if (check == check_music) {
setMusicActive(getWidgetCheckStatus(check_music));
@@ -279,64 +282,35 @@ static void initSettingFile()
static void saveAndDestroyConfigFile()
{
if (configFile == NULL) {
- fprintf(stderr,
- _
- ("I am unable to save configure file, because config file was not initialised!\n"));
-
+ 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)));
+ 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
if( getChoiceArena() != NULL )
{
- setValueInConfigFile(configFile, "ARENA",
- getArenaNetName(getChoiceArena()));
+ setValueInConfigFile(configFile, "ARENA", getArenaNetName(getChoiceArena()));
}
//TODO
@@ -352,63 +326,46 @@ void initScreenSetting()
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);
+ 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);
+ 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);
+ 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_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);
+ 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;
@@ -444,47 +401,21 @@ void initScreenSetting()
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));
+ 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();
diff --git a/src/screen/screen_settingKeys.c b/src/screen/screen_settingKeys.c
index 5bfc802..60ddd79 100644
--- a/src/screen/screen_settingKeys.c
+++ b/src/screen/screen_settingKeys.c
@@ -16,7 +16,8 @@
#ifndef NO_SOUND
# include "music.h"
# include "sound.h"
-#endif /* */
+#endif /*
+ */
#include "screen_mainMenu.h"
#include "screen_setting.h"
#include "screen_settingKeys.h"
@@ -26,114 +27,159 @@
#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
-
+ 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];
+{
+
+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++)
@@ -141,71 +187,123 @@ static widget_t *tux_right_keyup_val;
printf("keytable[%d] = %d\n", i, keytable[i]);
}
*/
-}
- int getKey(int n)
-{
+}
+
+int getKey(int n)
+{
// printf("keytable[n] = %d\n", keytable[n]);
- return keytable[n];
- }
- void drawScreenSettingKeys()
-{
- drawWidgetImage(image_backgorund);
- drawWidgetButton(button_back);
+ 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);
+ 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
-
+ 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");
+{
+
+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) ||
@@ -219,203 +317,264 @@ static widget_t *tux_right_keyup_val;
(catcher == tux_right_keyleft_val) ||
(catcher == tux_right_keyright_val) ||
(catcher == tux_right_keyswitch_val) ||
- (catcher == tux_right_keyfire_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
-
+ 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
-
+{
+
+}
+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);
+image_t * image;
- // 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);
- }
+
+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 f78d97c..5d4b3a4 100644
--- a/src/screen/screen_table.c
+++ b/src/screen/screen_table.c
@@ -90,14 +90,14 @@ static void setWidgetLabel()
int i;
if (textFile == NULL) {
- fprintf(stderr, _("Highscore file: \"%s\" was not loaded!"),
- SCREEN_TABLE_FILE_HIGHSCORE_NAME);
+ fprintf(stderr, _("Highscore file: \"%s\" was not loaded!"), SCREEN_TABLE_FILE_HIGHSCORE_NAME);
return;
}
if (listWidgetLabelNumer != NULL ||
- listWidgetLabelName != NULL || listWidgetLabelScore != NULL) {
+ listWidgetLabelName != NULL ||
+ listWidgetLabelScore != NULL) {
destroyListItem(listWidgetLabelNumer, destroyWidgetLabel);
destroyListItem(listWidgetLabelName, destroyWidgetLabel);
destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
@@ -119,19 +119,13 @@ static void setWidgetLabel()
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);
+ 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);
+ 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);
+ label = newWidgetLabel(score, WINDOW_SIZE_X / 2 + 80, 200 + i * 20, WIDGET_LABEL_LEFT);
addList(listWidgetLabelScore, label);
}
}
@@ -195,15 +189,11 @@ void initScreenTable()
{
image_t *image;
- image =
- addImageData("screen_table.png", IMAGE_NO_ALPHA, "screen_table",
- IMAGE_GROUP_BASE);
+ 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;
@@ -211,8 +201,7 @@ void initScreenTable()
listWidgetLabelScore = NULL;
setWidgetLabel();
- registerScreen(newScreen("table", startScreenTable, eventScreenTable,
- drawScreenTable, stopScreenTable));
+ registerScreen(newScreen("table", startScreenTable, eventScreenTable, drawScreenTable, stopScreenTable));
}
void quitScreenTable()
diff --git a/src/screen/screen_world.c b/src/screen/screen_world.c
index 08cfa82..8f2f6d2 100644
--- a/src/screen/screen_world.c
+++ b/src/screen/screen_world.c
@@ -62,9 +62,8 @@ void setGameType()
{
int ret = 0;
- ret =
- initNetMuliplayer(getSettingGameType(), getSettingIP(),
- getSettingPort(), getSettingProto());
+ ret = initNetMuliplayer(getSettingGameType(), getSettingIP(),
+ getSettingPort(), getSettingProto());
if (ret != 0) {
fprintf(stderr, _("Network initialization error!\n"));
@@ -109,8 +108,7 @@ void countRoundInc()
#ifndef NO_SOUND
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);
}
}
@@ -220,10 +218,13 @@ static void control_keyboard_right(tux_t * tux)
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++;
@@ -309,10 +310,13 @@ static void control_keyboard_left(tux_t * tux)
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++;
@@ -390,12 +394,12 @@ static void eventEnd()
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;
+ case TUX_CONTROL_KEYBOARD_RIGHT:
+ return tuxWithControlRightKeyboard;
+ break;
+ case TUX_CONTROL_KEYBOARD_LEFT:
+ return tuxWithControlLeftKeyboard;
+ break;
}
return NULL;
@@ -404,12 +408,12 @@ tux_t *getControlTux(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;
+ case TUX_CONTROL_KEYBOARD_RIGHT:
+ tuxWithControlRightKeyboard = tux;
+ break;
+ case TUX_CONTROL_KEYBOARD_LEFT:
+ tuxWithControlLeftKeyboard = tux;
+ break;
}
}
@@ -422,21 +426,21 @@ void tuxControl(tux_t * p)
}
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;
+ 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;
}
}
diff --git a/src/widget/widget.c b/src/widget/widget.c
index 0dcfb41..b72a463 100644
--- a/src/widget/widget.c
+++ b/src/widget/widget.c
@@ -32,6 +32,7 @@ void widgetGetLocation(widget_t * p, int *x, int *y)
{
if (x != NULL)
*x = p->x;
+
if (y != NULL)
*y = p->y;
}
@@ -46,6 +47,7 @@ void widgetGetSize(widget_t * p, int *w, int *h)
{
if (w != NULL)
*w = p->w;
+
if (h != NULL)
*h = p->h;
}
diff --git a/src/widget/widget_button.c b/src/widget/widget_button.c
index dbd7aa5..c2afcad 100644
--- a/src/widget/widget_button.c
+++ b/src/widget/widget_button.c
@@ -20,8 +20,8 @@ widget_t *newWidgetButton(char *text, int x, int y, void (*fce_event) (void *))
new->fce_event = fce_event;
getTextSize(text, &(new->w), &(new->h));
- return newWidget(WIDGET_TYPE_BUTTON, x, y, WIDGET_BUTTON_WIDTH,
- WIDGET_BUTTON_HEIGHT, new);
+ return newWidget(WIDGET_TYPE_BUTTON, x, y,
+ WIDGET_BUTTON_WIDTH, WIDGET_BUTTON_HEIGHT, new);
}
void drawWidgetButton(widget_t * widget)
@@ -38,30 +38,24 @@ void drawWidgetButton(widget_t * widget)
getMousePosition(&x, &y);
if (g_button0 == NULL) {
- g_button0 =
- addImageData("button0.png", IMAGE_ALPHA, "button0",
- IMAGE_GROUP_BASE);
+ g_button0 = addImageData("button0.png", IMAGE_ALPHA, "button0", IMAGE_GROUP_BASE);
}
if (g_button1 == NULL) {
g_button1 =
- addImageData("button1.png", IMAGE_ALPHA, "button1",
- IMAGE_GROUP_BASE);
+ addImageData("button1.png", IMAGE_ALPHA, "button1", IMAGE_GROUP_BASE);
}
if (x >= widget->x && x <= widget->x + WIDGET_BUTTON_WIDTH &&
- y >= widget->y && y <= widget->y + WIDGET_BUTTON_HEIGHT) {
- drawImage(g_button1, widget->x, widget->y, 0, 0, g_button0->w,
- g_button0->h);
+ y >= widget->y && y <= widget->y + WIDGET_BUTTON_HEIGHT) {
+ drawImage(g_button1, widget->x, widget->y, 0, 0, g_button0->w, g_button0->h);
} else {
- drawImage(g_button0, widget->x, widget->y, 0, 0, g_button0->w,
- g_button0->h);
+ drawImage(g_button0, widget->x, widget->y, 0, 0, g_button0->w, g_button0->h);
}
//drawFont(p->text, p->x+WIDGET_BUTTON_WIDTH/2-p->w/2, p->y+p->h/2, COLOR_WHITE);
- drawFont(p->text,
- widget->x + WIDGET_BUTTON_WIDTH / 2 - p->w / 2,
- widget->y + WIDGET_BUTTON_HEIGHT / 2 - p->h / 2, COLOR_WHITE);
+ drawFont(p->text, widget->x + WIDGET_BUTTON_WIDTH / 2 - p->w / 2,
+ widget->y + WIDGET_BUTTON_HEIGHT / 2 - p->h / 2, COLOR_WHITE);
}
void eventWidgetButton(widget_t * widget)
@@ -83,8 +77,8 @@ void eventWidgetButton(widget_t * widget)
getMousePosition(&x, &y);
if (x >= widget->x && x <= widget->x + WIDGET_BUTTON_WIDTH &&
- y >= widget->y && y <= widget->y + WIDGET_BUTTON_HEIGHT &&
- isMouseClicked()) {
+ y >= widget->y && y <= widget->y + WIDGET_BUTTON_HEIGHT &&
+ isMouseClicked()) {
time = WIDGET_BUTTON_TIME;
DEBUG_MSG(_("Event caught\n"));
diff --git a/src/widget/widget_buttonimage.c b/src/widget/widget_buttonimage.c
index 6c89d79..dd20e62 100644
--- a/src/widget/widget_buttonimage.c
+++ b/src/widget/widget_buttonimage.c
@@ -10,8 +10,7 @@
#include "widget.h"
#include "widget_buttonimage.h"
-widget_t *newWidgetButtonimage(image_t * image, int x, int y,
- void (*fce_event) (void *))
+widget_t *newWidgetButtonimage(image_t * image, int x, int y, void (*fce_event) (void *))
{
widget_buttonimage_t *new;
@@ -57,6 +56,7 @@ void eventWidgetButtonimage(widget_t * widget)
assert(widget->type == WIDGET_TYPE_BUTTONIMAGE);
p = (widget_buttonimage_t *) widget->private_data;
+
if (time > 0) {
time--;
return;
@@ -65,7 +65,7 @@ void eventWidgetButtonimage(widget_t * widget)
getMousePosition(&x, &y);
if (x >= widget->x && x <= widget->x + p->w &&
- y >= widget->y && y <= widget->y + p->h && isMouseClicked()) {
+ y >= widget->y && y <= widget->y + p->h && isMouseClicked()) {
time = WIDGET_BUTTONIMAGE_TIME;
p->active = 1;
p->fce_event(widget);
diff --git a/src/widget/widget_catchkey.c b/src/widget/widget_catchkey.c
index 37fab55..b213890 100644
--- a/src/widget/widget_catchkey.c
+++ b/src/widget/widget_catchkey.c
@@ -18,8 +18,7 @@ widget_t *newWidgetCatchkey(int key, int x, int y, void *event)
new->fce_event = event;
new->active = FALSE;
- return newWidget(WIDGET_TYPE_CATCHKEY, x, y, WIDGET_CATCHKEY_WIDTH,
- WIDGET_CATCHKEY_HEIGHT, new);
+ return newWidget(WIDGET_TYPE_CATCHKEY, x, y, WIDGET_CATCHKEY_WIDTH, WIDGET_CATCHKEY_HEIGHT, new);
}
int getWidgetCatchKey(widget_t * widget)
@@ -81,7 +80,8 @@ static int getPessAnyKey()
for (i = SDLK_FIRST; i <= SDLK_COMPOSE; i++) {
if (i == SDLK_NUMLOCK || // black key
- i == SDLK_CAPSLOCK || i == SDLK_SCROLLOCK) {
+ i == SDLK_CAPSLOCK ||
+ i == SDLK_SCROLLOCK) {
continue;
}
@@ -107,7 +107,7 @@ void eventWidgetCatchkey(widget_t * widget)
if (isMouseClicked()) {
if (x >= widget->x && x <= widget->x + WIDGET_CATCHKEY_WIDTH &&
- y >= widget->y && y <= widget->y + WIDGET_CATCHKEY_HEIGHT) {
+ y >= widget->y && y <= widget->y + WIDGET_CATCHKEY_HEIGHT) {
p->active = TRUE;
} else {
p->active = FALSE;
diff --git a/src/widget/widget_check.c b/src/widget/widget_check.c
index e57f151..e574211 100644
--- a/src/widget/widget_check.c
+++ b/src/widget/widget_check.c
@@ -9,8 +9,7 @@
#include "widget.h"
#include "widget_check.h"
-widget_t *newWidgetCheck(int x, int y, bool_t status,
- void (*fce_event) (void *))
+widget_t *newWidgetCheck(int x, int y, bool_t status, void (*fce_event) (void *))
{
widget_check_t *new;
@@ -19,8 +18,7 @@ widget_t *newWidgetCheck(int x, int y, bool_t status,
new->status = status;
new->fce_event = fce_event;
- return newWidget(WIDGET_TYPE_CHECK, x, y, WIDGET_CHECK_WIDTH,
- WIDGET_CHECK_HEIGHT, new);
+ return newWidget(WIDGET_TYPE_CHECK, x, y, WIDGET_CHECK_WIDTH, WIDGET_CHECK_HEIGHT, new);
}
void drawWidgetCheck(widget_t * widget)
@@ -38,8 +36,7 @@ void drawWidgetCheck(widget_t * widget)
getMousePosition(&x, &y);
if (g_check == NULL) {
- g_check =
- addImageData("check.png", IMAGE_ALPHA, "check", IMAGE_GROUP_BASE);
+ g_check = addImageData("check.png", IMAGE_ALPHA, "check", IMAGE_GROUP_BASE);
}
if (p->status == TRUE) {
@@ -48,8 +45,7 @@ void drawWidgetCheck(widget_t * widget)
offset = WIDGET_CHECK_WIDTH;
}
- drawImage(g_check, widget->x, widget->y, offset, 0, WIDGET_CHECK_WIDTH,
- WIDGET_CHECK_HEIGHT);
+ drawImage(g_check, widget->x, widget->y, offset, 0, WIDGET_CHECK_WIDTH, WIDGET_CHECK_HEIGHT);
}
void eventWidgetCheck(widget_t * widget)
@@ -70,8 +66,8 @@ void eventWidgetCheck(widget_t * widget)
getMousePosition(&x, &y);
if (x >= widget->x && x <= widget->x + WIDGET_CHECK_WIDTH &&
- y >= widget->y && y <= widget->y + WIDGET_CHECK_HEIGHT &&
- isMouseClicked()) {
+ y >= widget->y && y <= widget->y + WIDGET_CHECK_HEIGHT &&
+ isMouseClicked()) {
if (p->status == TRUE) {
p->status = FALSE;
p->time = WIDGET_CHECK_TIME_SWITCH_STATUS;
diff --git a/src/widget/widget_choicegroup.c b/src/widget/widget_choicegroup.c
index 64533af..1045f81 100644
--- a/src/widget/widget_choicegroup.c
+++ b/src/widget/widget_choicegroup.c
@@ -9,8 +9,7 @@
#include "widget.h"
#include "widget_choicegroup.h"
-widget_t *newWidgetChoicegroup(int x, int y, bool_t status, list_t * list,
- void (*fce_event) (void *))
+widget_t *newWidgetChoicegroup(int x, int y, bool_t status, list_t * list, void (*fce_event) (void *))
{
widget_choicegroup_t *new;
widget_t *widget;
@@ -21,9 +20,8 @@ widget_t *newWidgetChoicegroup(int x, int y, bool_t status, list_t * list,
new->fce_event = fce_event;
new->list = list;
- widget =
- newWidget(WIDGET_TYPE_CHOICE, x, y, WIDGET_CHOICEGROUP_WIDTH,
- WIDGET_CHOICEGROUP_HEIGHT, new);
+ widget = newWidget(WIDGET_TYPE_CHOICE, x, y, WIDGET_CHOICEGROUP_WIDTH, WIDGET_CHOICEGROUP_HEIGHT, new);
+
addList(new->list, widget);
return widget;
@@ -44,9 +42,7 @@ void drawWidgetChoicegroup(widget_t * widget)
getMousePosition(&x, &y);
if (g_choicegroup == NULL) {
- g_choicegroup =
- addImageData("choice.png", IMAGE_ALPHA, "choicegroup",
- IMAGE_GROUP_BASE);
+ g_choicegroup = addImageData("choice.png", IMAGE_ALPHA, "choicegroup", IMAGE_GROUP_BASE);
}
if (p->status == TRUE) {
@@ -56,7 +52,7 @@ void drawWidgetChoicegroup(widget_t * widget)
}
drawImage(g_choicegroup, widget->x, widget->y, offset, 0,
- WIDGET_CHOICEGROUP_WIDTH, WIDGET_CHOICEGROUP_HEIGHT);
+ WIDGET_CHOICEGROUP_WIDTH, WIDGET_CHOICEGROUP_HEIGHT);
}
void setWidgetChoiceActive(widget_t * widget)
@@ -127,7 +123,7 @@ void eventWidgetChoicegroup(widget_t * widget)
getMousePosition(&x, &y);
if (x >= widget->x && x <= widget->x + WIDGET_CHOICEGROUP_WIDTH &&
- y >= widget->y && y <= widget->y + WIDGET_CHOICEGROUP_HEIGHT &&
+ y >= widget->y && y <= widget->y + WIDGET_CHOICEGROUP_HEIGHT &&
isMouseClicked()) {
setWidgetChoiceActive(widget);
}
diff --git a/src/widget/widget_label.c b/src/widget/widget_label.c
index d4bb813..e3c907c 100644
--- a/src/widget/widget_label.c
+++ b/src/widget/widget_label.c
@@ -30,16 +30,15 @@ void drawWidgetLabel(widget_t * widget)
p = (widget_label_t *) widget->private_data;
switch (p->bind) {
- case WIDGET_LABEL_RIGHT:
- drawFont(p->text, widget->x + p->w, widget->y + p->h / 2, COLOR_WHITE);
- break;
- case WIDGET_LABEL_LEFT:
- drawFont(p->text, widget->x, widget->y + widget->h / 2, COLOR_WHITE);
- break;
- case WIDGET_LABEL_CENTER:
- drawFont(p->text, widget->x - p->w / 2, widget->y + p->h / 2,
- COLOR_WHITE);
- break;
+ case WIDGET_LABEL_RIGHT:
+ drawFont(p->text, widget->x + p->w, widget->y + p->h / 2, COLOR_WHITE);
+ break;
+ case WIDGET_LABEL_LEFT:
+ drawFont(p->text, widget->x, widget->y + widget->h / 2, COLOR_WHITE);
+ break;
+ case WIDGET_LABEL_CENTER:
+ drawFont(p->text, widget->x - p->w / 2, widget->y + p->h / 2, COLOR_WHITE);
+ break;
}
}
diff --git a/src/widget/widget_select.c b/src/widget/widget_select.c
index 2f89fe2..f53e583 100644
--- a/src/widget/widget_select.c
+++ b/src/widget/widget_select.c
@@ -94,8 +94,8 @@ void drawWidgetSelect(widget_t * widget)
getTextSize(line, &w, &h);
- if (x > widget->x && y > widget->y + i * 20 && x < widget->x + w
- && y < widget->y + i * 20 + h) {
+ if (x > widget->x && y > widget->y + i * 20 &&
+ x < widget->x + w && y < widget->y + i * 20 + h) {
drawFont(line, widget->x, widget->y + i * 20, COLOR_YELLOW);
} else {
if (p->select == i) {
@@ -127,8 +127,8 @@ void eventWidgetSelect(widget_t * widget)
getTextSize(line, &w, &h);
if (x > widget->x && y > widget->y + i * 20 &&
- x < widget->x + w && y < widget->y + i * 20 + h &&
- isMouseClicked()) {
+ x < widget->x + w && y < widget->y + i * 20 + h &&
+ isMouseClicked()) {
p->select = i;
p->fce_event(p);
}
diff --git a/src/widget/widget_textfield.c b/src/widget/widget_textfield.c
index b3aeeb3..6a8824a 100644
--- a/src/widget/widget_textfield.c
+++ b/src/widget/widget_textfield.c
@@ -27,8 +27,8 @@ widget_t *newWidgetTextfield(char *text, int filter, int x, int y)
new->filter = filter;
getTextSize(text, &new->w, &new->h);
- return newWidget(WIDGET_TYPE_TEXTFILED, x, y, WIDGET_TEXTFIELD_WIDTH,
- WIDGET_TEXTFIELD_HEIGHT, new);
+ return newWidget(WIDGET_TYPE_TEXTFILED, x, y,
+ WIDGET_TEXTFIELD_WIDTH, WIDGET_TEXTFIELD_HEIGHT, new);
}
static void drawBackground(widget_t * widget)
@@ -43,23 +43,17 @@ static void drawBackground(widget_t * widget)
p = (widget_textfield_t *) widget->private_data;
if (g_textfield0 == NULL) {
- g_textfield0 =
- addImageData("textfield0.png", IMAGE_ALPHA, "textfiled0",
- IMAGE_GROUP_BASE);
+ g_textfield0 = addImageData("textfield0.png", IMAGE_ALPHA, "textfiled0", IMAGE_GROUP_BASE);
}
if (g_textfield1 == NULL) {
- g_textfield1 =
- addImageData("textfield1.png", IMAGE_ALPHA, "textfiled1",
- IMAGE_GROUP_BASE);
+ g_textfield1 = addImageData("textfield1.png", IMAGE_ALPHA, "textfiled1", IMAGE_GROUP_BASE);
}
if (p->active) {
- drawImage(g_textfield1, widget->x, widget->y, 0, 0, g_textfield1->w,
- g_textfield1->h);
+ drawImage(g_textfield1, widget->x, widget->y, 0, 0, g_textfield1->w, g_textfield1->h);
} else {
- drawImage(g_textfield0, widget->x, widget->y, 0, 0, g_textfield0->w,
- g_textfield0->h);
+ drawImage(g_textfield0, widget->x, widget->y, 0, 0, g_textfield0->w, g_textfield0->h);
}
}
@@ -75,8 +69,8 @@ static void drawText(widget_t * widget)
strcpy(str, p->text);
- if (p->timeBlick > WIDGET_TEXTFIELD_TIME_BLICK_CURSOR / 2 &&
- p->active == TRUE) {
+ if (p->timeBlick > WIDGET_TEXTFIELD_TIME_BLICK_CURSOR / 2 && p->active == TRUE)
+ {
//strcat(str, ">");
strcat(str, "\f");
}
@@ -86,12 +80,12 @@ static void drawText(widget_t * widget)
if (p->timeBlick == WIDGET_TEXTFIELD_TIME_BLICK_CURSOR) {
p->timeBlick = 0;
}
+
//drawFont(str, p->x+WIDGET_TEXTFIELD_TEXT_OFFSET_X, p->y+p->h/2, COLOR_WHITE);
//printf("p->y: %d\nheight: %d\n p->h: %d\n", p->y, WIDGET_TEXTFIELD_HEIGHT, p->h);
- drawFont(str,
- widget->x + WIDGET_TEXTFIELD_TEXT_OFFSET_X,
- widget->y + WIDGET_TEXTFIELD_HEIGHT / 2 - p->h / 2, COLOR_WHITE);
+ drawFont(str, widget->x + WIDGET_TEXTFIELD_TEXT_OFFSET_X,
+ widget->y + WIDGET_TEXTFIELD_HEIGHT / 2 - p->h / 2, COLOR_WHITE);
}
void drawWidgetTextfield(widget_t * widget)
@@ -145,33 +139,35 @@ static void checkText(widget_textfield_t * p)
isDel = TRUE;
switch (p->filter) {
- case WIDGET_TEXTFIELD_FILTER_ALL:
- isDel = FALSE;
- break;
-
- case WIDGET_TEXTFIELD_FILTER_NUM:
- if (c >= '0' && c <= '9') {
- isDel = FALSE;
- }
- break;
-
- case WIDGET_TEXTFIELD_FILTER_ALPHANUM:
- if ((c >= '0' && c <= '9') ||
- (c >= 'a' && c <= 'z') ||
- (c >= 'A' && c <= 'Z') || (c == '_' || c == '-')) {
+ case WIDGET_TEXTFIELD_FILTER_ALL:
isDel = FALSE;
- }
- break;
-
- case WIDGET_TEXTFIELD_FILTER_IP_OR_DOMAIN:
- if ((c >= '0' && c <= '9') || (c == '.' || c == ':' || c == '-')) {
- isDel = FALSE;
- }
- break;
-
- default:
- assert(!_("Bad filter!"));
- break;
+ break;
+
+ case WIDGET_TEXTFIELD_FILTER_NUM:
+ if (c >= '0' && c <= '9') {
+ isDel = FALSE;
+ }
+ break;
+
+ case WIDGET_TEXTFIELD_FILTER_ALPHANUM:
+ if ((c >= '0' && c <= '9') ||
+ (c >= 'a' && c <= 'z') ||
+ (c >= 'A' && c <= 'Z') ||
+ (c == '_' || c == '-')) {
+ isDel = FALSE;
+ }
+ break;
+
+ case WIDGET_TEXTFIELD_FILTER_IP_OR_DOMAIN:
+ if ((c >= '0' && c <= '9') ||
+ (c == '.' || c == ':' || c == '-')) {
+ isDel = FALSE;
+ }
+ break;
+
+ default:
+ assert(!_("Bad filter!"));
+ break;
}
if (isDel) {
@@ -182,7 +178,6 @@ static void checkText(widget_textfield_t * p)
}
getTextSize(p->text, &p->w, &p->h);
-
}
#ifdef ZZEEXX86_READKEY
@@ -351,8 +346,10 @@ static void readKey(widget_textfield_t * p)
if (strlen(name) == 1)
c = name[0];
+
if (strlen(name) == 3)
c = name[1];
+
if (strcmp(name, "space") == 0)
c = ' ';
@@ -385,8 +382,7 @@ static void readKey(widget_textfield_t * p)
p->text[len] = c;
- if (mapa[SDLK_LSHIFT] == SDL_PRESSED ||
- mapa[SDLK_RSHIFT] == SDL_PRESSED) {
+ if (mapa[SDLK_LSHIFT] == SDL_PRESSED || mapa[SDLK_RSHIFT] == SDL_PRESSED) {
int i;
for (i = 0; i < len_shift_map; i += 2) {
@@ -399,8 +395,7 @@ static void readKey(widget_textfield_t * p)
return;
}
- if (mapa[SDLK_LSHIFT] == SDL_PRESSED ||
- mapa[SDLK_RSHIFT] == SDL_PRESSED) {
+ if (mapa[SDLK_LSHIFT] == SDL_PRESSED || mapa[SDLK_RSHIFT] == SDL_PRESSED) {
p->text[len] -= 32;
}
@@ -425,7 +420,7 @@ void eventWidgetTextfield(widget_t * widget)
if (isMouseClicked()) {
if (x >= widget->x && x <= widget->x + WIDGET_TEXTFIELD_WIDTH &&
- y >= widget->y && y <= widget->y + WIDGET_TEXTFIELD_HEIGHT) {
+ y >= widget->y && y <= widget->y + WIDGET_TEXTFIELD_HEIGHT) {
p->active = TRUE;
} else {
p->active = FALSE;