Skip to content

Commit 7d8885a

Browse files
author
FluffyFishGames
committed
- Fixed an error which corrupted the names due to a wrong offset
- Changed import behaviour and remove buttons like Save until action is finished - The tool now adds file extensions on export is they are missing - The tool shows which file types are supported in file dialogue now - Mac can select any file for *.anch and *.acnl imports as there is a weird bug with tinyfiledialogs where 4 letter extensions wont work with Mac.
1 parent 6889e9e commit 7d8885a

File tree

14 files changed

+146
-77
lines changed

14 files changed

+146
-77
lines changed

Assembly-CSharp-Editor.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,10 @@
415415
<HintPath>C:\Program Files\Unity\Hub\Editor\2022.3.62f3\Editor\Data\PlaybackEngines\LinuxStandaloneSupport\UnityEditor.LinuxStandalone.Extensions.dll</HintPath>
416416
<Private>False</Private>
417417
</Reference>
418+
<Reference Include="System.Runtime.CompilerServices.Unsafe">
419+
<HintPath>Assets\Plugins\ImageSharp\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
420+
<Private>False</Private>
421+
</Reference>
418422
<Reference Include="Newtonsoft.Json">
419423
<HintPath>Library\PackageCache\com.unity.nuget.newtonsoft-json@3.2.2\Runtime\Newtonsoft.Json.dll</HintPath>
420424
<Private>False</Private>

Assets/Plugins/Bitmap/TextureBitmap.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,11 @@ public void Save(string filename)
895895
else if (filename.ToLowerInvariant().EndsWith(".webp"))
896896
Save(filename, ImageFormat.GIF);
897897
else
898-
Save(filename, ImageFormat.PNG);
898+
{
899+
if (!filename.EndsWith(".png"))
900+
filename += ".png";
901+
Save(filename, ImageFormat.PNG);
902+
}
899903
}
900904

901905
public void Save(string filename, ImageFormat format)

