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=Gender::FEMALE)
 
void logic ()
 
void updatePlayer ()
 
void keyPressed (KeyEvent &event)
 
- 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)
 
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=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 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 ()
 
- 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=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 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 47 of file charcreatedialog.h.

Constructor & Destructor Documentation

◆ CharCreateDialog()

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

Constructor.

Definition at line 75 of file charcreatedialog.cpp.

References _, BasicContainer2::add(), Widget::addActionListener(), WidgetGroup::addButton(), Widget::addKeyListener(), 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::haveCharOtherGender(), 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(), Window::setVisible(), Widget::setVisible(), Widget::setWidth(), Window::setWindowName(), ServerCommandType::size, BeingSlot::spriteId, updateHair(), updateLook(), updatePlayer(), updateRace(), updateSliders(), Visible_true, and y.

76  :
77  // TRANSLATORS: char create dialog name
78  Window(_("New Character"), Modal_true, parent, "charcreate.xml"),
80  KeyListener(),
81  mCharSelectDialog(parent),
82  mNameField(new TextField(this, "")),
83  // TRANSLATORS: char create dialog label
84  mNameLabel(new Label(this, _("Name:"))),
85  mNextHairColorButton(nullptr),
86  mPrevHairColorButton(nullptr),
87  mHairColorLabel(nullptr),
88  mHairColorNameLabel(nullptr),
89  mNextHairStyleButton(nullptr),
90  mPrevHairStyleButton(nullptr),
91  mHairStyleLabel(nullptr),
92  mHairStyleNameLabel(nullptr),
93  mNextRaceButton(nullptr),
94  mPrevRaceButton(nullptr),
95  mRaceLabel(nullptr),
96  mRaceNameLabel(nullptr),
97  mNextLookButton(nullptr),
98  mPrevLookButton(nullptr),
99  mLookLabel(nullptr),
100  mLookNameLabel(nullptr),
101  // TRANSLATORS: char create dialog button
102  mActionButton(new Button(this, _("^"), "action", this)),
103  // TRANSLATORS: char create dialog button
104  mRotateButton(new Button(this, _(">"), "rotate", this)),
106  mAttributeLabel(),
107  mAttributeValue(),
108  mAttributesLeft(new Label(this,
109  // TRANSLATORS: char create dialog label
110  strprintf(_("Please distribute %d points"), 99))),
111  // TRANSLATORS: char create dialog button
112  mCreateButton(new Button(this, _("Create"), "create", this)),
113  // TRANSLATORS: char create dialog button
114  mCancelButton(new Button(this, _("Cancel"), "cancel", this)),
118  nullptr)),
119  mPlayerBox(new PlayerBox(this, mPlayer, "charcreate_playerbox.xml",
120  "charcreate_selectedplayerbox.xml")),
121  mGenderStrip(nullptr),
122  mMaxPoints(0),
123  mUsedPoints(0),
125  mLook(0),
130  mHairStyle(0),
131  mHairColor(0),
132  mMaxY(0U),
133  mSlot(slot),
140  mAction(0),
141  mDirection(0)
142 {
143  setStickyButtonLock(true);
144  setSticky(true);
145  setWindowName("NewCharacter");
146 
147  const int w = 480;
148  const int h = 350;
149  setContentSize(w, h);
150 
152  const STD_VECTOR<BeingSlot> &items = CharDB::getDefaultItems();
153  int i = 1;
154  for (STD_VECTOR<BeingSlot>::const_iterator it = items.begin(),
155  it_fend = items.end();
156  it != it_fend;
157  ++ it, i ++)
158  {
159  const BeingSlot &beingSlot = *it;
161  beingSlot.spriteId,
162  beingSlot.cardsId);
163  }
164 
165  if (maxHairColor == 0u)
167  if (maxHairStyle == 0u)
169 
170  if (maxHairStyle != 0u)
171  {
172  mHairStyle = (CAST_U32(rand())
174  }
175  else
176  {
177  mHairStyle = 0;
178  }
179  if (maxHairColor != 0u)
180  {
181  mHairColor = (CAST_U32(rand())
183  }
184  else
185  {
186  mHairColor = 0;
187  }
188 
189  mNameField->setMaximum(24);
190 
192  {
193  // TRANSLATORS: This is a narrow symbol used to denote 'next'.
194  // You may change this symbol if your language uses another.
195  // TRANSLATORS: char create dialog button
196  mNextHairColorButton = new Button(this, _(">"), "nextcolor", this);
197  // TRANSLATORS: This is a narrow symbol used to denote 'previous'.
198  // You may change this symbol if your language uses another.
199  // TRANSLATORS: char create dialog button
200  mPrevHairColorButton = new Button(this, _("<"), "prevcolor", this);
201  // TRANSLATORS: char create dialog label
202  mHairColorLabel = new Label(this, _("Hair color:"));
203  mHairColorNameLabel = new Label(this, "");
204  }
205 
207  {
208  // TRANSLATORS: char create dialog button
209  mNextHairStyleButton = new Button(this, _(">"), "nextstyle", this);
210  // TRANSLATORS: char create dialog button
211  mPrevHairStyleButton = new Button(this, _("<"), "prevstyle", this);
212  // TRANSLATORS: char create dialog label
213  mHairStyleLabel = new Label(this, _("Hair style:"));
214  mHairStyleNameLabel = new Label(this, "");
215  }
216 
218  {
219  // TRANSLATORS: char create dialog button
220  mNextRaceButton = new Button(this, _(">"), "nextrace", this);
221  // TRANSLATORS: char create dialog button
222  mPrevRaceButton = new Button(this, _("<"), "prevrace", this);
223  // TRANSLATORS: char create dialog label
224  mRaceLabel = new Label(this, _("Race:"));
225  mRaceNameLabel = new Label(this, "");
226  }
228  {
229  // TRANSLATORS: char create dialog button
230  mNextLookButton = new Button(this, _(">"), "nextlook", this);
231  // TRANSLATORS: char create dialog button
232  mPrevLookButton = new Button(this, _("<"), "prevlook", this);
233  // TRANSLATORS: char create dialog label
234  mLookLabel = new Label(this, _("Look:"));
235  mLookNameLabel = new Label(this, "");
236  }
237 
239  {
240  const int forceGender = features.getIntValue("forceCharGender");
241  if (forceGender == -1)
242  {
243  const int size = config.getIntValue("fontSize");
244  mGenderStrip = new TabStrip(this,
245  "gender_" + getWindowName(),
246  size + 16);
247  mGenderStrip->setPressFirst(false);
249  mGenderStrip->setActionEventId("gender_");
250  // TRANSLATORS: one char size female character gender
251  mGenderStrip->addButton(_("F"), "f", false);
252  if (features.getIntValue("forceAccountGender") == -1)
253  {
255  {
256  // TRANSLATORS: one char size male character gender
257  mGenderStrip->addButton(_("M"), "m", true);
258  // TRANSLATORS: one char size other character gender
259  mGenderStrip->addButton(_("O"), "o", false);
260  }
261  else
262  {
263  // TRANSLATORS: one char size male character gender
264  mGenderStrip->addButton(_("M"), "m", false);
265  // TRANSLATORS: one char size unknown character gender
266  mGenderStrip->addButton(_("U"), "u", true);
267  }
268  }
269  else
270  {
271  // TRANSLATORS: one char size male character gender
272  mGenderStrip->addButton(_("M"), "m", true);
274  {
275  // TRANSLATORS: one char size other character gender
276  mGenderStrip->addButton(_("O"), "o", false);
277  }
278  }
279 
280 
282  add(mGenderStrip);
283 
284  mGenderStrip->setPosition(385, 130);
285  mGenderStrip->setWidth(500);
286  mGenderStrip->setHeight(50);
287  }
288  else
289  {
290  mGender = Being::intToGender(CAST_U8(forceGender));
292  }
293  }
294 
295  mPlayerBox->setWidth(74);
296 
297  mNameField->setActionEventId("create");
299 
300  mPlayerBox->setDimension(Rect(360, 0, 110, 90));
301  mActionButton->setPosition(385, 100);
302  mRotateButton->setPosition(415, 100);
303 
306  300, mNameField->getHeight()));
307 
308  const uint32_t labelPadding = getOption("labelPadding", 2);
309  const uint32_t leftX = 120 + mPadding;
310  const uint32_t rightX = 300 + mPadding;
311  const uint32_t labelX = mPadding;
312  uint32_t nameX = leftX + labelPadding;
313  uint32_t y = 30;
314  if (mPrevHairColorButton != nullptr)
315  nameX += mPrevHairColorButton->getWidth();
316  else if (mPrevHairStyleButton != nullptr)
317  nameX += mPrevHairStyleButton->getWidth();
318  else if (mPrevLookButton != nullptr)
319  nameX += mPrevLookButton->getWidth();
320  else if (mPrevRaceButton != nullptr)
321  nameX += mPrevRaceButton->getWidth();
322 
324  {
326  mNextHairColorButton->setPosition(rightX, y);
327  y += 5;
328  mHairColorLabel->setPosition(labelX, y);
329  mHairColorNameLabel->setPosition(nameX, y);
330  y += 24;
331  }
333  {
335  mNextHairStyleButton->setPosition(rightX, y);
336  y += 5;
337  mHairStyleLabel->setPosition(labelX, y);
338  mHairStyleNameLabel->setPosition(nameX, y);
339  y += 24;
340  }
341 
343  {
344  if (mPrevLookButton != nullptr)
345  mPrevLookButton->setPosition(leftX, y);
346  if (mNextLookButton != nullptr)
347  mNextLookButton->setPosition(rightX, y);
348  y += 5;
349  if (mLookLabel != nullptr)
350  mLookLabel->setPosition(labelX, y);
351  if (mLookNameLabel != nullptr)
352  mLookNameLabel->setPosition(nameX, y); // 93
353  y += 24;
354  }
356  {
357  if (mPrevRaceButton != nullptr)
358  mPrevRaceButton->setPosition(leftX, y);
359  if (mNextRaceButton != nullptr)
360  mNextRaceButton->setPosition(rightX, y);
361  y += 5;
362  if (mRaceLabel != nullptr)
363  mRaceLabel->setPosition(labelX, y);
364  if (mRaceNameLabel != nullptr)
365  mRaceNameLabel->setPosition(nameX, y);
366  }
367  mMaxY = y + 29 + getTitlePadding();
368 
369  updateSliders();
370  setButtonsPosition(w, h);
371 
372  add(mPlayerBox);
373  add(mNameField);
374  add(mNameLabel);
375 
377  {
382  }
383 
385  {
390  }
393 
395  {
398  add(mLookLabel);
400  }
401 
403  {
406  add(mRaceLabel);
408  }
409 
413 
414  center();
417 
418  updateHair();
420  updateRace();
422  updateLook();
423  updatePlayer();
424 
425  addKeyListener(this);
426 }
const std::vector< BeingSlot > & getDefaultItems()
Definition: chardb.cpp:186
#define CAST_U32
Definition: cast.h:30
#define _(s)
Definition: gettext.h:34
int getWidth() const
Definition: widget.h:220
#define CAST_U8
Definition: cast.h:26
CardsList cardsId
Definition: beingslot.h:45
void setWidth(const int width)
Definition: widget.cpp:132
Button * mPrevHairStyleButton
int mPadding
Definition: window.h:610
std::vector< Label * > mAttributeLabel
const bool Visible_true
Definition: visible.h:29
virtual bool haveCharOtherGender() const =0
virtual void addButton(const std::string &text, const std::string &tag, const bool pressed)
Definition: widgetgroup.cpp:41
unsigned getMinHairColor()
Definition: chardb.cpp:131
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
void setVisible(Visible visible)
Definition: widget.cpp:224
CharSelectDialog * mCharSelectDialog
Definition: rect.h:72
unsigned getMaxLook()
Definition: chardb.cpp:171
Definition: button.h:94
Configuration config
virtual void setGender(const GenderT gender)
Definition: being.cpp:3514
const BeingTypeId BeingTypeId_zero
Definition: beingtypeid.h:29
void setDimension(const Rect &dimension)
Definition: widget.cpp:168
void setMaximum(const int max)
Definition: textfield.h:159
unsigned int minHairStyle
int getIntValue(const std::string &key) const
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:595
void setButtonsPosition(const int w, const int h)
unsigned getMaxHairColor()
Definition: chardb.cpp:136
static GenderT intToGender(const uint8_t sex) A_CONST
Definition: being.h:938
virtual bool haveRaceSelection() const =0
static Being * createBeing(const BeingId id, const ActorTypeT type, const BeingTypeId subtype, Map *const map)
Definition: being.cpp:5493
unsigned getMinLook()
Definition: chardb.cpp:166
void setContentSize(int width, int height)
Definition: window.cpp:484
Net::ServerFeatures * serverFeatures
Definition: net.cpp:94
int getTitlePadding() const
Definition: window.h:594
virtual void requestFocus()
Definition: widget.cpp:203
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
unsigned int mAction
void setSticky(const bool sticky)
Definition: window.cpp:754
Definition: label.h:87
TabStrip * mGenderStrip
unsigned int maxHairColor
virtual void add(Widget *const widget)
std::vector< Slider * > mAttributeSlider
unsigned getMaxHairStyle()
Definition: chardb.cpp:146
void setPosition(const int x, const int y)
Definition: widget.cpp:160
void addKeyListener(KeyListener *const keyListener)
Definition: widget.cpp:271
unsigned getMaxRace()
Definition: chardb.cpp:181
const std::string & getWindowName() const
Definition: window.h:359
Button * mNextHairColorButton
void setHeight(const int height)
Definition: widget.cpp:139
int spriteId
Definition: beingslot.h:44
virtual void setVisible(Visible visible)
Definition: window.cpp:766
void center()
Definition: window.cpp:1405
unsigned getMinRace()
Definition: chardb.cpp:176
void setPressFirst(const bool press)
Definition: tabstrip.h:50
virtual bool haveLookSelection() const =0
Configuration features
int getNumOfHairstyles()
Definition: itemdb.cpp:1217
int getHeight() const
Definition: widget.h:239
Button * mPrevHairColorButton
void setStickyButtonLock(const bool sticky)
Definition: window.cpp:760
TextField * mNameField
const BeingId BeingId_zero
Definition: beingid.h:29
int getOption(const std::string &name, const int def=0) const
Definition: window.cpp:1442
Window(const std::string &caption="Window", const Modal modal=Modal_false, Window *const parent=0, std::string skin="")
Definition: window.cpp:108
virtual bool haveCreateCharGender() const =0
std::vector< Label * > mAttributeValue
unsigned int minHairColor
unsigned int maxHairStyle
unsigned int mDirection
void setSpriteCards(const unsigned int slot, const int id, const CardsList &cards)
Definition: being.cpp:2984
int getHairSize()
Definition: colordb.cpp:212
Button * mNextHairStyleButton
PlayerBox * mPlayerBox
void setWindowName(const std::string &name)
Definition: window.h:353
unsigned getMinHairStyle()
Definition: chardb.cpp:141

