mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 12:53:51 +00:00
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 =
|
const MWWorld::Store<ESM::BirthSign> &signs =
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>();
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>();
|
||||||
|
|
||||||
int index = 0;
|
|
||||||
|
|
||||||
// sort by name
|
// sort by name
|
||||||
std::vector < std::pair<std::string, const ESM::BirthSign*> > birthSigns;
|
std::vector < std::pair<std::string, const ESM::BirthSign*> > birthSigns;
|
||||||
|
|
||||||
|
@ -145,12 +143,20 @@ void BirthDialog::updateBirths()
|
||||||
}
|
}
|
||||||
std::sort(birthSigns.begin(), birthSigns.end(), sortBirthSigns);
|
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);
|
mBirthList->addItem(it2->second->mName, it2->first);
|
||||||
if (boost::iequals(it2->first, mCurrentBirthId))
|
if (mCurrentBirthId.empty())
|
||||||
|
{
|
||||||
mBirthList->setIndexSelected(index);
|
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;
|
const std::string &id = it->mId;
|
||||||
mClassList->addItem(it->mName, id);
|
mClassList->addItem(it->mName, id);
|
||||||
if (boost::iequals(id, mCurrentClassId))
|
if (mCurrentClassId.empty())
|
||||||
|
{
|
||||||
|
mCurrentClassId = id;
|
||||||
mClassList->setIndexSelected(index);
|
mClassList->setIndexSelected(index);
|
||||||
|
}
|
||||||
|
else if (boost::iequals(id, mCurrentClassId))
|
||||||
|
{
|
||||||
|
mClassList->setIndexSelected(index);
|
||||||
|
}
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,17 @@
|
||||||
|
|
||||||
#include "inventorywindow.hpp"
|
#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
|
namespace MWGui
|
||||||
{
|
{
|
||||||
TradeWindow::TradeWindow(MWBase::WindowManager& parWindowManager) :
|
TradeWindow::TradeWindow(MWBase::WindowManager& parWindowManager) :
|
||||||
WindowBase("openmw_trade_window.layout", parWindowManager)
|
WindowBase("openmw_trade_window.layout", parWindowManager)
|
||||||
, ContainerBase(NULL) // no drag&drop
|
, ContainerBase(NULL) // no drag&drop
|
||||||
, mCurrentBalance(0)
|
, mCurrentBalance(0)
|
||||||
|
, mBalanceButtonsState(BBS_None)
|
||||||
|
, mBalanceChangePause(0.0)
|
||||||
{
|
{
|
||||||
MyGUI::ScrollView* itemView;
|
MyGUI::ScrollView* itemView;
|
||||||
MyGUI::Widget* containerWidget;
|
MyGUI::Widget* containerWidget;
|
||||||
|
@ -59,8 +64,10 @@ namespace MWGui
|
||||||
|
|
||||||
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onCancelButtonClicked);
|
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onCancelButtonClicked);
|
||||||
mOfferButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onOfferButtonClicked);
|
mOfferButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onOfferButtonClicked);
|
||||||
mIncreaseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onIncreaseButtonClicked);
|
mIncreaseButton->eventMouseButtonPressed += MyGUI::newDelegate(this, &TradeWindow::onIncreaseButtonPressed);
|
||||||
mDecreaseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onDecreaseButtonClicked);
|
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);
|
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)
|
void TradeWindow::onOfferButtonClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
const MWWorld::Store<ESM::GameSetting> &gmst =
|
const MWWorld::Store<ESM::GameSetting> &gmst =
|
||||||
|
@ -242,7 +264,7 @@ namespace MWGui
|
||||||
|
|
||||||
//skill use!
|
//skill use!
|
||||||
MWWorld::Class::get(playerPtr).skillUsageSucceeded(playerPtr, ESM::Skill::Mercantile, 0);
|
MWWorld::Class::get(playerPtr).skillUsageSucceeded(playerPtr, ESM::Skill::Mercantile, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int iBarterSuccessDisposition = gmst.find("iBarterSuccessDisposition")->getInt();
|
int iBarterSuccessDisposition = gmst.find("iBarterSuccessDisposition")->getInt();
|
||||||
MWBase::Environment::get().getDialogueManager()->applyTemporaryDispositionChange(iBarterSuccessDisposition);
|
MWBase::Environment::get().getDialogueManager()->applyTemporaryDispositionChange(iBarterSuccessDisposition);
|
||||||
|
@ -271,14 +293,33 @@ namespace MWGui
|
||||||
mWindowManager.removeGuiMode(GM_Barter);
|
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;
|
||||||
if(mCurrentBalance>=1) mCurrentBalance += 1;
|
if(mCurrentBalance>=1) mCurrentBalance += 1;
|
||||||
updateLabels();
|
updateLabels();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TradeWindow::onDecreaseButtonClicked(MyGUI::Widget* _sender)
|
void TradeWindow::onDecreaseButtonTriggered()
|
||||||
{
|
{
|
||||||
if(mCurrentBalance<-1) mCurrentBalance += 1;
|
if(mCurrentBalance<-1) mCurrentBalance += 1;
|
||||||
if(mCurrentBalance>1) mCurrentBalance -= 1;
|
if(mCurrentBalance>1) mCurrentBalance -= 1;
|
||||||
|
|
|
@ -34,6 +34,8 @@ namespace MWGui
|
||||||
|
|
||||||
void addOrRemoveGold(int gold);
|
void addOrRemoveGold(int gold);
|
||||||
|
|
||||||
|
void onFrame(float frameDuration);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MyGUI::Button* mFilterAll;
|
MyGUI::Button* mFilterAll;
|
||||||
MyGUI::Button* mFilterWeapon;
|
MyGUI::Button* mFilterWeapon;
|
||||||
|
@ -57,12 +59,24 @@ namespace MWGui
|
||||||
int mCurrentBalance;
|
int mCurrentBalance;
|
||||||
int mCurrentMerchantOffer;
|
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 onWindowResize(MyGUI::Window* _sender);
|
||||||
void onFilterChanged(MyGUI::Widget* _sender);
|
void onFilterChanged(MyGUI::Widget* _sender);
|
||||||
void onOfferButtonClicked(MyGUI::Widget* _sender);
|
void onOfferButtonClicked(MyGUI::Widget* _sender);
|
||||||
void onCancelButtonClicked(MyGUI::Widget* _sender);
|
void onCancelButtonClicked(MyGUI::Widget* _sender);
|
||||||
void onIncreaseButtonClicked(MyGUI::Widget* _sender);
|
void onIncreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
|
||||||
void onDecreaseButtonClicked(MyGUI::Widget* _sender);
|
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.
|
// don't show items that the NPC has equipped in his trade-window.
|
||||||
virtual bool ignoreEquippedItems() { return true; }
|
virtual bool ignoreEquippedItems() { return true; }
|
||||||
|
|
|
@ -613,6 +613,7 @@ void WindowManager::onFrame (float frameDuration)
|
||||||
mHud->onFrame(frameDuration);
|
mHud->onFrame(frameDuration);
|
||||||
|
|
||||||
mTrainingWindow->onFrame (frameDuration);
|
mTrainingWindow->onFrame (frameDuration);
|
||||||
|
mTradeWindow->onFrame(frameDuration);
|
||||||
|
|
||||||
mTrainingWindow->checkReferenceAvailable();
|
mTrainingWindow->checkReferenceAvailable();
|
||||||
mDialogueWindow->checkReferenceAvailable();
|
mDialogueWindow->checkReferenceAvailable();
|
||||||
|
|
|
@ -590,10 +590,14 @@ namespace MWInput
|
||||||
// Toggle between game mode and inventory mode
|
// Toggle between game mode and inventory mode
|
||||||
if(gameMode)
|
if(gameMode)
|
||||||
mWindows.pushGuiMode(MWGui::GM_Inventory);
|
mWindows.pushGuiMode(MWGui::GM_Inventory);
|
||||||
else if(mWindows.getMode() == MWGui::GM_Inventory)
|
else
|
||||||
mWindows.popGuiMode();
|
{
|
||||||
|
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()
|
void InputManager::toggleConsole()
|
||||||
|
|
Loading…
Reference in a new issue