Skip to content

Commit

Permalink
change buttons affected by if dlc is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Sajo8 committed Mar 25, 2020
1 parent da9a377 commit 9fa7186
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions gui/screens/OptionsScreen.gd
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

0 comments on commit 9fa7186

Please sign in to comment.