add auto_updater
This commit is contained in:
parent
5e74787bb0
commit
77fdf7d93a
4 changed files with 3377 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,3 +5,4 @@ venv
|
|||
# vim
|
||||
*.swo
|
||||
*.swp
|
||||
/abc3d_updater/*
|
||||
|
|
51
__init__.py
51
__init__.py
|
@ -26,11 +26,13 @@ if "bpy" in locals():
|
|||
importlib.reload(utils)
|
||||
importlib.reload(butils)
|
||||
importlib.reload(bimport)
|
||||
importlib.reload(addon_updater_ops)
|
||||
else:
|
||||
from .common import Font
|
||||
from .common import utils
|
||||
from . import butils
|
||||
from . import bimport
|
||||
from . import addon_updater_ops
|
||||
|
||||
import bpy
|
||||
import math
|
||||
|
@ -51,6 +53,8 @@ def getPreferences(context):
|
|||
preferences = context.preferences
|
||||
return preferences.addons[__name__].preferences
|
||||
|
||||
|
||||
@addon_updater_ops.make_annotations
|
||||
class ABC3D_addonPreferences(bpy.types.AddonPreferences):
|
||||
"""ABC3D Addon Preferences
|
||||
|
||||
|
@ -58,6 +62,39 @@ class ABC3D_addonPreferences(bpy.types.AddonPreferences):
|
|||
|
||||
bl_idname = __name__
|
||||
|
||||
# Addon updater preferences.
|
||||
auto_check_update = bpy.props.BoolProperty(
|
||||
name="Auto-check for Update",
|
||||
description="If enabled, auto-check for updates using an interval",
|
||||
default=False)
|
||||
|
||||
updater_interval_months = bpy.props.IntProperty(
|
||||
name='Months',
|
||||
description="Number of months between checking for updates",
|
||||
default=0,
|
||||
min=0)
|
||||
|
||||
updater_interval_days = bpy.props.IntProperty(
|
||||
name='Days',
|
||||
description="Number of days between checking for updates",
|
||||
default=7,
|
||||
min=0,
|
||||
max=31)
|
||||
|
||||
updater_interval_hours = bpy.props.IntProperty(
|
||||
name='Hours',
|
||||
description="Number of hours between checking for updates",
|
||||
default=0,
|
||||
min=0,
|
||||
max=23)
|
||||
|
||||
updater_interval_minutes = bpy.props.IntProperty(
|
||||
name='Minutes',
|
||||
description="Number of minutes between checking for updates",
|
||||
default=0,
|
||||
min=0,
|
||||
max=59)
|
||||
|
||||
def get_default_assets_dir():
|
||||
return bpy.utils.user_resource(
|
||||
'DATAFILES',
|
||||
|
@ -92,6 +129,13 @@ class ABC3D_addonPreferences(bpy.types.AddonPreferences):
|
|||
layout.label(text="Directory for storage of fonts and other assets:")
|
||||
layout.prop(self, "assets_dir")
|
||||
|
||||
# Works best if a column, or even just self.layout.
|
||||
mainrow = layout.row()
|
||||
col = mainrow.column()
|
||||
|
||||
# Updater draw function, could also pass in col as third arg.
|
||||
addon_updater_ops.update_settings_ui(self, context)
|
||||
|
||||
|
||||
class ABC3D_available_font(bpy.types.PropertyGroup):
|
||||
font_name: bpy.props.StringProperty(name="")
|
||||
|
@ -1500,7 +1544,10 @@ def on_depsgraph_update(scene, depsgraph):
|
|||
|
||||
|
||||
def register():
|
||||
addon_updater_ops.register(bl_info)
|
||||
|
||||
for cls in classes:
|
||||
addon_updater_ops.make_annotations(cls) # Avoid blender 2.8 warnings.
|
||||
bpy.utils.register_class(cls)
|
||||
bpy.types.Scene.abc3d_data = bpy.props.PointerProperty(type=ABC3D_data)
|
||||
# bpy.types.Object.__del__ = lambda self: print(f"Bye {self.name}")
|
||||
|
@ -1528,7 +1575,9 @@ def register():
|
|||
Font.name_to_glyph_d = Font.generate_name_to_glyph_d()
|
||||
|
||||
def unregister():
|
||||
for cls in classes:
|
||||
addon_updater_ops.unregister()
|
||||
|
||||
for cls in reversed(classes):
|
||||
bpy.utils.unregister_class(cls)
|
||||
|
||||
# remove autostart when loading blend file
|
||||
|
|
1787
addon_updater.py
Normal file
1787
addon_updater.py
Normal file
File diff suppressed because it is too large
Load diff
1539
addon_updater_ops.py
Normal file
1539
addon_updater_ops.py
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue