Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: erase flags and zones #90

Merged
merged 4 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions source/eraser_brush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,23 @@ void EraserBrush::undraw(BaseMap* map, Tile* tile) {

void EraserBrush::draw(BaseMap* map, Tile* tile, void* parameter) {
// Draw is undraw, undraw is super-undraw!
for (ItemVector::iterator item_iter = tile->items.begin(); item_iter != tile->items.end();) {
Item* item = *item_iter;
for (auto itemIter = tile->items.begin(); itemIter != tile->items.end();) {
const auto item = *itemIter;
if ((item->isComplex() || item->isBorder()) && g_settings.getInteger(Config::ERASER_LEAVE_UNIQUE)) {
++item_iter;
++itemIter;
//} else if(item->getDoodadBrush()) {
//++item_iter;
} else {
delete item;
item_iter = tile->items.erase(item_iter);
itemIter = tile->items.erase(itemIter);
}
}

if (tile->hasZone() && !g_settings.getInteger(Config::ERASER_KEEP_ZONES)) {
tile->removeZones();
}

if (!g_settings.getInteger(Config::ERASER_KEEP_MAP_FLAGS)) {
tile->unsetMapFlags(tile->getMapFlags());
}
}
12 changes: 12 additions & 0 deletions source/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,16 @@ wxNotebookPage* PreferencesWindow::CreateEditorPage() {
eraser_leave_unique_chkbox->SetToolTip("The eraser will leave containers with items in them, items with unique or action id and items.");
sizer->Add(eraser_leave_unique_chkbox, 0, wxLEFT | wxTOP, 5);

eraserKeepZonesCheckbox = newd wxCheckBox(editor_page, wxID_ANY, "Eraser keep Zones");
eraserKeepZonesCheckbox->SetValue(g_settings.getBoolean(Config::ERASER_KEEP_ZONES));
eraserKeepZonesCheckbox->SetToolTip("The eraser will keep Zones, will not delete them.");
sizer->Add(eraserKeepZonesCheckbox, 0, wxLEFT | wxTOP, 5);

eraserKeepMapFlagsCheckbox = newd wxCheckBox(editor_page, wxID_ANY, "Eraser keep Map Flags (PZ, NO PVP, PVP and NO LOGOUT)");
eraserKeepMapFlagsCheckbox->SetValue(g_settings.getBoolean(Config::ERASER_KEEP_MAP_FLAGS));
eraserKeepMapFlagsCheckbox->SetToolTip("The eraser will keep map flags, such as PZ, NO PVP, PVP and NO LOGOUT.");
sizer->Add(eraserKeepMapFlagsCheckbox, 0, wxLEFT | wxTOP, 5);

auto_create_spawn_chkbox = newd wxCheckBox(editor_page, wxID_ANY, "Auto create spawn when placing monster");
auto_create_spawn_chkbox->SetValue(g_settings.getBoolean(Config::AUTO_CREATE_SPAWN_MONSTER));
auto_create_spawn_chkbox->SetToolTip("When this option is checked, you can place monsters without placing a spawn manually, the spawn will be place automatically.");
Expand Down Expand Up @@ -619,6 +629,8 @@ void PreferencesWindow::Apply() {
g_settings.setInteger(Config::HOUSE_BRUSH_REMOVE_ITEMS, house_remove_chkbox->GetValue());
g_settings.setInteger(Config::AUTO_ASSIGN_DOORID, auto_assign_doors_chkbox->GetValue());
g_settings.setInteger(Config::ERASER_LEAVE_UNIQUE, eraser_leave_unique_chkbox->GetValue());
g_settings.setInteger(Config::ERASER_KEEP_ZONES, eraserKeepZonesCheckbox->GetValue());
g_settings.setInteger(Config::ERASER_KEEP_MAP_FLAGS, eraserKeepMapFlagsCheckbox->GetValue());
g_settings.setInteger(Config::DOODAD_BRUSH_ERASE_LIKE, doodad_erase_same_chkbox->GetValue());
g_settings.setInteger(Config::AUTO_CREATE_SPAWN_MONSTER, auto_create_spawn_chkbox->GetValue());
g_settings.setInteger(Config::AUTO_CREATE_SPAWN_NPC, auto_create_spawn_npc_chkbox->GetValue());
Expand Down
2 changes: 2 additions & 0 deletions source/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class PreferencesWindow : public wxDialog {
wxCheckBox* house_remove_chkbox;
wxCheckBox* auto_assign_doors_chkbox;
wxCheckBox* eraser_leave_unique_chkbox;
wxCheckBox* eraserKeepZonesCheckbox = nullptr;
wxCheckBox* eraserKeepMapFlagsCheckbox = nullptr;
wxCheckBox* doodad_erase_same_chkbox;
wxCheckBox* auto_create_spawn_chkbox;
wxCheckBox* auto_create_spawn_npc_chkbox;
Expand Down
2 changes: 2 additions & 0 deletions source/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ namespace Config {
HOUSE_BRUSH_REMOVE_ITEMS,
AUTO_ASSIGN_DOORID,
ERASER_LEAVE_UNIQUE,
ERASER_KEEP_ZONES,
ERASER_KEEP_MAP_FLAGS,
DOODAD_BRUSH_ERASE_LIKE,
WARN_FOR_DUPLICATE_ID,
USE_UPDATER,
Expand Down
8 changes: 8 additions & 0 deletions source/tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ class Tile {
void unsetStatFlags(uint16_t flags);
uint16_t getStatFlags() const noexcept;

bool hasZone() const {
return !zones.empty();
}

bool hasZone(unsigned int zone) const {
return zones.find(zone) != zones.end();
}
Expand All @@ -276,6 +280,10 @@ class Tile {
zones.erase(zone);
}

void removeZones() {
zones.clear();
}

protected:
union {
struct {
Expand Down
Loading