fading, greying out destinations you cant afford, warning fix

actorid
scrawl 12 years ago
parent 9583a1b8e9
commit 7d1e659960

@ -6,10 +6,12 @@
#include <OgreCompositorChain.h> #include <OgreCompositorChain.h>
#include <OgreMaterial.h> #include <OgreMaterial.h>
#include <openengine/ogre/fader.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/inputmanager.hpp" #include "../mwbase/inputmanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
@ -106,6 +108,7 @@ namespace MWGui
if (mTimer.getMilliseconds () > mLastRenderTime + (1.f/loadingScreenFps) * 1000.f) if (mTimer.getMilliseconds () > mLastRenderTime + (1.f/loadingScreenFps) * 1000.f)
{ {
float dt = mTimer.getMilliseconds () - mLastRenderTime;
mLastRenderTime = mTimer.getMilliseconds (); mLastRenderTime = mTimer.getMilliseconds ();
if (mFirstLoad && mTimer.getMilliseconds () > mLastWallpaperChangeTime + 3000*1) if (mFirstLoad && mTimer.getMilliseconds () > mLastWallpaperChangeTime + 3000*1)
@ -151,6 +154,8 @@ namespace MWGui
} }
} }
MWBase::Environment::get().getWorld ()->getFader ()->update (dt);
mWindow->update(); mWindow->update();
if (!hasCompositor) if (!hasCompositor)

@ -52,26 +52,28 @@ namespace MWGui
void TravelWindow::addDestination(const std::string& travelId,ESM::Position pos,bool interior) void TravelWindow::addDestination(const std::string& travelId,ESM::Position pos,bool interior)
{ {
//std::cout << "travel to" << travelId;
/*const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId);
int price = spell->data.cost*MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fSpellValueMult")->getFloat();*/
int price = 0; int price = 0;
MyGUI::Button* toAdd = mDestinationsView->createWidget<MyGUI::Button>((price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SpellText", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default);
mCurrentY += sLineHeight;
/// \todo price adjustment depending on merchantile skill
if(interior) if(interior)
{ {
toAdd->setUserString("interior","y");
price = MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fMagesGuildTravel")->getFloat(); price = MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fMagesGuildTravel")->getFloat();
} }
else else
{ {
toAdd->setUserString("interior","n");
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
ESM::Position PlayerPos = player.getRefData().getPosition(); ESM::Position PlayerPos = player.getRefData().getPosition();
float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) ); float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) );
price = d/MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fTravelMult")->getFloat(); price = d/MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fTravelMult")->getFloat();
} }
MyGUI::Button* toAdd = mDestinationsView->createWidget<MyGUI::Button>((price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SpellText", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default);
mCurrentY += sLineHeight;
/// \todo price adjustment depending on merchantile skill
if(interior)
toAdd->setUserString("interior","y");
else
toAdd->setUserString("interior","n");
std::ostringstream oss; std::ostringstream oss;
oss << price; oss << price;
toAdd->setUserString("price",oss.str()); toAdd->setUserString("price",oss.str());
@ -118,7 +120,7 @@ namespace MWGui
addDestination (*iter); addDestination (*iter);
}*/ }*/
for(int i = 0;i<mPtr.get<ESM::NPC>()->base->mTransport.size();i++) for(unsigned int i = 0;i<mPtr.get<ESM::NPC>()->base->mTransport.size();i++)
{ {
std::string cellname = mPtr.get<ESM::NPC>()->base->mTransport[i].mCellName; std::string cellname = mPtr.get<ESM::NPC>()->base->mTransport[i].mCellName;
bool interior = true; bool interior = true;
@ -141,35 +143,35 @@ namespace MWGui
int price; int price;
iss >> price; iss >> price;
if (mWindowManager.getInventoryWindow()->getPlayerGold()>=price) assert (mWindowManager.getInventoryWindow()->getPlayerGold()>=price);
MWBase::Environment::get().getWorld ()->getFader ()->fadeOut(1);
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
ESM::Position pos = *_sender->getUserData<ESM::Position>();
std::string cellname = _sender->getUserString("Destination");
int x,y;
bool interior = _sender->getUserString("interior") == "y";
MWBase::Environment::get().getWorld()->positionToIndex(pos.pos[0],pos.pos[1],x,y);
MWWorld::CellStore* cell;
if(interior) cell = MWBase::Environment::get().getWorld()->getInterior(cellname);
else
{ {
MWBase::Environment::get().getWorld ()->getFader ()->fadeOut(1); cell = MWBase::Environment::get().getWorld()->getExterior(x,y);
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); ESM::Position PlayerPos = player.getRefData().getPosition();
ESM::Position pos = *_sender->getUserData<ESM::Position>(); float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) );
std::string cellname = _sender->getUserString("Destination"); int time = int(d /MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fTravelTimeMult")->getFloat());
int x,y; std::cout << time;
bool interior = _sender->getUserString("interior") == "y"; for(int i = 0;i < time;i++)
MWBase::Environment::get().getWorld()->positionToIndex(pos.pos[0],pos.pos[1],x,y);
MWWorld::CellStore* cell;
if(interior) cell = MWBase::Environment::get().getWorld()->getInterior(cellname);
else
{ {
cell = MWBase::Environment::get().getWorld()->getExterior(x,y); MWBase::Environment::get().getMechanicsManager ()->restoreDynamicStats ();
ESM::Position PlayerPos = player.getRefData().getPosition();
float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) );
int time = int(d /MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fTravelTimeMult")->getFloat());
std::cout << time;
for(int i = 0;i < time;i++)
{
MWBase::Environment::get().getMechanicsManager ()->restoreDynamicStats ();
}
MWBase::Environment::get().getWorld()->advanceTime(time);
} }
MWBase::Environment::get().getWorld()->moveObject(player,*cell,pos.pos[0],pos.pos[1],pos.pos[2]); MWBase::Environment::get().getWorld()->advanceTime(time);
mWindowManager.removeGuiMode(GM_Travel);
mWindowManager.removeGuiMode(GM_Dialogue);
MWBase::Environment::get().getWorld ()->getFader ()->fadeIn(1);
} }
MWBase::Environment::get().getWorld()->moveObject(player,*cell,pos.pos[0],pos.pos[1],pos.pos[2]);
mWindowManager.removeGuiMode(GM_Travel);
mWindowManager.removeGuiMode(GM_Dialogue);
MWBase::Environment::get().getWorld ()->getFader ()->fadeOut(0);
MWBase::Environment::get().getWorld ()->getFader ()->fadeIn(1);
} }
void TravelWindow::onCancelButtonClicked(MyGUI::Widget* _sender) void TravelWindow::onCancelButtonClicked(MyGUI::Widget* _sender)

2
extern/shiny vendored

@ -1 +1 @@
Subproject commit 4750676ac46a7aaa86bca53dc68c5a1ba11f3bc1 Subproject commit f17c4ebab0e7a1f3bbb25fd9b3dbef2bd742536a
Loading…
Cancel
Save