Skip to content

Commit

Permalink
Fixed to be able to change the resolution setting of Fixed-size NUI
Browse files Browse the repository at this point in the history
  • Loading branch information
wacha-329 committed Feb 21, 2024
1 parent 68751bf commit a90d65a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
6 changes: 5 additions & 1 deletion code/components/nui-core/include/NUIWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,8 @@ class
void HandlePopupShow(bool show);

bool IsFixedSizeWindow() const;
};

private:
int m_fixedWidth;
int m_fixedHeight;
};
18 changes: 15 additions & 3 deletions code/components/nui-core/src/NUIWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extern void AddSchemeHandlerFactories(CefRefPtr<CefRequestContext> rc);
NUIWindow::NUIWindow(bool rawBlit, int width, int height, const std::string& windowContext)
: m_rawBlit(rawBlit), m_width(width), m_height(height), m_renderBuffer(nullptr), m_dirtyFlag(0), m_onClientCreated(nullptr), m_nuiTexture(nullptr), m_popupTexture(nullptr), m_swapTexture(nullptr),
m_swapRtv(nullptr), m_swapSrv(nullptr), m_dereferencedNuiTexture(false), m_lastFrameTime(0), m_lastMessageTime(0), m_roundedHeight(0), m_roundedWidth(0),
m_syncKey(0), m_paintType(NUIPaintTypeDummy), m_windowContext(windowContext)
m_syncKey(0), m_paintType(NUIPaintTypeDummy), m_windowContext(windowContext), m_fixedWidth(1920), m_fixedHeight(1080)
{
memset(&m_lastDirtyRect, 0, sizeof(m_lastDirtyRect));

Expand Down Expand Up @@ -387,6 +387,18 @@ void NUIWindow::Initialize(CefString url)
{
m_renderBuffer = new char[4 * m_roundedWidth * m_roundedHeight];
}

std::wstring fpath = MakeRelativeCitPath(L"CitizenFX.ini");
if (GetFileAttributes(fpath.c_str()) != INVALID_FILE_ATTRIBUTES)
{
m_fixedWidth = GetPrivateProfileInt(L"Game", L"FixedSizeWindowX", 1920, fpath.c_str());
m_fixedHeight = GetPrivateProfileInt(L"Game", L"FixedSizeWindowY", 1080, fpath.c_str());
if (!((640 <= m_fixedWidth && m_fixedWidth <= 7680) && (480 <= m_fixedHeight && m_fixedHeight <= 4320)))
{
m_fixedWidth = 1920;
m_fixedHeight = 1080;
}
}
}

void NUIWindow::InitializeRenderBacking()
Expand Down Expand Up @@ -562,8 +574,8 @@ void NUIWindow::UpdateFrame()

if (IsFixedSizeWindow())
{
resX = 1920;
resY = 1080;
resX = m_fixedWidth;
resY = m_fixedHeight;
}

if (m_width != resX || m_height != resY)
Expand Down

0 comments on commit a90d65a

Please sign in to comment.