From 91d2031eb7d54a6c0ffdf9c7a0cb666ef4999f33 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 16 Mar 2012 17:09:31 +0100 Subject: [PATCH] first attempt at map window --- apps/openmw/mwgui/layouts.hpp | 28 ++++++++++- apps/openmw/mwgui/window_manager.cpp | 18 ++++++- apps/openmw/mwgui/window_manager.hpp | 4 +- apps/openmw/mwrender/localmap.cpp | 6 +-- apps/openmw/mwworld/scene.cpp | 11 +---- .../openmw_map_window_layout.xml | 48 +++++++++++++++++-- 6 files changed, 94 insertions(+), 21 deletions(-) diff --git a/apps/openmw/mwgui/layouts.hpp b/apps/openmw/mwgui/layouts.hpp index 9917dcdccc..7b7c842252 100644 --- a/apps/openmw/mwgui/layouts.hpp +++ b/apps/openmw/mwgui/layouts.hpp @@ -67,7 +67,7 @@ namespace MWGui { setCoord(500,0,320,300); setText("WorldButton", "World"); - setImage("Compass", "compass.dds"); + setImage("Compass", "textures\\compass.dds"); // Obviously you should override this later on setCellName("No Cell Loaded"); @@ -77,6 +77,32 @@ namespace MWGui { mMainWidget->setCaption(cellName); } + + // for interiors: cell name, for exteriors: "Cell" + void setCellPrefix(const std::string& prefix) + { + mPrefix = prefix; + } + + void setActiveCell(const int x, const int y) + { + for (int mx=0; mx<3; ++mx) + { + for (int my=0; my<3; ++my) + { + std::string name = "Map_" + boost::lexical_cast(mx) + "_" + + boost::lexical_cast(my); + + std::string image = mPrefix+"_"+ boost::lexical_cast(x + (mx-1)) + "_" + + boost::lexical_cast(y - (my-1)); + setImage(name, image); + setImage(name+"_fog", image+"_fog"); + } + } + } + + private: + std::string mPrefix; }; class MainMenu : public OEngine::GUI::Layout diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 347db09e2f..014aa81083 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -402,7 +402,21 @@ const ESMS::ESMStore& WindowManager::getStore() const return environment.mWorld->getStore(); } -void WindowManager::setCellName(const std::string& cellName) +void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) { - map->setCellName(cellName); + if (!(cell->cell->data.flags & ESM::Cell::Interior)) + { + if (cell->cell->name != "") + map->setCellName( cell->cell->name ); + else + map->setCellName( cell->cell->region ); + map->setCellPrefix("Cell"); + map->setActiveCell( cell->cell->data.gridX, cell->cell->data.gridY ); + } + else + { + map->setCellName( cell->cell->name ); + map->setCellPrefix( cell->cell->name ); + } + } diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 258ab79936..c867fedbed 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -18,6 +18,7 @@ #include #include #include "../mwmechanics/stat.hpp" +#include "../mwworld/ptr.hpp" #include "mode.hpp" namespace MyGUI @@ -150,8 +151,7 @@ namespace MWGui void setBounty (int bounty); ///< set the current bounty value void updateSkillArea(); ///< update display of skills, factions, birth sign, reputation and bounty - - void setCellName(const std::string& cellName); ///< set the cell name to display in the map window + void changeCell(MWWorld::Ptr::CellStore* cell); ///< change the active cell template void removeDialog(T*& dialog); ///< Casts to OEngine::GUI::Layout and calls removeDialog, then resets pointer to nullptr. diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index fe9b3c191c..ee5413caba 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -58,7 +58,7 @@ LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend) overlay_panel->setMaterialName( "testMaterial" ); overlay_panel->show(); mOverlay->add2D(overlay_panel); - mOverlay->show(); + //mOverlay->show(); Overlay* mOverlay2 = ovm.create( "testOverlay2" ); mOverlay2->setZOrder(1); @@ -72,7 +72,7 @@ LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend) overlay_panel2->show(); mOverlay2->add2D(overlay_panel2); - mOverlay2->show(); + //mOverlay2->show(); } @@ -252,7 +252,7 @@ void LocalMap::render(const float x, const float y, xw*FOGOFWAR_RESOLUTION/SIZE, yw*FOGOFWAR_RESOLUTION/SIZE, 0, PF_A8R8G8B8, - TU_DYNAMIC_WRITE_ONLY); + TU_DYNAMIC_WRITE_ONLY_DISCARDABLE); // create a buffer to use for dynamic operations uint32* buffer = new uint32[FOGOFWAR_RESOLUTION*FOGOFWAR_RESOLUTION]; diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 84c10072a9..22955bf329 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -121,16 +121,7 @@ namespace MWWorld mEnvironment.mMechanicsManager->addActor (mWorld->getPlayer().getPlayer()); mEnvironment.mMechanicsManager->watchActor (mWorld->getPlayer().getPlayer()); - // set map window cell name - if (!(mCurrentCell->cell->data.flags & ESM::Cell::Interior)) - { - if (mCurrentCell->cell->name != "") - mEnvironment.mWindowManager->setCellName( mCurrentCell->cell->name ); - else - mEnvironment.mWindowManager->setCellName( mCurrentCell->cell->region ); - } - else - mEnvironment.mWindowManager->setCellName( mCurrentCell->cell->name ); + mEnvironment.mWindowManager->changeCell( mCurrentCell ); } void Scene::changeCell (int X, int Y, const ESM::Position& position, bool adjustPlayerPos) diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_map_window_layout.xml b/extern/mygui_3.0.1/openmw_resources/openmw_map_window_layout.xml index f4ff50f72c..d4b1b5b0a7 100644 --- a/extern/mygui_3.0.1/openmw_resources/openmw_map_window_layout.xml +++ b/extern/mygui_3.0.1/openmw_resources/openmw_map_window_layout.xml @@ -2,8 +2,50 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +