finishes adding mana symbols into tooltip text
This commit is contained in:
parent
75767e927d
commit
1c5c4728a3
@ -152,7 +152,7 @@ func _get_mana_img(symbol: String, img_url: String) -> Error:
|
|||||||
push_error(_cache_error("IMG_LOADING") + "Couldn't load the image.")
|
push_error(_cache_error("IMG_LOADING") + "Couldn't load the image.")
|
||||||
return FAILED
|
return FAILED
|
||||||
|
|
||||||
img.save_png("res://symbol_cache/" + symbol.replace("/", "-") + ".png")
|
img.save_png("res://symbol_cache/" + symbol.replace("/", "-").replace("{", "").replace("}", "") + ".png")
|
||||||
img = null
|
img = null
|
||||||
|
|
||||||
fetch_done.emit()
|
fetch_done.emit()
|
||||||
@ -182,7 +182,7 @@ func _fetch_mana_symbols() -> Error:
|
|||||||
err = await _get_mana_img(icon["symbol"], icon["svg_uri"])
|
err = await _get_mana_img(icon["symbol"], icon["svg_uri"])
|
||||||
if err != OK:
|
if err != OK:
|
||||||
push_error("Couldn't fetch mana symbol " + icon["symbol"])
|
push_error("Couldn't fetch mana symbol " + icon["symbol"])
|
||||||
mana_symbols[icon["symbol"]] = "res://symbol_cache/" + icon["symbol"].replace("/", "-") + ".png"
|
mana_symbols[icon["symbol"]] = "res://symbol_cache/" + icon["symbol"].replace("/", "-").replace("{", "").replace("}", "") + ".png"
|
||||||
print(icon["symbol"] + " image cached.")
|
print(icon["symbol"] + " image cached.")
|
||||||
|
|
||||||
var file = FileAccess.open("res://symbol_cache/symbols.json", FileAccess.WRITE)
|
var file = FileAccess.open("res://symbol_cache/symbols.json", FileAccess.WRITE)
|
||||||
|
@ -6,20 +6,20 @@ func _set_tip_text(card_info: Dictionary, _card_image: Image) -> void:
|
|||||||
text = card_info["name"] + " | " + card_info["type"] + "\n"
|
text = card_info["name"] + " | " + card_info["type"] + "\n"
|
||||||
var oracle_text = card_info["desc"]
|
var oracle_text = card_info["desc"]
|
||||||
var last_idx = 0
|
var last_idx = 0
|
||||||
|
var found_card: bool = false
|
||||||
# TODO: fix the string splitting here because its missing some symbols, and misplacing others
|
# TODO: fix the string splitting here because its missing some symbols, and misplacing others
|
||||||
|
|
||||||
|
# TODO: duh this is skipping some symbols because it will find the first symbol (which could be after many other symbols)
|
||||||
|
# and then add all the previous text, skipping them
|
||||||
|
|
||||||
for symbol in mana_symbols:
|
for symbol in mana_symbols:
|
||||||
if oracle_text.find(symbol, last_idx) == -1:
|
last_idx = 0
|
||||||
continue
|
while oracle_text.find(symbol, last_idx) != -1:
|
||||||
text += oracle_text.substr(last_idx, oracle_text.find(symbol, last_idx))
|
print("infinite loop?")
|
||||||
|
oracle_text = oracle_text.replace(symbol, "[img width=\"16\" height=\"16\"]" + mana_symbols[symbol] + "[/img]")
|
||||||
last_idx = oracle_text.find(symbol, last_idx) + symbol.length()
|
last_idx = oracle_text.find(symbol, last_idx) + symbol.length()
|
||||||
|
|
||||||
# NOTE:
|
text += oracle_text
|
||||||
# add_image() from richtextlabel has no positioning, and just throws it at the end,
|
|
||||||
# so we need to use raw bbcode to actually do this intext
|
|
||||||
# it also needs to be in res:// to actually be able to access it
|
|
||||||
# for some reason bbcode can't read from user://
|
|
||||||
text += "[img width=\"16\" height=\"16\"]" + mana_symbols[symbol] + "[/img]"
|
|
||||||
text += oracle_text.substr(last_idx, -1)
|
|
||||||
|
|
||||||
|
|
||||||
func _clear_tip_text() -> void:
|
func _clear_tip_text() -> void:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user