Invalidates handlers with unmatched physical dimension or nullablility in input config.
This commit is contained in:
@@ -31,8 +31,16 @@ namespace Cryville.Crtr.Config {
|
|||||||
readonly Dictionary<Identifier, InputConfigPanelEntry> _entries = new Dictionary<Identifier, InputConfigPanelEntry>();
|
readonly Dictionary<Identifier, InputConfigPanelEntry> _entries = new Dictionary<Identifier, InputConfigPanelEntry>();
|
||||||
|
|
||||||
Identifier _sel;
|
Identifier _sel;
|
||||||
|
int _targetDim;
|
||||||
|
PhysicalDimension? _targetPDim;
|
||||||
|
bool _targetNotNull;
|
||||||
public void OpenDialog(Identifier entry) {
|
public void OpenDialog(Identifier entry) {
|
||||||
_sel = entry;
|
_sel = entry;
|
||||||
|
var def = m_configScene.ruleset.Root.inputs[_sel];
|
||||||
|
_targetDim = def.dim;
|
||||||
|
if (def.pdim != null) _targetPDim = ParsePhysicalDimension(def.pdim);
|
||||||
|
else _targetPDim = null;
|
||||||
|
_targetNotNull = def.notnull;
|
||||||
m_inputDialog.SetActive(true);
|
m_inputDialog.SetActive(true);
|
||||||
CallHelper.Purge(m_deviceList);
|
CallHelper.Purge(m_deviceList);
|
||||||
_consumer.EnumerateEvents(ev => { });
|
_consumer.EnumerateEvents(ev => { });
|
||||||
@@ -40,6 +48,27 @@ namespace Cryville.Crtr.Config {
|
|||||||
AddSourceItem(null);
|
AddSourceItem(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PhysicalDimension ParsePhysicalDimension(string str) {
|
||||||
|
var comps = str.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
var result = new PhysicalDimension();
|
||||||
|
foreach (var comp in comps) {
|
||||||
|
int dim = 1;
|
||||||
|
if (comp.Length > 1) int.Parse(comp.Substring(1));
|
||||||
|
switch (comp[0]) {
|
||||||
|
case 'T': result.Time += dim; break;
|
||||||
|
case 'L': result.Length += dim; break;
|
||||||
|
case 'M': result.Mass += dim; break;
|
||||||
|
case 'I': result.ElectricCurrent += dim; break;
|
||||||
|
case '\x0398':
|
||||||
|
case 'H': result.ThermodynamicTemperature += dim; break;
|
||||||
|
case 'N': result.AmountOfSubstance += dim; break;
|
||||||
|
case 'J': result.LuminousIntensity += dim; break;
|
||||||
|
default: throw new ArgumentException(string.Format("Invalid dimension symbol {0}", comp[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public void CloseDialog() {
|
public void CloseDialog() {
|
||||||
m_inputDialog.SetActive(false);
|
m_inputDialog.SetActive(false);
|
||||||
}
|
}
|
||||||
@@ -103,7 +132,13 @@ namespace Cryville.Crtr.Config {
|
|||||||
if (proxy.IsUsed(tsrc)) {
|
if (proxy.IsUsed(tsrc)) {
|
||||||
text.text += " <size=9>(Used)</size>";
|
text.text += " <size=9>(Used)</size>";
|
||||||
}
|
}
|
||||||
else if (tsrc.Handler.Dimension < m_configScene.ruleset.Root.inputs[_sel].dim) {
|
else if (tsrc.Handler.Dimension < _targetDim) {
|
||||||
|
text.text += " <size=9>(Not Applicable)</size>";
|
||||||
|
}
|
||||||
|
else if (_targetPDim != null && tsrc.Handler.ReferenceCue.PhysicalDimension != _targetPDim) {
|
||||||
|
text.text += " <size=9>(Not Applicable)</size>";
|
||||||
|
}
|
||||||
|
else if (!_targetNotNull && !tsrc.Handler.IsNullable) {
|
||||||
text.text += " <size=9>(Not Applicable)</size>";
|
text.text += " <size=9>(Not Applicable)</size>";
|
||||||
}
|
}
|
||||||
else flag = true;
|
else flag = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user