forked from mirror/openmw-tes3mp
factored out code for generating month names
This commit is contained in:
parent
e6dc927f11
commit
99ea63dc4a
6 changed files with 47 additions and 149 deletions
|
@ -186,8 +186,11 @@ namespace MWBase
|
|||
virtual void setDay (int day) = 0;
|
||||
///< Set in-game time day.
|
||||
|
||||
virtual int getDay() = 0;
|
||||
virtual int getMonth() = 0;
|
||||
virtual int getDay() const = 0;
|
||||
virtual int getMonth() const = 0;
|
||||
|
||||
virtual std::string getMonthName (int month = -1) const = 0;
|
||||
///< Return name of month (-1: current month)
|
||||
|
||||
virtual MWWorld::TimeStamp getTimeStamp() const = 0;
|
||||
///< Return current in-game time stamp.
|
||||
|
|
|
@ -20,8 +20,6 @@ namespace MWGui {
|
|||
|
||||
struct JournalViewModelImpl;
|
||||
|
||||
static void injectMonthName (std::ostream & os, int month);
|
||||
|
||||
struct JournalViewModelImpl : JournalViewModel
|
||||
{
|
||||
typedef KeywordSearch <std::string, intptr_t> KeywordSearchT;
|
||||
|
@ -242,14 +240,14 @@ struct JournalViewModelImpl : JournalViewModel
|
|||
{
|
||||
if (timestamp_buffer.empty ())
|
||||
{
|
||||
std::string dayStr = MyGUI::LanguageManager::getInstance().replaceTags("#{sDay}");
|
||||
|
||||
std::ostringstream os;
|
||||
|
||||
os << itr->mDayOfMonth << ' ';
|
||||
|
||||
injectMonthName (os, itr->mMonth);
|
||||
|
||||
const std::string& dayStr = MyGUI::LanguageManager::getInstance().replaceTags("#{sDay}");
|
||||
os << " (" << dayStr << " " << (itr->mDay + 1) << ')';
|
||||
os
|
||||
<< itr->mDayOfMonth << ' '
|
||||
<< MWBase::Environment::get().getWorld()->getMonthName (itr->mMonth)
|
||||
<< " (" << dayStr << " " << (itr->mDay + 1) << ')';
|
||||
|
||||
timestamp_buffer = os.str ();
|
||||
}
|
||||
|
@ -349,38 +347,6 @@ struct JournalViewModelImpl : JournalViewModel
|
|||
}
|
||||
};
|
||||
|
||||
static void injectMonthName (std::ostream & os, int month)
|
||||
{
|
||||
MyGUI::LanguageManager& lm = MyGUI::LanguageManager::getInstance();
|
||||
|
||||
if (month == 0)
|
||||
os << lm.replaceTags ("#{sMonthMorningstar}");
|
||||
else if (month == 1)
|
||||
os << lm.replaceTags ("#{sMonthSunsdawn}");
|
||||
else if (month == 2)
|
||||
os << lm.replaceTags ("#{sMonthFirstseed}");
|
||||
else if (month == 3)
|
||||
os << lm.replaceTags ("#{sMonthRainshand}");
|
||||
else if (month == 4)
|
||||
os << lm.replaceTags ("#{sMonthSecondseed}");
|
||||
else if (month == 5)
|
||||
os << lm.replaceTags ("#{sMonthMidyear}");
|
||||
else if (month == 6)
|
||||
os << lm.replaceTags ("#{sMonthSunsheight}");
|
||||
else if (month == 7)
|
||||
os << lm.replaceTags ("#{sMonthLastseed}");
|
||||
else if (month == 8)
|
||||
os << lm.replaceTags ("#{sMonthHeartfire}");
|
||||
else if (month == 9)
|
||||
os << lm.replaceTags ("#{sMonthFrostfall}");
|
||||
else if (month == 10)
|
||||
os << lm.replaceTags ("#{sMonthSunsdusk}");
|
||||
else if (month == 11)
|
||||
os << lm.replaceTags ("#{sMonthEveningstar}");
|
||||
else
|
||||
os << month;
|
||||
}
|
||||
|
||||
JournalViewModel::Ptr JournalViewModel::create ()
|
||||
{
|
||||
return boost::make_shared <JournalViewModelImpl> ();
|
||||
|
|
|
@ -7,61 +7,12 @@
|
|||
|
||||
#include "../mwbase/statemanager.hpp"
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
||||
#include "../mwstate/character.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
std::string getMonth(int m)
|
||||
{
|
||||
std::string month;
|
||||
switch (m) {
|
||||
case 0:
|
||||
month = "#{sMonthMorningstar}";
|
||||
break;
|
||||
case 1:
|
||||
month = "#{sMonthSunsdawn}";
|
||||
break;
|
||||
case 2:
|
||||
month = "#{sMonthFirstseed}";
|
||||
break;
|
||||
case 3:
|
||||
month = "#{sMonthRainshand}";
|
||||
break;
|
||||
case 4:
|
||||
month = "#{sMonthSecondseed}";
|
||||
break;
|
||||
case 5:
|
||||
month = "#{sMonthMidyear}";
|
||||
break;
|
||||
case 6:
|
||||
month = "#{sMonthSunsheight}";
|
||||
break;
|
||||
case 7:
|
||||
month = "#{sMonthLastseed}";
|
||||
break;
|
||||
case 8:
|
||||
month = "#{sMonthHeartfire}";
|
||||
break;
|
||||
case 9:
|
||||
month = "#{sMonthFrostfall}";
|
||||
break;
|
||||
case 10:
|
||||
month = "#{sMonthSunsdusk}";
|
||||
break;
|
||||
case 11:
|
||||
month = "#{sMonthEveningstar}";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return month;
|
||||
}
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
SaveGameDialog::SaveGameDialog()
|
||||
: WindowModal("openmw_savegame_dialog.layout")
|
||||
, mSaving(true)
|
||||
|
@ -225,19 +176,18 @@ namespace MWGui
|
|||
text << asctime(timeinfo) << "\n";
|
||||
text << "Level " << slot->mProfile.mPlayerLevel << "\n";
|
||||
text << slot->mProfile.mPlayerCell << "\n";
|
||||
//text << "Time played: " << slot->mProfile.mTimePlayed << "\n";
|
||||
// text << "Time played: " << slot->mProfile.mTimePlayed << "\n";
|
||||
|
||||
int hour = int(slot->mProfile.mInGameTime.mGameHour);
|
||||
bool pm = hour >= 12;
|
||||
if (hour >= 13) hour -= 12;
|
||||
if (hour == 0) hour = 12;
|
||||
|
||||
text <<
|
||||
slot->mProfile.mInGameTime.mDay << " "
|
||||
<< getMonth(slot->mProfile.mInGameTime.mMonth)
|
||||
<< " " << hour << " " << (pm ? "#{sSaveMenuHelp05}" : "#{sSaveMenuHelp04}");
|
||||
text
|
||||
<< slot->mProfile.mInGameTime.mDay << " "
|
||||
<< MWBase::Environment::get().getWorld()->getMonthName(slot->mProfile.mInGameTime.mMonth)
|
||||
<< " " << hour << " " << (pm ? "#{sSaveMenuHelp05}" : "#{sSaveMenuHelp04}");
|
||||
|
||||
mInfoText->setCaptionWithReplacing(text.str());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,49 +87,7 @@ namespace MWGui
|
|||
onHourSliderChangedPosition(mHourSlider, 0);
|
||||
mHourSlider->setScrollPosition (0);
|
||||
|
||||
// http://www.uesp.net/wiki/Lore:Calendar
|
||||
std::string month;
|
||||
int m = MWBase::Environment::get().getWorld ()->getMonth ();
|
||||
switch (m) {
|
||||
case 0:
|
||||
month = "#{sMonthMorningstar}";
|
||||
break;
|
||||
case 1:
|
||||
month = "#{sMonthSunsdawn}";
|
||||
break;
|
||||
case 2:
|
||||
month = "#{sMonthFirstseed}";
|
||||
break;
|
||||
case 3:
|
||||
month = "#{sMonthRainshand}";
|
||||
break;
|
||||
case 4:
|
||||
month = "#{sMonthSecondseed}";
|
||||
break;
|
||||
case 5:
|
||||
month = "#{sMonthMidyear}";
|
||||
break;
|
||||
case 6:
|
||||
month = "#{sMonthSunsheight}";
|
||||
break;
|
||||
case 7:
|
||||
month = "#{sMonthLastseed}";
|
||||
break;
|
||||
case 8:
|
||||
month = "#{sMonthHeartfire}";
|
||||
break;
|
||||
case 9:
|
||||
month = "#{sMonthFrostfall}";
|
||||
break;
|
||||
case 10:
|
||||
month = "#{sMonthSunsdusk}";
|
||||
break;
|
||||
case 11:
|
||||
month = "#{sMonthEveningstar}";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
std::string month = MWBase::Environment::get().getWorld ()->getMonthName();
|
||||
int hour = MWBase::Environment::get().getWorld ()->getTimeStamp ().getHour ();
|
||||
bool pm = hour >= 12;
|
||||
if (hour >= 13) hour -= 12;
|
||||
|
|
|
@ -450,12 +450,10 @@ namespace MWWorld
|
|||
if (!cell->mCell->isExterior() || !cell->mCell->mName.empty())
|
||||
return cell->mCell->mName;
|
||||
|
||||
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||
|
||||
if (const ESM::Region* region = store.get<ESM::Region>().search (cell->mCell->mRegion))
|
||||
if (const ESM::Region* region = getStore().get<ESM::Region>().search (cell->mCell->mRegion))
|
||||
return region->mName;
|
||||
|
||||
return store.get<ESM::GameSetting>().find ("sDefaultCellname")->mValue.getString();
|
||||
return getStore().get<ESM::GameSetting>().find ("sDefaultCellname")->mValue.getString();
|
||||
}
|
||||
|
||||
void World::removeRefScript (MWWorld::RefData *ref)
|
||||
|
@ -673,16 +671,36 @@ namespace MWWorld
|
|||
mRendering->skySetDate (mGlobalVariables->getInt ("day"), month);
|
||||
}
|
||||
|
||||
int World::getDay()
|
||||
int World::getDay() const
|
||||
{
|
||||
return mGlobalVariables->getInt("day");
|
||||
}
|
||||
|
||||
int World::getMonth()
|
||||
int World::getMonth() const
|
||||
{
|
||||
return mGlobalVariables->getInt("month");
|
||||
}
|
||||
|
||||
std::string World::getMonthName (int month) const
|
||||
{
|
||||
if (month==-1)
|
||||
month = getMonth();
|
||||
|
||||
const int months = 12;
|
||||
|
||||
if (month<0 || month>=months)
|
||||
return "";
|
||||
|
||||
static const char *monthNames[months] =
|
||||
{
|
||||
"sMonthMorningstar", "sMonthSunsdawn", "sMonthFirstseed", "sMonthRainshand",
|
||||
"sMonthSecondseed", "sMonthMidyear", "sMonthSunsheight", "sMonthLastseed",
|
||||
"sMonthHeartfire", "sMonthFrostfall", "sMonthSunsdusk", "sMonthEveningstar"
|
||||
};
|
||||
|
||||
return getStore().get<ESM::GameSetting>().find (monthNames[month])->mValue.getString();
|
||||
}
|
||||
|
||||
TimeStamp World::getTimeStamp() const
|
||||
{
|
||||
return TimeStamp (mGlobalVariables->getFloat ("gamehour"),
|
||||
|
|
|
@ -251,8 +251,11 @@ namespace MWWorld
|
|||
virtual void setDay (int day);
|
||||
///< Set in-game time day.
|
||||
|
||||
virtual int getDay();
|
||||
virtual int getMonth();
|
||||
virtual int getDay() const;
|
||||
virtual int getMonth() const;
|
||||
|
||||
virtual std::string getMonthName (int month = -1) const;
|
||||
///< Return name of month (-1: current month)
|
||||
|
||||
virtual TimeStamp getTimeStamp() const;
|
||||
///< Return current in-game time stamp.
|
||||
|
|
Loading…
Reference in a new issue