From 552967246d5f582516a77fbd510d66b3e7553dc6 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 10 Apr 2022 23:01:55 -0500 Subject: [PATCH] **SUBMODULE UPDATE - PLEASE READ!** as of now I have added the Date library as a submodule in order to have log messages in the correct time zone please update your submodules by doing: ``` git submodule update --init --recursive ``` --- .gitmodules | 3 +++ CMakeLists.txt | 19 +++++++++++++++++++ extern/date | 1 + src/gui/gui.cpp | 3 ++- src/gui/gui.h | 3 +++ src/gui/log.cpp | 13 ++++++++++--- 6 files changed, 38 insertions(+), 4 deletions(-) create mode 160000 extern/date diff --git a/.gitmodules b/.gitmodules index d63fd70b5..e96848c30 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,3 +22,6 @@ [submodule "extern/Nuked-OPL3"] path = extern/Nuked-OPL3 url = https://github.com/nukeykt/Nuked-OPL3.git +[submodule "extern/date"] + path = extern/date + url = https://github.com/HowardHinnant/date diff --git a/CMakeLists.txt b/CMakeLists.txt index d3b98fc64..ae93abda6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ option(SYSTEM_LIBSNDFILE "Use a system-installed version of libsndfile instead o option(SYSTEM_RTMIDI "Use a system-installed version of RtMidi instead of the vendored one" OFF) option(SYSTEM_ZLIB "Use a system-installed version of zlib instead of the vendored one" OFF) option(SYSTEM_SDL2 "Use a system-installed version of SDL2 instead of the vendored one" ${SYSTEM_SDL2_DEFAULT}) +option(SYSTEM_DATE "Use a system-installed version of Date instead of the vendored one" OFF) option(WARNINGS_ARE_ERRORS "Whether warnings in furnace's C++ code should be treated as errors" OFF) set(DEPENDENCIES_INCLUDE_DIRS "") @@ -126,6 +127,24 @@ if (USE_RTMIDI) endif() endif() +if (SYSTEM_DATE) + find_package(PkgConfig REQUIRED) + pkg_check_modules(HHDATE REQUIRED date) + list(APPEND DEPENDENCIES_INCLUDE_DIRS ${HHDATE_INCLUDE_DIRS}) + list(APPEND DEPENDENCIES_COMPILE_OPTIONS ${HHDATE_CFLAGS_OTHER}) + list(APPEND DEPENDENCIES_LIBRARIES ${HHDATE_LIBRARIES}) + list(APPEND DEPENDENCIES_LIBRARY_DIRS ${HHDATE_LIBRARY_DIRS}) + list(APPEND DEPENDENCIES_LINK_OPTIONS ${HHDATE_LDFLAGS_OTHER}) + list(APPEND DEPENDENCIES_LEGACY_LDFLAGS ${HHDATE_LDFLAGS}) + message(STATUS "Using system-installed Date") +else() + set(BUILD_TZ_LIB ON CACHE BOOL "build/install of TZ library" FORCE) + add_subdirectory(extern/date EXCLUDE_FROM_ALL) + list(APPEND DEPENDENCIES_INCLUDE_DIRS extern/date/include) + list(APPEND DEPENDENCIES_LIBRARIES date date-tz) + message(STATUS "Using vendored Date") +endif() + if (SYSTEM_ZLIB) find_package(PkgConfig REQUIRED) pkg_check_modules(ZLIB REQUIRED zlib) diff --git a/extern/date b/extern/date new file mode 160000 index 000000000..9ea5654c1 --- /dev/null +++ b/extern/date @@ -0,0 +1 @@ +Subproject commit 9ea5654c1206e19245dc21d8a2c433e090c8c3f5 diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index ee69ae00a..4b3542b1e 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -3439,7 +3439,8 @@ FurnaceGUI::FurnaceGUI(): openSampleFilterOpt(false), oscTotal(0), oscZoom(0.5f), - oscZoomSlider(false) { + oscZoomSlider(false), + followLog(true) { // value keys valueKeys[SDLK_0]=0; valueKeys[SDLK_1]=1; diff --git a/src/gui/gui.h b/src/gui/gui.h index bcb7deee3..cadc84d48 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -1003,6 +1003,9 @@ class FurnaceGUI { // visualizer float keyHit[DIV_MAX_CHANS]; int lastIns[DIV_MAX_CHANS]; + + // log window + bool followLog; void drawSSGEnv(unsigned char type, const ImVec2& size); void drawWaveform(unsigned char type, bool opz, const ImVec2& size); diff --git a/src/gui/log.cpp b/src/gui/log.cpp index 2b83ab903..b6536cdb8 100644 --- a/src/gui/log.cpp +++ b/src/gui/log.cpp @@ -1,7 +1,7 @@ #include "gui.h" #include "../ta-log.h" #include -#include +#include "date/tz.h" const char* logLevels[5]={ "ERROR", @@ -27,8 +27,11 @@ void FurnaceGUI::drawLog() { } if (!logOpen) return; if (ImGui::Begin("Log Viewer",&logOpen)) { + ImGui::Checkbox("Follow",&followLog); + ImGui::SameLine(); ImGui::Text("Level"); ImGui::SameLine(); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); ImGui::Combo("##LogLevel",&logLevel,logLevels,5); if (ImGui::BeginTable("LogView",3,ImGuiTableFlags_ScrollY|ImGuiTableFlags_BordersInnerV)) { ImGui::PushFont(patFont); @@ -53,17 +56,21 @@ void FurnaceGUI::drawLog() { const LogEntry& logEntry=logEntries[(pos+i)&(TA_LOG_SIZE-1)]; if (!logEntry.ready) continue; if (logLevel(logEntry.time).time_since_epoch().count(); + String t=date::format("%T",date::make_zoned(date::current_zone(),date::floor(logEntry.time))); ImGui::TableNextRow(); ImGui::TableNextColumn(); // this will fail on 32-bit :< - ImGui::Text("%02ld:%02ld:%02ld",(t/3600)%24,(t/60)%60,t%60); + ImGui::TextUnformatted(t.c_str()); ImGui::TableNextColumn(); ImGui::TextColored(uiColors[logColors[logEntry.loglevel]],"%s",logLevels[logEntry.loglevel]); ImGui::TableNextColumn(); ImGui::TextWrapped("%s",logEntry.text.c_str()); } ImGui::PopFont(); + + if (followLog) { + ImGui::SetScrollY(ImGui::GetScrollMaxY()); + } ImGui::EndTable(); } }