GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
/* |
||
2 |
* The ManaPlus Client |
||
3 |
* Copyright (C) 2011-2019 The ManaPlus Developers |
||
4 |
* Copyright (C) 2019-2021 Andrei Karas |
||
5 |
* |
||
6 |
* This file is part of The ManaPlus Client. |
||
7 |
* |
||
8 |
* This program is free software; you can redistribute it and/or modify |
||
9 |
* it under the terms of the GNU General Public License as published by |
||
10 |
* the Free Software Foundation; either version 2 of the License, or |
||
11 |
* any later version. |
||
12 |
* |
||
13 |
* This program is distributed in the hope that it will be useful, |
||
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 |
* GNU General Public License for more details. |
||
17 |
* |
||
18 |
* You should have received a copy of the GNU General Public License |
||
19 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
20 |
*/ |
||
21 |
|||
22 |
#include "gui/windows/bankwindow.h" |
||
23 |
|||
24 |
#include "net/bankhandler.h" |
||
25 |
|||
26 |
#include "gui/windows/setupwindow.h" |
||
27 |
|||
28 |
#include "gui/widgets/button.h" |
||
29 |
#include "gui/widgets/containerplacer.h" |
||
30 |
#include "gui/widgets/inttextfield.h" |
||
31 |
#include "gui/widgets/label.h" |
||
32 |
|||
33 |
#include "utils/gettext.h" |
||
34 |
#include "utils/stringutils.h" |
||
35 |
|||
36 |
#include "resources/db/unitsdb.h" |
||
37 |
|||
38 |
#include "debug.h" |
||
39 |
|||
40 |
BankWindow *bankWindow = nullptr; |
||
41 |
|||
42 |
1 |
BankWindow::BankWindow() : |
|
43 |
// TRANSLATORS: bank window name |
||
44 |
1 |
Window(_("Bank"), Modal_false, nullptr, "bank.xml"), |
|
45 |
ActionListener(), |
||
46 |
BankListener(), |
||
47 |
✓✗ | 2 |
mBankMoneyLabel(new Label(this, strprintf( |
48 |
// TRANSLATORS: bank window money label |
||
49 |
✓✗✓✗ |
2 |
_("Money in bank: %s"), " "))), |
50 |
mInputMoneyTextField(new IntTextField(this, 0, 0, 2147483647, |
||
51 |
✓✗✓✗ |
1 |
Enable_true, 0)), |
52 |
// TRANSLATORS: bank window button |
||
53 |
1 |
mWithdrawButton(new Button(this, _("Withdraw"), "withdraw", |
|
54 |
✓✗✓✗ |
1 |
BUTTON_SKIN, this)), |
55 |
// TRANSLATORS: bank window button |
||
56 |
1 |
mDepositButton(new Button(this, _("Deposit"), "deposit", |
|
57 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
22 |
BUTTON_SKIN, this)) |
58 |
{ |
||
59 |
✓✗ | 4 |
setWindowName("Bank"); |
60 |
✓✗ | 1 |
setCloseButton(true); |
61 |
|||
62 |
✗✓ | 1 |
if (setupWindow != nullptr) |
63 |
setupWindow->registerWindowForReset(this); |
||
64 |
|||
65 |
✓✗ | 1 |
mBankMoneyLabel->adjustSize(); |
66 |
✓✗ | 1 |
ContainerPlacer placer = getPlacer(0, 0); |
67 |
✓✗ | 1 |
placer(0, 0, mBankMoneyLabel, 7, 1); |
68 |
✓✗ | 1 |
placer(0, 1, mInputMoneyTextField, 10, 1); |
69 |
✓✗ | 1 |
placer(0, 2, mDepositButton, 5, 1); |
70 |
✓✗ | 1 |
placer(5, 2, mWithdrawButton, 5, 1); |
71 |
|||
72 |
✓✗ | 1 |
setContentSize(300, 100); |
73 |
✓✗ | 1 |
setDefaultSize(300, 100, ImagePosition::CENTER, 0, 0); |
74 |
|||
75 |
✓✗ | 1 |
center(); |
76 |
✓✗ | 1 |
setDefaultSize(); |
77 |
✓✗ | 1 |
loadWindowState(); |
78 |
✓✗ | 1 |
reflowLayout(300, 0); |
79 |
2 |
enableVisibleSound(true); |
|
80 |
1 |
} |
|
81 |
|||
82 |
3 |
BankWindow::~BankWindow() |
|
83 |
{ |
||
84 |
2 |
} |
|
85 |
|||
86 |
void BankWindow::widgetShown(const Event &event) |
||
87 |
{ |
||
88 |
if (event.getSource() == this) |
||
89 |
bankHandler->check(); |
||
90 |
} |
||
91 |
|||
92 |
void BankWindow::bankMoneyChanged(const int money) |
||
93 |
{ |
||
94 |
// TRANSLATORS: bank window money label |
||
95 |
mBankMoneyLabel->setCaption(strprintf(_("Money in bank: %s"), |
||
96 |
UnitsDb::formatCurrency(money).c_str())); |
||
97 |
} |
||
98 |
|||
99 |
void BankWindow::action(const ActionEvent &event) |
||
100 |
{ |
||
101 |
const std::string &eventId = event.getId(); |
||
102 |
if (eventId == "deposit") |
||
103 |
bankHandler->deposit(mInputMoneyTextField->getValue()); |
||
104 |
else if (eventId == "withdraw") |
||
105 |
bankHandler->withdraw(mInputMoneyTextField->getValue()); |
||
106 |
✓✗✓✗ |
3 |
} |
Generated by: GCOVR (Version 3.3) |