// © 2025 Naked People Team. All Rights Reserved.


#include "PhoneStatusBar.h"

#include "CommonTextBlock.h"
#include "NakedDesire/Global/TimeOfDaySubsystem.h"

void UPhoneStatusBar::NativeTick(const FGeometry& MyGeometry, float InDeltaTime)
{
	Super::NativeTick(MyGeometry, InDeltaTime);

	if (!TimeText)
		return;

	const UWorld* World = GetWorld();
	const UTimeOfDaySubsystem* Time = World ? World->GetSubsystem<UTimeOfDaySubsystem>() : nullptr;
	if (!Time)
		return;

	// 24-hour HH:MM, refreshed only when the minute rolls so we aren't re-laying-out text every frame.
	FString NewTime = FString::Printf(TEXT("%02d:%02d"), Time->GetHour(), Time->GetMinute());
	if (NewTime == CachedTimeString)
		return;

	CachedTimeString = MoveTemp(NewTime);
	TimeText->SetText(FText::FromString(CachedTimeString));
}
