From f82a8240b7f160e1a171871b3596cc13cabc34b2 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 6 Sep 2017 00:24:57 +0300 Subject: Move dyecmd separate sources from dyetool into progs/dyecmd directory. --- src/CMakeLists.txt | 2 +- src/Makefile.am | 28 +- src/client.h | 2 +- src/dyetool/actions/actions.cpp | 120 ----- src/dyetool/actions/chat.cpp | 69 --- src/dyetool/actions/commands.cpp | 167 ------- src/dyetool/actions/move.cpp | 44 -- src/dyetool/actions/pets.cpp | 49 -- src/dyetool/actions/statusbar.cpp | 49 -- src/dyetool/actions/tabs.cpp | 39 -- src/dyetool/actions/target.cpp | 39 -- src/dyetool/actions/windows.cpp | 60 --- src/dyetool/client.cpp | 813 --------------------------------- src/dyetool/client.h | 119 ----- src/dyetool/dyemain.cpp | 119 ----- src/dyetool/gui/viewport.cpp | 272 ----------- src/dyetool/gui/viewport.h | 213 --------- src/gui/viewport.h | 2 +- src/progs/dyecmd/actions/actions.cpp | 120 +++++ src/progs/dyecmd/actions/chat.cpp | 69 +++ src/progs/dyecmd/actions/commands.cpp | 167 +++++++ src/progs/dyecmd/actions/move.cpp | 44 ++ src/progs/dyecmd/actions/pets.cpp | 49 ++ src/progs/dyecmd/actions/statusbar.cpp | 49 ++ src/progs/dyecmd/actions/tabs.cpp | 39 ++ src/progs/dyecmd/actions/target.cpp | 39 ++ src/progs/dyecmd/actions/windows.cpp | 60 +++ src/progs/dyecmd/client.cpp | 813 +++++++++++++++++++++++++++++++++ src/progs/dyecmd/client.h | 119 +++++ src/progs/dyecmd/dyemain.cpp | 119 +++++ src/progs/dyecmd/gui/viewport.cpp | 272 +++++++++++ src/progs/dyecmd/gui/viewport.h | 213 +++++++++ 32 files changed, 2189 insertions(+), 2189 deletions(-) delete mode 100644 src/dyetool/actions/actions.cpp delete mode 100644 src/dyetool/actions/chat.cpp delete mode 100644 src/dyetool/actions/commands.cpp delete mode 100644 src/dyetool/actions/move.cpp delete mode 100644 src/dyetool/actions/pets.cpp delete mode 100644 src/dyetool/actions/statusbar.cpp delete mode 100644 src/dyetool/actions/tabs.cpp delete mode 100644 src/dyetool/actions/target.cpp delete mode 100644 src/dyetool/actions/windows.cpp delete mode 100644 src/dyetool/client.cpp delete mode 100644 src/dyetool/client.h delete mode 100644 src/dyetool/dyemain.cpp delete mode 100644 src/dyetool/gui/viewport.cpp delete mode 100644 src/dyetool/gui/viewport.h create mode 100644 src/progs/dyecmd/actions/actions.cpp create mode 100644 src/progs/dyecmd/actions/chat.cpp create mode 100644 src/progs/dyecmd/actions/commands.cpp create mode 100644 src/progs/dyecmd/actions/move.cpp create mode 100644 src/progs/dyecmd/actions/pets.cpp create mode 100644 src/progs/dyecmd/actions/statusbar.cpp create mode 100644 src/progs/dyecmd/actions/tabs.cpp create mode 100644 src/progs/dyecmd/actions/target.cpp create mode 100644 src/progs/dyecmd/actions/windows.cpp create mode 100644 src/progs/dyecmd/client.cpp create mode 100644 src/progs/dyecmd/client.h create mode 100644 src/progs/dyecmd/dyemain.cpp create mode 100644 src/progs/dyecmd/gui/viewport.cpp create mode 100644 src/progs/dyecmd/gui/viewport.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index da2fc507f..62ba63ffd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1710,7 +1710,7 @@ SET(DYE_CMD_SRCS gui/color.h events/event.h gui/rect.h - dyetool/dyemain.cpp + progs/dyecmd/dyemain.cpp resources/sprite/animatedsprite.cpp resources/sprite/animatedsprite.h resources/sprite/animationdelayload.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 93cc93c07..f8b7cf8a6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -155,7 +155,7 @@ manaplus_CXXFLAGS += -DENABLE_CILKPLUS -fcilkplus -lcilkrts endif dyecmd_CXXFLAGS += -DDYECMD -dyecmd_SOURCES += dyetool/dyemain.cpp +dyecmd_SOURCES += progs/dyecmd/dyemain.cpp if USE_MUMBLE manaplus_CXXFLAGS += -DUSE_MUMBLE @@ -1996,19 +1996,19 @@ SRC += \ mumblemanager.cpp \ mumblemanager.h -dyecmd_SOURCES += dyetool/gui/viewport.cpp \ - dyetool/gui/viewport.h \ - dyetool/client.cpp \ - dyetool/client.h \ - dyetool/actions/actions.cpp \ - dyetool/actions/chat.cpp \ - dyetool/actions/commands.cpp \ - dyetool/actions/move.cpp \ - dyetool/actions/pets.cpp \ - dyetool/actions/statusbar.cpp \ - dyetool/actions/tabs.cpp \ - dyetool/actions/target.cpp \ - dyetool/actions/windows.cpp +dyecmd_SOURCES += progs/dyecmd/gui/viewport.cpp \ + progs/dyecmd/gui/viewport.h \ + progs/dyecmd/client.cpp \ + progs/dyecmd/client.h \ + progs/dyecmd/actions/actions.cpp \ + progs/dyecmd/actions/chat.cpp \ + progs/dyecmd/actions/commands.cpp \ + progs/dyecmd/actions/move.cpp \ + progs/dyecmd/actions/pets.cpp \ + progs/dyecmd/actions/statusbar.cpp \ + progs/dyecmd/actions/tabs.cpp \ + progs/dyecmd/actions/target.cpp \ + progs/dyecmd/actions/windows.cpp if ENABLE_MANAPLUSGAME manaplus_SOURCES += ${SRC} diff --git a/src/client.h b/src/client.h index 06e362a35..6c6888f52 100644 --- a/src/client.h +++ b/src/client.h @@ -24,7 +24,7 @@ #define CLIENT_H #ifdef DYECMD -#include "dyetool/client.h" +#include "progs/dyecmd/client.h" #else // DYECMD diff --git a/src/dyetool/actions/actions.cpp b/src/dyetool/actions/actions.cpp deleted file mode 100644 index 58353b699..000000000 --- a/src/dyetool/actions/actions.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 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/actions.h" - -#include "actions/actiondef.h" - -#include "debug.h" - -namespace Actions -{ - -impHandlerVoid(emote) -impHandlerVoid(outfit) -impHandlerVoid(mouseClick) -impHandlerVoid(ok) -impHandlerVoid(shortcut) -impHandlerVoid(quit) -impHandlerVoid(dropItem0) -impHandlerVoid(dropItem) -impHandlerVoid(dropItemId) -impHandlerVoid(dropItemInv) -impHandlerVoid(dropItemIdAll) -impHandlerVoid(dropItemInvAll) -impHandlerVoid(heal) -impHandlerVoid(healmd) -impHandlerVoid(itenplz) -impHandlerVoid(setHome) -impHandlerVoid(magicAttack) -impHandlerVoid(copyEquippedToOutfit) -impHandlerVoid(pickup) -impHandlerVoid(sit) -impHandlerVoid(screenshot) -impHandlerVoid(ignoreInput) -impHandlerVoid(buy) -impHandlerVoid(sell) -impHandlerVoid(talk) -impHandlerVoid(stopAttack) -impHandlerVoid(untarget) -impHandlerVoid(attack) -impHandlerVoid(targetAttack) -impHandlerVoid(attackHuman) -impHandlerVoid(safeVideoMode) -impHandlerVoid(stopSit) -impHandlerVoid(showKeyboard) -impHandlerVoid(showWindows) -impHandlerVoid(openTrade) -impHandlerVoid(ipcToggle) -impHandlerVoid(where) -impHandlerVoid(who) -impHandlerVoid(cleanGraphics) -impHandlerVoid(cleanFonts) -impHandlerVoid(trade) -impHandlerVoid(priceLoad) -impHandlerVoid(priceSave) -impHandlerVoid(cacheInfo) -impHandlerVoid(disconnect) -impHandlerVoid(undress) -impHandlerVoid(dirs) -impHandlerVoid(uptime) -impHandlerVoid(dump) -impHandlerVoid(serverIgnoreAll) -impHandlerVoid(serverUnIgnoreAll) -impHandler0(error) -{ - exit(0); -} -impHandlerVoid(dumpGraphics) -impHandlerVoid(dumpEnvironment) -impHandlerVoid(dumpTests) -impHandlerVoid(dumpOGL) -impHandlerVoid(dumpGL) -impHandlerVoid(dumpMods) -#if defined USE_OPENGL && defined DEBUG_SDLFONT -impHandlerVoid(testSdlFont) -#endif // defined USE_OPENGL && defined DEBUG_SDLFONT -impHandlerVoid(createItems) -impHandlerVoid(createItem) -impHandlerVoid(uploadConfig) -impHandlerVoid(uploadServerConfig) -impHandlerVoid(uploadLog) -impHandlerVoid(mercenaryFire) -impHandlerVoid(mercenaryToMaster) -impHandlerVoid(homunculusToMaster) -impHandlerVoid(homunculusFeed) -impHandlerVoid(useItem) -impHandlerVoid(useItemInv) -impHandlerVoid(invToStorage) -impHandlerVoid(tradeAdd) -impHandlerVoid(storageToInv) -impHandlerVoid(protectItem) -impHandlerVoid(unprotectItem) -impHandlerVoid(kick) -impHandlerVoid(clearDrop) -impHandlerVoid(testInfo) -impHandlerVoid(craftKey) -impHandlerVoid(resetGameModifiers) -impHandlerVoid(barToChat) -impHandlerVoid(seen) -impHandlerVoid(dumpMemoryUsage) -impHandlerVoid(setEmoteType) - -} // namespace Actions diff --git a/src/dyetool/actions/chat.cpp b/src/dyetool/actions/chat.cpp deleted file mode 100644 index ece0e42b9..000000000 --- a/src/dyetool/actions/chat.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 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/chat.h" - -#include "actions/actiondef.h" - -#include "debug.h" - -namespace Actions -{ - -impHandlerVoid(toggleChat) -impHandlerVoid(prevChatTab) -impHandlerVoid(nextChatTab) -impHandlerVoid(closeChatTab) -impHandlerVoid(closeAllChatTabs) -impHandlerVoid(ignoreAllWhispers) -impHandlerVoid(scrollChatUp) -impHandlerVoid(scrollChatDown) -impHandlerVoid(msg) -impHandlerVoid(msgText) -impHandlerVoid(msg2) -impHandlerVoid(query) -impHandlerVoid(clearChatTab) -impHandlerVoid(createParty) -impHandlerVoid(createGuild) -impHandlerVoid(party) -impHandlerVoid(guild) -impHandlerVoid(me) -impHandlerVoid(toggle) -impHandlerVoid(kickParty) -impHandlerVoid(kickGuild) -impHandlerVoid(addText) -impHandlerVoid(clearChat) -impHandlerVoid(chatGeneralTab) -impHandlerVoid(chatDebugTab) -impHandlerVoid(chatBattleTab) -impHandlerVoid(chatTradeTab) -impHandlerVoid(chatLangTab) -impHandlerVoid(chatGmTab) -impHandlerVoid(chatPartyTab) -impHandlerVoid(chatGuildTab) -impHandlerVoid(hat) -impHandlerVoid(chatClipboard) -impHandlerVoid(guildNotice) -impHandlerVoid(translate) -impHandlerVoid(sendGuiKey) -impHandlerVoid(sendMouseKey) -impHandlerVoid(sendChars) - -} // namespace Actions diff --git a/src/dyetool/actions/commands.cpp b/src/dyetool/actions/commands.cpp deleted file mode 100644 index 7f50ab20c..000000000 --- a/src/dyetool/actions/commands.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 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/commands.h" - -#include "actions/actiondef.h" - -#include "debug.h" - -namespace Actions -{ - -impHandlerVoid(chatAnnounce) -impHandlerVoid(chatIgnore) -impHandlerVoid(chatUnignore) -impHandlerVoid(chatErase) -impHandlerVoid(chatFriend) -impHandlerVoid(chatDisregard) -impHandlerVoid(chatNeutral) -impHandlerVoid(chatBlackList) -impHandlerVoid(chatEnemy) -impHandlerVoid(chatNuke) -impHandlerVoid(chatAdd) -impHandlerVoid(present) -impHandlerVoid(printAll) -impHandlerVoid(move) -impHandlerVoid(setTarget) -impHandlerVoid(commandOutfit) -impHandlerVoid(commandEmote) -impHandlerVoid(awayMessage) -impHandlerVoid(pseudoAway) -impHandlerVoid(follow) -impHandlerVoid(navigate) -impHandlerVoid(navigateTo) -impHandlerVoid(moveCamera) -impHandlerVoid(restoreCamera) -impHandlerVoid(imitation) -impHandlerVoid(sendMail) -impHandlerVoid(info) -impHandlerVoid(wait) -impHandlerVoid(addPriorityAttack) -impHandlerVoid(addAttack) -impHandlerVoid(removeAttack) -impHandlerVoid(addIgnoreAttack) -impHandlerVoid(setDrop) -impHandlerVoid(url) -impHandlerVoid(openUrl) -impHandlerVoid(execute) -impHandlerVoid(enableHighlight) -impHandlerVoid(disableHighlight) -impHandlerVoid(dontRemoveName) -impHandlerVoid(removeName) -impHandlerVoid(disableAway) -impHandlerVoid(enableAway) -impHandlerVoid(testParticle) -impHandlerVoid(talkRaw) -impHandlerVoid(gm) -impHandlerVoid(hack) -impHandlerVoid(debugSpawn) -impHandlerVoid(serverIgnoreWhisper) -impHandlerVoid(serverUnIgnoreWhisper) -impHandlerVoid(setHomunculusName) -impHandlerVoid(fireHomunculus) -impHandlerVoid(leaveParty) -impHandlerVoid(leaveGuild) -impHandlerVoid(warp) -impHandlerVoid(homunTalk) -impHandlerVoid(homunEmote) -impHandlerVoid(commandHomunEmote) -impHandlerVoid(createPublicChatRoom) -impHandlerVoid(joinChatRoom) -impHandlerVoid(leaveChatRoom) -impHandlerVoid(confSet) -impHandlerVoid(serverConfSet) -impHandlerVoid(confGet) -impHandlerVoid(serverConfGet) -impHandlerVoid(slide) -impHandlerVoid(selectSkillLevel) -impHandlerVoid(skill) -impHandlerVoid(craft) -impHandlerVoid(npcClipboard) -impHandlerVoid(clipboardCopy) -impHandlerVoid(addPickup) -impHandlerVoid(removePickup) -impHandlerVoid(ignorePickup) -impHandlerVoid(monsterInfo) -impHandlerVoid(itemInfo) -impHandlerVoid(whoDrops) -impHandlerVoid(mobSearch) -impHandlerVoid(mobSpawnSearch) -impHandlerVoid(playerGmCommands) -impHandlerVoid(playerCharGmCommands) -impHandlerVoid(commandShowLevel) -impHandlerVoid(commandShowStats) -impHandlerVoid(commandShowStorage) -impHandlerVoid(commandShowCart) -impHandlerVoid(commandShowInventory) -impHandlerVoid(locatePlayer) -impHandlerVoid(commandShowAccountInfo) -impHandlerVoid(commandSpawn) -impHandlerVoid(commandSpawnSlave) -impHandlerVoid(commandSpawnClone) -impHandlerVoid(commandSpawnSlaveClone) -impHandlerVoid(commandSpawnEvilClone) -impHandlerVoid(commandSavePosition) -impHandlerVoid(commandLoadPosition) -impHandlerVoid(commandRandomWarp) -impHandlerVoid(commandGotoNpc) -impHandlerVoid(commandGotoPc) -impHandlerVoid(commandRecallPc) -impHandlerVoid(commandIpCheck) -impHandlerVoid(commandKiller) -impHandlerVoid(commandKillable) -impHandlerVoid(commandHeal) -impHandlerVoid(commandAlive) -impHandlerVoid(commandDisguise) -impHandlerVoid(commandImmortal) -impHandlerVoid(commandHide) -impHandlerVoid(commandNuke) -impHandlerVoid(commandKill) -impHandlerVoid(commandJail) -impHandlerVoid(commandUnjail) -impHandlerVoid(commandNpcMove) -impHandlerVoid(commandNpcHide) -impHandlerVoid(commandNpcShow) -impHandlerVoid(commandChangePartyLeader) -impHandlerVoid(commandPartyRecall) -impHandlerVoid(commandBreakGuild) -impHandlerVoid(commandGuildRecall) -impHandlerVoid(mailTo) -impHandlerVoid(adoptChild) -impHandlerVoid(showSkillLevels) -impHandlerVoid(showSkillType) -impHandlerVoid(selectSkillType) -impHandlerVoid(showSkillOffsetX) -impHandlerVoid(showSkillOffsetY) -impHandlerVoid(setSkillOffsetX) -impHandlerVoid(setSkillOffsetY) -impHandlerVoid(partyItemShare) -impHandlerVoid(partyExpShare) -impHandlerVoid(partyAutoItemShare) -impHandlerVoid(outfitToChat) -impHandlerVoid(outfitClear) -impHandlerVoid(moveAttackUp) -impHandlerVoid(moveAttackDown) -impHandlerVoid(movePriorityAttackUp) -impHandlerVoid(movePriorityAttackDown) -impHandlerVoid(addSkillShortcut) - -} // namespace Actions diff --git a/src/dyetool/actions/move.cpp b/src/dyetool/actions/move.cpp deleted file mode 100644 index c3f82cd3a..000000000 --- a/src/dyetool/actions/move.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 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/move.h" - -#include "actions/actiondef.h" - -#include "debug.h" - -namespace Actions -{ - -impHandlerVoid(moveUp) -impHandlerVoid(moveDown) -impHandlerVoid(moveLeft) -impHandlerVoid(moveRight) -impHandlerVoid(moveForward) -impHandlerVoid(moveToPoint) -impHandlerVoid(crazyMoves) -impHandlerVoid(moveToTarget) -impHandlerVoid(moveToHome) -impHandlerVoid(directUp) -impHandlerVoid(directDown) -impHandlerVoid(directLeft) -impHandlerVoid(directRight) - -} // namespace Actions diff --git a/src/dyetool/actions/pets.cpp b/src/dyetool/actions/pets.cpp deleted file mode 100644 index 96a7e5393..000000000 --- a/src/dyetool/actions/pets.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 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/pets.h" - -#include "actions/actiondef.h" - -#include "debug.h" - -namespace Actions -{ - -impHandlerVoid(commandEmotePet) -impHandlerVoid(talkPet) -impHandlerVoid(setPetName) -impHandlerVoid(petEmote) -impHandlerVoid(catchPet) -impHandlerVoid(petMoveUp) -impHandlerVoid(petMoveDown) -impHandlerVoid(petMoveLeft) -impHandlerVoid(petMoveRight) -impHandlerVoid(petDirectUp) -impHandlerVoid(petDirectDown) -impHandlerVoid(petDirectLeft) -impHandlerVoid(petDirectRight) -impHandlerVoid(petMove) -impHandlerVoid(petFeed) -impHandlerVoid(petDropLoot) -impHandlerVoid(petReturnToEgg) -impHandlerVoid(petUnequip) - -} // namespace Actions diff --git a/src/dyetool/actions/statusbar.cpp b/src/dyetool/actions/statusbar.cpp deleted file mode 100644 index ed53ef8b0..000000000 --- a/src/dyetool/actions/statusbar.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 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 "actions/actiondef.h" - -#include "debug.h" - -namespace Actions -{ - -impHandlerVoid(switchQuickDrop) -impHandlerVoid(changeCrazyMove) -impHandlerVoid(changePickupType) -impHandlerVoid(changeMoveType) -impHandlerVoid(changeAttackWeaponType) -impHandlerVoid(changeAttackType) -impHandlerVoid(changeTargetingType) -impHandlerVoid(changeFollowMode) -impHandlerVoid(changeImitationMode) -impHandlerVoid(changeMagicAttackType) -impHandlerVoid(changePvpMode) -impHandlerVoid(changeMoveToTarget) -impHandlerVoid(changeGameModifier) -impHandlerVoid(changeAudio) -impHandlerVoid(away) -impHandlerVoid(camera) -impHandlerVoid(changeMapMode) -impHandlerVoid(changeTrade) - -} // namespace Actions diff --git a/src/dyetool/actions/tabs.cpp b/src/dyetool/actions/tabs.cpp deleted file mode 100644 index 3c795c2ab..000000000 --- a/src/dyetool/actions/tabs.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 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/tabs.h" - -#include "actions/actiondef.h" - -#include "debug.h" - -namespace Actions -{ - -impHandlerVoid(prevSocialTab) -impHandlerVoid(nextSocialTab) -impHandlerVoid(nextShortcutsTab) -impHandlerVoid(prevShortcutsTab) -impHandlerVoid(nextCommandsTab) -impHandlerVoid(prevCommandsTab) -impHandlerVoid(nextInvTab) -impHandlerVoid(prevInvTab) - -} // namespace Actions diff --git a/src/dyetool/actions/target.cpp b/src/dyetool/actions/target.cpp deleted file mode 100644 index 80b34a7fb..000000000 --- a/src/dyetool/actions/target.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 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/target.h" - -#include "actions/actiondef.h" - -#include "debug.h" - -namespace Actions -{ - -impHandlerVoid(targetPlayer) -impHandlerVoid(targetMonster) -impHandlerVoid(targetClosestMonster) -impHandlerVoid(targetNPC) -impHandlerVoid(targetMercenary) -impHandlerVoid(targetPet) -impHandlerVoid(targetSkillUnit) -impHandlerVoid(contextMenu) - -} // namespace Actions diff --git a/src/dyetool/actions/windows.cpp b/src/dyetool/actions/windows.cpp deleted file mode 100644 index ce5c72ce2..000000000 --- a/src/dyetool/actions/windows.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 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/windows.h" - -#include "actions/actiondef.h" - -#include "debug.h" - -namespace Actions -{ - -impHandlerVoid(setupWindowShow) -impHandlerVoid(hideWindows) -impHandlerVoid(helpWindowShow) -impHandlerVoid(aboutWindowShow) -impHandlerVoid(statusWindowShow) -impHandlerVoid(inventoryWindowShow) -impHandlerVoid(equipmentWindowShow) -impHandlerVoid(skillDialogShow) -impHandlerVoid(minimapWindowShow) -impHandlerVoid(chatWindowShow) -impHandlerVoid(shortcutWindowShow) -impHandlerVoid(debugWindowShow) -impHandlerVoid(socialWindowShow) -impHandlerVoid(emoteShortcutWindowShow) -impHandlerVoid(outfitWindowShow) -impHandlerVoid(shopWindowShow) -impHandlerVoid(dropShortcutWindowShow) -impHandlerVoid(killStatsWindowShow) -impHandlerVoid(spellShortcutWindowShow) -impHandlerVoid(whoIsOnlineWindowShow) -impHandlerVoid(didYouKnowWindowShow) -impHandlerVoid(questsWindowShow) -impHandlerVoid(bankWindowShow) -impHandlerVoid(cartWindowShow) -impHandlerVoid(updaterWindowShow) -impHandlerVoid(quickWindowShow) -impHandlerVoid(mailWindowShow) -impHandlerVoid(serverInfoWindowShow) -impHandlerVoid(showItems) - -} // namespace Actions diff --git a/src/dyetool/client.cpp b/src/dyetool/client.cpp deleted file mode 100644 index 42b570a6b..000000000 --- a/src/dyetool/client.cpp +++ /dev/null @@ -1,813 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 "client.h" - -#include "configmanager.h" -#include "dirs.h" -#include "eventsmanager.h" -#include "graphicsmanager.h" -#include "main.h" -#include "settings.h" -#include "soundmanager.h" - -#include "fs/virtfs/fs.h" -#include "fs/virtfs/tools.h" - -#include "gui/dialogsmanager.h" -#include "gui/gui.h" -#include "gui/skin.h" -#include "gui/popupmanager.h" -#include "gui/windowmanager.h" - -#include "gui/widgets/button.h" -#include "gui/widgets/createwidget.h" -#include "gui/widgets/desktop.h" -#include "gui/widgets/window.h" -#include "gui/widgets/windowcontainer.h" - -#include "input/inputmanager.h" -#include "input/joystick.h" -#include "input/keyboardconfig.h" - -#include "input/touch/touchmanager.h" - -#include "resources/imagehelper.h" - -#include "resources/dye/dyepalette.h" - -#include "resources/resourcemanager/resourcemanager.h" - -#include "utils/cpu.h" -#include "utils/delete2.h" -#include "utils/env.h" -#include "utils/fuzzer.h" -#include "utils/gettext.h" -#include "utils/gettexthelper.h" -#include "utils/mrand.h" -#ifdef ANDROID -#include "fs/paths.h" -#endif // ANDROID - -#include "utils/sdlcheckutils.h" -#include "utils/timer.h" - -#include "utils/translation/translationmanager.h" - -#include "configuration.h" - -#include "net/ipc.h" - -#ifdef WIN32 -PRAGMA48(GCC diagnostic push) -PRAGMA48(GCC diagnostic ignored "-Wshadow") -#include -PRAGMA48(GCC diagnostic pop) -#include -#include "fs/specialfolder.h" -#undef ERROR -#endif // WIN32 - -#ifdef ANDROID -#ifndef USE_SDL2 -PRAGMA48(GCC diagnostic push) -PRAGMA48(GCC diagnostic ignored "-Wshadow") -#include -PRAGMA48(GCC diagnostic pop) -#include -#endif // USE_SDL2 -#endif // ANDROID - -PRAGMA48(GCC diagnostic push) -PRAGMA48(GCC diagnostic ignored "-Wshadow") -#ifdef USE_SDL2 -#include -#else // USE_SDL2 -#include -#endif // USE_SDL2 -PRAGMA48(GCC diagnostic pop) - -#include "debug.h" - -std::string errorMessage; - -Client *client = nullptr; - -extern FPSmanager fpsManager; - -volatile bool runCounters; -bool isSafeMode = false; -int serverVersion = 0; -int packetVersion = 0; -unsigned int tmwServerVersion = 0; -time_t start_time; -unsigned int mLastHost = 0; -unsigned long mSearchHash = 0; -int textures_count = 0; - -Client::Client() : - ActionListener(), - mCurrentDialog(nullptr), - mSetupButton(nullptr), - mVideoButton(nullptr), - mHelpButton(nullptr), - mAboutButton(nullptr), - mThemesButton(nullptr), - mPerfomanceButton(nullptr), -#ifdef ANDROID - mCloseButton(nullptr), -#endif // ANDROID - mState(State::GAME), - mOldState(State::START), - mSkin(nullptr), - mButtonPadding(1), - mButtonSpacing(3) -{ - WindowManager::init(); -} - -void Client::testsInit() -{ -} - -void Client::testsClear() -{ -} - -// +++ need remove duplicate from here -void Client::gameInit() -{ - logger = new Logger; - - initRand(); - - // Load branding information - if (!settings.options.brandingPath.empty()) - branding.init(settings.options.brandingPath); - setBrandingDefaults(branding); - - Dirs::initRootDir(); - Dirs::initHomeDir(); - - // Configure logger - if (!settings.options.logFileName.empty()) - { - settings.logFileName = settings.options.logFileName; - } - else - { - settings.logFileName = pathJoin(settings.localDataDir, - "manaplus.log"); - } - logger->setLogFile(settings.logFileName); - -#ifdef USE_FUZZER - Fuzzer::init(); -#endif // USE_FUZZER - - if (settings.options.test.empty()) - ConfigManager::backupConfig("config.xml"); - ConfigManager::initConfiguration(); - setPathsDefaults(paths); - initPaths(); - logger->log("init 4"); - logger->setDebugLog(config.getBoolValue("debugLog")); - logger->setReportUnimplemented(config.getBoolValue("unimplimentedLog")); - - config.incValue("runcount"); - -#ifndef ANDROID - if (settings.options.test.empty()) - ConfigManager::storeSafeParameters(); -#endif // ANDROID - - if (!VirtFs::setWriteDir(settings.localDataDir)) - { - logger->error(strprintf("%s couldn't be set as home directory! " - "Exiting.", settings.localDataDir.c_str())); - } - - GettextHelper::initLang(); - -/* - chatLogger = new ChatLogger; - if (settings.options.chatLogDir.empty()) - { - chatLogger->setBaseLogDir(settings.localDataDir - + std::string("/logs/")); - } - else - { - chatLogger->setBaseLogDir(settings.options.chatLogDir); - } -*/ - logger->setLogToStandardOut(config.getBoolValue("logToStandardOut")); - - // Log the client version - logger->log1(FULL_VERSION); - logger->log("Start configPath: " + config.getConfigPath()); - - Dirs::initScreenshotDir(); - - // Initialize SDL - logger->log1("Initializing SDL..."); - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) - { - logger->safeError(strprintf("Could not initialize SDL: %s", - SDL_GetError())); - } - atexit(SDL_Quit); - -#ifndef USE_SDL2 - SDL_EnableUNICODE(1); -#endif // USE_SDL2 - - WindowManager::applyKeyRepeat(); - - // disable unused SDL events -#ifndef USE_SDL2 - SDL_EventState(SDL_VIDEOEXPOSE, SDL_IGNORE); -#endif // USE_SDL2 - - SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE); - SDL_EventState(SDL_USEREVENT, SDL_IGNORE); - -#ifdef WIN32 - Dirs::extractDataDir(); - Dirs::mountDataDir(); -#endif // WIN32 - - WindowManager::setIcon(); - ConfigManager::checkConfigVersion(); - logVars(); - Cpu::detect(); - DyePalette::initFunctions(); -#if defined(USE_OPENGL) -#if !defined(ANDROID) && !defined(__APPLE__) && !defined(__native_client__) - if (!settings.options.safeMode && settings.options.test.empty() - && !config.getBoolValue("videodetected")) - { - graphicsManager.detectVideoSettings(); - } -#endif // !defined(ANDROID) && !defined(__APPLE__) && - // !defined(__native_client__) -#endif // defined(USE_OPENGL) - - updateEnv(); - initGraphics(); - -#ifndef WIN32 - Dirs::extractDataDir(); - Dirs::mountDataDir(); -#endif // WIN32 - - Dirs::updateDataPath(); - - // Add the main data directories to our PhysicsFS search path - if (!settings.options.dataPath.empty()) - { - VirtFs::mountDir(settings.options.dataPath, - Append_false); - } - - // Add the local data directory to PhysicsFS search path - VirtFs::mountDir(settings.localDataDir, - Append_false); - TranslationManager::loadCurrentLang(); - TranslationManager::loadDictionaryLang(); -#ifdef ENABLE_CUSTOMNLS - TranslationManager::loadGettextLang(); -#endif // ENABLE_CUSTOMNLS - - WindowManager::initTitle(); - - mainGraphics->postInit(); - - theme = new Theme; - Theme::selectSkin(); - touchManager.init(); - - // Initialize the item and emote shortcuts. -// for (size_t f = 0; f < SHORTCUT_TABS; f ++) -// itemShortcut[f] = new ItemShortcut(f); -// emoteShortcut = new EmoteShortcut; -// dropShortcut = new DropShortcut; - - gui = new Gui; - gui->postInit(mainGraphics); - dialogsManager = new DialogsManager; - popupManager = new PopupManager; - - initSoundManager(); - eventsManager.init(); - - // Initialize keyboard - keyboard.init(); - inputManager.init(); - - // Initialise player relations - Joystick::init(); - WindowManager::createWindows(); - - keyboard.update(); - if (joystick != nullptr) - joystick->update(); - -// if (mState != State::ERROR) -// mState = State::CHOOSE_SERVER; - - startTimers(); - - const int fpsLimit = config.getIntValue("fpslimit"); - settings.limitFps = fpsLimit > 0; - - SDL_initFramerate(&fpsManager); - WindowManager::setFramerate(fpsLimit); - - start_time = time(nullptr); - -// PlayerInfo::init(); - -#ifdef ANDROID -#ifndef USE_SDL2 - WindowManager::updateScreenKeyboard(SDL_GetScreenKeyboardHeight(nullptr)); -#endif // USE_SDL2 -#endif // ANDROID - - mSkin = theme->load("windowmenu.xml", ""); - if (mSkin != nullptr) - { - mButtonPadding = mSkin->getPadding(); - mButtonSpacing = mSkin->getOption("spacing", 3); - } -} - -Client::~Client() -{ - if (!settings.options.testMode) - gameClear(); - else - testsClear(); -} - -void Client::initSoundManager() -{ - // Initialize sound engine - try - { - if (config.getBoolValue("sound")) - soundManager.init(); - - soundManager.setSfxVolume(config.getIntValue("sfxVolume")); - soundManager.setMusicVolume(config.getIntValue("musicVolume")); - } - catch (const char *const err) - { - mState = State::ERROR; - errorMessage = err; - logger->log("Warning: %s", err); - } - soundManager.playMusic(branding.getValue( - "loginMusic", - "Magick - Real.ogg"), - SkipError_true); -} - -void Client::initGraphics() -{ - WindowManager::applyVSync(); - runCounters = config.getBoolValue("packetcounters"); - - graphicsManager.initGraphics(); - - imageHelper->postInit(); - setConfigDefaults2(config); - WindowManager::applyGrabMode(); - WindowManager::applyGamma(); - - mainGraphics->beginDraw(); -} - -void Client::gameClear() -{ - if (logger != nullptr) - logger->log1("Quitting1"); - - eventsManager.shutdown(); - WindowManager::deleteWindows(); - if (windowContainer != nullptr) - windowContainer->slowLogic(); - - stopTimers(); - - delete2(ipc); - - if (logger != nullptr) - logger->log1("Quitting2"); - - delete2(mCurrentDialog); - delete2(popupManager); - delete2(dialogsManager); - delete2(gui); - - if (logger != nullptr) - logger->log1("Quitting3"); - - GraphicsManager::deleteRenderers(); - - if (logger != nullptr) - logger->log1("Quitting4"); - - XML::cleanupXML(); - - if (logger != nullptr) - logger->log1("Quitting5"); - - // Shutdown sound - soundManager.close(); - - if (logger != nullptr) - logger->log1("Quitting6"); - - touchManager.clear(); - ResourceManager::deleteInstance(); - - if (logger != nullptr) - logger->log1("Quitting8"); - - WindowManager::deleteIcon(); - - if (logger != nullptr) - logger->log1("Quitting9"); - - delete2(joystick); - - keyboard.deinit(); - - if (logger != nullptr) - logger->log1("Quitting10"); - - soundManager.shutdown(); - touchManager.shutdown(); - -#ifdef DEBUG_CONFIG - config.enableKeyLogging(); -#endif // DEBUG_CONFIG - - config.removeOldKeys(); - config.write(); - serverConfig.write(); - - config.clear(); - serverConfig.clear(); - - if (logger != nullptr) - logger->log1("Quitting11"); - -#ifdef USE_PROFILER - Perfomance::clear(); -#endif // USE_PROFILER - -#ifdef DEBUG_OPENGL_LEAKS - if (logger) - logger->log("textures left: %d", textures_count); -#endif // DEBUG_OPENGL_LEAKS - - Graphics::cleanUp(); - - if (logger != nullptr) - logger->log1("Quitting12"); - -// delete2(chatLogger); - TranslationManager::close(); - VirtFs::deinit(); -} - -#define ADDBUTTON(var, object) var = object; \ - x -= var->getWidth() + mButtonSpacing; \ - var->setPosition(x, mButtonPadding); \ - top->add(var); - -void Client::stateGame() -{ - if (gui == nullptr) - return; - - BasicContainer2 *const top = static_cast( - gui->getTop()); - - if (top == nullptr) - return; - - CREATEWIDGETV(desktop, Desktop, nullptr); - top->add(desktop); - int x = top->getWidth() - mButtonPadding; - ADDBUTTON(mSetupButton, new Button(desktop, - // TRANSLATORS: setup tab quick button - _("Setup"), "Setup", this)) - ADDBUTTON(mPerfomanceButton, new Button(desktop, - // TRANSLATORS: perfoamance tab quick button - _("Performance"), "Perfomance", this)) - ADDBUTTON(mVideoButton, new Button(desktop, - // TRANSLATORS: video tab quick button - _("Video"), "Video", this)) - ADDBUTTON(mThemesButton, new Button(desktop, - // TRANSLATORS: theme tab quick button - _("Theme"), "Themes", this)) - ADDBUTTON(mAboutButton, new Button(desktop, - // TRANSLATORS: theme tab quick button - _("About"), "about", this)) - ADDBUTTON(mHelpButton, new Button(desktop, - // TRANSLATORS: theme tab quick button - _("Help"), "help", this)) -#ifdef ANDROID - ADDBUTTON(mCloseButton, new Button(desktop, - // TRANSLATORS: close quick button - _("Close"), "close", this)) -#endif // ANDROID - - desktop->setSize(mainGraphics->getWidth(), - mainGraphics->getHeight()); -} - -int Client::gameExec() -{ - int lastTickTime = tick_time; - - while (mState != State::EXIT) - { - PROFILER_START(); - if (eventsManager.handleEvents()) - continue; - - BLOCK_START("Client::gameExec 4") - if (gui != nullptr) - gui->logic(); - cur_time = time(nullptr); - int k = 0; - while (lastTickTime != tick_time && k < 40) - { -// if (mGame) -// mGame->logic(); -// else - if (gui != nullptr) - gui->handleInput(); - - ++lastTickTime; - k ++; - } - soundManager.logic(); - - logic_count += k; - if (gui != nullptr) - gui->slowLogic(); -// if (mGame) -// mGame->slowLogic(); - slowLogic(); - BLOCK_END("Client::gameExec 4") - - // This is done because at some point tick_time will wrap. - lastTickTime = tick_time; - - // Update the screen when application is visible, delay otherwise. - if (!WindowManager::getIsMinimized()) - { - frame_count++; - if (gui != nullptr) - gui->draw(); - mainGraphics->updateScreen(); - } - else - { - SDL_Delay(100); - } - - BLOCK_START("~Client::SDL_framerateDelay") - if (settings.limitFps) - SDL_framerateDelay(&fpsManager); - BLOCK_END("~Client::SDL_framerateDelay") - - BLOCK_START("Client::gameExec 6") -/* - if (mState == State::CONNECT_GAME) - { - stateConnectGame1(); - } -*/ - BLOCK_END("Client::gameExec 6") - - if (mState != mOldState) - { - BLOCK_START("Client::gameExec 7") - - mOldState = mState; - - // Get rid of the dialog of the previous state - delete2(mCurrentDialog); - - // State has changed, while the quitDialog was active, it might - // not be correct anymore -/* - if (mQuitDialog) - { - mQuitDialog->scheduleDelete(); - mQuitDialog = nullptr; - } -*/ - BLOCK_END("Client::gameExec 7") - - BLOCK_START("Client::gameExec 8") - PRAGMA45(GCC diagnostic push) - PRAGMA45(GCC diagnostic ignored "-Wswitch-enum") - switch (mState) - { - case State::GAME: - stateGame(); - break; - - case State::LOAD_DATA: - { - BLOCK_START("Client::gameExec State::LOAD_DATA") - logger->log1("State: LOAD DATA"); - - // If another data path has been set, - // we don't load any other files... - if (settings.options.dataPath.empty()) - { - // Add customdata directory - VirtFs::searchAndAddArchives( - "customdata/", - "zip", - Append_false); - } - - if (!settings.options.skipUpdate) - { - VirtFs::searchAndAddArchives(pathJoin( - settings.updatesDir, "local/"), - "zip", - Append_false); - - VirtFs::mountDir(pathJoin( - settings.localDataDir, - settings.updatesDir, - "local/"), - Append_false); - } - - logger->log("Init paths"); - paths.init("paths.xml", UseVirtFs_true); - setPathsDefaults(paths); - initPaths(); - TranslationManager::loadCurrentLang(); - TranslationManager::loadDictionaryLang(); - - if (desktop != nullptr) - desktop->reloadWallpaper(); - - mState = State::GET_CHARACTERS; - BLOCK_END("Client::gameExec State::LOAD_DATA") - break; - } - case State::START: - default: - mState = State::FORCE_QUIT; - break; - } - PRAGMA45(GCC diagnostic pop) - BLOCK_END("Client::gameExec 8") - } - PROFILER_END(); - } - - return 0; -} - -void Client::action(const ActionEvent &event) -{ - std::string tab; - const std::string &eventId = event.getId(); - - if (eventId == "close") - { - setState(State::FORCE_QUIT); - return; - } - if (eventId == "Setup") - { - tab.clear(); - } - else if (eventId == "help") - { - inputManager.executeAction(InputAction::WINDOW_HELP); - return; - } - else if (eventId == "about") - { - inputManager.executeAction(InputAction::WINDOW_ABOUT); - return; - } - else if (eventId == "Video") - { - tab = "Video"; - } - else if (eventId == "Themes") - { - tab = "Theme"; - } - else if (eventId == "Perfomance") - { - tab = "Perfomance"; - } - else - { - return; - } -} - -void Client::moveButtons(const int width) -{ - if (mSetupButton != nullptr) - { - int x = width - mSetupButton->getWidth() - mButtonPadding; - mSetupButton->setPosition(x, mButtonPadding); -#ifndef WIN32 - x -= mPerfomanceButton->getWidth() + mButtonSpacing; - mPerfomanceButton->setPosition(x, mButtonPadding); - - x -= mVideoButton->getWidth() + mButtonSpacing; - mVideoButton->setPosition(x, mButtonPadding); - - x -= mThemesButton->getWidth() + mButtonSpacing; - mThemesButton->setPosition(x, mButtonPadding); - - x -= mAboutButton->getWidth() + mButtonSpacing; - mAboutButton->setPosition(x, mButtonPadding); - - x -= mHelpButton->getWidth() + mButtonSpacing; - mHelpButton->setPosition(x, mButtonPadding); -#ifdef ANDROID - x -= mCloseButton->getWidth() + mButtonSpacing; - mCloseButton->setPosition(x, mButtonPadding); -#endif // ANDROID -#endif // WIN32 - } -} - -void Client::windowRemoved(const Window *const window) -{ - if (mCurrentDialog == window) - mCurrentDialog = nullptr; -} - -void Client::logVars() -{ -#ifdef ANDROID - logger->log("APPDIR: %s", getenv("APPDIR")); - logger->log("DATADIR2: %s", getSdStoragePath().c_str()); -#endif // ANDROID -} - -void Client::slowLogic() -{ -} - -int Client::testsExec() -{ - return 0; -} - -bool Client::isTmw() -{ - const std::string &name = settings.serverName; - if (name == "server.themanaworld.org" - || name == "themanaworld.org" - || name == "167.114.185.71") - { - return true; - } - return false; -} - -void Client::initPaths() -{ -} diff --git a/src/dyetool/client.h b/src/dyetool/client.h deleted file mode 100644 index 57f62c2b9..000000000 --- a/src/dyetool/client.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 DYETOOL_CLIENT_H -#define DYETOOL_CLIENT_H - -#include "enums/state.h" - -#include "listeners/actionlistener.h" - -#include "localconsts.h" - -class Button; -class Skin; -class Window; - -extern bool isSafeMode; -extern int serverVersion; -extern unsigned int tmwServerVersion; -extern time_t start_time; -extern int textures_count; - -extern std::string errorMessage; - -/** - * The core part of the client. This class initializes all subsystems, runs - * the event loop, and shuts everything down again. - */ -class Client final : public ActionListener -{ - public: - Client(); - - A_DELETE_COPY(Client) - - ~Client(); - - void gameInit(); - - void testsInit(); - - int gameExec(); - - static int testsExec(); - - void setState(const StateT state) - { mState = state; } - - StateT getState() const noexcept2 A_WARN_UNUSED - { return mState; } - - void action(const ActionEvent &event) override final; - - void moveButtons(const int width); - - void windowRemoved(const Window *const window); - - void slowLogic(); - - static bool isTmw(); - - private: - void stateGame(); - - void initSoundManager(); - - static void initGraphics(); - - static void initPaths(); - - void gameClear(); - - void testsClear(); - - static void logVars(); - - Window *mCurrentDialog; - Button *mSetupButton; - Button *mVideoButton; - Button *mHelpButton; - Button *mAboutButton; - Button *mThemesButton; - Button *mPerfomanceButton; -#ifdef ANDROID - Button *mCloseButton; -#endif // ANDROID - - StateT mState; - StateT mOldState; - - Skin *mSkin; - int mButtonPadding; - int mButtonSpacing; -}; - -extern Client *client; -extern unsigned int mLastHost; -extern unsigned long mSearchHash; - -#endif // DYETOOL_CLIENT_H diff --git a/src/dyetool/dyemain.cpp b/src/dyetool/dyemain.cpp deleted file mode 100644 index 2217508cc..000000000 --- a/src/dyetool/dyemain.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2013-2017 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 "logger.h" - -#include "graphicsmanager.h" -#include "maingui.h" -#include "sdlshared.h" - -#include "fs/virtfs/fs.h" - -#include "resources/imagewriter.h" - -#include "resources/image/image.h" - -#ifdef USE_SDL2 -#include "resources/surfaceimagehelper.h" -#endif // USE_SDL2 - -#include "resources/loaders/imageloader.h" - -#include "utils/gettext.h" - -#include - -#ifndef USE_SDL2 -#include "resources/sdlimagehelper.h" -#endif // USE_SDL2 - -PRAGMA48(GCC diagnostic push) -PRAGMA48(GCC diagnostic ignored "-Wshadow") -#include -PRAGMA48(GCC diagnostic pop) - -#include "debug.h" - -static void printHelp() -{ - // TRANSLATORS: command line help - std::cout << _("dyecmd srcfile dyestring dstfile") << std::endl; - // TRANSLATORS: command line help - std::cout << _("or") << std::endl; - // TRANSLATORS: command line help - std::cout << _("dyecmd srcdyestring dstfile") << std::endl; -} - -int main(int argc, char **argv) -{ - if (argc == 2 && (strcmp(argv[1], "--help") != 0)) - { - return mainGui(argc, argv); - } - if (argc < 3 || argc > 4) - { - printHelp(); - return 1; - } - - logger = new Logger; - logger->setLogToStandardOut(false); - - VirtFs::init(argv[0]); - SDL_Init(SDL_INIT_VIDEO); - - graphicsManager.createWindow(10, 10, 0, SDL_ANYFORMAT); - -#ifdef USE_SDL2 - imageHelper = new SurfaceImageHelper; -#else // USE_SDL2 - - imageHelper = new SDLImageHelper; -#endif // USE_SDL2 - - VirtFs::setWriteDir("."); - VirtFs::mountDir(".", Append_false); - VirtFs::mountDir("/", Append_false); - std::string src = argv[1]; - std::string dst; - if (argc == 4) - { - src.append("|").append(argv[2]); - dst = argv[3]; - } - else - { - dst = argv[2]; - } - - Image *image = Loader::getImage(src); - if (image == nullptr) - { - printf("Error loading image\n"); - VirtFs::deinit(); - return 1; - } - SDL_Surface *const surface = ImageHelper::convertTo32Bit( - image->getSDLSurface()); - ImageWriter::writePNG(surface, dst); - SDL_FreeSurface(surface); - VirtFs::deinit(); - return 0; -} diff --git a/src/dyetool/gui/viewport.cpp b/src/dyetool/gui/viewport.cpp deleted file mode 100644 index 21719286f..000000000 --- a/src/dyetool/gui/viewport.cpp +++ /dev/null @@ -1,272 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 "dyetool/gui/viewport.h" - -#include "configuration.h" -#include "sdlshared.h" - -#include "gui/gui.h" -#include "gui/popupmanager.h" - -#include "render/graphics.h" - -#include "debug.h" - -Viewport *viewport = nullptr; - -extern volatile int tick_time; - -Viewport::Viewport() : - WindowContainer(nullptr), - MouseListener(), - ConfigListener(), - mMouseX(0), - mMouseY(0), - mMap(nullptr), - mHoverBeing(nullptr), - mHoverItem(nullptr), - mHoverSign(nullptr), - mScrollRadius(config.getIntValue("ScrollRadius")), - mScrollLaziness(config.getIntValue("ScrollLaziness")), - mScrollCenterOffsetX(config.getIntValue("ScrollCenterOffsetX")), - mScrollCenterOffsetY(config.getIntValue("ScrollCenterOffsetY")), - mMousePressX(0), - mMousePressY(0), - mPixelViewX(0), - mPixelViewY(0), - mLocalWalkTime(-1), - mCameraRelativeX(0), - mCameraRelativeY(0), - mShowBeingPopup(config.getBoolValue("showBeingPopup")), - mSelfMouseHeal(config.getBoolValue("selfMouseHeal")), - mEnableLazyScrolling(config.getBoolValue("enableLazyScrolling")), - mMouseDirectionMove(config.getBoolValue("mouseDirectionMove")), - mLongMouseClick(config.getBoolValue("longmouseclick")), - mMouseClicked(false), - mPlayerFollowMouse(false) -{ - setOpaque(Opaque_false); - addMouseListener(this); - - config.addListener("ScrollLaziness", this); - config.addListener("ScrollRadius", this); - config.addListener("showBeingPopup", this); - config.addListener("selfMouseHeal", this); - config.addListener("enableLazyScrolling", this); - config.addListener("mouseDirectionMove", this); - config.addListener("longmouseclick", this); - - setFocusable(true); -} - -Viewport::~Viewport() -{ - config.removeListeners(this); - CHECKLISTENERS -} - -void Viewport::setMap(Map *const map A_UNUSED) -{ -} - -void Viewport::draw(Graphics *const graphics) -{ - BLOCK_START("Viewport::draw 1") - static int lastTick = tick_time; - - graphics->setColor(Color(64, 64, 64)); - graphics->fillRectangle( - Rect(0, 0, getWidth(), getHeight())); - - // Avoid freaking out when tick_time overflows - if (tick_time < lastTick) - lastTick = tick_time; - - // Draw contained widgets - WindowContainer::draw(graphics); - BLOCK_END("Viewport::draw 1") -} - -void Viewport::safeDraw(Graphics *const graphics) -{ - Viewport::draw(graphics); -} - -void Viewport::logic() -{ - BLOCK_START("Viewport::logic") - // Make the player follow the mouse position - // if the mouse is dragged elsewhere than in a window. - Gui::getMouseState(mMouseX, mMouseY); - BLOCK_END("Viewport::logic") -} - -void Viewport::followMouse() -{ -} - -void Viewport::drawDebugPath(Graphics *const graphics A_UNUSED) -{ -} - -bool Viewport::openContextMenu(const MouseEvent &event A_UNUSED) -{ - return false; -} - -void Viewport::mousePressed(MouseEvent &event) -{ - if (event.getSource() != this || event.isConsumed()) - return; - - mMouseClicked = true; - - mMousePressX = event.getX(); - mMousePressY = event.getY(); - const MouseButtonT eventButton = event.getButton(); - - // Right click might open a popup - if (eventButton == MouseButton::RIGHT) - { - if (openContextMenu(event)) - return; - } - - // If a popup is active, just remove it - if (PopupManager::isPopupMenuVisible()) - { - mPlayerFollowMouse = false; - PopupManager::hidePopupMenu(); - return; - } - - // Left click can cause different actions - if (!mLongMouseClick && eventButton == MouseButton::LEFT) - { - if (leftMouseAction()) - { - mPlayerFollowMouse = false; - return; - } - } -} - -void Viewport::walkByMouse(const MouseEvent &event A_UNUSED) -{ -} - -void Viewport::mouseDragged(MouseEvent &event) -{ - if (event.getSource() != this || event.isConsumed()) - { - mPlayerFollowMouse = false; - return; - } - if (mMouseClicked) - { - if (abs(event.getX() - mMousePressX) > 32 - || abs(event.getY() - mMousePressY) > 32) - { - mPlayerFollowMouse = true; - } - } - - walkByMouse(event); -} - -void Viewport::mouseReleased(MouseEvent &event) -{ - mPlayerFollowMouse = false; - mLocalWalkTime = -1; - if (mLongMouseClick && mMouseClicked) - { - mMouseClicked = false; - if (event.getSource() != this || event.isConsumed()) - return; - const MouseButtonT eventButton = event.getButton(); - if (eventButton == MouseButton::LEFT) - { - // long button press - if ((gui != nullptr) && gui->isLongPress()) - { - if (openContextMenu(event)) - { - gui->resetClickCount(); - return; - } - } - else - { - if (leftMouseAction()) - return; - } - walkByMouse(event); - } - } -} - -void Viewport::optionChanged(const std::string &name) -{ - if (name == "ScrollLaziness") - mScrollLaziness = config.getIntValue("ScrollLaziness"); - else if (name == "ScrollRadius") - mScrollRadius = config.getIntValue("ScrollRadius"); - else if (name == "showBeingPopup") - mShowBeingPopup = config.getBoolValue("showBeingPopup"); - else if (name == "selfMouseHeal") - mSelfMouseHeal = config.getBoolValue("selfMouseHeal"); - else if (name == "enableLazyScrolling") - mEnableLazyScrolling = config.getBoolValue("enableLazyScrolling"); - else if (name == "mouseDirectionMove") - mMouseDirectionMove = config.getBoolValue("mouseDirectionMove"); - else if (name == "longmouseclick") - mLongMouseClick = config.getBoolValue("longmouseclick"); -} - -void Viewport::mouseMoved(MouseEvent &event A_UNUSED) -{ -} - -void Viewport::toggleMapDrawType() -{ -} - -void Viewport::toggleCameraMode() -{ -} - -void Viewport::cleanHoverItems() -{ - mHoverBeing = nullptr; - mHoverItem = nullptr; - mHoverSign = nullptr; -} - -bool Viewport::leftMouseAction() -{ - return false; -} - -void Viewport::videoResized() -{ -} diff --git a/src/dyetool/gui/viewport.h b/src/dyetool/gui/viewport.h deleted file mode 100644 index 7b1aa32c4..000000000 --- a/src/dyetool/gui/viewport.h +++ /dev/null @@ -1,213 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 DYETOOL_GUI_VIEWPORT_H -#define DYETOOL_GUI_VIEWPORT_H - -#include "position.h" - -#include "gui/widgets/windowcontainer.h" - -#include "listeners/mouselistener.h" - -class ActorSprite; -class Being; -class FloorItem; -class Graphics; -class Map; -class MapItem; - -/** - * The viewport on the map. Displays the current map and handles mouse input - * and the popup menu. - */ -class Viewport final : public WindowContainer, - public MouseListener, - public ConfigListener -{ - public: - /** - * Constructor. - */ - Viewport(); - - A_DELETE_COPY(Viewport) - - /** - * Destructor. - */ - ~Viewport(); - - /** - * Sets the map displayed by the viewport. - */ - void setMap(Map *const map); - - /** - * Draws the viewport. - */ - void draw(Graphics *const graphics) override final A_NONNULL(2); - - void safeDraw(Graphics *const graphics) override final A_NONNULL(2); - - /** - * Implements player to keep following mouse. - */ - void logic() override final; - - /** - * Toggles whether the path debug graphics are shown. normal, - * debug with all images and grid, debug with out big images - * and with out grid. - */ - void toggleMapDrawType(); - - void toggleCameraMode(); - - /** - * Handles mouse press on map. - */ - void mousePressed(MouseEvent &event) override final; - - /** - * Handles mouse move on map - */ - void mouseDragged(MouseEvent &event) override final; - - /** - * Handles mouse button release on map. - */ - void mouseReleased(MouseEvent &event) override final; - - /** - * Handles mouse move on map. - */ - void mouseMoved(MouseEvent &event) override final; - - /** - * A relevant config option changed. - */ - void optionChanged(const std::string &name) override final; - - /** - * Returns camera x offset in pixels. - */ - int getCameraX() const noexcept2 A_WARN_UNUSED - { return mPixelViewX; } - - /** - * Returns camera y offset in pixels. - */ - int getCameraY() const noexcept2 A_WARN_UNUSED - { return mPixelViewY; } - - /** - * Changes viewpoint by relative pixel coordinates. - */ - void scrollBy(const int x, const int y) - { mPixelViewX += x; mPixelViewY += y; } - - /** - * Clear all hover item, being etc - */ - void cleanHoverItems(); - - Map *getMap() const noexcept2 A_WARN_UNUSED - { return mMap; } - - void moveCamera(const int dx, const int dy); - - int getCameraRelativeX() const noexcept2 A_WARN_UNUSED - { return mCameraRelativeX; } - - int getCameraRelativeY() const noexcept2 A_WARN_UNUSED - { return mCameraRelativeY; } - - void setCameraRelativeX(const int n) noexcept2 - { mCameraRelativeX = n; } - - void setCameraRelativeY(const int n) noexcept2 - { mCameraRelativeY = n; } - - void videoResized(); - - int mMouseX; /**< Current mouse position in pixels. */ - int mMouseY; /**< Current mouse position in pixels. */ - - private: - /** - * Finds a path from the player to the mouse, and draws it. This is for - * debug purposes. - */ - void drawDebugPath(Graphics *const graphics) A_NONNULL(2); - - /** - * Draws the given path. - */ - void drawPath(Graphics *const graphics, - const Path &path, - const Color &color = Color(255, 0, 0)) - const A_NONNULL(2); - - bool leftMouseAction(); - - bool openContextMenu(const MouseEvent &event); - - void walkByMouse(const MouseEvent &event); - - /** - * Make the player go to the mouse position. - */ - void followMouse(); - - Map *mMap; /**< The current map. */ - - Being *mHoverBeing; /**< Being mouse is currently over. */ - FloorItem *mHoverItem; /**< FloorItem mouse is currently over. */ - MapItem *mHoverSign; /**< Map sign mouse is currently over. */ - - int mScrollRadius; - int mScrollLaziness; - int mScrollCenterOffsetX; - int mScrollCenterOffsetY; - int mMousePressX; - int mMousePressY; - int mPixelViewX; /**< Current viewpoint in pixels. */ - int mPixelViewY; /**< Current viewpoint in pixels. */ - - int mLocalWalkTime; /**< Timestamp before the next walk can be sent. */ - - int mCameraRelativeX; - int mCameraRelativeY; - - bool mShowBeingPopup; - bool mSelfMouseHeal; - bool mEnableLazyScrolling; - bool mMouseDirectionMove; - bool mLongMouseClick; - bool mMouseClicked; - bool mPlayerFollowMouse; -}; - -extern Viewport *viewport; /**< The viewport. */ - -#endif // DYETOOL_GUI_VIEWPORT_H diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 3dad7c920..f4e3d26be 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -24,7 +24,7 @@ #define GUI_VIEWPORT_H #ifdef DYECMD -#include "dyetool/gui/viewport.h" +#include "progs/dyecmd/gui/viewport.h" #else diff --git a/src/progs/dyecmd/actions/actions.cpp b/src/progs/dyecmd/actions/actions.cpp new file mode 100644 index 000000000..58353b699 --- /dev/null +++ b/src/progs/dyecmd/actions/actions.cpp @@ -0,0 +1,120 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2017 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/actions.h" + +#include "actions/actiondef.h" + +#include "debug.h" + +namespace Actions +{ + +impHandlerVoid(emote) +impHandlerVoid(outfit) +impHandlerVoid(mouseClick) +impHandlerVoid(ok) +impHandlerVoid(shortcut) +impHandlerVoid(quit) +impHandlerVoid(dropItem0) +impHandlerVoid(dropItem) +impHandlerVoid(dropItemId) +impHandlerVoid(dropItemInv) +impHandlerVoid(dropItemIdAll) +impHandlerVoid(dropItemInvAll) +impHandlerVoid(heal) +impHandlerVoid(healmd) +impHandlerVoid(itenplz) +impHandlerVoid(setHome) +impHandlerVoid(magicAttack) +impHandlerVoid(copyEquippedToOutfit) +impHandlerVoid(pickup) +impHandlerVoid(sit) +impHandlerVoid(screenshot) +impHandlerVoid(ignoreInput) +impHandlerVoid(buy) +impHandlerVoid(sell) +impHandlerVoid(talk) +impHandlerVoid(stopAttack) +impHandlerVoid(untarget) +impHandlerVoid(attack) +impHandlerVoid(targetAttack) +impHandlerVoid(attackHuman) +impHandlerVoid(safeVideoMode) +impHandlerVoid(stopSit) +impHandlerVoid(showKeyboard) +impHandlerVoid(showWindows) +impHandlerVoid(openTrade) +impHandlerVoid(ipcToggle) +impHandlerVoid(where) +impHandlerVoid(who) +impHandlerVoid(cleanGraphics) +impHandlerVoid(cleanFonts) +impHandlerVoid(trade) +impHandlerVoid(priceLoad) +impHandlerVoid(priceSave) +impHandlerVoid(cacheInfo) +impHandlerVoid(disconnect) +impHandlerVoid(undress) +impHandlerVoid(dirs) +impHandlerVoid(uptime) +impHandlerVoid(dump) +impHandlerVoid(serverIgnoreAll) +impHandlerVoid(serverUnIgnoreAll) +impHandler0(error) +{ + exit(0); +} +impHandlerVoid(dumpGraphics) +impHandlerVoid(dumpEnvironment) +impHandlerVoid(dumpTests) +impHandlerVoid(dumpOGL) +impHandlerVoid(dumpGL) +impHandlerVoid(dumpMods) +#if defined USE_OPENGL && defined DEBUG_SDLFONT +impHandlerVoid(testSdlFont) +#endif // defined USE_OPENGL && defined DEBUG_SDLFONT +impHandlerVoid(createItems) +impHandlerVoid(createItem) +impHandlerVoid(uploadConfig) +impHandlerVoid(uploadServerConfig) +impHandlerVoid(uploadLog) +impHandlerVoid(mercenaryFire) +impHandlerVoid(mercenaryToMaster) +impHandlerVoid(homunculusToMaster) +impHandlerVoid(homunculusFeed) +impHandlerVoid(useItem) +impHandlerVoid(useItemInv) +impHandlerVoid(invToStorage) +impHandlerVoid(tradeAdd) +impHandlerVoid(storageToInv) +impHandlerVoid(protectItem) +impHandlerVoid(unprotectItem) +impHandlerVoid(kick) +impHandlerVoid(clearDrop) +impHandlerVoid(testInfo) +impHandlerVoid(craftKey) +impHandlerVoid(resetGameModifiers) +impHandlerVoid(barToChat) +impHandlerVoid(seen) +impHandlerVoid(dumpMemoryUsage) +impHandlerVoid(setEmoteType) + +} // namespace Actions diff --git a/src/progs/dyecmd/actions/chat.cpp b/src/progs/dyecmd/actions/chat.cpp new file mode 100644 index 000000000..ece0e42b9 --- /dev/null +++ b/src/progs/dyecmd/actions/chat.cpp @@ -0,0 +1,69 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2017 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/chat.h" + +#include "actions/actiondef.h" + +#include "debug.h" + +namespace Actions +{ + +impHandlerVoid(toggleChat) +impHandlerVoid(prevChatTab) +impHandlerVoid(nextChatTab) +impHandlerVoid(closeChatTab) +impHandlerVoid(closeAllChatTabs) +impHandlerVoid(ignoreAllWhispers) +impHandlerVoid(scrollChatUp) +impHandlerVoid(scrollChatDown) +impHandlerVoid(msg) +impHandlerVoid(msgText) +impHandlerVoid(msg2) +impHandlerVoid(query) +impHandlerVoid(clearChatTab) +impHandlerVoid(createParty) +impHandlerVoid(createGuild) +impHandlerVoid(party) +impHandlerVoid(guild) +impHandlerVoid(me) +impHandlerVoid(toggle) +impHandlerVoid(kickParty) +impHandlerVoid(kickGuild) +impHandlerVoid(addText) +impHandlerVoid(clearChat) +impHandlerVoid(chatGeneralTab) +impHandlerVoid(chatDebugTab) +impHandlerVoid(chatBattleTab) +impHandlerVoid(chatTradeTab) +impHandlerVoid(chatLangTab) +impHandlerVoid(chatGmTab) +impHandlerVoid(chatPartyTab) +impHandlerVoid(chatGuildTab) +impHandlerVoid(hat) +impHandlerVoid(chatClipboard) +impHandlerVoid(guildNotice) +impHandlerVoid(translate) +impHandlerVoid(sendGuiKey) +impHandlerVoid(sendMouseKey) +impHandlerVoid(sendChars) + +} // namespace Actions diff --git a/src/progs/dyecmd/actions/commands.cpp b/src/progs/dyecmd/actions/commands.cpp new file mode 100644 index 000000000..7f50ab20c --- /dev/null +++ b/src/progs/dyecmd/actions/commands.cpp @@ -0,0 +1,167 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2017 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/commands.h" + +#include "actions/actiondef.h" + +#include "debug.h" + +namespace Actions +{ + +impHandlerVoid(chatAnnounce) +impHandlerVoid(chatIgnore) +impHandlerVoid(chatUnignore) +impHandlerVoid(chatErase) +impHandlerVoid(chatFriend) +impHandlerVoid(chatDisregard) +impHandlerVoid(chatNeutral) +impHandlerVoid(chatBlackList) +impHandlerVoid(chatEnemy) +impHandlerVoid(chatNuke) +impHandlerVoid(chatAdd) +impHandlerVoid(present) +impHandlerVoid(printAll) +impHandlerVoid(move) +impHandlerVoid(setTarget) +impHandlerVoid(commandOutfit) +impHandlerVoid(commandEmote) +impHandlerVoid(awayMessage) +impHandlerVoid(pseudoAway) +impHandlerVoid(follow) +impHandlerVoid(navigate) +impHandlerVoid(navigateTo) +impHandlerVoid(moveCamera) +impHandlerVoid(restoreCamera) +impHandlerVoid(imitation) +impHandlerVoid(sendMail) +impHandlerVoid(info) +impHandlerVoid(wait) +impHandlerVoid(addPriorityAttack) +impHandlerVoid(addAttack) +impHandlerVoid(removeAttack) +impHandlerVoid(addIgnoreAttack) +impHandlerVoid(setDrop) +impHandlerVoid(url) +impHandlerVoid(openUrl) +impHandlerVoid(execute) +impHandlerVoid(enableHighlight) +impHandlerVoid(disableHighlight) +impHandlerVoid(dontRemoveName) +impHandlerVoid(removeName) +impHandlerVoid(disableAway) +impHandlerVoid(enableAway) +impHandlerVoid(testParticle) +impHandlerVoid(talkRaw) +impHandlerVoid(gm) +impHandlerVoid(hack) +impHandlerVoid(debugSpawn) +impHandlerVoid(serverIgnoreWhisper) +impHandlerVoid(serverUnIgnoreWhisper) +impHandlerVoid(setHomunculusName) +impHandlerVoid(fireHomunculus) +impHandlerVoid(leaveParty) +impHandlerVoid(leaveGuild) +impHandlerVoid(warp) +impHandlerVoid(homunTalk) +impHandlerVoid(homunEmote) +impHandlerVoid(commandHomunEmote) +impHandlerVoid(createPublicChatRoom) +impHandlerVoid(joinChatRoom) +impHandlerVoid(leaveChatRoom) +impHandlerVoid(confSet) +impHandlerVoid(serverConfSet) +impHandlerVoid(confGet) +impHandlerVoid(serverConfGet) +impHandlerVoid(slide) +impHandlerVoid(selectSkillLevel) +impHandlerVoid(skill) +impHandlerVoid(craft) +impHandlerVoid(npcClipboard) +impHandlerVoid(clipboardCopy) +impHandlerVoid(addPickup) +impHandlerVoid(removePickup) +impHandlerVoid(ignorePickup) +impHandlerVoid(monsterInfo) +impHandlerVoid(itemInfo) +impHandlerVoid(whoDrops) +impHandlerVoid(mobSearch) +impHandlerVoid(mobSpawnSearch) +impHandlerVoid(playerGmCommands) +impHandlerVoid(playerCharGmCommands) +impHandlerVoid(commandShowLevel) +impHandlerVoid(commandShowStats) +impHandlerVoid(commandShowStorage) +impHandlerVoid(commandShowCart) +impHandlerVoid(commandShowInventory) +impHandlerVoid(locatePlayer) +impHandlerVoid(commandShowAccountInfo) +impHandlerVoid(commandSpawn) +impHandlerVoid(commandSpawnSlave) +impHandlerVoid(commandSpawnClone) +impHandlerVoid(commandSpawnSlaveClone) +impHandlerVoid(commandSpawnEvilClone) +impHandlerVoid(commandSavePosition) +impHandlerVoid(commandLoadPosition) +impHandlerVoid(commandRandomWarp) +impHandlerVoid(commandGotoNpc) +impHandlerVoid(commandGotoPc) +impHandlerVoid(commandRecallPc) +impHandlerVoid(commandIpCheck) +impHandlerVoid(commandKiller) +impHandlerVoid(commandKillable) +impHandlerVoid(commandHeal) +impHandlerVoid(commandAlive) +impHandlerVoid(commandDisguise) +impHandlerVoid(commandImmortal) +impHandlerVoid(commandHide) +impHandlerVoid(commandNuke) +impHandlerVoid(commandKill) +impHandlerVoid(commandJail) +impHandlerVoid(commandUnjail) +impHandlerVoid(commandNpcMove) +impHandlerVoid(commandNpcHide) +impHandlerVoid(commandNpcShow) +impHandlerVoid(commandChangePartyLeader) +impHandlerVoid(commandPartyRecall) +impHandlerVoid(commandBreakGuild) +impHandlerVoid(commandGuildRecall) +impHandlerVoid(mailTo) +impHandlerVoid(adoptChild) +impHandlerVoid(showSkillLevels) +impHandlerVoid(showSkillType) +impHandlerVoid(selectSkillType) +impHandlerVoid(showSkillOffsetX) +impHandlerVoid(showSkillOffsetY) +impHandlerVoid(setSkillOffsetX) +impHandlerVoid(setSkillOffsetY) +impHandlerVoid(partyItemShare) +impHandlerVoid(partyExpShare) +impHandlerVoid(partyAutoItemShare) +impHandlerVoid(outfitToChat) +impHandlerVoid(outfitClear) +impHandlerVoid(moveAttackUp) +impHandlerVoid(moveAttackDown) +impHandlerVoid(movePriorityAttackUp) +impHandlerVoid(movePriorityAttackDown) +impHandlerVoid(addSkillShortcut) + +} // namespace Actions diff --git a/src/progs/dyecmd/actions/move.cpp b/src/progs/dyecmd/actions/move.cpp new file mode 100644 index 000000000..c3f82cd3a --- /dev/null +++ b/src/progs/dyecmd/actions/move.cpp @@ -0,0 +1,44 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2017 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/move.h" + +#include "actions/actiondef.h" + +#include "debug.h" + +namespace Actions +{ + +impHandlerVoid(moveUp) +impHandlerVoid(moveDown) +impHandlerVoid(moveLeft) +impHandlerVoid(moveRight) +impHandlerVoid(moveForward) +impHandlerVoid(moveToPoint) +impHandlerVoid(crazyMoves) +impHandlerVoid(moveToTarget) +impHandlerVoid(moveToHome) +impHandlerVoid(directUp) +impHandlerVoid(directDown) +impHandlerVoid(directLeft) +impHandlerVoid(directRight) + +} // namespace Actions diff --git a/src/progs/dyecmd/actions/pets.cpp b/src/progs/dyecmd/actions/pets.cpp new file mode 100644 index 000000000..96a7e5393 --- /dev/null +++ b/src/progs/dyecmd/actions/pets.cpp @@ -0,0 +1,49 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2017 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/pets.h" + +#include "actions/actiondef.h" + +#include "debug.h" + +namespace Actions +{ + +impHandlerVoid(commandEmotePet) +impHandlerVoid(talkPet) +impHandlerVoid(setPetName) +impHandlerVoid(petEmote) +impHandlerVoid(catchPet) +impHandlerVoid(petMoveUp) +impHandlerVoid(petMoveDown) +impHandlerVoid(petMoveLeft) +impHandlerVoid(petMoveRight) +impHandlerVoid(petDirectUp) +impHandlerVoid(petDirectDown) +impHandlerVoid(petDirectLeft) +impHandlerVoid(petDirectRight) +impHandlerVoid(petMove) +impHandlerVoid(petFeed) +impHandlerVoid(petDropLoot) +impHandlerVoid(petReturnToEgg) +impHandlerVoid(petUnequip) + +} // namespace Actions diff --git a/src/progs/dyecmd/actions/statusbar.cpp b/src/progs/dyecmd/actions/statusbar.cpp new file mode 100644 index 000000000..ed53ef8b0 --- /dev/null +++ b/src/progs/dyecmd/actions/statusbar.cpp @@ -0,0 +1,49 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2017 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 "actions/actiondef.h" + +#include "debug.h" + +namespace Actions +{ + +impHandlerVoid(switchQuickDrop) +impHandlerVoid(changeCrazyMove) +impHandlerVoid(changePickupType) +impHandlerVoid(changeMoveType) +impHandlerVoid(changeAttackWeaponType) +impHandlerVoid(changeAttackType) +impHandlerVoid(changeTargetingType) +impHandlerVoid(changeFollowMode) +impHandlerVoid(changeImitationMode) +impHandlerVoid(changeMagicAttackType) +impHandlerVoid(changePvpMode) +impHandlerVoid(changeMoveToTarget) +impHandlerVoid(changeGameModifier) +impHandlerVoid(changeAudio) +impHandlerVoid(away) +impHandlerVoid(camera) +impHandlerVoid(changeMapMode) +impHandlerVoid(changeTrade) + +} // namespace Actions diff --git a/src/progs/dyecmd/actions/tabs.cpp b/src/progs/dyecmd/actions/tabs.cpp new file mode 100644 index 000000000..3c795c2ab --- /dev/null +++ b/src/progs/dyecmd/actions/tabs.cpp @@ -0,0 +1,39 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2017 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/tabs.h" + +#include "actions/actiondef.h" + +#include "debug.h" + +namespace Actions +{ + +impHandlerVoid(prevSocialTab) +impHandlerVoid(nextSocialTab) +impHandlerVoid(nextShortcutsTab) +impHandlerVoid(prevShortcutsTab) +impHandlerVoid(nextCommandsTab) +impHandlerVoid(prevCommandsTab) +impHandlerVoid(nextInvTab) +impHandlerVoid(prevInvTab) + +} // namespace Actions diff --git a/src/progs/dyecmd/actions/target.cpp b/src/progs/dyecmd/actions/target.cpp new file mode 100644 index 000000000..80b34a7fb --- /dev/null +++ b/src/progs/dyecmd/actions/target.cpp @@ -0,0 +1,39 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2017 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/target.h" + +#include "actions/actiondef.h" + +#include "debug.h" + +namespace Actions +{ + +impHandlerVoid(targetPlayer) +impHandlerVoid(targetMonster) +impHandlerVoid(targetClosestMonster) +impHandlerVoid(targetNPC) +impHandlerVoid(targetMercenary) +impHandlerVoid(targetPet) +impHandlerVoid(targetSkillUnit) +impHandlerVoid(contextMenu) + +} // namespace Actions diff --git a/src/progs/dyecmd/actions/windows.cpp b/src/progs/dyecmd/actions/windows.cpp new file mode 100644 index 000000000..ce5c72ce2 --- /dev/null +++ b/src/progs/dyecmd/actions/windows.cpp @@ -0,0 +1,60 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2017 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/windows.h" + +#include "actions/actiondef.h" + +#include "debug.h" + +namespace Actions +{ + +impHandlerVoid(setupWindowShow) +impHandlerVoid(hideWindows) +impHandlerVoid(helpWindowShow) +impHandlerVoid(aboutWindowShow) +impHandlerVoid(statusWindowShow) +impHandlerVoid(inventoryWindowShow) +impHandlerVoid(equipmentWindowShow) +impHandlerVoid(skillDialogShow) +impHandlerVoid(minimapWindowShow) +impHandlerVoid(chatWindowShow) +impHandlerVoid(shortcutWindowShow) +impHandlerVoid(debugWindowShow) +impHandlerVoid(socialWindowShow) +impHandlerVoid(emoteShortcutWindowShow) +impHandlerVoid(outfitWindowShow) +impHandlerVoid(shopWindowShow) +impHandlerVoid(dropShortcutWindowShow) +impHandlerVoid(killStatsWindowShow) +impHandlerVoid(spellShortcutWindowShow) +impHandlerVoid(whoIsOnlineWindowShow) +impHandlerVoid(didYouKnowWindowShow) +impHandlerVoid(questsWindowShow) +impHandlerVoid(bankWindowShow) +impHandlerVoid(cartWindowShow) +impHandlerVoid(updaterWindowShow) +impHandlerVoid(quickWindowShow) +impHandlerVoid(mailWindowShow) +impHandlerVoid(serverInfoWindowShow) +impHandlerVoid(showItems) + +} // namespace Actions diff --git a/src/progs/dyecmd/client.cpp b/src/progs/dyecmd/client.cpp new file mode 100644 index 000000000..42b570a6b --- /dev/null +++ b/src/progs/dyecmd/client.cpp @@ -0,0 +1,813 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2017 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 "client.h" + +#include "configmanager.h" +#include "dirs.h" +#include "eventsmanager.h" +#include "graphicsmanager.h" +#include "main.h" +#include "settings.h" +#include "soundmanager.h" + +#include "fs/virtfs/fs.h" +#include "fs/virtfs/tools.h" + +#include "gui/dialogsmanager.h" +#include "gui/gui.h" +#include "gui/skin.h" +#include "gui/popupmanager.h" +#include "gui/windowmanager.h" + +#include "gui/widgets/button.h" +#include "gui/widgets/createwidget.h" +#include "gui/widgets/desktop.h" +#include "gui/widgets/window.h" +#include "gui/widgets/windowcontainer.h" + +#include "input/inputmanager.h" +#include "input/joystick.h" +#include "input/keyboardconfig.h" + +#include "input/touch/touchmanager.h" + +#include "resources/imagehelper.h" + +#include "resources/dye/dyepalette.h" + +#include "resources/resourcemanager/resourcemanager.h" + +#include "utils/cpu.h" +#include "utils/delete2.h" +#include "utils/env.h" +#include "utils/fuzzer.h" +#include "utils/gettext.h" +#include "utils/gettexthelper.h" +#include "utils/mrand.h" +#ifdef ANDROID +#include "fs/paths.h" +#endif // ANDROID + +#include "utils/sdlcheckutils.h" +#include "utils/timer.h" + +#include "utils/translation/translationmanager.h" + +#include "configuration.h" + +#include "net/ipc.h" + +#ifdef WIN32 +PRAGMA48(GCC diagnostic push) +PRAGMA48(GCC diagnostic ignored "-Wshadow") +#include +PRAGMA48(GCC diagnostic pop) +#include +#include "fs/specialfolder.h" +#undef ERROR +#endif // WIN32 + +#ifdef ANDROID +#ifndef USE_SDL2 +PRAGMA48(GCC diagnostic push) +PRAGMA48(GCC diagnostic ignored "-Wshadow") +#include +PRAGMA48(GCC diagnostic pop) +#include +#endif // USE_SDL2 +#endif // ANDROID + +PRAGMA48(GCC diagnostic push) +PRAGMA48(GCC diagnostic ignored "-Wshadow") +#ifdef USE_SDL2 +#include +#else // USE_SDL2 +#include +#endif // USE_SDL2 +PRAGMA48(GCC diagnostic pop) + +#include "debug.h" + +std::string errorMessage; + +Client *client = nullptr; + +extern FPSmanager fpsManager; + +volatile bool runCounters; +bool isSafeMode = false; +int serverVersion = 0; +int packetVersion = 0; +unsigned int tmwServerVersion = 0; +time_t start_time; +unsigned int mLastHost = 0; +unsigned long mSearchHash = 0; +int textures_count = 0; + +Client::Client() : + ActionListener(), + mCurrentDialog(nullptr), + mSetupButton(nullptr), + mVideoButton(nullptr), + mHelpButton(nullptr), + mAboutButton(nullptr), + mThemesButton(nullptr), + mPerfomanceButton(nullptr), +#ifdef ANDROID + mCloseButton(nullptr), +#endif // ANDROID + mState(State::GAME), + mOldState(State::START), + mSkin(nullptr), + mButtonPadding(1), + mButtonSpacing(3) +{ + WindowManager::init(); +} + +void Client::testsInit() +{ +} + +void Client::testsClear() +{ +} + +// +++ need remove duplicate from here +void Client::gameInit() +{ + logger = new Logger; + + initRand(); + + // Load branding information + if (!settings.options.brandingPath.empty()) + branding.init(settings.options.brandingPath); + setBrandingDefaults(branding); + + Dirs::initRootDir(); + Dirs::initHomeDir(); + + // Configure logger + if (!settings.options.logFileName.empty()) + { + settings.logFileName = settings.options.logFileName; + } + else + { + settings.logFileName = pathJoin(settings.localDataDir, + "manaplus.log"); + } + logger->setLogFile(settings.logFileName); + +#ifdef USE_FUZZER + Fuzzer::init(); +#endif // USE_FUZZER + + if (settings.options.test.empty()) + ConfigManager::backupConfig("config.xml"); + ConfigManager::initConfiguration(); + setPathsDefaults(paths); + initPaths(); + logger->log("init 4"); + logger->setDebugLog(config.getBoolValue("debugLog")); + logger->setReportUnimplemented(config.getBoolValue("unimplimentedLog")); + + config.incValue("runcount"); + +#ifndef ANDROID + if (settings.options.test.empty()) + ConfigManager::storeSafeParameters(); +#endif // ANDROID + + if (!VirtFs::setWriteDir(settings.localDataDir)) + { + logger->error(strprintf("%s couldn't be set as home directory! " + "Exiting.", settings.localDataDir.c_str())); + } + + GettextHelper::initLang(); + +/* + chatLogger = new ChatLogger; + if (settings.options.chatLogDir.empty()) + { + chatLogger->setBaseLogDir(settings.localDataDir + + std::string("/logs/")); + } + else + { + chatLogger->setBaseLogDir(settings.options.chatLogDir); + } +*/ + logger->setLogToStandardOut(config.getBoolValue("logToStandardOut")); + + // Log the client version + logger->log1(FULL_VERSION); + logger->log("Start configPath: " + config.getConfigPath()); + + Dirs::initScreenshotDir(); + + // Initialize SDL + logger->log1("Initializing SDL..."); + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) + { + logger->safeError(strprintf("Could not initialize SDL: %s", + SDL_GetError())); + } + atexit(SDL_Quit); + +#ifndef USE_SDL2 + SDL_EnableUNICODE(1); +#endif // USE_SDL2 + + WindowManager::applyKeyRepeat(); + + // disable unused SDL events +#ifndef USE_SDL2 + SDL_EventState(SDL_VIDEOEXPOSE, SDL_IGNORE); +#endif // USE_SDL2 + + SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE); + SDL_EventState(SDL_USEREVENT, SDL_IGNORE); + +#ifdef WIN32 + Dirs::extractDataDir(); + Dirs::mountDataDir(); +#endif // WIN32 + + WindowManager::setIcon(); + ConfigManager::checkConfigVersion(); + logVars(); + Cpu::detect(); + DyePalette::initFunctions(); +#if defined(USE_OPENGL) +#if !defined(ANDROID) && !defined(__APPLE__) && !defined(__native_client__) + if (!settings.options.safeMode && settings.options.test.empty() + && !config.getBoolValue("videodetected")) + { + graphicsManager.detectVideoSettings(); + } +#endif // !defined(ANDROID) && !defined(__APPLE__) && + // !defined(__native_client__) +#endif // defined(USE_OPENGL) + + updateEnv(); + initGraphics(); + +#ifndef WIN32 + Dirs::extractDataDir(); + Dirs::mountDataDir(); +#endif // WIN32 + + Dirs::updateDataPath(); + + // Add the main data directories to our PhysicsFS search path + if (!settings.options.dataPath.empty()) + { + VirtFs::mountDir(settings.options.dataPath, + Append_false); + } + + // Add the local data directory to PhysicsFS search path + VirtFs::mountDir(settings.localDataDir, + Append_false); + TranslationManager::loadCurrentLang(); + TranslationManager::loadDictionaryLang(); +#ifdef ENABLE_CUSTOMNLS + TranslationManager::loadGettextLang(); +#endif // ENABLE_CUSTOMNLS + + WindowManager::initTitle(); + + mainGraphics->postInit(); + + theme = new Theme; + Theme::selectSkin(); + touchManager.init(); + + // Initialize the item and emote shortcuts. +// for (size_t f = 0; f < SHORTCUT_TABS; f ++) +// itemShortcut[f] = new ItemShortcut(f); +// emoteShortcut = new EmoteShortcut; +// dropShortcut = new DropShortcut; + + gui = new Gui; + gui->postInit(mainGraphics); + dialogsManager = new DialogsManager; + popupManager = new PopupManager; + + initSoundManager(); + eventsManager.init(); + + // Initialize keyboard + keyboard.init(); + inputManager.init(); + + // Initialise player relations + Joystick::init(); + WindowManager::createWindows(); + + keyboard.update(); + if (joystick != nullptr) + joystick->update(); + +// if (mState != State::ERROR) +// mState = State::CHOOSE_SERVER; + + startTimers(); + + const int fpsLimit = config.getIntValue("fpslimit"); + settings.limitFps = fpsLimit > 0; + + SDL_initFramerate(&fpsManager); + WindowManager::setFramerate(fpsLimit); + + start_time = time(nullptr); + +// PlayerInfo::init(); + +#ifdef ANDROID +#ifndef USE_SDL2 + WindowManager::updateScreenKeyboard(SDL_GetScreenKeyboardHeight(nullptr)); +#endif // USE_SDL2 +#endif // ANDROID + + mSkin = theme->load("windowmenu.xml", ""); + if (mSkin != nullptr) + { + mButtonPadding = mSkin->getPadding(); + mButtonSpacing = mSkin->getOption("spacing", 3); + } +} + +Client::~Client() +{ + if (!settings.options.testMode) + gameClear(); + else + testsClear(); +} + +void Client::initSoundManager() +{ + // Initialize sound engine + try + { + if (config.getBoolValue("sound")) + soundManager.init(); + + soundManager.setSfxVolume(config.getIntValue("sfxVolume")); + soundManager.setMusicVolume(config.getIntValue("musicVolume")); + } + catch (const char *const err) + { + mState = State::ERROR; + errorMessage = err; + logger->log("Warning: %s", err); + } + soundManager.playMusic(branding.getValue( + "loginMusic", + "Magick - Real.ogg"), + SkipError_true); +} + +void Client::initGraphics() +{ + WindowManager::applyVSync(); + runCounters = config.getBoolValue("packetcounters"); + + graphicsManager.initGraphics(); + + imageHelper->postInit(); + setConfigDefaults2(config); + WindowManager::applyGrabMode(); + WindowManager::applyGamma(); + + mainGraphics->beginDraw(); +} + +void Client::gameClear() +{ + if (logger != nullptr) + logger->log1("Quitting1"); + + eventsManager.shutdown(); + WindowManager::deleteWindows(); + if (windowContainer != nullptr) + windowContainer->slowLogic(); + + stopTimers(); + + delete2(ipc); + + if (logger != nullptr) + logger->log1("Quitting2"); + + delete2(mCurrentDialog); + delete2(popupManager); + delete2(dialogsManager); + delete2(gui); + + if (logger != nullptr) + logger->log1("Quitting3"); + + GraphicsManager::deleteRenderers(); + + if (logger != nullptr) + logger->log1("Quitting4"); + + XML::cleanupXML(); + + if (logger != nullptr) + logger->log1("Quitting5"); + + // Shutdown sound + soundManager.close(); + + if (logger != nullptr) + logger->log1("Quitting6"); + + touchManager.clear(); + ResourceManager::deleteInstance(); + + if (logger != nullptr) + logger->log1("Quitting8"); + + WindowManager::deleteIcon(); + + if (logger != nullptr) + logger->log1("Quitting9"); + + delete2(joystick); + + keyboard.deinit(); + + if (logger != nullptr) + logger->log1("Quitting10"); + + soundManager.shutdown(); + touchManager.shutdown(); + +#ifdef DEBUG_CONFIG + config.enableKeyLogging(); +#endif // DEBUG_CONFIG + + config.removeOldKeys(); + config.write(); + serverConfig.write(); + + config.clear(); + serverConfig.clear(); + + if (logger != nullptr) + logger->log1("Quitting11"); + +#ifdef USE_PROFILER + Perfomance::clear(); +#endif // USE_PROFILER + +#ifdef DEBUG_OPENGL_LEAKS + if (logger) + logger->log("textures left: %d", textures_count); +#endif // DEBUG_OPENGL_LEAKS + + Graphics::cleanUp(); + + if (logger != nullptr) + logger->log1("Quitting12"); + +// delete2(chatLogger); + TranslationManager::close(); + VirtFs::deinit(); +} + +#define ADDBUTTON(var, object) var = object; \ + x -= var->getWidth() + mButtonSpacing; \ + var->setPosition(x, mButtonPadding); \ + top->add(var); + +void Client::stateGame() +{ + if (gui == nullptr) + return; + + BasicContainer2 *const top = static_cast( + gui->getTop()); + + if (top == nullptr) + return; + + CREATEWIDGETV(desktop, Desktop, nullptr); + top->add(desktop); + int x = top->getWidth() - mButtonPadding; + ADDBUTTON(mSetupButton, new Button(desktop, + // TRANSLATORS: setup tab quick button + _("Setup"), "Setup", this)) + ADDBUTTON(mPerfomanceButton, new Button(desktop, + // TRANSLATORS: perfoamance tab quick button + _("Performance"), "Perfomance", this)) + ADDBUTTON(mVideoButton, new Button(desktop, + // TRANSLATORS: video tab quick button + _("Video"), "Video", this)) + ADDBUTTON(mThemesButton, new Button(desktop, + // TRANSLATORS: theme tab quick button + _("Theme"), "Themes", this)) + ADDBUTTON(mAboutButton, new Button(desktop, + // TRANSLATORS: theme tab quick button + _("About"), "about", this)) + ADDBUTTON(mHelpButton, new Button(desktop, + // TRANSLATORS: theme tab quick button + _("Help"), "help", this)) +#ifdef ANDROID + ADDBUTTON(mCloseButton, new Button(desktop, + // TRANSLATORS: close quick button + _("Close"), "close", this)) +#endif // ANDROID + + desktop->setSize(mainGraphics->getWidth(), + mainGraphics->getHeight()); +} + +int Client::gameExec() +{ + int lastTickTime = tick_time; + + while (mState != State::EXIT) + { + PROFILER_START(); + if (eventsManager.handleEvents()) + continue; + + BLOCK_START("Client::gameExec 4") + if (gui != nullptr) + gui->logic(); + cur_time = time(nullptr); + int k = 0; + while (lastTickTime != tick_time && k < 40) + { +// if (mGame) +// mGame->logic(); +// else + if (gui != nullptr) + gui->handleInput(); + + ++lastTickTime; + k ++; + } + soundManager.logic(); + + logic_count += k; + if (gui != nullptr) + gui->slowLogic(); +// if (mGame) +// mGame->slowLogic(); + slowLogic(); + BLOCK_END("Client::gameExec 4") + + // This is done because at some point tick_time will wrap. + lastTickTime = tick_time; + + // Update the screen when application is visible, delay otherwise. + if (!WindowManager::getIsMinimized()) + { + frame_count++; + if (gui != nullptr) + gui->draw(); + mainGraphics->updateScreen(); + } + else + { + SDL_Delay(100); + } + + BLOCK_START("~Client::SDL_framerateDelay") + if (settings.limitFps) + SDL_framerateDelay(&fpsManager); + BLOCK_END("~Client::SDL_framerateDelay") + + BLOCK_START("Client::gameExec 6") +/* + if (mState == State::CONNECT_GAME) + { + stateConnectGame1(); + } +*/ + BLOCK_END("Client::gameExec 6") + + if (mState != mOldState) + { + BLOCK_START("Client::gameExec 7") + + mOldState = mState; + + // Get rid of the dialog of the previous state + delete2(mCurrentDialog); + + // State has changed, while the quitDialog was active, it might + // not be correct anymore +/* + if (mQuitDialog) + { + mQuitDialog->scheduleDelete(); + mQuitDialog = nullptr; + } +*/ + BLOCK_END("Client::gameExec 7") + + BLOCK_START("Client::gameExec 8") + PRAGMA45(GCC diagnostic push) + PRAGMA45(GCC diagnostic ignored "-Wswitch-enum") + switch (mState) + { + case State::GAME: + stateGame(); + break; + + case State::LOAD_DATA: + { + BLOCK_START("Client::gameExec State::LOAD_DATA") + logger->log1("State: LOAD DATA"); + + // If another data path has been set, + // we don't load any other files... + if (settings.options.dataPath.empty()) + { + // Add customdata directory + VirtFs::searchAndAddArchives( + "customdata/", + "zip", + Append_false); + } + + if (!settings.options.skipUpdate) + { + VirtFs::searchAndAddArchives(pathJoin( + settings.updatesDir, "local/"), + "zip", + Append_false); + + VirtFs::mountDir(pathJoin( + settings.localDataDir, + settings.updatesDir, + "local/"), + Append_false); + } + + logger->log("Init paths"); + paths.init("paths.xml", UseVirtFs_true); + setPathsDefaults(paths); + initPaths(); + TranslationManager::loadCurrentLang(); + TranslationManager::loadDictionaryLang(); + + if (desktop != nullptr) + desktop->reloadWallpaper(); + + mState = State::GET_CHARACTERS; + BLOCK_END("Client::gameExec State::LOAD_DATA") + break; + } + case State::START: + default: + mState = State::FORCE_QUIT; + break; + } + PRAGMA45(GCC diagnostic pop) + BLOCK_END("Client::gameExec 8") + } + PROFILER_END(); + } + + return 0; +} + +void Client::action(const ActionEvent &event) +{ + std::string tab; + const std::string &eventId = event.getId(); + + if (eventId == "close") + { + setState(State::FORCE_QUIT); + return; + } + if (eventId == "Setup") + { + tab.clear(); + } + else if (eventId == "help") + { + inputManager.executeAction(InputAction::WINDOW_HELP); + return; + } + else if (eventId == "about") + { + inputManager.executeAction(InputAction::WINDOW_ABOUT); + return; + } + else if (eventId == "Video") + { + tab = "Video"; + } + else if (eventId == "Themes") + { + tab = "Theme"; + } + else if (eventId == "Perfomance") + { + tab = "Perfomance"; + } + else + { + return; + } +} + +void Client::moveButtons(const int width) +{ + if (mSetupButton != nullptr) + { + int x = width - mSetupButton->getWidth() - mButtonPadding; + mSetupButton->setPosition(x, mButtonPadding); +#ifndef WIN32 + x -= mPerfomanceButton->getWidth() + mButtonSpacing; + mPerfomanceButton->setPosition(x, mButtonPadding); + + x -= mVideoButton->getWidth() + mButtonSpacing; + mVideoButton->setPosition(x, mButtonPadding); + + x -= mThemesButton->getWidth() + mButtonSpacing; + mThemesButton->setPosition(x, mButtonPadding); + + x -= mAboutButton->getWidth() + mButtonSpacing; + mAboutButton->setPosition(x, mButtonPadding); + + x -= mHelpButton->getWidth() + mButtonSpacing; + mHelpButton->setPosition(x, mButtonPadding); +#ifdef ANDROID + x -= mCloseButton->getWidth() + mButtonSpacing; + mCloseButton->setPosition(x, mButtonPadding); +#endif // ANDROID +#endif // WIN32 + } +} + +void Client::windowRemoved(const Window *const window) +{ + if (mCurrentDialog == window) + mCurrentDialog = nullptr; +} + +void Client::logVars() +{ +#ifdef ANDROID + logger->log("APPDIR: %s", getenv("APPDIR")); + logger->log("DATADIR2: %s", getSdStoragePath().c_str()); +#endif // ANDROID +} + +void Client::slowLogic() +{ +} + +int Client::testsExec() +{ + return 0; +} + +bool Client::isTmw() +{ + const std::string &name = settings.serverName; + if (name == "server.themanaworld.org" + || name == "themanaworld.org" + || name == "167.114.185.71") + { + return true; + } + return false; +} + +void Client::initPaths() +{ +} diff --git a/src/progs/dyecmd/client.h b/src/progs/dyecmd/client.h new file mode 100644 index 000000000..96d230c60 --- /dev/null +++ b/src/progs/dyecmd/client.h @@ -0,0 +1,119 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2017 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 PROGS_DYECMD_CLIENT_H +#define PROGS_DYECMD_CLIENT_H + +#include "enums/state.h" + +#include "listeners/actionlistener.h" + +#include "localconsts.h" + +class Button; +class Skin; +class Window; + +extern bool isSafeMode; +extern int serverVersion; +extern unsigned int tmwServerVersion; +extern time_t start_time; +extern int textures_count; + +extern std::string errorMessage; + +/** + * The core part of the client. This class initializes all subsystems, runs + * the event loop, and shuts everything down again. + */ +class Client final : public ActionListener +{ + public: + Client(); + + A_DELETE_COPY(Client) + + ~Client(); + + void gameInit(); + + void testsInit(); + + int gameExec(); + + static int testsExec(); + + void setState(const StateT state) + { mState = state; } + + StateT getState() const noexcept2 A_WARN_UNUSED + { return mState; } + + void action(const ActionEvent &event) override final; + + void moveButtons(const int width); + + void windowRemoved(const Window *const window); + + void slowLogic(); + + static bool isTmw(); + + private: + void stateGame(); + + void initSoundManager(); + + static void initGraphics(); + + static void initPaths(); + + void gameClear(); + + void testsClear(); + + static void logVars(); + + Window *mCurrentDialog; + Button *mSetupButton; + Button *mVideoButton; + Button *mHelpButton; + Button *mAboutButton; + Button *mThemesButton; + Button *mPerfomanceButton; +#ifdef ANDROID + Button *mCloseButton; +#endif // ANDROID + + StateT mState; + StateT mOldState; + + Skin *mSkin; + int mButtonPadding; + int mButtonSpacing; +}; + +extern Client *client; +extern unsigned int mLastHost; +extern unsigned long mSearchHash; + +#endif // PROGS_DYECMD_CLIENT_H diff --git a/src/progs/dyecmd/dyemain.cpp b/src/progs/dyecmd/dyemain.cpp new file mode 100644 index 000000000..2217508cc --- /dev/null +++ b/src/progs/dyecmd/dyemain.cpp @@ -0,0 +1,119 @@ +/* + * The ManaPlus Client + * Copyright (C) 2013-2017 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 "logger.h" + +#include "graphicsmanager.h" +#include "maingui.h" +#include "sdlshared.h" + +#include "fs/virtfs/fs.h" + +#include "resources/imagewriter.h" + +#include "resources/image/image.h" + +#ifdef USE_SDL2 +#include "resources/surfaceimagehelper.h" +#endif // USE_SDL2 + +#include "resources/loaders/imageloader.h" + +#include "utils/gettext.h" + +#include + +#ifndef USE_SDL2 +#include "resources/sdlimagehelper.h" +#endif // USE_SDL2 + +PRAGMA48(GCC diagnostic push) +PRAGMA48(GCC diagnostic ignored "-Wshadow") +#include +PRAGMA48(GCC diagnostic pop) + +#include "debug.h" + +static void printHelp() +{ + // TRANSLATORS: command line help + std::cout << _("dyecmd srcfile dyestring dstfile") << std::endl; + // TRANSLATORS: command line help + std::cout << _("or") << std::endl; + // TRANSLATORS: command line help + std::cout << _("dyecmd srcdyestring dstfile") << std::endl; +} + +int main(int argc, char **argv) +{ + if (argc == 2 && (strcmp(argv[1], "--help") != 0)) + { + return mainGui(argc, argv); + } + if (argc < 3 || argc > 4) + { + printHelp(); + return 1; + } + + logger = new Logger; + logger->setLogToStandardOut(false); + + VirtFs::init(argv[0]); + SDL_Init(SDL_INIT_VIDEO); + + graphicsManager.createWindow(10, 10, 0, SDL_ANYFORMAT); + +#ifdef USE_SDL2 + imageHelper = new SurfaceImageHelper; +#else // USE_SDL2 + + imageHelper = new SDLImageHelper; +#endif // USE_SDL2 + + VirtFs::setWriteDir("."); + VirtFs::mountDir(".", Append_false); + VirtFs::mountDir("/", Append_false); + std::string src = argv[1]; + std::string dst; + if (argc == 4) + { + src.append("|").append(argv[2]); + dst = argv[3]; + } + else + { + dst = argv[2]; + } + + Image *image = Loader::getImage(src); + if (image == nullptr) + { + printf("Error loading image\n"); + VirtFs::deinit(); + return 1; + } + SDL_Surface *const surface = ImageHelper::convertTo32Bit( + image->getSDLSurface()); + ImageWriter::writePNG(surface, dst); + SDL_FreeSurface(surface); + VirtFs::deinit(); + return 0; +} diff --git a/src/progs/dyecmd/gui/viewport.cpp b/src/progs/dyecmd/gui/viewport.cpp new file mode 100644 index 000000000..30e89518e --- /dev/null +++ b/src/progs/dyecmd/gui/viewport.cpp @@ -0,0 +1,272 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2017 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 "progs/dyecmd/gui/viewport.h" + +#include "configuration.h" +#include "sdlshared.h" + +#include "gui/gui.h" +#include "gui/popupmanager.h" + +#include "render/graphics.h" + +#include "debug.h" + +Viewport *viewport = nullptr; + +extern volatile int tick_time; + +Viewport::Viewport() : + WindowContainer(nullptr), + MouseListener(), + ConfigListener(), + mMouseX(0), + mMouseY(0), + mMap(nullptr), + mHoverBeing(nullptr), + mHoverItem(nullptr), + mHoverSign(nullptr), + mScrollRadius(config.getIntValue("ScrollRadius")), + mScrollLaziness(config.getIntValue("ScrollLaziness")), + mScrollCenterOffsetX(config.getIntValue("ScrollCenterOffsetX")), + mScrollCenterOffsetY(config.getIntValue("ScrollCenterOffsetY")), + mMousePressX(0), + mMousePressY(0), + mPixelViewX(0), + mPixelViewY(0), + mLocalWalkTime(-1), + mCameraRelativeX(0), + mCameraRelativeY(0), + mShowBeingPopup(config.getBoolValue("showBeingPopup")), + mSelfMouseHeal(config.getBoolValue("selfMouseHeal")), + mEnableLazyScrolling(config.getBoolValue("enableLazyScrolling")), + mMouseDirectionMove(config.getBoolValue("mouseDirectionMove")), + mLongMouseClick(config.getBoolValue("longmouseclick")), + mMouseClicked(false), + mPlayerFollowMouse(false) +{ + setOpaque(Opaque_false); + addMouseListener(this); + + config.addListener("ScrollLaziness", this); + config.addListener("ScrollRadius", this); + config.addListener("showBeingPopup", this); + config.addListener("selfMouseHeal", this); + config.addListener("enableLazyScrolling", this); + config.addListener("mouseDirectionMove", this); + config.addListener("longmouseclick", this); + + setFocusable(true); +} + +Viewport::~Viewport() +{ + config.removeListeners(this); + CHECKLISTENERS +} + +void Viewport::setMap(Map *const map A_UNUSED) +{ +} + +void Viewport::draw(Graphics *const graphics) +{ + BLOCK_START("Viewport::draw 1") + static int lastTick = tick_time; + + graphics->setColor(Color(64, 64, 64)); + graphics->fillRectangle( + Rect(0, 0, getWidth(), getHeight())); + + // Avoid freaking out when tick_time overflows + if (tick_time < lastTick) + lastTick = tick_time; + + // Draw contained widgets + WindowContainer::draw(graphics); + BLOCK_END("Viewport::draw 1") +} + +void Viewport::safeDraw(Graphics *const graphics) +{ + Viewport::draw(graphics); +} + +void Viewport::logic() +{ + BLOCK_START("Viewport::logic") + // Make the player follow the mouse position + // if the mouse is dragged elsewhere than in a window. + Gui::getMouseState(mMouseX, mMouseY); + BLOCK_END("Viewport::logic") +} + +void Viewport::followMouse() +{ +} + +void Viewport::drawDebugPath(Graphics *const graphics A_UNUSED) +{ +} + +bool Viewport::openContextMenu(const MouseEvent &event A_UNUSED) +{ + return false; +} + +void Viewport::mousePressed(MouseEvent &event) +{ + if (event.getSource() != this || event.isConsumed()) + return; + + mMouseClicked = true; + + mMousePressX = event.getX(); + mMousePressY = event.getY(); + const MouseButtonT eventButton = event.getButton(); + + // Right click might open a popup + if (eventButton == MouseButton::RIGHT) + { + if (openContextMenu(event)) + return; + } + + // If a popup is active, just remove it + if (PopupManager::isPopupMenuVisible()) + { + mPlayerFollowMouse = false; + PopupManager::hidePopupMenu(); + return; + } + + // Left click can cause different actions + if (!mLongMouseClick && eventButton == MouseButton::LEFT) + { + if (leftMouseAction()) + { + mPlayerFollowMouse = false; + return; + } + } +} + +void Viewport::walkByMouse(const MouseEvent &event A_UNUSED) +{ +} + +void Viewport::mouseDragged(MouseEvent &event) +{ + if (event.getSource() != this || event.isConsumed()) + { + mPlayerFollowMouse = false; + return; + } + if (mMouseClicked) + { + if (abs(event.getX() - mMousePressX) > 32 + || abs(event.getY() - mMousePressY) > 32) + { + mPlayerFollowMouse = true; + } + } + + walkByMouse(event); +} + +void Viewport::mouseReleased(MouseEvent &event) +{ + mPlayerFollowMouse = false; + mLocalWalkTime = -1; + if (mLongMouseClick && mMouseClicked) + { + mMouseClicked = false; + if (event.getSource() != this || event.isConsumed()) + return; + const MouseButtonT eventButton = event.getButton(); + if (eventButton == MouseButton::LEFT) + { + // long button press + if ((gui != nullptr) && gui->isLongPress()) + { + if (openContextMenu(event)) + { + gui->resetClickCount(); + return; + } + } + else + { + if (leftMouseAction()) + return; + } + walkByMouse(event); + } + } +} + +void Viewport::optionChanged(const std::string &name) +{ + if (name == "ScrollLaziness") + mScrollLaziness = config.getIntValue("ScrollLaziness"); + else if (name == "ScrollRadius") + mScrollRadius = config.getIntValue("ScrollRadius"); + else if (name == "showBeingPopup") + mShowBeingPopup = config.getBoolValue("showBeingPopup"); + else if (name == "selfMouseHeal") + mSelfMouseHeal = config.getBoolValue("selfMouseHeal"); + else if (name == "enableLazyScrolling") + mEnableLazyScrolling = config.getBoolValue("enableLazyScrolling"); + else if (name == "mouseDirectionMove") + mMouseDirectionMove = config.getBoolValue("mouseDirectionMove"); + else if (name == "longmouseclick") + mLongMouseClick = config.getBoolValue("longmouseclick"); +} + +void Viewport::mouseMoved(MouseEvent &event A_UNUSED) +{ +} + +void Viewport::toggleMapDrawType() +{ +} + +void Viewport::toggleCameraMode() +{ +} + +void Viewport::cleanHoverItems() +{ + mHoverBeing = nullptr; + mHoverItem = nullptr; + mHoverSign = nullptr; +} + +bool Viewport::leftMouseAction() +{ + return false; +} + +void Viewport::videoResized() +{ +} diff --git a/src/progs/dyecmd/gui/viewport.h b/src/progs/dyecmd/gui/viewport.h new file mode 100644 index 000000000..4b69a607c --- /dev/null +++ b/src/progs/dyecmd/gui/viewport.h @@ -0,0 +1,213 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2017 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 PROGS_DYECMD_GUI_VIEWPORT_H +#define PROGS_DYECMD_GUI_VIEWPORT_H + +#include "position.h" + +#include "gui/widgets/windowcontainer.h" + +#include "listeners/mouselistener.h" + +class ActorSprite; +class Being; +class FloorItem; +class Graphics; +class Map; +class MapItem; + +/** + * The viewport on the map. Displays the current map and handles mouse input + * and the popup menu. + */ +class Viewport final : public WindowContainer, + public MouseListener, + public ConfigListener +{ + public: + /** + * Constructor. + */ + Viewport(); + + A_DELETE_COPY(Viewport) + + /** + * Destructor. + */ + ~Viewport(); + + /** + * Sets the map displayed by the viewport. + */ + void setMap(Map *const map); + + /** + * Draws the viewport. + */ + void draw(Graphics *const graphics) override final A_NONNULL(2); + + void safeDraw(Graphics *const graphics) override final A_NONNULL(2); + + /** + * Implements player to keep following mouse. + */ + void logic() override final; + + /** + * Toggles whether the path debug graphics are shown. normal, + * debug with all images and grid, debug with out big images + * and with out grid. + */ + void toggleMapDrawType(); + + void toggleCameraMode(); + + /** + * Handles mouse press on map. + */ + void mousePressed(MouseEvent &event) override final; + + /** + * Handles mouse move on map + */ + void mouseDragged(MouseEvent &event) override final; + + /** + * Handles mouse button release on map. + */ + void mouseReleased(MouseEvent &event) override final; + + /** + * Handles mouse move on map. + */ + void mouseMoved(MouseEvent &event) override final; + + /** + * A relevant config option changed. + */ + void optionChanged(const std::string &name) override final; + + /** + * Returns camera x offset in pixels. + */ + int getCameraX() const noexcept2 A_WARN_UNUSED + { return mPixelViewX; } + + /** + * Returns camera y offset in pixels. + */ + int getCameraY() const noexcept2 A_WARN_UNUSED + { return mPixelViewY; } + + /** + * Changes viewpoint by relative pixel coordinates. + */ + void scrollBy(const int x, const int y) + { mPixelViewX += x; mPixelViewY += y; } + + /** + * Clear all hover item, being etc + */ + void cleanHoverItems(); + + Map *getMap() const noexcept2 A_WARN_UNUSED + { return mMap; } + + void moveCamera(const int dx, const int dy); + + int getCameraRelativeX() const noexcept2 A_WARN_UNUSED + { return mCameraRelativeX; } + + int getCameraRelativeY() const noexcept2 A_WARN_UNUSED + { return mCameraRelativeY; } + + void setCameraRelativeX(const int n) noexcept2 + { mCameraRelativeX = n; } + + void setCameraRelativeY(const int n) noexcept2 + { mCameraRelativeY = n; } + + void videoResized(); + + int mMouseX; /**< Current mouse position in pixels. */ + int mMouseY; /**< Current mouse position in pixels. */ + + private: + /** + * Finds a path from the player to the mouse, and draws it. This is for + * debug purposes. + */ + void drawDebugPath(Graphics *const graphics) A_NONNULL(2); + + /** + * Draws the given path. + */ + void drawPath(Graphics *const graphics, + const Path &path, + const Color &color = Color(255, 0, 0)) + const A_NONNULL(2); + + bool leftMouseAction(); + + bool openContextMenu(const MouseEvent &event); + + void walkByMouse(const MouseEvent &event); + + /** + * Make the player go to the mouse position. + */ + void followMouse(); + + Map *mMap; /**< The current map. */ + + Being *mHoverBeing; /**< Being mouse is currently over. */ + FloorItem *mHoverItem; /**< FloorItem mouse is currently over. */ + MapItem *mHoverSign; /**< Map sign mouse is currently over. */ + + int mScrollRadius; + int mScrollLaziness; + int mScrollCenterOffsetX; + int mScrollCenterOffsetY; + int mMousePressX; + int mMousePressY; + int mPixelViewX; /**< Current viewpoint in pixels. */ + int mPixelViewY; /**< Current viewpoint in pixels. */ + + int mLocalWalkTime; /**< Timestamp before the next walk can be sent. */ + + int mCameraRelativeX; + int mCameraRelativeY; + + bool mShowBeingPopup; + bool mSelfMouseHeal; + bool mEnableLazyScrolling; + bool mMouseDirectionMove; + bool mLongMouseClick; + bool mMouseClicked; + bool mPlayerFollowMouse; +}; + +extern Viewport *viewport; /**< The viewport. */ + +#endif // PROGS_DYECMD_GUI_VIEWPORT_H -- cgit v1.2.3-70-g09d2