Skip to content

Commit

Permalink
Remove "redraw" window rendering logic
Browse files Browse the repository at this point in the history
and other non-noteworthy changes
  • Loading branch information
Lpsd committed Oct 15, 2024
1 parent 09a8805 commit 0b78b7f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 101 deletions.
2 changes: 0 additions & 2 deletions Client/gui/CGUIElement_Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ CGUIElement_Impl::CGUIElement_Impl()

void CGUIElement_Impl::DestroyElement()
{
m_pManager->RemoveFromRedrawQueue(reinterpret_cast<CGUIElement*>((m_pWindow)->getUserData()));

// Clear pointer back to this
m_pWindow->setUserData(NULL);

Expand Down
21 changes: 14 additions & 7 deletions Client/gui/CGUIStaticImage_Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,18 @@ bool CGUIStaticImage_Impl::LoadFromFile(const char* szFilename, const char* szRe

// Get the image from the image manager and cast to BasicImage
m_pImage = static_cast<CEGUI::BitmapImage*>(&m_pImagesetManager->get(szFilename));
}

// Set image to window
m_pWindow->setProperty("Image", szFilename);
// Store size
auto texture = m_pImage->getTexture();
auto& size = texture->getSize();
m_size = glm::vec2{size.d_width, size.d_height};

// Set size and create geometry
m_pImage->setImageArea(CEGUI::Rectf(0.0f, m_size.x, m_size.y, 0.0f));

// Set image to window
m_pWindow->setProperty("Image", szFilename);
}

return true;
}
Expand Down Expand Up @@ -123,7 +131,8 @@ bool CGUIStaticImage_Impl::LoadFromTexture(CGUITexture* pTexture)

// Set the image size based on texture
auto& size = pCEGUITexture->getSize();
m_pImage->setImageArea(CEGUI::Rectf(0.0f, size.d_width, size.d_height, 0.0f));
m_size = glm::vec2{size.d_width, size.d_height};
m_pImage->setImageArea(CEGUI::Rectf(0.0f, m_size.x, m_size.y, 0.0f));

// Set image to window
m_pWindow->setProperty("Image", szUnique);
Expand All @@ -137,7 +146,7 @@ void CGUIStaticImage_Impl::Clear()
if (!m_pImage)
return;

//m_pImagesetManager->destroy(m_pImage->getName());
m_pImagesetManager->destroy(m_pImage->getName());
}

bool CGUIStaticImage_Impl::GetNativeSize(CVector2D& vecSize)
Expand Down Expand Up @@ -168,8 +177,6 @@ CEGUI::Image* CGUIStaticImage_Impl::GetDirectImage()
return m_pImage;
}

/* Unused? */
void CGUIStaticImage_Impl::Render()
{
return m_pWindow->draw();
}
12 changes: 7 additions & 5 deletions Client/gui/CGUIStaticImage_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ class CGUIStaticImage_Impl : public CGUIStaticImage, public CGUIElement_Impl, pu
eCGUIType GetType() { return CGUI_STATICIMAGE; }

private:
CGUI_Impl* m_pGUI;
CGUITexture_Impl* m_pTexture;
CEGUI::BitmapImage* m_pImage;
CEGUI::ImageManager* m_pImagesetManager;
CGUI_Impl* m_pGUI;
CGUITexture_Impl* m_pTexture;
CEGUI::BitmapImage* m_pImage;
CEGUI::ImageManager* m_pImagesetManager;

#include "CGUIElement_Inc.h"
glm::vec2 m_size;

#include "CGUIElement_Inc.h"
};
81 changes: 4 additions & 77 deletions Client/gui/CGUI_Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ CGUI_Impl::CGUI_Impl(IDirect3DDevice9* pDevice)
m_pWindowManager = CEGUI::WindowManager::getSingletonPtr();
m_pWindowFactoryManager = CEGUI::WindowFactoryManager::getSingletonPtr();

auto& renderMaterial = m_pRenderer->createRenderMaterial(CEGUI::DefaultShaderType::Textured);
m_pGeometryBuffer = &m_pRenderer->createGeometryBufferTextured(renderMaterial);

m_pResourceProvider = m_pSystem->getResourceProvider();
m_pDefaultResourceProvider = static_cast<CEGUI::DefaultResourceProvider*>(m_pSystem->getResourceProvider());

