Skip to content

Commit

Permalink
Added search by 'floor change' property in the FindItemDialog.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mignari committed Oct 23, 2018
1 parent 7e4388c commit 96b65a3
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 15 deletions.
36 changes: 22 additions & 14 deletions source/find_item_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ FindItemDialog::FindItemDialog(wxWindow* parent, const wxString& title, bool onl
ignore_look = newd wxCheckBox(properties_box_sizer->GetStaticBox(), wxID_ANY, "Ignore Look", wxDefaultPosition, wxDefaultSize, 0);
properties_box_sizer->Add(ignore_look, 0, wxALL, 5);

floor_change = newd wxCheckBox(properties_box_sizer->GetStaticBox(), wxID_ANY, "Floor Change", wxDefaultPosition, wxDefaultSize, 0);
properties_box_sizer->Add(floor_change, 0, wxALL, 5);

box_sizer->Add(properties_box_sizer, 1, wxALL | wxEXPAND, 5);

// --------------- Items list ---------------
Expand Down Expand Up @@ -191,6 +194,7 @@ FindItemDialog::FindItemDialog(wxWindow* parent, const wxString& title, bool onl
hook_south->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
has_elevation->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
ignore_look->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
floor_change->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
}

FindItemDialog::~FindItemDialog()
Expand Down Expand Up @@ -219,6 +223,7 @@ FindItemDialog::~FindItemDialog()
hook_south->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
has_elevation->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
ignore_look->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
floor_change->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
}

FindItemDialog::SearchMode FindItemDialog::getSearchMode() const
Expand Down Expand Up @@ -265,6 +270,7 @@ void FindItemDialog::EnableProperties(bool enable)
hook_south->Enable(enable);
has_elevation->Enable(enable);
ignore_look->Enable(enable);
floor_change->Enable(enable);
}

void FindItemDialog::RefreshContentsInternal()
Expand Down Expand Up @@ -353,19 +359,20 @@ void FindItemDialog::RefreshContentsInternal()
}
else if(selection == SearchMode::Properties) {
bool has_selected = (unpassable->GetValue() ||
unmovable->GetValue() ||
block_missiles->GetValue() ||
block_pathfinder->GetValue() ||
readable->GetValue() ||
writeable->GetValue() ||
pickupable->GetValue() ||
stackable->GetValue() ||
rotatable->GetValue() ||
hangable->GetValue() ||
hook_east->GetValue() ||
hook_south->GetValue() ||
has_elevation->GetValue() ||
ignore_look->GetValue());
unmovable->GetValue() ||
block_missiles->GetValue() ||
block_pathfinder->GetValue() ||
readable->GetValue() ||
writeable->GetValue() ||
pickupable->GetValue() ||
stackable->GetValue() ||
rotatable->GetValue() ||
hangable->GetValue() ||
hook_east->GetValue() ||
hook_south->GetValue() ||
has_elevation->GetValue() ||
ignore_look->GetValue() ||
floor_change->GetValue());

if(has_selected) {
for(int id = 100; id <= g_items.getMaxID(); ++id) {
Expand All @@ -390,7 +397,8 @@ void FindItemDialog::RefreshContentsInternal()
(hook_east->GetValue() && !item.hookEast) ||
(hook_south->GetValue() && !item.hookSouth) ||
(has_elevation->GetValue() && !item.hasElevation) ||
(ignore_look->GetValue() && !item.ignoreLook)) {
(ignore_look->GetValue() && !item.ignoreLook) ||
(floor_change->GetValue() && !item.isFloorChange())) {
continue;
}

Expand Down
1 change: 1 addition & 0 deletions source/find_item_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class FindItemDialog : public wxDialog
wxCheckBox* hook_south;
wxCheckBox* has_elevation;
wxCheckBox* ignore_look;
wxCheckBox* floor_change;

FindDialogListBox* items_list;
wxStdDialogButtonSizer* buttons_box_sizer;
Expand Down
42 changes: 41 additions & 1 deletion source/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@ ItemType::ItemType() :
isTable(false),
isCarpet(false),

floorChangeDown(true),
floorChangeDown(false),
floorChangeNorth(false),
floorChangeSouth(false),
floorChangeEast(false),
floorChangeWest(false),
floorChange(false),

unpassable(false),
blockPickupable(false),
Expand All @@ -103,6 +104,11 @@ ItemType::~ItemType()
////
}

bool ItemType::isFloorChange() const
{
return floorChange || floorChangeDown || floorChangeNorth || floorChangeSouth || floorChangeEast || floorChangeWest;
}

ItemDatabase::ItemDatabase() :
// Version information
MajorVersion(0),
Expand Down Expand Up @@ -188,6 +194,7 @@ bool ItemDatabase::loadFromOtbVer1(BinaryNode* itemNode, wxString& error, wxArra
t->floorChangeEast = ((flags & FLAG_FLOORCHANGEEAST) == FLAG_FLOORCHANGEEAST);
t->floorChangeSouth = ((flags & FLAG_FLOORCHANGESOUTH) == FLAG_FLOORCHANGESOUTH);
t->floorChangeWest = ((flags & FLAG_FLOORCHANGEWEST) == FLAG_FLOORCHANGEWEST);
t->floorChange = t->floorChangeDown || t->floorChangeNorth || t->floorChangeEast || t->floorChangeSouth || t->floorChangeWest;
// Now this is confusing, just accept that the ALWAYSONTOP flag means it's always on bottom, got it?!
t->alwaysOnBottom = ((flags & FLAG_ALWAYSONTOP) == FLAG_ALWAYSONTOP);
t->isHangable = ((flags & FLAG_HANGABLE) == FLAG_HANGABLE);
Expand Down Expand Up @@ -440,6 +447,7 @@ bool ItemDatabase::loadFromOtbVer2(BinaryNode* itemNode, wxString& error, wxArra
t->floorChangeEast = ((flags & FLAG_FLOORCHANGEEAST) == FLAG_FLOORCHANGEEAST);
t->floorChangeSouth = ((flags & FLAG_FLOORCHANGESOUTH) == FLAG_FLOORCHANGESOUTH);
t->floorChangeWest = ((flags & FLAG_FLOORCHANGEWEST) == FLAG_FLOORCHANGEWEST);
t->floorChange = t->floorChangeDown || t->floorChangeNorth || t->floorChangeEast || t->floorChangeSouth || t->floorChangeWest;
// Now this is confusing, just accept that the ALWAYSONTOP flag means it's always on bottom, got it?!
t->alwaysOnBottom = ((flags & FLAG_ALWAYSONTOP) == FLAG_ALWAYSONTOP);
t->isHangable = ((flags & FLAG_HANGABLE) == FLAG_HANGABLE);
Expand Down Expand Up @@ -587,6 +595,7 @@ bool ItemDatabase::loadFromOtbVer3(BinaryNode* itemNode, wxString& error, wxArra
t->floorChangeEast = ((flags & FLAG_FLOORCHANGEEAST) == FLAG_FLOORCHANGEEAST);
t->floorChangeSouth = ((flags & FLAG_FLOORCHANGESOUTH) == FLAG_FLOORCHANGESOUTH);
t->floorChangeWest = ((flags & FLAG_FLOORCHANGEWEST) == FLAG_FLOORCHANGEWEST);
t->floorChange = t->floorChangeDown || t->floorChangeNorth || t->floorChangeEast || t->floorChangeSouth || t->floorChangeWest;
// Now this is confusing, just accept that the ALWAYSONTOP flag means it's always on bottom, got it?!
t->alwaysOnBottom = ((flags & FLAG_ALWAYSONTOP) == FLAG_ALWAYSONTOP);
t->isHangable = ((flags & FLAG_HANGABLE) == FLAG_HANGABLE);
Expand Down Expand Up @@ -868,6 +877,37 @@ bool ItemDatabase::loadItemFromGameXml(pugi::xml_node itemNode, int id)
it.charges = pugi::cast<int32_t>(attribute.value());
it.extra_chargeable = true;
}
} else if(key == "floorchange") {
if ((attribute = itemAttributesNode.attribute("value"))) {
std::string value = attribute.as_string();
if(value == "down") {
it.floorChangeDown = true;
it.floorChange = true;
} else if (value == "north") {
it.floorChangeNorth = true;
it.floorChange = true;
} else if (value == "south") {
it.floorChangeSouth = true;
it.floorChange = true;
} else if (value == "west") {
it.floorChangeWest = true;
it.floorChange = true;
} else if (value == "east") {
it.floorChangeEast = true;
it.floorChange = true;
} else if(value == "northex")
it.floorChange = true;
else if(value == "southex")
it.floorChange = true;
else if(value == "westex")
it.floorChange = true;
else if(value == "eastex")
it.floorChange = true;
else if (value == "southalt")
it.floorChange = true;
else if (value == "eastalt")
it.floorChange = true;
}
}
}
return true;
Expand Down
3 changes: 3 additions & 0 deletions source/items.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ class ItemType {
bool isStackable() const { return stackable; }
bool isMetaItem() const { return is_metaitem; }

bool isFloorChange() const;

GameSprite* sprite;
uint16_t id;
uint16_t clientID;
Expand Down Expand Up @@ -331,6 +333,7 @@ class ItemType {
bool floorChangeSouth;
bool floorChangeEast;
bool floorChangeWest;
bool floorChange;

bool unpassable;
bool blockPickupable;
Expand Down

0 comments on commit 96b65a3

Please sign in to comment.