mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-17 21:48:19 +00:00
Merge pull request #8981 from ChillerDragon/pr_qa_md
Add quick action "Map details"
This commit is contained in:
commit
78d702d3b7
|
@ -331,6 +331,7 @@ public:
|
|||
void AddFrontLayer();
|
||||
void LayerSelectImage();
|
||||
bool IsNonGameTileLayerSelected() const;
|
||||
void MapDetails();
|
||||
#define REGISTER_QUICK_ACTION(name, text, callback, disabled, active, button_color, description) CQuickAction m_QuickAction##name;
|
||||
#include <game/editor/quick_actions.h>
|
||||
#undef REGISTER_QUICK_ACTION
|
||||
|
|
|
@ -32,7 +32,6 @@ CUi::EPopupMenuFunctionResult CEditor::PopupMenuFile(void *pContext, CUIRect Vie
|
|||
static int s_OpenButton = 0;
|
||||
static int s_OpenCurrentMapButton = 0;
|
||||
static int s_AppendButton = 0;
|
||||
static int s_MapInfoButton = 0;
|
||||
static int s_ExitButton = 0;
|
||||
|
||||
CUIRect Slot;
|
||||
|
@ -115,15 +114,9 @@ CUi::EPopupMenuFunctionResult CEditor::PopupMenuFile(void *pContext, CUIRect Vie
|
|||
|
||||
View.HSplitTop(10.0f, nullptr, &View);
|
||||
View.HSplitTop(12.0f, &Slot, &View);
|
||||
if(pEditor->DoButton_MenuItem(&s_MapInfoButton, "Map details", 0, &Slot, 0, "Adjust the map details of the current map"))
|
||||
if(pEditor->DoButton_MenuItem(&pEditor->m_QuickActionMapDetails, pEditor->m_QuickActionMapDetails.Label(), 0, &Slot, 0, pEditor->m_QuickActionMapDetails.Description()))
|
||||
{
|
||||
const CUIRect *pScreen = pEditor->Ui()->Screen();
|
||||
pEditor->m_Map.m_MapInfoTmp.Copy(pEditor->m_Map.m_MapInfo);
|
||||
static SPopupMenuId s_PopupMapInfoId;
|
||||
constexpr float PopupWidth = 400.0f;
|
||||
constexpr float PopupHeight = 170.0f;
|
||||
pEditor->Ui()->DoPopupMenu(&s_PopupMapInfoId, pScreen->w / 2.0f - PopupWidth / 2.0f, pScreen->h / 2.0f - PopupHeight / 2.0f, PopupWidth, PopupHeight, pEditor, PopupMapInfo);
|
||||
pEditor->Ui()->SetActiveItem(nullptr);
|
||||
pEditor->m_QuickActionMapDetails.Call();
|
||||
return CUi::POPUP_CLOSE_CURRENT;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,3 +80,21 @@ void CEditor::LayerSelectImage()
|
|||
Ui()->DoPopupMenu(&s_LayerPopupContext, Ui()->MouseX(), Ui()->MouseY(), 120, 270, &s_LayerPopupContext, PopupLayer);
|
||||
PopupSelectImageInvoke(pTiles->m_Image, Ui()->MouseX(), Ui()->MouseY());
|
||||
}
|
||||
|
||||
void CEditor::MapDetails()
|
||||
{
|
||||
const CUIRect *pScreen = Ui()->Screen();
|
||||
m_Map.m_MapInfoTmp.Copy(m_Map.m_MapInfo);
|
||||
static SPopupMenuId s_PopupMapInfoId;
|
||||
constexpr float PopupWidth = 400.0f;
|
||||
constexpr float PopupHeight = 170.0f;
|
||||
Ui()->DoPopupMenu(
|
||||
&s_PopupMapInfoId,
|
||||
pScreen->w / 2.0f - PopupWidth / 2.0f,
|
||||
pScreen->h / 2.0f - PopupHeight / 2.0f,
|
||||
PopupWidth,
|
||||
PopupHeight,
|
||||
this,
|
||||
PopupMapInfo);
|
||||
Ui()->SetActiveItem(nullptr);
|
||||
}
|
||||
|
|
|
@ -284,6 +284,14 @@ REGISTER_QUICK_ACTION(
|
|||
[&]() -> bool { return m_ColorPipetteActive; },
|
||||
DEFAULT_BTN,
|
||||
"[Ctrl+Shift+C] Color pipette. Pick a color from the screen by clicking on it.")
|
||||
REGISTER_QUICK_ACTION(
|
||||
MapDetails,
|
||||
"Map details",
|
||||
[&]() { MapDetails(); },
|
||||
ALWAYS_FALSE,
|
||||
ALWAYS_FALSE,
|
||||
DEFAULT_BTN,
|
||||
"Adjust the map details of the current map.")
|
||||
|
||||
#undef ALWAYS_FALSE
|
||||
#undef DEFAULT_BTN
|
||||
|
|
Loading…
Reference in a new issue