Expand Down Expand Up @@ -223,7 +220,7 @@ void CGUI_Impl::SubscribeToMouseEvents()
pEvents->subscribeEvent("Window/" + CEGUI::Window::EventCursorLeavesArea, CEGUI::Event::Subscriber(&CGUI_Impl::Event_MouseLeave, this));
pEvents->subscribeEvent("Window/" + CEGUI::Window::EventMoved, CEGUI::Event::Subscriber(&CGUI_Impl::Event_Moved, this));
pEvents->subscribeEvent("Window/" + CEGUI::Window::EventSized, CEGUI::Event::Subscriber(&CGUI_Impl::Event_Sized, this));
// pEvents->subscribeEvent("Window/" + CEGUI::Window::EventRedrawRequested, CEGUI::Event::Subscriber(&CGUI_Impl::Event_RedrawRequested, this));
//pEvents->subscribeEvent("Window/" + CEGUI::Window::EventUpdated, CEGUI::Event::Subscriber(&CGUI_Impl::Event_Invalidated, this));
pEvents->subscribeEvent("Window/" + CEGUI::Window::EventActivated, CEGUI::Event::Subscriber(&CGUI_Impl::Event_FocusGained, this));
pEvents->subscribeEvent("Window/" + CEGUI::Window::EventDeactivated, CEGUI::Event::Subscriber(&CGUI_Impl::Event_FocusLost, this));
}
Expand All @@ -241,30 +238,8 @@ void CGUI_Impl::SetResolution(float fWidth, float fHeight)

void CGUI_Impl::Draw()
{
// Redraw the changed elements
if (!m_RedrawQueue.empty())
{
list<CGUIElement*>::const_iterator iter = m_RedrawQueue.begin();
for (; iter != m_RedrawQueue.end(); iter++)
{
(*iter)->ForceRedraw();
}
m_RedrawQueue.clear();
}

m_pSystem->renderAllGUIContexts();

// I don't think this is required anymore? There's most likely a better way to catch rendering issues now
// if (!m_pSystem->renderAllGUIContexts())
//{
// if (m_RenderOkTimer.Get() > 4000)
// {
// // 4 seconds and over 40 failed calls means we have a problem
// BrowseToSolution("gui-render", EXIT_GAME_FIRST, "Some sort of DirectX problem has occurred");
// }
//}
// else
// m_RenderOkTimer.Reset();
}

void CGUI_Impl::Invalidate()
Expand Down Expand Up @@ -1379,19 +1354,6 @@ bool CGUI_Impl::Event_Sized(const CEGUI::EventArgs& Args)
return true;
}

bool CGUI_Impl::Event_RedrawRequested(const CEGUI::EventArgs& Args)
{
const CEGUI::WindowEventArgs& e = reinterpret_cast<const CEGUI::WindowEventArgs&>(Args);

CGUIElement* pElement = reinterpret_cast<CGUIElement*>((e.window)->getUserData());
if (pElement)
AddToRedrawQueue(pElement);
else
e.window->invalidate(true);

return true;
}

bool CGUI_Impl::Event_FocusGained(const CEGUI::EventArgs& Args)
{
if (m_FocusGainedHandlers[m_Channel])
Expand Down Expand Up @@ -1438,38 +1400,6 @@ bool CGUI_Impl::Event_FocusLost(const CEGUI::EventArgs& Args)
return true;
}

void CGUI_Impl::AddToRedrawQueue(CGUIElement* pWindow)
{
// Manage the redraw queue, if we redraw the parent of the window passed,
// we should not add it to the redraw queue, and if the children are queued,
// remove them.
list<CGUIElement*>::const_iterator iter = m_RedrawQueue.begin();
for (; iter != m_RedrawQueue.end(); iter++)
{
if (pWindow->GetParent() == *iter)
{
return;
}
else if ((*iter)->GetParent() == pWindow)
{
m_RedrawQueue.remove(*iter);
if (m_RedrawQueue.empty())
return;
iter = m_RedrawQueue.begin();
}
else if (*iter == pWindow)
{
return;
}
}
m_RedrawQueue.push_back(pWindow);
}

void CGUI_Impl::RemoveFromRedrawQueue(CGUIElement* pWindow)
{
m_RedrawQueue.remove(pWindow);
}

