Skip to content

Commit

Permalink
Release - 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
simon50keda committed Jan 22, 2016
1 parent 61b62d5 commit 97e5eae
Show file tree
Hide file tree
Showing 26 changed files with 1,300 additions and 880 deletions.
25 changes: 16 additions & 9 deletions addon/io_scs_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"name": "SCS Tools",
"description": "Setup models, Import-Export SCS data format",
"author": "Simon Lusenc (50keda), Milos Zajic (4museman)",
"version": (1, 0, "76261ad"),
"version": (1, 1, "e02402c"),
"blender": (2, 75, 0),
"location": "File > Import-Export",
"wiki_url": "https://github.com/SCSSoftware/BlenderTools/wiki",
"tracker_url": "http://forum.scssoft.com/viewforum.php?f=165",
"tracker_url": "http://forum.scssoft.com/viewforum.php?f=163",
"support": "COMMUNITY",
"category": "Import-Export"}

Expand All @@ -50,7 +50,7 @@ def get_tools_version():
from io_scs_tools.imp import pix as _pix_import
from io_scs_tools.internals.callbacks import open_gl as _open_gl_callback
from io_scs_tools.internals.callbacks import persistent as _persistent_callback
from io_scs_tools.internals.icons import release_icons_data
from io_scs_tools.internals import icons as _icons
from io_scs_tools.utils import get_scs_globals as _get_scs_globals
from io_scs_tools.utils.view3d import switch_layers_visibility as _switch_layers_visibility
from io_scs_tools.utils.printout import lprint
Expand Down Expand Up @@ -218,9 +218,13 @@ def execute(self, context):

filepath = os.path.dirname(self.filepath)

export_type = _get_scs_globals().content_type
# convert it to None, so export will ignore given menu file path and try to export to other none menu set paths
if self.filepath == "":
filepath = None

export_scope = _get_scs_globals().export_scope
init_obj_list = {}
if export_type == "selection":
if export_scope == "selection":
for obj in bpy.context.selected_objects:
root = _object_utils.get_scs_root(obj)
if root:
Expand All @@ -241,9 +245,9 @@ def execute(self, context):
init_obj_list[reselected_obj.name] = reselected_obj

init_obj_list = tuple(init_obj_list.values())
elif export_type == "scene":
elif export_scope == "scene":
init_obj_list = tuple(bpy.context.scene.objects)
elif export_type == 'scenes':
elif export_scope == 'scenes':
init_obj_list = tuple(bpy.data.objects)

try:
Expand All @@ -266,7 +270,7 @@ def execute(self, context):
def draw(self, context):
box0 = self.layout.box()
row = box0.row()
row.prop(_get_scs_globals(), 'content_type', expand=True)
row.prop(_get_scs_globals(), 'export_scope', expand=True)
ui.shared.draw_export_panel(self.layout)


Expand All @@ -285,6 +289,9 @@ def register():

bpy.utils.register_module(__name__)

# CUSTOM ICONS CLEANUP
_icons.init()

