ManaPlus
Public Member Functions | Static Private Member Functions | Private Attributes
Setup_Input Class Reference

#include <setup_input.h>

Inheritance diagram for Setup_Input:
SetupTab Container ActionListener WidgetListener BasicContainer2 BasicContainer Widget WidgetDeathListener Widget2

Public Member Functions

 Setup_Input (const Widget2 *const widget)
 
 ~Setup_Input ()
 
void apply ()
 
void cancel ()
 
void action (const ActionEvent &event)
 
void refreshAssignedKey (const int index)
 
void newKeyCallback (const InputActionT index)
 
void refreshKeys ()
 
void keyUnresolved ()
 
int keyToSetupData (const InputActionT index) const
 
std::string keyToString (const InputActionT index) const
 
- Public Member Functions inherited from SetupTab
const std::string & getName () const
 
virtual void externalUpdated ()
 
virtual void externalUnloaded ()
 
- Public Member Functions inherited from Container
 Container (const Widget2 *const widget)
 
 ~Container ()
 
bool safeRemove (Widget *const widget)
 
void removeControls ()
 
- Public Member Functions inherited from BasicContainer2
 BasicContainer2 (const Widget2 *const widget)
 
 ~BasicContainer2 ()
 
void setOpaque (Opaque opaque)
 
bool isOpaque () const
 
virtual void add (Widget *const widget)
 
void addXY (Widget *const widget, const int x, const int y)
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
- Public Member Functions inherited from BasicContainer
 BasicContainer (const Widget2 *const widget)
 
 ~BasicContainer ()
 
void showWidgetPart (Widget *const widget, const Rect &area)
 
void moveToTop (Widget *const widget)
 
void moveToBottom (Widget *const widget)
 
Rect getChildrenArea ()
 
void focusNext ()
 
void focusPrevious ()
 
void logic ()
 
void setFocusHandler (FocusHandler *const focusHandler)
 
void setInternalFocusHandler (FocusHandler *const focusHandler)
 
WidgetgetWidgetAt (int x, int y)
 
void death (const Event &event)
 
WidgetfindFirstWidget (const std::set< Widget * > &list)
 
void add (Widget *const widget)
 
virtual void remove (Widget *const widget)
 
virtual void clear ()
 
- Public Member Functions inherited from Widget
 Widget (const Widget2 *const widget)
 
 ~Widget ()
 
virtual void drawFrame (Graphics *graphics)
 
virtual void safeDrawFrame (Graphics *graphics)
 
void setFrameSize (const unsigned int frameSize)
 
unsigned int getFrameSize () const
 
WidgetgetParent () const
 
void setWidth (const int width)
 
int getWidth () const
 
void setHeight (const int height)
 
int getHeight () const
 
void setSize (const int width, const int height)
 
void setX (const int x)
 
int getX () const
 
void setY (const int y)
 
int getY () const
 
void setPosition (const int x, const int y)
 
void setDimension (const Rect &dimension)
 
const RectgetDimension () const
 
void setFocusable (const bool focusable)
 
bool isFocusable () const
 
virtual bool isFocused () const
 
void setEnabled (const bool enabled)
 
bool isEnabled () const
 
void setVisible (Visible visible)
 
bool isVisible () const
 
void setBaseColor (const Color &color)
 
const ColorgetBaseColor () const
 
void setForegroundColor (const Color &color)
 
const ColorgetForegroundColor () const
 
void setBackgroundColor (const Color &color)
 
const ColorgetBackgroundColor () const
 
virtual void requestFocus ()
 
virtual void requestMoveToTop ()
 
virtual void requestMoveToBottom ()
 
FocusHandlergetFocusHandler ()
 
void addActionListener (ActionListener *const actionListener)
 
void removeActionListener (ActionListener *const actionListener)
 
void addDeathListener (WidgetDeathListener *const deathListener)
 
void removeDeathListener (WidgetDeathListener *const deathListener)
 
void addMouseListener (MouseListener *const mouseListener)
 
void removeMouseListener (MouseListener *const mouseListener)
 
void addKeyListener (KeyListener *const keyListener)
 
void removeKeyListener (KeyListener *const keyListener)
 
void addFocusListener (FocusListener *const focusListener)
 
void removeFocusListener (FocusListener *const focusListener)
 
void addWidgetListener (WidgetListener *const widgetListener)
 
void removeWidgetListener (WidgetListener *const widgetListener)
 
void setActionEventId (const std::string &actionEventId)
 
const std::string & getActionEventId () const
 
virtual void getAbsolutePosition (int &x, int &y) const
 
virtual void setParent (Widget *parent)
 
FontgetFont () const
 
void setFont (Font *const font)
 
virtual void fontChanged ()
 
bool isTabInEnabled () const
 
void setTabInEnabled (const bool enabled)
 
bool isTabOutEnabled () const
 
void setTabOutEnabled (const bool enabled)
 
void requestModalFocus ()
 
virtual void requestModalMouseInputFocus ()
 
virtual void releaseModalFocus ()
 
virtual void releaseModalMouseInputFocus ()
 
virtual bool isModalFocused () const
 
virtual bool isModalMouseInputFocused () const
 
const std::list< MouseListener * > & getMouseListeners () const A_CONST
 
const std::list< KeyListener * > & getKeyListeners () const A_CONST
 
const std::list< FocusListener * > & getFocusListeners () const A_CONST
 
virtual FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
void setId (const std::string &id)
 
const std::string & getId () const
 
virtual void showPart (const Rect &rectangle)
 
bool isAllowLogic () const
 
void setMouseConsume (const bool b)
 
bool isMouseConsume () const
 
void setRedraw (const bool b)
 
virtual bool isSelectable () const
 
void setSelectable (const bool selectable)
 
void windowResized ()
 
virtual void postInit ()
 
- Public Member Functions inherited from Widget2
virtual ~Widget2 ()
 
const ColorgetThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
 
const ColorgetThemeCharColor (const signed char c, bool &valid) const A_INLINE
 
virtual void setWidget2 (const Widget2 *const widget)
 
void setPalette (int palette)
 
void checkPalette ()
 
void setForegroundColor2 (const Color &color)
 
WidgetgetWindow () const
 
virtual void setWindow (Widget *const window)
 
- Public Member Functions inherited from WidgetDeathListener
virtual ~WidgetDeathListener ()
 
- Public Member Functions inherited from ActionListener
virtual ~ActionListener ()
 
- Public Member Functions inherited from WidgetListener
virtual ~WidgetListener ()
 
virtual void widgetResized (const Event &event)
 
virtual void widgetMoved (const Event &event)
 
virtual void widgetHidden (const Event &event)
 
virtual void widgetShown (const Event &event)
 

Static Private Member Functions

static void fixTranslations ()
 
static void fixTranslation (SetupActionData *const actionDatas, const InputActionT actionStart, const InputActionT actionEnd, const std::string &text)
 

Private Attributes

KeyListModelmKeyListModel
 
ListBoxmKeyList
 
ButtonmAssignKeyButton
 
ButtonmUnassignKeyButton
 
ButtonmDefaultButton
 
ButtonmResetKeysButton
 
TabStripmTabs
 
ScrollAreamScrollArea
 
bool mKeySetting
 
int * mActionDataSize
 

Additional Inherited Members

- Static Public Member Functions inherited from Widget
static void setGlobalFont (Font *const font)
 
static FontgetGloablFont ()
 
static void cleanGlobalFont ()
 
static bool widgetExists (const Widget *const widget)
 
static void distributeWindowResizeEvent ()
 
static WidgetcallPostInit (Widget *const widget)
 
- Data Fields inherited from Widget
Visible mVisible
 
- Protected Types inherited from BasicContainer
typedef std::vector< Widget * > WidgetList
 
