Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
PunishedPineapple committed May 18, 2022
1 parent b16322b commit 3ad2e28
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions WaymarkPresetPlugin/UI/Window_Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public Window_Map( PluginUI UI, DalamudPluginInterface pluginInterface, DataMana
// Try to read in the view state data.
try
{
string viewStateDataFilePath = Path.Join( mPluginInterface.GetPluginConfigDirectory(), $"\\MapViewStateData_v1.json" );
string viewStateDataFilePath = Path.Join( mPluginInterface.GetPluginConfigDirectory(), mMapViewStateDataFileName_v1 );
string jsonStr = File.ReadAllText( viewStateDataFilePath );
var viewData = JsonConvert.DeserializeObject<Dictionary<uint, MapViewState>>( jsonStr );
if( viewData != null ) MapViewStateData = viewData;
}
catch( Exception e )
{
PluginLog.LogWarning( $"Unable to load map view state data: {e}" );
PluginLog.LogWarning( $"Unable to load map view state data:\r\n{e}" );
}
}

Expand All @@ -50,12 +50,12 @@ public void Dispose()
try
{
string jsonStr = JsonConvert.SerializeObject( MapViewStateData, Formatting.Indented );
string viewStateDataFilePath = Path.Join( mPluginInterface.GetPluginConfigDirectory(), $"\\MapViewStateData_v1.json" );
string viewStateDataFilePath = Path.Join( mPluginInterface.GetPluginConfigDirectory(), mMapViewStateDataFileName_v1 );
File.WriteAllText( viewStateDataFilePath, jsonStr );
}
catch( Exception e )
{
PluginLog.LogWarning( $"Unable to save map view state data: {e}" );
PluginLog.LogWarning( $"Unable to save map view state data:\r\n{e}" );
}

// Try to do this nicely for a moment, but then just brute force it to clean up as much as we can.
Expand Down Expand Up @@ -440,7 +440,7 @@ private float GetDefaultMapZoom( float mapScaleFactor )
public void ClearAllMapViewStateData()
{
MapViewStateData.Clear();
string viewStateDataFilePath = Path.Join( mPluginInterface.GetPluginConfigDirectory(), $"\\MapViewStateData_v1.json" );
string viewStateDataFilePath = Path.Join( mPluginInterface.GetPluginConfigDirectory(), mMapViewStateDataFileName_v1 );
if( File.Exists( viewStateDataFilePath ) )
{
File.Delete( viewStateDataFilePath );
Expand All @@ -465,5 +465,7 @@ public bool WindowVisible
private int CapturedWaymarkIndex { get; set; } = -1;
private Vector2 CapturedWaymarkOffset { get; set; } = new( 0, 0 );
private static readonly Vector2 mWaymarkMapIconHalfSize_Px = new( 15, 15 );

private const string mMapViewStateDataFileName_v1 = "MapViewStateData_v1.json";
}
}

0 comments on commit 3ad2e28

Please sign in to comment.