diff --git a/include/Configuration.h b/include/Configuration.h index dc30577..7821a28 100644 --- a/include/Configuration.h +++ b/include/Configuration.h @@ -180,7 +180,6 @@ namespace S2Plugin private: size_t size{0}; friend class Configuration; - friend class ViewMatrix; }; struct RoomCode diff --git a/include/Data/EntityList.h b/include/Data/EntityList.h index c82d042..03ffa77 100644 --- a/include/Data/EntityList.h +++ b/include/Data/EntityList.h @@ -33,108 +33,109 @@ namespace S2Plugin { return mSize; } - struct Iterator - { - // Iterator(){}; - explicit Iterator(const EntityList entityList, uint32_t index) noexcept : Iterator(entityList.begin()) - { - advance(index); - } - void advance(int count) noexcept // should probably be int64 - { - addr.first += count * sizeof(uintptr_t); - addr.second += count * sizeof(uint32_t); - } - Iterator& operator++() noexcept - { - advance(1); - return *this; - } - Iterator operator++(int) noexcept - { - auto copy = *this; - advance(1); - return copy; - } - Iterator& operator--() noexcept - { - advance(-1); - } - Iterator operator--(int) noexcept - { - auto copy = *this; - advance(-1); - return copy; - } - std::pair operator*() const - { - return {addr.first, Script::Memory::ReadDword(addr.second)}; - } - bool operator==(const Iterator& other) const noexcept - { - return addr.first == other.addr.first; - } - bool operator!=(const Iterator& other) const noexcept - { - return addr.first != other.addr.first; - } - uintptr_t entityRaw() const - { - return Script::Memory::ReadQword(addr.first); - } - Entity entity() const - { - return Entity{Script::Memory::ReadQword(addr.first)}; - } - uint32_t uid() const - { - return Script::Memory::ReadDword(addr.second); - } - - private: - explicit Iterator(uintptr_t entitiesAddress, uintptr_t uidsAddress) : addr(entitiesAddress, uidsAddress){}; - std::pair addr; - friend class EntityList; - }; - - Iterator begin() const - { - return Iterator{entities(), uids()}; - } - Iterator end() const - { - uintptr_t entitiesEnd = entities() + size() * sizeof(uintptr_t); - uintptr_t uidsEnd = uids() + size() * sizeof(uint32_t); - return Iterator{entitiesEnd, uidsEnd}; - } - const Iterator cbegin() const - { - return begin(); - } - const Iterator cend() const - { - return end(); - } - Iterator find(uint32_t uid) const - { - auto endIterator = end(); - for (auto it = begin(); it != endIterator; ++it) - { - if (it.uid() == uid) - return it; - } - return endIterator; - } - Iterator findEntity(uintptr_t addr) const - { - auto endIterator = end(); - for (auto it = begin(); it != endIterator; ++it) - { - if (it.entityRaw() == addr) - return it; - } - return endIterator; - } + // prefer getting whole struct as it's much faster then calling read multiple times + // struct Iterator + //{ + // // Iterator(){}; + // explicit Iterator(const EntityList entityList, uint32_t index) noexcept : Iterator(entityList.begin()) + // { + // advance(index); + // } + // void advance(int count) noexcept // should probably be int64 + // { + // addr.first += count * sizeof(uintptr_t); + // addr.second += count * sizeof(uint32_t); + // } + // Iterator& operator++() noexcept + // { + // advance(1); + // return *this; + // } + // Iterator operator++(int) noexcept + // { + // auto copy = *this; + // advance(1); + // return copy; + // } + // Iterator& operator--() noexcept + // { + // advance(-1); + // } + // Iterator operator--(int) noexcept + // { + // auto copy = *this; + // advance(-1); + // return copy; + // } + // std::pair operator*() const + // { + // return {addr.first, Script::Memory::ReadDword(addr.second)}; + // } + // bool operator==(const Iterator& other) const noexcept + // { + // return addr.first == other.addr.first; + // } + // bool operator!=(const Iterator& other) const noexcept + // { + // return addr.first != other.addr.first; + // } + // uintptr_t entityRaw() const + // { + // return Script::Memory::ReadQword(addr.first); + // } + // Entity entity() const + // { + // return Entity{Script::Memory::ReadQword(addr.first)}; + // } + // uint32_t uid() const + // { + // return Script::Memory::ReadDword(addr.second); + // } + // + // private: + // explicit Iterator(uintptr_t entitiesAddress, uintptr_t uidsAddress) : addr(entitiesAddress, uidsAddress){}; + // std::pair addr; + // friend class EntityList; + //}; + // + // Iterator begin() const + //{ + // return Iterator{entities(), uids()}; + // } + // Iterator end() const + //{ + // uintptr_t entitiesEnd = entities() + size() * sizeof(uintptr_t); + // uintptr_t uidsEnd = uids() + size() * sizeof(uint32_t); + // return Iterator{entitiesEnd, uidsEnd}; + // } + // const Iterator cbegin() const + //{ + // return begin(); + // } + // const Iterator cend() const + //{ + // return end(); + // } + // Iterator find(uint32_t uid) const + //{ + // auto endIterator = end(); + // for (auto it = begin(); it != endIterator; ++it) + // { + // if (it.uid() == uid) + // return it; + // } + // return endIterator; + // } + // Iterator findEntity(uintptr_t addr) const + //{ + // auto endIterator = end(); + // for (auto it = begin(); it != endIterator; ++it) + // { + // if (it.entityRaw() == addr) + // return it; + // } + // return endIterator; + // } std::vector getAllEntities() const { std::vector result; diff --git a/include/QtHelpers/WidgetPagination.h b/include/QtHelpers/WidgetPagination.h index 15e0dab..c1904bd 100644 --- a/include/QtHelpers/WidgetPagination.h +++ b/include/QtHelpers/WidgetPagination.h @@ -7,6 +7,7 @@ #include #include #include +#include #include namespace S2Plugin diff --git a/src/QtHelpers/TreeViewMemoryFields.cpp b/src/QtHelpers/TreeViewMemoryFields.cpp index 47b950f..b33d63d 100644 --- a/src/QtHelpers/TreeViewMemoryFields.cpp +++ b/src/QtHelpers/TreeViewMemoryFields.cpp @@ -71,8 +71,6 @@ QTreeView::branch:open:has-children:has-siblings { })"); QObject::connect(this, &QTreeView::clicked, this, &TreeViewMemoryFields::cellClicked); - // QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont); - // setFont(font); } void S2Plugin::TreeViewMemoryFields::addMemoryFields(const std::vector& fields, const std::string& mainName, uintptr_t structAddr, size_t initialDelta, uint8_t deltaPrefixCount, @@ -162,8 +160,6 @@ QStandardItem* S2Plugin::TreeViewMemoryFields::addMemoryField(const MemoryField& typeName += "StdSet"; else if (field.type == MemoryFieldType::StdUnorderedMap && field.secondParameterType.empty()) // exception typeName += "StdUnorderedSet"; - // else if (field.type == MemoryFieldType::Dummy) - // typeName = ""; else if (auto str = Configuration::getTypeDisplayName(field.type); !str.empty()) typeName += QString::fromUtf8(str.data(), static_cast(str.size())); else @@ -2155,7 +2151,7 @@ void S2Plugin::TreeViewMemoryFields::updateRow(int row, std::optional { std::optional comparisonValue; auto addr = valueComparisonMemoryOffset == 0 ? 0 : valueComparisonMemoryOffset + 0x14; - comparisonValue = updateField(itemField, addr, itemComparisonValue, nullptr, nullptr, true, nullptr, true, false, highlightColor); + comparisonValue = updateField(itemField, addr, itemComparisonValue, nullptr, nullptr, true, nullptr, false, false, highlightColor); if (comparisonValue.has_value()) { if (comparisonValue.value() == 0) diff --git a/src/Views/ViewEntityList.cpp b/src/Views/ViewEntityList.cpp index 00645b6..aed08ee 100644 --- a/src/Views/ViewEntityList.cpp +++ b/src/Views/ViewEntityList.cpp @@ -11,7 +11,7 @@ S2Plugin::ViewEntityList::ViewEntityList(uintptr_t address, QWidget* parent) : m mEntityField.isPointer = true; mEntityField.type = MemoryFieldType::EntityPointer; - mMainTreeView->activeColumns.disable(gsColComparisonValue).disable(gsColComparisonValueHex).disable(gsColComment); //.disable(gsColMemoryAddressDelta).disable(gsColMemoryAddress); + mMainTreeView->activeColumns.disable(gsColComparisonValue).disable(gsColComparisonValueHex).disable(gsColComment); mMainTreeView->updateTableHeader(false); mMainTreeView->setColumnWidth(gsColField, 120); mMainTreeView->setColumnWidth(gsColValueHex, 125);