Skip to content

Commit

Permalink
Release - 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
simon50keda committed Mar 23, 2016
1 parent f7d5f1a commit 8cc7f92
Show file tree
Hide file tree
Showing 23 changed files with 348 additions and 106 deletions.
2 changes: 1 addition & 1 deletion addon/io_scs_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"name": "SCS Tools",
"description": "Setup models, Import-Export SCS data format",
"author": "Simon Lusenc (50keda), Milos Zajic (4museman)",
"version": (1, 2, "bfa9481"),
"version": (1, 2, "4a0a4dd"),
"blender": (2, 75, 0),
"location": "File > Import-Export",
"wiki_url": "https://github.com/SCSSoftware/BlenderTools/wiki",
Expand Down
22 changes: 13 additions & 9 deletions addon/io_scs_tools/exp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ def batch_export(operator_instance, init_obj_list, menu_filepath=None):

# MAKE FINAL FILEPATH
if menu_filepath:
filepath = menu_filepath
filepath = _path_utils.readable_norm(menu_filepath)
filepath_message = "Export path selected in file browser:\n\t \"" + filepath + "\""
elif custom_filepath:
filepath = custom_filepath
filepath = _path_utils.readable_norm(custom_filepath)
filepath_message = "Custom export path used for \"" + root_object.name + "\" is:\n\t \"" + filepath + "\""
else:
filepath = global_filepath
filepath = _path_utils.readable_norm(global_filepath)
filepath_message = "Default export path used for \"" + root_object.name + "\":\n\t \"" + filepath + "\""

scs_project_path = _get_scs_globals().scs_project_path
scs_project_path = _path_utils.readable_norm(_get_scs_globals().scs_project_path)
if os.path.isdir(filepath) and _path_utils.startswith(filepath, scs_project_path) and scs_project_path != "":

# EXPORT ENTRY POINT
Expand All @@ -106,18 +106,22 @@ def batch_export(operator_instance, init_obj_list, menu_filepath=None):
return {'CANCELLED'}

if not lprint("\nI Export procces completed, summaries are printed below!", report_errors=True, report_warnings=True):
operator_instance.report({'INFO'}, "Export successfully completed!")
operator_instance.report({'INFO'}, "Export successfully completed, exported %s game object(s)!" % len(scs_game_objects_exported))
bpy.ops.wm.show_3dview_report('INVOKE_DEFAULT', abort=True) # abort 3d view reporting operator

if len(scs_game_objects_exported) > 0:
print("\n\nEXPORTED GAME OBJECTS (" + str(len(scs_game_objects_exported)) + "):\n" + "=" * 26)
message = "EXPORTED GAME OBJECTS (" + str(len(scs_game_objects_exported)) + "):\n\t " + "=" * 26 + "\n\t "
for scs_game_object_export_message in scs_game_objects_exported:
print(scs_game_object_export_message)
message += scs_game_object_export_message + "\n\t "
message += "=" * 26
lprint("I " + message)

if len(scs_game_objects_rejected) > 0:
print("\n\nREJECTED GAME OBJECTS (" + str(len(scs_game_objects_rejected)) + "):\n" + "=" * 26)
message = "REJECTED GAME OBJECTS (" + str(len(scs_game_objects_rejected)) + "):\n\t " + "=" * 26 + "\n\t "
for scs_game_object_export_message in scs_game_objects_rejected:
print(scs_game_object_export_message)
message += scs_game_object_export_message + "\n\t "
message += "=" * 26
lprint("I " + message)

if len(scs_game_objects_exported) + len(scs_game_objects_rejected) == 0:
message = "Nothing to export! Please set at least one 'SCS Root Object'."
Expand Down
3 changes: 3 additions & 0 deletions addon/io_scs_tools/exp/pip/curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ def prepare_curves(curves_l):
msg = msg[:-2] + "]"
lprint(msg)

def __lt__(self, other):
return self.__index < other.get_index()

def __eq__(self, other):
return self.__index == other.get_index()