◆ ~CharCreateDialog()

CharCreateDialog::~CharCreateDialog ( )

Destructor.

Definition at line 428 of file charcreatedialog.cpp.

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

429 {
430  delete2(mPlayer);
431 
432  if (charServerHandler != nullptr)
434 }
virtual void setCharCreateDialog(CharCreateDialog *const window) const =0
#define delete2(var)
Definition: delete2.h:24
Net::CharServerHandler * charServerHandler
Definition: net.cpp:79

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 436 of file charcreatedialog.cpp.

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(), Gender::OTHER, Window::scheduleDelete(), Widget::setEnabled(), Being::setGender(), ShowCenter_true, Gender::UNSPECIFIED, updateHair(), updateLook(), updatePlayer(), updateRace(), and updateSliders().

Referenced by keyPressed().

437 {
438  const std::string &id = event.getId();
439  if (id == "create")
440  {
441  if (getName().length() >= 4)
442  {
443  // Attempt to create the character
444  mCreateButton->setEnabled(false);
445 
446  STD_VECTOR<int> atts;
447  const size_t sz = mAttributeSlider.size();
448  for (size_t i = 0; i < sz; i++)
449  {
450  atts.push_back(CAST_S32(
451  mAttributeSlider[i]->getValue()));
452  }
453  for (size_t i = sz; i < 6; i ++)
454  atts.push_back(1);
455 
456  const int characterSlot = mSlot;
457 
459  characterSlot,
460  mGender,
461  mHairStyle,
462  mHairColor,
463  CAST_U8(mRace),
464  CAST_U8(mLook),
465  atts);
466  }
467  else
468  {
470  // TRANSLATORS: char creation error
471  _("Error"),
472  // TRANSLATORS: char creation error
473  _("Your name needs to be at least 4 characters."),
474  // TRANSLATORS: ok dialog button
475  _("OK"),
477  Modal_true,
479  nullptr,
480  260);
481  }
482  }
483  else if (id == "cancel")
484  {
485  scheduleDelete();
486  }
487  else if (id == "nextcolor")
488  {
489  mHairColor ++;
490  updateHair();
491  }
492  else if (id == "prevcolor")
493  {
494  mHairColor --;
495  updateHair();
496  }
497  else if (id == "nextstyle")
498  {
499  mHairStyle ++;
500  updateHair();
501  }
502  else if (id == "prevstyle")
503  {
504  mHairStyle --;
505  updateHair();
506  }
507  else if (id == "nextrace")
508  {
509  mRace ++;
510  updateRace();
511  }
512  else if (id == "prevrace")
513  {
514  mRace --;
515  updateRace();
516  }
517  else if (id == "nextlook")
518  {
519  mLook ++;
520  updateLook();
521  }
522  else if (id == "prevlook")
523  {
524  mLook --;
525  updateLook();
526  }
527  else if (id == "statslider")
528  {
529  updateSliders();
530  }
531  else if (id == "action")
532  {
533  mAction ++;
534  if (mAction >= 5)
535  mAction = 0;
536  updatePlayer();
537  }
538  else if (id == "rotate")
539  {
540  mDirection ++;
541  if (mDirection >= 4)
542  mDirection = 0;
543  updatePlayer();
544  }
545  else if (id == "gender_m")
546  {
549  }
550  else if (id == "gender_f")
551  {
554  }
555  else if (id == "gender_u")
556  {
559  }
560  else if (id == "gender_o")
561  {
564  }
565 }
#define _(s)
Definition: gettext.h:34
#define CAST_U8
Definition: cast.h:26
virtual void setGender(const GenderT gender)
Definition: being.cpp:3514
#define CAST_S32
Definition: cast.h:29
unsigned int mAction
std::vector< Slider * > mAttributeSlider
const bool ShowCenter_true
Definition: showcenter.h:29
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:351
virtual void scheduleDelete()
Definition: window.cpp:819
#define CREATEWIDGET(type,...)
Definition: createwidget.h:28
Net::CharServerHandler * charServerHandler
Definition: net.cpp:79
unsigned int mDirection
std::string getName() const

