mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-26 08:52:52 +08:00
Multi-select update graphics, fix for multi-move path nodes
This commit is contained in:
parent
bac531208c
commit
24370c1b5d
@ -827,9 +827,9 @@ namespace CodeWalker.GameFiles
|
||||
_RawData.PositionZ = (short)(pos.Z * 32.0f);
|
||||
|
||||
Vector3 newpos = pos;
|
||||
newpos.X = _RawData.PositionX / 4.0f;
|
||||
newpos.Y = _RawData.PositionY / 4.0f;
|
||||
newpos.Z = _RawData.PositionZ / 32.0f;
|
||||
//newpos.X = _RawData.PositionX / 4.0f;
|
||||
//newpos.Y = _RawData.PositionY / 4.0f;
|
||||
//newpos.Z = _RawData.PositionZ / 32.0f;
|
||||
Position = newpos;
|
||||
|
||||
UpdateLinkLengths();
|
||||
|
@ -29,12 +29,14 @@ namespace CodeWalker.Project
|
||||
public Vector3 StartPosition { get; set; }
|
||||
public Vector3 EndPosition { get; set; }
|
||||
|
||||
public MultiPositionUndoStep(MapSelection multiSel, MapSelection[] items, Vector3 startpos)
|
||||
public MultiPositionUndoStep(MapSelection multiSel, MapSelection[] items, Vector3 startpos, WorldForm wf)
|
||||
{
|
||||
Selection = multiSel;
|
||||
Items = items;
|
||||
StartPosition = startpos;
|
||||
EndPosition = multiSel.WidgetPosition;
|
||||
|
||||
UpdateGraphics(wf);
|
||||
}
|
||||
|
||||
private void Update(WorldForm wf, ref MapSelection sel, Vector3 p, Vector3 o)
|
||||
@ -51,8 +53,54 @@ namespace CodeWalker.Project
|
||||
|
||||
wf.SelectMulti(Items);
|
||||
wf.SetWidgetPosition(p);
|
||||
|
||||
UpdateGraphics(wf);
|
||||
}
|
||||
|
||||
|
||||
private void UpdateGraphics(WorldForm wf)
|
||||
{
|
||||
|
||||
Dictionary<YndFile, int> pathYnds = new Dictionary<YndFile, int>();
|
||||
Dictionary<TrainTrack, int> trainTracks = new Dictionary<TrainTrack, int>();
|
||||
Dictionary<YmtFile, int> scenarioYmts = new Dictionary<YmtFile, int>();
|
||||
|
||||
if (Items != null)
|
||||
{
|
||||
foreach (var item in Items)
|
||||
{
|
||||
if (item.PathNode != null)
|
||||
{
|
||||
pathYnds[item.PathNode.Ynd] = 1;
|
||||
}
|
||||
if (item.TrainTrackNode != null)
|
||||
{
|
||||
trainTracks[item.TrainTrackNode.Track] = 1;
|
||||
}
|
||||
if (item.ScenarioNode != null)
|
||||
{
|
||||
scenarioYmts[item.ScenarioNode.Ymt] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var kvp in pathYnds)
|
||||
{
|
||||
wf.UpdatePathYndGraphics(kvp.Key, true);
|
||||
}
|
||||
foreach (var kvp in trainTracks)
|
||||
{
|
||||
wf.UpdateTrainTrackGraphics(kvp.Key, false);
|
||||
}
|
||||
foreach (var kvp in scenarioYmts)
|
||||
{
|
||||
wf.UpdateScenarioGraphics(kvp.Key, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void Undo(WorldForm wf, ref MapSelection sel)
|
||||
{
|
||||
Update(wf, ref sel, StartPosition, EndPosition);
|
||||
|
10
WorldForm.cs
10
WorldForm.cs
@ -3470,11 +3470,11 @@ namespace CodeWalker
|
||||
}
|
||||
else
|
||||
{
|
||||
var dpos = newpos - oldpos;
|
||||
for (int i = 0; i < SelectedItems.Count; i++)
|
||||
{
|
||||
var refpos = SelectedItems[i].WidgetPosition;
|
||||
var relpos = refpos - oldpos;
|
||||
SelectedItems[i].SetPosition(relpos + newpos, refpos, false);
|
||||
SelectedItems[i].SetPosition(refpos + dpos, refpos, false);
|
||||
}
|
||||
SelectedItem.MultipleSelectionCenter = newpos;
|
||||
}
|
||||
@ -3586,6 +3586,9 @@ namespace CodeWalker
|
||||
{
|
||||
if (fullupdate)
|
||||
{
|
||||
ynd.UpdateAllNodePositions();
|
||||
ynd.BuildBVH();
|
||||
|
||||
space.BuildYndData(ynd);
|
||||
}
|
||||
else
|
||||
@ -3618,6 +3621,7 @@ namespace CodeWalker
|
||||
public void UpdateTrainTrackGraphics(TrainTrack tt, bool fullupdate)
|
||||
{
|
||||
tt.BuildVertices();
|
||||
tt.BuildBVH();
|
||||
//if (fullupdate)
|
||||
//{
|
||||
// //space.BuildYndData(ynd);
|
||||
@ -6347,7 +6351,7 @@ namespace CodeWalker
|
||||
{
|
||||
switch (tw.Mode)
|
||||
{
|
||||
case WidgetMode.Position: s = new MultiPositionUndoStep(SelectedItem, SelectedItems.ToArray(), UndoStartPosition); break;
|
||||
case WidgetMode.Position: s = new MultiPositionUndoStep(SelectedItem, SelectedItems.ToArray(), UndoStartPosition, this); break;
|
||||
}
|
||||
}
|
||||
else if (ent != null)
|
||||
|
Loading…
Reference in New Issue
Block a user