Skip to content

Commit

Permalink
Event editor no longer crashes on flag enums, map editor now also cha…
Browse files Browse the repository at this point in the history
…nges map flags based on check boxes, text importer now correctly adds a text entry for all maps even if empty
  • Loading branch information
Pyrdacor committed Sep 7, 2021
1 parent aa7c4b7 commit e6ccfec
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
<RepositoryUrl>https://github.com/Pyrdacor/Ambermoon</RepositoryUrl>
<RepositoryType>Github</RepositoryType>
<PackageTags>Ambermoon ADF Extract File Legacy Amiga Disk</PackageTags>
<Version>1.0.7</Version>
<Version>1.0.8</Version>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64</RuntimeIdentifiers>
<Configurations>Debug;Release;ReleaseLinux</Configurations>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.0.1" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.0.2" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion AmbermoonTools/AmbermoonEditor/AmbermoonEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<ItemGroup>
<PackageReference Include="Ambermoon.Data.Common" Version="10.0.3" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.0.1" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.0.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Authors>Robert Schneckenhaus</Authors>
<Description>Command line tool to edit map or NPC events.</Description>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64</RuntimeIdentifiers>
<Version>1.0.7</Version>
<Version>1.0.8</Version>
<PackageProjectUrl>https://github.com/Pyrdacor/Ambermoon</PackageProjectUrl>
<RepositoryUrl>https://github.com/Pyrdacor/Ambermoon</RepositoryUrl>
<RepositoryType>Github</RepositoryType>
Expand All @@ -16,7 +16,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.0.1" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.0.2" />
</ItemGroup>

</Project>
10 changes: 9 additions & 1 deletion AmbermoonTools/AmbermoonEventEditor/EventDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;

namespace AmbermoonEventEditor
{
Expand Down Expand Up @@ -126,7 +127,14 @@ public override bool Check(ushort input)
return System.Enum.GetValues(typeof(TEnum)).OfType<TEnum>().Select(e => (ushort)Convert.ChangeType(e, typeof(ushort))).Contains(input);
}

public override string DefaultValueText => ((TEnum)(object)(int)DefaultValue).ToString();
public override string DefaultValueText
{
get
{
int value = DefaultValue;
return Unsafe.As<int, TEnum>(ref value).ToString();
}
}
}

// Shortcut for description creation -> Use.Byte(...) etc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<Configurations>Debug;Release;ReleaseLinux</Configurations>
<Version>1.0.8</Version>
<Authors>Robert Schneckenhaus</Authors>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -24,7 +26,7 @@

<ItemGroup>
<PackageReference Include="Ambermoon.Data.Common" Version="10.0.3" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.0.1" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.0.2" />
<PackageReference Include="NAudio" Version="2.0.1" />
<PackageReference Include="SonicArranger" Version="1.0.7" />
</ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions AmbermoonTools/AmbermoonMapEditor2D/MapEditorForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions AmbermoonTools/AmbermoonMapEditor2D/MapEditorForm.Impl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ enum Tool
bool saveIntoGameData = false;
string saveFileName = null;
bool showEvents = false;
bool mapLoading = false;

History history = new History();
Map map;
Expand Down Expand Up @@ -149,6 +150,7 @@ void InitializeMap(Map map)
unsavedChanges = false;
history.Clear();
this.map = map;
mapLoading = true;

numericUpDownWidth.Value = map.Width;
numericUpDownHeight.Value = map.Height;
Expand Down Expand Up @@ -181,6 +183,8 @@ void InitializeMap(Map map)

MapSizeChanged();
TilesetChanged();

mapLoading = false;
}

void ToggleMusic()
Expand Down Expand Up @@ -267,6 +271,34 @@ void MapSizeChanged()
panelMap.Refresh();
}

void UpdateMapFlags()
{
if (mapLoading)
return;

map.Flags &= MapFlags.Unknown2; // keep this unknown flag if present

if (radioButtonIndoor.Checked)
map.Flags |= MapFlags.Indoor;
else if (radioButtonOutdoor.Checked)
map.Flags |= MapFlags.Outdoor;
else if (radioButtonDungeon.Checked)
map.Flags |= MapFlags.Dungeon;

if (checkBoxMagic.Checked)
map.Flags |= MapFlags.CanUseMagic;
if (checkBoxResting.Checked)
map.Flags |= MapFlags.CanRest;
if (checkBoxUnknown1.Checked)
map.Flags |= MapFlags.Unknown1;
if (checkBoxTravelGraphics.Checked)
map.Flags |= MapFlags.StationaryGraphics;
if (checkBoxNoSleepUntilDawn.Checked)
map.Flags |= MapFlags.NoSleepUntilDawn;
if (checkBoxWorldSurface.Checked)
map.Flags |= MapFlags.WorldSurface;
}

void MapTypeChanged()
{
if (radioButtonIndoor.Checked || radioButtonDungeon.Checked)
Expand All @@ -278,6 +310,8 @@ void MapTypeChanged()
{
checkBoxWorldSurface.Enabled = true;
}

UpdateMapFlags();
}

void TilesetChanged()
Expand Down
24 changes: 24 additions & 0 deletions AmbermoonTools/AmbermoonMapEditor2D/MapEditorForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ private void checkBoxWorldSurface_CheckedChanged(object sender, EventArgs e)

checkBoxUnknown1.Checked = checkBoxTravelGraphics.Checked = checkBoxWorldSurface.Checked;
groupBoxCharacters.Enabled = !checkBoxWorldSurface.Checked;

UpdateMapFlags();
}

private void comboBoxMusic_SelectedIndexChanged(object sender, EventArgs e)
Expand All @@ -138,6 +140,8 @@ private void checkBoxResting_CheckedChanged(object sender, EventArgs e)
}

checkBoxNoSleepUntilDawn.Enabled = checkBoxResting.Checked;

UpdateMapFlags();
}

private void radioButtonIndoor_CheckedChanged(object sender, EventArgs e)
Expand Down Expand Up @@ -808,5 +812,25 @@ private void panelMap_MouseDoubleClick(object sender, MouseEventArgs e)
}
}
}

private void checkBoxTravelGraphics_CheckedChanged(object sender, EventArgs e)
{
UpdateMapFlags();
}

private void checkBoxMagic_CheckedChanged(object sender, EventArgs e)
{
UpdateMapFlags();
}

private void checkBoxNoSleepUntilDawn_CheckedChanged(object sender, EventArgs e)
{
UpdateMapFlags();
}

private void checkBoxUnknown1_CheckedChanged(object sender, EventArgs e)
{
UpdateMapFlags();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<Authors>Robert Schneckenhaus</Authors>
<Description>Command line tool to show and edit monster values of legacy Ambermoon game data.</Description>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64</RuntimeIdentifiers>
<Version>1.0.7</Version>
<Version>1.0.8</Version>
<Configurations>Debug;Release;ReleaseLinux</Configurations>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.0.1" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.0.2" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions AmbermoonTools/AmbermoonPack/AmbermoonPack.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<RepositoryType>Github</RepositoryType>
<PackageTags>Ambermoon Packer File Legacy Amiga Compression Encryption</PackageTags>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64</RuntimeIdentifiers>
<Version>1.0.7</Version>
<Version>1.0.8</Version>
<Configurations>Debug;Release;ReleaseLinux</Configurations>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.0.1" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.0.2" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions AmbermoonTools/AmbermoonTextImport/AmbermoonTextImport.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<Authors>Robert Schneckenhaus</Authors>
<Description>Command line tool to export and import texts from/into legacy Ambermoon game data.</Description>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64</RuntimeIdentifiers>
<Version>1.0.7</Version>
<Version>1.0.8</Version>
<Configurations>Debug;Release;ReleaseLinux</Configurations>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.0.1" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.0.2" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion AmbermoonTools/AmbermoonTextImport/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ static void Import(string gameDataPath, string file, string inputPath, List<Opti

try
{
Ambermoon.Data.Legacy.Serialization.FileWriter.WriteContainer(containerWriter, data, Ambermoon.Data.Legacy.Serialization.FileType.AMNP);
Ambermoon.Data.Legacy.Serialization.FileWriter.WriteContainer(containerWriter, data, Ambermoon.Data.Legacy.Serialization.FileType.AMNP, 528);

using var stream = File.Create(outPath);
containerWriter.CopyTo(stream);
Expand Down

0 comments on commit e6ccfec

Please sign in to comment.