WindowManager refactoring

celladd
scrawl 10 years ago
parent ef34d8b3fb
commit 37a6d7da76

@ -149,17 +149,16 @@ namespace MWBase
/// \todo investigate, if we really need to expose every single lousy UI element to the outside world
virtual MWGui::DialogueWindow* getDialogueWindow() = 0;
virtual MWGui::ContainerWindow* getContainerWindow() = 0;
virtual MWGui::InventoryWindow* getInventoryWindow() = 0;
virtual MWGui::BookWindow* getBookWindow() = 0;
virtual MWGui::ScrollWindow* getScrollWindow() = 0;
virtual MWGui::CountDialog* getCountDialog() = 0;
virtual MWGui::ConfirmationDialog* getConfirmationDialog() = 0;
virtual MWGui::TradeWindow* getTradeWindow() = 0;
virtual MWGui::SpellBuyingWindow* getSpellBuyingWindow() = 0;
virtual MWGui::TravelWindow* getTravelWindow() = 0;
virtual MWGui::SpellWindow* getSpellWindow() = 0;
virtual MWGui::Console* getConsole() = 0;
virtual void updateSpellWindow() = 0;
virtual void setConsoleSelectedObject(const MWWorld::Ptr& object) = 0;
virtual void wmUpdateFps(float fps, unsigned int triangleCount, unsigned int batchCount) = 0;
@ -181,12 +180,6 @@ namespace MWBase
virtual void configureSkills (const SkillList& major, const SkillList& minor) = 0;
///< configure skill groups, each set contains the skill ID for that group.
virtual void setReputation (int reputation) = 0;
///< set the current reputation value
virtual void setBounty (int bounty) = 0;
///< set the current bounty value
virtual void updateSkillArea() = 0;
///< update display of skills, factions, birth sign, reputation and bounty
@ -303,6 +296,10 @@ namespace MWBase
virtual void startTraining(MWWorld::Ptr actor) = 0;
virtual void startRepair(MWWorld::Ptr actor) = 0;
virtual void startRepairItem(MWWorld::Ptr item) = 0;
virtual void startTravel(const MWWorld::Ptr& actor) = 0;
virtual void startSpellBuying(const MWWorld::Ptr& actor) = 0;
virtual void startTrade(const MWWorld::Ptr& actor) = 0;
virtual void openContainer(const MWWorld::Ptr& container, bool loot) = 0;
virtual void showSoulgemDialog (MWWorld::Ptr item) = 0;
@ -332,9 +329,8 @@ namespace MWBase
/// Does the current stack of GUI-windows permit saving?
virtual bool isSavingAllowed() const = 0;
/// Returns the current Modal
/** Used to send exit command to active Modal when Esc is pressed **/
virtual MWGui::WindowModal* getCurrentModal() const = 0;
/// Send exit command to active Modal window
virtual void exitCurrentModal() = 0;
/// Sets the current Modal
/** Used to send exit command to active Modal when Esc is pressed **/

@ -179,10 +179,7 @@ namespace MWDialogue
bool isCompanion = !mActor.getClass().getScript(mActor).empty()
&& mActor.getRefData().getLocals().getIntVar(mActor.getClass().getScript(mActor), "companion");
if (isCompanion)
{
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Companion);
MWBase::Environment::get().getWindowManager()->showCompanionWindow(mActor);
}
}
bool DialogueManager::compile (const std::string& cmd,std::vector<Interpreter::Type_Code>& code)

