Skip to content

Commit

Permalink
[HaCreator] Dump unsupported 'info' properties back when saving
Browse files Browse the repository at this point in the history
this should fix some of the issues with newer version of MapleStory in the short term, until they all get sorted out
  • Loading branch information
lastbattle committed Dec 5, 2020
1 parent b084ac4 commit b9c813b
Show file tree
Hide file tree
Showing 9 changed files with 232 additions and 117 deletions.
9 changes: 9 additions & 0 deletions HaCreator/GUI/HaRibbon.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
<CommandBinding Command="ns:HaRibbon.UserObjs" CanExecute="AlwaysExecute" Executed="UserObjs_Executed" />
<CommandBinding Command="ns:HaRibbon.Export" CanExecute="AlwaysExecute" Executed="Export_Executed" />
<CommandBinding Command="ns:HaRibbon.PhysicsEdit" CanExecute="AlwaysExecute" Executed="PhysicsEdit_Executed" />

<CommandBinding Command="ns:HaRibbon.ShowMapProperties" CanExecute="AlwaysExecute" Executed="ShowMapProperties_Executed" />
</Ribbon.CommandBindings>

<Ribbon.ApplicationMenu>
Expand Down Expand Up @@ -197,6 +199,13 @@
</RibbonGroup>
</RibbonTab>

<!-- Debug, only appear when run under DEBUG mode-->
<RibbonTab x:Name="debugTab" Header="DEBUG" KeyTip="D">
<RibbonGroup x:Name="RibbonGroup_DebugMap" Header="Map">
<RibbonButton Label="Show unsupported 'info/' props" Command="ns:HaRibbon.ShowMapProperties" Focusable="False"/>
</RibbonGroup>
</RibbonTab>


<!-- <RibbonTab x:Name="statTab" Header="Stats" KeyTip="S">
<RibbonGroup x:Name="mouseVirt" Header="Mouse Virtual">
Expand Down
26 changes: 25 additions & 1 deletion HaCreator/GUI/HaRibbon.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public HaRibbon()
{
InitializeComponent();

#if DEBUG
debugTab.Visibility = Visibility.Visible;
#else
debugTab.Visibility = Visibility.Collapsed;
#endif

this.PreviewMouseWheel += HaRibbon_PreviewMouseWheel;
}

Expand Down Expand Up @@ -149,6 +155,11 @@ private void Ribbon_Loaded(object sender, RoutedEventArgs e)
public static readonly RoutedUICommand PhysicsEdit = new RoutedUICommand("PhysicsEdit", "PhysicsEdit", typeof(HaRibbon),
new InputGestureCollection() { });

#region Debug Items
public static readonly RoutedUICommand ShowMapProperties = new RoutedUICommand("ShowMapProperties", "ShowMapProperties", typeof(HaRibbon),
new InputGestureCollection() { });
#endregion

private void AlwaysExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
Expand Down Expand Up @@ -285,6 +296,18 @@ private void PhysicsEdit_Executed(object sender, ExecutedRoutedEventArgs e)
}


/// <summary>
/// Show map 'info' properties clicked
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ShowMapProperties_Executed(object sender, ExecutedRoutedEventArgs e)
{
if (ShowMapPropertiesClicked != null)
ShowMapPropertiesClicked.Invoke();
}


#region Layer UI
private void LayerUp_Executed(object sender, ExecutedRoutedEventArgs e)
{
Expand Down Expand Up @@ -467,7 +490,7 @@ public void SetLayer(Layer layer)
endInternalEditing();
}

#endregion
#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);
Expand Down Expand Up @@ -497,6 +520,7 @@ public void SetLayer(Layer layer)
public event EmptyEvent NewPlatformClicked;
public event EmptyEvent UserObjsClicked;
public event EmptyEvent MapPhysicsClicked;
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)
Expand Down
9 changes: 5 additions & 4 deletions HaCreator/GUI/InfoEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using MapleLib.WzLib.WzStructure;
using MapleLib.WzLib.WzStructure.Data;
using HaCreator.GUI.InstanceEditor;
using MapleLib.WzLib.WzStructure.Data.MapStructure;

