Cosmetic changes only to follow our style guide (esp
line length). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9911 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
2b805c7d69
commit
eb5b5553ea
@ -34,14 +34,14 @@
|
||||
|
||||
DEFINE_SCREEN_SINGLETON( AddonsScreen );
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
AddonsScreen::AddonsScreen() : Screen("addons_screen.stkgui")
|
||||
{
|
||||
m_selected_index = -1;
|
||||
} // AddonsScreen
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void AddonsScreen::loadedFromFile()
|
||||
{
|
||||
@ -54,7 +54,7 @@ void AddonsScreen::loadedFromFile()
|
||||
video::ITexture* icon4 = irr_driver->getTexture( file_manager->getGUIDir()
|
||||
+ "/package-featured.png");
|
||||
video::ITexture* icon5 = irr_driver->getTexture( file_manager->getGUIDir()
|
||||
+ "/no-package-featured.png");
|
||||
+ "/no-package-featured.png");
|
||||
video::ITexture* icon6 = irr_driver->getTexture( file_manager->getGUIDir()
|
||||
+ "/loading.png");
|
||||
|
||||
@ -66,7 +66,8 @@ void AddonsScreen::loadedFromFile()
|
||||
m_icon_loading = m_icon_bank->addTextureAsSprite(icon6);
|
||||
m_icon_needs_update = m_icon_bank->addTextureAsSprite(icon3);
|
||||
|
||||
GUIEngine::ListWidget* w_list = getWidget<GUIEngine::ListWidget>("list_addons");
|
||||
GUIEngine::ListWidget* w_list =
|
||||
getWidget<GUIEngine::ListWidget>("list_addons");
|
||||
w_list->setColumnListener(this);
|
||||
} // loadedFromFile
|
||||
|
||||
@ -75,7 +76,8 @@ void AddonsScreen::loadedFromFile()
|
||||
|
||||
void AddonsScreen::beforeAddingWidget()
|
||||
{
|
||||
GUIEngine::ListWidget* w_list = getWidget<GUIEngine::ListWidget>("list_addons");
|
||||
GUIEngine::ListWidget* w_list =
|
||||
getWidget<GUIEngine::ListWidget>("list_addons");
|
||||
assert(w_list != NULL);
|
||||
w_list->clearColumns();
|
||||
w_list->addColumn( _("Add-on name"), 2 );
|
||||
@ -95,14 +97,15 @@ void AddonsScreen::init()
|
||||
GUIEngine::getFont()->setTabStop(0.66f);
|
||||
|
||||
if(UserConfigParams::logAddons())
|
||||
std::cout << "[addons] Using directory <" + file_manager->getAddonsDir()
|
||||
std::cout << "[addons] Using directory <" + file_manager->getAddonsDir()
|
||||
<< ">\n";
|
||||
|
||||
GUIEngine::ListWidget* w_list =
|
||||
getWidget<GUIEngine::ListWidget>("list_addons");
|
||||
|
||||
m_icon_height = getHeight()/8.0f;
|
||||
m_icon_bank->setScale(m_icon_height/128.0f); // 128 is the height of the image file
|
||||
// 128 is the height of the image file
|
||||
m_icon_bank->setScale(m_icon_height/128.0f);
|
||||
w_list->setIcons(m_icon_bank, (int)(m_icon_height));
|
||||
|
||||
m_type = "kart";
|
||||
@ -175,12 +178,15 @@ void AddonsScreen::loadList()
|
||||
|
||||
core::stringw s;
|
||||
if (addon->getDesigner().size()==0)
|
||||
s = (addon->getName()+L"\t"+core::stringc(addon->getDateAsString().c_str())).c_str();
|
||||
s = (addon->getName()+L"\t" +
|
||||
core::stringc(addon->getDateAsString().c_str())).c_str();
|
||||
|
||||
gui::IGUIFont* font = GUIEngine::getFont();
|
||||
|
||||
// first column is 0.666% of the list's width. and icon width == icon height.
|
||||
const unsigned int available_width = (int)(w_list->m_w*0.6666f - m_icon_height);
|
||||
// first column is 0.666% of the list's width.
|
||||
// and icon width == icon height.
|
||||
const unsigned int available_width = (int)(w_list->m_w*0.6666f
|
||||
- m_icon_height);
|
||||
if (font->getDimension(s.c_str()).Width > available_width)
|
||||
{
|
||||
s = s.subString(0, int(AddonsScreen::getWidth()*0.018)+20);
|
||||
@ -195,7 +201,8 @@ void AddonsScreen::loadList()
|
||||
else
|
||||
{
|
||||
//I18N: as in: The Old Island by Johannes Sjolund
|
||||
s = _C("addons", "%s by %s", addon->getName().c_str(),addon->getDesigner().c_str());
|
||||
s = _C("addons", "%s by %s", addon->getName().c_str(),
|
||||
addon->getDesigner().c_str());
|
||||
}
|
||||
|
||||
// check if text is too long to fit
|
||||
@ -204,21 +211,26 @@ void AddonsScreen::loadList()
|
||||
// start by splitting on 2 lines
|
||||
|
||||
//I18N: as in: The Old Island by Johannes Sjolund
|
||||
s = _("%s\nby %s",addon->getName().c_str(),addon->getDesigner().c_str());
|
||||
s = _("%s\nby %s",addon->getName().c_str(),
|
||||
addon->getDesigner().c_str());
|
||||
|
||||
core::stringw final_string;
|
||||
|
||||
// then check if each line is now short enough.
|
||||
std::vector<irr::core::stringw> lines = StringUtils::split(s, '\n');
|
||||
std::vector<irr::core::stringw> lines =
|
||||
StringUtils::split(s, '\n');
|
||||
for (unsigned int n=0; n<lines.size(); n++)
|
||||
{
|
||||
if (font->getDimension(lines[n].c_str()).Width > available_width)
|
||||
if (font->getDimension(lines[n].c_str()).Width
|
||||
> available_width)
|
||||
{
|
||||
// arg, still too long! cut the text so that it fits.
|
||||
core::stringw line = lines[n];
|
||||
|
||||
// leave a margin of 14 pixels to account for the "..." that will be appended
|
||||
int split_at = font->getCharacterFromPos(line.c_str(), available_width - 14);
|
||||
// leave a margin of 14 pixels to account for the "..."
|
||||
// that will be appended
|
||||
int split_at = font->getCharacterFromPos(line.c_str(),
|
||||
available_width - 14);
|
||||
line = line.subString(0, split_at);
|
||||
line.append("...");
|
||||
if (final_string.size() > 0) final_string.append("\n");
|
||||
@ -229,16 +241,18 @@ void AddonsScreen::loadList()
|
||||
if (final_string.size() > 0) final_string.append("\n");
|
||||
final_string.append(lines[n]);
|
||||
}
|
||||
}
|
||||
} // for nlines.size()
|
||||
|
||||
s = final_string;
|
||||
}
|
||||
} // if
|
||||
s.append("\t");
|
||||
s.append(addon->getDateAsString().c_str());
|
||||
}
|
||||
|
||||
// we have no icon for featured+updateme, so if an add-on is updatable forget about the featured icon
|
||||
if (addon->testStatus(Addon::AS_FEATURED) && icon != m_icon_needs_update)
|
||||
// we have no icon for featured+updateme, so if an add-on is updatable
|
||||
// forget about the featured icon
|
||||
if (addon->testStatus(Addon::AS_FEATURED) &&
|
||||
icon != m_icon_needs_update)
|
||||
{
|
||||
icon += 2;
|
||||
}
|
||||
@ -246,7 +260,8 @@ void AddonsScreen::loadList()
|
||||
w_list->addItem(addon->getId(), s.c_str(), icon);
|
||||
|
||||
// Highlight if it's not approved in artists debug mode.
|
||||
if(UserConfigParams::m_artist_debug_mode && !addon->testStatus(Addon::AS_APPROVED))
|
||||
if(UserConfigParams::m_artist_debug_mode &&
|
||||
!addon->testStatus(Addon::AS_APPROVED))
|
||||
{
|
||||
w_list->markItemRed(addon->getId(), true);
|
||||
}
|
||||
@ -291,8 +306,6 @@ void AddonsScreen::eventCallback(GUIEngine::Widget* widget,
|
||||
{
|
||||
m_reloading = true;
|
||||
network_http->insertReInit();
|
||||
//new MessageDialog(_("Please wait while addons are updated, or click the button below to reload in the background."),
|
||||
// MessageDialog::MESSAGE_DIALOG_OK, this, false);
|
||||
|
||||
GUIEngine::ListWidget* w_list =
|
||||
getWidget<GUIEngine::ListWidget>("list_addons");
|
||||
@ -364,14 +377,18 @@ void AddonsScreen::onUpdate(float dt, irr::video::IVideoDriver*)
|
||||
{
|
||||
if(UserConfigParams::m_internet_status!=NetworkHttp::IPERM_ALLOWED)
|
||||
{
|
||||
// not allowed to access the net. how did you get to this menu in the first place??
|
||||
// not allowed to access the net. how did you get to this menu in
|
||||
// the first place??
|
||||
loadList();
|
||||
m_reloading = false;
|
||||
}
|
||||
else if (addons_manager->wasError())
|
||||
{
|
||||
m_reloading = false;
|
||||
new MessageDialog( _("Sorry, an error occurred while contacting the add-ons website. Make sure you are connected to the Internet and that SuperTuxKart is not blocked by a firewall") );
|
||||
new MessageDialog( _("Sorry, an error occurred while contacting "
|
||||
"the add-ons website. Make sure you are "
|
||||
"connected to the Internet and that "
|
||||
"SuperTuxKart is not blocked by a firewall"));
|
||||
}
|
||||
else if (addons_manager->onlineReady())
|
||||
{
|
||||
@ -383,4 +400,4 @@ void AddonsScreen::onUpdate(float dt, irr::video::IVideoDriver*)
|
||||
// Addons manager is still initialising/downloading.
|
||||
}
|
||||
}
|
||||
}
|
||||
} // onUpdate
|
||||
|
@ -78,7 +78,8 @@ public:
|
||||
virtual void unloaded();
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID);
|
||||
virtual void eventCallback(GUIEngine::Widget* widget,
|
||||
const std::string& name, const int playerID);
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void beforeAddingWidget();
|
||||
|
@ -58,23 +58,23 @@ using namespace GUIEngine;
|
||||
|
||||
DEFINE_SCREEN_SINGLETON( MainMenuScreen );
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
MainMenuScreen::MainMenuScreen() : Screen("main.stkgui")
|
||||
{
|
||||
}
|
||||
} // MainMenuScreen
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void MainMenuScreen::loadedFromFile()
|
||||
{
|
||||
m_lang_popup = NULL;
|
||||
|
||||
LabelWidget* w = this->getWidget<LabelWidget>("info_addons");
|
||||
LabelWidget* w = getWidget<LabelWidget>("info_addons");
|
||||
w->setScrollSpeed(15);
|
||||
}
|
||||
} // loadedFromFile
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
void MainMenuScreen::init()
|
||||
{
|
||||
@ -101,30 +101,30 @@ void MainMenuScreen::init()
|
||||
|
||||
if (UserConfigParams::m_internet_status!=NetworkHttp::IPERM_ALLOWED)
|
||||
{
|
||||
IconButtonWidget* w = this->getWidget<IconButtonWidget>("addons");
|
||||
IconButtonWidget* w = getWidget<IconButtonWidget>("addons");
|
||||
w->setDeactivated();
|
||||
w->resetAllBadges();
|
||||
w->setBadge(BAD_BADGE);
|
||||
}
|
||||
else if (!addons_manager->onlineReady())
|
||||
{
|
||||
IconButtonWidget* w = this->getWidget<IconButtonWidget>("addons");
|
||||
IconButtonWidget* w = getWidget<IconButtonWidget>("addons");
|
||||
w->setDeactivated();
|
||||
w->resetAllBadges();
|
||||
w->setBadge(LOADING_BADGE);
|
||||
}
|
||||
|
||||
|
||||
LabelWidget* w = this->getWidget<LabelWidget>("info_addons");
|
||||
LabelWidget* w = getWidget<LabelWidget>("info_addons");
|
||||
const core::stringw &news_text = news_manager->getNextNewsMessage();
|
||||
w->setText(news_text, true);
|
||||
w->update(0.01f);
|
||||
}
|
||||
} // init
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
void MainMenuScreen::onUpdate(float delta, irr::video::IVideoDriver* driver)
|
||||
{
|
||||
IconButtonWidget* addons_icon = this->getWidget<IconButtonWidget>("addons");
|
||||
IconButtonWidget* addons_icon = getWidget<IconButtonWidget>("addons");
|
||||
if (addons_icon != NULL)
|
||||
{
|
||||
if(UserConfigParams::m_internet_status!=NetworkHttp::IPERM_ALLOWED )
|
||||
@ -153,17 +153,19 @@ void MainMenuScreen::onUpdate(float delta, irr::video::IVideoDriver* driver)
|
||||
}
|
||||
}
|
||||
|
||||
LabelWidget* w = this->getWidget<LabelWidget>("info_addons");
|
||||
LabelWidget* w = getWidget<LabelWidget>("info_addons");
|
||||
w->update(delta);
|
||||
if(w->scrolledOff())
|
||||
{
|
||||
const core::stringw &news_text = news_manager->getNextNewsMessage();
|
||||
w->setText(news_text, true);
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
} // onUpdate
|
||||
|
||||
void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, const int playerID)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
const int playerID)
|
||||
{
|
||||
// most interesting stuff is in the ribbons, so start there
|
||||
RibbonWidget* ribbon = dynamic_cast<RibbonWidget*>(widget);
|
||||
@ -171,36 +173,54 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, cons
|
||||
if (ribbon == NULL) return; // what's that event??
|
||||
|
||||
// ---- A ribbon icon was clicked
|
||||
std::string selection = ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||
std::string selection =
|
||||
ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||
|
||||
#if DEBUG_MENU_ITEM
|
||||
if (selection == "options")
|
||||
{
|
||||
// The DEBUG item
|
||||
FeatureUnlockedCutScene* scene = FeatureUnlockedCutScene::getInstance();
|
||||
FeatureUnlockedCutScene* scene =
|
||||
FeatureUnlockedCutScene::getInstance();
|
||||
|
||||
static int i = 1;
|
||||
i++;
|
||||
|
||||
if (i % 4 == 0)
|
||||
{
|
||||
// the passed kart will not be modified, that's why I allow myself to use const_cast
|
||||
scene->addUnlockedKart( const_cast<KartProperties*>(kart_properties_manager->getKart("tux")),
|
||||
L"Unlocked");
|
||||
// the passed kart will not be modified, that's why I allow myself
|
||||
// to use const_cast
|
||||
scene->addUnlockedKart(
|
||||
const_cast<KartProperties*>(
|
||||
kart_properties_manager->getKart("tux")
|
||||
),
|
||||
L"Unlocked"
|
||||
);
|
||||
StateManager::get()->pushScreen(scene);
|
||||
}
|
||||
else if (i % 4 == 1)
|
||||
{
|
||||
std::vector<video::ITexture*> textures;
|
||||
textures.push_back(irr_driver->getTexture(track_manager->getTrack("lighthouse")->getScreenshotFile().c_str()));
|
||||
textures.push_back(irr_driver->getTexture(track_manager->getTrack("crescentcrossing")->getScreenshotFile().c_str()));
|
||||
textures.push_back(irr_driver->getTexture(track_manager->getTrack("sandtrack")->getScreenshotFile().c_str()));
|
||||
textures.push_back(irr_driver->getTexture(track_manager->getTrack("snowmountain")->getScreenshotFile().c_str()));
|
||||
textures.push_back(irr_driver->getTexture(
|
||||
track_manager->getTrack("lighthouse")
|
||||
->getScreenshotFile().c_str()));
|
||||
textures.push_back(irr_driver->getTexture(
|
||||
track_manager->getTrack("crescentcrossing")
|
||||
->getScreenshotFile().c_str()));
|
||||
textures.push_back(irr_driver->getTexture(
|
||||
track_manager->getTrack("sandtrack")
|
||||
->getScreenshotFile().c_str()));
|
||||
textures.push_back(irr_driver->getTexture(
|
||||
track_manager->getTrack("snowmountain")
|
||||
->getScreenshotFile().c_str()));
|
||||
|
||||
scene->addUnlockedPictures(textures, 1.0, 0.75, L"You did it");
|
||||
|
||||
/*
|
||||
scene->addUnlockedPicture( irr_driver->getTexture(track_manager->getTrack("lighthouse")->getScreenshotFile().c_str()),
|
||||
scene->addUnlockedPicture(
|
||||
irr_driver->getTexture(
|
||||
track_manager->getTrack("lighthouse")
|
||||
->getScreenshotFile().c_str()),
|
||||
1.0, 0.75, L"You did it");
|
||||
*/
|
||||
|
||||
@ -267,9 +287,9 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, cons
|
||||
{
|
||||
StateManager::get()->pushScreen(AddonsScreen::getInstance());
|
||||
}
|
||||
}
|
||||
} // eventCallback
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void MainMenuScreen::tearDown()
|
||||
{
|
||||
@ -277,9 +297,9 @@ void MainMenuScreen::tearDown()
|
||||
{
|
||||
closeLangPopup();
|
||||
}
|
||||
}
|
||||
} // tearDown
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool MainMenuScreen::onEscapePressed()
|
||||
{
|
||||
@ -290,9 +310,9 @@ bool MainMenuScreen::onEscapePressed()
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // onEscapePressed
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void MainMenuScreen::closeLangPopup()
|
||||
{
|
||||
@ -303,9 +323,9 @@ void MainMenuScreen::closeLangPopup()
|
||||
manualRemoveWidget(m_lang_popup);
|
||||
delete m_lang_popup;
|
||||
m_lang_popup = NULL;
|
||||
}
|
||||
} // closeLangPopup
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void MainMenuScreen::onDisabledItemClicked(const std::string& item)
|
||||
{
|
||||
@ -313,15 +333,19 @@ void MainMenuScreen::onDisabledItemClicked(const std::string& item)
|
||||
{
|
||||
if (UserConfigParams::m_internet_status != NetworkHttp::IPERM_ALLOWED)
|
||||
{
|
||||
new MessageDialog( _("The add-ons module is currently disabled in the Options screen") );
|
||||
new MessageDialog( _("The add-ons module is currently disabled in "
|
||||
"the Options screen") );
|
||||
}
|
||||
else if (addons_manager->wasError())
|
||||
{
|
||||
new MessageDialog( _("Sorry, an error occurred while contacting the add-ons website. Make sure you are connected to the Internet and that SuperTuxKart is not blocked by a firewall") );
|
||||
new MessageDialog( _("Sorry, an error occurred while contacting "
|
||||
"the add-ons website. Make sure you are "
|
||||
"connected to the Internet and that "
|
||||
"SuperTuxKart is not blocked by a firewall"));
|
||||
}
|
||||
else if (addons_manager->isLoading())
|
||||
{
|
||||
new MessageDialog( _("Please wait while the add-ons are loading") );
|
||||
new MessageDialog( _("Please wait while the add-ons are loading"));
|
||||
}
|
||||
}
|
||||
}
|
||||
} // onDisabledItemClicked
|
||||
|
@ -46,26 +46,27 @@ using namespace GUIEngine;
|
||||
|
||||
DEFINE_SCREEN_SINGLETON( OptionsScreenInput2 );
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
OptionsScreenInput2::OptionsScreenInput2() : Screen("options_device.stkgui")
|
||||
{
|
||||
m_config = NULL;
|
||||
} // OptionsScreenInput2
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void OptionsScreenInput2::loadedFromFile()
|
||||
{
|
||||
} // loadedFromFile
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void OptionsScreenInput2::init()
|
||||
{
|
||||
Screen::init();
|
||||
RibbonWidget* tabBar = this->getWidget<RibbonWidget>("options_choice");
|
||||
if (tabBar != NULL) tabBar->select( "tab_controls", PLAYER_ID_GAME_MASTER );
|
||||
RibbonWidget* tabBar = getWidget<RibbonWidget>("options_choice");
|
||||
if (tabBar != NULL) tabBar->select( "tab_controls",
|
||||
PLAYER_ID_GAME_MASTER );
|
||||
|
||||
tabBar->getRibbonChildren()[0].setTooltip( _("Graphics") );
|
||||
tabBar->getRibbonChildren()[1].setTooltip( _("Audio") );
|
||||
@ -73,16 +74,19 @@ void OptionsScreenInput2::init()
|
||||
tabBar->getRibbonChildren()[3].setTooltip( _("Players") );
|
||||
|
||||
|
||||
ButtonWidget* deleteBtn = this->getWidget<ButtonWidget>("delete");
|
||||
ButtonWidget* deleteBtn = getWidget<ButtonWidget>("delete");
|
||||
if (m_config->getType() != DEVICE_CONFIG_TYPE_KEYBOARD)
|
||||
{
|
||||
core::stringw label = (m_config->isEnabled() ? //I18N: button to disable a gamepad configuration
|
||||
_("Disable Device")
|
||||
: //I18N: button to enable a gamepad configuration
|
||||
_("Enable Device"));
|
||||
core::stringw label = (m_config->isEnabled()
|
||||
? //I18N: button to disable a gamepad configuration
|
||||
_("Disable Device")
|
||||
: //I18N: button to enable a gamepad configuration
|
||||
_("Enable Device"));
|
||||
|
||||
// Make sure button is wide enough as the text is being changed away from the original value
|
||||
core::dimension2d<u32> size = GUIEngine::getFont()->getDimension(label.c_str());
|
||||
// Make sure button is wide enough as the text is being changed away
|
||||
// from the original value
|
||||
core::dimension2d<u32> size =
|
||||
GUIEngine::getFont()->getDimension(label.c_str());
|
||||
const int needed = size.Width + deleteBtn->getWidthNeededAroundLabel();
|
||||
if (deleteBtn->m_w < needed) deleteBtn->m_w = needed;
|
||||
|
||||
@ -103,18 +107,20 @@ void OptionsScreenInput2::init()
|
||||
}
|
||||
}
|
||||
|
||||
// Make the two buttons the same length, not strictly needed but will look nicer...
|
||||
ButtonWidget* backBtn = this->getWidget<ButtonWidget>("back_to_device_list");
|
||||
// Make the two buttons the same length, not strictly needed but will
|
||||
// look nicer...
|
||||
ButtonWidget* backBtn = getWidget<ButtonWidget>("back_to_device_list");
|
||||
if (backBtn->m_w < deleteBtn->m_w) backBtn->m_w = deleteBtn->m_w;
|
||||
else deleteBtn->m_w = backBtn->m_w;
|
||||
|
||||
backBtn->moveIrrlichtElement();
|
||||
deleteBtn->moveIrrlichtElement();
|
||||
|
||||
LabelWidget* label = this->getWidget<LabelWidget>("title");
|
||||
LabelWidget* label = getWidget<LabelWidget>("title");
|
||||
label->setText( m_config->getName().c_str(), false );
|
||||
|
||||
GUIEngine::ListWidget* actions = this->getWidget<GUIEngine::ListWidget>("actions");
|
||||
GUIEngine::ListWidget* actions =
|
||||
getWidget<GUIEngine::ListWidget>("actions");
|
||||
assert( actions != NULL );
|
||||
|
||||
// ---- create list skeleton (right number of items, right internal names)
|
||||
@ -148,10 +154,12 @@ void OptionsScreenInput2::init()
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
irr::core::stringw OptionsScreenInput2::makeLabel(const irr::core::stringw translatedName,
|
||||
PlayerAction action) const
|
||||
irr::core::stringw OptionsScreenInput2::makeLabel(
|
||||
const irr::core::stringw &translatedName,
|
||||
PlayerAction action) const
|
||||
{
|
||||
//hack: one tab character is supported by out font object, it moves the cursor to the middle of the area
|
||||
//hack: one tab character is supported by out font object, it moves the
|
||||
// cursor to the middle of the area
|
||||
core::stringw out = irr::core::stringw(" ") + translatedName + L"\t";
|
||||
|
||||
out += m_config->getBindingAsString(action);
|
||||
@ -166,7 +174,8 @@ void OptionsScreenInput2::updateInputButtons()
|
||||
|
||||
//TODO: detect duplicates
|
||||
|
||||
GUIEngine::ListWidget* actions = this->getWidget<GUIEngine::ListWidget>("actions");
|
||||
GUIEngine::ListWidget* actions =
|
||||
getWidget<GUIEngine::ListWidget>("actions");
|
||||
assert( actions != NULL );
|
||||
|
||||
int i = 0;
|
||||
@ -225,7 +234,8 @@ void OptionsScreenInput2::updateInputButtons()
|
||||
|
||||
|
||||
bool conflicts = false;
|
||||
// ---- make sure there are no binding conflicts (same key used for two actions)
|
||||
// ---- make sure there are no binding conflicts
|
||||
// (same key used for two actions)
|
||||
std::set<irr::core::stringw> currentlyUsedKeys;
|
||||
for (PlayerAction action = PA_FIRST_GAME_ACTION;
|
||||
action <= PA_LAST_GAME_ACTION;
|
||||
@ -236,7 +246,8 @@ void OptionsScreenInput2::updateInputButtons()
|
||||
{
|
||||
currentlyUsedKeys.insert( item );
|
||||
if (m_config->getType() == DEVICE_CONFIG_TYPE_KEYBOARD
|
||||
&& conflictsBetweenKbdConfig(action, PA_FIRST_GAME_ACTION, PA_LAST_GAME_ACTION))
|
||||
&& conflictsBetweenKbdConfig(action, PA_FIRST_GAME_ACTION,
|
||||
PA_LAST_GAME_ACTION))
|
||||
{
|
||||
conflicts = true;
|
||||
actions->markItemBlue (KartActionStrings[action]);
|
||||
@ -251,18 +262,21 @@ void OptionsScreenInput2::updateInputButtons()
|
||||
for (PlayerAction others = PA_FIRST_GAME_ACTION;
|
||||
others < action; others=PlayerAction(others+1))
|
||||
{
|
||||
const irr::core::stringw others_item = m_config->getMappingIdString(others);
|
||||
const irr::core::stringw others_item =
|
||||
m_config->getMappingIdString(others);
|
||||
if (others_item == item)
|
||||
{
|
||||
actions->markItemRed( KartActionStrings[others] );
|
||||
}
|
||||
}
|
||||
|
||||
//actions->renameItem( KartActionStrings[action], _("Binding Conflict!") );
|
||||
//actions->renameItem( KartActionStrings[action],
|
||||
// _("Binding Conflict!") );
|
||||
}
|
||||
}
|
||||
|
||||
// menu keys and game keys can overlap, no problem, so forget game keys before checking menu keys
|
||||
// menu keys and game keys can overlap, no problem, so forget game keys
|
||||
// before checking menu keys
|
||||
currentlyUsedKeys.clear();
|
||||
for (PlayerAction action = PA_FIRST_MENU_ACTION;
|
||||
action <= PA_LAST_MENU_ACTION;
|
||||
@ -273,7 +287,8 @@ void OptionsScreenInput2::updateInputButtons()
|
||||
{
|
||||
currentlyUsedKeys.insert( item );
|
||||
if (m_config->getType() == DEVICE_CONFIG_TYPE_KEYBOARD
|
||||
&& conflictsBetweenKbdConfig(action, PA_FIRST_MENU_ACTION, PA_LAST_MENU_ACTION))
|
||||
&& conflictsBetweenKbdConfig(action, PA_FIRST_MENU_ACTION,
|
||||
PA_LAST_MENU_ACTION))
|
||||
{
|
||||
conflicts = true;
|
||||
actions->markItemBlue (KartActionStrings[action]);
|
||||
@ -288,20 +303,24 @@ void OptionsScreenInput2::updateInputButtons()
|
||||
for (PlayerAction others = PA_FIRST_MENU_ACTION;
|
||||
others < action; others=PlayerAction(others+1))
|
||||
{
|
||||
const irr::core::stringw others_item = m_config->getBindingAsString(others);
|
||||
const irr::core::stringw others_item =
|
||||
m_config->getBindingAsString(others);
|
||||
if (others_item == item)
|
||||
{
|
||||
actions->markItemRed( KartActionStrings[others] );
|
||||
}
|
||||
}
|
||||
|
||||
//actions->renameItem( KartActionStrings[action], _("Binding Conflict!") );
|
||||
//actions->renameItem( KartActionStrings[action],
|
||||
// _("Binding Conflict!") );
|
||||
}
|
||||
}
|
||||
|
||||
GUIEngine::Widget* conflict_label = this->getWidget<GUIEngine::LabelWidget>("conflict");
|
||||
GUIEngine::Widget* conflict_label =
|
||||
getWidget<GUIEngine::LabelWidget>("conflict");
|
||||
if (conflicts)
|
||||
conflict_label->setText( _("* A blue item means a conflict with another configuration") );
|
||||
conflict_label->setText(
|
||||
_("* A blue item means a conflict with another configuration") );
|
||||
else
|
||||
conflict_label->setText("");
|
||||
|
||||
@ -314,7 +333,7 @@ static std::string binding_to_set_button;
|
||||
|
||||
void OptionsScreenInput2::gotSensedInput(const Input& sensed_input)
|
||||
{
|
||||
const bool keyboard = (m_config->getType() == DEVICE_CONFIG_TYPE_KEYBOARD &&
|
||||
const bool keyboard = (m_config->getType() == DEVICE_CONFIG_TYPE_KEYBOARD&&
|
||||
sensed_input.m_type == Input::IT_KEYBOARD);
|
||||
const bool gamepad = (sensed_input.m_type == Input::IT_STICKMOTION ||
|
||||
sensed_input.m_type == Input::IT_STICKBUTTON) &&
|
||||
@ -347,8 +366,8 @@ void OptionsScreenInput2::gotSensedInput(const Input& sensed_input)
|
||||
|
||||
if (sensed_input.m_type == Input::IT_STICKMOTION)
|
||||
{
|
||||
std::cout << "axis " << sensed_input.m_button_id<< " direction "
|
||||
<< (sensed_input.m_axis_direction== Input::AD_NEGATIVE
|
||||
std::cout << "axis " <<sensed_input.m_button_id<< " direction "
|
||||
<< (sensed_input.m_axis_direction==Input::AD_NEGATIVE
|
||||
? "-" : "+")
|
||||
<< "\n\n";
|
||||
}
|
||||
@ -365,7 +384,7 @@ void OptionsScreenInput2::gotSensedInput(const Input& sensed_input)
|
||||
GamepadConfig* config = (GamepadConfig*)m_config;
|
||||
config->setBinding(binding_to_set, sensed_input.m_type,
|
||||
sensed_input.m_button_id,
|
||||
(Input::AxisDirection)sensed_input.m_axis_direction);
|
||||
(Input::AxisDirection)sensed_input.m_axis_direction);
|
||||
|
||||
// refresh display
|
||||
updateInputButtons();
|
||||
@ -378,14 +397,19 @@ void OptionsScreenInput2::gotSensedInput(const Input& sensed_input)
|
||||
ModalDialog::dismiss();
|
||||
input_manager->setMode(InputManager::MENU);
|
||||
|
||||
if (keyboard && (sensed_input.m_button_id == irr::KEY_SHIFT || sensed_input.m_button_id == irr::KEY_LSHIFT ||
|
||||
if (keyboard && (sensed_input.m_button_id == irr::KEY_SHIFT ||
|
||||
sensed_input.m_button_id == irr::KEY_LSHIFT ||
|
||||
sensed_input.m_button_id == irr::KEY_RSHIFT))
|
||||
{
|
||||
new MessageDialog(_("Warning, 'Shift' is not a recommended key : when shift is pressed down, all keys that contain a character that is different in upper-case will stop working."));
|
||||
new MessageDialog(_("Warning, 'Shift' is not a recommended key : when "
|
||||
"shift is pressed down, all keys that contain a "
|
||||
"character that is different in upper-case will "
|
||||
"stop working."));
|
||||
}
|
||||
|
||||
// re-select the previous button (TODO!)
|
||||
//ButtonWidget* btn = this->getWidget<ButtonWidget>(binding_to_set_button.c_str());
|
||||
//ButtonWidget* btn =
|
||||
// getWidget<ButtonWidget>(binding_to_set_button.c_str());
|
||||
//if(btn != NULL) btn->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
|
||||
// save new binding to file
|
||||
@ -393,33 +417,41 @@ void OptionsScreenInput2::gotSensedInput(const Input& sensed_input)
|
||||
} // gotSensedInput
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void OptionsScreenInput2::eventCallback(Widget* widget, const std::string& name, const int playerID)
|
||||
// ----------------------------------------------------------------------------
|
||||
void OptionsScreenInput2::eventCallback(Widget* widget,
|
||||
const std::string& name,
|
||||
const int playerID)
|
||||
{
|
||||
//const std::string& screen_name = this->getName();
|
||||
//const std::string& screen_name = getName();
|
||||
|
||||
StateManager *sm = StateManager::get();
|
||||
if (name == "options_choice")
|
||||
{
|
||||
std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str();
|
||||
const std::string &selection =
|
||||
((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||
|
||||
if (selection == "tab_audio") StateManager::get()->replaceTopMostScreen(OptionsScreenAudio::getInstance());
|
||||
else if (selection == "tab_video") StateManager::get()->replaceTopMostScreen(OptionsScreenVideo::getInstance());
|
||||
else if (selection == "tab_players") StateManager::get()->replaceTopMostScreen(OptionsScreenPlayers::getInstance());
|
||||
else if (selection == "tab_ui") StateManager::get()->replaceTopMostScreen(OptionsScreenUI::getInstance());
|
||||
if (selection == "tab_audio")
|
||||
sm->replaceTopMostScreen(OptionsScreenAudio::getInstance());
|
||||
else if (selection == "tab_video")
|
||||
sm->replaceTopMostScreen(OptionsScreenVideo::getInstance());
|
||||
else if (selection == "tab_players")
|
||||
sm->replaceTopMostScreen(OptionsScreenPlayers::getInstance());
|
||||
else if (selection == "tab_ui")
|
||||
sm->replaceTopMostScreen(OptionsScreenUI::getInstance());
|
||||
else if (selection == "tab_controls") {}
|
||||
}
|
||||
else if (name == "back_to_device_list")
|
||||
{
|
||||
StateManager::get()->replaceTopMostScreen(OptionsScreenInput::getInstance());
|
||||
sm->replaceTopMostScreen(OptionsScreenInput::getInstance());
|
||||
}
|
||||
else if (name == "back")
|
||||
{
|
||||
StateManager::get()->popMenu();
|
||||
sm->popMenu();
|
||||
}
|
||||
else if (name == "actions")
|
||||
{
|
||||
GUIEngine::ListWidget* actions = this->getWidget<GUIEngine::ListWidget>("actions");
|
||||
GUIEngine::ListWidget* actions =
|
||||
getWidget<GUIEngine::ListWidget>("actions");
|
||||
assert( actions != NULL );
|
||||
|
||||
// a player action in the list was clicked. find which one
|
||||
@ -463,7 +495,8 @@ void OptionsScreenInput2::eventCallback(Widget* widget, const std::string& name,
|
||||
{
|
||||
// keyboard configs may be deleted
|
||||
//I18N: shown before deleting an input configuration
|
||||
new MessageDialog( _("Are you sure you want to permanently delete this configuration?"),
|
||||
new MessageDialog( _("Are you sure you want to permanently delete "
|
||||
"this configuration?"),
|
||||
MessageDialog::MESSAGE_DIALOG_CONFIRM, this, false );
|
||||
}
|
||||
else
|
||||
@ -473,9 +506,9 @@ void OptionsScreenInput2::eventCallback(Widget* widget, const std::string& name,
|
||||
else m_config->setEnabled(true);
|
||||
|
||||
// update widget label
|
||||
ButtonWidget* deleteBtn = this->getWidget<ButtonWidget>("delete");
|
||||
if (m_config->isEnabled()) deleteBtn->setLabel(_("Disable Device"));
|
||||
else deleteBtn->setLabel(_("Enable Device"));
|
||||
ButtonWidget* deleteBtn = getWidget<ButtonWidget>("delete");
|
||||
deleteBtn->setLabel(m_config->isEnabled() ? _("Disable Device")
|
||||
: _("Enable Device") );
|
||||
|
||||
input_manager->getDeviceList()->serialize();
|
||||
}
|
||||
@ -493,23 +526,27 @@ void OptionsScreenInput2::unloaded()
|
||||
|
||||
bool OptionsScreenInput2::onEscapePressed()
|
||||
{
|
||||
StateManager::get()->replaceTopMostScreen(OptionsScreenInput::getInstance());
|
||||
return false; // don't use standard escape key handler, we handled it differently
|
||||
StateManager::get()
|
||||
->replaceTopMostScreen(OptionsScreenInput::getInstance());
|
||||
return false; // don't use standard escape key handler,
|
||||
// we handled it differently
|
||||
} // onEscapePressed
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void OptionsScreenInput2::onConfirm()
|
||||
{
|
||||
const bool success = input_manager->getDeviceList()->deleteConfig(m_config);
|
||||
const bool success =
|
||||
input_manager->getDeviceList()->deleteConfig(m_config);
|
||||
assert(success);
|
||||
if (!success) fprintf(stderr, "Failed to delete config!\n");
|
||||
|
||||
m_config = NULL;
|
||||
input_manager->getDeviceList()->serialize();
|
||||
ModalDialog::dismiss();
|
||||
StateManager::get()->replaceTopMostScreen(OptionsScreenInput::getInstance());
|
||||
}
|
||||
StateManager::get()
|
||||
->replaceTopMostScreen(OptionsScreenInput::getInstance());
|
||||
} // onConfirm
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@ -519,13 +556,18 @@ bool OptionsScreenInput2::conflictsBetweenKbdConfig(PlayerAction action,
|
||||
{
|
||||
KeyboardConfig* other_kbd_config;
|
||||
int id = m_config->getBinding(action).getId();
|
||||
for (int i=0; i < input_manager->getDeviceList()->getKeyboardAmount(); i++) {
|
||||
other_kbd_config = input_manager->getDeviceList()->getKeyboardConfig(i);
|
||||
for (int i=0; i < input_manager->getDeviceList()->getKeyboardAmount(); i++)
|
||||
{
|
||||
other_kbd_config =
|
||||
input_manager->getDeviceList()->getKeyboardConfig(i);
|
||||
|
||||
if (m_config != other_kbd_config && other_kbd_config->hasBindingFor(id, from, to)
|
||||
&& (other_kbd_config->getBinding(action).getId() != id || action == PA_FIRE)) {
|
||||
if (m_config != other_kbd_config &&
|
||||
other_kbd_config->hasBindingFor(id, from, to)
|
||||
&& (other_kbd_config->getBinding(action).getId() != id ||
|
||||
action == PA_FIRE) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // conflictsBetweenKbdConfig
|
||||
|
@ -38,18 +38,20 @@ struct Input;
|
||||
* \ingroup states_screens
|
||||
*/
|
||||
class OptionsScreenInput2 : public GUIEngine::Screen,
|
||||
public GUIEngine::ScreenSingleton<OptionsScreenInput2>,
|
||||
public MessageDialog::IConfirmDialogListener
|
||||
public GUIEngine::ScreenSingleton<OptionsScreenInput2>,
|
||||
public MessageDialog::IConfirmDialogListener
|
||||
{
|
||||
OptionsScreenInput2();
|
||||
|
||||
void updateInputButtons();
|
||||
|
||||
bool conflictsBetweenKbdConfig(PlayerAction action, PlayerAction from, PlayerAction to);
|
||||
bool conflictsBetweenKbdConfig(PlayerAction action, PlayerAction from,
|
||||
PlayerAction to);
|
||||
|
||||
DeviceConfig* m_config;
|
||||
|
||||
irr::core::stringw makeLabel(const irr::core::stringw translatedName, PlayerAction action) const;
|
||||
irr::core::stringw makeLabel(const irr::core::stringw &translatedName,
|
||||
PlayerAction action) const;
|
||||
|
||||
public:
|
||||
friend class GUIEngine::ScreenSingleton<OptionsScreenInput2>;
|
||||
@ -60,15 +62,18 @@ public:
|
||||
virtual void loadedFromFile();
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID);
|
||||
virtual void eventCallback(GUIEngine::Widget* widget,
|
||||
const std::string& name, const int playerID);
|
||||
|
||||
/** \brief implement optional callback from parent class GUIEngine::Screen */
|
||||
/** \brief implement optional callback from parent class
|
||||
* GUIEngine::Screen */
|
||||
virtual void unloaded();
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void init();
|
||||
|
||||
/** \brief implement optional callback from parent class GUIEngine::Screen */
|
||||
/** \brief implement optional callback from parent class
|
||||
* GUIEngine::Screen */
|
||||
virtual bool onEscapePressed();
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user