From 3e8ebf3133ece10efc8cf9219dafc02e780bc3ab Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 21 May 2022 21:17:27 +0200 Subject: Added naive icons loading --- View.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'View.cpp') diff --git a/View.cpp b/View.cpp index 50e5549..3360808 100644 --- a/View.cpp +++ b/View.cpp @@ -7,18 +7,22 @@ #include +#include "Globals.h" #include "Grid.h" #include "Label.h" #include "Timeline.h" #include "Utils.h" +const Color BACKGROUND {8, 8, 50, 255}; +const Color LINE {240, 240, 240, 160}; + + View::View(std::vector grids, Timeline timeline) : m_camera {}, m_grids {grids}, m_labels {}, m_grid {0}, - m_texture {LoadTexture("resources/wreck.png")}, m_active {nullptr}, m_timeline {timeline} { @@ -33,7 +37,6 @@ View::View(std::vector grids, Timeline timeline) : View::~View() { - UnloadTexture(m_texture); } @@ -62,7 +65,8 @@ View::update(const float dt) const auto depth = dist(m_camera.position, wreck.position); const auto length = dist(pos, base); const bool hover = 8.0f > dist(mouse, pos); - m_labels.push_back(Label{pos, base, depth, length, hover, std::ref(wreck)}); + m_labels.push_back( + Label{pos, base, depth, length, hover, std::ref(wreck), app.icons.find(wreck.killmail.ship)}); } std::sort(m_labels.begin(), m_labels.end(), [](auto& a, auto& b){ return a.depth > b.depth; }); m_active = nullptr; @@ -81,12 +85,12 @@ void View::draw() const { BeginDrawing(); - ClearBackground(RAYWHITE); + ClearBackground(BACKGROUND); BeginMode3D(m_camera); DrawGrid(12, 1.0f); EndMode3D(); for (const auto& point : m_labels) { - Color line = point.hover ? ORANGE : GRAY; + Color line = point.hover ? ORANGE : LINE; Color icon = point.hover ? ORANGE : WHITE; if (!point.hover && point.wreck.get().time > m_timeline.current()) { line.a = 20; @@ -94,7 +98,7 @@ View::draw() const } if (point.length > 8) DrawLine(point.base.x, point.base.y, point.pos.x, point.pos.y, line); - DrawTexture(m_texture, point.pos.x - 8, point.pos.y - 8, icon); + DrawTexture(point.texture, point.pos.x - 8, point.pos.y - 8, icon); } DrawFPS(5, 5); DrawText(TextFormat("%d", m_labels.size()), 5, 25, 20, DARKGRAY); -- cgit v1.1