everything done except health/mana restore

actorid
scrawl 12 years ago
parent 4829f47a4f
commit bf5e30b24f

@ -285,7 +285,12 @@ namespace MWBase
virtual void setupExternalRendering (MWRender::ExternalRendering& rendering) = 0; 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); creatureStats.setLevel (creatureStats.getLevel()+1);
pcStats.levelUp (); pcStats.levelUp ();
mWindowManager.removeGuiMode (GM_Rest); mWindowManager.removeGuiMode (GM_Levelup);
} }
} }

@ -20,6 +20,7 @@ namespace MWGui
GM_Dialogue, // NPC interaction GM_Dialogue, // NPC interaction
GM_Barter, GM_Barter,
GM_Rest, GM_Rest,
GM_RestBed,
GM_SpellBuying, GM_SpellBuying,
GM_Levelup, GM_Levelup,

@ -40,7 +40,7 @@ RaceDialog::RaceDialog(MWBase::WindowManager& parWindowManager)
getWidget(mHeadRotate, "HeadRotate"); getWidget(mHeadRotate, "HeadRotate");
mHeadRotate->setScrollRange(50); mHeadRotate->setScrollRange(50);
mHeadRotate->setScrollPosition(20); mHeadRotate->setScrollPosition(25);
mHeadRotate->setScrollViewPage(10); mHeadRotate->setScrollViewPage(10);
mHeadRotate->eventScrollChangePosition += MyGUI::newDelegate(this, &RaceDialog::onHeadRotate); mHeadRotate->eventScrollChangePosition += MyGUI::newDelegate(this, &RaceDialog::onHeadRotate);

@ -9,6 +9,11 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwworld/timestamp.hpp" #include "../mwworld/timestamp.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/class.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "widgets.hpp" #include "widgets.hpp"
@ -16,8 +21,34 @@
namespace MWGui 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) WaitDialog::WaitDialog(MWBase::WindowManager &parWindowManager)
: WindowBase("openmw_wait_dialog.layout", parWindowManager) : WindowBase("openmw_wait_dialog.layout", parWindowManager)
, mProgressBar(parWindowManager)
, mWaiting(false)
, mSleeping(false)
, mHours(1)
, mRemainingTime(0.05)
{ {
getWidget(mDateTimeText, "DateTimeText"); getWidget(mDateTimeText, "DateTimeText");
getWidget(mRestText, "RestText"); getWidget(mRestText, "RestText");
@ -32,11 +63,27 @@ namespace MWGui
mWaitButton->eventMouseButtonClick += MyGUI::newDelegate(this, &WaitDialog::onWaitButtonClicked); mWaitButton->eventMouseButtonClick += MyGUI::newDelegate(this, &WaitDialog::onWaitButtonClicked);
mHourSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &WaitDialog::onHourSliderChangedPosition); mHourSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &WaitDialog::onHourSliderChangedPosition);
mProgressBar.setVisible (false);
} }
void WaitDialog::open() 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); onHourSliderChangedPosition(mHourSlider, 0);
mHourSlider->setScrollPosition (0); mHourSlider->setScrollPosition (0);
@ -79,28 +126,38 @@ namespace MWGui
+ ") " + boost::lexical_cast<std::string>(hour) + " " + (pm ? "#{sSaveMenuHelp05}" : "#{sSaveMenuHelp04}"); + ") " + boost::lexical_cast<std::string>(hour) + " " + (pm ? "#{sSaveMenuHelp05}" : "#{sSaveMenuHelp04}");
mDateTimeText->setCaptionWithReplacing (dateTimeText); mDateTimeText->setCaptionWithReplacing (dateTimeText);
center();
} }
void WaitDialog::onUntilHealedButtonClicked(MyGUI::Widget* sender) void WaitDialog::onUntilHealedButtonClicked(MyGUI::Widget* sender)
{ {
startWaiting();
} }
void WaitDialog::onWaitButtonClicked(MyGUI::Widget* sender) 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) void WaitDialog::onCancelButtonClicked(MyGUI::Widget* sender)
{ {
mWindowManager.removeGuiMode (GM_Rest); mWindowManager.popGuiMode ();
} }
void WaitDialog::onHourSliderChangedPosition(MyGUI::ScrollBar* sender, size_t position) void WaitDialog::onHourSliderChangedPosition(MyGUI::ScrollBar* sender, size_t position)
{ {
mHourText->setCaptionWithReplacing (boost::lexical_cast<std::string>(position+1) + " #{sRestMenu2}"); mHourText->setCaptionWithReplacing (boost::lexical_cast<std::string>(position+1) + " #{sRestMenu2}");
mHours = position+1;
} }
void WaitDialog::setCanRest (bool canRest) void WaitDialog::setCanRest (bool canRest)
@ -108,6 +165,49 @@ namespace MWGui
mUntilHealedButton->setVisible(canRest); mUntilHealedButton->setVisible(canRest);
mWaitButton->setCaptionWithReplacing (canRest ? "#{sRest}" : "#{sWait}"); mWaitButton->setCaptionWithReplacing (canRest ? "#{sRest}" : "#{sWait}");
mRestText->setCaptionWithReplacing (canRest ? "#{sRestMenu3}" : "#{sRestIllegal}"); 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 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 class WaitDialog : public WindowBase
{ {
public: public:
@ -13,6 +27,10 @@ namespace MWGui
virtual void open(); virtual void open();
void onFrame(float dt);
void bedActivated() { setCanRest(true); }
protected: protected:
MyGUI::TextBox* mDateTimeText; MyGUI::TextBox* mDateTimeText;
MyGUI::TextBox* mRestText; MyGUI::TextBox* mRestText;
@ -22,12 +40,23 @@ namespace MWGui
MyGUI::Button* mWaitButton; MyGUI::Button* mWaitButton;
MyGUI::Button* mCancelButton; MyGUI::Button* mCancelButton;
bool mWaiting;
bool mSleeping;
int mCurHour;
int mHours;
float mRemainingTime;
WaitDialogProgressBar mProgressBar;
void onUntilHealedButtonClicked(MyGUI::Widget* sender); void onUntilHealedButtonClicked(MyGUI::Widget* sender);
void onWaitButtonClicked(MyGUI::Widget* sender); void onWaitButtonClicked(MyGUI::Widget* sender);
void onCancelButtonClicked(MyGUI::Widget* sender); void onCancelButtonClicked(MyGUI::Widget* sender);
void onHourSliderChangedPosition(MyGUI::ScrollBar* sender, size_t position); void onHourSliderChangedPosition(MyGUI::ScrollBar* sender, size_t position);
void setCanRest(bool canRest); void setCanRest(bool canRest);
void startWaiting();
void stopWaiting();
}; };
} }

