From f5ab127a39dd06a3b94ae5a9b839f255069f1b0c Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 16 Apr 2012 15:00:44 +0200 Subject: [PATCH] toggleFullHelp --- apps/openmw/mwgui/tooltips.cpp | 114 ++++++++++++++++++++----- apps/openmw/mwgui/tooltips.hpp | 6 +- apps/openmw/mwgui/window_manager.cpp | 5 ++ apps/openmw/mwgui/window_manager.hpp | 1 + apps/openmw/mwscript/docs/vmformat.txt | 3 +- apps/openmw/mwscript/guiextensions.cpp | 21 ++++- 6 files changed, 128 insertions(+), 22 deletions(-) diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 4dcb1cda78..25361ffcc6 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -10,6 +10,7 @@ ToolTips::ToolTips(WindowManager* windowManager) : Layout("openmw_tooltips.xml") , mGameMode(true) , mWindowManager(windowManager) + , mFullHelp(false) { getWidget(mDynamicToolTipBox, "DynamicToolTipBox"); @@ -67,7 +68,9 @@ void ToolTips::onFrame(float frameDuration) { std::string caption = focus->getUserString("ToolTipCaption"); std::string image = focus->getUserString("ToolTipImage"); - tooltipSize = createImageToolTip(caption, image, text); + std::string sizeString = focus->getUserString("ToolTipImageSize"); + int size = (sizeString != "" ? boost::lexical_cast(sizeString) : 32); + tooltipSize = createImageToolTip(caption, image, size, text); } IntPoint tooltipPosition = InputManager::getInstance().getMousePosition() + IntPoint(0, 24); @@ -179,6 +182,11 @@ IntSize ToolTips::getToolTipViaPtr () if (ref->ref.trap != "") text += "\n" + mWindowManager->getGameSettingString("sTrapped", "Trapped!"); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + tooltipSize = createToolTip(ref->base->name, text); } @@ -192,7 +200,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Apparatus ------------------------------- @@ -205,7 +218,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Armor ------------------------------- @@ -222,7 +240,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Book ------------------------------- @@ -234,7 +257,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Clothing ------------------------------- @@ -247,7 +275,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Ingredient ------------------------------- @@ -260,7 +293,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Light ------------------------------- @@ -272,7 +310,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Tool ------------------------------- @@ -286,7 +329,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Miscellaneous ------------------------------- @@ -298,7 +346,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Probe ------------------------------- @@ -312,7 +365,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Repair ------------------------------- @@ -326,7 +384,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Weapon ------------------------------- @@ -340,7 +403,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Activator ------------------------------- @@ -348,7 +416,12 @@ IntSize ToolTips::getToolTipViaPtr () { ESMS::LiveCellRef* ref = mFocusObject.get(); - tooltipSize = createToolTip(ref->base->name, ""); + std::string text; + if (mFullHelp) { + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createToolTip(ref->base->name, text); } else @@ -374,7 +447,7 @@ void ToolTips::findImageExtension(std::string& image) } } -IntSize ToolTips::createImageToolTip(const std::string& caption, const std::string& image, const std::string& text) +IntSize ToolTips::createImageToolTip(const std::string& caption, const std::string& image, const int imageSize, const std::string& text) { // remove the first newline (easier this way) std::string realText = text; @@ -384,12 +457,10 @@ IntSize ToolTips::createImageToolTip(const std::string& caption, const std::stri std::string realImage = "icons\\" + image; findImageExtension(realImage); - const int imageSize = 32; - EditBox* captionWidget = mDynamicToolTipBox->createWidget("NormalText", IntCoord(0, 0, 300, 300), Align::Left | Align::Top, "ToolTipCaption"); captionWidget->setProperty("Static", "true"); captionWidget->setCaption(caption); - EditBox* textWidget = mDynamicToolTipBox->createWidget("SandText", IntCoord(0, imageSize, 300, 262), Align::Stretch, "ToolTipText"); + EditBox* textWidget = mDynamicToolTipBox->createWidget("SandText", IntCoord(0, imageSize, 300, 300-imageSize), Align::Stretch, "ToolTipText"); textWidget->setProperty("Static", "true"); textWidget->setProperty("MultiLine", "true"); textWidget->setProperty("WordWrap", "true"); @@ -407,7 +478,7 @@ IntSize ToolTips::createImageToolTip(const std::string& caption, const std::stri Align::Left | Align::Top, "ToolTipImage"); imageWidget->setImageTexture(realImage); - captionWidget->setCoord( (totalSize.width - captionSize.width)/2 + imageSize, (32-captionSize.height)/2, captionSize.width-imageSize, captionSize.height); + captionWidget->setCoord( (totalSize.width - captionSize.width)/2 + imageSize, (imageSize-captionSize.height)/2, captionSize.width-imageSize, captionSize.height); mDynamicToolTipBox->setVisible(caption != ""); @@ -468,3 +539,8 @@ std::string ToolTips::getValueString(const int value) else return "\n" + mWindowManager->getGameSettingString("sValue", "Value") + ": " + toString(value); } + +void ToolTips::toggleFullHelp() +{ + mFullHelp = !mFullHelp; +} diff --git a/apps/openmw/mwgui/tooltips.hpp b/apps/openmw/mwgui/tooltips.hpp index 7a2dded114..f546f3976e 100644 --- a/apps/openmw/mwgui/tooltips.hpp +++ b/apps/openmw/mwgui/tooltips.hpp @@ -19,6 +19,8 @@ namespace MWGui void enterGameMode(); void enterGuiMode(); + void toggleFullHelp(); ///< show extra info in item tooltips (owner, script) + void setFocusObject(const MWWorld::Ptr& focus); private: @@ -33,7 +35,7 @@ namespace MWGui MyGUI::IntSize getToolTipViaPtr (); ///< @return requested tooltip size - MyGUI::IntSize createImageToolTip(const std::string& caption, const std::string& image, const std::string& text); + MyGUI::IntSize createImageToolTip(const std::string& caption, const std::string& image, const int imageSize, const std::string& text); ///< @return requested tooltip size MyGUI::IntSize createToolTip(const std::string& caption, const std::string& text); @@ -49,6 +51,8 @@ namespace MWGui std::string toString(const int value); bool mGameMode; + + bool mFullHelp; }; } #endif diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 8ed2050cc0..b18ee4e432 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -497,3 +497,8 @@ void WindowManager::setFocusObject(const MWWorld::Ptr& focus) { mToolTips->setFocusObject(focus); } + +void WindowManager::toggleFullHelp() +{ + mToolTips->toggleFullHelp(); +} diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index d5f0683b86..d76d15dd4c 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -161,6 +161,7 @@ namespace MWGui void setFocusObject(const MWWorld::Ptr& focus); void toggleFogOfWar(); + void toggleFullHelp(); ///< show extra info in item tooltips (owner, script) int toggleFps(); ///< toggle fps display @return resulting fps level diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 58960aac47..378b2412a5 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -144,4 +144,5 @@ op 0x200014d: ModDisposition op 0x200014e: ModDisposition, explicit reference op 0x200014f: ForceGreeting op 0x2000150: ForceGreeting, explicit reference -opcodes 0x2000151-0x3ffffff unused +op 0x2000151: ToggleFullHelp +opcodes 0x2000152-0x3ffffff unused diff --git a/apps/openmw/mwscript/guiextensions.cpp b/apps/openmw/mwscript/guiextensions.cpp index 426378efca..f7be161d62 100644 --- a/apps/openmw/mwscript/guiextensions.cpp +++ b/apps/openmw/mwscript/guiextensions.cpp @@ -80,6 +80,19 @@ namespace MWScript } }; + class OpToggleFullHelp : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + InterpreterContext& context = + static_cast (runtime.getContext()); + + context.getEnvironment().mWindowManager->toggleFullHelp(); + } + }; + const int opcodeEnableBirthMenu = 0x200000e; const int opcodeEnableClassMenu = 0x200000f; const int opcodeEnableNameMenu = 0x2000010; @@ -93,6 +106,7 @@ namespace MWScript const int opcodeShowRestMenu = 0x2000018; const int opcodeGetButtonPressed = 0x2000137; const int opcodeToggleFogOfWar = 0x2000145; + const int opcodeToggleFullHelp = 0x2000151; void registerExtensions (Compiler::Extensions& extensions) { @@ -101,7 +115,7 @@ namespace MWScript extensions.registerInstruction ("enablenamemenu", "", opcodeEnableNameMenu); extensions.registerInstruction ("enableracemenu", "", opcodeEnableRaceMenu); extensions.registerInstruction ("enablestatsreviewmenu", "", - opcodeEnableStatsReviewMenu); +opcodeEnableStatsReviewMenu); extensions.registerInstruction ("enableinventorymenu", "", opcodeEnableInventoryMenu); extensions.registerInstruction ("enablemagicmenu", "", opcodeEnableMagicMenu); @@ -117,6 +131,9 @@ namespace MWScript extensions.registerInstruction ("togglefogofwar", "", opcodeToggleFogOfWar); extensions.registerInstruction ("tfow", "", opcodeToggleFogOfWar); + + extensions.registerInstruction ("togglefullhelp", "", opcodeToggleFullHelp); + extensions.registerInstruction ("tfh", "", opcodeToggleFullHelp); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -154,6 +171,8 @@ namespace MWScript interpreter.installSegment5 (opcodeGetButtonPressed, new OpGetButtonPressed); interpreter.installSegment5 (opcodeToggleFogOfWar, new OpToggleFogOfWar); + + interpreter.installSegment5 (opcodeToggleFullHelp, new OpToggleFullHelp); } } }