Browse Source

Add some age detail validation nastygrams.

Fixes #234.
pull/235/head
Adam Johnson 3 years ago
parent
commit
f7499f25bb
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 15
      korman/properties/prop_world.py
  2. 19
      korman/ui/ui_world.py

15
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",

19
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()

Loading…
Cancel
Save