◆ attemptCharCreate()

void CharCreateDialog::attemptCharCreate ( )
private

Communicate character creation to the server.

◆ getDistributedPoints()

int CharCreateDialog::getDistributedPoints ( ) const
private

Definition at line 617 of file charcreatedialog.cpp.

References CAST_S32, mAttributeSlider, and ServerCommandType::points.

Referenced by updateSliders().

618 {
619  int points = 0;
620 
621  for (size_t i = 0, sz = mAttributeSlider.size(); i < sz; i++)
622  points += CAST_S32(mAttributeSlider[i]->getValue());
623  return points;
624 }
#define CAST_S32
Definition: cast.h:29
std::vector< Slider * > mAttributeSlider

◆ getName()

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

Returns the name of the character to create.

Definition at line 567 of file charcreatedialog.cpp.

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

Referenced by action().

568 {
569  std::string name = mNameField->getText();
570  trim(name);
571  return name;
572 }
std::string trim(std::string const &str)
TextField * mNameField
const std::string & getText() const
Definition: textfield.h:225

◆ 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 836 of file charcreatedialog.cpp.

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

837 {
838  const InputActionT actionId = event.getActionId();
839  PRAGMA45(GCC diagnostic push)
840  PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
841  switch (actionId)
842  {
844  event.consume();
847  break;
848 
849  default:
850  break;
851  }
852  PRAGMA45(GCC diagnostic pop)
853 }
void action(const ActionEvent &event)
PRAGMA45(GCC diagnostic push) PRAGMA45(GCC diagnostic ignored "-Wunused-result") int TestLauncher
const std::string & getActionEventId() const
Definition: widget.h:604
InputAction ::T InputActionT
Definition: inputaction.h:714

