Updated SammiAPI
Updated get_deck_status() to properly return true or false if the deck is 1 or 0 for return Updated modify_button() to be a variant, be it an int, color, or string to be passed for color.
This commit is contained in:
parent
90e9f1f496
commit
16fcd30a6a
1 changed files with 13 additions and 4 deletions
|
|
@ -12,6 +12,7 @@ var client: SammiClient
|
||||||
var last_error: String = ""
|
var last_error: String = ""
|
||||||
var last_error_description: String = ""
|
var last_error_description: String = ""
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
client = SammiClient.new()
|
client = SammiClient.new()
|
||||||
add_child(client)
|
add_child(client)
|
||||||
|
|
@ -185,7 +186,7 @@ func get_deck_status(deck_id: String) -> bool:
|
||||||
last_error_description = res["Description"]
|
last_error_description = res["Description"]
|
||||||
return false
|
return false
|
||||||
else:
|
else:
|
||||||
return true
|
return res["data"] == 1.0
|
||||||
else:
|
else:
|
||||||
push_error("Error: %d: %s" % [response.code, response.error_message])
|
push_error("Error: %d: %s" % [response.code, response.error_message])
|
||||||
last_error = "HTTP Error: %d" % response.code
|
last_error = "HTTP Error: %d" % response.code
|
||||||
|
|
@ -277,7 +278,7 @@ func release_button(button_id: String) -> bool:
|
||||||
last_error_description = response.error_message
|
last_error_description = response.error_message
|
||||||
return false
|
return false
|
||||||
|
|
||||||
func modify_button(button_id: String, text: String = "", color: int = -1, image: String = "", border: int = -1) -> bool:
|
func modify_button(button_id: String, text: String = "", color: Variant = null, image: String = "", border: int = -1) -> bool:
|
||||||
var api_path: String = "/api"
|
var api_path: String = "/api"
|
||||||
var req: Dictionary = {
|
var req: Dictionary = {
|
||||||
"request": "modifyButton",
|
"request": "modifyButton",
|
||||||
|
|
@ -285,8 +286,16 @@ func modify_button(button_id: String, text: String = "", color: int = -1, image:
|
||||||
}
|
}
|
||||||
if text != "":
|
if text != "":
|
||||||
req["text"] = text
|
req["text"] = text
|
||||||
if color != -1:
|
if color != null:
|
||||||
req["color"] = color
|
if color is int:
|
||||||
|
req["color"] = color
|
||||||
|
elif color is Color:
|
||||||
|
color.a = 0
|
||||||
|
req["color"] = color.to_abgr32()
|
||||||
|
elif color is String:
|
||||||
|
color = Color.from_string(color, Color.WHITE)
|
||||||
|
color.a = 0
|
||||||
|
req["color"] = color.to_abgr32()
|
||||||
if image != "":
|
if image != "":
|
||||||
req["image"] = image
|
req["image"] = image
|
||||||
if border != -1:
|
if border != -1:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue