Merge remote-tracking branch 'origin/master' into fix_2316

This commit is contained in:
Benau 2016-12-28 15:50:14 +08:00
commit 71161264be
17 changed files with 299 additions and 359 deletions

View File

@ -173,6 +173,14 @@
<gauge id="filtering" min_value="0" max_value="5" width="50%" />
</div>
<spacer height="4" width="10" />
<div layout="horizontal-row" width="100%" proportion="1">
<label text="Geometry detail" I18N="Video settings" width="40%"/>
<spacer width="10" height="10"/>
<gauge id="geometry_detail" min_value="0" max_value="2" width="50%" />
</div>
<spacer height="10" width="10" />
<label text="* Restart STK to apply new settings" width="100%" text_align="center" I18N="Video settings"/>

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<stkgui>
<div x="2%" y="10%" width="96%" height="80%" layout="vertical-row" >
<label id="title" width="100%" text_align="center" word_wrap="true"
I18N="In the 'add new grand prix' dialog"
text="Please enter the name of the grand prix" proportion="1" />
<spacer height="25" width="10" />
<textbox id="textfield" width="75%" I18N="In the 'add new grand prix' dialog" align="center"/>
<spacer height="20" width="20" />
<button id="accept" I18N="In the 'add new grand prix' dialog" text="OK" align="center" proportion="1"/>
<spacer height="15" width="20" />
<button id="cancel" I18N="In the 'add new grand prix' dialog" text="Cancel" align="center" proportion="1"/>
</div>
</stkgui>

View File

@ -7,9 +7,9 @@
<textbox id="textfield" width="75%" align="center"/>
<spacer height="20" width="20" />
<button id="ok" raw_text="OK" align="center" proportion="1"/>
<button id="ok" I18N="In the general textfield dialog" text="OK" align="center" proportion="1"/>
<spacer height="15" width="20" />
<button id="close" raw_text="Close" align="center" proportion="1"/>
<button id="cancel" I18N="In the general textfield dialog" text="Cancel" align="center" proportion="1"/>
</div>
</stkgui>

View File

@ -1,5 +1,5 @@
# Modify this file to change the last-modified date when you add/remove a file.
# This will then trigger a new cmake run automatically.
# This will then trigger a new cmake run automatically.
file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp")
file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp")
file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*")

View File

