From bc32f2a2f028d008d2fe948a8f8e095d7c081b0b Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Tue, 22 Oct 2013 19:43:20 +1100 Subject: [PATCH] The editor scene now works correctly with the TileSheetManager --- editor/editor_application.cpp | 6 +++--- editor/editor_scene.cpp | 27 ++++++++++++--------------- editor/editor_scene.hpp | 8 +++----- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/editor/editor_application.cpp b/editor/editor_application.cpp index f222165..8e9e8c8 100644 --- a/editor/editor_application.cpp +++ b/editor/editor_application.cpp @@ -109,9 +109,9 @@ void EditorApplication::LoadScene(SceneList sceneIndex) { switch(sceneIndex) { //add scene creation calls here case SceneList::FIRST: - case SceneList::TESTIFICATESCENE: - activeScene = new TestificateScene(); - break; +// case SceneList::TESTIFICATESCENE: +// activeScene = new TestificateScene(); +// break; case SceneList::EDITORSCENE: activeScene = new EditorScene(); diff --git a/editor/editor_scene.cpp b/editor/editor_scene.cpp index d607b33..c1e5650 100644 --- a/editor/editor_scene.cpp +++ b/editor/editor_scene.cpp @@ -50,20 +50,20 @@ EditorScene::EditorScene() { {"Debugging", "Debug On", "Debug Off", "Toggle Debug"} }); -// pager.SetOnNew([](Region* const ptr){ -// printf("New Region: %d, %d\n", ptr->GetX(), ptr->GetY()); -// }); + pager.SetOnNew([](Region* const ptr){ + printf("New Region: %d, %d\n", ptr->GetX(), ptr->GetY()); + }); -// pager.SetOnDelete([](Region* const ptr){ -// printf("Delete Region: %d, %d\n", ptr->GetX(), ptr->GetY()); -// }); + pager.SetOnDelete([](Region* const ptr){ + printf("Delete Region: %d, %d\n", ptr->GetX(), ptr->GetY()); + }); - //32 * 32 sized tiles -// pager.SetWidth(32*4); -// pager.SetHeight(32*4); + //Set a resonable size for the regions + pager.SetWidth(32*4); + pager.SetHeight(32*4); - sheetList.push_front(TileSheet()); - sheetList.front().LoadSurface("rsc\\graphics\\tilesets\\terrain.bmp", 32, 32); + sheetMgr.LoadSheet("rsc\\graphics\\tilesets\\grass.bmp", 32, 32); + sheetMgr.LoadSheet("rsc\\graphics\\tilesets\\longgrass.bmp", 32, 32); // loadGameMap("rsc\\maps\\mappy", &pager, &sheetList); // saveGameMap("rsc\\maps\\foo", &pager, &sheetList); @@ -71,9 +71,6 @@ EditorScene::EditorScene() { // cout << "Region Width: " << pager.GetWidth() << endl; // cout << "Region Height: " << pager.GetHeight() << endl; - pager.SetWidth(128); - pager.SetHeight(128); - // for (auto& it : sheetList) { // cout << it.GetName() << ": " << it.GetBegin() << ", " << it.GetEnd() << endl; // } @@ -101,7 +98,7 @@ void EditorScene::FrameEnd() { void EditorScene::Render(SDL_Surface* const screen) { //draw the map - pager.DrawTo(screen, &sheetList, camera.x, camera.y); + pager.DrawTo(screen, &sheetMgr, camera.x, camera.y); //draw a big bar across the top buttonImage.SetClipY(0); diff --git a/editor/editor_scene.hpp b/editor/editor_scene.hpp index 95b7414..7f3a1ce 100644 --- a/editor/editor_scene.hpp +++ b/editor/editor_scene.hpp @@ -25,15 +25,13 @@ #include "base_scene.hpp" #include "region_pager.hpp" -#include "tile_sheet.hpp" +#include "tile_sheet_manager.hpp" #include "image.hpp" #include "raster_font.hpp" #include "menu_bar.hpp" -#include "map_loader.hpp" - -#include +//#include "map_loader.hpp" class EditorScene : public BaseScene { public: @@ -63,7 +61,7 @@ protected: bool debugOpen = true; RegionPager pager; - std::list sheetList; + TileSheetManager sheetMgr; RasterFont font; Image buttonImage;