@ -795,7 +795,6 @@ void MWDynamicStat::initialiseOverride()
// --------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------
void AutoSizedWidget::notifySizeChange (MyGUI::Widget* w) void AutoSizedWidget::notifySizeChange (MyGUI::Widget* w)
{ {
if (w->getParent () != 0) if (w->getParent () != 0)

@ -310,9 +310,15 @@ void WindowManager::updateVisible()
mAlchemyWindow->setVisible(true); mAlchemyWindow->setVisible(true);
break; break;
case GM_Rest: case GM_Rest:
//mLevelupDialog->setVisible(true);
mWaitDialog->setVisible(true); mWaitDialog->setVisible(true);
break; break;
case GM_RestBed:
mWaitDialog->setVisible(true);
mWaitDialog->bedActivated();
break;
case GM_Levelup:
mLevelupDialog->setVisible(true);
break;
case GM_Name: case GM_Name:
case GM_Race: case GM_Race:
case GM_Class: case GM_Class:
@ -547,6 +553,8 @@ void WindowManager::onFrame (float frameDuration)
mStatsWindow->onFrame(); mStatsWindow->onFrame();
mWaitDialog->onFrame(frameDuration);
mHud->onFrame(frameDuration); mHud->onFrame(frameDuration);
mDialogueWindow->checkReferenceAvailable(); mDialogueWindow->checkReferenceAvailable();

@ -160,7 +160,7 @@ opcodeEnableStatsReviewMenu);
new OpEnableRest ()); new OpEnableRest ());
interpreter.installSegment5 (opcodeShowRestMenu, interpreter.installSegment5 (opcodeShowRestMenu,
new OpShowDialogue (MWGui::GM_Rest)); new OpShowDialogue (MWGui::GM_RestBed));
interpreter.installSegment5 (opcodeGetButtonPressed, new OpGetButtonPressed); interpreter.installSegment5 (opcodeGetButtonPressed, new OpGetButtonPressed);

@ -1252,13 +1252,27 @@ namespace MWWorld
mRendering->setupExternalRendering (rendering); mRendering->setupExternalRendering (rendering);
} }
bool World::canRest () int World::canRest ()
{ {
Ptr::CellStore *currentCell = mWorldScene->getCurrentCell(); 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) if (currentCell->cell->data.flags & ESM::Cell::NoSleep)
return false; return 1;
else
return true; return 0;
} }
} }

@ -316,7 +316,12 @@ namespace MWWorld
virtual void setupExternalRendering (MWRender::ExternalRendering& rendering); 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_loading_screen.layout
openmw_levelup_dialog.layout openmw_levelup_dialog.layout
openmw_wait_dialog.layout openmw_wait_dialog.layout
openmw_wait_dialog_progressbar.layout
smallbars.png smallbars.png
VeraMono.ttf VeraMono.ttf
markers.png markers.png