Expand Down
30 changes: 16 additions & 14 deletions addon/io_scs_tools/exp/pip/exporter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from os import path
from collections import OrderedDict
from mathutils import Vector, Quaternion
from io_scs_tools.consts import PrefabLocators as _PL_consts
from io_scs_tools.exp.pip.curve import Curve
Expand Down Expand Up @@ -27,13 +28,14 @@ def __sort_locators_by_type__(locator_list):
:rtype: tuple[dict[str, bpy.types.Object]]
"""

control_node_locs = {}
nav_point_locs = {}
sign_locs = {}
spawn_point_locs = {}
semaphore_locs = {}
map_point_locs = {}
trigger_point_locs = {}
# NOTE: doing all dictionaries ordered to have same export result on unchanged data
control_node_locs = OrderedDict()
nav_point_locs = OrderedDict()
sign_locs = OrderedDict()
spawn_point_locs = OrderedDict()
semaphore_locs = OrderedDict()
map_point_locs = OrderedDict()
trigger_point_locs = OrderedDict()

for loc in locator_list:
if loc.scs_props.locator_prefab_type == "Control Node":
Expand Down Expand Up @@ -148,21 +150,21 @@ def execute(dirpath, filename, prefab_locator_list, offset_matrix, used_terrain_
pip_header = Header(2, filename)
pip_global = Globall()

pip_nodes = {}
pip_nodes = OrderedDict()
""":type: dict[int,Node]"""
pip_curves = {}
pip_curves = OrderedDict()
""":type: dict[int, Curve]"""
pip_signs = []
""":type: list[Sign]"""
pip_spawn_points = []
""":type: list[SpawnPoint]"""
pip_semaphores = []
""":type: list[Semaphore]"""
pip_map_points = {}
pip_map_points = OrderedDict()
""":type: dict[str, MapPoint]"""
pip_trigger_points = {}
pip_trigger_points = OrderedDict()
""":type: dict[str, TriggerPoint]"""
pip_intersections = [{}, {}, {}]
pip_intersections = [OrderedDict(), OrderedDict(), OrderedDict()]
""":type: list[dict[str, list[Intersection]]]"""

# nodes creation
Expand Down Expand Up @@ -382,8 +384,8 @@ def execute(dirpath, filename, prefab_locator_list, offset_matrix, used_terrain_
TriggerPoint.prepare_trigger_points(pip_trigger_points.values())

# intersections creation
for c0_i, c0 in enumerate(pip_curves.values()):
for c1_i, c1 in enumerate(pip_curves.values()):
for c0_i, c0 in enumerate(sorted(pip_curves.values())):
for c1_i, c1 in enumerate(sorted(pip_curves.values())):

if c1_i <= c0_i: # only search each pair of curves once
continue
Expand Down
4 changes: 3 additions & 1 deletion addon/io_scs_tools/exp/pix.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ def export(dirpath, root_object, game_object_list):
context = bpy.context
context.window.cursor_modal_set('WAIT')

lprint("I Export started for: %r on: %s", (root_object.name, time.strftime("%b %d, %Y at %H:%M:%S")))

# TRANSITIONAL STRUCTURES
terrain_points = TerrainPntsTrans()
parts = PartsTrans()
Expand Down Expand Up @@ -216,6 +218,6 @@ def export(dirpath, root_object, game_object_list):
# FINAL FEEDBACK
context.window.cursor_modal_restore()
if export_success:
lprint('\nI Export completed in %.3f sec. Files were saved to folder:\n\t %r\n', (time.time() - t, dirpath))
lprint("I Export completed for: %r in %.3f seconds.\n", (root_object.name, time.time() - t))

return True
5 changes: 3 additions & 2 deletions addon/io_scs_tools/imp/pia.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from io_scs_tools.utils.printout import lprint
from io_scs_tools.utils import animation as _animation_utils
from io_scs_tools.utils import convert as _convert_utils
from io_scs_tools.utils import path as _path_utils
from io_scs_tools.utils import get_scs_globals as _get_scs_globals


Expand Down Expand Up @@ -212,7 +213,7 @@ def load(root_object, pia_files, armature, pis_filepath=None, bones=None):
if os.path.isfile(pia_skeleton):
bones = _pis.load(pia_skeleton, armature, get_only=True)
else:
lprint("\nE The filepath %r doesn't exist!", (pia_skeleton.replace("\\", "/"),))
lprint("\nE The filepath %r doesn't exist!", (_path_utils.readable_norm(pia_skeleton),))

else:
lprint(str("E Animation doesn't match the skeleton. Animation won't be loaded!\n\t "
Expand All @@ -222,7 +223,7 @@ def load(root_object, pia_files, armature, pis_filepath=None, bones=None):
lprint('I ++ "%s" IMPORTING animation data...', (os.path.basename(pia_filepath),))
pia_container = _pix_container.get_data_from_file(pia_filepath, ind)
if not pia_container:
lprint('\nE File "%s" is empty!', (pia_filepath.replace("\\", "/"),))
lprint('\nE File "%s" is empty!', (_path_utils.readable_norm(pia_filepath),))
continue

# TEST PRINTOUTS
Expand Down
5 changes: 3 additions & 2 deletions addon/io_scs_tools/imp/pix.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from io_scs_tools.utils import material as _material_utils
from io_scs_tools.utils import name as _name_utils
from io_scs_tools.utils import object as _object_utils
from io_scs_tools.utils import path as _path_utils
from io_scs_tools.utils.printout import lprint


Expand Down Expand Up @@ -304,15 +305,15 @@ def load(context, filepath):
if scs_globals.import_pim_file or scs_globals.import_pis_file:
if filepath:
if os.path.isfile(filepath):
lprint('\nD PIM filepath:\n %s', (filepath.replace("\\", "/"),))
lprint('\nD PIM filepath:\n %s', (_path_utils.readable_norm(filepath),))
result, objects, locators, armature, skeleton, mats_info = _pim.load(
context,
filepath,
terrain_points_trans=terrain_points
)
# print(' armature:\n%s\n skeleton:\n%s' % (str(armature), str(skeleton)))
else:
lprint('\nI No file found at %r!' % (filepath.replace("\\", "/"),))
lprint('\nI No file found at %r!' % (_path_utils.readable_norm(filepath),))
else:
lprint('\nI No filepath provided!')

Expand Down
7 changes: 4 additions & 3 deletions addon/io_scs_tools/internals/connections/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import bpy
import hashlib
from collections import OrderedDict
from io_scs_tools.consts import ConnectionsStorage as _CS_consts
from io_scs_tools.consts import PrefabLocators as _PL_consts
from io_scs_tools.internals.connections import collector as _collector
Expand Down Expand Up @@ -212,8 +213,8 @@ def gather_connections_upon_selected(data_block, loc_names):
locators_refs = data[REFS][LOCATORS]
conns_entries = data[REFS][CONNECTIONS][ENTRIES]

conns_to_draw = {}
for loc_name in loc_names:
conns_to_draw = OrderedDict() # use ordered one so export with unchanged data will be the same every time
for loc_name in sorted(loc_names):

if loc_name in locators_refs:

Expand Down Expand Up @@ -307,7 +308,7 @@ def get_connections(data_block, loc_name):
locators_refs = data[REFS][LOCATORS]
conns_entries = data[REFS][CONNECTIONS][ENTRIES]

connections = {}
connections = OrderedDict() # use ordered one so export with unchanged data will be the same every time
if loc_name in locators_refs:

loc_refs = locators_refs[loc_name]
Expand Down
7 changes: 4 additions & 3 deletions addon/io_scs_tools/internals/containers/mat.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# Copyright (C) 2013-2014: SCS Software

import os
from io_scs_tools.utils import path as _path_utils
from io_scs_tools.utils.printout import lprint
from io_scs_tools.internals.containers.parsers import mat as _mat

Expand Down Expand Up @@ -97,15 +98,15 @@ def get_data_from_file(filepath):

if data_dict:
if len(data_dict) < 1:
lprint('\nI MAT file "%s" is empty!', (str(filepath).replace("\\", "/"),))
lprint('\nI MAT file "%s" is empty!', (_path_utils.readable_norm(filepath),))
return None

container = MatContainer(data_dict, effect)
else:
lprint('\nI MAT file "%s" is empty!', (str(filepath).replace("\\", "/"),))
lprint('\nI MAT file "%s" is empty!', (_path_utils.readable_norm(filepath),))
return None
else:
lprint('\nW Invalid MAT file path %r!', (str(filepath).replace("\\", "/"),))
lprint('\nW Invalid MAT file path %r!', (_path_utils.readable_norm(filepath),))
else:
lprint('\nI No MAT file path provided!')

Expand Down
13 changes: 9 additions & 4 deletions addon/io_scs_tools/internals/containers/pix.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
from mathutils import Vector
from io_scs_tools.internals.containers.parsers import pix as _pix_parser
from io_scs_tools.internals.containers.writers import pix as _pix_writer
from io_scs_tools.utils.printout import lprint
from io_scs_tools.internals.structure import SectionData as _SectionData
from io_scs_tools.utils import path as _path_utils
from io_scs_tools.utils.printout import lprint


def fast_check_for_pia_skeleton(pia_filepath, skeleton):
Expand Down Expand Up @@ -197,7 +198,7 @@ def get_data_from_file(filepath, ind, print_info=False):
# print(' filepath: "%s"\n' % filepath)
container, state = _pix_parser.read_data(filepath, ind, print_info)
if len(container) < 1:
lprint('\nE File "%s" is empty!', (str(filepath).replace("\\", "/"),))
lprint('\nE File "%s" is empty!', (_path_utils.readable_norm(filepath),))
return None

# print_container(container) # TEST PRINTOUTS
Expand All @@ -221,10 +222,14 @@ def write_data_to_file(container, filepath, ind, print_info=False):
:rtype: bool
"""