@ -7,12 +7,14 @@
#include <MyGUI_ProgressBar.h>
#include <components/widgets/list.hpp>
#include <components/translation/translation.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/dialoguemanager.hpp"
#include "../mwmechanics/npcstats.hpp"
@ -20,12 +22,7 @@
#include "../mwworld/containerstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwdialogue/dialoguemanagerimp.hpp"
#include "widgets.hpp"
#include "tradewindow.hpp"
#include "spellbuyingwindow.hpp"
#include "travelwindow.hpp"
#include "bookpage.hpp"
#include "journalbooks.hpp" // to_utf8_span
@ -337,51 +334,25 @@ namespace MWGui
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
if (topic == gmst.find("sPersuasion")->getString())
{
mPersuasionDialog.setVisible(true);
}
else if (topic == gmst.find("sCompanionShare")->getString())
{
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Companion);
MWBase::Environment::get().getWindowManager()->showCompanionWindow(mPtr);
}
else if (!MWBase::Environment::get().getDialogueManager()->checkServiceRefused())
{
if (topic == gmst.find("sBarter")->getString())
{
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Barter);
MWBase::Environment::get().getWindowManager()->getTradeWindow()->startTrade(mPtr);
}
MWBase::Environment::get().getWindowManager()->startTrade(mPtr);
else if (topic == gmst.find("sSpells")->getString())
{
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_SpellBuying);
MWBase::Environment::get().getWindowManager()->getSpellBuyingWindow()->startSpellBuying(mPtr);
}
MWBase::Environment::get().getWindowManager()->startSpellBuying(mPtr);
else if (topic == gmst.find("sTravel")->getString())
{
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Travel);
MWBase::Environment::get().getWindowManager()->getTravelWindow()->startTravel(mPtr);
}
MWBase::Environment::get().getWindowManager()->startTravel(mPtr);
else if (topic == gmst.find("sSpellMakingMenuTitle")->getString())
{
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_SpellCreation);
MWBase::Environment::get().getWindowManager()->startSpellMaking (mPtr);
}
else if (topic == gmst.find("sEnchanting")->getString())
{
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Enchanting);
MWBase::Environment::get().getWindowManager()->startEnchanting (mPtr);
}
else if (topic == gmst.find("sServiceTrainingTitle")->getString())
{
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Training);
MWBase::Environment::get().getWindowManager()->startTraining (mPtr);
}
else if (topic == gmst.find("sRepair")->getString())
{
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_MerchantRepair);
MWBase::Environment::get().getWindowManager()->startRepair (mPtr);
}
}
}
}
@ -440,8 +411,6 @@ namespace MWGui
bool isCompanion = !mPtr.getClass().getScript(mPtr).empty()
&& mPtr.getRefData().getLocals().getIntVar(mPtr.getClass().getScript(mPtr), "companion");
bool anyService = mServices > 0 || isCompanion || mPtr.getTypeName() == typeid(ESM::NPC).name();
const MWWorld::Store<ESM::GameSetting> &gmst =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
@ -472,7 +441,7 @@ namespace MWGui
if (isCompanion)
mTopicsList->addItem(gmst.find("sCompanionShare")->getString());
if (anyService)
if (mTopicsList->getItemCount() > 0)
mTopicsList->addSeparator();

