Skip to content

Commit

Permalink
[HaCreator] added field & render support for 'MirrorFieldData' and 'i…
Browse files Browse the repository at this point in the history
…nfo/mirror_Bottom'

creates the ground reflection effect in Arcane river maps ..
450007030
450001000

TODO: ability to add 'MirrorFieldData' to maps without it by drag and drop & adjust the size of the boundary
+ further optimize it, not the most optimal way yet @ MapSimulator
  • Loading branch information
lastbattle committed Feb 22, 2022
1 parent 142c62d commit bb12bcb
Show file tree
Hide file tree
Showing 38 changed files with 1,733 additions and 378 deletions.
36 changes: 34 additions & 2 deletions HaCreator/Collections/BoardItemsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
using HaCreator.MapEditor;
using HaCreator.MapEditor.Info;
using MapleLib.WzLib.WzStructure;
using HaSharedLibrary.Render.DX;
using System.Runtime.CompilerServices;

namespace HaCreator.Collections
{
Expand All @@ -39,8 +41,34 @@ public class BoardItemsManager
public MapleList<BoardItem> MiscItems = new MapleList<BoardItem>(ItemTypes.Misc, true);
public MapleList<MapleDot> SpecialDots = new MapleList<MapleDot>(ItemTypes.Misc, true);

public MapleList<MirrorFieldData> MirrorFieldDatas = new MapleList<MirrorFieldData>(ItemTypes.MirrorFieldData, true);
/// <summary>
/// Map info/
/// Checks if a BaseDXDrawableItem is within any of the MirrorFieldData in the field.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="filter_objectForOverlay"></param>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public MirrorFieldData CheckObjectWithinMirrorFieldDataBoundary(int x, int y, MirrorFieldDataType filter_objectForOverlay)
{
if (MirrorFieldDatas.Count == 0)
return null;

Microsoft.Xna.Framework.Point pos = new Microsoft.Xna.Framework.Point(x, y - 60);
MirrorFieldData reflectionBoundaryWithin = MirrorFieldDatas.FirstOrDefault(
mirror =>
{
return mirror.Rectangle.Contains(pos) && mirror.MirrorFieldDataType == filter_objectForOverlay;
});

if (reflectionBoundaryWithin != null)
return reflectionBoundaryWithin;
return null;
}

/// <summary>
/// Map info
/// </summary>
public MapInfo MapInfo { get { return board.MapInfo; } }

Expand All @@ -53,7 +81,11 @@ public class BoardItemsManager

public BoardItemsManager(Board board)
{
AllItemLists = new IMapleList[] { BackBackgrounds, TileObjs, Mobs, NPCs, Reactors, Portals, FrontBackgrounds, FootholdLines, RopeLines, FHAnchors, RopeAnchors, Chairs, CharacterToolTips, ToolTips, ToolTipDots, MiscItems, SpecialDots };
AllItemLists = new IMapleList[]
{
BackBackgrounds, TileObjs, Mobs, NPCs, Reactors, Portals, FrontBackgrounds, FootholdLines, RopeLines, FHAnchors,
RopeAnchors, Chairs, CharacterToolTips, ToolTips, ToolTipDots, MiscItems, SpecialDots, MirrorFieldDatas
};
this.board = board;
Items = new BoardItemsCollection(this, true);
Lines = new MapleLinesCollection(this, false);
Expand Down
5 changes: 0 additions & 5 deletions HaCreator/Collections/IMapleList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

using MapleLib.WzLib.WzStructure.Data;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HaCreator.Collections
{
Expand Down
14 changes: 7 additions & 7 deletions HaCreator/CustomControls/MapBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace HaCreator.CustomControls
{
public partial class MapBrowser : UserControl
{
private bool load = false;
private bool loadMapAvailable = false;
private readonly List<string> maps = new List<string>();

public MapBrowser()
Expand All @@ -33,7 +33,7 @@ public bool LoadAvailable
{
get
{
return load;
return loadMapAvailable;
}
}

Expand Down Expand Up @@ -187,7 +187,7 @@ private void mapNamesBox_SelectedIndexChanged(object sender, EventArgs e)
linkLabel.Visible = false;
mapNotExist.Visible = false;
minimapBox.Image = new Bitmap(1, 1);
load = mapNamesBox.SelectedItem != null;
loadMapAvailable = mapNamesBox.SelectedItem != null;
}
else
{
Expand All @@ -200,7 +200,7 @@ private void mapNamesBox_SelectedIndexChanged(object sender, EventArgs e)
linkLabel.Visible = false;
mapNotExist.Visible = true;
minimapBox.Image = (Image)new Bitmap(1, 1);
load = false;
loadMapAvailable = false;
}
else
{
Expand All @@ -211,13 +211,13 @@ private void mapNamesBox_SelectedIndexChanged(object sender, EventArgs e)
linkLabel.Visible = true;
mapNotExist.Visible = false;
minimapBox.Image = new Bitmap(1, 1);
load = false;
loadMapAvailable = false;
}
else
{
linkLabel.Visible = false;
mapNotExist.Visible = false;
load = true;
loadMapAvailable = true;
WzCanvasProperty minimap = (WzCanvasProperty)mapImage.GetFromPath("miniMap/canvas");
if (minimap != null)
{
Expand All @@ -227,7 +227,7 @@ private void mapNamesBox_SelectedIndexChanged(object sender, EventArgs e)
{
minimapBox.Image = new Bitmap(1, 1);
}
load = true;
loadMapAvailable = true;
}
}
}
Expand Down
64 changes: 35 additions & 29 deletions HaCreator/GUI/HaRibbon.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,37 +76,43 @@
<RibbonGroup x:Name="MapObj" Header="Map Objects">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70" />
<ColumnDefinition Width="70" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="110" />
<ColumnDefinition Width="90" />
<ColumnDefinition Width="90" />
<ColumnDefinition Width="90" />
<ColumnDefinition Width="90" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="20" />
<RowDefinition Height="20" />
<RowDefinition Height="20" />
</Grid.RowDefinitions>

<CheckBox x:Name="tilesCheck" Content="Tiles" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Center" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
<CheckBox x:Name="objsCheck" Content="Objects" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Center" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
<CheckBox x:Name="npcsCheck" Content="NPCs" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Center" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>

<CheckBox x:Name="mobsCheck" Content="Mobs" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Center" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
<CheckBox x:Name="reactCheck" Content="Reactors" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Center" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
<CheckBox x:Name="portalCheck" Content="Portals" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Center" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>

<CheckBox x:Name="fhCheck" Content="Footholds" Grid.Column="2" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Center" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
<CheckBox x:Name="ropeCheck" Content="Ropes" Grid.Column="2" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Center" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
<CheckBox x:Name="chairCheck" Content="Chairs" Grid.Column="2" Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Center" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>

<CheckBox x:Name="tooltipCheck" Content="Tooltips" Grid.Column="3" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Center" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
<CheckBox x:Name="bgCheck" Content="Backgrounds" Grid.Column="3" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Center" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
<CheckBox x:Name="miscCheck" Content="Other" Grid.Column="3" Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Center" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>

<cc:CheckboxButton x:Name="allFullCheck" Content="All Objects" Grid.Column="4" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Center" IsThreeState="True" IsChecked="True" Clicked="allFullCheck_Click" Focusable="False"/>
<cc:CheckboxButton x:Name="allHalfCheck" Content="All Objects" Grid.Column="4" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Center" IsThreeState="True" IsChecked="{x:Null}" Clicked="allHalfCheck_Click" Focusable="False"/>
<cc:CheckboxButton x:Name="allClearCheck" Content="All Objects" Grid.Column="4" Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Center" IsThreeState="True" IsChecked="False" Clicked="allClearCheck_Click" Focusable="False"/>

<StackPanel Grid.Column="0">
<CheckBox x:Name="tilesCheck" Content="Tiles" Grid.Row="0" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
<CheckBox x:Name="objsCheck" Content="Objects" Grid.Row="1" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
<CheckBox x:Name="npcsCheck" Content="NPCs" Grid.Row="2" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
<CheckBox x:Name="mobsCheck" Content="Mobs" Grid.Row="3" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
</StackPanel>

<StackPanel Grid.Column="1">
<CheckBox x:Name="reactCheck" Content="Reactors" Grid.Row="0" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
<CheckBox x:Name="portalCheck" Content="Portals" Grid.Row="1" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
<CheckBox x:Name="fhCheck" Content="Footholds" Grid.Row="2" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
<CheckBox x:Name="ropeCheck" Content="Ropes" Grid.Row="3" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
</StackPanel>

<StackPanel Grid.Column="2" >
<CheckBox x:Name="chairCheck" Content="Chairs" Grid.Row="0" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
<CheckBox x:Name="tooltipCheck" Content="Tooltips" Grid.Row="1" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
<CheckBox x:Name="bgCheck" Content="Backgrounds" Grid.Row="2" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
<CheckBox x:Name="miscCheck" Content="Other" Grid.Row="3" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
</StackPanel>

<StackPanel Grid.Column="3">
<CheckBox x:Name="mirrorFieldDataCheck" Content="Mirror field" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Center" IsThreeState="True" Command="ns:HaRibbon.ViewBoxes" Focusable="False"/>
</StackPanel>

<StackPanel Grid.Column="4">
<cc:CheckboxButton x:Name="allFullCheck" Content="All Objects" Grid.Row="0" IsThreeState="True" IsChecked="True" Clicked="allFullCheck_Click" Focusable="False"/>
<cc:CheckboxButton x:Name="allHalfCheck" Content="All Objects" Grid.Row="1" IsThreeState="True" IsChecked="{x:Null}" Clicked="allHalfCheck_Click" Focusable="False"/>
<cc:CheckboxButton x:Name="allClearCheck" Content="All Objects" Grid.Row="2" IsThreeState="True" IsChecked="False" Clicked="allClearCheck_Click" Focusable="False"/>
</StackPanel>
</Grid>
</RibbonGroup>

Expand Down
9 changes: 5 additions & 4 deletions HaCreator/GUI/HaRibbon.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private void Exit_Executed(object sender, ExecutedRoutedEventArgs e)
private void ViewBoxes_Executed(object sender, ExecutedRoutedEventArgs e)
{
if (ViewToggled != null)
ViewToggled.Invoke(tilesCheck.IsChecked, objsCheck.IsChecked, npcsCheck.IsChecked, mobsCheck.IsChecked, reactCheck.IsChecked, portalCheck.IsChecked, fhCheck.IsChecked, ropeCheck.IsChecked, chairCheck.IsChecked, tooltipCheck.IsChecked, bgCheck.IsChecked, miscCheck.IsChecked);
ViewToggled.Invoke(tilesCheck.IsChecked, objsCheck.IsChecked, npcsCheck.IsChecked, mobsCheck.IsChecked, reactCheck.IsChecked, portalCheck.IsChecked, fhCheck.IsChecked, ropeCheck.IsChecked, chairCheck.IsChecked, tooltipCheck.IsChecked, bgCheck.IsChecked, miscCheck.IsChecked, mirrorFieldDataCheck.IsChecked);
}

private void Minimap_Executed(object sender, ExecutedRoutedEventArgs e)
Expand Down Expand Up @@ -494,7 +494,7 @@ public void SetLayer(Layer layer)
#endregion

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);
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);

Expand Down Expand Up @@ -524,7 +524,7 @@ public void SetLayer(Layer layer)
public event EmptyEvent ShowMapPropertiesClicked;
public event EventHandler<System.Windows.Forms.KeyEventArgs> RibbonKeyDown;

public void SetVisibilityCheckboxes(bool? tiles, bool? objs, bool? npcs, bool? mobs, bool? reactors, bool? portals, bool? footholds, bool? ropes, bool? chairs, bool? tooltips, bool? backgrounds, bool? misc)
public void SetVisibilityCheckboxes(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)
{
tilesCheck.IsChecked = tiles;
objsCheck.IsChecked = objs;
Expand All @@ -538,6 +538,7 @@ public void SetVisibilityCheckboxes(bool? tiles, bool? objs, bool? npcs, bool? m
tooltipCheck.IsChecked = tooltips;
bgCheck.IsChecked = backgrounds;
miscCheck.IsChecked = misc;
mirrorFieldDataCheck.IsChecked = mirrorField;
}

public void SetEnabled(bool enabled)
Expand Down Expand Up @@ -566,7 +567,7 @@ public void SetHasMinimap(bool hasMinimap)

private void ChangeAllCheckboxes(bool? state)
{
foreach (CheckBox cb in new CheckBox[] { tilesCheck, objsCheck, npcsCheck, mobsCheck, reactCheck, portalCheck, fhCheck, ropeCheck, chairCheck, tooltipCheck, bgCheck, miscCheck })
foreach (CheckBox cb in new CheckBox[] { tilesCheck, objsCheck, npcsCheck, mobsCheck, reactCheck, portalCheck, fhCheck, ropeCheck, chairCheck, tooltipCheck, bgCheck, miscCheck, mirrorFieldDataCheck })
{
cb.IsChecked = state;
}
Expand Down

1 comment on commit bb12bcb

@lastbattle
Copy link
Owner Author

@lastbattle lastbattle commented on bb12bcb Feb 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nameless Town
image

image

image

image

Please sign in to comment.