ManaPlus
Public Member Functions | Private Member Functions | Private Attributes
TextCommandEditor Class Reference

#include <textcommandeditor.h>

Inheritance diagram for TextCommandEditor:
Window ActionListener BasicContainer2 MouseListener WidgetListener BasicContainer Widget WidgetDeathListener Widget2

Public Member Functions

 TextCommandEditor (TextCommand *const command)
 
 ~TextCommandEditor ()
 
void postInit ()
 
void action (const ActionEvent &event)
 
void scheduleDelete ()
 
- Public Member Functions inherited from Window
 Window (const std::string &caption, const Modal modal, Window *const parent, std::string skin)
 
 ~Window ()
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
void setContentSize (int width, int height)
 
void setLocationRelativeTo (const Widget *const widget)
 
void setLocationHorisontallyRelativeTo (const Widget *const widget)
 
void setLocationRelativeTo (const ImagePosition::Type &position, int offsetX, int offsetY)
 
void setResizable (const bool resize)
 
void redraw ()
 
void widgetResized (const Event &event)
 
void widgetMoved (const Event &event)
 
void widgetHidden (const Event &event)
 
void setCloseButton (const bool flag)
 
bool getCloseButton () const
 
void setAllowClose (const bool b)
 
bool getAlowClose () const
 
bool isResizable () const
 
void setMinWidth (const int width)
 
int getMinWidth () const
 
void setMinHeight (const int height)
 
int getMinHeight () const
 
void setMaxWidth (const int width)
 
int getMaxWidth () const
 
void setMaxHeight (const int height)
 
int getMaxHeight () const
 
void setShowTitle (bool flag)
 
void setStickyButton (const bool flag)
 
void setSticky (const bool sticky)
 
bool isSticky () const
 
void setStickyButtonLock (const bool sticky)
 
bool isStickyButtonLock () const
 
virtual void setVisible (Visible visible)
 
void setVisible (const Visible visible, const bool forceSticky)
 
bool isDefaultVisible () const
 
void setDefaultVisible (const bool save)
 
bool willSaveVisible () const
 
void setSaveVisible (const bool save)
 
WindowgetParentWindow () const
 
void mousePressed (MouseEvent &event)
 
void mouseDragged (MouseEvent &event)
 
void mouseMoved (MouseEvent &event)
 
void mouseReleased (MouseEvent &event)
 
void mouseExited (MouseEvent &event)
 
void mouseEntered (MouseEvent &event)
 
void updateResizeHandler (MouseEvent &event)
 
void setWindowName (const std::string &name)
 
const std::string & getWindowName () const
 
void loadWindowState ()
 
void saveWindowState ()
 
void setDefaultSize (const int defaultX, const int defaultY, int defaultWidth, int defaultHeight)
 
void setDefaultSize ()
 
void setDefaultSize (const int defaultWidth, const int defaultHeight, const ImagePosition::Type &position, const int offsetx, const int offsetY)
 
virtual void resetToDefaultSize ()
 
void adjustPositionAfterResize (const int oldScreenWidth, const int oldScreenHeight)
 
LayoutgetLayout ()
 
void clearLayout ()
 
void reflowLayout (int w, int h)
 
LayoutCellplace (const int x, const int y, Widget *const wg, const int w, const int h)
 
ContainerPlacer getPlacer (const int x, const int y)
 
void center ()
 
void centerHorisontally ()
 
virtual void close ()
 
void setModal (const Modal modal)
 
Rect getWindowArea () const
 
bool isResizeAllowed (const MouseEvent &event) const
 
void setCaptionFont (Font *font)
 
void enableVisibleSound (bool b)
 
bool isWindowVisible () const
 
void setPadding (int padding)
 
int getPadding () const
 
void setTitleBarHeight (unsigned int height)
 
unsigned int getTitleBarHeight () const
 
void setCaption (const std::string &caption)
 
const std::string & getCaption () const
 
