view io_scene_touhou/__init__.py @ 1:ba73c663a227 default tip

Make it work with the latest PyTouhou.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 20 Dec 2013 17:11:29 +0100
parents 8265ef6db380
children
line wrap: on
line source

# ##### BEGIN GPL LICENSE BLOCK #####
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

# <pep8-80 compliant>


bl_info = {
    "name": "Touhou stage format (.std)",
    "author": "Emmanuel Gil Peyrot",
    "version": (0, 0),
    "blender": (2, 66, 0),
    "location": "File > Import-Export > Touhou Stage (.std) ",
    "description": "Import-Export Touhou Stage",
    "warning": "",
    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
                "Scripts/Import-Export/Raw_Mesh_IO",
    "tracker_url": "https://projects.blender.org/tracker/index.php?"
                   "func=detail&aid=25692",
    "category": "Import-Export"}

if "bpy" in locals():
    import imp
    if "import_std" in locals():
        imp.reload(import_std)
else:
    import bpy

from bpy.props import StringProperty


class StageImporter(bpy.types.Operator):
    """Load Touhou triangle mesh data"""
    bl_idname = "import_mesh.std"
    bl_label = "Import Touhou"
    bl_options = {'UNDO'}

    filepath = StringProperty(
            subtype='FILE_PATH',
            )
    filter_glob = StringProperty(default="stage*.std", options={'HIDDEN'})

    def execute(self, context):
        from . import import_std
        import_std.read(self.filepath)
        return {'FINISHED'}

    def invoke(self, context, event):
        wm = context.window_manager
        wm.fileselect_add(self)
        return {'RUNNING_MODAL'}


def menu_import(self, context):
    self.layout.operator(StageImporter.bl_idname, text="Touhou Stage (.std)")


def register():
    bpy.utils.register_module(__name__)
    bpy.types.INFO_MT_file_import.append(menu_import)


def unregister():
    bpy.utils.unregister_module(__name__)
    bpy.types.INFO_MT_file_import.remove(menu_import)

if __name__ == "__main__":
    register()