Refactoring tileset viewer to separate class.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <Data/Format.hpp>
|
||||
|
||||
#include "JUI/Widgets/FpsGraph.hpp"
|
||||
#include <App/Grid.hpp>
|
||||
|
||||
|
||||
JUI::Window* EditorApp::CreateAppInfoDialogWindow(JUI::Widget* parent)
|
||||
@@ -496,7 +497,9 @@ bool EditorApp::Open()
|
||||
// 1. Initialize elements of widgets that are independent of the level itself / the level depends on.
|
||||
// 2. Initialize the level.
|
||||
// 3. Initialize widgets that are dependent on the level itself.
|
||||
LoadTestFile();
|
||||
|
||||
//LoadTestFile();
|
||||
|
||||
CreateWidgets();
|
||||
|
||||
layer_view->UpdateComponents(loaded_level);
|
||||
@@ -727,25 +730,10 @@ void EditorApp::Update(float elapsed)
|
||||
|
||||
void EditorApp::DrawGrid(const AABB2D& bounds, const Color4& color)
|
||||
{
|
||||
Vector2 viewport_topleft = bounds.minPoint;
|
||||
Vector2 viewport_bottomright = bounds.maxPoint;
|
||||
|
||||
Vector2 cell_size (loaded_tileset->tile_width, loaded_tileset->tile_height);
|
||||
DrawGrid2(bounds, cell_size, color);
|
||||
|
||||
|
||||
int nearest_grid_left = Math::Floor(viewport_topleft.x / loaded_tileset->tile_width);
|
||||
int nearest_grid_right = Math::Floor(viewport_bottomright.x / loaded_tileset->tile_width);
|
||||
for (int x = nearest_grid_left; x <= nearest_grid_right; x++) {
|
||||
auto top = Vector2(x * loaded_tileset->tile_width, viewport_topleft.y);
|
||||
auto bottom = Vector2(x * loaded_tileset->tile_width, viewport_bottomright.y);
|
||||
JGL::J2D::DrawDashedLine(color, top, bottom, 4, 4, 1 / bounds.Width());
|
||||
}
|
||||
int nearest_grid_top = Math::Floor(viewport_topleft.y / loaded_tileset->tile_height);
|
||||
int nearest_grid_bottom = Math::Floor(viewport_bottomright.y / loaded_tileset->tile_height);
|
||||
for (int y = nearest_grid_top; y <= nearest_grid_bottom; y++) {
|
||||
auto left = Vector2(viewport_topleft.x, y * loaded_tileset->tile_height);
|
||||
auto right = Vector2(viewport_bottomright.x, y * loaded_tileset->tile_height);
|
||||
JGL::J2D::DrawDashedLine(color, left, right, 4, 4, 1 / bounds.Height());
|
||||
}
|
||||
}
|
||||
|
||||
void EditorApp::DrawGrid(const Color4& color)
|
||||
@@ -759,7 +747,11 @@ void EditorApp::DrawGrid(const Color4& color)
|
||||
float sw = GetWidth();
|
||||
float sh = GetHeight();
|
||||
|
||||
DrawGrid({{0,0}, {static_cast<float>(grid_rows*grid_pixel_width), static_cast<float>(grid_cols*grid_pixel_height)}}, color);
|
||||
AABB2D viewport = {{0,0}, {static_cast<float>(grid_rows*grid_pixel_width), static_cast<float>(grid_cols*grid_pixel_height)}};
|
||||
|
||||
Vector2 cell_size (loaded_tileset->tile_width, loaded_tileset->tile_height);
|
||||
|
||||
DrawGrid(viewport, color);
|
||||
}
|
||||
|
||||
void EditorApp::DrawCellPointerOutline()
|
||||
|
Reference in New Issue
Block a user