2025-12-01

This commit is contained in:
2026-03-17 14:58:51 -06:00
parent 183e865f8b
commit 4b82b57113
6846 changed files with 954887 additions and 162606 deletions
@@ -17,16 +17,18 @@
# ##### END GPL LICENSE BLOCK #####
from enum import IntEnum
from typing import Tuple
from typing import Tuple, Optional
from bpy.types import Operator
import bpy.utils.previews
from ..modules.poliigon_core.api_remote_control_params import (
CATEGORY_FREE,
CATEGORY_ALL,
KEY_TAB_IMPORTED,
KEY_TAB_MY_ASSETS,
KEY_TAB_ONLINE)
KEY_TAB_RECENT_DOWNLOADS,
KEY_TAB_ONLINE,
KEY_TAB_LOCAL)
from ..modules.poliigon_core.multilingual import _t
from ..asset_browser.asset_browser import create_poliigon_library
from ..dialogs.utils_dlg import get_ui_scale
@@ -35,7 +37,6 @@ from ..toolbox import get_context
from ..toolbox_settings import save_settings
from ..utils import f_MDir
from .. import reporting
from .operator_detail_view import check_and_report_detail_view_not_opening
class ModeUpdate(IntEnum):
@@ -80,19 +81,20 @@ class POLIIGON_OT_setting(Operator):
primary=True,
update_local_assets=True)
if bpy.app.version >= (3, 0):
if bpy.app.version >= (3, 0) and cTB.user_legacy_own_assets():
create_poliigon_library(force=True)
cTB.signal_popup(popup="ONBOARD_WELCOME")
bpy.ops.poliigon.popup_welcome("INVOKE_DEFAULT")
# do_update: update and switch to page 1
return ModeUpdate.IMPORTED_AND_GET_ASSETS_AND_PAGE_1
def _set_area(self) -> int:
def _set_area(self, area: Optional[str] = None) -> int:
with cTB.lock_thumbs:
cTB.thumbs.clear()
area = self.mode.replace("area_", "")
if area is None:
area = self.mode.replace("asset_filter_", "").replace("area_", "")
cTB.settings["area"] = area
# This caused a delay when switching between Poliigon/My Assets
@@ -103,9 +105,19 @@ class POLIIGON_OT_setting(Operator):
cTB.vActiveAsset = None
cTB.track_screen_from_area()
check_and_report_detail_view_not_opening()
# do_update: update, but skip switching to page 1 and getting assets
return ModeUpdate.IMPORTED_ONLY
update = ModeUpdate.IMPORTED_ONLY
# If local assets, always run get_assets in api_rc (no api call involved)
if area == KEY_TAB_LOCAL:
update = ModeUpdate.IMPORTED_AND_GET_ASSETS
# When changing filters we are always resetting to page 1
if "asset_filter" in self.mode:
update = ModeUpdate.IMPORTED_AND_GET_ASSETS_AND_PAGE_1
return update
@staticmethod
def _show_my_account() -> None:
@@ -113,7 +125,6 @@ class POLIIGON_OT_setting(Operator):
cTB.settings["show_user"] = 1
cTB.vActiveAsset = None
cTB.refresh_ui()
check_and_report_detail_view_not_opening()
@staticmethod
def _show_settings() -> None:
@@ -130,41 +141,37 @@ class POLIIGON_OT_setting(Operator):
mode_parts = self.mode.split("_")
idx_category = int(mode_parts[1])
button = mode_parts[2]
if idx_category < len(cTB.settings["category"][area]):
cTB.settings["category"][area][idx_category] = button
if idx_category < len(cTB.settings["category"]):
cTB.settings["category"][idx_category] = button
else:
cTB.settings["category"][area].append(button)
cTB.settings["category"][area] = cTB.settings[
"category"][area][: idx_category + 1]
cTB.settings["category"].append(button)
cTB.settings["category"] = cTB.settings[
"category"][: idx_category + 1]
categories = cTB.settings["category"][area]
categories = cTB.settings["category"]
if len(categories) > 1 and categories[-1].startswith("All "):
categories = categories[:-1]
cTB.settings["category"][area] = categories
cTB.settings["category"] = categories
if categories != [CATEGORY_ALL]:
cTB.signal_category_filter(" > ".join(categories))
cTB.vActiveAsset = None
cTB.vActiveMat = None
cTB.vActiveMode = None
# Do we want to clear searches when switching between areas?
cTB.vSearch[KEY_TAB_ONLINE] = props.search_poliigon
cTB.vSearch[KEY_TAB_MY_ASSETS] = props.search_my_assets
cTB.vSearch[KEY_TAB_IMPORTED] = props.search_imported
cTB.vSearch[KEY_TAB_ONLINE] = props.search
cTB.vSearch[KEY_TAB_MY_ASSETS] = props.search
cTB.vSearch[KEY_TAB_RECENT_DOWNLOADS] = props.search
cTB.vSearch[KEY_TAB_IMPORTED] = props.search
cTB.vSearch[KEY_TAB_LOCAL] = props.search
cTB.search_free = False
check_and_report_detail_view_not_opening()
self._clear_search_tab(tab=area)
self._set_area(KEY_TAB_ONLINE)
# do_update: update and switch to page 1
return ModeUpdate.IMPORTED_AND_GET_ASSETS_AND_PAGE_1
def _set_free_search(self) -> int:
cTB.search_free = True
cTB.settings["category"][KEY_TAB_ONLINE] = [CATEGORY_FREE]
cTB.vActiveAsset = None
cTB.vActiveMat = None
cTB.vActiveMode = None
return ModeUpdate.IMPORTED_AND_GET_ASSETS_AND_PAGE_1
def _set_page(self) -> int:
with cTB.lock_thumbs:
cTB.thumbs.clear()
@@ -183,8 +190,6 @@ class POLIIGON_OT_setting(Operator):
else:
cTB.vPage[area] = int(idx_page)
check_and_report_detail_view_not_opening()
# do_update: update, but skip switching to page 1 and getting assets
return ModeUpdate.IMPORTED_ONLY
@@ -198,40 +203,26 @@ class POLIIGON_OT_setting(Operator):
# do_update: update and switch to page 1
return ModeUpdate.IMPORTED_AND_GET_ASSETS_AND_PAGE_1, True
def _clear_search_tab(self, tab: str) -> None:
props = bpy.context.window_manager.poliigon_props
props.search = ""
cTB.vLastSearch[tab] = ""
cTB.vSearch[tab] = ""
def _clear_search(self) -> None:
props = bpy.context.window_manager.poliigon_props
if self.mode.endswith(KEY_TAB_ONLINE):
props.search_poliigon = ""
self._clear_search_tab(tab=KEY_TAB_ONLINE)
elif self.mode.endswith(KEY_TAB_MY_ASSETS):
props.search_my_assets = ""
self._clear_search_tab(tab=KEY_TAB_MY_ASSETS)
elif self.mode.endswith(KEY_TAB_IMPORTED):
props.search_imported = ""
self._clear_search_tab(tab=KEY_TAB_IMPORTED)
elif self.mode.endswith(KEY_TAB_RECENT_DOWNLOADS):
self._clear_search_tab(tab=KEY_TAB_RECENT_DOWNLOADS)
elif self.mode.endswith(KEY_TAB_LOCAL):
self._clear_search_tab(tab=KEY_TAB_LOCAL)
cTB.flush_thumb_prefetch_queue()
check_and_report_detail_view_not_opening()
@staticmethod
def _clear_email() -> None:
props = bpy.context.window_manager.poliigon_props
props.vEmail = ""
@staticmethod
def _clear_password() -> None:
props = bpy.context.window_manager.poliigon_props
props.vPassHide = ""
props.vPassShow = ""
@staticmethod
def _show_password() -> None:
# Can be removed if we're not going use the "show password" button
props = bpy.context.window_manager.poliigon_props
# TODO(Andreas): strange toggle logic?
if cTB.settings["show_pass"]:
props.vPassHide = (props.vPassShow)
else:
props.vPassShow = (props.vPassHide)
cTB.settings["show_pass"] = not cTB.settings["show_pass"]
def _set_thumb_size(self) -> None:
size = self.mode.split("@")[1]
if cTB.settings["thumbsize"] == size:
@@ -252,8 +243,7 @@ class POLIIGON_OT_setting(Operator):
library_dirs=cTB.get_library_paths())
cTB.refresh_ui()
elif self.mode == "hdri_use_jpg_bg":
# do_update: update, but skip switching to page 1
do_update = ModeUpdate.IMPORTED_AND_GET_ASSETS
do_update = ModeUpdate.IMPORTED_ONLY
return do_update
def _set_default(self) -> int:
@@ -312,12 +302,12 @@ class POLIIGON_OT_setting(Operator):
area = KEY_TAB_ONLINE
cTB.settings["area"] = area
cat_area = cTB.settings["category"][prev_area]
cTB.settings["category"][area] = cat_area
cat_area = cTB.settings["category"]
cTB.settings["category"] = cat_area
cTB.settings["show_settings"] = 0
cTB.settings["show_user"] = 0
cTB.vSearch[KEY_TAB_ONLINE] = cTB.vSearch[prev_area]
props.search_poliigon = cTB.vSearch[prev_area]
props.search = cTB.vSearch[prev_area]
cTB.vActiveAsset = None
# do_update: update, but skip switching to page 1
return ModeUpdate.IMPORTED_AND_GET_ASSETS
@@ -354,8 +344,13 @@ class POLIIGON_OT_setting(Operator):
cTB.f_GetSceneAssets()
if do_update < ModeUpdate.IMPORTED_ONLY:
if area in [KEY_TAB_ONLINE, KEY_TAB_MY_ASSETS, KEY_TAB_IMPORTED]:
cTB.f_GetAssets(area=area)
if area in [KEY_TAB_ONLINE,
KEY_TAB_MY_ASSETS,
KEY_TAB_RECENT_DOWNLOADS,
KEY_TAB_IMPORTED,
KEY_TAB_LOCAL]:
cTB.f_GetAssets(area=area,
force_request=area == KEY_TAB_LOCAL)
cTB.refresh_ui()
@@ -387,12 +382,6 @@ class POLIIGON_OT_setting(Operator):
do_update, clear_cache = self._set_page_size()
elif self.mode.startswith("clear_search_"):
self._clear_search()
elif self.mode == "clear_email":
self._clear_email()
elif self.mode == "clear_pass":
self._clear_password()
elif self.mode == "show_pass":
self._show_password()
elif self.mode.startswith("thumbsize@"):
self._set_thumb_size()
elif self.mode in [
@@ -433,8 +422,8 @@ class POLIIGON_OT_setting(Operator):
self._toggle_material_property()
elif self.mode == "view_more":
do_update = self._view_more()
elif self.mode == "search_free":
do_update = self._set_free_search()
elif self.mode.startswith("asset_filter_"):
do_update = self._set_area()
else:
reporting.capture_message("invalid_setting_mode", self.mode)
self.report(