Skip to content

Commit

Permalink
Added Show patches option to View Options
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertBeckebans committed Nov 25, 2023
1 parent 0955f33 commit 27cf7dc
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions common/src/IO/FreeImageTextureReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ Assets::Texture FreeImageTextureReader::readTextureFromMemory(
TRUE);

const auto textureType = Assets::Texture::selectTextureType(masked);

// RB: skip average Color to speed up map loading
// const Color averageColor(0.25f, 0.25f, 0.25f, 1.0f);
const Color averageColor = getAverageColor(buffers.at(0), format);

return Assets::Texture{
Expand Down
5 changes: 5 additions & 0 deletions common/src/Model/EditorContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ bool EditorContext::visible(const Model::PatchNode* patchNode) const
return true;
}

if (!pref(Preferences::ShowPatches))
{
return false;
}

if (patchNode->hasTag(m_hiddenTags))
{
return false;
Expand Down
1 change: 1 addition & 0 deletions common/src/Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ Preference<bool> ShowSoftMapBounds(IO::Path("Map view/Show soft map bounds"), tr

Preference<bool> ShowPointEntities(IO::Path("Map view/Show point entities"), true);
Preference<bool> ShowBrushes(IO::Path("Map view/Show brushes"), true);
Preference<bool> ShowPatches(IO::Path("Map view/Show patches"), true); // RB

QString entityLinkModeAll()
{
Expand Down
1 change: 1 addition & 0 deletions common/src/Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ extern Preference<bool> ShowSoftMapBounds;
// Editor context
extern Preference<bool> ShowPointEntities;
extern Preference<bool> ShowBrushes;
extern Preference<bool> ShowPatches; // RB

QString entityLinkModeAll();
QString entityLinkModeTransitive();
Expand Down
7 changes: 7 additions & 0 deletions common/src/View/Actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,13 @@ void ActionManager::createViewActions()
QKeySequence(),
[](ActionExecutionContext& context) { context.view()->toggleShowBrushes(); },
[](ActionExecutionContext& context) { return context.hasDocument(); });
createAction(
IO::Path("Controls/Map view/View Filter > Toggle show patches"),
QObject::tr("Toggle Show Patches"),
ActionContext::Any,
QKeySequence(),
[](ActionExecutionContext& context) { context.view()->toggleShowPatches(); },
[](ActionExecutionContext& context) { return context.hasDocument(); });
createAction(
IO::Path("Controls/Map view/View Filter > Show textures"),
QObject::tr("Show Textures"),
Expand Down
5 changes: 5 additions & 0 deletions common/src/View/MapViewBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,11 @@ void MapViewBase::toggleShowBrushes()
togglePref(Preferences::ShowBrushes);
}

void MapViewBase::toggleShowPatches()
{
togglePref(Preferences::ShowPatches);
}

void MapViewBase::showTextures()
{
setPref(Preferences::FaceRenderMode, Preferences::faceRenderModeTextured());
Expand Down
1 change: 1 addition & 0 deletions common/src/View/MapViewBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ class MapViewBase : public RenderView,
void toggleShowPointEntities();
void toggleShowPointEntityModels();
void toggleShowBrushes();
void toggleShowPatches(); // RB
void showTextures();
void hideTextures();
void hideFaces();
Expand Down
18 changes: 18 additions & 0 deletions common/src/View/ViewEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,17 @@ QWidget* ViewEditor::createBrushesPanel(QWidget* parent)
ensure(innerLayout != nullptr, "inner sizer is null");
innerLayout->insertWidget(0, m_showBrushesCheckBox);

// RB begin
m_showPatchesCheckBox = new QCheckBox(tr("Show patches"));
connect(
m_showPatchesCheckBox,
&QAbstractButton::clicked,
this,
&ViewEditor::showPatchesChanged);

innerLayout->insertWidget(0, m_showPatchesCheckBox);
// RB end

return panel;
}

Expand Down Expand Up @@ -615,6 +626,7 @@ void ViewEditor::refreshBrushesPanel()
auto document = kdl::mem_lock(m_document);

m_showBrushesCheckBox->setChecked(pref(Preferences::ShowBrushes));
m_showPatchesCheckBox->setChecked(pref(Preferences::ShowPatches));

Model::EditorContext& editorContext = document->editorContext();
const Model::TagType::Type hiddenTags = editorContext.hiddenTags();
Expand Down Expand Up @@ -670,6 +682,11 @@ void ViewEditor::showBrushesChanged(const bool checked)
setPref(Preferences::ShowBrushes, checked);
}

void ViewEditor::showPatchesChanged(const bool checked)
{
setPref(Preferences::ShowPatches, checked);
}

void ViewEditor::showTagChanged(const bool checked, const Model::TagType::Type tagType)
{
auto document = kdl::mem_lock(m_document);
Expand Down Expand Up @@ -760,6 +777,7 @@ void ViewEditor::restoreDefaultsClicked()
prefs.resetToDefault(Preferences::ShowSoftMapBounds);
prefs.resetToDefault(Preferences::ShowPointEntities);
prefs.resetToDefault(Preferences::ShowBrushes);
prefs.resetToDefault(Preferences::ShowPatches);
prefs.resetToDefault(Preferences::EntityLinkMode);
prefs.saveChanges();
}
Expand Down
2 changes: 2 additions & 0 deletions common/src/View/ViewEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class ViewEditor : public QWidget
EntityDefinitionCheckBoxList* m_entityDefinitionCheckBoxList;

QCheckBox* m_showBrushesCheckBox;
QCheckBox* m_showPatchesCheckBox; // RB
std::vector<std::pair<Model::TagType::Type, QCheckBox*>> m_tagCheckBoxes;

QButtonGroup* m_renderModeRadioGroup;
Expand Down Expand Up @@ -153,6 +154,7 @@ class ViewEditor : public QWidget
void showPointEntitiesChanged(bool checked);
void showPointEntityModelsChanged(bool checked);
void showBrushesChanged(bool checked);
void showPatchesChanged(bool checked);
void showTagChanged(bool checked, Model::TagType::Type tagType);
void faceRenderModeChanged(int id);
void shadeFacesChanged(bool checked);
Expand Down

0 comments on commit 27cf7dc

Please sign in to comment.