@ -279,6 +279,10 @@ enum AnimType {ANIMS_NONE = 0,
ANIMS_PLAYERS_ONLY = 1,
ANIMS_ALL = 2 };
enum GeometryLevel {GEOLEVEL_0 = 0,
GEOLEVEL_1 = 1,
GEOLEVEL_2 = 2 };
/** Using X-macros for setting-possible values is not very pretty, but it's a
* no-maintenance case :
* when you want to add a new parameter, just add one signle line below and
@ -673,6 +677,13 @@ namespace UserConfigParams
"steering_animations", &m_graphics_quality,
"Whether to display kart animations (0=disabled for all; "
"1=enabled for humans, disabled for AIs; 2=enabled for all") );
PARAM_PREFIX IntUserConfigParam m_geometry_level
PARAM_DEFAULT( IntUserConfigParam(GEOLEVEL_0,
"geometry_level", &m_graphics_quality,
"Geometry quality 0=everything is displayed; "
"1=a few details are displayed; 2=lowest level, no details") );
PARAM_PREFIX IntUserConfigParam m_anisotropic
PARAM_DEFAULT( IntUserConfigParam(4, "anisotropic",
&m_graphics_quality,

View File

@ -75,6 +75,17 @@ void CustomVideoSettingsDialog::beforeAddingWidgets()
UserConfigParams::m_show_steering_animations == 2 ?
1 : UserConfigParams::m_show_steering_animations);
SpinnerWidget* geometry_level = getWidget<SpinnerWidget>("geometry_detail");
//I18N: Geometry level disabled : lowest level, no details
geometry_level->addLabel(_("Disabled"));
//I18N: Geometry level low : few details are displayed
geometry_level->addLabel(_("low"));
//I18N: Geometry level high : everything is displayed
geometry_level->addLabel(_("high"));
geometry_level->setValue(
UserConfigParams::m_geometry_level == 2 ? 0 :
UserConfigParams::m_geometry_level == 0 ? 2 : 1);
SpinnerWidget* filtering = getWidget<SpinnerWidget>("filtering");
int value = 0;
if (UserConfigParams::m_anisotropic == 2) value = 2;
@ -192,6 +203,10 @@ GUIEngine::EventPropagation CustomVideoSettingsDialog::processEvent(const std::s
UserConfigParams::m_show_steering_animations =
getWidget<SpinnerWidget>("steering_animations")->getValue();
const int val =
getWidget<SpinnerWidget>("geometry_detail")->getValue();
UserConfigParams::m_geometry_level = val == 2 ? 0 : val == 0 ? 2 : 1;
switch (getWidget<SpinnerWidget>("filtering")->getValue())
{
case 0:

View File

@ -1,147 +0,0 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2014-2015 Marc Coll
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "states_screens/dialogs/enter_gp_name_dialog.hpp"
#include "audio/sfx_manager.hpp"
#include "guiengine/engine.hpp"
#include "guiengine/widgets/button_widget.hpp"
#include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets/text_box_widget.hpp"
#include "race/grand_prix_manager.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/translation.hpp"
#include <IGUIEnvironment.h>
using namespace GUIEngine;
using namespace irr::core;
// -----------------------------------------------------------------------------
EnterGPNameDialog::EnterGPNameDialog(INewGPListener* listener,
const float w, const float h)
: ModalDialog(w, h), m_listener(listener), m_self_destroy(false)
{
assert(listener != NULL);
loadFromFile("enter_gp_name_dialog.stkgui");
TextBoxWidget* textCtrl = getWidget<TextBoxWidget>("textfield");
assert(textCtrl != NULL);
textCtrl->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
}
// -----------------------------------------------------------------------------
EnterGPNameDialog::~EnterGPNameDialog()
{
// FIXME: what is this code for?
TextBoxWidget* textCtrl = getWidget<TextBoxWidget>("textfield");
textCtrl->getIrrlichtElement()->remove();
textCtrl->clearListeners();
}
// -----------------------------------------------------------------------------
GUIEngine::EventPropagation EnterGPNameDialog::processEvent(const std::string& eventSource)
{
if (eventSource == "cancel")
{
dismiss();
return GUIEngine::EVENT_BLOCK;
}
else if (eventSource == "accept")
{
validateName();
}
return GUIEngine::EVENT_LET;
}
// -----------------------------------------------------------------------------
void EnterGPNameDialog::onEnterPressedInternal()
{
//Cancel button pressed
ButtonWidget* cancelButton = getWidget<ButtonWidget>("cancel");
if (GUIEngine::isFocusedForPlayer(cancelButton, PLAYER_ID_GAME_MASTER))
{
std::string fakeEvent = "cancel";
processEvent(fakeEvent);
return;
}
//Otherwise, see if we can accept the new name and create the grand prix
validateName();
}
// -----------------------------------------------------------------------------
void EnterGPNameDialog::onUpdate(float dt)
{
// It's unsafe to delete from inside the event handler so we do it here
if (m_self_destroy)
{
TextBoxWidget* textCtrl = getWidget<TextBoxWidget>("textfield");
stringw name = textCtrl->getText().trim();
// irrLicht is too stupid to remove focus from deleted widgets
// so do it by hand
GUIEngine::getGUIEnv()->removeFocus( textCtrl->getIrrlichtElement() );
GUIEngine::getGUIEnv()->removeFocus( m_irrlicht_window );
// we will destroy the dialog before notifying the listener to be safer.
// but in order not to crash we must make a local copy of the listern
// otherwise we will crash
INewGPListener* listener = m_listener;
ModalDialog::dismiss();
if (listener != NULL)
listener->onNewGPWithName(name);
}
}
// ----------------------------------------------------------------------------
void EnterGPNameDialog::validateName()
{
TextBoxWidget* textCtrl = getWidget<TextBoxWidget>("textfield");
assert(textCtrl != NULL);
LabelWidget* label = getWidget<LabelWidget>("title");
assert(label != NULL);
stringw name = textCtrl->getText().trim();
if (name.size() == 0)
{
label->setText(_("Name is empty."), false);
SFXManager::get()->quickSound("anvil");
}
else if (grand_prix_manager->existsName(name) ||
name == GrandPrixData::getRandomGPName())
{
// check for duplicate names
label->setText(_("Another grand prix with this name already exists."), false);
SFXManager::get()->quickSound("anvil");
}
else if (name.size() > 30)
{
label->setText(_("Name is too long."), false);
SFXManager::get()->quickSound("anvil");
}
else
{
// It's unsafe to delete from inside the event handler so we do it
// in onUpdate (which checks for m_self_destroy)
m_self_destroy = true;
}
}

View File

@ -1,70 +0,0 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2014-2015 Marc Coll
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_ENTER_GP_NAME_DIALOG_HPP
#define HEADER_ENTER_GP_NAME_DIALOG_HPP
#include "guiengine/modaldialog.hpp"
#include <irrString.h>
namespace GUIEngine
{
class TextBoxWidget;
class ButtonWidget;
class LabelWidget;
}
/**
* \brief Dialog that allows the player to enter the name for a new grand prix
* \ingroup states_screens
*/
class EnterGPNameDialog : public GUIEngine::ModalDialog
{
public:
class INewGPListener
{
public:
virtual void onNewGPWithName(const irr::core::stringw& newName) = 0;
virtual ~INewGPListener(){}
};
private:
INewGPListener* m_listener;
bool m_self_destroy;
public:
/**
* Creates a modal dialog with given percentage of screen width and height
*/
EnterGPNameDialog(INewGPListener* listener, const float percentWidth,
const float percentHeight);
~EnterGPNameDialog();
void onEnterPressedInternal();
void validateName();
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
virtual void onUpdate(float dt);
};
#endif

