Skip to content

Commit

Permalink
[HaCreator] automatically navigate to the tileSet upon selecting a ne…
Browse files Browse the repository at this point in the history
…w layer
  • Loading branch information
lastbattle committed Nov 25, 2024
1 parent 5f8ce69 commit ca02951
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
14 changes: 14 additions & 0 deletions HaCreator/GUI/EditorPanels/TilePanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ private void tileBrowse_Click(object sender, EventArgs e)
}
}

/// <summary>
/// Sets the currently selected tileSet, and refresh the list of tiles
/// </summary>
/// <param name="tileSet"></param>
public void SetSelectedTileSet(string tileSet)
{
if (!Program.InfoManager.TileSets.ContainsKey(tileSet))
return;
tileSetList.SelectedItem = tileSet;

LoadTileSetList();
}

private void tileSetList_SelectedIndexChanged(object sender, EventArgs e)
{
LoadTileSetList();
Expand All @@ -81,6 +94,7 @@ public void LoadTileSetList()
return;
WzImage tileSetImage = Program.InfoManager.TileSets[selectedSetName];
int? mag = InfoTool.GetOptionalInt(tileSetImage["info"]["mag"]);

foreach (WzSubProperty tCat in tileSetImage.WzProperties)
{
if (tCat.Name == "info")
Expand Down
24 changes: 16 additions & 8 deletions HaCreator/GUI/HaRibbon.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,20 +409,24 @@ private void UpdateLocalLayerInfo()
actualPlatform = platformBox.SelectedItem == null ? 0 : (int)platformBox.SelectedItem;
}

private void UpdateRemoteLayerInfo()
/// <summary>
///
/// </summary>
/// <param name="tileSet">The tileSet name</param>
private void UpdateRemoteLayerInfo(string tileSet)
{
if (LayerViewChanged != null)
LayerViewChanged.Invoke(actualLayerIndex, actualPlatform, layerCheckbox.IsChecked.Value, (layerCheckbox.IsChecked.Value || platformCheckbox.IsChecked.Value));
LayerViewChanged.Invoke(actualLayerIndex, actualPlatform, layerCheckbox.IsChecked.Value, (layerCheckbox.IsChecked.Value || platformCheckbox.IsChecked.Value), tileSet);
}

private void AllLayerView_Executed(object sender, ExecutedRoutedEventArgs e)
{
UpdateRemoteLayerInfo();
UpdateRemoteLayerInfo(null);
}

private void AllPlatformView_Executed(object sender, ExecutedRoutedEventArgs e)
{
UpdateRemoteLayerInfo();
UpdateRemoteLayerInfo(null);
}

private void LoadPlatformsForLayer(SortedSet<int> zms)
Expand All @@ -443,9 +447,13 @@ private void layerBox_SelectionChanged(object sender, SelectionChangedEventArgs
{
if (!isInternal)
{
LoadPlatformsForLayer(layers[layerBox.SelectedIndex].zMList);
Layer layer = layers[layerBox.SelectedIndex];
var zmList = layer.zMList;
string tileSet = layer.tS;

LoadPlatformsForLayer(zmList);
UpdateLocalLayerInfo();
UpdateRemoteLayerInfo();
UpdateRemoteLayerInfo(tileSet);
}
}

Expand All @@ -454,7 +462,7 @@ private void platformBox_SelectionChanged(object sender, SelectionChangedEventAr
if (!isInternal)
{
UpdateLocalLayerInfo();
UpdateRemoteLayerInfo();
UpdateRemoteLayerInfo(null);
}
}

Expand Down Expand Up @@ -511,7 +519,7 @@ public void SetLayer(Layer layer)
public delegate void EmptyEvent();
public delegate void ViewToggleEvent(bool? tiles, bool? objs, bool? npcs, bool? mobs, bool? reactors, bool? portals, bool? footholds, bool? ropes, bool? chairs, bool? tooltips, bool? backgrounds, bool? misc, bool? mirrorField);
public delegate void ToggleEvent(bool pressed);
public delegate void LayerViewChangedEvent(int layer, int platform, bool allLayers, bool allPlats);
public delegate void LayerViewChangedEvent(int layer, int platform, bool allLayers, bool allPlats, string tileSet);

public event EmptyEvent NewClicked;
public event EmptyEvent OpenClicked;
Expand Down
7 changes: 6 additions & 1 deletion HaCreator/MapEditor/HaCreatorStateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -924,13 +924,18 @@ private void SetLayer(int currentLayer, int currentPlatform, bool allLayers, boo
ApplicationSettings.lastAllLayers = allLayers;
}

void ribbon_LayerViewChanged(int layer, int platform, bool allLayers, bool allPlats)
void ribbon_LayerViewChanged(int layer, int platform, bool allLayers, bool allPlats, string tileSet)
{
if (multiBoard.SelectedBoard == null)
return;
SetLayer(layer, platform, allLayers, allPlats);
InputHandler.ClearSelectedItems(multiBoard.SelectedBoard);

// Update tilePanel to navigate to that selected tileLayer
if (tileSet != null)
{
tilePanel.SetSelectedTileSet(tileSet);
}
}
#endregion

Expand Down

0 comments on commit ca02951

Please sign in to comment.