ManaPlus
statusbar.cpp
Go to the documentation of this file.
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 
36 
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 
58 {
59  callYellowBarCond(changeQuickDropCounter);
60 }
61 
63 {
64  callYellowBar(changeCrazyMoveType);
65 }
66 
68 {
69  callYellowBar(changePickUpType);
70 }
71 
73 {
75 }
76 
78 {
80 }
81 
83 {
85 }
86 
88 {
90 }
91 
93 {
95 }
96 
98 {
100 }
101 
103 {
105 }
106 
108 {
109  callYellowBar(changePvpAttackType);
110 }
111 
113 {
114  callYellowBar(changeMoveToTargetType);
115 }
116 
118 {
119  if (localPlayer != nullptr)
120  {
122  return true;
123  }
124  return false;
125 }
126 
128 {
130  if (localPlayer != nullptr)
132  return true;
133 }
134 
136 {
138  if (localPlayer != nullptr)
139  {
141  if (Game::instance() != nullptr)
143  return true;
144  }
145  return false;
146 }
147 
149 {
150  if (viewport != nullptr)
151  {
153  if (Game::instance() != nullptr)
155  return true;
156  }
157  return false;
158 }
159 
161 {
162  if (viewport != nullptr)
165  if (Game::instance() != nullptr)
166  {
167  if (Map *const map = Game::instance()->getCurrentMap())
168  map->redrawMap();
169  }
170  return true;
171 }
172 
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"),
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"),
197  }
198  deflt |= PlayerRelation::TRADE;
199  }
200 
202  return true;
203 }
204 
205 } // namespace Actions
#define callYellowBar(name)
Definition: actiondef.h:40
#define impHandler0(name)
Definition: actiondef.h:34
#define callYellowBarCond(name)
Definition: actiondef.h:45
ChatTab * localChatTab
Definition: chattab.cpp:62
void chatLog(std::string line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
Definition: chattab.cpp:111
static void changeAwayMode(const bool forward)
static void changeGameModifiers(const bool forward)
static Game * instance()
Definition: game.h:82
void setValidSpeed()
Definition: game.cpp:1273
void updateStatus() const
void updateMusic() const
Definition: map.h:75
void setDefault(const unsigned int permissions)
unsigned int getDefault() const
void changeAudio()
void toggleMapDrawType()
Definition: viewport.cpp:251
void toggleCameraMode()
Definition: viewport.cpp:255
Viewport * viewport
Definition: viewport.cpp:36
#define _(s)
Definition: gettext.h:35
const bool IgnoreRecord_false
Definition: ignorerecord.h:30
#define PRAGMA48(str)
Definition: localconsts.h:199
LocalPlayer * localPlayer
bool changeMagicAttackType(InputEvent &event)
Definition: statusbar.cpp:40
bool changeImitationMode(InputEvent &event)
Definition: statusbar.cpp:39
bool changeAttackWeaponType(InputEvent &event)
Definition: statusbar.cpp:35
bool changeAttackType(InputEvent &event)
Definition: statusbar.cpp:36
bool changeGameModifier(InputEvent &event)
Definition: statusbar.cpp:43
bool changeCrazyMove(InputEvent &event)
Definition: statusbar.cpp:32
bool changeMapMode(InputEvent &event)
Definition: statusbar.cpp:47
bool changeMoveToTarget(InputEvent &event)
Definition: statusbar.cpp:42
bool changeMoveType(InputEvent &event)
Definition: statusbar.cpp:34
bool changeAudio(InputEvent &event)
Definition: statusbar.cpp:44
bool changeTargetingType(InputEvent &event)
Definition: statusbar.cpp:37
bool changeTrade(InputEvent &event)
Definition: statusbar.cpp:48
bool changeFollowMode(InputEvent &event)
Definition: statusbar.cpp:38
bool switchQuickDrop(InputEvent &event)
Definition: statusbar.cpp:31
bool changePickupType(InputEvent &event)
Definition: statusbar.cpp:33
bool camera(InputEvent &event)
Definition: statusbar.cpp:46
bool away(InputEvent &event)
Definition: statusbar.cpp:45
bool changePvpMode(InputEvent &event)
Definition: statusbar.cpp:41
PlayerRelationsManager playerRelations
SoundManager soundManager
static const unsigned int TRADE
const bool TryRemoveColors_true