diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2009-06-15 13:16:33 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2009-06-15 13:16:33 +0000 |
| commit | 57b2c49d571ac160d03b9bc30b6eb72976bfe82a (patch) | |
| tree | 9e39336ac1976472b2a6a4fd69fa8e3b7f41bd9e /src/game | |
| parent | feade98dae813a1cdff48c4f15b3c01fb1fd3e8d (diff) | |
| download | zcatch-57b2c49d571ac160d03b9bc30b6eb72976bfe82a.tar.gz zcatch-57b2c49d571ac160d03b9bc30b6eb72976bfe82a.zip | |
fixed so that the demo player doesn't crash when the map isn't found
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/client/components/menus.cpp | 17 | ||||
| -rw-r--r-- | src/game/client/components/menus.hpp | 8 | ||||
| -rw-r--r-- | src/game/client/components/menus_demo.cpp | 6 |
3 files changed, 29 insertions, 2 deletions
diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 1748fe18..168c514d 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -666,6 +666,15 @@ void MENUS::on_init() config.cl_show_welcome = 0; } +void MENUS::popup_message(const char *topic, const char *body, const char *button) +{ + str_copy(message_topic, topic, sizeof(message_topic)); + str_copy(message_body, body, sizeof(message_body)); + str_copy(message_button, button, sizeof(message_button)); + popup = POPUP_MESSAGE; +} + + int MENUS::render() { RECT screen = *ui_screen(); @@ -749,7 +758,13 @@ int MENUS::render() const char *button_text = ""; int extra_align = 0; - if(popup == POPUP_CONNECTING) + if(popup == POPUP_MESSAGE) + { + title = message_topic; + extra_text = message_body; + button_text = message_button; + } + else if(popup == POPUP_CONNECTING) { title = localize("Connecting to"); extra_text = config.ui_server_address; // TODO: query the client about the address diff --git a/src/game/client/components/menus.hpp b/src/game/client/components/menus.hpp index 3ca3ee43..15369dbc 100644 --- a/src/game/client/components/menus.hpp +++ b/src/game/client/components/menus.hpp @@ -68,6 +68,7 @@ class MENUS : public COMPONENT POPUP_NONE=0, POPUP_FIRST_LAUNCH, POPUP_CONNECTING, + POPUP_MESSAGE, POPUP_DISCONNECTED, POPUP_PURE, POPUP_PASSWORD, @@ -95,6 +96,13 @@ class MENUS : public COMPONENT vec2 mouse_pos; int64 last_input; + + // + char message_topic[512]; + char message_body[512]; + char message_button[512]; + + void popup_message(const char *topic, const char *body, const char *button); // TODO: this is a bit ugly but.. well.. yeah enum { MAX_INPUTEVENTS = 32 }; diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index 3a22fde2..efcf05b8 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -406,7 +406,11 @@ void MENUS::render_demolist(RECT main_view) if(ui_do_button(&play_button, localize("Play"), 0, &play_rect, ui_draw_menu_button, 0)) { if(selected_item >= 0 && selected_item < demos.size()) - client_demoplayer_play(demos[selected_item].filename); + { + const char *error = client_demoplayer_play(demos[selected_item].filename); + if(error) + popup_message(localize("Error"), error, localize("Ok")); + } } } |