-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathOptions.cs
More file actions
132 lines (117 loc) · 4.22 KB
/
Copy pathOptions.cs
File metadata and controls
132 lines (117 loc) · 4.22 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
128
129
130
131
132
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();
ActiveDropdown = "none";
TilingFloatData = "";
CurrentTilingVector = Vector4.zero;
m_MapTextureReplacerSystem = World.DefaultGameObjectInjectionWorld?.GetOrCreateSystemManaged<MapTextureReplacerSystem>();
m_MapTextureReplacerSystem.ResetAll();
}
}
[SettingsUIHidden]
public string ActiveDropdown { get; set; }
[SettingsUIHidden]
public string TextureSelectData { get; set; }
[SettingsUIHidden]
public string TilingFloatData { get; set; }
//migration-only: absorbs the old Vector4 tiling from pre-1.6.0 saves so it can be converted
//to TilingFloatData once on load, then zeroed and never written again
[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;
CurrentTilingVector = Vector4.zero;
}
private static void RefreshUI()
{
GameManager.instance?.userInterface?.view?.View?.ExecuteScript("window.location.reload();");
}
}
}