editor assets refactored to fit the new project content system design

Gui_Panel_Refactor
Joeyrp 4 years ago
parent 894580c325
commit 6aef59c7e3

5
.gitignore vendored

@ -36,9 +36,14 @@
*.out *.out
*.app *.app
# line counter
.VSCodeCounter
# other # other
*.log *.log
*.zip *.zip
*.png
*.jpg
test_data/test_save.xml test_data/test_save.xml
######################## CMAKE IGNORES ######################## CMAKE IGNORES

@ -6,8 +6,8 @@
* Description - Common graphics definitions * Description - Common graphics definitions
******************************************************************************/ ******************************************************************************/
#ifndef DEFINITIONS_H_ #ifndef ASSETS_DEFINITIONS_H_
#define DEFINITIONS_H_ #define ASSETS_DEFINITIONS_H_
namespace lunarium namespace lunarium
{ {
@ -20,4 +20,4 @@ namespace lunarium
}; };
} }
#endif // DEFINITIONS_H_ #endif // ASSETS_DEFINITIONS_H_

@ -9,9 +9,11 @@ set(EDITOR_SRC
"panels/worldTree.cpp" "panels/worldTree.cpp"
"panels/worldView.cpp" "panels/worldView.cpp"
"panels/propertiesView.cpp" "panels/propertiesView.cpp"
"project/contents/content_manager.cpp"
"project/contents/editor_asset.cpp"
"project/contents/tile_map.cpp"
"project/contents/tile_set.cpp"
"tools/map_editor/map_editor.cpp" "tools/map_editor/map_editor.cpp"
"tools/map_editor/tile_map.cpp"
"tools/map_editor/tile_set.cpp"
"tools/map_editor/panels/map_canvas.cpp" "tools/map_editor/panels/map_canvas.cpp"
"tools/map_editor/panels/tile_set_view.cpp" "tools/map_editor/panels/tile_set_view.cpp"
) )

@ -23,9 +23,10 @@
namespace lunarium namespace lunarium
{ {
class FileBrowser; class FileBrowser;
namespace editor }
{
namespace lunarium { namespace editor
{
enum ToolType enum ToolType
{ {
TT_MAIN_EDITOR, TT_MAIN_EDITOR,
@ -41,7 +42,7 @@ namespace lunarium
public: public:
Editor(); Editor();
OpRes Initialize(); [[nodiscard]] OpRes Initialize();
void Shutdown(); void Shutdown();
void OnTick(double delta); void OnTick(double delta);
void OnRender(lunarium::IGraphics* g); void OnRender(lunarium::IGraphics* g);
@ -88,7 +89,7 @@ namespace lunarium
void HandleOpenPanel(const char* name, gui::PanelType type); void HandleOpenPanel(const char* name, gui::PanelType type);
}; };
}
} }}
#endif // EDITOR_H_ #endif // EDITOR_H_

@ -21,12 +21,12 @@ namespace editor
} }
void WorldTree::SetWorld(World* pWorld) void WorldTree::SetWorld(lunarium::game::World* pWorld)
{ {
mpWorld = pWorld; mpWorld = pWorld;
} }
World* WorldTree::GetWorld() lunarium::game::World* WorldTree::GetWorld()
{ {
return mpWorld; return mpWorld;
} }

@ -13,7 +13,8 @@
namespace lunarium namespace lunarium
{ {
class World; namespace game { class World; }
namespace editor namespace editor
{ {
class WorldTree : public gui::Panel class WorldTree : public gui::Panel
@ -21,13 +22,13 @@ namespace editor
public: public:
WorldTree(); WorldTree();
void SetWorld(World* pWorld); void SetWorld(lunarium::game::World* pWorld);
World* GetWorld(); lunarium::game::World* GetWorld();
bool DoFrame(); bool DoFrame();
private: private:
World* mpWorld; lunarium::game::World* mpWorld;
}; };
} }
} }