CGUIButton* CGUI_Impl::CreateButton(CGUIElement* pParent, const char* szCaption)
{
CGUIWindow_Impl* wnd = reinterpret_cast<CGUIWindow_Impl*>(pParent);
Expand Down Expand Up @@ -1574,7 +1504,9 @@ CGUIMemo* CGUI_Impl::CreateMemo(CGUITab* pParent, const char* szText)
CGUIStaticImage* CGUI_Impl::CreateStaticImage(CGUIElement* pParent)
{
CGUIWindow_Impl* wnd = reinterpret_cast<CGUIWindow_Impl*>(pParent);
return _CreateStaticImage(wnd);
auto image = _CreateStaticImage(wnd);
m_images.push_back(image);
return image;
}

CGUIStaticImage* CGUI_Impl::CreateStaticImage(CGUITab* pParent)
Expand Down Expand Up @@ -1725,11 +1657,6 @@ CEGUI::USize CGUI_Impl::CreateRelativeSize(float width, float height)
return CEGUI::USize(CEGUI::UDim(width, 0), CEGUI::UDim(height, 0));
}

CEGUI::GeometryBuffer* CGUI_Impl::GetGeometryBuffer()
{
return m_pGeometryBuffer;
}

void CGUI_Impl::ClearSystemKeys()
{
}
9 changes: 0 additions & 9 deletions Client/gui/CGUI_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ class CGUI_Impl : public CGUI, public CGUITabList
void GetUniqueName(char* pBuf);
CEGUI::Window* GetMasterWindow(CEGUI::Window* Window);

CEGUI::GeometryBuffer* GetGeometryBuffer();

CEGUI::USize CreateAbsoluteSize(float width, float height);
CEGUI::USize CreateRelativeSize(float width, float height);

Expand Down Expand Up @@ -259,13 +257,9 @@ class CGUI_Impl : public CGUI, public CGUITabList
bool Event_MouseLeave(const CEGUI::EventArgs& e);
bool Event_Moved(const CEGUI::EventArgs& e);
bool Event_Sized(const CEGUI::EventArgs& e);
bool Event_RedrawRequested(const CEGUI::EventArgs& e);
bool Event_FocusGained(const CEGUI::EventArgs& e);
bool Event_FocusLost(const CEGUI::EventArgs& e);

void AddToRedrawQueue(CGUIElement* pWindow);
void RemoveFromRedrawQueue(CGUIElement* pWindow);

void CleanDeadPool();
CGUIWindow* LoadLayout(CGUIElement* pParent, const SString& strFilename);
bool LoadImageset(const SString& strFilename);
Expand Down Expand Up @@ -306,7 +300,6 @@ class CGUI_Impl : public CGUI, public CGUITabList
CEGUI::ResourceProvider* m_pResourceProvider;
CEGUI::DefaultResourceProvider* m_pDefaultResourceProvider;

CEGUI::GeometryBuffer* m_pGeometryBuffer;
CEGUI::GUIContext* m_pDefaultGUIContext;

CEGUI::Window* m_pTop;
Expand All @@ -322,8 +315,6 @@ class CGUI_Impl : public CGUI, public CGUITabList
CGUIFont_Impl* m_pSansFont;
CGUIFont_Impl* m_pUniFont;

std::list<CGUIElement*> m_RedrawQueue;

unsigned long m_ulPreviousUnique;

eInputMode m_eInputMode;
Expand Down
2 changes: 1 addition & 1 deletion Shared/sdk/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@

#define _ASE_VERSION QUOTE_DEFINE(MTASA_VERSION_MAJOR) "." QUOTE_DEFINE(MTASA_VERSION_MINOR)
#define _NETCODE_VERSION_BRANCH_ID 0x4 // Use 0x1 - 0xF to indicate an incompatible branch is being used (0x0 is reserved, 0x4 is trunk)
#define _CLIENT_NET_MODULE_VERSION 0x0AE // (0x000 - 0xfff) Lvl9 wizards only
#define _CLIENT_NET_MODULE_VERSION 0x0AF // (0x000 - 0xfff) Lvl9 wizards only
#define _SERVER_NET_MODULE_VERSION 0x0AB // (0x000 - 0xfff) Lvl9 wizards only
#define _NETCODE_VERSION 0x1DA // (0x000 - 0xfff) Increment when net messages change (pre-release)

Expand Down

0 comments on commit 0b78b7f

Please sign in to comment.