Add a continue button for multitouch device in kart selection
This commit is contained in:
parent
db95d2f88f
commit
b816f94269
@ -7,21 +7,26 @@
|
||||
align="center" text_align="center" />
|
||||
<spacer height="1%" width="25"/>
|
||||
|
||||
<placeholder id="playerskarts" width="100%" align="center" proportion="4">
|
||||
<placeholder id="playerskarts" width="100%" height="70%" align="center" proportion="4">
|
||||
<!-- Contents is added programatically -->
|
||||
</placeholder>
|
||||
|
||||
<spacer height="1f" width="25"/>
|
||||
|
||||
<box proportion="2" width="100%" layout="vertical-row" padding="2">
|
||||
<ribbon_grid id="karts" proportion="1" square_items="true" width="100%" align="center"
|
||||
child_width="90" child_height="90" max_rows="2"/>
|
||||
</box>
|
||||
|
||||
<!-- Groups will be added dynamically at runtime -->
|
||||
<tabs width="98%" x="1%" height="1f" id="kartgroups">
|
||||
</tabs>
|
||||
<spacer width="100%" height="2%"/>
|
||||
<spacer height="1f"/>
|
||||
<div width="100%" height="30%" layout="horizontal-row" >
|
||||
<div id="kartlist" width="90%" height="100%" layout="vertical-row" >
|
||||
<box proportion="2" width="100%" layout="vertical-row" padding="2">
|
||||
<ribbon_grid id="karts" proportion="1" square_items="true" width="100%" align="center"
|
||||
child_width="90" child_height="90" max_rows="2"/>
|
||||
</box>
|
||||
<!-- Groups will be added dynamically at runtime -->
|
||||
<tabs width="98%" x="1%" height="1f" id="kartgroups">
|
||||
</tabs>
|
||||
<spacer width="100%" height="2%"/>
|
||||
</div>
|
||||
<spacer width="2%"/>
|
||||
<icon-button id="continue" icon="gui/icons/green_check.png" text="Continue"/>
|
||||
<spacer width="2%"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<icon-button id="back" x="1%" y="0" height="9%" icon="gui/icons/back.png"/>
|
||||
|
@ -1,26 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<stkgui>
|
||||
<div x="1%" y="1%" width="98%" height="98%" layout="vertical-row" >
|
||||
<div x="1%" y="1%" width="98%" height="90%" layout="vertical-row" >
|
||||
<header width="80%" height="8%" align="center" text_align="center" I18N="In the kart selection (player setup) screen" text="Choose a Kart"/>
|
||||
<spacer width="100%" height="1%"/>
|
||||
|
||||
<placeholder id="playerskarts" width="100%" align="center" proportion="5">
|
||||
<placeholder id="playerskarts" width="100%" height="70%" align="center" proportion="5">
|
||||
<!-- Contents is added programatically -->
|
||||
</placeholder>
|
||||
|
||||
<spacer height="15" width="25"/>
|
||||
|
||||
<box proportion="2" width="100%" layout="vertical-row" padding="2">
|
||||
<ribbon_grid id="karts" proportion="1" square_items="true" width="100%" align="center"
|
||||
child_width="90" child_height="90" max_rows="2"/>
|
||||
</box>
|
||||
|
||||
<!-- Groups will be added dynamically at runtime -->
|
||||
<tabs width="98%" x="1%" height="1f" id="kartgroups">
|
||||
</tabs>
|
||||
<spacer width="100%" height="2%"/>
|
||||
<progressbar x="1%" id="timer" height="1f" width="98%"></progressbar>
|
||||
<spacer height="1f"/>
|
||||
<div width="100%" height="30%" layout="horizontal-row" >
|
||||
<div id="kartlist" width="90%" height="100%" layout="vertical-row" >
|
||||
<box proportion="2" width="100%" layout="vertical-row" padding="2">
|
||||
<ribbon_grid id="karts" proportion="1" square_items="true" width="100%" align="center"
|
||||
child_width="90" child_height="90" max_rows="2"/>
|
||||
</box>
|
||||
<!-- Groups will be added dynamically at runtime -->
|
||||
<tabs width="98%" x="1%" height="1f" id="kartgroups">
|
||||
</tabs>
|
||||
<spacer width="100%" height="2%"/>
|
||||
</div>
|
||||
<spacer width="2%"/>
|
||||
<icon-button id="continue" proportion="1" icon="gui/icons/green_check.png" text="Continue"/>
|
||||
<spacer width="2%"/>
|
||||
</div>
|
||||
</div>
|
||||
<progressbar x="2%" y="93%" id="timer" height="1f" width="96%"></progressbar>
|
||||
<icon-button id="back" x="1%" y="0" height="9%" icon="gui/icons/back.png"/>
|
||||
|
||||
</stkgui>
|
||||
|
@ -268,6 +268,28 @@ void KartSelectionScreen::loadedFromFile()
|
||||
|
||||
void KartSelectionScreen::beforeAddingWidget()
|
||||
{
|
||||
if (useContinueButton())
|
||||
{
|
||||
getWidget("kartlist")->m_properties[GUIEngine::PROP_WIDTH] = "90%";
|
||||
getWidget("continue")->setVisible(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
getWidget("kartlist")->m_properties[GUIEngine::PROP_WIDTH] = "100%";
|
||||
getWidget("continue")->setVisible(false);
|
||||
}
|
||||
// Remove dispatcher from m_widgets before calculateLayout otherwise a
|
||||
// dummy button is shown in kart screen
|
||||
bool removed_dispatcher = false;
|
||||
if (m_widgets.contains(m_dispatcher))
|
||||
{
|
||||
m_widgets.remove(m_dispatcher);
|
||||
removed_dispatcher = true;
|
||||
}
|
||||
calculateLayout();
|
||||
if (removed_dispatcher)
|
||||
m_widgets.push_back(m_dispatcher);
|
||||
|
||||
// Dynamically add tabs
|
||||
RibbonWidget* tabs = getWidget<RibbonWidget>("kartgroups");
|
||||
assert( tabs != NULL );
|
||||
@ -1098,7 +1120,14 @@ void KartSelectionScreen::eventCallback(Widget* widget,
|
||||
}
|
||||
else if (name == "karts")
|
||||
{
|
||||
if (m_kart_widgets.size() > unsigned(player_id))
|
||||
if (!useContinueButton() &&
|
||||
m_kart_widgets.size() > unsigned(player_id))
|
||||
playerConfirm(player_id);
|
||||
}
|
||||
else if (name == "continue")
|
||||
{
|
||||
if (useContinueButton() &&
|
||||
m_kart_widgets.size() > unsigned(player_id))
|
||||
playerConfirm(player_id);
|
||||
}
|
||||
else if (name == "back")
|
||||
@ -1551,6 +1580,15 @@ void KartSelectionScreen::setKartsFromCurrentGroup()
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
bool KartSelectionScreen::useContinueButton() const
|
||||
{
|
||||
if (m_multiplayer)
|
||||
return false;
|
||||
bool multitouch_enabled = (UserConfigParams::m_multitouch_active == 1 &&
|
||||
irr_driver->getDevice()->supportsTouchDevice()) ||
|
||||
UserConfigParams::m_multitouch_active > 1;
|
||||
return multitouch_enabled;
|
||||
} // useContinueButton
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
|
@ -131,6 +131,7 @@ protected:
|
||||
private:
|
||||
PtrVector<const KartProperties, REF> getUsableKarts(
|
||||
const std::string& selected_kart_group);
|
||||
bool useContinueButton() const;
|
||||
public:
|
||||
/** Returns the current instance */
|
||||
static KartSelectionScreen* getRunningInstance();
|
||||
|
@ -32,12 +32,18 @@
|
||||
|
||||
using namespace GUIEngine;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void NetworkKartSelectionScreen::beforeAddingWidget()
|
||||
{
|
||||
m_multiplayer = NetworkConfig::get()->getNetworkPlayers().size() != 1;
|
||||
KartSelectionScreen::beforeAddingWidget();
|
||||
} // beforeAddingWidget
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void NetworkKartSelectionScreen::init()
|
||||
{
|
||||
assert(!NetworkConfig::get()->isAddingNetworkPlayers());
|
||||
m_all_players_done = false;
|
||||
m_multiplayer = NetworkConfig::get()->getNetworkPlayers().size() != 1;
|
||||
KartSelectionScreen::init();
|
||||
|
||||
m_timer = getWidget<GUIEngine::ProgressBarWidget>("timer");
|
||||
|
@ -64,6 +64,8 @@ private:
|
||||
{ return m_available_karts.find(ident) == m_available_karts.end(); }
|
||||
// ------------------------------------------------------------------------
|
||||
void updateProgressBarText();
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void beforeAddingWidget() OVERRIDE;
|
||||
|
||||
public:
|
||||
/** \brief Implement per-frame callback. */
|
||||
|
Loading…
Reference in New Issue
Block a user