Browse Source

added direct connect screen

galo 1 year ago
parent
commit
c3dfea0e3e
5 changed files with 143 additions and 80 deletions
  1. 46 0
      Client.tscn
  2. 33 0
      ClientDummy.tscn
  3. 13 0
      Login.gd
  4. 2 5
      hud.tscn
  5. 49 75
      main.tscn

+ 46 - 0
Client.tscn

@@ -0,0 +1,46 @@
+[gd_scene load_steps=8 format=2]
+
+[ext_resource path="res://Debug.tscn" type="PackedScene" id=1]
+[ext_resource path="res://PowerMenu.tscn" type="PackedScene" id=2]
+[ext_resource path="res://Client.gd" type="Script" id=3]
+[ext_resource path="res://Input.gd" type="Script" id=4]
+[ext_resource path="res://ping.gd" type="Script" id=5]
+[ext_resource path="res://enemiessprite.gd" type="Script" id=7]
+[ext_resource path="res://font/tiny.tres" type="DynamicFont" id=8]
+
+[node name="Client" type="Node" groups=["client"]]
+script = ExtResource( 3 )
+
+[node name="ping" type="Label" parent="."]
+margin_left = 12.1612
+margin_top = 260.304
+margin_right = 52.1612
+margin_bottom = 281.304
+custom_fonts/font = ExtResource( 8 )
+text = "ping..."
+script = ExtResource( 5 )
+__meta__ = {
+"_edit_use_anchors_": false
+}
+
+[node name="Input" type="Node" parent="."]
+script = ExtResource( 4 )
+
+[node name="players" type="Node" parent="."]
+
+[node name="enemies" type="Node" parent="."]
+script = ExtResource( 7 )
+
+[node name="Debug" parent="." instance=ExtResource( 1 )]
+
+[node name="Hud" type="CanvasLayer" parent="."]
+
+[node name="HBoxContainer" type="HBoxContainer" parent="Hud"]
+anchor_right = 1.0
+margin_right = 1.0
+margin_bottom = 60.0
+__meta__ = {
+"_edit_use_anchors_": false
+}
+
+[node name="PowerMenu" parent="." instance=ExtResource( 2 )]

+ 33 - 0
ClientDummy.tscn

