Skip to content
This repository has been archived by the owner on Oct 10, 2022. It is now read-only.

Commit

Permalink
Merge branch 'main' of gitlab-ncsa.ubisoft.org:animation-studio/blend…
Browse files Browse the repository at this point in the history
…er/stampinfo-addon
  • Loading branch information
jatubi committed Jul 21, 2022
2 parents 31b01fb + 348cab4 commit a7df2eb
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 24 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
-----
## 1.3.5 (2022-06-22)
- Added a preference property to toggle the check for updates

-----
## 1.3.1 (2022-06-02)
- Code refactor to allow more flexibility on the use of rendering resolution for Shot Manager
Expand Down
5 changes: 4 additions & 1 deletion stampinfo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

from .config import config
from .utils import utils
from .utils import utils_operators
from .utils.utils_render import Utils_LaunchRender
from .utils import utils_vse_render
from .properties import stampInfoSettings
Expand All @@ -52,7 +53,7 @@
"author": "Julien Blervaque (aka Werwack) - Ubisoft",
"description": "Stamp scene information on the rendered images",
"blender": (3, 1, 0),
"version": (1, 3, 2),
"version": (1, 3, 6),
"location": "View3D > Stamp Info",
"doc_url": "https://ubisoft-stampinfo.readthedocs.io",
"tracker_url": "https://github.com/ubisoft/stampinfo/issues",
Expand Down Expand Up @@ -179,6 +180,7 @@ def register():
si_ui.register()
ui.register()
utils_vse_render.register()
utils_operators.register()

bpy.types.Scene.UAS_StampInfo_Settings = PointerProperty(type=stampInfoSettings.UAS_StampInfoSettings)

Expand Down Expand Up @@ -212,6 +214,7 @@ def unregister():
from .operators import render_operators
from .addon_prefs import addon_prefs

utils_operators.unregister()
utils_vse_render.unregister()
ui.unregister()
si_ui.unregister()
Expand Down
49 changes: 34 additions & 15 deletions stampinfo/addon_prefs/addon_prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
from stampinfo.utils import utils
from stampinfo.utils.utils_os import get_latest_release_version

# from ..config import config

from stampinfo.config import config
from stampinfo.config import sm_logging

_logger = sm_logging.getLogger(__name__)
Expand Down Expand Up @@ -57,32 +56,52 @@ def version(self):
description="Store the version of the latest release of the add-on as an integer if there is an online release"
"\nthat is more recent than this version. If there is none then the value is 0",
# default=2005001,
default=1007016,
default=1000000,
)

checkForNewAvailableVersion: BoolProperty(
name="Check for Updates",
description=(
"If checked then the add-on automaticaly see if a new release\n"
"is available online, and if so then a red world icon is displayed at the\n"
"top right corner of the main panel"
),
default=True,
)

isInitialized: BoolProperty(
name="Preferences Initialization State",
description=(
"Flag to validate that Stamp Info preferences have been correctly initialized"
"\nThis flag can be changed for debug purpose: activate the debug mode and go to the add-on Preferences, in the Debug tab"
),
default=False,
)

def initialize_stamp_info_prefs(self):
print("\nInitializing Stamp Info Preferences...")

versionStr = get_latest_release_version("https://github.com/ubisoft/stampinfo/releases/latest", verbose=True)

if versionStr is not None:
# version string from the tags used by our releases on GitHub is formated as this: v<int>.<int>.<int>
version = utils.convertVersionStrToInt(versionStr)
self.newAvailableVersion = 0

