Move "Map details" button from editor file browser to file menu

There is not enought space for the button in the file browser on 4:3 and 5:4 resolutions.

The button fits in the file menu, as it allows to adjust the map details which are specific to the current map file.
This commit is contained in:
Robert Müller 2023-04-02 20:15:45 +02:00
parent 72775f236b
commit b7e8168e4b
2 changed files with 18 additions and 17 deletions

View file

@ -4958,7 +4958,6 @@ void CEditor::RenderFileDialog()
static int s_ShowDirectoryButton = 0;
static int s_DeleteButton = 0;
static int s_NewFolderButton = 0;
static int s_MapInfoButton = 0;
CUIRect Button;
ButtonBar.VSplitRight(50.0f, &ButtonBar, &Button);
@ -5082,21 +5081,6 @@ void CEditor::RenderFileDialog()
UiInvokePopupMenu(&s_PopupNewFolderId, 0, Width / 2.0f - PopupWidth / 2.0f, Height / 2.0f - PopupHeight / 2.0f, PopupWidth, PopupHeight, PopupNewFolder);
UI()->SetActiveItem(nullptr);
}
ButtonBar.VSplitLeft(40.0f, nullptr, &ButtonBar);
ButtonBar.VSplitLeft(70.0f, &Button, &ButtonBar);
if(DoButton_Editor(&s_MapInfoButton, "Map details", 0, &Button, 0, nullptr))
{
str_copy(m_Map.m_MapInfo.m_aAuthorTmp, m_Map.m_MapInfo.m_aAuthor);
str_copy(m_Map.m_MapInfo.m_aVersionTmp, m_Map.m_MapInfo.m_aVersion);
str_copy(m_Map.m_MapInfo.m_aCreditsTmp, m_Map.m_MapInfo.m_aCredits);
str_copy(m_Map.m_MapInfo.m_aLicenseTmp, m_Map.m_MapInfo.m_aLicense);
static int s_PopupMapInfoId;
constexpr float PopupWidth = 400.0f;
constexpr float PopupHeight = 170.0f;
UiInvokePopupMenu(&s_PopupMapInfoId, 0, Width / 2.0f - PopupWidth / 2.0f, Height / 2.0f - PopupHeight / 2.0f, PopupWidth, PopupHeight, PopupMapInfo);
UI()->SetActiveItem(nullptr);
}
}
}
@ -6031,7 +6015,7 @@ void CEditor::RenderMenubar(CUIRect MenuBar)
static int s_FileButton = 0;
MenuBar.VSplitLeft(60.0f, &FileButton, &MenuBar);
if(DoButton_Menu(&s_FileButton, "File", 0, &FileButton, 0, nullptr))
UiInvokePopupMenu(&s_FileButton, 1, FileButton.x, FileButton.y + FileButton.h - 1.0f, 120.0f, 152.0f, PopupMenuFile, this);
UiInvokePopupMenu(&s_FileButton, 1, FileButton.x, FileButton.y + FileButton.h - 1.0f, 120.0f, 174.0f, PopupMenuFile, this);
MenuBar.VSplitLeft(5.0f, nullptr, &MenuBar);

View file

@ -128,6 +128,7 @@ int CEditor::PopupMenuFile(CEditor *pEditor, CUIRect View, void *pContext)
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;
@ -216,6 +217,22 @@ int CEditor::PopupMenuFile(CEditor *pEditor, CUIRect View, void *pContext)
return 1;
}
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"))
{
const CUIRect *pScreen = pEditor->UI()->Screen();
str_copy(pEditor->m_Map.m_MapInfo.m_aAuthorTmp, pEditor->m_Map.m_MapInfo.m_aAuthor);
str_copy(pEditor->m_Map.m_MapInfo.m_aVersionTmp, pEditor->m_Map.m_MapInfo.m_aVersion);
str_copy(pEditor->m_Map.m_MapInfo.m_aCreditsTmp, pEditor->m_Map.m_MapInfo.m_aCredits);
str_copy(pEditor->m_Map.m_MapInfo.m_aLicenseTmp, pEditor->m_Map.m_MapInfo.m_aLicense);
static int s_PopupMapInfoId;
constexpr float PopupWidth = 400.0f;
constexpr float PopupHeight = 170.0f;
pEditor->UiInvokePopupMenu(&s_PopupMapInfoId, 0, pScreen->w / 2.0f - PopupWidth / 2.0f, pScreen->h / 2.0f - PopupHeight / 2.0f, PopupWidth, PopupHeight, PopupMapInfo);
pEditor->UI()->SetActiveItem(nullptr);
}
View.HSplitTop(10.0f, nullptr, &View);
View.HSplitTop(12.0f, &Slot, &View);
if(pEditor->DoButton_MenuItem(&s_ExitButton, "Exit", 0, &Slot, 0, "Exits from the editor"))