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

« back to all changes in this revision

Viewing changes to src/gui/killstats.cpp

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi, Andrei Karas, Patrick Matthäi
  • Date: 2013-05-18 21:06:29 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130518210629-3trtowluum0tekob
Tags: 1.3.5.12-1
[ Andrei Karas ]
* Add new files to copyright file.

[ Patrick Matthäi ]
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
 
39
39
#include "debug.h"
40
40
 
41
 
KillStats::KillStats():
 
41
KillStats::KillStats() :
 
42
    // TRANSLATORS: kill stats window name
42
43
    Window(_("Kill stats"), false, nullptr, "killstats.xml"),
43
44
    gcn::ActionListener(),
44
45
    mKillCounter(0),
46
47
    mKillTCounter(0),
47
48
    mExpTCounter(0),
48
49
    mKillTimer(0),
 
50
    // TRANSLATORS: kill stats window button
49
51
    mResetButton(new Button(this, _("Reset stats"), "reset", this)),
 
52
    // TRANSLATORS: kill stats window button
50
53
    mTimerButton(new Button(this, _("Reset timer"), "timer", this)),
51
54
    mLine1(nullptr),
52
55
    mLine2(nullptr),
53
56
    mLine3(nullptr),
 
57
    // TRANSLATORS: kill stats window label
54
58
    mLine4(new Label(this, strprintf(_("Kills: %s, total exp: %s"),
55
59
        "?", "?"))),
 
60
    // TRANSLATORS: kill stats window label
56
61
    mLine5(new Label(this, strprintf(_("Avg Exp: %s"), "?"))),
 
62
    // TRANSLATORS: kill stats window label
57
63
    mLine6(new Label(this, strprintf(_("No. of avg mob to next level: %s"),
58
64
        "?"))),
 
65
    // TRANSLATORS: kill stats window label
59
66
    mLine7(new Label(this, strprintf(_("Kills/Min: %s, Exp/Min: %s"),
60
67
        "?", "?"))),
61
68
    mExpSpeed1Label(new Label(this, strprintf(ngettext(
 
69
        // TRANSLATORS: kill stats window label
62
70
        "Exp speed per %d min: %s", "Exp speed per %d min: %s", 1), 1, "?"))),
