From dda5bfbc9f9abf0d2f43eb21e5e61f39b4a60dd2 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 16 Aug 2016 22:47:45 +0200 Subject: [PATCH] CharacterPreview no longer depends on osgViewer --- apps/openmw/mwgui/charactercreation.cpp | 6 +++--- apps/openmw/mwgui/charactercreation.hpp | 8 ++++---- apps/openmw/mwgui/inventorywindow.cpp | 4 ++-- apps/openmw/mwgui/inventorywindow.hpp | 6 +++--- apps/openmw/mwgui/race.cpp | 6 +++--- apps/openmw/mwgui/race.hpp | 8 ++++---- apps/openmw/mwgui/windowmanagerimp.cpp | 6 +++--- apps/openmw/mwrender/characterpreview.cpp | 18 +++++++++--------- apps/openmw/mwrender/characterpreview.hpp | 14 +++++--------- components/resource/imagemanager.hpp | 5 ----- 10 files changed, 36 insertions(+), 45 deletions(-) diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index a880bca45..9a1b43678 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -62,8 +62,8 @@ namespace namespace MWGui { - CharacterCreation::CharacterCreation(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem) - : mViewer(viewer) + CharacterCreation::CharacterCreation(osg::Group* parent, Resource::ResourceSystem* resourceSystem) + : mParent(parent) , mResourceSystem(resourceSystem) , mNameDialog(0) , mRaceDialog(0) @@ -152,7 +152,7 @@ namespace MWGui case GM_Race: MWBase::Environment::get().getWindowManager()->removeDialog(mRaceDialog); mRaceDialog = 0; - mRaceDialog = new RaceDialog(mViewer, mResourceSystem); + mRaceDialog = new RaceDialog(mParent, mResourceSystem); mRaceDialog->setNextButtonShow(mCreationStage >= CSE_RaceChosen); mRaceDialog->setRaceId(mPlayerRaceId); mRaceDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogDone); diff --git a/apps/openmw/mwgui/charactercreation.hpp b/apps/openmw/mwgui/charactercreation.hpp index 7fb67caf6..75f3a7016 100644 --- a/apps/openmw/mwgui/charactercreation.hpp +++ b/apps/openmw/mwgui/charactercreation.hpp @@ -8,9 +8,9 @@ #include "../mwmechanics/stat.hpp" -namespace osgViewer +namespace osg { - class Viewer; + class Group; } namespace Resource @@ -39,7 +39,7 @@ namespace MWGui public: typedef std::vector SkillList; - CharacterCreation(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem); + CharacterCreation(osg::Group* parent, Resource::ResourceSystem* resourceSystem); ~CharacterCreation(); //Show a dialog @@ -51,7 +51,7 @@ namespace MWGui void configureSkills (const SkillList& major, const SkillList& minor); private: - osgViewer::Viewer* mViewer; + osg::Group* mParent; Resource::ResourceSystem* mResourceSystem; //Dialogs diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 4599132e3..bd864b45b 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -56,7 +56,7 @@ namespace namespace MWGui { - InventoryWindow::InventoryWindow(DragAndDrop* dragAndDrop, osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem) + InventoryWindow::InventoryWindow(DragAndDrop* dragAndDrop, osg::Group* parent, Resource::ResourceSystem* resourceSystem) : WindowPinnableBase("openmw_inventory_window.layout") , mDragAndDrop(dragAndDrop) , mSelectedItem(-1) @@ -65,7 +65,7 @@ namespace MWGui , mGuiMode(GM_Inventory) , mLastXSize(0) , mLastYSize(0) - , mPreview(new MWRender::InventoryPreview(viewer, resourceSystem, MWMechanics::getPlayer())) + , mPreview(new MWRender::InventoryPreview(parent, resourceSystem, MWMechanics::getPlayer())) , mTrading(false) { mPreviewTexture.reset(new osgMyGUI::OSGTexture(mPreview->getTexture())); diff --git a/apps/openmw/mwgui/inventorywindow.hpp b/apps/openmw/mwgui/inventorywindow.hpp index b7ae067ac..651bda590 100644 --- a/apps/openmw/mwgui/inventorywindow.hpp +++ b/apps/openmw/mwgui/inventorywindow.hpp @@ -6,9 +6,9 @@ #include "../mwworld/ptr.hpp" -namespace osgViewer +namespace osg { - class Viewer; + class Group; } namespace Resource @@ -37,7 +37,7 @@ namespace MWGui class InventoryWindow : public WindowPinnableBase { public: - InventoryWindow(DragAndDrop* dragAndDrop, osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem); + InventoryWindow(DragAndDrop* dragAndDrop, osg::Group* parent, Resource::ResourceSystem* resourceSystem); virtual void open(); diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 6c08f7dc1..daa07d5c4 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -41,9 +41,9 @@ namespace namespace MWGui { - RaceDialog::RaceDialog(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem) + RaceDialog::RaceDialog(osg::Group* parent, Resource::ResourceSystem* resourceSystem) : WindowModal("openmw_chargen_race.layout") - , mViewer(viewer) + , mParent(parent) , mResourceSystem(resourceSystem) , mGenderIndex(0) , mFaceIndex(0) @@ -136,7 +136,7 @@ namespace MWGui mPreview.reset(NULL); mPreviewTexture.reset(NULL); - mPreview.reset(new MWRender::RaceSelectionPreview(mViewer, mResourceSystem)); + mPreview.reset(new MWRender::RaceSelectionPreview(mParent, mResourceSystem)); mPreview->rebuild(); mPreview->setAngle (mCurrentAngle); diff --git a/apps/openmw/mwgui/race.hpp b/apps/openmw/mwgui/race.hpp index b3de9bef0..42e758983 100644 --- a/apps/openmw/mwgui/race.hpp +++ b/apps/openmw/mwgui/race.hpp @@ -19,9 +19,9 @@ namespace ESM struct NPC; } -namespace osgViewer +namespace osg { - class Viewer; + class Group; } namespace Resource @@ -34,7 +34,7 @@ namespace MWGui class RaceDialog : public WindowModal { public: - RaceDialog(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem); + RaceDialog(osg::Group* parent, Resource::ResourceSystem* resourceSystem); enum Gender { @@ -93,7 +93,7 @@ namespace MWGui void getBodyParts (int part, std::vector& out); - osgViewer::Viewer* mViewer; + osg::Group* mParent; Resource::ResourceSystem* mResourceSystem; std::vector mAvailableHeads; diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 2426dc3e1..09b72ad3d 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -293,7 +293,7 @@ namespace MWGui bool questList = mResourceSystem->getVFS()->exists("textures/tx_menubook_options_over.dds"); mJournal = JournalWindow::create(JournalViewModel::create (), questList); mMessageBoxManager = new MessageBoxManager(mStore->get().find("fMessageTimePerChar")->getFloat()); - mInventoryWindow = new InventoryWindow(mDragAndDrop, mViewer, mResourceSystem); + mInventoryWindow = new InventoryWindow(mDragAndDrop, mViewer->getSceneData()->asGroup(), mResourceSystem); mTradeWindow = new TradeWindow(); trackWindow(mTradeWindow, "barter"); mSpellBuyingWindow = new SpellBuyingWindow(); @@ -350,7 +350,7 @@ namespace MWGui mHud->setVisible(mHudEnabled); - mCharGen = new CharacterCreation(mViewer, mResourceSystem); + mCharGen = new CharacterCreation(mViewer->getSceneData()->asGroup(), mResourceSystem); // Setup player stats for (int i = 0; i < ESM::Attribute::Length; ++i) @@ -384,7 +384,7 @@ namespace MWGui { disallowAll(); delete mCharGen; - mCharGen = new CharacterCreation(mViewer, mResourceSystem); + mCharGen = new CharacterCreation(mViewer->getSceneData()->asGroup(), mResourceSystem); mGuiModes.clear(); MWBase::Environment::get().getInputManager()->changeInputMode(false); mHud->unsetSelectedWeapon(); diff --git a/apps/openmw/mwrender/characterpreview.cpp b/apps/openmw/mwrender/characterpreview.cpp index 84f60c82d..ed61334bb 100644 --- a/apps/openmw/mwrender/characterpreview.cpp +++ b/apps/openmw/mwrender/characterpreview.cpp @@ -6,8 +6,8 @@ #include #include #include -#include #include +#include #include #include @@ -65,9 +65,9 @@ namespace MWRender unsigned int mLastRenderedFrame; }; - CharacterPreview::CharacterPreview(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem, + CharacterPreview::CharacterPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character, int sizeX, int sizeY, const osg::Vec3f& position, const osg::Vec3f& lookAt) - : mViewer(viewer) + : mParent(parent) , mResourceSystem(resourceSystem) , mPosition(position) , mLookAt(lookAt) @@ -139,7 +139,7 @@ namespace MWRender mDrawOnceCallback = new DrawOnceCallback; mCamera->addUpdateCallback(mDrawOnceCallback); - mViewer->getSceneData()->asGroup()->addChild(mCamera); + mParent->addChild(mCamera); mCharacter.mCell = NULL; } @@ -147,7 +147,7 @@ namespace MWRender CharacterPreview::~CharacterPreview () { mCamera->removeChildren(0, mCamera->getNumChildren()); - mViewer->getSceneData()->asGroup()->removeChild(mCamera); + mParent->removeChild(mCamera); } int CharacterPreview::getTextureWidth() const @@ -190,8 +190,8 @@ namespace MWRender // -------------------------------------------------------------------------------------------------- - InventoryPreview::InventoryPreview(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character) - : CharacterPreview(viewer, resourceSystem, character, 512, 1024, osg::Vec3f(0, 700, 71), osg::Vec3f(0,0,71)) + InventoryPreview::InventoryPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character) + : CharacterPreview(parent, resourceSystem, character, 512, 1024, osg::Vec3f(0, 700, 71), osg::Vec3f(0,0,71)) { } @@ -319,8 +319,8 @@ namespace MWRender // -------------------------------------------------------------------------------------------------- - RaceSelectionPreview::RaceSelectionPreview(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem) - : CharacterPreview(viewer, resourceSystem, MWMechanics::getPlayer(), + RaceSelectionPreview::RaceSelectionPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem) + : CharacterPreview(parent, resourceSystem, MWMechanics::getPlayer(), 512, 512, osg::Vec3f(0, 125, 8), osg::Vec3f(0,0,8)) , mBase (*mCharacter.get()->mBase) , mRef(&mBase) diff --git a/apps/openmw/mwrender/characterpreview.hpp b/apps/openmw/mwrender/characterpreview.hpp index 2b7984b00..2a4ef9877 100644 --- a/apps/openmw/mwrender/characterpreview.hpp +++ b/apps/openmw/mwrender/characterpreview.hpp @@ -16,11 +16,7 @@ namespace osg { class Texture2D; class Camera; -} - -namespace osgViewer -{ - class Viewer; + class Group; } namespace MWRender @@ -32,7 +28,7 @@ namespace MWRender class CharacterPreview { public: - CharacterPreview(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character, int sizeX, int sizeY, + CharacterPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character, int sizeX, int sizeY, const osg::Vec3f& position, const osg::Vec3f& lookAt); virtual ~CharacterPreview(); @@ -53,7 +49,7 @@ namespace MWRender virtual bool renderHeadOnly() { return false; } virtual void onSetup(); - osg::ref_ptr mViewer; + osg::ref_ptr mParent; Resource::ResourceSystem* mResourceSystem; osg::ref_ptr mTexture; osg::ref_ptr mCamera; @@ -76,7 +72,7 @@ namespace MWRender { public: - InventoryPreview(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character); + InventoryPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character); void updatePtr(const MWWorld::Ptr& ptr); @@ -102,7 +98,7 @@ namespace MWRender virtual void onSetup(); public: - RaceSelectionPreview(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem); + RaceSelectionPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem); virtual ~RaceSelectionPreview(); void setAngle(float angleRadians); diff --git a/components/resource/imagemanager.hpp b/components/resource/imagemanager.hpp index 8d9ad2c32..2ef601e6b 100644 --- a/components/resource/imagemanager.hpp +++ b/components/resource/imagemanager.hpp @@ -10,11 +10,6 @@ #include "resourcemanager.hpp" -namespace osgViewer -{ - class Viewer; -} - namespace osgDB { class Options;