Add support for ScenarioTypeGroups in scenario files

This commit is contained in:
alexguirre
2019-08-04 00:51:05 +02:00
Unverified
parent 4559312f1c
commit d260a58ee6
4 changed files with 210 additions and 23 deletions
+17 -6
View File
@@ -133,6 +133,9 @@ namespace CodeWalker.Project.Panels
var stypes = types.GetScenarioTypes();
if (stypes == null) return;
var stgroups = types.GetScenarioTypeGroups();
if (stgroups == null) return;
var pmsets = types.GetPedModelSets();
if (pmsets == null) return;
@@ -147,9 +150,17 @@ namespace CodeWalker.Project.Panels
ScenarioChainNodeTypeComboBox.Items.Add("");
foreach (var stype in stypes)
{
ScenarioPointTypeComboBox.Items.Add(stype);
ScenarioClusterPointTypeComboBox.Items.Add(stype);
ScenarioChainNodeTypeComboBox.Items.Add(stype);
ScenarioTypeRef? typeRef = new ScenarioTypeRef(stype);
ScenarioPointTypeComboBox.Items.Add(typeRef);
ScenarioClusterPointTypeComboBox.Items.Add(typeRef);
ScenarioChainNodeTypeComboBox.Items.Add(typeRef);
}
foreach (var stgroup in stgroups)
{
ScenarioTypeRef? typeRef = new ScenarioTypeRef(stgroup);
ScenarioPointTypeComboBox.Items.Add(typeRef);
ScenarioClusterPointTypeComboBox.Items.Add(typeRef);
ScenarioChainNodeTypeComboBox.Items.Add(typeRef);
}
ScenarioPointModelSetComboBox.Items.Clear();
@@ -827,7 +838,7 @@ namespace CodeWalker.Project.Panels
if (populatingui) return;
if (CurrentScenarioNode == null) return;
if (CurrentScenarioNode.MyPoint == null) return;
ScenarioType stype = ScenarioPointTypeComboBox.SelectedItem as ScenarioType;
ScenarioTypeRef? stype = ScenarioPointTypeComboBox.SelectedItem as ScenarioTypeRef?;
lock (ProjectForm.ProjectSyncRoot)
{
if (CurrentScenarioNode.MyPoint.Type != stype)
@@ -1711,7 +1722,7 @@ namespace CodeWalker.Project.Panels
if (populatingui) return;
if (CurrentScenarioNode == null) return;
if (CurrentScenarioNode.ChainingNode == null) return;
ScenarioType stype = ScenarioChainNodeTypeComboBox.SelectedItem as ScenarioType;
ScenarioTypeRef? stype = ScenarioChainNodeTypeComboBox.SelectedItem as ScenarioTypeRef?;
lock (ProjectForm.ProjectSyncRoot)
{
if (CurrentScenarioNode.ChainingNode.Type != stype)
@@ -2133,7 +2144,7 @@ namespace CodeWalker.Project.Panels
if (populatingui) return;
if (CurrentScenarioNode == null) return;
if (CurrentScenarioNode.ClusterMyPoint == null) return;
ScenarioType stype = ScenarioClusterPointTypeComboBox.SelectedItem as ScenarioType;
ScenarioTypeRef? stype = ScenarioClusterPointTypeComboBox.SelectedItem as ScenarioTypeRef?;
lock (ProjectForm.ProjectSyncRoot)
{
if (CurrentScenarioNode.ClusterMyPoint.Type != stype)
+19 -3
View File
@@ -4266,7 +4266,7 @@ namespace CodeWalker.Project
var action = Unk_3609807418.Move;
var navMode = Unk_3971773454.Direct;
var navSpeed = Unk_941086046.Unk_00_3279574318;
var stype = defaulttype;
var stype = new ScenarioTypeRef(defaulttype);
var modelset = defaultmodelset;
var flags = defaultflags;
var ok = true;
@@ -4298,7 +4298,23 @@ namespace CodeWalker.Project
if (vals.Length > 6)
{
var sthash = JenkHash.GenHash(vals[6].Trim().ToLowerInvariant());
stype = stypes?.GetScenarioType(sthash) ?? defaulttype;
var st = stypes?.GetScenarioType(sthash);
if (st != null)
{
stype = new ScenarioTypeRef(st);
}
else
{
var stg = stypes?.GetScenarioTypeGroup(sthash);
if (stg != null)
{
stype = new ScenarioTypeRef(stg);
}
else
{
stype = new ScenarioTypeRef(defaulttype);
}
}
}
if (vals.Length > 7)
{
@@ -4326,7 +4342,7 @@ namespace CodeWalker.Project
thisnode.ChainingNode.ScenarioNode = thisnode;
thisnode.ChainingNode.Chain = chain;
thisnode.ChainingNode.Type = stype;
thisnode.ChainingNode.TypeHash = stype?.NameHash ?? 0;
thisnode.ChainingNode.TypeHash = stype.NameHash;
thisnode.ChainingNode.NotLast = (i < (lines.Length - 1));
thisnode.ChainingNode.NotFirst = (lastnode != null);