Skip to content

Commit

Permalink
Revert CGUIGridLayout (move to cgui-gridlayout branch)
Browse files Browse the repository at this point in the history
This reverts commit dc34672.

Revert "Implement CGUIGridLayout custom element"

This reverts commit 4f47d47.

Revert "Add map for item lookup"

This reverts commit 5c47f44.

Revert "Fix issues with CEGUI testing tab"

This reverts commit 42cdfd4.

Revert "Minor optimization in item lookup map usage"

This reverts commit c80bb0c.

Revert "Fix cell item assignment in CGUIGridLayout"

This reverts commit 068a497.

Revert "Add flex column & row support to CGUIGridLayout"

This reverts commit 548e530.
  • Loading branch information
Lpsd committed Jan 22, 2025
1 parent dc34672 commit 2ae5ecd
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 1,283 deletions.
34 changes: 33 additions & 1 deletion Client/core/CChat.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

#include "CGUI.h"
#include <core/CCoreInterface.h>
#include <../Shared/sdk/CColor.h>

class CChatLineSection;

Expand All @@ -23,6 +22,39 @@ class CChatLineSection;
#define CHAT_BUFFER 1024 // Chatbox buffer size
#define CHAT_INPUT_HISTORY_LENGTH 128 // Chatbox input history length

class CColor
{
public:
CColor() { R = G = B = A = 255; }
CColor(unsigned char _R, unsigned char _G, unsigned char _B, unsigned char _A = 255)
{
R = _R;
G = _G;
B = _B;
A = _A;
}
CColor(const CColor& other) { *this = other; }
CColor(unsigned long ulColor) { *this = ulColor; }
CColor& operator=(const CColor& color)
{
R = color.R;
G = color.G;
B = color.B;
A = color.A;
return *this;
}
CColor& operator=(unsigned long ulColor)
{
R = (ulColor >> 16) & 0xFF;
G = (ulColor >> 8) & 0xFF;
B = (ulColor)&0xFF;
return *this;
}
bool operator==(const CColor& other) const { return R == other.R && G == other.G && B == other.B && A == other.A; }

unsigned char R, G, B, A;
};

class CChatLineSection
{
public:
Expand Down
119 changes: 1 addition & 118 deletions Client/core/CSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#include <game/CGame.h>
#include <game/CSettings.h>

#include <gui/CGUIGridLayout.h>

using namespace std;

#define CORE_MTA_FILLER "cgui\\images\\mta_filler.png"
Expand Down Expand Up @@ -58,7 +56,7 @@ void CSettings::CreateGUI()
if (m_pWindow)
DestroyGUI();

CGUITab *pTabMultiplayer, *pTabVideo, *pTabAudio, *pTabBinds, *pTabControls, *pTabAdvanced, *pTabCEGUI;
CGUITab *pTabMultiplayer, *pTabVideo, *pTabAudio, *pTabBinds, *pTabControls, *pTabAdvanced;
CGUI* pManager = g_pCore->GetGUI();

// Init
Expand Down Expand Up @@ -123,7 +121,6 @@ void CSettings::CreateGUI()
m_pTabInterface = m_pTabs->CreateTab(_("Interface"));
m_pTabBrowser = m_pTabs->CreateTab(_("Web Browser"));
pTabAdvanced = m_pTabs->CreateTab(_("Advanced"));
pTabCEGUI = m_pTabs->CreateTab(_("CEGUI"));

// Create buttons
// OK button
Expand Down Expand Up @@ -1268,93 +1265,6 @@ void CSettings::CreateGUI()
m_pAdvancedSettingDescriptionLabel->SetSize(CVector2D(500.0f, 95.0f));
m_pAdvancedSettingDescriptionLabel->SetHorizontalAlign(CGUI_ALIGN_HORIZONTALCENTER_WORDWRAP);

/**
* CEGUI tab.
**/
m_pGridLayout = reinterpret_cast<CGUIGridLayout*>(pManager->CreateGridLayout(pTabCEGUI));
m_pGridLayout->SetGrid(9, 9);
m_pGridLayout->SetColumnWidth(1, 0.25f);
m_pGridLayout->SetColumnWidth(3, 0.25f);
m_pGridLayout->SetRowHeight(2, 0.25f);
m_pGridLayout->SetRowHeight(4, 0.25f);
vecTemp = CVector2D(12.f, 12.f);

// Grid layout section label
m_pGridLayoutLabel = reinterpret_cast<CGUILabel*>(pManager->CreateLabel(pTabCEGUI, _("Grid layout")));
m_pGridLayoutLabel->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY));
m_pGridLayoutLabel->SetFont("default-bold-small");
m_pGridLayoutLabel->AutoSize();
m_pGridLayoutLabel->SetHorizontalAlign(CGUI_ALIGN_HORIZONTALCENTER_WORDWRAP);
vecTemp.fY += 15.0f;

m_pCellAlphaLabel = reinterpret_cast<CGUILabel*>(pManager->CreateLabel(pTabCEGUI, _("Cell alpha:")));
m_pCellAlphaLabel->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY));
m_pCellAlphaLabel->AutoSize();
m_pCellAlphaLabel->SetHorizontalAlign(CGUI_ALIGN_LEFT);

