Skip to content
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
1 change: 1 addition & 0 deletions resources/docs/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Autosave protects long runs. It saves the current simulation at regular interval
- **Interval (min)** sets the time between two autosaves, 40 minutes by default. The interval counts minutes of real time, so autosaves are also created while the simulation is paused.
- **Subfolder** names the folder inside **Folder** in which new autosaves are stored, for example one subfolder for each simulation run. A slash or a backslash creates nested subfolders. The autosaves that already exist stay where they are.
- **Mode** is *Limited save files* by default. In this mode, **Number of files** limits how many autosaves are kept in a folder, 20 by default. Each new autosave deletes the oldest ones of its folder beyond this number. In *Unlimited save files* mode, all autosaves are kept.
- **Autosave now** next to **Activate autosave** creates an autosave right away, whether autosave is on or off.
- The file name of an autosave is *save_* followed by its time step. Autosaves that lie in the folder of **My simulations** are also listed there like any other simulation. In **Autosaves**, select an autosave to open or delete it in the right column. To keep an autosave for good, open it and save it with **Save** (Ctrl+S) under a name of its own.
- **Earlier versions.** At the first start of this version, the folder in which the Autosave window of an earlier version has created save points becomes the folder of the simulations of this computer. These save points appear in **Autosaves** and in **My simulations**. They count as autosaves, so in *Limited save files* mode the oldest ones of the current subfolder are deleted as well. Save points that an earlier version has stored directly in the *resources* folder are loaded with **Open simulation** in the tool bar of the browser.

Expand Down
2 changes: 1 addition & 1 deletion resources/docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ See [Energy](energy.md#troubleshooting-energy) and [Evolution experiments](evolu
## I lost my simulation

- If **Settings > Save on exit** is enabled, which is the default, ALIEN saves the simulation when you close the program normally and opens it again at the next start. After a crash there is no such save, so ALIEN opens the simulation of the last normal exit instead.
- **Autosaves** in the left column of the browser shows the autosaves. Autosaves exist only if you switched on automatic saving with **Activate autosave** above the autosaves. Automatic saving is off after every start of ALIEN and after a simulation has been created or opened. Save points of earlier versions appear there as well if their folder lies in the folder of the simulations of this computer.
- **Autosaves** in the left column of the browser shows the autosaves. Autosaves exist only if you created them with **Autosave now** or switched on automatic saving with **Activate autosave** above the autosaves. Automatic saving is off after every start of ALIEN and after a simulation has been created or opened. Save points of earlier versions appear there as well if their folder lies in the folder of the simulations of this computer.
- The flashback of the **Temporal control** window exists only in memory and is lost when ALIEN is closed.

## The documentation is missing
Expand Down
32 changes: 25 additions & 7 deletions source/Gui/Impl/BrowserFolderBarWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ namespace
return AlienGui::ActionButtonParameters().buttonText("Deactivate autosave").smallIcon(ICON_FA_STOP).transparentBackground(false);
}

AlienGui::ActionButtonParameters getAutosaveNowButton()
{
auto const& folderName = LocalLibraryController::get().getAutosaveFolderName();
auto place = folderName.empty() ? std::string("directly in the folder") : "in the subfolder " + folderName;
return AlienGui::ActionButtonParameters()
.buttonText("Autosave now")
.smallIcon(ICON_FA_PLUS)
.transparentBackground(false)
.tooltip("Save the simulation right now as an autosave " + place + ".");
}

// Digits are measured as zeros, so a countdown does not change what fits into the row
float calcStableTextWidth(std::string text)
{
Expand Down Expand Up @@ -150,25 +161,32 @@ void _BrowserFolderBarWidget::processAutosave()
auto& controller = LocalLibraryController::get();
auto availableWidth = ImGui::GetContentRegionAvail().x;

if (!controller.isAutosaveEnabled()) {
if (AlienGui::ActionButton(getActivateButton())) {
auto isEnabled = controller.isAutosaveEnabled();
auto switchButton = isEnabled ? getDeactivateButton() : getActivateButton();
if (AlienGui::ActionButton(switchButton)) {
if (isEnabled) {
controller.setAutosaveEnabled(false);
} else {
AutosaveDialog::get().open();
}
}
ImGui::SameLine();
if (AlienGui::ActionButton(getAutosaveNowButton())) {
controller.onAutosave();
}
if (!isEnabled) {
ImGui::SameLine();
ImGui::PushStyleColor(ImGuiCol_Text, Const::TextDimColor.Value);
AlienGui::Text("Autosave is off");
ImGui::PopStyleColor();
return;
}

if (AlienGui::ActionButton(getDeactivateButton())) {
controller.setAutosaveEnabled(false);
}

// The interval is left out where the row is too narrow for it
auto frameHeight = ImGui::GetFrameHeight();
auto markerRadius = scale(AutosaveMarkerRadius);
auto infoOffset = AlienGui::CalcActionButtonWidth(getDeactivateButton()) + ImGui::GetStyle().ItemSpacing.x * 2 + markerRadius * 2;
auto buttonsWidth = AlienGui::CalcActionButtonWidth(switchButton) + AlienGui::CalcActionButtonWidth(getAutosaveNowButton());
auto infoOffset = buttonsWidth + ImGui::GetStyle().ItemSpacing.x * 3 + markerRadius * 2;
auto longestDuration = std::chrono::minutes(controller.getAutosaveInterval());
auto showInterval = infoOffset + calcStableTextWidth(getAutosaveInfo(longestDuration, true)) <= availableWidth;

Expand Down
2 changes: 1 addition & 1 deletion source/Gui/Impl/LocalLibraryController.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class LocalLibraryController : public MainLoopEntity
// Without a description, the description of a replaced simulation is kept
void onSave(std::string const& name, std::optional<std::string> const& description, std::string const& jpg);
void onSaveToFile(std::filesystem::path const& filename); // A file at any place
void onAutosave();
void onLoad(std::filesystem::path const& simulationPath);

// These functions return an error message if they fail. Editing, renaming and deleting take simulations and genomes.
Expand Down Expand Up @@ -115,7 +116,6 @@ class LocalLibraryController : public MainLoopEntity
void processPendingLoads();
void processPendingPicture();
void processAutosave();
void onAutosave();

void scheduleSave(PendingSave pendingSave);
void onSaveFinished(PendingSave const& pendingSave, SaveSimulationResultData const& data);
Expand Down