From 2ae5ecd1ea3ceb7d5fb0b204cf217d1c6f0ea5d6 Mon Sep 17 00:00:00 2001 From: Lpsd <40902730+Lpsd@users.noreply.github.com> Date: Wed, 22 Jan 2025 19:40:38 +0000 Subject: [PATCH] Revert CGUIGridLayout (move to cgui-gridlayout branch) This reverts commit dc34672cff71494322e93995de84d089dd79b6ce. Revert "Implement CGUIGridLayout custom element" This reverts commit 4f47d471c84f916d659650be66fcefa545ee2997. Revert "Add map for item lookup" This reverts commit 5c47f44193f49f840b03f69256cb2668b1bd7975. Revert "Fix issues with CEGUI testing tab" This reverts commit 42cdfd4fa3aa881d0ec0616a7d514f1556aa02da. Revert "Minor optimization in item lookup map usage" This reverts commit c80bb0c21c06deed5f0ad326b49e3fb0843ed1ed. Revert "Fix cell item assignment in CGUIGridLayout" This reverts commit 068a4975661ec5872318218651a5f3b1d06f7f77. Revert "Add flex column & row support to CGUIGridLayout" This reverts commit 548e53025d20122eb66987201ded0dca190a18f6. --- Client/core/CChat.h | 34 +- Client/core/CSettings.cpp | 119 +---- Client/core/CSettings.h | 46 +- Client/gui/CGUIGridLayout_Impl.cpp | 827 ----------------------------- Client/gui/CGUIGridLayout_Impl.h | 132 ----- Client/gui/CGUI_Impl.cpp | 11 - Client/gui/CGUI_Impl.h | 3 - Client/gui/StdInc.h | 1 - Client/sdk/gui/CGUI.h | 3 - Client/sdk/gui/CGUIElement.h | 3 +- Client/sdk/gui/CGUIGridLayout.h | 112 ---- Shared/sdk/CColor.h | 42 -- 12 files changed, 50 insertions(+), 1283 deletions(-) delete mode 100644 Client/gui/CGUIGridLayout_Impl.cpp delete mode 100644 Client/gui/CGUIGridLayout_Impl.h delete mode 100644 Client/sdk/gui/CGUIGridLayout.h delete mode 100644 Shared/sdk/CColor.h diff --git a/Client/core/CChat.h b/Client/core/CChat.h index 9269bcaf9b..e967127075 100644 --- a/Client/core/CChat.h +++ b/Client/core/CChat.h @@ -13,7 +13,6 @@ #include "CGUI.h" #include -#include <../Shared/sdk/CColor.h> class CChatLineSection; @@ -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: diff --git a/Client/core/CSettings.cpp b/Client/core/CSettings.cpp index a0568da998..566a374247 100644 --- a/Client/core/CSettings.cpp +++ b/Client/core/CSettings.cpp @@ -14,8 +14,6 @@ #include #include -#include - using namespace std; #define CORE_MTA_FILLER "cgui\\images\\mta_filler.png" @@ -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 @@ -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 @@ -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(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(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(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(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(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(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(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(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(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(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(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(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)); @@ -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(std::round(std::max(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(std::round(std::max(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 diff --git a/Client/core/CSettings.h b/Client/core/CSettings.h index d9b4872859..91a14ca40e 100644 --- a/Client/core/CSettings.h +++ b/Client/core/CSettings.h @@ -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 @@ -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; @@ -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); @@ -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); diff --git a/Client/gui/CGUIGridLayout_Impl.cpp b/Client/gui/CGUIGridLayout_Impl.cpp deleted file mode 100644 index 3e75a3354e..0000000000 --- a/Client/gui/CGUIGridLayout_Impl.cpp +++ /dev/null @@ -1,827 +0,0 @@ -/***************************************************************************** - * - * PROJECT: Multi Theft Auto v1.0 - * LICENSE: See LICENSE in the top level directory - * FILE: gui/CGUIGridList_Impl.cpp - * PURPOSE: Grid list widget class - * - * Multi Theft Auto is available from http://www.multitheftauto.com/ - * - *****************************************************************************/ - -#include "StdInc.h" -#include - -#define CGUIGRIDLAYOUT_NAME "CGUI/FrameWindow" - -CGUIGridLayout_Impl::CGUIGridLayout_Impl(CGUI_Impl* pGUI, CGUIElement* pParent) -{ - m_pManager = pGUI; - - // Get an unique identifier for CEGUI (gah, there's gotta be an another way) - char szUnique[CGUI_CHAR_SIZE]; - pGUI->GetUniqueName(szUnique); - - // Create the window and set default settings - m_pWindow = pGUI->GetWindowManager()->createWindow(pGUI->ResolveModernName(CGUIGRIDLAYOUT_NAME), szUnique); - - m_pWindow->setDestroyedByParent(false); - m_pWindow->setRect(CEGUI::Relative, CEGUI::Rect(0.00f, 0.00f, 1.0f, 1.0f)); - - CEGUI::FrameWindow* frameWindow = reinterpret_cast(m_pWindow); - frameWindow->setTitleBarEnabled(false); - frameWindow->setSizingEnabled(false); - frameWindow->setDragMovingEnabled(false); - frameWindow->setCloseButtonEnabled(false); - frameWindow->setFrameEnabled(false); - - // Store the pointer to this CGUI element in the CEGUI element - m_pWindow->setUserData(reinterpret_cast(this)); - - // Register our events - // m_pWindow->subscribeEvent(CEGUI::MultiColumnList::EventSortColumnChanged, CEGUI::Event::Subscriber(&CGUIGridList_Impl::Event_OnSortColumn, this)); - AddEvents(); - - // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager - if (pParent) - { - SetParent(pParent); - } - else - { - pGUI->AddChild(this); - SetParent(NULL); - } - - // Create our cell textures - m_cellTexture = m_pManager->CreateTexture(); - m_cellTextureAlt = m_pManager->CreateTexture(); - - unsigned long ulBackgroundColor255 = COLOR_ARGB(255, 0, 0, 0); - m_cellTexture->LoadFromMemory(&ulBackgroundColor255, 1, 1); - - unsigned long ulBackgroundColor150 = COLOR_ARGB(150, 0, 0, 0); - m_cellTextureAlt->LoadFromMemory(&ulBackgroundColor150, 1, 1); -} - -CGUIGridLayout_Impl::~CGUIGridLayout_Impl() -{ - DestroyElement(); -} - -const bool CGUIGridLayout_Impl::AddItem(CGUIElement* item, int column, int row, const bool moveToNextCell) -{ - auto* cell = GetCell(column, row); - - if (cell == nullptr) - return false; - - if (cell->element != nullptr) - RemoveItem(column, row, false, true); - - item->SetParent(cell->container); - item->SetPosition(CVector2D(0.0f, 0.0f), true); - item->ForceRedraw(); - - cell->element = item; - m_items.emplace(item, cell->id); - - if (moveToNextCell) - { - if (m_activeRow == m_rows) - { - if (m_activeColumn < m_columns) - { - m_activeColumn++; - m_activeRow = 1; - } - } - else - { - m_activeRow++; - } - } - - return true; -} - -const bool CGUIGridLayout_Impl::AddItem(CGUIElement* item, const bool moveToNextCell) -{ - return AddItem(item, m_activeColumn, m_activeRow); -} - -const bool CGUIGridLayout_Impl::RemoveItem(const int column, const int row, const bool moveToPreviousCell, const bool deleteItem) -{ - auto* cell = GetCell(column, row); - - if (cell == nullptr || cell->element == nullptr) - return false; - - cell->element->SetParent(nullptr); - cell->element->ForceRedraw(); - - m_items.erase(cell->element); - cell->element = nullptr; - - if (deleteItem) - delete cell->element; - - if (moveToPreviousCell) - { - if (m_activeRow == 1) - { - if (m_activeColumn > 1) - { - m_activeColumn--; - m_activeRow = m_rows; - } - } - else - { - m_activeRow--; - } - } - - return true; -} - -const bool CGUIGridLayout_Impl::RemoveItem(const CGUIElement* item, const bool moveToPreviousCell, const bool deleteItem) -{ - auto* cell = GetCell(item); - - if (cell == nullptr) - return false; - - return RemoveItem(cell->column, cell->row, moveToPreviousCell); -} - -SGridCellItem* CGUIGridLayout_Impl::GetCell(const int column, const int row) const -{ - if (!InGridRange(column, row)) - return nullptr; - - const auto& cell = m_cells.find(m_grid[column - 1][row - 1]); - - if (cell == m_cells.end()) - return nullptr; - - return cell->second; -} - -SGridCellItem* CGUIGridLayout_Impl::GetCell(const CGUIElement* item) const -{ - int id = m_items.count(item) ? m_items.at(item) : 0; - return id == 0 ? nullptr : m_cells.at(id); -} - -std::vector CGUIGridLayout_Impl::GetCellsInColumn(const int column) const -{ - return GetCellsInGrid(column, 0, column, m_rows - 1); -} - -std::vector CGUIGridLayout_Impl::GetCellsInRow(const int row) const -{ - return GetCellsInGrid(0, row, m_columns - 1, row); -} - -std::vector CGUIGridLayout_Impl::GetCellsInGrid(const int startColumn, const int startRow, const int endColumn, const int endRow) const -{ - if (startColumn < 1 || startRow < 1 || endColumn > m_columns || endRow > m_rows) - { - return std::vector(); - } - - std::vector cells; - - for (int i = startColumn; i <= endColumn; i++) - { - for (int j = startRow; j <= endRow; j++) - { - if (m_grid[i - 1][j - 1] != 0) - { - auto& cell = m_cells.find(m_grid[i - 1][j - 1]); - - if (cell != m_cells.end()) - { - cells.push_back(cell->second); - } - } - } - } - - return cells; -} - -std::vector CGUIGridLayout_Impl::GetCellsOutsideGrid(const int startColumn, const int startRow, const int endColumn, const int endRow) const -{ - if (startColumn < 1 || startRow < 1 || endColumn > m_columns || endRow > m_rows) - { - return std::vector(); - } - - std::vector cells; - - for (auto& cell : m_cells) - { - if (cell.second->column < startColumn || cell.second->column > endColumn || cell.second->row < startRow || cell.second->row > endRow) - { - cells.push_back(cell.second); - } - } - - return cells; -} - -const bool CGUIGridLayout_Impl::SetColumns(int columns) -{ - if (columns < 0 || columns == m_columns) - { - return false; - } - - bool set = SetGrid(columns, m_rows); - - if (set) - m_columns = columns; - - return set; -} - -const bool CGUIGridLayout_Impl::SetRows(int rows) -{ - if (rows < 0 || rows == m_rows) - return false; - - bool set = SetGrid(m_columns, rows); - - if (set) - m_rows = rows; - - return set; -} - -const bool CGUIGridLayout_Impl::SetGrid(int columns, int rows) -{ - if (columns < 0 || rows < 0 || (columns == m_columns && rows == m_rows)) - return false; - - m_columns = columns; - m_rows = rows; - - const size_t& size = m_grid.size(); - const bool larger = (columns * rows) > (size * (size > 0 ? m_grid[0].size() : 0)); - - m_grid.resize(columns); - - for (int i = 0; i < columns; i++) - { - m_grid[i].resize(rows, 0); - } - - m_columnWidths.resize(m_columns, 0.0f); - m_rowHeights.resize(m_rows, 0.0f); - - if (larger) - { - CreateGridCells(); - - // Since the grid starts at 0,0 make sure an active cell is set - m_activeColumn = (m_activeColumn == 0 ? 1 : m_activeColumn); - m_activeRow = (m_activeRow == 0 ? 1 : m_activeRow); - } - else - { - CleanupGridCells(); - - // Since the grid has been resized, we need to make sure the active cell is still within the grid - m_activeColumn = std::min(m_activeColumn, columns); - m_activeRow = std::min(m_activeRow, rows); - } - - RepositionGridCells(); - return true; -} - -const bool CGUIGridLayout_Impl::SetActiveCell(int column, int row) -{ - if (!InGridRange(column, row)) - return false; - - m_activeColumn = column; - m_activeRow = row; - return true; -} - -const bool CGUIGridLayout_Impl::SetActiveColumn(int column) -{ - if (!InColumnRange(column)) - return false; - - m_activeColumn = column; - return true; -} - -const bool CGUIGridLayout_Impl::SetActiveRow(int row) -{ - if (!InRowRange(row)) - return false; - - m_activeRow = row; - return true; -} - -const std::pair CGUIGridLayout_Impl::GetActiveCell() const -{ - return std::make_pair(m_activeColumn, m_activeRow); -} - -void CGUIGridLayout_Impl::SetItemAlignment(const CGUIElement* item, eGridLayoutItemAlignment alignment) -{ - auto* cell = GetCell(item); - - if (cell == nullptr) - return; - - cell->alignment = alignment; - RepositionGridCell(*cell, true); -} - -const eGridLayoutItemAlignment CGUIGridLayout_Impl::GetItemAlignment(const CGUIElement* item) const -{ - const auto* cell = GetCell(item); - - if (cell == nullptr) - return m_defaultAlignment; - - return cell->alignment; -} - -const bool CGUIGridLayout_Impl::SetCellAlpha(const int column, const int row, const float alpha) -{ - auto* cell = GetCell(column, row); - - if (cell == nullptr) - return false; - - cell->container->SetAlpha(alpha); - return true; -} - -const bool CGUIGridLayout_Impl::SetDefaultCellAlpha(const float alpha) -{ - m_defaultCellAlpha = alpha; - - for (auto& cell : m_cells) - { - cell.second->container->SetAlpha(alpha); - } - - return true; -} - -const bool CGUIGridLayout_Impl::SetColumnWidth(const int column, const float width) -{ - if (!InColumnRange(column)) - return false; - - m_columnWidths[column - 1] = width; - RepositionGridCells(); - return true; -} - -const bool CGUIGridLayout_Impl::SetRowHeight(const int row, const float height) -{ - if (!InRowRange(row)) - return false; - - m_rowHeights[row - 1] = height; - RepositionGridCells(); - return true; -} - -const bool CGUIGridLayout_Impl::SetCellFullSize(const int column, const int row, const bool fullSize) -{ - auto* cell = GetCell(column, row); - - if (cell == nullptr) - return false; - - cell->forceFullSize = fullSize; - RepositionGridCell(*cell, true); - return true; -} - -const bool CGUIGridLayout_Impl::SetDefaultCellFullSize(const bool fullSize, const bool updateExisting) -{ - m_defaultFullSize = fullSize; - - if (updateExisting) - { - for (auto& cell : m_cells) - { - cell.second->forceFullSize = fullSize; - } - - RepositionGridCells(true); - } - - return true; -} - -const bool CGUIGridLayout_Impl::GetCellFullSize(const int column, const int row) const -{ - auto* cell = GetCell(column, row); - - if (cell == nullptr) - return false; - - return cell->forceFullSize; -} - -const bool CGUIGridLayout_Impl::SetCellPadding(const int column, const int row, const CVector2D& padding) -{ - auto* cell = GetCell(column, row); - - if (cell == nullptr) - return false; - - cell->padding = padding; - RepositionGridCell(*cell, true); - return true; -} - -const bool CGUIGridLayout_Impl::SetDefaultCellPadding(const CVector2D& padding, const bool updateExisting) -{ - m_defaultPadding = padding; - - for (auto& cell : m_cells) - { - cell.second->padding = padding; - } - - RepositionGridCells(true); - return true; -} - -const CVector2D& CGUIGridLayout_Impl::GetCellPadding(const int column, const int row) const -{ - auto* cell = GetCell(column, row); - - if (cell == nullptr) - return m_defaultPadding; - - return cell->padding; -} - -const bool CGUIGridLayout_Impl::SetCellTexture(const int column, const int row, CGUITexture* texture, const bool alt) -{ - auto* cell = GetCell(column, row); - - if (cell == nullptr) - return false; - - cell->container->LoadFromTexture(texture); - return true; -} - -const bool CGUIGridLayout_Impl::SetCellColor(const int column, const int row, const CColor& color, const bool alt) -{ - auto* cell = GetCell(column, row); - - if (cell == nullptr) - return false; - - auto* texture = m_pManager->CreateTexture(); - unsigned long argb = COLOR_ARGB(color.A, color.R, color.G, color.B); - - texture->LoadFromMemory(&argb, 1, 1); - cell->container->LoadFromTexture(texture); - - return true; -} - -const bool CGUIGridLayout_Impl::SetDefaultCellTexture(CGUITexture* texture, const bool alt, const bool updateExisting) -{ - if (alt) - m_cellTextureAlt = texture; - else - m_cellTexture = texture; - - if (updateExisting) - { - for (auto& cell : m_cells) - { - cell.second->container->LoadFromTexture(texture); - } - } - - return true; -} - -const bool CGUIGridLayout_Impl::SetDefaultCellColor(const CColor& color, const bool alt, const bool updateExisting) -{ - auto* texture = m_pManager->CreateTexture(); - unsigned long argb = COLOR_ARGB(color.A, color.R, color.G, color.B); - - texture->LoadFromMemory(&argb, 1, 1); - return SetDefaultCellTexture(texture, alt, updateExisting); -} - -void CGUIGridLayout_Impl::CreateGridCells() -{ - auto* parent = reinterpret_cast(this); - - // Calculate our own offsets here for performance reasons - std::vector columnOffset(m_columns, 0.0f); - std::vector rowOffset(m_rows, 0.0f); - - for (int i = 0; i < m_columns; i++) - { - for (int j = 0; j < m_rows; j++) - { - const auto cell = m_cells.count(m_grid[i][j]); - - if (cell == 0) - { - auto* cellItem = new SGridCellItem(); - cellItem->container = m_pManager->CreateStaticImage(parent); - cellItem->alignment = m_defaultAlignment; - cellItem->forceFullSize = m_defaultFullSize; - cellItem->padding = m_defaultPadding; - - // Assign the cell container texture, alternative between m_cellTexture and m_cellTextureAlt - cellItem->container->LoadFromTexture((i + j) % 2 == 0 ? m_cellTexture : m_cellTextureAlt); - cellItem->container->SetAlpha(m_defaultCellAlpha); - - auto offsets = AccumulateOffsets({columnOffset, rowOffset}); - - // Position the cell container in the grid - cellItem->container->SetPosition(CalculateCellPosition(*cellItem, offsets), true); - - // Size the cell container in the grid - cellItem->container->SetSize(CalculateCellSize(*cellItem, offsets), true); - - // Create a test label for the cell - auto* label = m_pManager->CreateLabel(cellItem->container, std::to_string(m_nextId).c_str()); - - cellItem->id = m_nextId; - cellItem->element = label; - cellItem->column = i + 1; - cellItem->row = j + 1; - - label->SetFrameEnabled(true); - label->SetHorizontalAlign(CGUI_ALIGN_HORIZONTALCENTER); - label->SetVerticalAlign(CGUI_ALIGN_VERTICALCENTER); - - // For testing purposes. Use CGUIGridLayout::SetCellFullSize in proper implementation - if (cellItem->forceFullSize) - label->SetSize(CVector2D(1.0f - (cellItem->padding.fX * 2.0f), 1.0f - (cellItem->padding.fY * 2.0f)), true); - else - label->SetSize(CVector2D(0.2f, 0.2f), true); - - CVector2D offset = GetAlignmentOffset(*cellItem, label->GetSize(true)); - label->SetPosition(offset, true); - label->ForceRedraw(); - - m_cells.emplace(m_nextId, cellItem); - m_grid[i][j] = m_nextId; - - m_nextId++; - } - - rowOffset[j] = m_rowHeights[j]; - } - - columnOffset[i] = m_columnWidths[i]; - rowOffset.assign(m_rows, 0.0f); - } -} - -void CGUIGridLayout_Impl::CleanupGridCells() -{ - for (auto& cell : m_cells) - { - if (cell.second->column > m_columns || cell.second->row > m_rows) - { - delete cell.second->container; - - if (cell.second->element) - { - m_items.erase(cell.second->element); - - cell.second->element->SetParent(nullptr); - cell.second->element->ForceRedraw(); - - delete cell.second->element; - cell.second->element = nullptr; - } - - delete cell.second; - m_cells.erase(cell.first); - } - } -} - -const CVector2D CGUIGridLayout_Impl::CalculateCellPosition(const SGridCellItem& cell, const std::pair& offsets) const -{ - int widths = CountColumnWidths(); - int heights = CountRowHeights(); - - if (cell.element != nullptr) - cell.element->SetText(std::to_string(std::max(0, cell.column - widths)).c_str()); - - return CVector2D( - offsets.first + (std::max(0, cell.column - CountColumnWidths(cell.column) - 1) * ((1.0f - AccumulateOffset(m_columnWidths)) / (m_columns - widths))), - offsets.second + (std::max(0, cell.row - CountRowHeights(cell.row) - 1) * ((1.0f - AccumulateOffset(m_rowHeights)) / (m_rows - heights)))); -} - -const CVector2D CGUIGridLayout_Impl::CalculateCellSize(const SGridCellItem& cell, const std::pair& offsets) const -{ - int widths = CountColumnWidths(); - int heights = CountRowHeights(); - - return CVector2D( - m_columnWidths[cell.column - 1] == 0.0f ? (1.0f - AccumulateOffset(m_columnWidths)) / (m_columns - widths) : m_columnWidths[cell.column - 1], - m_rowHeights[cell.row - 1] == 0.0f ? (1.0f - AccumulateOffset(m_rowHeights)) / (m_rows - heights) : m_rowHeights[cell.row - 1]); -} - -const std::pair, std::vector> CGUIGridLayout_Impl::CalculateGridOffsets(const int column, const int row) const -{ - std::vector columnOffset(m_columns, 0.0f); - std::vector rowOffset(m_rows, 0.0f); - - for (int i = 0; i < (column == 0 ? m_columns : column) - 1; i++) - { - for (int j = 0; j < (row == 0 ? m_rows : row) - 1; j++) - { - if (j < (row == 0 ? m_rows : row)) - { - rowOffset[j + 1] = m_rowHeights[j]; - } - } - - columnOffset[i + 1] = m_columnWidths[i]; - rowOffset.assign(m_rows, 0.0f); - } - - return {columnOffset, rowOffset}; -} - -const float CGUIGridLayout_Impl::AccumulateOffset(const std::vector& offset) const -{ - return std::reduce(offset.begin(), offset.end()); -} - -const std::pair CGUIGridLayout_Impl::AccumulateOffsets(const std::pair, std::vector>& offsets) const -{ - return {AccumulateOffset(offsets.first), AccumulateOffset(offsets.second)}; -} - -void CGUIGridLayout_Impl::RepositionGridCells(const bool itemOnly) const -{ - std::vector columnOffset(m_columns, 0.0f); - std::vector rowOffset(m_rows, 0.0f); - - for (int i = 0; i < m_columns; i++) - { - for (int j = 0; j < m_rows; j++) - { - const auto cell = m_cells.count(m_grid[i][j]); - - if (cell != 0) - { - const auto& cellItem = m_cells.at(m_grid[i][j]); - - if (!itemOnly) - { - auto offsets = AccumulateOffsets({columnOffset, rowOffset}); - - cellItem->container->SetPosition(CalculateCellPosition(*cellItem, offsets), true); - cellItem->container->SetSize(CalculateCellSize(*cellItem, offsets), true); - cellItem->container->ForceRedraw(); - } - - if (cellItem->element != nullptr) - { - if (cellItem->forceFullSize) - { - cellItem->element->SetSize(CVector2D(1.0f - (cellItem->padding.fX * 2.0f), 1.0f - (cellItem->padding.fY * 2.0f)), true); - } - - CVector2D position = GetAlignmentOffset(*cellItem, cellItem->element->GetSize(true)); - cellItem->element->SetPosition(position, true); - cellItem->element->ForceRedraw(); - } - } - - rowOffset[j] = m_rowHeights[j]; - } - - columnOffset[i] = m_columnWidths[i]; - rowOffset.assign(m_rows, 0.0f); - } -} - -void CGUIGridLayout_Impl::RepositionGridCell(const SGridCellItem& cell, const bool itemOnly) const -{ - if (!itemOnly) - { - auto offsets = AccumulateOffsets(CalculateGridOffsets(cell.column, cell.row)); - - cell.container->SetPosition(CalculateCellPosition(cell, offsets), true); - cell.container->SetSize(CalculateCellSize(cell, offsets), true); - cell.container->ForceRedraw(); - } - - if (cell.element != nullptr) - { - if (cell.forceFullSize) - { - cell.element->SetSize(CVector2D(1.0f - (cell.padding.fX * 2.0f), 1.0f - (cell.padding.fY * 2.0f)), true); - } - - CVector2D position = GetAlignmentOffset(cell, cell.element->GetSize(true)); - cell.element->SetPosition(position, true); - cell.element->ForceRedraw(); - } -} - -void CGUIGridLayout_Impl::RepositionGridCell(const int column, const int row, const bool itemOnly) const -{ - const auto* cell = GetCell(column, row); - - if (cell == nullptr) - return; - - RepositionGridCell(*cell); -} - -const bool CGUIGridLayout_Impl::InGridRange(const int column, const int row) const -{ - return column >= 1 && row >= 1 && column <= m_columns && row <= m_rows; -} - -const bool CGUIGridLayout_Impl::InColumnRange(const int column) const -{ - return column >= 1 && column <= m_columns; -} - -const bool CGUIGridLayout_Impl::InRowRange(const int row) const -{ - return row >= 1 && row <= m_rows; -} - -const CVector2D CGUIGridLayout_Impl::GetAlignmentOffset(const SGridCellItem& cell, const CVector2D& size) const -{ - CVector2D offset; - - if (!cell.forceFullSize) - { - switch (cell.alignment) - { - case eGridLayoutItemAlignment::TOP_LEFT: - offset += CVector2D(0.0f, 0.0f); - break; - case eGridLayoutItemAlignment::TOP_CENTER: - offset += CVector2D(0.5f - (size.fX / 2.0f), 0.0f); - break; - case eGridLayoutItemAlignment::TOP_RIGHT: - offset += CVector2D(1.0f - size.fX, 0.0f); - break; - case eGridLayoutItemAlignment::MIDDLE_LEFT: - offset += CVector2D(0.0f, 0.5f - (size.fY / 2.0f)); - break; - case eGridLayoutItemAlignment::MIDDLE_CENTER: - offset += CVector2D(0.5f - (size.fX / 2.0f), 0.5f - (size.fY / 2.0f)); - break; - case eGridLayoutItemAlignment::MIDDLE_RIGHT: - offset += CVector2D(1.0f - size.fX, 0.5f - (size.fY / 2.0f)); - break; - case eGridLayoutItemAlignment::BOTTOM_LEFT: - offset += CVector2D(0.0f, 1.0f - size.fY); - break; - case eGridLayoutItemAlignment::BOTTOM_CENTER: - offset += CVector2D(0.5f - (size.fX / 2.0f), 1.0f - size.fY); - break; - case eGridLayoutItemAlignment::BOTTOM_RIGHT: - offset += CVector2D(1.0f - size.fX, 1.0f - size.fY); - break; - } - } - - offset = CVector2D(std::min(offset.fX, 1.0f - size.fX - cell.padding.fX), std::min(offset.fY, 1.0f - size.fY - cell.padding.fY)); - offset = CVector2D(std::max(offset.fX, cell.padding.fX), std::max(offset.fY, cell.padding.fY)); - return offset; -} - -const int CGUIGridLayout_Impl::CountColumnWidths(const int maxColumns) const -{ - return std::count_if(m_columnWidths.begin(), m_columnWidths.begin() + (maxColumns == 0 || maxColumns < 1 ? m_columns : maxColumns) - 1, - [&](const float& width) { return width > 0.0f; }); -} - -const int CGUIGridLayout_Impl::CountRowHeights(const int maxRows) const -{ - return std::count_if(m_rowHeights.begin(), m_rowHeights.begin() + (maxRows == 0 || maxRows < 1 ? m_rows : maxRows) - 1, - [&](const float& height) { return height > 0.0f; }); -} diff --git a/Client/gui/CGUIGridLayout_Impl.h b/Client/gui/CGUIGridLayout_Impl.h deleted file mode 100644 index 2f63fe13ff..0000000000 --- a/Client/gui/CGUIGridLayout_Impl.h +++ /dev/null @@ -1,132 +0,0 @@ -/***************************************************************************** - * - * PROJECT: Multi Theft Auto: San Andreas - * LICENSE: See LICENSE in the top level directory - * - * Multi Theft Auto is available from http://www.multitheftauto.com/ - * - *****************************************************************************/ - -#pragma once - -#include -#include "CGUIElement_Impl.h" - -class CGUIGridLayout_Impl : public CGUIGridLayout, public CGUIElement_Impl -{ -public: - CGUIGridLayout_Impl(class CGUI_Impl* pGUI, CGUIElement* pParent = NULL); - ~CGUIGridLayout_Impl(); - - eCGUIType GetType() { return CGUI_GRIDLAYOUT; }; - - const bool SetColumns(int columns); - const bool SetRows(int rows); - const bool SetGrid(int columns, int rows); - - const int GetColumns() const { return m_columns; } - const int GetRows() const { return m_rows; } - - const bool SetActiveCell(int column, int row); - const bool SetActiveColumn(int column); - const bool SetActiveRow(int row); - - const int GetActiveColumn() const { return m_activeColumn; } - const int GetActiveRow() const { return m_activeRow; } - const std::pair GetActiveCell() const; - - const bool AddItem(CGUIElement* item, int column, int row, const bool moveToNextCell = true); - const bool AddItem(CGUIElement* item, const bool moveToNextCell = true); - - const bool RemoveItem(const int column, const int row, const bool moveToPreviousCell = false, const bool deleteItem = false); - const bool RemoveItem(const CGUIElement* item, const bool moveToPreviousCell = false, const bool deleteItem = false); - - SGridCellItem* GetCell(const int column, const int row) const; - SGridCellItem* GetCell(const CGUIElement* item) const; - - std::vector GetCellsInGrid(const int startColumn, const int startRow, const int endColumn, const int endRow) const; - std::vector GetCellsOutsideGrid(const int startColumn, const int startRow, const int endColumn, const int endRow) const; - std::vector GetCellsInColumn(const int column) const; - std::vector GetCellsInRow(const int row) const; - - void SetItemAlignment(const CGUIElement* item, eGridLayoutItemAlignment alignment); - void SetDefaultItemAlignment(eGridLayoutItemAlignment alignment) { m_defaultAlignment = alignment; } - - const eGridLayoutItemAlignment GetItemAlignment(const CGUIElement* item) const; - const eGridLayoutItemAlignment GetDefaultItemAlignment() const { return m_defaultAlignment; } - - const bool SetCellAlpha(const int column, const int row, const float alpha); - const bool SetDefaultCellAlpha(const float alpha); - - const bool SetColumnWidth(const int column, const float width); - const bool SetRowHeight(const int row, const float height); - - const bool SetCellFullSize(const int column, const int row, const bool fullSize); - const bool SetDefaultCellFullSize(const bool fullSize, const bool updateExisting = false); - - const bool GetCellFullSize(const int column, const int row) const; - const bool GetDefaultCellFullSize() const { return m_defaultFullSize; } - - const bool SetCellPadding(const int column, const int row, const CVector2D& padding); - const bool SetDefaultCellPadding(const CVector2D& padding, const bool updateExisting); - - const CVector2D& GetCellPadding(const int column, const int row) const; - const CVector2D& GetDefaultCellPadding() const { return m_defaultPadding; } - - const bool SetCellTexture(const int column, const int row, CGUITexture* texture, const bool alt = false); - const bool SetCellColor(const int column, const int row, const CColor& color, const bool alt = false); - - const bool SetDefaultCellTexture(CGUITexture* texture, const bool alt = false, const bool updateExisting = false); - const bool SetDefaultCellColor(const CColor& color, const bool alt = false, const bool updateExisting = false); - -#include "CGUIElement_Inc.h" - -private: - int m_columns = 0; - int m_rows = 0; - - int m_activeColumn = 0; - int m_activeRow = 0; - - int m_nextId = 1; - - float m_defaultCellAlpha = 1.0f; - - std::vector> m_grid; - std::unordered_map m_cells; - std::unordered_map m_items; - - std::vector m_columnWidths; - std::vector m_rowHeights; - - CGUITexture* m_cellTexture = nullptr; - CGUITexture* m_cellTextureAlt = nullptr; - - eGridLayoutItemAlignment m_defaultAlignment = eGridLayoutItemAlignment::MIDDLE_CENTER; - - bool m_defaultFullSize = false; - CVector2D m_defaultPadding = CVector2D(0.1f, 0.1f); - - void CreateGridCells(); - void CleanupGridCells(); - - void RepositionGridCells(const bool itemOnly = false) const; - void RepositionGridCell(const SGridCellItem& cell, const bool itemOnly = false) const; - void RepositionGridCell(const int column, const int row, const bool itemOnly = false) const; - - const bool InGridRange(const int column, const int row) const; - const bool InColumnRange(const int column) const; - const bool InRowRange(const int row) const; - - const CVector2D CalculateCellPosition(const SGridCellItem& cell, const std::pair& offsets) const; - const CVector2D CalculateCellSize(const SGridCellItem& cell, const std::pair& offset) const; - - const std::pair, std::vector> CalculateGridOffsets(const int column = 0, const int row = 0) const; - const std::pair AccumulateOffsets(const std::pair, std::vector>& offsets) const; - const float AccumulateOffset(const std::vector& offset) const; - - const int CountColumnWidths(const int maxColumns = 0) const; - const int CountRowHeights(const int maxRows = 0) const; - - const CVector2D GetAlignmentOffset(const SGridCellItem& cell, const CVector2D& size) const; -}; diff --git a/Client/gui/CGUI_Impl.cpp b/Client/gui/CGUI_Impl.cpp index f16649fb41..0229a7bfbd 100644 --- a/Client/gui/CGUI_Impl.cpp +++ b/Client/gui/CGUI_Impl.cpp @@ -836,11 +836,6 @@ CGUIWindow* CGUI_Impl::CreateWnd(CGUIElement* pParent, const char* szCaption) return new CGUIWindow_Impl(this, pParent, szCaption); } -CGUIGridLayout* CGUI_Impl::_CreateGridLayout(CGUIElement_Impl* pParent) -{ - return new CGUIGridLayout_Impl(this, pParent); -} - void CGUI_Impl::SetCursorEnabled(bool bEnabled) { if (bEnabled) @@ -2001,12 +1996,6 @@ CGUIWebBrowser* CGUI_Impl::CreateWebBrowser(CGUITab* pParent) return _CreateWebBrowser(wnd); } -CGUIGridLayout* CGUI_Impl::CreateGridLayout(CGUIElement* pParent) -{ - CGUIWindow_Impl* wnd = reinterpret_cast(pParent); - return _CreateGridLayout(wnd); -} - void CGUI_Impl::CleanDeadPool() { if (m_pWindowManager) diff --git a/Client/gui/CGUI_Impl.h b/Client/gui/CGUI_Impl.h index 6ef917d157..c93593144c 100644 --- a/Client/gui/CGUI_Impl.h +++ b/Client/gui/CGUI_Impl.h @@ -142,8 +142,6 @@ class CGUI_Impl : public CGUI, public CGUITabList CGUITexture* CreateTexture(); CGUIFont* CreateFnt(const char* szFontName, const char* szFontFile, unsigned int uSize = 8, unsigned int uFlags = 0, bool bAutoScale = false); - CGUIGridLayout* CreateGridLayout(CGUIElement* pParent = nullptr); - void SetCursorEnabled(bool bEnabled); bool IsCursorEnabled(); void SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer = false); @@ -304,7 +302,6 @@ class CGUI_Impl : public CGUI, public CGUITabList CGUIScrollBar* _CreateScrollBar(bool bHorizontal, CGUIElement_Impl* pParent = NULL); CGUIComboBox* _CreateComboBox(CGUIElement_Impl* pParent = NULL, const char* szCaption = ""); CGUIWebBrowser* _CreateWebBrowser(CGUIElement_Impl* pParent = nullptr); - CGUIGridLayout* _CreateGridLayout(CGUIElement_Impl* pParent = nullptr); void SubscribeToMouseEvents(); CGUIFont* CreateFntFromWinFont(const char* szFontName, const char* szFontWinReg, const char* szFontWinFile, unsigned int uSize = 8, unsigned int uFlags = 0, diff --git a/Client/gui/StdInc.h b/Client/gui/StdInc.h index fdd2310e9d..e2a040a0ee 100644 --- a/Client/gui/StdInc.h +++ b/Client/gui/StdInc.h @@ -35,4 +35,3 @@ #include "CGUIWebBrowser_Impl.h" #include "CGUIWindow_Impl.h" #include "CGUIComboBox_Impl.h" -#include "CGUIGridLayout_Impl.h" diff --git a/Client/sdk/gui/CGUI.h b/Client/sdk/gui/CGUI.h index 1e04c28315..d4d40c2f09 100644 --- a/Client/sdk/gui/CGUI.h +++ b/Client/sdk/gui/CGUI.h @@ -35,7 +35,6 @@ class CGUI; #include "CGUIWebBrowser.h" #include "CGUITabPanel.h" #include "CGUIComboBox.h" -#include "CGUIGridLayout.h" #include "CGUITypes.h" class CXML; @@ -127,8 +126,6 @@ class CGUI virtual CGUIFont* CreateFnt(const char* szFontName, const char* szFontFile, unsigned int uSize = 8, unsigned int uFlags = 0, bool bAutoScale = false) = 0; virtual CGUITexture* CreateTexture() = 0; - virtual CGUIGridLayout* CreateGridLayout(CGUIElement* pParent = nullptr) = 0; - virtual void SetCursorEnabled(bool bEnabled) = 0; virtual bool IsCursorEnabled() = 0; virtual void SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer = false) = 0; diff --git a/Client/sdk/gui/CGUIElement.h b/Client/sdk/gui/CGUIElement.h index c787f149df..252c84de99 100644 --- a/Client/sdk/gui/CGUIElement.h +++ b/Client/sdk/gui/CGUIElement.h @@ -41,8 +41,7 @@ enum eCGUIType CGUI_SCROLLPANE, CGUI_SCROLLBAR, CGUI_COMBOBOX, - CGUI_WEBBROWSER, - CGUI_GRIDLAYOUT + CGUI_WEBBROWSER }; class CGUIElement diff --git a/Client/sdk/gui/CGUIGridLayout.h b/Client/sdk/gui/CGUIGridLayout.h deleted file mode 100644 index 796e321e74..0000000000 --- a/Client/sdk/gui/CGUIGridLayout.h +++ /dev/null @@ -1,112 +0,0 @@ -/***************************************************************************** - * - * PROJECT: Multi Theft Auto v1.0 - * LICENSE: See LICENSE in the top level directory - * FILE: sdk/gui/CGUIGridList.h - * PURPOSE: Grid list widget interface - * - * Multi Theft Auto is available from http://www.multitheftauto.com/ - * - *****************************************************************************/ - -#pragma once - -#include "CGUIElement.h" -#include "CGUIGridLayout.h" -#include <../Shared/sdk/CVector2D.h> -#include <../Shared/sdk/CColor.h> - -#include - -class CGUIStaticImage; -class CGUITexture; - -enum class eGridLayoutItemAlignment -{ - TOP_LEFT, - TOP_CENTER, - TOP_RIGHT, - MIDDLE_LEFT, - MIDDLE_CENTER, - MIDDLE_RIGHT, - BOTTOM_LEFT, - BOTTOM_CENTER, - BOTTOM_RIGHT -}; - -struct SGridCellItem -{ - int id; - CGUIStaticImage* container; - CGUIElement* element; - eGridLayoutItemAlignment alignment; - int column; - int row; - bool forceFullSize; - CVector2D padding; -}; - -class CGUIGridLayout : public CGUIElement -{ -public: - virtual ~CGUIGridLayout(){}; - - virtual const bool SetColumns(int columns) = 0; - virtual const bool SetRows(int rows) = 0; - virtual const bool SetGrid(int columns, int rows) = 0; - - virtual const int GetColumns() const = 0; - virtual const int GetRows() const = 0; - - virtual const bool SetActiveCell(int column, int row) = 0; - virtual const bool SetActiveColumn(int column) = 0; - virtual const bool SetActiveRow(int row) = 0; - - virtual const int GetActiveColumn() const = 0; - virtual const int GetActiveRow() const = 0; - virtual const std::pair GetActiveCell() const = 0; - - virtual const bool AddItem(CGUIElement* item, int column, int row, const bool moveToNextCell = true) = 0; - virtual const bool AddItem(CGUIElement* item, const bool moveToNextCell = true) = 0; - - virtual const bool RemoveItem(const int column, const int row, const bool moveToPreviousCell = false, const bool deleteItem = false) = 0; - virtual const bool RemoveItem(const CGUIElement* item, const bool moveToPreviousCell = false, const bool deleteItem = false) = 0; - - virtual SGridCellItem* GetCell(const int column, const int row) const = 0; - virtual SGridCellItem* GetCell(const CGUIElement* item) const = 0; - - virtual std::vector GetCellsInGrid(const int startColumn, const int startRow, const int endColumn, const int endRow) const = 0; - virtual std::vector GetCellsOutsideGrid(const int startColumn, const int startRow, const int endColumn, const int endRow) const = 0; - virtual std::vector GetCellsInColumn(const int column) const = 0; - virtual std::vector GetCellsInRow(const int row) const = 0; - - virtual void SetItemAlignment(const CGUIElement* item, eGridLayoutItemAlignment alignment) = 0; - virtual void SetDefaultItemAlignment(eGridLayoutItemAlignment alignment) = 0; - - virtual const eGridLayoutItemAlignment GetItemAlignment(const CGUIElement* item) const = 0; - virtual const eGridLayoutItemAlignment GetDefaultItemAlignment() const = 0; - - virtual const bool SetCellAlpha(const int column, const int row, const float alpha) = 0; - virtual const bool SetDefaultCellAlpha(const float alpha) = 0; - - virtual const bool SetColumnWidth(const int column, const float width) = 0; - virtual const bool SetRowHeight(const int row, const float height) = 0; - - virtual const bool SetCellFullSize(const int column, const int row, const bool fullSize) = 0; - virtual const bool SetDefaultCellFullSize(const bool fullSize, const bool updateExisting = false) = 0; - - virtual const bool GetCellFullSize(const int column, const int row) const = 0; - virtual const bool GetDefaultCellFullSize() const = 0; - - virtual const bool SetCellPadding(const int column, const int row, const CVector2D& padding) = 0; - virtual const bool SetDefaultCellPadding(const CVector2D& padding, const bool updateExisting) = 0; - - virtual const CVector2D& GetCellPadding(const int column, const int row) const = 0; - virtual const CVector2D& GetDefaultCellPadding() const = 0; - - virtual const bool SetCellTexture(const int column, const int row, CGUITexture* texture, const bool alt = false) = 0; - virtual const bool SetCellColor(const int column, const int row, const CColor& color, const bool alt = false) = 0; - - virtual const bool SetDefaultCellTexture(CGUITexture* texture, const bool alt = false, const bool updateExisting = false) = 0; - virtual const bool SetDefaultCellColor(const CColor& color, const bool alt = false, const bool updateExisting = false) = 0; -}; diff --git a/Shared/sdk/CColor.h b/Shared/sdk/CColor.h deleted file mode 100644 index 92f506926d..0000000000 --- a/Shared/sdk/CColor.h +++ /dev/null @@ -1,42 +0,0 @@ -/***************************************************************************** - * - * PROJECT: Multi Theft Auto: San Andreas - * LICENSE: See LICENSE in the top level directory - * - * Multi Theft Auto is available from http://www.multitheftauto.com/ - * - *****************************************************************************/ -#pragma once - -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; -};