mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-26 05:50:18 +00:00
add time scale to day-time window
This commit is contained in:
parent
4fff983c87
commit
91f136b97c
1 changed files with 25 additions and 4 deletions
|
@ -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();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue