Started implementing tweaks to multiplayer menus, which hopefully will make split-screen more user-friendly
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7505 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
073757f53e
commit
e9c036b957
@ -33,7 +33,7 @@
|
||||
<spacer width="25" height="25"/>
|
||||
<bubble proportion="1" height="100%"
|
||||
I18N="In the help menu"
|
||||
text="When input devices are configured, you are ready to play. Simply start a new race by selecting the race icon in the main menu. When it is time to choose a kart, each player can press on the 'fire' key of their gamepad or keyboard to join the game. Each player can use their input device to select their kart. The game continues when everyone selected their kart. Note that the mouse may not be used for this operation."/>
|
||||
text="When input devices are configured, you are ready to play. Select the 'multiplayer race' icon in the main menu. When it is time to choose a kart, each player can press on the 'fire' key of their gamepad or keyboard to join the game. Each player can use their input device to select their kart. The game continues when everyone selected their kart. Note that the mouse may not be used for this operation."/>
|
||||
</div>
|
||||
<spacer width="50" height="25" />
|
||||
</box>
|
||||
|
@ -6,14 +6,6 @@
|
||||
I18N="In the kart selection (player setup) screen"
|
||||
text="Choose a Kart"
|
||||
align="center" text_align="center" />
|
||||
|
||||
<!-- FIXME: don't hardcode height -->
|
||||
<box height="30" width="100%" layout="vertical-row">
|
||||
<label width="100%" proportion="1"
|
||||
I18N="In the kart selection (player setup) screen"
|
||||
text="(more players can join by pressing 'fire' now)"
|
||||
align="center" text_align="center" />
|
||||
</box>
|
||||
|
||||
<placeholder id="playerskarts" width="100%" proportion="4">
|
||||
<!-- Contents is added programatically -->
|
||||
|
BIN
data/gui/main_race_multi.png
Normal file
BIN
data/gui/main_race_multi.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
@ -6,8 +6,8 @@
|
||||
<buttonbar id="menu_toprow" proportion="3" width="75%" align="center">
|
||||
<icon-button id="new" width="128" height="128" icon="gui/main_race.png"
|
||||
I18N="Main menu button" text="Race"/>
|
||||
<icon-button id="network" width="128" height="128" icon="gui/main_options.png"
|
||||
I18N="Main menu button" text="DEBUG"/>
|
||||
<icon-button id="multiplayer" width="128" height="128" icon="gui/main_race_multi.png"
|
||||
I18N="Main menu button" text="Multiplayer Race"/>
|
||||
<icon-button id="challenges" width="128" height="128"
|
||||
icon="gui/challenge.png"
|
||||
I18N="Main menu button" text="Challenges"/>
|
||||
|
@ -404,6 +404,8 @@ namespace GUIEngine
|
||||
/** Get whether this object is allowed to receive focus */
|
||||
bool isFocusable() const { return m_focusable; }
|
||||
|
||||
void setFocusable(bool f) { m_focusable = f; }
|
||||
|
||||
/**
|
||||
* \}
|
||||
*/
|
||||
|
@ -49,7 +49,7 @@ void BubbleWidget::add()
|
||||
|
||||
IGUIStaticText* irrwidget;
|
||||
irrwidget = GUIEngine::getGUIEnv()->addStaticText(message.c_str(), m_shrinked_size,
|
||||
false, true /* word wrap */, m_parent, getNewID());
|
||||
false, true /* word wrap */, m_parent, (m_focusable ? getNewID() : getNewNoFocusID()));
|
||||
|
||||
// find expanded bubble size
|
||||
int text_height = irrwidget->getTextHeight();
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "guiengine/widgets/bubble_widget.hpp"
|
||||
#include "guiengine/widgets/dynamic_ribbon_widget.hpp"
|
||||
#include "guiengine/widgets/label_widget.hpp"
|
||||
#include "guiengine/widgets/model_view_widget.hpp"
|
||||
@ -843,6 +844,7 @@ public:
|
||||
KartSelectionScreen::KartSelectionScreen() : Screen("karts.stkgui")
|
||||
{
|
||||
m_removed_widget = NULL;
|
||||
m_multiplayer_message = NULL;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -852,6 +854,7 @@ void KartSelectionScreen::loadedFromFile()
|
||||
g_dispatcher = new FocusDispatcher(this);
|
||||
m_first_widget = g_dispatcher;
|
||||
m_player_confirmed = false;
|
||||
m_multiplayer_message = NULL;
|
||||
|
||||
// Dynamically add tabs
|
||||
RibbonWidget* tabs = getWidget<RibbonWidget>("kartgroups");
|
||||
@ -983,6 +986,13 @@ void KartSelectionScreen::tearDown()
|
||||
m_removed_widget = NULL;
|
||||
}
|
||||
|
||||
if (m_multiplayer_message != NULL)
|
||||
{
|
||||
manualRemoveWidget(m_multiplayer_message);
|
||||
delete m_multiplayer_message;
|
||||
m_multiplayer_message = NULL;
|
||||
}
|
||||
|
||||
Screen::tearDown();
|
||||
m_kart_widgets.clearAndDeleteAll();
|
||||
} // tearDown
|
||||
@ -1000,7 +1010,8 @@ void KartSelectionScreen::unloaded()
|
||||
bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)
|
||||
{
|
||||
if (UserConfigParams::m_verbosity>=5) std::cout << "[KartSelectionScreen] playerJoin() invoked\n";
|
||||
|
||||
if (!m_multiplayer && !firstPlayer) return false;
|
||||
|
||||
assert (g_dispatcher != NULL);
|
||||
|
||||
DynamicRibbonWidget* w = getWidget<DynamicRibbonWidget>("karts");
|
||||
@ -1045,6 +1056,17 @@ bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Remove multiplayer message
|
||||
if (m_multiplayer_message != NULL)
|
||||
{
|
||||
manualRemoveWidget(m_multiplayer_message);
|
||||
m_multiplayer_message->getIrrlichtElement()->remove();
|
||||
m_multiplayer_message->elementRemoved();
|
||||
delete m_multiplayer_message;
|
||||
m_multiplayer_message = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const int new_player_id = StateManager::get()->createActivePlayer( profileToUse, device );
|
||||
@ -1061,11 +1083,33 @@ bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)
|
||||
// ---- Divide screen space among all karts
|
||||
const int amount = m_kart_widgets.size();
|
||||
Widget* fullarea = getWidget("playerskarts");
|
||||
const int splitWidth = fullarea->m_w / amount;
|
||||
|
||||
for (int n=0; n<amount; n++)
|
||||
// in this special case, leave room for a message on the right
|
||||
if (m_multiplayer && firstPlayer)
|
||||
{
|
||||
m_kart_widgets[n].move( fullarea->m_x + splitWidth*n, fullarea->m_y, splitWidth, fullarea->m_h );
|
||||
const int splitWidth = fullarea->m_w / 2;
|
||||
|
||||
m_kart_widgets[0].move( fullarea->m_x, fullarea->m_y, splitWidth, fullarea->m_h );
|
||||
|
||||
m_multiplayer_message = new BubbleWidget();
|
||||
m_multiplayer_message->m_properties[PROP_TEXT_ALIGN] = "center";
|
||||
m_multiplayer_message->setText( _("Everyone:\nPress 'Fire' now to join the game!") );
|
||||
m_multiplayer_message->m_x = fullarea->m_x + splitWidth + splitWidth*0.2f;
|
||||
m_multiplayer_message->m_y = fullarea->m_y + fullarea->m_h*0.3f;
|
||||
m_multiplayer_message->m_w = splitWidth*0.6f;
|
||||
m_multiplayer_message->m_h = fullarea->m_h*0.6f;
|
||||
m_multiplayer_message->setFocusable(false);
|
||||
m_multiplayer_message->add();
|
||||
manualAddWidget(m_multiplayer_message);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int splitWidth = fullarea->m_w / amount;
|
||||
|
||||
for (int n=0; n<amount; n++)
|
||||
{
|
||||
m_kart_widgets[n].move( fullarea->m_x + splitWidth*n, fullarea->m_y, splitWidth, fullarea->m_h );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1370,6 +1414,13 @@ void KartSelectionScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void KartSelectionScreen::setMultiplayer(bool multiplayer)
|
||||
{
|
||||
m_multiplayer = multiplayer;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
namespace GUIEngine
|
||||
{
|
||||
class Widget;
|
||||
class BubbleWidget;
|
||||
}
|
||||
class InputDevice;
|
||||
class PlayerKartWidget;
|
||||
@ -47,6 +48,8 @@ class KartSelectionScreen : public GUIEngine::Screen, public GUIEngine::ScreenSi
|
||||
friend class GUIEngine::ScreenSingleton<KartSelectionScreen>;
|
||||
friend class PlayerKartWidget;
|
||||
|
||||
bool m_multiplayer;
|
||||
|
||||
KartSelectionScreen();
|
||||
|
||||
/** Stores whether any player confirmed their choice; then, some things are "frozen", for instance
|
||||
@ -56,6 +59,9 @@ class KartSelectionScreen : public GUIEngine::Screen, public GUIEngine::ScreenSi
|
||||
|
||||
PlayerKartWidget* m_removed_widget;
|
||||
|
||||
/** Message shown in multiplayer mode */
|
||||
GUIEngine::BubbleWidget* m_multiplayer_message;
|
||||
|
||||
/** Called when all players selected their kart */
|
||||
void allPlayersDone();
|
||||
|
||||
@ -82,6 +88,8 @@ public:
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void loadedFromFile();
|
||||
|
||||
void setMultiplayer(bool multiplayer);
|
||||
|
||||
/** \brief Called when a player hits 'fire'/'select' on his device to join the game */
|
||||
bool playerJoin(InputDevice* device, bool firstPlayer);
|
||||
|
||||
|
@ -298,7 +298,15 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, cons
|
||||
}
|
||||
else if (selection == "new")
|
||||
{
|
||||
StateManager::get()->pushScreen( KartSelectionScreen::getInstance() );
|
||||
KartSelectionScreen* s = KartSelectionScreen::getInstance();
|
||||
s->setMultiplayer(false);
|
||||
StateManager::get()->pushScreen( s );
|
||||
}
|
||||
else if (selection == "multiplayer")
|
||||
{
|
||||
KartSelectionScreen* s = KartSelectionScreen::getInstance();
|
||||
s->setMultiplayer(true);
|
||||
StateManager::get()->pushScreen( s );
|
||||
}
|
||||
else if (selection == "options")
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user