Skip to content

Commit 092fd41

Browse files
committed
Standardized background changing
Created AreaBasedBackground class
1 parent 5513751 commit 092fd41

File tree

8 files changed

+32
-36
lines changed

8 files changed

+32
-36
lines changed

Scenes/AreaBasedBackground.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using FunkEngine;
3+
using Godot;
4+
5+
public partial class AreaBasedBackground : TextureRect
6+
{
7+
public override void _Ready()
8+
{
9+
Texture = StageProducer.CurArea switch
10+
{
11+
Area.Forest => GD.Load<Texture2D>("res://SharedAssets/BackGround_Full.png"),
12+
Area.City => GD.Load<Texture2D>("res://icon.svg"),
13+
_ => null,
14+
};
15+
}
16+
}

Scenes/AreaBasedBackground.cs.uid

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://cp6t6haqyef7o

Scenes/BattleDirector/BattleScene.tscn

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
[gd_scene load_steps=11 format=3 uid="uid://b0mrgr7h0ty1y"]
1+
[gd_scene load_steps=12 format=3 uid="uid://b0mrgr7h0ty1y"]
22

33
[ext_resource type="Script" uid="uid://bttu0wmy2fp64" path="res://Scenes/BattleDirector/Scripts/BattleDirector.cs" id="1_jmdo1"]
44
[ext_resource type="Script" uid="uid://pl57giqyhckb" path="res://Scenes/UI/Scripts/MenuModule.cs" id="2_ka0ws"]
55
[ext_resource type="Script" uid="uid://tg14hkh1n7iv" path="res://Scenes/BattleDirector/Scripts/Conductor.cs" id="3_elcaj"]
66
[ext_resource type="PackedScene" uid="uid://duhiilcv4tat3" path="res://Scenes/BattleDirector/NotePlacementBar.tscn" id="4_qk7om"]
77
[ext_resource type="PackedScene" uid="uid://dfevfib11kou1" path="res://Scenes/ChartViewport/ChartViewport.tscn" id="5_r2xh0"]
88
[ext_resource type="Texture2D" uid="uid://qhwve7fik4do" path="res://SharedAssets/BackGround_Full.png" id="6_0jtpx"]
9+
[ext_resource type="Script" uid="uid://cp6t6haqyef7o" path="res://Scenes/AreaBasedBackground.cs" id="7_6k2qj"]
910
[ext_resource type="Texture2D" uid="uid://dbjotl0v1ymia" path="res://SharedAssets/BattleFrame1.png" id="7_klvil"]
1011
[ext_resource type="Theme" uid="uid://d37e3tpsbxwak" path="res://Scenes/UI/Assets/GeneralTheme.tres" id="8_62qim"]
1112

@@ -74,6 +75,7 @@ z_index = -1
7475
offset_right = 640.0
7576
offset_bottom = 178.0
7677
texture = ExtResource("6_0jtpx")
78+
script = ExtResource("7_6k2qj")
7779

7880
[node name="BattleFrame" type="TextureRect" parent="."]
7981
z_index = 1

Scenes/BattleDirector/Scripts/BattleDirector.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ public partial class BattleDirector : Node2D
1515
public PlayerPuppet Player;
1616
private EnemyPuppet[] _enemies;
1717

18-
[Export]
19-
public TextureRect BackgroundRect;
20-
2118
[Export]
2219
public Marker2D[] PuppetMarkers = new Marker2D[4]; //[0] is always player
2320

@@ -60,13 +57,6 @@ private void BeginPlayback()
6057

