Compare commits

4 Commits

5 changed files with 29 additions and 19 deletions

View File

@ -151,10 +151,15 @@ func _get_mana_img(symbol: String, img_url: String) -> Error:
if err != OK: if err != OK:
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):
print("resizing")
img.resize(20, 20, Image.INTERPOLATE_LANCZOS)
img.save_png( img.save_png(
"res://symbol_cache/" + symbol.replace("/", "-").replace("{", "").replace("}", "") + ".png" "res://symbol_cache/" + symbol.replace("/", "-").replace("{", "").replace("}", "") + ".png"
) )
img = null img = null
fetch_done.emit() fetch_done.emit()

View File

@ -12,14 +12,18 @@ var decks: Array[Dictionary]
func _ready() -> void: func _ready() -> void:
# The first field in the array will be the player's own field. # The first field in the array will be the player's own field.
# Might be a better idea to have that in a seperate variable? idk # Might be a better idea to have that in a seperate variable? idk
var card = _card_class.instantiate() var card = _card_class.instantiate()
card.init("d3f10f07-7cfe-4a6f-8de6-373e367a731b")
add_child(card)
card.position = Vector2(100, 100)
# TODO: Currently working with an already-cached card with a known ID to load this. # TODO: Currently working with an already-cached card with a known ID to load this.
# Later on, the cards should be pulling the IDs directly from the library's list of IDs. # Later on, the cards should be pulling the IDs directly from the library's list of IDs.
card.init("162e81d3-6cd4-4cb8-8ed8-cfbd8d34ca71")
add_child(card)
#fields.append(field_scene.instantiate()) #fields.append(field_scene.instantiate())
#var colors: Array[Color] = [Color(1, 0, 1)] #var colors: Array[Color] = [Color(1, 0, 1)]

View File

@ -41,6 +41,7 @@ func _load_data() -> Error:
card.card_info["name"] = card_json["name"] card.card_info["name"] = card_json["name"]
card.card_info["type"] = card_json["type_line"] card.card_info["type"] = card_json["type_line"]
card.card_info["desc"] = card_json["oracle_text"] card.card_info["desc"] = card_json["oracle_text"]
card.card_info["cost"] = card_json["mana_cost"]
return OK return OK

View File

@ -2,26 +2,26 @@ extends RichTextLabel
var mana_symbols: Dictionary var mana_symbols: Dictionary
func _convert_text_to_symbol(_text: String):
var last_idx = 0
for symbol in mana_symbols:
last_idx = 0
while _text.find(symbol, last_idx) != -1:
_text = _text.replace(symbol, "[img]" + mana_symbols[symbol] + "[/img]")
last_idx = _text.find(symbol, last_idx) + symbol.length()
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
# shrink text if we use too much space for it, etc # shrink text if we use too much space for it, etc
text = "[b]" + card_info["name"] + "[/b]\n" text = "[b]" + card_info["name"] + "[/b]\t"
text += _convert_text_to_symbol(card_info["cost"]) + "\n"
text += "[i]" + card_info["type"] + "[/i]\n" text += "[i]" + card_info["type"] + "[/i]\n"
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
text += _convert_text_to_symbol(card_info["desc"])
func _clear_tip_text() -> void: func _clear_tip_text() -> void:
text = "" text = ""
@ -35,7 +35,5 @@ func _ready() -> void:
mana_symbols = JSON.parse_string(file.get_as_text()) mana_symbols = JSON.parse_string(file.get_as_text())
file.close() file.close()
set_use_bbcode(true)
EventBus.connect("card_on_hover", _set_tip_text) EventBus.connect("card_on_hover", _set_tip_text)
EventBus.connect("card_on_unhover", _clear_tip_text) EventBus.connect("card_on_unhover", _clear_tip_text)

View File

@ -50,6 +50,8 @@ script = ExtResource("2_pqag1")
[node name="RichTextLabel" type="RichTextLabel" parent="UI/BigBar/Items/MenuArea/VBoxContainer"] [node name="RichTextLabel" type="RichTextLabel" parent="UI/BigBar/Items/MenuArea/VBoxContainer"]
custom_minimum_size = Vector2(0, 230) custom_minimum_size = Vector2(0, 230)
layout_mode = 2 layout_mode = 2
bbcode_enabled = true
fit_content = true
script = ExtResource("2_d43bn") script = ExtResource("2_d43bn")
[node name="ChatArea" type="PanelContainer" parent="UI/BigBar/Items"] [node name="ChatArea" type="PanelContainer" parent="UI/BigBar/Items"]