From 99bbe4be3aec2617d96bc71c20e03f30998989fa Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Mon, 1 Jul 2013 18:26:27 +1000 Subject: [PATCH] Removed the local editor files I'll be using Sketch to create the maps git clone https://github.com/Ratstail91/Sketch.git --- editor/base_scene.cpp | 139 ---------------------------------- editor/base_scene.hpp | 74 ------------------ editor/editor_application.cpp | 118 ----------------------------- editor/editor_application.hpp | 50 ------------ editor/main.cpp | 47 ------------ editor/makefile | 39 ---------- editor/map_editor.cpp | 82 -------------------- editor/map_editor.hpp | 48 ------------ editor/scene_list.hpp | 35 --------- makefile | 2 - 10 files changed, 634 deletions(-) delete mode 100644 editor/base_scene.cpp delete mode 100644 editor/base_scene.hpp delete mode 100644 editor/editor_application.cpp delete mode 100644 editor/editor_application.hpp delete mode 100644 editor/main.cpp delete mode 100644 editor/makefile delete mode 100644 editor/map_editor.cpp delete mode 100644 editor/map_editor.hpp delete mode 100644 editor/scene_list.hpp diff --git a/editor/base_scene.cpp b/editor/base_scene.cpp deleted file mode 100644 index ec1aabe..0000000 --- a/editor/base_scene.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013 - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. -*/ -#include "base_scene.hpp" - -#include - -//------------------------- -//Static declarations -//------------------------- - -SDL_Surface* BaseScene::screen = nullptr; - -//------------------------- -//Public access members -//------------------------- - -BaseScene::BaseScene() { - nextScene = SceneList::CONTINUE; -} - -BaseScene::~BaseScene() { - // -} - -//------------------------- -//Program control -//------------------------- - -SDL_Surface* BaseScene::SetScreen(int w, int h, int bpp, Uint32 flags) { - if (!bpp) { - bpp = SDL_GetVideoInfo()->vfmt->BitsPerPixel; - } - - screen = SDL_SetVideoMode(w, h, bpp, flags); - - if (!screen) { - throw(std::runtime_error("Failed to create the screen surface")); - } - - return screen; -} - -SDL_Surface* BaseScene::GetScreen() { - return screen; -} - -SceneList BaseScene::SetNextScene(SceneList sceneIndex) { - return nextScene = sceneIndex; -} - -SceneList BaseScene::GetNextScene() const { - return nextScene; -} - -//------------------------- -//Frame loop -//------------------------- - -void BaseScene::RunFrame(double delta) { - FrameStart(); - HandleEvents(); - Update(delta); - FrameEnd(); -} - -void BaseScene::RenderFrame() { - SDL_FillRect(screen, 0, 0); - Render(screen); - SDL_Flip(screen); -} - -//------------------------- -//Event handlers -//------------------------- - -void BaseScene::HandleEvents() { - SDL_Event event; - - while(SDL_PollEvent(&event)) { - switch(event.type) { - case SDL_QUIT: - QuitEvent(); - break; - - case SDL_VIDEORESIZE: - SetScreen(event.resize.w, event.resize.h, 0, screen->flags); - break; - - case SDL_MOUSEMOTION: - MouseMotion(event.motion); - break; - - case SDL_MOUSEBUTTONDOWN: - MouseButtonDown(event.button); - break; - - case SDL_MOUSEBUTTONUP: - MouseButtonUp(event.button); - break; - - case SDL_KEYDOWN: - KeyDown(event.key); - break; - - case SDL_KEYUP: - KeyUp(event.key); - break; - -#ifdef USE_EVENT_JOYSTICK - //TODO: joystick/gamepad support -#endif - -#ifdef USE_EVENT_UNKNOWN - default: - UnknownEvent(event); - break; -#endif - }//switch - }//while -} diff --git a/editor/base_scene.hpp b/editor/base_scene.hpp deleted file mode 100644 index cbb26ca..0000000 --- a/editor/base_scene.hpp +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013 - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. -*/ -#ifndef BASESCENE_HPP_ -#define BASESCENE_HPP_ - -#include "scene_list.hpp" - -#include "SDL/SDL.h" - -class BaseScene { -public: - /* Public access members */ - BaseScene(); - virtual ~BaseScene(); - - /* Program control */ - static SDL_Surface* SetScreen(int w, int h, int bpp = 0, Uint32 flags = SDL_HWSURFACE|SDL_DOUBLEBUF); - static SDL_Surface* GetScreen(); - - SceneList SetNextScene(SceneList sceneIndex); - SceneList GetNextScene() const; - - /* Frame loop */ - virtual void RunFrame(double delta); - virtual void RenderFrame(); - -protected: - virtual void FrameStart() {} - virtual void HandleEvents(); - virtual void Update(double delta) {} - virtual void FrameEnd() {} - virtual void Render(SDL_Surface* const screen) {} - - /* Event handlers */ - virtual void QuitEvent() { SetNextScene(SceneList::QUIT); } - virtual void MouseMotion(SDL_MouseMotionEvent const&) {} - virtual void MouseButtonDown(SDL_MouseButtonEvent const&) {} - virtual void MouseButtonUp(SDL_MouseButtonEvent const&) {} - virtual void KeyDown(SDL_KeyboardEvent const&) {} - virtual void KeyUp(SDL_KeyboardEvent const&) {} - -#ifdef USE_EVENT_JOYSTICK - //TODO: joystick/gamepad support -#endif - -#ifdef USE_EVENT_UNKNOWN - virtual void UnknownEvent(SDL_Event const&) {} -#endif - -private: - static SDL_Surface* screen; - SceneList nextScene; -}; - -#endif diff --git a/editor/editor_application.cpp b/editor/editor_application.cpp deleted file mode 100644 index 93af83c..0000000 --- a/editor/editor_application.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013 - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. -*/ -#include "editor_application.hpp" - -#include -#include - -//------------------------- -//Scene headers -//------------------------- - -//Add the custom scene headers here -#include "map_editor.hpp" - -//------------------------- -//Public access members -//------------------------- - -EditorApplication::EditorApplication() { - // -} - -EditorApplication::~EditorApplication() { - UnloadScene(); -} - -void EditorApplication::Init() { - if (SDL_Init(SDL_INIT_VIDEO)) - throw(std::runtime_error("Failed to initialize SDL")); - - BaseScene::SetScreen(800, 600); -} - -void EditorApplication::Proc() { - LoadScene(SceneList::FIRST); - - //prepare the time system - typedef std::chrono::high_resolution_clock Clock; - - Clock::duration delta(16 * Clock::duration::period::den / std::milli::den); - Clock::time_point simTime = Clock::now(); - Clock::time_point realTime; - - //The main loop - while(activeScene->GetNextScene() != SceneList::QUIT) { - //switch scenes when necessary - if (activeScene->GetNextScene() != SceneList::CONTINUE) { - LoadScene(activeScene->GetNextScene()); - continue; - } - - //update the current time - realTime = Clock::now(); - - //simulate game time - while (simTime < realTime) { - //call each user defined function - activeScene->RunFrame(double(delta.count()) / Clock::duration::period::den); - simTime += delta; - } - - //draw the game to the screen - activeScene->RenderFrame(); - - //give the computer a break - SDL_Delay(10); - } - - UnloadScene(); -} - -void EditorApplication::Quit() { - UnloadScene(); - SDL_Quit(); -} - -//------------------------- -//Private access members -//------------------------- - -void EditorApplication::LoadScene(SceneList sceneIndex) { - UnloadScene(); - - switch(sceneIndex) { - //add scene creation calls here - case SceneList::FIRST: - case SceneList::MAPEDITOR: - activeScene = new MapEditor(); - break; - - default: - throw(std::logic_error("Failed to recognize the scene index")); - } -} - -void EditorApplication::UnloadScene() { - delete activeScene; - activeScene = nullptr; -} diff --git a/editor/editor_application.hpp b/editor/editor_application.hpp deleted file mode 100644 index f41d53f..0000000 --- a/editor/editor_application.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013 - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. -*/ -#ifndef EDITORAPPLICATION_HPP_ -#define EDITORAPPLICATION_HPP_ - -#include "scene_list.hpp" -#include "base_scene.hpp" - -#include "SDL/SDL.h" - -class EditorApplication { -public: - /* Public access members */ - EditorApplication(); - ~EditorApplication(); - - void Init(); - void Proc(); - void Quit(); - - EditorApplication(EditorApplication const&) = delete; - EditorApplication(EditorApplication const&&) = delete; -private: - /* Private access members */ - void LoadScene(SceneList sceneIndex); - void UnloadScene(); - - BaseScene* activeScene = nullptr; -}; - -#endif diff --git a/editor/main.cpp b/editor/main.cpp deleted file mode 100644 index 1517d1e..0000000 --- a/editor/main.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013 - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. -*/ -#include "editor_application.hpp" - -#include -#include - -using namespace std; - -int main(int, char**) { -#ifdef DEBUG - cout << "Beginning program" << endl; -#endif - try { - EditorApplication app; - app.Init(); - app.Proc(); - app.Quit(); - } - catch(exception& e) { - cerr << "Fatal error: " << e.what() << endl; - return 1; - } -#ifdef DEBUG - cout << "Clean exit" << endl; -#endif - return 0; -} diff --git a/editor/makefile b/editor/makefile deleted file mode 100644 index 6e173fb..0000000 --- a/editor/makefile +++ /dev/null @@ -1,39 +0,0 @@ -#config -LIBDIR=../libs -LOCALLIBS=$(LIBDIR)/out/libCodebase.a $(LIBDIR)/out/libCommon.a -LIB=$(LOCALLIBS) -lmingw32 -lSDLmain -lSDL -INCLUDES=$(LIBDIR)/Codebase $(LIBDIR)/common -CXXFLAGS+=-std=c++11 -DDEBUG $(addprefix -I,$(INCLUDES)) - -#source -SRC=$(wildcard *.cpp) - -#objects -OBJDIR=obj -OBJ=$(addprefix $(OBJDIR)/,$(SRC:.cpp=.o)) - -#output -OUTDIR=../out -OUT=$(addprefix $(OUTDIR)/,editor) - -#targets -all: $(OBJ) $(OUT) - $(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIB) - -$(OBJ): | $(OBJDIR) - -$(OUT): | $(OUTDIR) - -$(OBJDIR): - mkdir $(OBJDIR) - -$(OUTDIR): - mkdir $(OUTDIR) - -$(OBJDIR)/%.o: %.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -clean: - $(RM) *.o *.a *.exe - -rebuild: clean all diff --git a/editor/map_editor.cpp b/editor/map_editor.cpp deleted file mode 100644 index 35307e8..0000000 --- a/editor/map_editor.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013 - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. -*/ -#include "map_editor.hpp" - -//------------------------- -//Public access members -//------------------------- - -MapEditor::MapEditor() { - // -} - -MapEditor::~MapEditor() { - // -} - -//------------------------- -//Frame loop -//------------------------- - -void MapEditor::FrameStart() { - // -} - -void MapEditor::Update(double delta) { - // -} - -void MapEditor::FrameEnd() { - // -} - -void MapEditor::Render(SDL_Surface* const screen) { - // -} - -//------------------------- -//Event handlers -//------------------------- - -void MapEditor::MouseMotion(SDL_MouseMotionEvent const& motion) { - // -} - -void MapEditor::MouseButtonDown(SDL_MouseButtonEvent const& button) { - // -} - -void MapEditor::MouseButtonUp(SDL_MouseButtonEvent const& button) { - // -} - -void MapEditor::KeyDown(SDL_KeyboardEvent const& key) { - switch(key.keysym.sym) { - case SDLK_ESCAPE: - QuitEvent(); - break; - } -} - -void MapEditor::KeyUp(SDL_KeyboardEvent const& key) { - // -} diff --git a/editor/map_editor.hpp b/editor/map_editor.hpp deleted file mode 100644 index d04390f..0000000 --- a/editor/map_editor.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013 - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. -*/ -#ifndef MAPEDITOR_HPP_ -#define MAPEDITOR_HPP_ - -#include "base_scene.hpp" - -class MapEditor : public BaseScene { -public: - //Public access members - MapEditor(); - ~MapEditor(); - -protected: - //Frame loop - void FrameStart(); - void Update(double delta); - void FrameEnd(); - void Render(SDL_Surface* const); - - //Event handlers - void MouseMotion(SDL_MouseMotionEvent const&); - void MouseButtonDown(SDL_MouseButtonEvent const&); - void MouseButtonUp(SDL_MouseButtonEvent const&); - void KeyDown(SDL_KeyboardEvent const&); - void KeyUp(SDL_KeyboardEvent const&); -}; - -#endif diff --git a/editor/scene_list.hpp b/editor/scene_list.hpp deleted file mode 100644 index cd3a8f0..0000000 --- a/editor/scene_list.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013 - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. -*/ -#ifndef SCENELIST_HPP_ -#define SCENELIST_HPP_ - -enum class SceneList { - //these are reserved - QUIT, - CONTINUE, - FIRST, - - //custom indexes - MAPEDITOR, -}; - -#endif diff --git a/makefile b/makefile index 4e39923..cb89da0 100644 --- a/makefile +++ b/makefile @@ -4,8 +4,6 @@ all: $(OUTDIR) $(MAKE) -C libs $(MAKE) -C server $(MAKE) -C client - $(MAKE) -C editor - $(MAKE) -C test $(OUTDIR): mkdir $(OUTDIR)