Skip to content

Commit

Permalink
Some Fixes, New Dev Tool (Remove Attribute))
Browse files Browse the repository at this point in the history
  • Loading branch information
Aspirata committed Jul 11, 2024
1 parent e9509bf commit ec689a8
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 37 deletions.
3 changes: 1 addition & 2 deletions Mcblend Source/Assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def append_asset(asset_name, asset_category):
run_python_script(asset_path)

except:
Absolute_Solver(err=traceback.print_exc(), data=asset_name, error_name="Bad Asset Import", description="Can't Import {Data} Asset")
Absolute_Solver(tech_things=traceback.print_exc(), data=asset_name, error_name="Bad Asset Import", description="Can't Import {Data} Asset")

def update_assets():
items = bpy.context.scene.assetsproperties.asset_items
Expand All @@ -48,7 +48,6 @@ def update_assets():
item = items.add()
item.name = key


def run_python_script(file_path):

def import_all_from_module(module_name, module_path=None):
Expand Down
31 changes: 31 additions & 0 deletions Mcblend Source/Operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,37 @@ def draw(self, context):
row = box.row()
row.prop(self, "create_clouds", text='create_clouds', expand=True)

class RemoveAttributeOperator(Operator):
bl_idname = "special.remove_attribute"
bl_label = "Remove Attribute"
bl_options = {'REGISTER', 'UNDO'}

attribute: bpy.props.StringProperty()

def execute(self, context):
attr_name = self.attribute

if attr_name in bpy.context.scene:
del bpy.context.scene[attr_name]
self.report({'INFO'}, f"Attribute '{attr_name}' has been removed.")
else:
try:
parts = attr_name.split(".")
current = bpy.context.scene

for part in parts[:-1]:
current = getattr(current, part)

attr = getattr(current, parts[-1])
attr.clear()
return {'FINISHED'}
except AttributeError as e:
self.report({'WARNING'}, f"Failed to remove attribute '{attr_name}': {str(e)}")
except TypeError as e:
self.report({'WARNING'}, f"Failed to remove attribute '{attr_name}': {str(e)}")
self.report({'WARNING'}, f"Attribute '{attr_name}' does not exist.")
return {'FINISHED'}

class FixWorldOperator(Operator):
bl_idname = "world.fix_world"
bl_label = "Fix World"
Expand Down
63 changes: 37 additions & 26 deletions Mcblend Source/UI.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ def draw(self, context):
row.enabled = scene.resource_properties.animate_textures
row.prop(scene.resource_properties, "only_fix_uv")

if Preferences.dev_tools:
row = box.row()
remove_attr = row.operator("special.remove_attribute", text="Remove Resource Packs List")
remove_attr.attribute = "resource_packs"

row = box.row()
row.operator("resource_pack.apply", icon='CHECKMARK')

Expand Down Expand Up @@ -504,39 +509,40 @@ def draw(self, context):
row.prop(scene.ppbr_properties, "revert_normals", slider=True)
row.enabled = not context.scene.ppbr_properties.use_normals

row = box.row()
row.prop(scene.ppbr_properties, "pspecular")
row.prop(scene.ppbr_properties, "pspecular_settings", icon=("TRIA_DOWN" if scene.ppbr_properties.pspecular_settings else "TRIA_LEFT"), icon_only=True)
if scene.ppbr_properties.pspecular_settings:
sbox = box.box()
row = sbox.row()
row.label(text="Procedural Specular Settings:", icon="MODIFIER")
if Preferences.dev_tools:
row = box.row()
row.prop(scene.ppbr_properties, "pspecular")
row.prop(scene.ppbr_properties, "pspecular_settings", icon=("TRIA_DOWN" if scene.ppbr_properties.pspecular_settings else "TRIA_LEFT"), icon_only=True)
if scene.ppbr_properties.pspecular_settings:
sbox = box.box()
row = sbox.row()
row.label(text="Procedural Specular Settings:", icon="MODIFIER")

row = sbox.row()
row.prop(scene.ppbr_properties, "ps_interpolation")
row = sbox.row()
row.prop(scene.ppbr_properties, "ps_interpolation")

row = sbox.row()
row.prop(scene.ppbr_properties, "ps_dif")
row = sbox.row()
row.prop(scene.ppbr_properties, "ps_dif")

row = sbox.row()
row.prop(scene.ppbr_properties, "ps_revert")
row = sbox.row()
row.prop(scene.ppbr_properties, "ps_revert")

row = box.row()
row.prop(scene.ppbr_properties, "proughness")
row.prop(scene.ppbr_properties, "proughness_settings", icon=("TRIA_DOWN" if scene.ppbr_properties.proughness_settings else "TRIA_LEFT"), icon_only=True)
if scene.ppbr_properties.proughness_settings:
sbox = box.box()
row = sbox.row()
row.label(text="Procedural Roughness Settings:", icon="MODIFIER")
row = box.row()
row.prop(scene.ppbr_properties, "proughness")
row.prop(scene.ppbr_properties, "proughness_settings", icon=("TRIA_DOWN" if scene.ppbr_properties.proughness_settings else "TRIA_LEFT"), icon_only=True)
if scene.ppbr_properties.proughness_settings:
sbox = box.box()
row = sbox.row()
row.label(text="Procedural Roughness Settings:", icon="MODIFIER")

row = sbox.row()
row.prop(scene.ppbr_properties, "pr_interpolation")
row = sbox.row()
row.prop(scene.ppbr_properties, "pr_interpolation")

row = sbox.row()
row.prop(scene.ppbr_properties, "pr_dif")
row = sbox.row()
row.prop(scene.ppbr_properties, "pr_dif")

row = sbox.row()
row.prop(scene.ppbr_properties, "pr_revert")
row = sbox.row()
row.prop(scene.ppbr_properties, "pr_revert")

row = box.row()
row.prop(scene.ppbr_properties, "advanced_settings", toggle=True, text="Advanced Settings", icon=("TRIA_DOWN" if scene.ppbr_properties.advanced_settings else "TRIA_RIGHT"))
Expand Down Expand Up @@ -803,6 +809,11 @@ def importcategoryfix():
row = box.row()
row.operator("assets.update_assets")

if Preferences.dev_tools:
row = box.row()
remove_attr = row.operator("special.remove_attribute", text="Remove Assets List")
remove_attr.attribute = "assetsproperties.asset_items"

row = box.row()
row.scale_y = Big_Button_Scale
row.operator("assets.import_asset", text=importcategoryfix())
Expand Down
4 changes: 2 additions & 2 deletions Mcblend Source/Utils/Absolute_Solver.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ..Data import *
import bpy, re
import bpy, re, traceback

Absolute_Solver_Errors = {

Expand All @@ -15,7 +15,7 @@

"000": {
"Error Name": "Absolute Solver Error",
"Description": "Absolute Solver Can't Display This Error - {Data}, Please Report To Aspirata",
"Description": "Absolute Solver Can't Display This Error - {Data}",
},

"001": {
Expand Down
14 changes: 7 additions & 7 deletions Mcblend Source/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ def InitOnStart():
def load_post_handler(dummy):
InitOnStart()

classes = [McblendPreferences, AbsoluteSolver, RecreateEnvironment,
WorldProperties, MaterialsProperties, ResourcePackProperties, CreateEnvProperties, PPBRProperties,
WorldAndMaterialsPanel, CreateEnvOperator, FixWorldOperator, OpenConsoleOperator, SetProceduralPBROperator, FixMaterialsOperator, UpgradeMaterialsOperator, SwapTexturesOperator,
ResourcePackToggleOperator, MoveResourcePackUp, MoveResourcePackDown, RemoveResourcePack, UpdateDefaultPack, FixPacks, AddResourcePack, ApplyResourcePack,
OptimizationProperties, OptimizationPanel, OptimizeOperator,
UtilsProperties, UtilsPanel, SetRenderSettingsOperator, EnchantOperator, AssingVertexGroupOperator,
AssetsProperties, AssetPanel, Assets_List_UL_, ImportAssetOperator, ManualAssetsUpdateOperator
classes = [McblendPreferences, AbsoluteSolver, RecreateEnvironment, # Special Paneles
WorldProperties, MaterialsProperties, ResourcePackProperties, CreateEnvProperties, PPBRProperties, OptimizationProperties, UtilsProperties, AssetsProperties, # Properties
WorldAndMaterialsPanel, OptimizationPanel, UtilsPanel, AssetPanel, Assets_List_UL_, # Panels
RemoveAttributeOperator, OpenConsoleOperator, FixWorldOperator, SwapTexturesOperator, ResourcePackToggleOperator, MoveResourcePackUp, MoveResourcePackDown, # Operators
RemoveResourcePack, UpdateDefaultPack, FixPacks, AddResourcePack, ApplyResourcePack, CreateEnvOperator, FixMaterialsOperator, UpgradeMaterialsOperator,
SetProceduralPBROperator, OptimizeOperator, SetRenderSettingsOperator, EnchantOperator, AssingVertexGroupOperator, ImportAssetOperator,
ManualAssetsUpdateOperator,
]

def register():
Expand Down

0 comments on commit ec689a8

Please sign in to comment.