◆ 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 819 of file charcreatedialog.cpp.

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

820 {
821  BLOCK_START("CharCreateDialog::logic")
822  if (mPlayer != nullptr)
823  mPlayer->logic();
824  BLOCK_END("CharCreateDialog::logic")
825 }
#define BLOCK_START(name)
Definition: perfomance.h:78
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:79

◆ setAttributes()

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

Definition at line 626 of file charcreatedialog.cpp.

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, serverFeatures, setButtonsPosition(), Window::setContentSize(), Widget::setVisible(), Catch::toString(), updateSliders(), Visible_false, and y.

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

629 {
630  size_t sz;
631 
632  if (min == max || available == 0)
633  {
634  sz = 0U;
635  available = 0;
636  }
637  else
638  {
639  sz = labels.size();
640  }
641 
642  mMaxPoints = available;
643 
644  for (size_t i = 0; i < mAttributeLabel.size(); i++)
645  {
646  remove(mAttributeLabel[i]);
648  remove(mAttributeSlider[i]);
650  remove(mAttributeValue[i]);
652  }
653 
654  mAttributeLabel.resize(sz);
655  mAttributeSlider.resize(sz);
656  mAttributeValue.resize(sz);
657 
658  const uint32_t w = 480;
659  uint32_t h = 350;
660  uint32_t y = 89;
662  y += 29;
664  y += 29;
665 
666  for (size_t i = 0; i < sz; i++)
667  {
668  mAttributeLabel[i] = new Label(this, labels[i]);
669  mAttributeLabel[i]->setWidth(70);
670  mAttributeLabel[i]->setPosition(mPadding,
671  y + CAST_S32(i * 24));
672  mAttributeLabel[i]->adjustSize();
673  add(mAttributeLabel[i]);
674 
675  mAttributeSlider[i] = new Slider(this, min, max, 1.0);
676  mAttributeSlider[i]->setDimension(Rect(140 + mPadding,
677  y + CAST_S32(i * 24),
678  150,
679  12));
680  mAttributeSlider[i]->setActionEventId("statslider");
681  mAttributeSlider[i]->addActionListener(this);
682  add(mAttributeSlider[i]);
683 
684  mAttributeValue[i] = new Label(this, toString(min));
685  mAttributeValue[i]->setPosition(295 + mPadding,
686  y + CAST_S32(i * 24));
687  add(mAttributeValue[i]);
688  }
689 
690  updateSliders();
691  if (available == 0)
692  {
694  h = y;
695  }
696  else
697  {
698  h = y +
699  CAST_S32(sz) * 24 +
701  getPadding();
702  }
704  features.getIntValue("forceCharGender") == -1 &&
705  y < 160)
706  {
707  if (h < 160)
708  h = 160;
709  }
710  if (h < mMaxY)
711  h = mMaxY;
713  {
714  const int forceGender = features.getIntValue("forceCharGender");
715  if (forceGender == -1 && h < 180)
716  h = 180;
717  else if (h < 120)
718  h = 120;
719  }
720  h += mCreateButton->getHeight();
721 
722  setContentSize(w, h);
723  setButtonsPosition(w, h);
724 }
int mPadding
Definition: window.h:610
std::vector< Label * > mAttributeLabel
void setVisible(Visible visible)
Definition: widget.cpp:224
Definition: rect.h:72
int getIntValue(const std::string &key) const
#define delete2(var)
Definition: delete2.h:24
void setButtonsPosition(const int w, const int h)
virtual bool haveRaceSelection() const =0
void setContentSize(int width, int height)
Definition: window.cpp:484
Net::ServerFeatures * serverFeatures
Definition: net.cpp:94
#define CAST_S32
Definition: cast.h:29
const bool Visible_false
Definition: visible.h:29
Definition: label.h:87
virtual void add(Widget *const widget)
std::vector< Slider * > mAttributeSlider
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
virtual bool haveLookSelection() const =0
Configuration features
int getHeight() const
Definition: widget.h:239
virtual bool haveCreateCharGender() const =0
Definition: slider.h:85
std::vector< Label * > mAttributeValue
int getPadding() const
Definition: window.h:496

