From 2084febca79d57de3fe1d2781bf0803dd3e96b27 Mon Sep 17 00:00:00 2001 From: Shereef Marzouk Date: Thu, 11 Aug 2011 10:43:27 +0200 Subject: Removed outdated comment --- src/game/mapitems.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/game/mapitems.h') diff --git a/src/game/mapitems.h b/src/game/mapitems.h index fb66e12d..43005f75 100644 --- a/src/game/mapitems.h +++ b/src/game/mapitems.h @@ -7,7 +7,7 @@ enum { LAYERTYPE_INVALID=0, - LAYERTYPE_GAME, // not used + LAYERTYPE_GAME, LAYERTYPE_TILES, LAYERTYPE_QUADS, -- cgit 1.4.1 From 9a03989e84c8d2719801889738c6af68864aba10 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 4 Dec 2011 14:34:27 +0100 Subject: added "Make an option for each envelope: (a) synchronized (b) starting at join" by Choupom --- src/game/client/components/maplayers.cpp | 13 +++++++++---- src/game/editor/editor.cpp | 11 +++++++++++ src/game/editor/editor.h | 2 ++ src/game/editor/io.cpp | 5 ++++- src/game/mapitems.h | 8 +++++++- 5 files changed, 33 insertions(+), 6 deletions(-) (limited to 'src/game/mapitems.h') diff --git a/src/game/client/components/maplayers.cpp b/src/game/client/components/maplayers.cpp index 48f11f26..a1e629a6 100644 --- a/src/game/client/components/maplayers.cpp +++ b/src/game/client/components/maplayers.cpp @@ -99,10 +99,15 @@ void CMapLayers::EnvelopeEval(float TimeOffset, int Env, float *pChannels, void } else { - if(pThis->m_pClient->m_Snap.m_pGameInfoObj) - Time = mix((pThis->Client()->PrevGameTick()-pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick) / (float)pThis->Client()->GameTickSpeed(), - (pThis->Client()->GameTick()-pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick) / (float)pThis->Client()->GameTickSpeed(), - pThis->Client()->IntraGameTick()); + if(pItem->m_Version < 2 || pItem->m_Synchronized) + { + if(pThis->m_pClient->m_Snap.m_pGameInfoObj) + Time = mix((pThis->Client()->PrevGameTick()-pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick) / (float)pThis->Client()->GameTickSpeed(), + (pThis->Client()->GameTick()-pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick) / (float)pThis->Client()->GameTickSpeed(), + pThis->Client()->IntraGameTick()); + } + else + Time = pThis->Client()->LocalTime(); pThis->RenderTools()->RenderEvalEnvelope(pPoints+pItem->m_StartPoint, pItem->m_NumPoints, 4, Time+TimeOffset, pChannels); } } diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 4f4096a9..d2a00d0d 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -3179,6 +3179,17 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) if(DoButton_Editor(&s_aChannelButtons[i], s_paNames[pEnvelope->m_Channels-3][i], s_ActiveChannels&Bit, &Button, 0, paDescriptions[pEnvelope->m_Channels-3][i])) s_ActiveChannels ^= Bit; } + + // sync checkbox + ToolBar.VSplitLeft(15.0f, &Button, &ToolBar); + ToolBar.VSplitLeft(12.0f, &Button, &ToolBar); + static int s_SyncButton; + if(DoButton_Editor(&s_SyncButton, pEnvelope->m_Synchronized?"X":"", 0, &Button, 0, "Enable envelope synchronization between clients")) + pEnvelope->m_Synchronized = !pEnvelope->m_Synchronized; + + ToolBar.VSplitLeft(4.0f, &Button, &ToolBar); + ToolBar.VSplitLeft(80.0f, &Button, &ToolBar); + UI()->DoLabel(&Button, "Synchronized", 10.0f, -1, -1); } float EndTime = pEnvelope->EndTime(); diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index 1f09b0bc..f5d43dae 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -51,6 +51,7 @@ public: array m_lPoints; char m_aName[32]; float m_Bottom, m_Top; + bool m_Synchronized; CEnvelope(int Chan) { @@ -58,6 +59,7 @@ public: m_aName[0] = 0; m_Bottom = 0; m_Top = 0; + m_Synchronized = true; } void Resort() diff --git a/src/game/editor/io.cpp b/src/game/editor/io.cpp index 68330f03..aec7231b 100644 --- a/src/game/editor/io.cpp +++ b/src/game/editor/io.cpp @@ -342,10 +342,11 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName) for(int e = 0; e < m_lEnvelopes.size(); e++) { CMapItemEnvelope Item; - Item.m_Version = 1; + Item.m_Version = CMapItemEnvelope::CURRENT_VERSION; Item.m_Channels = m_lEnvelopes[e]->m_Channels; Item.m_StartPoint = PointCount; Item.m_NumPoints = m_lEnvelopes[e]->m_lPoints.size(); + Item.m_Synchronized = m_lEnvelopes[e]->m_Synchronized; StrToInts(Item.m_aName, sizeof(Item.m_aName)/sizeof(int), m_lEnvelopes[e]->m_aName); df.AddItem(MAPITEMTYPE_ENVELOPE, e, sizeof(Item), &Item); @@ -601,6 +602,8 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag if(pItem->m_aName[0] != -1) // compatibility with old maps IntsToStr(pItem->m_aName, sizeof(pItem->m_aName)/sizeof(int), pEnv->m_aName); m_lEnvelopes.add(pEnv); + if(pItem->m_Version >= 2) + pEnv->m_Synchronized = pItem->m_Synchronized; } } } diff --git a/src/game/mapitems.h b/src/game/mapitems.h index 43005f75..bb2f4d19 100644 --- a/src/game/mapitems.h +++ b/src/game/mapitems.h @@ -178,7 +178,7 @@ struct CEnvPoint bool operator<(const CEnvPoint &Other) { return m_Time < Other.m_Time; } } ; -struct CMapItemEnvelope +struct CMapItemEnvelope_v1 { int m_Version; int m_Channels; @@ -187,4 +187,10 @@ struct CMapItemEnvelope int m_aName[8]; } ; +struct CMapItemEnvelope : public CMapItemEnvelope_v1 +{ + enum { CURRENT_VERSION=2 }; + int m_Synchronized; +}; + #endif -- cgit 1.4.1 From 65f4416164eb592efdcb56140f095944b485f8b6 Mon Sep 17 00:00:00 2001 From: SushiTee Date: Tue, 12 Jul 2011 23:31:39 +0200 Subject: added map info --- src/game/editor/editor.cpp | 20 +++++++++++++- src/game/editor/editor.h | 29 ++++++++++++++++++++ src/game/editor/io.cpp | 41 ++++++++++++++++++++++++++++ src/game/editor/popups.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++ src/game/mapitems.h | 9 ++++++ 5 files changed, 166 insertions(+), 1 deletion(-) (limited to 'src/game/mapitems.h') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 792c735a..fa1024e0 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -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; diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index 99ec964c..a81474d9 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -276,6 +276,34 @@ public: array m_lImages; array 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); diff --git a/src/game/editor/io.cpp b/src/game/editor/io.cpp index aec7231b..463147e1 100644 --- a/src/game/editor/io.cpp +++ b/src/game/editor/io.cpp @@ -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; diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index 64d0c799..2382823d 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -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; diff --git a/src/game/mapitems.h b/src/game/mapitems.h index bb2f4d19..e1dda4ee 100644 --- a/src/game/mapitems.h +++ b/src/game/mapitems.h @@ -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; -- cgit 1.4.1