Improved buttons to have their size depend on text contents; made the 'enter' key trigger a PA_FIRE action
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4388 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
e8e8b1c876
commit
2dd0a904b6
@ -62,7 +62,7 @@
|
|||||||
|
|
||||||
<spacer height="10" width="10"/>
|
<spacer height="10" width="10"/>
|
||||||
|
|
||||||
<button id="apply_resolution" width="40%" height="30"
|
<button id="apply_resolution" height="35"
|
||||||
I18N="In the video settings menu" text="Apply video changes" />
|
I18N="In the video settings menu" text="Apply video changes" />
|
||||||
|
|
||||||
</box>
|
</box>
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
<list id="players" proportion="5" width="75%" align="center"/>
|
<list id="players" proportion="5" width="75%" align="center"/>
|
||||||
<spacer width="20" height="25"/>
|
<spacer width="20" height="25"/>
|
||||||
|
|
||||||
<button id="addplayer" x="20" width="35%" height="30"
|
<button id="addplayer" x="20" height="35"
|
||||||
I18N="In players configuration menu"
|
I18N="In players configuration menu"
|
||||||
text="Add Player" align="center"/>
|
text="Add Player" align="center"/>
|
||||||
<!--
|
<!--
|
||||||
|
@ -314,10 +314,10 @@ void Widget::readCoords(Widget* parent)
|
|||||||
{
|
{
|
||||||
IGUIFont* font = (m_title_font ? GUIEngine::getTitleFont() : GUIEngine::getFont());
|
IGUIFont* font = (m_title_font ? GUIEngine::getTitleFont() : GUIEngine::getFont());
|
||||||
core::dimension2d< u32 > dim = font->getDimension( m_text.c_str() );
|
core::dimension2d< u32 > dim = font->getDimension( m_text.c_str() );
|
||||||
label_w = dim.Width;
|
label_w = dim.Width + getWidthNeededAroundLabel();
|
||||||
// FIXME - won't work with multiline labels. thus, for now, when multiple
|
// FIXME - won't work with multiline labels. thus, for now, when multiple
|
||||||
// lines are required, we need to specify a height explicitely
|
// lines are required, we need to specify a height explicitely
|
||||||
label_h = dim.Height;
|
label_h = dim.Height + getHeightNeededAroundLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- read dimension
|
// ---- read dimension
|
||||||
|
@ -173,7 +173,15 @@ namespace GUIEngine
|
|||||||
bool m_player_focus[MAX_PLAYER_COUNT];
|
bool m_player_focus[MAX_PLAYER_COUNT];
|
||||||
|
|
||||||
bool m_reserve_id;
|
bool m_reserve_id;
|
||||||
|
|
||||||
|
/** When inferring widget size from its label length, this method will be called to
|
||||||
|
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
||||||
|
virtual int getWidthNeededAroundLabel() const { return 0; }
|
||||||
|
|
||||||
|
/** When inferring widget size from its label length, this method will be called to
|
||||||
|
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
||||||
|
virtual int getHeightNeededAroundLabel() const { return 0; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* This is set to NULL by default; set to something else in a widget to mean
|
* This is set to NULL by default; set to something else in a widget to mean
|
||||||
|
@ -30,6 +30,14 @@ namespace GUIEngine
|
|||||||
/** A text button widget. See guiengine/engine.hpp for a detailed overview */
|
/** A text button widget. See guiengine/engine.hpp for a detailed overview */
|
||||||
class ButtonWidget : public Widget
|
class ButtonWidget : public Widget
|
||||||
{
|
{
|
||||||
|
/** When inferring widget size from its label length, this method will be called to
|
||||||
|
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
||||||
|
virtual int getWidthNeededAroundLabel() const { return 35; }
|
||||||
|
|
||||||
|
/** When inferring widget size from its label length, this method will be called to
|
||||||
|
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
||||||
|
virtual int getHeightNeededAroundLabel() const { return 16; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ButtonWidget();
|
ButtonWidget();
|
||||||
virtual ~ButtonWidget() {}
|
virtual ~ButtonWidget() {}
|
||||||
|
@ -38,6 +38,15 @@ namespace GUIEngine
|
|||||||
EventPropagation transmitEvent(Widget* w, std::string& originator, const int playerID);
|
EventPropagation transmitEvent(Widget* w, std::string& originator, const int playerID);
|
||||||
EventPropagation rightPressed(const int playerID);
|
EventPropagation rightPressed(const int playerID);
|
||||||
EventPropagation leftPressed(const int playerID);
|
EventPropagation leftPressed(const int playerID);
|
||||||
|
|
||||||
|
/** When inferring widget size from its label length, this method will be called to
|
||||||
|
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
||||||
|
virtual int getWidthNeededAroundLabel() const { return 25; }
|
||||||
|
|
||||||
|
/** When inferring widget size from its label length, this method will be called to
|
||||||
|
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
||||||
|
virtual int getHeightNeededAroundLabel() const { return 16; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SpinnerWidget(const bool gauge=false);
|
SpinnerWidget(const bool gauge=false);
|
||||||
|
@ -30,6 +30,14 @@ namespace GUIEngine
|
|||||||
/** A text field widget. See guiengine/engine.hpp for a detailed overview */
|
/** A text field widget. See guiengine/engine.hpp for a detailed overview */
|
||||||
class TextBoxWidget : public Widget
|
class TextBoxWidget : public Widget
|
||||||
{
|
{
|
||||||
|
/** When inferring widget size from its label length, this method will be called to
|
||||||
|
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
||||||
|
virtual int getWidthNeededAroundLabel() const { return 10; }
|
||||||
|
|
||||||
|
/** When inferring widget size from its label length, this method will be called to
|
||||||
|
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
||||||
|
virtual int getHeightNeededAroundLabel() const { return 10; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TextBoxWidget();
|
TextBoxWidget();
|
||||||
~TextBoxWidget()
|
~TextBoxWidget()
|
||||||
|
@ -264,17 +264,18 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID, int btnID,
|
|||||||
bool action_found = m_device_manager->translateInput( type, deviceID, btnID, axisDirection, value, &player, &action);
|
bool action_found = m_device_manager->translateInput( type, deviceID, btnID, axisDirection, value, &player, &action);
|
||||||
|
|
||||||
// in menus, some keyboard keys are standard (before each player selected his device)
|
// in menus, some keyboard keys are standard (before each player selected his device)
|
||||||
// FIXME: should enter always work to accept for a player using keyboard?
|
// So if a key could not be mapped to any known binding, fall back to check the defaults.
|
||||||
if (!action_found && StateManager::get()->getGameState() != GUIEngine::GAME && type == Input::IT_KEYBOARD &&
|
if (!action_found && StateManager::get()->getGameState() != GUIEngine::GAME && type == Input::IT_KEYBOARD &&
|
||||||
m_mode == MENU && m_device_manager->getAssignMode() == NO_ASSIGN)
|
m_mode == MENU && m_device_manager->getAssignMode() == NO_ASSIGN)
|
||||||
{
|
{
|
||||||
action = PA_FIRST;
|
action = PA_FIRST;
|
||||||
|
|
||||||
if (btnID == KEY_UP) action = PA_ACCEL;
|
if (btnID == KEY_UP) action = PA_ACCEL;
|
||||||
else if (btnID == KEY_DOWN) action = PA_BRAKE;
|
else if (btnID == KEY_DOWN) action = PA_BRAKE;
|
||||||
else if (btnID == KEY_LEFT) action = PA_LEFT;
|
else if (btnID == KEY_LEFT) action = PA_LEFT;
|
||||||
else if (btnID == KEY_RIGHT) action = PA_RIGHT;
|
else if (btnID == KEY_RIGHT) action = PA_RIGHT;
|
||||||
else if (btnID == KEY_SPACE) action = PA_FIRE;
|
else if (btnID == KEY_SPACE) action = PA_FIRE;
|
||||||
|
else if (btnID == KEY_RETURN) action = PA_FIRE;
|
||||||
|
|
||||||
if (btnID == KEY_RETURN && GUIEngine::ModalDialog::isADialogActive())
|
if (btnID == KEY_RETURN && GUIEngine::ModalDialog::isADialogActive())
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user