Skip to content

Commit

Permalink
Fixes, improvements, added all SA files
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrdacor committed Jun 1, 2022
1 parent 03a2bf9 commit a660036
Show file tree
Hide file tree
Showing 91 changed files with 167 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ambermoon.Data.Common" Version="10.4.0" />
<PackageReference Include="Ambermoon.Data.Common" Version="10.6.6" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;

Expand All @@ -8,6 +9,7 @@ public interface IEnumValueDescription
{
public object[] AllowedValues { get; }
public string[] AllowedValueNames { get; }
public Dictionary<int, string> AllowedEntries { get; }
public bool Flags { get; }
}

Expand All @@ -17,6 +19,7 @@ public class EnumValueDescription<TEnum> : ValueDescription, IEnumValueDescripti
public bool Flags { get; }
public string[] AllowedValueNames => AllowedEnumValues.Select(v => Enum.GetName(v)).ToArray();
public object[] AllowedValues => AllowedEnumValues.Select(v => (object)v).ToArray();
public Dictionary<int, string> AllowedEntries => AllowedEnumValues.ToDictionary(v => (int)(object)v, v => Enum.GetName(v));

public EnumValueDescription(string name, bool required, bool hidden, TEnum defaultValue, bool flags, bool word, TEnum[] allowedValues)
{
Expand Down
18 changes: 9 additions & 9 deletions AmbermoonTools/Ambermoon.Data.Descriptions/EventDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,22 +214,22 @@ public static string ToString(Event @event, int identation, string subIdentation
Use.Word("CorrectAnswerDictionaryIndex1", true),
Use.Word("CorrectAnswerDictionaryIndex2", false)
)},
{ EventType.Award, new EventDescription
{ EventType.Reward, new EventDescription
(
true, true, true, true, false,
Use.Enum<AwardEvent.AwardType>("TypeOfAward", true),
Use.Enum("Operation", true, AwardEvent.AwardOperation.Increase),
Use.Enum<RewardEvent.RewardType>("TypeOfReward", true),
Use.Enum("Operation", true, RewardEvent.RewardOperation.Increase),
Use.Bool("Random", true),
Use.Enum("Target", true, AwardEvent.AwardTarget.ActivePlayer),
Use.Enum("Target", true, RewardEvent.RewardTarget.ActivePlayer),
Use.HiddenByte(),
Use.Word("AwardTypeValue", false),
Use.Word("RewardTypeValue", false),
Use.Word("Value", false)
)},
{ EventType.ChangeTile, new EventDescription
(
true, true, true, true, false,
Use.Byte("X", true, 50),
Use.Byte("Y", true, 50),
Use.Byte("X", true, 200),
Use.Byte("Y", true, 200),
Use.HiddenByte(),
Use.HiddenByte(),
Use.HiddenByte(),
Expand Down Expand Up @@ -371,8 +371,8 @@ public static string ToString(Event @event, int identation, string subIdentation
{ EventType.Spawn, new EventDescription
(
true, true, true, true, false,
Use.Byte("X", true, 50),
Use.Byte("Y", true, 50),
Use.Byte("X", true, 200),
Use.Byte("Y", true, 200),
Use.Enum("TravelType", true, TravelType.Horse,
TravelType.Horse, TravelType.Raft, TravelType.Ship, TravelType.SandLizard, TravelType.SandShip),
Use.HiddenByte(),
Expand Down
8 changes: 4 additions & 4 deletions AmbermoonTools/Ambermoon.Data.Descriptions/ItemDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ static ItemDescription()
Use.SByte("SpellPoints", false),
Use.Enum<Attribute>("Attribute", false),
Use.SByte("AttributeValue", false),
Use.Enum<Ability>("Ability", false),
Use.SByte("AbilityValue", false),
Use.Enum<Skill>("Skill", false),
Use.SByte("SkillValue", false),
Use.SByte("Defense", false),
Use.SByte("Damage", false),
Use.Enum<AmmunitionType>("AmmunitionType", false),
Use.Enum<AmmunitionType>("UsedAmmunitionType", false),
Use.Enum<Ability>("SkillPenalty1", false),
Use.Enum<Ability>("SkillPenalty2", false),
Use.Enum<Skill>("SkillPenalty1", false),
Use.Enum<Skill>("SkillPenalty2", false),
Use.Byte("SkillPenalty1Value", false),
Use.Byte("SkillPenalty2Value", false),
Use.Byte("SpecialValue", false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.4.0" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.6.8" />
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions AmbermoonTools/AmbermoonCharEditor/AmbermoonCharEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
<TrimmableAssembly Include="Avalonia.Themes.Default" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.5.0" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.6.8" />
<PackageReference Include="AutoMapper" Version="11.0.1" />
<PackageReference Include="Avalonia" Version="0.10.13" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.13" />
<PackageReference Include="Avalonia" Version="0.10.14" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.14" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.13" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.13" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.14" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.14" />
<PackageReference Include="Material.Avalonia" Version="3.0.0-rc0.87-nightly" />
<PackageReference Include="XamlNameReferenceGenerator" Version="1.3.4" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.4.0" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.6.8" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions AmbermoonTools/AmbermoonEditor/AmbermoonEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ambermoon.Data.Common" Version="10.4.0" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.4.0" />
<PackageReference Include="Ambermoon.Data.Common" Version="10.6.6" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.6.8" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.4.0" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.6.8" />
</ItemGroup>

<ItemGroup>
Expand Down
74 changes: 67 additions & 7 deletions AmbermoonTools/AmbermoonEventEditor/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ static void AddEvent(List<Event> eventList, List<Event> events, bool map, int in

bool newChain = false;
int? connectTo = null;
bool prepend = false;

if (eventDescription.AllowOnlyAsFirst)
{
Expand All @@ -966,11 +967,11 @@ static void AddEvent(List<Event> eventList, List<Event> events, bool map, int in
{
Console.WriteLine();
Console.WriteLine("How should the new event be connected?");
var option = ReadOption(0, "Disconnected event", "New event chain", "Connect to event");
var option = ReadOption(0, "Disconnected event", "New event chain", "Connect to event", "Prepend to event");

if (option.Value == 1)
newChain = true;
else if (option.Value == 2)
else if (option.Value == 2) // append to event
{
Console.WriteLine();
Console.WriteLine("Connect to which event");
Expand All @@ -986,6 +987,24 @@ static void AddEvent(List<Event> eventList, List<Event> events, bool map, int in
connectTo = index;
}
}
else if (option.Value == 3) // prepend to event
{
Console.WriteLine();
Console.WriteLine("Prepend to which event");
var filteredEvents = events.Where(e => !EventDescriptions.Events[e.Type].AllowOnlyAsFirst).ToList();
ListEvents(filteredEvents, 0, e => events.IndexOf(e));
var index = ReadInt(true);

if (index == null || !filteredEvents.Any(e => e.Index == index))
{
Console.WriteLine("Invalid event index. Creating a disconnected event instead.");
}
else
{
connectTo = index;
prepend = true;
}
}
}
else if (eventList.Count == 0)
{
Expand All @@ -995,9 +1014,14 @@ static void AddEvent(List<Event> eventList, List<Event> events, bool map, int in
{
Console.WriteLine();
Console.WriteLine("How should the new event be connected?");
var option = ReadOption(0, "Disconnected event", "Connect to event");

if (option.Value == 1)
List<Event> noChainStartEvents = events.Where(e => !eventList.Contains(e)).ToList();

var option = noChainStartEvents.Count != 0
? ReadOption(0, "Disconnected event", "Connect to event", "Prepend to event")
: ReadOption(0, "Disconnected event", "Connect to event"); ;

if (option.Value == 1) // append to event
{
Console.WriteLine();
Console.WriteLine("Connect to which event");
Expand All @@ -1013,6 +1037,23 @@ static void AddEvent(List<Event> eventList, List<Event> events, bool map, int in
connectTo = index;
}
}
else if (noChainStartEvents.Count != 0 && option.Value == 2) // prepend to event
{
Console.WriteLine();
Console.WriteLine("Prepend to which event");
ListEvents(noChainStartEvents, 0, e => events.IndexOf(e));
var index = ReadInt(true);

if (index == null || !noChainStartEvents.Any(e => e.Index == index))
{
Console.WriteLine("Invalid event index. Creating a disconnected event instead.");
}
else
{
connectTo = index;
prepend = true;
}
}
}
}

Expand Down Expand Up @@ -1046,6 +1087,12 @@ void WriteWord(ushort value)
{
if (value.Required)
{
if (value is IEnumValueDescription e)
{
Console.WriteLine("Possible values:");
e.AllowedEntries.ToList().ForEach(v => Console.WriteLine($" {v.Key,3}: {v.Value}"));
}

Console.Write($"> {value.Name}: ");
var input = ReadInt(value.ShowAsHex);

Expand Down Expand Up @@ -1097,9 +1144,22 @@ void WriteWord(ushort value)
}
else if (connectTo != null)
{
var prev = events[connectTo.Value];
@event.Next = prev.Next;
prev.Next = @event;
if (prepend)
{
var next = events[connectTo.Value];
@event.Next = next;

int chainIndex = eventList.IndexOf(next);

if (chainIndex != -1)
eventList[chainIndex] = @event;
}
else // append
{
var prev = events[connectTo.Value];
@event.Next = prev.Next;
prev.Next = @event;
}
}

Console.WriteLine($"Event {(fromEdit ? "changed" : "added")} successfully.");
Expand Down
5 changes: 2 additions & 3 deletions AmbermoonTools/AmbermoonItemEditor/AmbermoonItemEditor.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -14,11 +14,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.5.0" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.6.8" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\ambermoon.net\Ambermoon.net\Ambermoon.Data.Legacy\Ambermoon.Data.Legacy.csproj" />
<ProjectReference Include="..\Ambermoon.Data.Descriptions\Ambermoon.Data.Descriptions.csproj" />
</ItemGroup>

Expand Down
8 changes: 5 additions & 3 deletions AmbermoonTools/AmbermoonItemEditor/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,11 @@ static void Save(string sourcePath, ItemManager items1, ItemManager items2)
if (items1 is Items)
{
var temp = Path.GetTempFileName();
using var stream = File.Create(temp);
items1.Save(stream);
File.Move(temp, Path.Combine(sourcePath, "Objects.amb"), true);
{
using var stream = File.Create(temp);
items1.Save(stream);
}
File.Move(temp, Path.Combine(sourcePath, "001"), true);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.4.0" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.6.8" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.4.0" />
<PackageReference Include="NAudio" Version="2.0.1" />
<PackageReference Include="SonicArranger" Version="1.0.7" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.6.8" />
<PackageReference Include="NAudio" Version="2.1.0" />
<PackageReference Include="SonicArranger" Version="1.0.9" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion AmbermoonTools/AmbermoonMapEditor2D/MapEditorForm.Impl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void Initialize()
comboBoxMusic.Items.Add(song.Value);

// TODO: what if we add one later?
for (int i = 1; i <= 9; ++i)
for (int i = 1; i <= 10; ++i)
comboBoxTilesets.Items.Add($"Tileset {i}");

imageCache = new ImageCache(gameData);
Expand Down
4 changes: 2 additions & 2 deletions AmbermoonTools/AmbermoonMapEditor2D/MapEditorForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ private void panelMap_Paint(object sender, PaintEventArgs e)
break;

var tile = map.InitialTiles[x, y];
var backgroundTile = tile.BackTileIndex == 0 ? null : tile.BackTileIndex >= tileset.Tiles.Length ? null : tileset.Tiles[tile.BackTileIndex - 1];
var foregroundTile = tile.FrontTileIndex == 0 ? null : tile.FrontTileIndex >= tileset.Tiles.Length ? null : tileset.Tiles[tile.FrontTileIndex - 1];
var backgroundTile = tile.BackTileIndex == 0 ? null : tile.BackTileIndex > tileset.Tiles.Length ? null : tileset.Tiles[tile.BackTileIndex - 1];
var foregroundTile = tile.FrontTileIndex == 0 ? null : tile.FrontTileIndex > tileset.Tiles.Length ? null : tileset.Tiles[tile.FrontTileIndex - 1];
var rect = new Rectangle(drawX, drawY, tileSize + (tileSize / 16 - 1), tileSize + (tileSize / 16 - 1));

if (toolStripMenuItemShowBackLayer.Checked && backgroundTile != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.4.0" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.6.8" />
</ItemGroup>

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

<ItemGroup>
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.4.0" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.6.8" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.4.0" />
<PackageReference Include="Ambermoon.Data.Legacy" Version="10.6.8" />
</ItemGroup>

</Project>
8 changes: 0 additions & 8 deletions AmbermoonTools/AmbermoonTools.sln
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,6 @@ Global
{5AF70021-F1C0-4093-9476-C42FA13AA6C7}.Release|Any CPU.Build.0 = Release|Any CPU
{5AF70021-F1C0-4093-9476-C42FA13AA6C7}.ReleaseLinux|Any CPU.ActiveCfg = Release|Any CPU
{5AF70021-F1C0-4093-9476-C42FA13AA6C7}.ReleaseLinux|Any CPU.Build.0 = Release|Any CPU
{A32F8E6C-F873-412F-A71F-6E6F661592E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A32F8E6C-F873-412F-A71F-6E6F661592E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A32F8E6C-F873-412F-A71F-6E6F661592E7}.DebugAndroid|Any CPU.ActiveCfg = Debug|Any CPU
{A32F8E6C-F873-412F-A71F-6E6F661592E7}.DebugAndroid|Any CPU.Build.0 = Debug|Any CPU
{A32F8E6C-F873-412F-A71F-6E6F661592E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A32F8E6C-F873-412F-A71F-6E6F661592E7}.Release|Any CPU.Build.0 = Release|Any CPU
{A32F8E6C-F873-412F-A71F-6E6F661592E7}.ReleaseLinux|Any CPU.ActiveCfg = ReleaseLinux|Any CPU
{A32F8E6C-F873-412F-A71F-6E6F661592E7}.ReleaseLinux|Any CPU.Build.0 = ReleaseLinux|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Binary file removed Files/AmbermoonMusicSAModules.zip
Binary file not shown.
Loading

0 comments on commit a660036

Please sign in to comment.