View File

@ -1,81 +0,0 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2016 SuperTuxKart-Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "states_screens/dialogs/general_debug_dialog.hpp"
#include "guiengine/engine.hpp"
#include "guiengine/widgets/button_widget.hpp"
#include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets/text_box_widget.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/string_utils.hpp"
#include <IGUIEnvironment.h>
using namespace GUIEngine;
using namespace irr::core;
// -----------------------------------------------------------------------------
GeneralDebugDialog::GeneralDebugDialog(const wchar_t* title, Callback cb) :
ModalDialog(0.95f, 0.4f, GUIEngine::MODAL_DIALOG_LOCATION_BOTTOM),
m_callback(cb)
{
m_fade_background = false;
loadFromFile("general_debug_dialog.stkgui");
TextBoxWidget* text_field = getWidget<TextBoxWidget>("textfield");
assert(text_field != NULL);
text_field->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
LabelWidget* label = getWidget<LabelWidget>("title");
assert(label != NULL);
label->setText(title, false/*expandAsNeeded*/);
} // GeneralDebugDialog
// -----------------------------------------------------------------------------
GeneralDebugDialog::~GeneralDebugDialog()
{
TextBoxWidget* text_field = getWidget<TextBoxWidget>("textfield");
text_field->getIrrlichtElement()->remove();
text_field->clearListeners();
} // ~GeneralDebugDialog
// -----------------------------------------------------------------------------
GUIEngine::EventPropagation GeneralDebugDialog::processEvent(const std::string& eventSource)
{
if (eventSource == "close")
{
dismiss();
return GUIEngine::EVENT_BLOCK;
}
else if (eventSource == "ok")
{
run();
return GUIEngine::EVENT_BLOCK;
}
return GUIEngine::EVENT_LET;
} // processEvent
// -----------------------------------------------------------------------------
void GeneralDebugDialog::run()
{
TextBoxWidget* text_field = getWidget<TextBoxWidget>("textfield");
std::string text = StringUtils::wideToUtf8(text_field->getText());
m_callback(text);
text_field->setText(L"");
} // run

View File

