Skip to content

Commit

Permalink
Merge pull request #11 from cooolbros/main
Browse files Browse the repository at this point in the history
core
  • Loading branch information
cooolbros authored Nov 13, 2024
2 parents 53cb2c7 + 6a285f5 commit 26e8c29
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 18 deletions.
56 changes: 40 additions & 16 deletions src/HUDAnimations/HUDAnimationsSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,35 +211,36 @@ bool ReadBool()
Duration = ReadNumber(),
Conditional = ReadConditional()
},
"runevent" => new RunEvent
"firecommand" => new FireCommand
{
Event = ReadString(),
Delay = ReadNumber(),
Command = ReadString(),
Conditional = ReadConditional()
},
"stopevent" => new StopEvent
"playsound" => new PlaySound
{
Event = ReadString(),
Delay = ReadNumber(),
Sound = ReadString(),
Conditional = ReadConditional()
},
"setvisible" => new SetVisible
"runevent" => new RunEvent
{
Element = ReadString(),
Visible = ReadBool(),
Event = ReadString(),
Delay = ReadNumber(),
Conditional = ReadConditional()
},
"firecommand" => new FireCommand
"runeventchild" => new RunEventChild
{
Element = ReadString(),
Event = ReadString(),
Delay = ReadNumber(),
Command = ReadString(),
Conditional = ReadConditional()
},
"runeventchild" => new RunEventChild
"setfont" => new SetFont
{
Element = ReadString(),
Event = ReadString(),
Property = ReadString(),
Font = ReadString(),
Delay = ReadNumber(),
Conditional = ReadConditional()
},
Expand All @@ -250,15 +251,26 @@ bool ReadBool()
Delay = ReadNumber(),
Conditional = ReadConditional()
},
"playsound" => new PlaySound
"setstring" => new SetString
{
Element = ReadString(),
Property = ReadString(),
String = ReadString(),
Delay = ReadNumber(),
Conditional = ReadConditional(),
},
"settexture" => new SetTexture
{
Element = ReadString(),
Property = ReadString(),
Texture = ReadString(),
Delay = ReadNumber(),
Sound = ReadString(),
Conditional = ReadConditional()
Conditional = ReadConditional(),
},
"stoppanelanimations" => new StopPanelAnimations
"setvisible" => new SetVisible
{
Element = ReadString(),
Visible = ReadBool(),
Delay = ReadNumber(),
Conditional = ReadConditional()
},
Expand All @@ -269,9 +281,21 @@ bool ReadBool()
Delay = ReadNumber(),
Conditional = ReadConditional()
},
"stopevent" => new StopEvent
{
Event = ReadString(),
Delay = ReadNumber(),
Conditional = ReadConditional()
},
"stoppanelanimations" => new StopPanelAnimations
{
Element = ReadString(),
Delay = ReadNumber(),
Conditional = ReadConditional()
},
string str => throw new VDFSyntaxException(
new VDFToken { Type = VDFTokenType.String, Value = str },
["animate"],
["Animate", "FireCommand", "PlaySound", "RunEvent", "RunEventChild", "SetFont", "SetInputEnabled", "SetString", "SetTexture", "SetVisible", "StopAnimation", "StopEvent", "StopPanelAnimations"],
tokeniser.Index,
tokeniser.Line,
tokeniser.Character
Expand Down
17 changes: 17 additions & 0 deletions src/HUDAnimations/Models/Animations/SetFont.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;

namespace HUDAnimations.Models.Animations;

public class SetFont : HUDAnimationBase
{
public override string Type => nameof(SetFont);
public required string Element { get; init; }
public required string Property { get; init; }
public required string Font { get; init; }
public required float Delay { get; init; }

public override string ToString()
{
return $"{Type} {Print(Element)} {Print(Property)} {Print(Font)} {Print(Delay)}" + PrintConditional();
}
}
17 changes: 17 additions & 0 deletions src/HUDAnimations/Models/Animations/SetString.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;

namespace HUDAnimations.Models.Animations;

public class SetString : HUDAnimationBase
{
public override string Type => nameof(SetString);
public required string Element { get; init; }
public required string Property { get; init; }
public required string String { get; init; }
public required float Delay { get; init; }

public override string ToString()
{
return $"{Type} {Print(Element)} {Print(Property)} {Print(String)} {Print(Delay)}" + PrintConditional();
}
}
17 changes: 17 additions & 0 deletions src/HUDAnimations/Models/Animations/SetTexture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;

namespace HUDAnimations.Models.Animations;

public class SetTexture : HUDAnimationBase
{
public override string Type => nameof(SetTexture);
public required string Element { get; init; }
public required string Property { get; init; }
public required string Texture { get; init; }
public required float Delay { get; init; }

public override string ToString()
{
return $"{Type} {Print(Element)} {Print(Property)} {Print(Texture)} {Print(Delay)}" + PrintConditional();
}
}
9 changes: 9 additions & 0 deletions src/HUDAnimationsTests/HUDAnimationsSerializerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ namespace HUDAnimations.Tests;
[TestClass()]
public class HUDAnimationsSerializerTests
{
[TestMethod()]
public void DeserializeTest()
{
foreach (string path in Directory.EnumerateFiles("HUDAnimationsSerializerTests/scripts"))
{
HUDAnimationsSerializer.Deserialize(File.ReadAllText(path));
}
}

[TestMethod()]
public void SerializeTest()
{
Expand Down
3 changes: 3 additions & 0 deletions src/HUDMerger.Core/Models/HUD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,9 @@ void Add(string eventName)
case RunEventChild runEvent:
Add(runEvent.Event);
break;
case SetFont setFont:
dependencies.ClientScheme.Fonts.Add(setFont.Font);
break;
case PlaySound playSound:
dependencies.Audio.Add($"sound\\{playSound.Sound}");
break;
Expand Down
20 changes: 20 additions & 0 deletions src/HUDMerger.Core/Resources/Panels.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,19 @@
]
}
},
{
"Name": "Demoman Pipes Label And Charge Meter",
"Main": "resource\\ui\\huddemomanpipes.res",
"Dependencies": {
"HUDLayout": [
"HudDemomanCharge",
"HudDemomanPipes"
]
},
"Files": [
"resource\\ui\\huddemomancharge.res"
]
},
{
"Name": "Engineer Build Menu",
"Main": "resource\\ui\\build_menu\\hudmenuengybuild.res",
Expand Down Expand Up @@ -450,6 +463,13 @@
"Name": "Map Loading",
"Main": "resource\\ui\\statsummary.res"
},
{
"Name": "MvM Currency",
"Main": "resource\\ui\\hudcurrencyaccount.res",
"Files": [
"resource\\ui\\mvminworldcurrency.res"
]
},
{
"Name": "MvM Upgrade Station",
"Main": "resource\\ui\\hudupgradepanel.res",
Expand Down
2 changes: 1 addition & 1 deletion src/HUDMerger/HUDMerger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<UseWPF>true</UseWPF>
<ApplicationIcon>Resources\favicon.ico</ApplicationIcon>
<Authors>Peter Wobcke</Authors>
<Version>2.0.1</Version>
<Version>2.0.2</Version>
<Nullable>Enable</Nullable>
</PropertyGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/HUDMerger/Views/AboutWindowView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</StackPanel.Resources>
<Image Source="/Resources/favicon.ico" Width="64" Height="64" Margin="0,0,0,10" />
<Label FontSize="28">HUD Merger</Label>
<Label FontSize="15">Version 2.0.1</Label>
<Label FontSize="15">Version 2.0.2</Label>
<Label FontSize="15">Revan</Label>
<WrapPanel HorizontalAlignment="Center" Margin="0,5,0,5" RenderOptions.BitmapScalingMode="Fant">
<Button Style="{StaticResource ImageButton}" Command="{Binding OpenGithubCommand}">
Expand Down

0 comments on commit 26e8c29

Please sign in to comment.