Skip to content

Commit

Permalink
feat: godotsteam basic integration, including test achievement
Browse files Browse the repository at this point in the history
Adds a GodotSteam autoload, references to godot-steam templates, and
some handling for creating and dropping a test achievement. Working
pretty well! Expects to be run in a version of godot compiled with
godot-steam as a godot extension: https://github.com/CoaguCo-Industries/GodotSteam/releases/tag/v4.6
  • Loading branch information
russmatney committed Feb 27, 2024
1 parent a99ad16 commit 29d4467
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 14 deletions.
12 changes: 6 additions & 6 deletions export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ encrypt_directory=false

[preset.0.options]

custom_template/debug=""
custom_template/release=""
debug/export_console_wrapper=1
custom_template/debug="/home/russ/.local/share/godotsteam/linux-421-debug-template.x86_64"
custom_template/release="/home/russ/.local/share/godotsteam/linux-421-template.x86_64"
debug/export_console_wrapper=2
binary_format/embed_pck=false
texture_format/bptc=true
texture_format/s3tc=true
Expand Down Expand Up @@ -94,9 +94,9 @@ encrypt_directory=false

[preset.2.options]

custom_template/debug=""
custom_template/release=""
debug/export_console_wrapper=1
custom_template/debug="/home/russ/.local/share/godotsteam/win64-421-debug-template.exe"
custom_template/release="/home/russ/.local/share/godotsteam/win64-421-template.exe"
debug/export_console_wrapper=2
binary_format/embed_pck=false
texture_format/bptc=true
texture_format/s3tc=true
Expand Down
1 change: 1 addition & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Store="*res://src/Store.gd"
SoundManager="*res://addons/sound_manager/sound_manager.gd"
Music="*res://src/Music.gd"
Sounds="*res://src/Sounds.gd"
GodotSteam="*res://src/GodotSteam.gd"

[display]

Expand Down
82 changes: 82 additions & 0 deletions src/GodotSteam.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
extends Node

## vars ########################################################3

const STEAM_APP_ID = 2779710
var enabled: bool = false

# Steam variables
var is_on_steam_deck: bool = false
var is_online: bool = false
var is_owned: bool = false
var steam_app_id: int = 480
var steam_id: int = 0
var steam_username: String = ""

## init ########################################################3

func _init() -> void:
OS.set_environment("SteamAppId", str(STEAM_APP_ID))
OS.set_environment("SteamGameId", str(STEAM_APP_ID))

## ready ########################################################3

func _ready():
# if not OS.has_feature("steam"):
# return
init_steam()

## process ########################################################3

func _process(_delta):
# if not OS.has_feature("steam"):
# return
Steam.run_callbacks()

## init steam ########################################################3

func init_steam() -> void:
var status = Steam.steamInitEx()

if status.get("status") != 0:
Log.warn("Steam init failed, disabling steam interactions", status)
enabled = false
return

Log.pr("Steam init success, enabling steam interactions", status)
enabled = true

# Gather additional data
is_on_steam_deck = Steam.isSteamRunningOnSteamDeck()
is_online = Steam.loggedOn()
is_owned = Steam.isSubscribed()
steam_id = Steam.getSteamID()
steam_username = Steam.getPersonaName()

Log.pr("Steam init data", {
is_on_steam_deck=is_on_steam_deck,
is_online=is_online,
is_owned=is_owned,
steam_id=steam_id,
steam_username=steam_username,
})

## achievements ########################################################3

func set_achievement(achv):
if enabled:
Steam.setAchievement(achv)
Steam.storeStats()

func clear_achievement(achv):
if enabled:
Steam.clearAchievement(achv)
Steam.storeStats()

func clear_test_achievements():
clear_achievement(TEST_ACHIEVEMENT)

const TEST_ACHIEVEMENT="TEST_ACHIEVEMENT"

func set_test_achievement():
set_achievement(TEST_ACHIEVEMENT)
1 change: 1 addition & 0 deletions src/menus/MainMenu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extends CanvasLayer
func _ready():
if not Engine.is_editor_hint():
SoundManager.play_music(Music.late_night_radio)
U.call_in(2.0, self, func(): GodotSteam.set_test_achievement())

start_button.grab_focus.call_deferred()
start_button.visibility_changed.connect(func(): start_button.grab_focus())
Expand Down
8 changes: 6 additions & 2 deletions src/menus/OptionsPanel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ func _ready():
reset_save_data_button.pressed.connect(func(): data_reset_conf.show())
unlock_all_button.pressed.connect(func(): data_unlock_conf.show())
data_reset_conf.confirmed.connect(func():
Store.reset_game_data())
Store.reset_game_data()
GodotSteam.clear_test_achievements()
)
data_unlock_conf.confirmed.connect(func():
Store.unlock_all_puzzle_sets())
Store.unlock_all_puzzle_sets()
# TODO add cheater-skeeter pumpkin eater achievement
)

main_menu_button.pressed.connect(func():
Navi.nav_to_main_menu())
Expand Down
4 changes: 2 additions & 2 deletions src/menus/OptionsPanel.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ layout_mode = 2
[node name="DataResetConfirmationDialog" type="ConfirmationDialog" parent="."]
unique_name_in_owner = true
initial_position = 2
size = Vector2i(700, 360)
size = Vector2i(700, 363)
transparent = true
keep_title_visible = false
theme = ExtResource("8_pvanl")
ok_button_text = "Reset my datums!"
dialog_text = "Are you sure you want to reset the game's progress? This will re-lock any unlocked Puzzle Sets and Themes."
dialog_text = "Are you sure you want to reset the game's progress? This will re-lock all the Puzzles!"
dialog_autowrap = true
cancel_button_text = "Nevermind!"

Expand Down
8 changes: 4 additions & 4 deletions src/menus/worldmap/WorldMapMenu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ color = Color(0.101961, 0.109804, 0.188235, 1)
unique_name_in_owner = true
position = Vector2(925, 449)
scale = Vector2(5, 5)
current_marker = NodePath("@Marker2D@37192")
current_marker = NodePath("@Marker2D@18712")
zoom_scale_min = 5.0
zoom_scale_max = 10.0

Expand Down Expand Up @@ -143,7 +143,7 @@ custom_minimum_size = Vector2(300, 0)
layout_mode = 2
focus_mode = 0
theme = ExtResource("11_hm0xn")
text = "Start Puzzle 2"
text = "Start Puzzle 3"

[node name="MarginContainer8" type="MarginContainer" parent="PanelContainer/VBoxContainer/HBoxContainer"]
custom_minimum_size = Vector2(30, 0)
Expand All @@ -153,9 +153,9 @@ size_flags_vertical = 3
[node name="PuzzleSetIcon" type="TextureRect" parent="."]
unique_name_in_owner = true
custom_minimum_size = Vector2(64, 64)
offset_left = 244.0
offset_left = 312.0
offset_top = 361.0
offset_right = 308.0
offset_right = 376.0
offset_bottom = 425.0
pivot_offset = Vector2(32, 32)
texture = ExtResource("8_mehyl")
Expand Down

0 comments on commit 29d4467

Please sign in to comment.