m_pGridColumnsLabel = reinterpret_cast<CGUILabel*>(pManager->CreateLabel(pTabCEGUI, _("Columns:")));
m_pGridColumnsLabel->SetPosition(CVector2D(vecTemp.fX + 200.0f, vecTemp.fY));
m_pGridColumnsLabel->AutoSize();
m_pGridColumnsLabel->SetHorizontalAlign(CGUI_ALIGN_LEFT);

m_pGridRowsLabel = reinterpret_cast<CGUILabel*>(pManager->CreateLabel(pTabCEGUI, _("Rows:")));
m_pGridRowsLabel->SetPosition(CVector2D(vecTemp.fX + 400.0f, vecTemp.fY));
m_pGridRowsLabel->AutoSize();
m_pGridRowsLabel->SetHorizontalAlign(CGUI_ALIGN_LEFT);

vecTemp.fY += 5.0f;

m_pCellAlpha = reinterpret_cast<CGUIScrollBar*>(pManager->CreateScrollBar(true, pTabCEGUI));
m_pCellAlpha->SetPosition(CVector2D(vecTemp.fX + 50.0f, vecTemp.fY));
m_pCellAlpha->SetSize(CVector2D(130.0f, 20.0f));
m_pCellAlpha->SetOnScrollHandler(GUI_CALLBACK(&CSettings::OnCellAlphaChanged, this));
m_pCellAlpha->SetProperty("StepSize", "0.01");

m_pGridColumns = reinterpret_cast<CGUIScrollBar*>(pManager->CreateScrollBar(true, pTabCEGUI));
m_pGridColumns->SetPosition(CVector2D(vecTemp.fX + 250.0f, vecTemp.fY));
m_pGridColumns->SetSize(CVector2D(130.0f, 20.0f));
m_pGridColumns->SetOnScrollHandler(GUI_CALLBACK(&CSettings::OnGridColumnsChanged, this));
m_pGridColumns->SetProperty("StepSize", "0.1");

m_pGridRows = reinterpret_cast<CGUIScrollBar*>(pManager->CreateScrollBar(true, pTabCEGUI));
m_pGridRows->SetPosition(CVector2D(vecTemp.fX + 450.0f, vecTemp.fY));
m_pGridRows->SetSize(CVector2D(130.0f, 20.0f));
m_pGridRows->SetOnScrollHandler(GUI_CALLBACK(&CSettings::OnGridRowsChanged, this));
m_pGridRows->SetProperty("StepSize", "0.1");

vecTemp.fY += 20.0f;
m_pCellAlphaValueLabel = reinterpret_cast<CGUILabel*>(pManager->CreateLabel(pTabCEGUI, "XXX"));
m_pCellAlphaValueLabel->SetPosition(CVector2D(vecTemp.fX + 50.0f, vecTemp.fY));
m_pCellAlphaValueLabel->AutoSize();
m_pCellAlphaValueLabel->SetHorizontalAlign(CGUI_ALIGN_LEFT);

m_pGridColumnsValueLabel = reinterpret_cast<CGUILabel*>(pManager->CreateLabel(pTabCEGUI, "XXX"));
m_pGridColumnsValueLabel->SetPosition(CVector2D(vecTemp.fX + 250.0f, vecTemp.fY));
m_pGridColumnsValueLabel->AutoSize();
m_pGridColumnsValueLabel->SetHorizontalAlign(CGUI_ALIGN_LEFT);

m_pGridRowsValueLabel = reinterpret_cast<CGUILabel*>(pManager->CreateLabel(pTabCEGUI, "XXX"));
m_pGridRowsValueLabel->SetPosition(CVector2D(vecTemp.fX + 450.0f, vecTemp.fY));
m_pGridRowsValueLabel->AutoSize();
m_pGridRowsValueLabel->SetHorizontalAlign(CGUI_ALIGN_LEFT);

m_pCellAlpha->SetScrollPosition(0.5f);
m_pGridColumns->SetScrollPosition(0.9f);
m_pGridRows->SetScrollPosition(0.9f);

// Grid layout
vecTemp.fY += 20.0f;
m_pGridLayout->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY));
m_pGridLayout->SetSize(CVector2D(500.0f, 300.0f));

//m_pTestCellLabel = reinterpret_cast<CGUILabel*>(pManager->CreateLabel(pTabCEGUI, _("Test cell")));
//m_pTestCellLabel->AutoSize();
//m_pTestCellLabel->SetHorizontalAlign(CGUI_ALIGN_HORIZONTALCENTER);
//m_pTestCellLabel->SetVerticalAlign(CGUI_ALIGN_VERTICALCENTER);

//bool add = m_pGridLayout->AddItem(m_pTestCellLabel, 1, 1);
//m_pTestCellLabel->SetText(add ? "true" : "false");

