FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
MagicStorage/EnvironmentGUI.cs at 1.4-stable · DawnDevelop/MagicStorage · GitHub
DawnDevelop
MagicStorage
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
MagicStorage
/
EnvironmentGUI.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
152 lines (120 loc) · 4.22 KB
Breadcrumbs
MagicStorage
/
EnvironmentGUI.cs
Copy path
File metadata and controls
152 lines (120 loc) · 4.22 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
using
MagicStorage
.
Components
;
using
MagicStorage
.
UI
;
using
Microsoft
.
Xna
.
Framework
;
using
Microsoft
.
Xna
.
Framework
.
Input
;
using
System
;
using
System
.
Collections
.
Generic
;
using
System
.
Linq
;
using
Terraria
;
using
Terraria
.
GameContent
.
UI
.
Elements
;
using
Terraria
.
Localization
;
using
Terraria
.
ModLoader
;
namespace
MagicStorage
{
public
static
class
EnvironmentGUI
{
private
const
int
Padding
=
4
;
internal
static
MouseState
curMouse
;
internal
static
MouseState
oldMouse
;
private
static
UIPanel
basePanel
;
private
static
float
panelTop
;
private
static
float
panelLeft
;
private
static
float
panelWidth
;
private
static
float
panelHeight
;
private
static
UIList
list
;
internal
static
Dictionary
<
string
,
EnvironmentGUIModEntry
>
entriesByMod
=
new
(
)
;
private
static
UIText
noModulesLoaded
;
internal
static
TEEnvironmentAccess
currentAccess
;
public
static
bool
MouseClicked
=>
curMouse
.
LeftButton
==
ButtonState
.
Pressed
&&
oldMouse
.
LeftButton
==
ButtonState
.
Released
;
public
static
bool
RightMouseClicked
=>
curMouse
.
RightButton
==
ButtonState
.
Pressed
&&
oldMouse
.
RightButton
==
ButtonState
.
Released
;
public
static
void
Initialize
(
)
{
if
(
Main
.
dedServ
)
return
;
entriesByMod
??=
new
(
)
;
panelTop
=
Main
.
instance
.
invBottom
+
60
;
panelLeft
=
20f
;
basePanel
?
.
Remove
(
)
;
basePanel
?
.
RemoveAllChildren
(
)
;
basePanel
=
new
UIPanel
(
)
;
float
innerPanelWidth
=
600f
+
Padding
;
panelWidth
=
basePanel
.
PaddingLeft
+
innerPanelWidth
+
basePanel
.
PaddingRight
;
panelHeight
=
Main
.
screenHeight
-
panelTop
;
basePanel
.
Left
.
Set
(
panelLeft
,
0f
)
;
basePanel
.
Top
.
Set
(
panelTop
,
0f
)
;
basePanel
.
Width
.
Set
(
panelWidth
,
0f
)
;
basePanel
.
Height
.
Set
(
panelHeight
,
0f
)
;
basePanel
.
Recalculate
(
)
;
list
?
.
Remove
(
)
;
list
?
.
Clear
(
)
;
list
=
new
(
)
;
list
.
SetPadding
(
0
)
;
list
.
Width
.
Set
(
-
20
,
1f
)
;
list
.
Height
.
Set
(
0
,
0.9f
)
;
list
.
Left
.
Set
(
20
,
0
)
;
list
.
Top
.
Set
(
0
,
0.05f
)
;
basePanel
.
Append
(
list
)
;
UIScrollbar
scroll
=
new
(
)
;
scroll
.
Width
.
Set
(
20
,
0
)
;
scroll
.
Height
.
Set
(
0
,
0.825f
)
;
scroll
.
Left
.
Set
(
0
,
0.95f
)
;
scroll
.
Top
.
Set
(
0
,
0.1f
)
;
list
.
SetScrollbar
(
scroll
)
;
list
.
Append
(
scroll
)
;
list
.
ListPadding
=
10
;
foreach
(
Mod
mod
in
ModLoader
.
Mods
)
{
EnvironmentGUIModEntry
entry
=
new
(
mod
)
;
if
(
!
entry
.
Exists
)
continue
;
entry
.
Width
.
Set
(
0
,
0.93f
)
;
entriesByMod
[
mod
.
Name
]
=
entry
;
list
.
Add
(
entry
)
;
}
/*
MagicStorage.Instance.Logger.Debug("Environment GUI Initialized\n" +
"Known modules:\n" +
" " + string.Join("\n ", entriesByMod.Values.SelectMany(entry => entry.Mod.GetContent<EnvironmentModule>().Select(m => m.FullName))));
*/
if
(
entriesByMod
.
Count
==
0
)
{
noModulesLoaded
=
new
(
Language
.
GetTextValue
(
"Mods.MagicStorage.EnvironmentGUI.NoModules"
)
,
textScale
:
1.3f
)
;
list
.
Add
(
noModulesLoaded
)
;
}
basePanel
.
Activate
(
)
;
}
internal
static
void
Unload
(
)
{
currentAccess
=
null
;
entriesByMod
=
null
;
basePanel
=
null
;
list
=
null
;
}
public
static
void
Update
(
GameTime
gameTime
)
{
try
{
oldMouse
=
StorageGUI
.
oldMouse
;
curMouse
=
StorageGUI
.
curMouse
;
if
(
Main
.
playerInventory
&&
StoragePlayer
.
LocalPlayer
.
ViewingStorage
(
)
.
X
>=
0
&&
StoragePlayer
.
IsStorageEnvironment
(
)
)
{
basePanel
?
.
Update
(
gameTime
)
;
}
}
catch
(
Exception
e
)
{
Main
.
NewTextMultiline
(
e
.
ToString
(
)
,
c
:
Color
.
White
)
;
}
}
public
static
void
LoadModules
(
TEEnvironmentAccess
access
)
{
//Assign the "state" for each module
foreach
(
var
entry
in
entriesByMod
.
Values
)
{
foreach
(
var
module
in
access
.
Modules
.
Where
(
m
=>
m
.
Mod
==
entry
.
Mod
)
)
entry
.
SetLabel
(
module
,
access
.
Enabled
(
module
)
)
;
}
currentAccess
=
access
;
}
public
static
void
Draw
(
)
{
try
{
Player
player
=
Main
.
LocalPlayer
;
if
(
Main
.
mouseX
>
panelLeft
&&
Main
.
mouseX
<
panelLeft
+
panelWidth
&&
Main
.
mouseY
>
panelTop
&&
Main
.
mouseY
<
panelTop
+
panelHeight
)
{
player
.
mouseInterface
=
true
;
player
.
cursorItemIconEnabled
=
false
;
InterfaceHelper
.
HideItemIconCache
(
)
;
}
basePanel
.
Draw
(
Main
.
spriteBatch
)
;
}
catch
(
Exception
e
)
{
Main
.
NewTextMultiline
(
e
.
ToString
(
)
,
c
:
Color
.
White
)
;
}
}
}
}
Back
|
FazBrowse Home
|
New Git URL