mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 14:39:42 +00:00
Merge pull request #2874 from akortunov/windowmanager
Cleanup WindowManager
This commit is contained in:
commit
f36288569c
9 changed files with 83 additions and 157 deletions
|
@ -45,7 +45,7 @@ add_openmw_dir (mwgui
|
|||
itemmodel containeritemmodel inventoryitemmodel sortfilteritemmodel itemview
|
||||
tradeitemmodel companionitemmodel pickpocketitemmodel controllers savegamedialog
|
||||
recharge mode videowidget backgroundimage itemwidget screenfader debugwindow spellmodel spellview
|
||||
draganddrop timeadvancer jailscreen itemchargeview keyboardnavigation
|
||||
draganddrop timeadvancer jailscreen itemchargeview keyboardnavigation textcolours
|
||||
)
|
||||
|
||||
add_openmw_dir (mwdialogue
|
||||
|
|
|
@ -181,7 +181,7 @@ bool OMW::Engine::frame(float frametime)
|
|||
osg::Timer_t afterWorldTick = osg::Timer::instance()->tick();
|
||||
|
||||
// update GUI
|
||||
mEnvironment.getWindowManager()->onFrame(frametime);
|
||||
mEnvironment.getWindowManager()->update(frametime);
|
||||
|
||||
unsigned int frameNumber = mViewer->getFrameStamp()->getFrameNumber();
|
||||
osg::Stats* stats = mViewer->getViewerStats();
|
||||
|
|
|
@ -251,13 +251,7 @@ namespace MWBase
|
|||
/// returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
||||
virtual int readPressedButton() = 0;
|
||||
|
||||
virtual void onFrame (float frameDuration) = 0;
|
||||
|
||||
/// \todo get rid of this stuff. Move it to the respective UI element classes, if needed.
|
||||
virtual std::map<int, MWMechanics::SkillValue > getPlayerSkillValues() = 0;
|
||||
virtual std::map<int, MWMechanics::AttributeValue > getPlayerAttributeValues() = 0;
|
||||
virtual SkillList getPlayerMinorSkills() = 0;
|
||||
virtual SkillList getPlayerMajorSkills() = 0;
|
||||
virtual void update (float duration) = 0;
|
||||
|
||||
/**
|
||||
* Fetches a GMST string from the store, if there is no setting with the given
|
||||
|
|
|
@ -105,23 +105,32 @@ namespace MWGui
|
|||
mGenerateClassSpecializations[0] = 0;
|
||||
mGenerateClassSpecializations[1] = 0;
|
||||
mGenerateClassSpecializations[2] = 0;
|
||||
|
||||
// Setup player stats
|
||||
for (int i = 0; i < ESM::Attribute::Length; ++i)
|
||||
mPlayerAttributes.emplace(ESM::Attribute::sAttributeIds[i], MWMechanics::AttributeValue());
|
||||
|
||||
for (int i = 0; i < ESM::Skill::Length; ++i)
|
||||
mPlayerSkillValues.emplace(ESM::Skill::sSkillIds[i], MWMechanics::SkillValue());
|
||||
}
|
||||
|
||||
void CharacterCreation::setValue (const std::string& id, const MWMechanics::AttributeValue& value)
|
||||
{
|
||||
if (mReviewDialog)
|
||||
static const char *ids[] =
|
||||
{
|
||||
static const char *ids[] =
|
||||
{
|
||||
"AttribVal1", "AttribVal2", "AttribVal3", "AttribVal4", "AttribVal5",
|
||||
"AttribVal6", "AttribVal7", "AttribVal8",
|
||||
0
|
||||
};
|
||||
"AttribVal1", "AttribVal2", "AttribVal3", "AttribVal4",
|
||||
"AttribVal5", "AttribVal6", "AttribVal7", "AttribVal8", 0
|
||||
};
|
||||
|
||||
for (int i=0; ids[i]; ++i)
|
||||
for (int i=0; ids[i]; ++i)
|
||||
{
|
||||
if (ids[i]==id)
|
||||
{
|
||||
if (ids[i]==id)
|
||||
mReviewDialog->setAttribute(ESM::Attribute::AttributeID(i), value);
|
||||
mPlayerAttributes[static_cast<ESM::Attribute::AttributeID>(i)] = value;
|
||||
if (mReviewDialog)
|
||||
mReviewDialog->setAttribute(static_cast<ESM::Attribute::AttributeID>(i), value);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -147,6 +156,7 @@ namespace MWGui
|
|||
|
||||
void CharacterCreation::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::SkillValue& value)
|
||||
{
|
||||
mPlayerSkillValues[parSkill] = value;
|
||||
if (mReviewDialog)
|
||||
mReviewDialog->setSkillValue(parSkill, value);
|
||||
}
|
||||
|
@ -155,6 +165,9 @@ namespace MWGui
|
|||
{
|
||||
if (mReviewDialog)
|
||||
mReviewDialog->configureSkills(major, minor);
|
||||
|
||||
mPlayerMajorSkills = major;
|
||||
mPlayerMinorSkills = minor;
|
||||
}
|
||||
|
||||
void CharacterCreation::onFrame(float duration)
|
||||
|
@ -269,31 +282,21 @@ namespace MWGui
|
|||
mReviewDialog->setClass(*playerClass);
|
||||
mReviewDialog->setBirthSign(player.getBirthSign());
|
||||
|
||||
{
|
||||
MWWorld::Ptr playerPtr = MWMechanics::getPlayer();
|
||||
const MWMechanics::CreatureStats& stats = playerPtr.getClass().getCreatureStats(playerPtr);
|
||||
|
||||
mReviewDialog->setHealth ( stats.getHealth() );
|
||||
mReviewDialog->setMagicka( stats.getMagicka() );
|
||||
mReviewDialog->setFatigue( stats.getFatigue() );
|
||||
}
|
||||
MWWorld::Ptr playerPtr = MWMechanics::getPlayer();
|
||||
const MWMechanics::CreatureStats& stats = playerPtr.getClass().getCreatureStats(playerPtr);
|
||||
|
||||
mReviewDialog->setHealth(stats.getHealth());
|
||||
mReviewDialog->setMagicka(stats.getMagicka());
|
||||
mReviewDialog->setFatigue(stats.getFatigue());
|
||||
for (auto& attributePair : mPlayerAttributes)
|
||||
{
|
||||
std::map<int, MWMechanics::AttributeValue > attributes = MWBase::Environment::get().getWindowManager()->getPlayerAttributeValues();
|
||||
for (auto& attributePair : attributes)
|
||||
{
|
||||
mReviewDialog->setAttribute(static_cast<ESM::Attribute::AttributeID> (attributePair.first), attributePair.second);
|
||||
}
|
||||
mReviewDialog->setAttribute(static_cast<ESM::Attribute::AttributeID> (attributePair.first), attributePair.second);
|
||||
}
|
||||
|
||||
for (auto& skillPair : mPlayerSkillValues)
|
||||
{
|
||||
std::map<int, MWMechanics::SkillValue > skills = MWBase::Environment::get().getWindowManager()->getPlayerSkillValues();
|
||||
for (auto& skillPair : skills)
|
||||
{
|
||||
mReviewDialog->setSkillValue(static_cast<ESM::Skill::SkillEnum> (skillPair.first), skillPair.second);
|
||||
}
|
||||
mReviewDialog->configureSkills(MWBase::Environment::get().getWindowManager()->getPlayerMajorSkills(), MWBase::Environment::get().getWindowManager()->getPlayerMinorSkills());
|
||||
mReviewDialog->setSkillValue(static_cast<ESM::Skill::SkillEnum> (skillPair.first), skillPair.second);
|
||||
}
|
||||
mReviewDialog->configureSkills(mPlayerMajorSkills, mPlayerMinorSkills);
|
||||
|
||||
mReviewDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogDone);
|
||||
mReviewDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogBack);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <components/esm/loadskil.hpp>
|
||||
#include <components/esm/loadclas.hpp>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "../mwmechanics/stat.hpp"
|
||||
|
@ -56,6 +57,10 @@ namespace MWGui
|
|||
osg::Group* mParent;
|
||||
Resource::ResourceSystem* mResourceSystem;
|
||||
|
||||
SkillList mPlayerMajorSkills, mPlayerMinorSkills;
|
||||
std::map<int, MWMechanics::AttributeValue> mPlayerAttributes;
|
||||
std::map<int, MWMechanics::SkillValue> mPlayerSkillValues;
|
||||
|
||||
//Dialogs
|
||||
TextInputDialog* mNameDialog;
|
||||
RaceDialog* mRaceDialog;
|
||||
|
|
36
apps/openmw/mwgui/textcolours.cpp
Normal file
36
apps/openmw/mwgui/textcolours.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "textcolours.hpp"
|
||||
|
||||
#include <MyGUI_LanguageManager.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
MyGUI::Colour getTextColour(const std::string& type)
|
||||
{
|
||||
return MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=" + type + "}"));
|
||||
}
|
||||
|
||||
void TextColours::loadColours()
|
||||
{
|
||||
header = getTextColour("header");
|
||||
normal = getTextColour("normal");
|
||||
notify = getTextColour("notify");
|
||||
|
||||
link = getTextColour("link");
|
||||
linkOver = getTextColour("link_over");
|
||||
linkPressed = getTextColour("link_pressed");
|
||||
|
||||
answer = getTextColour("answer");
|
||||
answerOver = getTextColour("answer_over");
|
||||
answerPressed = getTextColour("answer_pressed");
|
||||
|
||||
journalLink = getTextColour("journal_link");
|
||||
journalLinkOver = getTextColour("journal_link_over");
|
||||
journalLinkPressed = getTextColour("journal_link_pressed");
|
||||
|
||||
journalTopic = getTextColour("journal_topic");
|
||||
journalTopicOver = getTextColour("journal_topic_over");
|
||||
journalTopicPressed = getTextColour("journal_topic_pressed");
|
||||
}
|
||||
}
|
|
@ -5,14 +5,12 @@
|
|||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
struct TextColours
|
||||
{
|
||||
MyGUI::Colour header;
|
||||
MyGUI::Colour normal;
|
||||
MyGUI::Colour notify;
|
||||
|
||||
|
||||
MyGUI::Colour link;
|
||||
MyGUI::Colour linkOver;
|
||||
MyGUI::Colour linkPressed;
|
||||
|
@ -28,6 +26,9 @@ namespace MWGui
|
|||
MyGUI::Colour journalTopic;
|
||||
MyGUI::Colour journalTopicOver;
|
||||
MyGUI::Colour journalTopicPressed;
|
||||
|
||||
public:
|
||||
void loadColours();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -117,19 +117,8 @@
|
|||
#include "keyboardnavigation.hpp"
|
||||
#include "resourceskin.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
MyGUI::Colour getTextColour(const std::string& type)
|
||||
{
|
||||
return MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=" + type + "}"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
WindowManager::WindowManager(
|
||||
SDL_Window* window, osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue,
|
||||
const std::string& logpath, const std::string& resourcePath, bool consoleOnlyScripts, Translation::Storage& translationDataStorage,
|
||||
|
@ -182,12 +171,6 @@ namespace MWGui
|
|||
, mCursorVisible(true)
|
||||
, mCursorActive(false)
|
||||
, mPlayerBounty(-1)
|
||||
, mPlayerName()
|
||||
, mPlayerRaceId()
|
||||
, mPlayerAttributes()
|
||||
, mPlayerMajorSkills()
|
||||
, mPlayerMinorSkills()
|
||||
, mPlayerSkillValues()
|
||||
, mGui(nullptr)
|
||||
, mGuiModes()
|
||||
, mCursorManager(nullptr)
|
||||
|
@ -398,26 +381,7 @@ namespace MWGui
|
|||
int w = MyGUI::RenderManager::getInstance().getViewSize().width;
|
||||
int h = MyGUI::RenderManager::getInstance().getViewSize().height;
|
||||
|
||||
mTextColours.header = getTextColour("header");
|
||||
mTextColours.normal = getTextColour("normal");
|
||||
mTextColours.notify = getTextColour("notify");
|
||||
|
||||
mTextColours.link = getTextColour("link");
|
||||
mTextColours.linkOver = getTextColour("link_over");
|
||||
mTextColours.linkPressed = getTextColour("link_pressed");
|
||||
|
||||
mTextColours.answer = getTextColour("answer");
|
||||
mTextColours.answerOver = getTextColour("answer_over");
|
||||
mTextColours.answerPressed = getTextColour("answer_pressed");
|
||||
|
||||
mTextColours.journalLink = getTextColour("journal_link");
|
||||
mTextColours.journalLinkOver = getTextColour("journal_link_over");
|
||||
mTextColours.journalLinkPressed = getTextColour("journal_link_pressed");
|
||||
|
||||
mTextColours.journalTopic = getTextColour("journal_topic");
|
||||
mTextColours.journalTopicOver = getTextColour("journal_topic_over");
|
||||
mTextColours.journalTopicPressed = getTextColour("journal_topic_pressed");
|
||||
|
||||
mTextColours.loadColours();
|
||||
|
||||
mDragAndDrop = new DragAndDrop();
|
||||
|
||||
|
@ -594,17 +558,6 @@ namespace MWGui
|
|||
|
||||
mCharGen = new CharacterCreation(mViewer->getSceneData()->asGroup(), mResourceSystem);
|
||||
|
||||
// Setup player stats
|
||||
for (int i = 0; i < ESM::Attribute::Length; ++i)
|
||||
{
|
||||
mPlayerAttributes.insert(std::make_pair(ESM::Attribute::sAttributeIds[i], MWMechanics::AttributeValue()));
|
||||
}
|
||||
|
||||
for (int i = 0; i < ESM::Skill::Length; ++i)
|
||||
{
|
||||
mPlayerSkillValues.insert(std::make_pair(ESM::Skill::sSkillIds[i], MWMechanics::SkillValue()));
|
||||
}
|
||||
|
||||
updatePinnedWindows();
|
||||
|
||||
// Set up visibility
|
||||
|
@ -797,40 +750,14 @@ namespace MWGui
|
|||
{
|
||||
mStatsWindow->setValue (id, value);
|
||||
mCharGen->setValue(id, value);
|
||||
|
||||
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
|
||||
};
|
||||
for (size_t i = 0; i < sizeof(ids)/sizeof(ids[0]); ++i)
|
||||
{
|
||||
if (id != ids[i])
|
||||
continue;
|
||||
mPlayerAttributes[attributes[i]] = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WindowManager::setValue (int parSkill, const MWMechanics::SkillValue& value)
|
||||
{
|
||||
/// \todo Don't use the skill enum as a parameter type (we will have to drop it anyway, once we
|
||||
/// allow custom skills.
|
||||
mStatsWindow->setValue(static_cast<ESM::Skill::SkillEnum> (parSkill), value);
|
||||
mCharGen->setValue(static_cast<ESM::Skill::SkillEnum> (parSkill), value);
|
||||
mPlayerSkillValues[parSkill] = value;
|
||||
}
|
||||
|
||||
void WindowManager::setValue (const std::string& id, const MWMechanics::DynamicStat<float>& value)
|
||||
|
@ -843,10 +770,6 @@ namespace MWGui
|
|||
void WindowManager::setValue (const std::string& id, const std::string& value)
|
||||
{
|
||||
mStatsWindow->setValue (id, value);
|
||||
if (id=="name")
|
||||
mPlayerName = value;
|
||||
else if (id=="race")
|
||||
mPlayerRaceId = value;
|
||||
}
|
||||
|
||||
void WindowManager::setValue (const std::string& id, int value)
|
||||
|
@ -868,8 +791,6 @@ namespace MWGui
|
|||
{
|
||||
mStatsWindow->configureSkills (major, minor);
|
||||
mCharGen->configureSkills(major, minor);
|
||||
mPlayerMajorSkills = major;
|
||||
mPlayerMinorSkills = minor;
|
||||
}
|
||||
|
||||
void WindowManager::updateSkillArea()
|
||||
|
@ -1005,7 +926,7 @@ namespace MWGui
|
|||
mHud->setPlayerPos(x, y, u, v);
|
||||
}
|
||||
|
||||
void WindowManager::onFrame (float frameDuration)
|
||||
void WindowManager::update (float frameDuration)
|
||||
{
|
||||
bool gameRunning = MWBase::Environment::get().getStateManager()->getState()!=
|
||||
MWBase::StateManager::State_NoGame;
|
||||
|
@ -1639,26 +1560,6 @@ namespace MWGui
|
|||
return mGuiModes.back();
|
||||
}
|
||||
|
||||
std::map<int, MWMechanics::SkillValue > WindowManager::getPlayerSkillValues()
|
||||
{
|
||||
return mPlayerSkillValues;
|
||||
}
|
||||
|
||||
std::map<int, MWMechanics::AttributeValue > WindowManager::getPlayerAttributeValues()
|
||||
{
|
||||
return mPlayerAttributes;
|
||||
}
|
||||
|
||||
WindowManager::SkillList WindowManager::getPlayerMinorSkills()
|
||||
{
|
||||
return mPlayerMinorSkills;
|
||||
}
|
||||
|
||||
WindowManager::SkillList WindowManager::getPlayerMajorSkills()
|
||||
{
|
||||
return mPlayerMajorSkills;
|
||||
}
|
||||
|
||||
void WindowManager::disallowMouse()
|
||||
{
|
||||
mInputBlocker->setVisible (true);
|
||||
|
|
|
@ -280,13 +280,7 @@ namespace MWGui
|
|||
|
||||
virtual int readPressedButton (); ///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
||||
|
||||
virtual void onFrame (float frameDuration);
|
||||
|
||||
/// \todo get rid of this stuff. Move it to the respective UI element classes, if needed.
|
||||
virtual std::map<int, MWMechanics::SkillValue > getPlayerSkillValues();
|
||||
virtual std::map<int, MWMechanics::AttributeValue > getPlayerAttributeValues();
|
||||
virtual SkillList getPlayerMinorSkills();
|
||||
virtual SkillList getPlayerMajorSkills();
|
||||
virtual void update (float duration);
|
||||
|
||||
/**
|
||||
* Fetches a GMST string from the store, if there is no setting with the given
|
||||
|
@ -474,14 +468,6 @@ namespace MWGui
|
|||
|
||||
void setCursorVisible(bool visible);
|
||||
|
||||
/// \todo get rid of this stuff. Move it to the respective UI element classes, if needed.
|
||||
// Various stats about player as needed by window manager
|
||||
std::string mPlayerName;
|
||||
std::string mPlayerRaceId;
|
||||
std::map<int, MWMechanics::AttributeValue > mPlayerAttributes;
|
||||
SkillList mPlayerMajorSkills, mPlayerMinorSkills;
|
||||
std::map<int, MWMechanics::SkillValue > mPlayerSkillValues;
|
||||
|
||||
MyGUI::Gui *mGui; // Gui
|
||||
|
||||
struct GuiModeState
|
||||
|
|
Loading…
Reference in a new issue