add time scale to day-time window

This commit is contained in:
in0finite 2021-05-03 01:54:26 +02:00
parent 4fff983c87
commit 91f136b97c

View file

@ -7,8 +7,9 @@ namespace SanAndreasUnity.UI {
public class DayTimeWindow : PauseMenuWindow {
public byte[] availableHours = {7, 12, 15, 18, 21, 0, 3};
private string m_hoursText = "";
private string m_minutesText = "";
private string m_hoursText = "12";
private string m_minutesText = "0";
private string m_timeScaleText = "1";
DayTimeWindow() {
@ -24,7 +25,7 @@ namespace SanAndreasUnity.UI {
this.RegisterButtonInPauseMenu ();
// adjust rect
this.windowRect = new Rect(10, Screen.height - 220, 250, 200);
this.windowRect = new Rect(10, Screen.height - 220, 250, 300);
}
@ -32,6 +33,7 @@ namespace SanAndreasUnity.UI {
{
GUILayout.Label($"Current time: {WorldController.Singleton.CurrentTimeHours}:{WorldController.Singleton.CurrentTimeMinutes}");
GUILayout.Label($"Time scale: {WorldController.Singleton.timeScale}");
GUILayout.Space(15);
@ -56,7 +58,7 @@ namespace SanAndreasUnity.UI {
m_minutesText = GUILayout.TextField(m_minutesText);
GUILayout.EndHorizontal();
if (GUILayout.Button("Set"))
if (GUILayout.Button("Set time"))
{
if (byte.TryParse(m_hoursText, out byte hours) && byte.TryParse(m_minutesText, out byte minutes))
{
@ -64,6 +66,25 @@ namespace SanAndreasUnity.UI {
}
}
GUILayout.BeginHorizontal();
if (GUILayout.Button("Previous hour"))
WorldController.Singleton.SetTime((byte) (WorldController.Singleton.CurrentTimeHours == 0 ? 23 : WorldController.Singleton.CurrentTimeHours - 1), WorldController.Singleton.CurrentTimeMinutes, true);
if (GUILayout.Button("Next hour"))
WorldController.Singleton.SetTime((byte) ((WorldController.Singleton.CurrentTimeHours + 1) % 24), WorldController.Singleton.CurrentTimeMinutes, true);
GUILayout.EndHorizontal();
GUILayout.Space(15);
GUILayout.BeginHorizontal();
GUILayout.Label("Time scale:");
m_timeScaleText = GUILayout.TextField(m_timeScaleText);
if (GUILayout.Button("Set scale"))
{
if (float.TryParse(m_timeScaleText, out float value))
WorldController.Singleton.timeScale = value;
}
GUILayout.EndHorizontal();
}
}