typedef WidgetList::iterator WidgetListIterator
 
typedef WidgetList::const_iterator WidgetListConstIterator
 
typedef WidgetList::reverse_iterator WidgetListReverseIterator
 
typedef WidgetList::const_reverse_iterator WidgetListCReverseIterator
 
- Protected Types inherited from Widget
typedef std::list< MouseListener * > MouseListenerList
 
typedef MouseListenerList::iterator MouseListenerIterator
 
typedef std::list< KeyListener * > KeyListenerList
 
typedef KeyListenerList::iterator KeyListenerIterator
 
typedef std::list< ActionListener * > ActionListenerList
 
typedef ActionListenerList::iterator ActionListenerIterator
 
typedef std::list< WidgetDeathListener * > WidgetDeathListenerList
 
typedef WidgetDeathListenerList::iterator WidgetDeathListenerIterator
 
typedef std::list< FocusListener * > FocusListenerList
 
typedef FocusListenerList::iterator FocusListenerIterator
 
typedef std::list< WidgetListener * > WidgetListenerList
 
typedef WidgetListenerList::iterator WidgetListenerIterator
 
- Protected Member Functions inherited from SetupTab
 SetupTab (const Widget2 *const widget)
 
void setName (const std::string &name)
 
- Protected Member Functions inherited from BasicContainer
virtual void drawChildren (Graphics *const graphics)
 
virtual void safeDrawChildren (Graphics *const graphics)
 
virtual void logicChildren ()
 
- Protected Member Functions inherited from Widget
void distributeActionEvent ()
 
void distributeResizedEvent ()
 
void distributeMovedEvent ()
 
void distributeHiddenEvent ()
 
void distributeShownEvent ()
 
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
 
- Protected Member Functions inherited from WidgetDeathListener
 WidgetDeathListener ()
 
- Protected Member Functions inherited from ActionListener
 ActionListener ()
 
- Protected Member Functions inherited from WidgetListener
 WidgetListener ()
 
- Protected Attributes inherited from BasicContainer2
Opaque mOpaque
 
- Protected Attributes inherited from BasicContainer
WidgetList mWidgets
 
WidgetList mLogicWidgets
 
- Protected Attributes inherited from Widget
MouseListenerList mMouseListeners
 
KeyListenerList mKeyListeners
 
ActionListenerList mActionListeners
 
WidgetDeathListenerList mDeathListeners
 
FocusListenerList mFocusListeners
 
WidgetListenerList mWidgetListeners
 
Color mForegroundColor
 
Color mBackgroundColor
 
Color mBaseColor
 
Rect mDimension
 
std::string mActionEventId
 
std::string mId
 
FocusHandlermFocusHandler
 
FocusHandlermInternalFocusHandler
 
WidgetmParent
 
FontmCurrentFont
 
unsigned int mFrameSize
 
bool mFocusable
 
bool mTabIn
 
bool mTabOut
 
bool mEnabled
 
bool mAllowLogic
 
bool mMouseConsume
 
bool mRedraw
 
bool mSelectable
 
- Protected Attributes inherited from Widget2
int mPaletteOffset
 
WidgetmWindow
 
Color mForegroundColor2
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

Definition at line 40 of file setup_input.h.

Constructor & Destructor Documentation

◆ Setup_Input()

Setup_Input::Setup_Input ( const Widget2 *const  widget)
explicit

Constructor

Definition at line 61 of file setup_input.cpp.

