Merge branch 'master' of https://github.com/supertuxkart/stk-code into ScriptEngine

This commit is contained in:
Sachith Hasaranga Seneviratne 2014-06-13 08:00:56 +05:30
commit 390642cb5f
31 changed files with 427 additions and 496 deletions

BIN
data/fonts/BigDigitFont.xml Normal file → Executable file

Binary file not shown.

BIN
data/fonts/sigmar0.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -109,7 +109,7 @@ inline int btGetVersion()
#ifdef __SPU__
#include <spu_printf.h>
#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

View File

@ -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

View File

@ -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"<?xml version=\"1.0\"?>\n";
players_file << L"<players version=\"1\" >\n";
if(m_current_player && UserConfigParams::m_remember_user)
if(m_current_player)
{
players_file << L" <current player=\""
<< m_current_player->getName() << L"\"/>\n";

View File

@ -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);

View File

@ -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;
@ -212,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
@ -271,6 +277,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

View File

@ -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."));

View File

@ -532,7 +532,7 @@ unsigned GPUTimer::elapsedTimeus()
FrameBuffer::FrameBuffer() {}
FrameBuffer::FrameBuffer(const std::vector<GLuint> &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<GLuint> &RTTs, size_t w, size_t h, bo
}
FrameBuffer::FrameBuffer(const std::vector<GLuint> &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<s32>& position,
glUseProgram(0);
glGetError();
}
}

View File

@ -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<irr::f32>& 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();

View File

@ -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);

View File

@ -138,9 +138,9 @@ void AbstractStateManager::pushScreen(Screen* screen)
// ----------------------------------------------------------------------------
void AbstractStateManager::replaceTopMostScreen(Screen* screen)
void AbstractStateManager::replaceTopMostScreen(Screen* screen, GUIEngine::GameState gameState)
{
assert(m_game_mode != GAME);
//assert(m_game_mode != GAME);
// you need to close any dialog before calling this
assert(!ModalDialog::isADialogActive());
@ -156,9 +156,11 @@ 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;
setGameState(gameState);
switchToScreen(name.c_str());
// Send init event to new menu

View File

@ -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

View File

@ -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;

View File

@ -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);
}
}
@ -631,7 +516,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 +543,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 +584,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;

View File

@ -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

View File

@ -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<childrenCount; n++)

View File

@ -173,8 +173,6 @@ namespace GUIEngine
/** Override method from base class Widget */
virtual void setDeactivated();
bool isActivated() { return !m_deactivated; }
/** Display custom text in spinner */
void setCustomText(const core::stringw& text);

View File

@ -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);

View File

@ -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::CutsceneScreen*>(
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::CutsceneScreen*>(
// GUIEngine::getCurrentScreen());
// if (cs != NULL)
// cs->onCutsceneEnd();
//}
} // update
//-----------------------------------------------------------------------------
void CutsceneWorld::enterRaceOverState()
{
GUIEngine::CutsceneScreen* cs = dynamic_cast<GUIEngine::CutsceneScreen*>(
GUIEngine::getCurrentScreen());
if (cs != NULL)
cs->onCutsceneEnd();
int partId = -1;
for (int i=0; i<(int)m_parts.size(); i++)
{
@ -408,17 +415,101 @@ 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);
std::vector<const ChallengeData*> 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<std::string> 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, 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 (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<const ChallengeData*> 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<std::string> 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" ||

View File

@ -796,6 +796,11 @@ void World::updateWorld(float dt)
return;
update(dt);
#ifdef DEBUG
assert(m_magic_number == 0xB01D6543);
#endif
if( (!isFinishPhase()) && isRaceOver())
{
enterRaceOverState();

View File

@ -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,9 +187,9 @@ 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() );
saveSession(getOnlineId(), getToken());
}
ProfileManager::get()->addPersistent(m_profile);
std::string achieved_string("");
@ -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

View File

@ -346,6 +346,8 @@ void FeatureUnlockedCutScene::init()
std::cerr << "Malformed unlocked goody!!!\n";
}
}
PlayerManager::getCurrentPlayer()->clearUnlocked();
} // init
// ----------------------------------------------------------------------------

View File

@ -109,46 +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<const ChallengeData*> unlocked =
PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges();
if (unlocked.size() > 0)
{
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<std::string> 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();
}
}
}
// -------------------------------------------------------------------------------------

View File

@ -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<const ChallengeData*> 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<std::string> 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();
}
}
// -------------------------------------------------------------------------------------

View File

