__init__.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. # Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos and contributors.
  2. # All rights reserved.
  3. # Code licensed under the BSD License.
  4. # http://www.anki3d.org/LICENSE
  5. # keep methods in alphabetical order
  6. bl_info = {
  7. "name": "Anki Scene Exporter",
  8. "author": "A. A. Kalugin Jr.",
  9. "version": (0, 1),
  10. "blender": (2, 65, 0),
  11. "location": "Anki Preferences",
  12. "description": "Anki Scene Exporter",
  13. "warning": "",
  14. "wiki_url": "",
  15. "tracker_url": "",
  16. "category": "User"}
  17. # set up the
  18. if "bpy" in locals():
  19. import importlib
  20. importlib.reload(ops.environment)
  21. importlib.reload(ops.export)
  22. importlib.reload(ops.gui)
  23. importlib.reload(ops.material)
  24. importlib.reload(ops.text)
  25. importlib.reload(props.export_props)
  26. importlib.reload(ui.gui)
  27. importlib.reload(ui.panel_prop_dynamic)
  28. else:
  29. from .ops import environment
  30. from .ops import export
  31. from .ops import gui
  32. from .ops import material
  33. from .ops import text
  34. from .props import export_props
  35. from .ui import gui
  36. from .ui import panel_prop_dynamic
  37. import bpy, os
  38. from bpy.types import AddonPreferences
  39. from bpy.props import StringProperty
  40. from .lib import environment as ENV
  41. ################################ CONSTANTS ###############################
  42. ENV.ENVIRO = "ANKI_DATA_PATH"
  43. ################################ CONSTANTS ###############################
  44. class SCENE_anki_scene_exporter(AddonPreferences):
  45. # this must match the addon name, use '__package__'
  46. # when defining this in a submodule of a python package.
  47. bl_idname = __name__
  48. anki_environment = StringProperty(
  49. name="Anki Environment",
  50. default=ENV.ENVIRO,
  51. )
  52. anki_project_path = StringProperty(
  53. name="Project Path",
  54. subtype='FILE_PATH',
  55. )
  56. export_map_path = StringProperty(
  57. name="Map Path",
  58. default="Map Path",
  59. )
  60. export_source_path = StringProperty(
  61. name="Source Path",
  62. default="Source Path:",
  63. )
  64. export_texture_path = StringProperty(
  65. name="Texture Path",
  66. default="Texture Path",
  67. )
  68. im_convert = StringProperty(
  69. name="ImageMagick Convert Path",
  70. default="/usr/bin/convert",
  71. subtype='FILE_PATH',
  72. )
  73. tool_etcpack_path = StringProperty(
  74. name="Third Party etc pack",
  75. default="",
  76. subtype='FILE_PATH',
  77. )
  78. tools_path = StringProperty(
  79. name="Tools Path",
  80. default="Tools Path",
  81. )
  82. temp_dea = StringProperty(
  83. name="Temp Dea Path",
  84. )
  85. tool_py_texture = StringProperty(
  86. name="Texture Tool",
  87. )
  88. # Try to get/set the environment variables
  89. path_list = os.getenv(ENV.ENVIRO)
  90. environment_root = None
  91. if path_list:
  92. # Environment variable exists get the common path.
  93. environment_root = ENV.get_common_environment_path()
  94. anki_project_path[1]['default'] = environment_root
  95. env_dct, export_dct, tools_dct = ENV.get_environment()
  96. ENV.set_environment(env_dct, tools_dct)
  97. # check converter if does not exit remove default path
  98. if not os.path.exists(im_convert[1]['default']):
  99. im_convert[1]['default'] = ""
  100. #check etcpack tool and fill the path
  101. tool_etcpack = tools_dct['tool_etcpack_path']
  102. if os.path.exists(tool_etcpack):
  103. tool_etcpack_path[1]['default'] = tool_etcpack
  104. # Set the gui
  105. tools_path[1]['default'] = tools_dct['tools_path']
  106. export_source_path[1]['default'] = export_dct['export_src_data']
  107. export_map_path[1]['default'] = export_dct['export_map_path']
  108. temp_dea[1]['default'] = export_dct['export_temp_dea']
  109. export_texture_path[1]['default'] = export_dct['export_texture_path']
  110. tool_py_texture[1]['default'] = "{0}/convert_image.py".format(tools_dct['tools_texture_path'])
  111. def draw(self, context):
  112. layout = self.layout
  113. msg = "Preferences are driven by {} environment variable".format(ENV.ENVIRO)
  114. layout.label(text=msg)
  115. layout.prop(self, "anki_project_path")
  116. layout.prop(self, "im_convert")
  117. layout.prop(self, "tool_etcpack_path")
  118. split = layout.split()
  119. col = split.column()
  120. col.label(text='Source Path:')
  121. col.label(text='Map Path:')
  122. col.label(text='Texture Path:')
  123. col.label(text='Tools Path:')
  124. col = split.column()
  125. col.label(text=self.export_source_path)
  126. col.label(text=self.export_map_path)
  127. col.label(text=self.export_texture_path)
  128. col.label(text=self.tools_path)
  129. layout.operator("scene.anki_preference_set", text="Set Preferences")
  130. from .props import material
  131. def register():
  132. bpy.utils.register_module(__name__)
  133. bpy.types.Material.ANKI = bpy.props.PointerProperty(type=material.ANKI_Properties)
  134. def unregister():
  135. bpy.utils.unregister_module(__name__)
  136. del bpy.types.Material.ANKI
  137. if __name__ == "__main__":
  138. register()