ManaPlus
Public Member Functions | Private Member Functions | Private Attributes

#include <charcreatedialog.h>

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

Public Member Functions

 CharCreateDialog (CharSelectDialog *const parent, const int slot)
 
 ~CharCreateDialog ()
 
void action (const ActionEvent &event)
 
void unlock ()
 
void setAttributes (const StringVect &labels, int available, const int min, const int max)
 
void setDefaultGender (const GenderT gender)
 
void logic ()
 
void updatePlayer ()
 
void keyPressed (KeyEvent &event)
 
- 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)
 
void postInit ()
 
WindowgetParentWindow () const
 
virtual void scheduleDelete ()
 
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 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 ()
 
- Public Member Functions inherited from KeyListener
virtual ~KeyListener ()
 
virtual void keyReleased (KeyEvent &event)
 

Private Member Functions

int getDistributedPoints () const
 
void updateSliders ()
 
void setButtonsPosition (const int w, const int h)
 
std::string getName () const
 
void attemptCharCreate ()
 
void updateHair ()
 
void updateRace ()
 
void updateLook ()
 

Private Attributes

CharSelectDialogmCharSelectDialog
 
TextFieldmNameField
 
LabelmNameLabel
 
ButtonmNextHairColorButton
 
ButtonmPrevHairColorButton
 
LabelmHairColorLabel
 
LabelmHairColorNameLabel
 
ButtonmNextHairStyleButton
 
ButtonmPrevHairStyleButton
 
LabelmHairStyleLabel
 
LabelmHairStyleNameLabel
 
ButtonmNextRaceButton
 
ButtonmPrevRaceButton
 
LabelmRaceLabel
 
LabelmRaceNameLabel
 
ButtonmNextLookButton
 
ButtonmPrevLookButton
 
LabelmLookLabel
 
LabelmLookNameLabel
 
ButtonmActionButton
 
ButtonmRotateButton
 
std::vector< Slider * > mAttributeSlider
 
std::vector< Label * > mAttributeLabel
 
std::vector< Label * > mAttributeValue
 
LabelmAttributesLeft
 
ButtonmCreateButton
 
ButtonmCancelButton
 
BeingmPlayer
 
PlayerBoxmPlayerBox
 
TabStripmGenderStrip
 
int mMaxPoints
 
int mUsedPoints
 
int mRace
 
int mLook
 
int mMinLook
 
int mMaxLook
 
int mMinRace
 
int mMaxRace
 
int mHairStyle
 
int mHairColor
 
uint32_t mMaxY
 
int mSlot
 
GenderT mDefaultGender
 
GenderT mGender
 
unsigned int maxHairColor
 
unsigned int minHairColor
 
unsigned int maxHairStyle
 
unsigned int minHairStyle
 
unsigned int mAction
 
unsigned int mDirection
 

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 Member Functions inherited from KeyListener
 KeyListener ()
 
- 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

Character creation dialog.

Definition at line 48 of file charcreatedialog.h.

Constructor & Destructor Documentation

◆ CharCreateDialog()

CharCreateDialog::CharCreateDialog ( CharSelectDialog *const  parent,
const int  slot 
)

Constructor.

Definition at line 76 of file charcreatedialog.cpp.

77  :
78  // TRANSLATORS: char create dialog name
79  Window(_("New Character"), Modal_true, parent, "charcreate.xml"),
81  KeyListener(),
82  mCharSelectDialog(parent),
83  mNameField(new TextField(this, std::string(),
84  LoseFocusOnTab_true, nullptr, std::string(), false)),
85  // TRANSLATORS: char create dialog label
86  mNameLabel(new Label(this, _("Name:"))),
87  mNextHairColorButton(nullptr),
88  mPrevHairColorButton(nullptr),
89  mHairColorLabel(nullptr),
90  mHairColorNameLabel(nullptr),
91  mNextHairStyleButton(nullptr),
92  mPrevHairStyleButton(nullptr),
93  mHairStyleLabel(nullptr),
94  mHairStyleNameLabel(nullptr),
95  mNextRaceButton(nullptr),
96  mPrevRaceButton(nullptr),
97  mRaceLabel(nullptr),
98  mRaceNameLabel(nullptr),
99  mNextLookButton(nullptr),
100  mPrevLookButton(nullptr),
101  mLookLabel(nullptr),
102  mLookNameLabel(nullptr),
103  // TRANSLATORS: char create dialog button
104  mActionButton(new Button(this, _("^"), "action", BUTTON_SKIN, this)),
105  // TRANSLATORS: char create dialog button
106  mRotateButton(new Button(this, _(">"), "rotate", BUTTON_SKIN, this)),
108  mAttributeLabel(),
109  mAttributeValue(),
110  mAttributesLeft(new Label(this,
111  // TRANSLATORS: char create dialog label
112  strprintf(_("Please distribute %d points"), 99))),
113  // TRANSLATORS: char create dialog button
114  mCreateButton(new Button(this, _("Create"), "create", BUTTON_SKIN, this)),
115  // TRANSLATORS: char create dialog button
116  mCancelButton(new Button(this, _("Cancel"), "cancel", BUTTON_SKIN, this)),
120  nullptr)),
121  mPlayerBox(new PlayerBox(this, mPlayer, "charcreate_playerbox.xml",
122  "charcreate_selectedplayerbox.xml")),
123  mGenderStrip(nullptr),
124  mMaxPoints(0),
125  mUsedPoints(0),
127  mLook(0),
132  mHairStyle(0),
133  mHairColor(0),
134  mMaxY(0U),
135  mSlot(slot),
142  mAction(0),
143  mDirection(0)
144 {
145  setStickyButtonLock(true);
146  setSticky(true);
147  setWindowName("NewCharacter");
148 
149  const int w = 480;
150  const int h = 350;
151  setContentSize(w, h);
152 
154  const STD_VECTOR<BeingSlot> &items = CharDB::getDefaultItems();
155  int i = 1;
156  for (STD_VECTOR<BeingSlot>::const_iterator it = items.begin(),
157  it_fend = items.end();
158  it != it_fend;
159  ++ it, i ++)
160  {
161  const BeingSlot &beingSlot = *it;
163  beingSlot.spriteId,
164  beingSlot.cardsId);
165  }
166 
167  if (maxHairColor == 0U)
169  if (maxHairStyle == 0U)
171 
172  if (maxHairStyle != 0U)
173  {
174  mHairStyle = (CAST_U32(rand())
176  }
177  else
178  {
179  mHairStyle = 0;
180  }
181  if (maxHairColor != 0U)
182  {
183  mHairColor = (CAST_U32(rand())
185  }
186  else
187  {
188  mHairColor = 0;
189  }
190 
191  mNameField->setMaximum(24);
192 
194  {
195  mNextHairColorButton = new Button(this,
196  // TRANSLATORS: This is a narrow symbol used to denote 'next'.
197  // You may change this symbol if your language uses another.
198  // TRANSLATORS: char create dialog button
199  _(">"),
200  "nextcolor",
201  BUTTON_SKIN,
202  this);
203  mPrevHairColorButton = new Button(this,
204  // TRANSLATORS: This is a narrow symbol used to denote 'previous'.
205  // You may change this symbol if your language uses another.
206  // TRANSLATORS: char create dialog button
207  _("<"),
208  "prevcolor",
209  BUTTON_SKIN,
210  this);
211  // TRANSLATORS: char create dialog label
212  mHairColorLabel = new Label(this, _("Hair color:"));
213  mHairColorNameLabel = new Label(this, "");
214  }
215 
217  {
218  mNextHairStyleButton = new Button(this,
219  // TRANSLATORS: char create dialog button
220  _(">"),
221  "nextstyle",
222  BUTTON_SKIN,
223  this);
224  mPrevHairStyleButton = new Button(this,
225  // TRANSLATORS: char create dialog button
226  _("<"),
227  "prevstyle",
228  BUTTON_SKIN,
229  this);
230  // TRANSLATORS: char create dialog label
231  mHairStyleLabel = new Label(this, _("Hair style:"));
232  mHairStyleNameLabel = new Label(this, "");
233  }
234 
236  {
237  mNextRaceButton = new Button(this,
238  // TRANSLATORS: char create dialog button
239  _(">"),
240  "nextrace",
241  BUTTON_SKIN,
242  this);
243  mPrevRaceButton = new Button(this,
244  // TRANSLATORS: char create dialog button
245  _("<"),
246  "prevrace",
247  BUTTON_SKIN,
248  this);
249  // TRANSLATORS: char create dialog label
250  mRaceLabel = new Label(this, _("Race:"));
251  mRaceNameLabel = new Label(this, "");
252  }
254  {
255  mNextLookButton = new Button(this,
256  // TRANSLATORS: char create dialog button
257  _(">"),
258  "nextlook",
259  BUTTON_SKIN,
260  this);
261  mPrevLookButton = new Button(this,
262  // TRANSLATORS: char create dialog button
263  _("<"),
264  "prevlook",
265  BUTTON_SKIN,
266  this);
267  // TRANSLATORS: char create dialog label
268  mLookLabel = new Label(this, _("Look:"));
269  mLookNameLabel = new Label(this, "");
270  }
271 
273  {
274  const int forceGender = features.getIntValue("forceCharGender");
275  if (forceGender == -1)
276  {
277  const int size = config.getIntValue("fontSize");
278  mGenderStrip = new TabStrip(this,
279  "gender_" + getWindowName(),
280  size + 16,
281  0);
282  mGenderStrip->setPressFirst(false);
284  mGenderStrip->setActionEventId("gender_");
285  // TRANSLATORS: one char size female character gender
286  mGenderStrip->addButton(_("F"), "f", false);
287  if (features.getIntValue("forceAccountGender") == -1)
288  {
289  // TRANSLATORS: one char size male character gender
290  mGenderStrip->addButton(_("M"), "m", false);
291  // TRANSLATORS: one char size unknown character gender
292  mGenderStrip->addButton(_("U"), "u", true);
293  }
294  else
295  {
296  // TRANSLATORS: one char size male character gender
297  mGenderStrip->addButton(_("M"), "m", true);
298  }
299 
301  add(mGenderStrip);
302 
303  mGenderStrip->setPosition(385, 130);
304  mGenderStrip->setWidth(500);
305  mGenderStrip->setHeight(50);
306  }
307  else
308  {
309  mGender = Being::intToGender(CAST_U8(forceGender));
311  }
312  }
313 
314  mPlayerBox->setWidth(74);
315 
316  mNameField->setActionEventId("create");
318 
319  mPlayerBox->setDimension(Rect(360, 0, 110, 90));
320  mActionButton->setPosition(385, 100);
321  mRotateButton->setPosition(415, 100);
322 
325  300, mNameField->getHeight()));
326 
327  const uint32_t labelPadding = getOption("labelPadding", 2);
328  const uint32_t leftX = 120 + mPadding;
329  const uint32_t rightX = 300 + mPadding;
330  const uint32_t labelX = mPadding;
331  uint32_t nameX = leftX + labelPadding;
332  uint32_t y = 30;
333  if (mPrevHairColorButton != nullptr)
334  nameX += mPrevHairColorButton->getWidth();
335  else if (mPrevHairStyleButton != nullptr)
336  nameX += mPrevHairStyleButton->getWidth();
337  else if (mPrevLookButton != nullptr)
338  nameX += mPrevLookButton->getWidth();
339  else if (mPrevRaceButton != nullptr)
340  nameX += mPrevRaceButton->getWidth();
341 
343  {
346  y += 5;
347  mHairColorLabel->setPosition(labelX, y);
349  y += 24;
350  }
352  {
355  y += 5;
356  mHairStyleLabel->setPosition(labelX, y);
358  y += 24;
359  }
360 
362  {
363  if (mPrevLookButton != nullptr)
364  mPrevLookButton->setPosition(leftX, y);
365  if (mNextLookButton != nullptr)
366  mNextLookButton->setPosition(rightX, y);
367  y += 5;
368  if (mLookLabel != nullptr)
369  mLookLabel->setPosition(labelX, y);
370  if (mLookNameLabel != nullptr)
371  mLookNameLabel->setPosition(nameX, y); // 93
372  y += 24;
373  }
375  {
376  if (mPrevRaceButton != nullptr)
377  mPrevRaceButton->setPosition(leftX, y);
378  if (mNextRaceButton != nullptr)
379  mNextRaceButton->setPosition(rightX, y);
380  y += 5;
381  if (mRaceLabel != nullptr)
382  mRaceLabel->setPosition(labelX, y);
383  if (mRaceNameLabel != nullptr)
384  mRaceNameLabel->setPosition(nameX, y);
385  }
386  mMaxY = y + 29 + getTitlePadding();
387 
388  updateSliders();
389  setButtonsPosition(w, h);
390 
391  add(mPlayerBox);
392  add(mNameField);
393  add(mNameLabel);
394 
396  {
401  }
402 
404  {
409  }
412 
414  {
417  add(mLookLabel);
419  }
420 
422  {
425  add(mRaceLabel);
427  }
428 
432 
433  center();
436 
437  updateHair();
439  updateRace();
441  updateLook();
442  updatePlayer();
443 
444  addKeyListener(this);
445 }
const BeingId BeingId_zero
Definition: beingid.h:30
const BeingTypeId BeingTypeId_zero
Definition: beingtypeid.h:30
const std::string BUTTON_SKIN
Definition: button.h:89
#define CAST_U32
Definition: cast.h:31
#define CAST_U8
Definition: cast.h:27
virtual void add(Widget *const widget)
static GenderT intToGender(const uint8_t sex) A_CONST
Definition: being.h:941
void setSpriteCards(const unsigned int slot, const int id, const CardsList &cards)
Definition: being.cpp:3048
virtual void setGender(const GenderT gender)
Definition: being.cpp:3581
static Being * createBeing(const BeingId id, const ActorTypeT type, const BeingTypeId subtype, Map *const map)
Definition: being.cpp:5575
Definition: button.h:102
unsigned int mDirection
TabStrip * mGenderStrip
unsigned int mAction
unsigned int minHairStyle
Button * mPrevHairStyleButton
Button * mPrevHairColorButton
std::vector< Label * > mAttributeLabel
Button * mNextHairStyleButton
unsigned int maxHairColor
CharSelectDialog * mCharSelectDialog
std::vector< Label * > mAttributeValue
Button * mNextHairColorButton
unsigned int minHairColor
void setButtonsPosition(const int w, const int h)
TextField * mNameField
std::vector< Slider * > mAttributeSlider
PlayerBox * mPlayerBox
unsigned int maxHairStyle
int getIntValue(const std::string &key) const
Definition: label.h:91
virtual bool haveCreateCharGender() const =0
virtual bool haveRaceSelection() const =0
virtual bool haveLookSelection() const =0
Definition: rect.h:74
void setPressFirst(const bool press)
Definition: tabstrip.h:51
void setMaximum(const int max)
Definition: textfield.h:158
virtual void addButton(const std::string &text, const std::string &tag, const bool pressed)
Definition: widgetgroup.cpp:42
void setVisible(Visible visible)
Definition: widget.cpp:225
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 addKeyListener(KeyListener *const keyListener)
Definition: widget.cpp:272
virtual void requestFocus()
Definition: widget.cpp:204
void setDimension(const Rect &dimension)
Definition: widget.cpp:169
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:252
void setPosition(const int x, const int y)
Definition: widget.cpp:161
int getHeight() const
Definition: widget.h:240
int getWidth() const
Definition: widget.h:221
void center()
Definition: window.cpp:1417
virtual void setVisible(Visible visible)
Definition: window.cpp:778
void setContentSize(int width, int height)
Definition: window.cpp:492
int getTitlePadding() const
Definition: window.h:602
void setWindowName(const std::string &name)
Definition: window.h:355
int getOption(const std::string &name, const int def) const
Definition: window.cpp:1454
Window(const std::string &caption, const Modal modal, Window *const parent, std::string skin)
Definition: window.cpp:109
void setSticky(const bool sticky)
Definition: window.cpp:766
const std::string & getWindowName() const
Definition: window.h:361
int mPadding
Definition: window.h:618
void setStickyButtonLock(const bool sticky)
Definition: window.cpp:772
Configuration config
Configuration features
#define _(s)
Definition: gettext.h:35
const bool LoseFocusOnTab_true
const bool Modal_true
Definition: modal.h:30
const std::vector< BeingSlot > & getDefaultItems()
Definition: chardb.cpp:187
unsigned getMinLook()
Definition: chardb.cpp:167
unsigned getMinRace()
Definition: chardb.cpp:177
unsigned getMaxLook()
Definition: chardb.cpp:172
unsigned getMinHairStyle()
Definition: chardb.cpp:142
unsigned getMaxHairStyle()
Definition: chardb.cpp:147
unsigned getMaxHairColor()
Definition: chardb.cpp:137
unsigned getMaxRace()
Definition: chardb.cpp:182
unsigned getMinHairColor()
Definition: chardb.cpp:132
int getHairSize()
Definition: colordb.cpp:213
int size()
Definition: emotedb.cpp:306
@ UNSPECIFIED
Definition: gender.h:33
@ MALE
Definition: gender.h:31
@ FEMALE
Definition: gender.h:32
int getNumOfHairstyles()
Definition: itemdb.cpp:1192
Net::ServerFeatures * serverFeatures
Definition: net.cpp:101
std::string strprintf(const char *const format,...)
int spriteId
Definition: beingslot.h:45
CardsList cardsId
Definition: beingslot.h:46
const bool Visible_true
Definition: visible.h:30

