diff options
| author | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-08-16 21:00:29 +0000 |
|---|---|---|
| committer | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-08-16 21:00:29 +0000 |
| commit | c68df329f2483d8fc9b75488c695787cd18c20a4 (patch) | |
| tree | 18e11cd70360c77606ecdeafe5dbd8f9ff0c12d7 /src/screen | |
| parent | 753fde16397b5943091aa1e9112cea1e5ded0ca5 (diff) | |
- vsetky widegety pouzivaju widget_t
( priparava na kontajner s widgetmi )
git-svn-id: http://opensvn.csie.org/tuxanci_ng@201 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/screen')
| -rw-r--r-- | src/screen/screen_analyze.c | 17 | ||||
| -rw-r--r-- | src/screen/screen_browser.c | 32 | ||||
| -rw-r--r-- | src/screen/screen_choiceArena.c | 39 | ||||
| -rw-r--r-- | src/screen/screen_credits.c | 17 | ||||
| -rw-r--r-- | src/screen/screen_gameType.c | 184 | ||||
| -rw-r--r-- | src/screen/screen_mainMenu.c | 17 | ||||
| -rw-r--r-- | src/screen/screen_setting.c | 157 | ||||
| -rw-r--r-- | src/screen/screen_settingKeys.c | 93 | ||||
| -rw-r--r-- | src/screen/screen_table.c | 22 | ||||
| -rw-r--r-- | src/screen/screen_world.c | 10 | ||||
| -rw-r--r-- | src/screen/screen_world.h | 4 |
11 files changed, 310 insertions, 282 deletions
diff --git a/src/screen/screen_analyze.c b/src/screen/screen_analyze.c index 7723f94..ee42a90 100644 --- a/src/screen/screen_analyze.c +++ b/src/screen/screen_analyze.c @@ -17,18 +17,19 @@ #include "screen_mainMenu.h" #include "screen_analyze.h" +#include "widget.h" #include "widget_label.h" #include "widget_button.h" #include "widget_image.h" -static widget_image_t *image_backgorund; +static widget_t *image_backgorund; static list_t *listWidgetLabelName; static list_t *listWidgetLabelScore; static list_t *listAnalyze; -static widget_label_t *widgetLabelMsg; +static widget_t *widgetLabelMsg; -static widget_button_t *button_ok; +static widget_t *button_ok; static analyze_t* newAnalyze(char *name, int score) { @@ -56,20 +57,20 @@ void startScreenAnalyze() void drawScreenAnalyze() { - widget_label_t *this; + widget_t *this; int i; drawWidgetImage(image_backgorund); for( i = 0 ; i < listWidgetLabelName->count ; i++ ) { - this = (widget_label_t *)(listWidgetLabelName->list[i]); + this = (widget_t *)(listWidgetLabelName->list[i]); drawWidgetLabel(this); } for( i = 0 ; i < listWidgetLabelScore->count ; i++ ) { - this = (widget_label_t *)(listWidgetLabelScore->list[i]); + this = (widget_t *)(listWidgetLabelScore->list[i]); drawWidgetLabel(this); } @@ -90,9 +91,9 @@ void stopScreenAnalyze() static void eventWidget(void *p) { - widget_button_t *button; + widget_t *button; - button = (widget_button_t *)(p); + button = (widget_t *)(p); if( button == button_ok ) { diff --git a/src/screen/screen_browser.c b/src/screen/screen_browser.c index 5ec15b9..bb2f1a7 100644 --- a/src/screen/screen_browser.c +++ b/src/screen/screen_browser.c @@ -45,6 +45,7 @@ extern int errno; #include "screen_gameType.h" #include "screen_browser.h" +#include "widget.h" #include "widget_image.h" #include "widget_label.h" #include "widget_button.h" @@ -52,20 +53,20 @@ extern int errno; #define SERVER_TIMEOUT 200 -static widget_image_t *image_backgorund; +static widget_t *image_backgorund; -static widget_button_t *button_play; -static widget_button_t *button_back; -static widget_button_t *button_refresh; +static widget_t *button_play; +static widget_t *button_back; +static widget_t *button_refresh; -static widget_label_t *label_server; -static widget_label_t *label_version; -static widget_label_t *label_address; -static widget_label_t *label_arena; -static widget_label_t *label_players; -static widget_label_t *label_ping; +static widget_t *label_server; +static widget_t *label_version; +static widget_t *label_address; +static widget_t *label_arena; +static widget_t *label_players; +static widget_t *label_ping; -static widget_select_t *select_server; +static widget_t *select_server; static server_t server_list; @@ -148,9 +149,9 @@ void stopScreenBrowser() static void eventWidget(void *p) { - widget_button_t *button; + widget_t *button; - button = (widget_button_t *)(p); + button = (widget_t *)(p); if( button == button_play ) { @@ -192,7 +193,7 @@ server_t *server_getcurr () server_t *server; for (server = server_list.next; server != &server_list; server = server->next) { - if (i == select_server->select) + if (i == getWidgetSelectIndex(select_server)) return server; i ++; @@ -613,8 +614,11 @@ static int LoadServers () static int RefreshServers () { +/* destroyListItem(select_server->list, free); select_server->list = newList(); +*/ + removeAllFromWidgetSelect(select_server); struct in_addr srv; diff --git a/src/screen/screen_choiceArena.c b/src/screen/screen_choiceArena.c index dc88d84..336a9aa 100644 --- a/src/screen/screen_choiceArena.c +++ b/src/screen/screen_choiceArena.c @@ -18,15 +18,16 @@ #include "screen_mainMenu.h" #include "screen_choiceArena.h" +#include "widget.h" #include "widget_label.h" #include "widget_button.h" #include "widget_image.h" #include "widget_buttonimage.h" -static widget_image_t *image_backgorund; +static widget_t *image_backgorund; -static widget_button_t *button_play; -static widget_button_t *button_back; +static widget_t *button_play; +static widget_t *button_back; static list_t *listWidgetButtonimage; static int choiceArenaId; @@ -49,8 +50,8 @@ void drawScreenChoiceArena() for( i = 0 ; i < listWidgetButtonimage->count ; i++ ) { - widget_buttonimage_t *this; - this = (widget_buttonimage_t *) listWidgetButtonimage->list[i]; + widget_t *this; + this = (widget_t *) listWidgetButtonimage->list[i]; drawWidgetButtonimage(this); } } @@ -64,8 +65,8 @@ void eventScreenChoiceArena() for( i = 0 ; i < listWidgetButtonimage->count ; i++ ) { - widget_buttonimage_t *this; - this = (widget_buttonimage_t *) listWidgetButtonimage->list[i]; + widget_t *this; + this = (widget_t *) listWidgetButtonimage->list[i]; eventWidgetButtonimage(this); } } @@ -76,25 +77,25 @@ void stopScreenChoiceArena() static void eventWidgetButtonImage(void *p) { - widget_buttonimage_t *buttonimage; + widget_t *buttonimage; int i; - buttonimage = (widget_buttonimage_t *)(p); + buttonimage = (widget_t *)(p); for( i = 0 ; i < listWidgetButtonimage->count ; i++ ) { - widget_buttonimage_t *this; + widget_t *this; - this = (widget_buttonimage_t *)(listWidgetButtonimage->list[i]); + this = (widget_t *)(listWidgetButtonimage->list[i]); if( buttonimage == this ) { - this->active = 1; + setWidgetButtonimageActive(this, TRUE); choiceArenaId = i; } else { - this->active = 0; + setWidgetButtonimageActive(this, FALSE); } } } @@ -106,19 +107,19 @@ int getChoiceArenaId() void setChoiceArenaId(int n) { - widget_buttonimage_t *widget_buttonimage; + widget_t *widget_buttonimage; choiceArenaId = n; - widget_buttonimage = (widget_buttonimage_t *)listWidgetButtonimage->list[choiceArenaId]; - widget_buttonimage->active = TRUE; + widget_buttonimage = (widget_t *)listWidgetButtonimage->list[choiceArenaId]; + setWidgetButtonimageActive(widget_buttonimage, TRUE); } static void eventWidget(void *p) { - widget_button_t *button; + widget_t *button; - button = (widget_button_t *)(p); + button = (widget_t *)(p); if( button == button_play ) { @@ -147,7 +148,7 @@ void initScreenChoiceArena() for( i = 0 ; i < getArenaCount() ; i++ ) { - widget_buttonimage_t *widget_buttonimage; + widget_t *widget_buttonimage; int x, y; image = addImageData(getArenaImage(i), IMAGE_NO_ALPHA, "none", IMAGE_GROUP_BASE); diff --git a/src/screen/screen_credits.c b/src/screen/screen_credits.c index ffb6b5f..5a8e9b8 100644 --- a/src/screen/screen_credits.c +++ b/src/screen/screen_credits.c @@ -17,12 +17,13 @@ #include "screen_credits.h" +#include "widget.h" #include "widget_image.h" #include "widget_label.h" #include "widget_button.h" -static widget_image_t *image_backgorund; -static widget_button_t *button_back; +static widget_t *image_backgorund; +static widget_t *button_back; static list_t *listWidgetLabel; static textFile_t *textFile; static int offset; @@ -48,8 +49,8 @@ void drawScreenCredits() { int z; - widget_label_t *this; - this = (widget_label_t *)listWidgetLabel->list[i]; + widget_t *this; + this = (widget_t *)listWidgetLabel->list[i]; z = this->y; this->y += offset; @@ -84,9 +85,9 @@ void stopScreenCredits() static void eventWidget(void *p) { - widget_button_t *button; + widget_t *button; - button = (widget_button_t *)(p); + button = (widget_t *)(p); if( button == button_back ) { @@ -112,7 +113,7 @@ void initScreenCredits() textFile = loadTextFile(PATH_DATA SCREEN_CREDITS_FILE); for( i = 0 ; i < textFile->text->count ; i++ ) { - widget_label_t *label; + widget_t *label; char *line; line = (char *)textFile->text->list[i]; label = newWidgetLabel(line, WINDOW_SIZE_X/2-WINDOW_SIZE_X/4, @@ -126,7 +127,7 @@ void initScreenCredits() for( i = 0 ; i < 5 ; i++ ) { creditExists = 0; - widget_label_t *label; + widget_t *label; char *line; line = "Credit file not found..."; label = newWidgetLabel(line, WINDOW_SIZE_X/2, (WINDOW_SIZE_Y-100)+i*20, diff --git a/src/screen/screen_gameType.c b/src/screen/screen_gameType.c index 986b5dd..7dab4e4 100644 --- a/src/screen/screen_gameType.c +++ b/src/screen/screen_gameType.c @@ -22,38 +22,69 @@ #include "screen_gameType.h" #include "screen_setting.h" +#include "widget.h" #include "widget_label.h" #include "widget_button.h" #include "widget_image.h" #include "widget_textfield.h" #include "widget_choicegroup.h" +#include "widget_check.h" #include "widget_select.h" -static widget_image_t *image_backgorund; +static widget_t *image_backgorund; -static widget_button_t *button_back; -static widget_button_t *button_play; -static widget_button_t *button_browser; +static widget_t *button_back; +static widget_t *button_play; +static widget_t *button_browser; -static widget_label_t *label_none; -static widget_label_t *label_server; -static widget_label_t *label_client; -static widget_label_t *label_load_session; +static widget_t *label_none; +static widget_t *label_server; +static widget_t *label_client; +static widget_t *label_load_session; -static widget_label_t *label_ip; -static widget_label_t *label_port; -static widget_label_t *label_session; +static widget_t *label_ip; +static widget_t *label_port; +static widget_t *label_session; static list_t *listChoiceGroup; -static widget_choicegroup_t *check_none; -static widget_choicegroup_t *check_server; -static widget_choicegroup_t *check_client; -static widget_choicegroup_t *check_load_session; +static widget_t *check_none; +static widget_t *check_server; +static widget_t *check_client; +static widget_t *check_load_session; -static widget_textfield_t *textfield_ip; -static widget_textfield_t *textfield_port; +static widget_t *textfield_ip; +static widget_t *textfield_port; -static widget_select_t *selectSession; +static widget_t *selectSession; + +static void loadSession(widget_t *p) +{ + director_t *director; + int i; + + director = loadDirector(getHomeDirector()); + + removeAllFromWidgetSelect(p); + + if( director == NULL ) + { + return; + } + + for( i = 0 ; i < director->list->count ; i++ ) + { + char *line; + + line = director->list->list[i]; + + if( strstr(line, ".sav") != NULL ) + { + addToWidgetSelect(p, line); + } + } + + destroyDirector(director); +} void startScreenGameType() { @@ -61,9 +92,12 @@ void startScreenGameType() playMusic("menu", MUSIC_GROUP_BASE); #endif - check_none->status = TRUE; - check_server->status = FALSE; - check_client->status = FALSE; + setWidgetChoiceStatus(check_none, TRUE); + setWidgetChoiceStatus(check_server, FALSE); + setWidgetChoiceStatus(check_client, FALSE); + setWidgetChoiceStatus(check_load_session, FALSE); + + loadSession(selectSession); } void drawScreenGameType() @@ -74,9 +108,9 @@ void drawScreenGameType() for( i = 0 ; i < listChoiceGroup->count ; i++ ) { - widget_choicegroup_t *this; + widget_t *this; - this = (widget_choicegroup_t *)listChoiceGroup->list[i]; + this = (widget_t *)listChoiceGroup->list[i]; drawWidgetChoicegroup(this); } @@ -85,7 +119,7 @@ void drawScreenGameType() drawWidgetLabel(label_client); drawWidgetLabel(label_load_session); - if( check_server->status == TRUE || check_client->status == TRUE ) + if( getWidgetChoiceStatus(check_server) == TRUE || getWidgetChoiceStatus(check_client) == TRUE ) { drawWidgetLabel(label_port); drawWidgetTextfield(textfield_port); @@ -93,7 +127,7 @@ void drawScreenGameType() drawWidgetTextfield(textfield_ip); } - if( check_load_session->status == TRUE ) + if( getWidgetChoiceStatus(check_load_session) == TRUE ) { drawWidgetLabel(label_session); drawWidgetSelect(selectSession); @@ -107,7 +141,7 @@ void drawScreenGameType() } #endif - if( check_client->status == TRUE ) + if( getWidgetChoiceStatus(check_client) == TRUE ) drawWidgetButton(button_browser); drawWidgetButton(button_back); @@ -121,19 +155,19 @@ void eventScreenGameType() for( i = 0 ; i < listChoiceGroup->count ; i++ ) { - widget_choicegroup_t *this; + widget_t *this; - this = (widget_choicegroup_t *)listChoiceGroup->list[i]; + this = (widget_t *)listChoiceGroup->list[i]; eventWidgetChoicegroup(this); } - if( check_server->status == TRUE || check_client->status == TRUE ) + if( getWidgetChoiceStatus(check_server) == TRUE || getWidgetChoiceStatus(check_client) == TRUE ) { eventWidgetTextfield(textfield_ip); eventWidgetTextfield(textfield_port); } - if( check_load_session->status == TRUE ) + if( getWidgetChoiceStatus(check_load_session) == TRUE ) { eventWidgetSelect(selectSession); } @@ -141,7 +175,7 @@ void eventScreenGameType() eventWidgetButton(button_back); eventWidgetButton(button_play); - if( check_client->status == TRUE ) + if( getWidgetChoiceStatus(check_client) == TRUE ) eventWidgetButton(button_browser); } @@ -151,9 +185,9 @@ void stopScreenGameType() static void eventWidget(void *p) { - widget_button_t *button; + widget_t *button; - button = (widget_button_t *)(p); + button = (widget_t *)(p); if( button == button_back ) { @@ -188,33 +222,6 @@ static void eventWidget(void *p) } } -static void loadSession(widget_select_t *p) -{ - director_t *director; - int i; - - director = loadDirector(getHomeDirector()); - - if( director == NULL ) - { - return; - } - - for( i = 0 ; i < director->list->count ; i++ ) - { - char *line; - - line = director->list->list[i]; - - if( strstr(line, ".sav") != NULL ) - { - addToWidgetSelect(p, strdup(line)); - } - } - - destroyDirector(director); -} - void initScreenGameType() { image_t *image; @@ -234,15 +241,15 @@ void initScreenGameType() if( isParamFlag("--server") ) { - check_server->status = TRUE; + setWidgetChoiceStatus(check_server, TRUE); } else if( isParamFlag("--client") ) { - check_client->status = TRUE; + setWidgetChoiceStatus(check_client, TRUE); } else { - check_none->status = TRUE; + setWidgetChoiceStatus(check_none, TRUE); } label_none = newWidgetLabel(getMyText("NONE"), 130, 145, WIDGET_LABEL_LEFT); @@ -264,8 +271,7 @@ void initScreenGameType() WIDGET_TEXTFIELD_FILTER_NUM, 300, 280); - selectSession = newWidgetSelect(300, 175, eventWidget); - loadSession(selectSession); + selectSession = newWidgetSelect(300, 185, eventWidget); registerScreen( newScreen("gameType", startScreenGameType, eventScreenGameType, drawScreenGameType, stopScreenGameType) ); @@ -273,25 +279,41 @@ void initScreenGameType() int setSettingGameType(int status) { - check_none->status = status; + if( status == NET_GAME_TYPE_NONE ) + { + setWidgetChoiceStatus(check_none, TRUE); + return 0; + } - return 0; + if( status == NET_GAME_TYPE_SERVER ) + { + setWidgetChoiceStatus(check_server, TRUE); + return 0; + } + + if( status == NET_GAME_TYPE_CLIENT ) + { + setWidgetChoiceStatus(check_client, TRUE); + return 0; + } + + return -1; } int getSettingGameType() { - if( check_none->status == TRUE || - check_load_session->status == TRUE ) + if( getWidgetChoiceStatus(check_none) == TRUE || + getWidgetChoiceStatus(check_load_session) == TRUE ) { return NET_GAME_TYPE_NONE; } - if( check_server->status == TRUE ) + if( getWidgetChoiceStatus(check_server) == TRUE ) { return NET_GAME_TYPE_SERVER; } - if( check_client->status == TRUE ) + if( getWidgetChoiceStatus(check_client) == TRUE ) { return NET_GAME_TYPE_CLIENT; } @@ -303,7 +325,7 @@ int getSettingGameType() char* getGemeTypeLoadSession() { - if( check_load_session->status == TRUE ) + if( getWidgetChoiceStatus(check_load_session) == TRUE ) { return getWidgetSelectItem(selectSession); } @@ -313,36 +335,42 @@ char* getGemeTypeLoadSession() int setSettingIP(char *address) { - strcpy (textfield_ip->text, address); + char str[STR_SIZE]; + + strcpy (str, address); + setWidgetTextFiledText(textfield_ip, str); return 1; } char* getSettingIP() { - return textfield_ip->text; + return getTextFromWidgetTextfield(textfield_ip); } int setSettingPort(int port) { - sprintf (textfield_port->text, "%d", port); + char str[STR_SIZE]; + + sprintf (str, "%d", port); + setWidgetTextFiledText(textfield_port, str); return 0; } int getSettingPort() { - return atoi( textfield_port->text ); + return atoi( getTextFromWidgetTextfield(textfield_port) ); } int getSettingProto() { - if( strstr(textfield_ip->text, ".") != NULL ) + if( strstr(getTextFromWidgetTextfield(textfield_ip), ".") != NULL ) { return PROTO_UDPv4; } - if( strstr(textfield_ip->text, ":") != NULL ) + if( strstr(getTextFromWidgetTextfield(textfield_ip), ":") != NULL ) { return PROTO_UDPv6; } diff --git a/src/screen/screen_mainMenu.c b/src/screen/screen_mainMenu.c index eb07cab..8c6e656 100644 --- a/src/screen/screen_mainMenu.c +++ b/src/screen/screen_mainMenu.c @@ -17,19 +17,20 @@ #include "screen_mainMenu.h" #include "screen_setting.h" +#include "widget.h" #include "widget_label.h" #include "widget_button.h" #include "widget_textfield.h" #include "widget_check.h" #include "widget_image.h" -static widget_image_t *image_backgorund; +static widget_t *image_backgorund; -static widget_button_t *button_play; -static widget_button_t *button_setting; -static widget_button_t *button_table; -static widget_button_t *button_credits; -static widget_button_t *button_end; +static widget_t *button_play; +static widget_t *button_setting; +static widget_t *button_table; +static widget_t *button_credits; +static widget_t *button_end; void startScreenMainMenu() { @@ -64,9 +65,9 @@ void stopScreenMainMenu() static void eventWidget(void *p) { - widget_button_t *button; + widget_t *button; - button = (widget_button_t *)(p); + button = (widget_t *)(p); if( button == button_play ) { diff --git a/src/screen/screen_setting.c b/src/screen/screen_setting.c index 20e097f..1f77d2a 100644 --- a/src/screen/screen_setting.c +++ b/src/screen/screen_setting.c @@ -28,6 +28,7 @@ #include "screen_settingKeys.h" #include "screen_choiceArena.h" +#include "widget.h" #include "widget_label.h" #include "widget_button.h" #include "widget_image.h" @@ -35,46 +36,46 @@ #include "widget_check.h" #include "widget_select.h" -static widget_image_t *image_backgorund; +static widget_t *image_backgorund; -static widget_button_t *button_back; -static widget_button_t *button_keys; // setting of keycontrols +static widget_t *button_back; +static widget_t *button_keys; // setting of keycontrols -static widget_label_t *label_count_round; -static widget_label_t *label_name_player1; -static widget_label_t *label_name_player2; -static widget_label_t *label_ai; +static widget_t *label_count_round; +static widget_t *label_name_player1; +static widget_t *label_name_player2; +static widget_t *label_ai; #ifndef NO_SOUND -static widget_label_t *label_music; -static widget_label_t *label_sound; +static widget_t *label_music; +static widget_t *label_sound; #endif -static widget_check_t *check[ITEM_COUNT]; +static widget_t *check[ITEM_COUNT]; #ifndef NO_SOUND -static widget_check_t *check_music; -static widget_check_t *check_sound; +static widget_t *check_music; +static widget_t *check_sound; #endif -static widget_image_t *image_gun_dual_revolver; -static widget_image_t *image_gun_scatter; -static widget_image_t *image_gun_tommy; -static widget_image_t *image_gun_lasser; -static widget_image_t *image_gun_mine; -static widget_image_t *image_gun_bombball; +static widget_t *image_gun_dual_revolver; +static widget_t *image_gun_scatter; +static widget_t *image_gun_tommy; +static widget_t *image_gun_lasser; +static widget_t *image_gun_mine; +static widget_t *image_gun_bombball; -static widget_image_t *image_bonus_speed; -static widget_image_t *image_bonus_shot; -static widget_image_t *image_bonus_teleport; -static widget_image_t *image_bonus_ghost; -static widget_image_t *image_bonus_4x; -static widget_image_t *image_bonus_hidden; +static widget_t *image_bonus_speed; +static widget_t *image_bonus_shot; +static widget_t *image_bonus_teleport; +static widget_t *image_bonus_ghost; +static widget_t *image_bonus_4x; +static widget_t *image_bonus_hidden; -static widget_textfield_t *textfield_count_cound; -static widget_textfield_t *textfield_name_player1; -static widget_textfield_t *textfield_name_player2; +static widget_t *textfield_count_cound; +static widget_t *textfield_name_player1; +static widget_t *textfield_name_player2; -static widget_check_t *check_ai; +static widget_t *check_ai; static textFile_t *configFile; @@ -103,7 +104,7 @@ void drawScreenSetting() drawWidgetTextfield(textfield_count_cound); drawWidgetTextfield(textfield_name_player1); - if ( check_ai->status == 0 ) + if ( getWidgetCheckStatus(check_ai) == FALSE ) { drawWidgetLabel(label_name_player2); drawWidgetTextfield(textfield_name_player2); @@ -151,7 +152,7 @@ void eventScreenSetting() eventWidgetTextfield(textfield_count_cound); eventWidgetTextfield(textfield_name_player1); - if ( check_ai->status == 0 ) + if ( getWidgetCheckStatus(check_ai) == FALSE ) { eventWidgetTextfield(textfield_name_player2); } @@ -183,11 +184,11 @@ void stopScreenSetting() static void eventWidget(void *p) { - widget_button_t *button; - widget_check_t *check; + widget_t *button; + widget_t *check; - button = (widget_button_t *)(p); - check = (widget_check_t *)(p); + button = (widget_t *)(p); + check = (widget_t *)(p); if( button == button_back ) { @@ -201,12 +202,12 @@ static void eventWidget(void *p) #ifndef NO_SOUND if( check == check_music ) { - setMusicActive( check_music->status ); + setMusicActive( getWidgetCheckStatus(check_music) ); } if( check == check_sound ) { - setSoundActive( check_sound->status ); + setSoundActive( getWidgetCheckStatus(check_sound) ); } #endif } @@ -244,40 +245,40 @@ static void initSettingFile() setWidgetTextFiledText(textfield_name_player2, val); loadValueFromConfigFile(configFile, "GUN_DUAL_SIMPLE", val, STR_SIZE, "YES"); - check[GUN_DUAL_SIMPLE]->status = isYesOrNO(val); + setWidgetCheckStatus(check[GUN_DUAL_SIMPLE], isYesOrNO(val)); loadValueFromConfigFile(configFile, "GUN_SCATTER", val, STR_SIZE, "YES"); - check[GUN_SCATTER]->status = isYesOrNO(val); + setWidgetCheckStatus(check[GUN_SCATTER], isYesOrNO(val)); loadValueFromConfigFile(configFile, "GUN_TOMMY", val, STR_SIZE, "YES"); - check[GUN_TOMMY]->status = isYesOrNO(val); + setWidgetCheckStatus(check[GUN_TOMMY], isYesOrNO(val)); loadValueFromConfigFile(configFile, "GUN_LASSER", val, STR_SIZE, "YES"); - check[GUN_LASSER]->status = isYesOrNO(val); + setWidgetCheckStatus(check[GUN_LASSER], isYesOrNO(val)); loadValueFromConfigFile(configFile, "GUN_MINE", val, STR_SIZE, "YES"); - check[GUN_MINE]->status = isYesOrNO(val); + setWidgetCheckStatus(check[GUN_MINE], isYesOrNO(val)); loadValueFromConfigFile(configFile, "GUN_BOMBBALL", val, STR_SIZE, "YES"); - check[GUN_BOMBBALL]->status = isYesOrNO(val); + setWidgetCheckStatus(check[GUN_BOMBBALL], isYesOrNO(val)); loadValueFromConfigFile(configFile, "BONUS_SPEED", val, STR_SIZE, "YES"); - check[BONUS_SPEED]->status = isYesOrNO(val); + setWidgetCheckStatus(check[BONUS_SPEED], isYesOrNO(val)); loadValueFromConfigFile(configFile, "BONUS_SHOT", val, STR_SIZE, "YES"); - check[BONUS_SHOT]->status = isYesOrNO(val); + setWidgetCheckStatus(check[BONUS_SHOT], isYesOrNO(val)); loadValueFromConfigFile(configFile, "BONUS_TELEPORT", val, STR_SIZE, "YES"); - check[BONUS_TELEPORT]->status = isYesOrNO(val); + setWidgetCheckStatus(check[BONUS_TELEPORT], isYesOrNO(val)); loadValueFromConfigFile(configFile, "BONUS_GHOST", val, STR_SIZE, "YES"); - check[BONUS_GHOST]->status = isYesOrNO(val); + setWidgetCheckStatus(check[BONUS_GHOST], isYesOrNO(val)); loadValueFromConfigFile(configFile, "BONUS_4X", val, STR_SIZE, "YES"); - check[BONUS_4X]->status = isYesOrNO(val); + setWidgetCheckStatus(check[BONUS_4X], isYesOrNO(val)); loadValueFromConfigFile(configFile, "BONUS_HIDDEN", val, STR_SIZE, "YES"); - check[BONUS_HIDDEN]->status = isYesOrNO(val); + setWidgetCheckStatus(check[BONUS_HIDDEN], isYesOrNO(val)); loadValueFromConfigFile(configFile, "AI", val, STR_SIZE, "NO"); - check_ai->status = isYesOrNO(val); + setWidgetCheckStatus(check_ai, isYesOrNO(val)); #ifndef NO_SOUND loadValueFromConfigFile(configFile, "MUSIC", val, STR_SIZE, "YES"); - check_music->status = isYesOrNO(val); + setWidgetCheckStatus(check_music, isYesOrNO(val)); loadValueFromConfigFile(configFile, "SOUND", val, STR_SIZE, "YES"); - check_sound->status = isYesOrNO(val); + setWidgetCheckStatus(check_sound, isYesOrNO(val)); #endif loadValueFromConfigFile(configFile, "ARENA", val, STR_SIZE, "FAGN"); @@ -296,32 +297,32 @@ static void saveAndDestroyConfigFile() return; } - setValueInConfigFile(configFile, "COUNT_ROUND", textfield_count_cound->text ); - setValueInConfigFile(configFile, "NAME_PLAYER_RIGHT", textfield_name_player1->text ); - setValueInConfigFile(configFile, "NAME_PLAYER_LEFT", textfield_name_player2->text ); + setValueInConfigFile(configFile, "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(check[GUN_DUAL_SIMPLE]->status) ); - setValueInConfigFile(configFile, "GUN_SCATTER", getYesOrNo(check[GUN_SCATTER]->status) ); - setValueInConfigFile(configFile, "GUN_TOMMY", getYesOrNo(check[GUN_TOMMY]->status) ); - setValueInConfigFile(configFile, "GUN_LASSER", getYesOrNo(check[GUN_LASSER]->status) ); - setValueInConfigFile(configFile, "GUN_MINE", getYesOrNo(check[GUN_MINE]->status) ); - setValueInConfigFile(configFile, "GUN_BOMBBALL", getYesOrNo(check[GUN_BOMBBALL]->status) ); + setValueInConfigFile(configFile, "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(check[BONUS_SPEED]->status) ); - setValueInConfigFile(configFile, "BONUS_SHOT", getYesOrNo(check[BONUS_SHOT]->status) ); - setValueInConfigFile(configFile, "BONUS_TELEPORT", getYesOrNo(check[BONUS_TELEPORT]->status) ); - setValueInConfigFile(configFile, "BONUS_GHOST", getYesOrNo(check[BONUS_GHOST]->status) ); - setValueInConfigFile(configFile, "BONUS_4X", getYesOrNo(check[BONUS_4X]->status) ); - setValueInConfigFile(configFile, "BONUS_HIDDEN", getYesOrNo(check[BONUS_HIDDEN]->status) ); + 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(check_ai->status) ); + setValueInConfigFile(configFile, "AI", getYesOrNo(getWidgetCheckStatus(check_ai))); #ifndef NO_SOUND - setValueInConfigFile(configFile, "MUSIC", getYesOrNo(check_music->status) ); - setValueInConfigFile(configFile, "SOUND", getYesOrNo(check_sound->status) ); + setValueInConfigFile(configFile, "MUSIC", getYesOrNo(getWidgetCheckStatus(check_music))); + setValueInConfigFile(configFile, "SOUND", getYesOrNo(getWidgetCheckStatus(check_sound))); #endif - setValueInConfigFile(configFile, "ARENA", getArenaNetName(getChoiceArenaId()) ); + setValueInConfigFile(configFile, "ARENA", getArenaNetName(getChoiceArenaId())); saveTextFile(configFile); destroyTextFile(configFile); @@ -442,29 +443,29 @@ void initScreenSetting() void getSettingNameRight(char *s) { - strcpy(s, textfield_name_player1->text); + strcpy(s, getTextFromWidgetTextfield(textfield_name_player1)); } void getSettingNameLeft(char *s) { - if( check_ai->status ) + if( getWidgetCheckStatus(check_ai) ) { strcpy(s, NAME_AI); } else { - strcpy(s, textfield_name_player2->text); + strcpy(s, getTextFromWidgetTextfield(textfield_name_player2)); } } void getSettingCountRound(int *n) { - *n = atoi( textfield_count_cound->text ); + *n = atoi( getTextFromWidgetTextfield(textfield_count_cound) ); } bool_t isSettingAI() { - return check_ai->status; + return getWidgetCheckStatus(check_ai); } bool_t isSettingAnyItem() @@ -473,7 +474,7 @@ bool_t isSettingAnyItem() for( i = GUN_DUAL_SIMPLE ; i <= GUN_BOMBBALL ; i++ ) { - if( check[i]->status == TRUE ) + if( getWidgetCheckStatus(check[i]) == TRUE ) { return TRUE; } @@ -481,7 +482,7 @@ bool_t isSettingAnyItem() for( i = BONUS_SPEED ; i < BONUS_HIDDEN ; i++ ) { - if( check[i]->status == TRUE ) + if( getWidgetCheckStatus(check[i]) == TRUE ) { return TRUE; } @@ -492,7 +493,7 @@ bool_t isSettingAnyItem() bool_t isSettingItem(int item) { - return check[item]->status; + return getWidgetCheckStatus(check[item]); } void quitScreenSetting() diff --git a/src/screen/screen_settingKeys.c b/src/screen/screen_settingKeys.c index 91ec0f6..970c38d 100644 --- a/src/screen/screen_settingKeys.c +++ b/src/screen/screen_settingKeys.c @@ -21,6 +21,8 @@ #include "screen_mainMenu.h"
#include "screen_setting.h"
#include "screen_settingKeys.h"
+
+#include "widget.h"
#include "widget_button.h"
#include "widget_image.h"
#include "widget_catchkey.h"
@@ -28,38 +30,38 @@ static int keytable[KEY_LENGTH];
static textFile_t *keycontrolFile;
-static widget_image_t *image_backgorund;
-static widget_button_t *button_back;
+static widget_t *image_backgorund;
+static widget_t *button_back;
// key names
-static widget_label_t *tux_right;
-static widget_label_t *tux_right_keyup;
-static widget_label_t *tux_right_keydown;
-static widget_label_t *tux_right_keyleft;
-static widget_label_t *tux_right_keyright;
-static widget_label_t *tux_right_keyswitch;
-static widget_label_t *tux_right_keyfire;
-static widget_label_t *tux_left;
-static widget_label_t *tux_left_keyup;
-static widget_label_t *tux_left_keydown;
-static widget_label_t *tux_left_keyleft;
-static widget_label_t *tux_left_keyright;
-static widget_label_t *tux_left_keyswitch;
-static widget_label_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_catchkey_t *tux_right_keyup_val;
-static widget_catchkey_t *tux_right_keydown_val;
-static widget_catchkey_t *tux_right_keyleft_val;
-static widget_catchkey_t *tux_right_keyright_val;
-static widget_catchkey_t *tux_right_keyswitch_val;
-static widget_catchkey_t *tux_right_keyfire_val;
-static widget_catchkey_t *tux_left_keyup_val;
-static widget_catchkey_t *tux_left_keydown_val;
-static widget_catchkey_t *tux_left_keyleft_val;
-static widget_catchkey_t *tux_left_keyright_val;
-static widget_catchkey_t *tux_left_keyswitch_val;
-static widget_catchkey_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_catchkey_t *catcher;
+//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
@@ -179,11 +181,11 @@ static void refreshKeytable() }
static void eventWidget(void *p)
{
- widget_button_t *button;
- widget_catchkey_t *catcher;
+ widget_t *button;
+ widget_t *catcher;
- button = (widget_button_t *)(p);
- catcher = (widget_catchkey_t *)(p);
+ button = (widget_t *)(p);
+ catcher = (widget_t *)(p);
if (button == button_back)
setScreen("setting");
//events on value
@@ -268,29 +270,29 @@ void quitKeyTable() void saveKeyTable(textFile_t *configFile) {
char str[STR_SIZE];
- sprintf(str,"%d",tux_left_keyup_val->key);
+ sprintf(str,"%d", getWidgetCatchKey(tux_left_keyup_val));
setValueInConfigFile(configFile, "TUX_LEFT_MOVE_UP", str);
- sprintf(str,"%d",tux_left_keydown_val->key);
+ sprintf(str,"%d", getWidgetCatchKey(tux_left_keydown_val));
setValueInConfigFile(configFile, "TUX_LEFT_MOVE_DOWN", str);
- sprintf(str,"%d",tux_left_keyleft_val->key);
+ sprintf(str,"%d", getWidgetCatchKey(tux_left_keyleft_val));
setValueInConfigFile(configFile, "TUX_LEFT_MOVE_LEFT", str);
- sprintf(str,"%d",tux_left_keyright_val->key);
+ sprintf(str,"%d", getWidgetCatchKey(tux_left_keyright_val));
setValueInConfigFile(configFile, "TUX_LEFT_MOVE_RIGHT", str);
- sprintf(str,"%d",tux_left_keyfire_val->key);
+ sprintf(str,"%d", getWidgetCatchKey(tux_left_keyfire_val));
setValueInConfigFile(configFile, "TUX_LEFT_SHOOT", str);
- sprintf(str,"%d",tux_left_keyswitch_val->key);
+ sprintf(str,"%d", getWidgetCatchKey(tux_left_keyswitch_val));
setValueInConfigFile(configFile, "TUX_LEFT_SWITCH_WEAPON", str);
- sprintf(str,"%d",tux_right_keyup_val->key);
+ sprintf(str,"%d", getWidgetCatchKey(tux_right_keyup_val));
setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_UP", str);
- sprintf(str,"%d",tux_right_keydown_val->key);
+ sprintf(str,"%d", getWidgetCatchKey(tux_right_keydown_val));
setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_DOWN", str);
- sprintf(str,"%d",tux_right_keyleft_val->key);
+ sprintf(str,"%d", getWidgetCatchKey(tux_right_keyleft_val));
setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_LEFT", str);
- sprintf(str,"%d",tux_right_keyright_val->key);
+ sprintf(str,"%d", getWidgetCatchKey(tux_right_keyright_val));
setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_RIGHT", str);
- sprintf(str,"%d",tux_right_keyfire_val->key);
+ sprintf(str,"%d", getWidgetCatchKey(tux_right_keyfire_val));
setValueInConfigFile(configFile, "TUX_RIGHT_SHOOT", str);
- sprintf(str,"%d",tux_right_keyswitch_val->key);
+ sprintf(str,"%d", getWidgetCatchKey(tux_right_keyswitch_val));
setValueInConfigFile(configFile, "TUX_RIGHT_SWITCH_WEAPON", str);
saveTextFile(configFile);
}
@@ -311,6 +313,7 @@ void quitScreenSettingKeys() 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
diff --git a/src/screen/screen_table.c b/src/screen/screen_table.c index 1f53b8d..3c26c0a 100644 --- a/src/screen/screen_table.c +++ b/src/screen/screen_table.c @@ -23,8 +23,8 @@ #include "widget_label.h" #include "widget_button.h" -static widget_image_t *image_backgorund; -static widget_button_t *button_back; +static widget_t *image_backgorund; +static widget_t *button_back; static list_t *listWidgetLabelNumer; static list_t *listWidgetLabelName; @@ -49,22 +49,22 @@ void drawScreenTable() for( i = 0 ; i < listWidgetLabelNumer->count ; i++ ) { - widget_label_t *this; - this = (widget_label_t *)listWidgetLabelNumer->list[i]; + widget_t *this; + this = (widget_t *)listWidgetLabelNumer->list[i]; drawWidgetLabel(this); } for( i = 0 ; i < listWidgetLabelName->count ; i++ ) { - widget_label_t *this; - this = (widget_label_t *)listWidgetLabelName->list[i]; + widget_t *this; + this = (widget_t *)listWidgetLabelName->list[i]; drawWidgetLabel(this); } for( i = 0 ; i < listWidgetLabelScore->count ; i++ ) { - widget_label_t *this; - this = (widget_label_t *)listWidgetLabelScore->list[i]; + widget_t *this; + this = (widget_t *)listWidgetLabelScore->list[i]; drawWidgetLabel(this); } } @@ -80,9 +80,9 @@ void stopScreenTable() static void eventWidget(void *p) { - widget_button_t *button; + widget_t *button; - button = (widget_button_t *)(p); + button = (widget_t *)(p); if( button == button_back ) { @@ -117,7 +117,7 @@ static void setWidgetLabel() for( i = 0 ; i < SCREEN_TABLE_MAX_PLAYERS ; i++ ) { - widget_label_t *label; + widget_t *label; char name[STR_NAME_SIZE]; char score[STR_NUM_SIZE]; char num[STR_NUM_SIZE]; diff --git a/src/screen/screen_world.c b/src/screen/screen_world.c index e619bbb..4229556 100644 --- a/src/screen/screen_world.c +++ b/src/screen/screen_world.c @@ -78,16 +78,6 @@ void setWorldArena(int id) #endif } -void setMaxCountRound(int n) -{ - arena->max_countRound = n; -} - -int getMaxCountRound() -{ - return arena->max_countRound; -} - void setWorldEnd() { isEndWorld = TRUE; diff --git a/src/screen/screen_world.h b/src/screen/screen_world.h index 0ba4b41..a0358a7 100644 --- a/src/screen/screen_world.h +++ b/src/screen/screen_world.h @@ -15,10 +15,8 @@ extern bool_t isScreenWorldInicialized(); extern void initWorld(); extern void setWorldArena(int id); -extern void setLagServer(my_time_t lag); -extern void countRoundInc(); extern void setWorldEnd(); -extern void setMaxCountRound(int n); +extern void countRoundInc(); extern tux_t* getControlTux(int control_type); extern void setControlTux(tux_t *tux, int control_type); extern void tuxControl(tux_t *p); |