void setAlignment (Graphics::Alignment alignment)
 
Graphics::Alignment getAlignment () const
 
void setMovable (Move movable)
 
bool isMovable () const
 
Rect getChildrenArea ()
 
virtual void resizeToContent ()
 
- 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)
 
- 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)
 
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 ()
 
- 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 MouseListener
virtual ~MouseListener ()
 
virtual void mouseClicked (MouseEvent &event)
 
virtual void mouseWheelMovedUp (MouseEvent &event)
 
virtual void mouseWheelMovedDown (MouseEvent &event)
 
- Public Member Functions inherited from WidgetListener
virtual ~WidgetListener ()
 
virtual void widgetShown (const Event &event)
 
- Public Member Functions inherited from ActionListener
virtual ~ActionListener ()
 

Private Member Functions

void showControls (const Visible show)
 
void save ()
 
void deleteCommand ()
 

Private Attributes

bool mIsMagicCommand
 
TextCommandmCommand
 
RadioButtonmIsMagic
 
RadioButtonmIsOther
 
LabelmSymbolLabel
 
TextFieldmSymbolTextField
 
LabelmCommandLabel
 
TextFieldmCommandTextField
 
LabelmCommentLabel
 
TextFieldmCommentTextField
 
TargetTypeModelmTargetTypeModel
 
LabelmTypeLabel
 
DropDownmTypeDropDown
 
IconsModelmIconsModel
 
LabelmIconLabel
 
DropDownmIconDropDown
 
LabelmManaLabel
 
IntTextFieldmManaField
 
LabelmMagicLvlLabel
 
IntTextFieldmMagicLvlField
 
MagicSchoolModelmMagicSchoolModel
 
LabelmSchoolLabel
 
DropDownmSchoolDropDown
 
LabelmSchoolLvlLabel
 
IntTextFieldmSchoolLvlField
 
ButtonmCancelButton
 
ButtonmSaveButton
 
ButtonmDeleteButton
 
bool mEnabledKeyboard
 

Additional Inherited Members

- Static Public Member Functions inherited from Window
static void setWindowContainer (WindowContainer *const windowContainer)
 
- 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 Window
bool canMove () const
 
int getOption (const std::string &name, const int def) const
 
bool getOptionBool (const std::string &name, const bool def) const
 
void setTitlePadding (const int p)
 
int getTitlePadding () const
 
- 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 MouseListener
 MouseListener ()
 
- Protected Member Functions inherited from WidgetListener
 WidgetListener ()
 
- Protected Member Functions inherited from ActionListener
 ActionListener ()
 
- Protected Attributes inherited from Window
std::string mCaption
 
Graphics::Alignment mAlignment
 
int mPadding
 
unsigned int mTitleBarHeight
 
Move mMovable
 
int mDragOffsetX
 
int mDragOffsetY
 
bool mMoved
 
SkinmSkin
 
int mDefaultX
 
int mDefaultY
 
int mDefaultWidth
 
int mDefaultHeight
 
int mCaptionOffsetX
 
int mCaptionOffsetY
 
bool mShowTitle
 
bool mLastRedraw
 
- 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 44 of file textcommandeditor.h.

Constructor & Destructor Documentation

◆ TextCommandEditor()

TextCommandEditor::TextCommandEditor ( TextCommand *const  command)
explicit

Constructor.

Definition at line 54 of file textcommandeditor.cpp.

54  :
55  // TRANSLATORS: command editor name
56  Window(_("Command Editor"), Modal_false, nullptr, "commandeditor.xml"),
58 #ifdef TMWA_SUPPORT
59  mIsMagicCommand(command != nullptr ?
60  (command->getCommandType() == TextCommandType::Magic) : false),
61 #endif // TMWA_SUPPORT
62  mCommand(command),
63 #ifdef TMWA_SUPPORT
64  // TRANSLATORS: command editor button
65  mIsMagic(new RadioButton(this, _("magic"), "magic", mIsMagicCommand)),
66  // TRANSLATORS: command editor button
67  mIsOther(new RadioButton(this, _("other"), "magic", !mIsMagicCommand)),
68 #endif // TMWA_SUPPORT
69  // TRANSLATORS: command editor label
70  mSymbolLabel(new Label(this, _("Symbol:"))),
71  mSymbolTextField(new TextField(this, std::string(),
72  LoseFocusOnTab_true, nullptr, std::string(), false)),
73  // TRANSLATORS: command editor label
74  mCommandLabel(new Label(this, _("Command:"))),
75  mCommandTextField(new TextField(this, std::string(),
76  LoseFocusOnTab_true, nullptr, std::string(), false)),
77  // TRANSLATORS: command editor label
78  mCommentLabel(new Label(this, _("Comment:"))),
79  mCommentTextField(new TextField(this, std::string(),
80  LoseFocusOnTab_true, nullptr, std::string(), false)),
82  // TRANSLATORS: command editor label
83  mTypeLabel(new Label(this, _("Target Type:"))),
85  false, Modal_false, nullptr, std::string())),
87  // TRANSLATORS: command editor label
88  mIconLabel(new Label(this, _("Icon:"))),
90  false, Modal_false, nullptr, std::string())),
91 #ifdef TMWA_SUPPORT
92  // TRANSLATORS: command editor label
93  mManaLabel(new Label(this, _("Mana:"))),
94  mManaField(new IntTextField(this, 0, 0, 0, Enable_true, 0)),
95  // TRANSLATORS: command editor label
96  mMagicLvlLabel(new Label(this, _("Magic level:"))),
97  mMagicLvlField(new IntTextField(this, 0, 0, 0, Enable_true, 0)),
99  // TRANSLATORS: command editor label
100  mSchoolLabel(new Label(this, _("Magic School:"))),
102  false, Modal_false, nullptr, std::string())),
103  // TRANSLATORS: command editor label
104  mSchoolLvlLabel(new Label(this, _("School level:"))),
105  mSchoolLvlField(new IntTextField(this, 0, 0, 0, Enable_true, 0)),
106 #endif // TMWA_SUPPORT
107  // TRANSLATORS: command editor button
108  mCancelButton(new Button(this, _("Cancel"), "cancel", BUTTON_SKIN, this)),
109  // TRANSLATORS: command editor button
110  mSaveButton(new Button(this, _("Save"), "save", BUTTON_SKIN, this)),
111  // TRANSLATORS: command editor button
112  mDeleteButton(new Button(this, _("Delete"), "delete", BUTTON_SKIN, this)),
114 {
115  const int w = 350;
116  const int h = 370;
117 
118  keyboard.setEnabled(false);
119 
120  setWindowName("TextCommandEditor");
122 
123 #ifdef TMWA_SUPPORT
124  mIsMagic->setActionEventId("magic");
126 
127  mIsOther->setActionEventId("other");
129 
130  mManaField->setRange(0, 500);
131  mManaField->setWidth(20);
132 
133  mMagicLvlField->setRange(0, 5);
135 
139 
140  mSchoolLvlField->setRange(0, 5);
142 #endif // TMWA_SUPPORT
143 
146 
149  if (mCommand != nullptr)
151 
155 
156  if (command != nullptr)
157  {
158 #ifdef TMWA_SUPPORT
159  if (command->getCommandType() == TextCommandType::Magic)
161  else
163 
164  mManaField->setValue(command->getMana());
165  mMagicLvlField->setValue(command->getBaseLvl());
167  - MAGIC_START_ID);
169 #endif // TMWA_SUPPORT
170 
171  mSymbolTextField->setText(command->getSymbol());
172  mCommandTextField->setText(command->getCommand());
173  mCommentTextField->setText(command->getComment());
175  }
176 
177  ContainerPlacer placer(nullptr, nullptr);
178  placer = getPlacer(0, 0);
179 
180 #ifdef TMWA_SUPPORT
181  placer(0, 0, mIsMagic, 1, 1);
182  placer(2, 0, mIsOther, 1, 1);
183  placer(0, 1, mSymbolLabel, 2, 1).setPadding(3);
184  placer(2, 1, mSymbolTextField, 3, 1).setPadding(3);
185  placer(0, 2, mCommandLabel, 2, 1).setPadding(3);
186  placer(2, 2, mCommandTextField, 4, 1).setPadding(3);
187 
188  placer(0, 3, mCommentLabel, 2, 1).setPadding(3);
189  placer(2, 3, mCommentTextField, 4, 1).setPadding(3);
190 
191  placer(0, 4, mTypeLabel, 2, 1).setPadding(3);
192  placer(2, 4, mTypeDropDown, 3, 1).setPadding(3);
193 
194  placer(0, 5, mIconLabel, 2, 1).setPadding(3);
195  placer(2, 5, mIconDropDown, 3, 1).setPadding(3);
196 
197  placer(0, 6, mManaLabel, 2, 1).setPadding(3);
198  placer(2, 6, mManaField, 3, 1).setPadding(3);
199  placer(0, 7, mMagicLvlLabel, 2, 1).setPadding(3);
200  placer(2, 7, mMagicLvlField, 3, 1).setPadding(3);
201 
202  placer(0, 8, mSchoolLabel, 2, 1).setPadding(3);
203  placer(2, 8, mSchoolDropDown, 3, 1).setPadding(3);
204  placer(0, 9, mSchoolLvlLabel, 2, 1).setPadding(3);
205  placer(2, 9, mSchoolLvlField, 3, 1).setPadding(3);
206 
207  placer(0, 10, mSaveButton, 2, 1).setPadding(3);
208  placer(2, 10, mCancelButton, 2, 1).setPadding(3);
209  placer(4, 10, mDeleteButton, 2, 1).setPadding(3);
210 #else // TMWA_SUPPORT
211 
212  placer(0, 0, mSymbolLabel, 2, 1).setPadding(3);
213  placer(2, 0, mSymbolTextField, 3, 1).setPadding(3);
214  placer(0, 1, mCommandLabel, 2, 1).setPadding(3);
215  placer(2, 1, mCommandTextField, 4, 1).setPadding(3);
216 
217  placer(0, 2, mCommentLabel, 2, 1).setPadding(3);
218  placer(2, 2, mCommentTextField, 4, 1).setPadding(3);
219 
220  placer(0, 3, mTypeLabel, 2, 1).setPadding(3);
221  placer(2, 3, mTypeDropDown, 3, 1).setPadding(3);
222 
223  placer(0, 4, mIconLabel, 2, 1).setPadding(3);
224  placer(2, 4, mIconDropDown, 3, 1).setPadding(3);
225 
226  placer(0, 5, mSaveButton, 2, 1).setPadding(3);
227  placer(2, 5, mCancelButton, 2, 1).setPadding(3);
228  placer(4, 5, mDeleteButton, 2, 1).setPadding(3);
229 #endif // TMWA_SUPPORT
230 
231  setWidth(w);
232  setHeight(h);
233 
234  reflowLayout(w, 0);
235 
236  center();
237 }
const std::string BUTTON_SKIN
Definition: button.h:89
#define CAST_S32
Definition: cast.h:30
Definition: button.h:102
void adjustSize()
Definition: button.cpp:799
void setSelected(int selected)
Definition: dropdown.cpp:514
void setSelectedString(const std::string &str)
Definition: dropdown.cpp:445
void setValue(const int value)
void setRange(const int minimum, const int maximum)
void setEnabled(const bool flag)
bool isEnabled() const
Definition: label.h:91
TextCommand * mCommand
TextField * mCommentTextField
IconsModel * mIconsModel
IntTextField * mManaField
TargetTypeModel * mTargetTypeModel
MagicSchoolModel * mMagicSchoolModel
DropDown * mSchoolDropDown
IntTextField * mMagicLvlField
DropDown * mTypeDropDown
DropDown * mIconDropDown
TextField * mSymbolTextField
IntTextField * mSchoolLvlField
void showControls(const Visible show)
RadioButton * mIsMagic
RadioButton * mIsOther
TextField * mCommandTextField
unsigned getBaseLvl() const
Definition: textcommand.h:110
unsigned int getMana() const
Definition: textcommand.h:104
std::string getCommand() const
Definition: textcommand.h:85
unsigned getSchoolLvl() const
Definition: textcommand.h:113
MagicSchoolT getSchool() const
Definition: textcommand.h:107
std::string getSymbol() const
Definition: textcommand.h:91
TextCommandTypeT getCommandType() const
Definition: textcommand.h:128
std::string getComment() const
Definition: textcommand.h:88
CommandTargetT getTargetType() const
Definition: textcommand.h:97
std::string getIcon() const
Definition: textcommand.h:100
void setText(const std::string &text)
Definition: textfield.cpp:803
void setWidth(const int width)
Definition: widget.cpp:133
void setHeight(const int height)
Definition: widget.cpp:140
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:596
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:252
void center()
Definition: window.cpp:1417
ContainerPlacer getPlacer(const int x, const int y)
Definition: window.cpp:1391
void reflowLayout(int w, int h)
Definition: window.cpp:1396
void setWindowName(const std::string &name)
Definition: window.h:355
Window(const std::string &caption, const Modal modal, Window *const parent, std::string skin)
Definition: window.cpp:109
void setDefaultSize()
Definition: window.cpp:1198
const bool Enable_true
Definition: enable.h:30
#define _(s)
Definition: gettext.h:35
KeyboardConfig keyboard
const bool LoseFocusOnTab_true
const bool Modal_false
Definition: modal.h:30
const unsigned int MAGIC_START_ID
const bool Visible_false
Definition: visible.h:30
const bool Visible_true
Definition: visible.h:30