# PROPERTIES REGISTRATION
bpy.types.Object.scs_object_look_inventory = CollectionProperty(
type=properties.object.ObjectLooksInventoryItem
Expand Down Expand Up @@ -358,7 +365,7 @@ def unregister():
bpy.utils.unregister_module(__name__)

# CUSTOM ICONS CLEANUP
release_icons_data()
_icons.cleanup()

# REMOVE MENU ENTRIES
bpy.types.INFO_MT_file_export.remove(menu_func_export)
Expand Down
18 changes: 0 additions & 18 deletions addon/io_scs_tools/exp/pix.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,6 @@ def _get_objects_by_type(blender_objects, parts):
return mesh_object_list, prefab_locator_list, model_locator_list, collision_locator_list, armature_object


def _get_initial_selection(content_type):
"""
Takes content type and returns initial object list.
:param content_type:
:return:
"""
if content_type == 'selection':
init_obj_list = bpy.context.selected_objects
elif content_type == 'scene':
init_obj_list = bpy.context.scene.objects
elif content_type == 'scenes':
init_obj_list = bpy.data.objects
else:
init_obj_list = bpy.context.selected_objects
lprint('W Unkown "Selection type" - %r. Using "Selection Only".', content_type)
return init_obj_list


def export(dirpath, root_object, game_object_list):
"""The main export function.
Expand Down
15 changes: 8 additions & 7 deletions addon/io_scs_tools/imp/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,14 +472,12 @@ def _create_traffic_light_locator(
locator = _object_utils.create_locator_empty(tsem_name, tsem_position, tsem_rotation, (1, 1, 1), 0.1, 'Prefab')
if locator:
locator.scs_props.locator_prefab_type = 'Traffic Semaphore'
if tsem_id == -1:
tsem_id = 'none'
else:
tsem_id = str(tsem_id)
locator.scs_props.locator_prefab_tsem_id = tsem_id
locator.scs_props.locator_prefab_tsem_id = str(tsem_id)

tsem_profile_value = _inventory.get_item_name(scs_tsem_profile_inventory, tsem_profile, report_errors=True)
locator.scs_props.locator_prefab_tsem_profile = tsem_profile_value
# try to set semaphore profile only if it has some value
if tsem_profile != "":
tsem_profile_value = _inventory.get_item_name(scs_tsem_profile_inventory, tsem_profile, report_errors=True)
locator.scs_props.locator_prefab_tsem_profile = tsem_profile_value

locator.scs_props.locator_prefab_tsem_type = str(tsem_type)
locator.scs_props.locator_prefab_tsem_gs = tsem_intervals[0]
Expand Down Expand Up @@ -754,6 +752,9 @@ def load(filepath, terrain_points_trans):
if tsem_name is None:
tsem_name = str('Semaphore_Locator_' + str(tsem_index))

if tsem_id is None:
tsem_id = -1

traffic_lights_data[tsem_name] = (
tsem_position,
tsem_rotation,
Expand Down
3 changes: 2 additions & 1 deletion addon/io_scs_tools/internals/connections/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from io_scs_tools.consts import PrefabLocators as _PL_consts
from io_scs_tools.utils import curve as _curve_utils
from io_scs_tools.utils import math as _math_utils
from io_scs_tools.utils import get_scs_globals as _get_scs_globals


def collect_nav_curve_data(loc0_obj, loc1_obj):
Expand All @@ -41,7 +42,7 @@ def collect_nav_curve_data(loc0_obj, loc1_obj):
"locrot_1": tuple}
"""

curve_steps = bpy.context.scene.scs_props.curve_segments
curve_steps = _get_scs_globals().curve_segments

nav_point_0_loc = loc0_obj.matrix_world.translation
nav_point_0_rot = loc0_obj.matrix_world.to_euler('XYZ')
Expand Down
18 changes: 12 additions & 6 deletions addon/io_scs_tools/internals/connections/wrappers/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from io_scs_tools.consts import ConnectionsStorage as _CS_consts
from io_scs_tools.internals.connections import core as _core
from io_scs_tools.internals.open_gl import primitive as _gl_primitive
from io_scs_tools.utils import get_scs_globals as _get_scs_globals
from io_scs_tools.utils.printout import lprint as lprint

_GROUP_NAME = _CS_consts.group_name
Expand Down Expand Up @@ -276,12 +277,15 @@ def switch_to_stall():
_CACHE[_DATA_UP_TO_DATE] = True


def _execute_draw():
def _execute_draw(optimized_drawing):
"""Checks if connections should be drawn.
:param optimized_drawing: optimized connections drawing property from SCS globals
:type optimized_drawing: bool
"""

# exlude optimization drawing
if not bpy.context.scene.scs_props.optimized_connections_drawing:
# exclude optimization drawing
if not optimized_drawing:
_core.update_for_redraw(bpy.data.groups[_GROUP_NAME], None)
return True

Expand All @@ -296,7 +300,9 @@ def draw(visible_loc_names):
:type visible_loc_names: dict
"""

if _execute_draw():
scs_globals = _get_scs_globals()

if _execute_draw(scs_globals.optimized_connections_drawing):

connections = bpy.data.groups[_GROUP_NAME][_core.MAIN_DICT][_core.REFS][_core.CONNECTIONS][_core.ENTRIES]

Expand All @@ -308,6 +314,6 @@ def draw(visible_loc_names):

locator_type = bpy.data.objects[conn_entry[_core.IN]].scs_props.locator_prefab_type
if locator_type == "Navigation Point":
_gl_primitive.draw_shape_curve(conn_entry[_core.DATA], not conn_entry[_core.VALID])
_gl_primitive.draw_shape_curve(conn_entry[_core.DATA], not conn_entry[_core.VALID], scs_globals)
else:
_gl_primitive.draw_shape_line(conn_entry[_core.DATA], not conn_entry[_core.VALID], locator_type == "Map Point")
_gl_primitive.draw_shape_line(conn_entry[_core.DATA], not conn_entry[_core.VALID], locator_type == "Map Point", scs_globals)
66 changes: 34 additions & 32 deletions addon/io_scs_tools/internals/containers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ def fill_paths_section():
section.props.append(("TrafficRulesUseInfixed", int(_property_utils.get_default(bpy.types.GlobalSCSProps.traffic_rules_library_use_infixed))))
section.props.append(("HookupRelDirPath", _property_utils.get_default(bpy.types.GlobalSCSProps.hookup_library_rel_path)))
section.props.append(("MatSubsRelFilePath", _property_utils.get_default(bpy.types.GlobalSCSProps.matsubs_library_rel_path)))
section.props.append(("ConvertersPath", _property_utils.get_default(bpy.types.GlobalSCSProps.conv_hlpr_converters_path)))
return section

def fill_import_section():
Expand All @@ -509,7 +510,6 @@ def fill_import_section():
def fill_export_section():
"""Fills up "Export" section."""
section = _SectionData("Export")
section.props.append(("ContentType", _property_utils.get_default(bpy.types.GlobalSCSProps.content_type)))
section.props.append(("ExportScale", _property_utils.get_default(bpy.types.GlobalSCSProps.export_scale)))
section.props.append(("ApplyModifiers", int(_property_utils.get_default(bpy.types.GlobalSCSProps.apply_modifiers))))
section.props.append(("ExcludeEdgesplit", int(_property_utils.get_default(bpy.types.GlobalSCSProps.exclude_edgesplit))))
Expand All @@ -531,25 +531,25 @@ def fill_export_section():
def fill_global_display_section():
"""Fills up "GlobalDisplay" section."""
section = _SectionData("GlobalDisplay")
section.props.append(("DisplayLocators", int(_property_utils.get_default(bpy.types.SceneSCSProps.display_locators))))
section.props.append(("LocatorSize", _property_utils.get_default(bpy.types.SceneSCSProps.locator_size)))
section.props.append(("LocatorEmptySize", _property_utils.get_default(bpy.types.SceneSCSProps.locator_empty_size)))
section.props.append(("DisplayConnections", int(_property_utils.get_default(bpy.types.SceneSCSProps.display_connections))))
section.props.append(("CurveSegments", _property_utils.get_default(bpy.types.SceneSCSProps.curve_segments)))
section.props.append(("DisplayTextInfo", _property_utils.get_default(bpy.types.SceneSCSProps.display_info)))
section.props.append(("DisplayLocators", int(_property_utils.get_default(bpy.types.GlobalSCSProps.display_locators))))
section.props.append(("LocatorSize", _property_utils.get_default(bpy.types.GlobalSCSProps.locator_size)))
section.props.append(("LocatorEmptySize", _property_utils.get_default(bpy.types.GlobalSCSProps.locator_empty_size)))
section.props.append(("DisplayConnections", int(_property_utils.get_default(bpy.types.GlobalSCSProps.display_connections))))
section.props.append(("CurveSegments", _property_utils.get_default(bpy.types.GlobalSCSProps.curve_segments)))
section.props.append(("DisplayTextInfo", _property_utils.get_default(bpy.types.GlobalSCSProps.display_info)))
return section

def fill_global_colors_section():
"""Fills up "GlobalColors" section."""
section = _SectionData("GlobalColors")
section.props.append(("PrefabLocatorsWire", tuple(_property_utils.get_default(bpy.types.SceneSCSProps.locator_prefab_wire_color))))
section.props.append(("ModelLocatorsWire", tuple(_property_utils.get_default(bpy.types.SceneSCSProps.locator_model_wire_color))))
section.props.append(("ColliderLocatorsWire", tuple(_property_utils.get_default(bpy.types.SceneSCSProps.locator_coll_wire_color))))
section.props.append(("ColliderLocatorsFace", tuple(_property_utils.get_default(bpy.types.SceneSCSProps.locator_coll_face_color))))
section.props.append(("NavigationCurveBase", tuple(_property_utils.get_default(bpy.types.SceneSCSProps.np_connection_base_color))))
section.props.append(("MapLineBase", tuple(_property_utils.get_default(bpy.types.SceneSCSProps.mp_connection_base_color))))
section.props.append(("TriggerLineBase", tuple(_property_utils.get_default(bpy.types.SceneSCSProps.tp_connection_base_color))))
section.props.append(("InfoText", tuple(_property_utils.get_default(bpy.types.SceneSCSProps.info_text_color))))
section.props.append(("PrefabLocatorsWire", tuple(_property_utils.get_default(bpy.types.GlobalSCSProps.locator_prefab_wire_color))))
section.props.append(("ModelLocatorsWire", tuple(_property_utils.get_default(bpy.types.GlobalSCSProps.locator_model_wire_color))))
section.props.append(("ColliderLocatorsWire", tuple(_property_utils.get_default(bpy.types.GlobalSCSProps.locator_coll_wire_color))))
section.props.append(("ColliderLocatorsFace", tuple(_property_utils.get_default(bpy.types.GlobalSCSProps.locator_coll_face_color))))
section.props.append(("NavigationCurveBase", tuple(_property_utils.get_default(bpy.types.GlobalSCSProps.np_connection_base_color))))
section.props.append(("MapLineBase", tuple(_property_utils.get_default(bpy.types.GlobalSCSProps.mp_connection_base_color))))
section.props.append(("TriggerLineBase", tuple(_property_utils.get_default(bpy.types.GlobalSCSProps.tp_connection_base_color))))
section.props.append(("InfoText", tuple(_property_utils.get_default(bpy.types.GlobalSCSProps.info_text_color))))
return section

'''
Expand Down Expand Up @@ -625,6 +625,7 @@ def apply_settings():
traffic_rules_library_rel_path = _property_utils.get_default(bpy.types.GlobalSCSProps.traffic_rules_library_rel_path)
hookup_library_rel_path = _property_utils.get_default(bpy.types.GlobalSCSProps.hookup_library_rel_path)
matsubs_library_rel_path = _property_utils.get_default(bpy.types.GlobalSCSProps.matsubs_library_rel_path)
conv_hlpr_converters_path = _property_utils.get_default(bpy.types.GlobalSCSProps.conv_hlpr_converters_path)

_get_scs_globals().config_update_lock = True
# print(' > apply_settings...')
Expand Down Expand Up @@ -659,6 +660,8 @@ def apply_settings():
hookup_library_rel_path = prop[1]
elif prop[0] == "MatSubsRelFilePath":
matsubs_library_rel_path = prop[1]
elif prop[0] == "ConvertersPath":
conv_hlpr_converters_path = prop[1]
else:
lprint('W Unrecognised item "%s" has been found in setting file! Skipping...', (str(prop[0]),))
elif section.type == "Import":
Expand Down Expand Up @@ -697,8 +700,6 @@ def apply_settings():
for prop in section.props:
if prop[0] in ("", "#"):
pass
elif prop[0] == "ContentType":
_get_scs_globals().content_type = prop[1]
elif prop[0] == "ExportScale":
_get_scs_globals().export_scale = float(prop[1])
elif prop[0] == "ApplyModifiers":
Expand Down Expand Up @@ -736,41 +737,41 @@ def apply_settings():
if prop[0] in ("", "#"):
pass
elif prop[0] == "DisplayLocators":
bpy.context.scene.scs_props.display_locators = prop[1]
_get_scs_globals().display_locators = prop[1]
elif prop[0] == "LocatorSize":
bpy.context.scene.scs_props.locator_size = float(prop[1])
_get_scs_globals().locator_size = float(prop[1])
elif prop[0] == "LocatorEmptySize":
bpy.context.scene.scs_props.locator_empty_size = float(prop[1])
_get_scs_globals().locator_empty_size = float(prop[1])
elif prop[0] == "DisplayConnections":
bpy.context.scene.scs_props.display_connections = prop[1]
_get_scs_globals().display_connections = prop[1]
elif prop[0] == "CurveSegments":
bpy.context.scene.scs_props.curve_segments = prop[1]
_get_scs_globals().curve_segments = prop[1]
elif prop[0] == "OptimizedConnsDrawing":
bpy.context.scene.scs_props.optimized_connections_drawing = prop[1]
_get_scs_globals().optimized_connections_drawing = prop[1]
elif prop[0] == "DisplayTextInfo":
bpy.context.scene.scs_props.display_info = prop[1]
_get_scs_globals().display_info = prop[1]
else:
lprint('W Unrecognised item "%s" has been found in setting file! Skipping...', (str(prop[0]),))
elif section.type == "GlobalColors":
for prop in section.props:
if prop[0] in ("", "#"):
pass
elif prop[0] == "PrefabLocatorsWire":
bpy.context.scene.scs_props.locator_prefab_wire_color = prop[1]
_get_scs_globals().locator_prefab_wire_color = prop[1]
elif prop[0] == "ModelLocatorsWire":
bpy.context.scene.scs_props.locator_model_wire_color = prop[1]
_get_scs_globals().locator_model_wire_color = prop[1]
elif prop[0] == "ColliderLocatorsWire":
bpy.context.scene.scs_props.locator_coll_wire_color = prop[1]
_get_scs_globals().locator_coll_wire_color = prop[1]
elif prop[0] == "ColliderLocatorsFace":
bpy.context.scene.scs_props.locator_coll_face_color = prop[1]
_get_scs_globals().locator_coll_face_color = prop[1]
elif prop[0] == "NavigationCurveBase":
bpy.context.scene.scs_props.np_connection_base_color = prop[1]
_get_scs_globals().np_connection_base_color = prop[1]
elif prop[0] == "MapLineBase":
bpy.context.scene.scs_props.mp_connection_base_color = prop[1]
_get_scs_globals().mp_connection_base_color = prop[1]
elif prop[0] == "TriggerLineBase":
bpy.context.scene.scs_props.tp_connection_base_color = prop[1]
_get_scs_globals().tp_connection_base_color = prop[1]
elif prop[0] == "InfoText":
bpy.context.scene.scs_props.info_text_color = prop[1]
_get_scs_globals().info_text_color = prop[1]
else:
lprint('W Unrecognised item "%s" has been found in setting file! Skipping...', (str(prop[0]),))
elif section.type == "Various":
Expand Down Expand Up @@ -800,6 +801,7 @@ def apply_settings():
_get_scs_globals().traffic_rules_library_rel_path = traffic_rules_library_rel_path
_get_scs_globals().hookup_library_rel_path = hookup_library_rel_path
_get_scs_globals().matsubs_library_rel_path = matsubs_library_rel_path
_get_scs_globals().conv_hlpr_converters_path = conv_hlpr_converters_path

_get_scs_globals().config_update_lock = False
return True
Loading

0 comments on commit 97e5eae

Please sign in to comment.