2010-07-17 12:01:47 +00:00
|
|
|
#include "window_manager.hpp"
|
2010-09-14 21:17:08 +00:00
|
|
|
#include "text_input.hpp"
|
2010-10-20 19:40:32 +00:00
|
|
|
#include "review.hpp"
|
2010-11-03 20:21:08 +00:00
|
|
|
#include "dialogue.hpp"
|
|
|
|
#include "dialogue_history.hpp"
|
2012-04-01 17:39:53 +00:00
|
|
|
#include "map_window.hpp"
|
2011-01-02 16:17:33 +00:00
|
|
|
#include "stats_window.hpp"
|
2011-06-14 16:29:55 +00:00
|
|
|
#include "messagebox.hpp"
|
2012-04-15 15:52:39 +00:00
|
|
|
#include "container.hpp"
|
2012-04-21 08:51:01 +00:00
|
|
|
#include "inventorywindow.hpp"
|
2012-04-14 15:47:44 +00:00
|
|
|
#include "tooltips.hpp"
|
2012-05-03 01:33:33 +00:00
|
|
|
#include "scrollwindow.hpp"
|
|
|
|
#include "bookwindow.hpp"
|
2012-05-04 21:53:50 +00:00
|
|
|
#include "list.hpp"
|
2012-05-13 16:14:03 +00:00
|
|
|
#include "hud.hpp"
|
|
|
|
#include "mainmenu.hpp"
|
2012-05-15 10:51:51 +00:00
|
|
|
#include "countdialog.hpp"
|
2012-05-17 15:15:44 +00:00
|
|
|
#include "tradewindow.hpp"
|
2012-05-22 19:40:42 +00:00
|
|
|
#include "settingswindow.hpp"
|
2012-05-23 03:28:25 +00:00
|
|
|
#include "confirmationdialog.hpp"
|
2012-05-24 13:57:23 +00:00
|
|
|
#include "alchemywindow.hpp"
|
2010-07-17 12:01:47 +00:00
|
|
|
|
2010-09-14 19:27:40 +00:00
|
|
|
#include "../mwmechanics/mechanicsmanager.hpp"
|
2010-09-15 12:48:19 +00:00
|
|
|
#include "../mwinput/inputmanager.hpp"
|
2010-09-14 19:27:40 +00:00
|
|
|
|
2012-04-23 13:27:03 +00:00
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
|
2010-07-20 19:10:51 +00:00
|
|
|
#include "console.hpp"
|
2011-12-01 12:44:34 +00:00
|
|
|
#include "journalwindow.hpp"
|
2012-01-30 17:27:49 +00:00
|
|
|
#include "charactercreation.hpp"
|
2010-07-20 19:10:51 +00:00
|
|
|
|
2012-04-13 11:17:50 +00:00
|
|
|
#include <components/settings/settings.hpp>
|
|
|
|
|
2010-07-17 12:01:47 +00:00
|
|
|
#include <assert.h>
|
2010-08-22 09:22:10 +00:00
|
|
|
#include <iostream>
|
2010-08-22 10:56:35 +00:00
|
|
|
#include <iterator>
|
2010-07-17 12:01:47 +00:00
|
|
|
|
|
|
|
using namespace MWGui;
|
|
|
|
|
2012-04-23 13:27:03 +00:00
|
|
|
WindowManager::WindowManager(
|
2012-01-29 15:31:18 +00:00
|
|
|
const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string logpath)
|
2012-03-25 19:56:22 +00:00
|
|
|
: mGuiManager(NULL)
|
|
|
|
, hud(NULL)
|
|
|
|
, map(NULL)
|
|
|
|
, menu(NULL)
|
2012-05-19 12:19:21 +00:00
|
|
|
, mStatsWindow(NULL)
|
2012-04-14 15:47:44 +00:00
|
|
|
, mToolTips(NULL)
|
2012-03-25 19:56:22 +00:00
|
|
|
, mMessageBoxManager(NULL)
|
|
|
|
, console(NULL)
|
|
|
|
, mJournal(NULL)
|
2012-05-22 19:40:42 +00:00
|
|
|
, mDialogueWindow(NULL)
|
2012-05-03 01:33:33 +00:00
|
|
|
, mBookWindow(NULL)
|
|
|
|
, mScrollWindow(NULL)
|
2012-05-15 10:51:51 +00:00
|
|
|
, mCountDialog(NULL)
|
2012-05-17 15:15:44 +00:00
|
|
|
, mTradeWindow(NULL)
|
2012-05-22 19:40:42 +00:00
|
|
|
, mSettingsWindow(NULL)
|
2012-05-23 03:28:25 +00:00
|
|
|
, mConfirmationDialog(NULL)
|
2012-05-24 13:57:23 +00:00
|
|
|
, mAlchemyWindow(NULL)
|
2012-03-25 19:56:22 +00:00
|
|
|
, mCharGen(NULL)
|
|
|
|
, playerClass()
|
|
|
|
, playerName()
|
|
|
|
, playerRaceId()
|
|
|
|
, playerAttributes()
|
|
|
|
, playerMajorSkills()
|
|
|
|
, playerMinorSkills()
|
|
|
|
, playerSkillValues()
|
|
|
|
, playerHealth()
|
|
|
|
, playerMagicka()
|
|
|
|
, playerFatigue()
|
|
|
|
, gui(NULL)
|
|
|
|
, garbageDialogs()
|
2010-09-14 19:27:40 +00:00
|
|
|
, shown(GW_ALL)
|
|
|
|
, allowed(newGame ? GW_None : GW_ALL)
|
2012-03-25 19:56:22 +00:00
|
|
|
, showFPSLevel(fpsLevel)
|
|
|
|
, mFPS(0.0f)
|
|
|
|
, mTriangleCount(0)
|
|
|
|
, mBatchCount(0)
|
2010-07-17 12:01:47 +00:00
|
|
|
{
|
2010-11-03 20:21:08 +00:00
|
|
|
|
2012-01-29 15:31:18 +00:00
|
|
|
// Set up the GUI system
|
|
|
|
mGuiManager = new OEngine::GUI::MyGUIManager(mOgre->getWindow(), mOgre->getScene(), false, logpath);
|
|
|
|
gui = mGuiManager->getGui();
|
2012-04-27 18:54:39 +00:00
|
|
|
|
2010-11-03 20:21:08 +00:00
|
|
|
//Register own widgets with MyGUI
|
2012-03-22 14:10:29 +00:00
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<DialogueHistory>("Widget");
|
2012-05-04 21:53:50 +00:00
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSkill>("Widget");
|
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWAttribute>("Widget");
|
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSpell>("Widget");
|
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWEffectList>("Widget");
|
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSpellEffect>("Widget");
|
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWDynamicStat>("Widget");
|
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWList>("Widget");
|
2010-11-03 20:21:08 +00:00
|
|
|
|
2012-05-19 12:19:21 +00:00
|
|
|
MyGUI::LanguageManager::getInstance().eventRequestTag = MyGUI::newDelegate(this, &WindowManager::onRetrieveTag);
|
|
|
|
|
2011-01-01 21:53:34 +00:00
|
|
|
// Get size info from the Gui object
|
|
|
|
assert(gui);
|
2012-03-21 12:32:32 +00:00
|
|
|
int w = MyGUI::RenderManager::getInstance().getViewSize().width;
|
|
|
|
int h = MyGUI::RenderManager::getInstance().getViewSize().height;
|
2011-01-01 21:53:34 +00:00
|
|
|
|
2012-04-27 18:54:39 +00:00
|
|
|
MyGUI::Widget* dragAndDropWidget = gui->createWidgetT("Widget","",0,0,w,h,MyGUI::Align::Default,"DragAndDrop","DragAndDropWidget");
|
|
|
|
dragAndDropWidget->setVisible(false);
|
|
|
|
|
2012-05-18 15:58:33 +00:00
|
|
|
mDragAndDrop = new DragAndDrop();
|
2012-04-30 11:01:18 +00:00
|
|
|
mDragAndDrop->mIsOnDragAndDrop = false;
|
|
|
|
mDragAndDrop->mDraggedWidget = 0;
|
|
|
|
mDragAndDrop->mDragAndDropWidget = dragAndDropWidget;
|
|
|
|
|
2011-01-01 21:53:34 +00:00
|
|
|
menu = new MainMenu(w,h);
|
2012-04-01 17:39:53 +00:00
|
|
|
map = new MapWindow(*this);
|
2012-05-19 12:19:21 +00:00
|
|
|
mStatsWindow = new StatsWindow(*this);
|
2012-04-23 13:27:03 +00:00
|
|
|
console = new Console(w,h, extensions);
|
2011-11-28 15:51:11 +00:00
|
|
|
mJournal = new JournalWindow(*this);
|
2011-06-19 17:41:42 +00:00
|
|
|
mMessageBoxManager = new MessageBoxManager(this);
|
2012-05-17 19:56:16 +00:00
|
|
|
mInventoryWindow = new InventoryWindow(*this,mDragAndDrop);
|
2012-05-17 17:53:04 +00:00
|
|
|
mTradeWindow = new TradeWindow(*this);
|
2012-05-11 09:52:07 +00:00
|
|
|
mDialogueWindow = new DialogueWindow(*this);
|
|
|
|
mContainerWindow = new ContainerWindow(*this,mDragAndDrop);
|
2012-05-13 16:35:56 +00:00
|
|
|
hud = new HUD(w,h, showFPSLevel, mDragAndDrop);
|
2012-04-15 19:14:14 +00:00
|
|
|
mToolTips = new ToolTips(this);
|
2012-05-03 01:33:33 +00:00
|
|
|
mScrollWindow = new ScrollWindow(*this);
|
|
|
|
mBookWindow = new BookWindow(*this);
|
2012-05-15 10:51:51 +00:00
|
|
|
mCountDialog = new CountDialog(*this);
|
2012-05-22 19:40:42 +00:00
|
|
|
mSettingsWindow = new SettingsWindow(*this);
|
2012-05-23 03:28:25 +00:00
|
|
|
mConfirmationDialog = new ConfirmationDialog(*this);
|
2012-05-24 13:57:23 +00:00
|
|
|
mAlchemyWindow = new AlchemyWindow(*this);
|
2010-07-17 12:01:47 +00:00
|
|
|
|
2011-01-01 21:53:34 +00:00
|
|
|
// The HUD is always on
|
|
|
|
hud->setVisible(true);
|
2010-07-17 12:01:47 +00:00
|
|
|
|
2012-04-23 13:27:03 +00:00
|
|
|
mCharGen = new CharacterCreation(this);
|
2012-01-30 14:38:43 +00:00
|
|
|
|
2011-01-01 21:53:34 +00:00
|
|
|
// Setup player stats
|
|
|
|
for (int i = 0; i < ESM::Attribute::Length; ++i)
|
|
|
|
{
|
|
|
|
playerAttributes.insert(std::make_pair(ESM::Attribute::attributeIds[i], MWMechanics::Stat<int>()));
|
|
|
|
}
|
2010-10-21 07:28:09 +00:00
|
|
|
|
2011-01-01 21:53:34 +00:00
|
|
|
for (int i = 0; i < ESM::Skill::Length; ++i)
|
|
|
|
{
|
|
|
|
playerSkillValues.insert(std::make_pair(ESM::Skill::skillIds[i], MWMechanics::Stat<float>()));
|
|
|
|
}
|
2010-10-21 07:28:09 +00:00
|
|
|
|
2011-01-01 21:53:34 +00:00
|
|
|
// Set up visibility
|
|
|
|
updateVisible();
|
2010-07-17 12:01:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WindowManager::~WindowManager()
|
|
|
|
{
|
2012-01-29 15:31:18 +00:00
|
|
|
delete mGuiManager;
|
2011-01-01 21:53:34 +00:00
|
|
|
delete console;
|
2011-06-14 16:29:55 +00:00
|
|
|
delete mMessageBoxManager;
|
2011-01-01 21:53:34 +00:00
|
|
|
delete hud;
|
|
|
|
delete map;
|
|
|
|
delete menu;
|
2012-05-19 12:19:21 +00:00
|
|
|
delete mStatsWindow;
|
2011-11-28 15:51:11 +00:00
|
|
|
delete mJournal;
|
2012-04-30 11:01:18 +00:00
|
|
|
delete mDialogueWindow;
|
|
|
|
delete mContainerWindow;
|
2012-04-21 08:51:01 +00:00
|
|
|
delete mInventoryWindow;
|
2012-04-14 15:47:44 +00:00
|
|
|
delete mToolTips;
|
2012-01-30 19:53:17 +00:00
|
|
|
delete mCharGen;
|
2012-04-30 11:01:18 +00:00
|
|
|
delete mDragAndDrop;
|
2012-05-16 12:28:57 +00:00
|
|
|
delete mBookWindow;
|
|
|
|
delete mScrollWindow;
|
2012-05-17 15:15:44 +00:00
|
|
|
delete mTradeWindow;
|
2012-05-23 03:28:25 +00:00
|
|
|
delete mSettingsWindow;
|
|
|
|
delete mConfirmationDialog;
|
2012-05-24 13:57:23 +00:00
|
|
|
delete mAlchemyWindow;
|
2010-10-22 21:21:15 +00:00
|
|
|
|
2011-01-01 21:53:34 +00:00
|
|
|
cleanupGarbage();
|
2010-07-17 12:01:47 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 21:21:15 +00:00
|
|
|
void WindowManager::cleanupGarbage()
|
2010-10-22 20:53:34 +00:00
|
|
|
{
|
2010-10-22 21:21:15 +00:00
|
|
|
// Delete any dialogs which are no longer in use
|
2010-10-22 20:53:34 +00:00
|
|
|
if (!garbageDialogs.empty())
|
|
|
|
{
|
|
|
|
for (std::vector<OEngine::GUI::Layout*>::iterator it = garbageDialogs.begin(); it != garbageDialogs.end(); ++it)
|
|
|
|
{
|
|
|
|
delete *it;
|
|
|
|
}
|
|
|
|
garbageDialogs.clear();
|
|
|
|
}
|
2010-10-22 21:21:15 +00:00
|
|
|
}
|
2010-10-22 20:53:34 +00:00
|
|
|
|
2010-10-22 21:21:15 +00:00
|
|
|
void WindowManager::update()
|
|
|
|
{
|
|
|
|
cleanupGarbage();
|
2012-01-16 15:33:21 +00:00
|
|
|
if (showFPSLevel > 0)
|
2011-02-18 14:46:24 +00:00
|
|
|
{
|
|
|
|
hud->setFPS(mFPS);
|
2012-01-16 15:33:21 +00:00
|
|
|
hud->setTriangleCount(mTriangleCount);
|
|
|
|
hud->setBatchCount(mBatchCount);
|
2011-02-18 14:46:24 +00:00
|
|
|
}
|
2010-10-22 20:53:34 +00:00
|
|
|
}
|
|
|
|
|
2010-07-17 12:01:47 +00:00
|
|
|
void WindowManager::updateVisible()
|
|
|
|
{
|
2011-01-01 21:53:34 +00:00
|
|
|
// Start out by hiding everything except the HUD
|
|
|
|
map->setVisible(false);
|
|
|
|
menu->setVisible(false);
|
2012-05-19 12:19:21 +00:00
|
|
|
mStatsWindow->setVisible(false);
|
2011-01-01 21:53:34 +00:00
|
|
|
console->disable();
|
2011-11-28 15:51:11 +00:00
|
|
|
mJournal->setVisible(false);
|
2012-04-30 11:01:18 +00:00
|
|
|
mDialogueWindow->setVisible(false);
|
|
|
|
mContainerWindow->setVisible(false);
|
2012-04-21 08:51:01 +00:00
|
|
|
mInventoryWindow->setVisible(false);
|
2012-05-03 03:26:05 +00:00
|
|
|
mScrollWindow->setVisible(false);
|
|
|
|
mBookWindow->setVisible(false);
|
2012-05-17 19:15:48 +00:00
|
|
|
mTradeWindow->setVisible(false);
|
2012-05-22 19:40:42 +00:00
|
|
|
mSettingsWindow->setVisible(false);
|
2012-05-24 13:57:23 +00:00
|
|
|
mAlchemyWindow->setVisible(false);
|
2010-07-17 12:01:47 +00:00
|
|
|
|
2011-01-01 21:53:34 +00:00
|
|
|
// Mouse is visible whenever we're not in game mode
|
2012-03-21 12:32:32 +00:00
|
|
|
MyGUI::PointerManager::getInstance().setVisible(isGuiMode());
|
2010-07-17 12:01:47 +00:00
|
|
|
|
2012-05-23 10:23:35 +00:00
|
|
|
bool gameMode = !isGuiMode();
|
|
|
|
|
|
|
|
if (gameMode)
|
2012-04-14 15:47:44 +00:00
|
|
|
mToolTips->enterGameMode();
|
|
|
|
else
|
|
|
|
mToolTips->enterGuiMode();
|
|
|
|
|
2012-05-26 03:46:46 +00:00
|
|
|
setMinimapVisibility((allowed & GW_Map) && !map->pinned());
|
|
|
|
setWeaponVisibility((allowed & GW_Inventory) && !mInventoryWindow->pinned());
|
|
|
|
setSpellVisibility((allowed & GW_Magic)); /// \todo add pin state when spells window is implemented
|
|
|
|
setHMSVisibility((allowed & GW_Stats) && !mStatsWindow->pinned());
|
|
|
|
|
2012-05-23 10:23:35 +00:00
|
|
|
// If in game mode, don't show anything.
|
|
|
|
if (gameMode)
|
|
|
|
return;
|
|
|
|
|
|
|
|
GuiMode mode = mGuiModes.back();
|
|
|
|
|
2012-03-31 17:50:21 +00:00
|
|
|
switch(mode) {
|
|
|
|
case GM_MainMenu:
|
|
|
|
menu->setVisible(true);
|
|
|
|
break;
|
2012-05-22 19:40:42 +00:00
|
|
|
case GM_Settings:
|
|
|
|
mSettingsWindow->setVisible(true);
|
|
|
|
break;
|
2012-03-31 17:50:21 +00:00
|
|
|
case GM_Console:
|
|
|
|
console->enable();
|
|
|
|
break;
|
2012-05-03 03:26:05 +00:00
|
|
|
case GM_Scroll:
|
|
|
|
mScrollWindow->setVisible(true);
|
|
|
|
break;
|
|
|
|
case GM_Book:
|
|
|
|
mBookWindow->setVisible(true);
|
|
|
|
break;
|
2012-05-24 13:57:23 +00:00
|
|
|
case GM_Alchemy:
|
|
|
|
mAlchemyWindow->setVisible(true);
|
|
|
|
break;
|
2012-03-31 17:50:21 +00:00
|
|
|
case GM_Name:
|
|
|
|
case GM_Race:
|
|
|
|
case GM_Class:
|
|
|
|
case GM_ClassPick:
|
|
|
|
case GM_ClassCreate:
|
|
|
|
case GM_Birth:
|
|
|
|
case GM_ClassGenerate:
|
|
|
|
case GM_Review:
|
|
|
|
mCharGen->spawnDialog(mode);
|
|
|
|
break;
|
|
|
|
case GM_Inventory:
|
2012-03-31 19:29:46 +00:00
|
|
|
{
|
2012-03-31 17:50:21 +00:00
|
|
|
// First, compute the effective set of windows to show.
|
|
|
|
// This is controlled both by what windows the
|
|
|
|
// user has opened/closed (the 'shown' variable) and by what
|
|
|
|
// windows we are allowed to show (the 'allowed' var.)
|
2012-03-31 19:29:46 +00:00
|
|
|
int eff = shown & allowed;
|
2012-03-31 17:50:21 +00:00
|
|
|
|
|
|
|
// Show the windows we want
|
2012-05-26 19:09:21 +00:00
|
|
|
map -> setVisible( (eff & GW_Map) );
|
|
|
|
mStatsWindow -> setVisible( (eff & GW_Stats) );
|
|
|
|
mInventoryWindow->setVisible( (eff & GW_Inventory));
|
2012-03-31 17:50:21 +00:00
|
|
|
break;
|
2011-06-19 17:10:44 +00:00
|
|
|
}
|
2012-04-15 17:32:41 +00:00
|
|
|
case GM_Container:
|
2012-04-30 11:01:18 +00:00
|
|
|
mContainerWindow->setVisible(true);
|
2012-04-21 08:51:01 +00:00
|
|
|
mInventoryWindow->setVisible(true);
|
2012-04-15 17:32:41 +00:00
|
|
|
break;
|
2012-03-31 17:50:21 +00:00
|
|
|
case GM_Dialogue:
|
2012-05-23 10:23:35 +00:00
|
|
|
mDialogueWindow->setVisible(true);
|
2012-03-31 17:50:21 +00:00
|
|
|
break;
|
2012-05-17 19:15:48 +00:00
|
|
|
case GM_Barter:
|
|
|
|
mInventoryWindow->setVisible(true);
|
|
|
|
mTradeWindow->setVisible(true);
|
|
|
|
break;
|
2012-03-31 17:50:21 +00:00
|
|
|
case GM_InterMessageBox:
|
|
|
|
break;
|
|
|
|
case GM_Journal:
|
|
|
|
mJournal->setVisible(true);
|
|
|
|
mJournal->open();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// Unsupported mode, switch back to game
|
|
|
|
break;
|
2011-11-28 15:51:11 +00:00
|
|
|
}
|
2010-07-17 12:01:47 +00:00
|
|
|
}
|
2010-07-26 09:15:38 +00:00
|
|
|
|
2010-07-27 13:59:41 +00:00
|
|
|
void WindowManager::setValue (const std::string& id, const MWMechanics::Stat<int>& value)
|
|
|
|
{
|
2012-05-19 12:19:21 +00:00
|
|
|
mStatsWindow->setValue (id, value);
|
2010-10-21 07:28:09 +00:00
|
|
|
|
|
|
|
static const char *ids[] =
|
|
|
|
{
|
|
|
|
"AttribVal1", "AttribVal2", "AttribVal3", "AttribVal4", "AttribVal5",
|
|
|
|
"AttribVal6", "AttribVal7", "AttribVal8"
|
|
|
|
};
|
|
|
|
static ESM::Attribute::AttributeID attributes[] =
|
|
|
|
{
|
|
|
|
ESM::Attribute::Strength,
|
|
|
|
ESM::Attribute::Intelligence,
|
|
|
|
ESM::Attribute::Willpower,
|
|
|
|
ESM::Attribute::Agility,
|
|
|
|
ESM::Attribute::Speed,
|
|
|
|
ESM::Attribute::Endurance,
|
|
|
|
ESM::Attribute::Personality,
|
|
|
|
ESM::Attribute::Luck
|
|
|
|
};
|
2010-11-01 17:56:09 +00:00
|
|
|
for (size_t i = 0; i < sizeof(ids)/sizeof(ids[0]); ++i)
|
2010-10-21 07:28:09 +00:00
|
|
|
{
|
|
|
|
if (id != ids[i])
|
|
|
|
continue;
|
|
|
|
playerAttributes[attributes[i]] = value;
|
|
|
|
break;
|
|
|
|
}
|
2010-07-27 13:59:41 +00:00
|
|
|
}
|
|
|
|
|
2010-10-21 07:28:09 +00:00
|
|
|
|
2011-01-02 16:35:03 +00:00
|
|
|
void WindowManager::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value)
|
|
|
|
{
|
2012-05-19 12:19:21 +00:00
|
|
|
mStatsWindow->setValue(parSkill, value);
|
2011-01-02 16:35:03 +00:00
|
|
|
playerSkillValues[parSkill] = value;
|
2010-09-18 16:04:53 +00:00
|
|
|
}
|
|
|
|
|
2010-07-28 16:48:01 +00:00
|
|
|
void WindowManager::setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value)
|
|
|
|
{
|
2012-05-19 12:19:21 +00:00
|
|
|
mStatsWindow->setValue (id, value);
|
2010-07-28 16:48:01 +00:00
|
|
|
hud->setValue (id, value);
|
2010-10-21 07:28:09 +00:00
|
|
|
if (id == "HBar")
|
2012-02-03 10:24:28 +00:00
|
|
|
{
|
2010-10-21 07:28:09 +00:00
|
|
|
playerHealth = value;
|
2012-02-03 10:24:28 +00:00
|
|
|
mCharGen->setPlayerHealth (value);
|
|
|
|
}
|
2010-10-21 07:28:09 +00:00
|
|
|
else if (id == "MBar")
|
2012-02-03 10:24:28 +00:00
|
|
|
{
|
2010-10-21 07:28:09 +00:00
|
|
|
playerMagicka = value;
|
2012-02-03 10:24:28 +00:00
|
|
|
mCharGen->setPlayerMagicka (value);
|
|
|
|
}
|
2010-10-21 07:28:09 +00:00
|
|
|
else if (id == "FBar")
|
2012-02-03 10:24:28 +00:00
|
|
|
{
|
2010-10-21 07:28:09 +00:00
|
|
|
playerFatigue = value;
|
2012-02-03 10:24:28 +00:00
|
|
|
mCharGen->setPlayerFatigue (value);
|
|
|
|
}
|
2010-07-28 16:48:01 +00:00
|
|
|
}
|
2010-08-22 09:22:10 +00:00
|
|
|
|
2012-02-03 10:24:28 +00:00
|
|
|
#if 0
|
2012-01-30 19:53:17 +00:00
|
|
|
MWMechanics::DynamicStat<int> WindowManager::getValue(const std::string& id)
|
|
|
|
{
|
|
|
|
if(id == "HBar")
|
|
|
|
return playerHealth;
|
|
|
|
else if (id == "MBar")
|
|
|
|
return playerMagicka;
|
|
|
|
else if (id == "FBar")
|
|
|
|
return playerFatigue;
|
|
|
|
}
|
2012-02-03 10:24:28 +00:00
|
|
|
#endif
|
2012-01-30 19:53:17 +00:00
|
|
|
|
2010-09-15 10:22:06 +00:00
|
|
|
void WindowManager::setValue (const std::string& id, const std::string& value)
|
|
|
|
{
|
2012-05-19 12:19:21 +00:00
|
|
|
mStatsWindow->setValue (id, value);
|
2010-10-21 07:28:09 +00:00
|
|
|
if (id=="name")
|
|
|
|
playerName = value;
|
|
|
|
else if (id=="race")
|
|
|
|
playerRaceId = value;
|
2010-09-15 10:22:06 +00:00
|
|
|
}
|
|
|
|
|
2010-09-15 13:32:35 +00:00
|
|
|
void WindowManager::setValue (const std::string& id, int value)
|
|
|
|
{
|
2012-05-19 12:19:21 +00:00
|
|
|
mStatsWindow->setValue (id, value);
|
2010-09-15 13:32:35 +00:00
|
|
|
}
|
|
|
|
|
2010-10-21 07:28:09 +00:00
|
|
|
void WindowManager::setPlayerClass (const ESM::Class &class_)
|
|
|
|
{
|
|
|
|
playerClass = class_;
|
2012-05-19 12:19:21 +00:00
|
|
|
mStatsWindow->setValue("class", playerClass.name);
|
2010-10-21 07:28:09 +00:00
|
|
|
}
|
|
|
|
|
2010-09-18 17:26:45 +00:00
|
|
|
void WindowManager::configureSkills (const SkillList& major, const SkillList& minor)
|
2010-09-17 23:30:23 +00:00
|
|
|
{
|
2012-05-19 12:19:21 +00:00
|
|
|
mStatsWindow->configureSkills (major, minor);
|
2010-10-21 07:28:09 +00:00
|
|
|
playerMajorSkills = major;
|
|
|
|
playerMinorSkills = minor;
|
2010-09-17 23:30:23 +00:00
|
|
|
}
|
|
|
|
|
2010-09-18 00:24:42 +00:00
|
|
|
void WindowManager::setReputation (int reputation)
|
|
|
|
{
|
2012-05-19 12:19:21 +00:00
|
|
|
mStatsWindow->setReputation (reputation);
|
2010-09-18 00:24:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WindowManager::setBounty (int bounty)
|
|
|
|
{
|
2012-05-19 12:19:21 +00:00
|
|
|
mStatsWindow->setBounty (bounty);
|
2010-09-18 00:24:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WindowManager::updateSkillArea()
|
|
|
|
{
|
2012-05-19 12:19:21 +00:00
|
|
|
mStatsWindow->updateSkillArea();
|
2010-09-18 00:24:42 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 21:14:21 +00:00
|
|
|
void WindowManager::removeDialog(OEngine::GUI::Layout*dialog)
|
|
|
|
{
|
|
|
|
assert(dialog);
|
|
|
|
if (!dialog)
|
|
|
|
return;
|
|
|
|
dialog->setVisible(false);
|
|
|
|
garbageDialogs.push_back(dialog);
|
|
|
|
}
|
|
|
|
|
2010-08-22 09:22:10 +00:00
|
|
|
void WindowManager::messageBox (const std::string& message, const std::vector<std::string>& buttons)
|
|
|
|
{
|
2011-06-14 16:29:55 +00:00
|
|
|
if (buttons.empty())
|
|
|
|
{
|
|
|
|
mMessageBoxManager->createMessageBox(message);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mMessageBoxManager->createInteractiveMessageBox(message, buttons);
|
2012-05-23 10:23:35 +00:00
|
|
|
pushGuiMode(GM_InterMessageBox);
|
2010-08-22 10:56:35 +00:00
|
|
|
}
|
2010-08-22 09:22:10 +00:00
|
|
|
}
|
2010-09-14 17:33:40 +00:00
|
|
|
|
2011-07-12 18:05:04 +00:00
|
|
|
int WindowManager::readPressedButton ()
|
|
|
|
{
|
|
|
|
return mMessageBoxManager->readPressedButton();
|
|
|
|
}
|
|
|
|
|
2010-09-15 20:22:27 +00:00
|
|
|
const std::string &WindowManager::getGameSettingString(const std::string &id, const std::string &default_)
|
2010-09-15 10:41:53 +00:00
|
|
|
{
|
2012-04-23 13:27:03 +00:00
|
|
|
const ESM::GameSetting *setting = MWBase::Environment::get().getWorld()->getStore().gameSettings.search(id);
|
2010-09-15 10:41:53 +00:00
|
|
|
if (setting && setting->type == ESM::VT_String)
|
|
|
|
return setting->str;
|
2010-09-15 20:22:27 +00:00
|
|
|
return default_;
|
2010-09-15 10:41:53 +00:00
|
|
|
}
|
|
|
|
|
2010-11-03 20:21:08 +00:00
|
|
|
void WindowManager::onDialogueWindowBye()
|
|
|
|
{
|
2012-04-30 11:01:18 +00:00
|
|
|
if (mDialogueWindow)
|
2010-11-03 20:21:08 +00:00
|
|
|
{
|
|
|
|
//FIXME set some state and stuff?
|
2012-02-05 09:54:56 +00:00
|
|
|
//removeDialog(dialogueWindow);
|
2012-04-30 11:01:18 +00:00
|
|
|
mDialogueWindow->setVisible(false);
|
2010-11-03 20:21:08 +00:00
|
|
|
}
|
2012-05-23 10:23:35 +00:00
|
|
|
popGuiMode();
|
2010-11-03 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2011-06-15 20:53:05 +00:00
|
|
|
void WindowManager::onFrame (float frameDuration)
|
|
|
|
{
|
|
|
|
mMessageBoxManager->onFrame(frameDuration);
|
2012-04-14 15:47:44 +00:00
|
|
|
mToolTips->onFrame(frameDuration);
|
2012-05-18 15:58:33 +00:00
|
|
|
|
|
|
|
if (mDragAndDrop->mIsOnDragAndDrop)
|
|
|
|
{
|
|
|
|
assert(mDragAndDrop->mDraggedWidget);
|
|
|
|
mDragAndDrop->mDraggedWidget->setPosition(MyGUI::InputManager::getInstance().getMousePosition());
|
|
|
|
}
|
|
|
|
|
2012-05-19 12:55:09 +00:00
|
|
|
mInventoryWindow->onFrame();
|
2012-05-19 12:19:21 +00:00
|
|
|
|
|
|
|
mStatsWindow->onFrame();
|
2011-06-15 20:53:05 +00:00
|
|
|
}
|
|
|
|
|
2011-04-21 08:49:45 +00:00
|
|
|
const ESMS::ESMStore& WindowManager::getStore() const
|
2011-02-21 19:36:35 +00:00
|
|
|
{
|
2012-04-23 13:27:03 +00:00
|
|
|
return MWBase::Environment::get().getWorld()->getStore();
|
2011-02-21 19:36:35 +00:00
|
|
|
}
|
2012-03-10 15:05:12 +00:00
|
|
|
|
2012-03-16 16:09:31 +00:00
|
|
|
void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell)
|
2012-03-10 15:05:12 +00:00
|
|
|
{
|
2012-03-16 16:09:31 +00:00
|
|
|
if (!(cell->cell->data.flags & ESM::Cell::Interior))
|
|
|
|
{
|
2012-03-23 15:51:56 +00:00
|
|
|
std::string name;
|
2012-03-16 16:09:31 +00:00
|
|
|
if (cell->cell->name != "")
|
2012-03-23 15:51:56 +00:00
|
|
|
name = cell->cell->name;
|
2012-03-16 16:09:31 +00:00
|
|
|
else
|
2012-04-17 16:47:51 +00:00
|
|
|
{
|
2012-04-24 00:02:03 +00:00
|
|
|
const ESM::Region* region = MWBase::Environment::get().getWorld()->getStore().regions.search(cell->cell->region);
|
2012-05-17 16:14:33 +00:00
|
|
|
if (region)
|
|
|
|
name = region->name;
|
2012-05-17 21:42:09 +00:00
|
|
|
else
|
|
|
|
name = getGameSettingString("sDefaultCellname", "Wilderness");
|
2012-04-17 16:47:51 +00:00
|
|
|
}
|
2012-03-23 15:51:56 +00:00
|
|
|
|
|
|
|
map->setCellName( name );
|
|
|
|
|
2012-03-16 16:09:31 +00:00
|
|
|
map->setCellPrefix("Cell");
|
2012-03-23 15:51:56 +00:00
|
|
|
hud->setCellPrefix("Cell");
|
2012-03-16 16:09:31 +00:00
|
|
|
map->setActiveCell( cell->cell->data.gridX, cell->cell->data.gridY );
|
2012-03-23 15:51:56 +00:00
|
|
|
hud->setActiveCell( cell->cell->data.gridX, cell->cell->data.gridY );
|
2012-03-16 16:09:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
map->setCellName( cell->cell->name );
|
|
|
|
map->setCellPrefix( cell->cell->name );
|
2012-03-23 15:51:56 +00:00
|
|
|
hud->setCellPrefix( cell->cell->name );
|
2012-03-16 16:09:31 +00:00
|
|
|
}
|
|
|
|
|
2012-03-10 15:05:12 +00:00
|
|
|
}
|
2012-03-17 12:59:51 +00:00
|
|
|
|
|
|
|
void WindowManager::setInteriorMapTexture(const int x, const int y)
|
|
|
|
{
|
|
|
|
map->setActiveCell(x,y, true);
|
2012-03-23 15:51:56 +00:00
|
|
|
hud->setActiveCell(x,y, true);
|
2012-03-17 12:59:51 +00:00
|
|
|
}
|
2012-03-23 07:16:04 +00:00
|
|
|
|
|
|
|
void WindowManager::setPlayerPos(const float x, const float y)
|
|
|
|
{
|
|
|
|
map->setPlayerPos(x,y);
|
2012-03-23 15:51:56 +00:00
|
|
|
hud->setPlayerPos(x,y);
|
2012-03-23 07:16:04 +00:00
|
|
|
}
|
2012-03-23 14:00:48 +00:00
|
|
|
|
|
|
|
void WindowManager::setPlayerDir(const float x, const float y)
|
|
|
|
{
|
|
|
|
map->setPlayerDir(x,y);
|
2012-03-23 14:26:24 +00:00
|
|
|
hud->setPlayerDir(x,y);
|
2012-03-23 14:00:48 +00:00
|
|
|
}
|
2012-04-05 22:17:23 +00:00
|
|
|
|
|
|
|
void WindowManager::setHMSVisibility(bool visible)
|
|
|
|
{
|
|
|
|
hud->setBottomLeftVisibility(visible, hud->weapBox->getVisible(), hud->spellBox->getVisible());
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowManager::setMinimapVisibility(bool visible)
|
|
|
|
{
|
|
|
|
hud->setBottomRightVisibility(hud->effectBox->getVisible(), visible);
|
|
|
|
}
|
2012-04-07 14:30:20 +00:00
|
|
|
|
2012-03-29 17:45:19 +00:00
|
|
|
void WindowManager::toggleFogOfWar()
|
|
|
|
{
|
|
|
|
map->toggleFogOfWar();
|
|
|
|
hud->toggleFogOfWar();
|
|
|
|
}
|
2012-04-13 11:17:50 +00:00
|
|
|
|
2012-04-15 15:10:08 +00:00
|
|
|
void WindowManager::setFocusObject(const MWWorld::Ptr& focus)
|
|
|
|
{
|
|
|
|
mToolTips->setFocusObject(focus);
|
|
|
|
}
|
2012-04-16 13:00:44 +00:00
|
|
|
|
2012-05-14 19:37:43 +00:00
|
|
|
void WindowManager::setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y)
|
|
|
|
{
|
|
|
|
mToolTips->setFocusObjectScreenCoords(min_x, min_y, max_x, max_y);
|
|
|
|
}
|
|
|
|
|
2012-04-16 13:00:44 +00:00
|
|
|
void WindowManager::toggleFullHelp()
|
|
|
|
{
|
|
|
|
mToolTips->toggleFullHelp();
|
|
|
|
}
|
2012-04-16 20:58:16 +00:00
|
|
|
|
|
|
|
bool WindowManager::getFullHelp() const
|
|
|
|
{
|
|
|
|
return mToolTips->getFullHelp();
|
|
|
|
}
|
2012-05-12 20:44:12 +00:00
|
|
|
|
|
|
|
void WindowManager::setWeaponVisibility(bool visible)
|
|
|
|
{
|
2012-05-26 03:46:46 +00:00
|
|
|
hud->setBottomLeftVisibility(hud->health->getVisible(), visible, hud->spellBox->getVisible());
|
2012-05-12 20:44:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WindowManager::setSpellVisibility(bool visible)
|
|
|
|
{
|
2012-05-26 03:46:46 +00:00
|
|
|
hud->setBottomLeftVisibility(hud->health->getVisible(), hud->weapBox->getVisible(), visible);
|
|
|
|
hud->setBottomRightVisibility(visible, hud->minimapBox->getVisible());
|
2012-05-12 20:44:12 +00:00
|
|
|
}
|
2012-05-13 08:18:17 +00:00
|
|
|
|
|
|
|
void WindowManager::setMouseVisible(bool visible)
|
|
|
|
{
|
|
|
|
MyGUI::PointerManager::getInstance().setVisible(visible);
|
|
|
|
}
|
2012-05-13 09:25:35 +00:00
|
|
|
|
|
|
|
void WindowManager::setDragDrop(bool dragDrop)
|
|
|
|
{
|
|
|
|
mToolTips->setEnabled(!dragDrop);
|
|
|
|
MWBase::Environment::get().getInputManager()->setDragDrop(dragDrop);
|
|
|
|
}
|
2012-05-19 12:19:21 +00:00
|
|
|
|
|
|
|
void WindowManager::onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _result)
|
|
|
|
{
|
|
|
|
const ESM::GameSetting *setting = MWBase::Environment::get().getWorld()->getStore().gameSettings.search(_tag);
|
|
|
|
if (setting && setting->type == ESM::VT_String)
|
|
|
|
_result = setting->str;
|
2012-05-24 01:50:02 +00:00
|
|
|
else
|
|
|
|
_result = _tag;
|
2012-05-19 12:19:21 +00:00
|
|
|
}
|
2012-05-24 09:50:48 +00:00
|
|
|
|
|
|
|
void WindowManager::processChangedSettings(const Settings::CategorySettingVector& changed)
|
|
|
|
{
|
|
|
|
hud->setFpsLevel(Settings::Manager::getInt("fps", "HUD"));
|
|
|
|
}
|
2012-05-23 10:23:35 +00:00
|
|
|
|
|
|
|
void WindowManager::pushGuiMode(GuiMode mode)
|
|
|
|
{
|
|
|
|
if (mode==GM_Inventory && allowed==GW_None)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mGuiModes.push_back(mode);
|
|
|
|
|
|
|
|
bool gameMode = !isGuiMode();
|
|
|
|
MWBase::Environment::get().getInputManager()->changeInputMode(!gameMode);
|
|
|
|
|
|
|
|
updateVisible();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowManager::popGuiMode()
|
|
|
|
{
|
|
|
|
if (mGuiModes.size())
|
|
|
|
mGuiModes.pop_back();
|
|
|
|
|
|
|
|
bool gameMode = !isGuiMode();
|
|
|
|
MWBase::Environment::get().getInputManager()->changeInputMode(!gameMode);
|
|
|
|
|
|
|
|
updateVisible();
|
|
|
|
}
|