forked from teamnwah/openmw-tes3coop
everything done except health/mana restore
This commit is contained in:
parent
4829f47a4f
commit
bf5e30b24f
25 changed files with 228 additions and 30 deletions
|
@ -285,7 +285,12 @@ namespace MWBase
|
|||
|
||||
virtual void setupExternalRendering (MWRender::ExternalRendering& rendering) = 0;
|
||||
|
||||
virtual bool canRest() = 0;
|
||||
virtual int canRest() = 0;
|
||||
///< check if the player is allowed to rest \n
|
||||
/// 0 - yes \n
|
||||
/// 1 - only waiting \n
|
||||
/// 2 - player is underwater \n
|
||||
/// 3 - enemies are nearby (not implemented)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ namespace MWGui
|
|||
creatureStats.setLevel (creatureStats.getLevel()+1);
|
||||
pcStats.levelUp ();
|
||||
|
||||
mWindowManager.removeGuiMode (GM_Rest);
|
||||
mWindowManager.removeGuiMode (GM_Levelup);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace MWGui
|
|||
GM_Dialogue, // NPC interaction
|
||||
GM_Barter,
|
||||
GM_Rest,
|
||||
GM_RestBed,
|
||||
GM_SpellBuying,
|
||||
|
||||
GM_Levelup,
|
||||
|
|
|
@ -40,7 +40,7 @@ RaceDialog::RaceDialog(MWBase::WindowManager& parWindowManager)
|
|||
|
||||
getWidget(mHeadRotate, "HeadRotate");
|
||||
mHeadRotate->setScrollRange(50);
|
||||
mHeadRotate->setScrollPosition(20);
|
||||
mHeadRotate->setScrollPosition(25);
|
||||
mHeadRotate->setScrollViewPage(10);
|
||||
mHeadRotate->eventScrollChangePosition += MyGUI::newDelegate(this, &RaceDialog::onHeadRotate);
|
||||
|
||||
|
|
|
@ -9,6 +9,11 @@
|
|||
#include "../mwbase/environment.hpp"
|
||||
|
||||
#include "../mwworld/timestamp.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
#include "../mwmechanics/npcstats.hpp"
|
||||
|
||||
#include "widgets.hpp"
|
||||
|
||||
|
@ -16,8 +21,34 @@
|
|||
namespace MWGui
|
||||
{
|
||||
|
||||
WaitDialogProgressBar::WaitDialogProgressBar(MWBase::WindowManager &parWindowManager)
|
||||
: WindowBase("openmw_wait_dialog_progressbar.layout", parWindowManager)
|
||||
{
|
||||
getWidget(mProgressBar, "ProgressBar");
|
||||
getWidget(mProgressText, "ProgressText");
|
||||
}
|
||||
|
||||
void WaitDialogProgressBar::open()
|
||||
{
|
||||
center();
|
||||
}
|
||||
|
||||
void WaitDialogProgressBar::setProgress (int cur, int total)
|
||||
{
|
||||
mProgressBar->setProgressRange (total);
|
||||
mProgressBar->setProgressPosition (cur);
|
||||
mProgressText->setCaption(boost::lexical_cast<std::string>(cur) + "/" + boost::lexical_cast<std::string>(total));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------
|
||||
|
||||
WaitDialog::WaitDialog(MWBase::WindowManager &parWindowManager)
|
||||
: WindowBase("openmw_wait_dialog.layout", parWindowManager)
|
||||
, mProgressBar(parWindowManager)
|
||||
, mWaiting(false)
|
||||
, mSleeping(false)
|
||||
, mHours(1)
|
||||
, mRemainingTime(0.05)
|
||||
{
|
||||
getWidget(mDateTimeText, "DateTimeText");
|
||||
getWidget(mRestText, "RestText");
|
||||
|
@ -32,11 +63,27 @@ namespace MWGui
|
|||
mWaitButton->eventMouseButtonClick += MyGUI::newDelegate(this, &WaitDialog::onWaitButtonClicked);
|
||||
|
||||
mHourSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &WaitDialog::onHourSliderChangedPosition);
|
||||
|
||||
mProgressBar.setVisible (false);
|
||||
}
|
||||
|
||||
void WaitDialog::open()
|
||||
{
|
||||
setCanRest(MWBase::Environment::get().getWorld ()->canRest ());
|
||||
if (!MWBase::Environment::get().getWindowManager ()->getRestEnabled ())
|
||||
{
|
||||
mWindowManager.popGuiMode ();
|
||||
}
|
||||
|
||||
int canRest = MWBase::Environment::get().getWorld ()->canRest ();
|
||||
|
||||
if (canRest == 2)
|
||||
{
|
||||
// resting underwater or mid-air not allowed
|
||||
mWindowManager.messageBox ("#{sNotifyMessage1}", std::vector<std::string>());
|
||||
mWindowManager.popGuiMode ();
|
||||
}
|
||||
|
||||
setCanRest(canRest == 0);
|
||||
|
||||
onHourSliderChangedPosition(mHourSlider, 0);
|
||||
mHourSlider->setScrollPosition (0);
|
||||
|
@ -79,28 +126,38 @@ namespace MWGui
|
|||
+ ") " + boost::lexical_cast<std::string>(hour) + " " + (pm ? "#{sSaveMenuHelp05}" : "#{sSaveMenuHelp04}");
|
||||
|
||||
mDateTimeText->setCaptionWithReplacing (dateTimeText);
|
||||
|
||||
center();
|
||||
}
|
||||
|
||||
void WaitDialog::onUntilHealedButtonClicked(MyGUI::Widget* sender)
|
||||
{
|
||||
|
||||
startWaiting();
|
||||
}
|
||||
|
||||
void WaitDialog::onWaitButtonClicked(MyGUI::Widget* sender)
|
||||
{
|
||||
//MWBase::Environment::get().getWorld ()->getFader ()->fadeOut(1);
|
||||
startWaiting();
|
||||
}
|
||||
|
||||
void WaitDialog::startWaiting ()
|
||||
{
|
||||
MWBase::Environment::get().getWorld ()->getFader ()->fadeOut(0.2);
|
||||
setVisible(false);
|
||||
mProgressBar.setVisible (true);
|
||||
mWaiting = true;
|
||||
mCurHour = 0;
|
||||
mRemainingTime = 0.05;
|
||||
mProgressBar.setProgress (0, mHours);
|
||||
}
|
||||
|
||||
void WaitDialog::onCancelButtonClicked(MyGUI::Widget* sender)
|
||||
{
|
||||
mWindowManager.removeGuiMode (GM_Rest);
|
||||
mWindowManager.popGuiMode ();
|
||||
}
|
||||
|
||||
void WaitDialog::onHourSliderChangedPosition(MyGUI::ScrollBar* sender, size_t position)
|
||||
{
|
||||
mHourText->setCaptionWithReplacing (boost::lexical_cast<std::string>(position+1) + " #{sRestMenu2}");
|
||||
mHours = position+1;
|
||||
}
|
||||
|
||||
void WaitDialog::setCanRest (bool canRest)
|
||||
|
@ -108,6 +165,49 @@ namespace MWGui
|
|||
mUntilHealedButton->setVisible(canRest);
|
||||
mWaitButton->setCaptionWithReplacing (canRest ? "#{sRest}" : "#{sWait}");
|
||||
mRestText->setCaptionWithReplacing (canRest ? "#{sRestMenu3}" : "#{sRestIllegal}");
|
||||
|
||||
mSleeping = canRest;
|
||||
|
||||
dynamic_cast<Widgets::Box*>(mMainWidget)->notifyChildrenSizeChanged();
|
||||
center();
|
||||
}
|
||||
|
||||
void WaitDialog::onFrame(float dt)
|
||||
{
|
||||
if (!mWaiting)
|
||||
return;
|
||||
|
||||
mRemainingTime -= dt;
|
||||
|
||||
if (mRemainingTime < 0)
|
||||
{
|
||||
mRemainingTime = 0.05;
|
||||
++mCurHour;
|
||||
mProgressBar.setProgress (mCurHour, mHours);
|
||||
|
||||
if (mCurHour <= mHours)
|
||||
MWBase::Environment::get().getWorld ()->advanceTime (1);
|
||||
}
|
||||
|
||||
if (mCurHour > mHours)
|
||||
stopWaiting();
|
||||
}
|
||||
|
||||
void WaitDialog::stopWaiting ()
|
||||
{
|
||||
MWBase::Environment::get().getWorld ()->getFader ()->fadeIn(0.2);
|
||||
mProgressBar.setVisible (false);
|
||||
mWindowManager.popGuiMode ();
|
||||
mWaiting = false;
|
||||
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
MWMechanics::NpcStats pcstats = MWWorld::Class::get(player).getNpcStats(player);
|
||||
|
||||
// trigger levelup if possible
|
||||
if (mSleeping && pcstats.getLevelProgress () >= 10)
|
||||
{
|
||||
mWindowManager.pushGuiMode (GM_Levelup);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,20 @@
|
|||
namespace MWGui
|
||||
{
|
||||
|
||||
class WaitDialogProgressBar : public WindowBase
|
||||
{
|
||||
public:
|
||||
WaitDialogProgressBar(MWBase::WindowManager& parWindowManager);
|
||||
|
||||
virtual void open();
|
||||
|
||||
void setProgress(int cur, int total);
|
||||
|
||||
protected:
|
||||
MyGUI::ProgressBar* mProgressBar;
|
||||
MyGUI::TextBox* mProgressText;
|
||||
};
|
||||
|
||||
class WaitDialog : public WindowBase
|
||||
{
|
||||
public:
|
||||
|
@ -13,6 +27,10 @@ namespace MWGui
|
|||
|
||||
virtual void open();
|
||||
|
||||
void onFrame(float dt);
|
||||
|
||||
void bedActivated() { setCanRest(true); }
|
||||
|
||||
protected:
|
||||
MyGUI::TextBox* mDateTimeText;
|
||||
MyGUI::TextBox* mRestText;
|
||||
|
@ -22,12 +40,23 @@ namespace MWGui
|
|||
MyGUI::Button* mWaitButton;
|
||||
MyGUI::Button* mCancelButton;
|
||||
|
||||
bool mWaiting;
|
||||
bool mSleeping;
|
||||
int mCurHour;
|
||||
int mHours;
|
||||
float mRemainingTime;
|
||||
|
||||
WaitDialogProgressBar mProgressBar;
|
||||
|
||||
void onUntilHealedButtonClicked(MyGUI::Widget* sender);
|
||||
void onWaitButtonClicked(MyGUI::Widget* sender);
|
||||
void onCancelButtonClicked(MyGUI::Widget* sender);
|
||||
void onHourSliderChangedPosition(MyGUI::ScrollBar* sender, size_t position);
|
||||
|
||||
void setCanRest(bool canRest);
|
||||
|
||||
void startWaiting();
|
||||
void stopWaiting();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -795,7 +795,6 @@ void MWDynamicStat::initialiseOverride()
|
|||
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void AutoSizedWidget::notifySizeChange (MyGUI::Widget* w)
|
||||
{
|
||||
if (w->getParent () != 0)
|
||||
|
|
|
@ -310,9 +310,15 @@ void WindowManager::updateVisible()
|
|||
mAlchemyWindow->setVisible(true);
|
||||
break;
|
||||
case GM_Rest:
|
||||
//mLevelupDialog->setVisible(true);
|
||||
mWaitDialog->setVisible(true);
|
||||
break;
|
||||
case GM_RestBed:
|
||||
mWaitDialog->setVisible(true);
|
||||
mWaitDialog->bedActivated();
|
||||
break;
|
||||
case GM_Levelup:
|
||||
mLevelupDialog->setVisible(true);
|
||||
break;
|
||||
case GM_Name:
|
||||
case GM_Race:
|
||||
case GM_Class:
|
||||
|
@ -547,6 +553,8 @@ void WindowManager::onFrame (float frameDuration)
|
|||
|
||||
mStatsWindow->onFrame();
|
||||
|
||||
mWaitDialog->onFrame(frameDuration);
|
||||
|
||||
mHud->onFrame(frameDuration);
|
||||
|
||||
mDialogueWindow->checkReferenceAvailable();
|
||||
|
|
|
@ -160,7 +160,7 @@ opcodeEnableStatsReviewMenu);
|
|||
new OpEnableRest ());
|
||||
|
||||
interpreter.installSegment5 (opcodeShowRestMenu,
|
||||
new OpShowDialogue (MWGui::GM_Rest));
|
||||
new OpShowDialogue (MWGui::GM_RestBed));
|
||||
|
||||
interpreter.installSegment5 (opcodeGetButtonPressed, new OpGetButtonPressed);
|
||||
|
||||
|
|
|
@ -1252,13 +1252,27 @@ namespace MWWorld
|
|||
mRendering->setupExternalRendering (rendering);
|
||||
}
|
||||
|
||||
bool World::canRest ()
|
||||
int World::canRest ()
|
||||
{
|
||||
Ptr::CellStore *currentCell = mWorldScene->getCurrentCell();
|
||||
assert (currentCell);
|
||||
|
||||
Ogre::Vector3 playerPos;
|
||||
float* pos = mPlayer->getPlayer ().getRefData ().getPosition ().pos;
|
||||
playerPos.x = pos[0];
|
||||
playerPos.y = pos[1];
|
||||
playerPos.z = pos[2];
|
||||
|
||||
std::pair<bool, Ogre::Vector3> hit =
|
||||
mPhysics->castRay(playerPos, Ogre::Vector3(0,0,-1), 50);
|
||||
bool isOnGround = (hit.first ? (hit.second.distance (playerPos) < 25) : false);
|
||||
|
||||
if (!isOnGround || isUnderwater (*currentCell->cell, playerPos))
|
||||
return 2;
|
||||
|
||||
if (currentCell->cell->data.flags & ESM::Cell::NoSleep)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -316,7 +316,12 @@ namespace MWWorld
|
|||
|
||||
virtual void setupExternalRendering (MWRender::ExternalRendering& rendering);
|
||||
|
||||
virtual bool canRest();
|
||||
virtual int canRest();
|
||||
///< check if the player is allowed to rest \n
|
||||
/// 0 - yes \n
|
||||
/// 1 - only waiting \n
|
||||
/// 2 - player is underwater \n
|
||||
/// 3 - enemies are nearby (not implemented)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ set(MYGUI_FILES
|
|||
openmw_loading_screen.layout
|
||||
openmw_levelup_dialog.layout
|
||||
openmw_wait_dialog.layout
|
||||
openmw_wait_dialog_progressbar.layout
|
||||
smallbars.png
|
||||
VeraMono.ttf
|
||||
markers.png
|
||||
|
|
|
@ -77,8 +77,9 @@
|
|||
|
||||
<!-- Buttons -->
|
||||
<Widget type="HBox" skin="" position="160 370 380 24">
|
||||
<Widget type="Widget"/> <!-- spacer -->
|
||||
|
||||
<Widget type="Widget">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="CreateButton">
|
||||
<Property key="Caption" value="#{sCreate}"/>
|
||||
</Widget>
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
|
||||
<!-- Dialog buttons -->
|
||||
<Widget type="HBox" position="0 340 473 24">
|
||||
<Widget type="Widget"/> <!-- spacer -->
|
||||
<Widget type="Widget">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="BackButton">
|
||||
<Property key="Caption" value="#{sBack}"/>
|
||||
</Widget>
|
||||
|
|
|
@ -61,7 +61,9 @@
|
|||
|
||||
<!-- Dialog buttons -->
|
||||
<Widget type="HBox" position="0 265 476 24">
|
||||
<Widget type="Widget"/> <!-- spacer -->
|
||||
<Widget type="Widget">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="BackButton">
|
||||
<Property key="Caption" value="#{sBack}"/>
|
||||
</Widget>
|
||||
|
|
|
@ -59,7 +59,9 @@
|
|||
|
||||
<!-- Dialog buttons -->
|
||||
<Widget type="HBox" position="0 158 459 24">
|
||||
<Widget type="Widget"/> <!-- spacer -->
|
||||
<Widget type="Widget">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="DescriptionButton">
|
||||
<Property key="Caption" value="#{sCreateClassMenu1}"/>
|
||||
</Widget>
|
||||
|
|
|
@ -21,7 +21,9 @@
|
|||
|
||||
<!-- Dialog buttons -->
|
||||
<Widget type="HBox" position="0 219 319 24">
|
||||
<Widget type="Widget"/> <!-- spacer -->
|
||||
<Widget type="Widget">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="BackButton">
|
||||
<Property key="Caption" value="#{sBack}"/>
|
||||
</Widget>
|
||||
|
|
|
@ -57,7 +57,10 @@
|
|||
|
||||
<!-- Dialog buttons -->
|
||||
<Widget type="HBox" position="0 397 574 24">
|
||||
<Widget type="Widget"/>
|
||||
<Widget type="Widget">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" position="471 397 53 23" name="BackButton">
|
||||
<Property key="Caption" value="#{sBack}"/>
|
||||
</Widget>
|
||||
|
|
|
@ -112,7 +112,9 @@
|
|||
|
||||
<!-- Dialog buttons -->
|
||||
<Widget type="HBox" position="0 372 502 24">
|
||||
<Widget type="Widget"/>
|
||||
<Widget type="Widget">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="BackButton">
|
||||
<Property key="Caption" value="#{sBack}"/>
|
||||
</Widget>
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
</Widget>
|
||||
|
||||
<Widget type="HBox" position="0 84 272 24" align="Right Bottom">
|
||||
<Widget type="Widget"/> <!-- spacer -->
|
||||
<Widget type="Widget">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="CancelButton" align="Right Bottom">
|
||||
<Property key="Caption" value="#{sCancel}"/>
|
||||
</Widget>
|
||||
|
|
|
@ -12,7 +12,9 @@
|
|||
</Widget>
|
||||
|
||||
<Widget type="HBox" position="0 235 580 24" align="Right Bottom">
|
||||
<Widget type="Widget"/>
|
||||
<Widget type="Widget">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="TakeButton" align="Right Bottom">
|
||||
<Property key="Caption" value="#{sTakeAll}"/>
|
||||
</Widget>
|
||||
|
|
|
@ -22,7 +22,9 @@
|
|||
|
||||
|
||||
<Widget type="HBox" position="0 90 572 24" align="Right Bottom">
|
||||
<Widget type="Widget"/> <!-- spacer -->
|
||||
<Widget type="Widget">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" position="417 90 60 24" name="CancelButton" align="Right Top">
|
||||
<Property key="Caption" value="#{sCancel}"/>
|
||||
</Widget>
|
||||
|
|
|
@ -56,7 +56,9 @@
|
|||
</Widget>
|
||||
|
||||
<Widget type="HBox" position="0 60 566 24" align="Right Bottom">
|
||||
<Widget type="Widget"/>
|
||||
<Widget type="Widget">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="OfferButton" align="Right Top">
|
||||
<Property key="Caption" value="#{sBarterDialog8}"/>
|
||||
</Widget>
|
||||
|
|
13
files/mygui/openmw_wait_dialog_progressbar.layout
Normal file
13
files/mygui/openmw_wait_dialog_progressbar.layout
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MyGUI type="Layout">
|
||||
<Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 219 40" name="_Main">
|
||||
|
||||
<Widget type="ProgressBar" skin="MW_Progress_Blue" position="5 6 199 20" name="ProgressBar">
|
||||
<Widget type="TextBox" skin="SandText" position="0 0 199 20" name="ProgressText">
|
||||
<Property key="TextAlign" value="Center"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
</Widget>
|
||||
</MyGUI>
|
|
@ -39,6 +39,7 @@ Fader::Fader(Ogre::SceneManager* sceneMgr)
|
|||
Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
|
||||
node->attachObject(mRectangle);
|
||||
mRectangle->setVisible(false);
|
||||
mRectangle->setVisibilityFlags (0x01);
|
||||
}
|
||||
|
||||
Fader::~Fader()
|
||||
|
|
Loading…
Reference in a new issue