diff --git a/game/player/Body.gd b/game/player/Body.gd index aabe0a8..56401c8 100644 --- a/game/player/Body.gd +++ b/game/player/Body.gd @@ -85,8 +85,6 @@ var character_skeleton : CharacterSkeleton2D var visibility_update_timer : float = randi() -var gui : Node = null - func _enter_tree() -> void: world = get_node(world_path) as Node camera = get_node_or_null("Camera") as Camera2D @@ -104,10 +102,6 @@ func _enter_tree() -> void: transform = entity.get_transform_2d(true) set_physics_process(true) - -func _exit_tree(): - if gui != null and not gui.is_queued_for_deletion(): - gui.queue_free() func _process(delta : float) -> void: if entity.ai_state == EntityEnums.AI_STATE_OFF: @@ -484,10 +478,7 @@ func on_c_controlled_changed(val): var uiscn : PackedScene = ResourceLoader.load("res://ui/player_ui/player_ui.tscn") var ui = uiscn.instance() -# add_child(ui) - get_node("/root/Main/GUI").add_child(ui) - ui.set_player(entity) - gui = ui + add_child(ui) set_process_input(true) set_process_unhandled_input(true) @@ -498,13 +489,9 @@ func on_c_controlled_changed(val): set_process_input(false) set_process_unhandled_input(false) -# var nameplatescn : PackedScene = ResourceLoader.load("res://ui/nameplates/NamePlate.tscn") -# var nameplate = nameplatescn.instance() -# -# get_node("/root/Main/GUI").add_child(nameplate) -## get_parent().add_child(nameplate) -# nameplate.set_player(entity) -# gui = nameplate + var nameplatescn : PackedScene = ResourceLoader.load("res://ui/nameplates/NamePlate.tscn") + var nameplate = nameplatescn.instance() + get_parent().add_child(nameplate) diff --git a/game/player/GUI.gd b/game/player/GUI.gd index 24161c5..9d4a993 100644 --- a/game/player/GUI.gd +++ b/game/player/GUI.gd @@ -20,16 +20,19 @@ extends Control # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -#export (String) var player_path : String = "../../.." +export (String) var player_path : String = "../../.." export (Array, NodePath) var child_controls : Array -func set_player(player : Entity) -> void: - if (player == null): - print("Player is null!") - return +func _ready() -> void: + if player_path != null: + var player : Entity = get_node(player_path) as Entity + + if (player == null): + print("Player is null!") + return - for child_path in child_controls: - var child = get_node(child_path) + for child_path in child_controls: + var child = get_node(child_path) - child.set_player(player) + child.set_player(player) diff --git a/game/player/NamePlate.gd b/game/player/NamePlate.gd index e495358..799c20d 100644 --- a/game/player/NamePlate.gd +++ b/game/player/NamePlate.gd @@ -53,16 +53,7 @@ func _enter_tree(): health_bar = get_node(health_bar_path) as TextureProgress health_bar_label = get_node(health_bar_label_path) as Label - modulate = normal_color - set_scale(normal_scale) - - target_scale = normal_scale - interpolating = false - - set_process(false) - -func set_player(e : Entity): - entity = e + entity = get_node("..") as Entity entity.connect("centity_resource_added", self, "on_centity_resource_added") name_label.text = entity.centity_name @@ -73,6 +64,12 @@ func set_player(e : Entity): entity.connect("notification_ctargeted", self, "notification_ctargeted") entity.connect("notification_cuntargeted", self, "notification_cuntargeted") + modulate = normal_color + set_scale(normal_scale) + + target_scale = normal_scale + interpolating = false + set_process(true) func _process(delta): diff --git a/game/project.godot b/game/project.godot index 6b4b57c..b5efae8 100644 --- a/game/project.godot +++ b/game/project.godot @@ -371,7 +371,7 @@ gdscript/warnings/integer_division=false [display] window/dpi/allow_hidpi=true -window/handheld/orientation="sensor" +window/handheld/orientation="sensor_landscape" window/stretch/mode="2d" window/stretch/aspect="expand" mouse_cursor/sensitivity=0.9 diff --git a/game/scenes/GameViewport.gd b/game/scenes/GameViewport.gd deleted file mode 100644 index 063a4d7..0000000 --- a/game/scenes/GameViewport.gd +++ /dev/null @@ -1,93 +0,0 @@ -extends Container - -export(Vector2) var base_resolution : Vector2 = Vector2(600, 600) -var _scale : Vector2 = Vector2(1, 1) - -func _init(): - set_process_input(true); - set_process_unhandled_input(true); - -func _notification(p_what): - if (p_what == NOTIFICATION_RESIZED): - - for c in get_children(): - - if not c is Viewport: - continue - - var ar : float = 0 - var rc : Vector2 = Vector2() - -# if get_size().x > get_size().y: - ar = get_size().y / get_size().x - rc = Vector2(base_resolution.x, base_resolution.y * ar) -# else : -# ar = get_size().x / get_size().y -# rc = Vector2(base_resolution.x * ar, base_resolution.y) - - c.set_size(rc) - - _scale = get_size() / rc - - - if p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_VISIBILITY_CHANGED: - for c in get_children(): - - if not c is Viewport: - continue - - if is_visible_in_tree(): - c.set_update_mode(Viewport.UPDATE_ALWAYS) - else: - c.set_update_mode(Viewport.UPDATE_DISABLED) - - c.set_handle_input_locally(false); #do not handle input locally here - - if p_what == NOTIFICATION_DRAW: - for c in get_children(): - - if not c is Viewport: - continue - - draw_texture_rect(c.get_texture(), Rect2(Vector2(), get_size() * Vector2(1, -1)), false) - -func _input(p_event): - - if (Engine.is_editor_hint()): - return; - - var xform : Transform2D = get_global_transform() - - var scale_xf : Transform2D - scale_xf = scale_xf.scaled(_scale) - xform *= scale_xf - - var ev : InputEvent = p_event.xformed_by(xform.affine_inverse()) - - for c in get_children(): - - if not c is Viewport or c.is_input_disabled(): - continue - - c.input(ev) - -func _unhandled_input(p_event): - - if Engine.is_editor_hint(): - return - - var xform : Transform2D = get_global_transform() - - var scale_xf : Transform2D - scale_xf = scale_xf.scaled(_scale) - xform *= scale_xf - - var ev : InputEvent = p_event.xformed_by(xform.affine_inverse()) - - for c in get_children(): - - if not c is Viewport or c.is_input_disabled(): - continue - - c.unhandled_input(ev) - diff --git a/game/scenes/Main.tscn b/game/scenes/Main.tscn index 9ed9bac..43dcdb4 100644 --- a/game/scenes/Main.tscn +++ b/game/scenes/Main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://scenes/MainScene.gd" type="Script" id=1] [ext_resource path="res://scenes/World.tscn" type="PackedScene" id=2] @@ -6,7 +6,6 @@ [ext_resource path="res://ui/theme/ui_theme.tres" type="Theme" id=4] [ext_resource path="res://ui/debug/DebugInfo.tscn" type="PackedScene" id=5] [ext_resource path="res://debug/FreeLookCam.tscn" type="PackedScene" id=6] -[ext_resource path="res://scenes/GameViewport.gd" type="Script" id=7] [node name="Main" type="Node"] script = ExtResource( 1 ) @@ -14,8 +13,6 @@ menu_scene = ExtResource( 3 ) world_scene = ExtResource( 2 ) debug_camera_scene = ExtResource( 6 ) loading_screen_path = NodePath("LoadingScreen/PanelContainer") -gui_path = NodePath("GUI") -viewport_path = NodePath("GameViewport/Viewport") [node name="LoadingScreen" type="CanvasLayer" parent="."] layer = 100 @@ -97,21 +94,3 @@ LOADING " [node name="DebugInfo" parent="." instance=ExtResource( 5 )] - -[node name="GameViewport" type="Container" parent="."] -anchor_right = 1.0 -anchor_bottom = 1.0 -mouse_filter = 2 -size_flags_horizontal = 3 -size_flags_vertical = 3 -script = ExtResource( 7 ) - -[node name="Viewport" type="Viewport" parent="GameViewport"] -size = Vector2( 400, 200 ) -handle_input_locally = false -disable_3d = true -usage = 0 -render_target_update_mode = 3 -audio_listener_enable_2d = true - -[node name="GUI" type="Node" parent="."] diff --git a/game/scenes/MainScene.gd b/game/scenes/MainScene.gd index 164ac6e..0d6491f 100644 --- a/game/scenes/MainScene.gd +++ b/game/scenes/MainScene.gd @@ -26,11 +26,6 @@ export(PackedScene) var menu_scene : PackedScene export(PackedScene) var world_scene : PackedScene export(PackedScene) var debug_camera_scene : PackedScene export(NodePath) var loading_screen_path : NodePath -export(NodePath) var gui_path : NodePath -export(NodePath) var viewport_path : NodePath - -var gui : Node -var viewport : Node enum StartSceneTypes { NONE, MENU, WORLD @@ -45,8 +40,6 @@ var _modules : Array func _ready() -> void: _loading_screen = get_node(loading_screen_path) - gui = get_node(gui_path) - viewport = get_node(viewport_path) ProfileManager.load() ESS.load_entity_spawner() @@ -123,7 +116,7 @@ func switch_scene(scene : int) -> void: elif scene == StartSceneTypes.WORLD: var gs : Node = world_scene.instance() - viewport.add_child(gs) + add_child(gs) gs.owner = self current_scene = gs @@ -156,9 +149,6 @@ func switch_scene(scene : int) -> void: if current_scene.needs_loading_screen(): show_loading_screen() -func add_entity(entity : Entity) -> void: - pass - func load_character(file_name : String) -> void: current_character_file_name = file_name diff --git a/game/scripts/networking/SpawnPoint.gd b/game/scripts/networking/SpawnPoint.gd index 3663cdb..06f4eeb 100644 --- a/game/scripts/networking/SpawnPoint.gd +++ b/game/scripts/networking/SpawnPoint.gd @@ -41,7 +41,7 @@ var connect_button : Button var naturalist_button : Button var player : Entity -#var terrarin : VoxelWorld +var terrarin : VoxelWorld var spawned : bool = false @@ -61,7 +61,7 @@ func _ready(): naturalist_button = get_node(naturalist_button_path) naturalist_button.connect("pressed", self, "_on_client_naturalist_button_clicked") -# terrarin = get_node(terrarin_path) as VoxelWorld + terrarin = get_node(terrarin_path) as VoxelWorld Server.connect("cplayer_master_created", self, "_cplayer_master_created") @@ -90,8 +90,8 @@ func spawn(): # ESS.entity_spawner.spawn_mob(1, 50, Vector3(54, 6, 22)) # ESS.entity_spawner.spawn_mob(1, 50, Vector3(76, 6, 54)) -#func set_terrarin_player(): -# terrarin.set_player(player.get_body() as Spatial) +func set_terrarin_player(): + terrarin.set_player(player.get_body() as Spatial) func _on_host_button_clicked(): get_tree().connect("network_peer_connected", self, "_network_peer_connected") diff --git a/game/ui/nameplates/NamePlate.tscn b/game/ui/nameplates/NamePlate.tscn index 989b77f..43518ef 100644 --- a/game/ui/nameplates/NamePlate.tscn +++ b/game/ui/nameplates/NamePlate.tscn @@ -5,7 +5,7 @@ [ext_resource path="res://player/NamePlate.gd" type="Script" id=3] [node name="NamePlate" type="VBoxContainer"] -margin_right = 60.0 +margin_right = 62.0 margin_bottom = 17.0 rect_scale = Vector2( 0.75, 0.75 ) mouse_filter = 2 @@ -21,7 +21,7 @@ normal_color = Color( 0.74902, 0.74902, 0.74902, 1 ) mouseover_scale = Vector2( 0.75, 0.75 ) [node name="Name" type="Label" parent="."] -margin_right = 60.0 +margin_right = 62.0 margin_bottom = 15.0 custom_constants/line_spacing = 0 text = "Asda" @@ -30,14 +30,14 @@ valign = 1 [node name="MarginContainer" type="MarginContainer" parent="."] margin_top = 15.0 -margin_right = 60.0 +margin_right = 62.0 margin_bottom = 17.0 size_flags_horizontal = 15 size_flags_vertical = 15 size_flags_stretch_ratio = 2.3 [node name="TextureProgress" type="TextureProgress" parent="MarginContainer"] -margin_right = 60.0 +margin_right = 62.0 margin_bottom = 2.0 size_flags_horizontal = 3 size_flags_vertical = 3 @@ -54,15 +54,15 @@ stretch_margin_bottom = 1 [node name="CenterContainer" type="CenterContainer" parent="MarginContainer"] visible = false -margin_right = 60.0 +margin_right = 62.0 margin_bottom = 2.0 size_flags_horizontal = 3 size_flags_vertical = 3 [node name="Label" type="Label" parent="MarginContainer/CenterContainer"] visible = false -margin_left = 21.0 +margin_left = 22.0 margin_top = -7.0 -margin_right = 39.0 +margin_right = 40.0 margin_bottom = 8.0 text = "50%" diff --git a/game/ui/nameplates/name_plate_dynamicfont.tres b/game/ui/nameplates/name_plate_dynamicfont.tres index 306f2ca..b9a53e2 100644 --- a/game/ui/nameplates/name_plate_dynamicfont.tres +++ b/game/ui/nameplates/name_plate_dynamicfont.tres @@ -2,6 +2,7 @@ [ext_resource path="res://fonts/VT323-Regular.ttf" type="DynamicFontData" id=1] + [resource] size = 14 font_data = ExtResource( 1 ) diff --git a/game/ui/player_ui/player_ui.gd b/game/ui/player_ui/player_ui.gd index f4a11c0..1d2c524 100644 --- a/game/ui/player_ui/player_ui.gd +++ b/game/ui/player_ui/player_ui.gd @@ -29,6 +29,3 @@ func _ready(): func _on_Player_onc_open_loot_winow_request() -> void: if loot_window != null: loot_window.show() - -func set_player(player : Entity) -> void: - $GUI.set_player(player) diff --git a/game/ui/player_ui/player_ui.tscn b/game/ui/player_ui/player_ui.tscn index 45ad5f5..700a97b 100644 --- a/game/ui/player_ui/player_ui.tscn +++ b/game/ui/player_ui/player_ui.tscn @@ -40,7 +40,7 @@ script = ExtResource( 1 ) __meta__ = { "_edit_lock_": true } -child_controls = [ NodePath("Unitframes"), NodePath("Actionbars"), NodePath("Windows/SpellBookWindow"), NodePath("Buttons"), NodePath("Castbar"), NodePath("AuraFrame"), NodePath("Windows/Inventory"), NodePath("Windows/LootWindow"), NodePath("Windows/TalentWindow"), NodePath("Windows/CraftingWindow"), NodePath("TouchTargetControls/HBoxContainer/TargetPad/Analog"), NodePath("TouchMovementControls/HBoxContainer/VBoxContainer/TouchPad/Analog") ] +child_controls = [ NodePath("Unitframes"), NodePath("Actionbars"), NodePath("Windows/SpellBookWindow"), NodePath("Buttons"), NodePath("Castbar"), NodePath("AuraFrame"), NodePath("Windows/Inventory"), NodePath("Windows/LootWindow"), NodePath("Windows/TalentWindow"), NodePath("Windows/CraftingWindow") ] [node name="TouchTargetControls" type="MarginContainer" parent="GUI"] visible = false @@ -86,7 +86,6 @@ __meta__ = { [node name="Analog" parent="GUI/TouchTargetControls/HBoxContainer/TargetPad" instance=ExtResource( 13 )] position = Vector2( 40, 30 ) -listenerNodePath = "." padname = "TargetPad" [node name="TouchMovementControls" type="MarginContainer" parent="GUI"] @@ -132,7 +131,6 @@ size_flags_vertical = 15 [node name="Analog" parent="GUI/TouchMovementControls/HBoxContainer/VBoxContainer/TouchPad" instance=ExtResource( 13 )] position = Vector2( 107.368, 94.2101 ) -listenerNodePath = "." padname = "TouchPad" [node name="Control" type="Control" parent="GUI/TouchMovementControls/HBoxContainer"] diff --git a/game/ui/touch_pad/analog.gd b/game/ui/touch_pad/analog.gd index 3dd0183..2d8f5f1 100644 --- a/game/ui/touch_pad/analog.gd +++ b/game/ui/touch_pad/analog.gd @@ -20,8 +20,6 @@ var ballPos = Vector2() var squaredHalfSizeLength = 0 var currentPointerIDX = INACTIVE_IDX; -var entity - func _ready(): set_process_input(true) bg = get_node("bg") @@ -31,17 +29,16 @@ func _ready(): halfSize = bg.texture.get_size()/2 squaredHalfSizeLength = halfSize.x * halfSize.y -# if (listenerNodePath != "" && listenerNodePath!=null): -# listenerNode = get_node(listenerNodePath) -# elif listenerNodePath=="": -# listenerNode = null + if (listenerNodePath != "" && listenerNodePath!=null): + listenerNode = get_node(listenerNodePath) + elif listenerNodePath=="": + listenerNode = null # isDynamicallyShowing = isDynamicallyShowing and parent extends Control if isDynamicallyShowing: modulate.a = 0 # hide() - func get_force(): return currentForce @@ -157,13 +154,3 @@ func isReleased(event): return !event.is_pressed() elif event is InputEventMouseButton: return !event.is_pressed() - -func set_player(p): - entity = p - listenerNode = p.get_body() - - if listenerNode == null: - call_deferred("get_body") - -func get_body(): - listenerNode = entity.get_body()