Demo Finish
This commit is contained in:
@@ -82,8 +82,6 @@ public partial class Bottle : MenuButton, IChemicalContainer
|
||||
m.Volume = m.FreeVolume;
|
||||
GlobalScene.Flask.Content.AddLayer(m);
|
||||
}
|
||||
//GlobalScene.Flask.Content = Content;
|
||||
//Content.Container = GlobalScene.Flask;
|
||||
Content = HeterogeneousMixture.Null;
|
||||
GlobalScene.Flask.Update();
|
||||
break;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Godot;
|
||||
using VirtualChemDemo;
|
||||
using VirtualChemDemo.Concepts;
|
||||
using VirtualChemistry.Chemistry.Atoms.Implements;
|
||||
using VirtualChemistry.Chemistry.Atoms.Resolver;
|
||||
@@ -19,13 +17,14 @@ public partial class CompoundConstructor : Panel
|
||||
public BaseBond ConnectPending { get; set; } = BaseBond.Null;
|
||||
public Atom PendingAtom { get; set; }
|
||||
public Dictionary<Atom, HashSet<Bond2D>> BondMap { get; set; } = new();
|
||||
private Viewer PanelViewer { get; set; }
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
GlobalScene.CompoundConstructor = this;
|
||||
HeterogeneousMixture = new();
|
||||
HomogeneousMixture = HeterogeneousMixture.AddLayer();
|
||||
PanelViewer = GetNode<Viewer>("Viewer");
|
||||
}
|
||||
|
||||
private static class AtomPositionFixMemory
|
||||
@@ -214,4 +213,5 @@ public partial class CompoundConstructor : Panel
|
||||
}
|
||||
|
||||
private void ForceClear() => Clear(false);
|
||||
private void BackToCenter() => PanelViewer.BackToCenter();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://c1ww4cmceq16t"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://c1ww4cmceq16t"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scenes/CompoundConstructor.cs" id="1_bhwhs"]
|
||||
[ext_resource type="Script" path="res://Scenes/AddAtom.cs" id="2_ddlyc"]
|
||||
[ext_resource type="Script" path="res://Scenes/Viewer.cs" id="3_4yky0"]
|
||||
[ext_resource type="Script" path="res://Scenes/ViewerCamera.cs" id="4_1i4tm"]
|
||||
|
||||
[node name="CompoundConstructor" type="Panel"]
|
||||
offset_left = -370.0
|
||||
@@ -14,9 +16,9 @@ script = ExtResource("1_bhwhs")
|
||||
|
||||
[node name="Controller" type="HBoxContainer" parent="ControlLayer"]
|
||||
offset_left = 57.0
|
||||
offset_top = 588.0
|
||||
offset_top = 572.0
|
||||
offset_right = 877.0
|
||||
offset_bottom = 632.0
|
||||
offset_bottom = 649.0
|
||||
|
||||
[node name="AddAtom" type="MenuButton" parent="ControlLayer/Controller"]
|
||||
layout_mode = 2
|
||||
@@ -36,6 +38,20 @@ text = "Clear"
|
||||
layout_mode = 2
|
||||
text = "Back"
|
||||
|
||||
[node name="BackToOrigin" type="Button" parent="ControlLayer/Controller"]
|
||||
layout_mode = 2
|
||||
text = "\\/
|
||||
>o<
|
||||
^"
|
||||
|
||||
[node name="Viewer" type="Node2D" parent="."]
|
||||
position = Vector2(946, 506)
|
||||
script = ExtResource("3_4yky0")
|
||||
|
||||
[node name="ViewerCamera" type="Camera2D" parent="Viewer"]
|
||||
script = ExtResource("4_1i4tm")
|
||||
|
||||
[connection signal="pressed" from="ControlLayer/Controller/BuildMixture" to="." method="Build"]
|
||||
[connection signal="pressed" from="ControlLayer/Controller/Clear" to="." method="ForceClear"]
|
||||
[connection signal="pressed" from="ControlLayer/Controller/Back" to="." method="Back"]
|
||||
[connection signal="pressed" from="ControlLayer/Controller/BackToOrigin" to="." method="BackToCenter"]
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using Godot;
|
||||
using Skeleton.DataStructure.Link;
|
||||
using VirtualChemistry.Chemistry.Mixtures.Implements;
|
||||
@@ -37,17 +36,6 @@ public partial class FlaskContent : ColorRect
|
||||
Mixture.ColorGreen,
|
||||
Mixture.ColorTransparent
|
||||
);
|
||||
|
||||
/*Animation a = AP.GetAnimation("HeightChange");
|
||||
a.TrackSetKeyValue(0, 0, Size);
|
||||
a.TrackSetKeyValue(0, 1, new Vector2(Size.X, (float)height));
|
||||
AP.Play("HeightChange");
|
||||
AP.Play("PositionChange");
|
||||
a = AP.GetAnimation("PositionChange");
|
||||
a.TrackSetKeyValue(0,0,Position);
|
||||
a.TrackSetKeyValue(0,1, new Vector2(Position.X, 512-(float)(StartFrom + height)));
|
||||
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.
|
||||
@@ -62,15 +50,8 @@ public partial class FlaskContent : ColorRect
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
}
|
||||
|
||||
private void OnSizeChange() => Mask.Size = Size;
|
||||
|
||||
private void OnMouseEnter() => AP.Play("MouseEntered");
|
||||
|
||||
private void OnMouseExit() => AP.PlayBackwards("MouseEntered");
|
||||
|
||||
private void OnClick()
|
||||
{
|
||||
GlobalScene.MainControlPanel.Update(Mixture);
|
||||
}
|
||||
private void OnClick() => GlobalScene.MainControlPanel.Update(Mixture);
|
||||
}
|
||||
|
||||
@@ -57,12 +57,14 @@ public partial class MainControlPanel : HBoxContainer
|
||||
{
|
||||
Compounds.Clear();
|
||||
TreeItem root = Compounds.CreateItem();
|
||||
root.SetText(0, "Mixtures: ");
|
||||
root.SetText(0, $"Mixtures({GlobalScene.Flask.Content.Layers.Count}): ");
|
||||
root.SetMeta("isoExp", GlobalScene.Flask.Content.Dump());
|
||||
int i = 1;
|
||||
foreach (HomogeneousMixture h in GlobalScene.Flask.Content.LayerOrder)
|
||||
{
|
||||
TreeItem sRoot = Compounds.CreateItem(root);
|
||||
sRoot.SetText(0,$"Mixture{i} Amt{h.Amount}");
|
||||
sRoot.SetMeta("isoExp", h.Dump());
|
||||
foreach (var group in h.Compounds.GroupBy(x => x.Expression))
|
||||
{
|
||||
TreeItem t = Compounds.CreateItem(root);
|
||||
|
||||
24
Scenes/Viewer.cs
Normal file
24
Scenes/Viewer.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Godot;
|
||||
public partial class Viewer : Node2D
|
||||
{
|
||||
private Vector2 Origin => GetParent<CompoundConstructor>().Size / 2;
|
||||
|
||||
public ViewerCamera ViewerCamera { get; private set; }
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
ViewerCamera = GetNode<ViewerCamera>("ViewerCamera");
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
if (@event is InputEventMouseMotion em)
|
||||
if (em.ButtonMask == MouseButtonMask.Middle)
|
||||
Position -= em.Relative;
|
||||
base._Input(@event);
|
||||
}
|
||||
|
||||
public void BackToCenter() => Position = Origin;
|
||||
}
|
||||
24
Scenes/ViewerCamera.cs
Normal file
24
Scenes/ViewerCamera.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Godot;
|
||||
|
||||
public partial class ViewerCamera : Camera2D
|
||||
{
|
||||
private static readonly Vector2 ZoomMin = new(0.02001f, 0.02001f);
|
||||
|
||||
private static readonly Vector2 ZoomMax = new(4f, 4f);
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
if (@event is InputEventMouseButton eb)
|
||||
{
|
||||
if (eb.IsPressed())
|
||||
{
|
||||
if (eb.ButtonIndex == MouseButton.WheelDown)
|
||||
if (Zoom.X > ZoomMin.X && Zoom.Y > ZoomMin.Y)
|
||||
Zoom -= new Vector2(0.01f, 0.01f);
|
||||
if(eb.ButtonIndex == MouseButton.WheelUp)
|
||||
if (Zoom.X < ZoomMax.X && Zoom.Y < ZoomMax.Y)
|
||||
Zoom += new Vector2(0.01f, 0.01f);
|
||||
}
|
||||
}
|
||||
base._Input(@event);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user