~ubuntu-branches/ubuntu/trusty/manaplus/trusty-proposed

« back to all changes in this revision

Viewing changes to src/gui/charcreatedialog.cpp

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2013-07-11 10:09:41 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20130711100941-f0rwuvcwgl8ulqo8
Tags: 1.3.7.7.1-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
    mPrevRaceButton(nullptr),
97
97
    mRaceLabel(nullptr),
98
98
    mRaceNameLabel(nullptr),
 
99
    mNextLookButton(nullptr),
 
100
    mPrevLookButton(nullptr),
 
101
    mLookLabel(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)),
121
125
    mRace(0),
 
126
    mLook(0),
 
127
    mMinLook(CharDB::getMinLook()),
 
128
    mMaxLook(CharDB::getMaxLook()),
122
129
    mPlayer(new Being(0, ActorSprite::PLAYER, static_cast<uint16_t>(mRace),
123
130
            nullptr)),
124
131
    mPlayerBox(new PlayerBox(mPlayer, "charcreate_playerbox.xml",
152
159
    if (!maxHairStyle)
153
160
        maxHairStyle = mPlayer->getNumOfHairstyles();
154
161
 
155
 
    mHairStyle = (rand() % maxHairStyle) + minHairStyle;
156
 
    mHairColor = (rand() % maxHairColor) + minHairColor;
 
162
    if (maxHairStyle)
 
163
        mHairStyle = (rand() % maxHairStyle) + minHairStyle;
 
164
    else
 
165
        mHairStyle = 0;
 
166
    if (maxHairColor)
 
167
        mHairColor = (rand() % maxHairColor) + minHairColor;
 
168
    else
 
169
        mHairColor = 0;
157
170
 
158
171
    mNameField->setMaximum(24);
159
172
 
167
180
        mRaceLabel = new Label(this, _("Race:"));
168
181
        mRaceNameLabel = new Label(this, "");
169
182
    }
 
183
    if (serverVersion >= 9 && mMinLook < mMaxLook)
 
184
    {
 
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, "");
 
192
    }
170
193
 
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);
 
226
    int y = 30;
 
227
    mPrevHairColorButton->setPosition(leftX, y);
 
228
    mNextHairColorButton->setPosition(rightX, y);
 
229
    y += 5;
 
230
    mHairColorLabel->setPosition(labelX, y);
 
231
    mHairColorNameLabel->setPosition(nameX, y);
 
232
    y += 24;
 
233
    mPrevHairStyleButton->setPosition(leftX, y);
 
234
    mNextHairStyleButton->setPosition(rightX, y);
 
235
    y += 5;
 
236
    mHairStyleLabel->setPosition(labelX, y);
 
237
    mHairStyleNameLabel->setPosition(nameX, y);
211
238
 
 
239
    if (serverVersion >= 9 && mMinLook < mMaxLook)
 
240
    {
 
241
        y += 24;
 
242
        mPrevLookButton->setPosition(leftX, y);
 
243
        mNextLookButton->setPosition(rightX, y);
 
244
        y += 5;
 
245
        mLookLabel->setPosition(labelX, y);
 
246
        mLookNameLabel->setPosition(nameX, y);  // 93
 
247
    }
212
248
    if (serverVersion >= 2)
213
249
    {
214
 
        mPrevRaceButton->setPosition(leftX, 88);
215
 
        mNextRaceButton->setPosition(rightX, 88);
216
 
        mRaceLabel->setPosition(labelX, 93);
217
 
        mRaceNameLabel->setPosition(nameX, 93);
 
250
        y += 24;
 
251
        mPrevRaceButton->setPosition(leftX, y);
 
252
        mNextRaceButton->setPosition(rightX, y);
 
253
        y += 5;
 
254
        mRaceLabel->setPosition(labelX, y);
 
255
        mRaceNameLabel->setPosition(nameX, y);
218
256
    }
219
257
 
220
258
    updateSliders();
238
276
    add(mActionButton);
239
277
    add(mRotateButton);
240
278
 
 
279
    if (serverVersion >= 9 && mMinLook < mMaxLook)
 
280
    {
 
281
        add(mNextLookButton);
 
282
        add(mPrevLookButton);
 
283
        add(mLookLabel);
 
284
        add(mLookNameLabel);
 
285
    }
 
286
 
241
287
    if (serverVersion >= 2)
242
288
    {
243
289
        add(mNextRaceButton);
261
307
    updateHair();
262
308
    if (serverVersion >= 2)
263
309
        updateRace();
264
 
 
 
310
    if (serverVersion >= 9 && mMinLook < mMaxLook)
 
311
        updateLook();
265
312
    updatePlayer();
266
313
 
267
314
    addKeyListener(this);
308
355
 
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);
312
359
        }
313
360
        else
314
361
        {
353
400
        mRace --;
354
401
        updateRace();
355
402
    }
 
403
    else if (id == "nextlook")
 
404
    {
 
405
        mLook ++;
 
406
        updateLook();
 
407
    }
 
408
    else if (id == "prevlook")
 
409
    {
 
410
        mLook --;
 
411
        updateLook();
 
412
    }
356
413
    else if (id == "statslider")
357
414
    {
358
415
        updateSliders();
464
521
 
465
522
    const int w = 480;
466
523
    const int h = 350;
 
524
    const int y = 118 + 29;
467
525
 
468
526
    for (unsigned i = 0, sz = static_cast<unsigned>(labels.size());
469
527
         i < sz; i++)
470
528
    {
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]);
476
534
 
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,
479
537
                                                         150, 12));
480
538
        mAttributeSlider[i]->setActionEventId("statslider");
481
539
        mAttributeSlider[i]->addActionListener(this);
482
540
        add(mAttributeSlider[i]);
483
541
 
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]);
487
545
    }
488
546
 
561
619
    else if (mRace >= Being::getNumOfRaces())
562
620
        mRace = 0;
563
621
 
564
 
    mPlayer->setSubtype(static_cast<uint16_t>(mRace));
 
622
    updateLook();
 
623
}
 
624
 
 
625
void CharCreateDialog::updateLook()
 
626
{
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)
 
630
    {
 
631
        if (mLook < 0)
 
632
            mLook = sz - 1;
 
633
        if (mLook > mMaxLook)
 
634
            mLook = mMinLook;
 
635
        if (mLook >= sz)
 
636
            mLook = mMinLook;
 
637
    }
 
638
    else
 
639
    {
 
640
        mLook = 0;
 
641
    }
 
642
    mPlayer->setSubtype(static_cast<uint16_t>(mRace), mLook);
 
643
    if (mRaceNameLabel)
 
644
    {
 
645
        mRaceNameLabel->setCaption(item.getName());
 
646
        mRaceNameLabel->adjustSize();
 
647
    }
 
648
    if (mLookNameLabel)
 
649
    {
 
650
        mLookNameLabel->setCaption(item.getColorName(mLook));
 
651
        mLookNameLabel->adjustSize();
 
652
    }
568
653
}
569
654
 
570
655
void CharCreateDialog::logic()
614
699
            mCancelButton->getX() - 5 - mCreateButton->getWidth(),
615
700
            h - 5 - mCancelButton->getHeight());
616
701
    }
617
 
    mAttributesLeft->setPosition(15, 260);
 
702
    mAttributesLeft->setPosition(15, 260 + 29);
618
703
}