# Path: module/properties.py
# class KSPProperty(PropertyGroup):
# class KSPPropertyRef(PropertyGroup):
# class KSPBool(PropertyGroup):
# class KSPFloat(PropertyGroup):
# class KSPInt(PropertyGroup):
# class KSPString(PropertyGroup):
# class KSPVector(PropertyGroup):
# class KSPPointer(PropertyGroup):
# class KSPActiveField:
# class KSPModuleProps(PropertyGroup):
# class KSPModuleSet(PropertyGroup):
# def generate_property(field):
# def update_field(self, context):
#     def __init__(self, module, field, mod_index, fld_index):
#     def __del__(self):
#     def set_field(self, field, module_index, field_index):
#     def initialize(self, module):
#     def draw_item(self, layout, mod_index):


import bpy
from mathutils import Vector
from bpy.types import PropertyGroup
from bpy.utils import register_class, unregister_class
from bpy.props import BoolProperty, BoolVectorProperty
from bpy.props import CollectionProperty
from bpy.props import EnumProperty
from bpy.props import FloatProperty, FloatVectorProperty
from bpy.props import IntProperty, IntVectorProperty
from bpy.props import PointerProperty
from bpy.props import StringProperty
from .module import ksp_module_items, build_modules, available_modules_map
from .properties import module_active_field
# ##### END GPL LICENSE BLOCK #####

# <pep8 compliant>



class KSPMU_OT_ModuleExpand(bpy.types.Operator):
    bl_label = "KSP module expand"
    bl_idname = "object.kspmodule_expand"
    index: IntProperty()
    def execute(self, context):
        module = context.active_object.kspmodules.modules[self.index]
        module.expanded = not module.expanded
        return {'FINISHED'}

class KSPMU_OT_ScanModuleDefs(bpy.types.Operator):
    '''Rescan loaded module definitions: *.mod in blender text blocks'''
    bl_idname = "scene.scan_module_defs"
    bl_label = "RELOAD"

    def execute(self, context):
        build_modules()
        return {'FINISHED'}

class KSPMU_OT_AddModule(bpy.types.Operator):
    """Add a KSP module to the part. Note that where the module is placed
    in the hierarchy is irrelevant: modules will be collected from all objects
    in the exported model and written to the config in the same order in which
    they were found. No checking is done for duplicates: they will be
    written to the config file as-is."""

# Path: module/properties.py
# class KSPProperty(PropertyGroup):
# class KSPPropertyRef(PropertyGroup):
# class KSPBool(PropertyGroup):
# class KSPFloat(PropertyGroup):
# class KSPInt(PropertyGroup):
# class KSPString(PropertyGroup):
# class KSPVector(PropertyGroup):
# class KSPPointer(PropertyGroup):
# class KSPActiveField:
# class KSPModuleProps(PropertyGroup):
# class KSPModuleSet(PropertyGroup):
# def generate_property(field):
# def update_field(self, context):
#     def __init__(self, module, field, mod_index, fld_index):
#     def __del__(self):
#     def set_field(self, field, module_index, field_index):
#     def initialize(self, module):
#     def draw_item(self, layout, mod_index):


# Path: module/operators.py
import bpy
from mathutils import Vector
from bpy.types import PropertyGroup
from bpy.utils import register_class, unregister_class
from bpy.props import BoolProperty, BoolVectorProperty
from bpy.props import CollectionProperty
from bpy.props import EnumProperty
from bpy.props import FloatProperty, FloatVectorProperty
from bpy.props import IntProperty, IntVectorProperty
from bpy.props import PointerProperty
from bpy.props import StringProperty
from .module import ksp_module_items, build_modules, available_modules_map
from .properties import module_active_field

# ##### END GPL LICENSE BLOCK #####

# <pep8 compliant>



class KSPMU_OT_ModuleExpand(bpy.types.Operator):
    bl_label = "KSP module expand"
    bl_idname = "object.kspmodule_expand"
    index: IntProperty()
    def execute(self, context):
        module = context.active_object.kspmodules.modules[self.index]
        module.expanded = not module.expanded
        return {'FINISHED'}

class KSPMU_OT_ScanModuleDefs(bpy.types.Operator):
    '''Rescan loaded module definitions: *.mod in blender text blocks'''
    bl_idname = "scene.scan_module_defs"
    bl_label = "RELOAD"

    def execute(self, context):
        build_modules()
        return {'FINISHED'}

class KSPMU_OT_AddModule(bpy.types.Operator):
    """Add a KSP module to the part. Note that where the module is placed
    in the hierarchy is irrelevant: modules will be collected from all objects
    in the exported model and written to the config in the same order in which
    they were found. No checking is done for duplicates: they will be
    written to the config file as-is."""

    bl_idname = "object.add_ksp_module"