Skip to content

Commit

Permalink
Small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
UnrealKaraulov committed Jan 1, 2024
1 parent edd29c3 commit 19559a1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
36 changes: 23 additions & 13 deletions src/editor/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3331,7 +3331,8 @@ void Gui::drawMenuBar()
if (ImGui::MenuItem(get_localized_string(LANG_0599).c_str(), "", showLightmapEditorWidget))
{
showLightmapEditorWidget = !showLightmapEditorWidget;
FaceSelectPressed();
app->pickMode = PICK_FACE;
pickCount++;
showLightmapEditorUpdate = true;
}
if (ImGui::MenuItem(get_localized_string(LANG_0600).c_str(), "", showMergeMapWidget))
Expand Down Expand Up @@ -3457,10 +3458,13 @@ void Gui::drawToolbar()
ImGui::PushStyleColor(ImGuiCol_Border, app->pickMode == PICK_OBJECT ? dimColor : selectColor);
if (ImGui::ImageButton("##pickobj",(void*)(uint64_t)objectIconTexture->id, iconSize, ImVec2(0, 0), ImVec2(1, 1)))
{
app->deselectFaces();
app->deselectObject();
app->pickMode = PICK_OBJECT;
showFaceEditWidget = false;
if (app->pickMode != PICK_OBJECT)
{
app->deselectFaces();
app->deselectObject();
app->pickMode = PICK_OBJECT;
showFaceEditWidget = false;
}
}
ImGui::PopStyleColor(2);
if (ImGui::IsItemHovered() && g.HoveredIdTimer > g_tooltip_delay)
Expand All @@ -3476,10 +3480,13 @@ void Gui::drawToolbar()
ImGui::SameLine();
if (ImGui::ImageButton("##pickface", (ImTextureID)(uint64_t)faceIconTexture->id, iconSize, ImVec2(0, 0), ImVec2(1, 1)))
{
app->deselectFaces();
app->deselectObject();
FaceSelectPressed();
if (app->pickMode == PICK_OBJECT)
{
app->deselectObject(true);
pickCount++;
}
showFaceEditWidget = true;
app->pickMode = PICK_FACE;
}
ImGui::PopStyleColor(2);
if (ImGui::IsItemHovered() && g.HoveredIdTimer > g_tooltip_delay)
Expand All @@ -3494,10 +3501,13 @@ void Gui::drawToolbar()
ImGui::SameLine();
if (ImGui::ImageButton("##pickleaf", (void*)(uint64_t)leafIconTexture->id, iconSize, ImVec2(0, 0), ImVec2(1, 1)))
{
app->deselectFaces();
app->deselectObject();
app->pickMode = PICK_FACE_LEAF;
if (app->pickMode == PICK_OBJECT)
{
app->deselectObject(true);
pickCount++;
}
showFaceEditWidget = true;
app->pickMode = PICK_FACE_LEAF;
}
ImGui::PopStyleColor(1);
if (ImGui::IsItemHovered() && g.HoveredIdTimer > g_tooltip_delay)
Expand Down Expand Up @@ -3533,7 +3543,7 @@ void Gui::FaceSelectPressed()
}
}

if (app->pickMode != PICK_FACE)
if (app->pickMode == PICK_OBJECT)
app->deselectObject();

app->pickMode = PICK_FACE;
Expand Down Expand Up @@ -8719,7 +8729,7 @@ void Gui::drawFaceEditorWidget()
static bool stylesChanged = false;

Bsp* map = app->getSelectedMap();
if (!map || app->pickMode != PICK_FACE || app->pickInfo.selectedFaces.empty())
if (!map || app->pickMode == PICK_OBJECT || app->pickInfo.selectedFaces.empty())
{
ImGui::Text(get_localized_string(LANG_1130).c_str());
ImGui::End();
Expand Down
9 changes: 5 additions & 4 deletions src/editor/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ void Renderer::drawModelVerts()
Bsp* map = SelectedMap;
int entIdx = pickInfo.GetSelectedEnt();

if (!map || entIdx < 0)
if (!map || entIdx < 0)
return;
BspRenderer* rend = map->getBspRender();
if (!rend)
Expand Down Expand Up @@ -951,7 +951,7 @@ void Renderer::drawModelOrigin()
glClear(GL_DEPTH_BUFFER_BIT);

Bsp* map = SelectedMap;
if (!map )
if (!map)
return;
BspRenderer* rend = map->getBspRender();
if (!rend)
Expand Down Expand Up @@ -3650,11 +3650,12 @@ void Renderer::deleteEnts()
}
}

void Renderer::deselectObject()
void Renderer::deselectObject(bool onlyobject)
{
filterNeeded = true;
pickInfo.selectedEnts.clear();
pickInfo.selectedFaces.clear();
if (onlyobject)
pickInfo.selectedFaces.clear();
isTransformableSolid = false;
hoverVert = -1;
hoverEdge = -1;
Expand Down
2 changes: 1 addition & 1 deletion src/editor/Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class Renderer
void scaleSelectedVerts(float x, float y, float z);
vec3 getEdgeControlPoint(std::vector<TransformVert>& hullVerts, HullEdge& edge);
vec3 getCentroid(std::vector<TransformVert>& hullVerts);
void deselectObject(); // keep map selected but unselect all objects
void deselectObject(bool onlyobject = false); // keep map selected but unselect all objects
void selectFace(Bsp* map, int face, bool add = false);
void deselectFaces();
void selectEnt(Bsp* map, int entIdx, bool add = false);
Expand Down

0 comments on commit 19559a1

Please sign in to comment.