-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathOptions.cs
More file actions
127 lines (112 loc) · 4.18 KB
/
Copy pathOptions.cs
File metadata and controls
127 lines (112 loc) · 4.18 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
using MapTextureReplacer.Locale;
using Colossal.IO.AssetDatabase;
using Game.Modding;
using Game.SceneFlow;
using Game.Settings;
using Game;
using System;
using MapTextureReplacer.Systems;
using Unity.Entities;
using MapTextureReplacer.Helpers;
using System.Collections.Generic;
using UnityEngine;
using System.Reflection;
namespace MapTextureReplacer
{
[FileLocation(nameof(MapTextureReplacer))]
[SettingsUIShowGroupName(DisplayGroup, CreatorToolsGroup, OtherGroup)]
public class MapTextureReplacerOptions : ModSetting
{
public const string DisplayGroup = "DisplayGroup";
public const string CreatorToolsGroup = "CreatorToolsGroup";
public const string OtherGroup = "OtherGroup";
private MapTextureReplacerSystem m_MapTextureReplacerSystem;
private bool _InUniversalModMenu;
private bool _ShowDownloadedPacks;
private bool _ShowLocalPacks;
public MapTextureReplacerOptions(IMod mod)
: base(mod)
{
SetDefaults();
}
[SettingsUISection(DisplayGroup)]
public bool InUniversalModMenu
{
get => _InUniversalModMenu;
set
{
if (_InUniversalModMenu == value) return;
_InUniversalModMenu = value;
RefreshUI();
}
}
[SettingsUISection(DisplayGroup)]
public bool ShowDownloadedPacks
{
get => _ShowDownloadedPacks;
set
{
if (_ShowDownloadedPacks == value) return;
_ShowDownloadedPacks = value;
World.DefaultGameObjectInjectionWorld?
.GetExistingSystemManaged<MapTextureReplacerSystem>()?
.SerializeImportedPacksWithSource();
RefreshUI();
}
}
[SettingsUISection(DisplayGroup)]
public bool ShowLocalPacks
{
get => _ShowLocalPacks;
set
{
if (_ShowLocalPacks == value) return;
_ShowLocalPacks = value;
World.DefaultGameObjectInjectionWorld?
.GetExistingSystemManaged<MapTextureReplacerSystem>()?
.SerializeImportedPacksWithSource();
RefreshUI();
}
}
[SettingsUISection(CreatorToolsGroup)]
public bool ShowCameraHeight { get; set; }
[SettingsUISection(OtherGroup)]
public string ModVersion => Assembly.GetExecutingAssembly().GetName().Version.ToString();
[SettingsUIButton]
[SettingsUIConfirmation]
[SettingsUISection(OtherGroup)]
public bool ResetModSettings
{
set
{
MakeSureSave = new System.Random().Next();
TextureSelectData = "[{\"Key\":\"Default\",\"Value\":\"none\"},{\"Key\":\"Default\",\"Value\":\"none\"},{\"Key\":\"Default\",\"Value\":\"none\"},{\"Key\":\"Default\",\"Value\":\"none\"},{\"Key\":\"Default\",\"Value\":\"none\"},{\"Key\":\"Default\",\"Value\":\"none\"}]";
ActiveDropdown = "none";
CurrentTilingVector = Vector4.zero;
m_MapTextureReplacerSystem = World.DefaultGameObjectInjectionWorld?.GetOrCreateSystemManaged<MapTextureReplacerSystem>();
m_MapTextureReplacerSystem.ChangePack("none");
}
}
[SettingsUIHidden]
public string ActiveDropdown { get; set; }
[SettingsUIHidden]
public string TextureSelectData { get; set; }
[SettingsUIHidden]
public Vector4 CurrentTilingVector { get; set; }
//sometimes saving doesn't happen when changing values to their default? - hack to guarantee
[SettingsUIHidden]
public int MakeSureSave { get; set; }
public override void SetDefaults()
{
MakeSureSave = 0;
InUniversalModMenu = false;
ShowDownloadedPacks = true;
ShowLocalPacks = true;
ShowCameraHeight = false;
}
private static void RefreshUI()
{
GameManager.instance?.userInterface?.view?.View?.ExecuteScript("window.location.reload();");
}
}
}