Skip to content

Commit

Permalink
made show performance an option
Browse files Browse the repository at this point in the history
- it was not available in release mode
  • Loading branch information
ypujante committed Aug 14, 2023
1 parent 35b997f commit 2517a9f
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/cpp/re/edit/AppContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ void AppContext::render()

ImGui::PopID(); // Rendering

// Clipboard
ImGui::SeparatorText("Clipboard");
if(ReGui::ResetButton())
{
Expand All @@ -401,11 +402,13 @@ void AppContext::render()
ImGui::SameLine();
ImGui::TextUnformatted(fClipboard.getData()->getDescription().c_str());

#ifndef NDEBUG
ImGui::Separator();
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate,
ImGui::GetIO().Framerate);
#endif
// Performance
if(Application::GetCurrent().isShowPerformance())
{
ImGui::SeparatorText("Performance");
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate,
ImGui::GetIO().Framerate);
}
}

fCurrentPanelState->render(*this);
Expand Down
1 change: 1 addition & 0 deletions src/cpp/re/edit/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,7 @@ void Application::renderApplicationMenuItems()
{
fContext->setVSyncEnabled(fConfig.fVSyncEnabled);
}
ImGui::MenuItem("Show Performance", nullptr, &fConfig.fShowPerformance);
ImGui::EndMenu();
}
if(ImGui::MenuItem("Check For Updates...", nullptr, false, !hasAsyncAction(kCheckForUpdatesKey)))
Expand Down
1 change: 1 addition & 0 deletions src/cpp/re/edit/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class Application

constexpr int getTargetFrameRate() const { return fConfig.fTargetFrameRate; }
constexpr bool isVSyncEnabled() const { return fConfig.fVSyncEnabled; }
constexpr bool isShowPerformance() const { return fConfig.fShowPerformance; }

void onNativeWindowFontDpiScaleChange(float iFontDpiScale);
void onNativeWindowFontScaleChange(float iFontScale);
Expand Down
1 change: 1 addition & 0 deletions src/cpp/re/edit/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ struct Global
bool fSaveEnabled{true};
int fTargetFrameRate{60};
bool fVSyncEnabled{false};
bool fShowPerformance{false};

std::vector<Device> fDeviceHistory{};

Expand Down
1 change: 1 addition & 0 deletions src/cpp/re/edit/PreferencesManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ std::string PreferencesManager::getAsLua(config::Global const &iConfig)
s << fmt::printf("global_config[\"style\"] = \"%s\"\n", config::to_string(iConfig.fStyle));
s << fmt::printf("global_config[\"target_frame_rate\"] = %d\n", iConfig.fTargetFrameRate);
s << fmt::printf("global_config[\"vsync_enabled\"] = %s\n", fmt::Bool::to_chars(iConfig.fVSyncEnabled));
s << fmt::printf("global_config[\"show_performance\"] = %s\n", fmt::Bool::to_chars(iConfig.fShowPerformance));

auto const &history = iConfig.fDeviceHistory;
if(!history.empty())
Expand Down
1 change: 1 addition & 0 deletions src/cpp/re/edit/lua/ConfigParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ config::Global GlobalConfigParser::getConfig()
withOptionalValue(L.getTableValueAsOptionalNumber("font_size"), [&c](auto v) { c.fFontSize = v; });
withOptionalValue(L.getTableValueAsOptionalInteger("target_frame_rate"), [&c](auto v) { c.fTargetFrameRate = v; });
withOptionalValue(L.getTableValueAsOptionalBoolean("vsync_enabled"), [&c](auto v) { c.fVSyncEnabled = v; });
withOptionalValue(L.getTableValueAsOptionalBoolean("show_performance"), [&c](auto v) { c.fShowPerformance = v; });
withOptionalValue(L.getTableValueAsOptionalString("style"), [&c](auto v) {
v = Utils::str_tolower(v);
if(v == "light")
Expand Down
1 change: 1 addition & 0 deletions test/cpp/re/edit/lua/TestConfigParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ global_config["font_size"] = 20
global_config["style"] = "Dark"
global_config["target_frame_rate"] = 60
global_config["vsync_enabled"] = false
global_config["show_performance"] = false
global_config["device_history"] = {}
global_config["device_history"][1] = {
name = "CVA-7 CV Analyzer",
Expand Down

0 comments on commit 2517a9f

Please sign in to comment.