_logger.debug_ext(
f"Checking for updates: Latest version of Ubisoft Stamp Info online is: {versionStr}", col="BLUE"
if self.checkForNewAvailableVersion and not config.devDebug:
versionStr = get_latest_release_version(
"https://github.com/ubisoft/stampinfo/releases/latest", verbose=True
)
if self.version()[1] < version:
_logger.debug_ext(" New version available online...", col="BLUE")
self.newAvailableVersion = version

if versionStr is not None:
# version string from the tags used by our releases on GitHub is formated as this: v<int>.<int>.<int>
version = utils.convertVersionStrToInt(versionStr)

_logger.debug_ext(
f"Checking for updates: Latest version of Ubisoft Stamp Info online is: {versionStr}", col="BLUE"
)
if self.version()[1] < version:
_logger.debug_ext(" New version available online...", col="BLUE")
self.newAvailableVersion = version
else:
self.newAvailableVersion = 0
else:
self.newAvailableVersion = 0
else:
self.newAvailableVersion = 0

self.isInitialized = True

Expand Down
27 changes: 21 additions & 6 deletions stampinfo/addon_prefs/addon_prefs_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
UI for the Add-on Preferences
"""

from stampinfo import icons
from stampinfo.config import config
from stampinfo.ui.dependencies_ui import drawDependencies

Expand All @@ -30,6 +31,14 @@
def draw_addon_prefs(self, context):
layout = self.layout
# layout = layout.column(align=False)
mainCol = self.layout.column(align=False)

# Dependencies
###############
drawDependencies(context, mainCol)

# General
###############

# Dependencies
###############
Expand All @@ -40,21 +49,21 @@ def draw_addon_prefs(self, context):

splitFactor = 0.3

box = layout.box()
box = mainCol.box()
row = box.row()
row.separator(factor=3)
subCol = row.column()
subCol.prop(self, "display_main_panel", text="Display Stamp Info panel in the 3D View tabs")
subCol.prop(self, "write_still")

drawGeneral(context, self, layout)
drawGeneral(context, self, mainCol)

# Technical settings
###############

layout.separator(factor=0.5)
layout.label(text="Technical Settings:")
box = layout.box()
mainCol.separator(factor=0.5)
mainCol.label(text="Technical Settings:")
box = mainCol.box()
box.label(text="Stamped Images Compositing:")
row = box.row()
row.separator(factor=3)
Expand All @@ -64,7 +73,8 @@ def draw_addon_prefs(self, context):

# Dev and debug
###############
box = layout.box()
box = mainCol.box()
colSepHeight = 0.5

split = box.split(factor=splitFactor)
rowLeft = split.row()
Expand All @@ -88,6 +98,11 @@ def draw_addon_prefs(self, context):
else:
rowRight.operator("uas_stamp_info.enable_debug", text="Turn On").enable_debug = True

box.separator(factor=colSepHeight)
row = box.row()
iconExplorer = icons.icons_col["General_Explorer_32"]
row.operator("uas_si_utils.open_addon_folder", text="Open add-on Folder", icon_value=iconExplorer.icon_id)

if config.devDebug:
# initialization state
initRow = box.row()
Expand Down
2 changes: 1 addition & 1 deletion stampinfo/ui/si_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def draw_header_preset(self, context):
row.separator(factor=2)
row.menu("UAS_MT_StampInfo_prefs_mainmenu", icon="PREFERENCES", text="")

if prefs.newAvailableVersion:
if not config.devDebug and prefs.checkForNewAvailableVersion and prefs.newAvailableVersion:
row.separator(factor=0.5)
subRow = row.row()
subRow.alert = True
Expand Down
16 changes: 15 additions & 1 deletion stampinfo/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
functions that are not particularly related to the add-on and that could be reused as is
"""


import sys
import re
from pathlib import Path
from urllib.parse import unquote_plus, urlparse
Expand Down Expand Up @@ -125,12 +125,26 @@ def addonCategory(addonName):
return categ


# To get the script path folder use this:
# https://blender.stackexchange.com/questions/64129/get-blender-scripts-path
# bpy.utils.script_paths()
# or bpy.utils.script_path_user()


def addonPath():
"Return the install path of this add-on"
# get the path of this file and climb to its parent
filePath = Path(os.path.dirname(os.path.abspath(__file__))).parent
return str(filePath)


def getPythonPackagesFolder():
pyExeFile = sys.executable
# we have to go above \bin dir
localPyDir = str((Path(pyExeFile).parent).parent) + "\\lib\\site-packages\\"
return localPyDir


def file_path_from_uri(uri):
path = unquote_plus(urlparse(uri).path).replace("\\", "//")
if re.match(r"^/\S:.*", path): # Remove leading /
Expand Down
68 changes: 68 additions & 0 deletions stampinfo/utils/utils_operators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# GPLv3 License
#
# Copyright (C) 2021 Ubisoft
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

"""
Utils operators
"""

import json

# from tokenize import String

import bpy
from bpy.types import Operator
from bpy.props import StringProperty

from . import utils


class UAS_SIUtils_OpenAddonFolder(Operator):
bl_idname = "uas_si_utils.open_addon_folder"
bl_label = "Open Add-on Folder"
bl_description = (
"Open the folder in which this add-on is installed," "\nand print the user script folder paths in the Terminal"
)

def execute(self, context):
# https://blender.stackexchange.com/questions/64129/get-blender-scripts-path
# x = bpy.utils.script_path_user()
# bpy.utils.script_paths() returns the list of script folders

addonPath = utils.addonPath()
print(f"\nAdd-on Installation Path:\n - {addonPath}\\")
scriptPaths = bpy.utils.script_paths()
print("Script paths:")
for p in scriptPaths:
print(f" - {p}\\")
print("\n")

bpy.ops.uas_shot_manager.open_explorer("INVOKE_DEFAULT", path=addonPath)

return {"FINISHED"}


_classes = (UAS_SIUtils_OpenAddonFolder,)


def register():
for cls in _classes:
bpy.utils.register_class(cls)


def unregister():
for cls in reversed(_classes):
bpy.utils.unregister_class(cls)

0 comments on commit a7df2eb

Please sign in to comment.