# convert filepath in readable form so when file writting will be logged
# path will be properly readable even on windows. Without mixed back and forward slashes.
filepath = _path_utils.readable_norm(filepath)

result = _pix_writer.write_data(container, filepath, ind, print_info=print_info)
if result != {'FINISHED'}:
lprint('E Unable to export data into file:\n\t "%s"\nFor details check printouts above.', (str(filepath).replace("\\", "/"),))
lprint("E Unable to export data into file:\n\t %r\n\t For details check printouts above.", (filepath,))
return False
else:
lprint('I File created!')
lprint("I File created!")
return True
7 changes: 4 additions & 3 deletions addon/io_scs_tools/internals/containers/sii.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# Copyright (C) 2013-2014: SCS Software

import os
from io_scs_tools.utils import path as _path_utils
from io_scs_tools.utils.printout import lprint
from io_scs_tools.internals.containers.parsers import sii as _sii

Expand All @@ -32,13 +33,13 @@ def get_data_from_file(filepath):
container = _sii.parse_file(filepath)
if container:
if len(container) < 1:
lprint('D SII file "%s" is empty!', (str(filepath).replace("\\", "/"),))
lprint('D SII file "%s" is empty!', (_path_utils.readable_norm(filepath),))
return None
else:
lprint('D SII file "%s" is empty!', (str(filepath).replace("\\", "/"),))
lprint('D SII file "%s" is empty!', (_path_utils.readable_norm(filepath),))
return None
else:
lprint('W Invalid SII file path %r!', (str(filepath).replace("\\", "/"),))
lprint('W Invalid SII file path %r!', (_path_utils.readable_norm(filepath),))
else:
lprint('I No SII file path provided!')

