'''
Copyright (C) 2023 CG Cookie
http://cgcookie.com
hello@cgcookie.com
Created by Jonathan Denning, Jonathan Williamson, and Patrick Moore
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 3 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 .
'''
import os
import re
import bpy
from ..updater import updater
from ...addon_common.common.blender import get_path_from_addon_root
from ...addon_common.common.globals import Globals
from ...addon_common.common.utils import delay_exec
from ...addon_common.common.ui_styling import load_defaultstylings
from ...addon_common.common.ui_core import UI_Element
from ...config.options import options, retopoflow_product, retopoflow_urls
from ...config.keymaps import get_keymaps
class RetopoFlow_UpdaterSystem:
@staticmethod
def reload_stylings():
load_defaultstylings()
path = get_path_from_addon_root('config', 'ui.css')
try:
Globals.ui_draw.load_stylesheet(path)
except AssertionError as e:
# TODO: show proper dialog to user here!!
print('could not load stylesheet "%s"' % path)
print(e)
Globals.ui_document.body.dirty(cause='Reloaded stylings', children=True)
Globals.ui_document.body.dirty_styling()
Globals.ui_document.body.dirty_flow()
def substitute_keymaps(self, mdown, wrap='`', pre='', post='', separator=', ', onlyfirst=None):
if type(wrap) is str: wrap_pre, wrap_post = wrap, wrap
else: wrap_pre, wrap_post = wrap
while True:
m = re.search(r'{{(?P[^}]+)}}', mdown)
if not m: break
action = { s.strip() for s in m.group('action').split(',') }
sub = f'{pre}{wrap_pre}' + self.actions.to_human_readable(action, sep=f'{wrap_post}{separator}{wrap_pre}', onlyfirst=onlyfirst) + f'{wrap_post}{post}'
mdown = mdown[:m.start()] + sub + mdown[m.end():]
return mdown
def substitute_options(self, mdown, wrap='', pre='', post='', separator=', ', onlyfirst=None):
if type(wrap) is str: wrap_pre, wrap_post = wrap, wrap
else: wrap_pre, wrap_post = wrap
while True:
m = re.search(r'{\[(?P