@@ -0,0 +1,33 @@
+[gd_scene load_steps=5 format=2]
+
+[ext_resource path="res://PowerMenu.tscn" type="PackedScene" id=1]
+[ext_resource path="res://Client.gd" type="Script" id=2]
+[ext_resource path="res://PowerMenu.gd" type="Script" id=3]
+
+[sub_resource type="GDScript" id=6]
+script/source = "extends Node
+
+var enabled = false
+
+func _physics_process(delta):
+	if enabled:
+		var input = ''
+		if Input.is_action_pressed(\"s\"):
+			input =(\"ui_down\")
+		if Input.is_action_pressed(\"w\"):
+			input =(\"ui_up\")
+		if Input.is_action_pressed(\"a\"):
+			input =(\"ui_left\")
+		if Input.is_action_pressed(\"d\"):
+			input =(\"ui_right\")
+		get_parent().send_input(input)
+"
+
+[node name="ClientDummy" type="Node" groups=["client"]]
+script = ExtResource( 2 )
+
+[node name="Input" type="Node" parent="."]
+script = SubResource( 6 )
+
+[node name="PowerMenu" type="CanvasLayer" parent="." instance=ExtResource( 1 )]
+script = ExtResource( 3 )

+ 13 - 0
Login.gd

@@ -0,0 +1,13 @@
+extends Node
+
+var client = preload('res://Client.tscn')
+
+func _on_Button_button_down():
+	var client2 = client.instance()
+	var ip = $directconnect/VBoxContainer/HBoxContainer/LineEdit2.get_text()
+	var port = $directconnect/VBoxContainer/HBoxContainer/LineEdit.get_text()
+	client2.ip = ip
+	client2.port = int(port)
+	get_parent().add_child(client2)
+	$directconnect.hide()
+	pass # Replace with function body.

+ 2 - 5
hud.tscn

@@ -15,9 +15,6 @@ anti_aliasing = false
 margin_right = 97.0
 margin_bottom = 60.0
 script = ExtResource( 2 )
-__meta__ = {
-"_edit_use_anchors_": false
-}
 
 [node name="username" type="Label" parent="."]
 margin_right = 97.0
@@ -42,8 +39,8 @@ __meta__ = {
 show_behind_parent = true
 anchor_right = 1.0
 anchor_bottom = 1.0
-custom_styles/fg = SubResource( 1 )
 custom_fonts/font = ExtResource( 1 )
+custom_styles/fg = SubResource( 1 )
 percent_visible = false
 __meta__ = {
 "_edit_use_anchors_": false
@@ -63,8 +60,8 @@ __meta__ = {
 show_behind_parent = true
 anchor_right = 1.0
 anchor_bottom = 1.0
-custom_styles/fg = SubResource( 2 )
 custom_fonts/font = ExtResource( 1 )
+custom_styles/fg = SubResource( 2 )
 step = 1.0
 value = 100.0
 percent_visible = false

+ 49 - 75
main.tscn

@@ -1,17 +1,11 @@
-[gd_scene load_steps=20 format=2]
+[gd_scene load_steps=13 format=2]
 
-[ext_resource path="res://Client.gd" type="Script" id=1]
+[ext_resource path="res://Login.gd" type="Script" id=1]
 [ext_resource path="res://Server.gd" type="Script" id=2]
 [ext_resource path="res://Database.gd" type="Script" id=3]
-[ext_resource path="res://ping.gd" type="Script" id=4]
-[ext_resource path="res://Input.gd" type="Script" id=5]
 [ext_resource path="res://spawner.gd" type="Script" id=6]
-[ext_resource path="res://enemiessprite.gd" type="Script" id=7]
-[ext_resource path="res://font/tiny.tres" type="DynamicFont" id=8]
-[ext_resource path="res://Debug.tscn" type="PackedScene" id=9]
 [ext_resource path="res://art/Untitledcxz.png" type="Texture" id=10]
 [ext_resource path="res://Textures.gd" type="Script" id=11]
-[ext_resource path="res://PowerMenu.tscn" type="PackedScene" id=12]
 [ext_resource path="res://Camera2D.gd" type="Script" id=13]
 
 [sub_resource type="AtlasTexture" id=1]
@@ -38,25 +32,6 @@ animations = [ {
 "speed": 5.0
 } ]
 
-[sub_resource type="GDScript" id=6]
-script/source = "extends Node
-
-var enabled = false
-
-func _physics_process(delta):
-	if enabled:
-		var input = ''
-		if Input.is_action_pressed(\"s\"):
-			input =(\"ui_down\")
-		if Input.is_action_pressed(\"w\"):
-			input =(\"ui_up\")
-		if Input.is_action_pressed(\"a\"):
-			input =(\"ui_left\")
-		if Input.is_action_pressed(\"d\"):
-			input =(\"ui_right\")
-		get_parent().send_input(input)
-"
-
 [node name="Node" type="Node"]
 
 [node name="Textures" type="Node" parent="."]
@@ -71,7 +46,7 @@ render_target_v_flip = true
 [node name="Goblin" type="AnimatedSprite" parent="Textures/Goblin1"]
 modulate = Color( 0, 0.811765, 1, 1 )
 frames = SubResource( 5 )
-frame = 3
+frame = 2
 playing = true
 offset = Vector2( 32, 32 )
 
@@ -83,7 +58,7 @@ render_target_v_flip = true
 
 [node name="Goblin" type="AnimatedSprite" parent="Textures/Goblin2"]
 frames = SubResource( 5 )
-frame = 1
+frame = 2
 speed_scale = 0.8
 playing = true
 offset = Vector2( 32, 32 )
@@ -97,7 +72,7 @@ render_target_v_flip = true
 [node name="Goblin" type="AnimatedSprite" parent="Textures/Goblin3"]
 modulate = Color( 1, 0, 0, 1 )
 frames = SubResource( 5 )
-frame = 2
+frame = 1
 speed_scale = 1.2
 playing = true
 offset = Vector2( 32, 32 )
@@ -133,55 +108,52 @@ enemydmg = 1
 
 [node name="dmgbox" type="Node" parent="Server"]
 
-[node name="Client" type="Node" parent="." groups=["client"]]
-script = ExtResource( 1 )
-
-[node name="ping" type="Label" parent="Client"]
-margin_left = 12.1612
-margin_top = 260.304
-margin_right = 52.1612
-margin_bottom = 281.304
-custom_fonts/font = ExtResource( 8 )
-text = "ping..."
-script = ExtResource( 4 )
-__meta__ = {
-"_edit_use_anchors_": false
-}
-
-[node name="Input" type="Node" parent="Client"]
-script = ExtResource( 5 )
-
-[node name="players" type="Node" parent="Client"]
-
-[node name="enemies" type="Node" parent="Client"]
-script = ExtResource( 7 )
-
-[node name="Debug" parent="Client" instance=ExtResource( 9 )]
-
-[node name="Hud" type="CanvasLayer" parent="Client"]
-
-[node name="HBoxContainer" type="HBoxContainer" parent="Client/Hud"]
-anchor_right = 1.0
-margin_right = 1.0
-margin_bottom = 60.0
-__meta__ = {
-"_edit_use_anchors_": false
-}
-
-[node name="PowerMenu" parent="Client" instance=ExtResource( 12 )]
-
-[node name="Client2" type="Node" parent="." groups=["client"]]
-script = ExtResource( 1 )
-
-[node name="Input" type="Node" parent="Client2"]
-script = SubResource( 6 )
-
-[node name="PowerMenu" parent="Client2" instance=ExtResource( 12 )]
-
 [node name="Database" type="Node" parent="."]
 script = ExtResource( 3 )
 
 [node name="Login" type="Node" parent="."]
+script = ExtResource( 1 )
+
+[node name="directconnect" type="Control" parent="Login"]
+anchor_right = 1.0
+anchor_bottom = 1.0
+margin_left = 180.0
+margin_right = -180.0
+
+[node name="VBoxContainer" type="VBoxContainer" parent="Login/directconnect"]
+anchor_right = 1.0
+anchor_bottom = 1.0
+alignment = 1
+
+[node name="HBoxContainer" type="HBoxContainer" parent="Login/directconnect/VBoxContainer"]
+margin_top = 156.0
+margin_right = 280.0
+margin_bottom = 180.0
+alignment = 1
+
+[node name="LineEdit2" type="LineEdit" parent="Login/directconnect/VBoxContainer/HBoxContainer"]
+margin_right = 218.0
+margin_bottom = 24.0
+size_flags_horizontal = 3
+size_flags_vertical = 3
+text = "127.0.0.1"
+align = 1
+expand_to_text_length = true
+placeholder_text = "IP Adress"
+
+[node name="LineEdit" type="LineEdit" parent="Login/directconnect/VBoxContainer/HBoxContainer"]
+margin_left = 222.0
+margin_right = 280.0
+margin_bottom = 24.0
+text = "8081"
+align = 1
+placeholder_text = "Port"
+
+[node name="Button" type="Button" parent="Login/directconnect/VBoxContainer"]
+margin_top = 184.0
+margin_right = 280.0
+margin_bottom = 204.0
+text = "connnect"
 
 [node name="Authority" type="Node" parent="."]
 
@@ -189,3 +161,5 @@ script = ExtResource( 3 )
 position = Vector2( 320, 180 )
 current = true
 script = ExtResource( 13 )
+
+[connection signal="button_down" from="Login/directconnect/VBoxContainer/Button" to="Login" method="_on_Button_button_down"]