Loosened the requirements for constructing a MapPager

This is so that I can configure the size of the pages in the config.cfg
file.
This commit is contained in:
Kayne Ruse
2014-03-15 19:15:58 +11:00
parent dd786ba579
commit 7e500027e3
6 changed files with 46 additions and 20 deletions
-4
View File
@@ -62,7 +62,3 @@ Region* RegionPagerBase::GetRegion(int x, int y) {
if (ptr) return ptr;
return CreateRegion(x, y);
}
void RegionPagerBase::Update() {
//TODO
}
+13 -10
View File
@@ -29,15 +29,13 @@
class RegionPagerBase {
public:
RegionPagerBase() = delete;
RegionPagerBase() = default;
RegionPagerBase(int regionWidth, int regionHeight, int regionDepth);
virtual ~RegionPagerBase();
int SetTile(int x, int y, int z, int v);
int GetTile(int x, int y, int z);
void Update();
Region* GetRegion(int x, int y);
//interface
@@ -47,20 +45,25 @@ public:
virtual void UnloadRegion(int x, int y) = 0;
//accessors
int GetRegionWidth() { return regionWidth; }
int GetRegionHeight() { return regionHeight; }
int GetRegionDepth() { return regionDepth; }
//NOTE: don't change the sizes mid-program, it will cause issues
int SetRegionWidth(int i) { return regionWidth = i; }
int SetRegionHeight(int i) { return regionHeight = i; }
int SetRegionDepth(int i) { return regionDepth = i; }
int GetRegionWidth() const { return regionWidth; }
int GetRegionHeight() const { return regionHeight; }
int GetRegionDepth() const { return regionDepth; }
protected:
const int regionWidth;
const int regionHeight;
const int regionDepth;
int regionWidth;
int regionHeight;
int regionDepth;
std::list<Region*> regionList;
};
template<typename MapGenerator, typename MapFileFormat>
class RegionPager : public RegionPagerBase {
public:
RegionPager() = delete;
RegionPager() = default;
RegionPager(int w, int h, int d):
RegionPagerBase(w, h, d)
{
+7 -2
View File
@@ -34,8 +34,7 @@ using namespace std;
//-------------------------
EditorScene::EditorScene(ConfigUtility* const arg1):
config(*arg1),
pager(20, 20, 3)
config(*arg1)
{
//create the debugging "window"
debugInfo.CreateSurface(256, 256);
@@ -56,6 +55,11 @@ EditorScene::EditorScene(ConfigUtility* const arg1):
{"Debug", "Debug On", "Debug Off", "Toggle", "Testificate"}
});
//setup the map
pager.SetRegionWidth(config.Int("map.pager.width"));
pager.SetRegionHeight(config.Int("map.pager.height"));
pager.SetRegionDepth(config.Int("map.pager.depth"));
//debug
tsheet.Load("rsc\\graphics\\tilesets\\sand.bmp", 12, 3);
}
@@ -85,6 +89,7 @@ void EditorScene::Render(SDL_Surface* const screen) {
for (int i = 0; i < pager.GetRegionWidth()*2; i++) {
for (int j = 0; j < pager.GetRegionHeight()*2; j++) {
for (int k = 0; k < pager.GetRegionDepth(); k++) {
//TODO: skip the out-of-bounds regions
tsheet.DrawTo(
screen,
i*tsheet.GetTileW()-camera.x,
+5
View File
@@ -17,6 +17,11 @@ dir.tilesets = rsc/graphics/tilesets/
dir.interface = rsc/graphics/interface/
dir.scripts = rsc/scripts/
#map system
map.pager.width = 20
map.pager.height = 20
map.pager.depth = 3
#player options
player.handle = username
player.avatar = elliot2.bmp
+9
View File
@@ -96,6 +96,15 @@ void ServerApplication::Init(int argc, char** argv) {
}
cout << "Initialized lua's setup script" << endl;
//setup the map object
mapPager.SetRegionWidth(config.Int("map.pager.width"));
mapPager.SetRegionHeight(config.Int("map.pager.height"));
mapPager.SetRegionDepth(config.Int("map.pager.depth"));
//TODO: pass args to the generator & format as needed
//NOTE: I might need to rearrange the init process so that lua & SQL can interact
// with the map system as needed.
cout << "Initialized the map system" << endl;
//finalize the startup
cout << "Startup completed successfully" << endl;
}
+12 -4
View File
@@ -22,20 +22,25 @@
#ifndef SERVERAPPLICATION_HPP_
#define SERVERAPPLICATION_HPP_
//maps
#include "map_generator.hpp"
#include "map_file_format.hpp"
#include "region_pager.hpp"
//networking
#include "network_packet.hpp"
#include "udp_network_utility.hpp"
#include "serial.hpp"
//common
#include "config_utility.hpp"
#include "vector2.hpp"
//APIs
#include "lua/lua.hpp"
#include "sqlite3/sqlite3.h"
#include "SDL/SDL.h"
//common
#include "config_utility.hpp"
#include "vector2.hpp"
//STL
#include <map>
#include <string>
@@ -79,6 +84,9 @@ private:
void PumpPacket(NetworkPacket);
//maps
RegionPager<MapGenerator, MapFileFormat> mapPager;
//networking
UDPNetworkUtility network;