Skip to content

Commit

Permalink
improved update checks and updated dublf
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico-Duduf committed Oct 10, 2022
1 parent 262b4fa commit d551a67
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 21 deletions.
1 change: 0 additions & 1 deletion dublast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def view_header_func(self, context):
addon_keymaps = []

modules = (
dublf,
preferences,
properties,
panels,
Expand Down
5 changes: 1 addition & 4 deletions dublast/playblast.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ def poll(cls, context):
return context.scene is not None

def execute(self, context):

# Check if an update is available!
bpy.ops.dublf.updatebox('INVOKE_DEFAULT', addonModuleName = __package__, discreet = True)


scene = context.scene
playblast = scene.playblast
render = scene.render
Expand Down
42 changes: 39 additions & 3 deletions dublast/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@
# <pep8 compliant>

import bpy
from bpy.app.handlers import persistent
from dublast import dublf

class DUBLAST_OpenURL(dublf.ops.OpenURL):
bl_idname = "dublast.openurl"

class DUBLAST_UpdateBox(dublf.ops.UpdateBox):
bl_idname = "dublast.updatebox"
bl_label = "Update available"
bl_icon = "INFO"

discreet: bpy.props.BoolProperty(
default=False
)

addonName = __package__
openURLOp = DUBLAST_OpenURL.bl_idname

class DUBLAST_Preferences( bpy.types.AddonPreferences ):
bl_idname = __package__
Expand All @@ -35,10 +52,29 @@ class DUBLAST_Preferences( bpy.types.AddonPreferences ):
def draw(self, context):
layout = self.layout
layout.prop(self, "check_updates")
layout.operator("dublf.updatebox", text="Check for updates now").addonModuleName = __package__
layout.operator("dublast.updatebox", text="Check for updates now")

@persistent
def checkUpdateHandler(arg1, arg2):
bpy.ops.dublast.updatebox('INVOKE_DEFAULT', discreet = True)

classes = (
DUBLAST_OpenURL,
DUBLAST_UpdateBox,
DUBLAST_Preferences,
)

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

# Check for updates after loading a blend file
if not checkUpdateHandler in bpy.app.handlers.load_post:
bpy.app.handlers.load_post.append(checkUpdateHandler)

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

if checkUpdateHandler in bpy.app.handlers.load_post:
bpy.app.handlers.load_post.remove(checkUpdateHandler)
4 changes: 0 additions & 4 deletions tools/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ SET outputPath=%~dp0\build

SET "src_name=dublast"
SET "dublf_path=%repoPath%\..\DuBLF\dublf"
SET "dupyf_path=%repoPath%\..\..\Python\DuPYF\dupyf"

rd /s /q "%outputPath%\%src_name%"
md "%outputPath%\%src_name%"
Expand All @@ -20,8 +19,5 @@ for /f %%a IN ('dir /b "%repoPath%\%src_name%\*.py"') do copy "%repoPath%\%src_n
md "%outputPath%\%src_name%\dublf"
for /f %%a IN ('dir /b "%dublf_path%\*.py"') do copy "%dublf_path%\%%a" "%outputPath%\%src_name%\dublf\%%a"

:: copy dupyf
for /f %%a IN ('dir /b "%dupyf_path%\*.py"') do copy "%dupyf_path%\%%a" "%outputPath%\%src_name%\dublf\%%a"

echo "Done!"
pause
18 changes: 9 additions & 9 deletions tools/dev_install.bat
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
@echo off

:: The path to the addon
SET "addons_path=C:\Users\duduf\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons"
:: The path to Blender
SET "blender_config_path=%appData%\Blender Foundation\Blender\3.3"

:: The repo (current dir)
:: The repo and dependencies
SET repoPath=%~dp0..
SET src_name=dublast
SET "dublf_path=%repoPath%\..\DuBLF\dublf"

:: Need admin to create symlinks
@echo off
Expand All @@ -13,9 +15,10 @@ if not "%1"=="am_admin" (powershell start -verb runas '%0' am_admin & exit /b)
pushd "%CD%"
CD /D "%~dp0"

SET src_name=dublast
SET "dublf_path=%repoPath%\..\DuBLF\dublf"
SET "dupyf_path=%repoPath%\..\..\Python\DuPYF\dupyf"
:: get/create scripts path
md "%blender_config_path%\scripts"
md "%blender_config_path%\scripts\addons"
SET "addons_path=%blender_config_path%\scripts\addons"

:: Remove current version
rd /s /q "%addons_path%\%src_name%"
Expand All @@ -28,8 +31,5 @@ for /f %%a IN ('dir /b "%repoPath%\%src_name%\*.py"') do mklink "%addons_path%\%
md "%addons_path%\%src_name%\dublf"
for /f %%a IN ('dir /b "%dublf_path%\*.py"') do mklink "%addons_path%\%src_name%\dublf\%%a" "%dublf_path%\%%a"

:: link dupyf
for /f %%a IN ('dir /b "%dupyf_path%\*.py"') do mklink "%addons_path%\%src_name%\dublf\%%a" "%dupyf_path%\%%a"

echo "Done!"
pause

0 comments on commit d551a67

Please sign in to comment.