◆ setButtonsPosition()

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

Definition at line 855 of file charcreatedialog.cpp.

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

Referenced by CharCreateDialog(), and setAttributes().

856 {
857  const int h2 = h - 5 - mCancelButton->getHeight();
858  if (mainGraphics->getHeight() < 480)
859  {
860  if (mMaxPoints != 0)
861  {
862  mCreateButton->setPosition(337, 160);
864  }
865  else
866  {
868  w / 2,
869  160);
872  160);
873  }
874  }
875  else
876  {
878  w / 2,
879  h2);
882  h2);
883  }
885 }
int getWidth() const
Definition: widget.h:220
int getHeight() const
Definition: graphics.cpp:647
Graphics * mainGraphics
Definition: graphics.cpp:108
void setPosition(const int x, const int y)
Definition: widget.cpp:160
int getX() const
Definition: widget.h:268
int getHeight() const
Definition: widget.h:239

◆ setDefaultGender()

void CharCreateDialog::setDefaultGender ( const GenderT  gender = Gender::FEMALE)

Definition at line 726 of file charcreatedialog.cpp.

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

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

727 {
728  if (features.getIntValue("forceCharGender") != -1)
729  return;
730 
731  mDefaultGender = gender;
732  mPlayer->setGender(gender);
733 }
virtual void setGender(const GenderT gender)
Definition: being.cpp:3514
int getIntValue(const std::string &key) const
Configuration features

