From f9628eda0f0264492c0a3389a198734b4c347115 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Tue, 7 May 2024 00:03:22 +0200 Subject: [PATCH] Add basic plugin preference --- Fange Pipeline/__init__.py | 5 +++- Fange Pipeline/ops.py | 4 +-- Fange Pipeline/preference.py | 56 ++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 Fange Pipeline/preference.py diff --git a/Fange Pipeline/__init__.py b/Fange Pipeline/__init__.py index 001d33f..510f509 100644 --- a/Fange Pipeline/__init__.py +++ b/Fange Pipeline/__init__.py @@ -2,6 +2,7 @@ import bpy from .ui import GRAOU_PT_panel from .ops import ExportForFange +from .preference import GRAOU_AddonPreference bl_info = { 'name': 'Fange Pipeline', @@ -19,7 +20,9 @@ modules_class = [ # Main Property ExportForFange, # UI - GRAOU_PT_panel + GRAOU_PT_panel, + # Preference + GRAOU_AddonPreference ] diff --git a/Fange Pipeline/ops.py b/Fange Pipeline/ops.py index 9809763..8ac785a 100644 --- a/Fange Pipeline/ops.py +++ b/Fange Pipeline/ops.py @@ -5,8 +5,8 @@ from pathlib import Path class ExportForFange(bpy.types.Operator): """Export a building for fange""" - bl_idname = "graou.building_export" - bl_label = "Easily export a building asset" + bl_idname = 'graou.building_export' + bl_label = 'Easily export a building asset' def __init__(self): self.coll_layout = bpy.data.collections.get('Placeholder') diff --git a/Fange Pipeline/preference.py b/Fange Pipeline/preference.py new file mode 100644 index 0000000..5a2044d --- /dev/null +++ b/Fange Pipeline/preference.py @@ -0,0 +1,56 @@ +import bpy + +from pathlib import Path + + +def check_game_project(): + """Define the unity game project""" + unity_game_project = Path("W:\\", "Graou Studio", "Game Projects", "Fange Prototype", "Fange Prototype.sln") + if unity_game_project.exists(): + return unity_game_project.parent.as_posix() + + else: + return '' + + +class GRAOU_AddonPreference(bpy.types.AddonPreferences): + """ + Configuration about the Fange pipeline + """ + bl_idname = __package__.split('.')[0] + + project_path: bpy.props.StringProperty( + name='Fange Unity project', + description='Select your Unity game project', + default=check_game_project(), + subtype='FILE_PATH', + ) + + subdir_graph: bpy.props.StringProperty( + name='Subdir about assets folder', + default=r'Assets\Graph', + subtype='DIR_PATH', + ) + + subdir_props: bpy.props.StringProperty( + name='The props subdir', + default='Props', + subtype='DIR_PATH', + ) + + subdir_buildings: bpy.props.StringProperty( + name='The buildings subdir', + default='Buildings', + subtype='DIR_PATH', + ) + + subdir_characters: bpy.props.StringProperty( + name='The characters subdir', + default='Characters', + subtype='DIR_PATH', + ) + + def draw(self, context): + layout = self.layout + layout.label(text='Config all setup about the pipeline.') + layout.prop(self, 'project_path')