Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions shaders/SpinnerPixel.gdshader
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
shader_type canvas_item;

/*
Fragment is less performant but doesn't require to pass the size in the parameters.
If you need the more performant variant, you may use the other shader: SpinnerVertex
*/

// Use negative numbers to rotate counterclockwise
uniform float rotationSpeed = 1.0;

// Matrix to calculate the rotation
vec2 rotate (vec2 uv, vec2 pivot, float angle) {
mat2 rotationMatrix = mat2(vec2(cos(angle), -sin(angle)),
vec2(sin(angle), cos(angle)));

uv -= pivot;
uv = uv * rotationMatrix;
uv += pivot;
return uv;
}

void fragment() {
// Pass rotation speed
float time = -TIME * rotationSpeed;

vec2 uvRotated = rotate(UV, vec2(0.5), time);
COLOR = texture(TEXTURE, uvRotated);
}
1 change: 1 addition & 0 deletions shaders/SpinnerPixel.gdshader.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://c42nxgqvmb36k
34 changes: 34 additions & 0 deletions shaders/SpinnerVertex.gdshader
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
shader_type canvas_item;

/*
This Vertex shader requires the size property values to be passed again through shader parameters
If you want to avoid this, you may use the other spinner shader: SpinnerPixel
*/

// Use negative numbers to rotate counterclockwise
uniform float rotationSpeed = 1.0;

// This is done to ensure this shader will work with assets that have been scaled down in engine
uniform float sizeX = 0;
uniform float sizeY = 0;

// Matrix to calculate the rotation
vec2 rotate (vec2 uv, vec2 pivot, float angle) {
mat2 rotationMatrix = mat2(vec2(cos(angle), -sin(angle)),
vec2(sin(angle), cos(angle)));

uv -= pivot;
uv = uv * rotationMatrix;
uv += pivot;
return uv;
}

void vertex() {
// Make a vector2 with the passed size values
vec2 size = vec2(sizeX, sizeY);

// Pass rotation speed
float time = TIME * rotationSpeed;

VERTEX = rotate(VERTEX, vec2(size * 0.5), time);
}
1 change: 1 addition & 0 deletions shaders/SpinnerVertex.gdshader.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://ccqfxdx4iqla5
11 changes: 0 additions & 11 deletions src/engine/LoadingScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ public partial class LoadingScreen : Control
private string loadingDescription = string.Empty;
private string? artDescription;

private double totalElapsed;

private LoadingScreen()
{
instance = this;
Expand Down Expand Up @@ -153,14 +151,7 @@ public override void _Process(double delta)
wasVisible = false;
randomizeTimer.Stop();
}

return;
}

// Spin the spinner
totalElapsed += delta;

spinner.Rotation = (float)(totalElapsed * SpinnerSpeed) % MathF.Tau;
}

/// <summary>
Expand Down Expand Up @@ -206,7 +197,6 @@ public void RandomizeArt()

var category = gallery.AssetCategories.ContainsKey(gameStateName) ? gameStateName : "General";
var artwork = gallery.AssetCategories[category].Assets.Random(random);

artworkRect.Image = GD.Load<Texture2D>(artwork.ResourcePath);
ArtDescription = artwork.BuildDescription(true);
}
Expand All @@ -233,7 +223,6 @@ protected override void Dispose(bool disposing)
private void OnBecomeVisible()
{
wasVisible = true;
totalElapsed = 0;

RandomizeContent();

Expand Down
11 changes: 9 additions & 2 deletions src/engine/LoadingScreen.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=12 format=3 uid="uid://d386dbkjbq2rh"]
[gd_scene load_steps=14 format=3 uid="uid://d386dbkjbq2rh"]

