From 6bedc289455528fe609f492cd9f1a0c352d981bb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 21 Aug 2014 19:59:12 +0300 Subject: Move status bar (yellow bar) related actions into separate file. --- src/actions/actions.cpp | 139 --------------------------- src/actions/actions.h | 17 ---- src/actions/statusbar.cpp | 237 ++++++++++++++++++++++++++++++++++++++++++++++ src/actions/statusbar.h | 51 ++++++++++ 4 files changed, 288 insertions(+), 156 deletions(-) create mode 100644 src/actions/statusbar.cpp create mode 100644 src/actions/statusbar.h (limited to 'src/actions') diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index 93294bfc0..926b0e48a 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -228,11 +228,6 @@ impHandler0(dropItem) return false; } -impHandler0(switchQuickDrop) -{ - callYellowBarCond(changeQuickDropCounter) -} - impHandler0(heal) { if (actorManager) @@ -271,16 +266,6 @@ impHandler0(itenplz) return false; } -impHandler0(changeCrazyMove) -{ - callYellowBar(changeCrazyMoveType); -} - -impHandler0(changePickupType) -{ - callYellowBar(changePickUpType); -} - impHandler0(setHome) { if (localPlayer) @@ -291,31 +276,6 @@ impHandler0(setHome) return false; } -impHandler0(changeMoveType) -{ - callYellowBar(changeMoveType); -} - -impHandler0(changeAttackWeaponType) -{ - callYellowBar(changeAttackWeaponType); -} - -impHandler0(changeAttackType) -{ - callYellowBar(changeAttackType); -} - -impHandler0(changeFollowMode) -{ - callYellowBar(changeFollowMode); -} - -impHandler0(changeImitationMode) -{ - callYellowBar(changeImitationMode); -} - impHandler0(magicAttack) { if (localPlayer) @@ -326,21 +286,6 @@ impHandler0(magicAttack) return false; } -impHandler0(changeMagicAttackType) -{ - callYellowBar(changeMagicAttackType); -} - -impHandler0(changePvpMode) -{ - callYellowBar(changePvpAttackType); -} - -impHandler0(changeMoveToTarget) -{ - callYellowBar(changeMoveToTargetType); -} - impHandler0(copyEquippedToOutfit) { if (outfitWindow) @@ -351,49 +296,6 @@ impHandler0(copyEquippedToOutfit) return false; } -impHandler0(changeGameModifier) -{ - if (localPlayer) - { - GameModifiers::changeGameModifiers(); - return true; - } - return false; -} - -impHandler0(changeAudio) -{ - soundManager.changeAudio(); - if (localPlayer) - localPlayer->updateMusic(); - return true; -} - -impHandler0(away) -{ - GameModifiers::changeAwayMode(); - if (localPlayer) - { - localPlayer->updateStatus(); - if (Game::instance()) - Game::instance()->setValidSpeed(); - return true; - } - return false; -} - -impHandler0(camera) -{ - if (viewport) - { - viewport->toggleCameraMode(); - if (Game::instance()) - Game::instance()->setValidSpeed(); - return true; - } - return false; -} - impHandler0(pickup) { if (localPlayer) @@ -422,47 +324,6 @@ impHandler0(sit) return false; } -impHandler0(changeMapMode) -{ - if (viewport) - viewport->toggleMapDrawType(); - UpdateStatusListener::distributeEvent(); - if (Game::instance()) - { - if (Map *const map = Game::instance()->getCurrentMap()) - map->redrawMap(); - } - return true; -} - -impHandler0(changeTrade) -{ - unsigned int deflt = player_relations.getDefault(); - if (deflt & PlayerRelation::TRADE) - { - if (localChatTab) - { - // TRANSLATORS: disable trades message - localChatTab->chatLog(_("Ignoring incoming trade requests"), - ChatMsgType::BY_SERVER); - } - deflt &= ~PlayerRelation::TRADE; - } - else - { - if (localChatTab) - { - // TRANSLATORS: enable trades message - localChatTab->chatLog(_("Accepting incoming trade requests"), - ChatMsgType::BY_SERVER); - } - deflt |= PlayerRelation::TRADE; - } - - player_relations.setDefault(deflt); - return true; -} - impHandler0(screenshot) { Game::createScreenshot(); diff --git a/src/actions/actions.h b/src/actions/actions.h index da216deb5..36a83d1d3 100644 --- a/src/actions/actions.h +++ b/src/actions/actions.h @@ -35,30 +35,13 @@ namespace Actions decHandler(quit); decHandler(dropItem0); decHandler(dropItem); - decHandler(switchQuickDrop); decHandler(heal); decHandler(itenplz); - decHandler(changeCrazyMove); - decHandler(changePickupType); decHandler(setHome); - decHandler(changeMoveType); - decHandler(changeAttackWeaponType); - decHandler(changeAttackType); - decHandler(changeFollowMode); - decHandler(changeImitationMode); decHandler(magicAttack); - decHandler(changeMagicAttackType); - decHandler(changePvpMode); - decHandler(changeMoveToTarget); decHandler(copyEquippedToOutfit); - decHandler(changeGameModifier); - decHandler(changeAudio); - decHandler(away); - decHandler(camera); decHandler(pickup); decHandler(sit); - decHandler(changeMapMode); - decHandler(changeTrade); decHandler(screenshot); decHandler(ignoreInput); decHandler(talk); diff --git a/src/actions/statusbar.cpp b/src/actions/statusbar.cpp new file mode 100644 index 000000000..d74cc916b --- /dev/null +++ b/src/actions/statusbar.cpp @@ -0,0 +1,237 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "actions/statusbar.h" + +#include "actormanager.h" +#include "dropshortcut.h" +#include "emoteshortcut.h" +#include "game.h" +#include "itemshortcut.h" +#include "soundmanager.h" + +#include "actions/actiondef.h" + +#include "being/attributes.h" +#include "being/localplayer.h" +#include "being/playerinfo.h" +#include "being/playerrelations.h" + +#include "gui/dialogsmanager.h" +#include "gui/gui.h" +#include "gui/popupmanager.h" +#include "gui/sdlinput.h" +#include "gui/viewport.h" + +#include "gui/popups/popupmenu.h" + +#include "gui/windows/skilldialog.h" +#include "gui/windows/socialwindow.h" +#include "gui/windows/statuswindow.h" +#include "gui/windows/tradewindow.h" +#include "gui/windows/questswindow.h" +#include "gui/windows/quitdialog.h" +#include "gui/windows/whoisonline.h" +#include "gui/windows/botcheckerwindow.h" +#include "gui/windows/buyselldialog.h" +#include "gui/windows/chatwindow.h" +#include "gui/windows/debugwindow.h" +#include "gui/windows/didyouknowwindow.h" +#include "gui/windows/equipmentwindow.h" +#include "gui/windows/helpwindow.h" +#include "gui/windows/inventorywindow.h" +#include "gui/windows/killstats.h" +#include "gui/windows/minimap.h" +#include "gui/windows/npcdialog.h" +#include "gui/windows/outfitwindow.h" +#include "gui/windows/setupwindow.h" +#include "gui/windows/shopwindow.h" +#include "gui/windows/shortcutwindow.h" +#include "gui/windows/updaterwindow.h" + +#include "gui/widgets/tabs/chattab.h" + +#include "render/graphics.h" + +#include "net/net.h" +#include "net/playerhandler.h" +#include "net/tradehandler.h" + +#include "listeners/updatestatuslistener.h" + +#include "resources/map/map.h" + +#include "utils/gettext.h" + +#ifdef ANDROID +#ifndef USE_SDL2 +#include +#endif +#endif + +#include "debug.h" + +extern ShortcutWindow *spellShortcutWindow; +extern std::string tradePartnerName; +extern QuitDialog *quitDialog; + +namespace Actions +{ + +impHandler0(switchQuickDrop) +{ + callYellowBarCond(changeQuickDropCounter) +} + +impHandler0(changeCrazyMove) +{ + callYellowBar(changeCrazyMoveType); +} + +impHandler0(changePickupType) +{ + callYellowBar(changePickUpType); +} + +impHandler0(changeMoveType) +{ + callYellowBar(changeMoveType); +} + +impHandler0(changeAttackWeaponType) +{ + callYellowBar(changeAttackWeaponType); +} + +impHandler0(changeAttackType) +{ + callYellowBar(changeAttackType); +} + +impHandler0(changeFollowMode) +{ + callYellowBar(changeFollowMode); +} + +impHandler0(changeImitationMode) +{ + callYellowBar(changeImitationMode); +} + +impHandler0(changeMagicAttackType) +{ + callYellowBar(changeMagicAttackType); +} + +impHandler0(changePvpMode) +{ + callYellowBar(changePvpAttackType); +} + +impHandler0(changeMoveToTarget) +{ + callYellowBar(changeMoveToTargetType); +} + +impHandler0(changeGameModifier) +{ + if (localPlayer) + { + GameModifiers::changeGameModifiers(); + return true; + } + return false; +} + +impHandler0(changeAudio) +{ + soundManager.changeAudio(); + if (localPlayer) + localPlayer->updateMusic(); + return true; +} + +impHandler0(away) +{ + GameModifiers::changeAwayMode(); + if (localPlayer) + { + localPlayer->updateStatus(); + if (Game::instance()) + Game::instance()->setValidSpeed(); + return true; + } + return false; +} + +impHandler0(camera) +{ + if (viewport) + { + viewport->toggleCameraMode(); + if (Game::instance()) + Game::instance()->setValidSpeed(); + return true; + } + return false; +} + +impHandler0(changeMapMode) +{ + if (viewport) + viewport->toggleMapDrawType(); + UpdateStatusListener::distributeEvent(); + if (Game::instance()) + { + if (Map *const map = Game::instance()->getCurrentMap()) + map->redrawMap(); + } + return true; +} + +impHandler0(changeTrade) +{ + unsigned int deflt = player_relations.getDefault(); + if (deflt & PlayerRelation::TRADE) + { + if (localChatTab) + { + // TRANSLATORS: disable trades message + localChatTab->chatLog(_("Ignoring incoming trade requests"), + ChatMsgType::BY_SERVER); + } + deflt &= ~PlayerRelation::TRADE; + } + else + { + if (localChatTab) + { + // TRANSLATORS: enable trades message + localChatTab->chatLog(_("Accepting incoming trade requests"), + ChatMsgType::BY_SERVER); + } + deflt |= PlayerRelation::TRADE; + } + + player_relations.setDefault(deflt); + return true; +} + +} // namespace Actions diff --git a/src/actions/statusbar.h b/src/actions/statusbar.h new file mode 100644 index 000000000..68e1d6217 --- /dev/null +++ b/src/actions/statusbar.h @@ -0,0 +1,51 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef ACTIONS_STATUSBAR_H +#define ACTIONS_STATUSBAR_H + +#define decHandler(name) bool name(const InputEvent &event) + +struct InputEvent; + +namespace Actions +{ + decHandler(switchQuickDrop); + decHandler(changeCrazyMove); + decHandler(changePickupType); + decHandler(changeMoveType); + decHandler(changeAttackWeaponType); + decHandler(changeAttackType); + decHandler(changeFollowMode); + decHandler(changeImitationMode); + decHandler(changeMagicAttackType); + decHandler(changePvpMode); + decHandler(changeMoveToTarget); + decHandler(changeGameModifier); + decHandler(changeAudio); + decHandler(away); + decHandler(camera); + decHandler(changeMapMode); + decHandler(changeTrade); +} // namespace Actions + +#undef decHandler + +#endif // ACTIONS_STATUSBAR_H -- cgit v1.2.3-60-g2f50