Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove references deprecated in MCprep 3.5 #521

Merged
merged 2 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
178 changes: 0 additions & 178 deletions MCprep_addon/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,183 +210,6 @@ def deprecation_warning(self):

env = MCprepEnv()


# ! Deprecated as of MCprep 3.5
def init():
env.deprecation_warning()
# -----------------------------------------------
# Verbose, use as env.verbose
# Used to print out extra information, set false with distribution
# -----------------------------------------------
# ! Deprecated as of MCprep 3.5
global dev
dev = False

# ! Deprecated as of MCprep 3.5
global v
v = True # $VERBOSE, UI setting

# ! Deprecated as of MCprep 3.5
global vv
vv = dev # $VERYVERBOSE

# -----------------------------------------------
# JSON attributes
# -----------------------------------------------

# shouldn't load here, just globalize any json data?

# ! Deprecated as of MCprep 3.5
global data
# import json

# ! Deprecated as of MCprep 3.5
global json_data # mcprep_data.json
json_data = None # later will load addon information etc

# if existing json_data_update exists, overwrite it
# ! Deprecated as of MCprep 3.5
global json_path
json_path = os.path.join(
os.path.dirname(__file__),
"MCprep_resources",
"mcprep_data.json")
global json_path_update
json_path_update = os.path.join(
os.path.dirname(__file__),
"MCprep_resources",
"mcprep_data_update.json")

# Used to avoid checking for update file on disk too frequently.
global last_check_for_updated
last_check_for_updated = 0

# if new update file found from install, replace old one with new
if os.path.isfile(json_path_update):
if os.path.isfile(json_path) is True:
os.remove(json_path)
os.rename(json_path_update, json_path)

# lazy load json, ie only load it when needed (util function defined)

# -----------------------------------------------
# For preview icons
# -----------------------------------------------

# ! Deprecated as of MCprep 3.5
global use_icons
use_icons = True
# ! Deprecated as of MCprep 3.5
global preview_collections
preview_collections = {}

# -----------------------------------------------
# For initializing the custom icons
# -----------------------------------------------
icons_init()

# -----------------------------------------------
# For cross-addon lists
# -----------------------------------------------

# To ensure shift-A starts drawing sub menus after pressing load all spawns
# as without this, if any one of the spawners loads nothing (invalid folder,
# no blend files etc), then it would continue to ask to reload spanwers.
# ! Deprecated as of MCprep 3.5
global loaded_all_spawners
loaded_all_spawners = False

# ! Deprecated as of MCprep 3.5
global skin_list
skin_list = [] # each is: [ basename, path ]

# ! Deprecated as of MCprep 3.5
global rig_categories
rig_categories = [] # simple list of directory names

# ! Deprecated as of MCprep 3.5
global entity_list
entity_list = []

# -----------------------------------------------
# Matieral sync cahce, to avoid repeat lib reads
# -----------------------------------------------

# list of material names, each is a string. None by default to indicate
# that no reading has occurred. If lib not found, will update to [].
# If ever changing the resource pack, should also reset to None.
# ! Deprecated as of MCprep 3.5
global material_sync_cache
material_sync_cache = None


# ! Deprecated as of MCprep 3.5
# -----------------------------------------------------------------------------
# ICONS INIT
# -----------------------------------------------------------------------------

def icons_init():
env.deprecation_warning()
# start with custom icons
# put into a try statement in case older blender version!
global preview_collections
global v

collection_sets = [
"main", "skins", "mobs", "entities", "blocks", "items", "effects", "materials"]

try:
for iconset in collection_sets:
preview_collections[iconset] = bpy.utils.previews.new()

script_path = bpy.path.abspath(os.path.dirname(__file__))
icons_dir = os.path.join(script_path, 'icons')
preview_collections["main"].load(
"crafting_icon",
os.path.join(icons_dir, "crafting_icon.png"),
'IMAGE')
preview_collections["main"].load(
"meshswap_icon",
os.path.join(icons_dir, "meshswap_icon.png"),
'IMAGE')
preview_collections["main"].load(
"spawner_icon",
os.path.join(icons_dir, "spawner_icon.png"),
'IMAGE')
preview_collections["main"].load(
"sword_icon",
os.path.join(icons_dir, "sword_icon.png"),
'IMAGE')
preview_collections["main"].load(
"effects_icon",
os.path.join(icons_dir, "effects_icon.png"),
'IMAGE')
preview_collections["main"].load(
"entity_icon",
os.path.join(icons_dir, "entity_icon.png"),
'IMAGE')
preview_collections["main"].load(
"model_icon",
os.path.join(icons_dir, "model_icon.png"),
'IMAGE')
except Exception as e:
log("Old verison of blender, no custom icons available")
log("\t" + str(e))
global use_icons
use_icons = False
for iconset in collection_sets:
preview_collections[iconset] = ""


# ! Deprecated as of MCprep 3.5
def log(statement, vv_only=False):
env.deprecation_warning()
if env.verbose and vv_only and env.very_verbose:
print(statement)
elif env.verbose:
print(statement)


def updater_select_link_function(self, tag):
"""Indicates what zip file to use for updating from a tag structure.

Expand All @@ -404,7 +227,6 @@ def updater_select_link_function(self, tag):
# GLOBAL REGISTRATOR INIT
# -----------------------------------------------------------------------------


def register():
global env
if not env.json_data:
Expand Down
32 changes: 7 additions & 25 deletions MCprep_addon/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,32 +557,14 @@ def alphanum_key(key):
return sorted(elements, key=alphanum_key)

# -----------------------------------------------------------------------------
# Cross blender 2.7 and 2.8 functions
# Utility functions
#
# These funtions originally were created for the purpose of
# maintaining compatibility with Blender 2.7x and 2.8+. With
# MCprep 3.5 however, these moved from compatibility functions to
# utility functions that make the developer experience better.
# -----------------------------------------------------------------------------


def make_annotations(cls):
"""Add annotation attribute to class fields to avoid Blender 2.8 warnings"""
env.deprecation_warning()
if not hasattr(bpy.app, "version") or bpy.app.version < (2, 80):
return cls
if bpy.app.version < (2, 93, 0):
bl_props = {
k: v for k, v in cls.__dict__.items() if isinstance(v, tuple)}
else:
bl_props = {
k: v for k, v in cls.__dict__.items()
if isinstance(v, bpy.props._PropertyDeferred)}
if bl_props:
if '__annotations__' not in cls.__dict__:
setattr(cls, '__annotations__', {})
annotations = cls.__dict__['__annotations__']
for k, v in bl_props.items():
annotations[k] = v
delattr(cls, k)
return cls


def layout_split(layout: UILayout, factor:float =0.0, align: bool=False) -> UILayout:
""" TODO remove 2.7
Intermediate method for pre and post blender 2.8 split UI function"""
Expand Down Expand Up @@ -782,4 +764,4 @@ def move_assets_to_excluded_layer(context: Context, collections: List[Collection
if grp.name not in initial_view_coll.collection.children:
continue # not linked, likely a sub-group not added to scn
spawner_exclude_vl.collection.children.link(grp)
initial_view_coll.collection.children.unlink(grp)
initial_view_coll.collection.children.unlink(grp)