References Widget::addActionListener(), Button::adjustSize(), CAST_S32, ImagePosition::CENTER, Window::center(), TextCommand::getBaseLvl(), TextCommand::getCommand(), TextCommand::getCommandType(), TextCommand::getComment(), TextCommand::getIcon(), TextCommand::getMana(), Window::getPlacer(), TextCommand::getSchool(), TextCommand::getSchoolLvl(), TextCommand::getSymbol(), TextCommand::getTargetType(), keyboard, TextCommandType::Magic, MAGIC_START_ID, mCancelButton, mCommand, mCommandLabel, mCommandTextField, mCommentLabel, mCommentTextField, mDeleteButton, mIconDropDown, mIconLabel, mIsMagic, mIsOther, mMagicLvlField, mMagicLvlLabel, mManaField, mManaLabel, mSaveButton, mSchoolDropDown, mSchoolLabel, mSchoolLvlField, mSchoolLvlLabel, mSymbolLabel, mSymbolTextField, mTypeDropDown, mTypeLabel, Window::reflowLayout(), Widget::setActionEventId(), Window::setDefaultSize(), KeyboardConfig::setEnabled(), Widget::setHeight(), IntTextField::setRange(), DropDown::setSelected(), DropDown::setSelectedString(), TextField::setText(), IntTextField::setValue(), Widget::setWidth(), Window::setWindowName(), showControls(), Visible_false, and Visible_true.

