forked from teamnwah/openmw-tes3coop
date time label
This commit is contained in:
parent
0ba996f290
commit
ab698bb401
7 changed files with 159 additions and 9 deletions
|
@ -160,6 +160,9 @@ namespace MWBase
|
||||||
virtual void setDay (int day) = 0;
|
virtual void setDay (int day) = 0;
|
||||||
///< Set in-game time day.
|
///< Set in-game time day.
|
||||||
|
|
||||||
|
virtual int getDay() = 0;
|
||||||
|
virtual int getMonth() = 0;
|
||||||
|
|
||||||
virtual MWWorld::TimeStamp getTimeStamp() const = 0;
|
virtual MWWorld::TimeStamp getTimeStamp() const = 0;
|
||||||
///< Return current in-game time stamp.
|
///< Return current in-game time stamp.
|
||||||
|
|
||||||
|
@ -281,6 +284,8 @@ namespace MWBase
|
||||||
virtual void renderPlayer() = 0;
|
virtual void renderPlayer() = 0;
|
||||||
|
|
||||||
virtual void setupExternalRendering (MWRender::ExternalRendering& rendering) = 0;
|
virtual void setupExternalRendering (MWRender::ExternalRendering& rendering) = 0;
|
||||||
|
|
||||||
|
virtual bool canRest() = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,113 @@
|
||||||
#include "waitdialog.hpp"
|
#include "waitdialog.hpp"
|
||||||
|
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
|
#include <libs/openengine/ogre/fader.hpp>
|
||||||
|
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/environment.hpp"
|
||||||
|
|
||||||
|
#include "../mwworld/timestamp.hpp"
|
||||||
|
|
||||||
|
#include "widgets.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
|
|
||||||
WaitDialog::WaitDialog(MWBase::WindowManager &parWindowManager)
|
WaitDialog::WaitDialog(MWBase::WindowManager &parWindowManager)
|
||||||
: WindowBase("openmw_wait_dialog.layout", parWindowManager)
|
: WindowBase("openmw_wait_dialog.layout", parWindowManager)
|
||||||
{
|
{
|
||||||
|
getWidget(mDateTimeText, "DateTimeText");
|
||||||
|
getWidget(mRestText, "RestText");
|
||||||
|
getWidget(mHourText, "HourText");
|
||||||
|
getWidget(mHourSlider, "HourSlider");
|
||||||
|
getWidget(mUntilHealedButton, "UntilHealedButton");
|
||||||
|
getWidget(mWaitButton, "WaitButton");
|
||||||
|
getWidget(mCancelButton, "CancelButton");
|
||||||
|
|
||||||
|
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &WaitDialog::onCancelButtonClicked);
|
||||||
|
mUntilHealedButton->eventMouseButtonClick += MyGUI::newDelegate(this, &WaitDialog::onUntilHealedButtonClicked);
|
||||||
|
mWaitButton->eventMouseButtonClick += MyGUI::newDelegate(this, &WaitDialog::onWaitButtonClicked);
|
||||||
|
|
||||||
|
mHourSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &WaitDialog::onHourSliderChangedPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaitDialog::open()
|
||||||
|
{
|
||||||
|
setCanRest(MWBase::Environment::get().getWorld ()->canRest ());
|
||||||
|
|
||||||
|
onHourSliderChangedPosition(mHourSlider, 0);
|
||||||
|
mHourSlider->setScrollPosition (0);
|
||||||
|
|
||||||
|
// http://www.uesp.net/wiki/Lore:Calendar
|
||||||
|
std::string month;
|
||||||
|
int m = MWBase::Environment::get().getWorld ()->getMonth ();
|
||||||
|
if (m == 0)
|
||||||
|
month = "#{sMonthMorningstar}";
|
||||||
|
else if (m == 1)
|
||||||
|
month = "#{sMonthSunsdawn}";
|
||||||
|
else if (m == 2)
|
||||||
|
month = "#{sMonthFirstseed}";
|
||||||
|
else if (m == 3)
|
||||||
|
month = "#{sMonthRainshand}";
|
||||||
|
else if (m == 4)
|
||||||
|
month = "#{sMonthSecondseed}";
|
||||||
|
else if (m == 5)
|
||||||
|
month = "#{sMonthMidyear}";
|
||||||
|
else if (m == 6)
|
||||||
|
month = "#{sMonthSunsheight}";
|
||||||
|
else if (m == 7)
|
||||||
|
month = "#{sMonthLastseed}";
|
||||||
|
else if (m == 8)
|
||||||
|
month = "#{sMonthHeartfire}";
|
||||||
|
else if (m == 9)
|
||||||
|
month = "#{sMonthFrostfall}";
|
||||||
|
else if (m == 10)
|
||||||
|
month = "#{sMonthSunsdusk}";
|
||||||
|
else if (m == 11)
|
||||||
|
month = "#{sMonthEveningstar}";
|
||||||
|
|
||||||
|
int hour = MWBase::Environment::get().getWorld ()->getTimeStamp ().getHour ();
|
||||||
|
bool pm = hour >= 12;
|
||||||
|
if (hour >= 13) hour -= 12;
|
||||||
|
|
||||||
|
std::string dateTimeText =
|
||||||
|
boost::lexical_cast<std::string>(MWBase::Environment::get().getWorld ()->getDay ()+1) + " "
|
||||||
|
+ month + " (#{sDay} " + boost::lexical_cast<std::string>(MWBase::Environment::get().getWorld ()->getTimeStamp ().getDay ()+1)
|
||||||
|
+ ") " + boost::lexical_cast<std::string>(hour) + " " + (pm ? "#{sSaveMenuHelp05}" : "#{sSaveMenuHelp04}");
|
||||||
|
|
||||||
|
mDateTimeText->setCaptionWithReplacing (dateTimeText);
|
||||||
|
|
||||||
center();
|
center();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WaitDialog::onUntilHealedButtonClicked(MyGUI::Widget* sender)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaitDialog::onWaitButtonClicked(MyGUI::Widget* sender)
|
||||||
|
{
|
||||||
|
//MWBase::Environment::get().getWorld ()->getFader ()->fadeOut(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaitDialog::onCancelButtonClicked(MyGUI::Widget* sender)
|
||||||
|
{
|
||||||
|
mWindowManager.removeGuiMode (GM_Rest);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaitDialog::onHourSliderChangedPosition(MyGUI::ScrollBar* sender, size_t position)
|
||||||
|
{
|
||||||
|
mHourText->setCaptionWithReplacing (boost::lexical_cast<std::string>(position+1) + " #{sRestMenu2}");
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaitDialog::setCanRest (bool canRest)
|
||||||
|
{
|
||||||
|
mUntilHealedButton->setVisible(canRest);
|
||||||
|
mWaitButton->setCaptionWithReplacing (canRest ? "#{sRest}" : "#{sWait}");
|
||||||
|
mRestText->setCaptionWithReplacing (canRest ? "#{sRestMenu3}" : "#{sRestIllegal}");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,23 @@ namespace MWGui
|
||||||
public:
|
public:
|
||||||
WaitDialog(MWBase::WindowManager& parWindowManager);
|
WaitDialog(MWBase::WindowManager& parWindowManager);
|
||||||
|
|
||||||
|
virtual void open();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
MyGUI::TextBox* mDateTimeText;
|
||||||
|
MyGUI::TextBox* mRestText;
|
||||||
|
MyGUI::TextBox* mHourText;
|
||||||
|
MyGUI::ScrollBar* mHourSlider;
|
||||||
|
MyGUI::Button* mUntilHealedButton;
|
||||||
|
MyGUI::Button* mWaitButton;
|
||||||
|
MyGUI::Button* mCancelButton;
|
||||||
|
|
||||||
|
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);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -998,7 +998,10 @@ MyGUI::IntSize HBox::getRequestedSize ()
|
||||||
{
|
{
|
||||||
MyGUI::IntSize requested = getChildAt(i)->getSize ();
|
MyGUI::IntSize requested = getChildAt(i)->getSize ();
|
||||||
size.height = std::max(size.height, requested.height);
|
size.height = std::max(size.height, requested.height);
|
||||||
|
|
||||||
|
if (getChildAt(i)->getUserString("HStretch") != "true")
|
||||||
size.width = size.width + requested.width;
|
size.width = size.width + requested.width;
|
||||||
|
|
||||||
if (i != getChildCount()-1)
|
if (i != getChildCount()-1)
|
||||||
size.width += mSpacing;
|
size.width += mSpacing;
|
||||||
}
|
}
|
||||||
|
@ -1108,7 +1111,10 @@ MyGUI::IntSize VBox::getRequestedSize ()
|
||||||
{
|
{
|
||||||
MyGUI::IntSize requested = getChildAt(i)->getSize ();
|
MyGUI::IntSize requested = getChildAt(i)->getSize ();
|
||||||
size.width = std::max(size.width, requested.width);
|
size.width = std::max(size.width, requested.width);
|
||||||
|
|
||||||
|
if (getChildAt(i)->getUserString("VStretch") != "true")
|
||||||
size.height = size.height + requested.height;
|
size.height = size.height + requested.height;
|
||||||
|
|
||||||
if (i != getChildCount()-1)
|
if (i != getChildCount()-1)
|
||||||
size.height += mSpacing;
|
size.height += mSpacing;
|
||||||
}
|
}
|
||||||
|
|
|
@ -450,6 +450,16 @@ namespace MWWorld
|
||||||
mRendering->skySetDate (mGlobalVariables->getInt ("day"), month);
|
mRendering->skySetDate (mGlobalVariables->getInt ("day"), month);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int World::getDay()
|
||||||
|
{
|
||||||
|
return mGlobalVariables->getInt("day");
|
||||||
|
}
|
||||||
|
|
||||||
|
int World::getMonth()
|
||||||
|
{
|
||||||
|
return mGlobalVariables->getInt("month");
|
||||||
|
}
|
||||||
|
|
||||||
TimeStamp World::getTimeStamp() const
|
TimeStamp World::getTimeStamp() const
|
||||||
{
|
{
|
||||||
return TimeStamp (mGlobalVariables->getFloat ("gamehour"),
|
return TimeStamp (mGlobalVariables->getFloat ("gamehour"),
|
||||||
|
@ -1241,4 +1251,14 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
mRendering->setupExternalRendering (rendering);
|
mRendering->setupExternalRendering (rendering);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool World::canRest ()
|
||||||
|
{
|
||||||
|
Ptr::CellStore *currentCell = mWorldScene->getCurrentCell();
|
||||||
|
assert (currentCell);
|
||||||
|
if (currentCell->cell->data.flags & ESM::Cell::NoSleep)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,6 +179,9 @@ namespace MWWorld
|
||||||
virtual void setDay (int day);
|
virtual void setDay (int day);
|
||||||
///< Set in-game time day.
|
///< Set in-game time day.
|
||||||
|
|
||||||
|
virtual int getDay();
|
||||||
|
virtual int getMonth();
|
||||||
|
|
||||||
virtual TimeStamp getTimeStamp() const;
|
virtual TimeStamp getTimeStamp() const;
|
||||||
///< Return current in-game time stamp.
|
///< Return current in-game time stamp.
|
||||||
|
|
||||||
|
@ -312,6 +315,8 @@ namespace MWWorld
|
||||||
virtual void renderPlayer();
|
virtual void renderPlayer();
|
||||||
|
|
||||||
virtual void setupExternalRendering (MWRender::ExternalRendering& rendering);
|
virtual void setupExternalRendering (MWRender::ExternalRendering& rendering);
|
||||||
|
|
||||||
|
virtual bool canRest();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,22 +6,19 @@
|
||||||
<Property key="Spacing" value="8"/>
|
<Property key="Spacing" value="8"/>
|
||||||
<Property key="AutoResize" value="true"/>
|
<Property key="AutoResize" value="true"/>
|
||||||
|
|
||||||
<Widget type="AutoSizedTextBox" skin="SandText">
|
<Widget type="AutoSizedTextBox" skin="SandText" name="DateTimeText">
|
||||||
<Property key="Caption" value="24 Herzfeuer (Tag 24) 2 a.m."/>
|
<Property key="Caption" value="24 Herzfeuer (Tag 24) 2 a.m."/>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
<Widget type="AutoSizedTextBox" skin="SandText">
|
<Widget type="AutoSizedTextBox" skin="SandText" name="RestText">
|
||||||
<Property key="Caption" value="#{sRestIllegal}"/>
|
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
<Widget type="AutoSizedTextBox" skin="SandText">
|
<Widget type="AutoSizedTextBox" skin="SandText" name="HourText">
|
||||||
<Property key="Caption" value="1 Stunde(n)"/>
|
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
<Widget type="ScrollBar" skin="MW_HScroll" name="HourSlider" position="0 0 0 18">
|
<Widget type="ScrollBar" skin="MW_HScroll" name="HourSlider" position="0 0 0 18">
|
||||||
<Property key="MoveToClick" value="true"/>
|
<Property key="MoveToClick" value="true"/>
|
||||||
<Property key="Range" value="25"/>
|
<Property key="Range" value="24"/>
|
||||||
<Property key="RangePosition" value="23"/>
|
|
||||||
<UserString key="HStretch" value="true"/>
|
<UserString key="HStretch" value="true"/>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue