Skip to content

Commit

Permalink
Merge pull request ddnet#7083 from Marmare314/style-7017
Browse files Browse the repository at this point in the history
improve code style in proofmode, mapgrid and mapview
  • Loading branch information
Robyt3 authored Aug 27, 2023
2 parents c9557b2 + 605a937 commit d11bbbc
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/game/editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void CLayerGroup::Mapping(float *pPoints)
m_pMap->m_pEditor->RenderTools()->MapScreenToWorld(
m_pMap->m_pEditor->MapView()->GetWorldOffset().x, m_pMap->m_pEditor->MapView()->GetWorldOffset().y,
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[1] += m_pMap->m_pEditor->MapView()->GetEditorOffset().y;
Expand Down
9 changes: 4 additions & 5 deletions src/game/editor/map_grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ void CMapGrid::OnRender(CUIRect View)
float aGroupPoints[4];
pGroup->Mapping(aGroupPoints);

float w = UI()->Screen()->w;
float h = UI()->Screen()->h;
const CUIRect *pScreen = UI()->Screen();

int LineDistance = GridLineDistance();

Expand All @@ -36,22 +35,22 @@ void CMapGrid::OnRender(CUIRect View)
Graphics()->TextureClear();
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)
Graphics()->SetColor(1.0f, 0.3f, 0.3f, 0.3f);
else
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);

if((i + XGridOffset) % m_GridFactor == 0)
Graphics()->SetColor(1.0f, 0.3f, 0.3f, 0.3f);
else
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()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
Expand Down
12 changes: 6 additions & 6 deletions src/game/editor/map_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ void CMapView::RenderGroupBorder()
float w, h;
pLayer->GetSize(&w, &h);

IGraphics::CLineItem Array[4] = {
IGraphics::CLineItem aArray[4] = {
IGraphics::CLineItem(0, 0, w, 0),
IGraphics::CLineItem(w, 0, w, h),
IGraphics::CLineItem(w, h, 0, h),
IGraphics::CLineItem(0, h, 0, 0)};
Graphics()->TextureClear();
Graphics()->LinesBegin();
Graphics()->LinesDraw(Array, 4);
Graphics()->LinesDraw(aArray, std::size(aArray));
Graphics()->LinesEnd();
}
}
Expand Down Expand Up @@ -121,11 +121,11 @@ void CMapView::RenderMap()
}
}

std::shared_ptr<CLayerTiles> pT = 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)
std::shared_ptr<CLayerTiles> pSelectedTilesLayer = std::static_pointer_cast<CLayerTiles>(Editor()->GetSelectedLayerType(0, LAYERTYPE_TILES));
if(Editor()->m_ShowTileInfo != CEditor::SHOW_TILE_OFF && pSelectedTilesLayer && pSelectedTilesLayer->m_Visible && m_Zoom.GetValue() <= 300.0f)
{
Editor()->GetSelectedGroup()->MapScreen();
pT->ShowInfo();
pSelectedTilesLayer->ShowInfo();
}
}

Expand Down Expand Up @@ -230,7 +230,7 @@ vec2 CMapView::GetEditorOffset() const
return m_EditorOffset;
}

float CMapView::WorldZoom() const
float CMapView::GetWorldZoom() const
{
return m_WorldZoom;
}
2 changes: 1 addition & 1 deletion src/game/editor/map_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CMapView : public CEditorComponent

bool m_ShowPicker; // TODO: make private

float WorldZoom() const;
float GetWorldZoom() const;

void OffsetWorld(vec2 Offset);
void OffsetEditor(vec2 Offset);
Expand Down
28 changes: 14 additions & 14 deletions src/game/editor/proof_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,28 +119,28 @@ void CProofMode::RenderScreenSizes()

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[3], aPoints[2], aPoints[3])};
Graphics()->LinesDraw(Array, 2);
Graphics()->LinesDraw(aArray, std::size(aArray));
}

if(i != 0)
{
IGraphics::CLineItem Array[4] = {
IGraphics::CLineItem aArray[4] = {
IGraphics::CLineItem(aPoints[0], aPoints[1], aLastPoints[0], 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[2], aPoints[3], aLastPoints[2], aLastPoints[3])};
Graphics()->LinesDraw(Array, 4);
Graphics()->LinesDraw(aArray, std::size(aArray));
}

if(i == NumSteps)
{
IGraphics::CLineItem Array[2] = {
IGraphics::CLineItem aArray[2] = {
IGraphics::CLineItem(aPoints[0], aPoints[1], aPoints[0], 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));
Expand All @@ -166,12 +166,12 @@ void CProofMode::RenderScreenSizes()
r.w = aPoints[2] - aPoints[0];
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.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.y + r.h, r.x, r.y)};
Graphics()->LinesDraw(Array, 4);
Graphics()->LinesDraw(aArray, std::size(aArray));
Graphics()->SetColor(0, 1, 0, 1);
}
}
Expand All @@ -188,16 +188,16 @@ void CProofMode::RenderScreenSizes()
{
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++)
indices.insert(i);
Indices.insert(i);

while(!indices.empty())
while(!Indices.empty())
{
int i = *indices.begin();
indices.erase(i);
int i = *Indices.begin();
Indices.erase(i);
for(int k : m_vMenuBackgroundCollisions.at(i))
indices.erase(k);
Indices.erase(k);

vec2 Pos = m_vMenuBackgroundPositions[i];
Pos += WorldOffset - m_vMenuBackgroundPositions[m_CurrentMenuProofIndex];
Expand Down

0 comments on commit d11bbbc

Please sign in to comment.