Removed the old map system from the editor
This commit is contained in:
+1
-55
@@ -54,21 +54,6 @@ EditorScene::EditorScene(ConfigUtility* const arg1):
|
||||
{"Edit", "-Set Tile", "-Load Sheet", "-Delete Sheet", "-Metadata", "-Run Script"},
|
||||
{"Debugging", "Debug On", "Debug Off", "Toggle Debug", "Testificate"}
|
||||
});
|
||||
|
||||
//setup the pager
|
||||
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());
|
||||
});
|
||||
|
||||
//Set a resonable size for the regions
|
||||
pager.SetWidth(32*4);
|
||||
pager.SetHeight(32*4);
|
||||
|
||||
sheetMgr.LoadSheet(config["dir.tilesets"] + "terrain.bmp", 32, 32);
|
||||
}
|
||||
|
||||
EditorScene::~EditorScene() {
|
||||
@@ -84,7 +69,7 @@ void EditorScene::FrameStart() {
|
||||
}
|
||||
|
||||
void EditorScene::Update(double delta) {
|
||||
pager.Prune(camera.x, camera.y, camera.x + GetScreen()->w, camera.y + GetScreen()->h);
|
||||
//
|
||||
}
|
||||
|
||||
void EditorScene::FrameEnd() {
|
||||
@@ -92,9 +77,6 @@ void EditorScene::FrameEnd() {
|
||||
}
|
||||
|
||||
void EditorScene::Render(SDL_Surface* const screen) {
|
||||
//draw the map
|
||||
pager.DrawTo(screen, &sheetMgr, camera.x, camera.y);
|
||||
|
||||
//draw a big bar across the top
|
||||
buttonImage.SetClipY(0);
|
||||
for (int i = 0; i < screen->w; i += buttonImage.GetClipW()) {
|
||||
@@ -130,24 +112,6 @@ void EditorScene::DrawToDebugInfo(std::string str, int line) {
|
||||
void EditorScene::MouseMotion(SDL_MouseMotionEvent const& motion) {
|
||||
menuBar.MouseMotion(motion);
|
||||
|
||||
if (motion.state & SDL_BUTTON_LMASK && motion.y >= buttonImage.GetClipH()) {
|
||||
Region* regionPtr = pager.GetRegion(
|
||||
snapToBase(pager.GetWidth(), motion.x + camera.x),
|
||||
snapToBase(pager.GetHeight(), motion.y + camera.y)
|
||||
);
|
||||
|
||||
TileSheet* sheetPtr = sheetMgr.GetSheetByIndex(tileCounter);
|
||||
|
||||
regionPtr->NewTileA({
|
||||
snapToBase(sheetPtr->GetTileW(), motion.x + camera.x), //x
|
||||
snapToBase(sheetPtr->GetTileH(), motion.y + camera.y), //y
|
||||
0, //depth
|
||||
sheetPtr->GetTileW(), //width
|
||||
sheetPtr->GetTileH(), //height
|
||||
tileCounter++ //value
|
||||
});
|
||||
}
|
||||
|
||||
if (motion.state & SDL_BUTTON_RMASK) {
|
||||
camera.x -= motion.xrel;
|
||||
camera.y -= motion.yrel;
|
||||
@@ -156,24 +120,6 @@ void EditorScene::MouseMotion(SDL_MouseMotionEvent const& motion) {
|
||||
|
||||
void EditorScene::MouseButtonDown(SDL_MouseButtonEvent const& button) {
|
||||
menuBar.MouseButtonDown(button);
|
||||
|
||||
if (button.button == SDL_BUTTON_LEFT && button.y >= buttonImage.GetClipH()) {
|
||||
Region* regionPtr = pager.GetRegion(
|
||||
snapToBase(pager.GetWidth(), button.x + camera.x),
|
||||
snapToBase(pager.GetHeight(), button.y + camera.y)
|
||||
);
|
||||
|
||||
TileSheet* sheetPtr = sheetMgr.GetSheetByIndex(tileCounter);
|
||||
|
||||
regionPtr->NewTileA({
|
||||
snapToBase(sheetPtr->GetTileW(), button.x + camera.x), //x
|
||||
snapToBase(sheetPtr->GetTileH(), button.y + camera.y), //y
|
||||
0, //depth
|
||||
sheetPtr->GetTileW(), //width
|
||||
sheetPtr->GetTileH(), //height
|
||||
tileCounter++ //value
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void EditorScene::MouseButtonUp(SDL_MouseButtonEvent const& button) {
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
|
||||
#include "base_scene.hpp"
|
||||
|
||||
#include "region_pager.hpp"
|
||||
#include "tile_sheet_manager.hpp"
|
||||
|
||||
#include "config_utility.hpp"
|
||||
#include "image.hpp"
|
||||
#include "raster_font.hpp"
|
||||
@@ -62,19 +59,13 @@ protected:
|
||||
Image debugInfo;
|
||||
bool debugOpen = true;
|
||||
|
||||
RegionPager pager;
|
||||
TileSheetManager sheetMgr;
|
||||
|
||||
RasterFont font;
|
||||
Image buttonImage;
|
||||
|
||||
MenuBar menuBar;
|
||||
|
||||
struct {
|
||||
int x = 0, y = 0;
|
||||
} camera;
|
||||
|
||||
int tileCounter = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -33,18 +33,7 @@ using std::endl;
|
||||
TestificateScene::TestificateScene(ConfigUtility* const arg1):
|
||||
config(*arg1)
|
||||
{
|
||||
sheetMgr.LoadSheet(config["dir.tilesets"] + "grass.bmp", 32, 32);
|
||||
sheetMgr.LoadSheet(config["dir.tilesets"] + "longgrass.bmp", 32, 32);
|
||||
sheetMgr.LoadSheet(config["dir.tilesets"] + "sand.bmp", 32, 32);
|
||||
sheetMgr.LoadSheet(config["dir.tilesets"] + "dirt.bmp", 32, 32);
|
||||
sheetMgr.LoadSheet(config["dir.tilesets"] + "water.bmp", 32, 32);
|
||||
|
||||
cout << "Range End: " << sheetMgr.GetRangeEnd() << endl;
|
||||
|
||||
pager.SetWidth(128);
|
||||
pager.SetHeight(128);
|
||||
|
||||
pager.GetRegion(0, 0)->NewTileR({0, 0, 0, 32, 32, 0});
|
||||
//
|
||||
}
|
||||
|
||||
TestificateScene::~TestificateScene() {
|
||||
@@ -68,12 +57,7 @@ void TestificateScene::FrameEnd() {
|
||||
}
|
||||
|
||||
void TestificateScene::Render(SDL_Surface* const screen) {
|
||||
//dump all tile graphics to the screen
|
||||
for (int i = 0; i < sheetMgr.GetRangeEnd(); i++) {
|
||||
sheetMgr.DrawTo(screen, i * 32 % screen->w, i * 32 / screen->w * 32, i);
|
||||
}
|
||||
|
||||
// pager.DrawTo(screen, &sheetMgr, 0, 0);
|
||||
//
|
||||
}
|
||||
|
||||
//-------------------------
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
#include "base_scene.hpp"
|
||||
|
||||
#include "config_utility.hpp"
|
||||
#include "tile_Sheet_manager.hpp"
|
||||
#include "region_pager.hpp"
|
||||
|
||||
class TestificateScene : public BaseScene {
|
||||
public:
|
||||
@@ -50,10 +48,6 @@ protected:
|
||||
|
||||
//globals
|
||||
ConfigUtility& config;
|
||||
|
||||
//members
|
||||
TileSheetManager sheetMgr;
|
||||
RegionPager pager;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user