diff options
| author | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-08-14 14:47:44 +0000 |
|---|---|---|
| committer | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-08-14 14:47:44 +0000 |
| commit | 50ba3d5e1e9f9eeda049a348efa4645af07610bc (patch) | |
| tree | 3a41428f4ce755e596a4d5c2c69668515935e5b0 /src/screen | |
| parent | 5b67651831ad9b160b41990288c938c7a05c1db1 (diff) | |
- novy widget widget_choicegroup
- moznost ukladat a nacitavat rozohranu hru
( uklada sa pomocou F2)
( neda sa ulozit sietovy multiplayer, a este
nie je dokonce ulozenie hranie s AI )
git-svn-id: http://opensvn.csie.org/tuxanci_ng@195 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/screen')
| -rw-r--r-- | src/screen/screen_gameType.c | 168 | ||||
| -rw-r--r-- | src/screen/screen_gameType.h | 1 | ||||
| -rw-r--r-- | src/screen/screen_world.c | 43 |
3 files changed, 152 insertions, 60 deletions
diff --git a/src/screen/screen_gameType.c b/src/screen/screen_gameType.c index bafa747..986b5dd 100644 --- a/src/screen/screen_gameType.c +++ b/src/screen/screen_gameType.c @@ -5,6 +5,8 @@ #include "main.h" #include "list.h" +#include "director.h" +#include "homeDirector.h" #include "net_multiplayer.h" #include "tux.h" @@ -24,7 +26,8 @@ #include "widget_button.h" #include "widget_image.h" #include "widget_textfield.h" -#include "widget_check.h" +#include "widget_choicegroup.h" +#include "widget_select.h" static widget_image_t *image_backgorund; @@ -35,17 +38,23 @@ static widget_button_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_label_t *label_ip; static widget_label_t *label_port; +static widget_label_t *label_session; -static widget_check_t *check_none; -static widget_check_t *check_server; -static widget_check_t *check_client; +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_textfield_t *textfield_ip; static widget_textfield_t *textfield_port; +static widget_select_t *selectSession; + void startScreenGameType() { #ifndef NO_SOUND @@ -59,13 +68,24 @@ void startScreenGameType() void drawScreenGameType() { + int i; + drawWidgetImage(image_backgorund); + for( i = 0 ; i < listChoiceGroup->count ; i++ ) + { + widget_choicegroup_t *this; + + this = (widget_choicegroup_t *)listChoiceGroup->list[i]; + drawWidgetChoicegroup(this); + } + drawWidgetLabel(label_none); drawWidgetLabel(label_server); drawWidgetLabel(label_client); + drawWidgetLabel(label_load_session); - if( check_none->status == FALSE ) + if( check_server->status == TRUE || check_client->status == TRUE ) { drawWidgetLabel(label_port); drawWidgetTextfield(textfield_port); @@ -73,6 +93,12 @@ void drawScreenGameType() drawWidgetTextfield(textfield_ip); } + if( check_load_session->status == TRUE ) + { + drawWidgetLabel(label_session); + drawWidgetSelect(selectSession); + } + #if 0 if( check_server->status == TRUE ) { @@ -83,11 +109,7 @@ void drawScreenGameType() if( check_client->status == TRUE ) drawWidgetButton(button_browser); - - drawWidgetCheck(check_none); - drawWidgetCheck(check_server); - drawWidgetCheck(check_client); - + drawWidgetButton(button_back); drawWidgetButton(button_play); @@ -95,12 +117,26 @@ void drawScreenGameType() void eventScreenGameType() { - eventWidgetCheck(check_none); - eventWidgetCheck(check_server); - eventWidgetCheck(check_client); + int i; + + for( i = 0 ; i < listChoiceGroup->count ; i++ ) + { + widget_choicegroup_t *this; + + this = (widget_choicegroup_t *)listChoiceGroup->list[i]; + eventWidgetChoicegroup(this); + } + + if( check_server->status == TRUE || check_client->status == TRUE ) + { + eventWidgetTextfield(textfield_ip); + eventWidgetTextfield(textfield_port); + } - eventWidgetTextfield(textfield_ip); - eventWidgetTextfield(textfield_port); + if( check_load_session->status == TRUE ) + { + eventWidgetSelect(selectSession); + } eventWidgetButton(button_back); eventWidgetButton(button_play); @@ -116,34 +152,8 @@ void stopScreenGameType() static void eventWidget(void *p) { widget_button_t *button; - widget_check_t *check; button = (widget_button_t *)(p); - check = (widget_check_t *)(p); - - if( check == check_none ) - { - check_none->status = TRUE; - check_server->status = FALSE; - check_client->status = FALSE; - return; - } - - if( check == check_server ) - { - check_none->status = FALSE; - check_server->status = TRUE; - check_client->status = FALSE; - return; - } - - if( check == check_client ) - { - check_none->status = FALSE; - check_server->status = FALSE; - check_client->status = TRUE; - return; - } if( button == button_back ) { @@ -152,6 +162,16 @@ static void eventWidget(void *p) if( button == button_play ) { + char *str; + + str = getGemeTypeLoadSession(); + + if( str != NULL ) + { + setScreen("world"); + return; + } + if( getSettingGameType() == NET_GAME_TYPE_CLIENT ) { setScreen("world"); @@ -168,6 +188,33 @@ 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; @@ -179,9 +226,11 @@ void initScreenGameType() button_play = newWidgetButton(getMyText("PLAY"), WINDOW_SIZE_X-200, WINDOW_SIZE_Y-100, eventWidget); button_browser = newWidgetButton(getMyText("BROWSER"), 300, 345, eventWidget); - check_none = newWidgetCheck(100, 150, FALSE, eventWidget); - check_server = newWidgetCheck(100, 200, FALSE, eventWidget); - check_client = newWidgetCheck(100, 250, FALSE, eventWidget); + listChoiceGroup = newList(); + check_none = newWidgetChoicegroup(100, 150, FALSE, listChoiceGroup, eventWidget); + check_server = newWidgetChoicegroup(100, 200, FALSE, listChoiceGroup, eventWidget); + check_client = newWidgetChoicegroup(100, 250, FALSE, listChoiceGroup, eventWidget); + check_load_session = newWidgetChoicegroup(100, 300, FALSE, listChoiceGroup, eventWidget); if( isParamFlag("--server") ) { @@ -199,9 +248,11 @@ void initScreenGameType() label_none = newWidgetLabel(getMyText("NONE"), 130, 145, WIDGET_LABEL_LEFT); label_server = newWidgetLabel(getMyText("SERVER"), 130, 195, WIDGET_LABEL_LEFT); label_client = newWidgetLabel(getMyText("CLIENT"), 130, 245, WIDGET_LABEL_LEFT); + label_load_session = newWidgetLabel("load session", 130, 295, WIDGET_LABEL_LEFT); label_ip = newWidgetLabel(getMyText("IP_ADDR"), 300, 145, WIDGET_LABEL_LEFT); label_port = newWidgetLabel(getMyText("NET_PORT"), 300, 245, WIDGET_LABEL_LEFT); + label_session = newWidgetLabel("load session :", 300, 145, WIDGET_LABEL_LEFT); textfield_ip = newWidgetTextfield( getParamElse("--ip", "127.0.0.1"), @@ -213,6 +264,9 @@ void initScreenGameType() WIDGET_TEXTFIELD_FILTER_NUM, 300, 280); + selectSession = newWidgetSelect(300, 175, eventWidget); + loadSession(selectSession); + registerScreen( newScreen("gameType", startScreenGameType, eventScreenGameType, drawScreenGameType, stopScreenGameType) ); } @@ -226,7 +280,8 @@ int setSettingGameType(int status) int getSettingGameType() { - if( check_none->status == TRUE ) + if( check_none->status == TRUE || + check_load_session->status == TRUE ) { return NET_GAME_TYPE_NONE; } @@ -246,6 +301,16 @@ int getSettingGameType() return -1; } +char* getGemeTypeLoadSession() +{ + if( check_load_session->status == TRUE ) + { + return getWidgetSelectItem(selectSession); + } + + return NULL; +} + int setSettingIP(char *address) { strcpy (textfield_ip->text, address); @@ -293,19 +358,26 @@ void quitScreenGameType() destroyWidgetLabel(label_none); destroyWidgetLabel(label_server); destroyWidgetLabel(label_client); + destroyWidgetLabel(label_load_session); destroyWidgetLabel(label_ip); destroyWidgetLabel(label_port); + destroyWidgetLabel(label_session); destroyWidgetTextfield(textfield_ip); destroyWidgetTextfield(textfield_port); + destroyWidgetSelect(selectSession); + destroyWidgetButton(button_back); destroyWidgetButton(button_play); destroyWidgetButton(button_browser); - destroyWidgetCheck(check_none); - destroyWidgetCheck(check_server); - destroyWidgetCheck(check_client); + destroyWidgetChoicegroup(check_none); + destroyWidgetChoicegroup(check_server); + destroyWidgetChoicegroup(check_client); + destroyWidgetChoicegroup(check_load_session); + + destroyList(listChoiceGroup); } diff --git a/src/screen/screen_gameType.h b/src/screen/screen_gameType.h index 1d9b734..28976e0 100644 --- a/src/screen/screen_gameType.h +++ b/src/screen/screen_gameType.h @@ -10,6 +10,7 @@ extern void eventScreenGameType(); extern void initScreenGameType(); extern int setSettingGameType(int status); extern int getSettingGameType(); +extern char* getGemeTypeLoadSession(); extern int setSettingIP(char *address); extern char* getSettingIP(); extern int setSettingPort(int port); diff --git a/src/screen/screen_world.c b/src/screen/screen_world.c index 12da3a1..e619bbb 100644 --- a/src/screen/screen_world.c +++ b/src/screen/screen_world.c @@ -27,6 +27,8 @@ #include "chat.h" #include "pauza.h" #include "term.h" +#include "saveDialog.h" +#include "saveLoad.h" #ifndef NO_SOUND #include "music.h" @@ -43,8 +45,6 @@ static arena_t *arena; -static int count; -static int max_count; static bool_t isScreenWorldInit = FALSE; static bool_t isEndWorld; @@ -80,7 +80,12 @@ void setWorldArena(int id) void setMaxCountRound(int n) { - max_count = n; + arena->max_countRound = n; +} + +int getMaxCountRound() +{ + return arena->max_countRound; } void setWorldEnd() @@ -99,16 +104,16 @@ static void timer_endArena() void countRoundInc() { - if( count == WORLD_COUNT_ROUND_UNLIMITED || - count >= max_count ) + if( arena->max_countRound == WORLD_COUNT_ROUND_UNLIMITED || + arena->countRound >= arena->max_countRound ) { return; } - count++; + arena->countRound++; //printf("count %d/%d\n", count, max_count); - if( count >= max_count ) + if( arena->countRound >= arena->max_countRound ) { //printf("count %d ending\n", count); #ifndef NO_SOUND @@ -128,12 +133,18 @@ void prepareArena() tuxWithControlRightKeyboard = NULL; tuxWithControlLeftKeyboard = NULL; + if( getGemeTypeLoadSession() != NULL ) + { + loadArena(getGemeTypeLoadSession()); + return; + } + switch( getNetTypeGame() ) { case NET_GAME_TYPE_NONE : setWorldArena( getChoiceArenaId() ); addNewItem(arena->spaceItem, ID_UNKNOWN); - getSettingCountRound(&max_count); + getSettingCountRound(&arena->max_countRound); tux = newTux(); tux->control = TUX_CONTROL_KEYBOARD_RIGHT; @@ -156,12 +167,15 @@ void prepareArena() tux->control = TUX_CONTROL_AI; } } + + //printf("getGemeTypeLoadSession = %s\n", getGemeTypeLoadSession()); + break; case NET_GAME_TYPE_SERVER : setWorldArena( getChoiceArenaId() ); addNewItem(arena->spaceItem, ID_UNKNOWN); - getSettingCountRound(&max_count); + getSettingCountRound(&arena->max_countRound); tux = newTux(); tux->control = TUX_CONTROL_KEYBOARD_RIGHT; @@ -192,6 +206,7 @@ void drawWorld() drawChat(); drawPauza(); drawTerm(); + drawSaveDialog(); } static void netAction(tux_t *tux, int action) @@ -460,7 +475,7 @@ void eventWorld() eventNetMultiplayer(); - if( isPauzeActive() == FALSE ) + if( isPauzeActive() == FALSE && isSaveDialogActive() == FALSE ) { eventArena(arena); //eventModule(); @@ -487,6 +502,8 @@ void eventWorld() eventChat(); eventPauza(); eventTerm(); + eventSaveDialog(); + eventEsc(); } @@ -495,12 +512,12 @@ void startWorld() arena = NULL; isEndWorld = FALSE; - count = 0; - initListID(); initRadar(); initPauza(); initTerm(); + initSaveDialog(); + initModule(); setGameType(); initChat(); @@ -563,6 +580,8 @@ void stoptWorld() quitRadar(); quitPauza(); quitTerm(); + quitSaveDialog(); + #ifndef NO_SOUND stopMusic(); |