2025-12-01
This commit is contained in:
@@ -37,12 +37,27 @@ from . import reporting
|
||||
THUMB_SIZES = ["Tiny", "Small", "Medium", "Large", "Huge"]
|
||||
|
||||
|
||||
def update_optin_from_settings():
|
||||
if cTB is None:
|
||||
return
|
||||
settings_optin = cTB.settings_config.getboolean("logging",
|
||||
"reporting_opt_in",
|
||||
fallback=None)
|
||||
prefs = bpy.context.preferences.addons.get(__spec__.parent, None)
|
||||
prefs.preferences.reporting_opt_in = settings_optin
|
||||
|
||||
|
||||
def optin_update(self, context) -> None:
|
||||
"""Update the optin settings."""
|
||||
|
||||
# __spec__.parent since __package__ got deprecated
|
||||
prefs = bpy.context.preferences.addons.get(__spec__.parent, None)
|
||||
reporting.set_optin(prefs.preferences.reporting_opt_in)
|
||||
if cTB is None:
|
||||
return
|
||||
str_pref = "true" if prefs.preferences.reporting_opt_in else "false"
|
||||
cTB.settings_config.set("logging", "reporting_opt_in", str_pref)
|
||||
cTB._settings.save_settings()
|
||||
|
||||
|
||||
def verbose_update(self, context) -> None:
|
||||
@@ -303,6 +318,9 @@ class PoliigonPreferences(bpy.types.AddonPreferences):
|
||||
def _draw_asset_browser_prefs(self, context) -> None:
|
||||
"""Draws preferencees related to Blender's Asset Browser."""
|
||||
|
||||
if not cTB.user_legacy_own_assets():
|
||||
return
|
||||
|
||||
if bpy.app.version < (3, 0):
|
||||
return # Not available before blender 3.0.
|
||||
|
||||
@@ -653,34 +671,10 @@ class PoliigonPreferences(bpy.types.AddonPreferences):
|
||||
|
||||
def _draw_download_prefs_brush_resolutions(
|
||||
self, col_download, prefs_width) -> None:
|
||||
if self.any_owned_brushes == "No Brushes":
|
||||
return
|
||||
|
||||
col = col_download.box().column()
|
||||
|
||||
col.separator()
|
||||
|
||||
col.label(text=_t("Default Brush Resolution :"))
|
||||
grid = col.grid_flow(
|
||||
row_major=1,
|
||||
columns=int((prefs_width - 20) / 40),
|
||||
even_columns=1,
|
||||
even_rows=1,
|
||||
align=0,
|
||||
)
|
||||
for size in ["1K", "2K", "3K", "4K"]:
|
||||
op = grid.operator(
|
||||
"poliigon.poliigon_setting",
|
||||
text=size,
|
||||
depress=(size in cTB.settings["brush"]),
|
||||
)
|
||||
op.mode = f"default_brush_{size}"
|
||||
op.tooltip = _t("The default Resolution to use for Brushes")
|
||||
|
||||
col.separator()
|
||||
return # TODO(Patrick): Remove other references to self.any_owned_brushes
|
||||
|
||||
def _draw_download_prefs_purchase(self, col_download) -> None:
|
||||
if cTB.is_unlimited_user():
|
||||
if cTB.is_unlimited_user() or cTB.is_free_user():
|
||||
return
|
||||
|
||||
col = col_download.box().column()
|
||||
@@ -691,19 +685,20 @@ class PoliigonPreferences(bpy.types.AddonPreferences):
|
||||
|
||||
col.label(text=_t("Purchase Preferences :"))
|
||||
|
||||
row = col.row(align=1)
|
||||
row.separator()
|
||||
op = row.operator(
|
||||
"poliigon.poliigon_setting",
|
||||
text="",
|
||||
depress=auto_download,
|
||||
emboss=False,
|
||||
icon="CHECKBOX_HLT" if auto_download else "CHECKBOX_DEHLT",
|
||||
)
|
||||
op.mode = "auto_download"
|
||||
op.tooltip = _t("Auto-Download Assets on Purchase")
|
||||
row.label(text=_t(" Auto-Download Assets on Purchase"))
|
||||
row.separator()
|
||||
if cTB.is_legacy_limited_user():
|
||||
row = col.row(align=1)
|
||||
row.separator()
|
||||
op = row.operator(
|
||||
"poliigon.poliigon_setting",
|
||||
text="",
|
||||
depress=auto_download,
|
||||
emboss=False,
|
||||
icon="CHECKBOX_HLT" if auto_download else "CHECKBOX_DEHLT",
|
||||
)
|
||||
op.mode = "auto_download"
|
||||
op.tooltip = _t("Auto-Download Assets on Purchase")
|
||||
row.label(text=_t(" Auto-Download Assets on Purchase"))
|
||||
row.separator()
|
||||
|
||||
# Note: Blender launched first with a toggle "One Click Purchase",
|
||||
# but product-wise later decided a better name to use was inverted
|
||||
@@ -911,6 +906,8 @@ def register(addon_version: str) -> None:
|
||||
cTB = get_context(addon_version)
|
||||
|
||||
bpy.utils.register_class(PoliigonPreferences)
|
||||
|
||||
update_optin_from_settings()
|
||||
optin_update(None, bpy.context)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user