forked from mirror/openmw-tes3mp
Merge remote-tracking branch 'sergeyshambir/guiconvience' into next
This commit is contained in:
commit
910858c300
6 changed files with 89 additions and 16 deletions
|
@ -133,8 +133,6 @@ void BirthDialog::updateBirths()
|
|||
const MWWorld::Store<ESM::BirthSign> &signs =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>();
|
||||
|
||||
int index = 0;
|
||||
|
||||
// sort by name
|
||||
std::vector < std::pair<std::string, const ESM::BirthSign*> > birthSigns;
|
||||
|
||||
|
@ -145,12 +143,20 @@ void BirthDialog::updateBirths()
|
|||
}
|
||||
std::sort(birthSigns.begin(), birthSigns.end(), sortBirthSigns);
|
||||
|
||||
for (std::vector < std::pair<std::string, const ESM::BirthSign*> >::const_iterator it2 = birthSigns.begin(); it2 != birthSigns.end(); ++it2)
|
||||
int index = 0;
|
||||
for (std::vector<std::pair<std::string, const ESM::BirthSign*> >::const_iterator it2 = birthSigns.begin();
|
||||
it2 != birthSigns.end(); ++it2, ++index)
|
||||
{
|
||||
mBirthList->addItem(it2->second->mName, it2->first);
|
||||
if (boost::iequals(it2->first, mCurrentBirthId))
|
||||
if (mCurrentBirthId.empty())
|
||||
{
|
||||
mBirthList->setIndexSelected(index);
|
||||
++index;
|
||||
mCurrentBirthId = it2->first;
|
||||
}
|
||||
else if (boost::iequals(it2->first, mCurrentBirthId))
|
||||
{
|
||||
mBirthList->setIndexSelected(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -197,8 +197,15 @@ void PickClassDialog::updateClasses()
|
|||
|
||||
const std::string &id = it->mId;
|
||||
mClassList->addItem(it->mName, id);
|
||||
if (boost::iequals(id, mCurrentClassId))
|
||||
if (mCurrentClassId.empty())
|
||||
{
|
||||
mCurrentClassId = id;
|
||||
mClassList->setIndexSelected(index);
|
||||
}
|
||||
else if (boost::iequals(id, mCurrentClassId))
|
||||
{
|
||||
mClassList->setIndexSelected(index);
|
||||
}
|
||||
++index;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,17 @@
|
|||
|
||||
#include "inventorywindow.hpp"
|
||||
|
||||
static const float BALANCE_CHANGE_INITIAL_PAUSE = 0.5; // in seconds
|
||||
static const float BALANCE_CHANGE_INTERVAL = 0.1; // in seconds
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
TradeWindow::TradeWindow(MWBase::WindowManager& parWindowManager) :
|
||||
WindowBase("openmw_trade_window.layout", parWindowManager)
|
||||
, ContainerBase(NULL) // no drag&drop
|
||||
, mCurrentBalance(0)
|
||||
, mBalanceButtonsState(BBS_None)
|
||||
, mBalanceChangePause(0.0)
|
||||
{
|
||||
MyGUI::ScrollView* itemView;
|
||||
MyGUI::Widget* containerWidget;
|
||||
|
@ -59,8 +64,10 @@ namespace MWGui
|
|||
|
||||
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onCancelButtonClicked);
|
||||
mOfferButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onOfferButtonClicked);
|
||||
mIncreaseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onIncreaseButtonClicked);
|
||||
mDecreaseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onDecreaseButtonClicked);
|
||||
mIncreaseButton->eventMouseButtonPressed += MyGUI::newDelegate(this, &TradeWindow::onIncreaseButtonPressed);
|
||||
mIncreaseButton->eventMouseButtonReleased += MyGUI::newDelegate(this, &TradeWindow::onBalanceButtonReleased);
|
||||
mDecreaseButton->eventMouseButtonPressed += MyGUI::newDelegate(this, &TradeWindow::onDecreaseButtonPressed);
|
||||
mDecreaseButton->eventMouseButtonReleased += MyGUI::newDelegate(this, &TradeWindow::onBalanceButtonReleased);
|
||||
|
||||
setCoord(400, 0, 400, 300);
|
||||
|
||||
|
@ -143,6 +150,21 @@ namespace MWGui
|
|||
}
|
||||
}
|
||||
|
||||
void TradeWindow::onFrame(float frameDuration)
|
||||
{
|
||||
if (!mMainWidget->getVisible() || mBalanceButtonsState == BBS_None)
|
||||
return;
|
||||
|
||||
mBalanceChangePause -= frameDuration;
|
||||
if (mBalanceChangePause < 0.0) {
|
||||
mBalanceChangePause += BALANCE_CHANGE_INTERVAL;
|
||||
if (mBalanceButtonsState == BBS_Increase)
|
||||
onIncreaseButtonTriggered();
|
||||
else if (mBalanceButtonsState == BBS_Decrease)
|
||||
onDecreaseButtonTriggered();
|
||||
}
|
||||
}
|
||||
|
||||
void TradeWindow::onOfferButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
const MWWorld::Store<ESM::GameSetting> &gmst =
|
||||
|
@ -242,7 +264,7 @@ namespace MWGui
|
|||
|
||||
//skill use!
|
||||
MWWorld::Class::get(playerPtr).skillUsageSucceeded(playerPtr, ESM::Skill::Mercantile, 0);
|
||||
}
|
||||
}
|
||||
|
||||
int iBarterSuccessDisposition = gmst.find("iBarterSuccessDisposition")->getInt();
|
||||
MWBase::Environment::get().getDialogueManager()->applyTemporaryDispositionChange(iBarterSuccessDisposition);
|
||||
|
@ -271,14 +293,33 @@ namespace MWGui
|
|||
mWindowManager.removeGuiMode(GM_Barter);
|
||||
}
|
||||
|
||||
void TradeWindow::onIncreaseButtonClicked(MyGUI::Widget* _sender)
|
||||
void TradeWindow::onIncreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
|
||||
{
|
||||
mBalanceButtonsState = BBS_Increase;
|
||||
mBalanceChangePause = BALANCE_CHANGE_INITIAL_PAUSE;
|
||||
onIncreaseButtonTriggered();
|
||||
}
|
||||
|
||||
void TradeWindow::onDecreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
|
||||
{
|
||||
mBalanceButtonsState = BBS_Decrease;
|
||||
mBalanceChangePause = BALANCE_CHANGE_INITIAL_PAUSE;
|
||||
onDecreaseButtonTriggered();
|
||||
}
|
||||
|
||||
void TradeWindow::onBalanceButtonReleased(MyGUI::Widget *_sender, int _left, int _top, MyGUI::MouseButton _id)
|
||||
{
|
||||
mBalanceButtonsState = BBS_None;
|
||||
}
|
||||
|
||||
void TradeWindow::onIncreaseButtonTriggered()
|
||||
{
|
||||
if(mCurrentBalance<=-1) mCurrentBalance -= 1;
|
||||
if(mCurrentBalance>=1) mCurrentBalance += 1;
|
||||
updateLabels();
|
||||
}
|
||||
|
||||
void TradeWindow::onDecreaseButtonClicked(MyGUI::Widget* _sender)
|
||||
void TradeWindow::onDecreaseButtonTriggered()
|
||||
{
|
||||
if(mCurrentBalance<-1) mCurrentBalance += 1;
|
||||
if(mCurrentBalance>1) mCurrentBalance -= 1;
|
||||
|
|
|
@ -34,6 +34,8 @@ namespace MWGui
|
|||
|
||||
void addOrRemoveGold(int gold);
|
||||
|
||||
void onFrame(float frameDuration);
|
||||
|
||||
protected:
|
||||
MyGUI::Button* mFilterAll;
|
||||
MyGUI::Button* mFilterWeapon;
|
||||
|
@ -57,12 +59,24 @@ namespace MWGui
|
|||
int mCurrentBalance;
|
||||
int mCurrentMerchantOffer;
|
||||
|
||||
enum BalanceButtonsState {
|
||||
BBS_None,
|
||||
BBS_Increase,
|
||||
BBS_Decrease
|
||||
} mBalanceButtonsState;
|
||||
/// pause before next balance change will trigger while user holds +/- button pressed
|
||||
float mBalanceChangePause;
|
||||
|
||||
void onWindowResize(MyGUI::Window* _sender);
|
||||
void onFilterChanged(MyGUI::Widget* _sender);
|
||||
void onOfferButtonClicked(MyGUI::Widget* _sender);
|
||||
void onCancelButtonClicked(MyGUI::Widget* _sender);
|
||||
void onIncreaseButtonClicked(MyGUI::Widget* _sender);
|
||||
void onDecreaseButtonClicked(MyGUI::Widget* _sender);
|
||||
void onIncreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
|
||||
void onDecreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
|
||||
void onBalanceButtonReleased(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
|
||||
|
||||
void onIncreaseButtonTriggered();
|
||||
void onDecreaseButtonTriggered();
|
||||
|
||||
// don't show items that the NPC has equipped in his trade-window.
|
||||
virtual bool ignoreEquippedItems() { return true; }
|
||||
|
|
|
@ -613,6 +613,7 @@ void WindowManager::onFrame (float frameDuration)
|
|||
mHud->onFrame(frameDuration);
|
||||
|
||||
mTrainingWindow->onFrame (frameDuration);
|
||||
mTradeWindow->onFrame(frameDuration);
|
||||
|
||||
mTrainingWindow->checkReferenceAvailable();
|
||||
mDialogueWindow->checkReferenceAvailable();
|
||||
|
|
|
@ -590,10 +590,14 @@ namespace MWInput
|
|||
// Toggle between game mode and inventory mode
|
||||
if(gameMode)
|
||||
mWindows.pushGuiMode(MWGui::GM_Inventory);
|
||||
else if(mWindows.getMode() == MWGui::GM_Inventory)
|
||||
mWindows.popGuiMode();
|
||||
else
|
||||
{
|
||||
MWGui::GuiMode mode = mWindows.getMode();
|
||||
if(mode == MWGui::GM_Inventory || mode == MWGui::GM_Container)
|
||||
mWindows.popGuiMode();
|
||||
}
|
||||
|
||||
// .. but don't touch any other mode.
|
||||
// .. but don't touch any other mode, except container.
|
||||
}
|
||||
|
||||
void InputManager::toggleConsole()
|
||||
|
|
Loading…
Reference in a new issue