Skip to content

Commit

Permalink
+ browser display bug fixed
Browse files Browse the repository at this point in the history
+ further tooltips
  • Loading branch information
chrxh committed Apr 15, 2023
1 parent 21f331f commit 9d96d83
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 17 deletions.
27 changes: 21 additions & 6 deletions source/Gui/BrowserWindow.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "BrowserWindow.h"

#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/regex.hpp>
#include <imgui.h>

#include "Fonts/IconsFontAwesome5.h"
Expand Down Expand Up @@ -264,9 +265,9 @@ void _BrowserWindow::processTable()
AlienImGui::Text(StringHelper::format(item->contentSize / 1024) + " KB");
ImGui::TableNextColumn();
AlienImGui::Text(item->version);
ImGui::PopID();

ImGui::PopStyleColor();
ImGui::PopID();
}
ImGui::EndTable();
}
Expand Down Expand Up @@ -302,7 +303,7 @@ void _BrowserWindow::processStatus()
void _BrowserWindow::processFilter()
{
ImGui::Spacing();
if (AlienImGui::ToggleButton(AlienImGui::ToggleButtonParameters().name("Show community simulations"), _showCommunitySimulations)) {
if (AlienImGui::ToggleButton(AlienImGui::ToggleButtonParameters().name("From community"), _showCommunitySimulations)) {
calcFilteredSimulationDatas();
}
ImGui::SameLine();
Expand All @@ -311,12 +312,26 @@ void _BrowserWindow::processFilter()
}
}

namespace
{
std::vector<std::string> splitString(const std::string& str)
{
std::vector<std::string> tokens;
boost::algorithm::split_regex(tokens, str, boost::regex("(\r\n)+"));
return tokens;
}
}

