GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/progs/manaplus/actions/statusbar.cpp Lines: 1 63 1.6 %
Date: 2017-11-29 Branches: 0 34 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2012-2017  The ManaPlus Developers
4
 *
5
 *  This file is part of The ManaPlus Client.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
#include "actions/statusbar.h"
22
23
#include "game.h"
24
#include "soundmanager.h"
25
26
#include "actions/actiondef.h"
27
28
#include "being/localplayer.h"
29
#include "being/playerrelation.h"
30
#include "being/playerrelations.h"
31
32
#include "gui/viewport.h"
33
34
#include "gui/widgets/tabs/chat/chattab.h"
35
36
#include "listeners/updatestatuslistener.h"
37
38
#include "resources/map/map.h"
39
40
#include "utils/gettext.h"
41
42
PRAGMA48(GCC diagnostic push)
43
PRAGMA48(GCC diagnostic ignored "-Wshadow")
44
#ifdef ANDROID
45
#ifndef USE_SDL2
46
#include <SDL_screenkeyboard.h>
47
#endif  // USE_SDL2
48
#endif  // ANDROID
49
PRAGMA48(GCC diagnostic pop)
50
51
#include "debug.h"
52
53
namespace Actions
54
{
55
56
impHandler0(switchQuickDrop)
57
{
58
    callYellowBarCond(changeQuickDropCounter)
59
}
60
61
impHandler0(changeCrazyMove)
62
{
63
    callYellowBar(changeCrazyMoveType);
64
}
65
66
impHandler0(changePickupType)
67
{
68
    callYellowBar(changePickUpType);
69
}
70
71
impHandler0(changeMoveType)
72
{
73
    callYellowBar(changeMoveType);
74
}
75
76
impHandler0(changeAttackWeaponType)
77
{
78
    callYellowBar(changeAttackWeaponType);
79
}
80
81
impHandler0(changeAttackType)
82
{
83
    callYellowBar(changeAttackType);
84
}
85
86
impHandler0(changeTargetingType)
87
{
88
    callYellowBar(changeTargetingType);
89
}
90
91
impHandler0(changeFollowMode)
92
{
93
    callYellowBar(changeFollowMode);
94
}
95
96
impHandler0(changeImitationMode)
97
{
98
    callYellowBar(changeImitationMode);
99
}
100
101
impHandler0(changeMagicAttackType)
102
{
103
    callYellowBar(changeMagicAttackType);
104
}
105
106
impHandler0(changePvpMode)
107
{
108
    callYellowBar(changePvpAttackType);
109
}
110
111
impHandler0(changeMoveToTarget)
112
{
113
    callYellowBar(changeMoveToTargetType);
114
}
115
116
impHandler0(changeGameModifier)
117
{
118
    if (localPlayer != nullptr)
119
    {
120
        GameModifiers::changeGameModifiers(false);
121
        return true;
122
    }
123
    return false;
124
}
125
126
impHandler0(changeAudio)
127
{
128
    soundManager.changeAudio();
129
    if (localPlayer != nullptr)
130
        localPlayer->updateMusic();
131
    return true;
132
}
133
134
impHandler0(away)
135
{
136
    GameModifiers::changeAwayMode(true);
137
    if (localPlayer != nullptr)
138
    {
139
        localPlayer->updateStatus();
140
        if (Game::instance() != nullptr)
141
            Game::instance()->setValidSpeed();
142
        return true;
143
    }
144
    return false;
145
}
146
147
impHandler0(camera)
148
{
149
    if (viewport != nullptr)
150
    {
151
        viewport->toggleCameraMode();
152
        if (Game::instance() != nullptr)
153
            Game::instance()->setValidSpeed();
154
        return true;
155
    }
156
    return false;
157
}
158
159
impHandler0(changeMapMode)
160
{
161
    if (viewport != nullptr)
162
        viewport->toggleMapDrawType();
163
    UpdateStatusListener::distributeEvent();
164
    if (Game::instance() != nullptr)
165
    {
166
        if (Map *const map = Game::instance()->getCurrentMap())
167
            map->redrawMap();
168
    }
169
    return true;
170
}
171
172
impHandler0(changeTrade)
173
{
174
    unsigned int deflt = playerRelations.getDefault();
175
    if ((deflt & PlayerRelation::TRADE) != 0u)
176
    {
177
        if (localChatTab != nullptr)
178
        {
179
            // TRANSLATORS: disable trades message
180
            localChatTab->chatLog(_("Ignoring incoming trade requests"),
181
                ChatMsgType::BY_SERVER);
182
        }
183
        deflt &= ~PlayerRelation::TRADE;
184
    }
185
    else
186
    {
187
        if (localChatTab != nullptr)
188
        {
189
            // TRANSLATORS: enable trades message
190
            localChatTab->chatLog(_("Accepting incoming trade requests"),
191
                ChatMsgType::BY_SERVER);
192
        }
193
        deflt |= PlayerRelation::TRADE;
194
    }
195
196
    playerRelations.setDefault(deflt);
197
    return true;
198
}
199
200
4
}  // namespace Actions