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="Window", const Modal modal=Modal_false, Window *const parent=0, std::string skin="")
 
virtual ~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=0, int offsetY=0)
 
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=0, const int offsetY=0)
 
virtual void resetToDefaultSize ()
 
void adjustPositionAfterResize (const int oldScreenWidth, const int oldScreenHeight)
 
LayoutgetLayout ()
 
void clearLayout ()
 
void reflowLayout (int w=0, int h=0)
 
LayoutCellplace (const int x, const int y, Widget *const wg, const int w=1, const int h=1)
 
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)
 
virtual ~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)
 
virtual ~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)
 
virtual ~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=255U) 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=0) const
 
bool getOptionBool (const std::string &name, const bool def=false) 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.

References Widget::addActionListener(), Button::adjustSize(), CAST_S32, ImagePosition::CENTER, Window::center(), TextCommand::getBaseLvl(), TextCommand::getCommandType(), TextCommand::getIcon(), TextCommand::getMana(), Window::getPlacer(), TextCommand::getSchool(), TextCommand::getSchoolLvl(), keyboard, TextCommandType::Magic, 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(), IntTextField::setValue(), Widget::setWidth(), Window::setWindowName(), showControls(), Visible_false, and Visible_true.

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)),
72  // TRANSLATORS: command editor label
73  mCommandLabel(new Label(this, _("Command:"))),
74  mCommandTextField(new TextField(this)),
75  // TRANSLATORS: command editor label
76  mCommentLabel(new Label(this, _("Comment:"))),
77  mCommentTextField(new TextField(this)),
79  // TRANSLATORS: command editor label
80  mTypeLabel(new Label(this, _("Target Type:"))),
83  // TRANSLATORS: command editor label
84  mIconLabel(new Label(this, _("Icon:"))),
86 #ifdef TMWA_SUPPORT
87  // TRANSLATORS: command editor label
88  mManaLabel(new Label(this, _("Mana:"))),
89  mManaField(new IntTextField(this, 0)),
90  // TRANSLATORS: command editor label
91  mMagicLvlLabel(new Label(this, _("Magic level:"))),
92  mMagicLvlField(new IntTextField(this, 0)),
94  // TRANSLATORS: command editor label
95  mSchoolLabel(new Label(this, _("Magic School:"))),
97  // TRANSLATORS: command editor label
98  mSchoolLvlLabel(new Label(this, _("School level:"))),
99  mSchoolLvlField(new IntTextField(this, 0)),
100 #endif // TMWA_SUPPORT
101  // TRANSLATORS: command editor button
102  mCancelButton(new Button(this, _("Cancel"), "cancel", this)),
103  // TRANSLATORS: command editor button
104  mSaveButton(new Button(this, _("Save"), "save", this)),
105  // TRANSLATORS: command editor button
106  mDeleteButton(new Button(this, _("Delete"), "delete", this)),
108 {
109  const int w = 350;
110  const int h = 370;
111 
112  keyboard.setEnabled(false);
113 
114  setWindowName("TextCommandEditor");
116 
117 #ifdef TMWA_SUPPORT
118  mIsMagic->setActionEventId("magic");
120 
121  mIsOther->setActionEventId("other");
123 
124  mManaField->setRange(0, 500);
125  mManaField->setWidth(20);
126 
127  mMagicLvlField->setRange(0, 5);
129 
133 
134  mSchoolLvlField->setRange(0, 5);
136 #endif // TMWA_SUPPORT
137 
140 
143  if (mCommand != nullptr)
145 
149 
150  if (command != nullptr)
151  {
152 #ifdef TMWA_SUPPORT
153  if (command->getCommandType() == TextCommandType::Magic)
155  else
157 
158  mManaField->setValue(command->getMana());
159  mMagicLvlField->setValue(command->getBaseLvl());
161  - MAGIC_START_ID);
163 #endif // TMWA_SUPPORT
164  }
165 
166  ContainerPlacer placer;
167  placer = getPlacer(0, 0);
168 
169 #ifdef TMWA_SUPPORT
170  placer(0, 0, mIsMagic, 1);
171  placer(2, 0, mIsOther, 1);
172  placer(0, 1, mSymbolLabel, 2).setPadding(3);
173  placer(2, 1, mSymbolTextField, 3).setPadding(3);
174  placer(0, 2, mCommandLabel, 2).setPadding(3);
175  placer(2, 2, mCommandTextField, 4).setPadding(3);
176 
177  placer(0, 3, mCommentLabel, 2).setPadding(3);
178  placer(2, 3, mCommentTextField, 4).setPadding(3);
179 
180  placer(0, 4, mTypeLabel, 2).setPadding(3);
181  placer(2, 4, mTypeDropDown, 3).setPadding(3);
182 
183  placer(0, 5, mIconLabel, 2).setPadding(3);
184  placer(2, 5, mIconDropDown, 3).setPadding(3);
185 
186  placer(0, 6, mManaLabel, 2).setPadding(3);
187  placer(2, 6, mManaField, 3).setPadding(3);
188  placer(0, 7, mMagicLvlLabel, 2).setPadding(3);
189  placer(2, 7, mMagicLvlField, 3).setPadding(3);
190 
191  placer(0, 8, mSchoolLabel, 2).setPadding(3);
192  placer(2, 8, mSchoolDropDown, 3).setPadding(3);
193  placer(0, 9, mSchoolLvlLabel, 2).setPadding(3);
194  placer(2, 9, mSchoolLvlField, 3).setPadding(3);
195 
196  placer(0, 10, mSaveButton, 2).setPadding(3);
197  placer(2, 10, mCancelButton, 2).setPadding(3);
198  placer(4, 10, mDeleteButton, 2).setPadding(3);
199 #else // TMWA_SUPPORT
200 
201  placer(0, 0, mSymbolLabel, 2).setPadding(3);
202  placer(2, 0, mSymbolTextField, 3).setPadding(3);
203  placer(0, 1, mCommandLabel, 2).setPadding(3);
204  placer(2, 1, mCommandTextField, 4).setPadding(3);
205 
206  placer(0, 2, mCommentLabel, 2).setPadding(3);
207  placer(2, 2, mCommentTextField, 4).setPadding(3);
208 
209  placer(0, 3, mTypeLabel, 2).setPadding(3);
210  placer(2, 3, mTypeDropDown, 3).setPadding(3);
211 
212  placer(0, 4, mIconLabel, 2).setPadding(3);
213  placer(2, 4, mIconDropDown, 3).setPadding(3);
214 
215  placer(0, 5, mSaveButton, 2).setPadding(3);
216  placer(2, 5, mCancelButton, 2).setPadding(3);
217  placer(4, 5, mDeleteButton, 2).setPadding(3);
218 #endif // TMWA_SUPPORT
219 
220  setWidth(w);
221  setHeight(h);
222 
223  reflowLayout(w);
224 
225  center();
226 }
unsigned getSchoolLvl() const
Definition: textcommand.h:113
DropDown * mIconDropDown
void setDefaultSize()
Definition: window.cpp:1186
#define _(s)
Definition: gettext.h:34
TextField * mSymbolTextField
void setValue(const int value)
void setWidth(const int width)
Definition: widget.cpp:132
unsigned getBaseLvl() const
Definition: textcommand.h:110
const bool Visible_true
Definition: visible.h:29
std::string getIcon() const
Definition: textcommand.h:100
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
IntTextField * mSchoolLvlField
void showControls(const Visible show)
DropDown * mSchoolDropDown
Definition: button.h:94
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:595
RadioButton * mIsMagic
IntTextField * mMagicLvlField
bool isEnabled() const
TextCommand * mCommand
void adjustSize()
Definition: button.cpp:821
void reflowLayout(int w=0, int h=0)
Definition: window.cpp:1384
void setSelectedString(const std::string &str)
Definition: dropdown.cpp:441
IntTextField * mManaField
#define CAST_S32
Definition: cast.h:29
const unsigned int MAGIC_START_ID
const bool Visible_false
Definition: visible.h:29
Definition: label.h:87
IconsModel * mIconsModel
RadioButton * mIsOther
void setRange(const int minimum, const int maximum)
TextField * mCommentTextField
TargetTypeModel * mTargetTypeModel
ContainerPlacer getPlacer(const int x, const int y)
Definition: window.cpp:1379
DropDown * mTypeDropDown
void setHeight(const int height)
Definition: widget.cpp:139
unsigned int getMana() const
Definition: textcommand.h:104
void center()
Definition: window.cpp:1405
TextCommandTypeT getCommandType() const
Definition: textcommand.h:128
TextField * mCommandTextField
KeyboardConfig keyboard
Window(const std::string &caption="Window", const Modal modal=Modal_false, Window *const parent=0, std::string skin="")
Definition: window.cpp:108
void setSelected(int selected)
Definition: dropdown.cpp:510
void setEnabled(const bool flag)
MagicSchoolT getSchool() const
Definition: textcommand.h:107
void setWindowName(const std::string &name)
Definition: window.h:353
MagicSchoolModel * mMagicSchoolModel

