From 8a8ae125a5606a0ceeb4171419176f09d86dad04 Mon Sep 17 00:00:00 2001 From: Gone2Daly <71726742+Gone2Daly@users.noreply.github.com> Date: Sat, 19 Aug 2023 20:43:59 +0200 Subject: init --- game/art/ui/cancel.png | Bin 0 -> 64965 bytes game/art/ui/cancel.png.import | 34 +++++++++ game/src/Game/GameSession/GameSession.tscn | 21 ++++-- .../GameSession/MainManagamentPanel/BudgetPanel.gd | 6 ++ .../MainManagamentPanel/MainManagamentPanel.tscn | 61 ++++++++++++++++ .../GameSession/MainManagamentPanel/PopupPanel.gd | 24 +++++++ .../MainManagamentPanel/PopupPanel.tscn | 80 +++++++++++++++++++++ 7 files changed, 222 insertions(+), 4 deletions(-) create mode 100644 game/art/ui/cancel.png create mode 100644 game/art/ui/cancel.png.import create mode 100644 game/src/Game/GameSession/MainManagamentPanel/BudgetPanel.gd create mode 100644 game/src/Game/GameSession/MainManagamentPanel/MainManagamentPanel.tscn create mode 100644 game/src/Game/GameSession/MainManagamentPanel/PopupPanel.gd create mode 100644 game/src/Game/GameSession/MainManagamentPanel/PopupPanel.tscn (limited to 'game') diff --git a/game/art/ui/cancel.png b/game/art/ui/cancel.png new file mode 100644 index 0000000..a826985 Binary files /dev/null and b/game/art/ui/cancel.png differ diff --git a/game/art/ui/cancel.png.import b/game/art/ui/cancel.png.import new file mode 100644 index 0000000..fdba184 --- /dev/null +++ b/game/art/ui/cancel.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cvfxeyui44yj6" +path="res://.godot/imported/cancel.png-cc9794204b95b4d54a461409a3207cd9.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://art/ui/cancel.png" +dest_files=["res://.godot/imported/cancel.png-cc9794204b95b4d54a461409a3207cd9.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/game/src/Game/GameSession/GameSession.tscn b/game/src/Game/GameSession/GameSession.tscn index c9f4095..d515feb 100644 --- a/game/src/Game/GameSession/GameSession.tscn +++ b/game/src/Game/GameSession/GameSession.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=10 format=3 uid="uid://bgnupcshe1m7r"] +[gd_scene load_steps=11 format=3 uid="uid://bgnupcshe1m7r"] [ext_resource type="Script" path="res://src/Game/GameSession/GameSession.gd" id="1_eklvp"] [ext_resource type="PackedScene" uid="uid://cvl76duuym1wq" path="res://src/Game/MusicConductor/MusicPlayer.tscn" id="2_kt6aa"] [ext_resource type="PackedScene" uid="uid://g524p8lr574w" path="res://src/Game/GameSession/MapControlPanel/MapControlPanel.tscn" id="3_afh6d"] [ext_resource type="PackedScene" uid="uid://dvdynl6eir40o" path="res://src/Game/GameSession/GameSessionMenu.tscn" id="3_bvmqh"] +[ext_resource type="PackedScene" uid="uid://cyr5e31ucu44d" path="res://src/Game/GameSession/MainManagamentPanel/MainManagamentPanel.tscn" id="3_wxhjf"] [ext_resource type="PackedScene" uid="uid://dkehmdnuxih2r" path="res://src/Game/GameSession/MapView.tscn" id="4_xkg5j"] [ext_resource type="PackedScene" uid="uid://byq323jbel48u" path="res://src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn" id="5_osjnn"] [ext_resource type="PackedScene" uid="uid://cnbfxjy1m6wja" path="res://src/Game/Menu/OptionMenu/OptionsMenu.tscn" id="6_p5mnx"] @@ -24,6 +25,9 @@ _game_session_menu = NodePath("GameSessionMenu") [node name="MapView" parent="." instance=ExtResource("4_xkg5j")] +[node name="MainManagamentPanel" parent="." instance=ExtResource("3_wxhjf")] +layout_mode = 1 + [node name="MapControlPanel" parent="." instance=ExtResource("3_afh6d")] layout_mode = 1 anchors_preset = 3 @@ -38,9 +42,13 @@ grow_vertical = 0 layout_mode = 1 [node name="GameSpeedPanel" parent="." instance=ExtResource("7_myy4q")] -layout_mode = 0 -offset_right = 302.0 +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -311.0 offset_bottom = 31.0 +grow_horizontal = 0 [node name="GameSessionMenu" parent="." instance=ExtResource("3_bvmqh")] visible = false @@ -72,12 +80,17 @@ offset_right = 640.0 [node name="MusicPlayer" parent="." instance=ExtResource("2_kt6aa")] layout_mode = 1 -anchors_preset = 1 +anchors_preset = 6 anchor_left = 1.0 +anchor_top = 0.5 anchor_right = 1.0 +anchor_bottom = 0.5 offset_left = -150.0 +offset_top = -55.0 offset_right = 0.0 +offset_bottom = 55.0 grow_horizontal = 0 +grow_vertical = 2 [connection signal="map_view_camera_changed" from="MapView" to="MapControlPanel" method="_on_map_view_camera_changed"] [connection signal="game_session_menu_button_pressed" from="MapControlPanel" to="." method="_on_game_session_menu_button_pressed"] diff --git a/game/src/Game/GameSession/MainManagamentPanel/BudgetPanel.gd b/game/src/Game/GameSession/MainManagamentPanel/BudgetPanel.gd new file mode 100644 index 0000000..ba72a01 --- /dev/null +++ b/game/src/Game/GameSession/MainManagamentPanel/BudgetPanel.gd @@ -0,0 +1,6 @@ +extends Button +var Pan = load("res://src/Game/GameSession/MainManagamentPanel/PopupPanel.tscn") + +func _on_pressed(): + var spawn = Pan.instantiate() + $"../../..".add_child(spawn) # Spawning window on MainManagamentPanel diff --git a/game/src/Game/GameSession/MainManagamentPanel/MainManagamentPanel.tscn b/game/src/Game/GameSession/MainManagamentPanel/MainManagamentPanel.tscn new file mode 100644 index 0000000..abe720e --- /dev/null +++ b/game/src/Game/GameSession/MainManagamentPanel/MainManagamentPanel.tscn @@ -0,0 +1,61 @@ +[gd_scene load_steps=2 format=3 uid="uid://cyr5e31ucu44d"] + +[ext_resource type="Script" path="res://src/Game/GameSession/MainManagamentPanel/BudgetPanel.gd" id="1_5jsre"] + +[node name="MainManagamentPanel" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +custom_minimum_size = Vector2(700, 100) +layout_mode = 2 +offset_right = 700.0 +offset_bottom = 100.0 + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="ProductionPanel" type="Button" parent="VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="BudgetPanel" type="Button" parent="VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +script = ExtResource("1_5jsre") + +[node name="TechnologyPanel" type="Button" parent="VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="PoliticsPanel" type="Button" parent="VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="PopulationPanel" type="Button" parent="VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="TradePanel" type="Button" parent="VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="DiplomacyPanel" type="Button" parent="VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="MilitaryPanel" type="Button" parent="VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="CountryPanel" type="Button" parent="VBoxContainer"] +custom_minimum_size = Vector2(100, 60) +layout_mode = 2 +size_flags_horizontal = 0 + +[connection signal="pressed" from="VBoxContainer/HBoxContainer/BudgetPanel" to="VBoxContainer/HBoxContainer/BudgetPanel" method="_on_pressed"] diff --git a/game/src/Game/GameSession/MainManagamentPanel/PopupPanel.gd b/game/src/Game/GameSession/MainManagamentPanel/PopupPanel.gd new file mode 100644 index 0000000..72e54ae --- /dev/null +++ b/game/src/Game/GameSession/MainManagamentPanel/PopupPanel.gd @@ -0,0 +1,24 @@ +extends Control + +var _mouse_over_viewport : bool = true +var _mouse_entered : bool = true +const _action_click : StringName = &"map_click" + +func _on_close_button_pressed(): + self.queue_free() + +func _on_top_panel_gui_input(event): + var far_point1 : Vector2 = Vector2(self.get_global_position().x,self.get_global_position().y) + var far_point2 : Vector2 = Vector2(self.get_global_position().x+self.size.x,self.get_global_position().y+self.size.y) + + if Input.is_action_pressed(_action_click) and event is InputEventMouseMotion and _mouse_over_viewport: + if far_point1.x+event.relative.x > 0 and far_point1.y+event.relative.y > 0 and far_point2.x+event.relative.x < get_viewport().size.x and far_point2.y+event.relative.y < get_viewport().size.y and get_global_mouse_position().x > 0 and get_global_mouse_position().y > 0 and get_global_mouse_position().x < get_viewport().size.x and get_global_mouse_position().y < get_viewport().size.y: + set_position(self.get_screen_position()+event.relative) + else: + pass + +func _on_mouse_entered_viewport(): + _mouse_over_viewport = true + +func _on_mouse_exited_viewport(): + _mouse_over_viewport = false diff --git a/game/src/Game/GameSession/MainManagamentPanel/PopupPanel.tscn b/game/src/Game/GameSession/MainManagamentPanel/PopupPanel.tscn new file mode 100644 index 0000000..52cec21 --- /dev/null +++ b/game/src/Game/GameSession/MainManagamentPanel/PopupPanel.tscn @@ -0,0 +1,80 @@ +[gd_scene load_steps=5 format=3 uid="uid://cigua67hys7yl"] + +[ext_resource type="Script" path="res://src/Game/GameSession/MainManagamentPanel/PopupPanel.gd" id="1_u7a8e"] +[ext_resource type="Texture2D" uid="uid://cvfxeyui44yj6" path="res://art/ui/cancel.png" id="2_5e4k1"] + +[sub_resource type="GDScript" id="GDScript_c3oah"] +script/source = "extends Panel + +func _ready(): + self.set_size($\"../CloseButton/Sprite2D/Control\".get_size()*$\"../CloseButton/Sprite2D\".get_scale()) # Making it equal to sprite size + self.size.x = get_parent().size.x # Making it to be on whole top side +" + +[sub_resource type="GDScript" id="GDScript_vtk7h"] +script/source = "extends Button + + +# Called when the node enters the scene tree for the first time. +func _ready(): + self.set_size($Sprite2D/Control.get_size()*$Sprite2D.get_scale()) # Making it equal to sprite size + self.anchors_preset = 1 # Set it to the TOP RIGHT +" + +[node name="PopupPanel" type="Control"] +layout_mode = 3 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -125.0 +offset_top = -100.0 +offset_right = 125.0 +offset_bottom = 100.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_u7a8e") + +[node name="Body" type="Panel" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="TopPanel" type="Panel" parent="."] +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 +script = SubResource("GDScript_c3oah") + +[node name="CloseButton" type="Button" parent="."] +layout_mode = 1 +offset_right = 9.0 +offset_bottom = 9.0 +alignment = 0 +script = SubResource("GDScript_vtk7h") + +[node name="Sprite2D" type="Sprite2D" parent="CloseButton"] +scale = Vector2(0.1, 0.1) +texture = ExtResource("2_5e4k1") +centered = false + +[node name="Control" type="Control" parent="CloseButton/Sprite2D"] +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 +mouse_filter = 2 + +[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"] +[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"] +[connection signal="gui_input" from="TopPanel" to="." method="_on_top_panel_gui_input"] +[connection signal="pressed" from="CloseButton" to="." method="_on_close_button_pressed"] +[connection signal="pressed" from="CloseButton" to="." method="_on_button_pressed"] -- cgit v1.2.3-56-ga3b1