Skip to content

Commit

Permalink
fix wstring, fix crash when clicking empty field in ThreadsView, impr…
Browse files Browse the repository at this point in the history
…ove the look of memory tree, fix other small stuff in memory tree, rename `ThemeInfoName` -> `ThemeInfoPointer`
  • Loading branch information
Mr-Auto committed May 4, 2024
1 parent ad4cae6 commit 5fc9871
Show file tree
Hide file tree
Showing 14 changed files with 226 additions and 240 deletions.
2 changes: 1 addition & 1 deletion include/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ namespace S2Plugin
EntitySubclass, // a subclass of an entity defined in json
DefaultStructType, // a struct defined in json
UndeterminedThemeInfoPointer, // used to look up the theme pointer in the levelgen and show the correct theme name
ThemeInfoName, // same as above, but does not add struct tree
ThemeInfoPointer, // same as above, but does not add struct tree
LevelGenRoomsPointer, // used to make the level gen rooms title clickable
LevelGenRoomsMetaPointer, // used to make the level gen rooms title clickable
JournalPagePointer, // used to make journal page in vector clickable
Expand Down
2 changes: 1 addition & 1 deletion include/Data/StdString.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ namespace S2Plugin
};

using StdString = StdBasicString<char>;
using StdWstring = StdBasicString<char16_t>;
using StdWstring = StdBasicString<ushort>;
} // namespace S2Plugin
11 changes: 8 additions & 3 deletions include/QtHelpers/TreeViewMemoryFields.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,16 @@ namespace S2Plugin
public:
TreeViewMemoryFields(QWidget* parent = nullptr);

void addMemoryFields(const std::vector<MemoryField>& fields, const std::string& mainName, uintptr_t structAddr, size_t initialDelta = 0, QStandardItem* parent = nullptr);
QStandardItem* addMemoryField(const MemoryField& field, const std::string& fieldNameOverride, uintptr_t memoryAddress, size_t delta, QStandardItem* parent = nullptr);
void addMemoryFields(const std::vector<MemoryField>& fields, const std::string& mainName, uintptr_t structAddr, size_t initialDelta = 0, uint8_t deltaPrefixCount = 0,
QStandardItem* parent = nullptr);
QStandardItem* addMemoryField(const MemoryField& field, const std::string& fieldNameOverride, uintptr_t memoryAddress, size_t delta, uint8_t deltaPrefixCount = 0,
QStandardItem* parent = nullptr);
void clear();
void updateTableHeader(bool restoreColumnWidths = true);
void setEnableChangeHighlighting(bool b) noexcept;
void setEnableChangeHighlighting(bool b) noexcept
{
mEnableChangeHighlighting = b;
}

void updateTree(uintptr_t newAddr, uintptr_t newComparisonAddr = 0, bool initial = false);
void updateRow(int row, std::optional<uintptr_t> newAddr = std::nullopt, std::optional<uintptr_t> newAddrComparison = std::nullopt, QStandardItem* parent = nullptr,
Expand Down
2 changes: 1 addition & 1 deletion resources/Spelunky2.json
Original file line number Diff line number Diff line change
Expand Up @@ -9051,7 +9051,7 @@
{ "field": "padding3?", "type": "UnsignedDword" },
{
"field": "sub_theme",
"type": "ThemeInfoName",
"type": "ThemeInfoPointer",
"comment": "for cosmic ocean"
},
{ "field": "unknown3", "type": "UnsignedDword" },
Expand Down
21 changes: 18 additions & 3 deletions resources/spelunky2.qrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
<RCC>
<qresource prefix="/icons">
<file>caveman.png</file>
</qresource>
<qresource prefix="/icons">
<file>caveman.png</file>
</qresource>
<qresource prefix="/images">
<file alias="vline.png">stylesheet-vline.png</file>
</qresource>
<qresource prefix="/images">
<file alias="branch-more.png">stylesheet-branch-more.png</file>
</qresource>
<qresource prefix="/images">
<file alias="branch-end.png">stylesheet-branch-end.png</file>
</qresource>
<qresource prefix="/images">
<file alias="branch-closed.png">stylesheet-branch-closed.png</file>
</qresource>
<qresource prefix="/images">
<file alias="branch-open.png">stylesheet-branch-open.png</file>
</qresource>
</RCC>
Binary file added resources/stylesheet-branch-closed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/stylesheet-branch-end.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/stylesheet-branch-more.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/stylesheet-branch-open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/stylesheet-vline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ namespace S2Plugin
{MemoryFieldType::ConstCharPointer, "Const char*", "const char*", "ConstCharPointer", 8, true},
{MemoryFieldType::ConstCharPointerPointer, "Const char**", "const char**", "ConstCharPointerPointer", 8, true}, // there is more then just pointer to pointer?
{MemoryFieldType::UndeterminedThemeInfoPointer, "UndeterminedThemeInfoPointer", "ThemeInfo*", "UndeterminedThemeInfoPointer", 8, true}, // display theme name and add ThemeInfo fields
{MemoryFieldType::ThemeInfoName, "ThemeInfoName", "ThemeInfo*", "ThemeInfoName", 8, true}, // just theme name
{MemoryFieldType::ThemeInfoPointer, "ThemeInfoPointer", "ThemeInfo*", "ThemeInfoPointer", 8, true}, // just theme name
{MemoryFieldType::LevelGenRoomsPointer, "LevelGenRoomsPointer", "LevelGenRooms*", "LevelGenRoomsPointer", 8, true},
{MemoryFieldType::LevelGenRoomsMetaPointer, "LevelGenRoomsMetaPointer", "LevelGenRoomsMeta*", "LevelGenRoomsMetaPointer", 8, true},
{MemoryFieldType::JournalPagePointer, "JournalPagePointer", "JournalPage*", "JournalPagePointer", 8, true},
Expand Down
19 changes: 15 additions & 4 deletions src/QtHelpers/StyledItemDelegateHTML.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "QtHelpers/StyledItemDelegateHTML.h"
#include <QAbstractTextDocumentLayout>
#include <QPainter>
#include <QSize>
#include <QTextDocument>

void S2Plugin::StyledItemDelegateHTML::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
Expand All @@ -14,7 +16,7 @@ void S2Plugin::StyledItemDelegateHTML::paint(QPainter* painter, const QStyleOpti

options.text = "";
options.widget->style()->drawControl(QStyle::CE_ItemViewItem, &options, painter);

QSize iconSize = options.icon.actualSize(options.rect.size());
if (mCenterVertically)
{
doc.setTextWidth(options.rect.width());
Expand All @@ -23,10 +25,19 @@ void S2Plugin::StyledItemDelegateHTML::paint(QPainter* painter, const QStyleOpti
}
else
{
painter->translate(options.rect.left(), options.rect.top() - 2);
painter->translate(options.rect.left() + iconSize.width(), options.rect.top() - 2);
}
QRect clip(0, 0, options.rect.width(), options.rect.height());
doc.drawContents(painter, clip);
QRect clip(0, 0, options.rect.width() + iconSize.width(), options.rect.height());
// doc.drawContents(painter, clip);

painter->setClipRect(clip);
QAbstractTextDocumentLayout::PaintContext ctx;
auto newColor = index.data(Qt::TextColorRole);
if (!newColor.isNull())
ctx.palette.setColor(QPalette::Text, newColor.value<QColor>());

ctx.clip = clip;
doc.documentLayout()->draw(painter, ctx);

painter->restore();
}
Expand Down
Loading

0 comments on commit 5fc9871

Please sign in to comment.