fixes merge conflicts
This commit is contained in:
commit
bd5b734d79
15
caching.gd
15
caching.gd
@ -47,7 +47,6 @@ func _init() -> void:
|
|||||||
fetch_start.connect(_on_start_emit)
|
fetch_start.connect(_on_start_emit)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _on_start_emit() -> void:
|
func _on_start_emit() -> void:
|
||||||
_emitted_start += 1
|
_emitted_start += 1
|
||||||
|
|
||||||
@ -132,6 +131,7 @@ func _get_card_data_from_bulk(dict_entry: Dictionary) -> Dictionary:
|
|||||||
|
|
||||||
return dict_entry
|
return dict_entry
|
||||||
|
|
||||||
|
|
||||||
func _get_mana_img(symbol: String, img_url: String) -> Error:
|
func _get_mana_img(symbol: String, img_url: String) -> Error:
|
||||||
fetch_start.emit()
|
fetch_start.emit()
|
||||||
if FileAccess.file_exists("res://symbol_cache/" + symbol + ".svg"):
|
if FileAccess.file_exists("res://symbol_cache/" + symbol + ".svg"):
|
||||||
@ -152,12 +152,14 @@ 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
|
||||||
|
|
||||||
|
|
||||||
if img.get_size() == Vector2i(100, 100):
|
if img.get_size() == Vector2i(100, 100):
|
||||||
print("resizing")
|
print("resizing")
|
||||||
img.resize(20, 20, Image.INTERPOLATE_LANCZOS)
|
img.resize(20, 20, Image.INTERPOLATE_LANCZOS)
|
||||||
|
|
||||||
img.save_png("res://symbol_cache/" + symbol.replace("/", "-").replace("{", "").replace("}", "") + ".png")
|
img.save_png(
|
||||||
|
"res://symbol_cache/" + symbol.replace("/", "-").replace("{", "").replace("}", "") + ".png"
|
||||||
|
)
|
||||||
|
|
||||||
img = null
|
img = null
|
||||||
|
|
||||||
fetch_done.emit()
|
fetch_done.emit()
|
||||||
@ -187,7 +189,11 @@ 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("/", "-").replace("{", "").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)
|
||||||
@ -197,6 +203,7 @@ func _fetch_mana_symbols() -> Error:
|
|||||||
print("Done caching mana symbols.")
|
print("Done caching mana symbols.")
|
||||||
return OK
|
return OK
|
||||||
|
|
||||||
|
|
||||||
func _fetch_card_img(data: Dictionary) -> Error:
|
func _fetch_card_img(data: Dictionary) -> Error:
|
||||||
fetch_start.emit()
|
fetch_start.emit()
|
||||||
if FileAccess.file_exists("user://card_cache/" + data["id"] + "card.png"):
|
if FileAccess.file_exists("user://card_cache/" + data["id"] + "card.png"):
|
||||||
|
@ -3,4 +3,4 @@ extends Node
|
|||||||
@warning_ignore("unused_signal")
|
@warning_ignore("unused_signal")
|
||||||
signal card_on_hover(card_info, card_image)
|
signal card_on_hover(card_info, card_image)
|
||||||
@warning_ignore("unused_signal")
|
@warning_ignore("unused_signal")
|
||||||
signal card_on_unhover()
|
signal card_on_unhover
|
||||||
|
@ -47,7 +47,9 @@ func _load_data() -> Error:
|
|||||||
|
|
||||||
|
|
||||||
func _load_image() -> Error:
|
func _load_image() -> Error:
|
||||||
var cached_img = FileAccess.get_file_as_bytes("user://card_cache/" + card.card_info["id"] + "/card.png")
|
var cached_img = FileAccess.get_file_as_bytes(
|
||||||
|
"user://card_cache/" + card.card_info["id"] + "/card.png"
|
||||||
|
)
|
||||||
|
|
||||||
if cached_img.is_empty():
|
if cached_img.is_empty():
|
||||||
push_error("%sCard on-board image was not found in cache" % card.error("CACHE"))
|
push_error("%sCard on-board image was not found in cache" % card.error("CACHE"))
|
||||||
@ -78,5 +80,4 @@ func _load_image() -> Error:
|
|||||||
var card_sprite = card.get_node("Sprite2D")
|
var card_sprite = card.get_node("Sprite2D")
|
||||||
card_sprite.texture = image_texture
|
card_sprite.texture = image_texture
|
||||||
|
|
||||||
|
|
||||||
return OK
|
return OK
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
extends TextureRect
|
extends TextureRect
|
||||||
|
|
||||||
|
|
||||||
func _set_tip_image(_card_info: Dictionary, card_image: Image) -> void:
|
func _set_tip_image(_card_info: Dictionary, card_image: Image) -> void:
|
||||||
card_image.resize(int(size.x / 1.75), int(size.y), Image.INTERPOLATE_LANCZOS)
|
card_image.resize(int(size.x / 1.75), int(size.y), Image.INTERPOLATE_LANCZOS)
|
||||||
var tex = ImageTexture.new()
|
var tex = ImageTexture.new()
|
||||||
tex.set_image(card_image)
|
tex.set_image(card_image)
|
||||||
texture = tex
|
texture = tex
|
||||||
|
|
||||||
|
|
||||||
func _clear_tip_image() -> void:
|
func _clear_tip_image() -> void:
|
||||||
texture = null
|
texture = null
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
EventBus.connect("card_on_hover", _set_tip_image)
|
EventBus.connect("card_on_hover", _set_tip_image)
|
||||||
EventBus.connect("card_on_unhover", _clear_tip_image)
|
EventBus.connect("card_on_unhover", _clear_tip_image)
|
||||||
|
@ -11,6 +11,7 @@ func _convert_text_to_symbol(_text: String):
|
|||||||
last_idx = _text.find(symbol, last_idx) + symbol.length()
|
last_idx = _text.find(symbol, last_idx) + symbol.length()
|
||||||
return _text
|
return _text
|
||||||
|
|
||||||
|
|
||||||
func _set_tip_text(card_info: Dictionary, _card_image: Image) -> void:
|
func _set_tip_text(card_info: Dictionary, _card_image: Image) -> void:
|
||||||
# TODO: add more card formatting, check all of the logos, very niche icons will be affected i believe since they're
|
# TODO: add more card formatting, check all of the logos, very niche icons will be affected i believe since they're
|
||||||
# different sizes
|
# different sizes
|
||||||
@ -18,13 +19,30 @@ func _set_tip_text(card_info: Dictionary, _card_image: Image) -> void:
|
|||||||
text = "[b]" + card_info["name"] + "[/b]\t"
|
text = "[b]" + card_info["name"] + "[/b]\t"
|
||||||
text += _convert_text_to_symbol(card_info["cost"]) + "\n"
|
text += _convert_text_to_symbol(card_info["cost"]) + "\n"
|
||||||
text += "[i]" + card_info["type"] + "[/i]\n"
|
text += "[i]" + card_info["type"] + "[/i]\n"
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
text += _convert_text_to_symbol(card_info["desc"])
|
text += _convert_text_to_symbol(card_info["desc"])
|
||||||
|
|
||||||
|
=======
|
||||||
|
var oracle_text = card_info["desc"]
|
||||||
|
var last_idx = 0
|
||||||
|
|
||||||
|
for symbol in mana_symbols:
|
||||||
|
last_idx = 0
|
||||||
|
while oracle_text.find(symbol, last_idx) != -1:
|
||||||
|
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()
|
||||||
|
|
||||||
|
text += oracle_text
|
||||||
|
|
||||||
|
>>>>>>> 76a23aab5c62c7ff138d393c5f5fedd6cd6c7a46
|
||||||
|
|
||||||
func _clear_tip_text() -> void:
|
func _clear_tip_text() -> void:
|
||||||
text = ""
|
text = ""
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
if !FileAccess.file_exists("res://symbol_cache/symbols.json"):
|
if !FileAccess.file_exists("res://symbol_cache/symbols.json"):
|
||||||
push_error("Symbols haven't been cached yet!")
|
push_error("Symbols haven't been cached yet!")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user