restructured project
This commit is contained in:
27
MainMenu/MainMenu.cs
Normal file
27
MainMenu/MainMenu.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public class MainMenu : Control
|
||||
{
|
||||
|
||||
private Main _main;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_main = GetTree().Root.GetNode<Main>("Main");
|
||||
}
|
||||
|
||||
public void _on_Button_pressed()
|
||||
{
|
||||
var nParticles = GetNode<VBoxContainer>("MenuButtons").GetNode<TextEdit>("TextEdit").Text.ToInt();
|
||||
_main.StartSimulation(nParticles);
|
||||
}
|
||||
|
||||
public void _on_ToggleFullscreen_pressed()
|
||||
{
|
||||
if (OS.WindowFullscreen)
|
||||
OS.WindowFullscreen = false;
|
||||
else
|
||||
OS.WindowFullscreen = true;
|
||||
}
|
||||
}
|
||||
98
MainMenu/MainMenu.tscn
Normal file
98
MainMenu/MainMenu.tscn
Normal file
@@ -0,0 +1,98 @@
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://ui/ui_theme.tres" type="Theme" id=1]
|
||||
[ext_resource path="res://ui/particles_logo.png" type="Texture" id=2]
|
||||
[ext_resource path="res://MainMenu/MainMenu.cs" type="Script" id=3]
|
||||
[ext_resource path="res://ui/ColorTube-Regular.ttf" type="DynamicFontData" id=4]
|
||||
|
||||
[sub_resource type="DynamicFont" id=1]
|
||||
size = 12
|
||||
font_data = ExtResource( 4 )
|
||||
|
||||
[node name="MainMenu" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
theme = ExtResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="MenuButtons" type="VBoxContainer" parent="."]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -150.0
|
||||
margin_top = -105.315
|
||||
margin_right = 150.0
|
||||
margin_bottom = 192.685
|
||||
custom_constants/separation = 12
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Label" type="Label" parent="MenuButtons"]
|
||||
margin_right = 300.0
|
||||
margin_bottom = 27.0
|
||||
text = "Number of Particles"
|
||||
align = 1
|
||||
|
||||
[node name="TextEdit" type="TextEdit" parent="MenuButtons"]
|
||||
margin_top = 39.0
|
||||
margin_right = 300.0
|
||||
margin_bottom = 103.769
|
||||
rect_min_size = Vector2( 0, 64.769 )
|
||||
text = "1000"
|
||||
|
||||
[node name="Button" type="Button" parent="MenuButtons"]
|
||||
margin_top = 115.0
|
||||
margin_right = 300.0
|
||||
margin_bottom = 166.251
|
||||
text = "Simulate!"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Warning" type="Label" parent="MenuButtons"]
|
||||
margin_top = 178.0
|
||||
margin_right = 300.0
|
||||
margin_bottom = 223.0
|
||||
custom_fonts/font = SubResource( 1 )
|
||||
text = "Simulation cannot be resized
|
||||
once simulation starts!"
|
||||
align = 1
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MenuButtons"]
|
||||
margin_top = 235.0
|
||||
margin_right = 300.0
|
||||
margin_bottom = 235.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="ToggleFullscreen" type="Button" parent="MenuButtons"]
|
||||
margin_top = 247.0
|
||||
margin_right = 300.0
|
||||
margin_bottom = 298.251
|
||||
text = "Toggle Fullscreen"
|
||||
|
||||
[node name="Logo" type="TextureRect" parent="."]
|
||||
show_behind_parent = true
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -342.0
|
||||
margin_top = -357.183
|
||||
margin_right = 1578.0
|
||||
margin_bottom = 726.817
|
||||
rect_scale = Vector2( 0.35, 0.35 )
|
||||
mouse_filter = 2
|
||||
texture = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[connection signal="pressed" from="MenuButtons/Button" to="." method="_on_Button_pressed"]
|
||||
[connection signal="pressed" from="MenuButtons/ToggleFullscreen" to="." method="_on_ToggleFullscreen_pressed"]
|
||||
40
MainMenu/MenuBackground.cs
Normal file
40
MainMenu/MenuBackground.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public class MenuBackground : Node2D
|
||||
{
|
||||
|
||||
private Node2D _particleNodes;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
//_particleNodes = GetNode<Node2D>("ParticlesNodes");
|
||||
//var particleScene = GD.Load<PackedScene>("res://ParticleSimulation/ParticleNode.tscn");
|
||||
//var particleNode = particleScene.Instance<ParticleNode>();
|
||||
//_particleNodes.AddChild(particleNode);
|
||||
}
|
||||
|
||||
public void SetParticleCount(int nParticles)
|
||||
{
|
||||
int currentCount = _particleNodes.GetChildCount();
|
||||
if (currentCount < nParticles)
|
||||
{
|
||||
int addCount = nParticles - currentCount;
|
||||
for (int i = 0; i < addCount; i++)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO add private method to add particles
|
||||
|
||||
public override void _Process(float delta)
|
||||
{
|
||||
//var particleNodesArray = _particleNodes.GetChildren();
|
||||
//foreach (ParticleNode particle in particleNodesArray)
|
||||
//{
|
||||
// particle.Position += new Vector2(0.1f, 0f);
|
||||
//}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user