Fix input config screen, since the list widget was improved it didn't display quite right
This commit is contained in:
parent
daa84aabef
commit
06e4cbb9be
@ -43,6 +43,7 @@ ListWidget::ListWidget() : Widget(WTYPE_LIST)
|
|||||||
m_sort_desc = false;
|
m_sort_desc = false;
|
||||||
m_sort_default = true;
|
m_sort_default = true;
|
||||||
m_sort_col = 0;
|
m_sort_col = 0;
|
||||||
|
m_sortable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -270,9 +271,11 @@ std::string ListWidget::getSelectionInternalName()
|
|||||||
|
|
||||||
CGUISTKListBox* list = getIrrlichtElement<CGUISTKListBox>();
|
CGUISTKListBox* list = getIrrlichtElement<CGUISTKListBox>();
|
||||||
assert(list != NULL);
|
assert(list != NULL);
|
||||||
if (getSelectionID() == -1 || (getSelectionID() >= (int)list->getItemCount()))
|
int selectionID = getSelectionID();
|
||||||
|
if (selectionID == -1 || selectionID >= (int)list->getItemCount())
|
||||||
return "";
|
return "";
|
||||||
return list->getItem(getSelectionID()).m_internal_name;
|
CGUISTKListBox::ListItem& item = list->getItem(selectionID);
|
||||||
|
return item.m_internal_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -418,6 +421,8 @@ EventPropagation ListWidget::transmitEvent(Widget* w,
|
|||||||
|
|
||||||
if (originator.find(m_properties[PROP_ID] + "_column_") != std::string::npos)
|
if (originator.find(m_properties[PROP_ID] + "_column_") != std::string::npos)
|
||||||
{
|
{
|
||||||
|
if (!m_sortable) return EVENT_BLOCK;
|
||||||
|
|
||||||
if (m_sort_col != originator[(m_properties[PROP_ID] + "_column_").size()] - '0')
|
if (m_sort_col != originator[(m_properties[PROP_ID] + "_column_").size()] - '0')
|
||||||
{
|
{
|
||||||
m_sort_desc = false;
|
m_sort_desc = false;
|
||||||
|
@ -87,6 +87,8 @@ namespace GUIEngine
|
|||||||
|
|
||||||
IListWidgetHeaderListener* m_listener;
|
IListWidgetHeaderListener* m_listener;
|
||||||
|
|
||||||
|
bool m_sortable;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef irr::gui::CGUISTKListBox::ListItem ListItem;
|
typedef irr::gui::CGUISTKListBox::ListItem ListItem;
|
||||||
typedef ListItem::ListCell ListCell;
|
typedef ListItem::ListCell ListCell;
|
||||||
@ -240,6 +242,8 @@ namespace GUIEngine
|
|||||||
void addColumn(irr::core::stringw col, int proportion=1) { m_header.push_back( Column(col, proportion) ); }
|
void addColumn(irr::core::stringw col, int proportion=1) { m_header.push_back( Column(col, proportion) ); }
|
||||||
|
|
||||||
void clearColumns() { m_header.clear(); }
|
void clearColumns() { m_header.clear(); }
|
||||||
|
|
||||||
|
void setSortable(bool sortable) { m_sortable = sortable; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +61,19 @@ void OptionsScreenInput2::loadedFromFile()
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void OptionsScreenInput2::beforeAddingWidget()
|
||||||
|
{
|
||||||
|
GUIEngine::ListWidget* w_list =
|
||||||
|
getWidget<GUIEngine::ListWidget>("actions");
|
||||||
|
assert(w_list != NULL);
|
||||||
|
w_list->clearColumns();
|
||||||
|
w_list->addColumn(_("Action"), 1);
|
||||||
|
w_list->addColumn(_("Key binding"), 1);
|
||||||
|
w_list->setSortable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void OptionsScreenInput2::init()
|
void OptionsScreenInput2::init()
|
||||||
{
|
{
|
||||||
Screen::init();
|
Screen::init();
|
||||||
@ -127,27 +140,27 @@ void OptionsScreenInput2::init()
|
|||||||
// their actualy contents will be adapted as needed after
|
// their actualy contents will be adapted as needed after
|
||||||
|
|
||||||
//I18N: Key binding section
|
//I18N: Key binding section
|
||||||
actions->addItem("game_keys_section", _("Game Keys") );
|
addListItemSubheader(actions, "game_keys_section", _("Game Keys"));
|
||||||
actions->addItem(KartActionStrings[PA_STEER_LEFT], L"" );
|
addListItem(actions, PA_STEER_LEFT);
|
||||||
actions->addItem(KartActionStrings[PA_STEER_RIGHT], L"" );
|
addListItem(actions, PA_STEER_RIGHT);
|
||||||
actions->addItem(KartActionStrings[PA_ACCEL], L"" );
|
addListItem(actions, PA_ACCEL);
|
||||||
actions->addItem(KartActionStrings[PA_BRAKE], L"" );
|
addListItem(actions, PA_BRAKE);
|
||||||
actions->addItem(KartActionStrings[PA_FIRE], L"" );
|
addListItem(actions, PA_FIRE);
|
||||||
actions->addItem(KartActionStrings[PA_NITRO], L"" );
|
addListItem(actions, PA_NITRO);
|
||||||
actions->addItem(KartActionStrings[PA_DRIFT], L"" );
|
addListItem(actions, PA_DRIFT);
|
||||||
actions->addItem(KartActionStrings[PA_LOOK_BACK], L"" );
|
addListItem(actions, PA_LOOK_BACK);
|
||||||
actions->addItem(KartActionStrings[PA_RESCUE], L"" );
|
addListItem(actions, PA_RESCUE);
|
||||||
actions->addItem(KartActionStrings[PA_PAUSE_RACE], L"" );
|
addListItem(actions, PA_PAUSE_RACE);
|
||||||
|
|
||||||
|
|
||||||
//I18N: Key binding section
|
//I18N: Key binding section
|
||||||
actions->addItem("menu_keys_section", _("Menu Keys") );
|
addListItemSubheader(actions, "menu_keys_section", _("Menu Keys"));
|
||||||
actions->addItem(KartActionStrings[PA_MENU_UP], L"" );
|
addListItem(actions, PA_MENU_UP);
|
||||||
actions->addItem(KartActionStrings[PA_MENU_DOWN], L"" );
|
addListItem(actions, PA_MENU_DOWN);
|
||||||
actions->addItem(KartActionStrings[PA_MENU_LEFT], L"" );
|
addListItem(actions, PA_MENU_LEFT);
|
||||||
actions->addItem(KartActionStrings[PA_MENU_RIGHT], L"" );
|
addListItem(actions, PA_MENU_RIGHT);
|
||||||
actions->addItem(KartActionStrings[PA_MENU_SELECT], L"");
|
addListItem(actions, PA_MENU_SELECT);
|
||||||
actions->addItem(KartActionStrings[PA_MENU_CANCEL], L"" );
|
addListItem(actions, PA_MENU_CANCEL);
|
||||||
|
|
||||||
updateInputButtons();
|
updateInputButtons();
|
||||||
|
|
||||||
@ -163,16 +176,36 @@ void OptionsScreenInput2::init()
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
irr::core::stringw OptionsScreenInput2::makeLabel(
|
void OptionsScreenInput2::addListItemSubheader(GUIEngine::ListWidget* actions,
|
||||||
|
const char* id,
|
||||||
|
const core::stringw& text)
|
||||||
|
{
|
||||||
|
std::vector<GUIEngine::ListWidget::ListCell> row;
|
||||||
|
row.push_back(GUIEngine::ListWidget::ListCell(text, -1, 1, false));
|
||||||
|
row.push_back(GUIEngine::ListWidget::ListCell(L"", -1, 1, false));
|
||||||
|
actions->addItem(id, row);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void OptionsScreenInput2::addListItem(GUIEngine::ListWidget* actions, PlayerAction pa)
|
||||||
|
{
|
||||||
|
std::vector<GUIEngine::ListWidget::ListCell> row;
|
||||||
|
row.push_back(GUIEngine::ListWidget::ListCell(core::stringw(KartActionStrings[pa].c_str()), -1, 1, false));
|
||||||
|
row.push_back(GUIEngine::ListWidget::ListCell(L"", -1, 1, false));
|
||||||
|
actions->addItem(KartActionStrings[pa], row);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void OptionsScreenInput2::renameRow(GUIEngine::ListWidget* actions,
|
||||||
|
int idRow,
|
||||||
const irr::core::stringw &translatedName,
|
const irr::core::stringw &translatedName,
|
||||||
PlayerAction action) const
|
PlayerAction action) const
|
||||||
{
|
{
|
||||||
//hack: one tab character is supported by out font object, it moves the
|
actions->renameCell(idRow, 0, core::stringw(" ") + translatedName);
|
||||||
// cursor to the middle of the area
|
actions->renameCell(idRow, 1, m_config->getBindingAsString(action));
|
||||||
core::stringw out = irr::core::stringw(" ") + translatedName + L"\t";
|
|
||||||
|
|
||||||
out += m_config->getBindingAsString(action);
|
|
||||||
return out;
|
|
||||||
} // makeLabel
|
} // makeLabel
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -191,54 +224,54 @@ void OptionsScreenInput2::updateInputButtons()
|
|||||||
i++; // section header
|
i++; // section header
|
||||||
|
|
||||||
//I18N: Key binding name
|
//I18N: Key binding name
|
||||||
actions->renameItem(i++, makeLabel( _("Steer Left"), PA_STEER_LEFT) );
|
renameRow(actions, i++, _("Steer Left"), PA_STEER_LEFT);
|
||||||
|
|
||||||
//I18N: Key binding name
|
//I18N: Key binding name
|
||||||
actions->renameItem(i++, makeLabel( _("Steer Right"), PA_STEER_RIGHT) );
|
renameRow(actions, i++, _("Steer Right"), PA_STEER_RIGHT);
|
||||||
|
|
||||||
//I18N: Key binding name
|
//I18N: Key binding name
|
||||||
actions->renameItem(i++, makeLabel( _("Accelerate"), PA_ACCEL) );
|
renameRow(actions, i++, _("Accelerate"), PA_ACCEL);
|
||||||
|
|
||||||
//I18N: Key binding name
|
//I18N: Key binding name
|
||||||
actions->renameItem(i++, makeLabel( _("Brake"), PA_BRAKE) );
|
renameRow(actions, i++, _("Brake"), PA_BRAKE);
|
||||||
|
|
||||||
//I18N: Key binding name
|
//I18N: Key binding name
|
||||||
actions->renameItem(i++, makeLabel( _("Fire"), PA_FIRE) );
|
renameRow(actions, i++, _("Fire"), PA_FIRE);
|
||||||
|
|
||||||
//I18N: Key binding name
|
//I18N: Key binding name
|
||||||
actions->renameItem(i++, makeLabel( _("Nitro"), PA_NITRO) );
|
renameRow(actions, i++, _("Nitro"), PA_NITRO);
|
||||||
|
|
||||||
//I18N: Key binding name
|
//I18N: Key binding name
|
||||||
actions->renameItem(i++, makeLabel( _("Skidding"), PA_DRIFT) );
|
renameRow(actions, i++, _("Skidding"), PA_DRIFT);
|
||||||
|
|
||||||
//I18N: Key binding name
|
//I18N: Key binding name
|
||||||
actions->renameItem(i++, makeLabel( _("Look Back"), PA_LOOK_BACK) );
|
renameRow(actions, i++, _("Look Back"), PA_LOOK_BACK);
|
||||||
|
|
||||||
//I18N: Key binding name
|
//I18N: Key binding name
|
||||||
actions->renameItem(i++, makeLabel( _("Rescue"), PA_RESCUE) );
|
renameRow(actions, i++, _("Rescue"), PA_RESCUE);
|
||||||
|
|
||||||
//I18N: Key binding name
|
//I18N: Key binding name
|
||||||
actions->renameItem(i++, makeLabel( _("Pause Game"), PA_PAUSE_RACE) );
|
renameRow(actions, i++, _("Pause Game"), PA_PAUSE_RACE);
|
||||||
|
|
||||||
i++; // section header
|
i++; // section header
|
||||||
|
|
||||||
//I18N: Key binding name
|
//I18N: Key binding name
|
||||||
actions->renameItem(i++, makeLabel( _("Up"), PA_MENU_UP) );
|
renameRow(actions, i++, _("Up"), PA_MENU_UP);
|
||||||
|
|
||||||
//I18N: Key binding name
|
//I18N: Key binding name
|
||||||
actions->renameItem(i++, makeLabel( _("Down"), PA_MENU_DOWN) );
|
renameRow(actions, i++, _("Down"), PA_MENU_DOWN);
|
||||||
|
|
||||||
//I18N: Key binding name
|
//I18N: Key binding name
|
||||||
actions->renameItem(i++, makeLabel( _("Left"), PA_MENU_LEFT) );
|
renameRow(actions, i++, _("Left"), PA_MENU_LEFT);
|
||||||
|
|
||||||
//I18N: Key binding name
|
//I18N: Key binding name
|
||||||
actions->renameItem(i++, makeLabel( _("Right"), PA_MENU_RIGHT) );
|
renameRow(actions, i++, _("Right"), PA_MENU_RIGHT);
|
||||||
|
|
||||||
//I18N: Key binding name
|
//I18N: Key binding name
|
||||||
actions->renameItem(i++, makeLabel( _("Select"), PA_MENU_SELECT) );
|
renameRow(actions, i++, _("Select"), PA_MENU_SELECT);
|
||||||
|
|
||||||
//I18N: Key binding name
|
//I18N: Key binding name
|
||||||
actions->renameItem(i++, makeLabel( _("Cancel/Back"), PA_MENU_CANCEL) );
|
renameRow(actions, i++, _("Cancel/Back"), PA_MENU_CANCEL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include "guiengine/screen.hpp"
|
#include "guiengine/screen.hpp"
|
||||||
#include "states_screens/dialogs/message_dialog.hpp"
|
#include "states_screens/dialogs/message_dialog.hpp"
|
||||||
|
|
||||||
namespace GUIEngine { class Widget; }
|
namespace GUIEngine { class Widget; class ListWidget; }
|
||||||
class DeviceConfig;
|
class DeviceConfig;
|
||||||
namespace irr { namespace gui { class STKModifiedSpriteBank; } }
|
namespace irr { namespace gui { class STKModifiedSpriteBank; } }
|
||||||
|
|
||||||
@ -50,8 +50,15 @@ class OptionsScreenInput2 : public GUIEngine::Screen,
|
|||||||
|
|
||||||
DeviceConfig* m_config;
|
DeviceConfig* m_config;
|
||||||
|
|
||||||
irr::core::stringw makeLabel(const irr::core::stringw &translatedName,
|
void renameRow(GUIEngine::ListWidget* actions,
|
||||||
PlayerAction action) const;
|
int idRow,
|
||||||
|
const irr::core::stringw &translatedName,
|
||||||
|
PlayerAction action) const;
|
||||||
|
|
||||||
|
void addListItem(GUIEngine::ListWidget* actions, PlayerAction pa);
|
||||||
|
void addListItemSubheader(GUIEngine::ListWidget* actions,
|
||||||
|
const char* id,
|
||||||
|
const core::stringw& text);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
friend class GUIEngine::ScreenSingleton<OptionsScreenInput2>;
|
friend class GUIEngine::ScreenSingleton<OptionsScreenInput2>;
|
||||||
@ -84,6 +91,8 @@ public:
|
|||||||
|
|
||||||
/** \brief Implement IConfirmDialogListener callback */
|
/** \brief Implement IConfirmDialogListener callback */
|
||||||
virtual void onConfirm() OVERRIDE;
|
virtual void onConfirm() OVERRIDE;
|
||||||
|
|
||||||
|
virtual void beforeAddingWidget() OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user