Skip to content

Commit

Permalink
Merge pull request ddnet#9031 from ChillerDragon/pr_cfg_layer_selector
Browse files Browse the repository at this point in the history
Add ``ed_layer_selector`` config to to toggle layer selector feature
  • Loading branch information
Robyt3 authored Sep 25, 2024
2 parents 9298ee4 + d123aa6 commit cb4a66a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/engine/shared/config_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ MACRO_CONFIG_INT(EdShowkeys, ed_showkeys, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE
MACRO_CONFIG_INT(EdAlignQuads, ed_align_quads, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Enable/disable quad alignment. When enabled, red lines appear to show how quad/points are aligned and snapped to other quads/points when moving them")
MACRO_CONFIG_INT(EdShowQuadsRect, ed_show_quads_rect, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show the bounds of the selected quad. In case of multiple quads, it shows the bounds of the englobing rect. Can be helpful when aligning a group of quads")
MACRO_CONFIG_INT(EdAutoMapReload, ed_auto_map_reload, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Run 'hot_reload' on the local server while rcon authed on map save")
MACRO_CONFIG_INT(EdLayerSelector, ed_layer_selector, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Ctrl+right click tiles to select their layers in the editor")

MACRO_CONFIG_INT(ClShowWelcome, cl_show_welcome, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show welcome message indicating the first launch of the client")
MACRO_CONFIG_INT(ClMotdTime, cl_motd_time, 10, 0, 100, CFGFLAG_CLIENT | CFGFLAG_SAVE, "How long to show the server message of the day")
Expand Down
9 changes: 7 additions & 2 deletions src/game/editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3216,7 +3216,12 @@ void CEditor::DoMapEditor(CUIRect View)
else if(m_pBrush->IsEmpty() && GetSelectedLayerType(0, LAYERTYPE_QUADS) != nullptr)
str_copy(m_aTooltip, "Use left mouse button to drag and create a brush. Hold shift to select multiple quads. Press R to rotate selected quads. Use ctrl+right mouse to select layer.");
else if(m_pBrush->IsEmpty())
str_copy(m_aTooltip, "Use left mouse button to drag and create a brush. Use ctrl+right mouse to select layer.");
{
if(g_Config.m_EdLayerSelector)
str_copy(m_aTooltip, "Use left mouse button to drag and create a brush. Use ctrl+right click to select layer for hovered tile.");
else
str_copy(m_aTooltip, "Use left mouse button to drag and create a brush.");
}
else
str_copy(m_aTooltip, "Use left mouse button to paint with the brush. Right button clears the brush.");

Expand Down Expand Up @@ -7666,7 +7671,7 @@ void CEditor::RenderMenubar(CUIRect MenuBar)
if(DoButton_Ex(&s_SettingsButton, "Settings", 0, &SettingsButton, 0, nullptr, IGraphics::CORNER_T, EditorFontSizes::MENU, TEXTALIGN_ML))
{
static SPopupMenuId s_PopupMenuEntitiesId;
Ui()->DoPopupMenu(&s_PopupMenuEntitiesId, SettingsButton.x, SettingsButton.y + SettingsButton.h - 1.0f, 200.0f, 106.0f, this, PopupMenuSettings, PopupProperties);
Ui()->DoPopupMenu(&s_PopupMenuEntitiesId, SettingsButton.x, SettingsButton.y + SettingsButton.h - 1.0f, 210.0f, 120.0f, this, PopupMenuSettings, PopupProperties);
}

CUIRect ChangedIndicator, Info, Help, Close;
Expand Down
4 changes: 4 additions & 0 deletions src/game/editor/layer_selector.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <engine/shared/config.h>

#include "editor.h"

#include "layer_selector.h"
Expand All @@ -16,6 +18,8 @@ bool CLayerSelector::SelectByTile()
return false;
if(!Input()->ModifierIsPressed() || !Ui()->MouseButtonClicked(1))
return false;
if(!g_Config.m_EdLayerSelector)
return false;

int MatchedGroup = -1;
int MatchedLayer = -1;
Expand Down
24 changes: 24 additions & 0 deletions src/game/editor/popups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,30 @@ CUi::EPopupMenuFunctionResult CEditor::PopupMenuSettings(void *pContext, CUIRect
}
}

View.HSplitTop(2.0f, nullptr, &View);
View.HSplitTop(12.0f, &Slot, &View);
{
Slot.VMargin(5.0f, &Slot);

CUIRect Label, Selector;
Slot.VSplitMid(&Label, &Selector);
CUIRect No, Yes;
Selector.VSplitMid(&No, &Yes);

pEditor->Ui()->DoLabel(&Label, "Select layers by tile", 10.0f, TEXTALIGN_ML);

static int s_ButtonNo = 0;
static int s_ButtonYes = 0;
if(pEditor->DoButton_Ex(&s_ButtonNo, "No", !g_Config.m_EdLayerSelector, &No, 0, "Do not select layers when Ctrl+right clicking on a tile", IGraphics::CORNER_L))
{
g_Config.m_EdLayerSelector = false;
}
if(pEditor->DoButton_Ex(&s_ButtonYes, "Yes", g_Config.m_EdLayerSelector, &Yes, 0, "Select layers when Ctrl+right clicking on a tile", IGraphics::CORNER_R))
{
g_Config.m_EdLayerSelector = true;
}
}

return CUi::POPUP_KEEP_OPEN;
}

Expand Down

0 comments on commit cb4a66a

Please sign in to comment.