Welcome to Metin2Resources

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

[C++/Py] System de debug window

JIGSAW

Be the best, Ignore the rest.
Staff member
Administrator
Premium
Joined
Jul 14, 2025
Messages
117
Reaction score
1,097
Points
93
Discord
jigsaw86
1DbsVh0.png

[REPLYANDTHANKS]
Code:
* EterPythonLib\PythonGraphic.cpp

Search for:
Code:
long CPythonGraphic::GenerateColor(float r, float g, float b, float a)

Add the following code above it:
void CPythonGraphic::RenderTextLine(float x, float y, const char* c_szText, DWORD dwColor)
{
    assert(ms_lpd3dDevice != NULL);

    // Create a text instance with the provided text
    CGraphicTextInstance textInstance;

    // Set properties
    textInstance.SetColor(dwColor);

    // Get the default font from FontManager
    extern CResource* gs_pkDefaultFont;
    CGraphicText* pFont = static_cast<CGraphicText*>(gs_pkDefaultFont);
    if (!pFont)
        return;

    textInstance.SetTextPointer(pFont);
    textInstance.SetValue(c_szText);
    textInstance.SetPosition(x, y);

    // Update the text layout
    textInstance.Update();

    // Render the text at the specified position
    textInstance.Render();
}

* EterPythonLib\PythonGraphic.h

Search for:
Code:
        long GenerateColor(float r, float g, float b, float a);

Add the following code above it:
        void RenderTextLine(float x, float y, const char* c_szText, DWORD dwColor);

* EterPythonLib/PythonWindow.cpp

Add the following include:
#include <fmt/format.h>

Search for:
Code:
        if (g_bOutlineBoxEnable)
        {
            CPythonGraphic::Instance().SetDiffuseColor(1.0f, 1.0f, 1.0f);
            CPythonGraphic::Instance().RenderBox2d(m_rect.left, m_rect.top, m_rect.right, m_rect.bottom);
        }

Replace it with:
        if (g_bOutlineBoxEnable)
        {
            if (CWindowManager::instance().GetPointWindow() == this)
            {
                // Render parent rect with blue outline
                const auto parentRect = m_pParent ? m_pParent->m_rect : RECT{ 0, 0, 0, 0 };
                CPythonGraphic::Instance().SetDiffuseColor(0.0f, 0.0f, 1.0f);
                CPythonGraphic::Instance().RenderBox2d(parentRect.left, parentRect.top, parentRect.right, parentRect.bottom);

                // Render this rect with green outline
                CPythonGraphic::Instance().SetDiffuseColor(0.0f, 1.0f, 0.0f);
                CPythonGraphic::Instance().RenderBox2d(m_rect.left, m_rect.top, m_rect.right, m_rect.bottom);

                // Render info text with window name and flags
                const auto buffer = fmt::format("{} ({})", m_strName, Type());
                CPythonGraphic::Instance().RenderTextLine(m_rect.left + 5, m_rect.top - 30, buffer.c_str(), 0xFFFFFF00);

                const auto flags = m_dwFlag;
                std::string flagInfo;
                if (flags & FLAG_MOVABLE)
                    flagInfo += "FLAG_MOVABLE ";
                if (flags & FLAG_SNAP)
                    flagInfo += "FLAG_SNAP ";
                if (flags & FLAG_DRAGABLE)
                    flagInfo += "FLAG_DRAGABLE ";
                if (flags & FLAG_ATTACH)
                    flagInfo += "FLAG_ATTACH ";
                if (flags & FLAG_RESTRICT_X)
                    flagInfo += "FLAG_RESTRICT_X ";
                if (flags & FLAG_RESTRICT_Y)
                    flagInfo += "FLAG_RESTRICT_Y ";
                if (flags & FLAG_FLOAT)
                    flagInfo += "FLAG_FLOAT ";
                if (flags & FLAG_NOT_PICK)
                    flagInfo += "FLAG_NOT_PICK ";
                if (flags & FLAG_IGNORE_SIZE)
                    flagInfo += "FLAG_IGNORE_SIZE ";
                if (flags & FLAG_RTL)
                    flagInfo += "FLAG_RTL ";

                const auto parentName = m_pParent ? m_pParent->GetName() : "None";

                const auto stRectInfo = fmt::format("Pos: ({0}, {1}), Size: {2}x{3}, Flags: {4}, Parent: {5}",
                    m_rect.left, m_rect.top, m_rect.right - m_rect.left, m_rect.bottom - m_rect.top,
                    flagInfo, parentName
                );
                CPythonGraphic::Instance().RenderTextLine(m_rect.left + 5, m_rect.top - 15, stRectInfo.c_str(), 0xFFFFFFFF);
            }
        }

* UserInterface\GameType.cpp

Search for:
Code:
static CResource* gs_pkDefaultFont = NULL;

Replace it with:
CResource* gs_pkDefaultFont = NULL;

Activation:
Inside `EterPythonLib\PythonWindow.cpp`, you can change the value of `BOOL g_bOutlineBoxEnable` to `TRUE` or activate it via Python using `wndMgr.SetOutlineFlag(True)`.
[REPLYANDTHANKS][/REPLYANDTHANKS][/REPLYANDTHANKS]
 
619Threads
3,960Messages
1,276Members
Shamash ErhardLatest member
Back
Top