From 98c1dc115145ebcf8ce0deb6efc50900e8f82b99 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 20 Sep 2012 18:02:37 +0200 Subject: [PATCH] ShowMap & FillMap commands, merged next --- apps/openmw/mwbase/windowmanager.hpp | 2 + apps/openmw/mwgui/windowmanagerimp.cpp | 5 +++ apps/openmw/mwgui/windowmanagerimp.hpp | 2 + apps/openmw/mwscript/docs/vmformat.txt | 4 +- apps/openmw/mwscript/guiextensions.cpp | 54 ++++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 49f1f95b0e..4291631363 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -189,6 +189,8 @@ namespace MWBase virtual void allowMouse() = 0; virtual void notifyInputActionBound() = 0; + virtual void addVisitedLocation(const std::string& name, int x, int y) = 0; + virtual void removeDialog(OEngine::GUI::Layout* dialog) = 0; ///< Hides dialog and schedules dialog to be deleted. diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index c72ad9854a..c8e56f2c73 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -954,3 +954,8 @@ bool WindowManager::getPlayerSleeping () { return mWaitDialog->getSleeping(); } + +void WindowManager::addVisitedLocation(const std::string& name, int x, int y) +{ + mMap->addVisitedLocation (name, x, y); +} diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 0ed5e1feaa..47461f877a 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -172,6 +172,8 @@ namespace MWGui virtual void allowMouse(); virtual void notifyInputActionBound(); + virtual void addVisitedLocation(const std::string& name, int x, int y); + virtual void removeDialog(OEngine::GUI::Layout* dialog); ///< Hides dialog and schedules dialog to be deleted. virtual void messageBox (const std::string& message, const std::vector& buttons); diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index a9f2cd1435..a4a9e99fd8 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -203,5 +203,7 @@ op 0x200019c: PlaceAtPc op 0x200019d: PlaceAtMe op 0x200019e: PlaceAtMe Explicit op 0x200019f: GetPcSleep -opcodes 0x20001a0-0x3ffffff unused +op 0x20001a0: ShowMap +op 0x20001a1: FillMap +opcodes 0x20001a2-0x3ffffff unused diff --git a/apps/openmw/mwscript/guiextensions.cpp b/apps/openmw/mwscript/guiextensions.cpp index 6e5540fa8f..a93de0ede2 100644 --- a/apps/openmw/mwscript/guiextensions.cpp +++ b/apps/openmw/mwscript/guiextensions.cpp @@ -1,12 +1,17 @@ #include "guiextensions.hpp" +#include + #include #include #include #include +#include +#include + #include "../mwbase/environment.hpp" #include "../mwbase/windowmanager.hpp" @@ -91,6 +96,47 @@ namespace MWScript } }; + class OpShowMap : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + std::string cell = (runtime.getStringLiteral (runtime[0].mInteger)); + boost::algorithm::to_lower(cell); + runtime.pop(); + + // "Will match complete or partial cells, so ShowMap, "Vivec" will show cells Vivec and Vivec, Fred's House as well." + // http://www.uesp.net/wiki/Tes3Mod:ShowMap + + const ESMS::CellList::ExtCells& extCells = MWBase::Environment::get().getWorld ()->getStore ().cells.extCells; + for (ESMS::CellList::ExtCells::const_iterator it = extCells.begin(); it != extCells.end(); ++it) + { + std::string name = it->second->name; + boost::algorithm::to_lower(name); + if (name.find(cell) != std::string::npos) + MWBase::Environment::get().getWindowManager()->addVisitedLocation (it->second->name, it->first.first, it->first.second); + } + } + }; + + class OpFillMap : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + const ESMS::CellList::ExtCells& extCells = MWBase::Environment::get().getWorld ()->getStore ().cells.extCells; + for (ESMS::CellList::ExtCells::const_iterator it = extCells.begin(); it != extCells.end(); ++it) + { + std::string name = it->second->name; + if (name != "") + MWBase::Environment::get().getWindowManager()->addVisitedLocation (name, it->first.first, it->first.second); + } + } + }; + + const int opcodeEnableBirthMenu = 0x200000e; const int opcodeEnableClassMenu = 0x200000f; const int opcodeEnableNameMenu = 0x2000010; @@ -105,6 +151,8 @@ namespace MWScript const int opcodeGetButtonPressed = 0x2000137; const int opcodeToggleFogOfWar = 0x2000145; const int opcodeToggleFullHelp = 0x2000151; + const int opcodeShowMap = 0x20001a0; + const int opcodeFillMap = 0x20001a1; void registerExtensions (Compiler::Extensions& extensions) { @@ -132,6 +180,9 @@ opcodeEnableStatsReviewMenu); extensions.registerInstruction ("togglefullhelp", "", opcodeToggleFullHelp); extensions.registerInstruction ("tfh", "", opcodeToggleFullHelp); + + extensions.registerInstruction ("showmap", "S", opcodeShowMap); + extensions.registerInstruction ("fillmap", "", opcodeFillMap); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -167,6 +218,9 @@ opcodeEnableStatsReviewMenu); interpreter.installSegment5 (opcodeToggleFogOfWar, new OpToggleFogOfWar); interpreter.installSegment5 (opcodeToggleFullHelp, new OpToggleFullHelp); + + interpreter.installSegment5 (opcodeShowMap, new OpShowMap); + interpreter.installSegment5 (opcodeFillMap, new OpFillMap); } } }