Hooks
static bool BeforeCvGameTextMgr_setDateStr(CvString& strString, int iGameTurn, bool bSave, CalendarTypes eCalendar, int iStartYear, GameSpeedTypes eSpeed);static void AfterCvGameTextMgr_setDateStr(CvString& strString, int iGameTurn, bool bSave, CalendarTypes eCalendar, int iStartYear, GameSpeedTypes eSpeed);static void ReplaceCvGameTextMgr_setDateStr(void (*original)(CvString&, int, bool, CalendarTypes, int, GameSpeedTypes), CvString& strString, int iGameTurn, bool bSave, CalendarTypes eCalendar, int iStartYear, GameSpeedTypes eSpeed);CivRegisterBefore<CivHooks::CvGameTextMgr_setDateStr>(host, &BeforeCvGameTextMgr_setDateStr);CivRegisterAfter<CivHooks::CvGameTextMgr_setDateStr>(host, &AfterCvGameTextMgr_setDateStr);CivRegisterReplace<CivHooks::CvGameTextMgr_setDateStr>(host, &ReplaceCvGameTextMgr_setDateStr);
Code
60void CvGameTextMgr::setDateStr(CvString& strString, int iGameTurn, bool bSave, CalendarTypes eCalendar, int iStartYear, GameSpeedTypes eSpeed)61{62 CvString strYearBuffer;63 CvString strWeekBuffer;6465 int iTempGameTurn = iGameTurn + GC.getHIDDEN_START_TURN_OFFSET();6667 setYearStr(strYearBuffer, iTempGameTurn, bSave, eCalendar, iStartYear, eSpeed);6869 const int iNumMonths = DB.Count("Months");70 const int iNumSeasons = DB.Count("Seasons");7172 switch(eCalendar)73 {74 case CALENDAR_DEFAULT:75 {76 int iTurnMonth = getTurnMonthForGame(iTempGameTurn, iStartYear, eCalendar, eSpeed);77 if(0 == (getTurnMonthForGame(iTempGameTurn + 1, iStartYear, eCalendar, eSpeed) - iTurnMonth) % iNumMonths)78 {79 strString = strYearBuffer;80 }81 else82 {83 int iMonth = iTurnMonth % iNumMonths;8485 Database::SingleResult kResult;86 CvBaseInfo kInfo;87 DB.SelectAt(kResult, "Months", iMonth);88 kInfo.CacheResult(kResult);8990 Localization::String lstrMonth = Localization::Lookup(kInfo.GetDescription());91 CvString strMonth = lstrMonth.toUTF8();9293 if(bSave)94 {95 strString = (strYearBuffer + "-" + strMonth);96 }97 else98 {99 strString = (strMonth + CvString(", ") + strYearBuffer);100 }101 }102 }103 break;104 case CALENDAR_YEARS:105 case CALENDAR_BI_YEARLY:106 strString = strYearBuffer;107 break;108109 case CALENDAR_TURNS:110 strString = GetLocalizedText("TXT_KEY_TIME_TURN", (iTempGameTurn + 1));111 break;112113 case CALENDAR_SEASONS:114 {115 CvBaseInfo kSeasonInfo;116 Database::SingleResult kResult;117 DB.SelectAt(kResult, "Seasons", iTempGameTurn % iNumSeasons);118 kSeasonInfo.CacheResult(kResult);119 const char* Desc = kSeasonInfo.GetDescription();120 if(bSave)121 {122 strString = (strYearBuffer + "-" + CvString(Desc));123 }124 else125 {126 strString = (CvString(Desc) + CvString(", ") + strYearBuffer);127 }128 }129130 break;131132 case CALENDAR_MONTHS:133 {134 CvBaseInfo kMonthInfo;135 Database::SingleResult kResult;136 DB.SelectAt(kResult, "Months", iTempGameTurn % iNumMonths);137 kMonthInfo.CacheResult(kResult);138139 const char* Descr = kMonthInfo.GetDescription();140141 if(bSave)142 {143 strString = (strYearBuffer + "-" + CvString(Descr));144 }145 else146 {147 strString = (CvString(Descr) + CvString(", ") + strYearBuffer);148 }149 }150151152 break;153154 case CALENDAR_WEEKS:155 {156 strWeekBuffer = GetLocalizedText("TXT_KEY_TIME_WEEK", ((iTempGameTurn % GC.getWEEKS_PER_MONTHS()) + 1));157158 const int idx = (iTempGameTurn / GC.getWEEKS_PER_MONTHS()) % iNumMonths;159160 CvBaseInfo kCalendarInfo;161 Database::SingleResult kResult;162163 DB.SelectAt(kResult, "Months", idx);164 kCalendarInfo.CacheResult(kResult);165166 const char* Descr = kCalendarInfo.GetDescription();167168169 if(bSave)170 {171 strString = (strYearBuffer + "-" + CvString(Descr) + "-" + strWeekBuffer);172 }173 else174 {175 strString = (strWeekBuffer + ", " + CvString(Descr) + ", " + strYearBuffer);176 }177 }178 break;179180 default:181 CvAssert(false);182 }183}