mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
added map info
This commit is contained in:
parent
fa81141110
commit
65f4416164
|
@ -214,7 +214,6 @@ void CEditor::EnvelopeEval(float TimeOffset, int Env, float *pChannels, void *pU
|
|||
|
||||
// copied from gc_menu.cpp, should be more generalized
|
||||
//extern int ui_do_edit_box(void *id, const CUIRect *rect, char *str, int str_size, float font_size, bool hidden=false);
|
||||
|
||||
int CEditor::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden, int Corners)
|
||||
{
|
||||
int Inside = UI()->MouseInside(pRect);
|
||||
|
@ -2904,6 +2903,7 @@ void CEditor::RenderFileDialog()
|
|||
static int s_OkButton = 0;
|
||||
static int s_CancelButton = 0;
|
||||
static int s_NewFolderButton = 0;
|
||||
static int s_MapInfoButton = 0;
|
||||
|
||||
CUIRect Button;
|
||||
ButtonBar.VSplitRight(50.0f, &ButtonBar, &Button);
|
||||
|
@ -2979,6 +2979,22 @@ void CEditor::RenderFileDialog()
|
|||
UI()->SetActiveItem(0);
|
||||
}
|
||||
}
|
||||
|
||||
if(m_FileDialogStorageType == IStorage::TYPE_SAVE)
|
||||
{
|
||||
ButtonBar.VSplitLeft(40.0f, 0, &ButtonBar);
|
||||
ButtonBar.VSplitLeft(70.0f, &Button, &ButtonBar);
|
||||
if(DoButton_Editor(&s_MapInfoButton, "Map details", 0, &Button, 0, 0))
|
||||
{
|
||||
str_copy(m_Map.m_MapInfo.m_aAuthorTmp, m_Map.m_MapInfo.m_aAuthor, sizeof(m_Map.m_MapInfo.m_aAuthorTmp));
|
||||
str_copy(m_Map.m_MapInfo.m_aVersionTmp, m_Map.m_MapInfo.m_aVersion, sizeof(m_Map.m_MapInfo.m_aVersionTmp));
|
||||
str_copy(m_Map.m_MapInfo.m_aCreditsTmp, m_Map.m_MapInfo.m_aCredits, sizeof(m_Map.m_MapInfo.m_aCreditsTmp));
|
||||
str_copy(m_Map.m_MapInfo.m_aLicenseTmp, m_Map.m_MapInfo.m_aLicense, sizeof(m_Map.m_MapInfo.m_aLicenseTmp));
|
||||
static int s_MapInfoPopupID = 0;
|
||||
UiInvokePopupMenu(&s_MapInfoPopupID, 0, Width/2.0f-200.0f, Height/2.0f-100.0f, 400.0f, 200.0f, PopupMapInfo);
|
||||
UI()->SetActiveItem(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CEditor::FilelistPopulate(int StorageType)
|
||||
|
@ -3889,6 +3905,8 @@ void CEditorMap::Clean()
|
|||
m_lEnvelopes.delete_all();
|
||||
m_lImages.delete_all();
|
||||
|
||||
m_MapInfo.Reset();
|
||||
|
||||
m_pGameLayer = 0x0;
|
||||
m_pGameGroup = 0x0;
|
||||
|
||||
|
|
|
@ -276,6 +276,34 @@ public:
|
|||
array<CEditorImage*> m_lImages;
|
||||
array<CEnvelope*> m_lEnvelopes;
|
||||
|
||||
class CMapInfo
|
||||
{
|
||||
public:
|
||||
char m_aAuthorTmp[32];
|
||||
char m_aVersionTmp[16];
|
||||
char m_aCreditsTmp[128];
|
||||
char m_aLicenseTmp[32];
|
||||
|
||||
char m_aAuthor[32];
|
||||
char m_aVersion[16];
|
||||
char m_aCredits[128];
|
||||
char m_aLicense[32];
|
||||
|
||||
void Reset()
|
||||
{
|
||||
m_aAuthorTmp[0] = 0;
|
||||
m_aVersionTmp[0] = 0;
|
||||
m_aCreditsTmp[0] = 0;
|
||||
m_aLicenseTmp[0] = 0;
|
||||
|
||||
m_aAuthor[0] = 0;
|
||||
m_aVersion[0] = 0;
|
||||
m_aCredits[0] = 0;
|
||||
m_aLicense[0] = 0;
|
||||
}
|
||||
};
|
||||
CMapInfo m_MapInfo;
|
||||
|
||||
class CLayerGame *m_pGameLayer;
|
||||
CLayerGroup *m_pGameGroup;
|
||||
|
||||
|
@ -710,6 +738,7 @@ public:
|
|||
static int PopupQuad(CEditor *pEditor, CUIRect View);
|
||||
static int PopupPoint(CEditor *pEditor, CUIRect View);
|
||||
static int PopupNewFolder(CEditor *pEditor, CUIRect View);
|
||||
static int PopupMapInfo(CEditor *pEditor, CUIRect View);
|
||||
static int PopupEvent(CEditor *pEditor, CUIRect View);
|
||||
static int PopupSelectImage(CEditor *pEditor, CUIRect View);
|
||||
static int PopupSelectGametileOp(CEditor *pEditor, CUIRect View);
|
||||
|
|
|
@ -220,6 +220,31 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
|
|||
df.AddItem(MAPITEMTYPE_VERSION, 0, sizeof(Item), &Item);
|
||||
}
|
||||
|
||||
// save map info
|
||||
{
|
||||
CMapItemInfo Item;
|
||||
Item.m_Version = 1;
|
||||
|
||||
if(m_MapInfo.m_aAuthor[0])
|
||||
Item.m_Author = df.AddData(str_length(m_MapInfo.m_aAuthor)+1, m_MapInfo.m_aAuthor);
|
||||
else
|
||||
Item.m_Author = -1;
|
||||
if(m_MapInfo.m_aVersion[0])
|
||||
Item.m_MapVersion = df.AddData(str_length(m_MapInfo.m_aVersion)+1, m_MapInfo.m_aVersion);
|
||||
else
|
||||
Item.m_MapVersion = -1;
|
||||
if(m_MapInfo.m_aCredits[0])
|
||||
Item.m_Credits = df.AddData(str_length(m_MapInfo.m_aCredits)+1, m_MapInfo.m_aCredits);
|
||||
else
|
||||
Item.m_Credits = -1;
|
||||
if(m_MapInfo.m_aLicense[0])
|
||||
Item.m_License = df.AddData(str_length(m_MapInfo.m_aLicense)+1, m_MapInfo.m_aLicense);
|
||||
else
|
||||
Item.m_License = -1;
|
||||
|
||||
df.AddItem(MAPITEMTYPE_INFO, 0, sizeof(Item), &Item);
|
||||
}
|
||||
|
||||
// save images
|
||||
for(int i = 0; i < m_lImages.size(); i++)
|
||||
{
|
||||
|
@ -414,6 +439,22 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
|
|||
{
|
||||
//editor.reset(false);
|
||||
|
||||
// load map info
|
||||
{
|
||||
CMapItemInfo *pItem = (CMapItemInfo *)DataFile.FindItem(MAPITEMTYPE_INFO, 0);
|
||||
if(pItem && pItem->m_Version == 1)
|
||||
{
|
||||
if(pItem->m_Author > -1)
|
||||
str_copy(m_MapInfo.m_aAuthor, (char *)DataFile.GetData(pItem->m_Author), sizeof(m_MapInfo.m_aAuthor));
|
||||
if(pItem->m_MapVersion > -1)
|
||||
str_copy(m_MapInfo.m_aVersion, (char *)DataFile.GetData(pItem->m_MapVersion), sizeof(m_MapInfo.m_aVersion));
|
||||
if(pItem->m_Credits > -1)
|
||||
str_copy(m_MapInfo.m_aCredits, (char *)DataFile.GetData(pItem->m_Credits), sizeof(m_MapInfo.m_aCredits));
|
||||
if(pItem->m_License > -1)
|
||||
str_copy(m_MapInfo.m_aLicense, (char *)DataFile.GetData(pItem->m_License), sizeof(m_MapInfo.m_aLicense));
|
||||
}
|
||||
}
|
||||
|
||||
// load images
|
||||
{
|
||||
int Start, Num;
|
||||
|
|
|
@ -635,6 +635,74 @@ int CEditor::PopupNewFolder(CEditor *pEditor, CUIRect View)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CEditor::PopupMapInfo(CEditor *pEditor, CUIRect View)
|
||||
{
|
||||
CUIRect Label, ButtonBar, Button;
|
||||
|
||||
// title
|
||||
View.HSplitTop(10.0f, 0, &View);
|
||||
View.HSplitTop(30.0f, &Label, &View);
|
||||
pEditor->UI()->DoLabel(&Label, "Map details", 20.0f, 0);
|
||||
|
||||
View.HSplitBottom(10.0f, &View, 0);
|
||||
View.HSplitBottom(20.0f, &View, &ButtonBar);
|
||||
|
||||
View.VMargin(40.0f, &View);
|
||||
|
||||
// author box
|
||||
View.HSplitTop(20.0f, &Label, &View);
|
||||
pEditor->UI()->DoLabel(&Label, "Author:", 10.0f, -1);
|
||||
Label.VSplitLeft(40.0f, 0, &Button);
|
||||
Button.HSplitTop(12.0f, &Button, 0);
|
||||
static float s_AuthorBox = 0;
|
||||
pEditor->DoEditBox(&s_AuthorBox, &Button, pEditor->m_Map.m_MapInfo.m_aAuthorTmp, sizeof(pEditor->m_Map.m_MapInfo.m_aAuthorTmp), 10.0f, &s_AuthorBox);
|
||||
|
||||
// version box
|
||||
View.HSplitTop(20.0f, &Label, &View);
|
||||
pEditor->UI()->DoLabel(&Label, "Version:", 10.0f, -1);
|
||||
Label.VSplitLeft(40.0f, 0, &Button);
|
||||
Button.HSplitTop(12.0f, &Button, 0);
|
||||
static float s_VersionBox = 0;
|
||||
pEditor->DoEditBox(&s_VersionBox, &Button, pEditor->m_Map.m_MapInfo.m_aVersionTmp, sizeof(pEditor->m_Map.m_MapInfo.m_aVersionTmp), 10.0f, &s_VersionBox);
|
||||
|
||||
// credits box
|
||||
View.HSplitTop(20.0f, &Label, &View);
|
||||
pEditor->UI()->DoLabel(&Label, "Credits:", 10.0f, -1);
|
||||
Label.VSplitLeft(40.0f, 0, &Button);
|
||||
Button.HSplitTop(12.0f, &Button, 0);
|
||||
static float s_CreditsBox = 0;
|
||||
pEditor->DoEditBox(&s_CreditsBox, &Button, pEditor->m_Map.m_MapInfo.m_aCreditsTmp, sizeof(pEditor->m_Map.m_MapInfo.m_aCreditsTmp), 10.0f, &s_CreditsBox);
|
||||
|
||||
// license box
|
||||
View.HSplitTop(20.0f, &Label, &View);
|
||||
pEditor->UI()->DoLabel(&Label, "License:", 10.0f, -1);
|
||||
Label.VSplitLeft(40.0f, 0, &Button);
|
||||
Button.HSplitTop(12.0f, &Button, 0);
|
||||
static float s_LicenseBox = 0;
|
||||
pEditor->DoEditBox(&s_LicenseBox, &Button, pEditor->m_Map.m_MapInfo.m_aLicenseTmp, sizeof(pEditor->m_Map.m_MapInfo.m_aLicenseTmp), 10.0f, &s_LicenseBox);
|
||||
|
||||
// button bar
|
||||
ButtonBar.VSplitLeft(30.0f, 0, &ButtonBar);
|
||||
ButtonBar.VSplitLeft(110.0f, &Label, &ButtonBar);
|
||||
static int s_CreateButton = 0;
|
||||
if(pEditor->DoButton_Editor(&s_CreateButton, "Save", 0, &Label, 0, 0))
|
||||
{
|
||||
str_copy(pEditor->m_Map.m_MapInfo.m_aAuthor, pEditor->m_Map.m_MapInfo.m_aAuthorTmp, sizeof(pEditor->m_Map.m_MapInfo.m_aAuthor));
|
||||
str_copy(pEditor->m_Map.m_MapInfo.m_aVersion, pEditor->m_Map.m_MapInfo.m_aVersionTmp, sizeof(pEditor->m_Map.m_MapInfo.m_aVersion));
|
||||
str_copy(pEditor->m_Map.m_MapInfo.m_aCredits, pEditor->m_Map.m_MapInfo.m_aCreditsTmp, sizeof(pEditor->m_Map.m_MapInfo.m_aCredits));
|
||||
str_copy(pEditor->m_Map.m_MapInfo.m_aLicense, pEditor->m_Map.m_MapInfo.m_aLicenseTmp, sizeof(pEditor->m_Map.m_MapInfo.m_aLicense));
|
||||
return 1;
|
||||
}
|
||||
|
||||
ButtonBar.VSplitRight(30.0f, &ButtonBar, 0);
|
||||
ButtonBar.VSplitRight(110.0f, &ButtonBar, &Label);
|
||||
static int s_AbortButton = 0;
|
||||
if(pEditor->DoButton_Editor(&s_AbortButton, "Abort", 0, &Label, 0, 0))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CEditor::PopupEvent(CEditor *pEditor, CUIRect View)
|
||||
{
|
||||
CUIRect Label, ButtonBar;
|
||||
|
|
|
@ -90,6 +90,15 @@ public:
|
|||
unsigned char m_Reserved;
|
||||
};
|
||||
|
||||
struct CMapItemInfo
|
||||
{
|
||||
int m_Version;
|
||||
int m_Author;
|
||||
int m_MapVersion;
|
||||
int m_Credits;
|
||||
int m_License;
|
||||
} ;
|
||||
|
||||
struct CMapItemImage
|
||||
{
|
||||
int m_Version;
|
||||
|
|
Loading…
Reference in a new issue