@@ -502,3 +502,106 @@ DEFINE_HOOK(0x55F1F8, MPDebugPrint_CheckDrawFlag, 0x8)
502502{
503503 return Game::DrawMPDebugStats ? 0 : 0x55F280 ;
504504}
505+
506+ #pragma region Draw Timer
507+
508+ namespace DrawTimerTemp
509+ {
510+ bool AdjustLocation = false ;
511+ bool IsPercentage = false ;
512+ double Percentage = 0.0 ;
513+ int TimeLeft = 0 ;
514+ }
515+
516+ DEFINE_HOOK (0x6D3D10 , TacticalClass_Render_BeforeAll, 0x6 )
517+ {
518+ using namespace DrawTimerTemp ;
519+ AdjustLocation = false ;
520+ IsPercentage = false ;
521+ return 0 ;
522+ }
523+
524+ DEFINE_HOOK (0x6D4992 , TacticalClass_Render_DrawMissionTimer_TimeLeft, 0x6 )
525+ {
526+ DrawTimerTemp::TimeLeft = R->EDX <int >();
527+ return 0 ;
528+ }
529+
530+ DEFINE_HOOK (0x6D4A10 , TacticalClass_Render_DrawSuperTimer_PercentageTimer, 0x6 )
531+ {
532+ enum { SkipGetTimeLeft = 0x6D4A35 };
533+
534+ GET (SuperClass*, pSuper, ECX);
535+
536+ DrawTimerTemp::IsPercentage = false ;
537+ const int timeLeft = pSuper->RechargeTimer .GetTimeLeft ();
538+ const auto pSWTypeExt = SWTypeExt::ExtMap.Find (pSuper->Type );
539+
540+ if (pSWTypeExt->ShowTimer_Percentage .Get (RulesExt::Global ()->SuperWeaponTimer_Percentage ))
541+ {
542+ DrawTimerTemp::IsPercentage = true ;
543+ const int recharge = pSuper->GetRechargeTime ();
544+ const double percentage = DrawTimerTemp::Percentage = std::min (static_cast <double >(recharge - timeLeft) / recharge, 1.0 );
545+ R->ESI (percentage >= 1.0 ? 0 : 15 );
546+ }
547+ else
548+ {
549+ DrawTimerTemp::TimeLeft = timeLeft / 15 ;
550+ R->ESI (timeLeft);
551+ }
552+
553+ return SkipGetTimeLeft;
554+ }
555+
556+ DEFINE_HOOK (0x6D4B03 , TacticalClass_Render_DrawBlackoutTimer_TimeLeft, 0x5 )
557+ {
558+ DrawTimerTemp::TimeLeft = R->EDX <int >();
559+ return 0 ;
560+ }
561+
562+ static int __fastcall TacticalClass_DrawTimer_swprintf (wchar_t * pBuffer, size_t bufferCount, wchar_t * pFormat, ...)
563+ {
564+ using namespace DrawTimerTemp ;
565+
566+ if (IsPercentage)
567+ return swprintf (pBuffer, bufferCount, L" %.2lf%s" , Percentage * 100 , L" %%" );
568+ else
569+ return swprintf (pBuffer, bufferCount, L" %02d:%02d" , TimeLeft / 60 % 60 , TimeLeft % 60 );
570+ }
571+ DEFINE_FUNCTION_JUMP (CALL, 0x6D4C4C , TacticalClass_DrawTimer_swprintf)
572+
573+ static Point2D* __fastcall TacticalClass_DrawTimer_Print_Wide
574+ (
575+ Point2D& retBuffer,
576+ const wchar_t * pText,
577+ Surface* pSurface,
578+ const RectangleStruct& bounds,
579+ Point2D& location,
580+ ColorScheme* pForeScheme,
581+ ColorScheme* pBackScheme,
582+ TextPrintType flag,
583+ ...
584+ )
585+ {
586+ using namespace DrawTimerTemp ;
587+ AdjustLocation = !AdjustLocation;
588+
589+ if (AdjustLocation)
590+ {
591+ if (IsPercentage)
592+ {
593+ IsPercentage = false ;
594+ location.X += 8 ;
595+ }
596+ else
597+ {
598+ location.X -= 2 ;
599+ }
600+ }
601+
602+ return Fancy_Text_Print_Wide (retBuffer, pText, pSurface, bounds, location, pForeScheme, pBackScheme, flag);
603+ }
604+ DEFINE_FUNCTION_JUMP (CALL, 0x6D4D42 , TacticalClass_DrawTimer_Print_Wide)// UIName
605+ DEFINE_FUNCTION_JUMP(CALL, 0x6D4D9A , TacticalClass_DrawTimer_Print_Wide)// Time
606+
607+ #pragma endregion
0 commit comments