-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathprefs.py
173 lines (150 loc) · 6.25 KB
/
prefs.py
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
import bpy
from bpy.props import *
import bgl
import os
from . constants import *
__reload_order_index__ = -20
# METHODS
#############################################
def is_valid_game_path(path):
# We need at least these folders to be available to consider it a valid game path
if not os.path.exists(os.path.join(path, "images")):
return False
if not os.path.exists(os.path.join(path, "models")):
return False
if not os.path.exists(os.path.join(path, "textures")):
return False
return True
def get_game_asset_paths(context):
scn = context.scene
addon_prefs = context.preferences.addons[ADDON_NAME].preferences
if not hasattr(scn, 'thug_level_props') or not hasattr(scn.thug_level_props, 'export_props'):
print("Unable to read game files - Cannot find level/export properties")
return [], ""
if scn.thug_level_props.export_props.target_game == '':
print("Unable to read game files - target game not set")
return [], ""
target_game = scn.thug_level_props.export_props.target_game
game_paths = []
ext_suffix = ""
if target_game == 'THUG1':
if not is_valid_game_path(addon_prefs.game_data_dir_thug1):
print("Unable to read game files - game path {} is not valid.".format(addon_prefs.game_data_dir_thug1))
else:
game_paths.append(addon_prefs.game_data_dir_thug1)
elif target_game == 'THUG2':
ext_suffix = ".xbx"
if not is_valid_game_path(addon_prefs.game_data_dir_thug2):
print("Unable to read game files - game path {} is not valid.".format(addon_prefs.game_data_dir_thug2))
else:
game_paths.append(addon_prefs.game_data_dir_thug2)
if not is_valid_game_path(addon_prefs.game_data_dir_thugpro):
print("Unable to read game files - game path {} is not valid.".format(addon_prefs.game_data_dir_thugpro))
else:
game_paths.append(addon_prefs.game_data_dir_thugpro)
else:
print("Unable to read game files - target game is {}".format(target_game))
return [], ""
return game_paths, ext_suffix
# PROPERTIES
#############################################
class THUGAddonPreferences(bpy.types.AddonPreferences):
bl_idname = ADDON_NAME
line_width: FloatProperty(name="Line Width", min=0, max=15, default=10, description="Size of autorail lines displayed in the viewport")
autorail_edge_color: FloatVectorProperty(
name="Mesh Rail Edge Color",
size=4,
min=0.0,
max=1.0,
subtype="COLOR",
default=(1.0, 0.0, 0.0, 1.0))
rail_end_connection_color: FloatVectorProperty(
name="Rail End Connection Color",
size=4,
min=0.0,
max=1.0,
subtype="COLOR",
default=(1.0, 1.0, 0.0, 1.0))
bad_face_color: FloatVectorProperty(
name="Bad Face Color",
size=4,
min=0.0,
max=1.0,
subtype="COLOR",
default=(1.0, 0.0, 1.0, 0.5))
vert_face_color: FloatVectorProperty(
name="Vert Face Color",
size=4,
min=0.0,
max=1.0,
subtype="COLOR",
default=(0.0, 0.0, 1.0, 0.5))
wallridable_face_color: FloatVectorProperty(
name="Wallridable Face Color",
size=4,
min=0.0,
max=1.0,
subtype="COLOR",
default=(0.0, 1.0, 1.0, 0.5))
trigger_face_color: FloatVectorProperty(
name="Trigger Face Color",
size=4,
min=0.0,
max=1.0,
subtype="COLOR",
default=(0.0, 1.0, 0.0, 0.5))
non_collidable_face_color: FloatVectorProperty(
name="Non Collidable Face Color",
size=4,
min=0.0,
max=1.0,
subtype="COLOR",
default=(1.0, 1.0, 0.0, 0.5))
mix_face_colors: BoolProperty(name="Mix Face Colors", default=False)
show_bad_face_colors: BoolProperty(name="Highlight Bad Faces", default=True,
description="Colorize faces with bad collision flag combinations using Bad Face Color")
object_settings_tools: BoolProperty(name="Show Object Settings in the Tools Tab", default=True)
material_settings_tools: BoolProperty(name="Show Material Settings in the Tools Tab", default=True)
material_pass_settings_tools: BoolProperty(name="Show Material Pass Settings in the Tools Tab", default=True)
# New settings as of io_thps_scene v1.2
path_bevel_size: FloatProperty(name="Rail/Waypoint path size", min=0.1, max=128, default=1, description="Default size displayed in the viewport for all rail, ladder, and waypoint paths")
game_data_dir_thug1: StringProperty(
name="Game directory - THUG1",
subtype='DIR_PATH',
default="C:\\",
description="Path to your game files for THUG1 - select the 'Data' folder"
)
game_data_dir_thug2: StringProperty(
name="Game directory - THUG2",
subtype='DIR_PATH',
default="C:\\",
description="Path to your game files for THUG2 (Base game, NOT the THUG PRO files) - select the 'Data' folder"
)
game_data_dir_thugpro: StringProperty(
name="Game directory - THUG PRO",
subtype='DIR_PATH',
default="C:\\",
description="Path to your game files for THUG PRO (NOT the base game files) - select the 'Data' folder"
)
def draw(self, context):
layout = self.layout
layout.prop(self, "game_data_dir_thug1")
layout.prop(self, "game_data_dir_thug2")
layout.prop(self, "game_data_dir_thugpro")
for prop in ["autorail_edge_color",
"rail_end_connection_color",
"bad_face_color",
"vert_face_color",
"wallridable_face_color",
"trigger_face_color",
"non_collidable_face_color",]:
layout.row().prop(self, prop)
row = layout.row()
row.prop(self, "mix_face_colors")
row.prop(self, "show_bad_face_colors")
row = layout.row()
row.prop(self, "line_width")
row.prop(self, "path_bevel_size")
layout.prop(self, "object_settings_tools")
layout.prop(self, "material_settings_tools")
layout.prop(self, "material_pass_settings_tools")