96
96
mPrevRaceButton(nullptr),
97
97
mRaceLabel(nullptr),
98
98
mRaceNameLabel(nullptr),
99
mNextLookButton(nullptr),
100
mPrevLookButton(nullptr),
102
mLookNameLabel(nullptr),
99
103
// TRANSLATORS: char create dialog button
100
104
mActionButton(new Button(this, _("^"), "action", this)),
101
105
// TRANSLATORS: char create dialog button
119
123
// TRANSLATORS: char create dialog button
120
124
mCancelButton(new Button(this, _("Cancel"), "cancel", this)),
127
mMinLook(CharDB::getMinLook()),
128
mMaxLook(CharDB::getMaxLook()),
122
129
mPlayer(new Being(0, ActorSprite::PLAYER, static_cast<uint16_t>(mRace),
124
131
mPlayerBox(new PlayerBox(mPlayer, "charcreate_playerbox.xml",
152
159
if (!maxHairStyle)
153
160
maxHairStyle = mPlayer->getNumOfHairstyles();
155
mHairStyle = (rand() % maxHairStyle) + minHairStyle;
156
mHairColor = (rand() % maxHairColor) + minHairColor;
163
mHairStyle = (rand() % maxHairStyle) + minHairStyle;
167
mHairColor = (rand() % maxHairColor) + minHairColor;
158
171
mNameField->setMaximum(24);
167
180
mRaceLabel = new Label(this, _("Race:"));
168
181
mRaceNameLabel = new Label(this, "");
183
if (serverVersion >= 9 && mMinLook < mMaxLook)
185
// TRANSLATORS: char create dialog button
186
mNextLookButton = new Button(this, _(">"), "nextlook", this);
187
// TRANSLATORS: char create dialog button
188
mPrevLookButton = new Button(this, _("<"), "prevlook", this);
189
// TRANSLATORS: char create dialog label
190
mLookLabel = new Label(this, _("Look:"));
191
mLookNameLabel = new Label(this, "");
171
194
// Default to a Male character
172
195
mMale->setSelected(true);
200
223
const int rightX = 300;
201
224
const int labelX = 5;
202
225
const int nameX = 145;
203
mPrevHairColorButton->setPosition(leftX, 30);
204
mNextHairColorButton->setPosition(rightX, 30);
205
mHairColorLabel->setPosition(labelX, 35);
206
mHairColorNameLabel->setPosition(nameX, 35);
207
mPrevHairStyleButton->setPosition(leftX, 59);
208
mNextHairStyleButton->setPosition(rightX, 59);
209
mHairStyleLabel->setPosition(labelX, 64);
210
mHairStyleNameLabel->setPosition(nameX, 64);
227
mPrevHairColorButton->setPosition(leftX, y);
228
mNextHairColorButton->setPosition(rightX, y);
230
mHairColorLabel->setPosition(labelX, y);
231
mHairColorNameLabel->setPosition(nameX, y);
233
mPrevHairStyleButton->setPosition(leftX, y);
234
mNextHairStyleButton->setPosition(rightX, y);
236
mHairStyleLabel->setPosition(labelX, y);
237
mHairStyleNameLabel->setPosition(nameX, y);
239
if (serverVersion >= 9 && mMinLook < mMaxLook)
242
mPrevLookButton->setPosition(leftX, y);
243
mNextLookButton->setPosition(rightX, y);
245
mLookLabel->setPosition(labelX, y);
246
mLookNameLabel->setPosition(nameX, y); // 93
212
248
if (serverVersion >= 2)
214
mPrevRaceButton->setPosition(leftX, 88);
215
mNextRaceButton->setPosition(rightX, 88);
216
mRaceLabel->setPosition(labelX, 93);
217
mRaceNameLabel->setPosition(nameX, 93);
251
mPrevRaceButton->setPosition(leftX, y);
252
mNextRaceButton->setPosition(rightX, y);
254
mRaceLabel->setPosition(labelX, y);
255
mRaceNameLabel->setPosition(nameX, y);
309
356
Net::getCharServerHandler()->newCharacter(getName(), characterSlot,
310
357
mFemale->isSelected(), mHairStyle, mHairColor,
311
static_cast<unsigned char>(mRace), atts);
358
static_cast<unsigned char>(mRace), mLook, atts);
465
522
const int w = 480;
466
523
const int h = 350;
524
const int y = 118 + 29;
468
526
for (unsigned i = 0, sz = static_cast<unsigned>(labels.size());
471
529
mAttributeLabel[i] = new Label(this, labels[i]);
472
530
mAttributeLabel[i]->setWidth(70);
473
mAttributeLabel[i]->setPosition(5, 118 + i * 24);
531
mAttributeLabel[i]->setPosition(5, y + i * 24);
474
532
mAttributeLabel[i]->adjustSize();
475
533
add(mAttributeLabel[i]);
477
535
mAttributeSlider[i] = new Slider(min, max);
478
mAttributeSlider[i]->setDimension(gcn::Rectangle(140, 118 + i * 24,
536
mAttributeSlider[i]->setDimension(gcn::Rectangle(140, y + i * 24,
480
538
mAttributeSlider[i]->setActionEventId("statslider");
481
539
mAttributeSlider[i]->addActionListener(this);
482
540
add(mAttributeSlider[i]);
484
542
mAttributeValue[i] = new Label(this, toString(min));
485
mAttributeValue[i]->setPosition(295, 118 + i * 24);
543
mAttributeValue[i]->setPosition(295, y + i * 24);
486
544
add(mAttributeValue[i]);
561
619
else if (mRace >= Being::getNumOfRaces())
564
mPlayer->setSubtype(static_cast<uint16_t>(mRace));
625
void CharCreateDialog::updateLook()
565
627
const ItemInfo &item = ItemDB::get(-100 - mRace);
566
mRaceNameLabel->setCaption(item.getName());
567
mRaceNameLabel->adjustSize();
628
const int sz = item.getColorsSize();
629
if (sz > 0 && serverVersion >= 9)
633
if (mLook > mMaxLook)
642
mPlayer->setSubtype(static_cast<uint16_t>(mRace), mLook);
645
mRaceNameLabel->setCaption(item.getName());
646
mRaceNameLabel->adjustSize();
650
mLookNameLabel->setCaption(item.getColorName(mLook));
651
mLookNameLabel->adjustSize();
570
655
void CharCreateDialog::logic()
614
699
mCancelButton->getX() - 5 - mCreateButton->getWidth(),
615
700
h - 5 - mCancelButton->getHeight());
617
mAttributesLeft->setPosition(15, 260);
702
mAttributesLeft->setPosition(15, 260 + 29);