Skip to content

Commit f4555df

Browse files
committed
Add files
1 parent 6768618 commit f4555df

7 files changed

Lines changed: 150 additions & 0 deletions

File tree

images/1.png

1.23 MB
Loading

images/2.png

1.03 MB
Loading

images/settings.png

1.27 MB
Loading

src/SystemClock.cs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using UnityEngine;
2+
using DaggerfallWorkshop.Game.Utility.ModSupport;
3+
using DaggerfallWorkshop.Game.Utility.ModSupport.ModSettings;
4+
using DaggerfallWorkshop.Game;
5+
6+
namespace SystemClockMod
7+
{
8+
public class SystemClockMod : MonoBehaviour
9+
{
10+
public static Mod Mod;
11+
private static GUIStyle style;
12+
private static Rect rect;
13+
private static Vector2 rectSize;
14+
private static Vector2 rectPosition;
15+
16+
// Mod options
17+
static int horizontalPositionPercent;
18+
static int verticalPositionPercent;
19+
static string format; // https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings
20+
static Color fontColor;
21+
static int fontSize;
22+
static int guiDepth;
23+
24+
[Invoke(StateManager.StateTypes.Start, 0)]
25+
public static void Init(InitParams initParams)
26+
{
27+
Mod = initParams.Mod;
28+
new GameObject(Mod.Title).AddComponent<SystemClockMod>();
29+
Mod.LoadSettingsCallback = LoadSettings;
30+
Mod.IsReady = true;
31+
}
32+
33+
void Start()
34+
{
35+
style = new GUIStyle();
36+
style.alignment = TextAnchor.MiddleCenter;
37+
Mod.LoadSettings();
38+
}
39+
40+
void OnGUI()
41+
{
42+
GUI.depth = guiDepth;
43+
GUI.Label(
44+
rect,
45+
System.DateTime.Now.ToString(format),
46+
style
47+
);
48+
}
49+
50+
static void LoadSettings(ModSettings modSettings, ModSettingsChange change)
51+
{
52+
if (modSettings != null)
53+
{
54+
format = modSettings.GetString("Settings", "Format");
55+
guiDepth = modSettings.GetValue<int>("Settings", "RenderOrder"); ;
56+
horizontalPositionPercent = modSettings.GetValue<int>("Settings", "HorizontalPositionPercent");
57+
verticalPositionPercent = modSettings.GetValue<int>("Settings", "VerticalPositionPercent");
58+
fontSize = modSettings.GetValue<int>("Settings", "Size");
59+
fontColor = modSettings.GetColor("Settings", "Color");
60+
61+
style.normal.textColor = fontColor;
62+
style.fontSize = fontSize;
63+
rectSize = style.CalcSize(new GUIContent(System.DateTime.Now.ToString(format)));
64+
rectPosition.x = (Screen.width - rectSize.x) * (horizontalPositionPercent / 100f);
65+
rectPosition.y = (Screen.height - rectSize.y) * (verticalPositionPercent / 100f);
66+
rect = new Rect(rectPosition.x, rectPosition.y, rectSize.x, rectSize.y);
67+
}
68+
}
69+
70+
}
71+
}

src/SystemClock.dfmod.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"ModTitle": "SystemClock",
3+
"ModVersion": "1.0",
4+
"ModAuthor": "themrleon",
5+
"DFUnity_Version": "1.1.1",
6+
"ModDescription": "Show system time on screen",
7+
"GUID": "0b4b169a-1508-46c8-917e-454ed297a6f3",
8+
"Files": [
9+
"Assets/Game/Mods/SystemClock/modsettings.json",
10+
"Assets/Game/Mods/SystemClock/SystemClock.cs"
11+
]
12+
}

src/modsettings.json

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"Version": "1.00",
3+
"Sections": [
4+
{
5+
"Name": "Settings",
6+
"IsAdvanced": false,
7+
"Keys": [
8+
{
9+
"Value": "HH:mm:ss",
10+
"Name": "Format",
11+
"Description": "Output format (check mod page for details)",
12+
"$version": "v1",
13+
"$type": "DaggerfallWorkshop.Game.Utility.ModSupport.ModSettings.TextKey"
14+
},
15+
{
16+
"Min": -1000,
17+
"Max": 1000,
18+
"Value": -1,
19+
"Name": "RenderOrder",
20+
"Description": "Render order (negative values = above other UI elements, positive = under)",
21+
"$version": "v1",
22+
"$type": "DaggerfallWorkshop.Game.Utility.ModSupport.ModSettings.SliderIntKey"
23+
},
24+
{
25+
"Min": 0,
26+
"Max": 100,
27+
"Value": 100,
28+
"Name": "HorizontalPositionPercent",
29+
"Description": "Screen horizontal position (0 = left, 100 = right)",
30+
"$version": "v1",
31+
"$type": "DaggerfallWorkshop.Game.Utility.ModSupport.ModSettings.SliderIntKey"
32+
},
33+
{
34+
"Min": 0,
35+
"Max": 100,
36+
"Value": 0,
37+
"Name": "VerticalPositionPercent",
38+
"Description": "Screen vertical position (0 = top, 100 = bottom)",
39+
"$version": "v1",
40+
"$type": "DaggerfallWorkshop.Game.Utility.ModSupport.ModSettings.SliderIntKey"
41+
},
42+
{
43+
"Min": 1,
44+
"Max": 100,
45+
"Value": 20,
46+
"Name": "Size",
47+
"Description": "Font size",
48+
"$version": "v1",
49+
"$type": "DaggerfallWorkshop.Game.Utility.ModSupport.ModSettings.SliderIntKey"
50+
},
51+
{
52+
"Value": {
53+
"r": 255,
54+
"g": 255,
55+
"b": 255,
56+
"a": 255
57+
},
58+
"Name": "Color",
59+
"Description": "Font color",
60+
"$version": "v1",
61+
"$type": "DaggerfallWorkshop.Game.Utility.ModSupport.ModSettings.ColorKey"
62+
}
63+
],
64+
"$version": "v1"
65+
}
66+
]
67+
}

systemclock.dfmod

4.88 KB
Binary file not shown.

0 commit comments

Comments
 (0)