-
Notifications
You must be signed in to change notification settings - Fork 324
/
HUDInteractionModeIcon.cs
193 lines (170 loc) · 7.54 KB
/
HUDInteractionModeIcon.cs
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// Project: Daggerfall Unity
// Copyright: Copyright (C) 2009-2023 Daggerfall Workshop
// Web Site: http://www.dfworkshop.net
// License: MIT License (http://www.opensource.org/licenses/mit-license.php)
// Source Code: https://github.com/Interkarma/daggerfall-unity
// Original Author: Hazelnut
// Contributors:
//
// Notes:
//
using UnityEngine;
namespace DaggerfallWorkshop.Game.UserInterface
{
/// <summary>
/// InteractionModeIcon for HUD.
/// </summary>
public class HUDInteractionModeIcon : BaseScreenComponent
{
const string iconStealFilename = "icon-steal";
const string iconGrabFilename = "icon-grab";
const string iconInfoFilename = "icon-info";
const string iconTalkFilename = "icon-talk";
const float iconScale = 0.8f;
const float minimalScale = 0.5f;
const string classicStealFilename = "classic-steal";
const string classicGrabFilename = "classic-grab";
const string classicInfoFilename = "classic-info";
const string classicTalkFilename = "classic-talk";
const float classicScale = 3f;
const string colourStealFilename = "colour-steal";
const string colourGrabFilename = "colour-grab";
const string colourInfoFilename = "colour-info";
const string colourTalkFilename = "colour-talk";
const float colourScale = 1f;
const string monoStealFilename = "mono-steal";
const string monoGrabFilename = "mono-grab";
const string monoInfoFilename = "mono-info";
const string monoTalkFilename = "mono-talk";
const float monoScale = 0.8f;
private const string IconsFolder = "Icons/";
Vector2 stealSize;
Vector2 grabSize;
Vector2 infoSize;
Vector2 talkSize;
public Texture2D StealTexture;
public Texture2D GrabTexture;
public Texture2D InfoTexture;
public Texture2D TalkTexture;
float displayScale;
Texture2D crosshairTexture;
Vector2 crosshairSize;
bool crosshair = false;
HUDCrosshair hudCrosshair;
public HUDInteractionModeIcon(HUDCrosshair hudCrosshair)
: base()
{
this.hudCrosshair = hudCrosshair;
LoadAssets();
}
public override void Update()
{
if (Enabled)
{
if (crosshair)
{
if (crosshairTexture == null) {
crosshairTexture = hudCrosshair.CrosshairTexture;
crosshairSize = hudCrosshair.crosshairSize;
}
PlayerActivateModes mode = GameManager.Instance.PlayerActivate.CurrentMode;
switch (mode)
{
case PlayerActivateModes.Steal:
hudCrosshair.CrosshairTexture = StealTexture;
hudCrosshair.crosshairSize = stealSize * displayScale;
break;
case PlayerActivateModes.Grab:
hudCrosshair.CrosshairTexture = crosshairTexture;
hudCrosshair.crosshairSize = crosshairSize;
break;
case PlayerActivateModes.Info:
hudCrosshair.CrosshairTexture = InfoTexture;
hudCrosshair.crosshairSize = infoSize * displayScale;
break;
case PlayerActivateModes.Talk:
hudCrosshair.CrosshairTexture = TalkTexture;
hudCrosshair.crosshairSize = talkSize * displayScale;
break;
}
}
else
{
float barWidth = HUDVitals.nativeBarWidth * Scale.x;
float resScale = Scale.x > 3 ? 1 : 1 / Scale.x * 3; // Scale down at low resolutions.
PlayerActivateModes mode = GameManager.Instance.PlayerActivate.CurrentMode;
switch (mode)
{
case PlayerActivateModes.Steal:
BackgroundTexture = StealTexture;
Size = stealSize * displayScale / resScale;
break;
case PlayerActivateModes.Grab:
BackgroundTexture = GrabTexture;
Size = grabSize * displayScale / resScale;
break;
case PlayerActivateModes.Info:
BackgroundTexture = InfoTexture;
Size = infoSize * displayScale / resScale;
break;
case PlayerActivateModes.Talk:
BackgroundTexture = TalkTexture;
Size = talkSize * displayScale / resScale;
break;
}
Position = new Vector2((barWidth * 5) + (HUDVitals.borderSize * 2), Screen.height - HUDVitals.borderSize - Size.y);
}
base.Update();
}
}
void LoadAssets()
{
string stealFilename;
string grabFilename;
string infoFilename;
string talkFilename;
string iconSetting = DaggerfallUnity.Settings.InteractionModeIcon.ToLower();
switch (iconSetting)
{
case "classic":
case "classicxhair":
stealFilename = classicStealFilename;
grabFilename = classicGrabFilename;
infoFilename = classicInfoFilename;
talkFilename = classicTalkFilename;
displayScale = classicScale;
break;
case "monochrome":
stealFilename = monoStealFilename;
grabFilename = monoGrabFilename;
infoFilename = monoInfoFilename;
talkFilename = monoTalkFilename;
displayScale = monoScale;
break;
case "colour":
case "colourxhair":
stealFilename = colourStealFilename;
grabFilename = colourGrabFilename;
infoFilename = colourInfoFilename;
talkFilename = colourTalkFilename;
displayScale = colourScale;
break;
default:
stealFilename = iconStealFilename;
grabFilename = iconGrabFilename;
infoFilename = iconInfoFilename;
talkFilename = iconTalkFilename;
if (DaggerfallUnity.Settings.InteractionModeIcon.ToLower() == "minimal")
displayScale = minimalScale;
else
displayScale = iconScale;
break;
}
StealTexture = DaggerfallUI.GetTextureFromResources(IconsFolder + stealFilename, out stealSize);
GrabTexture = DaggerfallUI.GetTextureFromResources(IconsFolder + grabFilename, out grabSize);
InfoTexture = DaggerfallUI.GetTextureFromResources(IconsFolder + infoFilename, out infoSize);
TalkTexture = DaggerfallUI.GetTextureFromResources(IconsFolder + talkFilename, out talkSize);
crosshair = iconSetting.EndsWith("xhair");
}
}
}