-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change buttons affected by if dlc is enabled
- Loading branch information
Showing
1 changed file
with
19 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,38 @@ | ||
extends Control | ||
|
||
onready var dlc_level_button = get_node("Buttons/DLC/BuyDLC/Buy/HBoxContainer/level") | ||
onready var dlc_skin_button = get_node("Buttons/DLC/BuyDLC/Buy/HBoxContainer/skin") | ||
|
||
func _ready(): | ||
$MainMenu.grab_focus() | ||
|
||
# if it's not already disabled (ie, they have all the dlc) | ||
# then check the server to see if DLCs are currently enabled | ||
if not $Buttons/DLC.disabled: | ||
$Buttons/DLC.text = "Loading DLC..." | ||
$Buttons/DLC.disabled = true | ||
dlc_level_button.text = "Loading DLC..." | ||
dlc_skin_button.text = "Loading DLC..." | ||
|
||
dlc_level_button.disabled = true | ||
dlc_skin_button.disabled = true | ||
|
||
var err = $CheckDLCEnabled.request("https://testsajoeexpress.netlify.com/.netlify/functions/server/trtlapps/getDlcEnabled") | ||
if err != OK: | ||
$Buttons/DLC.text = "DLC currently disabled" | ||
$Buttons/DLC.disabled = true | ||
make_dlc_disabled() | ||
|
||
func _on_CheckDLCEnabled_request_completed(result: int, response_code: int, headers: PoolStringArray, body: PoolByteArray) -> void: | ||
var json_result = JSON.parse(body.get_string_from_utf8()).result | ||
if json_result['result']: | ||
$Buttons/DLC.text = "Buy DLC" | ||
$Buttons/DLC.disabled = false | ||
dlc_level_button.text = "Level DLC" | ||
dlc_skin_button.text = "Skin DLC" | ||
|
||
dlc_level_button.disabled = false | ||
dlc_skin_button.disabled = false | ||
else: | ||
make_dlc_disabled() | ||
|
||
func make_dlc_disabled(): | ||
$Buttons/DLC.text = "DLC currently disabled" | ||
$Buttons/DLC.disabled = true | ||
dlc_level_button.text = "DLC disabled" | ||
dlc_skin_button.text = "DLC disabled" | ||
|
||
dlc_level_button.disabled = true | ||
dlc_skin_button.disabled = true |