@ -0,0 +1,117 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2016 SuperTuxKart-Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "states_screens/dialogs/general_text_field_dialog.hpp"
#include "guiengine/engine.hpp"
#include "guiengine/widgets/button_widget.hpp"
#include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets/text_box_widget.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/string_utils.hpp"
#include <IGUIEnvironment.h>
using namespace GUIEngine;
using namespace irr::core;
// -----------------------------------------------------------------------------
GeneralTextFieldDialog::GeneralTextFieldDialog(const wchar_t* title,
DismissCallback dm_cb,
ValidationCallback val_cb)
: ModalDialog(0.95f, 0.4f,
GUIEngine::MODAL_DIALOG_LOCATION_BOTTOM),
m_dm_cb(dm_cb), m_val_cb(val_cb), m_self_destroy(false)
{
m_fade_background = false;
loadFromFile("general_text_field_dialog.stkgui");
m_text_field = getWidget<TextBoxWidget>("textfield");
assert(m_text_field != NULL);
m_text_field->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
m_title = getWidget<LabelWidget>("title");
assert(m_title != NULL);
m_title->setText(title, false/*expandAsNeeded*/);
assert(m_dm_cb != NULL);
assert(m_val_cb != NULL);
} // GeneralTextFieldDialog
// -----------------------------------------------------------------------------
GeneralTextFieldDialog::~GeneralTextFieldDialog()
{
m_text_field->getIrrlichtElement()->remove();
m_text_field->clearListeners();
} // ~GeneralTextFieldDialog
// -----------------------------------------------------------------------------
GUIEngine::EventPropagation GeneralTextFieldDialog::processEvent(const std::string& eventSource)
{
if (eventSource == "cancel")
{
dismiss();
return GUIEngine::EVENT_BLOCK;
}
else if (eventSource == "ok")
{
// If validation callback return true, dismiss the dialog
if (m_val_cb(m_title, m_text_field))
m_self_destroy = true;
return GUIEngine::EVENT_BLOCK;
}
return GUIEngine::EVENT_LET;
} // processEvent
// -----------------------------------------------------------------------------
void GeneralTextFieldDialog::onEnterPressedInternal()
{
// Cancel button pressed
ButtonWidget* cancel_button = getWidget<ButtonWidget>("cancel");
if (GUIEngine::isFocusedForPlayer(cancel_button, PLAYER_ID_GAME_MASTER))
{
std::string fake_event = "cancel";
processEvent(fake_event);
return;
}
if (m_val_cb(m_title, m_text_field))
m_self_destroy = true;
} // onEnterPressedInternal
// -----------------------------------------------------------------------------
void GeneralTextFieldDialog::onUpdate(float dt)
{
// It's unsafe to delete from inside the event handler so we do it here
if (m_self_destroy)
{
stringw name = m_text_field->getText().trim();
// irrLicht is too stupid to remove focus from deleted widgets
// so do it by hand
GUIEngine::getGUIEnv()
->removeFocus(m_text_field->getIrrlichtElement());
GUIEngine::getGUIEnv()->removeFocus(m_irrlicht_window);
// We will destroy the dialog before notifying the callback is run,
// but in order not to crash we must make a local copy of the callback
// otherwise we will crash
DismissCallback dm_cb = m_dm_cb;
ModalDialog::dismiss();
dm_cb(name);
}
} // onUpdate

View File