61  :
62  SetupTab(widget),
65  // TRANSLATORS: button in input settings tab
66  mAssignKeyButton(new Button(this, _("Assign"), "assign",
67  BUTTON_SKIN, this)),
68  // TRANSLATORS: button in input settings tab
69  mUnassignKeyButton(new Button(this, _("Unassign"), "unassign",
70  BUTTON_SKIN, this)),
71  // TRANSLATORS: button in input settings tab
72  mDefaultButton(new Button(this, _("Default"), "default",
73  BUTTON_SKIN, this)),
74  // TRANSLATORS: button in input settings tab
75  mResetKeysButton(new Button(this, _("Reset all keys"), "resetkeys",
76  BUTTON_SKIN, this)),
77  mTabs(new TabStrip(this, config.getIntValue("fontSize") + 10, 0)),
79  Opaque_true, "setup_input_background.xml")),
80  mKeySetting(false),
81  mActionDataSize(new int [SETUP_PAGES])
82 {
84  // TRANSLATORS: setting tab name
85  setName(_("Input"));
86 
88 
89  for (int f = 0; f < SETUP_PAGES; f ++)
90  {
91  int cnt = 0;
92  while (!setupActionData[f][cnt].name.empty())
93  cnt ++;
94  mActionDataSize[f] = cnt;
95  }
96 
98  refreshKeys();
99  if (gui != nullptr)
102 
110 
111  mTabs->addActionListener(this);
112  mTabs->setActionEventId("tabs_");
113  int k = 0;
114  while (pages[k] != nullptr)
115  {
116  mTabs->addButton(gettext(pages[k]), pages[k], false);
117  k ++;
118  }
119 
120  fixTranslations();
121 
122  // Do the layout
123  LayoutHelper h(this);
124  ContainerPlacer place = h.getPlacer(0, 0);
125 
126  place(0, 0, mTabs, 5, 1);
127  place(0, 1, mScrollArea, 5, 5).setPadding(2);
128  place(0, 6, mResetKeysButton, 1, 1);
129  place(2, 6, mAssignKeyButton, 1, 1);
130  place(3, 6, mUnassignKeyButton, 1, 1);
131  place(4, 6, mDefaultButton, 1, 1);
132 
133  int width = 600;
134  if (config.getIntValue("screenwidth") >= 730)
135  width += 100;
136 
137  setDimension(Rect(0, 0, width, 350));
138 }
const std::string BUTTON_SKIN
Definition: button.h:89
Definition: button.h:102
int getIntValue(const std::string &key) const
Font * getHelpFont() const
Definition: gui.h:166
void setSetupInput(Setup_Input *const setupInput)
Definition: inputmanager.h:110
void setSize(const int size)
Definition: keylistmodel.h:71
void setSelectedData(const int i)
Definition: keylistmodel.h:77
Definition: rect.h:74
void setHorizontalScrollPolicy(const ScrollPolicy hPolicy)
void setName(const std::string &name)
Definition: setuptab.h:68
SetupTab(const Widget2 *const widget)
Definition: setuptab.cpp:28
Button * mUnassignKeyButton
Definition: setup_input.h:97
Button * mResetKeysButton
Definition: setup_input.h:99
TabStrip * mTabs
Definition: setup_input.h:100
void refreshKeys()
ScrollArea * mScrollArea
Definition: setup_input.h:101
static void fixTranslations()
ListBox * mKeyList
Definition: setup_input.h:94
bool mKeySetting
Definition: setup_input.h:102
Button * mAssignKeyButton
Definition: setup_input.h:96
KeyListModel * mKeyListModel
Definition: setup_input.h:93
int * mActionDataSize
Definition: setup_input.h:103
Button * mDefaultButton
Definition: setup_input.h:98
virtual void addButton(const std::string &text, const std::string &tag, const bool pressed)
Definition: widgetgroup.cpp:42
void setEnabled(const bool enabled)
Definition: widget.h:352
void setFont(Font *const font)
Definition: widget.cpp:349
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:596
void setDimension(const Rect &dimension)
Definition: widget.cpp:169
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:252
Configuration config
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:36
#define _(s)
Definition: gettext.h:35
Gui * gui
Definition: gui.cpp:111
InputManager inputManager
SetupActionData *const setupActionData[]
const bool Opaque_true
Definition: opaque.h:30
const int SETUP_PAGES
Definition: pages.h:29
const char *const pages[SETUP_PAGES+1]

References _, Widget::addActionListener(), WidgetGroup::addButton(), config, fixTranslations(), Gui::getHelpFont(), Configuration::getIntValue(), LayoutHelper::getPlacer(), gui, inputManager, mActionDataSize, mAssignKeyButton, mDefaultButton, mKeyList, mKeyListModel, mResetKeysButton, mScrollArea, mTabs, mUnassignKeyButton, pages, refreshKeys(), Widget::setActionEventId(), Widget::setDimension(), Widget::setEnabled(), Widget::setFont(), ScrollArea::setHorizontalScrollPolicy(), SetupTab::setName(), KeyListModel::setSelectedData(), InputManager::setSetupInput(), KeyListModel::setSize(), SETUP_PAGES, setupActionData, and ScrollArea::SHOW_NEVER.

◆ ~Setup_Input()

Setup_Input::~Setup_Input ( )

Destructor

Definition at line 140 of file setup_input.cpp.

141 {
147  delete [] mActionDataSize;
148  mActionDataSize = nullptr;
150 }
#define delete2(var)
Definition: delete2.h:25

References delete2, mActionDataSize, mAssignKeyButton, mKeyList, mKeyListModel, mResetKeysButton, mScrollArea, and mUnassignKeyButton.

Member Function Documentation

◆ action()

void Setup_Input::action ( const ActionEvent actionEvent)
virtual

Called when an action is recieved from a widget. It is used to be able to recieve a notification that an action has occured.

Parameters
actionEventThe event of the action.

Implements ActionListener.

Definition at line 190 of file setup_input.cpp.

191 {
192  const std::string &id = event.getId();
193  const int selectedData = mKeyListModel->getSelectedData();
194 
195  if (event.getSource() == mKeyList)
196  {
197  if (!mKeySetting)
198  {
199  const int i(mKeyList->getSelected());
200  if (i >= 0 && i < mActionDataSize[selectedData])
201  {
202  if (setupActionData[selectedData][i].actionId
204  {
207  }
208  else
209  {
212  }
213  }
214  }
215  }
216  else if (id == "assign")
217  {
218  mKeySetting = true;
220  keyboard.setEnabled(false);
221  const int i(mKeyList->getSelected());
222  if (i >= 0 && i < mActionDataSize[selectedData])
223  {
224  const SetupActionData &key = setupActionData[selectedData][i];
225  const InputActionT ik = key.actionId;
227  mKeyListModel->setElementAt(i, std::string(
228  gettext(key.name.c_str())).append(": ?"));
229  }
230  }
231  else if (id == "unassign")
232  {
233  const int i(mKeyList->getSelected());
234  if (i >= 0 && i < mActionDataSize[selectedData])
235  {
236  const SetupActionData &key = setupActionData[selectedData][i];
237  const InputActionT ik = key.actionId;
242  }
244  }
245  else if (id == "resetkeys")
246  {
249  refreshKeys();
250  }
251  else if (id == "default")
252  {
253  const int i(mKeyList->getSelected());
254  if (i >= 0 && i < mActionDataSize[selectedData])
255  {
256  const SetupActionData &key = setupActionData[selectedData][i];
257  const InputActionT ik = key.actionId;
259  refreshKeys();
260  }
261  }
262  else if (strStartWith(id, "tabs_"))
263  {
264  int k = 0;
265  std::string str("tabs_");
266  while (pages[k] != nullptr)
267  {
268  if (str + pages[k] == id)
269  break;
270  k ++;
271  }
272  if ((pages[k] != nullptr) && str + pages[k] == id)
273  {
276  refreshKeys();
277  mKeyList->setSelected(0);
278  }
279  }
280 }
static void update()
void unassignKey()
void makeDefault(const InputActionT i)
void setNewKeyIndex(const InputActionT value)
Definition: inputmanager.h:104
int getSelectedData() const
Definition: keylistmodel.h:80
void setElementAt(const int i, const std::string &caption)
Definition: keylistmodel.h:68
void setEnabled(const bool flag)
int getSelected() const
Definition: listbox.h:168
void setSelected(const int selected)
Definition: listbox.cpp:399
void refreshAssignedKey(const int index)
InputAction ::T InputActionT
Definition: inputaction.h:717
KeyboardConfig keyboard
bool strStartWith(const std::string &str1, const std::string &str2)
std::string name
const InputActionT actionId

References SetupActionData::actionId, ListBox::getSelected(), KeyListModel::getSelectedData(), Event::getSource(), inputManager, keyboard, mActionDataSize, InputManager::makeDefault(), mAssignKeyButton, mKeyList, mKeyListModel, mKeySetting, mUnassignKeyButton, SetupActionData::name, InputAction::NO_VALUE, pages, refreshAssignedKey(), refreshKeys(), InputManager::resetKeys(), KeyListModel::setElementAt(), Widget::setEnabled(), KeyboardConfig::setEnabled(), InputManager::setNewKeyIndex(), ListBox::setSelected(), KeyListModel::setSelectedData(), KeyListModel::setSize(), setupActionData, strStartWith(), InputManager::unassignKey(), and InputManager::update().

◆ apply()

void Setup_Input::apply ( )
virtual

Called when the Apply button is pressed in the setup window.

Implements SetupTab.

Definition at line 152 of file setup_input.cpp.

153 {
154  keyUnresolved();
155  InputActionT key1;
156  InputActionT key2;
157 
158  if (inputManager.hasConflicts(key1, key2))
159  {
160  const std::string str1 = keyToString(key1);
161  const std::string str2 = keyToString(key2);
162 
164  // TRANSLATORS: input settings error header
165  _("Key Conflict(s) Detected."),
166  // TRANSLATORS: input settings error
167  strprintf(_("Conflict \"%s\" and \"%s\" keys. "
168  "Resolve them, or gameplay may result in strange behaviour."),
169  gettext(str1.c_str()), gettext(str2.c_str())),
170  // TRANSLATORS: ok dialog button
171  _("OK"),
173  Modal_true,
175  nullptr,
176  260);
177  }
178  keyboard.setEnabled(true);
180 }
void store() const
bool hasConflicts(InputActionT &key1, InputActionT &key2) const
std::string keyToString(const InputActionT index) const
void keyUnresolved()
#define CREATEWIDGET(type,...)
Definition: createwidget.h:29
const bool Modal_true
Definition: modal.h:30
const bool ShowCenter_true
Definition: showcenter.h:30
std::string strprintf(const char *const format,...)

References _, CREATEWIDGET, DialogType::ERROR, InputManager::hasConflicts(), inputManager, keyboard, keyToString(), keyUnresolved(), Modal_true, KeyboardConfig::setEnabled(), ShowCenter_true, InputManager::store(), and strprintf().

◆ cancel()

void Setup_Input::cancel ( )
virtual

Called when the Cancel button is pressed in the setup window.

Implements SetupTab.

Definition at line 182 of file setup_input.cpp.

183 {
184  keyUnresolved();
186  keyboard.setEnabled(true);
187  refreshKeys();
188 }

References inputManager, keyboard, keyUnresolved(), refreshKeys(), InputManager::retrieve(), and KeyboardConfig::setEnabled().

◆ fixTranslation()

void Setup_Input::fixTranslation ( SetupActionData *const  actionDatas,
const InputActionT  actionStart,
const InputActionT  actionEnd,
const std::string &  text 
)
staticprivate

Definition at line 358 of file setup_input.cpp.

362 {
363  int k = 0;
364 
365  while (!actionDatas[k].name.empty())
366  {
367  SetupActionData &data = actionDatas[k];
368 
369  const InputActionT actionId = data.actionId;
370  if (actionId >= actionStart && actionId <= actionEnd)
371  {
372  data.name = strprintf(gettext(text.c_str()),
373  actionId - actionStart + 1);
374  }
375  k ++;
376  }
377 }
uint32_t data

References data, and strprintf().

Referenced by fixTranslations().

◆ fixTranslations()

void Setup_Input::fixTranslations ( )
staticprivate

Definition at line 379 of file setup_input.cpp.

380 {
384  "Item Shortcut %d");
385 
389  "Emote Shortcut %d");
390 
394  "Craft shortcut %d");
395 
399  "Outfit Shortcut %d");
400 
404  "Move to point Shortcut %d");
405 }
static void fixTranslation(SetupActionData *const actionDatas, const InputActionT actionStart, const InputActionT actionEnd, const std::string &text)
SetupActionData setupActionDataCraft[]
Definition: craft.cpp:29
SetupActionData setupActionDataEmotes[]
Definition: emotes.cpp:32
SetupActionData setupActionDataMove[]
Definition: move.cpp:32
SetupActionData setupActionDataOutfits[]
Definition: outfits.cpp:32
SetupActionData setupActionDataShortcuts[]
Definition: shortcuts.cpp:32

References InputAction::CRAFT_1, InputAction::CRAFT_9, InputAction::EMOTE_1, InputAction::EMOTE_48, fixTranslation(), InputAction::MOVE_TO_POINT_1, InputAction::MOVE_TO_POINT_48, InputAction::OUTFIT_1, InputAction::OUTFIT_48, setupActionDataCraft, setupActionDataEmotes, setupActionDataMove, setupActionDataOutfits, setupActionDataShortcuts, InputAction::SHORTCUT_1, and InputAction::SHORTCUT_20.

Referenced by Setup_Input().

◆ keyToSetupData()

int Setup_Input::keyToSetupData ( const InputActionT  index) const

Definition at line 315 of file setup_input.cpp.

316 {
317  const int selectedData = mKeyListModel->getSelectedData();
318  for (int i = 0; i < mActionDataSize[selectedData]; i++)
319  {
320  const SetupActionData &key = setupActionData[selectedData][i];
321  if (key.actionId == index)
322  return i;
323  }
324  return -1;
325 }

References SetupActionData::actionId, KeyListModel::getSelectedData(), mActionDataSize, mKeyListModel, and setupActionData.

Referenced by newKeyCallback().

◆ keyToString()

std::string Setup_Input::keyToString ( const InputActionT  index) const

Definition at line 327 of file setup_input.cpp.

328 {
329  for (int f = 0; f < SETUP_PAGES; f ++)
330  {
331  for (int i = 0; i < mActionDataSize[f]; i++)
332  {
333  const SetupActionData &key = setupActionData[f][i];
334  if (key.actionId == index)
335  return key.name;
336  }
337  }
338  // TRANSLATORS: unknown key name
339  return _("unknown");
340 }

References _, SetupActionData::actionId, mActionDataSize, SetupActionData::name, SETUP_PAGES, and setupActionData.

Referenced by apply().

◆ keyUnresolved()

void Setup_Input::keyUnresolved ( )

If a key function is unresolved, then this reverts it.

Definition at line 349 of file setup_input.cpp.

350 {
351  if (mKeySetting)
352  {
355  }
356 }
InputActionT getNewKeyIndex() const
Definition: inputmanager.h:117
void newKeyCallback(const InputActionT index)

References InputManager::getNewKeyIndex(), inputManager, mKeySetting, newKeyCallback(), InputAction::NO_VALUE, and InputManager::setNewKeyIndex().

Referenced by apply(), and cancel().

◆ newKeyCallback()

void Setup_Input::newKeyCallback ( const InputActionT  index)

The callback function when a new key has been pressed.

Definition at line 306 of file setup_input.cpp.

307 {
308  mKeySetting = false;
309  const int i = keyToSetupData(index);
310  if (i >= 0)
313 }
int keyToSetupData(const InputActionT index) const

