mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 01:24:18 +00:00
Use std::vector instead of array in editor
This commit is contained in:
parent
3f8fb732a3
commit
0c69495522
|
@ -76,14 +76,16 @@ void CAutoMapper::Load(const char *pTileName)
|
|||
NewConf.m_StartY = 0;
|
||||
NewConf.m_EndX = 0;
|
||||
NewConf.m_EndY = 0;
|
||||
int ConfigurationID = m_lConfigs.add(NewConf);
|
||||
m_lConfigs.push_back(NewConf);
|
||||
int ConfigurationID = m_lConfigs.size() - 1;
|
||||
pCurrentConf = &m_lConfigs[ConfigurationID];
|
||||
str_copy(pCurrentConf->m_aName, pLine, str_length(pLine));
|
||||
|
||||
// add start run
|
||||
CRun NewRun;
|
||||
NewRun.m_AutomapCopy = true;
|
||||
int RunID = pCurrentConf->m_aRuns.add(NewRun);
|
||||
pCurrentConf->m_aRuns.push_back(NewRun);
|
||||
int RunID = pCurrentConf->m_aRuns.size() - 1;
|
||||
pCurrentRun = &pCurrentConf->m_aRuns[RunID];
|
||||
}
|
||||
else if(str_startswith(pLine, "NewRun") && pCurrentConf)
|
||||
|
@ -91,7 +93,8 @@ void CAutoMapper::Load(const char *pTileName)
|
|||
// add new run
|
||||
CRun NewRun;
|
||||
NewRun.m_AutomapCopy = true;
|
||||
int RunID = pCurrentConf->m_aRuns.add(NewRun);
|
||||
pCurrentConf->m_aRuns.push_back(NewRun);
|
||||
int RunID = pCurrentConf->m_aRuns.size() - 1;
|
||||
pCurrentRun = &pCurrentConf->m_aRuns[RunID];
|
||||
}
|
||||
else if(str_startswith(pLine, "Index") && pCurrentRun)
|
||||
|
@ -143,7 +146,8 @@ void CAutoMapper::Load(const char *pTileName)
|
|||
}
|
||||
|
||||
// add the index rule object and make it current
|
||||
int IndexRuleID = pCurrentRun->m_aIndexRules.add(NewIndexRule);
|
||||
pCurrentRun->m_aIndexRules.push_back(NewIndexRule);
|
||||
int IndexRuleID = pCurrentRun->m_aIndexRules.size() - 1;
|
||||
pCurrentIndex = &pCurrentRun->m_aIndexRules[IndexRuleID];
|
||||
}
|
||||
else if(str_startswith(pLine, "Pos") && pCurrentIndex)
|
||||
|
@ -151,7 +155,7 @@ void CAutoMapper::Load(const char *pTileName)
|
|||
int x = 0, y = 0;
|
||||
char aValue[128];
|
||||
int Value = CPosRule::NORULE;
|
||||
array<CIndexInfo> NewIndexList;
|
||||
std::vector<CIndexInfo> NewIndexList;
|
||||
|
||||
sscanf(pLine, "Pos %d %d %127s", &x, &y, aValue);
|
||||
|
||||
|
@ -159,15 +163,15 @@ void CAutoMapper::Load(const char *pTileName)
|
|||
{
|
||||
Value = CPosRule::INDEX;
|
||||
CIndexInfo NewIndexInfo = {0, 0, false};
|
||||
NewIndexList.add(NewIndexInfo);
|
||||
NewIndexList.push_back(NewIndexInfo);
|
||||
}
|
||||
else if(!str_comp(aValue, "FULL"))
|
||||
{
|
||||
Value = CPosRule::NOTINDEX;
|
||||
CIndexInfo NewIndexInfo1 = {0, 0, false};
|
||||
//CIndexInfo NewIndexInfo2 = {-1, 0};
|
||||
NewIndexList.add(NewIndexInfo1);
|
||||
//NewIndexList.add(NewIndexInfo2);
|
||||
NewIndexList.push_back(NewIndexInfo1);
|
||||
//NewIndexList.push_back(NewIndexInfo2);
|
||||
}
|
||||
else if(!str_comp(aValue, "INDEX") || !str_comp(aValue, "NOTINDEX"))
|
||||
{
|
||||
|
@ -193,7 +197,7 @@ void CAutoMapper::Load(const char *pTileName)
|
|||
|
||||
if(!str_comp(aOrientation1, "OR"))
|
||||
{
|
||||
NewIndexList.add(NewIndexInfo);
|
||||
NewIndexList.push_back(NewIndexInfo);
|
||||
pWord += 2;
|
||||
continue;
|
||||
}
|
||||
|
@ -213,13 +217,13 @@ void CAutoMapper::Load(const char *pTileName)
|
|||
}
|
||||
else
|
||||
{
|
||||
NewIndexList.add(NewIndexInfo);
|
||||
NewIndexList.push_back(NewIndexInfo);
|
||||
break;
|
||||
}
|
||||
|
||||
if(!str_comp(aOrientation2, "OR"))
|
||||
{
|
||||
NewIndexList.add(NewIndexInfo);
|
||||
NewIndexList.push_back(NewIndexInfo);
|
||||
pWord += 3;
|
||||
continue;
|
||||
}
|
||||
|
@ -234,13 +238,13 @@ void CAutoMapper::Load(const char *pTileName)
|
|||
}
|
||||
else
|
||||
{
|
||||
NewIndexList.add(NewIndexInfo);
|
||||
NewIndexList.push_back(NewIndexInfo);
|
||||
break;
|
||||
}
|
||||
|
||||
if(!str_comp(aOrientation3, "OR"))
|
||||
{
|
||||
NewIndexList.add(NewIndexInfo);
|
||||
NewIndexList.push_back(NewIndexInfo);
|
||||
pWord += 4;
|
||||
continue;
|
||||
}
|
||||
|
@ -255,19 +259,19 @@ void CAutoMapper::Load(const char *pTileName)
|
|||
}
|
||||
else
|
||||
{
|
||||
NewIndexList.add(NewIndexInfo);
|
||||
NewIndexList.push_back(NewIndexInfo);
|
||||
break;
|
||||
}
|
||||
|
||||
if(!str_comp(aOrientation4, "OR"))
|
||||
{
|
||||
NewIndexList.add(NewIndexInfo);
|
||||
NewIndexList.push_back(NewIndexInfo);
|
||||
pWord += 5;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
NewIndexList.add(NewIndexInfo);
|
||||
NewIndexList.push_back(NewIndexInfo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -276,7 +280,7 @@ void CAutoMapper::Load(const char *pTileName)
|
|||
if(Value != CPosRule::NORULE)
|
||||
{
|
||||
CPosRule NewPosRule = {x, y, Value, NewIndexList};
|
||||
pCurrentIndex->m_aRules.add(NewPosRule);
|
||||
pCurrentIndex->m_aRules.push_back(NewPosRule);
|
||||
|
||||
pCurrentConf->m_StartX = minimum(pCurrentConf->m_StartX, NewPosRule.m_X);
|
||||
pCurrentConf->m_StartY = minimum(pCurrentConf->m_StartY, NewPosRule.m_Y);
|
||||
|
@ -285,9 +289,9 @@ void CAutoMapper::Load(const char *pTileName)
|
|||
|
||||
if(x == 0 && y == 0)
|
||||
{
|
||||
for(int i = 0; i < NewIndexList.size(); ++i)
|
||||
for(const auto &Index : NewIndexList)
|
||||
{
|
||||
if(Value == CPosRule::INDEX && NewIndexList[i].m_ID == 0)
|
||||
if(Value == CPosRule::INDEX && Index.m_ID == 0)
|
||||
pCurrentIndex->m_SkipFull = true;
|
||||
else
|
||||
pCurrentIndex->m_SkipEmpty = true;
|
||||
|
@ -321,38 +325,36 @@ void CAutoMapper::Load(const char *pTileName)
|
|||
}
|
||||
|
||||
// add default rule for Pos 0 0 if there is none
|
||||
for(int g = 0; g < m_lConfigs.size(); ++g)
|
||||
for(auto &Config : m_lConfigs)
|
||||
{
|
||||
for(int h = 0; h < m_lConfigs[g].m_aRuns.size(); ++h)
|
||||
for(auto &Run : Config.m_aRuns)
|
||||
{
|
||||
for(int i = 0; i < m_lConfigs[g].m_aRuns[h].m_aIndexRules.size(); ++i)
|
||||
for(auto &IndexRule : Run.m_aIndexRules)
|
||||
{
|
||||
CIndexRule *pIndexRule = &m_lConfigs[g].m_aRuns[h].m_aIndexRules[i];
|
||||
bool Found = false;
|
||||
for(int j = 0; j < pIndexRule->m_aRules.size(); ++j)
|
||||
for(const auto &Rule : IndexRule.m_aRules)
|
||||
{
|
||||
CPosRule *pRule = &pIndexRule->m_aRules[j];
|
||||
if(pRule && pRule->m_X == 0 && pRule->m_Y == 0)
|
||||
if(Rule.m_X == 0 && Rule.m_Y == 0)
|
||||
{
|
||||
Found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!Found && pIndexRule->m_DefaultRule)
|
||||
if(!Found && IndexRule.m_DefaultRule)
|
||||
{
|
||||
array<CIndexInfo> NewIndexList;
|
||||
std::vector<CIndexInfo> NewIndexList;
|
||||
CIndexInfo NewIndexInfo = {0, 0, false};
|
||||
NewIndexList.add(NewIndexInfo);
|
||||
NewIndexList.push_back(NewIndexInfo);
|
||||
CPosRule NewPosRule = {0, 0, CPosRule::NOTINDEX, NewIndexList};
|
||||
pIndexRule->m_aRules.add(NewPosRule);
|
||||
IndexRule.m_aRules.push_back(NewPosRule);
|
||||
|
||||
pIndexRule->m_SkipEmpty = true;
|
||||
pIndexRule->m_SkipFull = false;
|
||||
IndexRule.m_SkipEmpty = true;
|
||||
IndexRule.m_SkipFull = false;
|
||||
}
|
||||
if(pIndexRule->m_SkipEmpty && pIndexRule->m_SkipFull)
|
||||
if(IndexRule.m_SkipEmpty && IndexRule.m_SkipFull)
|
||||
{
|
||||
pIndexRule->m_SkipEmpty = false;
|
||||
pIndexRule->m_SkipFull = false;
|
||||
IndexRule.m_SkipEmpty = false;
|
||||
IndexRule.m_SkipFull = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -368,7 +370,7 @@ void CAutoMapper::Load(const char *pTileName)
|
|||
|
||||
const char *CAutoMapper::GetConfigName(int Index)
|
||||
{
|
||||
if(Index < 0 || Index >= m_lConfigs.size())
|
||||
if(Index < 0 || Index >= (int)m_lConfigs.size())
|
||||
return "";
|
||||
|
||||
return m_lConfigs[Index].m_aName;
|
||||
|
@ -376,7 +378,7 @@ const char *CAutoMapper::GetConfigName(int Index)
|
|||
|
||||
void CAutoMapper::ProceedLocalized(CLayerTiles *pLayer, int ConfigID, int Seed, int X, int Y, int Width, int Height)
|
||||
{
|
||||
if(!m_FileLoaded || pLayer->m_Readonly || ConfigID < 0 || ConfigID >= m_lConfigs.size())
|
||||
if(!m_FileLoaded || pLayer->m_Readonly || ConfigID < 0 || ConfigID >= (int)m_lConfigs.size())
|
||||
return;
|
||||
|
||||
if(Width < 0)
|
||||
|
@ -428,7 +430,7 @@ void CAutoMapper::ProceedLocalized(CLayerTiles *pLayer, int ConfigID, int Seed,
|
|||
|
||||
void CAutoMapper::Proceed(CLayerTiles *pLayer, int ConfigID, int Seed, int SeedOffsetX, int SeedOffsetY)
|
||||
{
|
||||
if(!m_FileLoaded || pLayer->m_Readonly || ConfigID < 0 || ConfigID >= m_lConfigs.size())
|
||||
if(!m_FileLoaded || pLayer->m_Readonly || ConfigID < 0 || ConfigID >= (int)m_lConfigs.size())
|
||||
return;
|
||||
|
||||
if(Seed == 0)
|
||||
|
@ -437,7 +439,7 @@ void CAutoMapper::Proceed(CLayerTiles *pLayer, int ConfigID, int Seed, int SeedO
|
|||
CConfiguration *pConf = &m_lConfigs[ConfigID];
|
||||
|
||||
// for every run: copy tiles, automap, overwrite tiles
|
||||
for(int h = 0; h < pConf->m_aRuns.size(); ++h)
|
||||
for(size_t h = 0; h < pConf->m_aRuns.size(); ++h)
|
||||
{
|
||||
CRun *pRun = &pConf->m_aRuns[h];
|
||||
|
||||
|
@ -471,7 +473,7 @@ void CAutoMapper::Proceed(CLayerTiles *pLayer, int ConfigID, int Seed, int SeedO
|
|||
CTile *pTile = &(pLayer->m_pTiles[y * pLayer->m_Width + x]);
|
||||
m_pEditor->m_Map.m_Modified = true;
|
||||
|
||||
for(int i = 0; i < pRun->m_aIndexRules.size(); ++i)
|
||||
for(size_t i = 0; i < pRun->m_aIndexRules.size(); ++i)
|
||||
{
|
||||
CIndexRule *pIndexRule = &pRun->m_aIndexRules[i];
|
||||
if(pIndexRule->m_SkipEmpty && pTile->m_Index == 0) // skip empty tiles
|
||||
|
@ -480,7 +482,7 @@ void CAutoMapper::Proceed(CLayerTiles *pLayer, int ConfigID, int Seed, int SeedO
|
|||
continue;
|
||||
|
||||
bool RespectRules = true;
|
||||
for(int j = 0; j < pIndexRule->m_aRules.size() && RespectRules; ++j)
|
||||
for(size_t j = 0; j < pIndexRule->m_aRules.size() && RespectRules; ++j)
|
||||
{
|
||||
CPosRule *pRule = &pIndexRule->m_aRules[j];
|
||||
|
||||
|
@ -502,9 +504,9 @@ void CAutoMapper::Proceed(CLayerTiles *pLayer, int ConfigID, int Seed, int SeedO
|
|||
if(pRule->m_Value == CPosRule::INDEX)
|
||||
{
|
||||
RespectRules = false;
|
||||
for(int k = 0; k < pRule->m_aIndexList.size(); ++k)
|
||||
for(auto &Index : pRule->m_aIndexList)
|
||||
{
|
||||
if(CheckIndex == pRule->m_aIndexList[k].m_ID && (!pRule->m_aIndexList[k].m_TestFlag || CheckFlags == pRule->m_aIndexList[k].m_Flag))
|
||||
if(CheckIndex == Index.m_ID && (!Index.m_TestFlag || CheckFlags == Index.m_Flag))
|
||||
{
|
||||
RespectRules = true;
|
||||
break;
|
||||
|
@ -513,9 +515,9 @@ void CAutoMapper::Proceed(CLayerTiles *pLayer, int ConfigID, int Seed, int SeedO
|
|||
}
|
||||
else if(pRule->m_Value == CPosRule::NOTINDEX)
|
||||
{
|
||||
for(int k = 0; k < pRule->m_aIndexList.size(); ++k)
|
||||
for(auto &Index : pRule->m_aIndexList)
|
||||
{
|
||||
if(CheckIndex == pRule->m_aIndexList[k].m_ID && (!pRule->m_aIndexList[k].m_TestFlag || CheckFlags == pRule->m_aIndexList[k].m_Flag))
|
||||
if(CheckIndex == Index.m_ID && (!Index.m_TestFlag || CheckFlags == Index.m_Flag))
|
||||
{
|
||||
RespectRules = false;
|
||||
break;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef GAME_EDITOR_AUTO_MAP_H
|
||||
#define GAME_EDITOR_AUTO_MAP_H
|
||||
|
||||
#include <base/tl/array.h>
|
||||
#include <vector>
|
||||
|
||||
class CAutoMapper
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ class CAutoMapper
|
|||
int m_X;
|
||||
int m_Y;
|
||||
int m_Value;
|
||||
array<CIndexInfo> m_aIndexList;
|
||||
std::vector<CIndexInfo> m_aIndexList;
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ class CAutoMapper
|
|||
struct CIndexRule
|
||||
{
|
||||
int m_ID;
|
||||
array<CPosRule> m_aRules;
|
||||
std::vector<CPosRule> m_aRules;
|
||||
int m_Flag;
|
||||
float m_RandomProbability;
|
||||
bool m_DefaultRule;
|
||||
|
@ -40,13 +40,13 @@ class CAutoMapper
|
|||
|
||||
struct CRun
|
||||
{
|
||||
array<CIndexRule> m_aIndexRules;
|
||||
std::vector<CIndexRule> m_aIndexRules;
|
||||
bool m_AutomapCopy;
|
||||
};
|
||||
|
||||
struct CConfiguration
|
||||
{
|
||||
array<CRun> m_aRuns;
|
||||
std::vector<CRun> m_aRuns;
|
||||
char m_aName[128];
|
||||
int m_StartX;
|
||||
int m_StartY;
|
||||
|
@ -67,7 +67,7 @@ public:
|
|||
bool IsLoaded() const { return m_FileLoaded; }
|
||||
|
||||
private:
|
||||
array<CConfiguration> m_lConfigs;
|
||||
std::vector<CConfiguration> m_lConfigs;
|
||||
class CEditor *m_pEditor;
|
||||
bool m_FileLoaded;
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -10,9 +10,6 @@
|
|||
#include <base/math.h>
|
||||
#include <base/system.h>
|
||||
|
||||
#include <base/tl/algorithm.h>
|
||||
#include <base/tl/array.h>
|
||||
|
||||
#include <game/client/render.h>
|
||||
#include <game/client/ui.h>
|
||||
#include <game/client/ui_ex.h>
|
||||
|
@ -50,7 +47,7 @@ class CEnvelope
|
|||
{
|
||||
public:
|
||||
int m_Channels;
|
||||
array<CEnvPoint> m_lPoints;
|
||||
std::vector<CEnvPoint> m_lPoints;
|
||||
char m_aName[32];
|
||||
float m_Bottom, m_Top;
|
||||
bool m_Synchronized;
|
||||
|
@ -66,7 +63,7 @@ public:
|
|||
|
||||
void Resort()
|
||||
{
|
||||
sort(m_lPoints.all());
|
||||
std::sort(m_lPoints.begin(), m_lPoints.end());
|
||||
FindTopBottom(0xf);
|
||||
}
|
||||
|
||||
|
@ -74,13 +71,13 @@ public:
|
|||
{
|
||||
m_Top = -1000000000.0f;
|
||||
m_Bottom = 1000000000.0f;
|
||||
for(int i = 0; i < m_lPoints.size(); i++)
|
||||
for(auto &Point : m_lPoints)
|
||||
{
|
||||
for(int c = 0; c < m_Channels; c++)
|
||||
{
|
||||
if(ChannelMask & (1 << c))
|
||||
{
|
||||
float v = fx2f(m_lPoints[i].m_aValues[c]);
|
||||
float v = fx2f(Point.m_aValues[c]);
|
||||
if(v > m_Top)
|
||||
m_Top = v;
|
||||
if(v < m_Bottom)
|
||||
|
@ -92,7 +89,7 @@ public:
|
|||
|
||||
int Eval(float Time, float *pResult)
|
||||
{
|
||||
CRenderTools::RenderEvalEnvelope(m_lPoints.base_ptr(), m_lPoints.size(), m_Channels, std::chrono::nanoseconds((int64_t)((double)Time * (double)std::chrono::nanoseconds(1s).count())), pResult);
|
||||
CRenderTools::RenderEvalEnvelope(&m_lPoints[0], m_lPoints.size(), m_Channels, std::chrono::nanoseconds((int64_t)((double)Time * (double)std::chrono::nanoseconds(1s).count())), pResult);
|
||||
return m_Channels;
|
||||
}
|
||||
|
||||
|
@ -105,13 +102,13 @@ public:
|
|||
p.m_aValues[2] = v2;
|
||||
p.m_aValues[3] = v3;
|
||||
p.m_Curvetype = CURVETYPE_LINEAR;
|
||||
m_lPoints.add(p);
|
||||
m_lPoints.push_back(p);
|
||||
Resort();
|
||||
}
|
||||
|
||||
float EndTime() const
|
||||
{
|
||||
if(m_lPoints.size())
|
||||
if(!m_lPoints.empty())
|
||||
return m_lPoints[m_lPoints.size() - 1].m_Time * (1.0f / 1000.0f);
|
||||
return 0;
|
||||
}
|
||||
|
@ -180,7 +177,7 @@ class CLayerGroup
|
|||
public:
|
||||
class CEditorMap *m_pMap;
|
||||
|
||||
array<CLayer *> m_lLayers;
|
||||
std::vector<CLayer *> m_lLayers;
|
||||
|
||||
int m_OffsetX;
|
||||
int m_OffsetY;
|
||||
|
@ -261,20 +258,20 @@ public:
|
|||
|
||||
void ModifyImageIndex(INDEX_MODIFY_FUNC Func)
|
||||
{
|
||||
for(int i = 0; i < m_lLayers.size(); i++)
|
||||
m_lLayers[i]->ModifyImageIndex(Func);
|
||||
for(auto &pLayer : m_lLayers)
|
||||
pLayer->ModifyImageIndex(Func);
|
||||
}
|
||||
|
||||
void ModifyEnvelopeIndex(INDEX_MODIFY_FUNC Func)
|
||||
{
|
||||
for(int i = 0; i < m_lLayers.size(); i++)
|
||||
m_lLayers[i]->ModifyEnvelopeIndex(Func);
|
||||
for(auto &pLayer : m_lLayers)
|
||||
pLayer->ModifyEnvelopeIndex(Func);
|
||||
}
|
||||
|
||||
void ModifySoundIndex(INDEX_MODIFY_FUNC Func)
|
||||
{
|
||||
for(int i = 0; i < m_lLayers.size(); i++)
|
||||
m_lLayers[i]->ModifySoundIndex(Func);
|
||||
for(auto &pLayer : m_lLayers)
|
||||
pLayer->ModifySoundIndex(Func);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -349,10 +346,10 @@ public:
|
|||
Clean();
|
||||
}
|
||||
|
||||
array<CLayerGroup *> m_lGroups;
|
||||
array<CEditorImage *> m_lImages;
|
||||
array<CEnvelope *> m_lEnvelopes;
|
||||
array<CEditorSound *> m_lSounds;
|
||||
std::vector<CLayerGroup *> m_lGroups;
|
||||
std::vector<CEditorImage *> m_lImages;
|
||||
std::vector<CEnvelope *> m_lEnvelopes;
|
||||
std::vector<CEditorSound *> m_lSounds;
|
||||
|
||||
class CMapInfo
|
||||
{
|
||||
|
@ -386,7 +383,7 @@ public:
|
|||
{
|
||||
char m_aCommand[256];
|
||||
};
|
||||
array<CSetting> m_lSettings;
|
||||
std::vector<CSetting> m_lSettings;
|
||||
|
||||
class CLayerGame *m_pGameLayer;
|
||||
CLayerGroup *m_pGameGroup;
|
||||
|
@ -395,7 +392,7 @@ public:
|
|||
{
|
||||
m_Modified = true;
|
||||
CEnvelope *e = new CEnvelope(Channels);
|
||||
m_lEnvelopes.add(e);
|
||||
m_lEnvelopes.push_back(e);
|
||||
return e;
|
||||
}
|
||||
|
||||
|
@ -406,15 +403,15 @@ public:
|
|||
m_Modified = true;
|
||||
CLayerGroup *g = new CLayerGroup;
|
||||
g->m_pMap = this;
|
||||
m_lGroups.add(g);
|
||||
m_lGroups.push_back(g);
|
||||
return g;
|
||||
}
|
||||
|
||||
int SwapGroups(int Index0, int Index1)
|
||||
{
|
||||
if(Index0 < 0 || Index0 >= m_lGroups.size())
|
||||
if(Index0 < 0 || Index0 >= (int)m_lGroups.size())
|
||||
return Index0;
|
||||
if(Index1 < 0 || Index1 >= m_lGroups.size())
|
||||
if(Index1 < 0 || Index1 >= (int)m_lGroups.size())
|
||||
return Index0;
|
||||
if(Index0 == Index1)
|
||||
return Index0;
|
||||
|
@ -425,32 +422,32 @@ public:
|
|||
|
||||
void DeleteGroup(int Index)
|
||||
{
|
||||
if(Index < 0 || Index >= m_lGroups.size())
|
||||
if(Index < 0 || Index >= (int)m_lGroups.size())
|
||||
return;
|
||||
m_Modified = true;
|
||||
delete m_lGroups[Index];
|
||||
m_lGroups.remove_index(Index);
|
||||
m_lGroups.erase(m_lGroups.begin() + Index);
|
||||
}
|
||||
|
||||
void ModifyImageIndex(INDEX_MODIFY_FUNC pfnFunc)
|
||||
{
|
||||
m_Modified = true;
|
||||
for(int i = 0; i < m_lGroups.size(); i++)
|
||||
m_lGroups[i]->ModifyImageIndex(pfnFunc);
|
||||
for(auto &pGroup : m_lGroups)
|
||||
pGroup->ModifyImageIndex(pfnFunc);
|
||||
}
|
||||
|
||||
void ModifyEnvelopeIndex(INDEX_MODIFY_FUNC pfnFunc)
|
||||
{
|
||||
m_Modified = true;
|
||||
for(int i = 0; i < m_lGroups.size(); i++)
|
||||
m_lGroups[i]->ModifyEnvelopeIndex(pfnFunc);
|
||||
for(auto &pGroup : m_lGroups)
|
||||
pGroup->ModifyEnvelopeIndex(pfnFunc);
|
||||
}
|
||||
|
||||
void ModifySoundIndex(INDEX_MODIFY_FUNC pfnFunc)
|
||||
{
|
||||
m_Modified = true;
|
||||
for(int i = 0; i < m_lGroups.size(); i++)
|
||||
m_lGroups[i]->ModifySoundIndex(pfnFunc);
|
||||
for(auto &pGroup : m_lGroups)
|
||||
pGroup->ModifySoundIndex(pfnFunc);
|
||||
}
|
||||
|
||||
void Clean();
|
||||
|
@ -552,7 +549,7 @@ public:
|
|||
int Height = -1;
|
||||
int Color = 0;
|
||||
};
|
||||
static int RenderCommonProperties(SCommonPropState &State, CEditor *pEditor, CUIRect *pToolbox, array<CLayerTiles *> &pLayers);
|
||||
static int RenderCommonProperties(SCommonPropState &State, CEditor *pEditor, CUIRect *pToolbox, std::vector<CLayerTiles *> &pLayers);
|
||||
|
||||
void ModifyImageIndex(INDEX_MODIFY_FUNC pfnFunc) override;
|
||||
void ModifyEnvelopeIndex(INDEX_MODIFY_FUNC pfnFunc) override;
|
||||
|
@ -614,7 +611,7 @@ public:
|
|||
void GetSize(float *w, float *h) override;
|
||||
|
||||
int m_Image;
|
||||
array<CQuad> m_lQuads;
|
||||
std::vector<CQuad> m_lQuads;
|
||||
};
|
||||
|
||||
class CLayerGame : public CLayerTiles
|
||||
|
@ -789,7 +786,7 @@ public:
|
|||
void LoadCurrentMap();
|
||||
void Render();
|
||||
|
||||
array<CQuad *> GetSelectedQuads();
|
||||
std::vector<CQuad *> GetSelectedQuads();
|
||||
CLayer *GetSelectedLayerType(int Index, int Type) const;
|
||||
CLayer *GetSelectedLayer(int Index) const;
|
||||
CLayerGroup *GetSelectedGroup() const;
|
||||
|
@ -918,8 +915,8 @@ public:
|
|||
bool m_ShowServerSettingsEditor;
|
||||
bool m_ShowPicker;
|
||||
|
||||
array<int> m_lSelectedLayers;
|
||||
array<int> m_lSelectedQuads;
|
||||
std::vector<int> m_lSelectedLayers;
|
||||
std::vector<int> m_lSelectedQuads;
|
||||
int m_SelectedQuadPoint;
|
||||
int m_SelectedQuadIndex;
|
||||
int m_SelectedGroup;
|
||||
|
@ -990,7 +987,7 @@ public:
|
|||
|
||||
struct CLayerPopupContext
|
||||
{
|
||||
array<CLayerTiles *> m_aLayers;
|
||||
std::vector<CLayerTiles *> m_aLayers;
|
||||
CLayerTiles::SCommonPropState m_CommonPropState;
|
||||
};
|
||||
static int PopupLayer(CEditor *pEditor, CUIRect View, void *pContext);
|
||||
|
@ -1027,7 +1024,7 @@ public:
|
|||
void PopupSelectSoundInvoke(int Current, float x, float y);
|
||||
int PopupSelectSoundResult();
|
||||
|
||||
void DoQuadEnvelopes(const array<CQuad> &m_lQuads, IGraphics::CTextureHandle Texture = IGraphics::CTextureHandle());
|
||||
void DoQuadEnvelopes(const std::vector<CQuad> &m_lQuads, IGraphics::CTextureHandle Texture = IGraphics::CTextureHandle());
|
||||
void DoQuadEnvPoint(const CQuad *pQuad, int QIndex, int pIndex);
|
||||
void DoQuadPoint(CQuad *pQuad, int QuadIndex, int v);
|
||||
|
||||
|
@ -1287,7 +1284,7 @@ public:
|
|||
void ModifySoundIndex(INDEX_MODIFY_FUNC pfnFunc) override;
|
||||
|
||||
int m_Sound;
|
||||
array<CSoundSource> m_lSources;
|
||||
std::vector<CSoundSource> m_lSources;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -260,20 +260,20 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
|
|||
Item.m_License = -1;
|
||||
|
||||
Item.m_Settings = -1;
|
||||
if(m_lSettings.size())
|
||||
if(!m_lSettings.empty())
|
||||
{
|
||||
int Size = 0;
|
||||
for(int i = 0; i < m_lSettings.size(); i++)
|
||||
for(const auto &Setting : m_lSettings)
|
||||
{
|
||||
Size += str_length(m_lSettings[i].m_aCommand) + 1;
|
||||
Size += str_length(Setting.m_aCommand) + 1;
|
||||
}
|
||||
|
||||
char *pSettings = (char *)malloc(maximum(Size, 1));
|
||||
char *pNext = pSettings;
|
||||
for(int i = 0; i < m_lSettings.size(); i++)
|
||||
for(const auto &Setting : m_lSettings)
|
||||
{
|
||||
int Length = str_length(m_lSettings[i].m_aCommand) + 1;
|
||||
mem_copy(pNext, m_lSettings[i].m_aCommand, Length);
|
||||
int Length = str_length(Setting.m_aCommand) + 1;
|
||||
mem_copy(pNext, Setting.m_aCommand, Length);
|
||||
pNext += Length;
|
||||
}
|
||||
Item.m_Settings = df.AddData(Size, pSettings);
|
||||
|
@ -284,7 +284,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
|
|||
}
|
||||
|
||||
// save images
|
||||
for(int i = 0; i < m_lImages.size(); i++)
|
||||
for(size_t i = 0; i < m_lImages.size(); i++)
|
||||
{
|
||||
CEditorImage *pImg = m_lImages[i];
|
||||
|
||||
|
@ -327,7 +327,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
|
|||
}
|
||||
|
||||
// save sounds
|
||||
for(int i = 0; i < m_lSounds.size(); i++)
|
||||
for(size_t i = 0; i < m_lSounds.size(); i++)
|
||||
{
|
||||
CEditorSound *pSound = m_lSounds[i];
|
||||
|
||||
|
@ -345,9 +345,8 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
|
|||
// save layers
|
||||
int LayerCount = 0, GroupCount = 0;
|
||||
int AutomapperCount = 0;
|
||||
for(int g = 0; g < m_lGroups.size(); g++)
|
||||
for(const auto &pGroup : m_lGroups)
|
||||
{
|
||||
CLayerGroup *pGroup = m_lGroups[g];
|
||||
CMapItemGroup GItem;
|
||||
GItem.m_Version = CMapItemGroup::CURRENT_VERSION;
|
||||
|
||||
|
@ -366,43 +365,43 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
|
|||
// save group name
|
||||
StrToInts(GItem.m_aName, sizeof(GItem.m_aName) / sizeof(int), pGroup->m_aName);
|
||||
|
||||
for(int l = 0; l < pGroup->m_lLayers.size(); l++)
|
||||
for(const auto &pLayer : pGroup->m_lLayers)
|
||||
{
|
||||
if(pGroup->m_lLayers[l]->m_Type == LAYERTYPE_TILES)
|
||||
if(pLayer->m_Type == LAYERTYPE_TILES)
|
||||
{
|
||||
m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving tiles layer");
|
||||
CLayerTiles *pLayer = (CLayerTiles *)pGroup->m_lLayers[l];
|
||||
pLayer->PrepareForSave();
|
||||
CLayerTiles *pLayerTiles = (CLayerTiles *)pLayer;
|
||||
pLayerTiles->PrepareForSave();
|
||||
|
||||
CMapItemLayerTilemap Item;
|
||||
Item.m_Version = 3;
|
||||
|
||||
Item.m_Layer.m_Version = 0; // was previously uninitialized, do not rely on it being 0
|
||||
Item.m_Layer.m_Flags = pLayer->m_Flags;
|
||||
Item.m_Layer.m_Type = pLayer->m_Type;
|
||||
Item.m_Layer.m_Flags = pLayerTiles->m_Flags;
|
||||
Item.m_Layer.m_Type = pLayerTiles->m_Type;
|
||||
|
||||
Item.m_Color = pLayer->m_Color;
|
||||
Item.m_ColorEnv = pLayer->m_ColorEnv;
|
||||
Item.m_ColorEnvOffset = pLayer->m_ColorEnvOffset;
|
||||
Item.m_Color = pLayerTiles->m_Color;
|
||||
Item.m_ColorEnv = pLayerTiles->m_ColorEnv;
|
||||
Item.m_ColorEnvOffset = pLayerTiles->m_ColorEnvOffset;
|
||||
|
||||
Item.m_Width = pLayer->m_Width;
|
||||
Item.m_Height = pLayer->m_Height;
|
||||
// Item.m_Flags = pLayer->m_Game ? TILESLAYERFLAG_GAME : 0;
|
||||
Item.m_Width = pLayerTiles->m_Width;
|
||||
Item.m_Height = pLayerTiles->m_Height;
|
||||
// Item.m_Flags = pLayerTiles->m_Game ? TILESLAYERFLAG_GAME : 0;
|
||||
|
||||
if(pLayer->m_Tele)
|
||||
if(pLayerTiles->m_Tele)
|
||||
Item.m_Flags = TILESLAYERFLAG_TELE;
|
||||
else if(pLayer->m_Speedup)
|
||||
else if(pLayerTiles->m_Speedup)
|
||||
Item.m_Flags = TILESLAYERFLAG_SPEEDUP;
|
||||
else if(pLayer->m_Front)
|
||||
else if(pLayerTiles->m_Front)
|
||||
Item.m_Flags = TILESLAYERFLAG_FRONT;
|
||||
else if(pLayer->m_Switch)
|
||||
else if(pLayerTiles->m_Switch)
|
||||
Item.m_Flags = TILESLAYERFLAG_SWITCH;
|
||||
else if(pLayer->m_Tune)
|
||||
else if(pLayerTiles->m_Tune)
|
||||
Item.m_Flags = TILESLAYERFLAG_TUNE;
|
||||
else
|
||||
Item.m_Flags = pLayer->m_Game ? TILESLAYERFLAG_GAME : 0;
|
||||
Item.m_Flags = pLayerTiles->m_Game ? TILESLAYERFLAG_GAME : 0;
|
||||
|
||||
Item.m_Image = pLayer->m_Image;
|
||||
Item.m_Image = pLayerTiles->m_Image;
|
||||
|
||||
// the following values were previously uninitialized, do not rely on them being -1 when unused
|
||||
Item.m_Tele = -1;
|
||||
|
@ -411,29 +410,29 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
|
|||
Item.m_Switch = -1;
|
||||
Item.m_Tune = -1;
|
||||
|
||||
if(Item.m_Flags && !(pLayer->m_Game))
|
||||
if(Item.m_Flags && !(pLayerTiles->m_Game))
|
||||
{
|
||||
CTile *pEmptyTiles = (CTile *)calloc((size_t)pLayer->m_Width * pLayer->m_Height, sizeof(CTile));
|
||||
mem_zero(pEmptyTiles, (size_t)pLayer->m_Width * pLayer->m_Height * sizeof(CTile));
|
||||
Item.m_Data = df.AddData((size_t)pLayer->m_Width * pLayer->m_Height * sizeof(CTile), pEmptyTiles);
|
||||
CTile *pEmptyTiles = (CTile *)calloc((size_t)pLayerTiles->m_Width * pLayerTiles->m_Height, sizeof(CTile));
|
||||
mem_zero(pEmptyTiles, (size_t)pLayerTiles->m_Width * pLayerTiles->m_Height * sizeof(CTile));
|
||||
Item.m_Data = df.AddData((size_t)pLayerTiles->m_Width * pLayerTiles->m_Height * sizeof(CTile), pEmptyTiles);
|
||||
free(pEmptyTiles);
|
||||
|
||||
if(pLayer->m_Tele)
|
||||
Item.m_Tele = df.AddData((size_t)pLayer->m_Width * pLayer->m_Height * sizeof(CTeleTile), ((CLayerTele *)pLayer)->m_pTeleTile);
|
||||
else if(pLayer->m_Speedup)
|
||||
Item.m_Speedup = df.AddData((size_t)pLayer->m_Width * pLayer->m_Height * sizeof(CSpeedupTile), ((CLayerSpeedup *)pLayer)->m_pSpeedupTile);
|
||||
else if(pLayer->m_Front)
|
||||
Item.m_Front = df.AddData((size_t)pLayer->m_Width * pLayer->m_Height * sizeof(CTile), pLayer->m_pTiles);
|
||||
else if(pLayer->m_Switch)
|
||||
Item.m_Switch = df.AddData((size_t)pLayer->m_Width * pLayer->m_Height * sizeof(CSwitchTile), ((CLayerSwitch *)pLayer)->m_pSwitchTile);
|
||||
else if(pLayer->m_Tune)
|
||||
Item.m_Tune = df.AddData((size_t)pLayer->m_Width * pLayer->m_Height * sizeof(CTuneTile), ((CLayerTune *)pLayer)->m_pTuneTile);
|
||||
if(pLayerTiles->m_Tele)
|
||||
Item.m_Tele = df.AddData((size_t)pLayerTiles->m_Width * pLayerTiles->m_Height * sizeof(CTeleTile), ((CLayerTele *)pLayerTiles)->m_pTeleTile);
|
||||
else if(pLayerTiles->m_Speedup)
|
||||
Item.m_Speedup = df.AddData((size_t)pLayerTiles->m_Width * pLayerTiles->m_Height * sizeof(CSpeedupTile), ((CLayerSpeedup *)pLayerTiles)->m_pSpeedupTile);
|
||||
else if(pLayerTiles->m_Front)
|
||||
Item.m_Front = df.AddData((size_t)pLayerTiles->m_Width * pLayerTiles->m_Height * sizeof(CTile), pLayerTiles->m_pTiles);
|
||||
else if(pLayerTiles->m_Switch)
|
||||
Item.m_Switch = df.AddData((size_t)pLayerTiles->m_Width * pLayerTiles->m_Height * sizeof(CSwitchTile), ((CLayerSwitch *)pLayerTiles)->m_pSwitchTile);
|
||||
else if(pLayerTiles->m_Tune)
|
||||
Item.m_Tune = df.AddData((size_t)pLayerTiles->m_Width * pLayerTiles->m_Height * sizeof(CTuneTile), ((CLayerTune *)pLayerTiles)->m_pTuneTile);
|
||||
}
|
||||
else
|
||||
Item.m_Data = df.AddData((size_t)pLayer->m_Width * pLayer->m_Height * sizeof(CTile), pLayer->m_pTiles);
|
||||
Item.m_Data = df.AddData((size_t)pLayerTiles->m_Width * pLayerTiles->m_Height * sizeof(CTile), pLayerTiles->m_pTiles);
|
||||
|
||||
// save layer name
|
||||
StrToInts(Item.m_aName, sizeof(Item.m_aName) / sizeof(int), pLayer->m_aName);
|
||||
StrToInts(Item.m_aName, sizeof(Item.m_aName) / sizeof(int), pLayerTiles->m_aName);
|
||||
|
||||
df.AddItem(MAPITEMTYPE_LAYER, LayerCount, sizeof(Item), &Item);
|
||||
|
||||
|
@ -444,10 +443,10 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
|
|||
ItemAutomapper.m_Version = CMapItemAutoMapperConfig::CURRENT_VERSION;
|
||||
ItemAutomapper.m_GroupId = GroupCount;
|
||||
ItemAutomapper.m_LayerId = GItem.m_NumLayers;
|
||||
ItemAutomapper.m_AutomapperConfig = pLayer->m_AutoMapperConfig;
|
||||
ItemAutomapper.m_AutomapperSeed = pLayer->m_Seed;
|
||||
ItemAutomapper.m_AutomapperConfig = pLayerTiles->m_AutoMapperConfig;
|
||||
ItemAutomapper.m_AutomapperSeed = pLayerTiles->m_Seed;
|
||||
ItemAutomapper.m_Flags = 0;
|
||||
if(pLayer->m_AutoAutoMap)
|
||||
if(pLayerTiles->m_AutoAutoMap)
|
||||
ItemAutomapper.m_Flags |= CMapItemAutoMapperConfig::FLAG_AUTOMATIC;
|
||||
|
||||
df.AddItem(MAPITEMTYPE_AUTOMAPPER_CONFIG, AutomapperCount, sizeof(ItemAutomapper), &ItemAutomapper);
|
||||
|
@ -457,25 +456,25 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
|
|||
GItem.m_NumLayers++;
|
||||
LayerCount++;
|
||||
}
|
||||
else if(pGroup->m_lLayers[l]->m_Type == LAYERTYPE_QUADS)
|
||||
else if(pLayer->m_Type == LAYERTYPE_QUADS)
|
||||
{
|
||||
m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving quads layer");
|
||||
CLayerQuads *pLayer = (CLayerQuads *)pGroup->m_lLayers[l];
|
||||
if(pLayer->m_lQuads.size())
|
||||
CLayerQuads *pLayerQuads = (CLayerQuads *)pLayer;
|
||||
if(!pLayerQuads->m_lQuads.empty())
|
||||
{
|
||||
CMapItemLayerQuads Item;
|
||||
Item.m_Version = 2;
|
||||
Item.m_Layer.m_Version = 0; // was previously uninitialized, do not rely on it being 0
|
||||
Item.m_Layer.m_Flags = pLayer->m_Flags;
|
||||
Item.m_Layer.m_Type = pLayer->m_Type;
|
||||
Item.m_Image = pLayer->m_Image;
|
||||
Item.m_Layer.m_Flags = pLayerQuads->m_Flags;
|
||||
Item.m_Layer.m_Type = pLayerQuads->m_Type;
|
||||
Item.m_Image = pLayerQuads->m_Image;
|
||||
|
||||
// add the data
|
||||
Item.m_NumQuads = pLayer->m_lQuads.size();
|
||||
Item.m_Data = df.AddDataSwapped(pLayer->m_lQuads.size() * sizeof(CQuad), pLayer->m_lQuads.base_ptr());
|
||||
Item.m_NumQuads = pLayerQuads->m_lQuads.size();
|
||||
Item.m_Data = df.AddDataSwapped(pLayerQuads->m_lQuads.size() * sizeof(CQuad), &pLayerQuads->m_lQuads[0]);
|
||||
|
||||
// save layer name
|
||||
StrToInts(Item.m_aName, sizeof(Item.m_aName) / sizeof(int), pLayer->m_aName);
|
||||
StrToInts(Item.m_aName, sizeof(Item.m_aName) / sizeof(int), pLayerQuads->m_aName);
|
||||
|
||||
df.AddItem(MAPITEMTYPE_LAYER, LayerCount, sizeof(Item), &Item);
|
||||
|
||||
|
@ -486,25 +485,25 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
|
|||
LayerCount++;
|
||||
}
|
||||
}
|
||||
else if(pGroup->m_lLayers[l]->m_Type == LAYERTYPE_SOUNDS)
|
||||
else if(pLayer->m_Type == LAYERTYPE_SOUNDS)
|
||||
{
|
||||
m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving sounds layer");
|
||||
CLayerSounds *pLayer = (CLayerSounds *)pGroup->m_lLayers[l];
|
||||
if(pLayer->m_lSources.size())
|
||||
CLayerSounds *pLayerSounds = (CLayerSounds *)pLayer;
|
||||
if(!pLayerSounds->m_lSources.empty())
|
||||
{
|
||||
CMapItemLayerSounds Item;
|
||||
Item.m_Version = CMapItemLayerSounds::CURRENT_VERSION;
|
||||
Item.m_Layer.m_Version = 0; // was previously uninitialized, do not rely on it being 0
|
||||
Item.m_Layer.m_Flags = pLayer->m_Flags;
|
||||
Item.m_Layer.m_Type = pLayer->m_Type;
|
||||
Item.m_Sound = pLayer->m_Sound;
|
||||
Item.m_Layer.m_Flags = pLayerSounds->m_Flags;
|
||||
Item.m_Layer.m_Type = pLayerSounds->m_Type;
|
||||
Item.m_Sound = pLayerSounds->m_Sound;
|
||||
|
||||
// add the data
|
||||
Item.m_NumSources = pLayer->m_lSources.size();
|
||||
Item.m_Data = df.AddDataSwapped(pLayer->m_lSources.size() * sizeof(CSoundSource), pLayer->m_lSources.base_ptr());
|
||||
Item.m_NumSources = pLayerSounds->m_lSources.size();
|
||||
Item.m_Data = df.AddDataSwapped(pLayerSounds->m_lSources.size() * sizeof(CSoundSource), &pLayerSounds->m_lSources[0]);
|
||||
|
||||
// save layer name
|
||||
StrToInts(Item.m_aName, sizeof(Item.m_aName) / sizeof(int), pLayer->m_aName);
|
||||
StrToInts(Item.m_aName, sizeof(Item.m_aName) / sizeof(int), pLayerSounds->m_aName);
|
||||
|
||||
df.AddItem(MAPITEMTYPE_LAYER, LayerCount, sizeof(Item), &Item);
|
||||
GItem.m_NumLayers++;
|
||||
|
@ -518,7 +517,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
|
|||
|
||||
// save envelopes
|
||||
int PointCount = 0;
|
||||
for(int e = 0; e < m_lEnvelopes.size(); e++)
|
||||
for(size_t e = 0; e < m_lEnvelopes.size(); e++)
|
||||
{
|
||||
CMapItemEnvelope Item;
|
||||
Item.m_Version = CMapItemEnvelope::CURRENT_VERSION;
|
||||
|
@ -537,10 +536,10 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
|
|||
CEnvPoint *pPoints = (CEnvPoint *)calloc(maximum(PointCount, 1), sizeof(*pPoints));
|
||||
PointCount = 0;
|
||||
|
||||
for(int e = 0; e < m_lEnvelopes.size(); e++)
|
||||
for(const auto &pEnvelope : m_lEnvelopes)
|
||||
{
|
||||
int Count = m_lEnvelopes[e]->m_lPoints.size();
|
||||
mem_copy(&pPoints[PointCount], m_lEnvelopes[e]->m_lPoints.base_ptr(), sizeof(CEnvPoint) * Count);
|
||||
int Count = pEnvelope->m_lPoints.size();
|
||||
mem_copy(&pPoints[PointCount], &pEnvelope->m_lPoints[0], sizeof(CEnvPoint) * Count);
|
||||
PointCount += Count;
|
||||
}
|
||||
|
||||
|
@ -649,7 +648,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
|
|||
int StrSize = str_length(pNext) + 1;
|
||||
CSetting Setting;
|
||||
str_copy(Setting.m_aCommand, pNext, sizeof(Setting.m_aCommand));
|
||||
m_lSettings.add(Setting);
|
||||
m_lSettings.push_back(Setting);
|
||||
pNext += StrSize;
|
||||
}
|
||||
}
|
||||
|
@ -709,7 +708,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
|
|||
// load auto mapper file
|
||||
pImg->m_AutoMapper.Load(pImg->m_aName);
|
||||
|
||||
m_lImages.add(pImg);
|
||||
m_lImages.push_back(pImg);
|
||||
|
||||
// unload image
|
||||
DataFile.UnloadData(pItem->m_ImageData);
|
||||
|
@ -768,7 +767,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
|
|||
if(pName)
|
||||
str_copy(pSound->m_aName, pName, sizeof(pSound->m_aName));
|
||||
|
||||
m_lSounds.add(pSound);
|
||||
m_lSounds.push_back(pSound);
|
||||
|
||||
// unload image
|
||||
DataFile.UnloadData(pItem->m_SoundData);
|
||||
|
@ -1156,7 +1155,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
|
|||
pQuads->m_pEditor = m_pEditor;
|
||||
pLayer = pQuads;
|
||||
pQuads->m_Image = pQuadsItem->m_Image;
|
||||
if(pQuads->m_Image < -1 || pQuads->m_Image >= m_lImages.size())
|
||||
if(pQuads->m_Image < -1 || pQuads->m_Image >= (int)m_lImages.size())
|
||||
pQuads->m_Image = -1;
|
||||
|
||||
// load layer name
|
||||
|
@ -1165,8 +1164,8 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
|
|||
|
||||
void *pData = DataFile.GetDataSwapped(pQuadsItem->m_Data);
|
||||
pGroup->AddLayer(pQuads);
|
||||
pQuads->m_lQuads.set_size(pQuadsItem->m_NumQuads);
|
||||
mem_copy(pQuads->m_lQuads.base_ptr(), pData, sizeof(CQuad) * pQuadsItem->m_NumQuads);
|
||||
pQuads->m_lQuads.resize(pQuadsItem->m_NumQuads);
|
||||
mem_copy(&pQuads->m_lQuads[0], pData, sizeof(CQuad) * pQuadsItem->m_NumQuads);
|
||||
DataFile.UnloadData(pQuadsItem->m_Data);
|
||||
}
|
||||
else if(pLayerItem->m_Type == LAYERTYPE_SOUNDS)
|
||||
|
@ -1181,7 +1180,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
|
|||
pSounds->m_Sound = pSoundsItem->m_Sound;
|
||||
|
||||
// validate m_Sound
|
||||
if(pSounds->m_Sound < -1 || pSounds->m_Sound >= m_lSounds.size())
|
||||
if(pSounds->m_Sound < -1 || pSounds->m_Sound >= (int)m_lSounds.size())
|
||||
pSounds->m_Sound = -1;
|
||||
|
||||
// load layer name
|
||||
|
@ -1191,8 +1190,8 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
|
|||
// load data
|
||||
void *pData = DataFile.GetDataSwapped(pSoundsItem->m_Data);
|
||||
pGroup->AddLayer(pSounds);
|
||||
pSounds->m_lSources.set_size(pSoundsItem->m_NumSources);
|
||||
mem_copy(pSounds->m_lSources.base_ptr(), pData, sizeof(CSoundSource) * pSoundsItem->m_NumSources);
|
||||
pSounds->m_lSources.resize(pSoundsItem->m_NumSources);
|
||||
mem_copy(&pSounds->m_lSources[0], pData, sizeof(CSoundSource) * pSoundsItem->m_NumSources);
|
||||
DataFile.UnloadData(pSoundsItem->m_Data);
|
||||
}
|
||||
else if(pLayerItem->m_Type == LAYERTYPE_SOUNDS_DEPRECATED)
|
||||
|
@ -1208,7 +1207,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
|
|||
pSounds->m_Sound = pSoundsItem->m_Sound;
|
||||
|
||||
// validate m_Sound
|
||||
if(pSounds->m_Sound < -1 || pSounds->m_Sound >= m_lSounds.size())
|
||||
if(pSounds->m_Sound < -1 || pSounds->m_Sound >= (int)m_lSounds.size())
|
||||
pSounds->m_Sound = -1;
|
||||
|
||||
// load layer name
|
||||
|
@ -1218,7 +1217,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
|
|||
// load data
|
||||
CSoundSource_DEPRECATED *pData = (CSoundSource_DEPRECATED *)DataFile.GetDataSwapped(pSoundsItem->m_Data);
|
||||
pGroup->AddLayer(pSounds);
|
||||
pSounds->m_lSources.set_size(pSoundsItem->m_NumSources);
|
||||
pSounds->m_lSources.resize(pSoundsItem->m_NumSources);
|
||||
|
||||
for(int i = 0; i < pSoundsItem->m_NumSources; i++)
|
||||
{
|
||||
|
@ -1266,11 +1265,11 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
|
|||
{
|
||||
CMapItemEnvelope *pItem = (CMapItemEnvelope *)DataFile.GetItem(Start + e, 0, 0);
|
||||
CEnvelope *pEnv = new CEnvelope(pItem->m_Channels);
|
||||
pEnv->m_lPoints.set_size(pItem->m_NumPoints);
|
||||
mem_copy(pEnv->m_lPoints.base_ptr(), &pPoints[pItem->m_StartPoint], sizeof(CEnvPoint) * pItem->m_NumPoints);
|
||||
pEnv->m_lPoints.resize(pItem->m_NumPoints);
|
||||
mem_copy(&pEnv->m_lPoints[0], &pPoints[pItem->m_StartPoint], sizeof(CEnvPoint) * pItem->m_NumPoints);
|
||||
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);
|
||||
m_lEnvelopes.push_back(pEnv);
|
||||
if(pItem->m_Version >= 2)
|
||||
pEnv->m_Synchronized = pItem->m_Synchronized;
|
||||
}
|
||||
|
@ -1284,8 +1283,8 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
|
|||
CMapItemAutoMapperConfig *pItem = (CMapItemAutoMapperConfig *)DataFile.GetItem(Start + i, 0, 0);
|
||||
if(pItem->m_Version == CMapItemAutoMapperConfig::CURRENT_VERSION)
|
||||
{
|
||||
if(pItem->m_GroupId >= 0 && pItem->m_GroupId < m_lGroups.size() &&
|
||||
pItem->m_LayerId >= 0 && pItem->m_LayerId < m_lGroups[pItem->m_GroupId]->m_lLayers.size())
|
||||
if(pItem->m_GroupId >= 0 && (size_t)pItem->m_GroupId < m_lGroups.size() &&
|
||||
pItem->m_LayerId >= 0 && (size_t)pItem->m_LayerId < m_lGroups[pItem->m_GroupId]->m_lLayers.size())
|
||||
{
|
||||
CLayer *pLayer = m_lGroups[pItem->m_GroupId]->m_lLayers[pItem->m_LayerId];
|
||||
if(pLayer->m_Type == LAYERTYPE_TILES)
|
||||
|
@ -1337,25 +1336,25 @@ int CEditor::Append(const char *pFileName, int StorageType)
|
|||
NewMap.ModifyEnvelopeIndex(ModifyAdd);
|
||||
|
||||
// transfer images
|
||||
for(int i = 0; i < NewMap.m_lImages.size(); i++)
|
||||
m_Map.m_lImages.add(NewMap.m_lImages[i]);
|
||||
for(const auto &pImage : NewMap.m_lImages)
|
||||
m_Map.m_lImages.push_back(pImage);
|
||||
NewMap.m_lImages.clear();
|
||||
|
||||
// transfer envelopes
|
||||
for(int i = 0; i < NewMap.m_lEnvelopes.size(); i++)
|
||||
m_Map.m_lEnvelopes.add(NewMap.m_lEnvelopes[i]);
|
||||
for(const auto &pEnvelope : NewMap.m_lEnvelopes)
|
||||
m_Map.m_lEnvelopes.push_back(pEnvelope);
|
||||
NewMap.m_lEnvelopes.clear();
|
||||
|
||||
// transfer groups
|
||||
|
||||
for(int i = 0; i < NewMap.m_lGroups.size(); i++)
|
||||
for(const auto &pGroup : NewMap.m_lGroups)
|
||||
{
|
||||
if(NewMap.m_lGroups[i] == NewMap.m_pGameGroup)
|
||||
delete NewMap.m_lGroups[i];
|
||||
if(pGroup == NewMap.m_pGameGroup)
|
||||
delete pGroup;
|
||||
else
|
||||
{
|
||||
NewMap.m_lGroups[i]->m_pMap = &m_Map;
|
||||
m_Map.m_lGroups.add(NewMap.m_lGroups[i]);
|
||||
pGroup->m_pMap = &m_Map;
|
||||
m_Map.m_lGroups.push_back(pGroup);
|
||||
}
|
||||
}
|
||||
NewMap.m_lGroups.clear();
|
||||
|
|
|
@ -22,20 +22,21 @@ CLayerQuads::~CLayerQuads() = default;
|
|||
void CLayerQuads::Render(bool QuadPicker)
|
||||
{
|
||||
Graphics()->TextureClear();
|
||||
if(m_Image >= 0 && m_Image < m_pEditor->m_Map.m_lImages.size())
|
||||
if(m_Image >= 0 && (size_t)m_Image < m_pEditor->m_Map.m_lImages.size())
|
||||
Graphics()->TextureSet(m_pEditor->m_Map.m_lImages[m_Image]->m_Texture);
|
||||
|
||||
Graphics()->BlendNone();
|
||||
m_pEditor->RenderTools()->ForceRenderQuads(m_lQuads.base_ptr(), m_lQuads.size(), LAYERRENDERFLAG_OPAQUE, m_pEditor->EnvelopeEval, m_pEditor);
|
||||
m_pEditor->RenderTools()->ForceRenderQuads(&m_lQuads[0], m_lQuads.size(), LAYERRENDERFLAG_OPAQUE, m_pEditor->EnvelopeEval, m_pEditor);
|
||||
Graphics()->BlendNormal();
|
||||
m_pEditor->RenderTools()->ForceRenderQuads(m_lQuads.base_ptr(), m_lQuads.size(), LAYERRENDERFLAG_TRANSPARENT, m_pEditor->EnvelopeEval, m_pEditor);
|
||||
m_pEditor->RenderTools()->ForceRenderQuads(&m_lQuads[0], m_lQuads.size(), LAYERRENDERFLAG_TRANSPARENT, m_pEditor->EnvelopeEval, m_pEditor);
|
||||
}
|
||||
|
||||
CQuad *CLayerQuads::NewQuad(int x, int y, int Width, int Height)
|
||||
{
|
||||
m_pEditor->m_Map.m_Modified = true;
|
||||
|
||||
CQuad *q = &m_lQuads[m_lQuads.add(CQuad())];
|
||||
m_lQuads.emplace_back();
|
||||
CQuad *q = &m_lQuads[m_lQuads.size() - 1];
|
||||
|
||||
q->m_PosEnv = -1;
|
||||
q->m_ColorEnv = -1;
|
||||
|
@ -111,16 +112,14 @@ int CLayerQuads::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
|||
pBrush->AddLayer(pGrabbed);
|
||||
|
||||
//dbg_msg("", "%f %f %f %f", rect.x, rect.y, rect.w, rect.h);
|
||||
for(int i = 0; i < m_lQuads.size(); i++)
|
||||
for(const auto &Quad : m_lQuads)
|
||||
{
|
||||
CQuad *q = &m_lQuads[i];
|
||||
float px = fx2f(q->m_aPoints[4].x);
|
||||
float py = fx2f(q->m_aPoints[4].y);
|
||||
float px = fx2f(Quad.m_aPoints[4].x);
|
||||
float py = fx2f(Quad.m_aPoints[4].y);
|
||||
|
||||
if(px > Rect.x && px < Rect.x + Rect.w && py > Rect.y && py < Rect.y + Rect.h)
|
||||
{
|
||||
CQuad n;
|
||||
n = *q;
|
||||
CQuad n = Quad;
|
||||
|
||||
for(auto &Point : n.m_aPoints)
|
||||
{
|
||||
|
@ -128,19 +127,19 @@ int CLayerQuads::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
|||
Point.y -= f2fx(Rect.y);
|
||||
}
|
||||
|
||||
pGrabbed->m_lQuads.add(n);
|
||||
pGrabbed->m_lQuads.push_back(n);
|
||||
}
|
||||
}
|
||||
|
||||
return pGrabbed->m_lQuads.size() ? 1 : 0;
|
||||
return pGrabbed->m_lQuads.empty() ? 0 : 1;
|
||||
}
|
||||
|
||||
void CLayerQuads::BrushPlace(CLayer *pBrush, float wx, float wy)
|
||||
{
|
||||
CLayerQuads *l = (CLayerQuads *)pBrush;
|
||||
for(int i = 0; i < l->m_lQuads.size(); i++)
|
||||
for(const auto &Quad : l->m_lQuads)
|
||||
{
|
||||
CQuad n = l->m_lQuads[i];
|
||||
CQuad n = Quad;
|
||||
|
||||
for(auto &Point : n.m_aPoints)
|
||||
{
|
||||
|
@ -148,31 +147,27 @@ void CLayerQuads::BrushPlace(CLayer *pBrush, float wx, float wy)
|
|||
Point.y += f2fx(wy);
|
||||
}
|
||||
|
||||
m_lQuads.add(n);
|
||||
m_lQuads.push_back(n);
|
||||
}
|
||||
m_pEditor->m_Map.m_Modified = true;
|
||||
}
|
||||
|
||||
void CLayerQuads::BrushFlipX()
|
||||
{
|
||||
for(int i = 0; i < m_lQuads.size(); i++)
|
||||
for(auto &Quad : m_lQuads)
|
||||
{
|
||||
CQuad *q = &m_lQuads[i];
|
||||
|
||||
std::swap(q->m_aPoints[0], q->m_aPoints[1]);
|
||||
std::swap(q->m_aPoints[2], q->m_aPoints[3]);
|
||||
std::swap(Quad.m_aPoints[0], Quad.m_aPoints[1]);
|
||||
std::swap(Quad.m_aPoints[2], Quad.m_aPoints[3]);
|
||||
}
|
||||
m_pEditor->m_Map.m_Modified = true;
|
||||
}
|
||||
|
||||
void CLayerQuads::BrushFlipY()
|
||||
{
|
||||
for(int i = 0; i < m_lQuads.size(); i++)
|
||||
for(auto &Quad : m_lQuads)
|
||||
{
|
||||
CQuad *q = &m_lQuads[i];
|
||||
|
||||
std::swap(q->m_aPoints[0], q->m_aPoints[2]);
|
||||
std::swap(q->m_aPoints[1], q->m_aPoints[3]);
|
||||
std::swap(Quad.m_aPoints[0], Quad.m_aPoints[2]);
|
||||
std::swap(Quad.m_aPoints[1], Quad.m_aPoints[3]);
|
||||
}
|
||||
m_pEditor->m_Map.m_Modified = true;
|
||||
}
|
||||
|
@ -192,11 +187,9 @@ void CLayerQuads::BrushRotate(float Amount)
|
|||
Center.x /= 2;
|
||||
Center.y /= 2;
|
||||
|
||||
for(int i = 0; i < m_lQuads.size(); i++)
|
||||
for(auto &Quad : m_lQuads)
|
||||
{
|
||||
CQuad *q = &m_lQuads[i];
|
||||
|
||||
for(auto &Point : q->m_aPoints)
|
||||
for(auto &Point : Quad.m_aPoints)
|
||||
{
|
||||
vec2 Pos(fx2f(Point.x), fx2f(Point.y));
|
||||
Rotate(&Center, &Pos, Amount);
|
||||
|
@ -211,9 +204,9 @@ void CLayerQuads::GetSize(float *w, float *h)
|
|||
*w = 0;
|
||||
*h = 0;
|
||||
|
||||
for(int i = 0; i < m_lQuads.size(); i++)
|
||||
for(const auto &Quad : m_lQuads)
|
||||
{
|
||||
for(auto &Point : m_lQuads[i].m_aPoints)
|
||||
for(const auto &Point : Quad.m_aPoints)
|
||||
{
|
||||
*w = maximum(*w, fx2f(Point.x));
|
||||
*h = maximum(*h, fx2f(Point.y));
|
||||
|
@ -259,9 +252,9 @@ void CLayerQuads::ModifyImageIndex(INDEX_MODIFY_FUNC Func)
|
|||
|
||||
void CLayerQuads::ModifyEnvelopeIndex(INDEX_MODIFY_FUNC Func)
|
||||
{
|
||||
for(int i = 0; i < m_lQuads.size(); i++)
|
||||
for(auto &Quad : m_lQuads)
|
||||
{
|
||||
Func(&m_lQuads[i].m_PosEnv);
|
||||
Func(&m_lQuads[i].m_ColorEnv);
|
||||
Func(&Quad.m_PosEnv);
|
||||
Func(&Quad.m_ColorEnv);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,44 +23,42 @@ void CLayerSounds::Render(bool Tileset)
|
|||
|
||||
// draw falloff distance
|
||||
Graphics()->SetColor(0.6f, 0.8f, 1.0f, 0.4f);
|
||||
for(int i = 0; i < m_lSources.size(); i++)
|
||||
for(const auto &Source : m_lSources)
|
||||
{
|
||||
CSoundSource *pSource = &m_lSources[i];
|
||||
|
||||
float OffsetX = 0;
|
||||
float OffsetY = 0;
|
||||
|
||||
if(pSource->m_PosEnv >= 0)
|
||||
if(Source.m_PosEnv >= 0)
|
||||
{
|
||||
float aChannels[4];
|
||||
m_pEditor->EnvelopeEval(pSource->m_PosEnvOffset, pSource->m_PosEnv, aChannels, m_pEditor);
|
||||
m_pEditor->EnvelopeEval(Source.m_PosEnvOffset, Source.m_PosEnv, aChannels, m_pEditor);
|
||||
OffsetX = aChannels[0];
|
||||
OffsetY = aChannels[1];
|
||||
}
|
||||
|
||||
switch(pSource->m_Shape.m_Type)
|
||||
switch(Source.m_Shape.m_Type)
|
||||
{
|
||||
case CSoundShape::SHAPE_CIRCLE:
|
||||
{
|
||||
m_pEditor->RenderTools()->DrawCircle(fx2f(pSource->m_Position.x) + OffsetX, fx2f(pSource->m_Position.y) + OffsetY,
|
||||
pSource->m_Shape.m_Circle.m_Radius, 32);
|
||||
m_pEditor->RenderTools()->DrawCircle(fx2f(Source.m_Position.x) + OffsetX, fx2f(Source.m_Position.y) + OffsetY,
|
||||
Source.m_Shape.m_Circle.m_Radius, 32);
|
||||
|
||||
float Falloff = ((float)pSource->m_Falloff / 255.0f);
|
||||
float Falloff = ((float)Source.m_Falloff / 255.0f);
|
||||
if(Falloff > 0.0f)
|
||||
m_pEditor->RenderTools()->DrawCircle(fx2f(pSource->m_Position.x) + OffsetX, fx2f(pSource->m_Position.y) + OffsetY,
|
||||
pSource->m_Shape.m_Circle.m_Radius * Falloff, 32);
|
||||
m_pEditor->RenderTools()->DrawCircle(fx2f(Source.m_Position.x) + OffsetX, fx2f(Source.m_Position.y) + OffsetY,
|
||||
Source.m_Shape.m_Circle.m_Radius * Falloff, 32);
|
||||
break;
|
||||
}
|
||||
case CSoundShape::SHAPE_RECTANGLE:
|
||||
{
|
||||
float Width = fx2f(pSource->m_Shape.m_Rectangle.m_Width);
|
||||
float Height = fx2f(pSource->m_Shape.m_Rectangle.m_Height);
|
||||
m_pEditor->RenderTools()->DrawRoundRect(fx2f(pSource->m_Position.x) + OffsetX - Width / 2, fx2f(pSource->m_Position.y) + OffsetY - Height / 2,
|
||||
float Width = fx2f(Source.m_Shape.m_Rectangle.m_Width);
|
||||
float Height = fx2f(Source.m_Shape.m_Rectangle.m_Height);
|
||||
m_pEditor->RenderTools()->DrawRoundRect(fx2f(Source.m_Position.x) + OffsetX - Width / 2, fx2f(Source.m_Position.y) + OffsetY - Height / 2,
|
||||
Width, Height, 0.0f);
|
||||
|
||||
float Falloff = ((float)pSource->m_Falloff / 255.0f);
|
||||
float Falloff = ((float)Source.m_Falloff / 255.0f);
|
||||
if(Falloff > 0.0f)
|
||||
m_pEditor->RenderTools()->DrawRoundRect(fx2f(pSource->m_Position.x) + OffsetX - Falloff * Width / 2, fx2f(pSource->m_Position.y) + OffsetY - Falloff * Height / 2,
|
||||
m_pEditor->RenderTools()->DrawRoundRect(fx2f(Source.m_Position.x) + OffsetX - Falloff * Width / 2, fx2f(Source.m_Position.y) + OffsetY - Falloff * Height / 2,
|
||||
Width * Falloff, Height * Falloff, 0.0f);
|
||||
break;
|
||||
}
|
||||
|
@ -75,22 +73,20 @@ void CLayerSounds::Render(bool Tileset)
|
|||
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
m_pEditor->RenderTools()->SelectSprite(SPRITE_AUDIO_SOURCE);
|
||||
for(int i = 0; i < m_lSources.size(); i++)
|
||||
for(const auto &Source : m_lSources)
|
||||
{
|
||||
CSoundSource *pSource = &m_lSources[i];
|
||||
|
||||
float OffsetX = 0;
|
||||
float OffsetY = 0;
|
||||
|
||||
if(pSource->m_PosEnv >= 0)
|
||||
if(Source.m_PosEnv >= 0)
|
||||
{
|
||||
float aChannels[4];
|
||||
m_pEditor->EnvelopeEval(pSource->m_PosEnvOffset, pSource->m_PosEnv, aChannels, m_pEditor);
|
||||
m_pEditor->EnvelopeEval(Source.m_PosEnvOffset, Source.m_PosEnv, aChannels, m_pEditor);
|
||||
OffsetX = aChannels[0];
|
||||
OffsetY = aChannels[1];
|
||||
}
|
||||
|
||||
m_pEditor->RenderTools()->DrawSprite(fx2f(pSource->m_Position.x) + OffsetX, fx2f(pSource->m_Position.y) + OffsetY, s_SourceVisualSize * m_pEditor->m_WorldZoom);
|
||||
m_pEditor->RenderTools()->DrawSprite(fx2f(Source.m_Position.x) + OffsetX, fx2f(Source.m_Position.y) + OffsetY, s_SourceVisualSize * m_pEditor->m_WorldZoom);
|
||||
}
|
||||
|
||||
Graphics()->QuadsEnd();
|
||||
|
@ -100,7 +96,8 @@ CSoundSource *CLayerSounds::NewSource(int x, int y)
|
|||
{
|
||||
m_pEditor->m_Map.m_Modified = true;
|
||||
|
||||
CSoundSource *pSource = &m_lSources[m_lSources.add(CSoundSource())];
|
||||
m_lSources.emplace_back();
|
||||
CSoundSource *pSource = &m_lSources[m_lSources.size() - 1];
|
||||
|
||||
pSource->m_Position.x = f2fx(x);
|
||||
pSource->m_Position.y = f2fx(y);
|
||||
|
@ -150,38 +147,36 @@ int CLayerSounds::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
|||
pGrabbed->m_Sound = m_Sound;
|
||||
pBrush->AddLayer(pGrabbed);
|
||||
|
||||
for(int i = 0; i < m_lSources.size(); i++)
|
||||
for(const auto &Source : m_lSources)
|
||||
{
|
||||
CSoundSource *pSource = &m_lSources[i];
|
||||
float px = fx2f(pSource->m_Position.x);
|
||||
float py = fx2f(pSource->m_Position.y);
|
||||
float px = fx2f(Source.m_Position.x);
|
||||
float py = fx2f(Source.m_Position.y);
|
||||
|
||||
if(px > Rect.x && px < Rect.x + Rect.w && py > Rect.y && py < Rect.y + Rect.h)
|
||||
{
|
||||
CSoundSource n;
|
||||
n = *pSource;
|
||||
CSoundSource n = Source;
|
||||
|
||||
n.m_Position.x -= f2fx(Rect.x);
|
||||
n.m_Position.y -= f2fx(Rect.y);
|
||||
|
||||
pGrabbed->m_lSources.add(n);
|
||||
pGrabbed->m_lSources.push_back(n);
|
||||
}
|
||||
}
|
||||
|
||||
return pGrabbed->m_lSources.size() ? 1 : 0;
|
||||
return pGrabbed->m_lSources.empty() ? 0 : 1;
|
||||
}
|
||||
|
||||
void CLayerSounds::BrushPlace(CLayer *pBrush, float wx, float wy)
|
||||
{
|
||||
CLayerSounds *l = (CLayerSounds *)pBrush;
|
||||
for(int i = 0; i < l->m_lSources.size(); i++)
|
||||
for(const auto &Source : l->m_lSources)
|
||||
{
|
||||
CSoundSource n = l->m_lSources[i];
|
||||
CSoundSource n = Source;
|
||||
|
||||
n.m_Position.x += f2fx(wx);
|
||||
n.m_Position.y += f2fx(wy);
|
||||
|
||||
m_lSources.add(n);
|
||||
m_lSources.push_back(n);
|
||||
}
|
||||
m_pEditor->m_Map.m_Modified = true;
|
||||
}
|
||||
|
@ -224,9 +219,9 @@ void CLayerSounds::ModifySoundIndex(INDEX_MODIFY_FUNC Func)
|
|||
|
||||
void CLayerSounds::ModifyEnvelopeIndex(INDEX_MODIFY_FUNC Func)
|
||||
{
|
||||
for(int i = 0; i < m_lSources.size(); i++)
|
||||
for(auto &Source : m_lSources)
|
||||
{
|
||||
Func(&m_lSources[i].m_SoundEnv);
|
||||
Func(&m_lSources[i].m_PosEnv);
|
||||
Func(&Source.m_SoundEnv);
|
||||
Func(&Source.m_PosEnv);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
||||
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
||||
#include <base/math.h>
|
||||
#include <base/tl/algorithm.h>
|
||||
|
||||
#include <engine/client.h>
|
||||
#include <engine/graphics.h>
|
||||
|
@ -82,7 +81,7 @@ void CLayerTiles::MakePalette()
|
|||
|
||||
void CLayerTiles::Render(bool Tileset)
|
||||
{
|
||||
if(m_Image >= 0 && m_Image < m_pEditor->m_Map.m_lImages.size())
|
||||
if(m_Image >= 0 && (size_t)m_Image < m_pEditor->m_Map.m_lImages.size())
|
||||
m_Texture = m_pEditor->m_Map.m_lImages[m_Image]->m_Texture;
|
||||
Graphics()->TextureSet(m_Texture);
|
||||
ColorRGBA Color = ColorRGBA(m_Color.r / 255.0f, m_Color.g / 255.0f, m_Color.b / 255.0f, m_Color.a / 255.0f);
|
||||
|
@ -793,7 +792,7 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
|
|||
|
||||
if(m_pEditor->m_Map.m_pGameLayer != this)
|
||||
{
|
||||
if(m_Image >= 0 && m_Image < m_pEditor->m_Map.m_lImages.size() && m_pEditor->m_Map.m_lImages[m_Image]->m_AutoMapper.IsLoaded() &&
|
||||
if(m_Image >= 0 && (size_t)m_Image < m_pEditor->m_Map.m_lImages.size() && m_pEditor->m_Map.m_lImages[m_Image]->m_AutoMapper.IsLoaded() &&
|
||||
m_AutoMapperConfig != -1)
|
||||
{
|
||||
static int s_AutoMapperButton = 0;
|
||||
|
@ -926,11 +925,11 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
|
|||
}
|
||||
if(Prop == PROP_COLOR_ENV)
|
||||
{
|
||||
int Index = clamp(NewVal - 1, -1, m_pEditor->m_Map.m_lEnvelopes.size() - 1);
|
||||
int Index = clamp(NewVal - 1, -1, (int)m_pEditor->m_Map.m_lEnvelopes.size() - 1);
|
||||
int Step = (Index - m_ColorEnv) % 2;
|
||||
if(Step != 0)
|
||||
{
|
||||
for(; Index >= -1 && Index < m_pEditor->m_Map.m_lEnvelopes.size(); Index += Step)
|
||||
for(; Index >= -1 && Index < (int)m_pEditor->m_Map.m_lEnvelopes.size(); Index += Step)
|
||||
if(Index == -1 || m_pEditor->m_Map.m_lEnvelopes[Index]->m_Channels == 4)
|
||||
{
|
||||
m_ColorEnv = Index;
|
||||
|
@ -957,7 +956,7 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CLayerTiles::RenderCommonProperties(SCommonPropState &State, CEditor *pEditor, CUIRect *pToolbox, array<CLayerTiles *> &pLayers)
|
||||
int CLayerTiles::RenderCommonProperties(SCommonPropState &State, CEditor *pEditor, CUIRect *pToolbox, std::vector<CLayerTiles *> &pLayers)
|
||||
{
|
||||
if(State.Modified)
|
||||
{
|
||||
|
@ -967,7 +966,8 @@ int CLayerTiles::RenderCommonProperties(SCommonPropState &State, CEditor *pEdito
|
|||
if(pEditor->DoButton_Editor(&s_CommitButton, "Commit", 0, &Commit, 0, "Applies the changes"))
|
||||
{
|
||||
dbg_msg("editor", "applying changes");
|
||||
for_each(pLayers.all(), [&State](CLayerTiles *pLayer) {
|
||||
for(auto &pLayer : pLayers)
|
||||
{
|
||||
pLayer->Resize(State.Width, State.Height);
|
||||
|
||||
pLayer->m_Color.r = (State.Color >> 24) & 0xff;
|
||||
|
@ -976,18 +976,19 @@ int CLayerTiles::RenderCommonProperties(SCommonPropState &State, CEditor *pEdito
|
|||
pLayer->m_Color.a = State.Color & 0xff;
|
||||
|
||||
pLayer->FlagModified(0, 0, pLayer->m_Width, pLayer->m_Height);
|
||||
});
|
||||
}
|
||||
State.Modified = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for_each(pLayers.all(), [&State](CLayerTiles *pLayer) {
|
||||
for(auto &pLayer : pLayers)
|
||||
{
|
||||
if(pLayer->m_Width > State.Width)
|
||||
State.Width = pLayer->m_Width;
|
||||
if(pLayer->m_Height > State.Height)
|
||||
State.Height = pLayer->m_Height;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -1048,9 +1049,8 @@ int CLayerTiles::RenderCommonProperties(SCommonPropState &State, CEditor *pEdito
|
|||
}
|
||||
else if(Prop == PROP_SHIFT)
|
||||
{
|
||||
for_each(pLayers.all(), [NewVal](CLayerTiles *pLayer) {
|
||||
for(auto &pLayer : pLayers)
|
||||
pLayer->Shift(NewVal);
|
||||
});
|
||||
}
|
||||
else if(Prop == PROP_SHIFT_BY)
|
||||
pEditor->m_ShiftBy = NewVal;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
||||
|
||||
#include <base/color.h>
|
||||
#include <base/tl/array.h>
|
||||
|
||||
#include <engine/console.h>
|
||||
#include <engine/graphics.h>
|
||||
|
@ -138,11 +137,11 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
if(pEditor->DoButton_Editor(&s_DeleteButton, "Clean up game tiles", 0, &Button, 0, "Removes game tiles that aren't based on a layer"))
|
||||
{
|
||||
// gather all tile layers
|
||||
array<CLayerTiles *> Layers;
|
||||
for(int i = 0; i < pEditor->m_Map.m_pGameGroup->m_lLayers.size(); ++i)
|
||||
std::vector<CLayerTiles *> Layers;
|
||||
for(auto &pLayer : pEditor->m_Map.m_pGameGroup->m_lLayers)
|
||||
{
|
||||
if(pEditor->m_Map.m_pGameGroup->m_lLayers[i] != pEditor->m_Map.m_pGameLayer && pEditor->m_Map.m_pGameGroup->m_lLayers[i]->m_Type == LAYERTYPE_TILES)
|
||||
Layers.add(static_cast<CLayerTiles *>(pEditor->m_Map.m_pGameGroup->m_lLayers[i]));
|
||||
if(pLayer != pEditor->m_Map.m_pGameLayer && pLayer->m_Type == LAYERTYPE_TILES)
|
||||
Layers.push_back(static_cast<CLayerTiles *>(pLayer));
|
||||
}
|
||||
|
||||
// search for unneeded game tiles
|
||||
|
@ -154,9 +153,9 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
continue;
|
||||
|
||||
bool Found = false;
|
||||
for(int i = 0; i < Layers.size(); ++i)
|
||||
for(const auto &pLayer : Layers)
|
||||
{
|
||||
if(x < Layers[i]->m_Width && y < Layers[i]->m_Height && Layers[i]->m_pTiles[y * Layers[i]->m_Width + x].m_Index)
|
||||
if(x < pLayer->m_Width && y < pLayer->m_Height && pLayer->m_pTiles[y * pLayer->m_Width + x].m_Index)
|
||||
{
|
||||
Found = true;
|
||||
break;
|
||||
|
@ -329,7 +328,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
};
|
||||
|
||||
CProperty aProps[] = {
|
||||
{"Order", pEditor->m_SelectedGroup, PROPTYPE_INT_STEP, 0, pEditor->m_Map.m_lGroups.size() - 1},
|
||||
{"Order", pEditor->m_SelectedGroup, PROPTYPE_INT_STEP, 0, (int)pEditor->m_Map.m_lGroups.size() - 1},
|
||||
{"Pos X", -pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_OffsetX, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
||||
{"Pos Y", -pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_OffsetY, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
||||
{"Para X", pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_ParallaxX, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
||||
|
@ -442,8 +441,8 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
};
|
||||
|
||||
CProperty aProps[] = {
|
||||
{"Group", pEditor->m_SelectedGroup, PROPTYPE_INT_STEP, 0, pEditor->m_Map.m_lGroups.size() - 1},
|
||||
{"Order", pEditor->m_lSelectedLayers[0], PROPTYPE_INT_STEP, 0, pCurrentGroup->m_lLayers.size()},
|
||||
{"Group", pEditor->m_SelectedGroup, PROPTYPE_INT_STEP, 0, (int)pEditor->m_Map.m_lGroups.size() - 1},
|
||||
{"Order", pEditor->m_lSelectedLayers[0], PROPTYPE_INT_STEP, 0, (int)pCurrentGroup->m_lLayers.size()},
|
||||
{"Detail", pCurrentLayer && pCurrentLayer->m_Flags & LAYERFLAG_DETAIL, PROPTYPE_BOOL, 0, 1},
|
||||
{0},
|
||||
};
|
||||
|
@ -465,10 +464,12 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
pEditor->SelectLayer(pCurrentGroup->SwapLayers(pEditor->m_lSelectedLayers[0], NewVal));
|
||||
else if(Prop == PROP_GROUP && pCurrentLayer && pCurrentLayer->m_Type != LAYERTYPE_GAME)
|
||||
{
|
||||
if(NewVal >= 0 && NewVal < pEditor->m_Map.m_lGroups.size())
|
||||
if(NewVal >= 0 && (size_t)NewVal < pEditor->m_Map.m_lGroups.size())
|
||||
{
|
||||
pCurrentGroup->m_lLayers.remove(pCurrentLayer);
|
||||
pEditor->m_Map.m_lGroups[NewVal]->m_lLayers.add(pCurrentLayer);
|
||||
auto Position = std::find(pCurrentGroup->m_lLayers.begin(), pCurrentGroup->m_lLayers.end(), pCurrentLayer);
|
||||
if(Position != pCurrentGroup->m_lLayers.end())
|
||||
pCurrentGroup->m_lLayers.erase(Position);
|
||||
pEditor->m_Map.m_lGroups[NewVal]->m_lLayers.push_back(pCurrentLayer);
|
||||
pEditor->m_SelectedGroup = NewVal;
|
||||
pEditor->SelectLayer(pEditor->m_Map.m_lGroups[NewVal]->m_lLayers.size() - 1);
|
||||
}
|
||||
|
@ -487,7 +488,7 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
|
||||
int CEditor::PopupQuad(CEditor *pEditor, CUIRect View, void *pContext)
|
||||
{
|
||||
array<CQuad *> lQuads = pEditor->GetSelectedQuads();
|
||||
std::vector<CQuad *> lQuads = pEditor->GetSelectedQuads();
|
||||
CQuad *pCurrentQuad = lQuads[pEditor->m_SelectedQuadIndex];
|
||||
|
||||
CUIRect Button;
|
||||
|
@ -510,37 +511,37 @@ int CEditor::PopupQuad(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
View.HSplitBottom(10.0f, &View, &Button);
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
CLayerQuads *pLayer = (CLayerQuads *)pEditor->GetSelectedLayerType(0, LAYERTYPE_QUADS);
|
||||
if(pLayer && pLayer->m_Image >= 0 && pLayer->m_Image < pEditor->m_Map.m_lImages.size())
|
||||
if(pLayer && pLayer->m_Image >= 0 && (size_t)pLayer->m_Image < pEditor->m_Map.m_lImages.size())
|
||||
{
|
||||
static int s_AspectRatioButton = 0;
|
||||
if(pEditor->DoButton_Editor(&s_AspectRatioButton, "Aspect ratio", 0, &Button, 0, "Resizes the current Quad based on the aspect ratio of the image"))
|
||||
{
|
||||
for(int i = 0; i < lQuads.size(); ++i)
|
||||
for(auto &pQuad : lQuads)
|
||||
{
|
||||
int Top = lQuads[i]->m_aPoints[0].y;
|
||||
int Left = lQuads[i]->m_aPoints[0].x;
|
||||
int Right = lQuads[i]->m_aPoints[0].x;
|
||||
int Top = pQuad->m_aPoints[0].y;
|
||||
int Left = pQuad->m_aPoints[0].x;
|
||||
int Right = pQuad->m_aPoints[0].x;
|
||||
|
||||
for(int k = 1; k < 4; k++)
|
||||
{
|
||||
if(lQuads[i]->m_aPoints[k].y < Top)
|
||||
Top = lQuads[i]->m_aPoints[k].y;
|
||||
if(lQuads[i]->m_aPoints[k].x < Left)
|
||||
Left = lQuads[i]->m_aPoints[k].x;
|
||||
if(lQuads[i]->m_aPoints[k].x > Right)
|
||||
Right = lQuads[i]->m_aPoints[k].x;
|
||||
if(pQuad->m_aPoints[k].y < Top)
|
||||
Top = pQuad->m_aPoints[k].y;
|
||||
if(pQuad->m_aPoints[k].x < Left)
|
||||
Left = pQuad->m_aPoints[k].x;
|
||||
if(pQuad->m_aPoints[k].x > Right)
|
||||
Right = pQuad->m_aPoints[k].x;
|
||||
}
|
||||
|
||||
int Height = (Right - Left) * pEditor->m_Map.m_lImages[pLayer->m_Image]->m_Height / pEditor->m_Map.m_lImages[pLayer->m_Image]->m_Width;
|
||||
|
||||
lQuads[i]->m_aPoints[0].x = Left;
|
||||
lQuads[i]->m_aPoints[0].y = Top;
|
||||
lQuads[i]->m_aPoints[1].x = Right;
|
||||
lQuads[i]->m_aPoints[1].y = Top;
|
||||
lQuads[i]->m_aPoints[2].x = Left;
|
||||
lQuads[i]->m_aPoints[2].y = Top + Height;
|
||||
lQuads[i]->m_aPoints[3].x = Right;
|
||||
lQuads[i]->m_aPoints[3].y = Top + Height;
|
||||
pQuad->m_aPoints[0].x = Left;
|
||||
pQuad->m_aPoints[0].y = Top;
|
||||
pQuad->m_aPoints[1].x = Right;
|
||||
pQuad->m_aPoints[1].y = Top;
|
||||
pQuad->m_aPoints[2].x = Left;
|
||||
pQuad->m_aPoints[2].y = Top + Height;
|
||||
pQuad->m_aPoints[3].x = Right;
|
||||
pQuad->m_aPoints[3].y = Top + Height;
|
||||
pEditor->m_Map.m_Modified = true;
|
||||
}
|
||||
return 1;
|
||||
|
@ -553,12 +554,12 @@ int CEditor::PopupQuad(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
static int s_AlignButton = 0;
|
||||
if(pEditor->DoButton_Editor(&s_AlignButton, "Align", 0, &Button, 0, "Aligns coordinates of the quad points"))
|
||||
{
|
||||
for(int i = 0; i < lQuads.size(); ++i)
|
||||
for(auto &pQuad : lQuads)
|
||||
{
|
||||
for(int k = 1; k < 4; k++)
|
||||
{
|
||||
lQuads[i]->m_aPoints[k].x = 1000.0f * (lQuads[i]->m_aPoints[k].x / 1000);
|
||||
lQuads[i]->m_aPoints[k].y = 1000.0f * (lQuads[i]->m_aPoints[k].y / 1000);
|
||||
pQuad->m_aPoints[k].x = 1000.0f * (pQuad->m_aPoints[k].x / 1000);
|
||||
pQuad->m_aPoints[k].y = 1000.0f * (pQuad->m_aPoints[k].y / 1000);
|
||||
}
|
||||
pEditor->m_Map.m_Modified = true;
|
||||
}
|
||||
|
@ -571,33 +572,33 @@ int CEditor::PopupQuad(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
static int s_Button = 0;
|
||||
if(pEditor->DoButton_Editor(&s_Button, "Square", 0, &Button, 0, "Squares the current quad"))
|
||||
{
|
||||
for(int i = 0; i < lQuads.size(); ++i)
|
||||
for(auto &pQuad : lQuads)
|
||||
{
|
||||
int Top = lQuads[i]->m_aPoints[0].y;
|
||||
int Left = lQuads[i]->m_aPoints[0].x;
|
||||
int Bottom = lQuads[i]->m_aPoints[0].y;
|
||||
int Right = lQuads[i]->m_aPoints[0].x;
|
||||
int Top = pQuad->m_aPoints[0].y;
|
||||
int Left = pQuad->m_aPoints[0].x;
|
||||
int Bottom = pQuad->m_aPoints[0].y;
|
||||
int Right = pQuad->m_aPoints[0].x;
|
||||
|
||||
for(int k = 1; k < 4; k++)
|
||||
{
|
||||
if(lQuads[i]->m_aPoints[k].y < Top)
|
||||
Top = lQuads[i]->m_aPoints[k].y;
|
||||
if(lQuads[i]->m_aPoints[k].x < Left)
|
||||
Left = lQuads[i]->m_aPoints[k].x;
|
||||
if(lQuads[i]->m_aPoints[k].y > Bottom)
|
||||
Bottom = lQuads[i]->m_aPoints[k].y;
|
||||
if(lQuads[i]->m_aPoints[k].x > Right)
|
||||
Right = lQuads[i]->m_aPoints[k].x;
|
||||
if(pQuad->m_aPoints[k].y < Top)
|
||||
Top = pQuad->m_aPoints[k].y;
|
||||
if(pQuad->m_aPoints[k].x < Left)
|
||||
Left = pQuad->m_aPoints[k].x;
|
||||
if(pQuad->m_aPoints[k].y > Bottom)
|
||||
Bottom = pQuad->m_aPoints[k].y;
|
||||
if(pQuad->m_aPoints[k].x > Right)
|
||||
Right = pQuad->m_aPoints[k].x;
|
||||
}
|
||||
|
||||
lQuads[i]->m_aPoints[0].x = Left;
|
||||
lQuads[i]->m_aPoints[0].y = Top;
|
||||
lQuads[i]->m_aPoints[1].x = Right;
|
||||
lQuads[i]->m_aPoints[1].y = Top;
|
||||
lQuads[i]->m_aPoints[2].x = Left;
|
||||
lQuads[i]->m_aPoints[2].y = Bottom;
|
||||
lQuads[i]->m_aPoints[3].x = Right;
|
||||
lQuads[i]->m_aPoints[3].y = Bottom;
|
||||
pQuad->m_aPoints[0].x = Left;
|
||||
pQuad->m_aPoints[0].y = Top;
|
||||
pQuad->m_aPoints[1].x = Right;
|
||||
pQuad->m_aPoints[1].y = Top;
|
||||
pQuad->m_aPoints[2].x = Left;
|
||||
pQuad->m_aPoints[2].y = Bottom;
|
||||
pQuad->m_aPoints[3].x = Right;
|
||||
pQuad->m_aPoints[3].y = Bottom;
|
||||
pEditor->m_Map.m_Modified = true;
|
||||
}
|
||||
return 1;
|
||||
|
@ -645,50 +646,50 @@ int CEditor::PopupQuad(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
float OffsetX = i2fx(NewVal) - pCurrentQuad->m_aPoints[4].x;
|
||||
float OffsetY = i2fx(NewVal) - pCurrentQuad->m_aPoints[4].y;
|
||||
|
||||
for(int i = 0; i < lQuads.size(); ++i)
|
||||
for(auto &pQuad : lQuads)
|
||||
{
|
||||
if(Prop == PROP_POS_X)
|
||||
{
|
||||
for(auto &Point : lQuads[i]->m_aPoints)
|
||||
for(auto &Point : pQuad->m_aPoints)
|
||||
Point.x += OffsetX;
|
||||
}
|
||||
if(Prop == PROP_POS_Y)
|
||||
{
|
||||
for(auto &Point : lQuads[i]->m_aPoints)
|
||||
for(auto &Point : pQuad->m_aPoints)
|
||||
Point.y += OffsetY;
|
||||
}
|
||||
if(Prop == PROP_POS_ENV)
|
||||
{
|
||||
int Index = clamp(NewVal - 1, -1, pEditor->m_Map.m_lEnvelopes.size() - 1);
|
||||
int Step = (Index - lQuads[i]->m_PosEnv) % 2;
|
||||
int Index = clamp(NewVal - 1, -1, (int)pEditor->m_Map.m_lEnvelopes.size() - 1);
|
||||
int Step = (Index - pQuad->m_PosEnv) % 2;
|
||||
if(Step != 0)
|
||||
{
|
||||
for(; Index >= -1 && Index < pEditor->m_Map.m_lEnvelopes.size(); Index += Step)
|
||||
for(; Index >= -1 && Index < (int)pEditor->m_Map.m_lEnvelopes.size(); Index += Step)
|
||||
if(Index == -1 || pEditor->m_Map.m_lEnvelopes[Index]->m_Channels == 3)
|
||||
{
|
||||
lQuads[i]->m_PosEnv = Index;
|
||||
pQuad->m_PosEnv = Index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(Prop == PROP_POS_ENV_OFFSET)
|
||||
lQuads[i]->m_PosEnvOffset = NewVal;
|
||||
pQuad->m_PosEnvOffset = NewVal;
|
||||
if(Prop == PROP_COLOR_ENV)
|
||||
{
|
||||
int Index = clamp(NewVal - 1, -1, pEditor->m_Map.m_lEnvelopes.size() - 1);
|
||||
int Step = (Index - lQuads[i]->m_ColorEnv) % 2;
|
||||
int Index = clamp(NewVal - 1, -1, (int)pEditor->m_Map.m_lEnvelopes.size() - 1);
|
||||
int Step = (Index - pQuad->m_ColorEnv) % 2;
|
||||
if(Step != 0)
|
||||
{
|
||||
for(; Index >= -1 && Index < pEditor->m_Map.m_lEnvelopes.size(); Index += Step)
|
||||
for(; Index >= -1 && Index < (int)pEditor->m_Map.m_lEnvelopes.size(); Index += Step)
|
||||
if(Index == -1 || pEditor->m_Map.m_lEnvelopes[Index]->m_Channels == 4)
|
||||
{
|
||||
lQuads[i]->m_ColorEnv = Index;
|
||||
pQuad->m_ColorEnv = Index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(Prop == PROP_COLOR_ENV_OFFSET)
|
||||
lQuads[i]->m_ColorEnvOffset = NewVal;
|
||||
pQuad->m_ColorEnvOffset = NewVal;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -709,7 +710,7 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
if(pLayer)
|
||||
{
|
||||
pEditor->m_Map.m_Modified = true;
|
||||
pLayer->m_lSources.remove_index(pEditor->m_SelectedSource);
|
||||
pLayer->m_lSources.erase(pLayer->m_lSources.begin() + pEditor->m_SelectedSource);
|
||||
pEditor->m_SelectedSource--;
|
||||
}
|
||||
return 1;
|
||||
|
@ -798,11 +799,11 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
pSource->m_Falloff = NewVal;
|
||||
if(Prop == PROP_POS_ENV)
|
||||
{
|
||||
int Index = clamp(NewVal - 1, -1, pEditor->m_Map.m_lEnvelopes.size() - 1);
|
||||
int Index = clamp(NewVal - 1, -1, (int)pEditor->m_Map.m_lEnvelopes.size() - 1);
|
||||
int Step = (Index - pSource->m_PosEnv) % 2;
|
||||
if(Step != 0)
|
||||
{
|
||||
for(; Index >= -1 && Index < pEditor->m_Map.m_lEnvelopes.size(); Index += Step)
|
||||
for(; Index >= -1 && Index < (int)pEditor->m_Map.m_lEnvelopes.size(); Index += Step)
|
||||
if(Index == -1 || pEditor->m_Map.m_lEnvelopes[Index]->m_Channels == 3)
|
||||
{
|
||||
pSource->m_PosEnv = Index;
|
||||
|
@ -814,11 +815,11 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
pSource->m_PosEnvOffset = NewVal;
|
||||
if(Prop == PROP_SOUND_ENV)
|
||||
{
|
||||
int Index = clamp(NewVal - 1, -1, pEditor->m_Map.m_lEnvelopes.size() - 1);
|
||||
int Index = clamp(NewVal - 1, -1, (int)pEditor->m_Map.m_lEnvelopes.size() - 1);
|
||||
int Step = (Index - pSource->m_SoundEnv) % 2;
|
||||
if(Step != 0)
|
||||
{
|
||||
for(; Index >= -1 && Index < pEditor->m_Map.m_lEnvelopes.size(); Index += Step)
|
||||
for(; Index >= -1 && Index < (int)pEditor->m_Map.m_lEnvelopes.size(); Index += Step)
|
||||
if(Index == -1 || pEditor->m_Map.m_lEnvelopes[Index]->m_Channels == 1)
|
||||
{
|
||||
pSource->m_SoundEnv = Index;
|
||||
|
@ -896,7 +897,7 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
|
||||
int CEditor::PopupPoint(CEditor *pEditor, CUIRect View, void *pContext)
|
||||
{
|
||||
array<CQuad *> lQuads = pEditor->GetSelectedQuads();
|
||||
std::vector<CQuad *> lQuads = pEditor->GetSelectedQuads();
|
||||
CQuad *pCurrentQuad = lQuads[pEditor->m_SelectedQuadIndex];
|
||||
|
||||
enum
|
||||
|
@ -923,7 +924,7 @@ int CEditor::PopupPoint(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
CProperty aProps[] = {
|
||||
{"Pos X", x, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
||||
{"Pos Y", y, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
||||
{"Color", Color, PROPTYPE_COLOR, -1, pEditor->m_Map.m_lEnvelopes.size()},
|
||||
{"Color", Color, PROPTYPE_COLOR, -1, (int)pEditor->m_Map.m_lEnvelopes.size()},
|
||||
{"Tex U", tu, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
||||
{"Tex V", tv, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
||||
{0},
|
||||
|
@ -935,19 +936,19 @@ int CEditor::PopupPoint(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
if(Prop != -1)
|
||||
pEditor->m_Map.m_Modified = true;
|
||||
|
||||
for(int i = 0; i < lQuads.size(); ++i)
|
||||
for(auto &pQuad : lQuads)
|
||||
{
|
||||
if(Prop == PROP_POS_X)
|
||||
{
|
||||
for(int v = 0; v < 4; v++)
|
||||
if(pEditor->m_SelectedPoints & (1 << v))
|
||||
lQuads[i]->m_aPoints[v].x = i2fx(NewVal);
|
||||
pQuad->m_aPoints[v].x = i2fx(NewVal);
|
||||
}
|
||||
if(Prop == PROP_POS_Y)
|
||||
{
|
||||
for(int v = 0; v < 4; v++)
|
||||
if(pEditor->m_SelectedPoints & (1 << v))
|
||||
lQuads[i]->m_aPoints[v].y = i2fx(NewVal);
|
||||
pQuad->m_aPoints[v].y = i2fx(NewVal);
|
||||
}
|
||||
if(Prop == PROP_COLOR)
|
||||
{
|
||||
|
@ -955,10 +956,10 @@ int CEditor::PopupPoint(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
{
|
||||
if(pEditor->m_SelectedPoints & (1 << v))
|
||||
{
|
||||
lQuads[i]->m_aColors[v].r = (NewVal >> 24) & 0xff;
|
||||
lQuads[i]->m_aColors[v].g = (NewVal >> 16) & 0xff;
|
||||
lQuads[i]->m_aColors[v].b = (NewVal >> 8) & 0xff;
|
||||
lQuads[i]->m_aColors[v].a = NewVal & 0xff;
|
||||
pQuad->m_aColors[v].r = (NewVal >> 24) & 0xff;
|
||||
pQuad->m_aColors[v].g = (NewVal >> 16) & 0xff;
|
||||
pQuad->m_aColors[v].b = (NewVal >> 8) & 0xff;
|
||||
pQuad->m_aColors[v].a = NewVal & 0xff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -966,13 +967,13 @@ int CEditor::PopupPoint(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
{
|
||||
for(int v = 0; v < 4; v++)
|
||||
if(pEditor->m_SelectedPoints & (1 << v))
|
||||
lQuads[i]->m_aTexcoords[v].x = f2fx(NewVal / 1024.0f);
|
||||
pQuad->m_aTexcoords[v].x = f2fx(NewVal / 1024.0f);
|
||||
}
|
||||
if(Prop == PROP_TEX_V)
|
||||
{
|
||||
for(int v = 0; v < 4; v++)
|
||||
if(pEditor->m_SelectedPoints & (1 << v))
|
||||
lQuads[i]->m_aTexcoords[v].y = f2fx(NewVal / 1024.0f);
|
||||
pQuad->m_aTexcoords[v].y = f2fx(NewVal / 1024.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1251,7 +1252,7 @@ int CEditor::PopupSelectImage(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
|
||||
float ImageStopAt = ImagesHeight - ScrollDifference * (1 - s_ScrollValue);
|
||||
float ImageCur = 0.0f;
|
||||
for(int i = -1; i < pEditor->m_Map.m_lImages.size(); i++)
|
||||
for(int i = -1; i < (int)pEditor->m_Map.m_lImages.size(); i++)
|
||||
{
|
||||
if(ImageCur > ImageStopAt)
|
||||
break;
|
||||
|
@ -1280,7 +1281,7 @@ int CEditor::PopupSelectImage(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
}
|
||||
}
|
||||
|
||||
if(ShowImage >= 0 && ShowImage < pEditor->m_Map.m_lImages.size())
|
||||
if(ShowImage >= 0 && (size_t)ShowImage < pEditor->m_Map.m_lImages.size())
|
||||
{
|
||||
if(ImageView.h < ImageView.w)
|
||||
ImageView.w = ImageView.h;
|
||||
|
@ -1358,7 +1359,7 @@ int CEditor::PopupSelectSound(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
|
||||
float SoundStopAt = SoundsHeight - ScrollDifference * (1 - s_ScrollValue);
|
||||
float SoundCur = 0.0f;
|
||||
for(int i = -1; i < pEditor->m_Map.m_lSounds.size(); i++)
|
||||
for(int i = -1; i < (int)pEditor->m_Map.m_lSounds.size(); i++)
|
||||
{
|
||||
if(SoundCur > SoundStopAt)
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue