This commit is contained in:
h z
2024-06-24 07:27:50 +08:00
parent d0d90501a5
commit 634c503c7c
8 changed files with 67 additions and 11 deletions

View File

@@ -7,7 +7,6 @@ using VirtualChemistry.Chemistry.Mixtures.Implements;
public partial class Bottle : MenuButton, IChemicalContainer
{
private double ContainerVolume { get; set; }
private HeterogeneousMixture HeterogeneousMixture { get; set; }
public double Volume() => ContainerVolume;
public HeterogeneousMixture Content { get; set; } = HeterogeneousMixture.Null;
@@ -64,18 +63,38 @@ public partial class Bottle : MenuButton, IChemicalContainer
case 2:
GlobalScene.Demo.SelectedBottle = this;
GlobalScene.MainScene.SwitchToConstructor();
return;
break;
case 3:
Content = GlobalScene.Flask.Content;
Content.Container = this;
GlobalScene.Flask.Content = HeterogeneousMixture.Null;
GlobalScene.Flask.Update();
return;
break;
case 4:
return;
default:
return;
GlobalScene.Demo.SelectedBottle = this;
GlobalScene.Demo.PopupStringLoader();
break;
case 5:
foreach (HomogeneousMixture m in Content.Layers.ToArray())
{
m.Volume = m.FreeVolume;
GlobalScene.Flask.Content.AddLayer(m);
}
//GlobalScene.Flask.Content = Content;
//Content.Container = GlobalScene.Flask;
Content = HeterogeneousMixture.Null;
GlobalScene.Flask.Update();
break;
case 6:
GlobalScene.Demo.FullRepr.Text = Content.Dump();
break;
case 7:
Content = HeterogeneousMixture.Null;
break;
default:
break;
}
BuildMenu();
}
// Called when the node enters the scene tree for the first time.

View File

@@ -5,8 +5,8 @@ using VirtualChemistry.Chemistry.Mixtures.Implements;
public partial class Flask : TextureRect, IChemicalContainer
{
public double ContainerVolume { get; set; } = 100;
public double ContainerVolume { get; set; } = 0.5;
private TextureRect InnerLayer { get; set; }
public double Volume() => ContainerVolume;
public HeterogeneousMixture Content { get; set; }
@@ -24,8 +24,9 @@ public partial class Flask : TextureRect, IChemicalContainer
.Load<PackedScene>("res://Scenes/FlaskContent.tscn")
.Instantiate<FlaskContent>();
fc.Mixture = m;
AddChild(fc);
InnerLayer.AddChild(fc);
fc.Position = new(0, -(float)fc.StartFrom);
Map[m] = fc;
}
}
@@ -50,7 +51,8 @@ public partial class Flask : TextureRect, IChemicalContainer
public override void _Ready()
{
GlobalScene.Flask = this;
Content = HeterogeneousMixture.Null;
Content = new(this);
InnerLayer = GetNode<TextureRect>("InnerLayer");
}
// Called every frame. 'delta' is the elapsed time since the previous frame.

View File

@@ -8,3 +8,16 @@ offset_right = 40.0
offset_bottom = 40.0
texture = ExtResource("1_b34pm")
script = ExtResource("2_j1pe5")
[node name="InnerLayer" type="TextureRect" parent="."]
layout_mode = 0
offset_right = 40.0
offset_bottom = 40.0
texture = ExtResource("1_b34pm")
[node name="OuterLayer" type="TextureRect" parent="."]
layout_mode = 0
offset_right = 40.0
offset_bottom = 40.0
mouse_filter = 2
texture = ExtResource("1_b34pm")

View File

@@ -1,3 +1,4 @@
using System;
using Godot;
using Skeleton.DataStructure.Link;
using VirtualChemistry.Chemistry.Mixtures.Implements;
@@ -28,6 +29,16 @@ public partial class FlaskContent : ColorRect
public void UpdateVolumeAndPosition()
{
double height = (Volume / ContainerVolume) * ContainerHeight;
Position = new Vector2(Position.X, 512-(float)(StartFrom + height));
Size = new Vector2(Size.X, (float)height);
//Mask.Size = Size;
Color = Color.Color8(
Mixture.ColorRed,
Mixture.ColorGreen,
Mixture.ColorGreen,
Mixture.ColorTransparent
);
/*
Animation a = AP.GetAnimation("HeightChange");
a.TrackSetKeyValue(0, 0, Size);
a.TrackSetKeyValue(0, 1, new Vector2(Size.X, (float)height));
@@ -36,7 +47,8 @@ public partial class FlaskContent : ColorRect
a = AP.GetAnimation("PositionChange");
a.TrackSetKeyValue(0,0,Position);
a.TrackSetKeyValue(0,1, new Vector2(Position.X, -(float)StartFrom));
AP.Play();
Color = Color.Color8(Mixture.ColorRed, Mixture.ColorGreen, Mixture.ColorGreen, Mixture.ColorTransparent);
AP.Play();*/
}
// Called when the node enters the scene tree for the first time.

View File

@@ -82,3 +82,4 @@ offset_bottom = 4.0
[connection signal="resized" from="." to="." method="OnSizeChange"]
[connection signal="mouse_entered" from="Mask" to="." method="OnMouseEnter"]
[connection signal="mouse_exited" from="Mask" to="." method="OnMouseExit"]
[connection signal="pressed" from="Mask" to="." method="OnClick"]

View File

@@ -26,6 +26,7 @@ public partial class MainControlPanel : HBoxContainer
Amount = GetNode<Label>("V2/HAmount/Amount");
Temperature = GetNode<Label>("V2/HTemperature/Temperature");
Compounds = GetNode<Tree>("V3/Compounds");
GlobalScene.MainControlPanel = this;
}
@@ -37,6 +38,7 @@ public partial class MainControlPanel : HBoxContainer
public void Update(HomogeneousMixture mixture)
{
SelectedMixture = mixture;
Update();
}
public void Update()
@@ -45,7 +47,7 @@ public partial class MainControlPanel : HBoxContainer
return;
Density.Text = $"{SelectedMixture.Density}";
Volume.Text = $"{SelectedMixture.Volume}";
HeatConductivity.Text = $"{SelectedMixture.HeatConductivity}";
HeatConductivity.Text = $"{SelectedMixture.HeatConductivity.Get}";
Amount.Text = $"{SelectedMixture.Amount}";
Temperature.Text = $"{SelectedMixture.Temperature}";

View File

@@ -12,6 +12,7 @@ public partial class StringLoader : Window
{
Input = GetNode<TextEdit>("V1/Input");
GlobalScene.StringLoader = this;
Visible = true;
}
private void Load()

View File

@@ -7,6 +7,11 @@ public partial class VirtualChemDemo : Node2D
public Bottle SelectedBottle { get; set; }
private StringLoader ExpressionLoader { get; set; }
public void PopupStringLoader()
{
ExpressionLoader.Visible = true;
}
public void OneStep()
{
Flask.Content.OneStep();
@@ -21,6 +26,7 @@ public partial class VirtualChemDemo : Node2D
FullRepr = GetNode<RichTextLabel>("HRepr/FullRepr");
Flask = GetNode<Flask>("Flask");
GlobalScene.Demo = this;
}
// Called every frame. 'delta' is the elapsed time since the previous frame.