Add resizing code for add device dialog
This commit is contained in:
parent
f73e56c204
commit
31239615ef
@ -44,6 +44,79 @@ AddDeviceDialog::AddDeviceDialog() : ModalDialog(0.90f, 0.80f)
|
|||||||
{
|
{
|
||||||
doInit();
|
doInit();
|
||||||
|
|
||||||
|
core::stringw msg =
|
||||||
|
_("New gamepads and joysticks will automatically appear in the list "
|
||||||
|
"when you connect them to this device.\n\nTo add a "
|
||||||
|
"keyboard config, you can use the button below, HOWEVER please "
|
||||||
|
"note that most keyboards only support a limited amount of "
|
||||||
|
"simultaneous keypresses and are thus inappropriate for multiplayer "
|
||||||
|
"gameplay. (You can, however, connect multiple keyboards to this "
|
||||||
|
"device. Remember that everyone still needs different keybindings "
|
||||||
|
"in this case.)");
|
||||||
|
m_text =
|
||||||
|
GUIEngine::getGUIEnv()->addStaticText(msg,
|
||||||
|
core::rect<s32>(0, 0, 1, 1),
|
||||||
|
/*border*/false ,
|
||||||
|
/*word wrap*/true,
|
||||||
|
m_irrlicht_window);
|
||||||
|
m_text->setTabStop(false);
|
||||||
|
m_text->setText(msg);
|
||||||
|
|
||||||
|
#ifdef ENABLE_WIIUSE
|
||||||
|
{
|
||||||
|
ButtonWidget* widget = new ButtonWidget();
|
||||||
|
widget->m_properties[PROP_ID] = "addwiimote";
|
||||||
|
|
||||||
|
//I18N: In the 'add new input device' dialog
|
||||||
|
widget->setText( _("Add Wiimote") );
|
||||||
|
|
||||||
|
widget->m_x = 0;
|
||||||
|
widget->m_y = 0;
|
||||||
|
widget->m_w = 1;
|
||||||
|
widget->m_h = 1;
|
||||||
|
widget->setParent(m_irrlicht_window);
|
||||||
|
m_widgets.push_back(widget);
|
||||||
|
widget->add();
|
||||||
|
}
|
||||||
|
#endif // ENABLE_WIIUSE
|
||||||
|
|
||||||
|
{
|
||||||
|
ButtonWidget* widget = new ButtonWidget();
|
||||||
|
widget->m_properties[PROP_ID] = "addkeyboard";
|
||||||
|
|
||||||
|
//I18N: In the 'add new input device' dialog
|
||||||
|
widget->setText( _("Add Keyboard Configuration") );
|
||||||
|
|
||||||
|
widget->m_x = 0;
|
||||||
|
widget->m_y = 0;
|
||||||
|
widget->m_w = 1;
|
||||||
|
widget->m_h = 1;
|
||||||
|
widget->setParent(m_irrlicht_window);
|
||||||
|
m_widgets.push_back(widget);
|
||||||
|
widget->add();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
ButtonWidget* widget = new ButtonWidget();
|
||||||
|
widget->m_properties[PROP_ID] = "cancel";
|
||||||
|
widget->setText( _("Cancel") );
|
||||||
|
|
||||||
|
widget->m_x = 0;
|
||||||
|
widget->m_y = 0;
|
||||||
|
widget->m_w = 1;
|
||||||
|
widget->m_h = 1;
|
||||||
|
widget->setParent(m_irrlicht_window);
|
||||||
|
m_widgets.push_back(widget);
|
||||||
|
widget->add();
|
||||||
|
|
||||||
|
widget->setFocusForPlayer( PLAYER_ID_GAME_MASTER );
|
||||||
|
|
||||||
|
}
|
||||||
|
configDialog();
|
||||||
|
} // AddDeviceDialog
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void AddDeviceDialog::configDialog()
|
||||||
|
{
|
||||||
ScalableFont* font = GUIEngine::getFont();
|
ScalableFont* font = GUIEngine::getFont();
|
||||||
const int textHeight = GUIEngine::getFontHeight();
|
const int textHeight = GUIEngine::getFontHeight();
|
||||||
const int buttonHeight = textHeight + 10;
|
const int buttonHeight = textHeight + 10;
|
||||||
@ -59,32 +132,12 @@ AddDeviceDialog::AddDeviceDialog() : ModalDialog(0.90f, 0.80f)
|
|||||||
int cur_y = y_bottom;
|
int cur_y = y_bottom;
|
||||||
|
|
||||||
core::rect<s32> text_area( 15, 15, m_area.getWidth()-15, y_bottom-15 );
|
core::rect<s32> text_area( 15, 15, m_area.getWidth()-15, y_bottom-15 );
|
||||||
|
m_text->setRelativePosition(text_area);
|
||||||
|
|
||||||
core::stringw msg =
|
auto itr = m_widgets.begin();
|
||||||
_("New gamepads and joysticks will automatically appear in the list "
|
|
||||||
"when you connect them to this device.\n\nTo add a "
|
|
||||||
"keyboard config, you can use the button below, HOWEVER please "
|
|
||||||
"note that most keyboards only support a limited amount of "
|
|
||||||
"simultaneous keypresses and are thus inappropriate for multiplayer "
|
|
||||||
"gameplay. (You can, however, connect multiple keyboards to this "
|
|
||||||
"device. Remember that everyone still needs different keybindings "
|
|
||||||
"in this case.)");
|
|
||||||
IGUIStaticText* b =
|
|
||||||
GUIEngine::getGUIEnv()->addStaticText(msg,
|
|
||||||
text_area,
|
|
||||||
/*border*/false ,
|
|
||||||
/*word wrap*/true,
|
|
||||||
m_irrlicht_window);
|
|
||||||
b->setTabStop(false);
|
|
||||||
b->setText(msg);
|
|
||||||
|
|
||||||
#ifdef ENABLE_WIIUSE
|
#ifdef ENABLE_WIIUSE
|
||||||
{
|
{
|
||||||
ButtonWidget* widget = new ButtonWidget();
|
Widget* widget = *itr;
|
||||||
widget->m_properties[PROP_ID] = "addwiimote";
|
|
||||||
|
|
||||||
//I18N: In the 'add new input device' dialog
|
|
||||||
widget->setText( _("Add Wiimote") );
|
|
||||||
|
|
||||||
const int textWidth =
|
const int textWidth =
|
||||||
font->getDimension( widget->getText().c_str() ).Width + 40;
|
font->getDimension( widget->getText().c_str() ).Width + 40;
|
||||||
@ -93,19 +146,14 @@ AddDeviceDialog::AddDeviceDialog() : ModalDialog(0.90f, 0.80f)
|
|||||||
widget->m_y = cur_y;
|
widget->m_y = cur_y;
|
||||||
widget->m_w = textWidth;
|
widget->m_w = textWidth;
|
||||||
widget->m_h = buttonHeight;
|
widget->m_h = buttonHeight;
|
||||||
widget->setParent(m_irrlicht_window);
|
widget->resize();
|
||||||
m_widgets.push_back(widget);
|
itr++;
|
||||||
widget->add();
|
|
||||||
cur_y += y_stride;
|
cur_y += y_stride;
|
||||||
}
|
}
|
||||||
#endif // ENABLE_WIIUSE
|
#endif // ENABLE_WIIUSE
|
||||||
|
|
||||||
{
|
{
|
||||||
ButtonWidget* widget = new ButtonWidget();
|
Widget* widget = *itr;
|
||||||
widget->m_properties[PROP_ID] = "addkeyboard";
|
|
||||||
|
|
||||||
//I18N: In the 'add new input device' dialog
|
|
||||||
widget->setText( _("Add Keyboard Configuration") );
|
|
||||||
|
|
||||||
const int textWidth =
|
const int textWidth =
|
||||||
font->getDimension( widget->getText().c_str() ).Width + 40;
|
font->getDimension( widget->getText().c_str() ).Width + 40;
|
||||||
@ -114,15 +162,12 @@ AddDeviceDialog::AddDeviceDialog() : ModalDialog(0.90f, 0.80f)
|
|||||||
widget->m_y = cur_y;
|
widget->m_y = cur_y;
|
||||||
widget->m_w = textWidth;
|
widget->m_w = textWidth;
|
||||||
widget->m_h = buttonHeight;
|
widget->m_h = buttonHeight;
|
||||||
widget->setParent(m_irrlicht_window);
|
widget->resize();
|
||||||
m_widgets.push_back(widget);
|
itr++;
|
||||||
widget->add();
|
|
||||||
cur_y += y_stride;
|
cur_y += y_stride;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ButtonWidget* widget = new ButtonWidget();
|
Widget* widget = *itr;
|
||||||
widget->m_properties[PROP_ID] = "cancel";
|
|
||||||
widget->setText( _("Cancel") );
|
|
||||||
|
|
||||||
const int textWidth =
|
const int textWidth =
|
||||||
font->getDimension( widget->getText().c_str() ).Width + 40;
|
font->getDimension( widget->getText().c_str() ).Width + 40;
|
||||||
@ -131,24 +176,10 @@ AddDeviceDialog::AddDeviceDialog() : ModalDialog(0.90f, 0.80f)
|
|||||||
widget->m_y = cur_y;
|
widget->m_y = cur_y;
|
||||||
widget->m_w = textWidth;
|
widget->m_w = textWidth;
|
||||||
widget->m_h = buttonHeight;
|
widget->m_h = buttonHeight;
|
||||||
widget->setParent(m_irrlicht_window);
|
widget->resize();
|
||||||
m_widgets.push_back(widget);
|
|
||||||
widget->add();
|
|
||||||
cur_y += y_stride;
|
cur_y += y_stride;
|
||||||
|
|
||||||
widget->setFocusForPlayer( PLAYER_ID_GAME_MASTER );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} // configDialog
|
||||||
} // AddDeviceDialog
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void AddDeviceDialog::onEnterPressedInternal()
|
|
||||||
{
|
|
||||||
} // onEnterPressedInternal
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
GUIEngine::EventPropagation AddDeviceDialog::processEvent
|
GUIEngine::EventPropagation AddDeviceDialog::processEvent
|
||||||
|
@ -21,6 +21,11 @@
|
|||||||
|
|
||||||
#include "guiengine/modaldialog.hpp"
|
#include "guiengine/modaldialog.hpp"
|
||||||
|
|
||||||
|
namespace irr
|
||||||
|
{
|
||||||
|
namespace gui { class IGUIStaticText; }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Dialog that warns the user about the potential problems of
|
* \brief Dialog that warns the user about the potential problems of
|
||||||
* creating multiple keyboard configs.
|
* creating multiple keyboard configs.
|
||||||
@ -28,12 +33,19 @@
|
|||||||
*/
|
*/
|
||||||
class AddDeviceDialog : public GUIEngine::ModalDialog
|
class AddDeviceDialog : public GUIEngine::ModalDialog
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
irr::gui::IGUIStaticText* m_text;
|
||||||
|
void configDialog();
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AddDeviceDialog();
|
AddDeviceDialog();
|
||||||
|
|
||||||
void onEnterPressedInternal();
|
|
||||||
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
|
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
|
||||||
|
void onResize()
|
||||||
|
{
|
||||||
|
GUIEngine::ModalDialog::onResize();
|
||||||
|
configDialog();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user