// Set up the events
m_pWindow->SetEnterKeyHandler(GUI_CALLBACK(&CSettings::OnOKButtonClick, this));
m_pButtonOK->SetClickHandler(GUI_CALLBACK(&CSettings::OnOKButtonClick, this));
Expand Down Expand Up @@ -4565,33 +4475,6 @@ bool CSettings::OnChatAlphaChanged(CGUIElement* pElement)
return false;
}

bool CSettings::OnCellAlphaChanged(CGUIElement* pElement)
{
float alpha = (m_pCellAlpha->GetScrollPosition());
m_pCellAlphaValueLabel->SetText(SString("%g", alpha).c_str());

m_pGridLayout->SetDefaultCellAlpha(alpha);
return true;
}

bool CSettings::OnGridColumnsChanged(CGUIElement* pElement)
{
int columns = static_cast<int>(std::round(std::max<float>(0.1f, m_pGridColumns->GetScrollPosition()) * 10));
m_pGridColumnsValueLabel->SetText(SString("%i", columns).c_str());

m_pGridLayout->SetColumns(columns);
return true;
}

bool CSettings::OnGridRowsChanged(CGUIElement* pElement)
{
int rows = static_cast<int>(std::round(std::max<float>(0.1f, m_pGridRows->GetScrollPosition()) * 10));
m_pGridRowsValueLabel->SetText(SString("%i", rows).c_str());

m_pGridLayout->SetRows(rows);
return true;
}

bool CSettings::OnUpdateButtonClick(CGUIElement* pElement)
{
// Update build type
Expand Down
46 changes: 15 additions & 31 deletions Client/core/CSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class CSettings;
#include "CMainMenu.h"
#include "CCore.h"

#define SKINS_PATH "skins/*"
#define CHAT_PRESETS_PATH "mta/config/chatboxpresets.xml"
#define CHAT_PRESETS_ROOT "chatboxpresets"
#define SKINS_PATH "skins/*"
#define CHAT_PRESETS_PATH "mta/config/chatboxpresets.xml"
#define CHAT_PRESETS_ROOT "chatboxpresets"

// #define SHOWALLSETTINGS

Expand Down Expand Up @@ -125,18 +125,18 @@ class CSettings
const static int SecKeyNum = 3; // Number of secondary keys

// Keep these protected so we can access them in the event handlers of CClientGame
CGUIElement* m_pWindow;
CGUITabPanel* m_pTabs;
CGUITab* m_pTabInterface;
CGUITab* m_pTabBrowser;
CGUIButton* m_pButtonOK;
CGUIButton* m_pButtonCancel;
CGUILabel* m_pLabelNick;
CGUIButton* m_pButtonGenerateNick;
CGUIStaticImage* m_pButtonGenerateNickIcon;
CGUIEdit* m_pEditNick;
CGUICheckBox* m_pSavePasswords;
CGUICheckBox* m_pAutoRefreshBrowser;
CGUIElement* m_pWindow;
CGUITabPanel* m_pTabs;
CGUITab* m_pTabInterface;
CGUITab* m_pTabBrowser;
CGUIButton* m_pButtonOK;
CGUIButton* m_pButtonCancel;
CGUILabel* m_pLabelNick;
CGUIButton* m_pButtonGenerateNick;
CGUIStaticImage* m_pButtonGenerateNickIcon;
CGUIEdit* m_pEditNick;
CGUICheckBox* m_pSavePasswords;
CGUICheckBox* m_pAutoRefreshBrowser;

CGUILabel* m_pVideoGeneralLabel;
CGUILabel* m_pVideoResolutionLabel;
Expand Down Expand Up @@ -345,19 +345,6 @@ class CSettings
bool m_bBrowserListsChanged;
bool m_bBrowserListsLoadEnabled;

CGUILabel* m_pGridLayoutLabel;
CGUIGridLayout* m_pGridLayout;
CGUILabel* m_pTestCellLabel;
CGUILabel* m_pCellAlphaLabel;
CGUIScrollBar* m_pCellAlpha;
CGUILabel* m_pCellAlphaValueLabel;
CGUILabel* m_pGridColumnsLabel;
CGUIScrollBar* m_pGridColumns;
CGUILabel* m_pGridColumnsValueLabel;
CGUILabel* m_pGridRowsLabel;
CGUIScrollBar* m_pGridRows;
CGUILabel* m_pGridRowsValueLabel;

bool OnJoypadTextChanged(CGUIElement* pElement);
bool OnAxisSelectClick(CGUIElement* pElement);
bool OnAudioDefaultClick(CGUIElement* pElement);
Expand Down Expand Up @@ -399,9 +386,6 @@ class CSettings
bool OnBrowserWhitelistRemove(CGUIElement* pElement);
bool OnBrowserWhitelistDomainAddFocused(CGUIElement* pElement);
bool OnBrowserWhitelistDomainAddDefocused(CGUIElement* pElement);
bool OnCellAlphaChanged(CGUIElement* pElement);
bool OnGridColumnsChanged(CGUIElement* pElement);
bool OnGridRowsChanged(CGUIElement* pElement);

bool OnMouseDoubleClick(CGUIMouseEventArgs Args);

Expand Down
Loading

0 comments on commit 2ae5ecd

Please sign in to comment.