diff --git a/korman/properties/prop_world.py b/korman/properties/prop_world.py index 453f2d9..5e223af 100644 --- a/korman/properties/prop_world.py +++ b/korman/properties/prop_world.py @@ -148,6 +148,14 @@ class PlasmaPage(bpy.types.PropertyGroup): class PlasmaAge(bpy.types.PropertyGroup): def export(self, exporter): + if exporter.mgr.getVer() == pvMoul: + log_func = exporter.report.warn + else: + log_func = exporter.report.port + if self.seq_prefix <= self.MOUL_PREFIX_RANGE[0] or self.seq_prefix >= self.MOUL_PREFIX_RANGE[1]: + log_func("Age Sequence Prefix {} is potentially out of range (should be between {} and {})", + self.seq_prefix, *self.MOUL_PREFIX_RANGE) + _age_info = plAgeInfo() _age_info.dayLength = self.day_length _age_info.lingerTime = 180 # this is fairly standard @@ -157,6 +165,10 @@ class PlasmaAge(bpy.types.PropertyGroup): _age_info.startDateTime = self.start_time return _age_info + # Sequence prefix helpers + MOUL_PREFIX_RANGE = ((pow(2, 16) - pow(2, 15)) * -1, pow(2, 15) - 1) + SP_PRFIX_RANGE = ((pow(2, 24) - pow(2, 23)) * -1, pow(2, 23) - 1) + day_length = FloatProperty(name="Day Length", description="Length of a day (in hours) on this age", default=30.230000, @@ -169,7 +181,10 @@ class PlasmaAge(bpy.types.PropertyGroup): min=0) seq_prefix = IntProperty(name="Sequence Prefix", description="A unique numerical ID for this age", + min=SP_PRFIX_RANGE[0], soft_min=0, # Negative indicates global--advanced users only + soft_max=MOUL_PREFIX_RANGE[1], + max=SP_PRFIX_RANGE[1], default=100) pages = CollectionProperty(name="Pages", description="Registry pages for this age", diff --git a/korman/ui/ui_world.py b/korman/ui/ui_world.py index c4bcb8c..3ed422e 100644 --- a/korman/ui/ui_world.py +++ b/korman/ui/ui_world.py @@ -210,6 +210,8 @@ class PlasmaAgePanel(AgeButtonsPanel, bpy.types.Panel): # Age Names should really be legal Python 2.x identifiers for AgeSDLHooks legal_identifier = korlib.is_legal_python2_identifier(age.age_name) + illegal_age_name = not legal_identifier or '_' in age.age_name + bad_prefix = age.seq_prefix >= age.MOUL_PREFIX_RANGE[1] or age.seq_prefix <= age.MOUL_PREFIX_RANGE[0] # Core settings layout.separator() @@ -222,17 +224,28 @@ class PlasmaAgePanel(AgeButtonsPanel, bpy.types.Panel): col = split.column() col.label("Age Settings:") + col.alert = bad_prefix col.prop(age, "seq_prefix", text="ID") - col.alert = not legal_identifier or '_' in age.age_name + col.alert = illegal_age_name col.prop(age, "age_name", text="") + if age.seq_prefix >= age.MOUL_PREFIX_RANGE[1]: + layout.label(text="Your sequence prefix is too high for Myst Online: Uru Live", icon="ERROR") + elif age.seq_prefix <= age.MOUL_PREFIX_RANGE[0]: + # Unlikely. + layout.label(text="Your sequence prefix is too low for Myst Online: Uru Live", icon="ERROR") + # Display a hint if the identifier is illegal - if not legal_identifier: - if korlib.is_python_keyword(age.age_name): + if illegal_age_name: + if not age.age_name: + layout.label(text="Age names cannot be empty", icon="ERROR") + elif korlib.is_python_keyword(age.age_name): layout.label(text="Ages should not be named the same as a Python keyword", icon="ERROR") elif age.age_sdl: fixed_identifier = korlib.replace_python2_identifier(age.age_name) layout.label(text="Age's SDL will use the name '{}'".format(fixed_identifier), icon="ERROR") + if '_' in age.age_name: + layout.label(text="Age names should not contain underscores", icon="ERROR") layout.separator() split = layout.split()