Merge pull request 'Added Client' (#3) from develop into production

Reviewed-on: #3
pull/4/head
Евгений Сугоняко 2024-05-04 18:23:47 +00:00
commit a2d74e9a85
7 changed files with 208 additions and 18 deletions

1
config.cfg Normal file
View File

@ -0,0 +1 @@
{"Ip": "127.0.0.1", "Port": "3300"}

View File

@ -1,9 +0,0 @@
[gd_scene format=3 uid="uid://chcw74fuwkuu8"]
[node name="MainControl" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

View File

@ -0,0 +1,14 @@
extends Control
@export var InfoText : Label
func _on_exit_btn_pressed():
get_tree().quit()
func _on_login_btn_pressed():
var response = Client.connect_to_server()
if typeof(response) == TYPE_BOOL:
InfoText.text = "Connected to %s on port %s..." % [Client.settings.Ip, Client.settings.Port]
else:
InfoText.text = "Error connect to %s on port %s. ERROR: %s" % [Client.settings.Ip, Client.settings.Port, response]

View File

@ -0,0 +1,138 @@
[gd_scene load_steps=6 format=3 uid="uid://chcw74fuwkuu8"]
[ext_resource type="Script" path="res://data/scenes/main_menu/main_menu.gd" id="1_74xps"]
[ext_resource type="Texture2D" uid="uid://dlmiu17d1mdam" path="res://logo.png" id="2_fm7dl"]
[ext_resource type="FontFile" uid="uid://dhvfket83gjln" path="res://data/styles/fonts/Roboto-Regular.ttf" id="3_w2047"]
[sub_resource type="LabelSettings" id="LabelSettings_7g3em"]
line_spacing = 5.0
font = ExtResource("3_w2047")
font_size = 24
font_color = Color(0.853803, 0.675632, 0, 1)
[sub_resource type="LabelSettings" id="LabelSettings_iy7sm"]
font = ExtResource("3_w2047")
font_size = 18
font_color = Color(0.870032, 0.618438, 0.0727505, 1)
outline_size = 1
outline_color = Color(0, 0, 0, 1)
[node name="LoginSreen" type="Control" node_paths=PackedStringArray("InfoText")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("1_74xps")
InfoText = NodePath("MainBox/InfoBob/InfoText")
[node name="Background" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.125911, 0.125911, 0.125911, 1)
[node name="MainBox" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="GameNameBox" type="MarginContainer" parent="MainBox"]
layout_mode = 2
theme_override_constants/margin_left = 5
theme_override_constants/margin_top = 5
theme_override_constants/margin_right = 5
theme_override_constants/margin_bottom = 5
[node name="GameNameSeparator" type="HBoxContainer" parent="MainBox/GameNameBox"]
layout_mode = 2
size_flags_vertical = 4
theme_override_constants/separation = 5
alignment = 1
[node name="GameLogo" type="TextureRect" parent="MainBox/GameNameBox/GameNameSeparator"]
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
texture = ExtResource("2_fm7dl")
expand_mode = 3
stretch_mode = 4
[node name="GameName" type="Label" parent="MainBox/GameNameBox/GameNameSeparator"]
layout_mode = 2
size_flags_horizontal = 4
text = "Cashflow"
label_settings = SubResource("LabelSettings_7g3em")
horizontal_alignment = 1
vertical_alignment = 1
[node name="LoginBox" type="MarginContainer" parent="MainBox"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 6
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="LoginPanelBox" type="VBoxContainer" parent="MainBox/LoginBox"]
layout_mode = 2
size_flags_vertical = 4
theme_override_constants/separation = 10
[node name="LoginLabel" type="Label" parent="MainBox/LoginBox/LoginPanelBox"]
layout_mode = 2
size_flags_vertical = 2
text = "Enter to Cashflow World"
label_settings = SubResource("LabelSettings_iy7sm")
horizontal_alignment = 1
[node name="LoginInput" type="LineEdit" parent="MainBox/LoginBox/LoginPanelBox"]
layout_mode = 2
size_flags_vertical = 2
placeholder_text = "login"
alignment = 1
[node name="PasswordInput" type="LineEdit" parent="MainBox/LoginBox/LoginPanelBox"]
layout_mode = 2
size_flags_vertical = 2
placeholder_text = "password"
alignment = 1
secret = true
[node name="LoginButtonsBox" type="HBoxContainer" parent="MainBox/LoginBox/LoginPanelBox"]
layout_mode = 2
size_flags_vertical = 10
theme_override_constants/separation = 10
[node name="LoginBtn" type="Button" parent="MainBox/LoginBox/LoginPanelBox/LoginButtonsBox"]
layout_mode = 2
size_flags_horizontal = 2
text = "Enter"
[node name="ExitBtn" type="Button" parent="MainBox/LoginBox/LoginPanelBox/LoginButtonsBox"]
layout_mode = 2
size_flags_horizontal = 10
text = "Exit"
[node name="InfoBob" type="MarginContainer" parent="MainBox"]
layout_mode = 2
theme_override_constants/margin_left = 5
theme_override_constants/margin_top = 5
theme_override_constants/margin_right = 5
theme_override_constants/margin_bottom = 5
[node name="InfoText" type="Label" parent="MainBox/InfoBob"]
layout_mode = 2
horizontal_alignment = 1
[connection signal="pressed" from="MainBox/LoginBox/LoginPanelBox/LoginButtonsBox/LoginBtn" to="." method="_on_login_btn_pressed"]
[connection signal="pressed" from="MainBox/LoginBox/LoginPanelBox/LoginButtonsBox/ExitBtn" to="." method="_on_exit_btn_pressed"]

View File

@ -0,0 +1,43 @@
class_name CLIENT extends Node
# Helpers
var ClientPeer := ENetMultiplayerPeer.new()
var debug : bool = true
# Properties
var settings : Dictionary = {
Ip = '127.0.0.1',
Port = 3300,
}
#--------------------------------------------------------------------------------------------------#
# Initialization
func _init():
# Set priorities
set_process_mode(PROCESS_MODE_ALWAYS)
set_process_priority(0)
set_physics_process(0)
func _ready():
var config_dir = OS.get_executable_path().get_base_dir().path_join("config.cfg")
if debug:
config_dir = 'res://'.path_join("config.cfg")
if FileAccess.file_exists(config_dir):
var file = FileAccess.open(config_dir, FileAccess.READ)
var config = JSON.parse_string(file.get_as_text())
if typeof(config) == TYPE_DICTIONARY:
if config.has('Ip') and config.has('Port'):
settings.Ip = config.Ip
settings.Port = config.Port
#--------------------------------------------------------------------------------------------------#
# Methods
func connect_to_server():
var peer_status = ClientPeer.create_client(String(settings.Ip), int(settings.Port))
if peer_status != Error.OK:
return error_string(peer_status)
else:
multiplayer.multiplayer_peer = ClientPeer
return true

BIN
logo.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

View File

@ -18,24 +18,22 @@ config/name_localized={
} }
config/description="Economic board game online" config/description="Economic board game online"
config/version="0.0.0.001" config/version="0.0.0.001"
config/use_custom_user_dir=true run/main_scene="res://data/scenes/main_menu/main_menu.tscn"
config/custom_user_dir_name="data"
config/features=PackedStringArray("4.2", "GL Compatibility") config/features=PackedStringArray("4.2", "GL Compatibility")
boot_splash/bg_color=Color(0, 0, 0, 1) boot_splash/bg_color=Color(0, 0, 0, 1)
boot_splash/image="res://logo.png" boot_splash/image="res://logo.png"
config/icon="res://logo.png" config/icon="res://logo.png"
config/windows_native_icon="res://logo.ico"
boot_splash/minimum_display_time=15 boot_splash/minimum_display_time=15
[autoload]
Client="*res://data/scripts/objects/Client.gd"
[display] [display]
window/size/viewport_width=1280 window/size/viewport_width=800
window/size/viewport_height=720 window/size/viewport_height=600
window/stretch/mode="viewport"
window/stretch/aspect="expand" window/stretch/aspect="expand"
window/dpi/allow_hidpi=false
window/per_pixel_transparency/allowed=true
window/vsync/vsync_mode=0
window/ios/allow_high_refresh_rate=false window/ios/allow_high_refresh_rate=false
window/ios/hide_home_indicator=false window/ios/hide_home_indicator=false
window/ios/hide_status_bar=false window/ios/hide_status_bar=false
@ -45,6 +43,11 @@ window/ios/suppress_ui_gesture=false
naming/node_name_num_separator=2 naming/node_name_num_separator=2
[filesystem]
import/blender/enabled=false
import/fbx/enabled=false
[gui] [gui]
theme/custom_font="res://data/styles/fonts/Roboto-Regular.ttf" theme/custom_font="res://data/styles/fonts/Roboto-Regular.ttf"