References _, BasicContainer2::add(), Widget::addActionListener(), WidgetGroup::addButton(), Widget::addKeyListener(), BUTTON_SKIN, BeingSlot::cardsId, CAST_U32, CAST_U8, Window::center(), config, features, CharDB::getDefaultItems(), ColorDB::getHairSize(), Widget::getHeight(), Configuration::getIntValue(), ItemDB::getNumOfHairstyles(), Window::getOption(), Window::getTitlePadding(), Widget::getWidth(), Window::getWindowName(), Net::ServerFeatures::haveCreateCharGender(), Net::ServerFeatures::haveLookSelection(), Net::ServerFeatures::haveRaceSelection(), Being::intToGender(), mActionButton, Gender::MALE, mAttributesLeft, maxHairColor, maxHairStyle, mCancelButton, mCreateButton, mGender, mGenderStrip, mHairColor, mHairColorLabel, mHairColorNameLabel, mHairStyle, mHairStyleLabel, mHairStyleNameLabel, minHairColor, minHairStyle, mLookLabel, mLookNameLabel, mMaxLook, mMaxRace, mMaxY, mMinLook, mMinRace, mNameField, mNameLabel, mNextHairColorButton, mNextHairStyleButton, mNextLookButton, mNextRaceButton, Window::mPadding, mPlayer, mPlayerBox, mPrevHairColorButton, mPrevHairStyleButton, mPrevLookButton, mPrevRaceButton, mRaceLabel, mRaceNameLabel, mRotateButton, Widget::requestFocus(), serverFeatures, Widget::setActionEventId(), setButtonsPosition(), Window::setContentSize(), Widget::setDimension(), Being::setGender(), Widget::setHeight(), TextField::setMaximum(), Widget::setPosition(), TabStrip::setPressFirst(), Being::setSpriteCards(), Window::setSticky(), Window::setStickyButtonLock(), Widget::setVisible(), Window::setVisible(), Widget::setWidth(), Window::setWindowName(), EmoteDB::size(), BeingSlot::spriteId, updateHair(), updateLook(), updatePlayer(), updateRace(), updateSliders(), Visible_true, and y.

◆ ~CharCreateDialog()

CharCreateDialog::~CharCreateDialog ( )

Destructor.

Definition at line 447 of file charcreatedialog.cpp.

448 {
450 
451  if (charServerHandler != nullptr)
453 }
Net::CharServerHandler * charServerHandler
Definition: net.cpp:85
virtual void setCharCreateDialog(CharCreateDialog *const window) const =0
#define delete2(var)
Definition: delete2.h:25

References charServerHandler, delete2, mPlayer, and Net::CharServerHandler::setCharCreateDialog().

Member Function Documentation

◆ action()

void CharCreateDialog::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 455 of file charcreatedialog.cpp.

456 {
457  const std::string &id = event.getId();
458  if (id == "create")
459  {
460  if (getName().length() >= 4)
461  {
462  // Attempt to create the character
463  mCreateButton->setEnabled(false);
464 
465  STD_VECTOR<int> atts;
466  const size_t sz = mAttributeSlider.size();
467  for (size_t i = 0; i < sz; i++)
468  {
469  atts.push_back(CAST_S32(
470  mAttributeSlider[i]->getValue()));
471  }
472  for (size_t i = sz; i < 6; i ++)
473  atts.push_back(1);
474 
475  const int characterSlot = mSlot;
476 
478  characterSlot,
479  mGender,
480  mHairStyle,
481  mHairColor,
482  CAST_U8(mRace),
483  CAST_U8(mLook),
484  atts);
485  }
486  else
487  {
489  // TRANSLATORS: char creation error
490  _("Error"),
491  // TRANSLATORS: char creation error
492  _("Your name needs to be at least 4 characters."),
493  // TRANSLATORS: ok dialog button
494  _("OK"),
496  Modal_true,
498  nullptr,
499  260);
500  }
501  }
502  else if (id == "cancel")
503  {
504  scheduleDelete();
505  }
506  else if (id == "nextcolor")
507  {
508  mHairColor ++;
509  updateHair();
510  }
511  else if (id == "prevcolor")
512  {
513  mHairColor --;
514  updateHair();
515  }
516  else if (id == "nextstyle")
517  {
518  mHairStyle ++;
519  updateHair();
520  }
521  else if (id == "prevstyle")
522  {
523  mHairStyle --;
524  updateHair();
525  }
526  else if (id == "nextrace")
527  {
528  mRace ++;
529  updateRace();
530  }
531  else if (id == "prevrace")
532  {
533  mRace --;
534  updateRace();
535  }
536  else if (id == "nextlook")
537  {
538  mLook ++;
539  updateLook();
540  }
541  else if (id == "prevlook")
542  {
543  mLook --;
544  updateLook();
545  }
546  else if (id == "statslider")
547  {
548  updateSliders();
549  }
550  else if (id == "action")
551  {
552  mAction ++;
553  if (mAction >= 5)
554  mAction = 0;
555  updatePlayer();
556  }
557  else if (id == "rotate")
558  {
559  mDirection ++;
560  if (mDirection >= 4)
561  mDirection = 0;
562  updatePlayer();
563  }
564  else if (id == "gender_m")
565  {
568  }
569  else if (id == "gender_f")
570  {
573  }
574  else if (id == "gender_u")
575  {
578  }
579 }
#define CAST_S32
Definition: cast.h:30
std::string getName() const
virtual void newCharacter(const std::string &name, const int slot, const GenderT gender, const int hairstyle, const int hairColor, const unsigned char race, const uint16_t look, const std::vector< int > &stats) const =0
void setEnabled(const bool enabled)
Definition: widget.h:352
virtual void scheduleDelete()
Definition: window.cpp:831
#define CREATEWIDGET(type,...)
Definition: createwidget.h:29
const bool ShowCenter_true
Definition: showcenter.h:30

