Fix up/down arrow select in project window, Fix selecting project audio placements

This commit is contained in:
dexy 2024-07-27 13:40:12 +10:00
parent 76d0ac224c
commit 3d22e9b2a4
3 changed files with 247 additions and 215 deletions

View File

@ -86,6 +86,22 @@ namespace CodeWalker.World
} }
public AudioPlacement FindPlacement(RelFile relfile, Dat151RelData reldata)
{
if (relfile == null) return null;
if (reldata == null) return null;
if (PlacementsDict.TryGetValue(relfile, out var placements))
{
foreach (var placement in placements)
{
if (placement.AmbientZone == reldata) return placement;
if (placement.AmbientRule == reldata) return placement;
if (placement.StaticEmitter == reldata) return placement;
}
}
return null;
}
} }

View File

@ -114,6 +114,7 @@ namespace CodeWalker.Project
private List<YmapEntityDef> interiorslist = new List<YmapEntityDef>(); //used for handling interiors ybns private List<YmapEntityDef> interiorslist = new List<YmapEntityDef>(); //used for handling interiors ybns
private bool ShowProjectItemInProcess = false; private bool ShowProjectItemInProcess = false;
private bool WorldSelectionChangeInProcess = false;
public ProjectForm(WorldForm worldForm = null) public ProjectForm(WorldForm worldForm = null)
@ -886,13 +887,13 @@ namespace CodeWalker.Project
if (CurrentAudioAmbientRule?.AmbientRule == null) CurrentAudioAmbientRule = null; if (CurrentAudioAmbientRule?.AmbientRule == null) CurrentAudioAmbientRule = null;
if (CurrentAudioStaticEmitter?.StaticEmitter == null) CurrentAudioStaticEmitter = null; if (CurrentAudioStaticEmitter?.StaticEmitter == null) CurrentAudioStaticEmitter = null;
//need to create a temporary AudioPlacement wrapper for these, since AudioPlacements usually come from WorldForm
var daz = item as Dat151AmbientZone; var daz = item as Dat151AmbientZone;//need to get these from WorldForm, project tree only contains the Dat151Rel items
var dae = item as Dat151AmbientRule; var dae = item as Dat151AmbientRule;
var dse = item as Dat151StaticEmitter; var dse = item as Dat151StaticEmitter;
if (daz != null) CurrentAudioAmbientZone = new AudioPlacement(daz.Rel, daz); if (daz != null) CurrentAudioAmbientZone = WorldForm?.GetAudioPlacement(daz.Rel, daz);
if (dae != null) CurrentAudioAmbientRule = new AudioPlacement(dae.Rel, dae); if (dae != null) CurrentAudioAmbientRule = WorldForm?.GetAudioPlacement(dae.Rel, dae);
if (dse != null) CurrentAudioStaticEmitter = new AudioPlacement(dse.Rel, dse); if (dse != null) CurrentAudioStaticEmitter = WorldForm?.GetAudioPlacement(dse.Rel, dse);
@ -7610,13 +7611,15 @@ namespace CodeWalker.Project
public void OnWorldSelectionChanged(MapSelection sel) public void OnWorldSelectionChanged(MapSelection sel)
{ {
try if (WorldSelectionChangeInProcess) return;
{
if (InvokeRequired) if (InvokeRequired)
{ {
BeginInvoke(new Action(() => { OnWorldSelectionChanged(sel); })); BeginInvoke(new Action(() => { OnWorldSelectionChanged(sel); }));
return;
} }
else WorldSelectionChangeInProcess = true;
try
{ {
var wasmult = (CurrentMulti != null); var wasmult = (CurrentMulti != null);
if ((sel.MultipleSelectionItems != null) && (sel.MultipleSelectionItems.Length > 0)) if ((sel.MultipleSelectionItems != null) && (sel.MultipleSelectionItems.Length > 0))
@ -7627,6 +7630,7 @@ namespace CodeWalker.Project
ShowProjectItemInProcess = true; ShowProjectItemInProcess = true;
ShowCurrentProjectItem(false); ShowCurrentProjectItem(false);
ShowProjectItemInProcess = false; ShowProjectItemInProcess = false;
WorldSelectionChangeInProcess = false;
return; return;
} }
else else
@ -7833,8 +7837,9 @@ namespace CodeWalker.Project
ShowProjectItemInProcess = false; ShowProjectItemInProcess = false;
} }
} }
}
catch { } catch { }
WorldSelectionChangeInProcess = false;
} }
public void OnWorldSelectionModified(MapSelection sel) public void OnWorldSelectionModified(MapSelection sel)
{ {

View File

@ -2038,6 +2038,17 @@ namespace CodeWalker
{ {
audiozones.PlacementsDict.Remove(rel); //should cause a rebuild to add/remove items audiozones.PlacementsDict.Remove(rel); //should cause a rebuild to add/remove items
} }
public AudioPlacement GetAudioPlacement(RelFile rel, Dat151RelData reldata)
{
var placement = audiozones.FindPlacement(rel, reldata);
if (placement == null)
{
if (reldata is Dat151AmbientZone az) placement = new AudioPlacement(rel, az);
if (reldata is Dat151AmbientRule ar) placement = new AudioPlacement(rel, ar);
if (reldata is Dat151StaticEmitter se) placement = new AudioPlacement(rel, se);
}
return placement;
}
public void SetCameraTransform(Vector3 pos, Quaternion rot) public void SetCameraTransform(Vector3 pos, Quaternion rot)
@ -3619,7 +3630,7 @@ namespace CodeWalker
if (change) if (change)
{ {
// If an item has been selected the user is likely to use a keybind. We need focus! // If an item has been selected the user is likely to use a keybind. We need focus!
Focus(); //Focus();//DISABLED THIS due to causing problems with using arrows to select in project window!
} }
} }
public void SelectMulti(MapSelection[] items, bool addSelection = false, bool notifyProject = true) public void SelectMulti(MapSelection[] items, bool addSelection = false, bool notifyProject = true)