[Scummvm-git-logs] scummvm master -> effbdfe67f739e08ed91db64f423ddc2a4a11114
mgerhardy
noreply at scummvm.org
Fri Oct 11 07:14:23 UTC 2024
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
2a3d39edf7 TWINE: renamed function to better match the original name
610384ed36 DIRECTORY: prepare to split the imgui logger from directory engine
a3adb2933c BACKENDS: moved imgui_logger code from directory engine into backends code
effbdfe67f TWINE: added ImGuiLogger support to the twine debugger
Commit: 2a3d39edf7013f66db18a96d47c82415b622022a
https://github.com/scummvm/scummvm/commit/2a3d39edf7013f66db18a96d47c82415b622022a
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-10-11T08:39:00+02:00
Commit Message:
TWINE: renamed function to better match the original name
Changed paths:
engines/twine/holomap_v1.cpp
engines/twine/menu/menu.cpp
engines/twine/renderer/screens.cpp
engines/twine/scene/gamestate.cpp
engines/twine/twine.cpp
engines/twine/twine.h
diff --git a/engines/twine/holomap_v1.cpp b/engines/twine/holomap_v1.cpp
index 2dcd8dedaec..4463185f13b 100644
--- a/engines/twine/holomap_v1.cpp
+++ b/engines/twine/holomap_v1.cpp
@@ -188,7 +188,7 @@ void HolomapV1::computeCoorMapping() {
int projectedIndex = 0;
for (int32 alpha = -LBAAngles::ANGLE_90; alpha <= LBAAngles::ANGLE_90; alpha += LBAAngles::ANGLE_11_25) {
for (int32 beta = 0; beta < LBAAngles::ANGLE_360; beta += LBAAngles::ANGLE_11_25) {
- _projectedSurfacePositions[projectedIndex].x2 = lerp(0, 255 * LBAAngles::ANGLE_90 + 255, LBAAngles::ANGLE_360 - 1, beta);
+ _projectedSurfacePositions[projectedIndex].x2 = ruleThree32(0, 255 * LBAAngles::ANGLE_90 + 255, LBAAngles::ANGLE_360 - 1, beta);
if (alpha == LBAAngles::ANGLE_90) {
_projectedSurfacePositions[projectedIndex].y2 = 255 * LBAAngles::ANGLE_90 + 255;
} else {
diff --git a/engines/twine/menu/menu.cpp b/engines/twine/menu/menu.cpp
index f9c984323a2..36aff35f050 100644
--- a/engines/twine/menu/menu.cpp
+++ b/engines/twine/menu/menu.cpp
@@ -298,22 +298,22 @@ void Menu::drawButtonGfx(const MenuSettings *menuSettings, const Common::Rect &r
switch (buttonId) {
case MenuButtonTypes::kMusicVolume: {
const int volume = _engine->_system->getMixer()->getVolumeForSoundType(Audio::Mixer::kMusicSoundType);
- newWidth = lerp(rect.left, rect.right, Audio::Mixer::kMaxMixerVolume, volume);
+ newWidth = ruleThree32(rect.left, rect.right, Audio::Mixer::kMaxMixerVolume, volume);
break;
}
case MenuButtonTypes::kSoundVolume: {
const int volume = _engine->_system->getMixer()->getVolumeForSoundType(Audio::Mixer::kSFXSoundType);
- newWidth = lerp(rect.left, rect.right, Audio::Mixer::kMaxMixerVolume, volume);
+ newWidth = ruleThree32(rect.left, rect.right, Audio::Mixer::kMaxMixerVolume, volume);
break;
}
case MenuButtonTypes::kCDVolume: {
const AudioCDManager::Status status = _engine->_system->getAudioCDManager()->getStatus();
- newWidth = lerp(rect.left, rect.right, Audio::Mixer::kMaxMixerVolume, status.volume);
+ newWidth = ruleThree32(rect.left, rect.right, Audio::Mixer::kMaxMixerVolume, status.volume);
break;
}
case MenuButtonTypes::kSpeechVolume: {
const int volume = _engine->_system->getMixer()->getVolumeForSoundType(Audio::Mixer::kSpeechSoundType);
- newWidth = lerp(rect.left, rect.right, Audio::Mixer::kMaxMixerVolume, volume);
+ newWidth = ruleThree32(rect.left, rect.right, Audio::Mixer::kMaxMixerVolume, volume);
break;
}
}
@@ -1006,7 +1006,7 @@ int32 Menu::quitMenu() {
void Menu::drawHealthBar(int32 left, int32 right, int32 top, int32 barLeftPadding, int32 barHeight) {
_engine->_grid->drawSprite(left, top + 3, _engine->_resources->_spriteData[SPRITEHQR_LIFEPOINTS]);
const int32 barLeft = left + barLeftPadding;
- const int32 healthBarRight = lerp(barLeft, right, 50, _engine->_scene->_sceneHero->_lifePoint);
+ const int32 healthBarRight = ruleThree32(barLeft, right, 50, _engine->_scene->_sceneHero->_lifePoint);
const int32 barBottom = top + barHeight;
_engine->_interface->box(Common::Rect(barLeft, top, healthBarRight, barBottom), COLOR_91);
_engine->_interface->box(Common::Rect(healthBarRight, top, left + 325, barBottom), COLOR_BLACK);
@@ -1016,13 +1016,13 @@ void Menu::drawHealthBar(int32 left, int32 right, int32 top, int32 barLeftPaddin
void Menu::drawCloverLeafs(int32 newBoxLeft, int32 boxRight, int32 top) {
// Clover leaf boxes
for (int32 i = 0; i < _engine->_gameState->_inventoryNumLeafsBox; i++) {
- const int32 leftSpritePos = lerp(newBoxLeft, boxRight, 10, i);
+ const int32 leftSpritePos = ruleThree32(newBoxLeft, boxRight, 10, i);
_engine->_grid->drawSprite(leftSpritePos, top + 58, _engine->_resources->_spriteData[SPRITEHQR_CLOVERLEAFBOX]);
}
// Clover leafs
for (int32 i = 0; i < _engine->_gameState->_inventoryNumLeafs; i++) {
- const int32 leftSpritePos = lerp(newBoxLeft, boxRight, 10, i);
+ const int32 leftSpritePos = ruleThree32(newBoxLeft, boxRight, 10, i);
_engine->_grid->drawSprite(leftSpritePos + 2, top + 60, _engine->_resources->_spriteData[SPRITEHQR_CLOVERLEAF]);
}
}
@@ -1042,16 +1042,16 @@ void Menu::drawMagicPointsBar(int32 left, int32 right, int32 top, int32 barLeftP
const int32 barBottom = top + barHeight;
// max magic level is 4
const int32 maxMagicPoints = 4 * 20;
- const int32 barRight = lerp(barLeft, right, maxMagicPoints, _engine->_gameState->_magicPoint);
+ const int32 barRight = ruleThree32(barLeft, right, maxMagicPoints, _engine->_gameState->_magicPoint);
const Common::Rect pointsRect(barLeft, top, barRight, barBottom);
_engine->_interface->box(pointsRect, COLOR_75);
for (int32 l = 0; l < _engine->_gameState->_magicLevelIdx; l++) {
- const int32 x1 = lerp(barLeft, right, 40, _engine->_gameState->_magicLevelIdx * 10);
+ const int32 x1 = ruleThree32(barLeft, right, 40, _engine->_gameState->_magicLevelIdx * 10);
_engine->_interface->drawLine(x1, top + barHeight, x1, top + 35 + 15 - 1, 0);
}
- const int32 rectRight = lerp(barLeft, right, 40, _engine->_gameState->_magicLevelIdx * 10);
+ const int32 rectRight = ruleThree32(barLeft, right, 40, _engine->_gameState->_magicLevelIdx * 10);
drawRectBorders(barLeft, top, rectRight, barBottom);
}
diff --git a/engines/twine/renderer/screens.cpp b/engines/twine/renderer/screens.cpp
index 22eb0b5be8f..1da3a56efcd 100644
--- a/engines/twine/renderer/screens.cpp
+++ b/engines/twine/renderer/screens.cpp
@@ -177,9 +177,9 @@ void Screens::fadePal(uint8 r, uint8 g, uint8 b, const Graphics::Palette &rgbaPa
for (int32 i = 0; i < NUMOFCOLORS; i++) {
byte rIn, gIn, bIn;
rgbaPal.get(i, rIn, gIn, bIn);
- const byte newR = lerp(r, rIn, 100, intensity);
- const byte newG = lerp(g, gIn, 100, intensity);
- const byte newB = lerp(b, bIn, 100, intensity);
+ const byte newR = ruleThree32(r, rIn, 100, intensity);
+ const byte newG = ruleThree32(g, gIn, 100, intensity);
+ const byte newB = ruleThree32(b, bIn, 100, intensity);
pal.set(i, newR, newG, newB);
}
@@ -252,9 +252,9 @@ void Screens::fadePalToPal(const Graphics::Palette &ptrpal, const Graphics::Pale
byte r2, g2, b2;
ptrpal2.get(i, r2, g2, b2);
- byte newR = lerp(r1, r2, 100, m);
- byte newG = lerp(g1, g2, 100, m);
- byte newB = lerp(b1, b2, 100, m);
+ byte newR = ruleThree32(r1, r2, 100, m);
+ byte newG = ruleThree32(g1, g2, 100, m);
+ byte newB = ruleThree32(b1, b2, 100, m);
workpal.set(i, newR, newG, newB);
}
diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index 7f00c78f654..477db2f6ea4 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -539,7 +539,7 @@ void GameState::processGameoverAnimation() {
}
zoom = boundRuleThree(40000, 3200, _engine->toSeconds(10), _engine->timerRef - startLbaTime);
- const int32 angle = lerp(1, LBAAngles::ANGLE_360, _engine->toSeconds(2), (_engine->timerRef - startLbaTime) % _engine->toSeconds(2));
+ const int32 angle = ruleThree32(1, LBAAngles::ANGLE_360, _engine->toSeconds(2), (_engine->timerRef - startLbaTime) % _engine->toSeconds(2));
_engine->blitWorkToFront(rect);
_engine->_renderer->setFollowCamera(0, 0, 0, 0, -angle, 0, zoom);
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index adf3a91e05e..41d5dceea1d 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -156,7 +156,7 @@ int32 boundRuleThree(int32 val1, int32 val2, int32 nbstep, int32 step) { // Boun
return val1 + (((val2 - val1) * step) / nbstep);
}
-int32 lerp(int32 val1, int32 val2, int32 nbstep, int32 step) { // RegleTrois32
+int32 ruleThree32(int32 val1, int32 val2, int32 nbstep, int32 step) { // RegleTrois32
if (nbstep < 0) {
return val2;
}
diff --git a/engines/twine/twine.h b/engines/twine/twine.h
index 4a91ef94860..0c46e51332b 100644
--- a/engines/twine/twine.h
+++ b/engines/twine/twine.h
@@ -210,7 +210,7 @@ int32 boundRuleThree(int32 val1, int32 val2, int32 nbstep, int32 step);
* @return the lerped value
* @note Doesn't clamp
*/
-int32 lerp(int32 value, int32 start, int32 end, int32 t);
+int32 ruleThree32(int32 value, int32 start, int32 end, int32 t);
class TwinEEngine : public Engine {
private:
Commit: 610384ed36ffa2b1700e6fd1663a01392d7a7477
https://github.com/scummvm/scummvm/commit/610384ed36ffa2b1700e6fd1663a01392d7a7477
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-10-11T09:01:11+02:00
Commit Message:
DIRECTORY: prepare to split the imgui logger from directory engine
other engines could use the same code, too and thus we will move this into the backend module
Changed paths:
A engines/director/debugger/dt-logger.h
backends/imgui/imgui_utils.cpp
backends/imgui/imgui_utils.h
engines/director/debugger/debugtools.cpp
engines/director/debugger/dt-cast.cpp
engines/director/debugger/dt-internal.h
engines/director/debugger/dt-logger.cpp
engines/director/debugger/dt-scripts.cpp
diff --git a/backends/imgui/imgui_utils.cpp b/backends/imgui/imgui_utils.cpp
index 5de529b5829..8e2082bdb77 100644
--- a/backends/imgui/imgui_utils.cpp
+++ b/backends/imgui/imgui_utils.cpp
@@ -66,4 +66,19 @@ void Palette(const Graphics::Palette &palette) {
drawList->Flags = backupFlags;
}
+bool toggleButton(const char *label, bool *p_value, bool inverse) {
+ int pop = 0;
+ if (*p_value != inverse) {
+ ImVec4 hovered = ImGui::GetStyle().Colors[ImGuiCol_ButtonHovered];
+ ImGui::PushStyleColor(ImGuiCol_Button, hovered);
+ pop = 1;
+ }
+ bool result = ImGui::Button(label);
+ if (result) {
+ *p_value = !*p_value;
+ }
+ ImGui::PopStyleColor(pop);
+ return result;
+}
+
} // namespace ImGuiEx
diff --git a/backends/imgui/imgui_utils.h b/backends/imgui/imgui_utils.h
index 417449fce53..ca9f8431280 100644
--- a/backends/imgui/imgui_utils.h
+++ b/backends/imgui/imgui_utils.h
@@ -21,6 +21,10 @@
#include "backends/imgui/IconsMaterialSymbols.h"
+#ifndef IMGUI_DEFINE_MATH_OPERATORS
+#define IMGUI_DEFINE_MATH_OPERATORS
+#endif
+
#include "backends/imgui/imgui.h"
#include "graphics/palette.h"
@@ -38,5 +42,6 @@ bool InputInt(const char *label, INT *v, int step = 1, int step_fast = 100, ImGu
void Boolean(bool val);
void Palette(const Graphics::Palette &palette);
+bool toggleButton(const char *label, bool *p_value, bool inverse = false);
} // namespace ImGuiEx
diff --git a/engines/director/debugger/debugtools.cpp b/engines/director/debugger/debugtools.cpp
index e60048f29bb..8ed3605890b 100644
--- a/engines/director/debugger/debugtools.cpp
+++ b/engines/director/debugger/debugtools.cpp
@@ -39,21 +39,6 @@ namespace DT {
ImGuiState *_state = nullptr;
-bool toggleButton(const char *label, bool *p_value, bool inverse) {
- int pop = 0;
- if (*p_value != inverse) {
- ImVec4 hovered = ImGui::GetStyle().Colors[ImGuiCol_ButtonHovered];
- ImGui::PushStyleColor(ImGuiCol_Button, hovered);
- pop = 1;
- }
- bool result = ImGui::Button(label);
- if (result) {
- *p_value = !*p_value;
- }
- ImGui::PopStyleColor(pop);
- return result;
-}
-
const LingoDec::Handler *getHandler(const Cast *cast, CastMemberID id, const Common::String &handlerId) {
if (!cast)
return nullptr;
@@ -283,15 +268,7 @@ static void showSettings() {
ImGui::ColorEdit4("Variable", &_state->_colors._var_ref.x);
ImGui::ColorEdit4("Variable changed", &_state->_colors._var_ref_changed.x);
- ImGui::SeparatorText("Logger");
- ImGui::ColorEdit4("Error", &_state->_colors._logger_error.x);
- ImGui::ColorEdit4("Error Button", &_state->_colors._logger_error_b.x);
- ImGui::ColorEdit4("Warning", &_state->_colors._logger_warning.x);
- ImGui::ColorEdit4("Warning Button", &_state->_colors._logger_warning_b.x);
- ImGui::ColorEdit4("Info", &_state->_colors._logger_info.x);
- ImGui::ColorEdit4("Info Button", &_state->_colors._logger_info_b.x);
- ImGui::ColorEdit4("Debug", &_state->_colors._logger_debug.x);
- ImGui::ColorEdit4("Debug Button", &_state->_colors._logger_debug_b.x);
+ _state->_logger->drawColorOptions();
}
ImGui::End();
}
diff --git a/engines/director/debugger/dt-cast.cpp b/engines/director/debugger/dt-cast.cpp
index 5ebb4616c59..f7990439321 100644
--- a/engines/director/debugger/dt-cast.cpp
+++ b/engines/director/debugger/dt-cast.cpp
@@ -20,6 +20,7 @@
*/
#include "backends/imgui/IconsMaterialSymbols.h"
+#include "backends/imgui/imgui_utils.h"
#include "director/director.h"
#include "director/debugger/dt-internal.h"
@@ -114,10 +115,10 @@ void showCast() {
if (ImGui::Begin("Cast", &_state->_w.cast)) {
// display a toolbar with: grid/list/filters buttons + name filter
- toggleButton(ICON_MS_LIST, &_state->_cast._listView);
+ ImGuiEx::toggleButton(ICON_MS_LIST, &_state->_cast._listView);
ImGui::SetItemTooltip("List");
ImGui::SameLine();
- toggleButton(ICON_MS_GRID_VIEW, &_state->_cast._listView, true);
+ ImGuiEx::toggleButton(ICON_MS_GRID_VIEW, &_state->_cast._listView, true);
ImGui::SetItemTooltip("Grid");
ImGui::SameLine();
diff --git a/engines/director/debugger/dt-internal.h b/engines/director/debugger/dt-internal.h
index f02fb3b4257..29448f42c5b 100644
--- a/engines/director/debugger/dt-internal.h
+++ b/engines/director/debugger/dt-internal.h
@@ -22,7 +22,9 @@
#ifndef DIRECTOR_DEBUGER_DT_INTERNAL_H
#define DIRECTOR_DEBUGER_DT_INTERNAL_H
+#ifndef IMGUI_DEFINE_MATH_OPERATORS
#define IMGUI_DEFINE_MATH_OPERATORS
+#endif
#include "graphics/surface.h"
@@ -30,6 +32,7 @@
#include "backends/imgui/imgui_fonts.h"
#include "director/debugger/imgui_memory_editor.h"
+#include "director/debugger/dt-logger.h"
#include "director/types.h"
#include "director/lingo/lingo.h"
@@ -137,16 +140,6 @@ typedef struct ImGuiState {
ImVec4 _script_ref = ImColor(IM_COL32(0x7f, 0x7f, 0xff, 0xfff));
ImVec4 _var_ref = ImColor(IM_COL32(0xe6, 0xe6, 0x00, 0xff));
ImVec4 _var_ref_changed = ImColor(IM_COL32(0xFF, 0x00, 0x00, 0xFF));
-
- ImVec4 _logger_error_b = ImVec4(1.f, 0.f, 0.f, 1.f);
- ImVec4 _logger_warning_b = ImVec4(1.f, 1.f, 0.f, 1.f);
- ImVec4 _logger_info_b = ImVec4(1.f, 1.f, 1.f, 1.f);
- ImVec4 _logger_debug_b = ImVec4(0.8f, 0.8f, 0.8f, 1.f);
-
- ImVec4 _logger_error = ImVec4(1.0f, 0.4f, 0.4f, 1.0f);
- ImVec4 _logger_warning = ImVec4(1.0f, 1.0f, 0.4f, 1.0f);
- ImVec4 _logger_info = ImVec4(1.0f, 0.8f, 0.6f, 1.0f);
- ImVec4 _logger_debug = ImVec4(0.8f, 0.8f, 0.8f, 1.0f);
} _colors;
struct {
@@ -190,30 +183,7 @@ typedef struct ImGuiState {
ImGuiLogger *_logger = nullptr;
} ImGuiState;
-// dt-logger.cpp
-class ImGuiLogger {
- char _inputBuf[256];
- ImVector<char *> _items;
- ImVector<char *> _history;
- int _historyPos; // -1: new line, 0.._history.Size-1 browsing history.
- ImGuiTextFilter _filter;
- bool _autoScroll;
- bool _scrollToBottom;
- bool _showError = true;
- bool _showWarn = true;
- bool _showInfo = true;
- bool _showdebug = true;
-
-public:
- ImGuiLogger();
- ~ImGuiLogger();
- void clear();
- void addLog(const char *fmt, ...) IM_FMTARGS(2);
- void draw(const char *title, bool *p_open);
-};
-
// debugtools.cpp
-bool toggleButton(const char *label, bool *p_value, bool inverse = false);
ImGuiScript toImGuiScript(ScriptType scriptType, CastMemberID id, const Common::String &handlerId);
void setScriptToDisplay(const ImGuiScript &script);
Director::Breakpoint *getBreakpoint(const Common::String &handlerName, uint16 scriptId, uint pc);
diff --git a/engines/director/debugger/dt-logger.cpp b/engines/director/debugger/dt-logger.cpp
index 6d575d02fcb..004dd9b7d19 100644
--- a/engines/director/debugger/dt-logger.cpp
+++ b/engines/director/debugger/dt-logger.cpp
@@ -20,222 +20,234 @@
*/
#include "backends/imgui/IconsMaterialSymbols.h"
-#include "common/debug.h"
+#include "backends/imgui/imgui_utils.h"
#include "common/debug-channels.h"
+#include "common/debug.h"
-#include "director/director.h"
-#include "director/debugger/dt-internal.h"
+#include "director/debugger/dt-logger.h"
namespace Director {
namespace DT {
ImGuiLogger::ImGuiLogger() {
- clear();
- memset(_inputBuf, 0, sizeof(_inputBuf));
- _historyPos = -1;
- _autoScroll = true;
- _scrollToBottom = false;
+ clear();
+ memset(_inputBuf, 0, sizeof(_inputBuf));
+ _historyPos = -1;
+ _autoScroll = true;
+ _scrollToBottom = false;
}
ImGuiLogger::~ImGuiLogger() {
- clear();
- for (int i = 0; i < _history.Size; i++)
- free(_history[i]);
+ clear();
+ for (int i = 0; i < _history.Size; i++)
+ free(_history[i]);
}
void ImGuiLogger::clear() {
- for (int i = 0; i < _items.Size; i++)
- free(_items[i]);
- _items.clear();
+ for (int i = 0; i < _items.Size; i++)
+ free(_items[i]);
+ _items.clear();
}
void ImGuiLogger::addLog(const char *fmt, ...) {
- // FIXME-OPT
- char buf[1024];
- va_list args;
- va_start(args, fmt);
- vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args);
- buf[IM_ARRAYSIZE(buf) - 1] = 0;
- va_end(args);
- _items.push_back(scumm_strdup(buf));
+ // FIXME-OPT
+ char buf[1024];
+ va_list args;
+ va_start(args, fmt);
+ vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args);
+ buf[IM_ARRAYSIZE(buf) - 1] = 0;
+ va_end(args);
+ _items.push_back(scumm_strdup(buf));
}
void ImGuiLogger::draw(const char *title, bool *p_open) {
- if (!*p_open)
- return;
-
- ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
- if (!ImGui::Begin(title, p_open)) {
- ImGui::End();
- return;
- }
-
- // As a specific feature guaranteed by the library, after calling Begin() the last Item represent the title bar. So e.g. IsItemHovered() will return true when hovering the title bar.
- // Here we create a context menu only available from the title bar.
- if (ImGui::BeginPopupContextItem()) {
- if (ImGui::MenuItem("Close ImGuiLogger"))
- *p_open = false;
- ImGui::EndPopup();
- }
-
- // Clear
- if (ImGui::Button(ICON_MS_CLEAR_ALL)) {
- clear();
- }
- ImGui::SetItemTooltip("Clear");
- ImGui::SameLine();
-
- // Copy
- bool copy_to_clipboard = ImGui::Button(ICON_MS_CONTENT_COPY);
- ImGui::SetItemTooltip("Copy to clipboard");
- ImGui::SameLine();
-
- // debug channels
- int numChannels = 0;
- auto channels = DebugMan.getDebugChannels();
- for (auto &channel : channels) {
- if (channel.name == "imgui")
- continue;
- bool enabled = DebugMan.isDebugChannelEnabled(channel.channel);
- if (enabled)
- numChannels++;
- }
-
- Common::String selChannels(Common::String::format("(%d channel%s)", numChannels, numChannels > 1 ? "s" : ""));
- ImGui::PushItemWidth(120);
- if (ImGui::BeginCombo("##Channels", selChannels.c_str())) {
- for (auto &channel : channels) {
- if (channel.name == "imgui")
- continue;
- bool enabled = DebugMan.isDebugChannelEnabled(channel.channel);
- if (ImGui::Checkbox(channel.name.c_str(), &enabled)) {
- if (enabled) {
- DebugMan.enableDebugChannel(channel.channel);
- } else {
- DebugMan.disableDebugChannel(channel.channel);
- }
- }
- ImGui::SetItemTooltip("%s", channel.description.c_str());
- }
- ImGui::EndCombo();
- }
- ImGui::SameLine();
-
- // Options menu
- if (ImGui::BeginPopup("Options")) {
- if (ImGui::InputInt("Debug Level", &gDebugLevel)) {
- if (gDebugLevel < 0)
- gDebugLevel = 0;
- }
- ImGui::Separator();
- ImGui::Checkbox("Auto-scroll", &_autoScroll);
- ImGui::EndPopup();
- }
-
- // Options, Filter
- if (ImGui::Button(ICON_MS_SETTINGS))
- ImGui::OpenPopup("Options");
- ImGui::SetItemTooltip("Options");
- ImGui::SameLine();
-
- ImGui::Spacing();
- ImGui::SameLine();
-
- // Error
- ImGui::PushStyleColor(ImGuiCol_Text, _state->_colors._logger_error_b);
- toggleButton("\ue160", &_showError);
- ImGui::PopStyleColor();
- ImGui::SetItemTooltip("Show Errors");
- ImGui::SameLine();
-
- // Warning
- ImGui::PushStyleColor(ImGuiCol_Text, _state->_colors._logger_warning_b);
- toggleButton("\ue002", &_showWarn);
- ImGui::PopStyleColor();
- ImGui::SetItemTooltip("Show Warnings");
- ImGui::SameLine();
-
- // Info
- ImGui::PushStyleColor(ImGuiCol_Text, _state->_colors._logger_info_b);
- toggleButton(ICON_MS_INFO, &_showInfo);
- ImGui::PopStyleColor();
- ImGui::SetItemTooltip("Show Info");
- ImGui::SameLine();
-
- // Debug
- ImGui::PushStyleColor(ImGuiCol_Text, _state->_colors._logger_debug_b);
- toggleButton(ICON_MS_BUG_REPORT, &_showdebug);
- ImGui::PopStyleColor();
- ImGui::SetItemTooltip("Show Debug");
- ImGui::SameLine();
-
- _filter.Draw("Filter (\"incl,-excl\") (\"warn\")", 180);
- ImGui::Separator();
-
- ImGui::BeginChild("ScrollingRegion", ImVec2(), false, ImGuiWindowFlags_HorizontalScrollbar);
- if (ImGui::BeginPopupContextWindow()) {
- if (ImGui::Selectable(ICON_MS_CLEAR_ALL " Clear"))
- clear();
- if (ImGui::Selectable(ICON_MS_CONTENT_COPY " Copy"))
- copy_to_clipboard = true;
- ImGui::EndPopup();
- }
-
- ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4, 1)); // Tighten spacing
- if (copy_to_clipboard)
- ImGui::LogToClipboard();
- for (int i = 0; i < _items.Size; i++) {
- const char *item = _items[i];
- bool isError = strstr(item, "[error]");
- if (!_showError && isError)
- continue;
-
- bool isWarn = strstr(item, "[warn]");
- if (!_showWarn && isWarn)
- continue;
-
- bool isDebug = strstr(item, "[debug]");
- if (!_showdebug && isDebug)
- continue;
-
- if (!_showInfo && !isError && !isWarn && !isDebug)
- continue;
-
- if (!_filter.PassFilter(item))
- continue;
-
- // Normally you would store more information in your item (e.g. make _items[] an array of structure, store color/type etc.)
- bool pop_color = false;
- if (isError) {
- item += 7;
- ImGui::PushStyleColor(ImGuiCol_Text, _state->_colors._logger_error);
- pop_color = true;
- } else if (isWarn) {
- item += 6;
- ImGui::PushStyleColor(ImGuiCol_Text, _state->_colors._logger_warning);
- pop_color = true;
- } else if (isDebug) {
- item += 7;
- ImGui::PushStyleColor(ImGuiCol_Text, _state->_colors._logger_debug);
- pop_color = true;
- } else if (strncmp(item, "> ", 2) == 0) {
- ImGui::PushStyleColor(ImGuiCol_Text, _state->_colors._logger_info);
- pop_color = true;
- }
- ImGui::TextUnformatted(item);
- if (pop_color)
- ImGui::PopStyleColor();
- }
- if (copy_to_clipboard)
- ImGui::LogFinish();
-
- if (_scrollToBottom || (_autoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY()))
- ImGui::SetScrollHereY(1.0f);
- _scrollToBottom = false;
-
- ImGui::PopStyleVar();
- ImGui::EndChild();
- ImGui::End();
+ if (!*p_open)
+ return;
+
+ ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
+ if (!ImGui::Begin(title, p_open)) {
+ ImGui::End();
+ return;
+ }
+
+ // As a specific feature guaranteed by the library, after calling Begin() the last Item represent the title bar. So e.g. IsItemHovered() will return true when hovering the title bar.
+ // Here we create a context menu only available from the title bar.
+ if (ImGui::BeginPopupContextItem()) {
+ if (ImGui::MenuItem("Close ImGuiLogger"))
+ *p_open = false;
+ ImGui::EndPopup();
+ }
+
+ // Clear
+ if (ImGui::Button(ICON_MS_CLEAR_ALL)) {
+ clear();
+ }
+ ImGui::SetItemTooltip("Clear");
+ ImGui::SameLine();
+
+ // Copy
+ bool copy_to_clipboard = ImGui::Button(ICON_MS_CONTENT_COPY);
+ ImGui::SetItemTooltip("Copy to clipboard");
+ ImGui::SameLine();
+
+ // debug channels
+ int numChannels = 0;
+ auto channels = DebugMan.getDebugChannels();
+ for (auto &channel : channels) {
+ if (channel.name == "imgui")
+ continue;
+ bool enabled = DebugMan.isDebugChannelEnabled(channel.channel);
+ if (enabled)
+ numChannels++;
+ }
+
+ Common::String selChannels(Common::String::format("(%d channel%s)", numChannels, numChannels > 1 ? "s" : ""));
+ ImGui::PushItemWidth(120);
+ if (ImGui::BeginCombo("##Channels", selChannels.c_str())) {
+ for (auto &channel : channels) {
+ if (channel.name == "imgui")
+ continue;
+ bool enabled = DebugMan.isDebugChannelEnabled(channel.channel);
+ if (ImGui::Checkbox(channel.name.c_str(), &enabled)) {
+ if (enabled) {
+ DebugMan.enableDebugChannel(channel.channel);
+ } else {
+ DebugMan.disableDebugChannel(channel.channel);
+ }
+ }
+ ImGui::SetItemTooltip("%s", channel.description.c_str());
+ }
+ ImGui::EndCombo();
+ }
+ ImGui::SameLine();
+
+ // Options menu
+ if (ImGui::BeginPopup("Options")) {
+ if (ImGui::InputInt("Debug Level", &gDebugLevel)) {
+ if (gDebugLevel < 0)
+ gDebugLevel = 0;
+ }
+ ImGui::Separator();
+ ImGui::Checkbox("Auto-scroll", &_autoScroll);
+ ImGui::EndPopup();
+ }
+
+ // Options, Filter
+ if (ImGui::Button(ICON_MS_SETTINGS))
+ ImGui::OpenPopup("Options");
+ ImGui::SetItemTooltip("Options");
+ ImGui::SameLine();
+
+ ImGui::Spacing();
+ ImGui::SameLine();
+
+ // Error
+ ImGui::PushStyleColor(ImGuiCol_Text, _colors._logger_error_b);
+ ImGuiEx::toggleButton("\ue160", &_showError);
+ ImGui::PopStyleColor();
+ ImGui::SetItemTooltip("Show Errors");
+ ImGui::SameLine();
+
+ // Warning
+ ImGui::PushStyleColor(ImGuiCol_Text, _colors._logger_warning_b);
+ ImGuiEx::toggleButton("\ue002", &_showWarn);
+ ImGui::PopStyleColor();
+ ImGui::SetItemTooltip("Show Warnings");
+ ImGui::SameLine();
+
+ // Info
+ ImGui::PushStyleColor(ImGuiCol_Text, _colors._logger_info_b);
+ ImGuiEx::toggleButton(ICON_MS_INFO, &_showInfo);
+ ImGui::PopStyleColor();
+ ImGui::SetItemTooltip("Show Info");
+ ImGui::SameLine();
+
+ // Debug
+ ImGui::PushStyleColor(ImGuiCol_Text, _colors._logger_debug_b);
+ ImGuiEx::toggleButton(ICON_MS_BUG_REPORT, &_showdebug);
+ ImGui::PopStyleColor();
+ ImGui::SetItemTooltip("Show Debug");
+ ImGui::SameLine();
+
+ _filter.Draw("Filter (\"incl,-excl\") (\"warn\")", 180);
+ ImGui::Separator();
+
+ ImGui::BeginChild("ScrollingRegion", ImVec2(), false, ImGuiWindowFlags_HorizontalScrollbar);
+ if (ImGui::BeginPopupContextWindow()) {
+ if (ImGui::Selectable(ICON_MS_CLEAR_ALL " Clear"))
+ clear();
+ if (ImGui::Selectable(ICON_MS_CONTENT_COPY " Copy"))
+ copy_to_clipboard = true;
+ ImGui::EndPopup();
+ }
+
+ ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4, 1)); // Tighten spacing
+ if (copy_to_clipboard)
+ ImGui::LogToClipboard();
+ for (int i = 0; i < _items.Size; i++) {
+ const char *item = _items[i];
+ bool isError = strstr(item, "[error]");
+ if (!_showError && isError)
+ continue;
+
+ bool isWarn = strstr(item, "[warn]");
+ if (!_showWarn && isWarn)
+ continue;
+
+ bool isDebug = strstr(item, "[debug]");
+ if (!_showdebug && isDebug)
+ continue;
+
+ if (!_showInfo && !isError && !isWarn && !isDebug)
+ continue;
+
+ if (!_filter.PassFilter(item))
+ continue;
+
+ // Normally you would store more information in your item (e.g. make _items[] an array of structure, store color/type etc.)
+ bool pop_color = false;
+ if (isError) {
+ item += 7;
+ ImGui::PushStyleColor(ImGuiCol_Text, _colors._logger_error);
+ pop_color = true;
+ } else if (isWarn) {
+ item += 6;
+ ImGui::PushStyleColor(ImGuiCol_Text, _colors._logger_warning);
+ pop_color = true;
+ } else if (isDebug) {
+ item += 7;
+ ImGui::PushStyleColor(ImGuiCol_Text, _colors._logger_debug);
+ pop_color = true;
+ } else if (strncmp(item, "> ", 2) == 0) {
+ ImGui::PushStyleColor(ImGuiCol_Text, _colors._logger_info);
+ pop_color = true;
+ }
+ ImGui::TextUnformatted(item);
+ if (pop_color)
+ ImGui::PopStyleColor();
+ }
+ if (copy_to_clipboard)
+ ImGui::LogFinish();
+
+ if (_scrollToBottom || (_autoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY()))
+ ImGui::SetScrollHereY(1.0f);
+ _scrollToBottom = false;
+
+ ImGui::PopStyleVar();
+ ImGui::EndChild();
+ ImGui::End();
+}
+
+void ImGuiLogger::drawColorOptions() {
+ ImGui::SeparatorText("Logger");
+ ImGui::ColorEdit4("Error", &_colors._logger_error.x);
+ ImGui::ColorEdit4("Error Button", &_colors._logger_error_b.x);
+ ImGui::ColorEdit4("Warning", &_colors._logger_warning.x);
+ ImGui::ColorEdit4("Warning Button", &_colors._logger_warning_b.x);
+ ImGui::ColorEdit4("Info", &_colors._logger_info.x);
+ ImGui::ColorEdit4("Info Button", &_colors._logger_info_b.x);
+ ImGui::ColorEdit4("Debug", &_colors._logger_debug.x);
+ ImGui::ColorEdit4("Debug Button", &_colors._logger_debug_b.x);
}
} // namespace DT
diff --git a/engines/director/debugger/dt-logger.h b/engines/director/debugger/dt-logger.h
new file mode 100644
index 00000000000..1d08ce43eea
--- /dev/null
+++ b/engines/director/debugger/dt-logger.h
@@ -0,0 +1,67 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef DIRECTOR_DEBUGER_DT_LOGGER_H
+#define DIRECTOR_DEBUGER_DT_LOGGER_H
+
+#include "backends/imgui/imgui.h"
+
+namespace Director {
+namespace DT {
+
+class ImGuiLogger {
+ char _inputBuf[256];
+ ImVector<char *> _items;
+ ImVector<char *> _history;
+ int _historyPos; // -1: new line, 0.._history.Size-1 browsing history.
+ ImGuiTextFilter _filter;
+ bool _autoScroll;
+ bool _scrollToBottom;
+ bool _showError = true;
+ bool _showWarn = true;
+ bool _showInfo = true;
+ bool _showdebug = true;
+
+ struct {
+ ImVec4 _logger_error_b = ImVec4(1.f, 0.f, 0.f, 1.f);
+ ImVec4 _logger_warning_b = ImVec4(1.f, 1.f, 0.f, 1.f);
+ ImVec4 _logger_info_b = ImVec4(1.f, 1.f, 1.f, 1.f);
+ ImVec4 _logger_debug_b = ImVec4(0.8f, 0.8f, 0.8f, 1.f);
+
+ ImVec4 _logger_error = ImVec4(1.0f, 0.4f, 0.4f, 1.0f);
+ ImVec4 _logger_warning = ImVec4(1.0f, 1.0f, 0.4f, 1.0f);
+ ImVec4 _logger_info = ImVec4(1.0f, 0.8f, 0.6f, 1.0f);
+ ImVec4 _logger_debug = ImVec4(0.8f, 0.8f, 0.8f, 1.0f);
+ } _colors;
+
+public:
+ ImGuiLogger();
+ ~ImGuiLogger();
+ void clear();
+ void addLog(const char *fmt, ...) IM_FMTARGS(2);
+ void drawColorOptions();
+ void draw(const char *title, bool *p_open);
+};
+
+} // namespace DT
+} // namespace Director
+
+#endif
diff --git a/engines/director/debugger/dt-scripts.cpp b/engines/director/debugger/dt-scripts.cpp
index a55c6781ef4..89ff48d4f2d 100644
--- a/engines/director/debugger/dt-scripts.cpp
+++ b/engines/director/debugger/dt-scripts.cpp
@@ -20,6 +20,7 @@
*/
#include "backends/imgui/IconsMaterialSymbols.h"
+#include "backends/imgui/imgui_utils.h"
#include "director/director.h"
#include "director/debugger/dt-internal.h"
@@ -221,11 +222,11 @@ void showScripts() {
if (!_state->_functions._scripts[_state->_functions._current].oldAst) {
ImGui::SameLine(0, 20);
- toggleButton(ICON_MS_PACKAGE_2, &_state->_functions._showByteCode, true); // Lingo
+ ImGuiEx::toggleButton(ICON_MS_PACKAGE_2, &_state->_functions._showByteCode, true); // Lingo
ImGui::SetItemTooltip("Lingo");
ImGui::SameLine();
- toggleButton(ICON_MS_STACKS, &_state->_functions._showByteCode); // Bytecode
+ ImGuiEx::toggleButton(ICON_MS_STACKS, &_state->_functions._showByteCode); // Bytecode
ImGui::SetItemTooltip("Bytecode");
}
Commit: a3adb2933c62cf2aaa5a701bdd854cec331f00f6
https://github.com/scummvm/scummvm/commit/a3adb2933c62cf2aaa5a701bdd854cec331f00f6
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-10-11T09:06:43+02:00
Commit Message:
BACKENDS: moved imgui_logger code from directory engine into backends code
Changed paths:
A backends/imgui/components/imgui_logger.cpp
A backends/imgui/components/imgui_logger.h
R engines/director/debugger/dt-logger.cpp
R engines/director/debugger/dt-logger.h
backends/module.mk
engines/director/debugger/debugtools.cpp
engines/director/debugger/dt-internal.h
engines/director/module.mk
diff --git a/engines/director/debugger/dt-logger.cpp b/backends/imgui/components/imgui_logger.cpp
similarity index 98%
rename from engines/director/debugger/dt-logger.cpp
rename to backends/imgui/components/imgui_logger.cpp
index 004dd9b7d19..aa7e38efaa4 100644
--- a/engines/director/debugger/dt-logger.cpp
+++ b/backends/imgui/components/imgui_logger.cpp
@@ -24,10 +24,9 @@
#include "common/debug-channels.h"
#include "common/debug.h"
-#include "director/debugger/dt-logger.h"
+#include "backends/imgui/components/imgui_logger.h"
-namespace Director {
-namespace DT {
+namespace ImGuiEx {
ImGuiLogger::ImGuiLogger() {
clear();
@@ -250,5 +249,4 @@ void ImGuiLogger::drawColorOptions() {
ImGui::ColorEdit4("Debug Button", &_colors._logger_debug_b.x);
}
-} // namespace DT
-} // namespace Director
+} // namespace ImGuiEx
diff --git a/engines/director/debugger/dt-logger.h b/backends/imgui/components/imgui_logger.h
similarity index 89%
rename from engines/director/debugger/dt-logger.h
rename to backends/imgui/components/imgui_logger.h
index 1d08ce43eea..e26910bbd5d 100644
--- a/engines/director/debugger/dt-logger.h
+++ b/backends/imgui/components/imgui_logger.h
@@ -19,13 +19,16 @@
*
*/
-#ifndef DIRECTOR_DEBUGER_DT_LOGGER_H
-#define DIRECTOR_DEBUGER_DT_LOGGER_H
+#ifndef BACKENDS_IMGUI_COMPONENTS_IMGUI_LOGGER_H
+#define BACKENDS_IMGUI_COMPONENTS_IMGUI_LOGGER_H
+
+#ifndef IMGUI_DEFINE_MATH_OPERATORS
+#define IMGUI_DEFINE_MATH_OPERATORS
+#endif
#include "backends/imgui/imgui.h"
-namespace Director {
-namespace DT {
+namespace ImGuiEx {
class ImGuiLogger {
char _inputBuf[256];
@@ -61,7 +64,6 @@ public:
void draw(const char *title, bool *p_open);
};
-} // namespace DT
-} // namespace Director
+} // namespace ImGuiEx
#endif
diff --git a/backends/module.mk b/backends/module.mk
index 17888680048..8be83686573 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -493,6 +493,7 @@ MODULE_OBJS += \
imgui/imgui_tables.o \
imgui/imgui_widgets.o \
imgui/imgui_utils.o \
+ imgui/components/imgui_logger.o \
imgui/misc/freetype/imgui_freetype.o
endif
diff --git a/engines/director/debugger/debugtools.cpp b/engines/director/debugger/debugtools.cpp
index 8ed3605890b..6cdc9787f37 100644
--- a/engines/director/debugger/debugtools.cpp
+++ b/engines/director/debugger/debugtools.cpp
@@ -310,7 +310,7 @@ void onImGuiInit() {
_state->_archive.memEdit.ReadOnly = true;
- _state->_logger = new ImGuiLogger;
+ _state->_logger = new ImGuiEx::ImGuiLogger;
Common::setLogWatcher(onLog);
}
diff --git a/engines/director/debugger/dt-internal.h b/engines/director/debugger/dt-internal.h
index 29448f42c5b..eeaa7e12946 100644
--- a/engines/director/debugger/dt-internal.h
+++ b/engines/director/debugger/dt-internal.h
@@ -30,9 +30,9 @@
#include "backends/imgui/imgui.h"
#include "backends/imgui/imgui_fonts.h"
+#include "backends/imgui/components/imgui_logger.h"
#include "director/debugger/imgui_memory_editor.h"
-#include "director/debugger/dt-logger.h"
#include "director/types.h"
#include "director/lingo/lingo.h"
@@ -40,11 +40,8 @@
#include "director/lingo/lingodec/handler.h"
namespace Director {
-
namespace DT {
-class ImGuiLogger;
-
#define kMaxColumnsInTable 512
typedef struct ImGuiImage {
@@ -180,7 +177,7 @@ typedef struct ImGuiState {
MemoryEditor memEdit;
} _archive;
- ImGuiLogger *_logger = nullptr;
+ ImGuiEx::ImGuiLogger *_logger = nullptr;
} ImGuiState;
// debugtools.cpp
diff --git a/engines/director/module.mk b/engines/director/module.mk
index f4bbab8d0fc..98db944ca45 100644
--- a/engines/director/module.mk
+++ b/engines/director/module.mk
@@ -176,7 +176,6 @@ MODULE_OBJS += \
debugger/dt-cast.o \
debugger/dt-controlpanel.o \
debugger/dt-lists.o \
- debugger/dt-logger.o \
debugger/dt-score.o \
debugger/dt-script-d2.o \
debugger/dt-script-d4.o \
Commit: effbdfe67f739e08ed91db64f423ddc2a4a11114
https://github.com/scummvm/scummvm/commit/effbdfe67f739e08ed91db64f423ddc2a4a11114
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-10-11T09:13:57+02:00
Commit Message:
TWINE: added ImGuiLogger support to the twine debugger
Changed paths:
engines/twine/debugger/debug_state.h
engines/twine/debugger/debugtools.cpp
engines/twine/debugger/dt-internal.h
diff --git a/engines/twine/debugger/debug_state.h b/engines/twine/debugger/debug_state.h
index 512876a2d3c..5d17ea525f1 100644
--- a/engines/twine/debugger/debug_state.h
+++ b/engines/twine/debugger/debug_state.h
@@ -90,6 +90,7 @@ public:
bool _actorDetailsWindow = true;
bool _sceneFlagsWindow = false;
bool _paletteWindow = false;
+ bool _loggerWindow = false;
bool _useFreeCamera = false;
bool _disableGridRendering = false;
diff --git a/engines/twine/debugger/debugtools.cpp b/engines/twine/debugger/debugtools.cpp
index 6cb99cd3dab..e162129d17b 100644
--- a/engines/twine/debugger/debugtools.cpp
+++ b/engines/twine/debugger/debugtools.cpp
@@ -20,8 +20,11 @@
*/
#include "twine/debugger/debugtools.h"
+#include "backends/imgui/components/imgui_logger.h"
#include "backends/imgui/imgui.h"
+#include "backends/imgui/imgui_fonts.h"
#include "backends/imgui/imgui_utils.h"
+#include "common/log.h"
#include "common/scummsys.h"
#include "common/str-enc.h"
#include "common/str.h"
@@ -132,6 +135,23 @@ static const char *toString(ShapeType type) {
}
}
+static void onLog(LogMessageType::Type type, int level, uint32 debugChannels, const char *message) {
+ switch (type) {
+ case LogMessageType::kError:
+ _logger->addLog("[error]%s", message);
+ break;
+ case LogMessageType::kWarning:
+ _logger->addLog("[warn]%s", message);
+ break;
+ case LogMessageType::kInfo:
+ _logger->addLog("%s", message);
+ break;
+ case LogMessageType::kDebug:
+ _logger->addLog("[debug]%s", message);
+ break;
+ }
+}
+
void onImGuiInit() {
ImGuiIO &io = ImGui::GetIO();
io.Fonts->AddFontDefault();
@@ -147,6 +167,10 @@ void onImGuiInit() {
ImGui::addTTFFontFromArchive("MaterialSymbolsSharp.ttf", 16.f, &icons_config, icons_ranges);
_tinyFont = ImGui::addTTFFontFromArchive("FreeSans.ttf", 10.0f, nullptr, nullptr);
+
+ _logger = new ImGuiEx::ImGuiLogger;
+
+ Common::setLogWatcher(onLog);
}
static void holomapFlagsWindow(TwinEEngine *engine) {
@@ -736,6 +760,9 @@ static void gridMenu(TwinEEngine *engine) {
static void debuggerMenu(TwinEEngine *engine) {
if (ImGui::BeginMenu("Debugger")) {
+ if (ImGui::MenuItem("Logs")) {
+ engine->_debugState->_loggerWindow = true;
+ }
if (ImGui::MenuItem("Texts")) {
engine->_debugState->_menuTextWindow = true;
}
@@ -838,6 +865,8 @@ void onImGuiRender() {
gameFlagsWindow(engine);
paletteWindow(engine);
sceneFlagsWindow(engine);
+ _logger->draw("Logger", &engine->_debugState->_loggerWindow);
+
if (engine->_debugState->_openPopup) {
ImGui::OpenPopup(engine->_debugState->_openPopup);
@@ -846,6 +875,11 @@ void onImGuiRender() {
}
void onImGuiCleanup() {
+ delete _logger;
+ _logger = nullptr;
+
+ delete _tinyFont;
+ _tinyFont = nullptr;
}
} // namespace TwinE
diff --git a/engines/twine/debugger/dt-internal.h b/engines/twine/debugger/dt-internal.h
index 7d29b02e421..086ee403b0e 100644
--- a/engines/twine/debugger/dt-internal.h
+++ b/engines/twine/debugger/dt-internal.h
@@ -22,16 +22,12 @@
#ifndef TWINE_DEBUGGER_DT_INTERNAL_H
#define TWINE_DEBUGGER_DT_INTERNAL_H
-#define IMGUI_DEFINE_MATH_OPERATORS
-
-#include "graphics/surface.h"
-
-#include "backends/imgui/imgui.h"
-#include "backends/imgui/imgui_fonts.h"
+#include "backends/imgui/components/imgui_logger.h"
namespace TwinE {
ImFont *_tinyFont = nullptr;
+ImGuiEx::ImGuiLogger *_logger = nullptr;
} // namespace TwinE
More information about the Scummvm-git-logs
mailing list