References _, CAST_S32, CAST_U8, charServerHandler, CREATEWIDGET, DialogType::ERROR, Gender::FEMALE, getName(), mAction, Gender::MALE, mAttributeSlider, mCreateButton, mDefaultGender, mDirection, mGender, mHairColor, mHairStyle, mLook, Modal_true, mPlayer, mRace, mSlot, Net::CharServerHandler::newCharacter(), Window::scheduleDelete(), Widget::setEnabled(), Being::setGender(), ShowCenter_true, Gender::UNSPECIFIED, updateHair(), updateLook(), updatePlayer(), updateRace(), and updateSliders().

Referenced by keyPressed().

◆ attemptCharCreate()

void CharCreateDialog::attemptCharCreate ( )
private

Communicate character creation to the server.

◆ getDistributedPoints()

int CharCreateDialog::getDistributedPoints ( ) const
private

Definition at line 631 of file charcreatedialog.cpp.

632 {
633  unsigned int points = 0;
634 
635  for (size_t i = 0, sz = mAttributeSlider.size(); i < sz; i++)
636  points += CAST_U32(mAttributeSlider[i]->getValue());
637  return CAST_S32(points);
638 }

References CAST_S32, CAST_U32, and mAttributeSlider.

Referenced by updateSliders().

◆ getName()

std::string CharCreateDialog::getName ( ) const
private

Returns the name of the character to create.

Definition at line 581 of file charcreatedialog.cpp.

582 {
583  std::string name = mNameField->getText();
584  trim(name);
585  return name;
586 }
const std::string & getText() const
Definition: textfield.h:224
std::string trim(std::string const &str)

References TextField::getText(), mNameField, and Catch::trim().

Referenced by action().

◆ keyPressed()

void CharCreateDialog::keyPressed ( KeyEvent event)
virtual

Called if a key is pressed when the widget has keyboard focus. If a key is held down the widget will generate multiple key presses.

Parameters
eventDiscribes the event.

Reimplemented from KeyListener.

Definition at line 850 of file charcreatedialog.cpp.

851 {
852  const InputActionT actionId = event.getActionId();
853  PRAGMA45(GCC diagnostic push)
854  PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
855  switch (actionId)
856  {
858  event.consume();
861  break;
862 
863  default:
864  break;
865  }
866  PRAGMA45(GCC diagnostic pop)
867 }
void action(const ActionEvent &event)
const std::string & getActionEventId() const
Definition: widget.h:605
PRAGMA45(GCC diagnostic push) PRAGMA45(GCC diagnostic ignored "-Wredundant-decls") PRAGMA45(GCC diagnostic pop) class TestMain
InputAction ::T InputActionT
Definition: inputaction.h:717

References action(), Widget::getActionEventId(), InputAction::GUI_CANCEL, mCancelButton, and PRAGMA45().

◆ logic()

void CharCreateDialog::logic ( )
virtual

Called for all widgets in the gui each time Gui::logic is called. You can do logic stuff here like playing an animation.

See also
Gui::logic

Reimplemented from BasicContainer.

Definition at line 833 of file charcreatedialog.cpp.

834 {
835  BLOCK_START("CharCreateDialog::logic")
836  if (mPlayer != nullptr)
837  mPlayer->logic();
839 }
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79

References BLOCK_END, BLOCK_START, Being::logic(), and mPlayer.

◆ setAttributes()

void CharCreateDialog::setAttributes ( const StringVect labels,
int  available,
const int  min,
const int  max 
)

Definition at line 640 of file charcreatedialog.cpp.

643 {
644  size_t sz;
645 
646  if (min == max || available == 0)
647  {
648  sz = 0U;
649  available = 0;
650  }
651  else
652  {
653  sz = labels.size();
654  }
655 
656  mMaxPoints = available;
657 
658  for (size_t i = 0; i < mAttributeLabel.size(); i++)
659  {
666  }
667 
668  mAttributeLabel.resize(sz);
669  mAttributeSlider.resize(sz);
670  mAttributeValue.resize(sz);
671 
672  const uint32_t w = 480;
673  uint32_t h = 350;
674  uint32_t y = 89;
676  y += 29;
678  y += 29;
679 
680  for (size_t i = 0; i < sz; i++)
681  {
682  mAttributeLabel[i] = new Label(this, labels[i]);
683  mAttributeLabel[i]->setWidth(70);
684  mAttributeLabel[i]->setPosition(mPadding,
685  y + CAST_S32(i * 24));
686  mAttributeLabel[i]->adjustSize();
687  add(mAttributeLabel[i]);
688 
689  mAttributeSlider[i] = new Slider(this, min, max, 1.0);
690  mAttributeSlider[i]->setDimension(Rect(140 + mPadding,
691  y + CAST_S32(i * 24),
692  150,
693  12));
694  mAttributeSlider[i]->setActionEventId("statslider");
695  mAttributeSlider[i]->addActionListener(this);
696  add(mAttributeSlider[i]);
697 
698  mAttributeValue[i] = new Label(this, toString(min));
699  mAttributeValue[i]->setPosition(295 + mPadding,
700  y + CAST_S32(i * 24));
701  add(mAttributeValue[i]);
702  }
703 
704  updateSliders();
705  if (available == 0)
706  {
708  h = y;
709  }
710  else
711  {
712  h = y +
713  CAST_S32(sz) * 24 +
715  getPadding();
716  }
718  features.getIntValue("forceCharGender") == -1 &&
719  y < 160)
720  {
721  if (h < 160)
722  h = 160;
723  }
724  if (h < mMaxY)
725  h = mMaxY;
727  {
728  const int forceGender = features.getIntValue("forceCharGender");
729  if (forceGender == -1 && h < 180)
730  h = 180;
731  else if (h < 120)
732  h = 120;
733  }
734  h += mCreateButton->getHeight();
735 
736  setContentSize(w, h);
737  setButtonsPosition(w, h);
738 }
virtual void remove(Widget *const widget)
Definition: slider.h:89
int getPadding() const
Definition: window.h:504
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
const bool Visible_false
Definition: visible.h:30