6158
public override void _Ready()
6259
{
63-
BackgroundRect.Texture = StageProducer.CurArea switch
64-
{
65-
Area.Forest => GD.Load<Texture2D>("res://SharedAssets/BackGround_Full.png"),
66-
Area.City => GD.Load<Texture2D>("res://icon.svg"),
67-
_ => null,
68-
};
69-
7060
SongData curSong = StageProducer.Config.CurSong.SongData;
7161
Audio.SetStream(GD.Load<AudioStream>(StageProducer.Config.CurSong.AudioLocation));
7262
if (curSong.SongLength <= 0)

Scenes/ChestScene/ChestScene.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,8 @@ public partial class ChestScene : Node2D
1515
[Export]
1616
public Marker2D PlayerMarker;
1717

18-
[Export]
19-
public TextureRect BackgroundRect;
20-
2118
public override void _Ready()
2219
{
23-
BackgroundRect.Texture = StageProducer.CurArea switch //TODO: Standardized BG changing behaviour.
24-
{
25-
Area.Forest => GD.Load<Texture2D>("res://SharedAssets/BackGround_Full.png"),
26-
Area.City => GD.Load<Texture2D>("res://icon.svg"),
27-
_ => null,
28-
};
29-
3020
_player = GD.Load<PackedScene>(PlayerPuppet.LoadPath).Instantiate<PlayerPuppet>();
3121
PlayerMarker.AddChild(_player);
3222

Scenes/ChestScene/ChestScene.tscn

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
[gd_scene load_steps=10 format=3 uid="uid://c4vmb783d3v03"]
1+
[gd_scene load_steps=11 format=3 uid="uid://c4vmb783d3v03"]
22

33
[ext_resource type="Script" uid="uid://cetn71kolbrmg" path="res://Scenes/ChestScene/ChestScene.cs" id="1_ardd2"]
44
[ext_resource type="AudioStream" uid="uid://be5ial13ynf3o" path="res://Audio/Song1.ogg" id="2_x78jo"]
55
[ext_resource type="Script" uid="uid://pl57giqyhckb" path="res://Scenes/UI/Scripts/MenuModule.cs" id="3_5uvci"]
6+
[ext_resource type="Script" uid="uid://cp6t6haqyef7o" path="res://Scenes/AreaBasedBackground.cs" id="5_u0wcg"]
67
[ext_resource type="Shader" uid="uid://dp36iuuy414k1" path="res://SharedAssets/StarryNight.gdshader" id="5_whthd"]
78
[ext_resource type="Texture2D" uid="uid://qhwve7fik4do" path="res://SharedAssets/BackGround_Full.png" id="6_37nar"]
89
[ext_resource type="Texture2D" uid="uid://d0ywqw1j1k71v" path="res://Scenes/ChestScene/Assets/Chest.png" id="6_58hf4"]
@@ -39,6 +40,7 @@ z_index = -1
3940
offset_right = 640.0
4041
offset_bottom = 178.0
4142
texture = ExtResource("6_37nar")
43+
script = ExtResource("5_u0wcg")
4244

4345
[node name="BattleFrame" type="TextureRect" parent="."]
4446
z_index = 1

Scenes/Maps/Cartographer.tscn

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
[gd_scene load_steps=6 format=3 uid="uid://cydmo2lbnj1de"]
1+
[gd_scene load_steps=7 format=3 uid="uid://cydmo2lbnj1de"]
22

33
[ext_resource type="Script" uid="uid://dtlpiwt4n3pta" path="res://Scenes/Maps/Scripts/Cartographer.cs" id="1_u4q3n"]
44
[ext_resource type="Texture2D" uid="uid://qhwve7fik4do" path="res://SharedAssets/BackGround_Full.png" id="2_5g6at"]
55
[ext_resource type="Script" uid="uid://pl57giqyhckb" path="res://Scenes/UI/Scripts/MenuModule.cs" id="2_cl7v0"]
66
[ext_resource type="Theme" uid="uid://bcejp4llrb3m0" path="res://Scenes/UI/Assets/EmptyButton.tres" id="2_rnj1y"]
77
[ext_resource type="Texture2D" uid="uid://cmc7gcplqnebx" path="res://SharedAssets/Player.png" id="3_qiprp"]
8+
[ext_resource type="Script" uid="uid://cp6t6haqyef7o" path="res://Scenes/AreaBasedBackground.cs" id="5_taedj"]
89

910
[node name="Cartographer" type="Node2D" node_paths=PackedStringArray("BackgroundSprite", "PlayerSprite", "Camera")]
1011
process_mode = 1
1112
script = ExtResource("1_u4q3n")
12-
BackgroundSprite = NodePath("BG")
13+
BackgroundSprite = NodePath("")
1314
PlayerSprite = NodePath("Player")
1415
ButtonTheme = ExtResource("2_rnj1y")
1516
Camera = NodePath("TheView")
@@ -23,11 +24,15 @@ limit_top = -10
2324
script = ExtResource("2_cl7v0")
2425
CurSceneNode = NodePath("..")
2526

26-
[node name="BG" type="Sprite2D" parent="."]
27+
[node name="BG" type="TextureRect" parent="."]
2728
modulate = Color(0.462, 0.462, 0.66, 1)
28-
position = Vector2(175, 240)
29+
offset_left = -557.0
30+
offset_top = -84.0
31+
offset_right = 83.0
32+
offset_bottom = 96.0
2933
scale = Vector2(3, 3)
3034
texture = ExtResource("2_5g6at")
35+
script = ExtResource("5_taedj")
3136

3237
[node name="Player" type="Sprite2D" parent="."]
3338
z_index = 2

Scenes/Maps/Scripts/Cartographer.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ public partial class Cartographer : Node2D
1111
{
1212
public static readonly string LoadPath = "res://Scenes/Maps/Cartographer.tscn";
1313

14-
[Export]
15-
public Sprite2D BackgroundSprite;
16-
1714
[Export]
1815
public Sprite2D PlayerSprite;
1916

@@ -39,13 +36,6 @@ public partial class Cartographer : Node2D
3936

4037
public override void _Ready()
4138
{
42-
BackgroundSprite.Texture = StageProducer.CurArea switch
43-
{
44-
Area.Forest => GD.Load<Texture2D>("res://SharedAssets/BackGround_Full.png"),
45-
Area.City => GD.Load<Texture2D>("res://icon.svg"),
46-
_ => null,
47-
};
48-
4939
DrawMap();
5040
SaveSystem.SaveGame();
5141
if (

0 commit comments

Comments
 (0)