@ -0,0 +1,91 @@
/******************************************************************************
* File - content_manager.cpp
* Author - Joey Pollack
* Date - 2022/02/22 (y/m/d)
* Mod Date - 2022/02/22 (y/m/d)
* Description - Keeps track of all resource files in the project.
* Reads/Writes meta-data to the contents_meta.xml file.
* Also manages the physical location of each asset file.
******************************************************************************/
#include "content_manager.h"
#include "../project.h"
#include <pugixml.hpp>
namespace lunarium { namespace editor
{
ContentManager* ContentManager::mpInstance = nullptr;
ContentManager::ContentManager()
: mpProject(nullptr)
{
}
ContentManager& ContentManager::GetInstance()
{
if (!mpInstance)
{
mpInstance = new ContentManager();
}
return *mpInstance;
}
void ContentManager::FreeInstance()
{
if (mpInstance)
{
delete mpInstance;
mpInstance = nullptr;
}
}
OpRes ContentManager::Load(Project* project)
{
mpProject = project;
std::filesystem::path root = mpProject->GetRootDirectory();
mContentFile = root / "contents/content_meta.xml";
if (!std::filesystem::exists(mContentFile))
{
pugi::xml_document doc;
pugi::xml_node proj_node = doc.append_child("Contents");
if (!doc.save_file(mContentFile.string().c_str()))
{
return OpRes::Fail("ContentManager could not save file: %s", mContentFile.string().c_str());
}
return OpRes::OK();
}
return OpRes::Fail("ContentManager::Load not implemented");
}
OpRes ContentManager::Save()
{
return OpRes::Fail("ContentManager::Save not implemented");
}
void ContentManager::Unload()
{
mpProject = nullptr;
mAssets.clear();
mContentFile = "";
}
OpRes ContentManager::ImportFile(std::filesystem::path file, AssetType type)
{
return OpRes::Fail("ContentManager::ImportFile not implemented");
}
void ContentManager::MoveAsset(EditorAsset* asset, std::filesystem::path to)
{
}
void ContentManager::RenameAsset(EditorAsset* asset, std::string name)
{
}
}}

@ -0,0 +1,55 @@
/******************************************************************************
* File - content_manager.h
* Author - Joey Pollack
* Date - 2022/02/22 (y/m/d)
* Mod Date - 2022/02/22 (y/m/d)
* Description - Keeps track of all resource files in the project.
* Reads/Writes meta-data to the contents_meta.xml file.
* Also manages the physical location of each asset file.
******************************************************************************/
#ifndef CONTENT_MANAGER_H_
#define CONTENT_MANAGER_H_
#include "definitions.h"
#include <filesystem>
#include <string>
#include <utils/opRes.h>
#include <map>
namespace lunarium { namespace editor
{
class Project;
class EditorAsset;
class ContentManager
{
public:
static ContentManager& GetInstance();
static void FreeInstance();
[[nodiscard]] OpRes Load(Project* project);
[[nodiscard]] OpRes Save();
void Unload();
[[nodiscard]] OpRes ImportFile(std::filesystem::path file, AssetType type);
void MoveAsset(EditorAsset* asset, std::filesystem::path to);
void RenameAsset(EditorAsset* asset, std::string name);
private:
static ContentManager* mpInstance;
Project* mpProject;
std::filesystem::path mContentFile;
std::map<uint64_t, EditorAsset*> mAssets;
private:
ContentManager();
ContentManager(ContentManager&) = delete;
ContentManager& operator=(const ContentManager&) = delete;
};
}}
#endif // CONTENT_MANAGER_H_

@ -0,0 +1,22 @@
/******************************************************************************
* File - definitions.h
* Author - Joey Pollack
* Date - 2022/02/24 (y/m/d)
* Mod Date - 2022/02/24 (y/m/d)
* Description - file for common defintions for the editor content system
******************************************************************************/
#ifndef EDITOR_ASSETS_DEFINITIONS_H_
#define EDITOR_ASSETS_DEFINITIONS_H_
namespace lunarium { namespace editor
{
enum AssetType
{
EATYPE_IMAGE,
EATYPE_TILE_SET,
EATYPE_TILE_MAP,
};
}}
#endif // EDITOR_ASSETS_DEFINITIONS_H_