[ext_resource type="Script" uid="uid://bg5x6f3rbsqy" path="res://src/engine/LoadingScreen.cs" id="1"]
[ext_resource type="PackedScene" uid="uid://cgdp2u78cxxe7" path="res://src/gui_common/CrossFadableTextureRect.tscn" id="2"]
Expand All @@ -7,6 +7,7 @@
[ext_resource type="Shader" uid="uid://lf6igwl1dy7j" path="res://shaders/UVFlipper.gdshader" id="6"]
[ext_resource type="LabelSettings" uid="uid://bnhcbmq3brx0s" path="res://src/gui_common/fonts/Title-SemiBold-Normal.tres" id="6_rw556"]
[ext_resource type="LabelSettings" uid="uid://fua052cwp5ap" path="res://src/gui_common/fonts/Body-Regular-AlmostSmaller.tres" id="7_dhkod"]
[ext_resource type="Shader" uid="uid://ccqfxdx4iqla5" path="res://shaders/SpinnerVertex.gdshader" id="8_kw2xg"]
[ext_resource type="Script" uid="uid://c0itxwsgtedpj" path="res://src/gui_common/CustomRichTextLabel.cs" id="9"]

[sub_resource type="ShaderMaterial" id="1"]
Expand All @@ -19,6 +20,12 @@ colors = PackedColorArray(0.0117647, 0.027451, 0.0392157, 1, 0, 0, 0.00392157, 0
[sub_resource type="GradientTexture2D" id="3"]
gradient = SubResource("2")

[sub_resource type="ShaderMaterial" id="ShaderMaterial_3t0ay"]
shader = ExtResource("8_kw2xg")
shader_parameter/rotationSpeed = 1.0
shader_parameter/sizeX = 64.0
shader_parameter/sizeY = 64.0

[node name="LoadingScreen" type="Control"]
process_mode = 3
layout_mode = 3
Expand Down Expand Up @@ -128,11 +135,11 @@ custom_minimum_size = Vector2(64, 64)
layout_mode = 2

[node name="TextureRect" type="TextureRect" parent="MarginContainer/HBoxContainer/Spinner/Control"]
material = SubResource("ShaderMaterial_3t0ay")
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
offset_right = 64.0
offset_bottom = 64.0
pivot_offset = Vector2(32, 32)
texture = ExtResource("3")
expand_mode = 1
stretch_mode = 6
Expand Down
11 changes: 9 additions & 2 deletions src/gui_common/ChemicalEquation.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=9 format=3 uid="uid://d3vq1x8lvthvt"]
[gd_scene load_steps=11 format=3 uid="uid://d3vq1x8lvthvt"]

[ext_resource type="Theme" uid="uid://b4cx0o110g4b6" path="res://src/gui_common/thrive_theme.tres" id="1"]
[ext_resource type="Script" uid="uid://6yfse7bf5lb7" path="res://src/gui_common/ChemicalEquation.cs" id="2"]
Expand All @@ -7,6 +7,13 @@
[ext_resource type="LabelSettings" uid="uid://4teclbsvoawb" path="res://src/gui_common/fonts/Body-Bold-Smaller-Red.tres" id="4_vbkf3"]
[ext_resource type="Texture2D" uid="uid://bembxnxct020" path="res://assets/textures/gui/bevel/WhiteArrow.png" id="5_tr4hc"]
[ext_resource type="FontFile" uid="uid://b62thy1er4r08" path="res://assets/fonts/Lato-Bold.ttf" id="5_wdgi7"]
[ext_resource type="Shader" uid="uid://ccqfxdx4iqla5" path="res://shaders/SpinnerVertex.gdshader" id="6_m8q6p"]

[sub_resource type="ShaderMaterial" id="ShaderMaterial_1oc4h"]
shader = ExtResource("6_m8q6p")
shader_parameter/rotationSpeed = 0.3
shader_parameter/sizeX = 32.0
shader_parameter/sizeY = 32.0

[sub_resource type="Theme" id="1"]
default_font = ExtResource("5_wdgi7")
Expand Down Expand Up @@ -36,11 +43,11 @@ custom_minimum_size = Vector2(32, 32)
layout_mode = 2

[node name="Spinner" type="TextureRect" parent="HBoxContainer/SpinnerNode"]
material = SubResource("ShaderMaterial_1oc4h")
custom_minimum_size = Vector2(32, 32)
layout_mode = 2
offset_right = 32.0
offset_bottom = 32.0
pivot_offset = Vector2(16, 16)
texture = ExtResource("3")
expand_mode = 1
stretch_mode = 5
Expand Down