References keyToSetupData(), mAssignKeyButton, mKeySetting, refreshAssignedKey(), and Widget::setEnabled().

Referenced by InputManager::callbackNewKey(), and keyUnresolved().

◆ refreshAssignedKey()

void Setup_Input::refreshAssignedKey ( const int  index)

Get an update on the assigned key.

Definition at line 282 of file setup_input.cpp.

283 {
284  const int selectedData = mKeyListModel->getSelectedData();
285  const SetupActionData &key = setupActionData[selectedData][index];
286  if (key.actionId == InputAction::NO_VALUE)
287  {
288  const std::string str(" \342\200\225\342\200\225\342\200\225"
289  "\342\200\225\342\200\225 ");
291  str + gettext(key.name.c_str()) + str);
292  }
293  else
294  {
295  std::string str = gettext(key.name.c_str());
296  unsigned int sz = 20;
297  if (mainGraphics->mWidth > 800)
298  sz = 30;
299  while (str.size() < sz)
300  str.append(" ");
301  mKeyListModel->setElementAt(index, strprintf("%s: %s", str.c_str(),
302  inputManager.getKeyStringLong(key.actionId).c_str()));
303  }
304 }
int mWidth
Definition: graphics.h:484
std::string getKeyStringLong(const InputActionT index) const
Graphics * mainGraphics
Definition: graphics.cpp:109

References SetupActionData::actionId, InputManager::getKeyStringLong(), KeyListModel::getSelectedData(), inputManager, mainGraphics, mKeyListModel, Graphics::mWidth, SetupActionData::name, InputAction::NO_VALUE, KeyListModel::setElementAt(), setupActionData, and strprintf().

Referenced by action(), newKeyCallback(), and refreshKeys().

◆ refreshKeys()

void Setup_Input::refreshKeys ( )

Shorthand method to update all the keys.

Definition at line 342 of file setup_input.cpp.

343 {
344  const int selectedData = mKeyListModel->getSelectedData();
345  for (int i = 0; i < mActionDataSize[selectedData]; i++)
347 }

References KeyListModel::getSelectedData(), mActionDataSize, mKeyListModel, and refreshAssignedKey().

Referenced by action(), cancel(), and Setup_Input().

Field Documentation

◆ mActionDataSize

int* Setup_Input::mActionDataSize
private

◆ mAssignKeyButton

Button* Setup_Input::mAssignKeyButton
private

Definition at line 96 of file setup_input.h.

Referenced by action(), newKeyCallback(), Setup_Input(), and ~Setup_Input().

◆ mDefaultButton

Button* Setup_Input::mDefaultButton
private

Definition at line 98 of file setup_input.h.

Referenced by Setup_Input().

◆ mKeyList

ListBox* Setup_Input::mKeyList
private

Definition at line 94 of file setup_input.h.

Referenced by action(), Setup_Input(), and ~Setup_Input().

◆ mKeyListModel

KeyListModel* Setup_Input::mKeyListModel
private

◆ mKeySetting

bool Setup_Input::mKeySetting
private

flag to check if key being set.

Definition at line 102 of file setup_input.h.

Referenced by action(), keyUnresolved(), and newKeyCallback().

◆ mResetKeysButton

Button* Setup_Input::mResetKeysButton
private

Definition at line 99 of file setup_input.h.

Referenced by Setup_Input(), and ~Setup_Input().

◆ mScrollArea

ScrollArea* Setup_Input::mScrollArea
private

Definition at line 101 of file setup_input.h.

Referenced by Setup_Input(), and ~Setup_Input().

◆ mTabs

TabStrip* Setup_Input::mTabs
private

Definition at line 100 of file setup_input.h.

Referenced by Setup_Input().

◆ mUnassignKeyButton

Button* Setup_Input::mUnassignKeyButton
private

Definition at line 97 of file setup_input.h.

Referenced by action(), Setup_Input(), and ~Setup_Input().


The documentation for this class was generated from the following files: