Skip to content

Commit

Permalink
kill me part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
katzerax authored Nov 15, 2024
1 parent 69a9499 commit af3511f
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 76 deletions.
50 changes: 50 additions & 0 deletions Modules/DependencyChecks/dependency_checks.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
extends Node

var dependency_prefix = "[KMOD.dependency_check] "

func _get_gdweave_dir() -> String:
var game_directory = OS.get_executable_path().get_base_dir()
var folder_override = _get_folder_override()
if folder_override:
var relative_path = game_directory.plus_file(folder_override)
var is_relative = not ":" in relative_path and Directory.new().file_exists(relative_path)
return relative_path if is_relative else folder_override
else:
return game_directory.plus_file("GDWeave")

func _get_folder_override() -> String:
for argument in OS.get_cmdline_args():
if argument.begins_with("--gdweave-folder-override="):
return argument.trim_prefix("--gdweave-folder-override=").replace("\\", "/")
return ""

func _check_manifest(manifest_path: String, api_name: String) -> bool:
var file = File.new()
if file.file_exists(manifest_path):
print(dependency_prefix, api_name, "manifest found!")
return true
else:
print(dependency_prefix, api_name, "manifest not found.")
return false

func _check_for_size_unlocker() -> bool:
var gdweave_dir = _get_gdweave_dir()
var manifest_path = ""
if gdweave_dir != "":
if _get_folder_override() != "":
manifest_path = gdweave_dir.plus_file("mods").plus_file("nowaha-SizeUnlocker").plus_file("manifest.json")
else:
manifest_path = gdweave_dir.plus_file("mods").plus_file("SizeUnlocker").plus_file("manifest.json")
return _check_manifest(manifest_path, "SizeUnlocker ")
return false

func _check_for_title_api() -> bool:
var gdweave_dir = _get_gdweave_dir()
var manifest_path = ""
if gdweave_dir != "":
if _get_folder_override() != "":
manifest_path = gdweave_dir.plus_file("mods").plus_file("LoafWF-TitleAPI").plus_file("manifest.json")
else:
manifest_path = gdweave_dir.plus_file("mods").plus_file("TitleAPI").plus_file("manifest.json")
return _check_manifest(manifest_path, "TitleAPI ")
return false
41 changes: 5 additions & 36 deletions Modules/KRecognizer/k_recognizer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,20 @@ extends Node

var prefix = "[KMOD.k_recognizer] "
var title_api
var dependency_check_script : Node = null

func _register_kmod_titles():
title_api.register_title(76561198233616048, "[color=#ff1a5c]KMod Dev[/color]", false)
title_api.register_title(76561198799078563, "[color=#f6a4f3]Paw tuah[/color]", false)

func _ready():
if _check_r2_titleapi_location() or _check_for_title_api():
var dependency_check_script = preload("res://mods/KMod/Modules/DependencyChecks/dependency_checks.gd").new()
var has_title = dependency_check_script._check_for_title_api()
if has_title:
yield(wait_for_title_api(), "completed")
if title_api != null:
_register_kmod_titles()

func _get_gdweave_dir() -> String:
var game_directory = OS.get_executable_path().get_base_dir()
var folder_override = _get_folder_override()
if folder_override:
var relative_path = game_directory.plus_file(folder_override)
var is_relative = not ":" in relative_path and Directory.new().file_exists(relative_path)
return relative_path if is_relative else folder_override
else:
return game_directory.plus_file("GDWeave")

func _get_folder_override() -> String:
for argument in OS.get_cmdline_args():
if argument.begins_with("--gdweave-folder-override="):
return argument.trim_prefix("--gdweave-folder-override=").replace("\\", "/")
return ""

func _check_r2_titleapi_location() -> bool:
var gdweave_dir = _get_gdweave_dir()
var manifest_path = gdweave_dir.plus_file("mods").plus_file("LoafWF-TitleAPI").plus_file("manifest.json")
return _check_manifest(manifest_path, "r2modman TitleAPI ")

func _check_for_title_api() -> bool:
var gdweave_dir = _get_gdweave_dir()
var manifest_path = gdweave_dir.plus_file("mods").plus_file("TitleAPI").plus_file("manifest.json")
return _check_manifest(manifest_path, "TitleAPI ")

func _check_manifest(manifest_path: String, api_name: String) -> bool:
var file = File.new()
if file.file_exists(manifest_path):
print(prefix, api_name, "manifest found!")
return true
else:
print(prefix, api_name, "manifest not found.")
return false
dependency_check_script.queue_free()

func wait_for_title_api() -> GDScriptFunctionState:
print(prefix, "Waiting for TitleAPI to be loaded...")
Expand Down
45 changes: 5 additions & 40 deletions Modules/SizeChanger/size_changer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,13 @@ var player_size = 1.0
var save_timer = null
var size_min = 0.6
var size_max = 1.4

func _get_gdweave_dir() -> String:
var game_directory = OS.get_executable_path().get_base_dir()
var folder_override = _get_folder_override()
if folder_override:
var relative_path = game_directory.plus_file(folder_override)
var is_relative = not ":" in relative_path and Directory.new().file_exists(relative_path)
return relative_path if is_relative else folder_override
else:
return game_directory.plus_file("GDWeave")

func _get_folder_override() -> String:
for argument in OS.get_cmdline_args():
if argument.begins_with("--gdweave-folder-override="):
return argument.trim_prefix("--gdweave-folder-override=").replace("\\", "/")
return ""
var dependency_check_script : Node = null

func _ready():
initialize()
dependency_check_script = preload("res://mods/KMod/Modules/DependencyChecks/dependency_checks.gd").new() # Load the dependency check script
_apply_size_unlocker()
initialize()
dependency_check_script.queue_free()

func initialize():
if !in_lobby():
Expand All @@ -46,7 +33,7 @@ func initialize():
print(prefix, "No player instance found yet. Waiting...")

func _apply_size_unlocker():
var has_unlocker = _check_for_size_unlocker()
var has_unlocker = dependency_check_script._check_for_size_unlocker() # Call the method from dependency_check.gd
if has_unlocker:
print(prefix, "SizeUnlocker detected: Using extended size limits.")
size_min = 0.1
Expand All @@ -56,27 +43,6 @@ func _apply_size_unlocker():
size_min = 0.6
size_max = 1.4

func _check_for_size_unlocker() -> bool:
var gdweave_dir = _get_gdweave_dir()
var size_unlocker_dir = gdweave_dir.plus_file("mods")
var folder_override = _get_folder_override()
if folder_override != "":
size_unlocker_dir = size_unlocker_dir.plus_file("nowaha-SizeUnlocker")
else:
size_unlocker_dir = size_unlocker_dir.plus_file("SizeUnlocker")
var manifest_path = size_unlocker_dir.plus_file("manifest.json")
print(prefix, "Checking manifest at: ", manifest_path)
return _check_manifest(manifest_path, "SizeUnlocker ")

func _check_manifest(manifest_path: String, api_name: String) -> bool:
var file = File.new()
if file.file_exists(manifest_path):
print(prefix, api_name, "manifest found!")
return true
else:
print(prefix, api_name, "manifest not found.")
return false

func get_player_node():
return get_tree().current_scene.get_node_or_null("Viewport/main/entities/player")

Expand Down Expand Up @@ -120,7 +86,6 @@ func start_save_timer():
if save_timer:
save_timer.stop()
save_timer.queue_free()

save_timer = Timer.new()
save_timer.wait_time = IDLE_SAVE_DELAY
save_timer.one_shot = true
Expand Down

0 comments on commit af3511f

Please sign in to comment.