Expand Down
4 changes: 2 additions & 2 deletions addon/io_scs_tools/internals/containers/tobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,15 @@ def read_data_from_file(cls, filepath, skip_validation=False):
return None

if not (os.path.isfile(filepath) and filepath.lower().endswith(".tobj")):
lprint("W Invalid TOBJ file path %r!", (str(filepath).replace("\\", "/"),))
lprint("W Invalid TOBJ file path %r!", (_path_utils.readable_norm(filepath),))
return None

records = _tobj.parse_file(filepath)
records_len = len(records)
records_iter = iter(records)

if records is None or records_len <= 0:
lprint("I TOBJ file %r is empty!", (os.path.normpath(filepath),))
lprint("I TOBJ file %r is empty!", (_path_utils.readable_norm(filepath),))
return None

container = cls()
Expand Down
3 changes: 2 additions & 1 deletion addon/io_scs_tools/internals/persistent/initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import bpy
import os
from bpy.app.handlers import persistent
from io_scs_tools import get_tools_version
from io_scs_tools.internals import preview_models as _preview_models
from io_scs_tools.internals.callbacks import open_gl as _open_gl_callback
from io_scs_tools.internals.containers import config as _config_container
Expand Down Expand Up @@ -49,7 +50,7 @@ def initialise_scs_dict(scene):

# SCREEN CHECK...
if bpy.context.screen:
lprint("I Initialization of SCS scene")
lprint("I Initialization of SCS scene, BT version: " + get_tools_version())

# NOTE: covers: start-up, reload, enable/disable and it should be immediately removed
# from handlers as soon as it's executed for the first time
Expand Down
6 changes: 4 additions & 2 deletions addon/io_scs_tools/internals/preview_models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,12 @@ def load(locator):
if filepath.lower().endswith(".pim"):
abs_filepath = _path_utils.get_abs_path(filepath, skip_mod_check=True)
if not os.path.isfile(abs_filepath):
lprint("W Locator %r has invalid path to Preview Model PIM file: %r", (locator.name, abs_filepath.replace("\\", "/")))
lprint("W Locator %r has invalid path to Preview Model PIM file: %r",
(locator.name, _path_utils.readable_norm(abs_filepath)))
load_model = False
else:
lprint("W Locator %r has invalid path to Preview Model PIM file: %r", (locator.name, filepath.replace("\\", "/")))
lprint("W Locator %r has invalid path to Preview Model PIM file: %r",
(locator.name, _path_utils.readable_norm(filepath)))
load_model = False
else:
load_model = False
Expand Down
Loading

0 comments on commit 8cc7f92

Please sign in to comment.