63
71
    mExpTime1Label(new Label(this, strprintf(ngettext(
64
72
        "Time for next level per %d min: %s",
74
82
    mExpTime15Label(new Label(this, strprintf(ngettext(
75
83
        "Time for next level per %d min: %s",
76
84
        "Time for next level per %d min: %s", 15), 15, "?"))),
 
85
    // TRANSLATORS: kill stats window label
77
86
    mLastKillExpLabel(new Label(this, strprintf("%s ?", _("Last kill exp:")))),
78
87
    mTimeBeforeJackoLabel(new Label(this, strprintf(
 
88
        // TRANSLATORS: kill stats window label
79
89
        "%s ?", _("Time before jacko spawn:")))),
80
90
    m1minExpTime(0),
81
91
    m1minExpNum(0),
107
117
    if (!xpNextLevel)
108
118
        xpNextLevel = 1;
109
119
 
 
120
    // TRANSLATORS: kill stats window label
110
121
    mLine1 = new Label(this, strprintf(_("Level: %d at %f%%"),
111
122
        player_node->getLevel(), static_cast<double>(xp)
112
123
        / static_cast<double>(xpNextLevel) * 100.0));
113
124
 
 
125
    // TRANSLATORS: kill stats window label
114
126
    mLine2 = new Label(this, strprintf(_("Exp: %d/%d Left: %d"),
115
127
        xp, xpNextLevel, xpNextLevel - xp));
116
128
 
 
129
    // TRANSLATORS: kill stats window label
117
130
    mLine3 = new Label(this, strprintf(_("1%% = %d exp, avg mob for 1%%: %s"),
118
131
        xpNextLevel / 100, "?"));
119
132
 
154
167
        mExpCounter = 0;
155
168
        mLine3->setCaption(strprintf("1%% = %d exp, avg mob for 1%%: %s",
156
169
            PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED) / 100, "?"));
 
170
        // TRANSLATORS: kill stats window label
157
171
        mLine4->setCaption(strprintf(_("Kills: %s, total exp: %s"), "?", "?"));
 
172
        // TRANSLATORS: kill stats window label
158
173
        mLine5->setCaption(strprintf(_("Avg Exp: %s"), "?"));
159
174
        mLine6->setCaption(strprintf(
 
175
            // TRANSLATORS: kill stats window label
160
176
            _("No. of avg mob to next level: %s"), "?"));
161
177
 
162
178
        resetTimes();
167
183
        mKillTCounter = 0;
168
184
        mExpTCounter = 0;
169
185
        mLine7->setCaption(strprintf(
 
186
            // TRANSLATORS: kill stats window label
170
187
            _("Kills/Min: %s, Exp/Min: %s"), "?", "?"));
171
188
 
172
189
        resetTimes();
217
234
        timeDiff = 1;
218
235
 
219
236
    const int exp = PlayerInfo::getAttribute(PlayerInfo::EXP);
 
237
    // TRANSLATORS: kill stats window label
220
238
    mLine1->setCaption(strprintf(_("Level: %d at %f%%"),
221
239
        player_node->getLevel(), static_cast<double>(exp)
222
240
        / static_cast<double>(xpNextLevel) * 100.0));
223
241
 
 
242
    // TRANSLATORS: kill stats window label
224
243
    mLine2->setCaption(strprintf(_("Exp: %d/%d Left: %d"), exp,
225
244
        xpNextLevel, xpNextLevel - exp));
226
245
 
227
246
    if (AvgExp >= 0.001f && AvgExp <= 0.001f)
228
247
    {
 
248
        // TRANSLATORS: kill stats window label
229
249
        mLine3->setCaption(strprintf(_("1%% = %d exp, avg mob for 1%%: %s"),
230
250
            xpNextLevel / 100, "?"));
231
251
 
 
252
        // TRANSLATORS: kill stats window label
232
253
        mLine5->setCaption(strprintf(_("Avg Exp: %s"),
233
254
            toString(AvgExp).c_str()));
234
255
 
235
256
        mLine6->setCaption(strprintf(
 
257
            // TRANSLATORS: kill stats window label
236
258
            _("No. of avg mob to next level: %s"), "?"));
237
259
    }
238
260
    else
239
261
    {
 
262
        // TRANSLATORS: kill stats window label
240
263
        mLine3->setCaption(strprintf(_("1%% = %d exp, avg mob for 1%%: %s"),
241
264
            xpNextLevel / 100, toString((static_cast<float>(
242
265
            xpNextLevel) / 100) / AvgExp).c_str()));
243
266
 
 
267
        // TRANSLATORS: kill stats window label
244
268
        mLine5->setCaption(strprintf(_("Avg Exp: %s"),
245
269
            toString(AvgExp).c_str()));
246
270
 
 
271
        // TRANSLATORS: kill stats window label
247
272
        mLine6->setCaption(strprintf(_("No. of avg mob to next level: %s"),
248
273
            toString(static_cast<float>(xpNextLevel - exp) / AvgExp).c_str()));
249
274
    }
 
275
    // TRANSLATORS: kill stats window label
250
276
    mLine4->setCaption(strprintf(_("Kills: %s, total exp: %s"),
251
277
        toString(mKillCounter).c_str(), toString(mExpCounter).c_str()));
252
278
 
 
279
    // TRANSLATORS: kill stats window label
253
280
    mLine7->setCaption(strprintf(_("Kills/Min: %s, Exp/Min: %s"),
254
281
        toString(mKillTCounter / timeDiff).c_str(),
255
282
        toString(mExpTCounter / timeDiff).c_str()));
256
283
 
 
284
    // TRANSLATORS: kill stats window label
257
285
    mLastKillExpLabel->setCaption(strprintf("%s %d", _("Last kill exp:"), xp));
258
286
 
259
287
    recalcStats();
311
339
 
312
340
    if (m1minSpeed != 0)
313
341
    {
 
342
        // TRANSLATORS: kill stats window label
314
343
        mExpTime1Label->setCaption(strprintf(_("  Time for next level: %s"),
315
344
            toString(static_cast<float>((PlayerInfo::getAttribute(
316
345
            PlayerInfo::EXP_NEEDED) - PlayerInfo::getAttribute(
319
348
    else
320
349
    {
321
350
        mExpTime1Label->setCaption(strprintf(
 
351
            // TRANSLATORS: kill stats window label
322
352
            _("  Time for next level: %s"), "?"));
323
353
    }
324
354
    mExpTime1Label->adjustSize();
329
359
 
330
360
    if (m5minSpeed != 0)
331
361
    {
 
362
        // TRANSLATORS: kill stats window label
332
363
        mExpTime5Label->setCaption(strprintf(_("  Time for next level: %s"),
333
364
            toString(static_cast<float>((PlayerInfo::getAttribute(
334
365
            PlayerInfo::EXP_NEEDED) - PlayerInfo::getAttribute(
337
368
    else
338
369
    {
339
370
        mExpTime5Label->setCaption(strprintf(
 
371
            // TRANSLATORS: kill stats window label
340
372
            _("  Time for next level: %s"), "?"));
341
373
    }
342
374
    mExpTime5Label->adjustSize();
349
381
 
350
382
    if (m15minSpeed != 0)
351
383
    {
 
384
        // TRANSLATORS: kill stats window label
352
385
        mExpTime15Label->setCaption(strprintf(_("  Time for next level: %s"),
353
386
            toString(static_cast<float>((PlayerInfo::getAttribute(
354
387
            PlayerInfo::EXP_NEEDED) - PlayerInfo::getAttribute(
357
390
    else
358
391
    {
359
392
        mExpTime15Label->setCaption(strprintf(
 
393
            // TRANSLATORS: kill stats window label
360
394
            _("  Time for next level: %s"), "?"));
361
395
    }
362
396
 
364
398
    updateJackoLabel();
365
399
    BLOCK_END("KillStats::update")
366
400
}
367
 
void KillStats::draw(gcn::Graphics *g)
368
 
{
369
 
//    update();
370
 
 
371
 
    Window::draw(g);
372
 
}
373
401
 
374
402
void KillStats::updateJackoLabel()
375
403
{
376
404
    if (mIsJackoAlive)
377
405
    {
378
406
        mTimeBeforeJackoLabel->setCaption(strprintf("%s jacko alive",
 
407
            // TRANSLATORS: kill stats window label
379
408
            _("Time before jacko spawn:")));
380
409
    }
381
410
    else if (mIsJackoSpawnTimeUnknown && mJackoSpawnTime != 0)
382
411
    {
383
 
        // TRANSLATORS: Example: Time before jacko spawn: 10?
 
412
        // TRANSLATORS: kill stats window label
384
413
        mTimeBeforeJackoLabel->setCaption(strprintf(
 
414
            // TRANSLATORS: kill stats window label
385
415
            _("%s %d?"), _("Time before jacko spawn:"),
386
416
            mJackoSpawnTime - cur_time));
387
417
    }
388
418
    else if (mIsJackoMustSpawn)
389
419
    {
390
420
        mTimeBeforeJackoLabel->setCaption(strprintf("%s %s",
 
421
            // TRANSLATORS: kill stats window label
391
422
            _("Time before jacko spawn:"), _("jacko spawning")));
392
423
    }
393
424
    else
394
425
    {
395
426
        mTimeBeforeJackoLabel->setCaption(strprintf("%s %d",
 
427
            // TRANSLATORS: kill stats window label
396
428
            _("Time before jacko spawn:"), mJackoSpawnTime - cur_time));
397
429
    }
398
430
}
463
495
        if (id == PlayerInfo::EXP || id == PlayerInfo::EXP_NEEDED)
464
496
        {
465
497
            gainXp(event.getInt("newValue") - event.getInt("oldValue"));
466
 
//            update();
467
498
        }
468
499
        else if (id == PlayerInfo::LEVEL)
469
500
        {
473
504
            mExpTCounter = 0;
474
505
            mLine3->setCaption(strprintf("1%% = %d exp, avg mob for 1%%: %s",
475
506
                PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED) / 100, "?"));
476
 
            mLine4->setCaption(strprintf(_(
477
 
                "Kills: %s, total exp: %s"), "?", "?"));
 
507
            mLine4->setCaption(strprintf(
 
508
                // TRANSLATORS: kill stats window label
 
509
                _("Kills: %s, total exp: %s"), "?", "?"));
 
510
                // TRANSLATORS: kill stats window label
478
511
            mLine5->setCaption(strprintf(_("Avg Exp: %s"), "?"));
479
512
            mLine6->setCaption(strprintf(
 
513
                // TRANSLATORS: kill stats window label
480
514
                _("No. of avg mob to next level: %s"), "?"));
481
515
            mLine7->setCaption(strprintf(
 
516
                // TRANSLATORS: kill stats window label
482
517
                _("Kills/Min: %s, Exp/Min: %s"), "?", "?"));
483
518
 
484
519
            resetTimes();