This repository was archived by the owner on Oct 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathTimeWindow.cs
More file actions
60 lines (50 loc) · 1.8 KB
/
TimeWindow.cs
File metadata and controls
60 lines (50 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace EditorTime
{
public class TimeWindow
{
public bool visible = false;
private bool mouseOver = false;
private Settings settings;
private TimeKeeper timeKeeper;
public TimeWindow(Settings settings, TimeKeeper timeKeeper)
{
this.settings = settings;
this.timeKeeper = timeKeeper;
}
public void Draw()
{
settings.timeWindow = GUILayout.Window(1936342, settings.timeWindow, Render, "Current Time", HighLogic.Skin.window);
}
private void Render(int windowID)
{
//All this defines the window itself
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace(); //This setup will center the text in the window
TimeSpan? timer = timeKeeper.OutsourceTimer();
if (timer.HasValue)
{
GUILayout.Label(timer.Value.Minutes + "m " + timer.Value.Seconds + "s ", HighLogic.Skin.label);
}
else if (mouseOver)
{
if (GUILayout.Button("Outsource!", HighLogic.Skin.button))
timeKeeper.Outsource();
}
else
{
GUILayout.Label(KSPUtil.PrintDateCompact((int)HighLogic.CurrentGame.flightState.universalTime, true, true), HighLogic.Skin.label);
}
if (Event.current.type == EventType.Repaint)
mouseOver = GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition);
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
//Allow the window to be dragged around
GUI.DragWindow();
}
}
}