Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a miche viewer to the auto-evo prediction #5760

Merged
merged 4 commits into from
Jan 10, 2025
Merged
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
22 changes: 22 additions & 0 deletions src/microbe_stage/editor/CellEditorComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ public partial class CellEditorComponent :
[Export]
private CustomWindow processListWindow = null!;

[Export]
private PopupMicheViewer micheViewer = null!;

private CustomWindow autoEvoPredictionExplanationPopup = null!;
private CustomRichTextLabel autoEvoPredictionExplanationLabel = null!;

Expand Down Expand Up @@ -358,6 +361,8 @@ public partial class CellEditorComponent :
private PendingAutoEvoPrediction? waitingForPrediction;
private LocalizedStringBuilder? predictionDetailsText;

private Miche? predictionMiches;

private OrganelleSuggestionCalculation? inProgressSuggestion;
private bool suggestionDirty;
private double suggestionStartTimer;
Expand Down Expand Up @@ -2974,6 +2979,8 @@ private void OnAutoEvoPredictionComplete(PendingAutoEvoPrediction run)
{
UpdateAutoEvoPredictionDetailsText();
}

predictionMiches = results.GetMicheForPatch(Editor.CurrentPatch);
}

private void CreateAutoEvoPredictionDetailsText(
Expand Down Expand Up @@ -3048,6 +3055,21 @@ private void ToggleProcessList()
processListWindow.Visible = !processListWindow.Visible;
}

private void OnMicheViewRequested()
{
GUICommon.Instance.PlayButtonPressSound();

if (predictionMiches == null)
{
GD.PrintErr("Missing miches data, can't show the popup");
return;
}

micheViewer.ShowMiches(Editor.CurrentPatch, predictionMiches, Editor.CurrentGame.GameWorld.WorldSettings);

autoEvoPredictionExplanationPopup.Hide();
}

private class PendingAutoEvoPrediction
{
public AutoEvoRun AutoEvoRun;
Expand Down
15 changes: 13 additions & 2 deletions src/microbe_stage/editor/CellEditorComponent.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=65 format=3 uid="uid://cwot2e52r7lx0"]
[gd_scene load_steps=66 format=3 uid="uid://cwot2e52r7lx0"]

[ext_resource type="PackedScene" uid="uid://bwegwjlcioasf" path="res://src/microbe_stage/editor/EditorComponentBottomLeftButtons.tscn" id="3"]
[ext_resource type="Script" path="res://src/microbe_stage/editor/CellEditorComponent.cs" id="4"]
Expand Down Expand Up @@ -41,6 +41,7 @@
[ext_resource type="PackedScene" uid="uid://sxqf3o1pkl0n" path="res://src/microbe_stage/editor/CompoundBalanceDisplay.tscn" id="42"]
[ext_resource type="PackedScene" uid="uid://cwe0bjv8qtrtr" path="res://src/gui_common/TweakedColourPicker.tscn" id="43"]
[ext_resource type="PackedScene" path="res://src/gui_common/SegmentedBar.tscn" id="44"]
[ext_resource type="PackedScene" uid="uid://ci8lopfc3lodh" path="res://src/microbe_stage/editor/PopupMicheViewer.tscn" id="44_bxafd"]
[ext_resource type="PackedScene" uid="uid://bq6aee8pw8y3m" path="res://src/gui_common/CollapsibleList.tscn" id="45"]
[ext_resource type="PackedScene" uid="uid://jdsjx1iyga8d" path="res://src/microbe_stage/editor/OrganellePopupMenu.tscn" id="47"]

Expand Down Expand Up @@ -346,7 +347,7 @@ _data = {
"show": SubResource("44")
}

[node name="CellEditorComponent" type="Control" node_paths=PackedStringArray("growthOrderTabButton", "toleranceTabButton", "growthOrderTab", "growthOrderGUI", "toleranceTab", "organelleSuggestionLoadingIndicator", "organelleSuggestionLabel", "atpBalanceLabel", "pendingEndosymbiosisPopup", "endosymbiosisButton", "endosymbiosisPopup", "calculateBalancesAsIfDay", "calculateBalancesWhenMoving", "compoundBalance", "compoundStorageLastingTimes", "notEnoughStorageWarning", "processListButton", "processList", "growthOrderNumberContainer", "processListWindow")]
[node name="CellEditorComponent" type="Control" node_paths=PackedStringArray("growthOrderTabButton", "toleranceTabButton", "growthOrderTab", "growthOrderGUI", "toleranceTab", "organelleSuggestionLoadingIndicator", "organelleSuggestionLabel", "atpBalanceLabel", "pendingEndosymbiosisPopup", "endosymbiosisButton", "endosymbiosisPopup", "calculateBalancesAsIfDay", "calculateBalancesWhenMoving", "compoundBalance", "compoundStorageLastingTimes", "notEnoughStorageWarning", "processListButton", "processList", "growthOrderNumberContainer", "processListWindow", "micheViewer")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
Expand Down Expand Up @@ -421,6 +422,7 @@ processListButton = NodePath("RightPanel/VBoxContainer/Statistics/VBoxContainer/
processList = NodePath("ProcessPanel/ScrollContainer/ProcessList")
growthOrderNumberContainer = NodePath("GrowthOrderNumberContainer")
processListWindow = NodePath("ProcessPanel")
micheViewer = NodePath("PopupMicheViewer")
IslandErrorPath = NodePath("IslandError")
MutationPointsBarPath = NodePath("LeftPanel/MainPanel/VBoxContainer/MarginContainer2/MutationPointsBar")
ComponentBottomLeftButtonsPath = NodePath("EditorComponentBottomLeftButtons")
Expand Down Expand Up @@ -1500,12 +1502,20 @@ text = "AUTO-EVO_EXPLANATION_EXPLANATION"
label_settings = ExtResource("28_qclxk")
autowrap_mode = 3

[node name="MichesViewButton" type="Button" parent="PredictionExplanation/VBoxContainer/ScrollContainer/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 14
text = "VIEW_PATCH_MICHES"

[node name="Close" type="Button" parent="PredictionExplanation/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
theme_override_font_sizes/font_size = 14
text = "CLOSE"

[node name="PopupMicheViewer" parent="." instance=ExtResource("44_bxafd")]
layout_mode = 1

[connection signal="Clicked" from="." to="EditorComponentBottomLeftButtons" method="OnClickedOffName"]
[connection signal="gui_input" from="." to="." method="OnHexEditorGuiInput"]
[connection signal="mouse_entered" from="." to="." method="OnHexEditorMouseEntered"]
Expand Down Expand Up @@ -1548,6 +1558,7 @@ text = "CLOSE"
[connection signal="EndosymbiosisCancelled" from="EndosymbiosisPopup" to="." method="OnAbandonEndosymbiosisOperation"]
[connection signal="EndosymbiosisFinished" from="EndosymbiosisPopup" to="." method="OnEndosymbiosisFinished"]
[connection signal="SpeciesSelected" from="EndosymbiosisPopup" to="." method="OnEndosymbiosisSelected"]
[connection signal="pressed" from="PredictionExplanation/VBoxContainer/ScrollContainer/MarginContainer/VBoxContainer/MichesViewButton" to="." method="OnMicheViewRequested"]
[connection signal="pressed" from="PredictionExplanation/VBoxContainer/Close" to="." method="CloseAutoEvoPrediction"]

[editable path="CompleteEndosymbiosisWarning"]