GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/progs/manaplus/actions/statusbar.cpp Lines: 1 65 1.5 %
Date: 2021-03-17 Branches: 0 30 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2012-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 "actions/statusbar.h"
23
24
#include "game.h"
25
#include "soundmanager.h"
26
27
#include "actions/actiondef.h"
28
29
#include "being/localplayer.h"
30
#include "being/playerrelation.h"
31
#include "being/playerrelations.h"
32
33
#include "gui/viewport.h"
34
35
#include "gui/widgets/tabs/chat/chattab.h"
36
37
#include "listeners/updatestatuslistener.h"
38
39
#include "resources/map/map.h"
40
41
#include "utils/gettext.h"
42
43
PRAGMA48(GCC diagnostic push)
44
PRAGMA48(GCC diagnostic ignored "-Wshadow")
45
#ifdef ANDROID
46
#ifndef USE_SDL2
47
#include <SDL_screenkeyboard.h>
48
#endif  // USE_SDL2
49
#endif  // ANDROID
50
PRAGMA48(GCC diagnostic pop)
51
52
#include "debug.h"
53
54
namespace Actions
55
{
56
57
impHandler0(switchQuickDrop)
58
{
59
    callYellowBarCond(changeQuickDropCounter);
60
}
61
62
impHandler0(changeCrazyMove)
63
{
64
    callYellowBar(changeCrazyMoveType);
65
}
66
67
impHandler0(changePickupType)
68
{
69
    callYellowBar(changePickUpType);
70
}
71
72
impHandler0(changeMoveType)
73
{
74
    callYellowBar(changeMoveType);
75
}
76
77
impHandler0(changeAttackWeaponType)
78
{
79
    callYellowBar(changeAttackWeaponType);
80
}
81
82
impHandler0(changeAttackType)
83
{
84
    callYellowBar(changeAttackType);
85
}
86
87
impHandler0(changeTargetingType)
88
{
89
    callYellowBar(changeTargetingType);
90
}
91
92
impHandler0(changeFollowMode)
93
{
94
    callYellowBar(changeFollowMode);
95
}
96
97
impHandler0(changeImitationMode)
98
{
99
    callYellowBar(changeImitationMode);
100
}
101
102
impHandler0(changeMagicAttackType)
103
{
104
    callYellowBar(changeMagicAttackType);
105
}
106
107
impHandler0(changePvpMode)
108
{
109
    callYellowBar(changePvpAttackType);
110
}
111
112
impHandler0(changeMoveToTarget)
113
{
114
    callYellowBar(changeMoveToTargetType);
115
}
116
117
impHandler0(changeGameModifier)
118
{
119
    if (localPlayer != nullptr)
120
    {
121
        GameModifiers::changeGameModifiers(false);
122
        return true;
123
    }
124
    return false;
125
}
126
127
impHandler0(changeAudio)
128
{
129
    soundManager.changeAudio();
130
    if (localPlayer != nullptr)
131
        localPlayer->updateMusic();
132
    return true;
133
}
134
135
impHandler0(away)
136
{
137
    GameModifiers::changeAwayMode(true);
138
    if (localPlayer != nullptr)
139
    {
140
        localPlayer->updateStatus();
141
        if (Game::instance() != nullptr)
142
            Game::instance()->setValidSpeed();
143
        return true;
144
    }
145
    return false;
146
}
147
148
impHandler0(camera)
149
{
150
    if (viewport != nullptr)
151
    {
152
        viewport->toggleCameraMode();
153
        if (Game::instance() != nullptr)
154
            Game::instance()->setValidSpeed();
155
        return true;
156
    }
157
    return false;
158
}
159
160
impHandler0(changeMapMode)
161
{
162
    if (viewport != nullptr)
163
        viewport->toggleMapDrawType();
164
    UpdateStatusListener::distributeEvent();
165
    if (Game::instance() != nullptr)
166
    {
167
        if (Map *const map = Game::instance()->getCurrentMap())
168
            map->redrawMap();
169
    }
170
    return true;
171
}
172
173
impHandler0(changeTrade)
174
{
175
    unsigned int deflt = playerRelations.getDefault();
176
    if ((deflt & PlayerRelation::TRADE) != 0U)
177
    {
178
        if (localChatTab != nullptr)
179
        {
180
            // TRANSLATORS: disable trades message
181
            localChatTab->chatLog(_("Ignoring incoming trade requests"),
182
                ChatMsgType::BY_SERVER,
183
                IgnoreRecord_false,
184
                TryRemoveColors_true);
185
        }
186
        deflt &= ~PlayerRelation::TRADE;
187
    }
188
    else
189
    {
190
        if (localChatTab != nullptr)
191
        {
192
            // TRANSLATORS: enable trades message
193
            localChatTab->chatLog(_("Accepting incoming trade requests"),
194
                ChatMsgType::BY_SERVER,
195
                IgnoreRecord_false,
196
                TryRemoveColors_true);
197
        }
198
        deflt |= PlayerRelation::TRADE;
199
    }
200
201
    playerRelations.setDefault(deflt);
202
    return true;
203
}
204
205
2
}  // namespace Actions