References BasicContainer2::add(), CAST_S32, delete2, features, Widget::getHeight(), Configuration::getIntValue(), Window::getPadding(), Net::ServerFeatures::haveCreateCharGender(), Net::ServerFeatures::haveLookSelection(), Net::ServerFeatures::haveRaceSelection(), mAttributeLabel, mAttributesLeft, mAttributeSlider, mAttributeValue, mCreateButton, mMaxLook, mMaxPoints, mMaxRace, mMaxY, mMinLook, mMinRace, Window::mPadding, BasicContainer::remove(), serverFeatures, setButtonsPosition(), Window::setContentSize(), Widget::setVisible(), Catch::toString(), updateSliders(), Visible_false, and y.

Referenced by EAthena::CharServerHandler::setCharCreateDialog(), and TmwAthena::CharServerHandler::setCharCreateDialog().

◆ setButtonsPosition()

void CharCreateDialog::setButtonsPosition ( const int  w,
const int  h 
)
private

Definition at line 869 of file charcreatedialog.cpp.

870 {
871  const int h2 = h - 5 - mCancelButton->getHeight();
872  if (mainGraphics->getHeight() < 480)
873  {
874  if (mMaxPoints != 0)
875  {
876  mCreateButton->setPosition(337, 160);
878  }
879  else
880  {
882  w / 2,
883  160);
886  160);
887  }
888  }
889  else
890  {
892  w / 2,
893  h2);
896  h2);
897  }
899 }
int getHeight() const
Definition: graphics.cpp:648
int getX() const
Definition: widget.h:269
Graphics * mainGraphics
Definition: graphics.cpp:109

References Widget::getHeight(), Graphics::getHeight(), Widget::getWidth(), Widget::getX(), mainGraphics, mAttributesLeft, mCancelButton, mCreateButton, mMaxPoints, and Widget::setPosition().

Referenced by CharCreateDialog(), and setAttributes().

◆ setDefaultGender()

void CharCreateDialog::setDefaultGender ( const GenderT  gender)

Definition at line 740 of file charcreatedialog.cpp.

741 {
742  if (features.getIntValue("forceCharGender") != -1)
743  return;
744 
745  mDefaultGender = gender;
746  mPlayer->setGender(gender);
747 }

References features, Configuration::getIntValue(), mDefaultGender, mPlayer, and Being::setGender().

Referenced by EAthena::CharServerHandler::setCharCreateDialog(), and TmwAthena::CharServerHandler::setCharCreateDialog().

◆ unlock()

void CharCreateDialog::unlock ( )

Unlocks the dialog, enabling the create character button again.

Definition at line 626 of file charcreatedialog.cpp.

627 {
628  mCreateButton->setEnabled(true);
629 }

References mCreateButton, and Widget::setEnabled().

Referenced by Ea::CharServerRecv::processCharCreateFailed().

◆ updateHair()

void CharCreateDialog::updateHair ( )
private

Definition at line 749 of file charcreatedialog.cpp.

750 {
751  if (mHairStyle <= 0)
753  else
757  {
759  }
760  const ItemInfo &item = ItemDB::get(-mHairStyle);
761  if (mHairStyleNameLabel != nullptr)
762  {
764  mHairStyleNameLabel->resizeTo(150, 150);
765  }
766 
767  if (ColorDB::getHairSize() != 0)
769  else
770  mHairColor = 0;
771  if (mHairColor < 0)
775  {
777  }
778  if (mHairColorNameLabel != nullptr)
779  {
782  mHairColorNameLabel->resizeTo(150, 150);
783  }
784 
786  mHairStyle * -1,
788  updatePlayer();
789 }
void setSpriteColor(const unsigned int slot, const int id, const std::string &color)
Definition: being.cpp:2890
const std::string & getName() const
Definition: iteminfo.h:74
std::string getDyeColorsString(const ItemColor color) const
Definition: iteminfo.cpp:227
void resizeTo(const int maxSize, const int minSize)
Definition: label.cpp:227
void setCaption(const std::string &caption)
Definition: label.cpp:264
virtual unsigned int hairSprite() const =0
#define fromInt(val, name)
Definition: intdefines.h:46
uint16_t ItemColor
Definition: itemcolor.h:30
std::string & getHairColorName(const ItemColor id)
Definition: colordb.cpp:190
const ItemInfo & get(const int id)
Definition: itemdb.cpp:792

References CAST_S32, charServerHandler, fromInt, ItemDB::get(), ItemInfo::getDyeColorsString(), ColorDB::getHairColorName(), ColorDB::getHairSize(), ItemInfo::getName(), ItemDB::getNumOfHairstyles(), Net::CharServerHandler::hairSprite(), maxHairColor, maxHairStyle, mHairColor, mHairColorNameLabel, mHairStyle, mHairStyleNameLabel, minHairColor, minHairStyle, mPlayer, Label::resizeTo(), Label::setCaption(), Being::setSpriteColor(), and updatePlayer().

Referenced by action(), and CharCreateDialog().

◆ updateLook()

void CharCreateDialog::updateLook ( )
private

Definition at line 801 of file charcreatedialog.cpp.

802 {
803  const ItemInfo &item = ItemDB::get(-100 - mRace);
804  const int sz = item.getColorsSize();
805  if (sz > 0 && serverFeatures->haveLookSelection())
806  {
807  if (mLook < 0)
808  mLook = sz - 1;
809  if (mLook > mMaxLook)
810  mLook = mMinLook;
811  if (mLook >= sz)
812  mLook = mMinLook;
813  }
814  else
815  {
816  mLook = 0;
817  }
819  CAST_U8(mLook));
820  if (mRaceNameLabel != nullptr)
821  {
823  mRaceNameLabel->resizeTo(150, 150);
824  }
825  if (mLookNameLabel != nullptr)
826  {
828  fromInt(mLook, ItemColor)));
829  mLookNameLabel->resizeTo(150, 150);
830  }
831 }
int BeingTypeId
Definition: beingtypeid.h:30
void setSubtype(const BeingTypeId subtype, const uint16_t look)
Definition: being.cpp:371
int getColorsSize() const
Definition: iteminfo.h:304
std::string getColorName(const ItemColor idx) const
Definition: iteminfo.cpp:413

References CAST_U8, fromInt, ItemDB::get(), ItemInfo::getColorName(), ItemInfo::getColorsSize(), ItemInfo::getName(), Net::ServerFeatures::haveLookSelection(), mLook, mLookNameLabel, mMaxLook, mMinLook, mPlayer, mRace, mRaceNameLabel, Label::resizeTo(), serverFeatures, Label::setCaption(), and Being::setSubtype().

Referenced by action(), CharCreateDialog(), and updateRace().

◆ updatePlayer()

void CharCreateDialog::updatePlayer ( )

Definition at line 841 of file charcreatedialog.cpp.

842 {
843  if (mPlayer != nullptr)
844  {
847  }
848 }
static const uint8_t directions[]
static const BeingActionT actions[]
virtual void setDirection(const uint8_t direction)
Definition: being.cpp:1690
virtual void setAction(const BeingActionT &action, const int attackId)
Definition: being.cpp:1554

References actions, directions, mAction, mDirection, mPlayer, Being::setAction(), and Being::setDirection().

Referenced by action(), CharCreateDialog(), and updateHair().

◆ updateRace()

void CharCreateDialog::updateRace ( )
private

Definition at line 791 of file charcreatedialog.cpp.

792 {
793  if (mRace < mMinRace)
794  mRace = mMaxRace;
795  else if (mRace > mMaxRace)
796  mRace = mMinRace;
797 
798  updateLook();
799 }

References mMaxRace, mMinRace, mRace, and updateLook().

Referenced by action(), and CharCreateDialog().

◆ updateSliders()

void CharCreateDialog::updateSliders ( )
private

Definition at line 588 of file charcreatedialog.cpp.

589 {
590  for (size_t i = 0, sz = mAttributeSlider.size(); i < sz; i++)
591  {
592  // Update captions
593  mAttributeValue[i]->setCaption(
594  toString(CAST_S32(mAttributeSlider[i]->getValue())));
595  mAttributeValue[i]->adjustSize();
596  }
597 
598  // Update distributed points
599  const int pointsLeft = mMaxPoints - getDistributedPoints();
600  if (pointsLeft == 0)
601  {
602  // TRANSLATORS: char create dialog label
603  mAttributesLeft->setCaption(_("Character stats OK"));
604  mCreateButton->setEnabled(true);
605  }
606  else
607  {
608  mCreateButton->setEnabled(false);
609  if (pointsLeft > 0)
610  {
612  // TRANSLATORS: char create dialog label
613  strprintf(_("Please distribute %d points"), pointsLeft));
614  }
615  else
616  {
618  // TRANSLATORS: char create dialog label
619  strprintf(_("Please remove %d points"), -pointsLeft));
620  }
621  }
622 
624 }
int getDistributedPoints() const
void adjustSize()
Definition: label.cpp:200

References _, Label::adjustSize(), CAST_S32, getDistributedPoints(), mAttributesLeft, mAttributeSlider, mAttributeValue, mCreateButton, mMaxPoints, Label::setCaption(), Widget::setEnabled(), strprintf(), and Catch::toString().

Referenced by action(), CharCreateDialog(), and setAttributes().

Field Documentation

◆ mAction

unsigned int CharCreateDialog::mAction
private

Definition at line 168 of file charcreatedialog.h.

Referenced by action(), and updatePlayer().

◆ mActionButton

Button* CharCreateDialog::mActionButton
private

Definition at line 128 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mAttributeLabel

std::vector<Label*> CharCreateDialog::mAttributeLabel
private

Definition at line 132 of file charcreatedialog.h.

Referenced by setAttributes().

◆ mAttributesLeft

Label* CharCreateDialog::mAttributesLeft
private

◆ mAttributeSlider

std::vector<Slider*> CharCreateDialog::mAttributeSlider
private

Definition at line 131 of file charcreatedialog.h.

Referenced by action(), getDistributedPoints(), setAttributes(), and updateSliders().

◆ mAttributeValue

std::vector<Label*> CharCreateDialog::mAttributeValue
private

Definition at line 133 of file charcreatedialog.h.

Referenced by setAttributes(), and updateSliders().

◆ maxHairColor

unsigned int CharCreateDialog::maxHairColor
private

Definition at line 163 of file charcreatedialog.h.

Referenced by CharCreateDialog(), and updateHair().

◆ maxHairStyle

unsigned int CharCreateDialog::maxHairStyle
private

Definition at line 165 of file charcreatedialog.h.

Referenced by CharCreateDialog(), and updateHair().

◆ mCancelButton

Button* CharCreateDialog::mCancelButton
private

Definition at line 137 of file charcreatedialog.h.

Referenced by CharCreateDialog(), keyPressed(), and setButtonsPosition().

◆ mCharSelectDialog

CharSelectDialog* CharCreateDialog::mCharSelectDialog
private

