diff --git a/source/palette_brushlist.cpp b/source/palette_brushlist.cpp index d8244c81..51c219bc 100644 --- a/source/palette_brushlist.cpp +++ b/source/palette_brushlist.cpp @@ -31,6 +31,8 @@ BEGIN_EVENT_TABLE(BrushPalettePanel, PalettePanel) EVT_BUTTON(wxID_ADD, BrushPalettePanel::OnClickAddItemToTileset) EVT_BUTTON(wxID_NEW, BrushPalettePanel::OnClickAddTileset) +EVT_BUTTON(wxID_FORWARD, BrushPalettePanel::OnNextPage) +EVT_BUTTON(wxID_BACKWARD, BrushPalettePanel::OnPreviousPage) EVT_CHOICEBOOK_PAGE_CHANGING(wxID_ANY, BrushPalettePanel::OnSwitchingPage) EVT_CHOICEBOOK_PAGE_CHANGED(wxID_ANY, BrushPalettePanel::OnPageChanged) END_EVENT_TABLE() @@ -38,18 +40,19 @@ END_EVENT_TABLE() BrushPalettePanel::BrushPalettePanel(wxWindow* parent, const TilesetContainer &tilesets, TilesetCategoryType category, wxWindowID id) : PalettePanel(parent, id), paletteType(category) { - const auto topsizer = newd wxBoxSizer(wxVERTICAL); // Create the tileset panel const auto tsSizer = newd wxStaticBoxSizer(wxVERTICAL, this, "Tileset"); choicebook = newd wxChoicebook(this, wxID_ANY, wxDefaultPosition, wxSize(180, 250)); tsSizer->Add(choicebook, 1, wxEXPAND); - topsizer->Add(tsSizer, 1, wxEXPAND); + sizer->Add(tsSizer, 1, wxEXPAND); if (g_settings.getBoolean(Config::SHOW_TILESET_EDITOR)) { - AddTilesetEditor(topsizer); + AddTilesetEditor(); } + sizer->Add(pageInfoSizer); + for (auto it = tilesets.begin(); it != tilesets.end(); ++it) { const auto tilesetCategory = it->second->getCategory(category); if (tilesetCategory && !tilesetCategory->brushlist.empty()) { @@ -58,10 +61,57 @@ BrushPalettePanel::BrushPalettePanel(wxWindow* parent, const TilesetContainer &t } } - SetSizerAndFit(topsizer); + SetSizerAndFit(sizer); +} + +BrushPalettePanel::~BrushPalettePanel() { + if (currentPageCtrl) { + currentPageCtrl->Unbind(wxEVT_SET_FOCUS, &BrushPalettePanel::OnSetFocus, this); + currentPageCtrl->Unbind(wxEVT_KILL_FOCUS, &BrushPalettePanel::OnKillFocus, this); + currentPageCtrl->Unbind(wxEVT_TEXT_ENTER, &BrushPalettePanel::OnSetPage, this); + } +} + +void BrushPalettePanel::OnSetFocus(wxFocusEvent &event) { + g_gui.DisableHotkeys(); + event.Skip(); +} + +void BrushPalettePanel::OnKillFocus(wxFocusEvent &event) { + g_gui.EnableHotkeys(); + event.Skip(); +} + +void BrushPalettePanel::RemovePagination() { + pageInfoSizer->ShowItems(false); + pageInfoSizer->Clear(); +} + +void BrushPalettePanel::AddPagination() { + RemovePagination(); + + const auto buttonsSize = wxSize(55, 25); + const auto middleElementsSize = wxSize(35, 25); + + nextPageButton = newd wxButton(this, wxID_FORWARD, "->", wxDefaultPosition, buttonsSize); + currentPageCtrl = newd wxTextCtrl(this, wxID_ANY, "1", wxDefaultPosition, middleElementsSize, wxTE_PROCESS_ENTER, wxTextValidator(wxFILTER_DIGITS)); + pageInfo = newd wxStaticText(this, wxID_ANY, "/x", wxPoint(0, 5), middleElementsSize); + previousPageButton = newd wxButton(this, wxID_BACKWARD, "<-", wxDefaultPosition, buttonsSize); + + currentPageCtrl->Bind(wxEVT_SET_FOCUS, &BrushPalettePanel::OnSetFocus, this); + currentPageCtrl->Bind(wxEVT_KILL_FOCUS, &BrushPalettePanel::OnKillFocus, this); + currentPageCtrl->Bind(wxEVT_TEXT_ENTER, &BrushPalettePanel::OnSetPage, this); + + pageInfoSizer->Add(previousPageButton, wxEXPAND); + pageInfoSizer->AddSpacer(15); + pageInfoSizer->Add(currentPageCtrl); + pageInfoSizer->AddSpacer(5); + pageInfoSizer->Add(pageInfo); + pageInfoSizer->AddSpacer(15); + pageInfoSizer->Add(nextPageButton, wxEXPAND); } -void BrushPalettePanel::AddTilesetEditor(wxSizer* sizer) { +void BrushPalettePanel::AddTilesetEditor() { const auto tmpsizer = newd wxBoxSizer(wxHORIZONTAL); const auto buttonAddTileset = newd wxButton(this, wxID_NEW, "Add new Tileset"); tmpsizer->Add(buttonAddTileset, wxSizerFlags(0).Center()); @@ -101,24 +151,45 @@ PaletteType BrushPalettePanel::GetType() const { return paletteType; } -void BrushPalettePanel::SetListType(BrushListType newListType) const { +BrushListType BrushPalettePanel::GetListType() const { + if (!choicebook) { + return BRUSHLIST_LISTBOX; + } + + const auto panel = dynamic_cast(choicebook->GetPage(0)); + return panel->GetListType(); +} + +void BrushPalettePanel::SetListType(BrushListType newListType) { if (!choicebook) { return; } + + RemovePagination(); + + if (newListType == BRUSHLIST_SMALL_ICONS || newListType == BRUSHLIST_LARGE_ICONS) { + AddPagination(); + } + for (auto pageIndex = 0; pageIndex < choicebook->GetPageCount(); ++pageIndex) { const auto panel = dynamic_cast(choicebook->GetPage(pageIndex)); panel->SetListType(newListType); } } -void BrushPalettePanel::SetListType(const wxString &newListType) const { +void BrushPalettePanel::SetListType(const wxString &newListType) { if (!choicebook) { return; } - for (auto pageIndex = 0; pageIndex < choicebook->GetPageCount(); ++pageIndex) { - const auto panel = dynamic_cast(choicebook->GetPage(pageIndex)); - panel->SetListType(newListType); + + const auto it = listTypeMap.find(newListType); + if (it == listTypeMap.end()) { + return; } + + const auto newListTypeEnum = (*it).second; + + SetListType(newListTypeEnum); } Brush* BrushPalettePanel::GetSelectedBrush() const { @@ -209,6 +280,13 @@ void BrushPalettePanel::OnSwitchingPage(wxChoicebookEvent &event) { const auto panel = dynamic_cast(page); if (panel) { panel->OnSwitchIn(); + const auto &brushbox = panel->GetBrushBox(); + const auto currentPage = brushbox->GetCurrentPage(); + const auto totalPages = brushbox->GetTotalPages(); + SetPageInfo(wxString::Format("/%d", totalPages)); + SetCurrentPage(wxString::Format("%d", currentPage)); + EnableNextPage(totalPages > currentPage); + EnablePreviousPage(currentPage > 1); for (const auto palettePanel : tool_bars) { palettePanel->SelectBrush(rememberedBrushes[panel]); } @@ -264,6 +342,82 @@ void BrushPalettePanel::OnClickAddItemToTileset(wxCommandEvent &WXUNUSED(event)) } } +void BrushPalettePanel::OnPageUpdate(BrushBoxInterface* brushbox, int page) { + if (brushbox->SetPage(page)) { + const auto currentPage = brushbox->GetCurrentPage(); + const auto totalPages = brushbox->GetTotalPages(); + currentPageCtrl->SetValue(wxString::Format("%d", currentPage)); + Fit(); + g_gui.aui_manager->Update(); + brushbox->SelectFirstBrush(); + nextPageButton->Enable(totalPages > currentPage); + previousPageButton->Enable(currentPage > 1); + } +} + +void BrushPalettePanel::OnSetPage(wxCommandEvent &WXUNUSED(event)) { + const auto &brushPanel = dynamic_cast(choicebook->GetCurrentPage()); + if (!brushPanel) { + return; + } + + const auto &brushbox = brushPanel->GetBrushBox(); + + int page; + if (!currentPageCtrl->GetValue().ToInt(&page)) { + return; + } + + if (page > brushbox->GetTotalPages() || page < 1) { + return; + } + + OnPageUpdate(brushbox, page); +} + +void BrushPalettePanel::OnNextPage(wxCommandEvent &WXUNUSED(event)) { + const auto &brushPanel = dynamic_cast(choicebook->GetCurrentPage()); + if (brushPanel) { + const auto &brushbox = brushPanel->GetBrushBox(); + OnPageUpdate(brushbox, brushbox->GetCurrentPage() + 1); + } +} +void BrushPalettePanel::OnPreviousPage(wxCommandEvent &WXUNUSED(event)) { + const auto &brushPanel = dynamic_cast(choicebook->GetCurrentPage()); + if (brushPanel) { + const auto &brushbox = brushPanel->GetBrushBox(); + OnPageUpdate(brushbox, brushbox->GetCurrentPage() - 1); + } +} + +void BrushPalettePanel::EnableNextPage(bool enable /* = true*/) { + if (!nextPageButton) { + return; + } + nextPageButton->Enable(enable); +} + +void BrushPalettePanel::EnablePreviousPage(bool enable /* = true*/) { + if (!previousPageButton) { + return; + } + previousPageButton->Enable(enable); +} + +void BrushPalettePanel::SetPageInfo(const wxString &text) { + if (!pageInfo) { + return; + } + pageInfo->SetLabelText(text); +} + +void BrushPalettePanel::SetCurrentPage(const wxString &value) { + if (!currentPageCtrl) { + return; + } + currentPageCtrl->SetValue(value); +} + // ============================================================================ // Brush Panel // A container of brush buttons @@ -285,6 +439,10 @@ void BrushPanel::AssignTileset(const TilesetCategory* newTileset) { } } +BrushListType BrushPanel::GetListType() const { + return listType; +} + void BrushPanel::SetListType(BrushListType newListType) { if (listType != newListType) { InvalidateContents(); @@ -387,6 +545,10 @@ void BrushPanel::OnClickListBoxRow(wxCommandEvent &event) { g_gui.SelectBrush(tileset->brushlist[index], tileset->getType()); } +BrushBoxInterface* BrushPanel::GetBrushBox() const { + return brushbox; +} + // ============================================================================ // BrushIconBox @@ -400,31 +562,70 @@ BrushIconBox::BrushIconBox(wxWindow* parent, const TilesetCategory* tileset, Ren BrushBoxInterface(tileset), iconSize(rsz) { ASSERT(tileset->getType() >= TILESET_UNKNOWN && tileset->getType() <= TILESET_HOUSE); - const auto width = iconSize == RENDER_SIZE_32x32 ? std::max(g_settings.getInteger(Config::PALETTE_COL_COUNT) / 2 + 1, 1) : std::max(g_settings.getInteger(Config::PALETTE_COL_COUNT) + 1, 1); + width = iconSize == RENDER_SIZE_32x32 ? std::max(g_settings.getInteger(Config::PALETTE_COL_COUNT) / 2 + 1, 1) : std::max(g_settings.getInteger(Config::PALETTE_COL_COUNT) + 1, 1); + height = iconSize == RENDER_SIZE_32x32 ? std::max(g_settings.getInteger(Config::PALETTE_ROW_COUNT) / 2 + 1, 1) : std::max(g_settings.getInteger(Config::PALETTE_ROW_COUNT) + 1, 1); + + const auto totalItems = (width * height); + totalPages = (tileset->brushlist.size() / totalItems) + 1; + + SetScrollbars(20, 20, 8, 0, 0, 0, false); + + brushButtons.reserve(totalItems); + + LoadContentByPage(); + + const auto &brushPalettePanel = g_gui.GetParentWindowByType(this); + brushPalettePanel->SetPageInfo(wxString::Format("/%d", totalPages)); + brushPalettePanel->EnableNextPage(totalPages > currentPage); + brushPalettePanel->EnablePreviousPage(currentPage > 1); +} + +bool BrushIconBox::LoadContentByPage(int page /* = 1 */) { + if (page <= 0 || page > totalPages) { + return false; + } + + currentPage = page; + + const auto startOffset = (width * height) * (page - 1); + auto endOffset = (width * height) * page; + endOffset = page > 1 ? endOffset : startOffset + endOffset; + endOffset = endOffset > tileset->brushlist.size() ? tileset->brushlist.size() : endOffset; + + if (stacksizer) { + stacksizer->ShowItems(false); + stacksizer->Clear(); + rowsizers.clear(); + brushButtons.clear(); + } - // Create buttons stacksizer = newd wxBoxSizer(wxVERTICAL); SetSizer(stacksizer); - SetScrollbars(20, 20, 8, tileset->brushlist.size() / width, 0, 0, false); + auto rowSizer = newd wxBoxSizer(wxHORIZONTAL); - auto rowsizer = newd wxBoxSizer(wxHORIZONTAL); - - for (const auto brush : tileset->brushlist) { - const auto brushButton = newd BrushButton(this, brush, rsz); - rowsizer->Add(brushButton); + for (auto i = startOffset; i < endOffset; ++i) { + const auto brushButton = newd BrushButton(this, tileset->brushlist[i], iconSize); brushButtons.emplace_back(brushButton); + rowSizer->Add(brushButton); - if (brushButtons.size() % width == 0) { // new row - stacksizer->Add(rowsizer); - rowsizers.emplace_back(rowsizer); - rowsizer = newd wxBoxSizer(wxHORIZONTAL); + if (brushButtons.size() % width == 0) { + stacksizer->Add(rowSizer); + rowsizers.emplace_back(rowSizer); + rowSizer = newd wxBoxSizer(wxHORIZONTAL); } } - if (rowsizers.size() <= 0 || rowsizer != rowsizers.back()) { - stacksizer->Add(rowsizer); + if (rowsizers.size() <= 0 || rowSizer != rowsizers.back()) { + stacksizer->Add(rowSizer); + rowsizers.emplace_back(rowSizer); + } + + if (!stacksizer->AreAnyItemsShown()) { + stacksizer->ShowItems(true); } + + return true; } void BrushIconBox::SelectFirstBrush() { @@ -441,6 +642,30 @@ Brush* BrushIconBox::GetSelectedBrush() const { return selectedButton ? selectedButton->brush : nullptr; } +bool BrushIconBox::SelectPaginatedBrush(const Brush* whatBrush, BrushPalettePanel* brushPalettePanel) { + const auto index = std::ranges::find(tileset->brushlist.begin(), tileset->brushlist.end(), whatBrush) - tileset->brushlist.begin(); + + if (index < tileset->brushlist.size()) { + const auto page = std::ceil(index / (width * height)) + 1; + if (currentPage != page) { + brushPalettePanel->OnPageUpdate(this, page); + } + + const auto it = std::ranges::find_if(brushButtons, [&](const auto &brushButton) { + return brushButton->brush == whatBrush; + }); + + if (it != brushButtons.end()) { + Select(*it); + return true; + } + + return false; + } + + return false; +} + bool BrushIconBox::SelectBrush(const Brush* whatBrush) { Deselect(); @@ -448,7 +673,13 @@ bool BrushIconBox::SelectBrush(const Brush* whatBrush) { return false; } - const auto it = std::ranges::find_if(brushButtons.begin(), brushButtons.end(), [&](const auto brushButton) { + const auto &brushPalettePanel = g_gui.GetParentWindowByType(GetSelfWindow()); + const auto listType = brushPalettePanel->GetListType(); + if (listType == BRUSHLIST_LARGE_ICONS || listType == BRUSHLIST_SMALL_ICONS) { + return SelectPaginatedBrush(whatBrush, brushPalettePanel); + } + + const auto it = std::ranges::find_if(brushButtons, [&](const auto &brushButton) { return brushButton->brush == whatBrush; }); @@ -460,6 +691,18 @@ bool BrushIconBox::SelectBrush(const Brush* whatBrush) { return false; } +bool BrushIconBox::NextPage() { + return LoadContentByPage(currentPage + 1); +} + +bool BrushIconBox::SetPage(int page) { + return LoadContentByPage(page); +} + +bool BrushIconBox::PreviousPage() { + return LoadContentByPage(currentPage - 1); +} + void BrushIconBox::Select(BrushButton* brushButton) { Deselect(); selectedButton = brushButton; @@ -544,6 +787,10 @@ Brush* BrushListBox::GetSelectedBrush() const { return nullptr; } +bool BrushListBox::SelectPaginatedBrush(const Brush* whatBrush, BrushPalettePanel* brushPalettePanel) noexcept { + return false; +} + bool BrushListBox::SelectBrush(const Brush* whatBrush) { for (auto index = 0; index < tileset->brushlist.size(); ++index) { if (tileset->brushlist[index] == whatBrush) { diff --git a/source/palette_brushlist.h b/source/palette_brushlist.h index 99fb57bf..7e2d9c2d 100644 --- a/source/palette_brushlist.h +++ b/source/palette_brushlist.h @@ -50,11 +50,26 @@ class BrushBoxInterface { // Returns the currently selected brush (First brush if panel is not loaded) virtual Brush* GetSelectedBrush() const = 0; // Select the brush in the parameter, this only changes the look of the panel + virtual bool SelectPaginatedBrush(const Brush* brush, BrushPalettePanel* brushPalettePanel) = 0; virtual bool SelectBrush(const Brush* brush) = 0; + virtual bool NextPage() = 0; + virtual bool SetPage(int page) = 0; + virtual bool PreviousPage() = 0; + + virtual int GetCurrentPage() { + return currentPage; + } + + virtual int GetTotalPages() { + return totalPages; + } + protected: const TilesetCategory* const tileset; bool loaded = false; + int currentPage = 1; + int totalPages = 1; }; class BrushListBox : public wxVListBox, public BrushBoxInterface { @@ -71,8 +86,21 @@ class BrushListBox : public wxVListBox, public BrushBoxInterface { // Returns the currently selected brush (First brush if panel is not loaded) Brush* GetSelectedBrush() const; // Select the brush in the parameter, this only changes the look of the panel + bool SelectPaginatedBrush(const Brush* whatBrush, BrushPalettePanel* brushPalettePanel) noexcept override; bool SelectBrush(const Brush* whatBrush) override; + bool NextPage() override { + return false; + }; + + bool SetPage(int page) override { + return false; + }; + + bool PreviousPage() override { + return false; + }; + // Event handlers void OnDrawItem(wxDC &dc, const wxRect &rect, size_t index) const override; wxCoord OnMeasureItem(size_t index) const override; @@ -94,13 +122,20 @@ class BrushIconBox : public wxScrolledWindow, public BrushBoxInterface { // Scrolls the window to the position of the named brush button void EnsureVisible(const BrushButton* brushButto); + bool LoadContentByPage(int page = 1); + // Select the first brush void SelectFirstBrush(); // Returns the currently selected brush (First brush if panel is not loaded) Brush* GetSelectedBrush() const; // Select the brush in the parameter, this only changes the look of the panel + bool SelectPaginatedBrush(const Brush* whatBrush, BrushPalettePanel* brushPalettePanel) override; bool SelectBrush(const Brush* whatBrush) override; + bool NextPage() override; + bool SetPage(int page) override; + bool PreviousPage() override; + // Event handling... void OnClickBrushButton(wxCommandEvent &event); @@ -110,12 +145,15 @@ class BrushIconBox : public wxScrolledWindow, public BrushBoxInterface { // Used internally to deselect a button before selecting a new one. void Deselect(); + int width = 0; + int height = 0; + BrushButton* selectedButton = nullptr; std::vector brushButtons; RenderSize iconSize; wxBoxSizer* stacksizer = nullptr; - std::vector rowsizers; + std::vector rowsizers; DECLARE_EVENT_TABLE(); }; @@ -137,6 +175,8 @@ class BrushPanel : public wxPanel { // Loads the content (This must be called before the panel is displayed, else it will appear empty void LoadContents(); + BrushListType GetListType() const; + // Sets the display type (list or icons) void SetListType(BrushListType newListType); void SetListType(const wxString &newListType); @@ -158,6 +198,8 @@ class BrushPanel : public wxPanel { // wxWidgets event handlers void OnClickListBoxRow(wxCommandEvent &event); + [[nodiscard]] BrushBoxInterface* GetBrushBox() const; + protected: const TilesetCategory* tileset; wxSizer* sizer = newd wxBoxSizer(wxVERTICAL); @@ -171,9 +213,11 @@ class BrushPanel : public wxPanel { class BrushPalettePanel : public PalettePanel { public: BrushPalettePanel(wxWindow* parent, const TilesetContainer &tilesets, TilesetCategoryType category, wxWindowID id = wxID_ANY); - ~BrushPalettePanel() final = default; + ~BrushPalettePanel(); - void AddTilesetEditor(wxSizer* sizer); + void RemovePagination(); + void AddPagination(); + void AddTilesetEditor(); // Interface // Flushes this panel and consequent views will feature reloaded data @@ -184,10 +228,11 @@ class BrushPalettePanel : public PalettePanel { void LoadAllContents(); PaletteType GetType() const; + BrushListType GetListType() const; // Sets the display type (list or icons) - void SetListType(BrushListType newListType) const; - void SetListType(const wxString &newListType) const; + void SetListType(BrushListType newListType); + void SetListType(const wxString &newListType); // Select the first brush void SelectFirstBrush(); @@ -205,9 +250,28 @@ class BrushPalettePanel : public PalettePanel { void OnClickAddTileset(wxCommandEvent &WXUNUSED(event)); void OnClickAddItemToTileset(wxCommandEvent &WXUNUSED(event)); + void OnSetFocus(wxFocusEvent &event); + void OnKillFocus(wxFocusEvent &event); + + void OnPageUpdate(BrushBoxInterface* brushbox, int page); + void OnSetPage(wxCommandEvent &WXUNUSED(event)); + void OnNextPage(wxCommandEvent &WXUNUSED(event)); + void OnPreviousPage(wxCommandEvent &WXUNUSED(event)); + + void EnableNextPage(bool enable = true); + void EnablePreviousPage(bool enable = true); + void SetPageInfo(const wxString &text); + void SetCurrentPage(const wxString &text); + protected: + wxSizer* sizer = newd wxBoxSizer(wxVERTICAL); + wxSizer* pageInfoSizer = newd wxFlexGridSizer(7, 1, 1); PaletteType paletteType; wxChoicebook* choicebook = nullptr; + wxButton* nextPageButton = nullptr; + wxButton* previousPageButton = nullptr; + wxTextCtrl* currentPageCtrl = nullptr; + wxStaticText* pageInfo = nullptr; BrushSizePanel* sizePanel = nullptr; std::map rememberedBrushes; diff --git a/source/preferences.cpp b/source/preferences.cpp index 8b4c8b94..eedace17 100644 --- a/source/preferences.cpp +++ b/source/preferences.cpp @@ -265,6 +265,18 @@ wxNotebookPage* PreferencesWindow::CreateGraphicsPage() { auto* subsizer = newd wxFlexGridSizer(2, 10, 10); subsizer->AddGrowableCol(1); + palette_icons_col_size = newd wxTextCtrl(graphics_page, wxID_ANY, wxString::Format("%d", g_settings.getInteger(Config::PALETTE_COL_COUNT)), wxDefaultPosition, wxDefaultSize, 0, wxTextValidator(wxFILTER_DIGITS)); + palette_icons_col_size->SetMaxLength(2); + subsizer->Add(tmp = newd wxStaticText(graphics_page, wxID_ANY, "Icons column size: "), 0); + subsizer->Add(palette_icons_col_size, 0); + SetWindowToolTip(palette_icons_col_size, tmp, "This will set the column size of the palette when using SMALL ICONS and LARGE ICONS will be the value divided by 2. The max columns are 99."); + + palette_icons_row_size = newd wxTextCtrl(graphics_page, wxID_ANY, wxString::Format("%d", g_settings.getInteger(Config::PALETTE_ROW_COUNT)), wxDefaultPosition, wxDefaultSize, 0, wxTextValidator(wxFILTER_DIGITS)); + palette_icons_row_size->SetMaxLength(2); + subsizer->Add(tmp = newd wxStaticText(graphics_page, wxID_ANY, "Icons row size: "), 0); + subsizer->Add(palette_icons_row_size, 0); + SetWindowToolTip(palette_icons_row_size, tmp, "This will set the row size of the palette when using SMALL ICONS and LARGE ICONS will be the value divided by 2. The max rows are 99."); + // Icon background color icon_background_choice = newd wxChoice(graphics_page, wxID_ANY); icon_background_choice->Append("Black background"); @@ -649,6 +661,14 @@ void PreferencesWindow::Apply() { if (g_settings.getBoolean(Config::USE_MEMCACHED_SPRITES) != use_memcached_chkbox->GetValue()) { must_restart = true; } + if (int iconsColSize; palette_icons_col_size->GetValue().ToInt(&iconsColSize) && g_settings.getInteger(Config::PALETTE_COL_COUNT) != iconsColSize) { + g_settings.setInteger(Config::PALETTE_COL_COUNT, iconsColSize); + must_restart = true; + } + if (int iconsRowSize; palette_icons_row_size->GetValue().ToInt(&iconsRowSize) && g_settings.getInteger(Config::PALETTE_ROW_COUNT) != iconsRowSize) { + g_settings.setInteger(Config::PALETTE_ROW_COUNT, iconsRowSize); + must_restart = true; + } g_settings.setInteger(Config::USE_MEMCACHED_SPRITES_TO_SAVE, use_memcached_chkbox->GetValue()); if (icon_background_choice->GetSelection() == 0) { if (g_settings.getInteger(Config::ICON_BACKGROUND) != 0) { diff --git a/source/preferences.h b/source/preferences.h index 541b1466..5d687f29 100644 --- a/source/preferences.h +++ b/source/preferences.h @@ -74,6 +74,8 @@ class PreferencesWindow : public wxDialog { wxCheckBox* icon_selection_shadow_chkbox; wxChoice* icon_background_choice; wxCheckBox* use_memcached_chkbox; + wxTextCtrl* palette_icons_col_size; + wxTextCtrl* palette_icons_row_size; wxDirPickerCtrl* screenshot_directory_picker; wxChoice* screenshot_format_choice; wxCheckBox* hide_items_when_zoomed_chkbox; diff --git a/source/settings.cpp b/source/settings.cpp index 0f7cd209..4e6659e8 100644 --- a/source/settings.cpp +++ b/source/settings.cpp @@ -313,6 +313,7 @@ void Settings::IO(IOMode mode) { Int(USE_LARGE_RAW_SIZEBAR, 1); Int(USE_GUI_SELECTION_SHADOW, 0); Int(PALETTE_COL_COUNT, 8); + Int(PALETTE_ROW_COUNT, 30); String(PALETTE_TERRAIN_STYLE, "large icons"); String(PALETTE_DOODAD_STYLE, "large icons"); String(PALETTE_ITEM_STYLE, "listbox"); diff --git a/source/settings.h b/source/settings.h index 80b9889e..8722a95f 100644 --- a/source/settings.h +++ b/source/settings.h @@ -106,6 +106,7 @@ namespace Config { USE_LARGE_RAW_SIZEBAR, USE_GUI_SELECTION_SHADOW, PALETTE_COL_COUNT, + PALETTE_ROW_COUNT, PALETTE_TERRAIN_STYLE, PALETTE_DOODAD_STYLE, PALETTE_ITEM_STYLE,