Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Globals/StageProducer.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System;
using System.Threading.Tasks;
using FunkEngine;
using FunkEngine.Classes.MidiMaestro;
using Godot;
using GodotSteam;

/**
* <summary>StageProducer: Handles scene transitions and persistent gameplay data.</summary>
Expand Down Expand Up @@ -240,7 +239,7 @@ public override void _Input(InputEvent @event)
{
//Consume controller input, if window out of focus.
//This handles ui_input, other scenes need to consume their own.
if (!GetWindow().HasFocus())
if (ControlSettings.IsOutOfFocus(this))
{
GetViewport().SetInputAsHandled();
return;
Expand Down
99 changes: 99 additions & 0 deletions Globals/SteamWhisperer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
using Godot;
using GodotSteam;

public partial class SteamWhisperer : Node
{
private const uint AppId = 3647600;

public static bool IsOverlayActive = false;

private static int placedNotes = 0;

public override void _EnterTree()
{
OS.SetEnvironment("SteamAppId", AppId.ToString());
OS.SetEnvironment("SteamGameId", AppId.ToString());
}

public override void _ExitTree()
{
if (!Steam.IsSteamRunning())
return;
Steam.StoreStats();
GD.Print("SW: Steam shut down.");
}

public override void _Ready()
{
if (!Steam.SteamInit(AppId, true))
{
GD.PrintErr(
"SW: here was an error initializing Steam. No Steam features will be available."
);
return;
}

GD.Print("SW: Steam initialized successfully.");
Steam.OverlayToggled += (active, _, _) =>
{
IsOverlayActive = active;
};

//Pull in stats
placedNotes = Steam.GetStatInt("NotesPlaced");
GD.Print($"SW: Placed notes: {placedNotes}");

//Uncomment this to reset your achievements/stats. There's no confirmation so...
//ResetAll();
}

//TODO: This might fail sometimes? IDK, need to look into it
public static bool PopAchievement(string id)
{
if (!Steam.IsSteamRunning())
{
return false;
}

if (Steam.SetAchievement(id) && Steam.StoreStats())
{
GD.Print($"SW: Unlocked {id}.");
return true;
}

GD.PrintErr($"SW: Failed to set achievement {id}.");
return false;
}

//Should make this more generic, but we only have one stat
public static bool IncrementNoteCount()
{
if (!Steam.IsSteamRunning())
{
return false;
}

placedNotes++;

if (Steam.SetStatInt("NotesPlaced", placedNotes) && Steam.StoreStats())
{
GD.Print($"SW: Incremented placed notes to {placedNotes}.");
return true;
}
GD.PrintErr($"SW: Failed to increment placed notes to {placedNotes}.");
return false;
}

//For Debugging purposes. Resets all stats/ achievements
private static void ResetAll()
{
if (!Steam.IsSteamRunning())
{
return;
}

Steam.ResetAllStats(true);
Steam.StoreStats();
GD.Print("SW: All stats reset.");
}
}
1 change: 1 addition & 0 deletions Globals/SteamWhisperer.cs.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://bt4f7m5qx106a
1 change: 1 addition & 0 deletions Scenes/BattleDirector/Scripts/BattleDirector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ public class NoteHitArgs(BattleDirector bd, Note note, Timing timing) : BattleEv

public void InvokeNotePlaced(ArrowData data)
{
SteamWhisperer.IncrementNoteCount();
NotePlaced?.Invoke(new NoteEventArgs(_curDirector, data));
}

Expand Down
6 changes: 6 additions & 0 deletions Scenes/Maps/Scripts/Cartographer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ private void WinArea()
return;
}

//Achievement code for emptyPockets
if (StageProducer.PlayerStats.CurRelics.Length == 0)
{
SteamWhisperer.PopAchievement("emptyPockets");
}

EndScreen es = GD.Load<PackedScene>(EndScreen.LoadPath).Instantiate<EndScreen>();
AddChild(es);
es.TopLabel.Text = Tr("BATTLE_ROOM_WIN");
Expand Down
17 changes: 17 additions & 0 deletions Scenes/Puppets/Enemies/BossBlood/P_BossBlood.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ public override void _Ready()
eff.Owner.Heal(val);
}
),
new EnemyEffect(
this,
BattleEffectTrigger.OnDamageInstance,
1,
(e, eff, val) =>
{
if (e is not BattleDirector.Harbinger.OnDamageInstanceArgs dArgs)
return;
if (
dArgs.Dmg.Target == this
&& dArgs.Dmg.Target.GetCurrentHealth() <= dArgs.Dmg.Damage
)
{
SteamWhisperer.PopAchievement("actOneComp");
}
}
),
};
}
}
1 change: 1 addition & 0 deletions Scenes/Puppets/Enemies/Strawman/P_Strawman.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public override void _Ready()
)
{
SaveSystem.UpdateConfig(SaveSystem.ConfigSettings.FirstTime, false);
SteamWhisperer.PopAchievement("tutorial");
}
}
),
Expand Down
9 changes: 9 additions & 0 deletions Scenes/Puppets/Scripts/PlayerStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ public void AddRelic(RelicTemplate relic)

public void AddNote(Note nSelection)
{
//If the note is vampire, check to see if we already have 2 of them
if (
nSelection.Name == "PlayerVampire"
&& CurNotes.Count(note => note.Name == "PlayerVampire") >= 2
)
{
SteamWhisperer.PopAchievement("vampire");
}

CurNotes = CurNotes.Append(nSelection).ToArray();
}
}
2 changes: 1 addition & 1 deletion Scenes/UI/Options/Scripts/HowToPlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private void DoTutorial()

public override void _Input(InputEvent @event)
{
if (!GetWindow().HasFocus())
if (ControlSettings.IsOutOfFocus(this))
{
GetViewport().SetInputAsHandled();
return;
Expand Down
2 changes: 1 addition & 1 deletion Scenes/UI/Options/Scripts/OptionsMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public override void _Ready()

public override void _Input(InputEvent @event)
{
if (!GetWindow().HasFocus())
if (ControlSettings.IsOutOfFocus(this))
{
GetViewport().SetInputAsHandled();
return;
Expand Down
6 changes: 6 additions & 0 deletions Scenes/UI/Remapping/ControlSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Globalization;
using FunkEngine;
using Godot;
using GodotSteam;

public partial class ControlSettings : Node2D, IFocusableMenu
{ //TODO: Add messages when an invalid key is attempted to be set.
Expand Down Expand Up @@ -465,4 +466,9 @@ evt is InputEventKey keyEvent
}
return true;
}

public static bool IsOutOfFocus(Node asker)
{
return !asker.GetWindow().HasFocus() || SteamWhisperer.IsOverlayActive;
}
}
2 changes: 1 addition & 1 deletion Scenes/UI/Scripts/Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public override void _Process(double delta)

public override void _Input(InputEvent @event)
{
if (!GetWindow().HasFocus())
if (ControlSettings.IsOutOfFocus(this))
{
GetViewport().SetInputAsHandled();
return;
Expand Down
15 changes: 14 additions & 1 deletion Scenes/UI/Scripts/MenuModule.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using FunkEngine;
using Godot;
using GodotSteam;

/**
* <summary>Simple system for any scene which should display pause and inventory screen.</summary>
Expand All @@ -19,6 +20,12 @@ public override void _Ready()
OpenPauseMenu(); //Pause on disconnection
};
GetTree().GetRoot().FocusExited += OpenPauseMenu;
Steam.OverlayToggled += OpenPauseMenu;
}

public override void _ExitTree()
{
Steam.OverlayToggled -= OpenPauseMenu;
}

public void ResumeFocus()
Expand Down Expand Up @@ -49,7 +56,7 @@ public void ReturnToPrev()

public override void _Input(InputEvent @event)
{
if (!GetWindow().HasFocus())
if (ControlSettings.IsOutOfFocus(this))
{
GetViewport().SetInputAsHandled();
return;
Expand All @@ -69,6 +76,12 @@ public override void _Input(InputEvent @event)
}
}

private void OpenPauseMenu(bool active, bool initiated = false, uint id = 0)
{
if (active)
OpenPauseMenu();
}

private void OpenPauseMenu()
{
if (CurSceneNode.ProcessMode == ProcessModeEnum.Disabled)
Expand Down
2 changes: 1 addition & 1 deletion Scenes/UI/Scripts/PauseMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private void OpenOptions()

public override void _Input(InputEvent @event)
{
if (!GetWindow().HasFocus())
if (ControlSettings.IsOutOfFocus(this))
{
GetViewport().SetInputAsHandled();
return;
Expand Down
7 changes: 7 additions & 0 deletions Scenes/UI/Scripts/ScoringScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ private void DrawScoreLabels()
private void FinishScoring()
{
StageProducer.PlayerStats.Money += FinalMoney;

//Achievement check for 1k money
if (StageProducer.PlayerStats.Money >= 1000)
{
SteamWhisperer.PopAchievement("money");
}

Finished?.Invoke();
QueueFree();
}
Expand Down
22 changes: 22 additions & 0 deletions addons/godotsteam/godotsteam.gdextension
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[configuration]
entry_symbol = "godotsteam_init"
compatibility_minimum = "4.4"

[libraries]
macos.debug = "res://addons/godotsteam/osx/libgodotsteam.macos.template_debug.framework"
macos.release = "res://addons/godotsteam/osx/libgodotsteam.macos.template_release.framework"
windows.debug.x86_64 = "res://addons/godotsteam/win64/libgodotsteam.windows.template_debug.x86_64.dll"
windows.debug.x86_32 = "res://addons/godotsteam/win32/libgodotsteam.windows.template_debug.x86_32.dll"
windows.release.x86_64 = "res://addons/godotsteam/win64/libgodotsteam.windows.template_release.x86_64.dll"
windows.release.x86_32 = "res://addons/godotsteam/win32/libgodotsteam.windows.template_release.x86_32.dll"
linux.debug.x86_64 = "res://addons/godotsteam/linux64/libgodotsteam.linux.template_debug.x86_64.so"
linux.debug.x86_32 = "res://addons/godotsteam/linux32/libgodotsteam.linux.template_debug.x86_32.so"
linux.release.x86_64 = "res://addons/godotsteam/linux64/libgodotsteam.linux.template_release.x86_64.so"
linux.release.x86_32 = "res://addons/godotsteam/linux32/libgodotsteam.linux.template_release.x86_32.so"

[dependencies]
macos.universal = { "res://addons/godotsteam/osx/libsteam_api.dylib": "" }
windows.x86_64 = { "res://addons/godotsteam/win64/steam_api64.dll": "" }
windows.x86_32 = { "res://addons/godotsteam/win32/steam_api.dll": "" }
linux.x86_64 = { "res://addons/godotsteam/linux64/libsteam_api.so": "" }
linux.x86_32 = { "res://addons/godotsteam/linux32/libsteam_api.so": "" }
1 change: 1 addition & 0 deletions addons/godotsteam/godotsteam.gdextension.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://ue83e761t35n
Binary file not shown.
Binary file not shown.
Binary file added addons/godotsteam/linux32/libsteam_api.so
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added addons/godotsteam/linux64/libsteam_api.so
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>libgodotsteam.debug</string>
<key>CFBundleIdentifier</key>
<string>org.godotsteam.godotsteam</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>libgodotsteam.debug</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>4.15</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>4.15</string>
<key>LSMinimumSystemVersion</key>
<string>10.12</string>
</dict>
</plist>
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>libgodotsteam</string>
<key>CFBundleIdentifier</key>
<string>org.godotsteam.godotsteam</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>libgodotsteam</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>4.15</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>4.15</string>
<key>LSMinimumSystemVersion</key>
<string>10.12</string>
</dict>
</plist>
Binary file not shown.
Binary file not shown.
Binary file added addons/godotsteam/osx/libsteam_api.dylib
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added addons/godotsteam/win32/steam_api.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added addons/godotsteam/win64/steam_api64.dll
Binary file not shown.
8 changes: 8 additions & 0 deletions addons/godotsteam_csharpbindings/Apps/Dlc.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace GodotSteam;

public class Dlc
{
public uint AppId { get; set; }
public bool Available { get; set; }
public string Name { get; set; }
}
1 change: 1 addition & 0 deletions addons/godotsteam_csharpbindings/Apps/Dlc.cs.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://ck0g3t7wpau3w
Loading