From 2814e62fbe0f4f4dd9cbfba71ce8499d7e7bc4d9 Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Wed, 16 Aug 2023 00:35:59 +0930 Subject: [PATCH] Messing around with battle scene UI --- test_scene.gd | 1 + test_scene.tscn | 2 - theme/menu_theme.tres | 15 +- widgets/BattleScene.gd | 15 +- widgets/BattleScene.tscn | 376 ++++++++++++++++++++++++++++++++++++++- 5 files changed, 394 insertions(+), 15 deletions(-) diff --git a/test_scene.gd b/test_scene.gd index 93f9d05..ed32092 100644 --- a/test_scene.gd +++ b/test_scene.gd @@ -45,6 +45,7 @@ func _ready(): bbg.max_value = len(SpriteLoader.battle_backgrounds) - 1 bbg.connect('value_changed', $BattleScene, 'set_bg') bbg.rect_min_size.x = 32 + bbg.rect_position.y = 218 bbg.align = LineEdit.ALIGN_RIGHT add_child(bbg) diff --git a/test_scene.tscn b/test_scene.tscn index 445ee48..a515688 100644 --- a/test_scene.tscn +++ b/test_scene.tscn @@ -30,5 +30,3 @@ visible = false margin_right = 320.0 [node name="BattleScene" parent="." instance=ExtResource( 7 )] -margin_left = 64.0 -margin_right = 320.0 diff --git a/theme/menu_theme.tres b/theme/menu_theme.tres index 4843ef4..ca993c8 100644 --- a/theme/menu_theme.tres +++ b/theme/menu_theme.tres @@ -1,4 +1,4 @@ -[gd_resource type="Theme" load_steps=20 format=2] +[gd_resource type="Theme" load_steps=22 format=2] [ext_resource path="res://3rd_party/sysfont/dynamicfont.tres" type="DynamicFont" id=1] [ext_resource path="res://theme/border_stylebox.tres" type="StyleBox" id=2] @@ -22,6 +22,11 @@ region_rect = Rect2( 12, 1, 8, 7 ) margin_left = 3.0 margin_right = 3.0 +[sub_resource type="StyleBoxLine" id=12] +color = Color( 1, 1, 1, 1 ) +grow_begin = 0.0 +grow_end = 0.0 + [sub_resource type="ImageTexture" id=4] [sub_resource type="ImageTexture" id=2] @@ -34,6 +39,12 @@ margin_right = 3.0 atlas = ExtResource( 9 ) region = Rect2( 1, 55, 7, 8 ) +[sub_resource type="StyleBoxLine" id=13] +color = Color( 1, 1, 1, 1 ) +grow_begin = 0.0 +grow_end = 0.0 +vertical = true + [sub_resource type="ImageTexture" id=6] [sub_resource type="ImageTexture" id=7] @@ -52,6 +63,7 @@ HScrollBar/styles/grabber_highlight = SubResource( 10 ) HScrollBar/styles/grabber_pressed = SubResource( 10 ) HScrollBar/styles/scroll = SubResource( 9 ) HScrollBar/styles/scroll_focus = SubResource( 9 ) +HSeparator/styles/separator = SubResource( 12 ) HSlider/icons/grabber = SubResource( 4 ) HSlider/icons/grabber_disabled = SubResource( 2 ) HSlider/icons/grabber_highlight = SubResource( 3 ) @@ -93,6 +105,7 @@ VScrollBar/styles/grabber = ExtResource( 5 ) VScrollBar/styles/grabber_highlight = ExtResource( 5 ) VScrollBar/styles/grabber_pressed = ExtResource( 5 ) VScrollBar/styles/scroll = ExtResource( 6 ) +VSeparator/styles/separator = SubResource( 13 ) VSlider/icons/grabber = SubResource( 6 ) VSlider/icons/grabber_disabled = SubResource( 7 ) VSlider/icons/grabber_highlight = SubResource( 8 ) diff --git a/widgets/BattleScene.gd b/widgets/BattleScene.gd index 2ac176a..9b68aeb 100644 --- a/widgets/BattleScene.gd +++ b/widgets/BattleScene.gd @@ -1,6 +1,7 @@ extends ReferenceRect const battle_bg_shader = preload('res://shaders/tilemap_shader.gdshader') +onready var background := $background var bg: SpriteLoader.BattleBackground var pal_l: int var atlas_l: int @@ -9,22 +10,22 @@ var atlas_l: int func _ready() -> void: var battle_bg_mat := ShaderMaterial.new() battle_bg_mat.shader = battle_bg_shader - $background.material = battle_bg_mat + background.material = battle_bg_mat set_bg(1) func set_bg(index: int) -> void: self.bg = SpriteLoader.battle_backgrounds[index] self.pal_l = len(self.bg.palette_texs) self.atlas_l = len(self.bg.tile_atlas_texs) - $background.texture = self.bg.tilemap_tex - $background.material.set_shader_param('palette', self.bg.palette_texs[0]) - $background.material.set_shader_param('tile_atlas', self.bg.tile_atlas_texs[0]) + background.texture = self.bg.tilemap_tex + background.material.set_shader_param('palette', self.bg.palette_texs[0]) + background.material.set_shader_param('tile_atlas', self.bg.tile_atlas_texs[0]) # Called every frame. 'delta' is the elapsed time since the previous frame. var t := 0.0 func _process(delta: float) -> void: if not self.bg: return - self.t = fmod(self.t + delta, 2.0) - $background.material.set_shader_param('palette', self.bg.palette_texs[int(self.t * 30) % self.pal_l]) - $background.material.set_shader_param('tile_atlas', self.bg.tile_atlas_texs[int(self.t * 7.5) % self.atlas_l]) + self.t = fmod(self.t + delta, 30.0) + background.material.set_shader_param('palette', self.bg.palette_texs[int(self.t * 30) % self.pal_l]) + background.material.set_shader_param('tile_atlas', self.bg.tile_atlas_texs[int(self.t * 7.5) % self.atlas_l]) diff --git a/widgets/BattleScene.tscn b/widgets/BattleScene.tscn index 8c50a0d..93fe8d5 100644 --- a/widgets/BattleScene.tscn +++ b/widgets/BattleScene.tscn @@ -1,20 +1,386 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=3 format=2] [ext_resource path="res://widgets/BattleScene.gd" type="Script" id=1] +[ext_resource path="res://theme/ThemeElements.png" type="Texture" id=2] [node name="BattleScene" type="ReferenceRect"] -margin_right = 256.0 -margin_bottom = 240.0 +anchor_right = 1.0 +anchor_bottom = 1.0 script = ExtResource( 1 ) [node name="background" type="TextureRect" parent="."] -margin_right = 32.0 +margin_left = 64.0 +margin_right = 96.0 margin_bottom = 20.0 rect_min_size = Vector2( 32, 20 ) rect_scale = Vector2( 8, 8 ) +stretch_mode = 3 -[node name="Panel" type="Panel" parent="."] +[node name="panels" type="HBoxContainer" parent="."] anchor_top = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 margin_top = -80.0 +size_flags_horizontal = 3 +custom_constants/separation = 0 + +[node name="enemy_panel" type="PanelContainer" parent="panels"] +margin_right = 154.0 +margin_bottom = 81.0 +size_flags_horizontal = 3 + +[node name="VBoxContainer" type="VBoxContainer" parent="panels/enemy_panel"] +margin_left = 4.0 +margin_top = 4.0 +margin_right = 150.0 +margin_bottom = 77.0 +custom_constants/separation = -1 + +[node name="enemies" type="Label" parent="panels/enemy_panel/VBoxContainer"] +margin_right = 146.0 +margin_bottom = 14.0 +rect_min_size = Vector2( 0, 14 ) +text = "Enemies" + +[node name="HSeparator" type="HSeparator" parent="panels/enemy_panel/VBoxContainer"] +margin_top = 13.0 +margin_right = 146.0 +margin_bottom = 21.0 + +[node name="grid" type="GridContainer" parent="panels/enemy_panel/VBoxContainer"] +margin_top = 20.0 +margin_right = 146.0 +margin_bottom = 34.0 +custom_constants/vseparation = -1 +columns = 2 + +[node name="Label" type="Label" parent="panels/enemy_panel/VBoxContainer/grid"] +margin_right = 123.0 +margin_bottom = 14.0 +rect_min_size = Vector2( 0, 14 ) +size_flags_horizontal = 3 +text = "Gilgamesh Prime" + +[node name="Label2" type="Label" parent="panels/enemy_panel/VBoxContainer/grid"] +margin_left = 131.0 +margin_right = 146.0 +margin_bottom = 14.0 +rect_min_size = Vector2( 0, 14 ) +text = "x7" + +[node name="party_panel" type="PanelContainer" parent="panels"] +margin_left = 154.0 +margin_right = 384.0 +margin_bottom = 81.0 + +[node name="HBoxContainer" type="HBoxContainer" parent="panels/party_panel"] +margin_left = 4.0 +margin_top = 4.0 +margin_right = 226.0 +margin_bottom = 77.0 + +[node name="party" type="VBoxContainer" parent="panels/party_panel/HBoxContainer"] +margin_right = 44.0 +margin_bottom = 73.0 +custom_constants/separation = -1 + +[node name="party" type="Label" parent="panels/party_panel/HBoxContainer/party"] +margin_right = 44.0 +margin_bottom = 14.0 +rect_min_size = Vector2( 0, 14 ) +text = "Party " + +[node name="HSeparator" type="HSeparator" parent="panels/party_panel/HBoxContainer/party"] +margin_top = 13.0 +margin_right = 44.0 +margin_bottom = 21.0 + +[node name="Bartz" type="Label" parent="panels/party_panel/HBoxContainer/party"] +margin_top = 20.0 +margin_right = 44.0 +margin_bottom = 34.0 +rect_min_size = Vector2( 0, 14 ) +text = "Bartz" + +[node name="Lenna" type="Label" parent="panels/party_panel/HBoxContainer/party"] +margin_top = 33.0 +margin_right = 44.0 +margin_bottom = 47.0 +rect_min_size = Vector2( 0, 14 ) +text = "Lenna" + +[node name="Faris" type="Label" parent="panels/party_panel/HBoxContainer/party"] +margin_top = 46.0 +margin_right = 44.0 +margin_bottom = 60.0 +rect_min_size = Vector2( 0, 14 ) +text = "Faris" + +[node name="Galuf" type="Label" parent="panels/party_panel/HBoxContainer/party"] +margin_top = 59.0 +margin_right = 44.0 +margin_bottom = 73.0 +rect_min_size = Vector2( 0, 14 ) +text = "Galuf" + +[node name="hp" type="VBoxContainer" parent="panels/party_panel/HBoxContainer"] +margin_left = 52.0 +margin_right = 116.0 +margin_bottom = 73.0 +custom_constants/separation = -1 + +[node name="hp" type="Label" parent="panels/party_panel/HBoxContainer/hp"] +margin_right = 64.0 +margin_bottom = 14.0 +rect_min_size = Vector2( 0, 14 ) +text = "HP" +align = 1 + +[node name="HSeparator" type="HSeparator" parent="panels/party_panel/HBoxContainer/hp"] +margin_top = 13.0 +margin_right = 64.0 +margin_bottom = 21.0 + +[node name="GridContainer" type="GridContainer" parent="panels/party_panel/HBoxContainer/hp"] +margin_top = 20.0 +margin_right = 64.0 +margin_bottom = 73.0 +custom_constants/vseparation = -1 +custom_constants/hseparation = 0 +columns = 2 + +[node name="Label5" type="Label" parent="panels/party_panel/HBoxContainer/hp/GridContainer"] +margin_right = 35.0 +margin_bottom = 14.0 +rect_min_size = Vector2( 0, 14 ) +text = "787/" +align = 2 + +[node name="Label6" type="Label" parent="panels/party_panel/HBoxContainer/hp/GridContainer"] +margin_left = 35.0 +margin_right = 64.0 +margin_bottom = 14.0 +rect_min_size = Vector2( 0, 14 ) +text = "900" +align = 2 + +[node name="Label7" type="Label" parent="panels/party_panel/HBoxContainer/hp/GridContainer"] +margin_top = 13.0 +margin_right = 35.0 +margin_bottom = 27.0 +rect_min_size = Vector2( 0, 14 ) +text = "787/" +align = 2 + +[node name="Label8" type="Label" parent="panels/party_panel/HBoxContainer/hp/GridContainer"] +margin_left = 35.0 +margin_top = 13.0 +margin_right = 64.0 +margin_bottom = 27.0 +rect_min_size = Vector2( 0, 14 ) +text = "900" +align = 2 + +[node name="Label9" type="Label" parent="panels/party_panel/HBoxContainer/hp/GridContainer"] +margin_top = 26.0 +margin_right = 35.0 +margin_bottom = 40.0 +rect_min_size = Vector2( 0, 14 ) +text = "787/" +align = 2 + +[node name="Label10" type="Label" parent="panels/party_panel/HBoxContainer/hp/GridContainer"] +margin_left = 35.0 +margin_top = 26.0 +margin_right = 64.0 +margin_bottom = 40.0 +rect_min_size = Vector2( 0, 14 ) +text = "900" +align = 2 + +[node name="Label11" type="Label" parent="panels/party_panel/HBoxContainer/hp/GridContainer"] +margin_top = 39.0 +margin_right = 35.0 +margin_bottom = 53.0 +rect_min_size = Vector2( 0, 14 ) +text = "7879/" +align = 2 + +[node name="Label12" type="Label" parent="panels/party_panel/HBoxContainer/hp/GridContainer"] +margin_left = 35.0 +margin_top = 39.0 +margin_right = 64.0 +margin_bottom = 53.0 +rect_min_size = Vector2( 0, 14 ) +text = "9999" +align = 2 + +[node name="mp" type="VBoxContainer" parent="panels/party_panel/HBoxContainer"] +margin_left = 124.0 +margin_right = 174.0 +margin_bottom = 73.0 +custom_constants/separation = -1 + +[node name="mp" type="Label" parent="panels/party_panel/HBoxContainer/mp"] +margin_right = 50.0 +margin_bottom = 14.0 +rect_min_size = Vector2( 0, 14 ) +text = "MP" +align = 1 + +[node name="HSeparator" type="HSeparator" parent="panels/party_panel/HBoxContainer/mp"] +margin_top = 13.0 +margin_right = 50.0 +margin_bottom = 21.0 + +[node name="GridContainer" type="GridContainer" parent="panels/party_panel/HBoxContainer/mp"] +margin_top = 20.0 +margin_right = 50.0 +margin_bottom = 73.0 +custom_constants/vseparation = -1 +custom_constants/hseparation = 0 +columns = 2 + +[node name="Label5" type="Label" parent="panels/party_panel/HBoxContainer/mp/GridContainer"] +margin_right = 28.0 +margin_bottom = 14.0 +rect_min_size = Vector2( 0, 14 ) +text = "787/" +align = 2 + +[node name="Label6" type="Label" parent="panels/party_panel/HBoxContainer/mp/GridContainer"] +margin_left = 28.0 +margin_right = 50.0 +margin_bottom = 14.0 +rect_min_size = Vector2( 0, 14 ) +text = "900" +align = 2 + +[node name="Label7" type="Label" parent="panels/party_panel/HBoxContainer/mp/GridContainer"] +margin_top = 13.0 +margin_right = 28.0 +margin_bottom = 27.0 +rect_min_size = Vector2( 0, 14 ) +text = "787/" +align = 2 + +[node name="Label8" type="Label" parent="panels/party_panel/HBoxContainer/mp/GridContainer"] +margin_left = 28.0 +margin_top = 13.0 +margin_right = 50.0 +margin_bottom = 27.0 +rect_min_size = Vector2( 0, 14 ) +text = "900" +align = 2 + +[node name="Label9" type="Label" parent="panels/party_panel/HBoxContainer/mp/GridContainer"] +margin_top = 26.0 +margin_right = 28.0 +margin_bottom = 40.0 +rect_min_size = Vector2( 0, 14 ) +text = "787/" +align = 2 + +[node name="Label10" type="Label" parent="panels/party_panel/HBoxContainer/mp/GridContainer"] +margin_left = 28.0 +margin_top = 26.0 +margin_right = 50.0 +margin_bottom = 40.0 +rect_min_size = Vector2( 0, 14 ) +text = "900" +align = 2 + +[node name="Label11" type="Label" parent="panels/party_panel/HBoxContainer/mp/GridContainer"] +margin_top = 39.0 +margin_right = 28.0 +margin_bottom = 53.0 +rect_min_size = Vector2( 0, 14 ) +text = "787/" +align = 2 + +[node name="Label12" type="Label" parent="panels/party_panel/HBoxContainer/mp/GridContainer"] +margin_left = 28.0 +margin_top = 39.0 +margin_right = 50.0 +margin_bottom = 53.0 +rect_min_size = Vector2( 0, 14 ) +text = "900" +align = 2 + +[node name="atb" type="VBoxContainer" parent="panels/party_panel/HBoxContainer"] +margin_left = 182.0 +margin_right = 222.0 +margin_bottom = 73.0 +custom_constants/separation = -1 + +[node name="atb" type="Label" parent="panels/party_panel/HBoxContainer/atb"] +margin_right = 40.0 +margin_bottom = 14.0 +rect_min_size = Vector2( 0, 14 ) +text = "ATB" +align = 1 + +[node name="HSeparator" type="HSeparator" parent="panels/party_panel/HBoxContainer/atb"] +margin_top = 13.0 +margin_right = 40.0 +margin_bottom = 21.0 + +[node name="MarginContainer" type="MarginContainer" parent="panels/party_panel/HBoxContainer/atb"] +margin_top = 20.0 +margin_right = 40.0 +margin_bottom = 69.0 +custom_constants/margin_top = 3 + +[node name="VBoxContainer" type="VBoxContainer" parent="panels/party_panel/HBoxContainer/atb/MarginContainer"] +margin_top = 3.0 +margin_right = 40.0 +margin_bottom = 49.0 +size_flags_vertical = 3 +custom_constants/separation = 6 + +[node name="NinePatchRect" type="NinePatchRect" parent="panels/party_panel/HBoxContainer/atb/MarginContainer/VBoxContainer"] +margin_right = 40.0 +margin_bottom = 7.0 +rect_min_size = Vector2( 40, 7 ) +texture = ExtResource( 2 ) +region_rect = Rect2( 12, 1, 8, 7 ) +patch_margin_left = 3 +patch_margin_top = 1 +patch_margin_right = 3 +patch_margin_bottom = 1 + +[node name="NinePatchRect2" type="NinePatchRect" parent="panels/party_panel/HBoxContainer/atb/MarginContainer/VBoxContainer"] +margin_top = 13.0 +margin_right = 40.0 +margin_bottom = 20.0 +rect_min_size = Vector2( 40, 7 ) +texture = ExtResource( 2 ) +region_rect = Rect2( 12, 1, 8, 7 ) +patch_margin_left = 3 +patch_margin_top = 1 +patch_margin_right = 3 +patch_margin_bottom = 1 + +[node name="NinePatchRect3" type="NinePatchRect" parent="panels/party_panel/HBoxContainer/atb/MarginContainer/VBoxContainer"] +margin_top = 26.0 +margin_right = 40.0 +margin_bottom = 33.0 +rect_min_size = Vector2( 40, 7 ) +texture = ExtResource( 2 ) +region_rect = Rect2( 12, 1, 8, 7 ) +patch_margin_left = 3 +patch_margin_top = 1 +patch_margin_right = 3 +patch_margin_bottom = 1 + +[node name="NinePatchRect4" type="NinePatchRect" parent="panels/party_panel/HBoxContainer/atb/MarginContainer/VBoxContainer"] +margin_top = 39.0 +margin_right = 40.0 +margin_bottom = 46.0 +rect_min_size = Vector2( 40, 7 ) +texture = ExtResource( 2 ) +region_rect = Rect2( 12, 1, 8, 7 ) +patch_margin_left = 3 +patch_margin_top = 1 +patch_margin_right = 3 +patch_margin_bottom = 1