Skip to content

Commit

Permalink
Cleaned code for blender and mixer version comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
jatubi committed Mar 9, 2021
1 parent d0ed09b commit 4f436cf
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 34 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
## Features

- Grease pencil: synchronize effects
- UI: Simplification of Mixer user interface
- UI: Property panel for the selected room
- UI: Advanced and developper properties now visible only in the add-on preferences
- UI: Toggle between Mixer and VRtist panels

## Fixes

- Object modifier synchronization failure on Blender 2.92
- VSE synchronization error on 2.92
- Invalid values for user color

## CI

Expand Down
2 changes: 1 addition & 1 deletion extra/inject_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def main():
if line.startswith("__version__ = "):
new_init_file_str += f'__version__ = "v{version_string}"{comment}\n'
elif line.startswith("display_version = "):
new_init_file_str += f'display_version = "v{version_string}{suffix}"{comment}\n'
new_init_file_str += f'display_version = "{version_string}{suffix}"{comment}\n'
elif line.startswith("version_date = "):
date = datetime.now(timezone.utc).strftime("%Y-%m-%d:%H:%M:%S %Z")
new_init_file_str += f'version_date = "{date}"{comment}\n'
Expand Down
16 changes: 9 additions & 7 deletions mixer/bl_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,20 +502,22 @@ class ToggleBetweenMixerAndVRtistPanels(bpy.types.Operator):
bl_description = "Toggle Between Mixer and VRtist Panels"
bl_options = {"INTERNAL"}

mixer_desciption = """Toggle from VRtist to Mixer panel.
Mixer offers a collaborative real-time environment for Blender users.
\nSee the documentation for more information"""
vrtist_desciption = """Toggle from Mixer to VRtist panel.
This panel will allow you to set up a live link between Blender and VRtist,
a VR application developed by Ubisoft Animation Studio for immersive animation direction.
\nSee the documentation for more information"""
panel_mode: bpy.props.StringProperty(default="MIXER")

@classmethod
def description(cls, context, properties):
descr = "Toggle between Mixer and VRtist panels.\n"
if "MIXER" == properties.panel_mode:
descr = "Toggle from VRtist to Mixer panel.\n"
descr += "Mixer offers a collaborative real-time environment for Blender users."
descr += "\n\nSee the documentation for more information."
descr = cls.mixer_desciption
elif "VRTIST" == properties.panel_mode:
descr = "Toggle from Mixer to VRtist Panel.\n"
descr += "This panel will allow you to set up a live link between Blender and VRtist,"
descr += "\na VR application developed by Ubisoft Animation Studio for immersive animation direction."
descr += "\n\nSee the documentation for more information."
descr = cls.vrtist_desciption
return descr

def invoke(self, context, event):
Expand Down
15 changes: 5 additions & 10 deletions mixer/bl_panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from mixer import icons
from mixer.local_data import get_data_directory
from mixer.vrtist import icons as vrtist_icons
from mixer.utils.utils import convert_version_str_to_int
from mixer.utils.utils import convert_version_str_to_tupple

if TYPE_CHECKING:
from mixer.bl_preferences import MixerPreferences
Expand Down Expand Up @@ -365,7 +365,7 @@ def draw_preferences_ui(mixer_prefs: MixerPreferences, context: bpy.types.Contex


class MixerSettingsPanel(bpy.types.Panel):
bl_label = f"Mixer V. {display_version[1:] or '(Unknown version)'}"
bl_label = f"Mixer V. {display_version or '(Unknown version)'}"
bl_idname = "MIXER_PT_mixer_settings"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
Expand Down Expand Up @@ -537,14 +537,10 @@ def _display_property(layout, name, value, has_warning=False):
_display_property(col, "Room Name:", current_room.name)
_display_property(col, "Room Size:", f"{current_room.mega_byte_size:.2} MB")

blender_version_int_app = convert_version_str_to_int(bpy.app.version_string)
blender_version_int_room = convert_version_str_to_int(current_room.blender_version)
blender_warning = blender_version_int_app != blender_version_int_room
blender_warning = bpy.app.version != convert_version_str_to_tupple(current_room.blender_version)
_display_property(col, "Blender Version:", current_room.blender_version, has_warning=blender_warning)

mixer_version_int_app = convert_version_str_to_int(display_version[1:])
mixer_version_int_room = convert_version_str_to_int(current_room.mixer_version[1:])
mixer_warning = mixer_version_int_app != mixer_version_int_room
mixer_warning = display_version != current_room.mixer_version
_display_property(col, "Mixer Version:", current_room.mixer_version[1:], has_warning=mixer_warning)

_display_property(col, "Command Count:", current_room.command_count)
Expand All @@ -570,8 +566,7 @@ def _display_property(layout, name, value, has_warning=False):


class VRtistSettingsPanel(bpy.types.Panel):
bl_label = f"VRtist V. {display_version[1:] or '(Unknown version)'}"
# bl_label = "VRtist"
bl_label = f"VRtist V. {display_version or '(Unknown version)'}"
bl_idname = "MIXER_PT_vrtist_settings"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
Expand Down
17 changes: 5 additions & 12 deletions mixer/bl_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,17 @@
from mixer.broadcaster.common import RoomAttributes
from mixer.os_utils import getuser
from mixer.share_data import share_data
from mixer.utils.utils import convert_version_str_to_int
from mixer.utils.utils import convert_version_str_to_tupple

logger = logging.getLogger(__name__)


class RoomItem(bpy.types.PropertyGroup):
def has_warnings(self):
blender_version_int_app = convert_version_str_to_int(bpy.app.version_string)
blender_version_int_room = convert_version_str_to_int(self.blender_version)
if blender_version_int_app != blender_version_int_room:
return True

mixer_version_int_app = convert_version_str_to_int(display_version[1:])
mixer_version_int_room = convert_version_str_to_int(self.mixer_version[1:])
if mixer_version_int_app != mixer_version_int_room:
return True

return False
return (
bpy.app.version != convert_version_str_to_tupple(self.blender_version)
or display_version != self.mixer_version
)

def get_room_blender_version(self):
if (
Expand Down
7 changes: 3 additions & 4 deletions mixer/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"""


def convert_version_str_to_int(version_str):
"""Convert a string formated like "1.23.48" to a version integer such as 1023048"""
formated_version = "{:02}{:03}{:03}"
def convert_version_str_to_tupple(version_str):
"""Convert a string formated like "1.23.48" to a tupple such as (1,23,48)"""
version_splitted = version_str.split(".")
return int(formated_version.format(int(version_splitted[0]), int(version_splitted[1]), int(version_splitted[2])))
return (int(version_splitted[0]), int(version_splitted[1]), int(version_splitted[2]))

0 comments on commit 4f436cf

Please sign in to comment.