@ -0,0 +1,35 @@
/******************************************************************************
* File - editor_asset.h
* Author - Joey Pollack
* Date - 2022/02/22 (y/m/d)
* Mod Date - 2022/02/22 (y/m/d)
* Description - Editor assets base class
******************************************************************************/
#include "editor_asset.h"
namespace lunarium { namespace editor {
EditorAsset::EditorAsset(AssetType type)
: mType(type)
{
}
AssetType EditorAsset::GetType()
{
return mType;
}
uint64_t EditorAsset::GetID()
{
return mID;
}
std::filesystem::path EditorAsset::GetFileLocation()
{
return mLocation;
}
}}

@ -0,0 +1,40 @@
/******************************************************************************
* File - editor_asset.h
* Author - Joey Pollack
* Date - 2022/02/22 (y/m/d)
* Mod Date - 2022/02/22 (y/m/d)
* Description - Editor assets base class
******************************************************************************/
#ifndef EDITOR_ASSETS_H_
#define EDITOR_ASSETS_H_
#include "definitions.h"
#include "content_manager.h"
#include <filesystem>
#include <string>
namespace lunarium { namespace editor
{
class EditorAsset
{
public:
EditorAsset(AssetType type);
AssetType GetType();
uint64_t GetID();
std::filesystem::path GetFileLocation();
private:
friend class ContentManager;
AssetType mType;
uint64_t mID;
std::filesystem::path mLocation;
protected:
};
}}
#endif // EDITOR_ASSETS_H_

@ -15,16 +15,11 @@
namespace lunarium { namespace editor namespace lunarium { namespace editor
{ {
TileSet::TileSet() TileSet::TileSet()
: mSetImage(nullptr), mTileSize({ 0, 0}) : EditorAsset(AssetType::EATYPE_TILE_SET), mSetImage(nullptr), mTileSize({ 0, 0})
{ {
} }
void TileSet::SetFileLocation(std::filesystem::path path)
{
mFileLocation = path;
}
void TileSet::SetImage(Image* image) void TileSet::SetImage(Image* image)
{ {
mSetImage = image; mSetImage = image;
@ -37,11 +32,6 @@ namespace lunarium { namespace editor
mNumTiles.Height = mSetImage->GetHeight() / mTileSize.Height; mNumTiles.Height = mSetImage->GetHeight() / mTileSize.Height;
} }
std::filesystem::path TileSet::GetFileLocation()
{
return mFileLocation;
}
Image* TileSet::GetImage() Image* TileSet::GetImage()
{ {
return mSetImage; return mSetImage;

@ -9,6 +9,7 @@
#ifndef TILE_SET_H_ #ifndef TILE_SET_H_
#define TILE_SET_H_ #define TILE_SET_H_
#include "editor_asset.h"
#include <core/types.h> #include <core/types.h>
#include <filesystem> #include <filesystem>
@ -16,16 +17,14 @@ namespace lunarium { class Image; class IGraphics; }
namespace lunarium { namespace editor namespace lunarium { namespace editor
{ {
class TileSet class TileSet : public EditorAsset
{ {
public: public:
TileSet(); TileSet();
void SetFileLocation(std::filesystem::path path);
void SetImage(Image* image); void SetImage(Image* image);
void SetTileSize(Sizei size); void SetTileSize(Sizei size);
std::filesystem::path GetFileLocation();
Image* GetImage(); Image* GetImage();
Sizei GetTileSize(); Sizei GetTileSize();
Rectangle GetTileRect(Vec2i index); Rectangle GetTileRect(Vec2i index);
@ -33,7 +32,6 @@ namespace lunarium { namespace editor
void Render(lunarium::IGraphics* g); void Render(lunarium::IGraphics* g);
private: private:
std::filesystem::path mFileLocation;
Image* mSetImage; Image* mSetImage;
Sizei mTileSize; // in pixels, must be a square power of 2 Sizei mTileSize; // in pixels, must be a square power of 2
Sizei mNumTiles; Sizei mNumTiles;

@ -7,10 +7,11 @@
******************************************************************************/ ******************************************************************************/
#include "project.h" #include "project.h"
#include <editor/editor.h>
#include "contents/content_manager.h"
#include <pugixml.hpp> #include <pugixml.hpp>
namespace lunarium namespace lunarium { namespace editor
{ {
Project::Project() Project::Project()
: mIsLoaded(false) : mIsLoaded(false)
@ -49,6 +50,12 @@ namespace lunarium
std::filesystem::create_directory(mLocation / std::filesystem::path("contents")); std::filesystem::create_directory(mLocation / std::filesystem::path("contents"));
std::filesystem::create_directory(mLocation / std::filesystem::path("contents/assets")); std::filesystem::create_directory(mLocation / std::filesystem::path("contents/assets"));
mpContentManager = &ContentManager::GetInstance();
if (Failed(mpContentManager->Load(this).LogIfFailed(Editor::LogCat)))
{
return OpRes::Fail("Could not load project in content manager");
}
mIsLoaded = true; mIsLoaded = true;
return OpRes::OK(); return OpRes::OK();
} }
@ -94,4 +101,4 @@ namespace lunarium
{ {
return mLocation; return mLocation;
} }
} }}

@ -15,19 +15,21 @@
#include <vector> #include <vector>
#include <filesystem> #include <filesystem>
namespace lunarium namespace lunarium { namespace editor
{ {
class Scene; class ContentManager;
class World;
class Project class Project
{ {
public: public:
Project(); Project();
/// location should NOT include the project file /// location should NOT include the project file
OpRes GenerateProject(std::string name, std::filesystem::path location); [[nodiscard]] OpRes GenerateProject(std::string name, std::filesystem::path location);
/// location should be the full path including the project file /// location should be the full path including the project file
OpRes LoadProject(std::filesystem::path location); [[nodiscard]] OpRes LoadProject(std::filesystem::path location);
void UnloadCurrentProject(); void UnloadCurrentProject();
void SaveProject(); void SaveProject();
@ -40,8 +42,12 @@ namespace lunarium
std::string mName; std::string mName;
std::filesystem::path mLocation; std::filesystem::path mLocation;
std::vector<Scene*> mScenes; ContentManager* mpContentManager;
std::vector<World*> mWorlds;
private:
void LoadContent();
}; };
} }}
#endif // PROJECT_H_ #endif // PROJECT_H_

@ -14,8 +14,8 @@
#include <editor/editor.h> #include <editor/editor.h>
#include <gui/panel.h> #include <gui/panel.h>
#include <gui/dearimgui/imgui.h> #include <gui/dearimgui/imgui.h>
#include "tile_set.h" #include <editor/project/contents/tile_set.h>
#include "tile_map.h" #include <editor/project/contents/tile_map.h>
// Panels // Panels
#include "panels/map_canvas.h" #include "panels/map_canvas.h"
@ -150,6 +150,11 @@ namespace lunarium { namespace editor
return mMapLoaded; return mMapLoaded;
} }
const std::map<int, TileSet*>* MapEditor::GetTileSets() const
{
return &mTileSets;
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// HELPERS // HELPERS
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -229,7 +234,7 @@ namespace lunarium { namespace editor
Core::Graphics().RegisterImage(*i); Core::Graphics().RegisterImage(*i);
TileSet* ts = new TileSet(); TileSet* ts = new TileSet();
ts->SetFileLocation(*path); // ts->SetFileLocation(*path);
ts->SetImage(i); ts->SetImage(i);
ts->SetTileSize({16, 16}); // NOTE: Hardcoding the tile size for testing ts->SetTileSize({16, 16}); // NOTE: Hardcoding the tile size for testing

@ -46,6 +46,8 @@ namespace editor
void SaveMap(); void SaveMap();
bool IsMapLoaded() const; bool IsMapLoaded() const;
const std::map<int, TileSet*>* GetTileSets() const;
private: private:
bool mIsOpen; bool mIsOpen;

@ -10,7 +10,7 @@
#define MAP_CANVAS_H_ #define MAP_CANVAS_H_
#include <gui/panel.h> #include <gui/panel.h>
#include "../tile_map.h" #include <editor/project/contents/tile_map.h>
#include <core/types.h> #include <core/types.h>
#include <string> #include <string>

@ -8,7 +8,7 @@
#include "tile_set_view.h" #include "tile_set_view.h"
#include "../map_editor.h" #include "../map_editor.h"
#include "../tile_set.h" #include <editor/project/contents/tile_set.h>
#include <assets/types/image.h> #include <assets/types/image.h>
#include <editor/editor.h> #include <editor/editor.h>
#include <core/core.h> #include <core/core.h>
@ -21,7 +21,7 @@ namespace lunarium { namespace editor
{ {
TileSetView::TileSetView(MapEditor* editor) TileSetView::TileSetView(MapEditor* editor)
: Panel(gui::PanelType::PT_TILE_SET_VIEW, "Tile Set View", gui::PanelDockZone::DDZ_RIGHT, true), : Panel(gui::PanelType::PT_TILE_SET_VIEW, "Tile Set View", gui::PanelDockZone::DDZ_RIGHT, true),
mpEditor(editor), mpTileSet(nullptr), mpViewImage(nullptr), mFrameBuffer(-1), mpEditor(editor), mpSelectedTileSet(nullptr), mpViewImage(nullptr), mFrameBuffer(-1),
mViewOffset({0, 0}), mViewZoom(1.0f), mMouseDown(false) mViewOffset({0, 0}), mViewZoom(1.0f), mMouseDown(false)
{ {
@ -47,7 +47,7 @@ namespace lunarium { namespace editor
// Check that it's within the window // Check that it's within the window
bool is_in_window = x >= 0.0f && x < mWorkAreaSize.X && y >= 0.0f && y < mWorkAreaSize.Y; bool is_in_window = x >= 0.0f && x < mWorkAreaSize.X && y >= 0.0f && y < mWorkAreaSize.Y;
if (is_in_window && mpTileSet) if (is_in_window && mpSelectedTileSet)
{ {
// Adjust for scrolling // Adjust for scrolling
x += mScrollOffset.X; x += mScrollOffset.X;
@ -56,8 +56,8 @@ namespace lunarium { namespace editor
//Logger::Log(Editor::LogCat, LogLevel::INFO_VERBOSE, "Mouse Pos scrolled (%f, %f)", x, y); //Logger::Log(Editor::LogCat, LogLevel::INFO_VERBOSE, "Mouse Pos scrolled (%f, %f)", x, y);
// Find selected tile // Find selected tile
mSelectedTile.X = x / mpTileSet->GetTileSize().Width; mSelectedTile.X = x / mpSelectedTileSet->GetTileSize().Width;
mSelectedTile.Y = y / mpTileSet->GetTileSize().Height; mSelectedTile.Y = y / mpSelectedTileSet->GetTileSize().Height;
//Logger::Log(Editor::LogCat, LogLevel::INFO_VERBOSE, "Updating Tile Selection: tile (%d, %d)", mSelectedTile.X, mSelectedTile.Y); //Logger::Log(Editor::LogCat, LogLevel::INFO_VERBOSE, "Updating Tile Selection: tile (%d, %d)", mSelectedTile.X, mSelectedTile.Y);
@ -73,11 +73,11 @@ namespace lunarium { namespace editor
if (mInvalidate) if (mInvalidate)
{ {
if (mpTileSet) if (mpSelectedTileSet)
{ {
if (mFrameBuffer == -1) if (mFrameBuffer == -1)
{ {
mFrameBuffer = Core::Graphics().CreateRenderTexture(mpTileSet->GetImage()->GetWidth(), mpTileSet->GetImage()->GetHeight(), 4); mFrameBuffer = Core::Graphics().CreateRenderTexture(mpSelectedTileSet->GetImage()->GetWidth(), mpSelectedTileSet->GetImage()->GetHeight(), 4);
} }
//Logger::Log(Editor::LogCat, LogLevel::INFO_VERBOSE, "Invalidating tile set window"); //Logger::Log(Editor::LogCat, LogLevel::INFO_VERBOSE, "Invalidating tile set window");
@ -86,12 +86,12 @@ namespace lunarium { namespace editor
Core::Graphics().SetClearColor(Color::Transparent()); Core::Graphics().SetClearColor(Color::Transparent());
Core::GetInstance().BeginRenderToTexture(mFrameBuffer).LogIfFailed(Editor::LogCat); Core::GetInstance().BeginRenderToTexture(mFrameBuffer).LogIfFailed(Editor::LogCat);
mpTileSet->Render(&Core::Graphics()); mpSelectedTileSet->Render(&Core::Graphics());
// Draw selected tile highlight // Draw selected tile highlight
if (mSelectedTile.X >= 0 && mSelectedTile.Y >= 0) if (mSelectedTile.X >= 0 && mSelectedTile.Y >= 0)
{ {
Rectangle selection = mpTileSet->GetTileRect(mSelectedTile); Rectangle selection = mpSelectedTileSet->GetTileRect(mSelectedTile);
Core::Graphics().DrawBox(selection, Color::Red(), 1.5f); Core::Graphics().DrawBox(selection, Color::Red(), 1.5f);
} }
@ -126,12 +126,31 @@ namespace lunarium { namespace editor
float child_height = ImGui::GetFrameHeight() * 2; float child_height = ImGui::GetFrameHeight() * 2;
ImGui::BeginChild(ImGui::GetID(GetName()), ImVec2(ImGui::GetWindowSize().x, child_height), true); ImGui::BeginChild(ImGui::GetID(GetName()), ImVec2(ImGui::GetWindowSize().x, child_height), true);
ImGui::TextUnformatted("THIS IS SOME PLACEHOLDER TEXT -- ADD TOOLS HERE FOR SELECTING TILE SETS"); // ImGui::TextUnformatted("THIS IS SOME PLACEHOLDER TEXT -- ADD TOOLS HERE FOR SELECTING TILE SETS");
ImGui::EndChild(); std::string name = "";
if (mpSelectedTileSet)
{
name = mpSelectedTileSet->GetFileLocation().filename().string();
}
if (ImGui::BeginCombo("Tile Sets", name.c_str()))
{
auto tile_sets = mpEditor->GetTileSets();
for (auto iter = tile_sets->begin(); iter != tile_sets->end(); iter++)
{
bool selected = false;
if (ImGui::Selectable(iter->second->GetFileLocation().filename().string().c_str(), &selected))
{
ImGui::SetItemDefaultFocus();
mpSelectedTileSet = iter->second;
Invalidate();
}
}
ImGui::EndCombo();
}
ImVec2 test = ImGui::GetWindowSize(); ImGui::EndChild();
test.y -= child_height;
//ImGui::BeginChild(ImGui::GetID(GetName()), ImVec2(ImGui::GetWindowSize().x, test.y));
mWorkAreaPos = { ImGui::GetWindowPos().x, ImGui::GetWindowPos().y }; mWorkAreaPos = { ImGui::GetWindowPos().x, ImGui::GetWindowPos().y };
mWorkAreaSize = { ImGui::GetWindowSize().x, ImGui::GetWindowSize().y }; mWorkAreaSize = { ImGui::GetWindowSize().x, ImGui::GetWindowSize().y };
@ -151,20 +170,19 @@ namespace lunarium { namespace editor
ImVec2(mpViewImage->GetWidth(), mpViewImage->GetHeight()), ImVec2(0, 1), ImVec2(1, 0)); // the last 2 params are flipping the image on the y ImVec2(mpViewImage->GetWidth(), mpViewImage->GetHeight()), ImVec2(0, 1), ImVec2(1, 0)); // the last 2 params are flipping the image on the y
} }
//ImGui::EndChild();
ImGui::End(); ImGui::End();
return mIsOpen; return mIsOpen;
} }
void TileSetView::SetTileSet(TileSet* set) void TileSetView::SetTileSet(TileSet* set)
{ {
mpTileSet = set; mpSelectedTileSet = set;
Invalidate(true); Invalidate(true);
} }
TileSet* TileSetView::GetTileSet() TileSet* TileSetView::GetTileSet()
{ {
return mpTileSet; return mpSelectedTileSet;
} }

@ -36,7 +36,7 @@ namespace lunarium { namespace editor
private: private:
MapEditor* mpEditor; MapEditor* mpEditor;
TileSet* mpTileSet; TileSet* mpSelectedTileSet;
int mFrameBuffer; int mFrameBuffer;
bool mInvalidate; bool mInvalidate;
Image* mpViewImage; Image* mpViewImage;

@ -16,7 +16,7 @@
#include <graphics/graphics.h> #include <graphics/graphics.h>
#include <graphics/camera.h> #include <graphics/camera.h>
namespace lunarium namespace lunarium { namespace game
{ {
World::World(Camera* pCam, Sizei region_size, Sizei world_size) World::World(Camera* pCam, Sizei region_size, Sizei world_size)
: mpCamera(pCam), mRegionSize(region_size), mpWorldScript(nullptr), mRegions(region_size), mWorldSize(world_size) : mpCamera(pCam), mRegionSize(region_size), mpWorldScript(nullptr), mRegions(region_size), mWorldSize(world_size)
@ -108,4 +108,4 @@ namespace lunarium
return mpWorldScript; return mpWorldScript;
} }
} }}

@ -21,20 +21,24 @@
namespace lunarium namespace lunarium
{ {
class Graphics; class Graphics;
class Image;
class Script;
}
namespace lunarium { namespace game
{
class Camera; class Camera;
class GameObject; class GameObject;
class Script;
class Image;
class World class World
{ {
public: public:
struct Region struct Region
{ {
Script* mRegionScript; lunarium::Script* mRegionScript;
Vec2i mCoords; Vec2i mCoords;
std::vector<GameObject*> mObjects; std::vector<GameObject*> mObjects;
std::vector<Image*> mLayers; std::vector<lunarium::Image*> mLayers;
}; };
public: // INTERFACE public: // INTERFACE
@ -58,13 +62,13 @@ namespace lunarium
bool RemoveRegion(Vec2i at); bool RemoveRegion(Vec2i at);
void SetWorldScript(Script* pScript); void SetWorldScript(Script* pScript);
Script* GetWorldScript(); lunarium::Script* GetWorldScript();
private: private:
Camera* mpCamera; Camera* mpCamera;
std::vector<GameObject*> mWorldObjects; std::vector<GameObject*> mWorldObjects;
Script* mpWorldScript; lunarium::Script* mpWorldScript;
Sizei mRegionSize; // in pixels Sizei mRegionSize; // in pixels
Sizei mWorldSize; // num regions ex. 10x10 Sizei mWorldSize; // num regions ex. 10x10
Grid<Region*> mRegions; Grid<Region*> mRegions;
@ -72,6 +76,6 @@ namespace lunarium
}; };
} }}
#endif // WORLD_H_ #endif // WORLD_H_
Loading…
Cancel
Save