online multiplayer chess game (note server currently down)
remove emojis, cleaned chat, cleaned possible move ui, created go back button instead of immediately going back, removed unnecessary scripts! :sparkles:
58 files changed, 376 insertions, 1832 deletions
@@ -8,7 +8,6 @@ bend-n/chess is distributed in the hope that it will be useful, but WITHOUT ANY Files|Author(s)|License(s) --- | --- | --- -|NotoColorEmoji in assets|[Google](?)|[Apache 2.0](https://github.com/googlefonts/noto-emoji/blob/main/LICENSE)| |Cascadia Code in assets|Aaron Bell|[SILOpenFontLicense 1.1](https://github.com/microsoft/cascadia-code/blob/main/LICENSE)| |[Ubuntu](https://fonts.google.com/specimen/Ubuntu) in assets ([nerd font](https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/Ubuntu))|Daiton Mag|[Ubuntu Font License](https://ubuntu.com/legal/font-licence)| |assets/pieces/horsey|cham, michael1241|[CCBY-NC-SA4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)| diff --git a/Credentials.gd b/Credentials.gd new file mode 100644 index 0000000..34eef5f --- /dev/null +++ b/Credentials.gd @@ -0,0 +1,29 @@ +extends Node +class_name Credentials + +const default_id_data := {uuid = "", name = "", country = "rainbow", password = ""} +const file := "user://.chess.id" + +var data := default_id_data + + +func _ready(): + var lod = SaveLoad.load(file) + data = lod if Utils.dict_cmp(lod, default_id_data) else default_id_data + + +func reset(): + data = default_id_data + save() + + +func save() -> void: + SaveLoad.save(file, data, false) + + +func get(property: String) -> String: + return data[property] + + +func get_public() -> Dictionary: # obviously the uuid is public. This actually just means ok for server: must not be used to send to other clients, directly. the id will be filtered out + return {id = data.uuid, name = data.name, country = data.country} diff --git a/Game.tscn b/Game.tscn deleted file mode 100644 index 1c9f55a..0000000 --- a/Game.tscn +++ /dev/null @@ -1,247 +0,0 @@ -[gd_scene load_steps=34 format=2] - -[ext_resource path="res://Game.gd" type="Script" id=1] -[ext_resource path="res://assets/ui/whitespace.png" type="Texture" id=2] -[ext_resource path="res://ui/theme/transblack.tres" type="StyleBox" id=3] -[ext_resource path="res://ui/menus/sidebarright/SidebarRight.tscn" type="PackedScene" id=4] -[ext_resource path="res://ui/theme/flatblack.tres" type="StyleBox" id=7] -[ext_resource path="res://ui/chat/Chat.tscn" type="PackedScene" id=9] -[ext_resource path="res://ui/theme/main.theme" type="Theme" id=10] -[ext_resource path="res://assets/ui/ubuntu/ubuntu-bold.ttf" type="DynamicFontData" id=11] -[ext_resource path="res://ui/theme/buttonhover.tres" type="StyleBox" id=12] -[ext_resource path="res://assets/ui/ubuntu/ubuntu-normal-nerd.ttf" type="DynamicFontData" id=13] -[ext_resource path="res://ui/theme/button.tres" type="StyleBox" id=14] -[ext_resource path="res://assets/ui/button.png" type="Texture" id=15] -[ext_resource path="res://assets/ui/checkedbox.png" type="Texture" id=16] -[ext_resource path="res://assets/ui/CascadiaCode.ttf" type="DynamicFontData" id=17] -[ext_resource path="res://assets/ui/ubuntu/ubuntu-bold-italic.ttf" type="DynamicFontData" id=18] -[ext_resource path="res://ui/board/Board.tscn" type="PackedScene" id=29] - -[sub_resource type="StyleBoxTexture" id=6] -texture = ExtResource( 15 ) -region_rect = Rect2( 0, 0, 84, 84 ) -margin_left = 28.0 -margin_right = 28.0 -margin_top = 28.0 -margin_bottom = 28.0 -modulate_color = Color( 0.772549, 0.772549, 0.772549, 0.54902 ) - -[sub_resource type="StyleBoxEmpty" id=7] - -[sub_resource type="StyleBoxEmpty" id=8] - -[sub_resource type="StyleBoxEmpty" id=9] - -[sub_resource type="StyleBoxEmpty" id=4] - -[sub_resource type="StyleBoxFlat" id=3] -bg_color = Color( 0.0784314, 0.0784314, 0.0784314, 1 ) -border_width_left = 2 -border_width_top = 2 -border_width_right = 2 -border_width_bottom = 2 -border_color = Color( 1, 1, 1, 1 ) -corner_detail = 20 -expand_margin_left = 10.0 -expand_margin_right = 10.0 - -[sub_resource type="DynamicFont" id=18] -size = 20 -font_data = ExtResource( 11 ) - -[sub_resource type="DynamicFont" id=19] -size = 20 -font_data = ExtResource( 18 ) - -[sub_resource type="DynamicFont" id=14] -size = 20 -font_data = ExtResource( 17 ) - -[sub_resource type="DynamicFont" id=20] -size = 25 -font_data = ExtResource( 13 ) - -[sub_resource type="StyleBoxFlat" id=10] -content_margin_left = 30.0 -content_margin_right = 30.0 -content_margin_top = 30.0 -content_margin_bottom = 30.0 -bg_color = Color( 0, 0, 0, 0.313726 ) -border_blend = true -corner_radius_top_left = 50 -corner_radius_top_right = 50 -corner_radius_bottom_right = 30 -corner_radius_bottom_left = 30 -corner_detail = 15 - -[sub_resource type="StyleBoxFlat" id=12] -content_margin_left = 10.0 -content_margin_right = 10.0 -bg_color = Color( 0, 0, 0, 0.313726 ) -border_width_left = 3 -border_width_top = 3 -border_width_right = 3 -border_width_bottom = 1 -border_color = Color( 0, 0, 0, 0.392157 ) - -[sub_resource type="StyleBoxFlat" id=11] -content_margin_left = 10.0 -content_margin_right = 10.0 -bg_color = Color( 0.188235, 0.188235, 0.188235, 1 ) -border_width_left = 3 -border_width_top = 3 -border_width_right = 3 -border_width_bottom = 1 -border_color = Color( 0, 0, 0, 0.392157 ) - -[sub_resource type="StyleBoxEmpty" id=5] - -[sub_resource type="StyleBoxFlat" id=13] -content_margin_left = 10.0 -content_margin_right = 10.0 -content_margin_bottom = 10.0 -bg_color = Color( 0, 0, 0, 0.588235 ) -border_width_top = 65 -border_color = Color( 0.180392, 0.180392, 0.180392, 1 ) -corner_radius_top_left = 30 -corner_radius_top_right = 30 -corner_radius_bottom_right = 30 -corner_radius_bottom_left = 30 -corner_detail = 15 -expand_margin_top = 65.0 - -[sub_resource type="DynamicFont" id=15] -size = 20 -font_data = ExtResource( 11 ) - -[sub_resource type="Theme" id=16] -default_font = SubResource( 15 ) -Button/colors/font_color = Color( 1, 1, 1, 1 ) -Button/colors/font_color_disabled = Color( 1, 1, 1, 0.305882 ) -Button/colors/font_color_focus = Color( 1, 1, 1, 1 ) -Button/colors/font_color_hover = Color( 0, 0, 0, 1 ) -Button/colors/font_color_pressed = Color( 1, 1, 1, 1 ) -Button/styles/disabled = SubResource( 6 ) -Button/styles/focus = ExtResource( 14 ) -Button/styles/hover = ExtResource( 12 ) -Button/styles/normal = ExtResource( 14 ) -Button/styles/pressed = ExtResource( 14 ) -CheckBox/icons/checked = ExtResource( 16 ) -CheckBox/icons/checked_disabled = null -CheckBox/icons/radio_checked = null -CheckBox/icons/radio_checked_disabled = null -CheckBox/icons/radio_unchecked = null -CheckBox/icons/radio_unchecked_disabled = null -CheckBox/icons/unchecked = ExtResource( 15 ) -CheckBox/icons/unchecked_disabled = null -ColorPicker/icons/color_sample = ExtResource( 2 ) -ColorPicker/icons/overbright_indicator = ExtResource( 2 ) -ColorPicker/icons/preset_bg = ExtResource( 2 ) -ColorPicker/icons/screen_picker = ExtResource( 2 ) -ColorPickerButton/colors/font_color = Color( 1, 1, 1, 1 ) -ColorPickerButton/colors/font_color_disabled = Color( 1, 1, 1, 0.301961 ) -ColorPickerButton/colors/font_color_focus = Color( 1, 1, 1, 1 ) -ColorPickerButton/colors/font_color_hover = Color( 1, 1, 1, 1 ) -ColorPickerButton/colors/font_color_pressed = Color( 0.913725, 0.913725, 0.913725, 1 ) -ColorPickerButton/icons/bg = ExtResource( 2 ) -HBoxContainer/constants/separation = 15 -HSlider/styles/grabber_area = SubResource( 7 ) -HSlider/styles/grabber_area_highlight = SubResource( 8 ) -HSlider/styles/slider = SubResource( 9 ) -ItemList/colors/font_color = Color( 1, 1, 1, 1 ) -ItemList/colors/font_color_selected = Color( 0.905882, 0.905882, 0.905882, 1 ) -ItemList/styles/bg = SubResource( 4 ) -ItemList/styles/bg_focus = ExtResource( 7 ) -LineEdit/colors/cursor_color = Color( 1, 1, 1, 1 ) -LineEdit/colors/font_color = Color( 1, 1, 1, 1 ) -LineEdit/colors/font_color_uneditable = Color( 1, 1, 1, 0.67451 ) -LineEdit/styles/focus = ExtResource( 14 ) -LineEdit/styles/normal = ExtResource( 14 ) -LineEdit/styles/read_only = ExtResource( 14 ) -OptionButton/colors/font_color = Color( 1, 1, 1, 1 ) -OptionButton/colors/font_color_focus = Color( 1, 1, 1, 1 ) -OptionButton/colors/font_color_hover = Color( 0, 0, 0, 1 ) -OptionButton/colors/font_color_pressed = Color( 1, 1, 1, 1 ) -OptionButton/icons/arrow = ExtResource( 2 ) -PopupMenu/colors/font_color = Color( 1, 1, 1, 1 ) -PopupMenu/colors/font_color_accel = Color( 1, 1, 1, 0.8 ) -PopupMenu/colors/font_color_hover = Color( 1, 1, 1, 1 ) -PopupMenu/colors/font_color_separator = Color( 0.262745, 0.262745, 0.262745, 1 ) -PopupMenu/icons/radio_checked = ExtResource( 2 ) -PopupMenu/icons/radio_unchecked = ExtResource( 2 ) -PopupMenu/styles/hover = SubResource( 3 ) -PopupMenu/styles/panel = ExtResource( 7 ) -PopupPanel/styles/panel = ExtResource( 3 ) -RichTextLabel/colors/default_color = Color( 1, 1, 1, 1 ) -RichTextLabel/fonts/bold_font = SubResource( 18 ) -RichTextLabel/fonts/bold_italics_font = SubResource( 19 ) -RichTextLabel/fonts/italics_font = SubResource( 19 ) -RichTextLabel/fonts/mono_font = SubResource( 14 ) -RichTextLabel/fonts/normal_font = SubResource( 20 ) -SpinBox/icons/updown = ExtResource( 2 ) -TabContainer/colors/font_color_bg = Color( 0.709804, 0.709804, 0.709804, 0.72549 ) -TabContainer/colors/font_color_fg = Color( 1, 1, 1, 1 ) -TabContainer/styles/panel = SubResource( 10 ) -TabContainer/styles/tab_bg = SubResource( 12 ) -TabContainer/styles/tab_fg = SubResource( 11 ) -VBoxContainer/constants/separation = 15 -VScrollBar/styles/scroll = SubResource( 5 ) -WindowDialog/colors/title_color = Color( 1, 1, 1, 1 ) -WindowDialog/constants/close_h_ofs = 0 -WindowDialog/constants/close_v_ofs = 0 -WindowDialog/constants/title_height = 60 -WindowDialog/icons/close = ExtResource( 2 ) -WindowDialog/icons/close_highlight = ExtResource( 2 ) -WindowDialog/styles/panel = SubResource( 13 ) - -[node name="Game" type="MarginContainer"] -anchor_right = 1.0 -anchor_bottom = 1.0 -mouse_filter = 2 -script = ExtResource( 1 ) - -[node name="Holder" type="HBoxContainer" parent="."] -margin_right = 1422.0 -margin_bottom = 800.0 -mouse_filter = 2 -theme = ExtResource( 10 ) -custom_constants/separation = 0 - -[node name="Spacer" type="Control" parent="Holder"] -margin_right = 300.0 -margin_bottom = 800.0 -rect_min_size = Vector2( 300, 0 ) -mouse_filter = 2 -theme = SubResource( 16 ) - -[node name="middle" type="VBoxContainer" parent="Holder"] -margin_left = 300.0 -margin_right = 940.0 -margin_bottom = 800.0 -rect_min_size = Vector2( 640, 640 ) -mouse_filter = 2 -custom_constants/separation = 0 - -[node name="Board" parent="Holder/middle" instance=ExtResource( 29 )] -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_right = 640.0 -margin_bottom = 640.0 -sidebar_path = NodePath("../../SidebarRight") -ui_path = NodePath("../../..") - -[node name="Chat" parent="Holder/middle" instance=ExtResource( 9 )] -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 640.0 -margin_right = 640.0 -margin_bottom = 800.0 -size_flags_vertical = 3 - -[node name="SidebarRight" parent="Holder" instance=ExtResource( 4 )] -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 940.0 -margin_right = 1422.0 -margin_bottom = 800.0 -rect_min_size = Vector2( 400, 0 ) @@ -1,22 +1,25 @@ -extends MarginContainer +extends ColorRect class_name BackgroundSquare +# warning-ignore-all:unused_signal signal clicked signal right_clicked -var color: Color +var move_indicators := [] +var square: String +var piece_above := false onready var circle: TextureRect = $CircleHolder/Circle onready var move_indicator: ColorRect = $MoveIndicator -onready var b_square: ColorRect = $BackgroundSquare func _ready() -> void: + Events.connect("turn_over", self, "check_piece_above") + connect("clicked", self, "clicked") + check_piece_above() move_indicator.color = Globals.grid.last_move_indicator_color - b_square.color = color circle.rect_min_size = Globals.grid.piece_size / 4 circle.material.set_shader_param("color", Globals.grid.overlay_color) - circle.visible = false rect_min_size = Globals.grid.piece_size if Globals.spectating: mouse_default_cursor_shape = CURSOR_FORBIDDEN @@ -24,7 +27,34 @@ func _ready() -> void: mouse_default_cursor_shape = CURSOR_POINTING_HAND +func check_piece_above(): + piece_above = is_instance_valid(Globals.grid.get_piece(square)) + + func _gui_input(event: InputEvent): if !Globals.spectating and event is InputEventMouseButton and event.pressed: emit_signal("clicked" if event.button_index == BUTTON_LEFT else "right_clicked") get_tree().set_input_as_handled() + + +func _focus_exited(): + if piece_above: + Globals.grid.get_piece(square).background.hide() + for m in move_indicators: + if is_instance_valid(m): + m.hide() + move_indicators.clear() + + +func clicked(): + var b = Globals.grid + var p = b.get_piece(square) + if piece_above and b.chess.turn == Globals.team and not Globals.spectating and p.color == Globals.team: + p.background.show() + var movs = b.chess.__generate_moves({"square": square, "verbose": true}) + for m in movs: + if m.flags & Chess.BITS.CAPTURE: + move_indicators.append(b.board[m.to].frame) + else: + move_indicators.append(b.background_array[m.to].circle) + move_indicators[-1].show() diff --git a/Square.tscn b/Square.tscn index 76e168a..aa172e8 100644 --- a/Square.tscn +++ b/Square.tscn @@ -26,28 +26,25 @@ shader = SubResource( 2 ) shader_param/amt = 1.0 shader_param/color = Color( 0.431373, 0.584314, 0.388235, 0.639216 ) -[node name="MarginContainer" type="MarginContainer"] +[node name="Square" type="ColorRect"] margin_right = 40.0 margin_bottom = 40.0 +focus_mode = 1 script = ExtResource( 1 ) -[node name="BackgroundSquare" type="ColorRect" parent="."] -margin_right = 40.0 -margin_bottom = 40.0 -mouse_filter = 2 - [node name="MoveIndicator" type="ColorRect" parent="."] visible = false -margin_right = 40.0 -margin_bottom = 40.0 +anchor_right = 1.0 +anchor_bottom = 1.0 mouse_filter = 2 [node name="CircleHolder" type="CenterContainer" parent="."] -margin_right = 40.0 -margin_bottom = 40.0 +anchor_right = 1.0 +anchor_bottom = 1.0 mouse_filter = 2 [node name="Circle" type="TextureRect" parent="CircleHolder"] +visible = false material = SubResource( 3 ) margin_left = 20.0 margin_top = 20.0 @@ -56,3 +53,5 @@ margin_bottom = 20.0 mouse_filter = 2 texture = ExtResource( 2 ) expand = true + +[connection signal="focus_exited" from="." to="." method="_focus_exited"] @@ -1,6 +1,6 @@ extends Node -var internet := false +var internet := false # is internet available static func compile(src: String) -> RegEx: @@ -29,12 +29,8 @@ func get_args() -> Dictionary: func _ready() -> void: + request() # check internet ok? cli() - var t = Timer.new() - add_child(t) - t.name = "t" - t.connect("timeout", self, "_on_timeout", [t]) - _on_timeout(t) func cli() -> void: @@ -50,6 +46,9 @@ func cli() -> void: print(options) get_tree().quit() # dont wait if "host" in args or "join" in args: + if !internet: + printerr("No internet") + get_tree().quit() yield(PacketHandler, "connection_established") if "host" in args && args.host: print("hosting game: %s" % args.host) @@ -70,11 +69,6 @@ func cli() -> void: # "debug" is handled by Debug.gd -func _on_timeout(timer: Timer) -> void: - timer.start(600) # every 10m - request() # ping server so it doesnt go down - - static func exec_ext() -> String: if OS.has_feature("Windows"): return ".exe" @@ -148,3 +142,24 @@ static func append_dict(dict: Dictionary, newdict: Dictionary) -> Dictionary: for key in newdict: dict[key] = newdict[key] return dict + + +static func sort(arr: Array) -> Array: + arr.sort() + return arr + + +static func value_types(arr: Array) -> Array: + var types = [] + for value in arr: + types.append(typeof(value)) + types.sort() + return types + + +static func dict_cmp(d1: Dictionary, d2: Dictionary) -> bool: + return ( + len(d1) == len(d2) + and sort(d1.keys()) == sort(d2.keys()) + and value_types(d1.values()) == value_types(d2.values()) + ) diff --git a/assets/NotoColorEmoji.ttf b/assets/NotoColorEmoji.ttf deleted file mode 100644 index e4685a0..0000000 --- a/assets/NotoColorEmoji.ttf +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:33d225e31cabfbd738168ca5f02ec031f61abc97caab916c63f92124e59544fa -size 450740 diff --git a/networking/PacketHandler.gd b/networking/PacketHandler.gd index 89a5cb6..8f7803e 100644 --- a/networking/PacketHandler.gd +++ b/networking/PacketHandler.gd @@ -97,9 +97,8 @@ func _data_recieved() -> void: Log.info("load pgn " + text) Globals.grid.load_pgn(text) # call deferred wont work since grid obj may be null HEADERS.stopgame: - if !leaving: # dont go back if its a stophost thing (HACK) + if !Globals.grid.chess.game_over(): # dont go back if its a stophost thing or the game is over by the st (HACK) go_back(text, true) - leaving = false HEADERS.signal: var signal: Dictionary = text match signal.type: @@ -155,7 +154,6 @@ func handle_result(accepted, resultstring: String) -> bool: func go_back(error: String, isok: bool) -> void: - stopgame(game_code) Globals.reset_vars() if has_node("/root/Game"): $"/root/Game".queue_free() @@ -167,7 +165,7 @@ func go_back(error: String, isok: bool) -> void: func _start_game() -> void: set_hosting(false) - var board: Control = load("res://Game.tscn").instance() + var board: Control = load("res://ui/board/Game.tscn").instance() get_tree().get_root().add_child(board) lobby.toggle(false) emit_signal("start_game") @@ -190,16 +188,16 @@ func signal(body: Dictionary, header: String, _mainheader := HEADERS.signal) -> func join_game(game: String = game_code) -> void: - send_gamecode_packet(SaveLoad.get_public_info(), HEADERS.joinrequest, game) + send_gamecode_packet(Creds.get_public(), HEADERS.joinrequest, game) func host_game(game: String = game_code, white := true, moves_array: PoolStringArray = []) -> void: - var pckt := Utils.append_dict(SaveLoad.get_public_info(), {team = white, moves = moves_array}) + var pckt := Utils.append_dict(Creds.get_public(), {team = white, moves = moves_array}) send_gamecode_packet(pckt, HEADERS.hostrequest, game) func spectate(game: String = game_code) -> void: - send_gamecode_packet(SaveLoad.get_public_info(), HEADERS.spectate, game) + send_gamecode_packet(Creds.get_public(), HEADERS.spectate, game) func send_gamecode_packet(data: Dictionary, header: String, gamecode: String = game_code): diff --git a/project.godot b/project.godot index c4143f0..48c6dc9 100644 --- a/project.godot +++ b/project.godot @@ -9,7 +9,12 @@ config_version=4 _global_script_classes=[ { -"base": "MarginContainer", +"base": "Button", +"class": "BackButton", +"language": "GDScript", +"path": "res://ui/board/BackButton.gd" +}, { +"base": "ColorRect", "class": "BackgroundSquare", "language": "GDScript", "path": "res://Square.gd" @@ -19,11 +24,6 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://ui/barbutton/BarTextureButton.gd" }, { -"base": "KeyUtils", -"class": "CapsLock", -"language": "GDScript", -"path": "res://ui/virtual_keyboard/CapsLock.gd" -}, { "base": "Control", "class": "Chat", "language": "GDScript", @@ -64,6 +64,11 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://ui/menus/sidebarright/confirmbutton.gd" }, { +"base": "Node", +"class": "Credentials", +"language": "GDScript", +"path": "res://Credentials.gd" +}, { "base": "ConfirmButton", "class": "DrawButton", "language": "GDScript", @@ -109,16 +114,6 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://ui/menus/account/InfoLabel.gd" }, { -"base": "KeyUtils", -"class": "Key", -"language": "GDScript", -"path": "res://ui/virtual_keyboard/Key.gd" -}, { -"base": "Button", -"class": "KeyUtils", -"language": "GDScript", -"path": "res://ui/virtual_keyboard/KeyUtils.gd" -}, { "base": "Control", "class": "Lobby", "language": "GDScript", @@ -194,11 +189,6 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://ui/slider_button/SliderButton.gd" }, { -"base": "KeyUtils", -"class": "SpecialKey", -"language": "GDScript", -"path": "res://ui/virtual_keyboard/SpecialKey.gd" -}, { "base": "Label", "class": "StatusLabel", "language": "GDScript", @@ -214,20 +204,20 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://ui/menus/sidebarright/undobutton.gd" }, { +"base": "PanelContainer", +"class": "UserPanel", +"language": "GDScript", +"path": "res://ui/menus/sidebarright/UserPanel.gd" +}, { "base": "Control", "class": "UsernamePass", "language": "GDScript", "path": "res://ui/menus/account/usernamepass.gd" -}, { -"base": "CanvasLayer", -"class": "VirtualKeyboard", -"language": "GDScript", -"path": "res://ui/virtual_keyboard/VirtualKeyboard.gd" } ] _global_script_class_icons={ +"BackButton": "", "BackgroundSquare": "", "BarTextureButton": "", -"CapsLock": "", "Chat": "", "CheckBoxButton": "", "Chess": "", @@ -236,6 +226,7 @@ _global_script_class_icons={ "ColorSelect": "", "Confirm": "", "ConfirmButton": "", +"Credentials": "", "DrawButton": "", "ExpandableTextEdit": "", "FEN": "", @@ -245,8 +236,6 @@ _global_script_class_icons={ "GridMenuButton": "", "HueSlider": "", "InfoLabel": "", -"Key": "", -"KeyUtils": "", "Lobby": "", "MaterialLabel": "", "MaterialLabelManager": "", @@ -262,12 +251,11 @@ _global_script_class_icons={ "Restrict": "", "SaveLoader": "", "SliderButton": "", -"SpecialKey": "", "StatusLabel": "", "TextEditor": "", "UndoButton": "", -"UsernamePass": "", -"VirtualKeyboard": "" +"UserPanel": "", +"UsernamePass": "" } [application] @@ -295,6 +283,7 @@ Debug="*res://Debug.gd" Pgn="*res://PGN/PGN.gd" Log="*res://Log.gd" Fen="*res://FEN/Fen.gd" +Creds="*res://Credentials.gd" [debug] diff --git a/saveload.gd b/saveload.gd index 1e1f476..cbdb8f4 100644 --- a/saveload.gd +++ b/saveload.gd @@ -1,9 +1,6 @@ extends Node class_name SaveLoader -const settings_file := "user://chess.settings" -const id := "user://.chess.id" - var file: File = File.new() const default_settings_data = { @@ -16,28 +13,6 @@ const default_settings_data = { rainbow = false } -const default_id_data = {id = "", name = "", country = "rainbow", password = ""} - -var files := { - settings = {file = settings_file, data = default_settings_data.duplicate(true)}, - id = {file = id, data = default_id_data.duplicate()} -} # file types - - -func get_public_info(): - return {name = files.id.data.name, country = files.id.data.country, id = files.id.data.id} - - -func get_data(type: String) -> Dictionary: - if !files.has(type): - return {} - return files[type].data - - -func _ready() -> void: - SaveLoad.load_data("settings") - SaveLoad.load_data("id") - static func to_base64(variant) -> String: return Marshalls.variant_to_base64(variant) @@ -47,11 +22,7 @@ static func from_base64(base64: String): return Marshalls.base64_to_variant(base64) -func save(type: String) -> void: - save_dict(files[type]["file"], files[type]["data"]) - - -func save_dict(path: String, data: Dictionary, plain := false) -> void: +func save(path: String, data: Dictionary, plain := true) -> void: file.open(path, File.WRITE) file.store_string(var2str(data) if plain else to_base64(data)) file.close() @@ -76,18 +47,11 @@ func load_string(path: String) -> String: var string = file.get_as_text() file.close() return string + save_string(path, "") # create file if it doesn't exist return "" -func load_data(type: String) -> Dictionary: - var read_dictionary = load_file(files[type]["file"]) - if files[type]["data"].keys() == read_dictionary.keys(): - files[type]["data"] = read_dictionary - save(type) # write over old data - return files[type]["data"] - - -func load_file(path: String) -> Dictionary: +func load(path: String) -> Dictionary: if file.file_exists(path): file.open(path, File.READ) var text := file.get_as_text() @@ -100,8 +64,5 @@ func load_file(path: String) -> Dictionary: dict = from_base64(text) file.close() return dict + save(path, {}) # create file if it doesn't exist return {} - - -func check_file(type: String) -> bool: - return file.file_exists(files[type]["file"]) diff --git a/ui/barbutton/BarTextureButton.gd b/ui/barbutton/BarTextureButton.gd index 3a7e488..579d4b1 100644 --- a/ui/barbutton/BarTextureButton.gd +++ b/ui/barbutton/BarTextureButton.gd @@ -1,7 +1,7 @@ extends TextureButton class_name BarTextureButton -var focused: bool +var focused: bool setget _focused export(Color) var normal_color := Color.black export(Color) var highlight_color := Color(0.670588, 0.352941, 0.352941) @@ -10,9 +10,12 @@ export(Color) var disabled_color := Color(0.501961, 0.501961, 0.501961) onready var background := $Background +var n := 0 + func _ready() -> void: _focused(false) + n = round(rand_range(10, 20)) func set_disabled(new: bool) -> void: @@ -21,8 +24,9 @@ func set_disabled(new: bool) -> void: mouse_default_cursor_shape = CURSOR_FORBIDDEN if disabled else CURSOR_POINTING_HAND -func _input(_event: InputEvent): - _update() +func _process(_delta): + if visible and Engine.get_idle_frames() % n == 0: + _update() func _update(): diff --git a/ui/barbutton/big-ubuntu-bold.tres b/ui/barbutton/big-ubuntu-bold.tres index 9e5894d..e2d611b 100644 --- a/ui/barbutton/big-ubuntu-bold.tres +++ b/ui/barbutton/big-ubuntu-bold.tres @@ -1,11 +1,9 @@ -[gd_resource type="DynamicFont" load_steps=4 format=2] +[gd_resource type="DynamicFont" load_steps=3 format=2] [ext_resource path="res://assets/ui/ubuntu/ubuntu-normal-nerd.ttf" type="DynamicFontData" id=1] -[ext_resource path="res://assets/NotoColorEmoji.ttf" type="DynamicFontData" id=2] [ext_resource path="res://assets/ui/ubuntu/ubuntu-bold.ttf" type="DynamicFontData" id=3] [resource] size = 85 font_data = ExtResource( 3 ) -fallback/0 = ExtResource( 2 ) -fallback/1 = ExtResource( 1 ) +fallback/0 = ExtResource( 1 ) diff --git a/ui/board/BackButton.gd b/ui/board/BackButton.gd new file mode 100644 index 0000000..9d0d362 --- /dev/null +++ b/ui/board/BackButton.gd @@ -0,0 +1,14 @@ +extends Button +class_name BackButton + + +func _ready(): + Events.connect("game_over", self, "game_over") + + +func _pressed(): + Events.emit_signal("go_back", "", true) + + +func game_over(_reason: String, _ok: bool) -> void: + show() diff --git a/ui/board/Board.gd b/ui/board/Board.gd index 4a7495a..70c21de 100644 --- a/ui/board/Board.gd +++ b/ui/board/Board.gd @@ -34,8 +34,7 @@ func set_piece(alg: String, p: Piece) -> void: var flipped = false var labels = {numbers = [], letters = []} var background_array = [] -var last_clicked: Piece = null -var last_clicked_moves := [] +var last_clicked export(NodePath) var sidebar_path = @"" onready var sidebar := get_node_or_null(sidebar_path) @@ -62,10 +61,9 @@ func _ready(): PacketHandler.connect("move_data", self, "move") rect_min_size = piece_size * 8 rect_pivot_offset = rect_min_size / 2 - board.resize(128) + create_pieces() init_board() init_labels() - create_pieces() func init_board() -> void: # create the board @@ -74,6 +72,7 @@ func init_board() -> void: # create the board var alg = Chess.algebraic(i) var square := Square.instance() # create a square square.name = alg + square.square = alg square.hint_tooltip = alg square.color = (Globals.board_color1 if Chess.square_color(alg) == "light" else Globals.board_color2) # set the color background.add_child(square) # add the square to the background @@ -105,6 +104,7 @@ func init_label(i: int, position: Vector2, text: String, off := Vector2.ZERO, va func create_pieces(): + board.resize(128) for k in Chess.SQUARE_MAP: var piece = chess.get(k) if piece: @@ -163,34 +163,20 @@ func square_clicked(clicked_square: String) -> void: if !p or p.color != Globals.team: if !is_instance_valid(last_clicked): return - for m in last_clicked_moves: + for m in chess.moves({square = last_clicked.position, verbose = true}): if m.to == clicked_square && m.from == last_clicked.position: move(m.san, false) break - clear_circles() - - elif last_clicked != p: - if is_instance_valid(last_clicked): - clear_circles() - last_clicked = p - p.background.show() - var movs = chess.moves({"square": clicked_square, "verbose": true}) - for mov in movs: - if "c" in mov.flags: - get_piece(mov.to).frame.show() - else: - background_array[Chess.SQUARE_MAP[mov.to]].circle.show() - #e.p && castling dont really need attention here - last_clicked_moves.append(mov) + clear_last_clicked() + return + last_clicked = p func move(san: String, is_recieved_move := true) -> void: var sound_handled = false var move_0x88 = chess.__move_from_san(san, true) - if ( - chess.moves({square = chess.algebraic(move_0x88.from), stripped = true}).find(chess.stripped_san(san)) - == -1 - ): + var valid_moves = chess.moves({square = chess.algebraic(move_0x88.from), stripped = true}) + if valid_moves.find(chess.stripped_san(san)) == -1: Log.err("Invalid move") return chess.__make_move(move_0x88) @@ -235,17 +221,9 @@ func move(san: String, is_recieved_move := true) -> void: Events.emit_signal("turn_over") -func clear_circles(): - darken.hide() - if not last_clicked: - return - last_clicked.background.hide() - for move in last_clicked_moves: - if ("c" in move.flags or "e" in move.flags) and get_piece(move.to): # the take may have been used as the move, so this may just do nothing. on enpasant - get_piece(move.to).frame.hide() # for the take circle - background_array[Chess.SQUARE_MAP[move.to]].circle.hide() - last_clicked_moves = [] +func clear_last_clicked(): last_clicked = null + darken.hide() func clear_pieces() -> void: @@ -259,10 +237,9 @@ func clear_pieces() -> void: func draw(reason := "") -> void: var string = "draw by " + reason ui.set_status(string, 0) - Events.emit_signal("game_over", string, true) SoundFx.play("Victory") - yield(get_tree().create_timer(5), "timeout") - Events.emit_signal("go_back", string, true) + Events.emit_signal("game_over", string, true) + PacketHandler.stopgame("game over") func win(winner: String, reason := "") -> void: @@ -270,8 +247,7 @@ func win(winner: String, reason := "") -> void: ui.set_status(string, 0) #: black won the game by checkmate Events.emit_signal("game_over", string, true) SoundFx.play("Victory") - yield(get_tree().create_timer(5), "timeout") - Events.emit_signal("go_back", string, true) + PacketHandler.stopgame("game over") func load_pgn(pgn: String) -> void: @@ -291,12 +267,14 @@ func undo(two: bool = false) -> void: Globals.chat.server("undid move %s" % chess.undo().san) emit_signal("remove_last") clear_pieces() - clear_circles() + clear_last_clicked() create_pieces() Events.emit_signal("turn_over") func _on_turn_over(): + SaveLoad.save("user://game.json", {pgn = chess.pgn(), fen = chess.fen()}) + clear_last_clicked() check_game_over() create_last_move_indicators() diff --git a/Game.gd b/ui/board/Game.gd index 654636d..834a3da 100644 --- a/Game.gd +++ b/ui/board/Game.gd @@ -21,16 +21,16 @@ func get_board() -> Node: func _spectate_info(info: Dictionary) -> void: - var whitepnl = panels[0] + var whitepnl: UserPanel = panels[0] set_panel(whitepnl, info.white.name, info.white.country) - var blackpnl = panels[1] + var blackpnl: UserPanel = panels[1] set_panel(blackpnl, info.black.name, info.black.country) func _on_info(info: Dictionary) -> void: - var enemy_int = 1 if Globals.team == "w" else 0 + var enemy_int := int(Globals.team == "w") set_panel(panels[enemy_int], info.name, info.country) # enemy panel - set_panel(panels[abs(enemy_int - 1)], SaveLoad.get_data("id").name, SaveLoad.get_data("id").country) # own panel + set_panel(panels[abs(enemy_int - 1)], Creds.get("name"), Creds.get("country")) # own panel func set_panel(pnl, name, country) -> void: diff --git a/ui/board/Game.tscn b/ui/board/Game.tscn new file mode 100644 index 0000000..f2c11ce --- /dev/null +++ b/ui/board/Game.tscn @@ -0,0 +1,63 @@ +[gd_scene load_steps=7 format=2] + +[ext_resource path="res://ui/theme/main.theme" type="Theme" id=1] +[ext_resource path="res://ui/menus/sidebarright/SidebarRight.tscn" type="PackedScene" id=2] +[ext_resource path="res://ui/chat/Chat.tscn" type="PackedScene" id=3] +[ext_resource path="res://ui/board/Game.gd" type="Script" id=4] +[ext_resource path="res://ui/board/Board.tscn" type="PackedScene" id=5] +[ext_resource path="res://ui/board/BackButton.gd" type="Script" id=6] + +[node name="Game" type="MarginContainer"] +anchor_right = 1.0 +anchor_bottom = 1.0 +mouse_filter = 2 +script = ExtResource( 4 ) + +[node name="Holder" type="HBoxContainer" parent="."] +margin_right = 1422.0 +margin_bottom = 800.0 +mouse_filter = 2 +theme = ExtResource( 1 ) +custom_constants/separation = 0 + +[node name="Chat" parent="Holder" instance=ExtResource( 3 )] +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_right = 391.0 +margin_bottom = 800.0 +size_flags_horizontal = 3 + +[node name="middle" type="VBoxContainer" parent="Holder"] +margin_left = 391.0 +margin_right = 1031.0 +margin_bottom = 800.0 +rect_min_size = Vector2( 640, 640 ) +mouse_filter = 2 +custom_constants/separation = 10 + +[node name="Board" parent="Holder/middle" instance=ExtResource( 5 )] +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_right = 640.0 +margin_bottom = 640.0 +sidebar_path = NodePath("../../SidebarRight") +ui_path = NodePath("../../..") + +[node name="BackButton" type="Button" parent="Holder/middle"] +visible = false +margin_left = 210.0 +margin_top = 650.0 +margin_right = 430.0 +margin_bottom = 752.0 +rect_min_size = Vector2( 220, 0 ) +size_flags_horizontal = 4 +size_flags_vertical = 4 +text = "go back" +script = ExtResource( 6 ) + +[node name="SidebarRight" parent="Holder" instance=ExtResource( 2 )] +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 1031.0 +margin_right = 1422.0 +margin_bottom = 800.0 diff --git a/ui/chat/Chat.gd b/ui/chat/Chat.gd index 5543783..b223f96 100644 --- a/ui/chat/Chat.gd +++ b/ui/chat/Chat.gd @@ -2,8 +2,6 @@ extends Control class_name Chat onready var list: MessageList = $v/MessageList -onready var kb = $v/Keyboard -onready var dsk_input: TextEditor = $v/DesktopInput var regexes := [ [Utils.compile("_([^_]+)_"), "[i]$1[/i]"], @@ -20,94 +18,6 @@ var regexes := [ "[url]$1[/url]" ], ] -var emoji_replace_regex: RegEx = Utils.compile(":[^:]{1,30}:") - -const piece_emoji_path = "res://assets/pieces/cburnett/" -const emoji_path = "res://assets/emojis/" -const emojis := { - ":grinning:": "😀", - ":smiley:": "😃", - ":smile:": "😄", - ":grin:": "😁", - [":laughing:", ":satisfied:"]: "😆", - ":sweat_smile:": "😅", - ":joy:": "😂", - ":rofl:": "🤣", - ":blush:": "😊", - ":innocent:": "😇", - [":slight_smile:", ":slightly_smiling:"]: "🙂", - [":upside_down:", ":upside_down:"]: "🙃", - ":wink:": "😉", - ":relieved:": "😌", - ":tear_smile:": "🥲", - ":heart_eyes:": "😍", - ":hearty:": "🥰", - ":stuck_out_tongue_winking_eye:": "😜", - ":yum:": "😋", - ":stuck_out_tongue_closed_eyes:": "😝", - ":stuck_out_tongue:": "😛", - ":raised_eyebrow:": "🤨", - ":sunglasses:": "😎", - ":nerd:": "🤓", - ":star_struck:": "🤩", - ":partying:": "🥳", - ":smirk:": "😏", - ":unamused:": "😒", - ":disappointed:": "😞", - ":pensive:": "😔", - ":worried:": "😟", - ":confused:": "😕", - ":frown:": "🙁", - ":persevere:": "😣", - ":confounded:": "😖", - ":tired:": "😫", - ":weary:": "😩", - ":cry:": "😢", - ":sob:": "😭", - ":triumph:": "😤", - ":angry:": "😠", - ":rage:": "😡", - ":no_mouth:": "😶", - ":sleeping:": "😴", - ":cold:": "🥶", - ":neutral:": "😐", - ":expressionless:": "😑", - ":hushed:": "😯", - ":frowning:": "😦", - ":anguished:": "😧", - ":open_mouth:": "😮", - ":astonished:": "😲", - ":dizzy:": "😵", - ":scream:": "😱", - ":fearful:": "😨", - ":cold_sweat:": "😰", - ":disappointed_relieved:": "😥", - ":sweat:": "😓", - ":sleepy:": "😪", - ":devil:": "😈", - ":face_with_rolling_eyes:": "🙄", - ":lying:": "🤥", - ":grimacing:": "😬", - ":zipped_mouth:": "🤐", - ":nauseated:": "🤢", - ":sneezing:": "🤧", - ":mask:": "😷", - ":face_with_thermometer:": "🤒", - ":face_with_head_bandage:": "🤕", - ":smiley_cat:": "😺", - ":smile_cat:": "😸", - ":joy_cat:": "😹", - ":heart_eyes_cat:": "😻", - ":turtle:": "🐢", - ":cat:": "🐈", - ":smirk_cat:": "😼", - ":scream_cat:": "🙀", - ":cat_joy:": "😹", - ":cat_grin:": "😸", - ":crying_cat:": "😿", - ":pouting_cat:": "😾", -} -var expanded_emojis = {} # create smokey centered text @@ -123,38 +33,7 @@ func _exit_tree(): Globals.chat = null -func expand_emojis(): - for trigger_list in emojis: - if typeof(trigger_list) == TYPE_ARRAY: - for trigger in trigger_list: - expanded_emojis[trigger] = emojis[trigger_list] - else: - expanded_emojis[trigger_list] = emojis[trigger_list] - - -func setup_text_input(): - if OS.has_touchscreen_ui_hint(): - # dsk_input is a little dummy button that just opens the kb and shows text on mobile - kb.connect("done", self, "send") - kb.connect("closed", dsk_input, "set_text") - kb.text.emojibutton._setup(emojis) - dsk_input.textedit.connect("focus_entered", self, "open_kb") - Log.info("Mobile keyboard setup") - else: - kb.free() - dsk_input.show() - dsk_input.connect("done", self, "send") - - dsk_input.emojibutton._setup(emojis) - - -func open_kb(): - kb.open(dsk_input.text) - - func _ready(): - expand_emojis() - setup_text_input() PacketHandler.connect("chat", self, "add_label_with") server("Welcome!") # say hello yield(get_tree().create_timer(.4), "timeout") @@ -167,12 +46,8 @@ func add_label_with(data: Dictionary) -> void: func send(t: String) -> void: - t = t.strip_edges() - if !t: - return - t = md2bb(emoji2bb(t)) - var name_data = SaveLoad.get_data("id").name - var name = name_data if name_data else "Anonymous" + t = md2bb(t) + var name = Creds.get("name") if Creds.get("name") else "Anonymous" name += "(%s)" % ("Spectator" if Globals.spectating else Globals.team) if PacketHandler.connected: PacketHandler.relay_signal({"text": t, "who": name}, PacketHandler.RELAYHEADERS.chat) @@ -193,11 +68,3 @@ func md2bb(input: String) -> String: input = replacement[0].sub(input, replacement[1], true) input = input.replace("\\", "") # remove escapers return input - - -func emoji2bb(input: String) -> String: - for i in emoji_replace_regex.search_all(input): - var emoji = i.strings[0] - if emoji in expanded_emojis: - input = input.replace(emoji, "%s" % expanded_emojis[emoji]) - return input diff --git a/ui/chat/Chat.tscn b/ui/chat/Chat.tscn index 0bad13e..59da6c2 100644 --- a/ui/chat/Chat.tscn +++ b/ui/chat/Chat.tscn @@ -1,9 +1,8 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://ui/chat/chat_theme.tres" type="Theme" id=1] [ext_resource path="res://ui/chat/Chat.gd" type="Script" id=2] [ext_resource path="res://ui/chat/MessageList.tscn" type="PackedScene" id=3] -[ext_resource path="res://ui/virtual_keyboard/VirtualKeyboard.tscn" type="PackedScene" id=4] [ext_resource path="res://ui/chat/TextEditor.tscn" type="PackedScene" id=5] [node name="Chat" type="MarginContainer"] @@ -22,11 +21,12 @@ custom_constants/separation = 0 anchor_right = 0.0 anchor_bottom = 0.0 margin_right = 1422.0 -margin_bottom = 750.0 +margin_bottom = 777.0 +mouse_filter = 2 -[node name="DesktopInput" parent="v" instance=ExtResource( 5 )] -margin_top = 750.0 +[node name="Input" parent="v" instance=ExtResource( 5 )] +margin_top = 777.0 margin_right = 1422.0 margin_bottom = 800.0 -[node name="Keyboard" parent="v" instance=ExtResource( 4 )] +[connection signal="done" from="v/Input" to="." method="send"] diff --git a/ui/chat/ExpandableTextEdit.gd b/ui/chat/ExpandableTextEdit.gd index 2e338f5..fa25b4f 100644 --- a/ui/chat/ExpandableTextEdit.gd +++ b/ui/chat/ExpandableTextEdit.gd @@ -20,7 +20,7 @@ func _ready(): line_count = _get_real_line_count() _update_height(line_count) - connect("text_changed", self, "_text_changed") + connect("text_changed", self, "_on_text_changed") func _get_line_spacing(): @@ -65,11 +65,7 @@ func _update_height(count): update() -func _text_changed(): - _on_text_changed(false) - - -func _on_text_changed(force = false): +func _on_text_changed(force := false): var new_line_count = _get_real_line_count() if force or line_count != new_line_count: line_count = new_line_count diff --git a/ui/chat/MessageList.tscn b/ui/chat/MessageList.tscn index ba2703e..630d18f 100644 --- a/ui/chat/MessageList.tscn +++ b/ui/chat/MessageList.tscn @@ -3,7 +3,7 @@ [ext_resource path="res://ui/chat/MessageList.gd" type="Script" id=1] [sub_resource type="StyleBoxFlat" id=1] -bg_color = Color( 0.188235, 0.180392, 0.172549, 1 ) +bg_color = Color( 0.14902, 0.141176, 0.129412, 0.784314 ) [node name="MessageList" type="PanelContainer"] anchor_right = 1.0 diff --git a/ui/chat/TextEditor.gd b/ui/chat/TextEditor.gd index 578b7d7..aa879b3 100644 --- a/ui/chat/TextEditor.gd +++ b/ui/chat/TextEditor.gd @@ -20,9 +20,6 @@ onready var textedit: TextEdit = get_node(textedit_path) export(NodePath) var placeholder_path onready var placeholder := get_node(placeholder_path) -export(NodePath) var emojibutton_path -onready var emojibutton := get_node(emojibutton_path) - func _text_changed() -> void: placeholder.visible = len(textedit.text) == 0 diff --git a/ui/chat/TextEditor.tscn b/ui/chat/TextEditor.tscn index 8b61bab..199ba2e 100644 --- a/ui/chat/TextEditor.tscn +++ b/ui/chat/TextEditor.tscn @@ -1,24 +1,12 @@ -[gd_scene load_steps=13 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://ui/chat/textedit.gd" type="Script" id=1] -[ext_resource path="res://ui/chat/emojibutton.gd" type="Script" id=2] -[ext_resource path="res://ui/gridmenu/GridMenu.gd" type="Script" id=3] -[ext_resource path="res://ui/chat/grayscale.shader" type="Shader" id=4] -[ext_resource path="res://ui/chat/emoji_button_font.tres" type="DynamicFont" id=5] [ext_resource path="res://ui/chat/chat_theme.tres" type="Theme" id=6] [ext_resource path="res://ui/chat/TextEditor.gd" type="Script" id=7] [ext_resource path="res://ui/theme/richtextlabel/tiny.tres" type="DynamicFont" id=8] [sub_resource type="StyleBoxFlat" id=2] -bg_color = Color( 0.25098, 0.266667, 0.294118, 1 ) - -[sub_resource type="ShaderMaterial" id=3] -shader = ExtResource( 4 ) -shader_param/saturation = 0.0 - -[sub_resource type="StyleBoxEmpty" id=5] - -[sub_resource type="StyleBoxEmpty" id=4] +bg_color = Color( 0.1, 0.0948, 0.087, 0.784314 ) [node name="TextEditor" type="PanelContainer"] margin_right = 965.0 @@ -26,24 +14,18 @@ margin_bottom = 50.0 theme = ExtResource( 6 ) custom_styles/panel = SubResource( 2 ) script = ExtResource( 7 ) -textedit_path = NodePath("TextBar/TextEditHolder/text") -placeholder_path = NodePath("TextBar/TextEditHolder/placeholder") -emojibutton_path = NodePath("TextBar/EmojiButtonHoldler/EmojiButton") +textedit_path = NodePath("TextEditHolder/text") +placeholder_path = NodePath("TextEditHolder/placeholder") -[node name="TextBar" type="HBoxContainer" parent="."] +[node name="TextEditHolder" type="MarginContainer" parent="."] margin_right = 965.0 margin_bottom = 50.0 -custom_constants/separation = 0 - -[node name="TextEditHolder" type="MarginContainer" parent="TextBar"] -margin_right = 915.0 -margin_bottom = 50.0 size_flags_horizontal = 3 size_flags_vertical = 3 custom_constants/margin_right = 5 custom_constants/margin_left = 5 -[node name="placeholder" type="Label" parent="TextBar/TextEditHolder"] +[node name="placeholder" type="Label" parent="TextEditHolder"] margin_left = 5.0 margin_top = 13.0 margin_right = 141.0 @@ -53,59 +35,21 @@ custom_colors/font_color = Color( 1, 1, 1, 0.509804 ) text = "write text here" valign = 2 -[node name="text" type="TextEdit" parent="TextBar/TextEditHolder"] +[node name="text" type="TextEdit" parent="TextEditHolder"] margin_left = 5.0 margin_top = 15.0 -margin_right = 910.0 +margin_right = 960.0 margin_bottom = 35.0 rect_min_size = Vector2( 200, 20 ) size_flags_vertical = 4 custom_fonts/font = ExtResource( 8 ) context_menu_enabled = false -virtual_keyboard_enabled = false smooth_scrolling = true wrap_enabled = true caret_blink = true +caret_blink_speed = 0.45 script = ExtResource( 1 ) max_lines = 4 -[node name="EmojiButtonHoldler" type="MarginContainer" parent="TextBar"] -margin_left = 915.0 -margin_right = 965.0 -margin_bottom = 50.0 -size_flags_horizontal = 8 -size_flags_vertical = 0 - -[node name="EmojiButton" type="Button" parent="TextBar/EmojiButtonHoldler"] -material = SubResource( 3 ) -margin_right = 50.0 -margin_bottom = 50.0 -rect_min_size = Vector2( 50, 50 ) -focus_mode = 1 -mouse_default_cursor_shape = 2 -custom_fonts/font = ExtResource( 5 ) -custom_styles/hover = SubResource( 5 ) -custom_styles/pressed = SubResource( 5 ) -custom_styles/focus = SubResource( 5 ) -custom_styles/disabled = SubResource( 5 ) -custom_styles/normal = SubResource( 5 ) -text = "😿" -flat = true -script = ExtResource( 2 ) -offset = Vector2( -350, -350 ) - -[node name="Popup" type="PopupPanel" parent="TextBar/EmojiButtonHoldler/EmojiButton"] -visible = true -custom_styles/panel = SubResource( 4 ) - -[node name="EmojiMenu" type="GridContainer" parent="TextBar/EmojiButtonHoldler/EmojiButton/Popup"] -custom_constants/vseparation = 0 -custom_constants/hseparation = 0 -script = ExtResource( 3 ) - -[connection signal="send" from="TextBar/TextEditHolder/text" to="." method="_on_text_send"] -[connection signal="text_changed" from="TextBar/TextEditHolder/text" to="." method="_text_changed"] -[connection signal="emoji_selected" from="TextBar/EmojiButtonHoldler/EmojiButton" to="TextBar/TextEditHolder/text" method="_emoji_selected"] -[connection signal="mouse_entered" from="TextBar/EmojiButtonHoldler/EmojiButton" to="TextBar/EmojiButtonHoldler/EmojiButton" method="_focused" binds= [ true ]] -[connection signal="mouse_exited" from="TextBar/EmojiButtonHoldler/EmojiButton" to="TextBar/EmojiButtonHoldler/EmojiButton" method="_focused" binds= [ false ]] -[connection signal="pressed" from="TextBar/EmojiButtonHoldler/EmojiButton/Popup/EmojiMenu" to="TextBar/EmojiButtonHoldler/EmojiButton" method="_on_EmojiMenu_pressed"] +[connection signal="send" from="TextEditHolder/text" to="." method="_on_text_send"] +[connection signal="text_changed" from="TextEditHolder/text" to="." method="_text_changed"] diff --git a/ui/chat/chat_theme.tres b/ui/chat/chat_theme.tres index 5b507a1..5a26d6c 100644 --- a/ui/chat/chat_theme.tres +++ b/ui/chat/chat_theme.tres @@ -1,26 +1,15 @@ -[gd_resource type="Theme" load_steps=30 format=2] +[gd_resource type="Theme" load_steps=19 format=2] [ext_resource path="res://ui/theme/richtextlabel/tiny-bold.tres" type="DynamicFont" id=1] [ext_resource path="res://assets/ui/CascadiaCode.ttf" type="DynamicFontData" id=2] [ext_resource path="res://assets/ui/whitespace.png" type="Texture" id=4] -[ext_resource path="res://assets/NotoColorEmoji.ttf" type="DynamicFontData" id=6] [ext_resource path="res://ui/theme/richtextlabel/tiny-italic.tres" type="DynamicFont" id=7] [ext_resource path="res://ui/theme/button.tres" type="StyleBox" id=8] -[ext_resource path="res://ui/barbutton/default_pressed.tres" type="StyleBox" id=9] -[ext_resource path="res://ui/theme/transblack.tres" type="StyleBox" id=10] [ext_resource path="res://ui/theme/flatblack.tres" type="StyleBox" id=11] [ext_resource path="res://ui/theme/richtextlabel/tiny.tres" type="DynamicFont" id=12] -[ext_resource path="res://ui/barbutton/default_highlight.tres" type="StyleBox" id=13] -[ext_resource path="res://ui/barbutton/default.tres" type="StyleBox" id=14] [ext_resource path="res://ui/theme/richtextlabel/tiny-bold-italic.tres" type="DynamicFont" id=15] [ext_resource path="res://ui/theme/richtextlabel/tiny-Cascadia-Code.tres" type="DynamicFont" id=16] -[sub_resource type="DynamicFont" id=28] -size = 40 -font_data = ExtResource( 6 ) - -[sub_resource type="StyleBoxEmpty" id=11] - [sub_resource type="StyleBoxEmpty" id=7] [sub_resource type="StyleBoxEmpty" id=8] @@ -29,50 +18,6 @@ font_data = ExtResource( 6 ) [sub_resource type="StyleBoxEmpty" id=4] -[sub_resource type="StyleBoxFlat" id=3] -bg_color = Color( 0.0784314, 0.0784314, 0.0784314, 1 ) -border_width_left = 2 -border_width_top = 2 -border_width_right = 2 -border_width_bottom = 2 -border_color = Color( 1, 1, 1, 1 ) -corner_detail = 20 -expand_margin_left = 10.0 -expand_margin_right = 10.0 - -[sub_resource type="StyleBoxFlat" id=10] -content_margin_left = 30.0 -content_margin_right = 30.0 -content_margin_top = 30.0 -content_margin_bottom = 30.0 -bg_color = Color( 0, 0, 0, 0.313726 ) -border_blend = true -corner_radius_top_left = 50 -corner_radius_top_right = 50 -corner_radius_bottom_right = 30 -corner_radius_bottom_left = 30 -corner_detail = 15 - -[sub_resource type="StyleBoxFlat" id=12] -content_margin_left = 10.0 -content_margin_right = 10.0 -bg_color = Color( 0, 0, 0, 0.313726 ) -border_width_left = 3 -border_width_top = 3 -border_width_right = 3 -border_width_bottom = 1 -border_color = Color( 0, 0, 0, 0.392157 ) - -[sub_resource type="StyleBoxFlat" id=23] -content_margin_left = 10.0 -content_margin_right = 10.0 -bg_color = Color( 0.188235, 0.188235, 0.188235, 1 ) -border_width_left = 3 -border_width_top = 3 -border_width_right = 3 -border_width_bottom = 1 -border_color = Color( 0, 0, 0, 0.392157 ) - [sub_resource type="StyleBoxEmpty" id=21] [sub_resource type="StyleBoxEmpty" id=5] @@ -101,27 +46,6 @@ fallback/0 = ExtResource( 2 ) [resource] default_font = SubResource( 27 ) -Button/colors/font_color = Color( 1, 1, 1, 1 ) -Button/colors/font_color_disabled = Color( 0.643137, 0.592157, 0.592157, 0.2 ) -Button/colors/font_color_focus = Color( 1, 1, 1, 1 ) -Button/colors/font_color_hover = Color( 1, 1, 1, 1 ) -Button/colors/font_color_pressed = Color( 1, 1, 1, 1 ) -Button/fonts/font = SubResource( 28 ) -Button/styles/disabled = ExtResource( 14 ) -Button/styles/focus = SubResource( 11 ) -Button/styles/hover = ExtResource( 13 ) -Button/styles/normal = ExtResource( 14 ) -Button/styles/pressed = ExtResource( 9 ) -ColorPicker/icons/color_sample = ExtResource( 4 ) -ColorPicker/icons/overbright_indicator = ExtResource( 4 ) -ColorPicker/icons/preset_bg = ExtResource( 4 ) -ColorPicker/icons/screen_picker = ExtResource( 4 ) -ColorPickerButton/colors/font_color = Color( 1, 1, 1, 1 ) -ColorPickerButton/colors/font_color_disabled = Color( 1, 1, 1, 0.301961 ) -ColorPickerButton/colors/font_color_focus = Color( 1, 1, 1, 1 ) -ColorPickerButton/colors/font_color_hover = Color( 1, 1, 1, 1 ) -ColorPickerButton/colors/font_color_pressed = Color( 0.913725, 0.913725, 0.913725, 1 ) -ColorPickerButton/icons/bg = ExtResource( 4 ) HBoxContainer/constants/separation = 15 HSlider/styles/grabber_area = SubResource( 7 ) HSlider/styles/grabber_area_highlight = SubResource( 8 ) @@ -136,32 +60,12 @@ LineEdit/colors/font_color_uneditable = Color( 1, 1, 1, 0.67451 ) LineEdit/styles/focus = ExtResource( 8 ) LineEdit/styles/normal = ExtResource( 8 ) LineEdit/styles/read_only = ExtResource( 8 ) -OptionButton/colors/font_color = Color( 1, 1, 1, 1 ) -OptionButton/colors/font_color_focus = Color( 1, 1, 1, 1 ) -OptionButton/colors/font_color_hover = Color( 0, 0, 0, 1 ) -OptionButton/colors/font_color_pressed = Color( 1, 1, 1, 1 ) -OptionButton/icons/arrow = ExtResource( 4 ) -PopupMenu/colors/font_color = Color( 1, 1, 1, 1 ) -PopupMenu/colors/font_color_accel = Color( 1, 1, 1, 0.8 ) -PopupMenu/colors/font_color_hover = Color( 1, 1, 1, 1 ) -PopupMenu/colors/font_color_separator = Color( 0.262745, 0.262745, 0.262745, 1 ) -PopupMenu/icons/radio_checked = ExtResource( 4 ) -PopupMenu/icons/radio_unchecked = ExtResource( 4 ) -PopupMenu/styles/hover = SubResource( 3 ) -PopupMenu/styles/panel = ExtResource( 11 ) -PopupPanel/styles/panel = ExtResource( 10 ) RichTextLabel/colors/default_color = Color( 1, 1, 1, 1 ) RichTextLabel/fonts/bold_font = ExtResource( 1 ) RichTextLabel/fonts/bold_italics_font = ExtResource( 15 ) RichTextLabel/fonts/italics_font = ExtResource( 7 ) RichTextLabel/fonts/mono_font = ExtResource( 16 ) RichTextLabel/fonts/normal_font = ExtResource( 12 ) -SpinBox/icons/updown = ExtResource( 4 ) -TabContainer/colors/font_color_bg = Color( 0.709804, 0.709804, 0.709804, 0.72549 ) -TabContainer/colors/font_color_fg = Color( 1, 1, 1, 1 ) -TabContainer/styles/panel = SubResource( 10 ) -TabContainer/styles/tab_bg = SubResource( 12 ) -TabContainer/styles/tab_fg = SubResource( 23 ) TextEdit/styles/normal = SubResource( 21 ) VBoxContainer/constants/separation = 15 VScrollBar/styles/scroll = SubResource( 5 ) diff --git a/ui/chat/emoji_button_font.tres b/ui/chat/emoji_button_font.tres deleted file mode 100644 index fc2bb55..0000000 --- a/ui/chat/emoji_button_font.tres +++ /dev/null @@ -1,7 +0,0 @@ -[gd_resource type="DynamicFont" load_steps=2 format=2] - -[ext_resource path="res://assets/NotoColorEmoji.ttf" type="DynamicFontData" id=2] - -[resource] -size = 50 -font_data = ExtResource( 2 ) diff --git a/ui/chat/emojibutton.gd b/ui/chat/emojibutton.gd deleted file mode 100644 index 5303da4..0000000 --- a/ui/chat/emojibutton.gd +++ /dev/null @@ -1,90 +0,0 @@ -extends Button - -export(float) var scale_normal := 0.8 -export(float) var scale_hover := 1.0 -var cur_scale := scale_normal - -export(float) var saturation_normal := 0.0 -export(float) var saturation_hover := 1.0 -var cur_saturation := saturation_normal - -export(float) var weight := 0.35 - -export(Vector2) var offset = Vector2.ZERO - -var emojis := {} - -var focused := false - -signal emoji_selected(emoji) - -onready var emojimenu: GridMenu = $Popup/EmojiMenu -onready var popup: PopupPanel = $Popup -var font: DynamicFont = load("res://ui/chat/emoji_button_font.tres") -onready var font_size = font.size - - -func change_icon(): - if emojis: - text = emojis.values()[randi() % len(emojis)] - - -func _ready(): - scale() - set_process(false) - - -func _setup(_emojis: Dictionary): - emojis = _emojis - change_icon() - for key in emojis.keys(): - emojimenu.add_text_item(emojis[key], arr2tooltip(key), Vector2(40, 40)) - - -func arr2tooltip(arr) -> String: - if typeof(arr) == TYPE_ARRAY: - var string = "" - for i in arr: - string += i + " " - return string - return arr - - -func _focused(q: bool): - focused = q - if q: - change_icon() - set_process(true) - - -func _process(_delta: float) -> void: - if focused: - cur_scale = lerp(cur_scale, scale_hover, weight) - cur_saturation = lerp(cur_saturation, saturation_hover, weight) - else: - cur_scale = lerp(cur_scale, scale_normal, weight) - cur_saturation = lerp(cur_saturation, saturation_normal, weight) - if is_equal_approx(cur_scale, scale_normal): - set_process(false) - - scale() - material.set_shader_param("saturation", cur_saturation) - - -func scale(): - font.size = cur_scale * font_size - - -func _pressed() -> void: - popup.popup() - emojimenu.open() - yield(get_tree(), "idle_frame") - popup.rect_global_position = rect_global_position + offset - - -func _on_EmojiMenu_pressed(index: int): - emit_signal( - "emoji_selected", - emojis.keys()[index] if typeof(emojis.keys()[index]) == TYPE_STRING else emojis.keys()[index][0] - ) - popup.hide() diff --git a/ui/chat/grayscale.shader b/ui/chat/grayscale.shader deleted file mode 100644 index 61f3970..0000000 --- a/ui/chat/grayscale.shader +++ /dev/null @@ -1,8 +0,0 @@ -shader_type canvas_item; -uniform float saturation: hint_range(0.0, 1.0) = 0.0; - -void fragment() { - vec4 tex_color = texture(TEXTURE, (UV)); - COLOR.rgb = mix(vec3(dot(tex_color.rgb, vec3(0.299, 0.587, 0.114))), tex_color.rgb, saturation); // magic numbers - COLOR.a = tex_color.a; -}
\ No newline at end of file diff --git a/ui/chat/textedit.gd b/ui/chat/textedit.gd index 4aa92da..e34a6f4 100644 --- a/ui/chat/textedit.gd +++ b/ui/chat/textedit.gd @@ -2,41 +2,19 @@ extends ExpandableTextEdit signal send(msg) -const auto_complete = [ - "bigsmile", - "cold", - "cry", - "flushed", - "happy", - "hmm", - "huh", - "kiss", - "oh", - "smile", - "unhappy", - "upsidedown_smile", - "weary", - "what", - "wink_tongue", - "wink", - "wow", - "zany", - "..." -] - func _input(event: InputEvent) -> void: - if event is InputEventKey: - if event.pressed: - var key_name = OS.get_scancode_string(event.get_scancode_with_modifiers()) - if key_name == "Enter" or key_name == "Kp Enter": - get_tree().set_input_as_handled() - if text.length() != 0: - emit_signal("send", text) - text = "" - emit_signal("text_changed") - - -func _emoji_selected(emoji: String): - text += emoji - emit_signal("text_changed") + if ( + event is InputEventKey + and OS.get_scancode_string(event.get_scancode_with_modifiers()) in ["Kp Enter", "Enter"] + and event.pressed + ): + get_tree().set_input_as_handled() + if has_focus(): + text = text.strip_edges() + if text: + emit_signal("send", text) + text = "" + emit_signal("text_changed") + else: + grab_focus() diff --git a/ui/colorpicker/ColorPicker.tscn b/ui/colorpicker/ColorPicker.tscn index e499dc5..3bbde35 100644 --- a/ui/colorpicker/ColorPicker.tscn +++ b/ui/colorpicker/ColorPicker.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=10 format=2] +[gd_scene load_steps=11 format=2] [ext_resource path="res://ui/colorpicker/ColorPicker.gd" type="Script" id=1] +[ext_resource path="res://assets/ui/ubuntu/ubuntu-normal-nerd.ttf" type="DynamicFontData" id=2] [ext_resource path="res://ui/barbutton/BarButton.theme" type="Theme" id=3] [ext_resource path="res://assets/ui/ubuntu/ubuntu-bold.ttf" type="DynamicFontData" id=4] [ext_resource path="res://ui/colorpicker/HueSlider.gd" type="Script" id=6] @@ -10,7 +11,9 @@ [ext_resource path="res://ui/colorpicker/ColorSelect.material" type="Material" id=11] [sub_resource type="DynamicFont" id=1] +size = 17 font_data = ExtResource( 4 ) +fallback/0 = ExtResource( 2 ) [node name="ColorPicker" type="Control"] margin_right = 125.0 @@ -70,11 +73,10 @@ margin_bottom = 125.0 custom_constants/separation = 0 [node name="Close" type="Button" parent="V/H2"] - focus_mode = 0 margin_right = 20.0 margin_bottom = 20.0 rect_min_size = Vector2( 20, 0 ) - +focus_mode = 0 mouse_default_cursor_shape = 2 theme = ExtResource( 3 ) custom_fonts/font = SubResource( 1 ) diff --git a/ui/menus/account/Account.gd b/ui/menus/account/Account.gd index c1bc49e..6ab623a 100644 --- a/ui/menus/account/Account.gd +++ b/ui/menus/account/Account.gd @@ -2,7 +2,6 @@ extends Control onready var flags: PoolStringArray = ["rainbow"] onready var flagchoice: GridMenuButton = $choose/signup/flag -onready var data: Dictionary = SaveLoad.get_data("id") onready var status: InfoLabel = $H/InfoLabel # not a StatusLabel onready var loading = $LoadingAnimation @@ -35,16 +34,16 @@ func _ready(): func attempt_autologin(): - if data.name and data.password: - PacketHandler.signin(data) + if Creds.data.name and Creds.data.password: + PacketHandler.signin(Creds.data) else: reset("", false) -func _on_signin_pressed(): +func signin(): $choose/signin/signinbutton.disabled = true update_data(tabs.signin.username, tabs.signin.pw) - PacketHandler.signin(data) + PacketHandler.signin(Creds.data) func _on_signin_result(result): @@ -55,57 +54,48 @@ func _on_signin_result(result): $choose/signin/signinbutton.disabled = false if typeof(result) == TYPE_STRING: # ew, error, get it away from me return reset(result, status_set) - data.id = result.id - data.country = result.country - _after_result() + Creds.data.uuid = result.id # server uses `id` instead of `uuid`... + Creds.data.country = result.country + on_successful() -func _on_signup_pressed(): +func signup(): $choose/signup/signupbutton.disabled = true - data.country = flags[flagchoice.selected] + Creds.data.country = flags[flagchoice.selected] update_data(tabs.signup.username, tabs.signup.pw) - PacketHandler.signup(data) + PacketHandler.signup(Creds.data) func _on_signup_result(result: String): $choose/signup/signupbutton.disabled = false if "err:" in result: # ew error go awway return reset(result) - data.id = result - _after_result() + Creds.data.uuid = result + on_successful() func reset(reason: String, set_status := true): if set_status: status.set_text(reason, 0) - data = SaveLoad.default_id_data + Creds.reset() tabcontainer.show() loading.hide() set_signed_in(false) - save_data() - tabcontainer.show() -func _after_result(): - save_data() +func on_successful(): + Creds.save() loading.hide() - status.set_text("Signed in to " + SaveLoad.get_data("id").name, 0) + status.set_text("Signed in to " + Creds.get("name"), 0) set_signed_in(true) # yay $H/LogOut.show() - tabcontainer.hide() func update_data(username, pw): - username.text = username.get_text().strip_edges().strip_escapes() - data.name = username.get_text() - data.password = pw.get_text() - save_data() - - -func save_data(): - SaveLoad.files.id.data = data - SaveLoad.save("id") + Creds.data.name = username.get_text() + Creds.data.password = pw.get_text() + Creds.save() func _on_choose_tab_changed(tab: int): diff --git a/ui/menus/account/Account.tscn b/ui/menus/account/Account.tscn index c5e1c32..fa20b02 100644 --- a/ui/menus/account/Account.tscn +++ b/ui/menus/account/Account.tscn @@ -120,5 +120,7 @@ expand = true [connection signal="pressed" from="H/LogOut" to="." method="log_out"] [connection signal="tab_changed" from="choose" to="." method="_on_choose_tab_changed"] -[connection signal="pressed" from="choose/signup/signupbutton" to="." method="_on_signup_pressed"] -[connection signal="pressed" from="choose/signin/signinbutton" to="." method="_on_signin_pressed"] +[connection signal="done" from="choose/signup/usernamepass" to="." method="signup"] +[connection signal="pressed" from="choose/signup/signupbutton" to="." method="signup"] +[connection signal="done" from="choose/signin/usernamepass" to="." method="signin"] +[connection signal="pressed" from="choose/signin/signinbutton" to="." method="signin"] diff --git a/ui/menus/account/Password.gd b/ui/menus/account/Password.gd deleted file mode 100644 index 32db589..0000000 --- a/ui/menus/account/Password.gd +++ /dev/null @@ -1 +0,0 @@ -extends Restrict diff --git a/ui/menus/account/Restrict.gd b/ui/menus/account/Restrict.gd index 5786d80..c1b6470 100644 --- a/ui/menus/account/Restrict.gd +++ b/ui/menus/account/Restrict.gd @@ -4,5 +4,9 @@ class_name Restrict func _on_text_changed(new_text: String): var pos = caret_position - text = new_text.strip_edges() + text = new_text.strip_edges().strip_escapes() caret_position = pos + + +func _ready(): + connect("text_changed", self, "_on_text_changed") diff --git a/ui/menus/account/Username.gd b/ui/menus/account/Username.gd deleted file mode 100644 index 32db589..0000000 --- a/ui/menus/account/Username.gd +++ /dev/null @@ -1 +0,0 @@ -extends Restrict diff --git a/ui/menus/account/usernamepass.gd b/ui/menus/account/usernamepass.gd index 851152f..40a7ccf 100644 --- a/ui/menus/account/usernamepass.gd +++ b/ui/menus/account/usernamepass.gd @@ -4,6 +4,8 @@ class_name UsernamePass onready var username = $Username onready var pw = $H/Password +signal done + func update_data(data: Dictionary) -> void: username.text = data.user @@ -24,3 +26,8 @@ func export_data() -> Dictionary: func set_enabled(enabled: bool) -> void: username.editable = enabled pw.editable = enabled + + +func _entered(_nt := "") -> void: + if username.text and pw.text: + emit_signal("done") diff --git a/ui/menus/account/usernamepass.tscn b/ui/menus/account/usernamepass.tscn index 9ec2469..5f0b303 100644 --- a/ui/menus/account/usernamepass.tscn +++ b/ui/menus/account/usernamepass.tscn @@ -1,15 +1,10 @@ -[gd_scene load_steps=9 format=2] +[gd_scene load_steps=7 format=2] -[ext_resource path="res://assets/ui/ubuntu/ubuntu-bold.ttf" type="DynamicFontData" id=1] +[ext_resource path="res://ui/barbutton/big-ubuntu-bold.tres" type="DynamicFont" id=1] [ext_resource path="res://ui/menus/account/Secret.gd" type="Script" id=2] +[ext_resource path="res://ui/menus/account/Restrict.gd" type="Script" id=3] [ext_resource path="res://ui/theme/main.theme" type="Theme" id=5] [ext_resource path="res://ui/menus/account/usernamepass.gd" type="Script" id=6] -[ext_resource path="res://ui/menus/account/Password.gd" type="Script" id=7] -[ext_resource path="res://ui/menus/account/Username.gd" type="Script" id=8] - -[sub_resource type="DynamicFont" id=2] -size = 85 -font_data = ExtResource( 1 ) [sub_resource type="StyleBoxEmpty" id=1] @@ -17,6 +12,7 @@ font_data = ExtResource( 1 ) anchor_right = 1.0 anchor_bottom = 1.0 rect_min_size = Vector2( 0, 225 ) +mouse_filter = 2 size_flags_horizontal = 4 size_flags_vertical = 4 theme = ExtResource( 5 ) @@ -35,12 +31,13 @@ max_length = 20 placeholder_text = "username goes here" caret_blink = true caret_blink_speed = 0.5 -script = ExtResource( 8 ) +script = ExtResource( 3 ) [node name="H" type="HBoxContainer" parent="."] margin_top = 405.0 margin_right = 1422.0 margin_bottom = 511.0 +mouse_filter = 2 custom_constants/separation = 2 alignment = 1 @@ -58,20 +55,19 @@ context_menu_enabled = false placeholder_text = "password goes here" caret_blink = true caret_blink_speed = 0.5 -script = ExtResource( 7 ) +script = ExtResource( 3 ) [node name="Secret" type="Button" parent="H"] - focus_mode = 0 margin_left = 1109.0 margin_right = 1215.0 margin_bottom = 106.0 rect_min_size = Vector2( 106, 106 ) - +focus_mode = 0 custom_colors/font_color_focus = Color( 1, 1, 1, 1 ) custom_colors/font_color = Color( 1, 1, 1, 1 ) custom_colors/font_color_hover = Color( 0.976471, 0.937255, 0.937255, 1 ) custom_colors/font_color_pressed = Color( 1, 1, 1, 1 ) -custom_fonts/font = SubResource( 2 ) +custom_fonts/font = ExtResource( 1 ) custom_styles/hover = SubResource( 1 ) custom_styles/pressed = SubResource( 1 ) custom_styles/focus = SubResource( 1 ) @@ -82,5 +78,5 @@ pressed = true text = "" script = ExtResource( 2 ) -[connection signal="text_changed" from="Username" to="Username" method="_on_text_changed"] -[connection signal="text_changed" from="H/Password" to="H/Password" method="_on_text_changed"] +[connection signal="text_entered" from="Username" to="." method="_entered"] +[connection signal="text_entered" from="H/Password" to="." method="_entered"] diff --git a/ui/menus/settings/Settings.gd b/ui/menus/settings/Settings.gd index ef58eb2..7c23b8a 100644 --- a/ui/menus/settings/Settings.gd +++ b/ui/menus/settings/Settings.gd @@ -1,5 +1,7 @@ extends Control +const file = "user://chess.settings" + onready var piece_sets := Utils.walk_dir() onready var piece_set_button: GridMenuButton = find_node("PieceSet") onready var fullscreenbutton := find_node("FullscreenButton") @@ -10,34 +12,44 @@ onready var board_color1: ColorPickerButtonBetter = find_node("boardcolor1") onready var board_color2: ColorPickerButtonBetter = find_node("boardcolor2") onready var rainbow = find_node("rainbow") -onready var settings: Dictionary = SaveLoad.get_data("settings") setget set_settings +onready var settings: Dictionary = default_settings_data setget set_settings + +const default_settings_data = { + vsync = OS.vsync_enabled, + fullscreen = OS.window_fullscreen, + borderless = OS.window_borderless, + piece_set = "california", + board_color1 = Color(0.870588, 0.890196, 0.901961), + board_color2 = Color(0.54902, 0.635294, 0.678431), + rainbow = false +} var ignore_set_settings = false func set_settings(new_settings: Dictionary) -> void: - if ignore_set_settings: - return - update_button_visuals(new_settings) - settings = new_settings - SaveLoad.files["settings"]["data"] = settings - SaveLoad.save("settings") + if not ignore_set_settings: + update_button_visuals(new_settings) + settings = new_settings + SaveLoad.save(file, settings) func update_button_visuals(set: Dictionary = settings) -> void: ignore_set_settings = true - vsyncbutton.pressed = set["vsync"] - fullscreenbutton.pressed = set["fullscreen"] + vsyncbutton.pressed = set.vsync + fullscreenbutton.pressed = set.fullscreen if is_instance_valid(borderlessbutton): - borderlessbutton.pressed = !set["borderless"] - board_color1.color = set["board_color1"] - board_color2.color = set["board_color2"] - rainbow.pressed = set["rainbow"] - preview.update_preview(set["board_color1"], set["board_color2"], set["piece_set"]) + borderlessbutton.pressed = !set.borderless + board_color1.color = set.board_color1 + board_color2.color = set.board_color2 + rainbow.pressed = set.rainbow + preview.update_preview(set.board_color1, set.board_color2, set.piece_set) ignore_set_settings = false func _ready() -> void: + var lod = SaveLoad.load(file) + settings = lod if Utils.dict_cmp(lod, default_settings_data) else default_settings_data if OS.has_feature("HTML5"): borderlessbutton.queue_free() for i in piece_sets: # add the items @@ -55,8 +67,7 @@ func update_vars() -> void: OS.window_fullscreen = settings.fullscreen OS.window_borderless = settings.borderless ColorBack.rainbow = settings.rainbow - SaveLoad.files["settings"]["data"] = settings - SaveLoad.save("settings") + SaveLoad.save(file, settings) func _on_PieceSet_selected(index: int) -> void: diff --git a/ui/menus/sidebarright/SidebarRight.tscn b/ui/menus/sidebarright/SidebarRight.tscn index a17e064..4542487 100644 --- a/ui/menus/sidebarright/SidebarRight.tscn +++ b/ui/menus/sidebarright/SidebarRight.tscn @@ -171,7 +171,7 @@ anchor_bottom = 0.0 margin_top = 313.0 margin_right = 1422.0 margin_bottom = 513.0 -rect_min_size = Vector2( 482, 200 ) +rect_min_size = Vector2( 0, 200 ) [node name="WhitePanel" parent="V" instance=ExtResource( 22 )] anchor_right = 0.0 diff --git a/ui/menus/sidebarright/UserPanel.gd b/ui/menus/sidebarright/UserPanel.gd index e9b3935..57b8a92 100644 --- a/ui/menus/sidebarright/UserPanel.gd +++ b/ui/menus/sidebarright/UserPanel.gd @@ -1,4 +1,5 @@ extends PanelContainer +class_name UserPanel onready var flag_display = $MC/H/Flag onready var name_display = $MC/H/Name diff --git a/ui/menus/sidebarright/material/MaterialLabel.gd b/ui/menus/sidebarright/material/MaterialLabel.gd index 79d0af4..e6ad54c 100644 --- a/ui/menus/sidebarright/material/MaterialLabel.gd +++ b/ui/menus/sidebarright/material/MaterialLabel.gd @@ -15,15 +15,17 @@ func _ready(): func display(pieces: Dictionary, score: int) -> void: get_tree().call_group("material@" + name, "free") for p in pieces: + var container := HBoxContainer.new() + container.add_constant_override("separation", -14 if p == "p" else -8) + container.add_to_group("material@" + name) + container.name = p for i in pieces[p]: var t := TextureRect.new() t.expand = true t.stretch_mode = t.STRETCH_KEEP_ASPECT t.rect_min_size = Vector2(30, 30) t.texture = load("res://assets/silhouette/%s.png" % p.to_upper()) - - add_child(t) - t.add_to_group("material@" + name) - t.name = p + container.add_child(t) + add_child(container) move_child(l, get_child_count()) l.text = ("+%d " % score) if score > 0 else "" diff --git a/ui/menus/sidebarright/material/MaterialLabelManager.gd b/ui/menus/sidebarright/material/MaterialLabelManager.gd index 6b616f0..d8982ae 100644 --- a/ui/menus/sidebarright/material/MaterialLabelManager.gd +++ b/ui/menus/sidebarright/material/MaterialLabelManager.gd @@ -50,4 +50,4 @@ func show_material_imbalance(): var d = get_material_diff() var score = get_material_score(d) w.display(d.w, score if score > 0 else 0) - b.display(d.b, abs(score) if score < 0 else 0) + b.display(d.b, int(abs(score)) if score < 0 else 0) diff --git a/ui/menus/tests/tests.gd b/ui/menus/tests/tests.gd index 124b0d0..d465d6e 100644 --- a/ui/menus/tests/tests.gd +++ b/ui/menus/tests/tests.gd @@ -12,7 +12,7 @@ func _ready(): func _load(i: int): in_sim = true - var boar = load("res://Game.tscn").instance() + var boar = load("res://ui/board/Game.tscn").instance() get_tree().get_root().add_child(boar) boar = boar.get_board() boar.load_pgn(pgns[i]) diff --git a/ui/theme/richtextlabel/tiny-Cascadia-Code.tres b/ui/theme/richtextlabel/tiny-Cascadia-Code.tres index e2d9b0e..da905dd 100644 --- a/ui/theme/richtextlabel/tiny-Cascadia-Code.tres +++ b/ui/theme/richtextlabel/tiny-Cascadia-Code.tres @@ -1,11 +1,9 @@ -[gd_resource type="DynamicFont" load_steps=4 format=2] +[gd_resource type="DynamicFont" load_steps=3 format=2] -[ext_resource path="res://assets/NotoColorEmoji.ttf" type="DynamicFontData" id=1] [ext_resource path="res://assets/ui/ubuntu/ubuntu-normal-nerd.ttf" type="DynamicFontData" id=2] [ext_resource path="res://assets/ui/CascadiaCode.ttf" type="DynamicFontData" id=3] [resource] size = 20 font_data = ExtResource( 3 ) -fallback/0 = ExtResource( 1 ) -fallback/1 = ExtResource( 2 ) +fallback/0 = ExtResource( 2 ) diff --git a/ui/theme/richtextlabel/tiny-bold-italic.tres b/ui/theme/richtextlabel/tiny-bold-italic.tres index 0284b53..e8f5c1e 100644 --- a/ui/theme/richtextlabel/tiny-bold-italic.tres +++ b/ui/theme/richtextlabel/tiny-bold-italic.tres @@ -1,11 +1,9 @@ -[gd_resource type="DynamicFont" load_steps=4 format=2] +[gd_resource type="DynamicFont" load_steps=3 format=2] -[ext_resource path="res://assets/NotoColorEmoji.ttf" type="DynamicFontData" id=1] [ext_resource path="res://assets/ui/ubuntu/ubuntu-normal-nerd.ttf" type="DynamicFontData" id=2] [ext_resource path="res://assets/ui/ubuntu/ubuntu-bold-italic.ttf" type="DynamicFontData" id=3] [resource] size = 20 font_data = ExtResource( 3 ) -fallback/0 = ExtResource( 1 ) -fallback/1 = ExtResource( 2 ) +fallback/0 = ExtResource( 2 ) diff --git a/ui/theme/richtextlabel/tiny-bold.tres b/ui/theme/richtextlabel/tiny-bold.tres index 303efda..9e5f3e2 100644 --- a/ui/theme/richtextlabel/tiny-bold.tres +++ b/ui/theme/richtextlabel/tiny-bold.tres @@ -1,11 +1,9 @@ -[gd_resource type="DynamicFont" load_steps=4 format=2] +[gd_resource type="DynamicFont" load_steps=3 format=2] [ext_resource path="res://assets/ui/ubuntu/ubuntu-bold.ttf" type="DynamicFontData" id=1] -[ext_resource path="res://assets/NotoColorEmoji.ttf" type="DynamicFontData" id=2] [ext_resource path="res://assets/ui/ubuntu/ubuntu-normal-nerd.ttf" type="DynamicFontData" id=3] [resource] size = 20 font_data = ExtResource( 1 ) -fallback/0 = ExtResource( 2 ) -fallback/1 = ExtResource( 3 ) +fallback/0 = ExtResource( 3 ) diff --git a/ui/theme/richtextlabel/tiny-italic.tres b/ui/theme/richtextlabel/tiny-italic.tres index 81da42d..7c69c96 100644 --- a/ui/theme/richtextlabel/tiny-italic.tres +++ b/ui/theme/richtextlabel/tiny-italic.tres @@ -1,11 +1,9 @@ -[gd_resource type="DynamicFont" load_steps=4 format=2] +[gd_resource type="DynamicFont" load_steps=3 format=2] [ext_resource path="res://assets/ui/ubuntu/ubuntu-italic.ttf" type="DynamicFontData" id=1] -[ext_resource path="res://assets/NotoColorEmoji.ttf" type="DynamicFontData" id=2] [ext_resource path="res://assets/ui/ubuntu/ubuntu-normal-nerd.ttf" type="DynamicFontData" id=3] [resource] size = 20 font_data = ExtResource( 1 ) -fallback/0 = ExtResource( 2 ) -fallback/1 = ExtResource( 3 ) +fallback/0 = ExtResource( 3 ) diff --git a/ui/theme/richtextlabel/tiny.tres b/ui/theme/richtextlabel/tiny.tres index b8209a3..4353c85 100644 --- a/ui/theme/richtextlabel/tiny.tres +++ b/ui/theme/richtextlabel/tiny.tres @@ -1,9 +1,7 @@ -[gd_resource type="DynamicFont" load_steps=3 format=2] +[gd_resource type="DynamicFont" load_steps=2 format=2] -[ext_resource path="res://assets/NotoColorEmoji.ttf" type="DynamicFontData" id=1] [ext_resource path="res://assets/ui/ubuntu/ubuntu-normal-nerd.ttf" type="DynamicFontData" id=2] [resource] size = 20 font_data = ExtResource( 2 ) -fallback/0 = ExtResource( 1 ) diff --git a/ui/ubuntu-bold-small.tres b/ui/ubuntu-bold-small.tres index 303efda..9e5f3e2 100644 --- a/ui/ubuntu-bold-small.tres +++ b/ui/ubuntu-bold-small.tres @@ -1,11 +1,9 @@ -[gd_resource type="DynamicFont" load_steps=4 format=2] +[gd_resource type="DynamicFont" load_steps=3 format=2] [ext_resource path="res://assets/ui/ubuntu/ubuntu-bold.ttf" type="DynamicFontData" id=1] -[ext_resource path="res://assets/NotoColorEmoji.ttf" type="DynamicFontData" id=2] [ext_resource path="res://assets/ui/ubuntu/ubuntu-normal-nerd.ttf" type="DynamicFontData" id=3] [resource] size = 20 font_data = ExtResource( 1 ) -fallback/0 = ExtResource( 2 ) -fallback/1 = ExtResource( 3 ) +fallback/0 = ExtResource( 3 ) diff --git a/ui/ubuntu-bold.tres b/ui/ubuntu-bold.tres index e47a781..4f3f409 100644 --- a/ui/ubuntu-bold.tres +++ b/ui/ubuntu-bold.tres @@ -1,11 +1,9 @@ -[gd_resource type="DynamicFont" load_steps=4 format=2] +[gd_resource type="DynamicFont" load_steps=3 format=2] [ext_resource path="res://assets/ui/ubuntu/ubuntu-normal-nerd.ttf" type="DynamicFontData" id=1] -[ext_resource path="res://assets/NotoColorEmoji.ttf" type="DynamicFontData" id=2] [ext_resource path="res://assets/ui/ubuntu/ubuntu-bold.ttf" type="DynamicFontData" id=3] [resource] size = 40 font_data = ExtResource( 3 ) -fallback/0 = ExtResource( 2 ) -fallback/1 = ExtResource( 1 ) +fallback/0 = ExtResource( 1 ) diff --git a/ui/ubuntu.tres b/ui/ubuntu.tres index 1463533..c214a6f 100644 --- a/ui/ubuntu.tres +++ b/ui/ubuntu.tres @@ -1,9 +1,7 @@ -[gd_resource type="DynamicFont" load_steps=3 format=2] +[gd_resource type="DynamicFont" load_steps=2 format=2] -[ext_resource path="res://assets/NotoColorEmoji.ttf" type="DynamicFontData" id=1] [ext_resource path="res://assets/ui/ubuntu/ubuntu-normal-nerd.ttf" type="DynamicFontData" id=2] [resource] size = 40 font_data = ExtResource( 2 ) -fallback/0 = ExtResource( 1 ) diff --git a/ui/virtual_keyboard/CapsLock.gd b/ui/virtual_keyboard/CapsLock.gd deleted file mode 100644 index 16ae665..0000000 --- a/ui/virtual_keyboard/CapsLock.gd +++ /dev/null @@ -1,9 +0,0 @@ -extends KeyUtils -class_name CapsLock - - -func _toggled(button_pressed: bool) -> void: - if button_pressed: - simulate_key_input_event(KEY_CAPSLOCK) - else: - simulate_key_input_event(KEY_CAPSLOCK, 0, false) diff --git a/ui/virtual_keyboard/Key.gd b/ui/virtual_keyboard/Key.gd deleted file mode 100644 index fb953ea..0000000 --- a/ui/virtual_keyboard/Key.gd +++ /dev/null @@ -1,64 +0,0 @@ -extends KeyUtils -class_name Key - -var scncode = 0 -var unicode = 0 -export(String) var key = "" setget set_key -export(String) var shift_key = "" setget set_shift_key -export(bool) var shift_on_capslock = false - -var shift_scncode := 0 -var shift_unicode := 0 - -var shf_p := false setget set_shift_pressed # is shift pressed - - -func set_shift_pressed(is_pressed: bool) -> void: - if shf_p != is_pressed: - shf_p = is_pressed - text = shift_key if shf_p else key - - -func set_shift_key(new_shift_key: String) -> void: - if len(new_shift_key) == 1: - shift_key = new_shift_key - shift_unicode = ord(shift_key) - shift_scncode = OS.find_scancode_from_string(shift_key) - elif new_shift_key: - print_debug("this size is incorrect") - - -func _input(event: InputEvent): - if event is InputEventKey: - if event.scancode == KEY_SHIFT: - if shift_on_capslock and shf_p and Input.is_action_pressed("caps"): - return - set_shift_pressed(event.pressed) - if event.scancode == KEY_CAPSLOCK and shift_on_capslock: - if Input.is_action_pressed("shift") and shf_p: - return - set_shift_pressed(event.pressed) - - -func set_key(new_key: String) -> void: - if len(new_key) == 1: - key = new_key - name = new_key if new_key.validate_node_name() else name - text = new_key - unicode = ord(new_key) - scncode = OS.find_scancode_from_string(key) - elif new_key: - print_debug("this size is incorrect") - - -func pressed(): - simulate_key_input_event(shift_scncode if shf_p else scncode, shift_unicode if shf_p else unicode) - - -func released(): - simulate_key_input_event(shift_scncode if shf_p else scncode, shift_unicode if shf_p else unicode, false) - - -func _ready(): - if !shift_key: - shift_key = key.to_upper() # x -> X diff --git a/ui/virtual_keyboard/Key.tscn b/ui/virtual_keyboard/Key.tscn deleted file mode 100644 index 492a1ad..0000000 --- a/ui/virtual_keyboard/Key.tscn +++ /dev/null @@ -1,18 +0,0 @@ -[gd_scene load_steps=3 format=2] - -[ext_resource path="res://ui/virtual_keyboard/kb_theme.theme" type="Theme" id=1] -[ext_resource path="res://ui/virtual_keyboard/Key.gd" type="Script" id=2] - -[node name="w" type="Button"] -margin_right = 40.0 -margin_bottom = 40.0 -rect_min_size = Vector2( 60, 60 ) - -theme = ExtResource( 1 ) -action_mode = 0 -keep_pressed_outside = true -text = "w" -script = ExtResource( 2 ) -key = "w" -shift_key = "W" -shift_on_capslock = null diff --git a/ui/virtual_keyboard/KeyUtils.gd b/ui/virtual_keyboard/KeyUtils.gd deleted file mode 100644 index 0b06d43..0000000 --- a/ui/virtual_keyboard/KeyUtils.gd +++ /dev/null @@ -1,44 +0,0 @@ -extends Button -class_name KeyUtils - -var is_pressed = false - - -func simulate_key_input_event(scancode: int, unicode := 0, pressed := true): - var i = InputEventKey.new() - i.pressed = pressed - i.scancode = scancode - i.unicode = unicode - Input.parse_input_event(i) - - -func is_mouse(event) -> bool: - return event is InputEventMouseButton and event.button_index == BUTTON_LEFT - - -func _input(event: InputEvent) -> void: - if is_mouse(event): - if !event.pressed and is_pressed: - _release() - elif event is InputEventMouseMotion: - if !get_global_rect().has_point(event.position): - _release() - - -func _release(): - if is_pressed != false: - is_pressed = false - released() - - -func _pressed(): - is_pressed = true - pressed() - - -func pressed() -> void: - pass - - -func released() -> void: - pass diff --git a/ui/virtual_keyboard/SpecialKey.gd b/ui/virtual_keyboard/SpecialKey.gd deleted file mode 100644 index a2ea71c..0000000 --- a/ui/virtual_keyboard/SpecialKey.gd +++ /dev/null @@ -1,13 +0,0 @@ -extends KeyUtils -class_name SpecialKey - -export(int) var k_scncode := 0 -var unicode := 0 - - -func pressed(): - simulate_key_input_event(k_scncode, unicode) - - -func released(): - simulate_key_input_event(k_scncode, unicode, false) diff --git a/ui/virtual_keyboard/VirtualKeyboard.gd b/ui/virtual_keyboard/VirtualKeyboard.gd deleted file mode 100644 index d0a10ff..0000000 --- a/ui/virtual_keyboard/VirtualKeyboard.gd +++ /dev/null @@ -1,47 +0,0 @@ -extends CanvasLayer -class_name VirtualKeyboard - -onready var holder = $ForceDown -var text: TextEditor - -signal done(text) -signal closed(text) - -export(PackedScene) var text_editor - - -func _ready(): - if !OS.has_touchscreen_ui_hint(): - $ForceDown/Panel/V/KeyHolder.free() # remove keys if not touchscreen - text = text_editor.instance() - $ForceDown/Panel/V.add_child(text) - $ForceDown/Panel/V.move_child(text, 0) - text.connect("done", self, "done") - - -func open(with_text: String = "") -> void: - text.text = with_text - var txedit = text.textedit - txedit.grab_focus() - txedit.cursor_set_line(txedit.get_line_count() - 1) - txedit.cursor_set_column(len(txedit.get_line(txedit.get_line_count() - 1))) - - show() - - -func hide(): - holder.hide() - - -func show(): - holder.show() - - -func done(tx := text.text) -> void: - emit_signal("done", tx) - hide() - - -func _on_Close_pressed(): - hide() - emit_signal("closed", text.text) diff --git a/ui/virtual_keyboard/VirtualKeyboard.tscn b/ui/virtual_keyboard/VirtualKeyboard.tscn deleted file mode 100644 index 969a7ca..0000000 --- a/ui/virtual_keyboard/VirtualKeyboard.tscn +++ /dev/null @@ -1,654 +0,0 @@ -[gd_scene load_steps=9 format=2] - -[ext_resource path="res://ui/virtual_keyboard/SpecialKey.gd" type="Script" id=1] -[ext_resource path="res://ui/virtual_keyboard/kb_theme.theme" type="Theme" id=2] -[ext_resource path="res://ui/virtual_keyboard/Key.gd" type="Script" id=3] -[ext_resource path="res://ui/virtual_keyboard/CapsLock.gd" type="Script" id=4] -[ext_resource path="res://ui/virtual_keyboard/VirtualKeyboard.gd" type="Script" id=5] -[ext_resource path="res://ui/chat/TextEditor.tscn" type="PackedScene" id=6] -[ext_resource path="res://ui/virtual_keyboard/Key.tscn" type="PackedScene" id=7] - -[sub_resource type="StyleBoxFlat" id=1] -content_margin_left = 15.0 -content_margin_right = 15.0 -content_margin_top = 15.0 -content_margin_bottom = 15.0 -bg_color = Color( 0.188235, 0.180392, 0.172549, 1 ) -corner_radius_top_left = 5 -corner_radius_top_right = 5 -corner_radius_bottom_right = 5 -corner_radius_bottom_left = 5 - -[node name="VirtualKeyboard" type="CanvasLayer"] -script = ExtResource( 5 ) -text_editor = ExtResource( 6 ) - -[node name="ForceDown" type="VBoxContainer" parent="."] -visible = false -anchor_right = 1.0 -anchor_bottom = 1.0 -alignment = 2 -__meta__ = { -"_edit_lock_": true -} - -[node name="Panel" type="PanelContainer" parent="ForceDown"] -margin_left = 213.0 -margin_top = 450.0 -margin_right = 1208.0 -margin_bottom = 800.0 -size_flags_horizontal = 4 -theme = ExtResource( 2 ) -custom_styles/panel = SubResource( 1 ) -__meta__ = { -"_edit_lock_": true, -"_editor_description_": "" -} - -[node name="V" type="VBoxContainer" parent="ForceDown/Panel"] -margin_left = 15.0 -margin_top = 15.0 -margin_right = 980.0 -margin_bottom = 335.0 -__meta__ = { -"_edit_lock_": true -} - -[node name="KeyHolder" type="VBoxContainer" parent="ForceDown/Panel/V"] -margin_right = 965.0 -margin_bottom = 320.0 -custom_constants/separation = 5 -__meta__ = { -"_edit_lock_": true -} - -[node name="Row1" type="HBoxContainer" parent="ForceDown/Panel/V/KeyHolder"] -margin_right = 965.0 -margin_bottom = 60.0 -custom_constants/separation = 5 -alignment = 1 -__meta__ = { -"_edit_lock_": true -} - -[node name="`" parent="ForceDown/Panel/V/KeyHolder/Row1" instance=ExtResource( 7 )] -margin_right = 60.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "`" -key = "`" -shift_key = "~" - -[node name="1" parent="ForceDown/Panel/V/KeyHolder/Row1" instance=ExtResource( 7 )] -margin_left = 65.0 -margin_right = 125.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "1" -key = "1" -shift_key = "!" - -[node name="2" parent="ForceDown/Panel/V/KeyHolder/Row1" instance=ExtResource( 7 )] -margin_left = 130.0 -margin_right = 190.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "2" -key = "2" -shift_key = "@" - -[node name="3" parent="ForceDown/Panel/V/KeyHolder/Row1" instance=ExtResource( 7 )] -margin_left = 195.0 -margin_right = 255.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "3" -key = "3" -shift_key = "#" - -[node name="4" parent="ForceDown/Panel/V/KeyHolder/Row1" instance=ExtResource( 7 )] -margin_left = 260.0 -margin_right = 320.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "4" -key = "4" -shift_key = "$" - -[node name="5" parent="ForceDown/Panel/V/KeyHolder/Row1" instance=ExtResource( 7 )] -margin_left = 325.0 -margin_right = 385.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "5" -key = "5" -shift_key = "%" - -[node name="6" parent="ForceDown/Panel/V/KeyHolder/Row1" instance=ExtResource( 7 )] -margin_left = 390.0 -margin_right = 450.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "6" -key = "6" -shift_key = "^" - -[node name="7" parent="ForceDown/Panel/V/KeyHolder/Row1" instance=ExtResource( 7 )] -margin_left = 455.0 -margin_right = 515.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "7" -key = "7" -shift_key = "&" - -[node name="8" parent="ForceDown/Panel/V/KeyHolder/Row1" instance=ExtResource( 7 )] -margin_left = 520.0 -margin_right = 580.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "8" -key = "8" -shift_key = "*" - -[node name="9" parent="ForceDown/Panel/V/KeyHolder/Row1" instance=ExtResource( 7 )] -margin_left = 585.0 -margin_right = 645.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "9" -key = "9" -shift_key = "(" - -[node name="0" parent="ForceDown/Panel/V/KeyHolder/Row1" instance=ExtResource( 7 )] -margin_left = 650.0 -margin_right = 710.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "0" -key = "0" -shift_key = ")" - -[node name="-" parent="ForceDown/Panel/V/KeyHolder/Row1" instance=ExtResource( 7 )] -margin_left = 715.0 -margin_right = 775.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "-" -key = "-" -shift_key = "_" - -[node name="=" parent="ForceDown/Panel/V/KeyHolder/Row1" instance=ExtResource( 7 )] -margin_left = 780.0 -margin_right = 840.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "=" -key = "=" -shift_key = "+" - -[node name="Backspace" type="Button" parent="ForceDown/Panel/V/KeyHolder/Row1"] -margin_left = 845.0 -margin_right = 965.0 -margin_bottom = 60.0 -rect_min_size = Vector2( 120, 45 ) -focus_mode = 0 -size_flags_horizontal = 3 -theme = ExtResource( 2 ) -action_mode = 0 -text = "" -script = ExtResource( 1 ) -k_scncode = 16777220 - -[node name="Row2" type="HBoxContainer" parent="ForceDown/Panel/V/KeyHolder"] -margin_top = 65.0 -margin_right = 965.0 -margin_bottom = 125.0 -custom_constants/separation = 5 -alignment = 1 -__meta__ = { -"_edit_lock_": true -} - -[node name="tab" type="Button" parent="ForceDown/Panel/V/KeyHolder/Row2"] -margin_right = 90.0 -margin_bottom = 60.0 -rect_min_size = Vector2( 90, 0 ) -focus_mode = 0 -size_flags_horizontal = 3 -text = "" -script = ExtResource( 1 ) -k_scncode = 16777218 - -[node name="q" parent="ForceDown/Panel/V/KeyHolder/Row2" instance=ExtResource( 7 )] -margin_left = 95.0 -margin_right = 155.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "q" -key = "q" -shift_key = "Q" -shift_on_capslock = true - -[node name="w" parent="ForceDown/Panel/V/KeyHolder/Row2" instance=ExtResource( 7 )] -margin_left = 160.0 -margin_right = 220.0 -margin_bottom = 60.0 -focus_mode = 0 -shift_on_capslock = true - -[node name="e" parent="ForceDown/Panel/V/KeyHolder/Row2" instance=ExtResource( 7 )] -margin_left = 225.0 -margin_right = 285.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "e" -key = "e" -shift_key = "E" -shift_on_capslock = true - -[node name="r" parent="ForceDown/Panel/V/KeyHolder/Row2" instance=ExtResource( 7 )] -margin_left = 290.0 -margin_right = 350.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "r" -key = "r" -shift_key = "R" -shift_on_capslock = true - -[node name="t" parent="ForceDown/Panel/V/KeyHolder/Row2" instance=ExtResource( 7 )] -margin_left = 355.0 -margin_right = 415.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "t" -key = "t" -shift_key = "T" -shift_on_capslock = true - -[node name="y" parent="ForceDown/Panel/V/KeyHolder/Row2" instance=ExtResource( 7 )] -margin_left = 420.0 -margin_right = 480.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "y" -key = "y" -shift_key = "Y" -shift_on_capslock = true - -[node name="u" parent="ForceDown/Panel/V/KeyHolder/Row2" instance=ExtResource( 7 )] -margin_left = 485.0 -margin_right = 545.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "u" -key = "u" -shift_key = "U" -shift_on_capslock = true - -[node name="i" parent="ForceDown/Panel/V/KeyHolder/Row2" instance=ExtResource( 7 )] -margin_left = 550.0 -margin_right = 610.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "i" -key = "i" -shift_key = "I" -shift_on_capslock = true - -[node name="o" parent="ForceDown/Panel/V/KeyHolder/Row2" instance=ExtResource( 7 )] -margin_left = 615.0 -margin_right = 675.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "o" -key = "o" -shift_key = "O" -shift_on_capslock = true - -[node name="p" parent="ForceDown/Panel/V/KeyHolder/Row2" instance=ExtResource( 7 )] -margin_left = 680.0 -margin_right = 740.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "p" -key = "p" -shift_key = "P" -shift_on_capslock = true - -[node name="[" parent="ForceDown/Panel/V/KeyHolder/Row2" instance=ExtResource( 7 )] -margin_left = 745.0 -margin_right = 805.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "[" -key = "[" -shift_key = "{" - -[node name="]" parent="ForceDown/Panel/V/KeyHolder/Row2" instance=ExtResource( 7 )] -margin_left = 810.0 -margin_right = 870.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "]" -key = "]" -shift_key = "}" - -[node name="\\" parent="ForceDown/Panel/V/KeyHolder/Row2" instance=ExtResource( 7 )] -margin_left = 875.0 -margin_right = 965.0 -margin_bottom = 60.0 -focus_mode = 0 -size_flags_horizontal = 3 -text = "\\" -key = "\\" -shift_key = "|" - -[node name="Row3" type="HBoxContainer" parent="ForceDown/Panel/V/KeyHolder"] -margin_top = 130.0 -margin_right = 965.0 -margin_bottom = 190.0 -custom_constants/separation = 5 -alignment = 1 -__meta__ = { -"_edit_lock_": true -} - -[node name="caps" type="Button" parent="ForceDown/Panel/V/KeyHolder/Row3"] -margin_right = 122.0 -margin_bottom = 60.0 -rect_min_size = Vector2( 120, 45 ) -focus_mode = 0 -size_flags_horizontal = 3 -theme = ExtResource( 2 ) -toggle_mode = true -action_mode = 0 -text = "" -script = ExtResource( 4 ) - -[node name="a" parent="ForceDown/Panel/V/KeyHolder/Row3" instance=ExtResource( 7 )] -margin_left = 127.0 -margin_right = 187.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "a" -key = "a" -shift_key = "A" -shift_on_capslock = true - -[node name="s" parent="ForceDown/Panel/V/KeyHolder/Row3" instance=ExtResource( 7 )] -margin_left = 192.0 -margin_right = 252.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "s" -key = "s" -shift_key = "S" -shift_on_capslock = true - -[node name="d" parent="ForceDown/Panel/V/KeyHolder/Row3" instance=ExtResource( 7 )] -margin_left = 257.0 -margin_right = 317.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "d" -key = "d" -shift_key = "D" -shift_on_capslock = true - -[node name="f" parent="ForceDown/Panel/V/KeyHolder/Row3" instance=ExtResource( 7 )] -margin_left = 322.0 -margin_right = 382.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "f" -key = "f" -shift_key = "F" -shift_on_capslock = true - -[node name="g" parent="ForceDown/Panel/V/KeyHolder/Row3" instance=ExtResource( 7 )] -margin_left = 387.0 -margin_right = 447.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "g" -key = "g" -shift_key = "G" -shift_on_capslock = true - -[node name="h" parent="ForceDown/Panel/V/KeyHolder/Row3" instance=ExtResource( 7 )] -margin_left = 452.0 -margin_right = 512.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "h" -key = "h" -shift_key = "H" -shift_on_capslock = true - -[node name="j" parent="ForceDown/Panel/V/KeyHolder/Row3" instance=ExtResource( 7 )] -margin_left = 517.0 -margin_right = 577.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "j" -key = "j" -shift_key = "J" -shift_on_capslock = true - -[node name="k" parent="ForceDown/Panel/V/KeyHolder/Row3" instance=ExtResource( 7 )] -margin_left = 582.0 -margin_right = 642.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "k" -key = "k" -shift_key = "K" -shift_on_capslock = true - -[node name="l" parent="ForceDown/Panel/V/KeyHolder/Row3" instance=ExtResource( 7 )] -margin_left = 647.0 -margin_right = 707.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "l" -key = "l" -shift_key = "L" -shift_on_capslock = true - -[node name=";" parent="ForceDown/Panel/V/KeyHolder/Row3" instance=ExtResource( 7 )] -margin_left = 712.0 -margin_right = 772.0 -margin_bottom = 60.0 -focus_mode = 0 -text = ";" -key = ";" -shift_key = ":" - -[node name="\'" parent="ForceDown/Panel/V/KeyHolder/Row3" instance=ExtResource( 7 )] -margin_left = 777.0 -margin_right = 837.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "'" -key = "'" -shift_key = "\"" - -[node name="enter" type="Button" parent="ForceDown/Panel/V/KeyHolder/Row3"] -margin_left = 842.0 -margin_right = 965.0 -margin_bottom = 60.0 -rect_min_size = Vector2( 120, 45 ) -focus_mode = 0 -size_flags_horizontal = 3 -theme = ExtResource( 2 ) -action_mode = 0 -text = "" -script = ExtResource( 1 ) -k_scncode = 16777221 - -[node name="Row4" type="HBoxContainer" parent="ForceDown/Panel/V/KeyHolder"] -margin_top = 195.0 -margin_right = 965.0 -margin_bottom = 255.0 -custom_constants/separation = 5 -alignment = 1 -__meta__ = { -"_edit_lock_": true -} - -[node name="shift" type="Button" parent="ForceDown/Panel/V/KeyHolder/Row4"] -margin_right = 155.0 -margin_bottom = 60.0 -rect_min_size = Vector2( 120, 45 ) -focus_mode = 0 -size_flags_horizontal = 3 -theme = ExtResource( 2 ) -action_mode = 0 -text = "וּ" -script = ExtResource( 1 ) -k_scncode = 16777237 - -[node name="z" parent="ForceDown/Panel/V/KeyHolder/Row4" instance=ExtResource( 7 )] -margin_left = 160.0 -margin_right = 220.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "z" -key = "z" -shift_key = "Z" -shift_on_capslock = true - -[node name="x" parent="ForceDown/Panel/V/KeyHolder/Row4" instance=ExtResource( 7 )] -margin_left = 225.0 -margin_right = 285.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "x" -key = "x" -shift_key = "X" -shift_on_capslock = true - -[node name="c" parent="ForceDown/Panel/V/KeyHolder/Row4" instance=ExtResource( 7 )] -margin_left = 290.0 -margin_right = 350.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "c" -key = "c" -shift_key = "C" -shift_on_capslock = true - -[node name="v" parent="ForceDown/Panel/V/KeyHolder/Row4" instance=ExtResource( 7 )] -margin_left = 355.0 -margin_right = 415.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "v" -key = "v" -shift_key = "V" -shift_on_capslock = true - -[node name="b" parent="ForceDown/Panel/V/KeyHolder/Row4" instance=ExtResource( 7 )] -margin_left = 420.0 -margin_right = 480.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "b" -key = "b" -shift_key = "B" -shift_on_capslock = true - -[node name="n" parent="ForceDown/Panel/V/KeyHolder/Row4" instance=ExtResource( 7 )] -margin_left = 485.0 -margin_right = 545.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "n" -key = "n" -shift_key = "N" -shift_on_capslock = true - -[node name="m" parent="ForceDown/Panel/V/KeyHolder/Row4" instance=ExtResource( 7 )] -margin_left = 550.0 -margin_right = 610.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "m" -key = "m" -shift_key = "M" -shift_on_capslock = true - -[node name="," parent="ForceDown/Panel/V/KeyHolder/Row4" instance=ExtResource( 7 )] -margin_left = 615.0 -margin_right = 675.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "," -key = "," -shift_key = "<" - -[node name="dot" parent="ForceDown/Panel/V/KeyHolder/Row4" instance=ExtResource( 7 )] -margin_left = 680.0 -margin_right = 740.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "." -key = "." -shift_key = ">" - -[node name="slash" parent="ForceDown/Panel/V/KeyHolder/Row4" instance=ExtResource( 7 )] -margin_left = 745.0 -margin_right = 805.0 -margin_bottom = 60.0 -focus_mode = 0 -text = "/" -key = "/" -shift_key = "?" - -[node name="shift2" type="Button" parent="ForceDown/Panel/V/KeyHolder/Row4"] -margin_left = 810.0 -margin_right = 965.0 -margin_bottom = 60.0 -rect_min_size = Vector2( 120, 45 ) -focus_mode = 0 -size_flags_horizontal = 3 -theme = ExtResource( 2 ) -action_mode = 0 -text = "וּ" -script = ExtResource( 1 ) -k_scncode = 16777237 - -[node name="Row5" type="HBoxContainer" parent="ForceDown/Panel/V/KeyHolder"] -margin_top = 260.0 -margin_right = 965.0 -margin_bottom = 320.0 -custom_constants/separation = 5 -alignment = 1 -__meta__ = { -"_edit_lock_": true -} - -[node name="Spacebar" type="Button" parent="ForceDown/Panel/V/KeyHolder/Row5"] -margin_right = 900.0 -margin_bottom = 60.0 -focus_mode = 0 -size_flags_horizontal = 3 -text = " " -script = ExtResource( 3 ) -key = " " -shift_key = " " - -[node name="Close" type="Button" parent="ForceDown/Panel/V/KeyHolder/Row5"] -margin_left = 905.0 -margin_right = 965.0 -margin_bottom = 60.0 -rect_min_size = Vector2( 60, 60 ) -focus_mode = 0 -theme = ExtResource( 2 ) -action_mode = 0 -keep_pressed_outside = true -text = "" - -[connection signal="pressed" from="ForceDown/Panel/V/KeyHolder/Row5/Close" to="." method="_on_Close_pressed"] diff --git a/ui/virtual_keyboard/high_light.tres b/ui/virtual_keyboard/high_light.tres deleted file mode 100644 index dfe6d61..0000000 --- a/ui/virtual_keyboard/high_light.tres +++ /dev/null @@ -1,12 +0,0 @@ -[gd_resource type="StyleBoxFlat" format=2] - -[resource] -content_margin_left = 2.0 -content_margin_right = 2.0 -content_margin_top = 2.0 -content_margin_bottom = 2.0 -bg_color = Color( 0.443137, 0.482353, 0.443137, 1 ) -corner_radius_top_left = 5 -corner_radius_top_right = 5 -corner_radius_bottom_right = 5 -corner_radius_bottom_left = 5 diff --git a/ui/virtual_keyboard/kb_theme.theme b/ui/virtual_keyboard/kb_theme.theme Binary files differdeleted file mode 100644 index b586a21..0000000 --- a/ui/virtual_keyboard/kb_theme.theme +++ /dev/null |