# Copyright (c) 2015 Damian Jakub Smoczyk (jakub.smoczyk@gmail.com)
#
# Permission is hereby granted, free of charge,  to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction,  including without limitation the rights
# to use, copy,  modify,  merge,  publish,  distribute, sublicense, and/or sell
# copies  of  the  Software,  and  to  permit  persons  to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in 
# all copies or substantial portions of the Software.
#
# THE  SOFTWARE  IS  PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED,  INCLUDING  BUT  NOT  LIMITED  TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS  FOR  A  PARTICULAR  PURPOSE  AND  NONINFRINGEMENT. IN NO EVENT SHALL
# THE  AUTHORS  OR  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

bl_info = {
	"name": "Raw Binary Arena (*.rba)",
	"author": "Damian Jakub Smoczyk",
	"blender": (2, 74, 0),
	"location": "File > Import-Export",
	"description": "Export scene as RBA file",
	"category": "reVision"
}

# Reload other submodules
import imp
if "export_rba" in locals():
	imp.reload(export_rba)

import os
import bpy
from bpy.props import StringProperty
from bpy_extras.io_utils import ExportHelper

class ExportRBA(bpy.types.Operator, ExportHelper):
	bl_idname = "mesh.rba"
	bl_label = "Export RBA"

	filename_ext = ".rba"
	filter_glob = StringProperty(default="*.rba", options={'HIDDEN'})

	def execute(self, context):
		from . import export_rba
		filepath = self.filepath
		filepath = bpy.path.ensure_ext(filepath, self.filename_ext)
		return export_rba.save(self, context, filepath)

def menu_func_export(self, context):
	self.layout.operator(ExportRBA.bl_idname, text="RBA (*.rba)")

def register():
	bpy.utils.register_module(__name__)

	bpy.types.INFO_MT_file_export.append(menu_func_export)

def unregister():
	bpy.utils.unregister_module(__name__)

	bpy.types.INFO_MT_file_export.remove(menu_func_export)

if __name__ == "__main__":
	register()