@ -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.
@ -143,6 +123,7 @@ RaceGUI::~RaceGUI()
*/
void RaceGUI::reset()
{
RaceGUIBase::reset();
for(unsigned int i=0; i<race_manager->getNumberOfKarts(); i++)
{
m_animation_states[i] = AS_NONE;
@ -225,15 +206,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 +325,9 @@ void RaceGUI::drawGlobalTimer()
pos += core::vector2d<s32>(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 */);
@ -608,8 +591,87 @@ 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<WorldWithRank*>(World::getWorld());
if (!world || !world->displayRank())
return;
void RaceGUI::drawSpeedAndEnergy(const AbstractKart* kart,
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)
{
@ -639,6 +701,10 @@ void RaceGUI::drawSpeedAndEnergy(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)
@ -716,90 +782,25 @@ void RaceGUI::drawSpeedAndEnergy(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<WorldWithRank*>(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.8f;
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)
{
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 = 0.0f;
}
}
else if(m_animation_states[id] == AS_BIGGER)
{
scale = (world->getTime() - m_rank_animation_start_times[id])
/ DURATION;
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 * 0.7f);
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),
int(offset.Y-0.5f*meter_height));
pos.UpperLeftCorner = core::vector2di(offset.X+int(0.6f*meter_width),
int(offset.Y-0.5f*meter_height));
font->draw(oss.str().c_str(), pos, color, true, true);
}
} // 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 +810,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

View File

@ -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,16 @@ 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 drawRankLap (const AbstractKart* kart,
const core::recti &viewport);
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 ();

View File

@ -73,8 +73,6 @@ void BaseUserScreen::init()
m_info_widget = getWidget<LabelWidget>("message");
assert(m_info_widget);
getWidget<CheckBoxWidget>("remember-user")
->setState(UserConfigParams::m_remember_user);
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; n<PlayerManager::get()->getNumPlayers(); n++)
{
@ -96,38 +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() );
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
@ -157,9 +137,8 @@ void BaseUserScreen::selectUser(int index)
PlayerProfile *profile = PlayerManager::get()->getPlayer(index);
assert(profile);
getWidget<TextBoxWidget >("username")->setText(profile
->getLastOnlineName());
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).
@ -175,6 +154,8 @@ void BaseUserScreen::selectUser(int index)
m_online_cb->setState(true);
makeEntryFieldsVisible();
m_username_tb->setText(profile->getLastOnlineName());
getWidget<CheckBoxWidget>("remember-user")->setState(
profile->rememberPassword());
if(profile->getLastOnlineName().size()>0)
m_username_tb->setDeactivated();
else
@ -246,21 +227,24 @@ void BaseUserScreen::eventCallback(Widget* widget,
}
else if (name == "remember-user")
{
UserConfigParams::m_remember_user =
getWidget<CheckBoxWidget>("remember-user")->getState();
getSelectedPlayer()->setRememberPassword(
getWidget<CheckBoxWidget>("remember-user")->getState());
}
else if (name == "online")
{
// 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 ==
Online::RequestManager::IPERM_NOT_ALLOWED)
if (m_online_cb->getState())
{
m_info_widget->setText(
_("Internet access is disabled, please enable it in the options"),
true);
sfx_manager->quickSound( "anvil" );
m_online_cb->setState(false);
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);
}
}
makeEntryFieldsVisible();
}

View File

@ -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; i<n; i++)
bUsed[short(characters[i])] = true;
return true;
} // setUsedCharacters
// ----------------------------------------------------------------------------
// windows specific
#ifdef _IRR_WINDOWS_

View File

@ -21,6 +21,7 @@
#endif
bool LoadPoFiles(const char* sListFileName);
bool setUsedCharacters(const char* characters);
namespace irr {
class CFontTool : public irr::IReferenceCounted

View File

@ -412,7 +412,7 @@ void createGUI(IrrlichtDevice* device, CFontTool* fc)
//new
env->addCheckBox(false, core::rect<s32>(xp,yp,xp+150,yp+h),win, 201, L"Export used characters only")->setEnabled(false);
env->addCheckBox(false, core::rect<s32>(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<s32>(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<argc; i++)
{
if(!strcmp(argv[i],"-c") && i<argc-1)
{
i++;
if(setUsedCharacters(argv[i]))
{
IGUICheckBox *box =
dynamic_cast<IGUICheckBox*>(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<IGUICheckBox*>(device->getGUIEnvironment()
->getRootGUIElement()
->getElementFromId(201, true));
box->setChecked(true);
}
}
} // for i <argc
while(device->run())
{