16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 01:59:19 +02:00

Conversion to cpp 20

This commit is contained in:
2026-01-18 21:21:15 +01:00
parent ecf5934209
commit 11e79f52ae
10 changed files with 1014 additions and 908 deletions

View File

@@ -7,10 +7,9 @@
#include <sys/stat.h>
#endif
trainingcard_panel::trainingcard_panel()
: ui_panel("Raport szkolenia", false)
trainingcard_panel::trainingcard_panel() : ui_panel("Raport szkolenia", false)
{
//size = {400, 500};
// size = {400, 500};
clear();
}
@@ -58,21 +57,25 @@ void trainingcard_panel::save_thread_func()
std::fstream input("report_template.html", std::ios_base::in | std::ios_base::binary);
std::string in_line;
while (std::getline(input, in_line)) {
while (std::getline(input, in_line))
{
const std::string magic("{{CONTENT}}");
if (in_line.compare(0, magic.size(), magic) == 0) {
if (in_line.compare(0, magic.size(), magic) == 0)
{
temp << "<div><b>Miejsce: </b>" << (std::string(place.c_str())) << "</div><br />" << std::endl;
temp << "<div><b>Data: </b>" << (date) << "</div><br />" << std::endl;
temp << "<div><b>Czas: </b>" << (from) << " - " << (to) << "</div><br />" << std::endl;
temp << "<div><b>Imię (imiona) i nazwisko szkolonego: </b>" << (trainee_name) << "</div><br />" << std::endl;
temp << "<div><b>Data urodzenia: </b>" << (trainee_birthdate) << "</div><br />" << std::endl;
temp << "<div><b>Firma: </b>" << (trainee_company) << "</div><br />" << std::endl;
temp << "<div><b>Imię i nazwisko instruktora: </b>" << (instructor_name) << "</div><br />" << std::endl;
temp << "<div><b>Odcinek trasy: </b>" << (track_segment) << "</div><br />" << std::endl;
temp << "<div><b>Imię i nazwisko instruktora: </b>" << (instructor_name) << "</div><br />" << std::endl;
temp << "<div><b>Odcinek trasy: </b>" << (track_segment) << "</div><br />" << std::endl;
if (distance > 0.0f)
temp << "<div><b>Przebyta odległość: </b>" << std::round(distance) << " km</div><br />" << std::endl;
temp << "<div><b>Uwagi: </b><br />" << (remarks) << "</div>" << std::endl;
} else {
temp << "<div><b>Przebyta odległość: </b>" << std::round(distance) << " km</div><br />" << std::endl;
temp << "<div><b>Uwagi: </b><br />" << (remarks) << "</div>" << std::endl;
}
else
{
temp << in_line;
}
}
@@ -85,37 +88,42 @@ void trainingcard_panel::save_thread_func()
void trainingcard_panel::render_contents()
{
if (ImGui::BeginPopupModal("Zapisywanie danych")) {
if (ImGui::BeginPopupModal("Zapisywanie danych"))
{
ImGui::SetWindowSize(ImVec2(-1, -1));
int s = state.load();
if (s == 1) {
if (s == 1)
{
ImGui::CloseCurrentPopup();
clear();
}
if (s < 1) {
if (s < 1)
{
if (s == 0)
ImGui::TextUnformatted("Error occured please contact with administrator!");
if (s == -1)
ImGui::TextUnformatted("The recording of the training has not been archived, please do not start the next training before manually archiving the file!");
if (ImGui::Button("OK")) {
if (ImGui::Button("OK"))
{
ImGui::CloseCurrentPopup();
clear();
}
}
if (s == 2)
ImGui::TextUnformatted(u8"Proszę czekać, trwa archiwizacja nagrania...");
ImGui::TextUnformatted("Proszę czekać, trwa archiwizacja nagrania...");
ImGui::EndPopup();
}
if (start_time_wall) {
if (start_time_wall)
{
std::tm *tm = std::localtime(&(*start_time_wall));
std::string rep = u8"Czas rozpoczęcia: " + std::to_string(tm->tm_year + 1900) + "-" + std::to_string(tm->tm_mon + 1) + "-" + std::to_string(tm->tm_mday)
+ " " + std::to_string(tm->tm_hour) + ":" + std::to_string(tm->tm_min);
std::string rep = "Czas rozpoczęcia: " + std::to_string(tm->tm_year + 1900) + "-" + std::to_string(tm->tm_mon + 1) + "-" + std::to_string(tm->tm_mday) + " " + std::to_string(tm->tm_hour) +
":" + std::to_string(tm->tm_min);
ImGui::TextUnformatted(rep.c_str());
}
@@ -146,22 +154,27 @@ void trainingcard_panel::render_contents()
ImGui::TextUnformatted("Uwagi");
ImGui::InputTextMultiline("##remarks", &remarks[0], remarks.size(), ImVec2(-1.0f, 200.0f));
if (!start_time_wall) {
if (ImGui::Button("Rozpocznij szkolenie")) {
if (!start_time_wall)
{
if (ImGui::Button("Rozpocznij szkolenie"))
{
start_time_wall = std::time(nullptr);
std::tm *tm = std::localtime(&(*start_time_wall));
recording_timestamp = std::to_string(tm->tm_year + 1900) + std::to_string(tm->tm_mon + 1) + std::to_string(tm->tm_mday)
+ std::to_string(tm->tm_hour) + std::to_string(tm->tm_min) + "_" + std::string(trainee_name.c_str()) + "_" + std::string(instructor_name.c_str());
recording_timestamp = std::to_string(tm->tm_year + 1900) + std::to_string(tm->tm_mon + 1) + std::to_string(tm->tm_mday) + std::to_string(tm->tm_hour) + std::to_string(tm->tm_min) + "_" +
std::string(trainee_name.c_str()) + "_" + std::string(instructor_name.c_str());
int ret = StartRecording();
if (ret != 1) {
if (ret != 1)
{
state.store(ret);
ImGui::OpenPopup("Zapisywanie danych");
}
}
}
else {
if (ImGui::Button(u8"Zakończ szkolenie")) {
else
{
if (ImGui::Button("Zakończ szkolenie"))
{
state.store(2);
if (simulation::Trains.sequence().size() > 0)
distance = simulation::Trains.sequence()[0]->Dynamic()->MoverParameters->DistCounter;