@ -15,12 +15,14 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_GENERAL_DEBUG_DIALOG_HPP
#define HEADER_GENERAL_DEBUG_DIALOG_HPP
#ifndef HEADER_GENERAL_TEXT_FIELD_DIALOG_HPP
#define HEADER_GENERAL_TEXT_FIELD_DIALOG_HPP
#include "guiengine/modaldialog.hpp"
#include "utils/cpp2011.hpp"
#include <functional>
namespace GUIEngine
{
class TextBoxWidget;
@ -29,24 +31,43 @@ namespace GUIEngine
}
/**
* \brief A general debug dialog to run stuff based on captured text.
* \brief A general textfield dialog to do anything based on captured text
* using callbacks.
* \ingroup states_screens
*/
class GeneralDebugDialog : public GUIEngine::ModalDialog
class GeneralTextFieldDialog : public GUIEngine::ModalDialog
{
private:
typedef void (*Callback)(const std::string& text);
typedef std::function<void(const irr::core::stringw&)> DismissCallback;
Callback m_callback;
typedef
std::function<bool(GUIEngine::LabelWidget*, GUIEngine::TextBoxWidget*)>
ValidationCallback;
void run();
GUIEngine::LabelWidget* m_title;
GUIEngine::TextBoxWidget* m_text_field;
DismissCallback m_dm_cb;
ValidationCallback m_val_cb;
bool m_self_destroy;
public:
GeneralDebugDialog(const wchar_t* title, Callback cb);
GeneralTextFieldDialog(const wchar_t* title, DismissCallback dm_cb,
ValidationCallback val_cb = []
(GUIEngine::LabelWidget* lw, GUIEngine::TextBoxWidget* tb)->bool
{
// No validation if not specify, always go to dismiss callback
return true;
});
// ------------------------------------------------------------------------
~GeneralDebugDialog();
~GeneralTextFieldDialog();
// ------------------------------------------------------------------------
virtual void onEnterPressedInternal() OVERRIDE { run(); }
virtual void onEnterPressedInternal() OVERRIDE;
// ------------------------------------------------------------------------
virtual void onUpdate(float dt) OVERRIDE;
// ------------------------------------------------------------------------
GUIEngine::EventPropagation processEvent(const std::string& eventSource)
OVERRIDE;

View File

@ -22,6 +22,8 @@
#include "race/grand_prix_manager.hpp"
#include "race/race_manager.hpp"
#include "states_screens/grand_prix_cutscene.hpp"
#include "states_screens/grand_prix_editor_screen.hpp"
#include "states_screens/dialogs/general_text_field_dialog.hpp"
#include "tracks/track_manager.hpp"
#include <string>
@ -42,7 +44,7 @@ void GrandPrixCutscene::saveGPButton()
* The GP that the race_manager provides can't be used because we need some
* functions and settings that the GP manager only gives us through
* createNewGP(). */
void GrandPrixCutscene::onNewGPWithName(const irr::core::stringw& name)
void GrandPrixCutscene::setNewGPWithName(const irr::core::stringw& name)
{
// create a new GP with the correct filename and a unique id
GrandPrixData* gp = grand_prix_manager->createNewGP(name);
@ -56,7 +58,7 @@ void GrandPrixCutscene::onNewGPWithName(const irr::core::stringw& name)
// Avoid double-save which can have bad side-effects
getWidget<Button>("save")->setVisible(false);
} // onNewGPWithName
} // setNewGPWithName
// ----------------------------------------------------------------------------
@ -70,7 +72,9 @@ void GrandPrixCutscene::eventCallback(GUIEngine::Widget* widget,
}
else if (name == "save")
{
new EnterGPNameDialog(this, 0.5f, 0.4f);
new GeneralTextFieldDialog(_("Please enter the name of the grand prix"),
std::bind(&GrandPrixCutscene::setNewGPWithName, this,
std::placeholders::_1), GrandPrixEditorScreen::validateName);
}
} // eventCallback

View File