void _BrowserWindow::processShortenedText(std::string const& text) {
auto substrings = splitString(text);
if (substrings.empty()) {
return;
}
auto styleRepository = StyleRepository::getInstance();
auto textSize = ImGui::CalcTextSize(text.c_str());
auto needDetailButton = textSize.x > ImGui::GetContentRegionAvailWidth();
auto textSize = ImGui::CalcTextSize(substrings.at(0).c_str());
auto needDetailButton = textSize.x > ImGui::GetContentRegionAvailWidth() || substrings.size() > 1;
auto cursorPos = ImGui::GetCursorPosX() + ImGui::GetContentRegionAvailWidth() - styleRepository.contentScale(15.0f);
AlienImGui::Text(text);
AlienImGui::Text(substrings.at(0));
if (needDetailButton) {
ImGui::SameLine();
ImGui::SetCursorPosX(cursorPos);
Expand Down Expand Up @@ -462,7 +477,7 @@ void _BrowserWindow::calcFilteredSimulationDatas()
_filteredRemoteSimulationDatas.clear();
_filteredRemoteSimulationDatas.reserve(_remoteSimulationDatas.size());
for (auto const& simData : _remoteSimulationDatas) {
if (simData.matchWithFilter(_filter) && (_showCommunitySimulations || (!_showCommunitySimulations && simData.fromRelease)) && isVersionCompatible(simData)) {
if (simData.matchWithFilter(_filter) &&_showCommunitySimulations != simData.fromRelease/* && isVersionCompatible(simData)*/) {
_filteredRemoteSimulationDatas.emplace_back(simData);
}
}
Expand Down
33 changes: 22 additions & 11 deletions source/Gui/SimulationParametersWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,9 @@ void _SimulationParametersWindow::processBase(
.logarithmic(true)
.colorDependence(true)
.defaultValue(origSimParameters.baseValues.cellFunctionConstructorMutationPropertiesProbability)
.tooltip("This type of mutation changes a random property (e.g. (input) execution order number, required energy, block output or "
"function-specific properties such as minimum density for sensors, etc.). The spatial structure, color, cell function type and "
"self-replication capabilities are not changed."),
.tooltip("This type of mutation changes a random property (e.g. (input) execution order number, required energy, block output and "
"function-specific properties such as minimum density for sensors, neural net weights etc.). The spatial structure, color, cell "
"function type and self-replication capabilities are not changed."),
simParameters.baseValues.cellFunctionConstructorMutationPropertiesProbability);
AlienImGui::SliderFloat(
AlienImGui::SliderFloatParameters()
Expand All @@ -582,7 +582,8 @@ void _SimulationParametersWindow::processBase(
.format("%.6f")
.logarithmic(true)
.colorDependence(true)
.defaultValue(origSimParameters.baseValues.cellFunctionConstructorMutationStructureProbability),
.defaultValue(origSimParameters.baseValues.cellFunctionConstructorMutationStructureProbability)
.tooltip("This type of mutation only changes angles and required connections."),
simParameters.baseValues.cellFunctionConstructorMutationStructureProbability);
AlienImGui::SliderFloat(
AlienImGui::SliderFloatParameters()
Expand All @@ -593,7 +594,10 @@ void _SimulationParametersWindow::processBase(
.format("%.6f")
.logarithmic(true)
.colorDependence(true)
.defaultValue(origSimParameters.baseValues.cellFunctionConstructorMutationCellFunctionProbability),
.defaultValue(origSimParameters.baseValues.cellFunctionConstructorMutationCellFunctionProbability)
.tooltip("This type of mutation changes the type of cell function. The changed cell function will have random properties. If the "
"flag 'Preserve self-replication' is disabled it can also alter self-replication capabilities by changing a constructor to "
"something else or vice versa."),
simParameters.baseValues.cellFunctionConstructorMutationCellFunctionProbability);
AlienImGui::SliderFloat(
AlienImGui::SliderFloatParameters()
Expand All @@ -604,7 +608,8 @@ void _SimulationParametersWindow::processBase(
.format("%.6f")
.logarithmic(true)
.colorDependence(true)
.defaultValue(origSimParameters.baseValues.cellFunctionConstructorMutationInsertionProbability),
.defaultValue(origSimParameters.baseValues.cellFunctionConstructorMutationInsertionProbability)
.tooltip("This type of mutation inserts a new cell description to the genome at a random position."),
simParameters.baseValues.cellFunctionConstructorMutationInsertionProbability);
AlienImGui::SliderFloat(
AlienImGui::SliderFloatParameters()
Expand All @@ -615,7 +620,8 @@ void _SimulationParametersWindow::processBase(
.format("%.6f")
.logarithmic(true)
.colorDependence(true)
.defaultValue(origSimParameters.baseValues.cellFunctionConstructorMutationDeletionProbability),
.defaultValue(origSimParameters.baseValues.cellFunctionConstructorMutationDeletionProbability)
.tooltip("This type of mutation deletes a cell description from the genome at a random position."),
simParameters.baseValues.cellFunctionConstructorMutationDeletionProbability);
AlienImGui::SliderFloat(
AlienImGui::SliderFloatParameters()
Expand All @@ -626,7 +632,8 @@ void _SimulationParametersWindow::processBase(
.format("%.6f")
.logarithmic(true)
.colorDependence(true)
.defaultValue(origSimParameters.baseValues.cellFunctionConstructorMutationTranslationProbability),
.defaultValue(origSimParameters.baseValues.cellFunctionConstructorMutationTranslationProbability)
.tooltip("This type of mutation moves a block of cell descriptions from the genome at a random position to a new random position."),
simParameters.baseValues.cellFunctionConstructorMutationTranslationProbability);
AlienImGui::SliderFloat(
AlienImGui::SliderFloatParameters()
Expand All @@ -637,7 +644,8 @@ void _SimulationParametersWindow::processBase(
.format("%.6f")
.logarithmic(true)
.colorDependence(true)
.defaultValue(origSimParameters.baseValues.cellFunctionConstructorMutationDuplicationProbability),
.defaultValue(origSimParameters.baseValues.cellFunctionConstructorMutationDuplicationProbability)
.tooltip("This type of mutation copies a block of cell descriptions from the genome at a random position to a new random position."),
simParameters.baseValues.cellFunctionConstructorMutationDuplicationProbability);
AlienImGui::SliderFloat(
AlienImGui::SliderFloatParameters()
Expand All @@ -648,13 +656,16 @@ void _SimulationParametersWindow::processBase(
.format("%.6f")
.logarithmic(true)
.colorDependence(true)
.defaultValue(origSimParameters.baseValues.cellFunctionConstructorMutationColorProbability),
.defaultValue(origSimParameters.baseValues.cellFunctionConstructorMutationColorProbability)
.tooltip("This type of mutation alters the color of all cell descriptions in a genome or sub-genome by using the specified color transitions."),
simParameters.baseValues.cellFunctionConstructorMutationColorProbability);
AlienImGui::CheckboxColorMatrix(
AlienImGui::CheckboxColorMatrixParameters()
.name("Color transitions")
.textWidth(RightColumnWidth)
.defaultValue(toVector<MAX_COLORS, MAX_COLORS>(origSimParameters.cellFunctionConstructorMutationColorTransitions)),
.defaultValue(toVector<MAX_COLORS, MAX_COLORS>(origSimParameters.cellFunctionConstructorMutationColorTransitions))
.tooltip(
"The color transitions are used for color mutations. The row index indicates the source color and the column index the target color."),
simParameters.cellFunctionConstructorMutationColorTransitions);
auto preserveSelfReplication = !simParameters.cellFunctionConstructorMutationSelfReplication;
AlienImGui::Checkbox(
Expand Down

0 comments on commit 9d96d83

Please sign in to comment.