Skip to content
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
28 changes: 15 additions & 13 deletions external/ImFileDialog/ImFileDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <imgui.h>
#include <imgui_internal.h>

#include "../../source/Gui/TranslationService.h"

#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"

Expand Down Expand Up @@ -1097,7 +1099,7 @@ namespace ifd {
if (m_zoom == 1.0f) {
if (ImGui::BeginTable("##contentTable", 3, /*ImGuiTableFlags_Resizable |*/ ImGuiTableFlags_Sortable, ImVec2(0, -FLT_MIN))) {
// header
ImGui::TableSetupColumn("Name##filename", ImGuiTableColumnFlags_WidthStretch, 0.0f -1.0f, 0);
ImGui::TableSetupColumn((std::string(_("Name")) + "##filename").c_str(), ImGuiTableColumnFlags_WidthStretch, 0.0f -1.0f, 0);
ImGui::TableSetupColumn("Date modified##filedate", ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoResize, 0.0f, 1);
ImGui::TableSetupColumn("Size##filesize", ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoResize, 0.0f, 2);
ImGui::TableSetupScrollFreeze(0, 1);
Expand Down Expand Up @@ -1215,7 +1217,7 @@ namespace ifd {
if (openAreYouSureDlg)
ImGui::OpenPopup("Are you sure?##delete");
if (openNewFileDlg)
ImGui::OpenPopup("Enter file name##newfile");
ImGui::OpenPopup((std::string(_("Enter file name")) + "##newfile").c_str());
if (openNewDirectoryDlg)
ImGui::OpenPopup("Enter directory name##newdir");
if (ImGui::BeginPopupModal("Are you sure?##delete")) {
Expand All @@ -1236,7 +1238,7 @@ namespace ifd {
}
ImGui::EndPopup();
}
if (ImGui::BeginPopupModal("Enter file name##newfile")) {
if (ImGui::BeginPopupModal((std::string(_("Enter file name")) + "##newfile").c_str())) {
ImGui::PushItemWidth(250.0f);
ImGui::InputText("##newfilename", m_newEntryBuffer, 1024); // TODO: remove hardcoded literals
ImGui::PopItemWidth();
Expand All @@ -1252,26 +1254,26 @@ namespace ifd {
ImGui::CloseCurrentPopup();
}
ImGui::SameLine();
if (ImGui::Button("Cancel")) {
if (ImGui::Button(_("Cancel"))) {
m_newEntryBuffer[0] = 0;
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
if (ImGui::BeginPopupModal("Enter directory name##newdir")) {
if (ImGui::BeginPopupModal((std::string(_("Enter directory name")) + "##newdir").c_str())) {
ImGui::PushItemWidth(250.0f);
ImGui::InputText("##newfilename", m_newEntryBuffer, 1024); // TODO: remove hardcoded literals
ImGui::InputText("##newfilename", m_newEntryBuffer, 1024);
ImGui::PopItemWidth();

if (ImGui::Button("OK")) {
if (ImGui::Button(_("OK"))) {
std::error_code ec;
std::filesystem::create_directory(m_currentDirectory / std::string(m_newEntryBuffer), ec);
m_setDirectory(m_currentDirectory, false); // refresh
m_newEntryBuffer[0] = 0;
ImGui::CloseCurrentPopup();
}
ImGui::SameLine();
if (ImGui::Button("Cancel")) {
if (ImGui::Button(_("Cancel"))) {
ImGui::CloseCurrentPopup();
m_newEntryBuffer[0] = 0;
}
Expand Down Expand Up @@ -1325,7 +1327,7 @@ namespace ifd {
ImGui::SameLine();
ImGui::PopStyleColor();

if (ImGui::InputTextEx("##searchTB", "Search", m_searchBuffer, 128, ImVec2(-FLT_MIN, GUI_ELEMENT_SIZE), 0)) // TODO: no hardcoded literals
if (ImGui::InputTextEx("##searchTB", _("Search"), m_searchBuffer, 128, ImVec2(-FLT_MIN, GUI_ELEMENT_SIZE), 0)) // TODO: no hardcoded literals
m_setDirectory(m_currentDirectory, false); // refresh


Expand Down Expand Up @@ -1367,9 +1369,9 @@ namespace ifd {

/***** BOTTOM BAR *****/
if (m_type != IFD_DIALOG_DIRECTORY) {
ImGui::Text("File name:");
ImGui::Text("%s", _("File name:"));
ImGui::SameLine();
if (ImGui::InputTextEx("##file_input", "Filename", reinterpret_cast<char*>(m_inputTextbox), 1024, ImVec2((m_type != IFD_DIALOG_DIRECTORY) ? -250.0f : -FLT_MIN, 0), ImGuiInputTextFlags_EnterReturnsTrue)) {
if (ImGui::InputTextEx("##file_input", _("Filename"), reinterpret_cast<char*>(m_inputTextbox), 1024, ImVec2((m_type != IFD_DIALOG_DIRECTORY) ? -250.0f : -FLT_MIN, 0), ImGuiInputTextFlags_EnterReturnsTrue)) {
bool success = m_finalize(std::u8string(m_inputTextbox));
#ifdef _WIN32
if (!success)
Expand All @@ -1385,7 +1387,7 @@ namespace ifd {
// buttons

ImGui::SetCursorPosX(ImGui::GetWindowWidth() - 250);
if (ImGui::Button(m_type == IFD_DIALOG_SAVE ? "Save" : "Open", ImVec2(250 / 2 - ImGui::GetStyle().ItemSpacing.x, 0.0f))) {
if (ImGui::Button(m_type == IFD_DIALOG_SAVE ? _("Save") : _("Open"), ImVec2(250 / 2 - ImGui::GetStyle().ItemSpacing.x, 0.0f))) {
std::u8string filename(m_inputTextbox);
bool success = false;
if (!filename.empty() || m_type == IFD_DIALOG_DIRECTORY)
Expand All @@ -1396,7 +1398,7 @@ namespace ifd {
#endif
}
ImGui::SameLine();
if (ImGui::Button("Cancel", ImVec2(-FLT_MIN, 0.0f)))
if (ImGui::Button(_("Cancel"), ImVec2(-FLT_MIN, 0.0f)))
m_finalize();
}
}
Expand Down
2 changes: 1 addition & 1 deletion external/vcpkg
Submodule vcpkg updated 6078 files
6 changes: 3 additions & 3 deletions source/Gui/AboutDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
#include "StyleRepository.h"

AboutDialog::AboutDialog()
: AlienDialog("About")
: AlienDialog(_("About"))
{}

void AboutDialog::processIntern()
{
ImGui::Text(
"Artificial Life Environment, version %s\n\nis an open source project initiated and maintained by\nChristian Heinemann.",
_("Artificial Life Environment, version %s\n\nis an open source project initiated and maintained by\nChristian Heinemann."),
Const::ProgramVersion.c_str());

ImGui::Dummy({0, ImGui::GetContentRegionAvail().y - scale(50.0f)});
AlienGui::Separator();

if (AlienGui::Button("OK")) {
if (AlienGui::Button(_("OK"))) {
close();
}
ImGui::SetItemDefaultFocus();
Expand Down
22 changes: 11 additions & 11 deletions source/Gui/ActivateUserDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ void ActivateUserDialog::open(std::string const& userName, std::string const& pa
}

ActivateUserDialog::ActivateUserDialog()
: AlienDialog("Activate user")
: AlienDialog(_("Activate user"))
{}

void ActivateUserDialog::processIntern()
{
AlienGui::Text("Please enter the confirmation code sent to your email address.");
AlienGui::Text(_("Please enter the confirmation code sent to your email address."));
AlienGui::HelpMarker(
"Please check your spam folder if you did not find an email. If you did not receive an email there, try signing up with possibly another "
"email address. If this still does not work, please contact info@alien-project.org.");
_("Please check your spam folder if you did not find an email. If you did not receive an email there, try signing up with possibly another "
"email address. If this still does not work, please contact info@alien-project.org."));
AlienGui::Separator();
AlienGui::InputText(AlienGui::InputTextParameters().hint("Code (case sensitive)").textWidth(0), _confirmationCode);
AlienGui::InputText(AlienGui::InputTextParameters().hint(_("Code (case sensitive)")).textWidth(0), _confirmationCode);

AlienGui::Separator();

ImGui::BeginDisabled(_confirmationCode.empty());
if (AlienGui::Button("OK")) {
if (AlienGui::Button(_("OK"))) {
close();
onActivateUser();
}
Expand All @@ -52,12 +52,12 @@ void ActivateUserDialog::processIntern()
AlienGui::VerticalSeparator();

ImGui::SameLine();
if (AlienGui::Button("Resend")) {
if (AlienGui::Button(_("Resend"))) {
CreateUserDialog::get().onCreateUser();
}

ImGui::SameLine();
if (AlienGui::Button("Resend to other email address")) {
if (AlienGui::Button(_("Resend to other email address"))) {
close();
CreateUserDialog::get().open(_userName, _password, _userInfo);
}
Expand All @@ -66,7 +66,7 @@ void ActivateUserDialog::processIntern()
AlienGui::VerticalSeparator();

ImGui::SameLine();
if (AlienGui::Button("Cancel")) {
if (AlienGui::Button(_("Cancel"))) {
close();
}
}
Expand All @@ -79,10 +79,10 @@ void ActivateUserDialog::onActivateUser()
result |= NetworkService::get().login(errorCode, _userName, _password, _userInfo);
}
if (!result) {
GenericMessageDialog::get().information("Error", "An error occurred on the server. Your entered code may be incorrect.\nPlease try to register again.");
GenericMessageDialog::get().information(_("Error"), _("An error occurred on the server. Your entered code may be incorrect.\nPlease try to register again."));
} else {
GenericMessageDialog::get().information(
"Information",
_("Information"),
"The user '" + _userName
+ "' has been successfully created.\nYou are logged in and are now able to upload your own simulations\nor upvote others by likes.");
BrowserWindow::get().onRefresh();
Expand Down
56 changes: 28 additions & 28 deletions source/Gui/AutosaveWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace
}

AutosaveWindow::AutosaveWindow()
: AlienWindow("Autosave", "windows.autosave", false, true)
: AlienWindow(_("Autosave"), "windows.autosave", false, true)
{}

void AutosaveWindow::initIntern()
Expand Down Expand Up @@ -95,7 +95,7 @@ void AutosaveWindow::processIntern()

validateAndCorrect();
} catch (std::runtime_error const& error) {
GenericMessageDialog::get().information("Error", error.what());
GenericMessageDialog::get().information(_("Error"), error.what());
}
}

Expand All @@ -116,22 +116,22 @@ void AutosaveWindow::processToolbar()
onCreateSavepoint(false);
}
ImGui::EndDisabled();
AlienGui::Tooltip("Create save point");
AlienGui::Tooltip(_("Create save point"));

ImGui::SameLine();
ImGui::BeginDisabled(!static_cast<bool>(_selectedEntry));
if (AlienGui::ToolbarButton(AlienGui::ToolbarButtonParameters().text(ICON_FA_MINUS))) {
onDeleteSavepoint(_selectedEntry);
}
AlienGui::Tooltip("Delete save point");
AlienGui::Tooltip(_("Delete save point"));
ImGui::EndDisabled();

ImGui::SameLine();
ImGui::BeginDisabled(!_savepointTable.has_value() || _savepointTable->isEmpty());
if (AlienGui::ToolbarButton(AlienGui::ToolbarButtonParameters().text(ICON_FA_BROOM))) {
GenericMessageDialog::get().yesNo("Delete", "Do you really want to delete all savepoints?", [&]() { scheduleCleanup(); });
GenericMessageDialog::get().yesNo(_("Delete"), _("Do you really want to delete all savepoints?"), [&]() { scheduleCleanup(); });
}
AlienGui::Tooltip("Delete all save points");
AlienGui::Tooltip(_("Delete all save points"));
ImGui::EndDisabled();

AlienGui::Separator();
Expand All @@ -142,16 +142,16 @@ void AutosaveWindow::processHeader() {}
void AutosaveWindow::processTable()
{
if (!_savepointTable.has_value()) {
AlienGui::Text("Error: Savepoint files could not be read or created in the specified directory.");
AlienGui::Text(_("Error: Savepoint files could not be read or created in the specified directory."));
return;
}
static ImGuiTableFlags flags = ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_RowBg
| ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ScrollY | ImGuiTableFlags_ScrollX;

if (ImGui::BeginTable("Save files", 3, flags, ImVec2(-1, -1), 0.0f)) {
ImGui::TableSetupColumn("Simulation", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed, scale(140.0f));
ImGui::TableSetupColumn("Timestamp", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed, scale(140.0f));
ImGui::TableSetupColumn("Time step", ImGuiTableColumnFlags_DefaultSort | ImGuiTableColumnFlags_WidthFixed, scale(100.0f));
ImGui::TableSetupColumn(_("Simulation"), ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed, scale(140.0f));
ImGui::TableSetupColumn(_("Timestamp"), ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed, scale(140.0f));
ImGui::TableSetupColumn(_("Time step"), ImGuiTableColumnFlags_DefaultSort | ImGuiTableColumnFlags_WidthFixed, scale(100.0f));
//ImGui::TableSetupColumn("Peak value", ImGuiTableColumnFlags_DefaultSort | ImGuiTableColumnFlags_WidthFixed, scale(200.0f));
ImGui::TableSetupScrollFreeze(0, 1);
ImGui::TableHeadersRow();
Expand All @@ -170,23 +170,23 @@ void AutosaveWindow::processTable()
ImGui::TableNextColumn();
if (entry->state == SavepointState_InQueue) {
ImGui::PushStyleColor(ImGuiCol_Text, Const::TextDecentColor.Value);
AlienGui::Text("In queue");
AlienGui::Text(_("In queue"));
ImGui::PopStyleColor();
} else if (entry->state == SavepointState_InProgress) {
ImGui::PushStyleColor(ImGuiCol_Text, Const::TextDecentColor.Value);
AlienGui::Text("In progress");
AlienGui::Text(_("In progress"));
ImGui::PopStyleColor();
} else if (entry->state == SavepointState_Persisted) {
auto triggerLoadSavepoint = AlienGui::ActionButton(AlienGui::ActionButtonParameters().buttonText(ICON_FA_DOWNLOAD));
AlienGui::Tooltip("Load save point", false);
AlienGui::Tooltip(_("Load save point"), false);
if (triggerLoadSavepoint) {
onLoadSavepoint(entry);
}

ImGui::SameLine();
AlienGui::Text(entry->name);
} else if (entry->state == SavepointState_Error) {
AlienGui::Text("Error");
AlienGui::Text(_("Error"));
}
ImGui::SameLine();
ImGui::Dummy({0, scale(22.0f)});
Expand Down Expand Up @@ -237,11 +237,11 @@ void AutosaveWindow::processSettings()
AlienGui::MovableHorizontalSeparator(AlienGui::MovableHorizontalSeparatorParameters().additive(false), _settingsHeight);
}

_settingsOpen = AlienGui::BeginTreeNode(AlienGui::TreeNodeParameters().name("Settings").rank(AlienGui::TreeNodeRank::High).defaultOpen(_settingsOpen));
_settingsOpen = AlienGui::BeginTreeNode(AlienGui::TreeNodeParameters().name(_("Settings")).rank(AlienGui::TreeNodeRank::High).defaultOpen(_settingsOpen));
if (_settingsOpen) {
if (ImGui::BeginChild("##autosaveSettings", {scale(0), 0})) {
if (AlienGui::InputInt(
AlienGui::InputIntParameters().name("Autosave interval (min)").textWidth(RightColumnWidth).defaultValue(_origAutosaveInterval),
AlienGui::InputIntParameters().name(_("Autosave interval (min)")).textWidth(RightColumnWidth).defaultValue(_origAutosaveInterval),
_autosaveInterval,
&_autosaveEnabled)) {
if (_autosaveEnabled) {
Expand All @@ -266,25 +266,25 @@ void AutosaveWindow::processSettings()

if (AlienGui::InputText(
AlienGui::InputTextParameters()
.name("Directory")
.name(_("Directory"))
.textWidth(RightColumnWidth)
.defaultValue(_origDirectory)
.folderButton(true)
.tooltip("The directory where the savepoints are stored can be chosen here. This allows the savepoints to be created in a separate "
"directory for a simulation run. The savepoints are named using the current time step."),
.tooltip(_("The directory where the savepoints are stored can be chosen here. This allows the savepoints to be created in a separate "
"directory for a simulation run. The savepoints are named using the current time step.")),
_directory)) {
updateSavepointTableFromFile();
}
AlienGui::Switcher(
AlienGui::SwitcherParameters()
.name("Mode")
.values({"Limited save files", "Unlimited save files"})
.name(_("Mode"))
.values({_("Limited save files"), _("Unlimited save files")})
.textWidth(RightColumnWidth)
.defaultValue(_origSaveMode),
&_saveMode);
if (_saveMode == SaveMode_Circular) {
AlienGui::InputInt(
AlienGui::InputIntParameters().name("Number of files").textWidth(RightColumnWidth).defaultValue(_origNumberOfFiles), _numberOfFiles);
AlienGui::InputIntParameters().name(_("Number of files")).textWidth(RightColumnWidth).defaultValue(_origNumberOfFiles), _numberOfFiles);
}
}
ImGui::EndChild();
Expand All @@ -296,9 +296,9 @@ void AutosaveWindow::processStatusBar()
{
std::vector<std::string> statusItems;
if (!_savepointTable.has_value()) {
statusItems.emplace_back("No valid directory");
statusItems.emplace_back(_("No valid directory"));
} else if (!_autosaveEnabled) {
statusItems.emplace_back("No autosave scheduled");
statusItems.emplace_back(_("No autosave scheduled"));
} else {
auto secondsSinceLastAutosave = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - _lastAutosaveTimepoint);
statusItems.emplace_back("Next autosave in " + StringHelper::format(std::chrono::seconds(_autosaveInterval * 60) - secondsSinceLastAutosave));
Expand All @@ -312,7 +312,7 @@ void AutosaveWindow::processStatusBar()

void AutosaveWindow::onCreateSavepoint(bool usePeakSimulation)
{
printOverlayMessage("Creating save point ...");
printOverlayMessage(_("Creating save point ..."));

if (_saveMode == SaveMode_Circular) {
auto nonPersistentEntries = SavepointTableService::get().truncate(_savepointTable.value(), _numberOfFiles - 1);
Expand Down Expand Up @@ -342,7 +342,7 @@ void AutosaveWindow::onCreateSavepoint(bool usePeakSimulation)

void AutosaveWindow::onDeleteSavepoint(SavepointEntry const& entry)
{
printOverlayMessage("Deleting save point ...");
printOverlayMessage(_("Deleting save point ..."));

SavepointTableService::get().deleteEntry(_savepointTable.value(), entry);

Expand Down Expand Up @@ -370,7 +370,7 @@ void AutosaveWindow::processStateUpdates()
void AutosaveWindow::processCleanup()
{
if (_scheduleCleanup) {
printOverlayMessage("Cleaning up save points ...");
printOverlayMessage(_("Cleaning up save points ..."));

auto nonPersistentEntries = SavepointTableService::get().truncate(_savepointTable.value(), 0);
scheduleDeleteNonPersistentSavepoint(nonPersistentEntries);
Expand Down Expand Up @@ -410,7 +410,7 @@ void AutosaveWindow::processAutomaticSavepoints()
.center = Viewport::get().getCenterInWorldPos()});
},
[&](auto const& requestId) {},
[](auto const& errors) { GenericMessageDialog::get().information("Error", errors); });
[](auto const& errors) { GenericMessageDialog::get().information(_("Error"), errors); });
_lastPeakTimepoint = std::chrono::steady_clock::now();
}
}
Expand Down
Loading