@ -21,12 +21,10 @@
#include "guiengine/screen.hpp"
#include "guiengine/widgets/button_widget.hpp"
#include "race/race_manager.hpp"
#include "states_screens/dialogs/enter_gp_name_dialog.hpp"
#include <string>
class GrandPrixCutscene: public GUIEngine::CutsceneScreen,
public EnterGPNameDialog::INewGPListener
class GrandPrixCutscene: public GUIEngine::CutsceneScreen
{
friend class GUIEngine::ScreenSingleton<GrandPrixCutscene>;
public:
@ -34,8 +32,7 @@ public:
protected:
void saveGPButton();
/** implement callback from INewGPListener */
void onNewGPWithName(const irr::core::stringw& name) OVERRIDE;
void setNewGPWithName(const irr::core::stringw& name);
// implement callbacks from parent class GUIEngine::Screen
void eventCallback(GUIEngine::Widget* widget,

View File

@ -17,21 +17,22 @@
#include "states_screens/grand_prix_editor_screen.hpp"
#include "audio/sfx_manager.hpp"
#include "graphics/irr_driver.hpp"
#include "guiengine/widget.hpp"
#include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets/text_box_widget.hpp"
#include "guiengine/widgets/dynamic_ribbon_widget.hpp"
#include "guiengine/widgets/icon_button_widget.hpp"
#include "io/file_manager.hpp"
#include "race/grand_prix_manager.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/edit_gp_screen.hpp"
#include "states_screens/dialogs/enter_gp_name_dialog.hpp"
#include "states_screens/dialogs/general_text_field_dialog.hpp"
#include "tracks/track.hpp"
#include "tracks/track_manager.hpp"
#include "utils/translation.hpp"
using namespace GUIEngine;
using namespace irr::core;
@ -97,7 +98,9 @@ void GrandPrixEditorScreen::eventCallback(Widget* widget, const std::string& nam
if (m_action == "new" || m_action == "copy")
{
new EnterGPNameDialog(this, 0.5f, 0.4f);
new GeneralTextFieldDialog(_("Please enter the name of the grand prix"),
std::bind(&GrandPrixEditorScreen::setNewGPWithName,
this, std::placeholders::_1), validateName);
}
else if (m_action == "edit" && m_selection != NULL)
{
@ -112,7 +115,9 @@ void GrandPrixEditorScreen::eventCallback(Widget* widget, const std::string& nam
}
else if (m_action == "rename" && m_selection != NULL)
{
new EnterGPNameDialog(this, 0.5f, 0.4f);
new GeneralTextFieldDialog(_("Please enter the name of the grand prix"),
std::bind(&GrandPrixEditorScreen::setNewGPWithName,
this, std::placeholders::_1), validateName);
}
}
else if (name == "gpgroups")
@ -281,7 +286,7 @@ void GrandPrixEditorScreen::enableButtons()
}
// -----------------------------------------------------------------------------
void GrandPrixEditorScreen::onNewGPWithName(const stringw& newName)
void GrandPrixEditorScreen::setNewGPWithName(const stringw& newName)
{
if (m_action == "copy" && m_selection != NULL)
{
@ -328,3 +333,34 @@ const core::stringw GrandPrixEditorScreen::getGroupName(enum GrandPrixData::GPGr
default: return L"???";
}
}
// -----------------------------------------------------------------------------
bool GrandPrixEditorScreen::validateName(LabelWidget* label,
TextBoxWidget* text)
{
stringw name = text->getText().trim();
if (name.size() == 0)
{
label->setText(_("Name is empty."), false);
SFXManager::get()->quickSound("anvil");
return false;
}
else if (grand_prix_manager->existsName(name) ||
name == GrandPrixData::getRandomGPName())
{
// check for duplicate names
label->setText(_("Another grand prix with this name already exists."), false);
SFXManager::get()->quickSound("anvil");
return false;
}
else if (name.size() > 30)
{
label->setText(_("Name is too long."), false);
SFXManager::get()->quickSound("anvil");
return false;
}
else
{
return true;
}
}

View File

@ -20,11 +20,10 @@
#include "guiengine/screen.hpp"
#include "race/grand_prix_data.hpp"
#include "states_screens/dialogs/enter_gp_name_dialog.hpp"
#include "states_screens/dialogs/message_dialog.hpp"
namespace GUIEngine { class Widget; }
namespace GUIEngine { class Widget; class LabelWidget; }
class GrandPrixData;
@ -35,7 +34,6 @@ class GrandPrixData;
class GrandPrixEditorScreen :
public GUIEngine::Screen,
public GUIEngine::ScreenSingleton<GrandPrixEditorScreen>,
public EnterGPNameDialog::INewGPListener,
public MessageDialog::IConfirmDialogListener
{
friend class GUIEngine::ScreenSingleton<GrandPrixEditorScreen>;
@ -48,7 +46,7 @@ class GrandPrixEditorScreen :
void showEditScreen(GrandPrixData* gp);
void enableButtons();
void onNewGPWithName(const irr::core::stringw& newName) OVERRIDE;
void setNewGPWithName(const irr::core::stringw& newName);
void onConfirm() OVERRIDE;
static const core::stringw getGroupName(enum GrandPrixData::GPGroupType group);
@ -71,6 +69,9 @@ public:
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void init() OVERRIDE;
/** \brief Global function to validate grand prix names. */
static bool validateName(GUIEngine::LabelWidget*, GUIEngine::TextBoxWidget*);
};
#endif

View File

@ -1960,6 +1960,10 @@ void Track::loadObjects(const XMLNode* root, const std::string& path, ModelDefin
if (name == "track" || name == "default-start") continue;
if (name == "object" || name == "library")
{
int geo_level = 0;
node->get("geometry-level", &geo_level);
if (UserConfigParams::m_geometry_level + geo_level - 2 > 0)
continue;
m_track_object_manager->add(*node, parent, model_def_loader, parent_library);
}
else if (name == "water")

View File

@ -29,11 +29,13 @@
#include "graphics/irr_driver.hpp"
#include "graphics/light.hpp"
#include "graphics/shaders.hpp"
#include "guiengine/widgets/text_box_widget.hpp"
#include "items/powerup_manager.hpp"
#include "items/attachment.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/kart_properties.hpp"
#include "karts/controller/controller.hpp"
#include "modes/cutscene_world.hpp"
#include "modes/world.hpp"
#include "physics/irr_debug_drawer.hpp"
#include "physics/physics.hpp"
@ -42,7 +44,8 @@
#include "replay/replay_recorder.hpp"
#include "scriptengine/script_engine.hpp"
#include "states_screens/dialogs/debug_slider.hpp"
#include "states_screens/dialogs/general_debug_dialog.hpp"
#include "states_screens/dialogs/general_text_field_dialog.hpp"
#include "tracks/track_manager.hpp"
#include "utils/constants.hpp"
#include "utils/log.hpp"
#include "utils/profiler.hpp"
@ -55,14 +58,6 @@
using namespace irr;
using namespace gui;
// -----------------------------------------------------------------------------
// Callback for each general debug dialog
static void scripting(const std::string& text)
{
Scripting::ScriptEngine::getInstance()->evalScript(text);
} // scripting
// -----------------------------------------------------------------------------
namespace Debug {
/** This is to let mouse input events go through when the debug menu is
@ -134,7 +129,8 @@ enum DebugMenuCommand
DEBUG_VISUAL_VALUES,
DEBUG_PRINT_START_POS,
DEBUG_ADJUST_LIGHTS,
DEBUG_SCRIPT_CONSOLE
DEBUG_SCRIPT_CONSOLE,
DEBUG_RUN_CUTSCENE,
}; // DebugMenuCommand
// -----------------------------------------------------------------------------
@ -639,7 +635,54 @@ bool handleContextMenuAction(s32 cmd_id)
break;
}
case DEBUG_SCRIPT_CONSOLE:
new GeneralDebugDialog(L"Run Script", scripting);
new GeneralTextFieldDialog(L"Run Script", []
(const irr::core::stringw& text) {},
[] (GUIEngine::LabelWidget* lw, GUIEngine::TextBoxWidget* tb)->bool
{
Scripting::ScriptEngine* engine =
Scripting::ScriptEngine::getInstance();
if (engine == NULL)
{
Log::warn("Debug", "No scripting engine loaded!");
return true;
}
engine->evalScript(StringUtils::wideToUtf8(tb->getText()));
tb->setText(L"");
// Don't close the console after each run
return false;
});
break;
case DEBUG_RUN_CUTSCENE:
new GeneralTextFieldDialog(
L"Enter the cutscene names (separate parts by space)", []
(const irr::core::stringw& text)
{
if (World::getWorld())
{
Log::warn("Debug", "Please run cutscene in main menu");
return;
}
if (text.empty()) return;
std::vector<std::string> parts =
StringUtils::split(StringUtils::wideToUtf8(text), ' ');
for (const std::string& track : parts)
{
Track* t = track_manager->getTrack(track);
if (t == NULL)
{
Log::warn("Debug", "Cutscene %s not found!",
track.c_str());
return;
}
}
CutsceneWorld::setUseDuration(true);
StateManager::get()->enterGameState();
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
race_manager->startSingleRace(parts.front(), 999, false);
((CutsceneWorld*)World::getWorld())->setParts(parts);
});
break;
} // switch
return false;
@ -748,6 +791,7 @@ bool onEvent(const SEvent &event)
mnu->addItem(L"Print position", DEBUG_PRINT_START_POS);
mnu->addItem(L"Adjust Lights", DEBUG_ADJUST_LIGHTS);
mnu->addItem(L"Scripting console", DEBUG_SCRIPT_CONSOLE);
mnu->addItem(L"Run cutscene(s)", DEBUG_RUN_CUTSCENE);
g_debug_menu_visible = true;
irr_driver->showPointer();