The editor scene now works correctly with the TileSheetManager

This commit is contained in:
Kayne Ruse
2013-10-22 19:43:20 +11:00
parent 76bfecd466
commit bc32f2a2f0
3 changed files with 18 additions and 23 deletions
+3 -3
View File
@@ -109,9 +109,9 @@ void EditorApplication::LoadScene(SceneList sceneIndex) {
switch(sceneIndex) { switch(sceneIndex) {
//add scene creation calls here //add scene creation calls here
case SceneList::FIRST: case SceneList::FIRST:
case SceneList::TESTIFICATESCENE: // case SceneList::TESTIFICATESCENE:
activeScene = new TestificateScene(); // activeScene = new TestificateScene();
break; // break;
case SceneList::EDITORSCENE: case SceneList::EDITORSCENE:
activeScene = new EditorScene(); activeScene = new EditorScene();
+12 -15
View File
@@ -50,20 +50,20 @@ EditorScene::EditorScene() {
{"Debugging", "Debug On", "Debug Off", "Toggle Debug"} {"Debugging", "Debug On", "Debug Off", "Toggle Debug"}
}); });
// pager.SetOnNew([](Region* const ptr){ pager.SetOnNew([](Region* const ptr){
// printf("New Region: %d, %d\n", ptr->GetX(), ptr->GetY()); printf("New Region: %d, %d\n", ptr->GetX(), ptr->GetY());
// }); });
// pager.SetOnDelete([](Region* const ptr){ pager.SetOnDelete([](Region* const ptr){
// printf("Delete Region: %d, %d\n", ptr->GetX(), ptr->GetY()); printf("Delete Region: %d, %d\n", ptr->GetX(), ptr->GetY());
// }); });
//32 * 32 sized tiles //Set a resonable size for the regions
// pager.SetWidth(32*4); pager.SetWidth(32*4);
// pager.SetHeight(32*4); pager.SetHeight(32*4);
sheetList.push_front(TileSheet()); sheetMgr.LoadSheet("rsc\\graphics\\tilesets\\grass.bmp", 32, 32);
sheetList.front().LoadSurface("rsc\\graphics\\tilesets\\terrain.bmp", 32, 32); sheetMgr.LoadSheet("rsc\\graphics\\tilesets\\longgrass.bmp", 32, 32);
// loadGameMap("rsc\\maps\\mappy", &pager, &sheetList); // loadGameMap("rsc\\maps\\mappy", &pager, &sheetList);
// saveGameMap("rsc\\maps\\foo", &pager, &sheetList); // saveGameMap("rsc\\maps\\foo", &pager, &sheetList);
@@ -71,9 +71,6 @@ EditorScene::EditorScene() {
// cout << "Region Width: " << pager.GetWidth() << endl; // cout << "Region Width: " << pager.GetWidth() << endl;
// cout << "Region Height: " << pager.GetHeight() << endl; // cout << "Region Height: " << pager.GetHeight() << endl;
pager.SetWidth(128);
pager.SetHeight(128);
// for (auto& it : sheetList) { // for (auto& it : sheetList) {
// cout << it.GetName() << ": " << it.GetBegin() << ", " << it.GetEnd() << endl; // cout << it.GetName() << ": " << it.GetBegin() << ", " << it.GetEnd() << endl;
// } // }
@@ -101,7 +98,7 @@ void EditorScene::FrameEnd() {
void EditorScene::Render(SDL_Surface* const screen) { void EditorScene::Render(SDL_Surface* const screen) {
//draw the map //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 //draw a big bar across the top
buttonImage.SetClipY(0); buttonImage.SetClipY(0);
+3 -5
View File
@@ -25,15 +25,13 @@
#include "base_scene.hpp" #include "base_scene.hpp"
#include "region_pager.hpp" #include "region_pager.hpp"
#include "tile_sheet.hpp" #include "tile_sheet_manager.hpp"
#include "image.hpp" #include "image.hpp"
#include "raster_font.hpp" #include "raster_font.hpp"
#include "menu_bar.hpp" #include "menu_bar.hpp"
#include "map_loader.hpp" //#include "map_loader.hpp"
#include <list>
class EditorScene : public BaseScene { class EditorScene : public BaseScene {
public: public:
@@ -63,7 +61,7 @@ protected:
bool debugOpen = true; bool debugOpen = true;
RegionPager pager; RegionPager pager;
std::list<TileSheet> sheetList; TileSheetManager sheetMgr;
RasterFont font; RasterFont font;
Image buttonImage; Image buttonImage;