Definition at line 107 of file charcreatedialog.h.

◆ mCreateButton

Button* CharCreateDialog::mCreateButton
private

◆ mDefaultGender

GenderT CharCreateDialog::mDefaultGender
private

Definition at line 160 of file charcreatedialog.h.

Referenced by action(), and setDefaultGender().

◆ mDirection

unsigned int CharCreateDialog::mDirection
private

Definition at line 169 of file charcreatedialog.h.

Referenced by action(), and updatePlayer().

◆ mGender

GenderT CharCreateDialog::mGender
private

Definition at line 161 of file charcreatedialog.h.

Referenced by action(), and CharCreateDialog().

◆ mGenderStrip

TabStrip* CharCreateDialog::mGenderStrip
private

Definition at line 142 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mHairColor

int CharCreateDialog::mHairColor
private

Definition at line 155 of file charcreatedialog.h.

Referenced by action(), CharCreateDialog(), and updateHair().

◆ mHairColorLabel

Label* CharCreateDialog::mHairColorLabel
private

Definition at line 113 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mHairColorNameLabel

Label* CharCreateDialog::mHairColorNameLabel
private

Definition at line 114 of file charcreatedialog.h.

Referenced by CharCreateDialog(), and updateHair().

◆ mHairStyle

int CharCreateDialog::mHairStyle
private

Definition at line 154 of file charcreatedialog.h.

Referenced by action(), CharCreateDialog(), and updateHair().

◆ mHairStyleLabel

Label* CharCreateDialog::mHairStyleLabel
private

Definition at line 117 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mHairStyleNameLabel

Label* CharCreateDialog::mHairStyleNameLabel
private

Definition at line 118 of file charcreatedialog.h.

Referenced by CharCreateDialog(), and updateHair().

◆ minHairColor

unsigned int CharCreateDialog::minHairColor
private

Definition at line 164 of file charcreatedialog.h.

Referenced by CharCreateDialog(), and updateHair().

◆ minHairStyle

unsigned int CharCreateDialog::minHairStyle
private

Definition at line 166 of file charcreatedialog.h.

Referenced by CharCreateDialog(), and updateHair().

◆ mLook

int CharCreateDialog::mLook
private

Definition at line 148 of file charcreatedialog.h.

Referenced by action(), and updateLook().

◆ mLookLabel

Label* CharCreateDialog::mLookLabel
private

Definition at line 125 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mLookNameLabel

Label* CharCreateDialog::mLookNameLabel
private

Definition at line 126 of file charcreatedialog.h.

Referenced by CharCreateDialog(), and updateLook().

◆ mMaxLook

int CharCreateDialog::mMaxLook
private

Definition at line 150 of file charcreatedialog.h.

Referenced by CharCreateDialog(), setAttributes(), and updateLook().

◆ mMaxPoints

int CharCreateDialog::mMaxPoints
private

Definition at line 144 of file charcreatedialog.h.

Referenced by setAttributes(), setButtonsPosition(), and updateSliders().

◆ mMaxRace

int CharCreateDialog::mMaxRace
private

Definition at line 152 of file charcreatedialog.h.

Referenced by CharCreateDialog(), setAttributes(), and updateRace().

◆ mMaxY

uint32_t CharCreateDialog::mMaxY
private

Definition at line 156 of file charcreatedialog.h.

Referenced by CharCreateDialog(), and setAttributes().

◆ mMinLook

int CharCreateDialog::mMinLook
private

Definition at line 149 of file charcreatedialog.h.

Referenced by CharCreateDialog(), setAttributes(), and updateLook().

◆ mMinRace

int CharCreateDialog::mMinRace
private

Definition at line 151 of file charcreatedialog.h.

Referenced by CharCreateDialog(), setAttributes(), and updateRace().

◆ mNameField

TextField* CharCreateDialog::mNameField
private

Definition at line 109 of file charcreatedialog.h.

Referenced by CharCreateDialog(), and getName().

◆ mNameLabel

Label* CharCreateDialog::mNameLabel
private

Definition at line 110 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mNextHairColorButton

Button* CharCreateDialog::mNextHairColorButton
private

Definition at line 111 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mNextHairStyleButton

Button* CharCreateDialog::mNextHairStyleButton
private

Definition at line 115 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mNextLookButton

Button* CharCreateDialog::mNextLookButton
private

Definition at line 123 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mNextRaceButton

Button* CharCreateDialog::mNextRaceButton
private

Definition at line 119 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mPlayer

Being* CharCreateDialog::mPlayer
private

◆ mPlayerBox

PlayerBox* CharCreateDialog::mPlayerBox
private

Definition at line 140 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mPrevHairColorButton

Button* CharCreateDialog::mPrevHairColorButton
private

Definition at line 112 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mPrevHairStyleButton

Button* CharCreateDialog::mPrevHairStyleButton
private

Definition at line 116 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mPrevLookButton

Button* CharCreateDialog::mPrevLookButton
private

Definition at line 124 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mPrevRaceButton

Button* CharCreateDialog::mPrevRaceButton
private

Definition at line 120 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mRace

int CharCreateDialog::mRace
private

Definition at line 147 of file charcreatedialog.h.

Referenced by action(), updateLook(), and updateRace().

◆ mRaceLabel

Label* CharCreateDialog::mRaceLabel
private

Definition at line 121 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mRaceNameLabel

Label* CharCreateDialog::mRaceNameLabel
private

Definition at line 122 of file charcreatedialog.h.

Referenced by CharCreateDialog(), and updateLook().

◆ mRotateButton

Button* CharCreateDialog::mRotateButton
private

Definition at line 129 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mSlot

int CharCreateDialog::mSlot
private

Definition at line 158 of file charcreatedialog.h.

Referenced by action().

◆ mUsedPoints

int CharCreateDialog::mUsedPoints
private

Definition at line 145 of file charcreatedialog.h.


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