◆ ~TextCommandEditor()

TextCommandEditor::~TextCommandEditor ( )

Destructor.

Definition at line 246 of file textcommandeditor.cpp.

247 {
250 #ifdef TMWA_SUPPORT
252 #endif // TMWA_SUPPORT
253 }
#define delete2(var)
Definition: delete2.h:25

References delete2, mIconsModel, mMagicSchoolModel, and mTargetTypeModel.

Member Function Documentation

◆ action()

void TextCommandEditor::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 255 of file textcommandeditor.cpp.

256 {
257  const std::string &eventId = event.getId();
258  if (eventId == "save")
259  {
260  save();
261  scheduleDelete();
262  }
263  else if (eventId == "cancel")
264  {
265  scheduleDelete();
266  }
267  else if (eventId == "delete")
268  {
269  deleteCommand();
270  scheduleDelete();
271  }
272 #ifdef TMWA_SUPPORT
273  else if (eventId == "magic")
274  {
275  mIsMagicCommand = true;
277  }
278  else if (eventId == "other")
279  {
280  mIsMagicCommand = false;
282  }
283 #endif // TMWA_SUPPORT
284 }

References deleteCommand(), mIsMagicCommand, save(), scheduleDelete(), showControls(), Visible_false, and Visible_true.

◆ deleteCommand()

