Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 5 additions & 7 deletions src/gui/gui.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/***************************************************************************

Check notice on line 1 in src/gui/gui.cc

View check run for this annotation

CodeScene Delta Analysis / CodeScene Code Health Review (main)

✅ Getting better: Lines of Code in a Single File

The lines of code decreases from 2464 to 2463, improve code health by reducing it to 1000. The number of Lines of Code in a single file. More Lines of Code lowers the code health.
* Copyright (C) 2019 PCSX-Redux authors *
* *
* This program is free software; you can redistribute it and/or modify *
Expand Down Expand Up @@ -63,7 +63,6 @@
#include "core/sstate.h"
#include "core/web-server.h"
#include "flags.h"
#include "fmt/chrono.h"
#include "gui/gui.h"
#include "gui/luaimguiextra.h"
#include "gui/luanvg.h"
Expand Down Expand Up @@ -2413,16 +2412,17 @@
ImGui::EndDisabled();
ImGui::TextUnformatted(_("No version information.\n\nProbably built from source."));
} else {
auto timestamp = version.formatTimestamp("{:%Y-%m-%d %H:%M:%S}");
if (ImGui::Button(_("Copy to clipboard"))) {
if (version.buildId.has_value()) {
clip::set_text(
fmt::format("Version: {}\nBuild: {}\nChangeset: {}\nDate & time: {:%Y-%m-%d %H:%M:%S}",
fmt::format("Version: {}\nBuild: {}\nChangeset: {}\nDate & time: {}",
version.version, version.buildId.value(), version.changeset,
fmt::localtime(version.timestamp)));
timestamp));
} else {
clip::set_text(fmt::format("Version: {}\nChangeset: {}\nDate & time: {:%Y-%m-%d %H:%M:%S}",
clip::set_text(fmt::format("Version: {}\nChangeset: {}\nDate & time: {}",
version.version, version.changeset,
fmt::localtime(version.timestamp)));
timestamp));
}
}
ImGui::Text(_("Version: %s"), version.version.c_str());
Expand All @@ -2434,8 +2434,6 @@
if (ImGui::SmallButton(version.changeset.c_str())) {
openUrl(fmt::format("https://github.com/grumpycoders/pcsx-redux/commit/{}", version.changeset));
}
std::tm tm = fmt::localtime(version.timestamp);
std::string timestamp = fmt::format("{:%Y-%m-%d %H:%M:%S}", tm);
ImGui::Text(_("Date & time: %s"), timestamp.c_str());
}
ImGui::EndTabItem();
Expand Down
5 changes: 2 additions & 3 deletions src/main/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "core/sstate.h"
#include "core/ui.h"
#include "flags.h"
#include "fmt/chrono.h"
#include "gui/gui.h"
#include "lua/extra.h"
#include "lua/luawrapper.h"
Expand Down Expand Up @@ -217,8 +216,8 @@ int pcsxMain(int argc, char **argv) {
}
fmt::print(
"{{\n \"version\": \"{}\",\n \"changeset\": \"{}\",\n \"timestamp\": \"{}\",\n \"timestampDecoded\": "
"\"{:%Y-%m-%d %H:%M:%S}\"\n}}\n",
version.version, version.changeset, version.timestamp, fmt::localtime(version.timestamp));
"\"{}\"\n}}\n",
version.version, version.changeset, version.timestamp, version.formatTimestamp("{:%Y-%m-%d %H:%M:%S}"));
return 0;
}

Expand Down
9 changes: 9 additions & 0 deletions src/support/version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ SOFTWARE.
#include "support/version.h"

#include <algorithm>
#include <chrono>
#include <fmt/chrono.h>
#include <fmt/format.h>

#include "json.hpp"
#include "support/container-file.h"
Expand Down Expand Up @@ -65,6 +68,12 @@ void PCSX::VersionInfo::loadFromFile(IO<File> file) {
updateStorageUrl = getString("updateStorageUrl");
}

std::string PCSX::VersionInfo::formatTimestamp(const std::string& format) const {
auto timepoint = std::chrono::system_clock::from_time_t(timestamp);
auto local = std::chrono::current_zone()->to_local(timepoint);
return fmt::format(fmt::runtime(format), floor<std::chrono::seconds>(local));
}

bool PCSX::Update::downloadUpdateInfo(const VersionInfo& versionInfo, std::function<void(bool)> callback,
uv_loop_t* loop) {
if (versionInfo.failed() || !versionInfo.hasUpdateInfo()) return false;
Expand Down
1 change: 1 addition & 0 deletions src/support/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ struct VersionInfo {
}
return (updateMethod == "appcenter");
}
std::string formatTimestamp(const std::string& format) const;
void clear() {
version.clear();
buildId = std::nullopt;
Expand Down
Loading