mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 01:24:18 +00:00
use array again and consider checkpoints
This commit is contained in:
parent
0ce70f863b
commit
9537656e57
|
@ -19,9 +19,9 @@
|
|||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
std::vector<vec2> GenerateMenuBackgroundPositions()
|
||||
std::array<vec2, CMenuBackground::NUM_POS> GenerateMenuBackgroundPositions()
|
||||
{
|
||||
std::vector<vec2> Positions(CMenuBackground::NUM_POS);
|
||||
std::array<vec2, CMenuBackground::NUM_POS> Positions;
|
||||
|
||||
Positions[CMenuBackground::POS_START] = vec2(500.0f, 500.0f);
|
||||
Positions[CMenuBackground::POS_BROWSER_INTERNET] = vec2(1000.0f, 1000.0f);
|
||||
|
|
|
@ -28,8 +28,6 @@ public:
|
|||
bool operator<(const CTheme &Other) const { return m_Name < Other.m_Name; }
|
||||
};
|
||||
|
||||
std::vector<vec2> GenerateMenuBackgroundPositions();
|
||||
|
||||
class CMenuBackground : public CBackground
|
||||
{
|
||||
std::chrono::nanoseconds m_ThemeScanStartTime{0};
|
||||
|
@ -85,7 +83,7 @@ public:
|
|||
|
||||
vec2 m_MenuCenter;
|
||||
vec2 m_RotationCenter;
|
||||
std::vector<vec2> m_aPositions;
|
||||
std::array<vec2, NUM_POS> m_aPositions;
|
||||
int m_CurrentPosition;
|
||||
vec2 m_AnimationStartPos;
|
||||
bool m_ChangedPosition;
|
||||
|
@ -119,4 +117,6 @@ public:
|
|||
std::vector<CTheme> &GetThemes();
|
||||
};
|
||||
|
||||
std::array<vec2, CMenuBackground::NUM_POS> GenerateMenuBackgroundPositions();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2827,6 +2827,7 @@ void CEditor::DoMapEditor(CUIRect View)
|
|||
// menu proof selection
|
||||
if(m_MenuProofBorders && !m_ShowPicker)
|
||||
{
|
||||
ResetMenuBackgroundPositions();
|
||||
for(int i = 0; i < (int)m_vMenuBackgroundPositions.size(); i++)
|
||||
{
|
||||
vec2 Pos = m_vMenuBackgroundPositions[i];
|
||||
|
@ -6911,15 +6912,7 @@ void CEditor::Init()
|
|||
|
||||
ms_PickerColor = ColorHSVA(1.0f, 0.0f, 0.0f);
|
||||
|
||||
m_vMenuBackgroundPositions = GenerateMenuBackgroundPositions();
|
||||
for(size_t i = 0; i < m_vMenuBackgroundPositions.size(); i++)
|
||||
{
|
||||
for(size_t j = 0; j < m_vMenuBackgroundPositions.size(); j++)
|
||||
{
|
||||
if(i != j && distance(m_vMenuBackgroundPositions[i], m_vMenuBackgroundPositions[j]) < 0.001f)
|
||||
m_vMenuBackgroundPositions[j] = vec2(0, 0);
|
||||
}
|
||||
}
|
||||
ResetMenuBackgroundPositions();
|
||||
}
|
||||
|
||||
void CEditor::PlaceBorderTiles()
|
||||
|
@ -7067,6 +7060,40 @@ void CEditor::LoadCurrentMap()
|
|||
|
||||
IEditor *CreateEditor() { return new CEditor; }
|
||||
|
||||
void CEditor::ResetMenuBackgroundPositions()
|
||||
{
|
||||
std::array<vec2, CMenuBackground::NUM_POS> aBackgroundPositions = GenerateMenuBackgroundPositions();
|
||||
m_vMenuBackgroundPositions.assign(aBackgroundPositions.begin(), aBackgroundPositions.end());
|
||||
|
||||
CLayerGame *pLayer = m_Map.m_pGameLayer;
|
||||
if(pLayer)
|
||||
{
|
||||
for(int y = 0; y < pLayer->m_Height; ++y)
|
||||
{
|
||||
for(int x = 0; x < pLayer->m_Width; ++x)
|
||||
{
|
||||
CTile Tile = pLayer->GetTile(x, y);
|
||||
if(Tile.m_Index >= TILE_TIME_CHECKPOINT_FIRST && Tile.m_Index <= TILE_TIME_CHECKPOINT_LAST)
|
||||
{
|
||||
int ArrayIndex = clamp<int>((Tile.m_Index - TILE_TIME_CHECKPOINT_FIRST), 0, CMenuBackground::NUM_POS);
|
||||
m_vMenuBackgroundPositions[ArrayIndex] = vec2(x * 32.0f + 16.0f, y * 32.0f + 16.0f);
|
||||
}
|
||||
|
||||
x += Tile.m_Skip;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < m_vMenuBackgroundPositions.size(); i++)
|
||||
{
|
||||
for(size_t j = 0; j < m_vMenuBackgroundPositions.size(); j++)
|
||||
{
|
||||
if(i != j && distance(m_vMenuBackgroundPositions[i], m_vMenuBackgroundPositions[j]) < 0.001f)
|
||||
m_vMenuBackgroundPositions[j] = vec2(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DDRace
|
||||
|
||||
void CEditorMap::MakeTeleLayer(CLayer *pLayer)
|
||||
|
|
|
@ -902,6 +902,8 @@ public:
|
|||
void LoadCurrentMap();
|
||||
void Render();
|
||||
|
||||
void ResetMenuBackgroundPositions();
|
||||
|
||||
std::vector<CQuad *> GetSelectedQuads();
|
||||
CLayer *GetSelectedLayerType(int Index, int Type) const;
|
||||
CLayer *GetSelectedLayer(int Index) const;
|
||||
|
|
|
@ -406,6 +406,7 @@ bool CEditor::Load(const char *pFileName, int StorageType)
|
|||
str_copy(m_aFileName, pFileName, 512);
|
||||
SortImages();
|
||||
SelectGameLayer();
|
||||
ResetMenuBackgroundPositions();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue