mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
traveling.
This commit is contained in:
parent
1f4de03613
commit
5a611b66d7
2 changed files with 26 additions and 14 deletions
|
@ -47,7 +47,7 @@ namespace MWGui
|
|||
mSelect->getHeight());
|
||||
}
|
||||
|
||||
void TravelWindow::addDestination(const std::string& travelId)
|
||||
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);
|
||||
|
@ -56,12 +56,17 @@ namespace MWGui
|
|||
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
|
||||
toAdd->setUserData(price);
|
||||
std::ostringstream oss;
|
||||
oss << price;
|
||||
toAdd->setUserString("price",oss.str());
|
||||
if(interior) toAdd->setUserString("interior","y");
|
||||
else toAdd->setUserString("interior","n");
|
||||
toAdd->setCaptionWithReplacing(travelId+" - "+boost::lexical_cast<std::string>(price)+"#{sgp}");
|
||||
toAdd->setSize(toAdd->getTextSize().width,sLineHeight);
|
||||
toAdd->eventMouseWheel += MyGUI::newDelegate(this, &TravelWindow::onMouseWheel);
|
||||
//toAdd->setUserString("ToolTipType", "Spell");
|
||||
toAdd->setUserString("Destination", travelId);
|
||||
toAdd->setUserData(pos);
|
||||
toAdd->eventMouseButtonClick += MyGUI::newDelegate(this, &TravelWindow::onTravelButtonClick);
|
||||
mDestinationsWidgetMap.insert(std::make_pair (toAdd, travelId));
|
||||
}
|
||||
|
@ -102,11 +107,12 @@ namespace MWGui
|
|||
for(int i = 0;i<mPtr.get<ESM::NPC>()->base->mTransport.size();i++)
|
||||
{
|
||||
std::string cellname = mPtr.get<ESM::NPC>()->base->mTransport[i].mCellName;
|
||||
bool interior = true;
|
||||
int x,y;
|
||||
MWBase::Environment::get().getWorld()->positionToIndex(mPtr.get<ESM::NPC>()->base->mTransport[i].mPos.pos[0],
|
||||
mPtr.get<ESM::NPC>()->base->mTransport[i].mPos.pos[1],x,y);
|
||||
if(cellname == "") cellname = MWBase::Environment::get().getWorld()->getExterior(x,y)->cell->name;
|
||||
addDestination(cellname);
|
||||
if(cellname == "") {cellname = MWBase::Environment::get().getWorld()->getExterior(x,y)->cell->name; interior= false;}
|
||||
addDestination(cellname,mPtr.get<ESM::NPC>()->base->mTransport[i].mPos,interior);
|
||||
}
|
||||
|
||||
updateLabels();
|
||||
|
@ -117,19 +123,25 @@ namespace MWGui
|
|||
void TravelWindow::onTravelButtonClick(MyGUI::Widget* _sender)
|
||||
{
|
||||
std::cout << "traveling to:" << _sender->getUserString("Destination");
|
||||
/*int price = *_sender->getUserData<int>();
|
||||
std::istringstream iss(_sender->getUserString("price"));
|
||||
int price;
|
||||
iss >> price;
|
||||
|
||||
if (mWindowManager.getInventoryWindow()->getPlayerGold()>=price)
|
||||
{
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
||||
MWMechanics::Spells& spells = stats.getSpells();
|
||||
spells.add (mSpellsWidgetMap.find(_sender)->second);
|
||||
mWindowManager.getTradeWindow()->addOrRemoveGold(-price);
|
||||
startSpellBuying(mPtr);
|
||||
|
||||
MWBase::Environment::get().getSoundManager()->playSound ("Item Gold Up", 1.0, 1.0);
|
||||
}*/
|
||||
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 cell = MWBase::Environment::get().getWorld()->getExterior(x,y);
|
||||
MWBase::Environment::get().getWorld()->moveObject(player,*cell,pos.pos[0],pos.pos[1],pos.pos[2]);
|
||||
mWindowManager.removeGuiMode(GM_Travel);
|
||||
mWindowManager.removeGuiMode(GM_Dialogue);
|
||||
}
|
||||
}
|
||||
|
||||
void TravelWindow::onCancelButtonClicked(MyGUI::Widget* _sender)
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace MWGui
|
|||
void onCancelButtonClicked(MyGUI::Widget* _sender);
|
||||
void onTravelButtonClick(MyGUI::Widget* _sender);
|
||||
void onMouseWheel(MyGUI::Widget* _sender, int _rel);
|
||||
void addDestination(const std::string& destinationID);
|
||||
void addDestination(const std::string& destinationID,ESM::Position pos,bool interior);
|
||||
void clearDestinations();
|
||||
int mLastPos,mCurrentY;
|
||||
|
||||
|
|
Loading…
Reference in a new issue