Adjust based on auria's feedback

This commit is contained in:
Benau 2018-03-20 14:56:17 +08:00
parent dd3a544834
commit 4379244f3e
6 changed files with 45 additions and 32 deletions

View File

@ -25,7 +25,8 @@
<spacer height="20" width="50"/> <spacer height="20" width="50"/>
<div width="80%" align="center" layout="vertical-row" height="fit" > <div width="80%" align="center" layout="vertical-row" height="fit" >
<div width="100%" height="fit" layout="horizontal-row" > <div width="100%" height="fit" layout="horizontal-row" >
<label id="error-message" proportion="1" text_align="left"/> <label id="message-label" proportion="1" text_align="left" I18N="Splitscreen player in network"
text="Press the 'All players ready' button after the player list is ready."/>
</div> </div>
</div> </div>
@ -33,11 +34,13 @@
<buttonbar id="options" width="90%" height="20%" align="center"> <buttonbar id="options" width="90%" height="20%" align="center">
<icon-button id="add" width="64" height="64" icon="gui/blue_plus.png" <icon-button id="add" width="64" height="64" icon="gui/blue_plus.png"
I18N="Splitscreen player in network" text="Add" label_location="bottom"/> I18N="Splitscreen player in network" text="Add player" label_location="bottom"/>
<icon-button id="connect" width="64" height="64" icon="gui/green_check.png" <icon-button id="connect" width="64" height="64" icon="gui/green_check.png"
I18N="Splitscreen player in network" text="Connect" label_location="bottom"/> I18N="Splitscreen player in network" text="All players ready" label_location="bottom"/>
<icon-button id="cancel" width="64" height="64" icon="gui/main_quit.png" <icon-button id="cancel" width="64" height="64" icon="gui/main_quit.png"
I18N="Splitscreen player in network" text="Cancel" label_location="bottom"/> I18N="Splitscreen player in network" text="Cancel" label_location="bottom"/>
<icon-button id="reset" width="64" height="64" icon="gui/remove.png"
I18N="Splitscreen player in network" text="Clear added player" label_location="bottom"/>
</buttonbar> </buttonbar>
</div> </div>
</stkgui> </stkgui>

View File

@ -714,6 +714,9 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID,
{ {
if (NetworkConfig::get()->isAddingNetworkPlayers()) if (NetworkConfig::get()->isAddingNetworkPlayers())
{ {
// Ignore release event
if (value == 0)
return;
InputDevice *device = NULL; InputDevice *device = NULL;
if (type == Input::IT_KEYBOARD) if (type == Input::IT_KEYBOARD)
{ {
@ -791,7 +794,7 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID,
// Prevent null pointer crash // Prevent null pointer crash
return; return;
} }
Log::info("","%s",StringUtils::wideToUtf8(player->getProfile()->getName()).c_str());
// Find the corresponding PlayerKart from our ActivePlayer instance // Find the corresponding PlayerKart from our ActivePlayer instance
AbstractKart* pk = player->getKart(); AbstractKart* pk = player->getKart();

View File

@ -32,18 +32,6 @@
using namespace GUIEngine; using namespace GUIEngine;
using namespace irr; using namespace irr;
using namespace irr::gui;
using namespace Online;
// ----------------------------------------------------------------------------
SplitscreenPlayerDialog::~SplitscreenPlayerDialog()
{
if (!m_connect_now)
{
input_manager->getDeviceManager()->setAssignMode(DETECT_NEW);
input_manager->getDeviceManager()->mapFireToSelect(true);
}
} // ~SplitscreenPlayerDialog
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void SplitscreenPlayerDialog::beforeAddingWidgets() void SplitscreenPlayerDialog::beforeAddingWidgets()
@ -52,7 +40,7 @@ void SplitscreenPlayerDialog::beforeAddingWidgets()
for (unsigned i = 0; i < PlayerManager::get()->getNumPlayers(); i++) for (unsigned i = 0; i < PlayerManager::get()->getNumPlayers(); i++)
m_profiles->addLabel(PlayerManager::get()->getPlayer(i)->getName()); m_profiles->addLabel(PlayerManager::get()->getPlayer(i)->getName());
m_error_message = getWidget<LabelWidget>("error-message"); m_message = getWidget<LabelWidget>("message-label");
m_handicap = getWidget<CheckBoxWidget>("handicap"); m_handicap = getWidget<CheckBoxWidget>("handicap");
m_handicap->setState(false); m_handicap->setState(false);
@ -67,6 +55,8 @@ void SplitscreenPlayerDialog::beforeAddingWidgets()
assert(m_connect != NULL); assert(m_connect != NULL);
m_cancel = getWidget<IconButtonWidget>("cancel"); m_cancel = getWidget<IconButtonWidget>("cancel");
assert(m_cancel != NULL); assert(m_cancel != NULL);
m_reset = getWidget<IconButtonWidget>("reset");
assert(m_reset != NULL);
input_manager->getDeviceManager()->setAssignMode(NO_ASSIGN); input_manager->getDeviceManager()->setAssignMode(NO_ASSIGN);
input_manager->getDeviceManager()->mapFireToSelect(false); input_manager->getDeviceManager()->mapFireToSelect(false);
@ -97,8 +87,9 @@ GUIEngine::EventPropagation
else else
{ {
//I18N: in splitscreen player dialog for network game //I18N: in splitscreen player dialog for network game
m_error_message->setErrorColor(); m_message->setErrorColor();
m_error_message->setText(_("Player already exists."), false); m_message->setText(_("Player or input device already exists."),
false);
} }
return GUIEngine::EVENT_BLOCK; return GUIEngine::EVENT_BLOCK;
} }
@ -108,14 +99,13 @@ GUIEngine::EventPropagation
{ {
NetworkConfig::get()->doneAddingNetworkPlayers(); NetworkConfig::get()->doneAddingNetworkPlayers();
NetworkingLobby::getInstance()->finishAddingPlayers(); NetworkingLobby::getInstance()->finishAddingPlayers();
m_connect_now = true;
m_self_destroy = true; m_self_destroy = true;
return GUIEngine::EVENT_BLOCK; return GUIEngine::EVENT_BLOCK;
} }
//I18N: in splitscreen player dialog for network game //I18N: in splitscreen player dialog for network game
m_error_message->setErrorColor(); m_message->setErrorColor();
m_error_message->setText(_("No player available to connect."), m_message->setText(
false); _("No player available for connecting to server."), false);
return GUIEngine::EVENT_BLOCK; return GUIEngine::EVENT_BLOCK;
} }
else if(selection == m_cancel->m_properties[PROP_ID]) else if(selection == m_cancel->m_properties[PROP_ID])
@ -123,6 +113,13 @@ GUIEngine::EventPropagation
m_self_destroy = true; m_self_destroy = true;
return GUIEngine::EVENT_BLOCK; return GUIEngine::EVENT_BLOCK;
} }
else if(selection == m_reset->m_properties[PROP_ID])
{
NetworkConfig::get()->cleanNetworkPlayers();
NetworkingLobby::getInstance()->cleanAddedPlayers();
m_self_destroy = true;
return GUIEngine::EVENT_BLOCK;
}
} }
return GUIEngine::EVENT_LET; return GUIEngine::EVENT_LET;
} // processEvent } // processEvent

View File

@ -38,9 +38,7 @@ private:
bool m_self_destroy; bool m_self_destroy;
bool m_connect_now; GUIEngine::LabelWidget* m_message;
GUIEngine::LabelWidget* m_error_message;
GUIEngine::SpinnerWidget* m_profiles; GUIEngine::SpinnerWidget* m_profiles;
@ -54,15 +52,16 @@ private:
GUIEngine::IconButtonWidget* m_cancel; GUIEngine::IconButtonWidget* m_cancel;
GUIEngine::IconButtonWidget* m_reset;
public: public:
SplitscreenPlayerDialog(InputDevice* device) SplitscreenPlayerDialog(InputDevice* device)
: ModalDialog(0.8f,0.8f), m_device(device), m_self_destroy(false), : ModalDialog(0.8f,0.8f), m_device(device), m_self_destroy(false)
m_connect_now(false)
{ {
loadFromFile("online/splitscreen_player_dialog.stkgui"); loadFromFile("online/splitscreen_player_dialog.stkgui");
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
~SplitscreenPlayerDialog(); ~SplitscreenPlayerDialog() {}
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
virtual void beforeAddingWidgets(); virtual void beforeAddingWidgets();
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------

View File

@ -130,8 +130,6 @@ void NetworkingLobby::init()
if (NetworkConfig::get()->getNetworkPlayers().empty()) if (NetworkConfig::get()->getNetworkPlayers().empty())
{ {
m_state = LS_ADD_PLAYERS; m_state = LS_ADD_PLAYERS;
input_manager->getDeviceManager()->mapFireToSelect(true);
input_manager->getDeviceManager()->setAssignMode(DETECT_NEW);
} }
else if (NetworkConfig::get()->isClient()) else if (NetworkConfig::get()->isClient())
{ {
@ -222,6 +220,11 @@ void NetworkingLobby::onUpdate(float delta)
"join the game"), true); "join the game"), true);
m_start_button->setVisible(false); m_start_button->setVisible(false);
m_exit_widget->setVisible(false); m_exit_widget->setVisible(false);
if (!GUIEngine::ModalDialog::isADialogActive())
{
input_manager->getDeviceManager()->setAssignMode(DETECT_NEW);
input_manager->getDeviceManager()->mapFireToSelect(true);
}
return; return;
} }
@ -345,7 +348,6 @@ void NetworkingLobby::tearDown()
if (!NetworkConfig::get()->isClient()) if (!NetworkConfig::get()->isClient())
return; return;
input_manager->getDeviceManager()->mapFireToSelect(false); input_manager->getDeviceManager()->mapFireToSelect(false);
assert(!NetworkConfig::get()->isAddingNetworkPlayers());
StateManager::get()->resetActivePlayers(); StateManager::get()->resetActivePlayers();
for (auto& p : NetworkConfig::get()->getNetworkPlayers()) for (auto& p : NetworkConfig::get()->getNetworkPlayers())
{ {
@ -416,3 +418,11 @@ void NetworkingLobby::finishAddingPlayers()
getWidget("send")->setActive(true); getWidget("send")->setActive(true);
} }
} // finishAddingPlayers } // finishAddingPlayers
// ----------------------------------------------------------------------------
void NetworkingLobby::cleanAddedPlayers()
{
if (!m_player_list)
return;
m_player_list->clear();
} // cleanAddedPlayers

View File

@ -117,6 +117,7 @@ public:
uint32_t/*online id*/, core::stringw/*player name*/, uint32_t/*online id*/, core::stringw/*player name*/,
int/*icon id*/> >& p); int/*icon id*/> >& p);
void addSplitscreenPlayer(irr::core::stringw name); void addSplitscreenPlayer(irr::core::stringw name);
void cleanAddedPlayers();
}; // class NetworkingLobby }; // class NetworkingLobby