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

Disabled tolerance warnings in multicellular #5942

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
53 changes: 29 additions & 24 deletions src/microbe_stage/editor/CellEditorComponent.GUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -773,39 +773,44 @@ private void UpdateGUIAfterLoadingSpecies(Species species)

private void CalculateAndDisplayToleranceWarnings()
{
var tolerances = CalculateRawTolerances();

usedToleranceWarnings = 0;

void AddToleranceWarning(string text)
// Tolerances with the cell editor are not used in multicellular, rather the body plan editor will display
// the warnings (once they are done)
if (!IsMulticellularEditor)
{
if (usedToleranceWarnings < activeToleranceWarnings.Count)
{
var warning = activeToleranceWarnings[usedToleranceWarnings];
warning.Text = text;
}
else if (usedToleranceWarnings < MaxToleranceWarnings)
var tolerances = CalculateRawTolerances();

void AddToleranceWarning(string text)
{
var warning = new Label
if (usedToleranceWarnings < activeToleranceWarnings.Count)
{
var warning = activeToleranceWarnings[usedToleranceWarnings];
warning.Text = text;
}
else if (usedToleranceWarnings < MaxToleranceWarnings)
{
HorizontalAlignment = HorizontalAlignment.Center,
AutowrapMode = TextServer.AutowrapMode.WordSmart,
CustomMinimumSize = new Vector2(150, 0),
LabelSettings = toleranceWarningsFont,
};

warning.Text = text;
activeToleranceWarnings.Add(warning);
toleranceWarningContainer.AddChild(warning);
var warning = new Label
{
HorizontalAlignment = HorizontalAlignment.Center,
AutowrapMode = TextServer.AutowrapMode.WordSmart,
CustomMinimumSize = new Vector2(150, 0),
LabelSettings = toleranceWarningsFont,
};

warning.Text = text;
activeToleranceWarnings.Add(warning);
toleranceWarningContainer.AddChild(warning);
}

++usedToleranceWarnings;
}

++usedToleranceWarnings;
// This allocates a delegate, but it's probably not a significant amount of garbage
MicrobeEnvironmentalToleranceCalculations.GenerateToleranceProblemList(tolerances,
MicrobeEnvironmentalToleranceCalculations.ResolveToleranceValues(tolerances), AddToleranceWarning);
}

// This allocates a delegate, but it's probably not a significant amount of garbage
MicrobeEnvironmentalToleranceCalculations.GenerateToleranceProblemList(tolerances,
MicrobeEnvironmentalToleranceCalculations.ResolveToleranceValues(tolerances), AddToleranceWarning);

// Remove excess text that is no longer used
while (usedToleranceWarnings < activeToleranceWarnings.Count)
{
Expand Down
29 changes: 26 additions & 3 deletions src/microbe_stage/editor/CellEditorComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ public partial class CellEditorComponent :

private bool showGrowthOrderNumbers;

private bool multicellularTolerancesPrinted;

private TutorialState? tutorialState;

public enum SelectionMenuTab
Expand Down Expand Up @@ -1085,9 +1087,12 @@ public void OnCurrentPatchUpdated(Patch patch)
CalculateOrganelleEffectivenessInCurrentPatch();
UpdatePatchDependentBalanceData();

// Refresh tolerances data for the new patch
tolerancesEditor.OnPatchChanged();
OnTolerancesChanged(tolerancesEditor.CurrentTolerances);
if (!IsMulticellularEditor)
{
// Refresh tolerances data for the new patch
tolerancesEditor.OnPatchChanged();
OnTolerancesChanged(tolerancesEditor.CurrentTolerances);
}

// Redo suggestion calculations as they could depend on the patch data (though at the time of writing this is
// not really changing)
Expand Down Expand Up @@ -1923,6 +1928,24 @@ private void OnResourceLimitingModeChanged()

private ResolvedMicrobeTolerances CalculateLatestTolerances()
{
if (IsMulticellularEditor)
{
if (!multicellularTolerancesPrinted)
{
GD.Print("TODO: implement tolerances data coming from the multicellular editor");
multicellularTolerancesPrinted = true;
}

// TODO: this should use info from the cell body plan editor regarding tolerances and remove this dummy
// return
return new ResolvedMicrobeTolerances
{
HealthModifier = 1,
OsmoregulationModifier = 1,
ProcessSpeedModifier = 1,
};
}

return MicrobeEnvironmentalToleranceCalculations.ResolveToleranceValues(CalculateRawTolerances());
}

Expand Down