◆ unlock()

void CharCreateDialog::unlock ( )

Unlocks the dialog, enabling the create character button again.

Definition at line 612 of file charcreatedialog.cpp.

References mCreateButton, and Widget::setEnabled().

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

613 {
614  mCreateButton->setEnabled(true);
615 }
void setEnabled(const bool enabled)
Definition: widget.h:351

◆ updateHair()

void CharCreateDialog::updateHair ( )
private

Definition at line 735 of file charcreatedialog.cpp.

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

Referenced by action(), and CharCreateDialog().

736 {
737  if (mHairStyle <= 0)
739  else
743  {
745  }
746  const ItemInfo &item = ItemDB::get(-mHairStyle);
747  if (mHairStyleNameLabel != nullptr)
748  {
750  mHairStyleNameLabel->resizeTo(150, 150);
751  }
752 
753  if (ColorDB::getHairSize() != 0)
755  else
756  mHairColor = 0;
757  if (mHairColor < 0)
761  {
763  }
764  if (mHairColorNameLabel != nullptr)
765  {
768  mHairColorNameLabel->resizeTo(150, 150);
769  }
770 
772  mHairStyle * -1,
774  updatePlayer();
775 }
const ItemInfo & get(const int id)
Definition: itemdb.cpp:814
#define fromInt(val, name)
Definition: intdefines.h:45
unsigned int minHairStyle
uint16_t ItemColor
Definition: itemcolor.h:29
const std::string & getName() const
Definition: iteminfo.h:73
void setSpriteColor(const unsigned int slot, const int id, const std::string &color)
Definition: being.cpp:2828
std::string & getHairColorName(const ItemColor id)
Definition: colordb.cpp:189
#define CAST_S32
Definition: cast.h:29
void setCaption(const std::string &caption)
Definition: label.cpp:256
unsigned int maxHairColor
virtual unsigned int hairSprite() const =0
int getNumOfHairstyles()
Definition: itemdb.cpp:1217
std::string getDyeColorsString(const ItemColor color) const
Definition: iteminfo.cpp:226
void resizeTo(const int maxSize, const int minSize)
Definition: label.cpp:219
unsigned int minHairColor
unsigned int maxHairStyle
Net::CharServerHandler * charServerHandler
Definition: net.cpp:79
int getHairSize()
Definition: colordb.cpp:212

◆ updateLook()

void CharCreateDialog::updateLook ( )
private

Definition at line 787 of file charcreatedialog.cpp.

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

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

788 {
789  const ItemInfo &item = ItemDB::get(-100 - mRace);
790  const int sz = item.getColorsSize();
791  if (sz > 0 && serverFeatures->haveLookSelection())
792  {
793  if (mLook < 0)
794  mLook = sz - 1;
795  if (mLook > mMaxLook)
796  mLook = mMinLook;
797  if (mLook >= sz)
798  mLook = mMinLook;
799  }
800  else
801  {
802  mLook = 0;
803  }
805  CAST_U8(mLook));
806  if (mRaceNameLabel != nullptr)
807  {
809  mRaceNameLabel->resizeTo(150, 150);
810  }
811  if (mLookNameLabel != nullptr)
812  {
814  fromInt(mLook, ItemColor)));
815  mLookNameLabel->resizeTo(150, 150);
816  }
817 }
const ItemInfo & get(const int id)
Definition: itemdb.cpp:814
#define CAST_U8
Definition: cast.h:26
#define fromInt(val, name)
Definition: intdefines.h:45
uint16_t ItemColor
Definition: itemcolor.h:29
const std::string & getName() const
Definition: iteminfo.h:73
Net::ServerFeatures * serverFeatures
Definition: net.cpp:94
int getColorsSize() const
Definition: iteminfo.h:303
void setCaption(const std::string &caption)
Definition: label.cpp:256
std::string getColorName(const ItemColor idx) const
Definition: iteminfo.cpp:412
void setSubtype(const BeingTypeId subtype, const uint16_t look)
Definition: being.cpp:371
virtual bool haveLookSelection() const =0
void resizeTo(const int maxSize, const int minSize)
Definition: label.cpp:219
int BeingTypeId
Definition: beingtypeid.h:29

