From bf76fbff6ec058f4e186e27904313b4cc31fac62 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Thu, 5 Jun 2014 16:16:08 +0200 Subject: [PATCH 01/17] Fix bug with deactivated widgets where visibility is changed --- src/guiengine/event_handler.cpp | 6 +++--- src/guiengine/widget.cpp | 1 - src/guiengine/widgets/spinner_widget.hpp | 2 -- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/guiengine/event_handler.cpp b/src/guiengine/event_handler.cpp index cfcc0332c..0e6e3465f 100644 --- a/src/guiengine/event_handler.cpp +++ b/src/guiengine/event_handler.cpp @@ -631,7 +631,7 @@ void EventHandler::sendEventToUser(GUIEngine::Widget* widget, std::string& name, EventPropagation EventHandler::onWidgetActivated(GUIEngine::Widget* w, const int playerID) { - if (w->m_deactivated) return EVENT_BLOCK; + if (!w->isActivated()) return EVENT_BLOCK; Widget* parent = w->m_event_handler; @@ -658,7 +658,7 @@ EventPropagation EventHandler::onWidgetActivated(GUIEngine::Widget* w, const int parent = parent->m_event_handler; } - if (parent->m_deactivated) return EVENT_BLOCK; + if (!parent->isActivated()) return EVENT_BLOCK; /* notify the found event event handler, and also notify the main callback if the parent event handler says so */ @@ -699,7 +699,7 @@ EventPropagation EventHandler::onGUIEvent(const SEvent& event) { Widget* w = GUIEngine::getWidget(id); if (w == NULL) break; - if (w->m_deactivated) + if (!w->isActivated()) { GUIEngine::getCurrentScreen()->onDisabledItemClicked(w->m_properties[PROP_ID].c_str()); return EVENT_BLOCK; diff --git a/src/guiengine/widget.cpp b/src/guiengine/widget.cpp index 446d4b565..4d8fe4e98 100644 --- a/src/guiengine/widget.cpp +++ b/src/guiengine/widget.cpp @@ -339,7 +339,6 @@ void Widget::setVisible(bool visible) m_element->setVisible(visible); } m_is_visible = visible; - m_deactivated = !visible; const int childrenCount = m_children.size(); for (int n=0; n Date: Thu, 5 Jun 2014 18:27:19 +0200 Subject: [PATCH 02/17] Fix compiler warnings --- lib/bullet/src/LinearMath/btScalar.h | 2 +- src/animations/animation_base.hpp | 1 + src/graphics/glwrap.cpp | 6 +++--- src/graphics/stkbillboard.cpp | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/bullet/src/LinearMath/btScalar.h b/lib/bullet/src/LinearMath/btScalar.h index 7d54bf5ad..f601e3a90 100644 --- a/lib/bullet/src/LinearMath/btScalar.h +++ b/lib/bullet/src/LinearMath/btScalar.h @@ -109,7 +109,7 @@ inline int btGetVersion() #ifdef __SPU__ #include #define printf spu_printf - #define btAssert(x) {if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);spu_hcmpeq(0,0);}} + #define btAssert(x) {if(!(x)){printf("Assert " __FILE__ ":%u ("#x")\n", __LINE__);spu_hcmpeq(0,0);}} #else #define btAssert assert #endif diff --git a/src/animations/animation_base.hpp b/src/animations/animation_base.hpp index 2bc335bc3..9be757ae6 100644 --- a/src/animations/animation_base.hpp +++ b/src/animations/animation_base.hpp @@ -69,6 +69,7 @@ protected: public: AnimationBase(const XMLNode &node); AnimationBase(Ipo *ipo); + virtual ~AnimationBase() {}; virtual void update(float dt, Vec3 *xyz=NULL, Vec3 *hpr=NULL, Vec3 *scale=NULL); /** This needs to be implemented by the inheriting classes. It is called diff --git a/src/graphics/glwrap.cpp b/src/graphics/glwrap.cpp index 45c51a279..516be8203 100644 --- a/src/graphics/glwrap.cpp +++ b/src/graphics/glwrap.cpp @@ -532,7 +532,7 @@ unsigned GPUTimer::elapsedTimeus() FrameBuffer::FrameBuffer() {} FrameBuffer::FrameBuffer(const std::vector &RTTs, size_t w, size_t h, bool layered) : - DepthTexture(0), RenderTargets(RTTs), width(w), height(h) + RenderTargets(RTTs), DepthTexture(0), width(w), height(h) { glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); @@ -551,7 +551,7 @@ FrameBuffer::FrameBuffer(const std::vector &RTTs, size_t w, size_t h, bo } FrameBuffer::FrameBuffer(const std::vector &RTTs, GLuint DS, size_t w, size_t h, bool layered) : - DepthTexture(DS), RenderTargets(RTTs), width(w), height(h) + RenderTargets(RTTs), DepthTexture(DS), width(w), height(h) { glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); @@ -904,4 +904,4 @@ void GL32_draw2DRectangle(video::SColor color, const core::rect& position, glUseProgram(0); glGetError(); -} \ No newline at end of file +} diff --git a/src/graphics/stkbillboard.cpp b/src/graphics/stkbillboard.cpp index 4ce29f479..710dec32d 100644 --- a/src/graphics/stkbillboard.cpp +++ b/src/graphics/stkbillboard.cpp @@ -22,7 +22,7 @@ static void createbillboardvao() STKBillboard::STKBillboard(irr::scene::ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id, const irr::core::vector3df& position, const irr::core::dimension2d& size, irr::video::SColor colorTop, irr::video::SColor colorBottom) : - CBillboardSceneNode(parent, mgr, id, position, size, colorTop, colorBottom), IBillboardSceneNode(parent, mgr, id, position) + IBillboardSceneNode(parent, mgr, id, position), CBillboardSceneNode(parent, mgr, id, position, size, colorTop, colorBottom) { if (!billboardvao) createbillboardvao(); From db4699781ad156775e15bc14743c4e53b3fb39f6 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Thu, 5 Jun 2014 18:47:15 +0200 Subject: [PATCH 03/17] Fix my fix --- src/animations/animation_base.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/animations/animation_base.hpp b/src/animations/animation_base.hpp index 9be757ae6..1fc6ef090 100644 --- a/src/animations/animation_base.hpp +++ b/src/animations/animation_base.hpp @@ -69,7 +69,7 @@ protected: public: AnimationBase(const XMLNode &node); AnimationBase(Ipo *ipo); - virtual ~AnimationBase() {}; + virtual ~AnimationBase() {} virtual void update(float dt, Vec3 *xyz=NULL, Vec3 *hpr=NULL, Vec3 *scale=NULL); /** This needs to be implemented by the inheriting classes. It is called From cd8c27cbecec79c12cad2e6adf5066a6a695df83 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Thu, 5 Jun 2014 22:07:00 +0200 Subject: [PATCH 04/17] Save 'remember-password' setting per user --- src/config/player_manager.cpp | 13 +++++-------- src/config/player_profile.cpp | 26 +++++++++++++++----------- src/config/player_profile.hpp | 10 ++++++++++ src/config/user_config.hpp | 4 ---- src/online/online_player_profile.cpp | 12 ++++++------ src/states_screens/user_screen.cpp | 19 +++++++++++++------ 6 files changed, 49 insertions(+), 35 deletions(-) diff --git a/src/config/player_manager.cpp b/src/config/player_manager.cpp index 0455fab3c..31d553cb7 100644 --- a/src/config/player_manager.cpp +++ b/src/config/player_manager.cpp @@ -166,15 +166,12 @@ PlayerManager::PlayerManager() */ PlayerManager::~PlayerManager() { - // If the passwords should not be remembered, clear all saved sessions. - if(!UserConfigParams::m_remember_user) + // If the passwords should not be remembered, clear the saved session. + PlayerProfile *player; + for_in(player, m_all_players) { - PlayerProfile *player; - for_in(player, m_all_players) - { + if(player->rememberPassword()) player->clearSession(); - } - } save(); @@ -266,7 +263,7 @@ void PlayerManager::save() players_file << L"\n"; players_file << L"\n"; - if(m_current_player && UserConfigParams::m_remember_user) + if(m_current_player) { players_file << L" getName() << L"\"/>\n"; diff --git a/src/config/player_profile.cpp b/src/config/player_profile.cpp index fe7d47077..e8db49a39 100644 --- a/src/config/player_profile.cpp +++ b/src/config/player_profile.cpp @@ -47,6 +47,7 @@ PlayerProfile::PlayerProfile(const core::stringw& name, bool is_guest) m_saved_user_id = 0; m_last_online_name = ""; m_last_was_online = false; + m_remember_password = false; initRemainingData(); } // PlayerProfile @@ -72,20 +73,22 @@ PlayerProfile::PlayerProfile(const XMLNode* node) m_saved_user_id = 0; m_last_online_name = ""; m_last_was_online = false; + m_remember_password = false; m_story_mode_status = NULL; m_achievements_status = NULL; m_icon_filename = ""; - node->get("name", &m_local_name ); - node->get("guest", &m_is_guest_account); - node->get("use-frequency", &m_use_frequency ); - node->get("unique-id", &m_unique_id ); - node->get("saved-session", &m_saved_session ); - node->get("saved-user", &m_saved_user_id ); - node->get("saved-token", &m_saved_token ); - node->get("last-online-name", &m_last_online_name); - node->get("last-was-online", &m_last_was_online ); - node->get("icon-filename", &m_icon_filename ); + node->get("name", &m_local_name ); + node->get("guest", &m_is_guest_account ); + node->get("use-frequency", &m_use_frequency ); + node->get("unique-id", &m_unique_id ); + node->get("saved-session", &m_saved_session ); + node->get("saved-user", &m_saved_user_id ); + node->get("saved-token", &m_saved_token ); + node->get("last-online-name", &m_last_online_name ); + node->get("last-was-online", &m_last_was_online ); + node->get("remember-password", &m_remember_password); + node->get("icon-filename", &m_icon_filename ); #ifdef DEBUG m_magic_number = 0xABCD1234; @@ -203,7 +206,8 @@ void PlayerProfile::save(UTFWriter &out) out << L" saved-user=\"" << m_saved_user_id << L"\" saved-token=\"" << m_saved_token << L"\"\n"; out << L" last-online-name=\"" << m_last_online_name - << L"\" last-was-online=\"" << m_last_was_online<< L"\">\n"; + << L"\" last-was-online=\"" << m_last_was_online << L"\"\n"; + out << L" remember-password=\"" << m_remember_password << L"\">\n"; { if(m_story_mode_status) m_story_mode_status->save(out); diff --git a/src/config/player_profile.hpp b/src/config/player_profile.hpp index a4c5ab3c7..82bbb1b92 100644 --- a/src/config/player_profile.hpp +++ b/src/config/player_profile.hpp @@ -101,6 +101,9 @@ private: /** True if the last time this player was used as online. */ bool m_last_was_online; + /** True if the login data are saved. */ + bool m_remember_password; + /** The complete challenge state. */ StoryModeStatus *m_story_mode_status; @@ -269,6 +272,13 @@ public: /** Sets if this player was logged in last time it was used. */ void setWasOnlineLastTime(bool b) { m_last_was_online = b; } // ------------------------------------------------------------------------ + /** Returns if the last time this player was used it was used online or + * offline. */ + bool rememberPassword() const { return m_remember_password; } + // ------------------------------------------------------------------------ + /** Sets if this player was logged in last time it was used. */ + void setRememberPassword(bool b) { m_remember_password = b; } + // ------------------------------------------------------------------------ }; // class PlayerProfile #endif diff --git a/src/config/user_config.hpp b/src/config/user_config.hpp index bf91d0ddc..bf65f4633 100644 --- a/src/config/user_config.hpp +++ b/src/config/user_config.hpp @@ -682,10 +682,6 @@ namespace UserConfigParams // ---- User managerment - PARAM_PREFIX BoolUserConfigParam m_remember_user - PARAM_DEFAULT( BoolUserConfigParam(true, "remember_me", - "Automatically remember login data")); - PARAM_PREFIX BoolUserConfigParam m_always_show_login_screen PARAM_DEFAULT( BoolUserConfigParam(false, "always_show_login_screen", "Always show the login screen even if last player's session was saved.")); diff --git a/src/online/online_player_profile.cpp b/src/online/online_player_profile.cpp index 11634a4a0..6617a2195 100644 --- a/src/online/online_player_profile.cpp +++ b/src/online/online_player_profile.cpp @@ -125,8 +125,8 @@ namespace Online request->addParameter("username",username); request->addParameter("password",password); request->addParameter("save-session", - UserConfigParams::m_remember_user ? "true" - : "false"); + rememberPassword() ? "true" + : "false"); request->queue(); m_online_state = OS_SIGNING_IN; return request; @@ -187,7 +187,7 @@ namespace Online m_profile = new OnlineProfile(userid, username, true); assert(token_fetched && username_fetched && userid_fetched); m_online_state = OS_SIGNED_IN; - if(UserConfigParams::m_remember_user) + if(rememberPassword()) { saveSession(getOnlineId(), getToken() ); } @@ -238,8 +238,8 @@ namespace Online { m_player = player; m_player->setUserDetails(this, - UserConfigParams::m_remember_user ? "client-quit" - :"disconnect"); + m_player->rememberPassword() ? "client-quit" + : "disconnect"); setAbortable(false); } // SignOutRequest }; // SignOutRequest @@ -282,7 +282,7 @@ namespace Online m_profile = NULL; m_online_state = OS_SIGNED_OUT; // Discard token if session should not be saved. - if(!UserConfigParams::m_remember_user) + if(!rememberPassword()) clearSession(); } // signOut diff --git a/src/states_screens/user_screen.cpp b/src/states_screens/user_screen.cpp index 0f305431c..0f8532d1b 100644 --- a/src/states_screens/user_screen.cpp +++ b/src/states_screens/user_screen.cpp @@ -74,7 +74,7 @@ void BaseUserScreen::init() assert(m_info_widget); getWidget("remember-user") - ->setState(UserConfigParams::m_remember_user); + ->setState(false); m_sign_out_name = ""; m_sign_in_name = ""; @@ -114,6 +114,8 @@ void BaseUserScreen::init() // Select 'online m_online_cb->setState(player->wasOnlineLastTime() || player->isLoggedIn() ); + getWidget("remember-user")->setState( + player->rememberPassword()); makeEntryFieldsVisible(); // We have to deactivate after make visible (since make visible // automatically activates widgets). @@ -157,8 +159,6 @@ void BaseUserScreen::selectUser(int index) PlayerProfile *profile = PlayerManager::get()->getPlayer(index); assert(profile); - getWidget("username")->setText(profile - ->getLastOnlineName()); m_players->setSelection(StringUtils::toString(index), 0, /*focusIt*/true); // Last game was not online, so make the offline settings the default @@ -175,6 +175,8 @@ void BaseUserScreen::selectUser(int index) m_online_cb->setState(true); makeEntryFieldsVisible(); m_username_tb->setText(profile->getLastOnlineName()); + getWidget("remember-user")->setState( + profile->rememberPassword()); // And make the password invisible if the session is saved (i.e // the user does not need to enter a password). @@ -242,8 +244,8 @@ void BaseUserScreen::eventCallback(Widget* widget, } else if (name == "remember-user") { - UserConfigParams::m_remember_user = - getWidget("remember-user")->getState(); + getSelectedPlayer()->setRememberPassword( + getWidget("remember-user")->getState()); } else if (name == "online") { @@ -257,8 +259,13 @@ void BaseUserScreen::eventCallback(Widget* widget, true); sfx_manager->quickSound( "anvil" ); m_online_cb->setState(false); + } else + { + m_username_tb->setText(""); + m_password_tb->setText(""); + getWidget("remember-user")->setState(false); + makeEntryFieldsVisible(); } - makeEntryFieldsVisible(); } else if (name == "options") { From de4e45280b093ddb9fc3a276f8b3b33a541bdf79 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Fri, 6 Jun 2014 11:31:52 +0200 Subject: [PATCH 05/17] Remember password better --- src/config/player_manager.cpp | 2 +- src/config/player_profile.cpp | 2 +- src/online/online_player_profile.cpp | 2 +- src/states_screens/user_screen.cpp | 67 +++++++++------------------- 4 files changed, 25 insertions(+), 48 deletions(-) diff --git a/src/config/player_manager.cpp b/src/config/player_manager.cpp index 31d553cb7..af4e0bc63 100644 --- a/src/config/player_manager.cpp +++ b/src/config/player_manager.cpp @@ -170,7 +170,7 @@ PlayerManager::~PlayerManager() PlayerProfile *player; for_in(player, m_all_players) { - if(player->rememberPassword()) + if(!player->rememberPassword()) player->clearSession(); } save(); diff --git a/src/config/player_profile.cpp b/src/config/player_profile.cpp index e8db49a39..c5fdcabe5 100644 --- a/src/config/player_profile.cpp +++ b/src/config/player_profile.cpp @@ -207,7 +207,7 @@ void PlayerProfile::save(UTFWriter &out) << L"\" saved-token=\"" << m_saved_token << L"\"\n"; out << L" last-online-name=\"" << m_last_online_name << L"\" last-was-online=\"" << m_last_was_online << L"\"\n"; - out << L" remember-password=\"" << m_remember_password << L"\">\n"; + out << L" remember-password=\"" << m_remember_password << L"\">\n"; { if(m_story_mode_status) m_story_mode_status->save(out); diff --git a/src/online/online_player_profile.cpp b/src/online/online_player_profile.cpp index 6617a2195..4559fa538 100644 --- a/src/online/online_player_profile.cpp +++ b/src/online/online_player_profile.cpp @@ -189,7 +189,7 @@ namespace Online m_online_state = OS_SIGNED_IN; if(rememberPassword()) { - saveSession(getOnlineId(), getToken() ); + saveSession(getOnlineId(), getToken()); } ProfileManager::get()->addPersistent(m_profile); std::string achieved_string(""); diff --git a/src/states_screens/user_screen.cpp b/src/states_screens/user_screen.cpp index 20011b4a7..266d73db6 100644 --- a/src/states_screens/user_screen.cpp +++ b/src/states_screens/user_screen.cpp @@ -73,8 +73,6 @@ void BaseUserScreen::init() m_info_widget = getWidget("message"); assert(m_info_widget); - getWidget("remember-user") - ->setState(false); m_sign_out_name = ""; m_sign_in_name = ""; @@ -87,7 +85,7 @@ void BaseUserScreen::init() Screen::init(); m_players->clearItems(); - std::string current_player_index=""; + int current_player_index = -1; for (unsigned int n=0; ngetNumPlayers(); n++) { @@ -96,40 +94,20 @@ void BaseUserScreen::init() std::string s = StringUtils::toString(n); m_players->addItem(player->getName(), s, player->getIconFilename(), 0, IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE); - if(player==PlayerManager::getCurrentPlayer()) - current_player_index = s; + if(player == PlayerManager::getCurrentPlayer()) + current_player_index = n; } m_players->updateItemDisplay(); // Select the current player. That can only be done after // updateItemDisplay is called. - if(current_player_index.size()>0) - { - m_players->setSelection(current_player_index, PLAYER_ID_GAME_MASTER, - /*focus*/ true); - PlayerProfile *player = PlayerManager::getCurrentPlayer(); - const stringw &online_name = player->getLastOnlineName(); - m_username_tb->setText(online_name); - // Select 'online - m_online_cb->setState(player->wasOnlineLastTime() || - player->isLoggedIn() ); - getWidget("remember-user")->setState( - player->rememberPassword()); - makeEntryFieldsVisible(); - // We have to deactivate after make visible (since make visible - // automatically activates widgets). - if(online_name.size()>0) - m_username_tb->setDeactivated(); - else - m_username_tb->setActivated(); - } - else // no current player found - { - // The first player is the most frequently used, so select it - if (PlayerManager::get()->getNumPlayers() > 0) - selectUser(0); - } + if(current_player_index != -1) + selectUser(current_player_index); + // no current player found + // The first player is the most frequently used, so select it + else if (PlayerManager::get()->getNumPlayers() > 0) + selectUser(0); } // init @@ -159,7 +137,8 @@ void BaseUserScreen::selectUser(int index) PlayerProfile *profile = PlayerManager::get()->getPlayer(index); assert(profile); - m_players->setSelection(StringUtils::toString(index), 0, /*focusIt*/true); + m_players->setSelection(StringUtils::toString(index), PLAYER_ID_GAME_MASTER, + /*focusIt*/ true); // Last game was not online, so make the offline settings the default // (i.e. unckeck online checkbox, and make entry fields invisible). @@ -255,21 +234,19 @@ void BaseUserScreen::eventCallback(Widget* widget, { // If online access is not allowed, do not accept an online account // but advice the user where to enable this option. - if (m_online_cb->getState() && UserConfigParams::m_internet_status == + if (m_online_cb->getState()) + { + if (UserConfigParams::m_internet_status == Online::RequestManager::IPERM_NOT_ALLOWED) - { - m_info_widget->setText( - _("Internet access is disabled, please enable it in the options"), - true); - sfx_manager->quickSound( "anvil" ); - m_online_cb->setState(false); - } else - { - m_username_tb->setText(""); - m_password_tb->setText(""); - getWidget("remember-user")->setState(false); - makeEntryFieldsVisible(); + { + m_info_widget->setText( + _("Internet access is disabled, please enable it in the options"), + true); + sfx_manager->quickSound( "anvil" ); + m_online_cb->setState(false); + } } + makeEntryFieldsVisible(); } else if (name == "options") { From 9a37cd2c2bf8661b3bc93f6b65bdc94f68e82947 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Fri, 6 Jun 2014 22:23:52 +0200 Subject: [PATCH 06/17] Change focus cycle so invisible and deactivated widgets are skiped --- src/guiengine/event_handler.cpp | 205 +++++++------------------------- src/guiengine/event_handler.hpp | 3 +- 2 files changed, 46 insertions(+), 162 deletions(-) diff --git a/src/guiengine/event_handler.cpp b/src/guiengine/event_handler.cpp index cfcc0332c..5f493127f 100644 --- a/src/guiengine/event_handler.cpp +++ b/src/guiengine/event_handler.cpp @@ -305,12 +305,12 @@ void EventHandler::processGUIAction(const PlayerAction action, case PA_ACCEL: case PA_MENU_UP: - navigateUp(playerID, type, pressedDown); + navigate(playerID, type, pressedDown, true); break; case PA_BRAKE: case PA_MENU_DOWN: - navigateDown(playerID, type, pressedDown); + navigate(playerID, type, pressedDown, false); break; case PA_RESCUE: @@ -364,10 +364,14 @@ const bool NAVIGATION_DEBUG = false; #pragma mark Private methods #endif -void EventHandler::navigateUp(const int playerID, Input::InputType type, const bool pressedDown) +/** + * Focus the next widget either downwards or upwards. + * + * \param reverse True means navigating up, false means down. + */ +void EventHandler::navigate(const int playerID, Input::InputType type, const bool pressedDown, const bool reverse) { - //std::cout << "Naviagte up!\n"; - IGUIElement *el = NULL/*, *first=NULL*/, *closest=NULL; + IGUIElement *el = NULL, *closest = NULL; if (type == Input::IT_STICKBUTTON && !pressedDown) return; @@ -378,19 +382,22 @@ void EventHandler::navigateUp(const int playerID, Input::InputType type, const b el = w->getIrrlichtElement(); } - // list widgets are a bit special, because up/down keys are also used // to navigate between various list items, not only to navigate between // components if (w != NULL && w->m_type == WTYPE_LIST) { - ListWidget* list = (ListWidget*)w; + ListWidget* list = (ListWidget*) w; - const bool stay_within_list = list->getSelectionID() > 0; + const bool stay_within_list = reverse ? list->getSelectionID() > 0 : + list->getSelectionID() < list->getItemCount() - 1; if (stay_within_list) { - list->setSelectionID(list->getSelectionID()-1); + if (reverse) + list->setSelectionID(list->getSelectionID() - 1); + else + list->setSelectionID(list->getSelectionID() + 1); return; } else @@ -399,16 +406,15 @@ void EventHandler::navigateUp(const int playerID, Input::InputType type, const b } } - if (w != NULL && w->m_tab_up_root != -1) + if (w != NULL && ((reverse && w->m_tab_up_root != -1) || (!reverse && w->m_tab_down_root != -1))) { - Widget* up = GUIEngine::getWidget( w->m_tab_up_root ); - assert( up != NULL ); - - el = up->getIrrlichtElement(); + Widget* next = GUIEngine::getWidget(reverse ? w->m_tab_up_root : w->m_tab_down_root); + assert(next != NULL); + el = next->getIrrlichtElement(); if (el == NULL) { - std::cerr << "WARNING : m_tab_down_root is set to an ID for which I can't find the widget\n"; + std::cerr << "WARNING : m_tab_down/up_root is set to an ID for which I can't find the widget\n"; return; } } @@ -424,190 +430,69 @@ void EventHandler::navigateUp(const int playerID, Input::InputType type, const b // find closest widget if (el != NULL && el->getTabGroup() != NULL) { - // if the current widget is e.g. 15, search for widget 14, 13, 12, ... (up to 10 IDs may be missing) - for (int n=1; n<10 && !found; n++) + // Up: if the current widget is e.g. 15, search for widget 14, 13, 12, ... (up to 10 IDs may be missing) + // Down: if the current widget is e.g. 5, search for widget 6, 7, 8, 9, ..., 15 (up to 10 IDs may be missing) + for (int n = 1; n < 10 && !found; n++) { - closest = GUIEngine::getGUIEnv()->getRootGUIElement()->getElementFromId(el->getTabOrder() - n, true); + closest = GUIEngine::getGUIEnv()->getRootGUIElement()->getElementFromId(el->getTabOrder() + (reverse ? -n : n), true); if (closest != NULL && Widget::isFocusableId(closest->getID())) { - if (NAVIGATION_DEBUG) std::cout << "Navigating up to " << closest->getID() << std::endl; Widget* closestWidget = GUIEngine::getWidget( closest->getID() ); if (playerID != PLAYER_ID_GAME_MASTER && !closestWidget->m_supports_multiplayer) return; // if a dialog is shown, restrict to items in the dialog if (ModalDialog::isADialogActive() && !ModalDialog::getCurrent()->isMyChild(closestWidget)) - { continue; + + if (NAVIGATION_DEBUG) + { + std::cout << "Navigating " << (reverse ? "up" : "down") << " to " << closest->getID() << std::endl; } - // when focusing a list by going up, select the last item of the list - assert (closestWidget != NULL); + assert(closestWidget != NULL); + + if (!closestWidget->isVisible() || !closestWidget->isActivated()) + continue; closestWidget->setFocusForPlayer(playerID); + // another list exception : when entering a list by going down, select the first item + // when focusing a list by going up, select the last item of the list if (closestWidget->m_type == WTYPE_LIST) { - IGUIListBox* list = (IGUIListBox*)(closestWidget->m_element); + ListWidget* list = (ListWidget*) closestWidget; assert(list != NULL); - - list->setSelected( list->getItemCount()-1 ); - return; + list->setSelectionID(reverse ? list->getItemCount() - 1 : 0); } found = true; - } } // end for - } if (!found) { if (NAVIGATION_DEBUG) - { - std::cout << "EventHandler::navigateUp : wrap around, selecting the last widget\n"; - } + std::cout << "EventHandler::navigat : wrap around\n"; - // select the last widget - Widget* lastWidget = NULL; + // select the last/first widget + Widget* wrapWidget = NULL; if (ModalDialog::isADialogActive()) { - lastWidget = ModalDialog::getCurrent()->getLastWidget(); + wrapWidget = reverse ? ModalDialog::getCurrent()->getLastWidget() : + ModalDialog::getCurrent()->getFirstWidget(); } else { Screen* screen = GUIEngine::getCurrentScreen(); if (screen == NULL) return; - lastWidget = screen->getLastWidget(); + wrapWidget = reverse ? screen->getLastWidget() : + screen->getFirstWidget(); } - if (lastWidget != NULL) lastWidget->setFocusForPlayer(playerID); - } -} - -// ----------------------------------------------------------------------------- - -void EventHandler::navigateDown(const int playerID, Input::InputType type, const bool pressedDown) -{ - //std::cout << "Naviagte down!\n"; - - IGUIElement *el = NULL, *closest = NULL; - - if (type == Input::IT_STICKBUTTON && !pressedDown) - return; - - Widget* w = GUIEngine::getFocusForPlayer(playerID); - if (w != NULL) - { - el = w->getIrrlichtElement(); - } - //std::cout << "!!! Player " << playerID << " navigating down of " << w->m_element->getID() << std::endl; - - // list widgets are a bit special, because up/down keys are also used - // to navigate between various list items, not only to navigate between - // components - if (w != NULL && w->m_type == WTYPE_LIST) - { - ListWidget* list = (ListWidget*)w; - - const bool stay_within_list = list->getSelectionID() < list->getItemCount()-1; - - if (stay_within_list) - { - list->setSelectionID(list->getSelectionID()+1); - return; - } - else - { - list->setSelectionID(-1); - } - } - - if (w != NULL && w->m_tab_down_root != -1) - { - Widget* down = GUIEngine::getWidget( w->m_tab_down_root ); - assert(down != NULL); - el = down->getIrrlichtElement(); - - if (el == NULL) - { - std::cerr << "WARNING : m_tab_down_root is set to an ID for which I can't find the widget\n"; - return; - } - } - - // don't allow navigating to any widget when a dialog is shown; only navigate to widgets in the dialog - if (ModalDialog::isADialogActive() && !ModalDialog::getCurrent()->isMyIrrChild(el)) - { - el = NULL; - } - - bool found = false; - - if (el != NULL && el->getTabGroup() != NULL) - { - // if the current widget is e.g. 5, search for widget 6, 7, 8, 9, ..., 15 (up to 10 IDs may be missing) - for (int n=1; n<10 && !found; n++) - { - closest = GUIEngine::getGUIEnv()->getRootGUIElement()->getElementFromId(el->getTabOrder() + n, true); - - if (closest != NULL && Widget::isFocusableId(closest->getID())) - { - - Widget* closestWidget = GUIEngine::getWidget( closest->getID() ); - if (playerID != PLAYER_ID_GAME_MASTER && !closestWidget->m_supports_multiplayer) return; - - // if a dialog is shown, restrict to items in the dialog - if (ModalDialog::isADialogActive() && !ModalDialog::getCurrent()->isMyChild(closestWidget)) - { - continue; - } - - if (NAVIGATION_DEBUG) - { - std::cout << "Navigating down to " << closestWidget->getID() << "\n"; - } - - assert( closestWidget != NULL ); - closestWidget->setFocusForPlayer(playerID); - - // another list exception : when entering a list, select the first item - if (closestWidget->m_type == WTYPE_LIST) - { - IGUIListBox* list = (IGUIListBox*)(closestWidget->m_element); - assert(list != NULL); - - list->setSelected(0); - } - - found = true; - } - } // end for - } - - if (!found) - { - - if (NAVIGATION_DEBUG) std::cout << "Navigating down : wrap around\n"; - - // select the first widget - Widget* firstWidget = NULL; - - if (ModalDialog::isADialogActive()) - { - //std::cout << "w = ModalDialog::getCurrent()->getFirstWidget();\n"; - firstWidget = ModalDialog::getCurrent()->getFirstWidget(); - } - else - { - Screen* screen = GUIEngine::getCurrentScreen(); - if (screen == NULL) return; - firstWidget = screen->getFirstWidget(); - } - - if (firstWidget != NULL) firstWidget->setFocusForPlayer(playerID); + if (wrapWidget != NULL) wrapWidget->setFocusForPlayer(playerID); } } diff --git a/src/guiengine/event_handler.hpp b/src/guiengine/event_handler.hpp index f4207f4e8..be31df84f 100644 --- a/src/guiengine/event_handler.hpp +++ b/src/guiengine/event_handler.hpp @@ -62,8 +62,7 @@ namespace GUIEngine EventPropagation onGUIEvent(const irr::SEvent& event); EventPropagation onWidgetActivated(Widget* w, const int playerID); - void navigateUp(const int playerID, Input::InputType type, const bool pressedDown); - void navigateDown(const int playerID, Input::InputType type, const bool pressedDown); + void navigate(const int playerID, Input::InputType type, const bool pressedDown, const bool reverse); /** \brief send an event to the GUI module user's event callback * \param widget the widget that triggerred this event From 9ae8446faeb418fb40a33f820566310ec7401d50 Mon Sep 17 00:00:00 2001 From: hiker Date: Thu, 12 Jun 2014 08:11:51 +1000 Subject: [PATCH 07/17] Added -c CHARLIST option which will only export the characters specified in the character list. Fixed auto-selection of export used characters only. --- tools/font_tool/CFontTool.cpp | 11 +++++++++++ tools/font_tool/CFontTool.h | 1 + tools/font_tool/main.cpp | 34 +++++++++++++++++++++++++++++----- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/tools/font_tool/CFontTool.cpp b/tools/font_tool/CFontTool.cpp index d616f8855..a13a962b3 100644 --- a/tools/font_tool/CFontTool.cpp +++ b/tools/font_tool/CFontTool.cpp @@ -62,6 +62,17 @@ bool LoadPoFiles(const char* sListFileName){ return true; } +// ---------------------------------------------------------------------------- +/** Set all characters in the given character string to be used. */ +bool setUsedCharacters(const char* characters) +{ + int n = strlen(characters); + for(int i=0; iaddCheckBox(false, core::rect(xp,yp,xp+150,yp+h),win, 201, L"Export used characters only")->setEnabled(false); + env->addCheckBox(false, core::rect(xp,yp,xp+150,yp+h),win, 201, L"Export used characters only")->setChecked(false); yp += (s32)(h*1.5f); env->addCheckBox(false, core::rect(xp,yp,xp+150,yp+h),win, 202, L"Exclude basic latin characters"); @@ -512,10 +512,34 @@ int main(int argc,char **argv) createGUI(device, fc); - //new - if(argc>1 && LoadPoFiles(argv[1])){ - device->getGUIEnvironment()->getRootGUIElement()->getElementFromId(201,true)->setEnabled(true); - } + for(int i=1; i(device->getGUIEnvironment() + ->getRootGUIElement() + ->getElementFromId(201, true)); + box->setChecked(true); + } + + } + else + { + // Old style: just a single parameter, assume it's a file name with pot files in it + if(LoadPoFiles(argv[i])) + { + IGUICheckBox *box = + dynamic_cast(device->getGUIEnvironment() + ->getRootGUIElement() + ->getElementFromId(201, true)); + box->setChecked(true); + } + } + } // for i run()) { From 1dc63849c9eda5faf0c4ef62286b381e497a3cb6 Mon Sep 17 00:00:00 2001 From: hiker Date: Thu, 12 Jun 2014 09:27:45 +1000 Subject: [PATCH 08/17] Use a sigmar as big digit font and display time and lap using this font (temporarily till we agree on a font). --- data/fonts/BigDigitFont.xml | Bin 1696 -> 1330 bytes data/fonts/sigmar0.png | Bin 0 -> 2922 bytes src/guiengine/engine.cpp | 1 + src/states_screens/race_gui.cpp | 106 ++++++++++++-------------------- src/states_screens/race_gui.hpp | 21 +++---- 5 files changed, 50 insertions(+), 78 deletions(-) mode change 100644 => 100755 data/fonts/BigDigitFont.xml create mode 100755 data/fonts/sigmar0.png diff --git a/data/fonts/BigDigitFont.xml b/data/fonts/BigDigitFont.xml old mode 100644 new mode 100755 index 41536824d498e77ce15cc7648d01d6e17a4e1161..8ae41eeeb1df8a4e0f9d6349a650a6cedfc7411b GIT binary patch literal 1330 zcmbu9-A=+l5QWdJCcXpV+5p?qmYNFj9ee>q)Fuj~v<6>ZJ-f3Tr(`c0ynyb{%(rJx zXZrJ9VTBVu@Qx8au|tIfNY-QLXSz%Ff~}Q)bqv*=_t>TPAk_G)QAhGs+wcdbYjDBke0} z&kR*KY<#h*l29?$1cpe02@7rxi3JNR1H7t@Z zU=&rr6c9*7wPc)V+yG()v11gRLO3H0r*K2K5>*IP zdCEqVw4_AQ3=Gex1dUnmYRcitrk=5sazz8cYuUge66jKkf$(_b-_|dXj*Vl zioAiTh*~hyndctvXQxnTU7vP3>-9P!j*qZwkzRMan)Q$7mZehMQ1*t9>-p^E$d~6v zK&vIqGRAYDo0QhJ`7V@g@}wqdLECZEh0?c6`82j^7Y%%4g#W-Bt_be8JM3h?Q~u2m z{uhI}6i+nOSO?dVEsYk^2bhYwkt{DX983=(?skW5e2n0Y{TG7B%vvImMrlgl2r>Y; z79uYxCX}_1Zf=27oD}E>S8s}12;+cGLatz(DhjpXsW#g=uc@TKDh!~}J1Z$Fc&KRG zy2i!A+F$8U51}_2b*=s*_)ao{4qDpWLN+buxd+bNG0=@GK|D9Y57c(?mupg%;M!un ztEhaT+tDNSYf78VraXqr5<4sfN9Q2GR5*`PNS!~VDigE$LZpTj zEAeB52R$**W=S$}pr4o7VbE^dPnQh}x~b_nTrypeI>dk9oh5XmjkOGZWj5om8@e!@ zRLH&hB3-cj6U!OOs(BtlLDZzI3o;J1G&Jm-2k$Ue3aN`A$6>#PQy<`?Kg7rIBm_Xl z6TJ|S7{s_>iC&Cvj<8`o5<8@KgewjiVw64P$Ri_Mw@BRY{s%dBh?6qHRVSr)f?9To z`VKj> z4GY!M?UQQk4lBXKw_*#4`zXSkTe`zp#I~{`dGU(Yw+}@6;o^&;#|!oZE4TR8fEC08 z{3*Dr?@srZ77~ThwVPC?v#Mn6>!5f_k;M_U@&~w&q>CD)ob|t1G;Im$T3@J(_kE9u(maW z)y6|Kj*0sY9=dYw@sc$a;b#1a)7Ap)73NCIX;-kkZb6}CIW9b=thJ74jrOTd5|_Ry zI0TQKGCF%(_v0fbiyy1?VQQl(O`Iw*{*i;J;h6eb;~ax{93(jM>7knD8)NgNFHii6 z4O;HB6%0t=S{7iiP~1o1(wtYI<%Y)mxGjA5_vFay&pTuy*O&d-ss%qk?#oHhj&}`R zbLMq8%^_uk!mC*@^nLV++TuBesxh??gV`H(NX2qFm&?KoeF}IC6RE^~-2t;PWG=dw zUeAe=_+`Zu6VSd2fTeKt&&ckdgqWMto4Ru+PCbT_7E5!)KTUSc9STCRkI+tBIk$UoO-%@}um=Y`Zt z7&(S*CM&0zZ!fGQY-Bs3dIL?5Nf;lPI-&Lp7aFE3y9le@SB;$+>v8jIanCX|bJ11r zdJ5v@>mkN&j5oylM=dJt(S-E_Whk}elHQ32%`#v7A2w;Z-KvM~Zov=FAEQZgo`~0H z8M*n`B~84WK$r~9Zo#KyC2vmcGcLN+pC=aNOOg!vvosks8l%rPz#a|BAz9c!{p$~< z*f)H2!EBbvt73+7@1Y!ar~t?7YWNDpLC#bFm4_=;>6U;CS{a_Q^g0AnHdO5_HH>V) zdOqpgjH8*)QEzPNM)_%0oWkn`~y*EQzbiL_1fD1REo@ufH;2B3tfX3Q# zeWBYbQ6QS2h%py|zcg9(0==m+3^#D0kXZ*7MdLBD;RxxclVzB3T`o=1D9c&P+3<_a z7tcXcpri=p^Edn4Aag>w<=G`LW53B zul$a_z&7HL%JP- z!PCdFnq7D7eL3CfFm6?Ljwxqo{18j-x@z&h(J#W$KD+L7p1pYa;IG(5y}nD8%?W4~ z7iWW%6eu)iB4@<$UHm{m$KC=X6O37_$YLE@a6ZDBE`1UeNkgru1a0cdOLQ!VoM#Lh zTyCh2rhAl^uZgj|WqH%_(1ghbcJ$#oC*vkSn^FAH)PWk{VZ&pqQ$DT*j6rUAXq~9s=ZF-X)|oRx6y&PCljUwyY>YaGe&#DKHNYoodTbzfykilKy)&7iP1R%@tUvE{on3%AWSVy}yF)z-+=_i%fs*U^5Bm9h zabjBZ^k>4e&C(6arQg3w9Dnrg9_T(gR?q|Vr*JB%q;@T^Mx*aTdwSH69qXIcUzB#d z@=1;cTKs1zXHBn01~cl>M^;ZLQvb45?}D<#BvBAE6^3wXWZ^)V};@%^J2 z74@y#Oa*K|W=G)|9_jeGR0l#4aJK~m8`LI}DDCSCN`d@)w6|$lC?%HdNXWgPU`pZl z{xy}8M44Oq<~)Fo&cTJb!YCN(rP{we!2cOvKRA&8rrrP0Kaj8bf2C|J>><_H?j`&e D<6oRy literal 0 HcmV?d00001 diff --git a/src/guiengine/engine.cpp b/src/guiengine/engine.cpp index 5c12232c1..2126d1f19 100644 --- a/src/guiengine/engine.cpp +++ b/src/guiengine/engine.cpp @@ -1072,6 +1072,7 @@ namespace GUIEngine file_manager->getAssetChecked(FileManager::FONT, "BigDigitFont.xml",true)); digit_font->lazyLoadTexture(0); // make sure the texture is loaded for this one + digit_font->setMonospaceDigits(true); g_digit_font = digit_font; Private::font_height = g_font->getDimension( L"X" ).Height; diff --git a/src/states_screens/race_gui.cpp b/src/states_screens/race_gui.cpp index 681e8e649..ec0d2f4b3 100644 --- a/src/states_screens/race_gui.cpp +++ b/src/states_screens/race_gui.cpp @@ -89,39 +89,19 @@ RaceGUI::RaceGUI() m_speed_bar_icon = material_manager->getMaterial("speedfore.png"); createMarkerTexture(); - // Translate strings only one in constructor to avoid calling - // gettext in each frame. - //I18N: Shown at the end of a race - m_string_lap = _("Lap"); - m_string_rank = _("Rank"); - - // Determine maximum length of the rank/lap text, in order to // align those texts properly on the right side of the viewport. - gui::ScalableFont* font = GUIEngine::getFont(); - m_rank_lap_width = font->getDimension(m_string_lap.c_str()).Width; + gui::ScalableFont* font = GUIEngine::getHighresDigitFont(); + core::dimension2du area = font->getDimension(L"99:99:99"); + m_timer_width = area.Width; + m_font_height = area.Height; - m_timer_width = font->getDimension(L"99:99:99").Width; - - font = (race_manager->getNumLocalPlayers() > 2 ? GUIEngine::getSmallFont() - : GUIEngine::getFont()); - - int w; if (race_manager->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER || race_manager->getMinorMode()==RaceManager::MINOR_MODE_3_STRIKES || race_manager->getNumLaps() > 9) - w = font->getDimension(L"99/99").Width; + m_lap_width = font->getDimension(L"99/99").Width; else - w = font->getDimension(L"9/9").Width; - - // In some split screen configuration the energy bar might be next - // to the lap display - so make the lap X/Y display large enough to - // leave space for the energy bar (16 pixels) and 10 pixels of space - // to the right (see drawEnergyMeter for details). - w += 16 + 10; - if(m_rank_lap_width < w) m_rank_lap_width = w; - w = font->getDimension(m_string_rank.c_str()).Width; - if(m_rank_lap_width < w) m_rank_lap_width = w; + m_lap_width = font->getDimension(L"9/9").Width; // Technically we only need getNumLocalPlayers, but using the // global kart id to find the data for a specific kart. @@ -225,15 +205,15 @@ void RaceGUI::renderPlayerView(const Camera *camera, float dt) drawPlungerInFace(camera, dt); scaling *= viewport.getWidth()/800.0f; // scale race GUI along screen size - drawAllMessages (kart, viewport, scaling); + drawAllMessages(kart, viewport, scaling); if(!World::getWorld()->isRacePhase()) return; - drawPowerupIcons (kart, viewport, scaling); - drawSpeedAndEnergy (kart, viewport, scaling); + drawPowerupIcons (kart, viewport, scaling); + drawSpeedEnergyRank(kart, viewport, scaling); if (!m_is_tutorial) - drawRankLap (kart, viewport); + drawLap(kart, viewport, scaling); RaceGUIBase::renderPlayerView(camera, dt); } // renderPlayerView @@ -344,7 +324,9 @@ void RaceGUI::drawGlobalTimer() pos += core::vector2d(0, UserConfigParams::m_height/2); } - gui::ScalableFont* font = GUIEngine::getFont(); + gui::ScalableFont* font = GUIEngine::getHighresDigitFont(); + font->setShadow(video::SColor(255, 128, 0, 0)); + font->setScale(1.0f); font->draw(sw.c_str(), pos, time_color, false, false, NULL, true /* ignore RTL */); @@ -609,7 +591,7 @@ void RaceGUI::drawEnergyMeter(int x, int y, const AbstractKart *kart, //----------------------------------------------------------------------------- -void RaceGUI::drawSpeedAndEnergy(const AbstractKart* kart, +void RaceGUI::drawSpeedEnergyRank(const AbstractKart* kart, const core::recti &viewport, const core::vector2df &scaling) { @@ -775,31 +757,40 @@ void RaceGUI::drawSpeedAndEnergy(const AbstractKart* kart, m_last_ranks[id] = kart->getPosition(); } - font->setScale(min_ratio * scale * 0.7f); + font->setScale(min_ratio * scale); font->setShadow(video::SColor(255, 128, 0, 0)); static video::SColor color = video::SColor(255, 255, 255, 255); std::ostringstream oss; oss << rank; // the current font has no . :( << "."; - pos.LowerRightCorner = core::vector2di(offset.X+int(0.6f*meter_width), + pos.LowerRightCorner = core::vector2di(int(offset.X+0.6f*meter_width), int(offset.Y-0.5f*meter_height)); - pos.UpperLeftCorner = core::vector2di(offset.X+int(0.6f*meter_width), + pos.UpperLeftCorner = core::vector2di(int(offset.X+0.6f*meter_width), int(offset.Y-0.5f*meter_height)); font->draw(oss.str().c_str(), pos, color, true, true); + font->setScale(1.0f); } -} // drawSpeedAndEnergy +} // drawSpeedEnergyRank //----------------------------------------------------------------------------- /** Displays the rank and the lap of the kart. * \param info Info object c */ -void RaceGUI::drawRankLap(const AbstractKart* kart, - const core::recti &viewport) +void RaceGUI::drawLap(const AbstractKart* kart, + const core::recti &viewport, + const core::vector2df &scaling) { // Don't display laps or ranks if the kart has already finished the race. if (kart->hasFinishedRace()) return; + + World *world = World::getWorld(); + if (!world->raceHasLaps()) return; + const int lap = world->getKartLaps(kart->getWorldKartId()); + + // don't display 'lap 0/..' at the start of a race + if (lap < 0 ) return; core::recti pos; pos.UpperLeftCorner.Y = viewport.UpperLeftCorner.Y; @@ -809,37 +800,20 @@ void RaceGUI::drawRankLap(const AbstractKart* kart, if(viewport.UpperLeftCorner.Y==0 && viewport.LowerRightCorner.X==UserConfigParams::m_width && race_manager->getNumPlayers()!=3) - pos.UpperLeftCorner.Y += 40; - pos.LowerRightCorner.Y = viewport.LowerRightCorner.Y; + pos.UpperLeftCorner.Y += m_font_height; + pos.LowerRightCorner.Y = viewport.LowerRightCorner.Y+20; pos.UpperLeftCorner.X = viewport.LowerRightCorner.X - - m_rank_lap_width - 10; + - m_lap_width - 10; pos.LowerRightCorner.X = viewport.LowerRightCorner.X; - gui::ScalableFont* font = (race_manager->getNumLocalPlayers() > 2 - ? GUIEngine::getSmallFont() - : GUIEngine::getFont()); - int font_height = (int)(font->getDimension(L"X").Height); + gui::ScalableFont* font = GUIEngine::getHighresDigitFont(); static video::SColor color = video::SColor(255, 255, 255, 255); - WorldWithRank *world = (WorldWithRank*)(World::getWorld()); + std::ostringstream out; + out << lap + 1 << "/" << race_manager->getNumLaps(); + font = GUIEngine::getHighresDigitFont(); + font->setScale(scaling.Y < 1.0f ? 0.5f: 1.0f); + font->draw(out.str().c_str(), pos, color); + font->setScale(1.0f); - // Don't display laps in follow the leader mode - if(world->raceHasLaps()) - { - const int lap = world->getKartLaps(kart->getWorldKartId()); - - // don't display 'lap 0/...' - if(lap>=0) - { - font->draw(m_string_lap.c_str(), pos, color); - char str[256]; - sprintf(str, "%d/%d", lap+1, race_manager->getNumLaps()); - pos.UpperLeftCorner.Y += font_height; - pos.LowerRightCorner.Y += font_height; - font->draw(core::stringw(str).c_str(), pos, color); - pos.UpperLeftCorner.Y += font_height; - pos.LowerRightCorner.Y += font_height; - } - } - -} // drawRankLap +} // drawLap diff --git a/src/states_screens/race_gui.hpp b/src/states_screens/race_gui.hpp index 9e4f08c95..638c86593 100644 --- a/src/states_screens/race_gui.hpp +++ b/src/states_screens/race_gui.hpp @@ -44,12 +44,6 @@ private: Material *m_speed_meter_icon; Material *m_speed_bar_icon; - /** Translated string 'lap' displayed every frame. */ - core::stringw m_string_lap; - - /** Translated string 'rank' displayed every frame. */ - core::stringw m_string_rank; - // Minimap related variables // ------------------------- /** The mini map of the track. */ @@ -81,13 +75,15 @@ private: /** Distance of map from bottom of screen. */ int m_map_bottom; - /** Maximum string length of 'rank', 'lap', '99/99'. Used to position - * the rank/lap text correctly close to the right border. */ - int m_rank_lap_width; + /** Maximum lap display length (either 9/9 or 99/99). */ + int m_lap_width; /** Maximum string length for the timer */ int m_timer_width; + /** Height of the digit font. */ + int m_font_height; + /** Animation state: none, getting smaller (old value), * getting bigger (new number). */ enum AnimationState {AS_NONE, AS_SMALLER, AS_BIGGER}; @@ -105,11 +101,12 @@ private: void drawEnergyMeter (int x, int y, const AbstractKart *kart, const core::recti &viewport, const core::vector2df &scaling); - void drawSpeedAndEnergy (const AbstractKart* kart, + void drawSpeedEnergyRank (const AbstractKart* kart, + const core::recti &viewport, + const core::vector2df &scaling); + void drawLap (const AbstractKart* kart, const core::recti &viewport, const core::vector2df &scaling); - void drawRankLap (const AbstractKart* kart, - const core::recti &viewport); /** Display items that are shown once only (for all karts). */ void drawGlobalMiniMap (); From 60f707b55d3a0819dadc455ad32b2c0fab91c54b Mon Sep 17 00:00:00 2001 From: hiker Date: Thu, 12 Jun 2014 09:33:52 +1000 Subject: [PATCH 09/17] Fixed gcc compiler warning. --- tools/font_tool/CFontTool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/font_tool/CFontTool.cpp b/tools/font_tool/CFontTool.cpp index a13a962b3..b75a84f4f 100644 --- a/tools/font_tool/CFontTool.cpp +++ b/tools/font_tool/CFontTool.cpp @@ -68,7 +68,7 @@ bool setUsedCharacters(const char* characters) { int n = strlen(characters); for(int i=0; i Date: Wed, 11 Jun 2014 19:37:04 -0400 Subject: [PATCH 10/17] Improve code to switch between GUI-cutscenes. Still not fully functional, but better --- src/guiengine/abstract_state_manager.cpp | 5 +- src/modes/cutscene_world.cpp | 69 ++++++++++++++++++++---- src/modes/world.cpp | 5 ++ src/states_screens/grand_prix_lose.cpp | 2 + src/states_screens/grand_prix_win.cpp | 37 ------------- 5 files changed, 68 insertions(+), 50 deletions(-) diff --git a/src/guiengine/abstract_state_manager.cpp b/src/guiengine/abstract_state_manager.cpp index f3fd29fe6..69c4b3cb3 100644 --- a/src/guiengine/abstract_state_manager.cpp +++ b/src/guiengine/abstract_state_manager.cpp @@ -140,7 +140,7 @@ void AbstractStateManager::pushScreen(Screen* screen) void AbstractStateManager::replaceTopMostScreen(Screen* screen) { - assert(m_game_mode != GAME); + //assert(m_game_mode != GAME); // you need to close any dialog before calling this assert(!ModalDialog::isADialogActive()); @@ -156,7 +156,8 @@ void AbstractStateManager::replaceTopMostScreen(Screen* screen) assert(m_menu_stack.size() > 0); // Send tear-down event to previous menu - getCurrentScreen()->tearDown(); + if (getCurrentScreen() != NULL) + getCurrentScreen()->tearDown(); m_menu_stack[m_menu_stack.size()-1] = name; switchToScreen(name.c_str()); diff --git a/src/modes/cutscene_world.cpp b/src/modes/cutscene_world.cpp index f59c1937c..ce878bf10 100644 --- a/src/modes/cutscene_world.cpp +++ b/src/modes/cutscene_world.cpp @@ -32,6 +32,7 @@ #include "physics/physics.hpp" #include "states_screens/credits.hpp" #include "states_screens/cutscene_gui.hpp" +#include "states_screens/feature_unlocked.hpp" #include "states_screens/offline_kart_selection.hpp" #include "states_screens/main_menu_screen.hpp" #include "tracks/track.hpp" @@ -367,20 +368,26 @@ void CutsceneWorld::update(float dt) } } - bool isOver = (m_time > m_duration); - if (isOver && (s_use_duration || m_aborted)) - { - GUIEngine::CutsceneScreen* cs = dynamic_cast( - GUIEngine::getCurrentScreen()); - if (cs != NULL) - cs->onCutsceneEnd(); - } + //bool isOver = (m_time > m_duration); + //if (isOver && (s_use_duration || m_aborted)) + //{ + // GUIEngine::CutsceneScreen* cs = dynamic_cast( + // GUIEngine::getCurrentScreen()); + // if (cs != NULL) + // cs->onCutsceneEnd(); + //} } // update //----------------------------------------------------------------------------- void CutsceneWorld::enterRaceOverState() { + GUIEngine::CutsceneScreen* cs = dynamic_cast( + GUIEngine::getCurrentScreen()); + if (cs != NULL) + cs->onCutsceneEnd(); + + int partId = -1; for (int i=0; i<(int)m_parts.size(); i++) { @@ -408,9 +415,49 @@ void CutsceneWorld::enterRaceOverState() else if (m_parts.size() == 1 && m_parts[0] == "gpwin") { race_manager->exitRace(); - StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance()); - if (race_manager->raceWasStartedFromOverworld()) - OverWorld::enterOverWorld(); + + // un-set the GP mode so that after unlocking, it doesn't try to continue the GP + race_manager->setMajorMode(RaceManager::MAJOR_MODE_SINGLE); + + if (PlayerManager::getCurrentPlayer() + ->getRecentlyCompletedChallenges().size() > 0) + { + std::vector unlocked = + PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges(); + PlayerManager::getCurrentPlayer()->clearUnlocked(); + + StateManager::get()->enterGameState(); + race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE); + race_manager->setNumKarts(0); + race_manager->setNumPlayers(0); + race_manager->setNumLocalPlayers(0); + race_manager->startSingleRace("featunlocked", 999, false); + + FeatureUnlockedCutScene* scene = + FeatureUnlockedCutScene::getInstance(); + std::vector parts; + parts.push_back("featunlocked"); + ((CutsceneWorld*)World::getWorld())->setParts(parts); + + assert(unlocked.size() > 0); + scene->addTrophy(race_manager->getDifficulty()); + scene->findWhatWasUnlocked(race_manager->getDifficulty()); + + StateManager::get()->replaceTopMostScreen(scene); + } + else + { + if (race_manager->raceWasStartedFromOverworld()) + { + OverWorld::enterOverWorld(); + } + else + { + StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance()); + // we assume the main menu was pushed before showing this menu + //StateManager::get()->popMenu(); + } + } } // TODO: remove hardcoded knowledge of cutscenes, replace with scripting probably else if (m_parts.size() == 1 && m_parts[0] == "gplose") diff --git a/src/modes/world.cpp b/src/modes/world.cpp index 1b86b76a7..facd390a1 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -794,6 +794,11 @@ void World::updateWorld(float dt) return; update(dt); + +#ifdef DEBUG + assert(m_magic_number == 0xB01D6543); +#endif + if( (!isFinishPhase()) && isRaceOver()) { enterRaceOverState(); diff --git a/src/states_screens/grand_prix_lose.cpp b/src/states_screens/grand_prix_lose.cpp index 26e55b51f..80ba7bfe9 100644 --- a/src/states_screens/grand_prix_lose.cpp +++ b/src/states_screens/grand_prix_lose.cpp @@ -117,6 +117,8 @@ void GrandPrixLose::onCutsceneEnd() PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges(); if (unlocked.size() > 0) { + race_manager->exitRace(); + StateManager::get()->enterGameState(); race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE); race_manager->setNumKarts(0); diff --git a/src/states_screens/grand_prix_win.cpp b/src/states_screens/grand_prix_win.cpp index eb5ee8fb2..97a0b835f 100644 --- a/src/states_screens/grand_prix_win.cpp +++ b/src/states_screens/grand_prix_win.cpp @@ -114,43 +114,6 @@ void GrandPrixWin::onCutsceneEnd() m_podium_steps[0] = NULL; m_podium_steps[1] = NULL; m_podium_steps[2] = NULL; - - - - // un-set the GP mode so that after unlocking, it doesn't try to continue the GP - race_manager->setMajorMode(RaceManager::MAJOR_MODE_SINGLE); - - if (PlayerManager::getCurrentPlayer() - ->getRecentlyCompletedChallenges().size() > 0) - { - std::vector unlocked = - PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges(); - PlayerManager::getCurrentPlayer()->clearUnlocked(); - - StateManager::get()->enterGameState(); - race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE); - race_manager->setNumKarts(0); - race_manager->setNumPlayers(0); - race_manager->setNumLocalPlayers(0); - race_manager->startSingleRace("featunlocked", 999, false); - - FeatureUnlockedCutScene* scene = - FeatureUnlockedCutScene::getInstance(); - std::vector parts; - parts.push_back("featunlocked"); - ((CutsceneWorld*)World::getWorld())->setParts(parts); - - assert(unlocked.size() > 0); - scene->addTrophy(race_manager->getDifficulty()); - scene->findWhatWasUnlocked(race_manager->getDifficulty()); - - StateManager::get()->replaceTopMostScreen(scene); - } - else - { - // we assume the main menu was pushed before showing this menu - StateManager::get()->popMenu(); - } } // ------------------------------------------------------------------------------------- From 540df391286283c4ae0acdfd3eb65778e171941c Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Wed, 11 Jun 2014 20:50:53 -0400 Subject: [PATCH 11/17] fix crash when using track debug. unfortunately, visual aids are not yet functional --- src/graphics/stkmesh.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/graphics/stkmesh.cpp b/src/graphics/stkmesh.cpp index ed85b16e8..245180270 100644 --- a/src/graphics/stkmesh.cpp +++ b/src/graphics/stkmesh.cpp @@ -553,8 +553,11 @@ void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelView tmpcol.getGreen() / 255.0f, tmpcol.getBlue() / 255.0f); - compressTexture(mesh.textures[0], true); - setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); + if (mesh.textures[0] != NULL) + { + compressTexture(mesh.textures[0], true); + setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); + } glUseProgram(MeshShader::TransparentFogShader::Program); MeshShader::TransparentFogShader::setUniforms(ModelViewProjectionMatrix, TextureMatrix, fogmax, startH, endH, start, end, col, Camera::getCamera(0)->getCameraSceneNode()->getAbsolutePosition(), 0); From cfe93f96f27eff38de3b4bc050f362651a48ffa7 Mon Sep 17 00:00:00 2001 From: hiker Date: Thu, 12 Jun 2014 15:58:40 +1000 Subject: [PATCH 12/17] Speed up the rank animation, and don't make the old value completely disappear (which makes the animation even faster). --- src/states_screens/race_gui.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/states_screens/race_gui.cpp b/src/states_screens/race_gui.cpp index ec0d2f4b3..652f97cba 100644 --- a/src/states_screens/race_gui.cpp +++ b/src/states_screens/race_gui.cpp @@ -723,27 +723,28 @@ void RaceGUI::drawSpeedEnergyRank(const AbstractKart* kart, } } - float scale = 1.0f; - int rank = kart->getPosition(); - const float DURATION = 0.8f; + float scale = 1.0f; + int rank = kart->getPosition(); + const float DURATION = 0.4f; + const float MIN_SHRINK = 0.3f; if(m_animation_states[id] == AS_SMALLER) { scale = 1.0f - (world->getTime()-m_rank_animation_start_times[id]) / DURATION; rank = m_last_ranks[id]; - if(scale<0) + if(scalegetTime(); // Store the new rank m_last_ranks[id] = kart->getPosition(); - scale = 0.0f; + scale = MIN_SHRINK; } } else if(m_animation_states[id] == AS_BIGGER) { scale = (world->getTime() - m_rank_animation_start_times[id]) - / DURATION; + / DURATION + MIN_SHRINK; rank = m_last_ranks[id]; if(scale>1.0f) { From d72decfa651af37137538be81e8d78ae01ffc0e8 Mon Sep 17 00:00:00 2001 From: hiker Date: Thu, 12 Jun 2014 16:54:09 +1000 Subject: [PATCH 13/17] Fixed using the last used track when specifying -N. --- src/main.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 922be5db5..cac5404f1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -405,7 +405,7 @@ void setupRaceStart() StateManager::get()->createActivePlayer( PlayerManager::get()->getPlayer(0), device); - if (kart_properties_manager->getKart(UserConfigParams::m_default_kart) == NULL) + if (!kart_properties_manager->getKart(UserConfigParams::m_default_kart)) { Log::warn("main", "Kart '%s' is unknown so will use the " "default kart.", @@ -418,6 +418,13 @@ void setupRaceStart() race_manager->setLocalKartInfo(0, UserConfigParams::m_default_kart); } + if(!track_manager->getTrack(UserConfigParams::m_last_track)) + { + race_manager->setTrack("jungle"); + } + else + race_manager->setTrack(UserConfigParams::m_last_track); + // ASSIGN should make sure that only input from assigned devices // is read. input_manager->getDeviceList()->setAssignMode(ASSIGN); From 025d7fa114452a87b8c518502d62abe20bd85458 Mon Sep 17 00:00:00 2001 From: hiker Date: Thu, 12 Jun 2014 22:00:00 +1000 Subject: [PATCH 14/17] Tweaked position of font somewhat. Fixed missing rank display when kart is standing still. --- src/states_screens/race_gui.cpp | 158 +++++++++++++++++--------------- src/states_screens/race_gui.hpp | 4 + 2 files changed, 87 insertions(+), 75 deletions(-) diff --git a/src/states_screens/race_gui.cpp b/src/states_screens/race_gui.cpp index 652f97cba..be49e2834 100644 --- a/src/states_screens/race_gui.cpp +++ b/src/states_screens/race_gui.cpp @@ -590,7 +590,86 @@ void RaceGUI::drawEnergyMeter(int x, int y, const AbstractKart *kart, } // drawEnergyMeter //----------------------------------------------------------------------------- +void RaceGUI::drawRank(const AbstractKart *kart, + const core::vector2df &offset, + float min_ratio, int meter_width, + int meter_height) +{ + // Draw rank + WorldWithRank *world = dynamic_cast(World::getWorld()); + if (!world || !world->displayRank()) + return; + int id = kart->getWorldKartId(); + + if (m_animation_states[id] == AS_NONE) + { + if (m_last_ranks[id] != kart->getPosition()) + { + m_rank_animation_start_times[id] = world->getTime(); + m_animation_states[id] = AS_SMALLER; + } + } + + float scale = 1.0f; + int rank = kart->getPosition(); + const float DURATION = 0.4f; + const float MIN_SHRINK = 0.3f; + if (m_animation_states[id] == AS_SMALLER) + { + scale = 1.0f - (world->getTime() - m_rank_animation_start_times[id]) + / DURATION; + rank = m_last_ranks[id]; + if (scale < MIN_SHRINK) + { + m_animation_states[id] = AS_BIGGER; + m_rank_animation_start_times[id] = world->getTime(); + // Store the new rank + m_last_ranks[id] = kart->getPosition(); + scale = MIN_SHRINK; + } + } + else if (m_animation_states[id] == AS_BIGGER) + { + scale = (world->getTime() - m_rank_animation_start_times[id]) + / DURATION + MIN_SHRINK; + rank = m_last_ranks[id]; + if (scale > 1.0f) + { + m_animation_states[id] = AS_NONE; + scale = 1.0f; + } + + } + else + { + m_last_ranks[id] = kart->getPosition(); + } + + gui::ScalableFont* font = GUIEngine::getHighresDigitFont(); + font->setScale(min_ratio * scale); + font->setShadow(video::SColor(255, 128, 0, 0)); + std::ostringstream oss; + oss << rank; // the current font has no . :( << "."; + + core::recti pos; + pos.LowerRightCorner = core::vector2di(int(offset.X + 0.65f*meter_width), + int(offset.Y - 0.55f*meter_height)); + pos.UpperLeftCorner = core::vector2di(int(offset.X + 0.65f*meter_width), + int(offset.Y - 0.55f*meter_height)); + + static video::SColor color = video::SColor(255, 255, 255, 255); + font->draw(oss.str().c_str(), pos, color, true, true); + font->setScale(1.0f); +} // drawRank + +//----------------------------------------------------------------------------- +/** Draws the speedometer, the display of available nitro, and + * the rank of the kart (inside the speedometer). + * \param kart The kart for which to show the data. + * \param viewport The viewport to use. + * \param scaling Which scaling to apply to the speedometer. + */ void RaceGUI::drawSpeedEnergyRank(const AbstractKart* kart, const core::recti &viewport, const core::vector2df &scaling) @@ -621,6 +700,10 @@ void RaceGUI::drawSpeedEnergyRank(const AbstractKart* kart, NULL, true); const float speed = kart->getSpeed(); + + drawRank(kart, offset, min_ratio, meter_width, meter_height); + + if(speed <=0) return; // Nothing to do if speed is negative. // Draw the actual speed bar (if the speed is >0) @@ -698,81 +781,6 @@ void RaceGUI::drawSpeedEnergyRank(const AbstractKart* kart, irr_driver->getVideoDriver()->draw2DVertexPrimitiveList(vertices, count, index, count-2, video::EVT_STANDARD, scene::EPT_TRIANGLE_FAN); - - // Draw rank - WorldWithRank *world = dynamic_cast(World::getWorld()); - - if (world && world->displayRank()) - { - core::recti pos; - pos.UpperLeftCorner.X = (int)(offset.X + 0.5f*meter_width); - pos.UpperLeftCorner.Y = (int)(offset.Y - 0.62f*meter_height); - pos.LowerRightCorner.X = (int)(offset.X + 0.8f*meter_width); - pos.LowerRightCorner.Y = (int)(offset.X - 0.5f*meter_height); - - gui::ScalableFont* font = GUIEngine::getHighresDigitFont(); - - int id = kart->getWorldKartId(); - - if(m_animation_states[id] == AS_NONE) - { - if(m_last_ranks[id]!=kart->getPosition()) - { - m_rank_animation_start_times[id] = world->getTime(); - m_animation_states[id] = AS_SMALLER; - } - } - - float scale = 1.0f; - int rank = kart->getPosition(); - const float DURATION = 0.4f; - const float MIN_SHRINK = 0.3f; - if(m_animation_states[id] == AS_SMALLER) - { - scale = 1.0f - (world->getTime()-m_rank_animation_start_times[id]) - / DURATION; - rank = m_last_ranks[id]; - if(scalegetTime(); - // Store the new rank - m_last_ranks[id] = kart->getPosition(); - scale = MIN_SHRINK; - } - } - else if(m_animation_states[id] == AS_BIGGER) - { - scale = (world->getTime() - m_rank_animation_start_times[id]) - / DURATION + MIN_SHRINK; - rank = m_last_ranks[id]; - if(scale>1.0f) - { - m_animation_states[id] = AS_NONE; - scale = 1.0f; - } - - } - else - { - m_last_ranks[id] = kart->getPosition(); - } - - font->setScale(min_ratio * scale); - font->setShadow(video::SColor(255, 128, 0, 0)); - static video::SColor color = video::SColor(255, 255, 255, 255); - std::ostringstream oss; - oss << rank; // the current font has no . :( << "."; - - pos.LowerRightCorner = core::vector2di(int(offset.X+0.6f*meter_width), - int(offset.Y-0.5f*meter_height)); - pos.UpperLeftCorner = core::vector2di(int(offset.X+0.6f*meter_width), - int(offset.Y-0.5f*meter_height)); - - font->draw(oss.str().c_str(), pos, color, true, true); - font->setScale(1.0f); - } - } // drawSpeedEnergyRank //----------------------------------------------------------------------------- diff --git a/src/states_screens/race_gui.hpp b/src/states_screens/race_gui.hpp index 638c86593..7c26ea2fe 100644 --- a/src/states_screens/race_gui.hpp +++ b/src/states_screens/race_gui.hpp @@ -107,6 +107,10 @@ private: void drawLap (const AbstractKart* kart, const core::recti &viewport, const core::vector2df &scaling); + void drawRank (const AbstractKart *kart, + const core::vector2df &offset, + float min_ratio, int meter_width, + int meter_height); /** Display items that are shown once only (for all karts). */ void drawGlobalMiniMap (); From bc2209284bc9bef1906e315aeff20cb266d3969a Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Thu, 12 Jun 2014 18:25:54 -0400 Subject: [PATCH 15/17] Some fixes with menu-cutscenes --- src/guiengine/abstract_state_manager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/guiengine/abstract_state_manager.cpp b/src/guiengine/abstract_state_manager.cpp index 69c4b3cb3..90ca4068f 100644 --- a/src/guiengine/abstract_state_manager.cpp +++ b/src/guiengine/abstract_state_manager.cpp @@ -160,6 +160,7 @@ void AbstractStateManager::replaceTopMostScreen(Screen* screen) getCurrentScreen()->tearDown(); m_menu_stack[m_menu_stack.size()-1] = name; + setGameState(MENU); switchToScreen(name.c_str()); // Send init event to new menu From e3a2246e25d33b21ccd327960073b248167b8630 Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Thu, 12 Jun 2014 18:43:20 -0400 Subject: [PATCH 16/17] More work on cutscene screens --- src/config/player_profile.hpp | 5 +- src/guiengine/abstract_state_manager.cpp | 4 +- src/guiengine/abstract_state_manager.hpp | 2 +- src/modes/cutscene_world.cpp | 62 ++++++++++++++++++++---- src/states_screens/feature_unlocked.cpp | 2 + src/states_screens/grand_prix_lose.cpp | 42 ---------------- 6 files changed, 62 insertions(+), 55 deletions(-) diff --git a/src/config/player_profile.hpp b/src/config/player_profile.hpp index a294d0a70..6625e211f 100644 --- a/src/config/player_profile.hpp +++ b/src/config/player_profile.hpp @@ -215,7 +215,10 @@ public: // ------------------------------------------------------------------------ bool isFirstTime() const { return m_story_mode_status->isFirstTime(); } // ------------------------------------------------------------------------ - void clearUnlocked() { m_story_mode_status->clearUnlocked(); } + void clearUnlocked() + { + m_story_mode_status->clearUnlocked(); + } // ------------------------------------------------------------------------ /** Returns the current challenge for this player. */ const ChallengeStatus* getCurrentChallengeStatus() const diff --git a/src/guiengine/abstract_state_manager.cpp b/src/guiengine/abstract_state_manager.cpp index 90ca4068f..3b7989370 100644 --- a/src/guiengine/abstract_state_manager.cpp +++ b/src/guiengine/abstract_state_manager.cpp @@ -138,7 +138,7 @@ void AbstractStateManager::pushScreen(Screen* screen) // ---------------------------------------------------------------------------- -void AbstractStateManager::replaceTopMostScreen(Screen* screen) +void AbstractStateManager::replaceTopMostScreen(Screen* screen, GUIEngine::GameState gameState) { //assert(m_game_mode != GAME); // you need to close any dialog before calling this @@ -160,7 +160,7 @@ void AbstractStateManager::replaceTopMostScreen(Screen* screen) getCurrentScreen()->tearDown(); m_menu_stack[m_menu_stack.size()-1] = name; - setGameState(MENU); + setGameState(gameState); switchToScreen(name.c_str()); // Send init event to new menu diff --git a/src/guiengine/abstract_state_manager.hpp b/src/guiengine/abstract_state_manager.hpp index e280103ac..b8ace0901 100644 --- a/src/guiengine/abstract_state_manager.hpp +++ b/src/guiengine/abstract_state_manager.hpp @@ -82,7 +82,7 @@ namespace GUIEngine * without displaying the second-topmost menu of the stack * in-between) */ - void replaceTopMostScreen(Screen* screen); + void replaceTopMostScreen(Screen* screen, GUIEngine::GameState gameState = GUIEngine::MENU); /** * \brief removes the menu at the top of the screens stack diff --git a/src/modes/cutscene_world.cpp b/src/modes/cutscene_world.cpp index ce878bf10..a998896e8 100644 --- a/src/modes/cutscene_world.cpp +++ b/src/modes/cutscene_world.cpp @@ -419,12 +419,11 @@ void CutsceneWorld::enterRaceOverState() // un-set the GP mode so that after unlocking, it doesn't try to continue the GP race_manager->setMajorMode(RaceManager::MAJOR_MODE_SINGLE); - if (PlayerManager::getCurrentPlayer() - ->getRecentlyCompletedChallenges().size() > 0) + std::vector unlocked = + PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges(); + if (unlocked.size() > 0) { - std::vector unlocked = - PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges(); - PlayerManager::getCurrentPlayer()->clearUnlocked(); + //PlayerManager::getCurrentPlayer()->clearUnlocked(); StateManager::get()->enterGameState(); race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE); @@ -443,12 +442,13 @@ void CutsceneWorld::enterRaceOverState() scene->addTrophy(race_manager->getDifficulty()); scene->findWhatWasUnlocked(race_manager->getDifficulty()); - StateManager::get()->replaceTopMostScreen(scene); + StateManager::get()->replaceTopMostScreen(scene, GUIEngine::INGAME_MENU); } else { if (race_manager->raceWasStartedFromOverworld()) { + //StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance()); OverWorld::enterOverWorld(); } else @@ -462,10 +462,54 @@ void CutsceneWorld::enterRaceOverState() // TODO: remove hardcoded knowledge of cutscenes, replace with scripting probably else if (m_parts.size() == 1 && m_parts[0] == "gplose") { + //race_manager->exitRace(); + //StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance()); + //if (race_manager->raceWasStartedFromOverworld()) + // OverWorld::enterOverWorld(); + race_manager->exitRace(); - StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance()); - if (race_manager->raceWasStartedFromOverworld()) - OverWorld::enterOverWorld(); + + // un-set the GP mode so that after unlocking, it doesn't try to continue the GP + race_manager->setMajorMode(RaceManager::MAJOR_MODE_SINGLE); + + std::vector unlocked = + PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges(); + if (unlocked.size() > 0) + { + //PlayerManager::getCurrentPlayer()->clearUnlocked(); + + StateManager::get()->enterGameState(); + race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE); + race_manager->setNumKarts(0); + race_manager->setNumPlayers(0); + race_manager->setNumLocalPlayers(0); + race_manager->startSingleRace("featunlocked", 999, false); + + FeatureUnlockedCutScene* scene = + FeatureUnlockedCutScene::getInstance(); + std::vector parts; + parts.push_back("featunlocked"); + ((CutsceneWorld*)World::getWorld())->setParts(parts); + + scene->addTrophy(race_manager->getDifficulty()); + scene->findWhatWasUnlocked(race_manager->getDifficulty()); + + StateManager::get()->replaceTopMostScreen(scene, GUIEngine::INGAME_MENU); + } + else + { + if (race_manager->raceWasStartedFromOverworld()) + { + //StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance()); + OverWorld::enterOverWorld(); + } + else + { + StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance()); + // we assume the main menu was pushed before showing this menu + //StateManager::get()->popMenu(); + } + } } // TODO: remove hardcoded knowledge of cutscenes, replace with scripting probably else if (race_manager->getTrackName() == "introcutscene" || diff --git a/src/states_screens/feature_unlocked.cpp b/src/states_screens/feature_unlocked.cpp index 624e99e0c..ab7c2df9f 100644 --- a/src/states_screens/feature_unlocked.cpp +++ b/src/states_screens/feature_unlocked.cpp @@ -346,6 +346,8 @@ void FeatureUnlockedCutScene::init() std::cerr << "Malformed unlocked goody!!!\n"; } } + + PlayerManager::getCurrentPlayer()->clearUnlocked(); } // init // ---------------------------------------------------------------------------- diff --git a/src/states_screens/grand_prix_lose.cpp b/src/states_screens/grand_prix_lose.cpp index 80ba7bfe9..f9bc459fd 100644 --- a/src/states_screens/grand_prix_lose.cpp +++ b/src/states_screens/grand_prix_lose.cpp @@ -109,48 +109,6 @@ void GrandPrixLose::onCutsceneEnd() m_kart_node[1] = NULL; m_kart_node[2] = NULL; m_kart_node[3] = NULL; - - // un-set the GP mode so that after unlocking, it doesn't try to continue the GP - race_manager->setMajorMode(RaceManager::MAJOR_MODE_SINGLE); - - std::vector unlocked = - PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges(); - if (unlocked.size() > 0) - { - race_manager->exitRace(); - - StateManager::get()->enterGameState(); - race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE); - race_manager->setNumKarts(0); - race_manager->setNumPlayers(0); - race_manager->setNumLocalPlayers(0); - race_manager->startSingleRace("featunlocked", 999, false); - - FeatureUnlockedCutScene* scene = - FeatureUnlockedCutScene::getInstance(); - std::vector parts; - parts.push_back("featunlocked"); - ((CutsceneWorld*)World::getWorld())->setParts(parts); - - scene->addTrophy(race_manager->getDifficulty()); - scene->findWhatWasUnlocked(race_manager->getDifficulty()); - - StateManager::get()->replaceTopMostScreen(scene); - PlayerManager::getCurrentPlayer()->clearUnlocked(); - } - else - { - if (race_manager->raceWasStartedFromOverworld()) - { - StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance()); - OverWorld::enterOverWorld(); - } - else - { - // we assume the main menu was pushed before showing this menu - StateManager::get()->popMenu(); - } - } } // ------------------------------------------------------------------------------------- From d36ff8b6db89f1fb339409e9e3f09f5e68c4ea7b Mon Sep 17 00:00:00 2001 From: hiker Date: Fri, 13 Jun 2014 09:07:52 +1000 Subject: [PATCH 17/17] Call reset function of RaceGUIBase, which fixes #1363 (missing thunderbird). --- src/states_screens/race_gui.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/states_screens/race_gui.cpp b/src/states_screens/race_gui.cpp index be49e2834..ae03ffe7e 100644 --- a/src/states_screens/race_gui.cpp +++ b/src/states_screens/race_gui.cpp @@ -123,6 +123,7 @@ RaceGUI::~RaceGUI() */ void RaceGUI::reset() { + RaceGUIBase::reset(); for(unsigned int i=0; igetNumberOfKarts(); i++) { m_animation_states[i] = AS_NONE;