Assets/Plugins/Savegame/BinaryData.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,17 @@ public long ReadS64(int offset)
6464
public string ReadString(int offset, int size)
6565
{
6666
if (offset < 0 || offset + size * 2 > Size) throw new IndexOutOfRangeException(offset + " is outside of binary data.");
67-
return System.Text.Encoding.Unicode.GetString(ReadBytes(offset, size * 2)).Trim('\0');
67+
var bytes = ReadBytes(offset, size * 2);
68+
var len = size * 2;
69+
for (var i = 0; i < bytes.Length - 1; i+=2)
70+
{
71+
if (bytes[i] == 0x00 && bytes[i + 1] == 0x00)
72+
{
73+
len = i;
74+
break;
75+
}
76+
}
77+
return System.Text.Encoding.Unicode.GetString(bytes, 0, len).Trim('\0');
6878
//return Marshal.PtrToStringUni(new IntPtr(Data + offset), size * 2).Trim('\0');
6979
/*byte[] byteData = new byte[size * 2];
7080
fixed (byte* bytePtr = &byteData[0])

Assets/Plugins/Savegame/Data/ProDesignPattern.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public unsafe class ProDesignPattern : DesignPattern
1515
public Usage _UsageFlag;
1616

1717
public const int NameOffset = 0x10;
18-
public const int UsageOffset = 0x30;
18+
public const int UsageOffset = 0x70;
1919
public const int PersonalIDOffset = 0x38;
2020
public const int PaletteOffset = 0x78;
2121
public const int ImageOffset = 0xA5;

Assets/Plugins/Savegame/Data/SimpleDesignPattern.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public unsafe class SimpleDesignPattern : DesignPattern
2323
public override Usage UsageFlag { get => _UsageFlag; set => _UsageFlag = value; }
2424

2525
public const int NameOffset = 0x10;
26-
public const int UsageOffset = 0x30;
26+
public const int UsageOffset = 0x70;
2727
public const int PersonalIDOffset = 0x38;
2828
public const int PaletteOffset = 0x78;
2929
public const int ImageOffset = 0xA5;

Assets/Scenes/SampleScene.unity

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8887,8 +8887,8 @@ MonoBehaviour:
88878887
serializedVersion: 2
88888888
x: 0
88898889
y: 0
8890-
width: 4.3220754
8891-
height: 1.2313598
8890+
width: 4.2916703
8891+
height: 1.2226986
88928892
--- !u!1 &199922433
88938893
GameObject:
88948894
m_ObjectHideFlags: 0
@@ -11044,7 +11044,7 @@ RectTransform:
1104411044
m_Father: {fileID: 2117182710}
1104511045
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
1104611046
m_AnchorMin: {x: 0, y: 0}
11047-
m_AnchorMax: {x: 1, y: 1}
11047+
m_AnchorMax: {x: 0, y: 0}
1104811048
m_AnchoredPosition: {x: 0, y: 0}
1104911049
m_SizeDelta: {x: 0, y: 20}
1105011050
m_Pivot: {x: 0.5, y: 0.5}
@@ -21516,7 +21516,7 @@ RectTransform:
2151621516
m_AnchorMin: {x: 0, y: 1}
2151721517
m_AnchorMax: {x: 0, y: 1}
2151821518
m_AnchoredPosition: {x: 1091, y: -81}
21519-
m_SizeDelta: {x: 463, y: 85}
21519+
m_SizeDelta: {x: 463, y: 0}
2152021520
m_Pivot: {x: 0.5, y: 0.5}
2152121521
--- !u!114 &481257581
2152221522
MonoBehaviour:
@@ -25832,8 +25832,8 @@ MonoBehaviour:
2583225832
serializedVersion: 2
2583325833
x: 0
2583425834
y: 0
25835-
width: 4.8007646
25836-
height: 1.2313598
25835+
width: 4.7669964
25836+
height: 1.2226986
2583725837
--- !u!1 &583112240
2583825838
GameObject:
2583925839
m_ObjectHideFlags: 0
@@ -44761,7 +44761,7 @@ MonoBehaviour:
4476144761
m_TargetGraphic: {fileID: 248820484}
4476244762
m_HandleRect: {fileID: 248820483}
4476344763
m_Direction: 2
44764-
m_Value: 0
44764+
m_Value: 1
4476544765
m_Size: 1
4476644766
m_NumberOfSteps: 8
4476744767
m_OnValueChanged:
@@ -46547,8 +46547,8 @@ MonoBehaviour:
4654746547
serializedVersion: 2
4654846548
x: 0
4654946549
y: 0
46550-
width: 4.8007646
46551-
height: 1.2313598
46550+
width: 4.7669964
46551+
height: 1.2226986
4655246552
--- !u!1 &1069338936
4655346553
GameObject:
4655446554
m_ObjectHideFlags: 0
@@ -55015,7 +55015,7 @@ GameObject:
5501555015
m_Component:
5501655016
- component: {fileID: 1236777854}
5501755017
m_Layer: 5
55018-
m_Name: CloneSwapButtons
55018+
m_Name: CancelButton
5501955019
m_TagString: Untagged
5502055020
m_Icon: {fileID: 0}
5502155021
m_NavMeshLayer: 0
@@ -71124,7 +71124,7 @@ GameObject:
7112471124
m_Icon: {fileID: 0}
7112571125
m_NavMeshLayer: 0
7112671126
m_StaticEditorFlags: 0
71127-
m_IsActive: 0
71127+
m_IsActive: 1
7112871128
--- !u!224 &1584672643
7112971129
RectTransform:
7113071130
m_ObjectHideFlags: 0
@@ -72963,7 +72963,7 @@ RectTransform:
7296372963
m_AnchorMin: {x: 0, y: 1}
7296472964
m_AnchorMax: {x: 1, y: 1}
7296572965
m_AnchoredPosition: {x: 0, y: 0}
72966-
m_SizeDelta: {x: 0, y: 5}
72966+
m_SizeDelta: {x: 0, y: 0}
7296772967
m_Pivot: {x: 0, y: 1}
7296872968
--- !u!114 &1608408937
7296972969
MonoBehaviour:
@@ -94204,8 +94204,8 @@ MonoBehaviour:
9420494204
serializedVersion: 2
9420594205
x: 0
9420694206
y: 0
94207-
width: 5.9139733
94208-
height: 1.2313598
94207+
width: 5.8723774
94208+
height: 1.2226986
9420994209
--- !u!222 &2049374030
9421094210
CanvasRenderer:
9421194211
m_ObjectHideFlags: 0

Assets/Scripts/Controller.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ public void SwitchToMainMenu()
781781
Tutorial.gameObject.SetActive(false);
782782
if (CurrentState == State.PatternSelection)
783783
PatternSelector.Close();
784+
PatternSelector.Close();
784785
CurrentState = State.MainMenu;
785786
MainMenu.Open();
786787
}

Assets/Scripts/MainMenu.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void Start()
101101
{
102102
if (Controller.Instance.CurrentState == Controller.State.MainMenu)
103103
{
104-
var path = TinyFileDialogs.OpenFileDialog("Open designs", "", new List<string>() { "*.designs" }, "Design file", false);
104+
var path = TinyFileDialogs.OpenFileDialog("Open designs", "", new List<string>() { "*.designs" }, "Designs (*.designs)", false);
105105
if (path != null)
106106
{
107107
LoadDesigns(path);
@@ -116,7 +116,7 @@ void Start()
116116
{
117117
if (Controller.Instance.CurrentState == Controller.State.MainMenu)
118118
{
119-
var path = TinyFileDialogs.SaveFileDialog("Open designs", "", new List<string>() { "*.designs" }, "Design file");
119+
var path = TinyFileDialogs.SaveFileDialog("Open designs", "", new List<string>() { "*.designs" }, "Designs (*.designs)");
120120
if (path != null)
121121
{
122122
if (!path.ToLowerInvariant().EndsWith(".designs"))

Assets/Scripts/Operations/ImportOperation.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using System.Drawing;
2+
using System.Runtime.InteropServices;
3+
using System.Security;
24

35
public class ImportOperation : IOperation, ISelectPatternOperation, IBackToPatternExchangeOperation
46
{

Assets/Scripts/PatternExchange/PatternExchange.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ void Start()
316316
};
317317
CancelButton.OnClick = () =>
318318
{
319-
this.IsOpen = false;
320319
Controller.Instance.SwitchToPatternMenu();
321320
};
322321
ImportButton.OnClick = () =>

0 commit comments

Comments
 (0)