namespace HaCreator.GUI
{
Expand Down Expand Up @@ -135,7 +136,7 @@ public InfoEditor(Board board, MapInfo info, MultiBoard multiBoard)
helpBox.Text = info.help.Replace(@"\n", "\r\n");
if (info.timeMob != null)
{
MapInfo.TimeMob tMob = (MapInfo.TimeMob)info.timeMob;
TimeMob tMob = (TimeMob)info.timeMob;
summonMobEnable.Checked = true;
LoadOptionalInt(tMob.startHour, timedMobStart, timedMobEnable);
LoadOptionalInt(tMob.endHour, timedMobEnd, timedMobEnable);
Expand All @@ -144,7 +145,7 @@ public InfoEditor(Board board, MapInfo info, MultiBoard multiBoard)
}
if (info.autoLieDetector != null)
{
MapInfo.AutoLieDetector ald = (MapInfo.AutoLieDetector)info.autoLieDetector;
AutoLieDetector ald = (AutoLieDetector)info.autoLieDetector;
autoLieDetectorEnable.Checked = true;
autoLieStart.Value = ald.startHour;
autoLieEnd.Value = ald.endHour;
Expand Down Expand Up @@ -341,13 +342,13 @@ protected override void okButton_Click(object sender, EventArgs e)

if (helpEnable.Checked) info.help = helpBox.Text.Replace("\r\n", @"\n");
if (summonMobEnable.Checked)
info.timeMob = new MapInfo.TimeMob(
info.timeMob = new TimeMob(
GetOptionalInt(timedMobStart, timedMobEnable),
GetOptionalInt(timedMobEnd, timedMobEnable),
(int)timedMobId.Value,
timedMobMessage.Text.Replace("\r\n", @"\n"));
if (autoLieDetectorEnable.Checked)
info.autoLieDetector = new MapInfo.AutoLieDetector(
info.autoLieDetector = new AutoLieDetector(
(int)autoLieStart.Value,
(int)autoLieEnd.Value,
(int)autoLieInterval.Value,
Expand Down
4 changes: 2 additions & 2 deletions HaCreator/MapEditor/Board.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public class Board
private int _vScroll = 0;
private int _mag = 16;
private UndoRedoManager undoRedoMan;
ItemTypes visibleTypes;
ItemTypes editedTypes;
private ItemTypes visibleTypes;
private ItemTypes editedTypes;
private bool loading = false;
private VRRectangle vrRect = null;
private MinimapRectangle mmRect = null;
Expand Down
28 changes: 28 additions & 0 deletions HaCreator/MapEditor/HaCreatorStateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ public HaCreatorStateManager(MultiBoard multiBoard, HaRibbon ribbon, System.Wind
this.ribbon.RibbonKeyDown += multiBoard.DxContainer_KeyDown;
this.ribbon.MapPhysicsClicked += Ribbon_EditMapPhysicsClicked;

// Debug
this.ribbon.ShowMapPropertiesClicked += Ribbon_ShowMapPropertiesClicked;
//

this.tabs.SelectionChanged += Tabs_SelectionChanged;

this.multiBoard.OnBringToFrontClicked += MultiBoard_OnBringToFrontClicked;
Expand Down Expand Up @@ -486,6 +490,30 @@ private void Tabs_SelectionChanged(object sender, System.Windows.Controls.Select
}
#endregion

#region Ribbon Debug Handlers
/// <summary>
/// Show map '/info' handlers
/// </summary>
private void Ribbon_ShowMapPropertiesClicked()
{
if (multiBoard.SelectedBoard == null)
return;
List<WzImageProperty> unsupportedProp = multiBoard.SelectedBoard.MapInfo.unsupportedInfoProperties;

StringBuilder sb = new StringBuilder();
int i = 1;
foreach (WzImageProperty imgProp in unsupportedProp)
{
sb.Append(i).Append(": ").Append(imgProp.Name).Append(", val: ").Append(imgProp.WzValue.ToString()).Append(Environment.NewLine);
i++;
}
sb.Append(Environment.NewLine).Append("Fix it under MapInfo.cs");

MessageBox.Show(sb.ToString(), "List of unsupported properties.");
}
#endregion


#region Ribbon Handlers
private string lastSaveLoc = null;

Expand Down
2 changes: 2 additions & 0 deletions MapleLib/MapleLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@
<Compile Include="WzLib\WzStructure\Data\MapConstants.cs" />
<Compile Include="WzLib\WzStructure\Data\FieldType.cs" />
<Compile Include="WzLib\WzStructure\Data\ItemTypes.cs" />
<Compile Include="WzLib\WzStructure\Data\MapStructure\AutoLieDetector.cs" />
<Compile Include="WzLib\WzStructure\Data\MapStructure\TimeMob.cs" />
<Compile Include="WzLib\WzStructure\Data\MapType.cs" />
<Compile Include="WzLib\WzStructure\Data\PortalType.cs" />
<Compile Include="WzLib\WzStructure\Data\FieldLimitType.cs" />
Expand Down
21 changes: 21 additions & 0 deletions MapleLib/WzLib/WzStructure/Data/MapStructure/AutoLieDetector.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MapleLib.WzLib.WzStructure.Data.MapStructure
{
public class AutoLieDetector
{
public int startHour, endHour, interval, prop; //interval in mins, prop default = 80

public AutoLieDetector(int startHour, int endHour, int interval, int prop)
{
this.startHour = startHour;
this.endHour = endHour;
this.interval = interval;
this.prop = prop;
}
}
}
23 changes: 23 additions & 0 deletions MapleLib/WzLib/WzStructure/Data/MapStructure/TimeMob.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MapleLib.WzLib.WzStructure.Data.MapStructure
{
public struct TimeMob
{
public int? startHour, endHour;
public int id;
public string message;

public TimeMob(int? startHour, int? endHour, int id, string message)
{
this.startHour = startHour;
this.endHour = endHour;
this.id = id;
this.message = message;
}
}
}
Loading

0 comments on commit b9c813b

Please sign in to comment.