◆ updatePlayer()

void CharCreateDialog::updatePlayer ( )

Definition at line 827 of file charcreatedialog.cpp.

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

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

828 {
829  if (mPlayer != nullptr)
830  {
833  }
834 }
virtual void setDirection(const uint8_t direction)
Definition: being.cpp:1649
static const BeingActionT actions[]
unsigned int mAction
virtual void setAction(const BeingActionT &action, const int attackId)
Definition: being.cpp:1513
static const uint8_t directions[]
unsigned int mDirection

◆ updateRace()

void CharCreateDialog::updateRace ( )
private

Definition at line 777 of file charcreatedialog.cpp.

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

Referenced by action(), and CharCreateDialog().

778 {
779  if (mRace < mMinRace)
780  mRace = mMaxRace;
781  else if (mRace > mMaxRace)
782  mRace = mMinRace;
783 
784  updateLook();
785 }

◆ updateSliders()

void CharCreateDialog::updateSliders ( )
private

Definition at line 574 of file charcreatedialog.cpp.

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

575 {
576  for (size_t i = 0, sz = mAttributeSlider.size(); i < sz; i++)
577  {
578  // Update captions
579  mAttributeValue[i]->setCaption(
580  toString(CAST_S32(mAttributeSlider[i]->getValue())));
581  mAttributeValue[i]->adjustSize();
582  }
583 
584  // Update distributed points
585  const int pointsLeft = mMaxPoints - getDistributedPoints();
586  if (pointsLeft == 0)
587  {
588  // TRANSLATORS: char create dialog label
589  mAttributesLeft->setCaption(_("Character stats OK"));
590  mCreateButton->setEnabled(true);
591  }
592  else
593  {
594  mCreateButton->setEnabled(false);
595  if (pointsLeft > 0)
596  {
598  // TRANSLATORS: char create dialog label
599  strprintf(_("Please distribute %d points"), pointsLeft));
600  }
601  else
602  {
604  // TRANSLATORS: char create dialog label
605  strprintf(_("Please remove %d points"), -pointsLeft));
606  }
607  }
608 
610 }
#define _(s)
Definition: gettext.h:34
int getDistributedPoints() const
#define CAST_S32
Definition: cast.h:29
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
void setCaption(const std::string &caption)
Definition: label.cpp:256
std::vector< Slider * > mAttributeSlider
void setEnabled(const bool enabled)
Definition: widget.h:351
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
std::vector< Label * > mAttributeValue
void adjustSize()
Definition: label.cpp:192

Field Documentation

◆ mAction

unsigned int CharCreateDialog::mAction
private

Definition at line 167 of file charcreatedialog.h.

Referenced by action(), and updatePlayer().

◆ mActionButton

Button* CharCreateDialog::mActionButton
private

Definition at line 127 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mAttributeLabel

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

Definition at line 131 of file charcreatedialog.h.

Referenced by setAttributes().

◆ mAttributesLeft

Label* CharCreateDialog::mAttributesLeft
private

◆ mAttributeSlider

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

Definition at line 130 of file charcreatedialog.h.

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

◆ mAttributeValue

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

Definition at line 132 of file charcreatedialog.h.

Referenced by setAttributes(), and updateSliders().

◆ maxHairColor

unsigned int CharCreateDialog::maxHairColor
private

Definition at line 162 of file charcreatedialog.h.

Referenced by CharCreateDialog(), and updateHair().

◆ maxHairStyle

unsigned int CharCreateDialog::maxHairStyle
private

Definition at line 164 of file charcreatedialog.h.

Referenced by CharCreateDialog(), and updateHair().

◆ mCancelButton

Button* CharCreateDialog::mCancelButton
private

Definition at line 136 of file charcreatedialog.h.

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

◆ mCharSelectDialog

CharSelectDialog* CharCreateDialog::mCharSelectDialog
private

Definition at line 106 of file charcreatedialog.h.

◆ mCreateButton

Button* CharCreateDialog::mCreateButton
private

◆ mDefaultGender

GenderT CharCreateDialog::mDefaultGender
private

Definition at line 159 of file charcreatedialog.h.

Referenced by action(), and setDefaultGender().

◆ mDirection

unsigned int CharCreateDialog::mDirection
private

Definition at line 168 of file charcreatedialog.h.

