mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
Merge remote-tracking branch 'scrawl/sleep_wait' into next
This commit is contained in:
commit
a3c680d20a
34 changed files with 713 additions and 103 deletions
|
@ -29,7 +29,7 @@ add_openmw_dir (mwgui
|
|||
map_window window_pinnable_base cursorreplace tooltips scrollwindow bookwindow list
|
||||
formatting inventorywindow container hud countdialog tradewindow settingswindow
|
||||
confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu
|
||||
itemselection spellbuyingwindow loadingscreen levelupdialog
|
||||
itemselection spellbuyingwindow loadingscreen levelupdialog waitdialog
|
||||
)
|
||||
|
||||
add_openmw_dir (mwdialogue
|
||||
|
|
|
@ -222,6 +222,8 @@ namespace MWBase
|
|||
|
||||
virtual void enableRest() = 0;
|
||||
virtual bool getRestEnabled() = 0;
|
||||
|
||||
virtual bool getPlayerSleeping() = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -160,6 +160,9 @@ namespace MWBase
|
|||
virtual void setDay (int day) = 0;
|
||||
///< Set in-game time day.
|
||||
|
||||
virtual int getDay() = 0;
|
||||
virtual int getMonth() = 0;
|
||||
|
||||
virtual MWWorld::TimeStamp getTimeStamp() const = 0;
|
||||
///< Return current in-game time stamp.
|
||||
|
||||
|
@ -281,6 +284,13 @@ namespace MWBase
|
|||
virtual void renderPlayer() = 0;
|
||||
|
||||
virtual void setupExternalRendering (MWRender::ExternalRendering& rendering) = 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);
|
||||
|
||||
|
|
213
apps/openmw/mwgui/waitdialog.cpp
Normal file
213
apps/openmw/mwgui/waitdialog.cpp
Normal file
|
@ -0,0 +1,213 @@
|
|||
#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 "../mwworld/player.hpp"
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
#include "../mwmechanics/npcstats.hpp"
|
||||
|
||||
#include "widgets.hpp"
|
||||
|
||||
|
||||
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");
|
||||
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);
|
||||
|
||||
mProgressBar.setVisible (false);
|
||||
}
|
||||
|
||||
void WaitDialog::open()
|
||||
{
|
||||
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);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
void WaitDialog::onUntilHealedButtonClicked(MyGUI::Widget* sender)
|
||||
{
|
||||
startWaiting();
|
||||
}
|
||||
|
||||
void WaitDialog::onWaitButtonClicked(MyGUI::Widget* sender)
|
||||
{
|
||||
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.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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
66
apps/openmw/mwgui/waitdialog.hpp
Normal file
66
apps/openmw/mwgui/waitdialog.hpp
Normal file
|
@ -0,0 +1,66 @@
|
|||
#ifndef MWGUI_WAIT_DIALOG_H
|
||||
#define MWGUI_WAIT_DIALOG_H
|
||||
|
||||
#include "window_base.hpp"
|
||||
|
||||
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:
|
||||
WaitDialog(MWBase::WindowManager& parWindowManager);
|
||||
|
||||
virtual void open();
|
||||
|
||||
void onFrame(float dt);
|
||||
|
||||
void bedActivated() { setCanRest(true); }
|
||||
|
||||
bool getSleeping() { return mWaiting && mSleeping; }
|
||||
|
||||
protected:
|
||||
MyGUI::TextBox* mDateTimeText;
|
||||
MyGUI::TextBox* mRestText;
|
||||
MyGUI::TextBox* mHourText;
|
||||
MyGUI::ScrollBar* mHourSlider;
|
||||
MyGUI::Button* mUntilHealedButton;
|
||||
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();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -795,7 +795,6 @@ void MWDynamicStat::initialiseOverride()
|
|||
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void AutoSizedWidget::notifySizeChange (MyGUI::Widget* w)
|
||||
{
|
||||
if (w->getParent () != 0)
|
||||
|
@ -869,29 +868,33 @@ void AutoSizedButton::setPropertyOverride(const std::string& _key, const std::st
|
|||
|
||||
Box::Box()
|
||||
: mSpacing(4)
|
||||
, mPadding(0)
|
||||
, mAutoResize(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Box::setPropertyOverride(const std::string& _key, const std::string& _value)
|
||||
{
|
||||
if (_key == "Spacing")
|
||||
{
|
||||
mSpacing = MyGUI::utility::parseValue<int>(_value);
|
||||
}
|
||||
}
|
||||
|
||||
void Box::notifyChildrenSizeChanged ()
|
||||
{
|
||||
align();
|
||||
}
|
||||
|
||||
void Box::_setPropertyImpl(const std::string& _key, const std::string& _value)
|
||||
{
|
||||
if (_key == "Spacing")
|
||||
mSpacing = MyGUI::utility::parseValue<int>(_value);
|
||||
else if (_key == "Padding")
|
||||
mPadding = MyGUI::utility::parseValue<int>(_value);
|
||||
else if (_key == "AutoResize")
|
||||
mAutoResize = MyGUI::utility::parseValue<bool>(_value);
|
||||
}
|
||||
|
||||
void HBox::align ()
|
||||
{
|
||||
unsigned int count = getChildCount ();
|
||||
size_t h_stretched_count = 0;
|
||||
int total_width = 0;
|
||||
int total_height = 0;
|
||||
std::vector< std::pair<MyGUI::IntSize, bool> > sizes;
|
||||
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
|
@ -904,28 +907,43 @@ void HBox::align ()
|
|||
{
|
||||
sizes.push_back(std::make_pair(aw->getRequestedSize (), hstretch));
|
||||
total_width += aw->getRequestedSize ().width;
|
||||
total_height = std::max(total_height, aw->getRequestedSize ().height);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!hstretch) h_stretched_count ++;
|
||||
sizes.push_back (std::make_pair(MyGUI::IntSize(0,0), true));
|
||||
sizes.push_back (std::make_pair(w->getSize(), hstretch));
|
||||
total_width += w->getSize().width;
|
||||
}
|
||||
|
||||
if (i != count-1)
|
||||
total_width += mSpacing;
|
||||
}
|
||||
|
||||
if (mAutoResize && (total_width+mPadding*2 != getSize().width || total_height+mPadding*2 != getSize().height))
|
||||
{
|
||||
setSize(MyGUI::IntSize(total_width+mPadding*2, total_height+mPadding*2));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int curX = 0;
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
if (i == 0)
|
||||
curX += mPadding;
|
||||
|
||||
MyGUI::Widget* w = getChildAt(i);
|
||||
|
||||
bool vstretch = w->getUserString ("VStretch") == "true";
|
||||
int height = vstretch ? total_height : sizes[i].first.height;
|
||||
|
||||
MyGUI::IntCoord widgetCoord;
|
||||
widgetCoord.left = curX;
|
||||
widgetCoord.top = (getSize().height - sizes[i].first.height) / 2;
|
||||
int width = sizes[i].second ? sizes[i].first.width + (getSize().width - total_width)/h_stretched_count
|
||||
widgetCoord.top = mPadding + (getSize().height-mPadding*2 - height) / 2;
|
||||
int width = sizes[i].second ? sizes[i].first.width + (getSize().width-mPadding*2 - total_width)/h_stretched_count
|
||||
: sizes[i].first.width;
|
||||
widgetCoord.width = width;
|
||||
widgetCoord.height = sizes[i].first.height;
|
||||
widgetCoord.height = height;
|
||||
w->setCoord(widgetCoord);
|
||||
curX += width;
|
||||
|
||||
|
@ -934,12 +952,33 @@ void HBox::align ()
|
|||
}
|
||||
}
|
||||
|
||||
void HBox::setPropertyOverride(const std::string& _key, const std::string& _value)
|
||||
{
|
||||
Box::_setPropertyImpl (_key, _value);
|
||||
}
|
||||
|
||||
void HBox::setSize (const MyGUI::IntSize& _value)
|
||||
{
|
||||
MyGUI::Widget::setSize (_value);
|
||||
align();
|
||||
}
|
||||
|
||||
void HBox::setCoord (const MyGUI::IntCoord& _value)
|
||||
{
|
||||
MyGUI::Widget::setCoord (_value);
|
||||
align();
|
||||
}
|
||||
|
||||
void HBox::onWidgetCreated(MyGUI::Widget* _widget)
|
||||
{
|
||||
align();
|
||||
}
|
||||
|
||||
void HBox::onWidgetDestroy(MyGUI::Widget* _widget)
|
||||
{
|
||||
align();
|
||||
}
|
||||
|
||||
MyGUI::IntSize HBox::getRequestedSize ()
|
||||
{
|
||||
MyGUI::IntSize size(0,0);
|
||||
|
@ -954,6 +993,19 @@ MyGUI::IntSize HBox::getRequestedSize ()
|
|||
if (i != getChildCount()-1)
|
||||
size.width += mSpacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
MyGUI::IntSize requested = getChildAt(i)->getSize ();
|
||||
size.height = std::max(size.height, requested.height);
|
||||
|
||||
if (getChildAt(i)->getUserString("HStretch") != "true")
|
||||
size.width = size.width + requested.width;
|
||||
|
||||
if (i != getChildCount()-1)
|
||||
size.width += mSpacing;
|
||||
}
|
||||
size.height += mPadding*2;
|
||||
size.width += mPadding*2;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
@ -963,7 +1015,69 @@ MyGUI::IntSize HBox::getRequestedSize ()
|
|||
|
||||
void VBox::align ()
|
||||
{
|
||||
// not yet implemented
|
||||
unsigned int count = getChildCount ();
|
||||
size_t v_stretched_count = 0;
|
||||
int total_height = 0;
|
||||
int total_width = 0;
|
||||
std::vector< std::pair<MyGUI::IntSize, bool> > sizes;
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
MyGUI::Widget* w = getChildAt(i);
|
||||
bool vstretch = w->getUserString ("VStretch") == "true";
|
||||
v_stretched_count += vstretch;
|
||||
AutoSizedWidget* aw = dynamic_cast<AutoSizedWidget*>(w);
|
||||
if (aw)
|
||||
{
|
||||
sizes.push_back(std::make_pair(aw->getRequestedSize (), vstretch));
|
||||
total_height += aw->getRequestedSize ().height;
|
||||
total_width = std::max(total_width, aw->getRequestedSize ().width);
|
||||
}
|
||||
else
|
||||
{
|
||||
sizes.push_back (std::make_pair(w->getSize(), vstretch));
|
||||
total_height += w->getSize().height;
|
||||
}
|
||||
|
||||
if (i != count-1)
|
||||
total_height += mSpacing;
|
||||
}
|
||||
|
||||
if (mAutoResize && (total_width+mPadding*2 != getSize().width || total_height+mPadding*2 != getSize().height))
|
||||
{
|
||||
setSize(MyGUI::IntSize(total_width+mPadding*2, total_height+mPadding*2));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int curY = 0;
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
if (i==0)
|
||||
curY += mPadding;
|
||||
|
||||
MyGUI::Widget* w = getChildAt(i);
|
||||
|
||||
bool hstretch = w->getUserString ("HStretch") == "true";
|
||||
int width = hstretch ? total_width : sizes[i].first.width;
|
||||
|
||||
MyGUI::IntCoord widgetCoord;
|
||||
widgetCoord.top = curY;
|
||||
widgetCoord.left = mPadding + (getSize().width-mPadding*2 - width) / 2;
|
||||
int height = sizes[i].second ? sizes[i].first.height + (getSize().height-mPadding*2 - total_height)/v_stretched_count
|
||||
: sizes[i].first.height;
|
||||
widgetCoord.height = height;
|
||||
widgetCoord.width = width;
|
||||
w->setCoord(widgetCoord);
|
||||
curY += height;
|
||||
|
||||
if (i != count-1)
|
||||
curY += mSpacing;
|
||||
}
|
||||
}
|
||||
|
||||
void VBox::setPropertyOverride(const std::string& _key, const std::string& _value)
|
||||
{
|
||||
Box::_setPropertyImpl (_key, _value);
|
||||
}
|
||||
|
||||
void VBox::setSize (const MyGUI::IntSize& _value)
|
||||
|
@ -972,6 +1086,12 @@ void VBox::setSize (const MyGUI::IntSize& _value)
|
|||
align();
|
||||
}
|
||||
|
||||
void VBox::setCoord (const MyGUI::IntCoord& _value)
|
||||
{
|
||||
MyGUI::Widget::setCoord (_value);
|
||||
align();
|
||||
}
|
||||
|
||||
MyGUI::IntSize VBox::getRequestedSize ()
|
||||
{
|
||||
MyGUI::IntSize size(0,0);
|
||||
|
@ -986,6 +1106,29 @@ MyGUI::IntSize VBox::getRequestedSize ()
|
|||
if (i != getChildCount()-1)
|
||||
size.height += mSpacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
MyGUI::IntSize requested = getChildAt(i)->getSize ();
|
||||
size.width = std::max(size.width, requested.width);
|
||||
|
||||
if (getChildAt(i)->getUserString("VStretch") != "true")
|
||||
size.height = size.height + requested.height;
|
||||
|
||||
if (i != getChildCount()-1)
|
||||
size.height += mSpacing;
|
||||
}
|
||||
size.height += mPadding*2;
|
||||
size.width += mPadding*2;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
void VBox::onWidgetCreated(MyGUI::Widget* _widget)
|
||||
{
|
||||
align();
|
||||
}
|
||||
|
||||
void VBox::onWidgetDestroy(MyGUI::Widget* _widget)
|
||||
{
|
||||
align();
|
||||
}
|
||||
|
|
|
@ -357,10 +357,13 @@ namespace MWGui
|
|||
protected:
|
||||
virtual void align() = 0;
|
||||
|
||||
virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
|
||||
|
||||
virtual void _setPropertyImpl(const std::string& _key, const std::string& _value);
|
||||
|
||||
int mSpacing; // how much space to put between elements
|
||||
|
||||
int mPadding; // outer padding
|
||||
|
||||
bool mAutoResize; // auto resize the box so that it exactly fits all elements
|
||||
};
|
||||
|
||||
class HBox : public Box, public MyGUI::Widget
|
||||
|
@ -369,10 +372,16 @@ namespace MWGui
|
|||
|
||||
public:
|
||||
virtual void setSize (const MyGUI::IntSize &_value);
|
||||
virtual void setCoord (const MyGUI::IntCoord &_value);
|
||||
|
||||
protected:
|
||||
virtual void align();
|
||||
virtual MyGUI::IntSize getRequestedSize();
|
||||
|
||||
virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
|
||||
|
||||
virtual void onWidgetCreated(MyGUI::Widget* _widget);
|
||||
virtual void onWidgetDestroy(MyGUI::Widget* _widget);
|
||||
};
|
||||
|
||||
class VBox : public Box, public MyGUI::Widget
|
||||
|
@ -381,10 +390,16 @@ namespace MWGui
|
|||
|
||||
public:
|
||||
virtual void setSize (const MyGUI::IntSize &_value);
|
||||
virtual void setCoord (const MyGUI::IntCoord &_value);
|
||||
|
||||
protected:
|
||||
virtual void align();
|
||||
virtual MyGUI::IntSize getRequestedSize();
|
||||
|
||||
virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
|
||||
|
||||
virtual void onWidgetCreated(MyGUI::Widget* _widget);
|
||||
virtual void onWidgetDestroy(MyGUI::Widget* _widget);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "quickkeysmenu.hpp"
|
||||
#include "loadingscreen.hpp"
|
||||
#include "levelupdialog.hpp"
|
||||
#include "waitdialog.hpp"
|
||||
|
||||
using namespace MWGui;
|
||||
|
||||
|
@ -71,6 +72,8 @@ WindowManager::WindowManager(
|
|||
, mSpellWindow(NULL)
|
||||
, mLoadingScreen(NULL)
|
||||
, mCharGen(NULL)
|
||||
, mLevelupDialog(NULL)
|
||||
, mWaitDialog(NULL)
|
||||
, mPlayerClass()
|
||||
, mPlayerName()
|
||||
, mPlayerRaceId()
|
||||
|
@ -150,6 +153,7 @@ WindowManager::WindowManager(
|
|||
mSpellWindow = new SpellWindow(*this);
|
||||
mQuickKeysMenu = new QuickKeysMenu(*this);
|
||||
mLevelupDialog = new LevelupDialog(*this);
|
||||
mWaitDialog = new WaitDialog(*this);
|
||||
|
||||
mLoadingScreen = new LoadingScreen(mOgre->getScene (), mOgre->getWindow (), *this);
|
||||
mLoadingScreen->onResChange (w,h);
|
||||
|
@ -204,6 +208,7 @@ WindowManager::~WindowManager()
|
|||
delete mSpellWindow;
|
||||
delete mLoadingScreen;
|
||||
delete mLevelupDialog;
|
||||
delete mWaitDialog;
|
||||
|
||||
cleanupGarbage();
|
||||
|
||||
|
@ -252,6 +257,7 @@ void WindowManager::updateVisible()
|
|||
mSpellWindow->setVisible(false);
|
||||
mQuickKeysMenu->setVisible(false);
|
||||
mLevelupDialog->setVisible(false);
|
||||
mWaitDialog->setVisible(false);
|
||||
|
||||
mHud->setVisible(true);
|
||||
|
||||
|
@ -304,6 +310,13 @@ void WindowManager::updateVisible()
|
|||
mAlchemyWindow->setVisible(true);
|
||||
break;
|
||||
case GM_Rest:
|
||||
mWaitDialog->setVisible(true);
|
||||
break;
|
||||
case GM_RestBed:
|
||||
mWaitDialog->setVisible(true);
|
||||
mWaitDialog->bedActivated();
|
||||
break;
|
||||
case GM_Levelup:
|
||||
mLevelupDialog->setVisible(true);
|
||||
break;
|
||||
case GM_Name:
|
||||
|
@ -540,6 +553,8 @@ void WindowManager::onFrame (float frameDuration)
|
|||
|
||||
mStatsWindow->onFrame();
|
||||
|
||||
mWaitDialog->onFrame(frameDuration);
|
||||
|
||||
mHud->onFrame(frameDuration);
|
||||
|
||||
mDialogueWindow->checkReferenceAvailable();
|
||||
|
@ -931,3 +946,8 @@ void WindowManager::loadingDone ()
|
|||
{
|
||||
mLoadingScreen->loadingDone ();
|
||||
}
|
||||
|
||||
bool WindowManager::getPlayerSleeping ()
|
||||
{
|
||||
return mWaitDialog->getSleeping();
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ namespace MWGui
|
|||
class QuickKeysMenu;
|
||||
class LoadingScreen;
|
||||
class LevelupDialog;
|
||||
class WaitDialog;
|
||||
|
||||
class WindowManager : public MWBase::WindowManager
|
||||
{
|
||||
|
@ -203,6 +204,8 @@ namespace MWGui
|
|||
virtual void enableRest() { mRestAllowed = true; }
|
||||
virtual bool getRestEnabled() { return mRestAllowed; }
|
||||
|
||||
virtual bool getPlayerSleeping();
|
||||
|
||||
private:
|
||||
OEngine::GUI::MyGUIManager *mGuiManager;
|
||||
HUD *mHud;
|
||||
|
@ -229,6 +232,7 @@ namespace MWGui
|
|||
QuickKeysMenu* mQuickKeysMenu;
|
||||
LoadingScreen* mLoadingScreen;
|
||||
LevelupDialog* mLevelupDialog;
|
||||
WaitDialog* mWaitDialog;
|
||||
|
||||
CharacterCreation* mCharGen;
|
||||
|
||||
|
|
|
@ -202,5 +202,6 @@ op 0x200019b: PlaceItem
|
|||
op 0x200019c: PlaceAtPc
|
||||
op 0x200019d: PlaceAtMe
|
||||
op 0x200019e: PlaceAtMe Explicit
|
||||
opcodes 0x200019f-0x3ffffff unused
|
||||
op 0x200019f: GetPcSleep
|
||||
opcodes 0x20001a0-0x3ffffff unused
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <components/interpreter/opcodes.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
|
@ -20,6 +21,16 @@ namespace MWScript
|
|||
{
|
||||
namespace Misc
|
||||
{
|
||||
class OpGetPcSleep : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
runtime.push (MWBase::Environment::get().getWindowManager ()->getPlayerSleeping());
|
||||
}
|
||||
};
|
||||
|
||||
class OpXBox : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
@ -249,6 +260,7 @@ namespace MWScript
|
|||
const int opcodeTogglePathgrid = 0x2000146;
|
||||
const int opcodeDontSaveObject = 0x2000153;
|
||||
const int opcodeToggleVanityMode = 0x2000174;
|
||||
const int opcodeGetPcSleep = 0x200019f;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
|
@ -273,6 +285,7 @@ namespace MWScript
|
|||
extensions.registerInstruction ("dontsaveobject", "", opcodeDontSaveObject);
|
||||
extensions.registerInstruction ("togglevanitymode", "", opcodeToggleVanityMode);
|
||||
extensions.registerInstruction ("tvm", "", opcodeToggleVanityMode);
|
||||
extensions.registerFunction ("getpcsleep", 'l', "", opcodeGetPcSleep);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
|
@ -293,6 +306,7 @@ namespace MWScript
|
|||
interpreter.installSegment5 (opcodeToggleWater, new OpToggleWater);
|
||||
interpreter.installSegment5 (opcodeDontSaveObject, new OpDontSaveObject);
|
||||
interpreter.installSegment5 (opcodeToggleVanityMode, new OpToggleVanityMode);
|
||||
interpreter.installSegment5 (opcodeGetPcSleep, new OpGetPcSleep);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -452,6 +452,16 @@ namespace MWWorld
|
|||
mRendering->skySetDate (mGlobalVariables->getInt ("day"), month);
|
||||
}
|
||||
|
||||
int World::getDay()
|
||||
{
|
||||
return mGlobalVariables->getInt("day");
|
||||
}
|
||||
|
||||
int World::getMonth()
|
||||
{
|
||||
return mGlobalVariables->getInt("month");
|
||||
}
|
||||
|
||||
TimeStamp World::getTimeStamp() const
|
||||
{
|
||||
return TimeStamp (mGlobalVariables->getFloat ("gamehour"),
|
||||
|
@ -1247,4 +1257,28 @@ namespace MWWorld
|
|||
{
|
||||
mRendering->setupExternalRendering (rendering);
|
||||
}
|
||||
|
||||
int World::canRest ()
|
||||
{
|
||||
Ptr::CellStore *currentCell = mWorldScene->getCurrentCell();
|
||||
|
||||
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 1;
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,6 +179,9 @@ namespace MWWorld
|
|||
virtual void setDay (int day);
|
||||
///< Set in-game time day.
|
||||
|
||||
virtual int getDay();
|
||||
virtual int getMonth();
|
||||
|
||||
virtual TimeStamp getTimeStamp() const;
|
||||
///< Return current in-game time stamp.
|
||||
|
||||
|
@ -312,6 +315,13 @@ namespace MWWorld
|
|||
virtual void renderPlayer();
|
||||
|
||||
virtual void setupExternalRendering (MWRender::ExternalRendering& rendering);
|
||||
|
||||
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)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -73,6 +73,8 @@ set(MYGUI_FILES
|
|||
openmw_spell_buying_window.layout
|
||||
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>
|
||||
|
|
42
files/mygui/openmw_wait_dialog.layout
Normal file
42
files/mygui/openmw_wait_dialog.layout
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MyGUI type="Layout">
|
||||
<Widget type="VBox" skin="MW_Dialog" layer="Windows" position="0 0 600 200" name="_Main">
|
||||
<Property key="Padding" value="12"/>
|
||||
<Property key="Spacing" value="8"/>
|
||||
<Property key="AutoResize" value="true"/>
|
||||
|
||||
<Widget type="AutoSizedTextBox" skin="SandText" name="DateTimeText">
|
||||
<Property key="Caption" value="24 Herzfeuer (Tag 24) 2 a.m."/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="AutoSizedTextBox" skin="SandText" name="RestText">
|
||||
</Widget>
|
||||
|
||||
<Widget type="AutoSizedTextBox" skin="SandText" name="HourText">
|
||||
</Widget>
|
||||
|
||||
<Widget type="ScrollBar" skin="MW_HScroll" name="HourSlider" position="0 0 0 18">
|
||||
<Property key="MoveToClick" value="true"/>
|
||||
<Property key="Range" value="24"/>
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="HBox">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
<Widget type="Widget">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="UntilHealedButton">
|
||||
<Property key="Caption" value="#{sUntilHealed}"/>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="WaitButton">
|
||||
<Property key="Caption" value="#{sRest}"/>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="CancelButton">
|
||||
<Property key="Caption" value="#{sCancel}"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</MyGUI>
|
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>
|
|
@ -1,52 +1,50 @@
|
|||
#include "fader.hpp"
|
||||
|
||||
#include <OgreOverlayManager.h>
|
||||
#include <OgreOverlayContainer.h>
|
||||
#include <OgreOverlay.h>
|
||||
#include <OgreMaterial.h>
|
||||
#include <OgreTechnique.h>
|
||||
#include <OgreMaterialManager.h>
|
||||
#include <OgreResourceGroupManager.h>
|
||||
#include <OgreRectangle2D.h>
|
||||
#include <OgreSceneManager.h>
|
||||
|
||||
#define FADE_OVERLAY_NAME "FadeInOutOverlay"
|
||||
#define FADE_OVERLAY_PANEL_NAME "FadeInOutOverlayPanel"
|
||||
#define FADE_MATERIAL_NAME "FadeInOutMaterial"
|
||||
|
||||
using namespace Ogre;
|
||||
using namespace OEngine::Render;
|
||||
|
||||
Fader::Fader() :
|
||||
mMode(FadingMode_In),
|
||||
mRemainingTime(0.f),
|
||||
mTargetTime(0.f),
|
||||
mTargetAlpha(0.f),
|
||||
mCurrentAlpha(0.f),
|
||||
mStartAlpha(0.f)
|
||||
Fader::Fader(Ogre::SceneManager* sceneMgr)
|
||||
: mSceneMgr(sceneMgr)
|
||||
, mMode(FadingMode_In)
|
||||
, mRemainingTime(0.f)
|
||||
, mTargetTime(0.f)
|
||||
, mTargetAlpha(0.f)
|
||||
, mCurrentAlpha(0.f)
|
||||
, mStartAlpha(0.f)
|
||||
{
|
||||
|
||||
// Create the fading material
|
||||
MaterialPtr material = MaterialManager::getSingleton().create( FADE_MATERIAL_NAME, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
|
||||
MaterialPtr material = MaterialManager::getSingleton().create("FadeInOutMaterial", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
|
||||
Pass* pass = material->getTechnique(0)->getPass(0);
|
||||
pass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
|
||||
mFadeTextureUnit = pass->createTextureUnitState();
|
||||
mFadeTextureUnit->setColourOperationEx(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, ColourValue(0.f, 0.f, 0.f)); // always black colour
|
||||
|
||||
// Create the overlay
|
||||
OverlayManager& ovm = OverlayManager::getSingleton();
|
||||
mRectangle = new Ogre::Rectangle2D(true);
|
||||
mRectangle->setCorners(-1.0, 1.0, 1.0, -1.0);
|
||||
mRectangle->setMaterial("FadeInOutMaterial");
|
||||
mRectangle->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY-1);
|
||||
// Use infinite AAB to always stay visible
|
||||
Ogre::AxisAlignedBox aabInf;
|
||||
aabInf.setInfinite();
|
||||
mRectangle->setBoundingBox(aabInf);
|
||||
// Attach background to the scene
|
||||
Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
|
||||
node->attachObject(mRectangle);
|
||||
mRectangle->setVisible(false);
|
||||
mRectangle->setVisibilityFlags (0x01);
|
||||
}
|
||||
|
||||
mOverlay = ovm.create( FADE_OVERLAY_NAME );
|
||||
|
||||
OverlayContainer* overlay_panel;
|
||||
overlay_panel = (OverlayContainer*)ovm.createOverlayElement("Panel", FADE_OVERLAY_PANEL_NAME);
|
||||
|
||||
// position it over the whole screen
|
||||
overlay_panel->_setPosition(0, 0);
|
||||
overlay_panel->_setDimensions(1, 1);
|
||||
|
||||
overlay_panel->setMaterialName( FADE_MATERIAL_NAME );
|
||||
overlay_panel->show();
|
||||
mOverlay->add2D(overlay_panel);
|
||||
mOverlay->hide();
|
||||
Fader::~Fader()
|
||||
{
|
||||
delete mRectangle;
|
||||
}
|
||||
|
||||
void Fader::update(float dt)
|
||||
|
@ -69,12 +67,12 @@ void Fader::update(float dt)
|
|||
mRemainingTime -= dt;
|
||||
}
|
||||
|
||||
if (mCurrentAlpha == 0.f) mOverlay->hide();
|
||||
if (mCurrentAlpha == 0.f) mRectangle->setVisible(false);
|
||||
}
|
||||
|
||||
void Fader::applyAlpha()
|
||||
{
|
||||
mOverlay->show();
|
||||
mRectangle->setVisible(true);
|
||||
mFadeTextureUnit->setAlphaOperation(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, mCurrentAlpha);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,52 +4,52 @@
|
|||
/*
|
||||
A class that handles fading in the screen from black or fading it out to black.
|
||||
|
||||
To achieve this, it uses a full-screen Ogre::Overlay
|
||||
|
||||
inspired by http://www.ogre3d.org/tikiwiki/FadeEffectOverlay (heavily adjusted)
|
||||
To achieve this, it uses a full-screen Rectangle2d
|
||||
*/
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
class TextureUnitState;
|
||||
class Overlay;
|
||||
class Rectangle2D;
|
||||
class SceneManager;
|
||||
}
|
||||
|
||||
namespace OEngine {
|
||||
namespace Render
|
||||
{
|
||||
class Fader
|
||||
{
|
||||
public:
|
||||
Fader();
|
||||
|
||||
void update(float dt);
|
||||
|
||||
void fadeIn(const float time);
|
||||
void fadeOut(const float time);
|
||||
void fadeTo(const int percent, const float time);
|
||||
|
||||
private:
|
||||
enum FadingMode
|
||||
class Fader
|
||||
{
|
||||
FadingMode_In,
|
||||
FadingMode_Out
|
||||
public:
|
||||
Fader(Ogre::SceneManager* sceneMgr);
|
||||
~Fader();
|
||||
|
||||
void update(float dt);
|
||||
|
||||
void fadeIn(const float time);
|
||||
void fadeOut(const float time);
|
||||
void fadeTo(const int percent, const float time);
|
||||
|
||||
private:
|
||||
enum FadingMode
|
||||
{
|
||||
FadingMode_In,
|
||||
FadingMode_Out
|
||||
};
|
||||
|
||||
void applyAlpha();
|
||||
|
||||
Ogre::TextureUnitState* mFadeTextureUnit;
|
||||
Ogre::Rectangle2D* mRectangle;
|
||||
|
||||
FadingMode mMode;
|
||||
|
||||
float mRemainingTime;
|
||||
float mTargetTime;
|
||||
float mTargetAlpha;
|
||||
float mCurrentAlpha;
|
||||
float mStartAlpha;
|
||||
|
||||
Ogre::SceneManager* mSceneMgr;
|
||||
};
|
||||
|
||||
void applyAlpha();
|
||||
|
||||
Ogre::TextureUnitState* mFadeTextureUnit;
|
||||
Ogre::Overlay* mOverlay;
|
||||
|
||||
FadingMode mMode;
|
||||
|
||||
float mRemainingTime;
|
||||
float mTargetTime;
|
||||
float mTargetAlpha;
|
||||
float mCurrentAlpha;
|
||||
float mStartAlpha;
|
||||
|
||||
protected:
|
||||
};
|
||||
}}
|
||||
}}
|
||||
#endif
|
||||
|
|
|
@ -243,7 +243,7 @@ void OgreRenderer::createScene(const std::string& camName, float fov, float near
|
|||
// Alter the camera aspect ratio to match the viewport
|
||||
mCamera->setAspectRatio(Real(mView->getActualWidth()) / Real(mView->getActualHeight()));
|
||||
|
||||
mFader = new Fader();
|
||||
mFader = new Fader(mScene);
|
||||
}
|
||||
|
||||
void OgreRenderer::adjustViewport()
|
||||
|
|
Loading…
Reference in a new issue