diff options
Diffstat (limited to 'client.gd')
-rw-r--r-- | client.gd | 73 |
1 files changed, 35 insertions, 38 deletions
@@ -11,43 +11,40 @@ var character: Dictionary = { } -func _ready() -> void: - #var grf = GRF.open("res://client_data/data.grf") - #grf.extract() - #grf.convert()#"user://data") +func show_message_window( + message: String, + title: String = "", + attached_to: Control = null, + anchor: Side = SIDE_TOP +) -> GameWindow: + var window = preload("res://ui/message_window.tscn").instantiate() + window.message = message + window.title = title - #Sprite.from_bytes(FileAccess.get_file_as_bytes("res://client_data/data/sprite/cursors.spr")) - #ActionFormat.from_bytes( - #ByteStream.from_bytes( - #FileAccess.get_file_as_bytes("res://client_data/data/sprite/cursors.act") - #) - #) - #GATFormat.from_bytes( - #ByteStream.from_bytes( - #FileAccess.get_file_as_bytes("res://client_data/data/int_land02.gat") - #) - #) - #GNDFormat.from_bytes( - #ByteStream.from_bytes( - #FileAccess.get_file_as_bytes("res://client_data/data/int_land02.gnd") - #) - #) - var rsw = RSWFormat.from_bytes( - ByteStream.from_bytes( - #FileAccess.get_file_as_bytes("res://client_data/data/int_land02.rsw") - FileAccess.get_file_as_bytes("res://client_data/data/pay_dun00.rsw") - ) - ) - #RSMFormat.from_bytes( - #ByteStream.from_bytes( - ##FileAccess.get_file_as_bytes("res://client_data/data/model/prontera/chair_01.rsm") - #FileAccess.get_file_as_bytes("res://client_data/data/model/izlude/iz_academy.rsm") - ## TODO: not parseable - ##FileAccess.get_file_as_bytes("res://client_data/data/model/graywolf/bridge_e_01.rsm2") - #) - #) + # add window first to get the correct size + get_tree().current_scene.add_child(window) - #var scene_root := rsw.convert("pay_dun00", "res://client_data") - #var scene := PackedScene.new() - #scene.pack(scene_root) - #ResourceSaver.save(scene, "res://extractor/test/pay_dun00.tscn") + # attach window to control + if attached_to: + window.global_position = attached_to.global_position + + if anchor == SIDE_TOP: + window.global_position.y -= window.size.y + window.size.x = max(window.size.x, attached_to.size.x) + elif anchor == SIDE_BOTTOM: + window.global_position.y += attached_to.size.y + window.size.x = max(window.size.x, attached_to.size.x) + elif anchor == SIDE_LEFT: + window.global_position.x -= window.size.x + window.size.y = max(window.size.y, attached_to.size.y) + elif anchor == SIDE_RIGHT: + window.global_position.x += attached_to.size.x + window.size.y = max(window.size.y, attached_to.size.y) + + # else add window in center + else: + window.global_position = get_viewport().get_visible_rect().size * 0.5 - window.size * 0.5 + + window.minimum_size = window.size + + return window |