void TextCommandEditor::deleteCommand ( )
private

Definition at line 336 of file textcommandeditor.cpp.

337 {
338  if (mCommand == nullptr)
339  return;
340  mCommand->setSymbol("");
341  mCommand->setCommand("");
342  mCommand->setComment("");
344  mCommand->setIcon("");
345 #ifdef TMWA_SUPPORT
347  mCommand->setMana(0);
348  mCommand->setBaseLvl(0);
351 #endif // TMWA_SUPPORT
352 
353  if (spellManager != nullptr)
354  spellManager->save();
355 }
void save() const
void setSchoolLvl(const unsigned int schoolLvl)
Definition: textcommand.h:125
void setBaseLvl(const unsigned int baseLvl)
Definition: textcommand.h:122
void setSchool(const MagicSchoolT school)
Definition: textcommand.h:119
void setTargetType(const CommandTargetT targetType)
Definition: textcommand.h:147
void setCommand(const std::string &command)
Definition: textcommand.h:135
void setComment(const std::string &comment)
Definition: textcommand.h:138
void setIcon(const std::string &icon)
Definition: textcommand.h:150
void setSymbol(const std::string &symbol)
Definition: textcommand.h:141
void setCommandType(const TextCommandTypeT commandType)
Definition: textcommand.h:131
void setMana(const unsigned int mana)
Definition: textcommand.h:116
SpellManager * spellManager

References mCommand, CommandTarget::NoTarget, SpellManager::save(), TextCommand::setBaseLvl(), TextCommand::setCommand(), TextCommand::setCommandType(), TextCommand::setComment(), TextCommand::setIcon(), TextCommand::setMana(), TextCommand::setSchool(), TextCommand::setSchoolLvl(), TextCommand::setSymbol(), TextCommand::setTargetType(), MagicSchool::SkillMagic, spellManager, and TextCommandType::Text.

Referenced by action().

◆ postInit()

void TextCommandEditor::postInit ( )
virtual

Reimplemented from Window.

Definition at line 239 of file textcommandeditor.cpp.

240 {
242  enableVisibleSound(true);
244 }
virtual void setVisible(Visible visible)
Definition: window.cpp:778
void postInit()
Definition: window.cpp:249
void enableVisibleSound(bool b)
Definition: window.h:481

References Window::enableVisibleSound(), Window::postInit(), Window::setVisible(), and Visible_true.

◆ save()

void TextCommandEditor::save ( )
private

Definition at line 306 of file textcommandeditor.cpp.

307 {
308  if (mCommand == nullptr)
309  return;
310 #ifdef TMWA_SUPPORT
311  if (mIsMagicCommand)
313  else
315 #endif // TMWA_SUPPORT
316 
321  static_cast<CommandTargetT>(mTypeDropDown->getSelected()));
323 
324 #ifdef TMWA_SUPPORT
327  mCommand->setSchool(static_cast<MagicSchoolT>(
330 #endif // TMWA_SUPPORT
331 
332  if (spellManager != nullptr)
333  spellManager->save();
334 }
std::string getSelectedString() const
Definition: dropdown.cpp:461
int getSelected() const
Definition: dropdown.cpp:509
int getValue() const
const std::string & getText() const
Definition: textfield.h:224
CommandTarget ::T CommandTargetT
Definition: commandtarget.h:33
MagicSchool ::T MagicSchoolT
Definition: magicschool.h:38

References DropDown::getSelected(), DropDown::getSelectedString(), TextField::getText(), IntTextField::getValue(), TextCommandType::Magic, MAGIC_START_ID, mCommand, mCommandTextField, mCommentTextField, mIconDropDown, mIsMagicCommand, mMagicLvlField, mManaField, mSchoolDropDown, mSchoolLvlField, mSymbolTextField, mTypeDropDown, SpellManager::save(), TextCommand::setBaseLvl(), TextCommand::setCommand(), TextCommand::setCommandType(), TextCommand::setComment(), TextCommand::setIcon(), TextCommand::setMana(), TextCommand::setSchool(), TextCommand::setSchoolLvl(), TextCommand::setSymbol(), TextCommand::setTargetType(), spellManager, and TextCommandType::Text.

Referenced by action().

◆ scheduleDelete()

void TextCommandEditor::scheduleDelete ( )
virtual

Schedule this window for deletion. It will be deleted at the start of the next logic update.

Reimplemented from Window.

Definition at line 300 of file textcommandeditor.cpp.

301 {
304 }
virtual void scheduleDelete()
Definition: window.cpp:831

References keyboard, mEnabledKeyboard, Window::scheduleDelete(), and KeyboardConfig::setEnabled().

Referenced by action().

◆ showControls()

void TextCommandEditor::showControls ( const Visible  show)
private

Definition at line 287 of file textcommandeditor.cpp.

288 {
289  mManaField->setVisible(show);
290  mManaLabel->setVisible(show);
291  mMagicLvlLabel->setVisible(show);
292  mMagicLvlField->setVisible(show);
293  mSchoolLabel->setVisible(show);
297 }
void setVisible(Visible visible)
Definition: widget.cpp:225

References mMagicLvlField, mMagicLvlLabel, mManaField, mManaLabel, mSchoolDropDown, mSchoolLabel, mSchoolLvlField, mSchoolLvlLabel, and Widget::setVisible().

Referenced by action(), and TextCommandEditor().

Field Documentation

◆ mCancelButton

Button* TextCommandEditor::mCancelButton
private

Definition at line 109 of file textcommandeditor.h.

Referenced by TextCommandEditor().

◆ mCommand

TextCommand* TextCommandEditor::mCommand
private

Definition at line 79 of file textcommandeditor.h.

Referenced by deleteCommand(), save(), and TextCommandEditor().

◆ mCommandLabel

Label* TextCommandEditor::mCommandLabel
private

Definition at line 87 of file textcommandeditor.h.

Referenced by TextCommandEditor().

◆ mCommandTextField

TextField* TextCommandEditor::mCommandTextField
private

Definition at line 88 of file textcommandeditor.h.

Referenced by save(), and TextCommandEditor().

◆ mCommentLabel

Label* TextCommandEditor::mCommentLabel
private

Definition at line 89 of file textcommandeditor.h.

Referenced by TextCommandEditor().

◆ mCommentTextField

TextField* TextCommandEditor::mCommentTextField
private

Definition at line 90 of file textcommandeditor.h.

Referenced by save(), and TextCommandEditor().

◆ mDeleteButton

Button* TextCommandEditor::mDeleteButton
private

Definition at line 111 of file textcommandeditor.h.

Referenced by TextCommandEditor().

◆ mEnabledKeyboard

bool TextCommandEditor::mEnabledKeyboard
private

Definition at line 113 of file textcommandeditor.h.

Referenced by scheduleDelete().

◆ mIconDropDown

DropDown* TextCommandEditor::mIconDropDown
private

Definition at line 96 of file textcommandeditor.h.

Referenced by save(), and TextCommandEditor().

◆ mIconLabel

Label* TextCommandEditor::mIconLabel
private

Definition at line 95 of file textcommandeditor.h.

Referenced by TextCommandEditor().

◆ mIconsModel

IconsModel* TextCommandEditor::mIconsModel
private

Definition at line 94 of file textcommandeditor.h.

Referenced by ~TextCommandEditor().

◆ mIsMagic

RadioButton* TextCommandEditor::mIsMagic
private

Definition at line 81 of file textcommandeditor.h.

Referenced by TextCommandEditor().

◆ mIsMagicCommand

bool TextCommandEditor::mIsMagicCommand
private

Definition at line 76 of file textcommandeditor.h.

Referenced by action(), and save().

◆ mIsOther

RadioButton* TextCommandEditor::mIsOther
private

Definition at line 84 of file textcommandeditor.h.

Referenced by TextCommandEditor().

◆ mMagicLvlField

IntTextField* TextCommandEditor::mMagicLvlField
private

Definition at line 101 of file textcommandeditor.h.

Referenced by save(), showControls(), and TextCommandEditor().

◆ mMagicLvlLabel

Label* TextCommandEditor::mMagicLvlLabel
private

Definition at line 100 of file textcommandeditor.h.

Referenced by showControls(), and TextCommandEditor().

◆ mMagicSchoolModel

MagicSchoolModel* TextCommandEditor::mMagicSchoolModel
private

Definition at line 102 of file textcommandeditor.h.

Referenced by ~TextCommandEditor().

◆ mManaField

IntTextField* TextCommandEditor::mManaField
private

Definition at line 99 of file textcommandeditor.h.

Referenced by save(), showControls(), and TextCommandEditor().

◆ mManaLabel

Label* TextCommandEditor::mManaLabel
private

Definition at line 98 of file textcommandeditor.h.

Referenced by showControls(), and TextCommandEditor().

◆ mSaveButton

Button* TextCommandEditor::mSaveButton
private

Definition at line 110 of file textcommandeditor.h.

Referenced by TextCommandEditor().

◆ mSchoolDropDown

DropDown* TextCommandEditor::mSchoolDropDown
private

Definition at line 104 of file textcommandeditor.h.

Referenced by save(), showControls(), and TextCommandEditor().

◆ mSchoolLabel

Label* TextCommandEditor::mSchoolLabel
private

Definition at line 103 of file textcommandeditor.h.

Referenced by showControls(), and TextCommandEditor().

◆ mSchoolLvlField

IntTextField* TextCommandEditor::mSchoolLvlField
private

Definition at line 106 of file textcommandeditor.h.

Referenced by save(), showControls(), and TextCommandEditor().

◆ mSchoolLvlLabel

Label* TextCommandEditor::mSchoolLvlLabel
private

Definition at line 105 of file textcommandeditor.h.

Referenced by showControls(), and TextCommandEditor().

◆ mSymbolLabel

Label* TextCommandEditor::mSymbolLabel
private

Definition at line 85 of file textcommandeditor.h.

Referenced by TextCommandEditor().

◆ mSymbolTextField

TextField* TextCommandEditor::mSymbolTextField
private

Definition at line 86 of file textcommandeditor.h.

Referenced by save(), and TextCommandEditor().

◆ mTargetTypeModel

TargetTypeModel* TextCommandEditor::mTargetTypeModel
private

Definition at line 91 of file textcommandeditor.h.

Referenced by ~TextCommandEditor().

◆ mTypeDropDown

DropDown* TextCommandEditor::mTypeDropDown
private

Definition at line 93 of file textcommandeditor.h.

Referenced by save(), and TextCommandEditor().

◆ mTypeLabel

Label* TextCommandEditor::mTypeLabel
private

Definition at line 92 of file textcommandeditor.h.

Referenced by TextCommandEditor().


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