mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge pull request #7083 from Marmare314/style-7017
improve code style in proofmode, mapgrid and mapview
This commit is contained in:
commit
d11bbbc921
|
@ -140,7 +140,7 @@ void CLayerGroup::Mapping(float *pPoints)
|
||||||
m_pMap->m_pEditor->RenderTools()->MapScreenToWorld(
|
m_pMap->m_pEditor->RenderTools()->MapScreenToWorld(
|
||||||
m_pMap->m_pEditor->MapView()->GetWorldOffset().x, m_pMap->m_pEditor->MapView()->GetWorldOffset().y,
|
m_pMap->m_pEditor->MapView()->GetWorldOffset().x, m_pMap->m_pEditor->MapView()->GetWorldOffset().y,
|
||||||
m_ParallaxX, m_ParallaxY, ParallaxZoom, m_OffsetX, m_OffsetY,
|
m_ParallaxX, m_ParallaxY, ParallaxZoom, m_OffsetX, m_OffsetY,
|
||||||
m_pMap->m_pEditor->Graphics()->ScreenAspect(), m_pMap->m_pEditor->MapView()->WorldZoom(), pPoints);
|
m_pMap->m_pEditor->Graphics()->ScreenAspect(), m_pMap->m_pEditor->MapView()->GetWorldZoom(), pPoints);
|
||||||
|
|
||||||
pPoints[0] += m_pMap->m_pEditor->MapView()->GetEditorOffset().x;
|
pPoints[0] += m_pMap->m_pEditor->MapView()->GetEditorOffset().x;
|
||||||
pPoints[1] += m_pMap->m_pEditor->MapView()->GetEditorOffset().y;
|
pPoints[1] += m_pMap->m_pEditor->MapView()->GetEditorOffset().y;
|
||||||
|
|
|
@ -23,8 +23,7 @@ void CMapGrid::OnRender(CUIRect View)
|
||||||
float aGroupPoints[4];
|
float aGroupPoints[4];
|
||||||
pGroup->Mapping(aGroupPoints);
|
pGroup->Mapping(aGroupPoints);
|
||||||
|
|
||||||
float w = UI()->Screen()->w;
|
const CUIRect *pScreen = UI()->Screen();
|
||||||
float h = UI()->Screen()->h;
|
|
||||||
|
|
||||||
int LineDistance = GridLineDistance();
|
int LineDistance = GridLineDistance();
|
||||||
|
|
||||||
|
@ -36,14 +35,14 @@ void CMapGrid::OnRender(CUIRect View)
|
||||||
Graphics()->TextureClear();
|
Graphics()->TextureClear();
|
||||||
Graphics()->LinesBegin();
|
Graphics()->LinesBegin();
|
||||||
|
|
||||||
for(int i = 0; i < (int)w; i++)
|
for(int i = 0; i < (int)pScreen->w; i++)
|
||||||
{
|
{
|
||||||
if((i + YGridOffset) % m_GridFactor == 0)
|
if((i + YGridOffset) % m_GridFactor == 0)
|
||||||
Graphics()->SetColor(1.0f, 0.3f, 0.3f, 0.3f);
|
Graphics()->SetColor(1.0f, 0.3f, 0.3f, 0.3f);
|
||||||
else
|
else
|
||||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.15f);
|
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.15f);
|
||||||
|
|
||||||
IGraphics::CLineItem Line = IGraphics::CLineItem(LineDistance * XOffset, LineDistance * i + LineDistance * YOffset, w + aGroupPoints[2], LineDistance * i + LineDistance * YOffset);
|
IGraphics::CLineItem Line = IGraphics::CLineItem(LineDistance * XOffset, LineDistance * i + LineDistance * YOffset, pScreen->w + aGroupPoints[2], LineDistance * i + LineDistance * YOffset);
|
||||||
Graphics()->LinesDraw(&Line, 1);
|
Graphics()->LinesDraw(&Line, 1);
|
||||||
|
|
||||||
if((i + XGridOffset) % m_GridFactor == 0)
|
if((i + XGridOffset) % m_GridFactor == 0)
|
||||||
|
@ -51,7 +50,7 @@ void CMapGrid::OnRender(CUIRect View)
|
||||||
else
|
else
|
||||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.15f);
|
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.15f);
|
||||||
|
|
||||||
Line = IGraphics::CLineItem(LineDistance * i + LineDistance * XOffset, LineDistance * YOffset, LineDistance * i + LineDistance * XOffset, h + aGroupPoints[3]);
|
Line = IGraphics::CLineItem(LineDistance * i + LineDistance * XOffset, LineDistance * YOffset, LineDistance * i + LineDistance * XOffset, pScreen->h + aGroupPoints[3]);
|
||||||
Graphics()->LinesDraw(&Line, 1);
|
Graphics()->LinesDraw(&Line, 1);
|
||||||
}
|
}
|
||||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
|
@ -66,14 +66,14 @@ void CMapView::RenderGroupBorder()
|
||||||
float w, h;
|
float w, h;
|
||||||
pLayer->GetSize(&w, &h);
|
pLayer->GetSize(&w, &h);
|
||||||
|
|
||||||
IGraphics::CLineItem Array[4] = {
|
IGraphics::CLineItem aArray[4] = {
|
||||||
IGraphics::CLineItem(0, 0, w, 0),
|
IGraphics::CLineItem(0, 0, w, 0),
|
||||||
IGraphics::CLineItem(w, 0, w, h),
|
IGraphics::CLineItem(w, 0, w, h),
|
||||||
IGraphics::CLineItem(w, h, 0, h),
|
IGraphics::CLineItem(w, h, 0, h),
|
||||||
IGraphics::CLineItem(0, h, 0, 0)};
|
IGraphics::CLineItem(0, h, 0, 0)};
|
||||||
Graphics()->TextureClear();
|
Graphics()->TextureClear();
|
||||||
Graphics()->LinesBegin();
|
Graphics()->LinesBegin();
|
||||||
Graphics()->LinesDraw(Array, 4);
|
Graphics()->LinesDraw(aArray, std::size(aArray));
|
||||||
Graphics()->LinesEnd();
|
Graphics()->LinesEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,11 +121,11 @@ void CMapView::RenderMap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<CLayerTiles> pT = std::static_pointer_cast<CLayerTiles>(Editor()->GetSelectedLayerType(0, LAYERTYPE_TILES));
|
std::shared_ptr<CLayerTiles> pSelectedTilesLayer = std::static_pointer_cast<CLayerTiles>(Editor()->GetSelectedLayerType(0, LAYERTYPE_TILES));
|
||||||
if(Editor()->m_ShowTileInfo != CEditor::SHOW_TILE_OFF && pT && pT->m_Visible && m_Zoom.GetValue() <= 300.0f)
|
if(Editor()->m_ShowTileInfo != CEditor::SHOW_TILE_OFF && pSelectedTilesLayer && pSelectedTilesLayer->m_Visible && m_Zoom.GetValue() <= 300.0f)
|
||||||
{
|
{
|
||||||
Editor()->GetSelectedGroup()->MapScreen();
|
Editor()->GetSelectedGroup()->MapScreen();
|
||||||
pT->ShowInfo();
|
pSelectedTilesLayer->ShowInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ vec2 CMapView::GetEditorOffset() const
|
||||||
return m_EditorOffset;
|
return m_EditorOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CMapView::WorldZoom() const
|
float CMapView::GetWorldZoom() const
|
||||||
{
|
{
|
||||||
return m_WorldZoom;
|
return m_WorldZoom;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
|
|
||||||
bool m_ShowPicker; // TODO: make private
|
bool m_ShowPicker; // TODO: make private
|
||||||
|
|
||||||
float WorldZoom() const;
|
float GetWorldZoom() const;
|
||||||
|
|
||||||
void OffsetWorld(vec2 Offset);
|
void OffsetWorld(vec2 Offset);
|
||||||
void OffsetEditor(vec2 Offset);
|
void OffsetEditor(vec2 Offset);
|
||||||
|
|
|
@ -119,28 +119,28 @@ void CProofMode::RenderScreenSizes()
|
||||||
|
|
||||||
if(i == 0)
|
if(i == 0)
|
||||||
{
|
{
|
||||||
IGraphics::CLineItem Array[2] = {
|
IGraphics::CLineItem aArray[2] = {
|
||||||
IGraphics::CLineItem(aPoints[0], aPoints[1], aPoints[2], aPoints[1]),
|
IGraphics::CLineItem(aPoints[0], aPoints[1], aPoints[2], aPoints[1]),
|
||||||
IGraphics::CLineItem(aPoints[0], aPoints[3], aPoints[2], aPoints[3])};
|
IGraphics::CLineItem(aPoints[0], aPoints[3], aPoints[2], aPoints[3])};
|
||||||
Graphics()->LinesDraw(Array, 2);
|
Graphics()->LinesDraw(aArray, std::size(aArray));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i != 0)
|
if(i != 0)
|
||||||
{
|
{
|
||||||
IGraphics::CLineItem Array[4] = {
|
IGraphics::CLineItem aArray[4] = {
|
||||||
IGraphics::CLineItem(aPoints[0], aPoints[1], aLastPoints[0], aLastPoints[1]),
|
IGraphics::CLineItem(aPoints[0], aPoints[1], aLastPoints[0], aLastPoints[1]),
|
||||||
IGraphics::CLineItem(aPoints[2], aPoints[1], aLastPoints[2], aLastPoints[1]),
|
IGraphics::CLineItem(aPoints[2], aPoints[1], aLastPoints[2], aLastPoints[1]),
|
||||||
IGraphics::CLineItem(aPoints[0], aPoints[3], aLastPoints[0], aLastPoints[3]),
|
IGraphics::CLineItem(aPoints[0], aPoints[3], aLastPoints[0], aLastPoints[3]),
|
||||||
IGraphics::CLineItem(aPoints[2], aPoints[3], aLastPoints[2], aLastPoints[3])};
|
IGraphics::CLineItem(aPoints[2], aPoints[3], aLastPoints[2], aLastPoints[3])};
|
||||||
Graphics()->LinesDraw(Array, 4);
|
Graphics()->LinesDraw(aArray, std::size(aArray));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i == NumSteps)
|
if(i == NumSteps)
|
||||||
{
|
{
|
||||||
IGraphics::CLineItem Array[2] = {
|
IGraphics::CLineItem aArray[2] = {
|
||||||
IGraphics::CLineItem(aPoints[0], aPoints[1], aPoints[0], aPoints[3]),
|
IGraphics::CLineItem(aPoints[0], aPoints[1], aPoints[0], aPoints[3]),
|
||||||
IGraphics::CLineItem(aPoints[2], aPoints[1], aPoints[2], aPoints[3])};
|
IGraphics::CLineItem(aPoints[2], aPoints[1], aPoints[2], aPoints[3])};
|
||||||
Graphics()->LinesDraw(Array, 2);
|
Graphics()->LinesDraw(aArray, std::size(aArray));
|
||||||
}
|
}
|
||||||
|
|
||||||
mem_copy(aLastPoints, aPoints, sizeof(aPoints));
|
mem_copy(aLastPoints, aPoints, sizeof(aPoints));
|
||||||
|
@ -166,12 +166,12 @@ void CProofMode::RenderScreenSizes()
|
||||||
r.w = aPoints[2] - aPoints[0];
|
r.w = aPoints[2] - aPoints[0];
|
||||||
r.h = aPoints[3] - aPoints[1];
|
r.h = aPoints[3] - aPoints[1];
|
||||||
|
|
||||||
IGraphics::CLineItem Array[4] = {
|
IGraphics::CLineItem aArray[4] = {
|
||||||
IGraphics::CLineItem(r.x, r.y, r.x + r.w, r.y),
|
IGraphics::CLineItem(r.x, r.y, r.x + r.w, r.y),
|
||||||
IGraphics::CLineItem(r.x + r.w, r.y, r.x + r.w, r.y + r.h),
|
IGraphics::CLineItem(r.x + r.w, r.y, r.x + r.w, r.y + r.h),
|
||||||
IGraphics::CLineItem(r.x + r.w, r.y + r.h, r.x, r.y + r.h),
|
IGraphics::CLineItem(r.x + r.w, r.y + r.h, r.x, r.y + r.h),
|
||||||
IGraphics::CLineItem(r.x, r.y + r.h, r.x, r.y)};
|
IGraphics::CLineItem(r.x, r.y + r.h, r.x, r.y)};
|
||||||
Graphics()->LinesDraw(Array, 4);
|
Graphics()->LinesDraw(aArray, std::size(aArray));
|
||||||
Graphics()->SetColor(0, 1, 0, 1);
|
Graphics()->SetColor(0, 1, 0, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,16 +188,16 @@ void CProofMode::RenderScreenSizes()
|
||||||
{
|
{
|
||||||
Graphics()->SetColor(0, 1, 0, 0.3f);
|
Graphics()->SetColor(0, 1, 0, 0.3f);
|
||||||
|
|
||||||
std::set<int> indices;
|
std::set<int> Indices;
|
||||||
for(int i = 0; i < (int)m_vMenuBackgroundPositions.size(); i++)
|
for(int i = 0; i < (int)m_vMenuBackgroundPositions.size(); i++)
|
||||||
indices.insert(i);
|
Indices.insert(i);
|
||||||
|
|
||||||
while(!indices.empty())
|
while(!Indices.empty())
|
||||||
{
|
{
|
||||||
int i = *indices.begin();
|
int i = *Indices.begin();
|
||||||
indices.erase(i);
|
Indices.erase(i);
|
||||||
for(int k : m_vMenuBackgroundCollisions.at(i))
|
for(int k : m_vMenuBackgroundCollisions.at(i))
|
||||||
indices.erase(k);
|
Indices.erase(k);
|
||||||
|
|
||||||
vec2 Pos = m_vMenuBackgroundPositions[i];
|
vec2 Pos = m_vMenuBackgroundPositions[i];
|
||||||
Pos += WorldOffset - m_vMenuBackgroundPositions[m_CurrentMenuProofIndex];
|
Pos += WorldOffset - m_vMenuBackgroundPositions[m_CurrentMenuProofIndex];
|
||||||
|
|
Loading…
Reference in a new issue