◆ ~TextCommandEditor()

TextCommandEditor::~TextCommandEditor ( )

Destructor.

Definition at line 235 of file textcommandeditor.cpp.

References delete2, mIconsModel, mMagicSchoolModel, and mTargetTypeModel.

236 {
239 #ifdef TMWA_SUPPORT
241 #endif // TMWA_SUPPORT
242 }
#define delete2(var)
Definition: delete2.h:24
IconsModel * mIconsModel
TargetTypeModel * mTargetTypeModel
MagicSchoolModel * mMagicSchoolModel

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 244 of file textcommandeditor.cpp.

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

245 {
246  const std::string &eventId = event.getId();
247  if (eventId == "save")
248  {
249  save();
250  scheduleDelete();
251  }
252  else if (eventId == "cancel")
253  {
254  scheduleDelete();
255  }
256  else if (eventId == "delete")
257  {
258  deleteCommand();
259  scheduleDelete();
260  }
261 #ifdef TMWA_SUPPORT
262  else if (eventId == "magic")
263  {
264  mIsMagicCommand = true;
266  }
267  else if (eventId == "other")
268  {
269  mIsMagicCommand = false;
271  }
272 #endif // TMWA_SUPPORT
273 }
const bool Visible_true
Definition: visible.h:29
void showControls(const Visible show)
const bool Visible_false
Definition: visible.h:29

◆ deleteCommand()

void TextCommandEditor::deleteCommand ( )
private

Definition at line 325 of file textcommandeditor.cpp.

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().

326 {
327  if (mCommand == nullptr)
328  return;
329  mCommand->setSymbol("");
330  mCommand->setCommand("");
331  mCommand->setComment("");
333  mCommand->setIcon("");
334 #ifdef TMWA_SUPPORT
336  mCommand->setMana(0);
337  mCommand->setBaseLvl(0);
340 #endif // TMWA_SUPPORT
341 
342  if (spellManager != nullptr)
343  spellManager->save();
344 }
SpellManager * spellManager
void setComment(const std::string &comment)
Definition: textcommand.h:138
void save() const
TextCommand * mCommand
void setCommand(const std::string &command)
Definition: textcommand.h:135
void setCommandType(const TextCommandTypeT commandType)
Definition: textcommand.h:131
void setTargetType(const CommandTargetT targetType)
Definition: textcommand.h:147
void setMana(const unsigned int mana)
Definition: textcommand.h:116
void setSchool(const MagicSchoolT school)
Definition: textcommand.h:119
void setBaseLvl(const unsigned int baseLvl)
Definition: textcommand.h:122
void setSymbol(const std::string &symbol)
Definition: textcommand.h:141
void setSchoolLvl(const unsigned int schoolLvl)
Definition: textcommand.h:125
void setIcon(const std::string &icon)
Definition: textcommand.h:150

◆ postInit()

void TextCommandEditor::postInit ( )
virtual

Reimplemented from Window.

Definition at line 228 of file textcommandeditor.cpp.

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

229 {
231  enableVisibleSound(true);
233 }
const bool Visible_true
Definition: visible.h:29
void enableVisibleSound(bool b)
Definition: window.h:473
virtual void setVisible(Visible visible)
Definition: window.cpp:766
void postInit()
Definition: window.cpp:241

◆ save()

void TextCommandEditor::save ( )
private

Definition at line 295 of file textcommandeditor.cpp.

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().

296 {
297  if (mCommand == nullptr)
298  return;
299 #ifdef TMWA_SUPPORT
300  if (mIsMagicCommand)
302  else
304 #endif // TMWA_SUPPORT
305 
310  static_cast<CommandTargetT>(mTypeDropDown->getSelected()));
312 
313 #ifdef TMWA_SUPPORT
316  mCommand->setSchool(static_cast<MagicSchoolT>(
319 #endif // TMWA_SUPPORT
320 
321  if (spellManager != nullptr)
322  spellManager->save();
323 }
DropDown * mIconDropDown
TextField * mSymbolTextField
SpellManager * spellManager
IntTextField * mSchoolLvlField
void setComment(const std::string &comment)
Definition: textcommand.h:138
DropDown * mSchoolDropDown
void save() const
IntTextField * mMagicLvlField
TextCommand * mCommand
void setCommand(const std::string &command)
Definition: textcommand.h:135
void setCommandType(const TextCommandTypeT commandType)
Definition: textcommand.h:131
IntTextField * mManaField
const unsigned int MAGIC_START_ID
void setTargetType(const CommandTargetT targetType)
Definition: textcommand.h:147
void setMana(const unsigned int mana)
Definition: textcommand.h:116
TextField * mCommentTextField
int getValue() const
void setSchool(const MagicSchoolT school)
Definition: textcommand.h:119
std::string getSelectedString() const
Definition: dropdown.cpp:457
void setBaseLvl(const unsigned int baseLvl)
Definition: textcommand.h:122
DropDown * mTypeDropDown
void setSymbol(const std::string &symbol)
Definition: textcommand.h:141
TextField * mCommandTextField
const std::string & getText() const
Definition: textfield.h:225
int getSelected() const
Definition: dropdown.cpp:505
void setSchoolLvl(const unsigned int schoolLvl)
Definition: textcommand.h:125
void setIcon(const std::string &icon)
Definition: textcommand.h:150

◆ 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 289 of file textcommandeditor.cpp.

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

Referenced by action().

290 {
293 }
virtual void scheduleDelete()
Definition: window.cpp:819
KeyboardConfig keyboard
void setEnabled(const bool flag)

◆ showControls()

void TextCommandEditor::showControls ( const Visible  show)
private

Definition at line 276 of file textcommandeditor.cpp.

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

Referenced by action(), and TextCommandEditor().

277 {
278  mManaField->setVisible(show);
279  mManaLabel->setVisible(show);
280  mMagicLvlLabel->setVisible(show);
281  mMagicLvlField->setVisible(show);
282  mSchoolLabel->setVisible(show);
286 }
IntTextField * mSchoolLvlField
void setVisible(Visible visible)
Definition: widget.cpp:224
DropDown * mSchoolDropDown
IntTextField * mMagicLvlField
IntTextField * mManaField

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: