Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,27 @@ def execute(self, context: "bpy.types.Context"):
return {"FINISHED"}


class ExampleAddonPreferences(bpy.types.AddonPreferences, addon_updater_ops.AddonUpdaterPreferences):
class Fast64AddonPreferences(bpy.types.AddonPreferences, addon_updater_ops.AddonUpdaterPreferences):
bl_idname = __package__

allow_changing_unset_material_props: bpy.props.BoolProperty(
name="Allow changing unset material props",
description=(
'Allow changing material properties for which the "set" checkbox is unchecked. '
"By default such properties are disabled in the UI. "
"This affects the prim/env/blend colors, chroma keys, K0-K5 and combiner properties"
),
)

def draw(self, context):
self.layout.prop(self, "allow_changing_unset_material_props")
addon_updater_ops.update_settings_ui(self, context)


def get_addon_preferences() -> Fast64AddonPreferences:
return bpy.context.preferences.addons[__package__].preferences


classes = (
Fast64Settings_Properties,
Fast64RenderSettings_Properties,
Expand Down Expand Up @@ -468,7 +482,7 @@ def register():

# Register addon updater first,
# this way if a broken version fails to register the user can still pick another version.
register_class(ExampleAddonPreferences)
register_class(Fast64AddonPreferences)
addon_updater_ops.register(bl_info)

register_class(Matrix4x4Property)
Expand Down Expand Up @@ -554,4 +568,4 @@ def unregister():
bpy.app.handlers.load_post.remove(after_load)

addon_updater_ops.unregister()
unregister_class(ExampleAddonPreferences)
unregister_class(Fast64AddonPreferences)
21 changes: 14 additions & 7 deletions fast64_internal/f3d/f3d_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,8 @@ def ui_other(settings, dataHolder, layout, useDropdown):
prop_input = blend_color_group.column()
prop_input_name.prop(dataHolder, "set_blend", text="Blend Color")
prop_input.prop(dataHolder, "blend_color", text="")
prop_input.enabled = dataHolder.set_blend
if not get_addon_preferences().allow_changing_unset_material_props:
prop_input.enabled = dataHolder.set_blend


def tmemUsageUI(layout, textureProp):
Expand Down Expand Up @@ -856,7 +857,8 @@ def ui_prim(self, material, layout, setName, setProp, showCheckBox):
prop_input.prop(f3dMat, "prim_color", text="")
prop_input.prop(f3dMat, "prim_lod_frac", text="Prim LOD Fraction")
prop_input.prop(f3dMat, "prim_lod_min", text="Min LOD Ratio")
prop_input.enabled = setProp
if not get_addon_preferences().allow_changing_unset_material_props:
prop_input.enabled = setProp
return inputGroup

def ui_env(self, material, layout, showCheckBox):
Expand All @@ -870,7 +872,8 @@ def ui_env(self, material, layout, showCheckBox):
prop_input_name.label(text="Environment Color")
prop_input.prop(material.f3d_mat, "env_color", text="")
setProp = material.f3d_mat.set_env
prop_input.enabled = setProp
if not get_addon_preferences().allow_changing_unset_material_props:
prop_input.enabled = setProp
return inputGroup

def ui_chroma(self, material, layout, name, setName, setProp, showCheckBox):
Expand All @@ -887,7 +890,8 @@ def ui_chroma(self, material, layout, name, setName, setProp, showCheckBox):
prop_input.prop(f3d_mat, "key_width", text="Width")
if f3d_mat.key_width[0] > 1 or f3d_mat.key_width[1] > 1 or f3d_mat.key_width[2] > 1:
layout.box().label(text="NOTE: Keying is disabled for channels with width > 1.")
prop_input.enabled = setProp
if not get_addon_preferences().allow_changing_unset_material_props:
prop_input.enabled = setProp
return inputGroup

def ui_lights(self, f3d_mat: "F3DMaterialProperty", layout: UILayout, name, showCheckBox):
Expand Down Expand Up @@ -969,7 +973,8 @@ def ui_convert(self, material, layout, showCheckBox):
prop_k5.prop(material, "k5", text="K5")
prop_k5.label(text=str(int(material.k5 * 255)))

prop_input.enabled = material.set_k0_5
if not get_addon_preferences().allow_changing_unset_material_props:
prop_input.enabled = material.set_k0_5
return inputGroup

def ui_lower_render_mode(self, material, layout, useDropdown):
Expand Down Expand Up @@ -1331,7 +1336,8 @@ def drawCCProps(ui: UILayout, combiner: "CombinerProperty", isAlpha: bool, enabl
combinerBox = layout.box()
combinerBox.prop(f3dMat, "set_combiner", text="Color Combiner (Color = (A - B) * C + D)")
combinerCol = combinerBox.row().split(factor=0.45)
combinerCol.enabled = f3dMat.set_combiner
if not get_addon_preferences().allow_changing_unset_material_props:
combinerCol.enabled = f3dMat.set_combiner
drawCCProps(combinerCol, f3dMat.combiner1, False)
drawCCProps(combinerCol, f3dMat.combiner1, True, not f3dMat.use_cel_shading)
if f3dMat.use_cel_shading:
Expand All @@ -1342,7 +1348,8 @@ def drawCCProps(ui: UILayout, combiner: "CombinerProperty", isAlpha: bool, enabl
if is_two_cycle:
combinerBox2 = layout.box()
combinerBox2.label(text="Color Combiner Cycle 2")
combinerBox2.enabled = f3dMat.set_combiner
if not get_addon_preferences().allow_changing_unset_material_props:
combinerBox2.enabled = f3dMat.set_combiner
combinerCol2 = combinerBox2.row().split(factor=0.45)
drawCCProps(combinerCol2, f3dMat.combiner2, False)
drawCCProps(combinerCol2, f3dMat.combiner2, True)
Expand Down
6 changes: 6 additions & 0 deletions fast64_internal/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -2196,3 +2196,9 @@ def __exit__(self, exc_type, exc_value, traceback):
print("\nExecution type:", exc_type)
print("\nExecution value:", exc_value)
print("\nTraceback:", traceback)


def get_addon_preferences():
from .. import get_addon_preferences

return get_addon_preferences()
Loading