Referenced by action(), and updatePlayer().

◆ mGender

GenderT CharCreateDialog::mGender
private

Definition at line 160 of file charcreatedialog.h.

Referenced by action(), and CharCreateDialog().

◆ mGenderStrip

TabStrip* CharCreateDialog::mGenderStrip
private

Definition at line 141 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mHairColor

int CharCreateDialog::mHairColor
private

Definition at line 154 of file charcreatedialog.h.

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

◆ mHairColorLabel

Label* CharCreateDialog::mHairColorLabel
private

Definition at line 112 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mHairColorNameLabel

Label* CharCreateDialog::mHairColorNameLabel
private

Definition at line 113 of file charcreatedialog.h.

Referenced by CharCreateDialog(), and updateHair().

◆ mHairStyle

int CharCreateDialog::mHairStyle
private

Definition at line 153 of file charcreatedialog.h.

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

◆ mHairStyleLabel

Label* CharCreateDialog::mHairStyleLabel
private

Definition at line 116 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mHairStyleNameLabel

Label* CharCreateDialog::mHairStyleNameLabel
private

Definition at line 117 of file charcreatedialog.h.

Referenced by CharCreateDialog(), and updateHair().

◆ minHairColor

unsigned int CharCreateDialog::minHairColor
private

Definition at line 163 of file charcreatedialog.h.

Referenced by CharCreateDialog(), and updateHair().

◆ minHairStyle

unsigned int CharCreateDialog::minHairStyle
private

Definition at line 165 of file charcreatedialog.h.

Referenced by CharCreateDialog(), and updateHair().

◆ mLook

int CharCreateDialog::mLook
private

Definition at line 147 of file charcreatedialog.h.

Referenced by action(), and updateLook().

◆ mLookLabel

Label* CharCreateDialog::mLookLabel
private

Definition at line 124 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mLookNameLabel

Label* CharCreateDialog::mLookNameLabel
private

Definition at line 125 of file charcreatedialog.h.

Referenced by CharCreateDialog(), and updateLook().

◆ mMaxLook

int CharCreateDialog::mMaxLook
private

Definition at line 149 of file charcreatedialog.h.

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

◆ mMaxPoints

int CharCreateDialog::mMaxPoints
private

Definition at line 143 of file charcreatedialog.h.

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

◆ mMaxRace

int CharCreateDialog::mMaxRace
private

Definition at line 151 of file charcreatedialog.h.

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

◆ mMaxY

uint32_t CharCreateDialog::mMaxY
private

Definition at line 155 of file charcreatedialog.h.

Referenced by CharCreateDialog(), and setAttributes().

◆ mMinLook

int CharCreateDialog::mMinLook
private

Definition at line 148 of file charcreatedialog.h.

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

◆ mMinRace

int CharCreateDialog::mMinRace
private

Definition at line 150 of file charcreatedialog.h.

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

◆ mNameField

TextField* CharCreateDialog::mNameField
private

Definition at line 108 of file charcreatedialog.h.

Referenced by CharCreateDialog(), and getName().

◆ mNameLabel

Label* CharCreateDialog::mNameLabel
private

Definition at line 109 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mNextHairColorButton

Button* CharCreateDialog::mNextHairColorButton
private

Definition at line 110 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mNextHairStyleButton

Button* CharCreateDialog::mNextHairStyleButton
private

Definition at line 114 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mNextLookButton

Button* CharCreateDialog::mNextLookButton
private

Definition at line 122 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mNextRaceButton

Button* CharCreateDialog::mNextRaceButton
private

Definition at line 118 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mPlayer

Being* CharCreateDialog::mPlayer
private

◆ mPlayerBox

PlayerBox* CharCreateDialog::mPlayerBox
private

Definition at line 139 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mPrevHairColorButton

Button* CharCreateDialog::mPrevHairColorButton
private

Definition at line 111 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mPrevHairStyleButton

Button* CharCreateDialog::mPrevHairStyleButton
private

Definition at line 115 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mPrevLookButton

Button* CharCreateDialog::mPrevLookButton
private

Definition at line 123 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mPrevRaceButton

Button* CharCreateDialog::mPrevRaceButton
private

Definition at line 119 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mRace

int CharCreateDialog::mRace
private

Definition at line 146 of file charcreatedialog.h.

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

◆ mRaceLabel

Label* CharCreateDialog::mRaceLabel
private

Definition at line 120 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mRaceNameLabel

Label* CharCreateDialog::mRaceNameLabel
private

Definition at line 121 of file charcreatedialog.h.

Referenced by CharCreateDialog(), and updateLook().

◆ mRotateButton

Button* CharCreateDialog::mRotateButton
private

Definition at line 128 of file charcreatedialog.h.

Referenced by CharCreateDialog().

◆ mSlot

int CharCreateDialog::mSlot
private

Definition at line 157 of file charcreatedialog.h.

Referenced by action().

◆ mUsedPoints

int CharCreateDialog::mUsedPoints
private

Definition at line 144 of file charcreatedialog.h.


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