-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVrage_Settings.ms
300 lines (242 loc) · 12.4 KB
/
Vrage_Settings.ms
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
struct VRageConfig
(
/*Static Options */
VRageConfigDir = GetDir #plugcfg + @"\VRageUtilities",
VRageConfigFile = VRageConfigDir + @"\MyVRageCfg.ini",
VRageScriptsDir = GetDir #userScripts + "\\VRageToolbox\\",
/*configureable User Paths*/
PathToolsFolder = "",
PathHavokContentTools = " ",
PathFBXImporter = " ",
PathMwmBuilder = " ",
PathTextures = " ",
PathModSDK = " ",
UseGameTextures = False,
TextureType = 5,
PathGame = " ",
UsePbrMats = True, --Needs GUI
DefaultThumbnail = VrageConfigDir + "\\MaterialThumbnails\\" + "NoThumbnail.jpg",
/*UI Layout stuff */
MatBrowserSizeX = 1150,
MatBrowserSizeY = 720,
fn save = (
try (
makedir VRageConfigDir
)
catch (
messageBox title:"Permission Error!"
)
if ( VRageScriptsDir ) != "" then (
if getDirectories ( VRageScriptsDir ) != undefined then (
PathFBXImporter = if ( tmp = getFiles ( VRageScriptsDir + "\\Vrage_Tools\\FbxImporter.exe" ) ).count != 0 then tmp[1] else ""
PathMwmBuilder = if ( tmp = getFiles ( VRageScriptsDir + "\\Vrage_Tools\\MWMBuilder\\MwmBuilder.exe" ) ).count != 0 then ( VRageScriptsDir + "\\Vrage_Tools\\MWMBuilder\\MwmBuilder.exe" ) else ""
PathTextures = if ( tmp = getDirectories ( PathToolsFolder + "\\Textures" ) ).count != 0 then ( PathToolsFolder ) else ""
)
)
setINISetting VRageConfigFile "Directories" "Toolsfolder" PathToolsFolder
--setINISetting VRageConfigFile "Directories" "FBXImporter" PathFBXImporter
--setINISetting VRageConfigFile "Directories" "MwMBuilder" PathMwmBuilder
--setINISetting VRageConfigFile "Directories" "TexturePath" PathTextures
setINISetting VRageConfigFile "Directories" "ModSDK" PathModSDK
setINISetting VRageConfigFile "Directories" "HavokContentTools" PathHavokContentTools
setINISetting VRageConfigFile "Textures" "TextureType" ( TextureType as string )
setINISetting VRageConfigFile "Directories" "pathgame" PathGame
setINISetting VRageConfigFile "Textures" "UseGameTextures" ( if UseGameTextures then "1" else "0" )
setINISetting VRageConfigFile "Textures" "UsePbrMats" ( if UsePbrMats then "1" else "0" )
setINISetting VRageConfigFile "UI" "MatBrowserSizex" (MatBrowserSizeX as string)
setINISetting VRageConfigFile "UI" "MatBrowserSizeY" (MatBrowserSizeY as string)
),
fn load = (
if ( doesFileExist VRageConfigFile ) then (
PathToolsFolder = if ( tmp = getINISetting VRageConfigFile "Directories" "Toolsfolder" ) != undefined then tmp else ""
if ( PathToolsFolder ) != "" then (
if getDirectories ( PathToolsFolder ) != undefined then (
PathFBXImporter = if ( tmp = getFiles ( VRageScriptsDir + "\\Vrage_Tools\\FbxImporter.exe" ) ).count != 0 then tmp[1] else ""
PathMwmBuilder = if ( tmp = getFiles ( VRageScriptsDir + "\\Vrage_Tools\\MWMBuilder\\MwmBuilder.exe" ) ).count != 0 then ( VRageScriptsDir + "\\Vrage_Tools\\MWMBuilder\\MwmBuilder.exe" ) else ""
PathTextures = if ( tmp = getDirectories ( PathToolsFolder + "\\Textures" ) ).count != 0 then PathToolsFolder else ""
)
)
PathHavokContentTools = if ( tmp = getINISetting VRageConfigFile "Directories" "HavokContentTools" ) != undefined then tmp else ""
--PathHavokContentTools = if (tmp = getFiles (PathHavokContentTools + "\\hctStandAloneFilterManager.exe")) != undefined then PathHavokContentTools else ""
--registry get HavoK:
--regPath = @"SOFTWARE\Havok\hkFilters_x64"
--evalKey = ((dotnetclass "Microsoft.Win32.Registry").CurrentUser).OpenSubKey regPath
--docFolder = evalKey.GetValue "FilterPath"
PathModSDK = if ( tmp = getINISetting VRageConfigFile "Directories" "ModSDK" ) != undefined then tmp else ""
UseGameTextures = ( getINISetting VRageConfigFile "Textures" "UseGameTextures" ) == "1"
UsePbrMats = ( getINISetting VRageConfigFile "Textures" "UsePbrMats" ) == "1"
TextureType = try ( getINISetting VRageConfigFile "Textures" "TextureType" as integer ) catch 5
PathGame = if ( tmp = getINISetting VRageConfigFile "Directories" "pathgame" ) != undefined then tmp else ""
MatBrowserSizeX = if ( tmp = getINISetting VRageConfigFile "UI" "MatBrowserSizeX" ) != "" then (tmp as integer) else MatBrowserSizeX
MatBrowserSizeY = if ( tmp = getINISetting VRageConfigFile "UI" "MatBrowserSizeY" ) != "" then (tmp as integer) else MatBrowserSizeY
)
else (
PathToolsFolder = ""
PathFBXImporter = " "
PathHavokContentTools = " "
PathMwmBuilder = " "
PathTextures = " "
PathModSDK = ""
UseGameTextures = False
TextureType = 5
PathGame = ""
)
),
fn gInt prop = (
( getProperty VRageConfig ( name as name ) )
),
fn gFloat prop = (
( getProperty VRageConfig ( name as name ) ) as float
)
)
global VrageTextureIO_ConvertSEtoReadable
global MyVRageCfg = VRageConfig()
MyVRageCfg.load()
-- intialize Materiallibrary if its lost...
if Vrage_MaterialThumbRenderer == undefined then
(
fileIn ( GetDir #userScripts + "\\VRageToolbox\\Vrage_IO\\Vrage_MaterialLibrary.ms" )
)
global VRageTexTypes = #(".dds", ".jpg", ".png", ".tga", ".tif")
/* has to be global to be closable from anywhere */
global MyVRageCfgFloater
fn Vrage_LaunchGame = (
if MyVRageCfg.PathGame != "" and doesDirectoryExist MyVRageCfg.PathGame then (
executeables = getFiles ( MyVRageCfg.PathGame + "*Engineers.exe" )
if executeables.count == 0 then (
dirs = getDirectories ( MyVRageCfg.PathGame + "\\*" )
for d in dirs do join executeables ( getFiles ( d + "*Engineers.exe" ) )
if executeables.count > 0 then (
ShellLaunch executeables[1] ""
)
else (
--TODO: Messagebox to notify the user that no Game.exe could be found
)
)
else (
ShellLaunch executeables[1] ""
)
)
)
fn OpenSettings = (
rollout VrageUtils_CfgScene "VRage Utilities - Config" width:210 height:400
(
label lbl_text "Configuration Panel for the VRAGE Utilites. \nPlease refer to the setup tutorial if the settings are unclear." height:30 align:#left across:2
button btn_CFgHelp "Help / Info" width:50 height:25 align:#right \
toolTip:"Opens the Documentation/Help" images: #( VRageIcons, VRageIcons, VRageIcoLeng, 17, 17, 17, 17 )
on btn_CFgHelp pressed do (ShellLaunch "https://vragetoolbox.ratpool.de/doku.php?id=vrt:settings" "")
)
rollout VrageUtils_CfgTools "Tools/Paths" width:210 height:400
(
label lbl_PathTools "VrageToolbox Utils Folder:" align:#left across:2
button btn_PathTools MyVRageCfg.PathToolsFolder width:400 height:25 align:#right \
tooltip:"Path to the Vragetoolbox Folder which has/will contain textures and other custom materials for example"
on btn_PathTools pressed do (
FilePath = getSavePath caption:"Test path..."
if ( FilePath != undefined ) do (
btn_PathTools.text = MyVRageCfg.PathToolsFolder = FilePath
MyVRageCfg.save()
)
)
on btn_PathTools rightclick do try ( shellLaunch ( getFilenamePath MyVRageCfg.PathToolsFolder ) "" ) catch()
label lbl_PathHavok "HavokContentTools:" align:#left across:2
button btn_PathHavok MyVRageCfg.PathHavokContentTools width:400 height:25 align:#right \
tooltip:" path to the installation directory of HavokContentTools"
on btn_PathHavok pressed do (
FilePath = getSavePath caption:"Test path..."
if ( FilePath != undefined ) do (
btn_PathHavok.text = MyVRageCfg.PathHavokContentTools = FilePath
MyVRageCfg.save()
)
)
on btn_PathHavok rightclick do try ( shellLaunch ( getFilenamePath MyVRageCfg.PathHavokContentTools ) "" ) catch()
label lbl_ToolStatus "Status:" align:#left across:5 tooltip:"Status if the displayed tools have benn found in the defined paths.(green = yes/red=no) "
hyperlink Chbx_Textures "Textures" Enabled:false color: ( color 240 0 0 ) align:#right
hyperlink Chbx_FBXImporter "FBXImporter" Enabled:false color: ( color 240 0 0 ) align:#right
hyperlink Chbx_MwMBuilder "MWMBuilder" Enabled:false color: ( color 240 0 0 ) align:#right
hyperlink Chbx_Havoktools "Havoktools " Enabled:false color: ( color 240 0 0 ) align:#right
timer clock "testClock" interval:500 --tick every 2 sec
on clock tick do
(
if getDirectories ( MyVRageCfg.PathToolsFolder ) != undefined then (
MyVRageCfg.PathTextures = if ( tmp = getDirectories ( MyVRageCfg.PathToolsFolder + "\\Textures" ) ).count != 0 then ( MyVRageCfg.PathToolsFolder ) else ""
)
MyVRageCfg.PathFBXImporter = if ( tmp = getFiles ( MyVRageCfg.VRageScriptsDir + "\\Vrage_Tools\\FbxImporter.exe" ) ).count != 0 then tmp[1] else ""
MyVRageCfg.PathMwmBuilder = if ( tmp = getFiles ( MyVRageCfg.VRageScriptsDir + "\\Vrage_Tools\\MWMBuilder\\MwmBuilder.exe" ) ).count != 0 then ( MyVRageCfg.VRageScriptsDir + "\\Vrage_Tools\\MWMBuilder\\MwmBuilder.exe" ) else ""
MyVRageCfg.PathHavokContentTools = if ( tmp = getFiles ( MyVRageCfg.PathHavokContentTools + "\\hctStandAloneFilterManager.exe" ) ).count != 0 then MyVRageCfg.PathHavokContentTools else "none"
if MyVRageCfg.PathFBXImporter != "" then ( Chbx_FBXImporter.color = ( color 0 200 0 ) ) else ( Chbx_FBXImporter.color = ( color 240 0 0 ) )
if MyVRageCfg.PathMwmBuilder != "" then ( Chbx_MwMBuilder.color = ( color 0 200 0 ) ) else ( Chbx_MwMBuilder.color = ( color 240 0 0 ) )
if MyVRageCfg.PathTextures != "" then ( Chbx_Textures.color = ( color 0 200 0 ) ) else ( Chbx_Textures.color = ( color 240 0 0 ) )
if MyVRageCfg.PathHavokContentTools != "none" then ( Chbx_Havoktools.color = ( color 0 200 0 ) ) else ( Chbx_Havoktools.color = ( color 240 0 0 ) )
)
)
rollout VrageUtils_CfgTextures "Textures" width:210 height:400
(
button btn_ConvertTxt "Convert Textures" width:150 height:25 toolTip:"Run the Bulk Texture Converter to convert the Game textures to the 3dsmax readable format." across:3
on btn_ConvertTxt pressed do
(
if VrageTextureIO_ConvertSEtoReadable == undefined then
(
fileIn ( GetDir #userScripts + "\\VRageToolbox\\Vrage_IO\\Vrage_TextureIO.ms" )
)
if queryBox "This will take ~5 minutes or more. \n Do you want to continue?" beep:false title:"VrageToolbox" then VrageTextureIO_ConvertSEtoReadable()
)
button btn_GenMatThumbs "Generate MaterialThumbnails" width:150 height:25 toolTip:"Re/Generates the Materialthumbnails"
on btn_GenMatThumbs pressed do
(
if Vrage_MaterialThumbRenderer == undefined then
(
fileIn ( GetDir #userScripts + "\\VRageToolbox\\Vrage_IO\\Vrage_MaterialLibrary.ms" )
)
if queryBox "This will take ~5 minutes or more. \n Do you want to continue?" beep:false title:"VrageToolbox" do (
MyVrageThumbRenderer = Vrage_MaterialThumbRenderer()
MyVrageThumbRenderer.GenerateMatThumbnails MyVrageMatLib.mat_names
)
)
on VrageUtils_CfgTextures open do
(
--theBmp = (openBitMap @"C:\Users\patgr\Desktop\Standard_24i.tif")
--the_bmp.bitmap = theBmp
--print theBmp.color
-- btn_ConvertTxt.images = #(theBmp, undefined, 1,1,1,1,1 )
)
)
rollout VrageUtils_CfgGame "Game" width:210 height:400
(
label lbl_PathPathModeSDK "ModSDK:" align:#left across:2
button btn_PathPathModeSDK MyVRageCfg.PathModSDK width:400 height:25 align:#right tooltip:"Path to the SE/ME PathModSDK directory"
on btn_PathPathModeSDK pressed do (
FilePath = getSavePath caption:"Test path..."
if ( FilePath != undefined ) do (
btn_PathPathModeSDK.text = MyVRageCfg.PathModSDK = FilePath
MyVRageCfg.save()
)
)
on btn_PathPathModeSDK rightclick do try ( shellLaunch MyVRageCfg.PathModSDK "" ) catch()
label lbl_PathGame "Game Directory:" align:#left across:2
button btn_PathGame MyVRageCfg.PathGame width:400 height:25 align:#right tooltip:"Path to the Space/Medieval Engineers directory"
on btn_pathgame pressed do (
filepath = getsavepath caption:"test path..."
if ( filepath != undefined ) do (
btn_pathgame.text = MyVRageCfg.pathgame = filepath
MyVRageCfg.save()
)
)
on btn_pathgame rightclick do try ( shellLaunch MyVRageCfg.PathGame "" ) catch()
button btn_LaunchGame "Launch Game" width:150 height:25 toolTip:"Launches the Game" align:#right offset:[0, 15]
on btn_LaunchGame pressed do (
Vrage_LaunchGame()
)
)
try ( cui.UnRegisterDialogBar MyVRageCfgFloater ) catch ()
try ( closeRolloutFloater MyVRageCfgFloater ) catch ()
Pos = getMaxWindowSize()
PosX = Pos[1] / 2 - 300
MyVRageCfgFloater = newRolloutFloater "VRage Utilities Config" 600 380 PosX 250
addRollout VrageUtils_CfgScene MyVRageCfgFloater
addRollout VrageUtils_CfgTools MyVRageCfgFloater
addRollout VrageUtils_CfgTextures MyVRageCfgFloater
addRollout VrageUtils_CfgGame MyVRageCfgFloater
cui.RegisterDialogBar MyVRageCfgFloater style:#( #cui_floatable, #cui_dock_right , #cui_dock_left )
)
--OpenSettings()