tibia-rme/source/materials.h
Victor ce8d5093ee
feat: add SQLite materials backend with XML import pipeline, schema migrations, and inspection tools (#183)
New Features:
- Added "SQLite Materials Inspector" to the Window menu — a read-only multi-tab viewer for summary stats, brushes by type, and tilesets with reload and detail panes.
- Background initialization and async bootstrap/import of the materials database to avoid blocking the UI; startup/shutdown now synchronize to prevent concurrent access.

Chores:
- New runtime option to enable the SQLite materials backend and control migration/bootstrap behavior (default enabled).
2026-05-22 19:41:30 -03:00

70 lines
2.6 KiB
C++

//////////////////////////////////////////////////////////////////////
// This file is part of Remere's Map Editor
//////////////////////////////////////////////////////////////////////
// Remere's Map Editor is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Remere's Map Editor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//////////////////////////////////////////////////////////////////////
#ifndef RME_MATERIALS_H_
#define RME_MATERIALS_H_
#include "tileset.h"
using TilesetContainer = std::map<std::string, Tileset*>;
class Materials {
public:
Materials();
~Materials();
void clear();
bool initializeBrushDatabase(wxArrayString &warnings);
bool shouldSkipSqliteBootstrapImports(bool &outSkip, wxString &reason);
bool bootstrapSqliteDatabase(wxString &error, wxArrayString &warnings);
bool migrateSingleBrushToSQLite(const FileName &identifier, const wxString &brushName, wxString &error, wxArrayString &warnings);
bool migrateGroundsToSQLite(wxString &error, wxArrayString &warnings);
bool migrateWallsToSQLite(wxString &error, wxArrayString &warnings);
bool migrateDecorativeBrushesToSQLite(wxString &error, wxArrayString &warnings);
bool migrateTilesetsToSQLite(wxString &error, wxArrayString &warnings);
TilesetContainer tilesets;
bool loadMaterials(const FileName &identifier, wxString &error, wxArrayString &warnings);
void createOtherTileset();
void addToTileset(std::string tilesetName, int itemId, TilesetCategoryType categoryType);
void createNpcTileset();
bool isInTileset(Item* item, std::string tileset) const;
bool isInTileset(Brush* brush, std::string tileset) const;
bool needSave() const {
return modified;
}
void modify(bool newValue = true) {
this->modified = newValue;
}
protected:
bool unserializeMaterials(const FileName &filename, pugi::xml_node node, wxString &error, wxArrayString &warnings);
bool unserializeTileset(pugi::xml_node node, wxArrayString &warnings);
private:
void populateRawBrushes(Tileset* others);
bool modified = false;
Materials(const Materials &);
Materials &operator=(const Materials &);
};
extern Materials g_materials;
#endif