@ -77,8 +77,9 @@
<!-- Buttons --> <!-- Buttons -->
<Widget type="HBox" skin="" position="160 370 380 24"> <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"> <Widget type="AutoSizedButton" skin="MW_Button" name="CreateButton">
<Property key="Caption" value="#{sCreate}"/> <Property key="Caption" value="#{sCreate}"/>
</Widget> </Widget>

@ -15,7 +15,9 @@
<!-- Dialog buttons --> <!-- Dialog buttons -->
<Widget type="HBox" position="0 340 473 24"> <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"> <Widget type="AutoSizedButton" skin="MW_Button" name="BackButton">
<Property key="Caption" value="#{sBack}"/> <Property key="Caption" value="#{sBack}"/>
</Widget> </Widget>

@ -61,7 +61,9 @@
<!-- Dialog buttons --> <!-- Dialog buttons -->
<Widget type="HBox" position="0 265 476 24"> <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"> <Widget type="AutoSizedButton" skin="MW_Button" name="BackButton">
<Property key="Caption" value="#{sBack}"/> <Property key="Caption" value="#{sBack}"/>
</Widget> </Widget>

@ -59,7 +59,9 @@
<!-- Dialog buttons --> <!-- Dialog buttons -->
<Widget type="HBox" position="0 158 459 24"> <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"> <Widget type="AutoSizedButton" skin="MW_Button" name="DescriptionButton">
<Property key="Caption" value="#{sCreateClassMenu1}"/> <Property key="Caption" value="#{sCreateClassMenu1}"/>
</Widget> </Widget>

@ -21,7 +21,9 @@
<!-- Dialog buttons --> <!-- Dialog buttons -->
<Widget type="HBox" position="0 219 319 24"> <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"> <Widget type="AutoSizedButton" skin="MW_Button" name="BackButton">
<Property key="Caption" value="#{sBack}"/> <Property key="Caption" value="#{sBack}"/>
</Widget> </Widget>

@ -57,7 +57,10 @@
<!-- Dialog buttons --> <!-- Dialog buttons -->
<Widget type="HBox" position="0 397 574 24"> <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"> <Widget type="AutoSizedButton" skin="MW_Button" position="471 397 53 23" name="BackButton">
<Property key="Caption" value="#{sBack}"/> <Property key="Caption" value="#{sBack}"/>
</Widget> </Widget>

@ -112,7 +112,9 @@
<!-- Dialog buttons --> <!-- Dialog buttons -->
<Widget type="HBox" position="0 372 502 24"> <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"> <Widget type="AutoSizedButton" skin="MW_Button" name="BackButton">
<Property key="Caption" value="#{sBack}"/> <Property key="Caption" value="#{sBack}"/>
</Widget> </Widget>

@ -14,7 +14,9 @@
</Widget> </Widget>
<Widget type="HBox" position="0 84 272 24" align="Right Bottom"> <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"> <Widget type="AutoSizedButton" skin="MW_Button" name="CancelButton" align="Right Bottom">
<Property key="Caption" value="#{sCancel}"/> <Property key="Caption" value="#{sCancel}"/>
</Widget> </Widget>

@ -12,7 +12,9 @@
</Widget> </Widget>
<Widget type="HBox" position="0 235 580 24" align="Right Bottom"> <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"> <Widget type="AutoSizedButton" skin="MW_Button" name="TakeButton" align="Right Bottom">
<Property key="Caption" value="#{sTakeAll}"/> <Property key="Caption" value="#{sTakeAll}"/>
</Widget> </Widget>

@ -22,7 +22,9 @@
<Widget type="HBox" position="0 90 572 24" align="Right Bottom"> <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"> <Widget type="AutoSizedButton" skin="MW_Button" position="417 90 60 24" name="CancelButton" align="Right Top">
<Property key="Caption" value="#{sCancel}"/> <Property key="Caption" value="#{sCancel}"/>
</Widget> </Widget>

@ -56,7 +56,9 @@
</Widget> </Widget>
<Widget type="HBox" position="0 60 566 24" align="Right Bottom"> <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"> <Widget type="AutoSizedButton" skin="MW_Button" name="OfferButton" align="Right Top">
<Property key="Caption" value="#{sBarterDialog8}"/> <Property key="Caption" value="#{sBarterDialog8}"/>
</Widget> </Widget>

@ -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(); Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
node->attachObject(mRectangle); node->attachObject(mRectangle);
mRectangle->setVisible(false); mRectangle->setVisible(false);
mRectangle->setVisibilityFlags (0x01);
} }
Fader::~Fader() Fader::~Fader()

Loading…
Cancel
Save