@ -24,7 +24,6 @@
#include "../mwmechanics/npcstats.hpp"
#include "inventorywindow.hpp"
#include "console.hpp"
#include "spellicons.hpp"
#include "itemmodel.hpp"
#include "draganddrop.hpp"
@ -309,7 +308,7 @@ namespace MWGui
MWWorld::Ptr object = MWBase::Environment::get().getWorld()->getFacedObject();
if (mode == GM_Console)
MWBase::Environment::get().getWindowManager()->getConsole()->setSelectedObject(object);
MWBase::Environment::get().getWindowManager()->setConsoleSelectedObject(object);
else if ((mode == GM_Container) || (mode == GM_Inventory))
{
// pick up object

@ -25,7 +25,6 @@
#include "bookwindow.hpp"
#include "scrollwindow.hpp"
#include "spellwindow.hpp"
#include "itemview.hpp"
#include "inventoryitemmodel.hpp"
#include "sortfilteritemmodel.hpp"
@ -317,8 +316,7 @@ namespace MWGui
void InventoryWindow::updateItemView()
{
if (MWBase::Environment::get().getWindowManager()->getSpellWindow())
MWBase::Environment::get().getWindowManager()->getSpellWindow()->updateSpells();
MWBase::Environment::get().getWindowManager()->updateSpellWindow();
mItemView->update();
mPreviewDirty = true;
@ -568,8 +566,7 @@ namespace MWGui
void InventoryWindow::notifyContentChanged()
{
// update the spell window just in case new enchanted items were added to inventory
if (MWBase::Environment::get().getWindowManager()->getSpellWindow())
MWBase::Environment::get().getWindowManager()->getSpellWindow()->updateSpells();
MWBase::Environment::get().getWindowManager()->updateSpellWindow();
MWBase::Environment::get().getMechanicsManager()->updateMagicEffects(
MWBase::Environment::get().getWorld()->getPlayerPtr());
@ -626,8 +623,7 @@ namespace MWGui
MWBase::Environment::get().getMechanicsManager()->itemTaken(player, newObject, MWWorld::Ptr(), count);
if (MWBase::Environment::get().getWindowManager()->getSpellWindow())
MWBase::Environment::get().getWindowManager()->getSpellWindow()->updateSpells();
MWBase::Environment::get().getWindowManager()->updateSpellWindow();
}
void InventoryWindow::cycle(bool next)

@ -715,16 +715,6 @@ namespace MWGui
mPlayerMinorSkills = minor;
}
void WindowManager::setReputation (int reputation)
{
mStatsWindow->setReputation (reputation);
}
void WindowManager::setBounty (int bounty)
{
mStatsWindow->setBounty (bounty);
}
void WindowManager::updateSkillArea()
{
mStatsWindow->updateSkillArea();
@ -1287,17 +1277,12 @@ namespace MWGui
}
MWGui::DialogueWindow* WindowManager::getDialogueWindow() { return mDialogueWindow; }
MWGui::ContainerWindow* WindowManager::getContainerWindow() { return mContainerWindow; }
MWGui::InventoryWindow* WindowManager::getInventoryWindow() { return mInventoryWindow; }
MWGui::BookWindow* WindowManager::getBookWindow() { return mBookWindow; }
MWGui::ScrollWindow* WindowManager::getScrollWindow() { return mScrollWindow; }
MWGui::CountDialog* WindowManager::getCountDialog() { return mCountDialog; }
MWGui::ConfirmationDialog* WindowManager::getConfirmationDialog() { return mConfirmationDialog; }
MWGui::TradeWindow* WindowManager::getTradeWindow() { return mTradeWindow; }
MWGui::SpellBuyingWindow* WindowManager::getSpellBuyingWindow() { return mSpellBuyingWindow; }
MWGui::TravelWindow* WindowManager::getTravelWindow() { return mTravelWindow; }
MWGui::SpellWindow* WindowManager::getSpellWindow() { return mSpellWindow; }
MWGui::Console* WindowManager::getConsole() { return mConsole; }
bool WindowManager::isAllowed (GuiWindow wnd) const
{
@ -1459,11 +1444,13 @@ namespace MWGui
void WindowManager::startSpellMaking(MWWorld::Ptr actor)
{
pushGuiMode(GM_SpellCreation);
mSpellCreationDialog->startSpellMaking (actor);
}
void WindowManager::startEnchanting (MWWorld::Ptr actor)
{
pushGuiMode(GM_Enchanting);
mEnchantingDialog->startEnchanting (actor);
}
@ -1474,16 +1461,19 @@ namespace MWGui
void WindowManager::startTraining(MWWorld::Ptr actor)
{
pushGuiMode(GM_Training);
mTrainingWindow->startTraining(actor);
}
void WindowManager::startRepair(MWWorld::Ptr actor)
{
pushGuiMode(GM_MerchantRepair);
mMerchantRepair->startRepair(actor);
}
void WindowManager::startRepairItem(MWWorld::Ptr item)
{
pushGuiMode(MWGui::GM_Repair);
mRepair->startRepairItem(item);
}
@ -1494,6 +1484,7 @@ namespace MWGui
void WindowManager::showCompanionWindow(MWWorld::Ptr actor)
{
pushGuiMode(MWGui::GM_Companion);
mCompanionWindow->open(actor);
}
@ -1744,12 +1735,10 @@ namespace MWGui
mVideoWidget->autoResize(stretch);
}
WindowModal* WindowManager::getCurrentModal() const
void WindowManager::exitCurrentModal()
{
if(!mCurrentModals.empty())
return mCurrentModals.top();
else
return NULL;
if (!mCurrentModals.empty())
mCurrentModals.top()->exit();
}
void WindowManager::removeCurrentModal(WindowModal* input)
@ -1874,4 +1863,39 @@ namespace MWGui
mInventoryWindow->cycle(next);
}
void WindowManager::setConsoleSelectedObject(const MWWorld::Ptr &object)
{
mConsole->setSelectedObject(object);
}
void WindowManager::updateSpellWindow()
{
if (mSpellWindow)
mSpellWindow->updateSpells();
}
void WindowManager::startTravel(const MWWorld::Ptr &actor)
{
pushGuiMode(GM_Travel);
mTravelWindow->startTravel(actor);
}
void WindowManager::startSpellBuying(const MWWorld::Ptr &actor)
{
pushGuiMode(GM_SpellBuying);
mSpellBuyingWindow->startSpellBuying(actor);
}
void WindowManager::startTrade(const MWWorld::Ptr &actor)
{
pushGuiMode(GM_Barter);
mTradeWindow->startTrade(actor);
}
void WindowManager::openContainer(const MWWorld::Ptr &container, bool loot)
{
pushGuiMode(GM_Container);
mContainerWindow->open(container, loot);
}
}

@ -154,17 +154,16 @@ namespace MWGui
/// \todo investigate, if we really need to expose every single lousy UI element to the outside world
virtual MWGui::DialogueWindow* getDialogueWindow();
virtual MWGui::ContainerWindow* getContainerWindow();
virtual MWGui::InventoryWindow* getInventoryWindow();
virtual MWGui::BookWindow* getBookWindow();
virtual MWGui::ScrollWindow* getScrollWindow();
virtual MWGui::CountDialog* getCountDialog();
virtual MWGui::ConfirmationDialog* getConfirmationDialog();
virtual MWGui::TradeWindow* getTradeWindow();
virtual MWGui::SpellBuyingWindow* getSpellBuyingWindow();
virtual MWGui::TravelWindow* getTravelWindow();
virtual MWGui::SpellWindow* getSpellWindow();
virtual MWGui::Console* getConsole();
virtual void updateSpellWindow();
virtual void setConsoleSelectedObject(const MWWorld::Ptr& object);
virtual void wmUpdateFps(float fps, unsigned int triangleCount, unsigned int batchCount);
@ -182,8 +181,6 @@ namespace MWGui
virtual void setPlayerClass (const ESM::Class &class_); ///< set current class of player
virtual void configureSkills (const SkillList& major, const SkillList& minor); ///< configure skill groups, each set contains the skill ID for that group.
virtual void setReputation (int reputation); ///< set the current reputation value
virtual void setBounty (int bounty); ///< set the current bounty value
virtual void updateSkillArea(); ///< update display of skills, factions, birth sign, reputation and bounty
virtual void changeCell(MWWorld::CellStore* cell); ///< change the active cell
@ -292,6 +289,10 @@ namespace MWGui
virtual void startRepair(MWWorld::Ptr actor);
virtual void startRepairItem(MWWorld::Ptr item);
virtual void startRecharge(MWWorld::Ptr soulgem);
virtual void startTravel(const MWWorld::Ptr& actor);
virtual void startSpellBuying(const MWWorld::Ptr &actor);
virtual void startTrade(const MWWorld::Ptr &actor);
virtual void openContainer(const MWWorld::Ptr &container, bool loot);
virtual void frameStarted(float dt);
@ -317,9 +318,8 @@ namespace MWGui
/// Does the current stack of GUI-windows permit saving?
virtual bool isSavingAllowed() const;
/// Returns the current Modal
/** Used to send exit command to active Modal when Esc is pressed **/
virtual WindowModal* getCurrentModal() const;
/// Send exit command to active Modal window **/
virtual void exitCurrentModal();
/// Sets the current Modal
/** Used to send exit command to active Modal when Esc is pressed **/

@ -33,8 +33,6 @@
#include "../mwdialogue/dialoguemanagerimp.hpp"
#include "../mwgui/windowbase.hpp"
#include <iostream>
using namespace ICS;
@ -887,7 +885,7 @@ namespace MWInput
void InputManager::toggleMainMenu()
{
if (MyGUI::InputManager::getInstance().isModalAny()) {
MWBase::Environment::get().getWindowManager()->getCurrentModal()->exit();
MWBase::Environment::get().getWindowManager()->exitCurrentModal();
return;
}
@ -1061,7 +1059,7 @@ namespace MWInput
}
else if (MWBase::Environment::get().getWindowManager()->getMode () == MWGui::GM_QuickKeysMenu) {
while(MyGUI::InputManager::getInstance().isModalAny()) { //Handle any open Modal windows
MWBase::Environment::get().getWindowManager()->getCurrentModal()->exit();
MWBase::Environment::get().getWindowManager()->exitCurrentModal();
}
MWBase::Environment::get().getWindowManager()->exitCurrentGuiMode(); //And handle the actual main window
}

@ -3,8 +3,6 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwgui/container.hpp"
#include "../mwmechanics/disease.hpp"
#include "class.hpp"
@ -25,7 +23,6 @@ namespace MWWorld
MWMechanics::diseaseContact(actor, getTarget());
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Container);
MWBase::Environment::get().getWindowManager()->getContainerWindow()->open(getTarget(), mLoot);
MWBase::Environment::get().getWindowManager()->openContainer(getTarget(), mLoot);
}
}

@ -19,7 +19,6 @@ namespace MWWorld
return;
}
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Repair);
MWBase::Environment::get().getWindowManager()->startRepairItem(getTarget());
}
}

Loading…
Cancel
Save