Browse Source

Fixed include and namespace mess

Florian DORMONT 10 years ago
parent
commit
9a8c41daa8

+ 2 - 2
src/drivers/Graphics.cpp

@@ -1,6 +1,6 @@
 #include <os.h>
-#include <Graphics.h>
-#include <misc.h>
+#include "Graphics.h"
+#include "../utility/misc.h"
 
 #define GRAPHICS WalrusRPG::Graphics
 

+ 1 - 1
src/drivers/Graphics.h

@@ -1,7 +1,7 @@
 #ifndef INCLUDE_GRAPHICS_H
 #define INCLUDE_GRAPHICS_H
 
-#include "Rect.h"
+#include "../utility/Rect.h"
 
 namespace WalrusRPG
 {

+ 1 - 1
src/drivers/Timers.cpp

@@ -1,5 +1,5 @@
 #include <os.h>
-#include <Timers.h>
+#include "Timers.h"
 
 #define TIMER 0x900D0000
 volatile unsigned *timer_ctl = (unsigned *) (TIMER + 0x08);

+ 1 - 1
src/engine/State.h

@@ -1,7 +1,7 @@
 #ifndef INCLUDE_STATE_H
 #define INCLUDE_STATE_H
 
-#include "Camera.h"
+#include "../render/Camera.h"
 
 namespace WalrusRPG
 {

+ 12 - 8
src/engine/StateMachine.cpp

@@ -1,13 +1,17 @@
 #include "StateMachine.h"
-#include "Timers.h"
-#include "Graphics.h"
-#include "Text.h"
-#include "version.h"
+#include "../drivers/Timers.h"
+#include "../drivers/Graphics.h"
+#include "../render/Text.h"
+#include "../version/version.h"
 #include <os.h>
 
+using namespace WalrusRPG::Graphics;
+using namespace WalrusRPG::States;
+using namespace WalrusRPG::Timers;
+
 #define STATEMACHINE WalrusRPG::StateMachine
 
-STATEMACHINE::StateMachine(WalrusRPG::States::State *state)
+STATEMACHINE::StateMachine(State *state)
 {
     push(state);
 }
@@ -16,7 +20,7 @@ STATEMACHINE::~StateMachine()
 {
 }
 
-void STATEMACHINE::push(WalrusRPG::States::State *state)
+void STATEMACHINE::push(State *state)
 {
     stack.push_back(state);
 }
@@ -50,8 +54,8 @@ void STATEMACHINE::run()
             stack.back()->render(frame_time);
             last_frame = frame_stamp;
 
-            Graphics::Text::print_format(0, 0, "WalrusRPG test build %s", git_version);
-            Graphics::Text::print_format(0, 240 - 8, "%ufps, %uups", 32768 / frame_time,
+            Text::print_format(0, 0, "WalrusRPG test build %s", git_version);
+            Text::print_format(0, 240 - 8, "%ufps, %uups", 32768 / frame_time,
                                          32768 / update_time);
             Graphics::buffer_swap_render();
         }

+ 6 - 6
src/engine/main.cpp

@@ -1,10 +1,10 @@
 #include <os.h>
-#include "Timers.h"
-#include "Graphics.h"
-#include "Map.h"
-#include "misc.h"
-#include "Interrupts.h"
-#include "StateMap.h"
+#include "../drivers/Timers.h"
+#include "../drivers/Graphics.h"
+#include "../map/Map.h"
+#include "../utility/misc.h"
+#include "../drivers/Interrupts.h"
+#include "../map/StateMap.h"
 #include "StateMachine.h"
 
 using namespace WalrusRPG;

+ 5 - 5
src/map/Entity.cpp

@@ -1,10 +1,10 @@
 #include "Entity.h"
-#include "misc.h"
-#include "Rect.h"
-#include "Text.h"
+#include "../utility/misc.h"
+#include "../utility/Rect.h"
+#include "../render/Text.h"
 
 #define ENTITY WalrusRPG::Entity
-#define RECT WalrusRPG::Utils::Rect
+using namespace WalrusRPG::Utils;
 
 ENTITY::Entity(int x, int y, unsigned w, unsigned h, WalrusRPG::Renderer *tset,
                unsigned sprite_id)
@@ -24,7 +24,7 @@ void ENTITY::render(Camera &camera, unsigned dt) const
     if (camera.is_visible(coords))
     {
         tset->render(sprite_id,
-                     RECT(coords.x - camera.get_x(), coords.y - camera.get_y()));
+                     Rect(coords.x - camera.get_x(), coords.y - camera.get_y()));
         //(*tset).render_tile(sprite_id, coords.x - camera.get_x(), coords.y -
         // camera.get_y(), dt);
     }

+ 4 - 4
src/map/Entity.h

@@ -1,10 +1,10 @@
 #ifndef INCLUDE_ENTITY_H
 #define INCLUDE_ENTITY_H
 
-#include "Rect.h"
-#include "Camera.h"
-#include "Renderer.h"
-#include "TileRenderer.h"
+#include "../utility/Rect.h"
+#include "../render/Camera.h"
+#include "../render/Renderer.h"
+#include "../render/TileRenderer.h"
 
 namespace WalrusRPG
 {

+ 11 - 11
src/map/Map.cpp

@@ -1,14 +1,14 @@
 #include "Map.h"
-#include "Camera.h"
-#include "Graphics.h"
-#include "sprites.h"
-#include "Rect.h"
-#include "TileRenderer.h"
-#include "misc.h"
+#include "../render/Camera.h"
+#include "../drivers/Graphics.h"
+#include <sprites.h>
+#include "../utility/Rect.h"
+#include "../render/TileRenderer.h"
+#include "../utility/misc.h"
 
 #define MAP WalrusRPG::Map
-#define RECT WalrusRPG::Utils::Rect
-#define TILERENDERER WalrusRPG::TileRenderer
+using namespace WalrusRPG;
+using namespace WalrusRPG::Utils;
 
 MAP::Map(int width, int height, uint16_t *layer0, uint16_t *layer1) : anim()
 {
@@ -84,15 +84,15 @@ void MAP::render(WalrusRPG::Camera &camera, unsigned dt)
             unsigned tile_over = anim.get_animation_frame(this->layer0[index]);
             if (tile_over != 0)
                 renderer->render(tile_over,
-                                 RECT(offset_x + i * t_width, offset_y + j * t_height));
+                                 Rect(offset_x + i * t_width, offset_y + j * t_height));
 
             // layer1 : Over-layer
-            if (this->layer1 == NULL)
+            if (this->layer1 == nullptr)
                 continue;
             tile_over = anim.get_animation_frame(this->layer1[index]);
             if (tile_over != 0)
                 renderer->render(anim.get_animation_frame(tile_over),
-                                 RECT(offset_x + i * t_width, offset_y + j * t_height));
+                                 Rect(offset_x + i * t_width, offset_y + j * t_height));
         }
     }
 }

+ 4 - 4
src/map/Map.h

@@ -2,10 +2,10 @@
 #define INCLUDE_MAP_H
 
 #include <stdint.h>
-#include "Camera.h"
-#include "Entity.h"
-#include "TileRenderer.h"
-#include "Animator.h"
+#include "../render/Camera.h"
+#include "../map/Entity.h"
+#include "../render/TileRenderer.h"
+#include "../render/Animator.h"
 
 namespace WalrusRPG
 {

+ 9 - 8
src/map/StateMap.cpp

@@ -1,25 +1,26 @@
 #include "StateMap.h"
-#include "misc.h"
-#include "version.h"
-#include "Graphics.h"
-#include "Pixel.h"
-#include "Text.h"
+#include "../utility/misc.h"
+#include "../version/version.h"
+#include "../drivers/Graphics.h"
+#include "../render/Pixel.h"
+#include "../render/Text.h"
 
 #define STATEMAP WalrusRPG::States::StateMap
 
 using namespace WalrusRPG;
+using namespace WalrusRPG::Graphics;
 
 namespace
 {
     void print_debug_camera_data(const Camera &camera)
     {
-        Graphics::Text::print_format(0, 8, "CAM : X : %d Y: %d", camera.get_x(),
+        Text::print_format(0, 8, "CAM : X : %d Y: %d", camera.get_x(),
                                      camera.get_y());
     }
 
     void print_debug_map_data(const Map &map)
     {
-        Graphics::Text::print_format(0, 16, "MAP : W: %d, H:%d", map.get_width(),
+        Text::print_format(0, 16, "MAP : W: %d, H:%d", map.get_width(),
                                      map.get_height());
     }
 }
@@ -35,7 +36,7 @@ void STATEMAP::update(unsigned dt)
 
 void STATEMAP::render(unsigned dt)
 {
-    Graphics::Pixel pix(Graphics::Green);
+    Pixel pix(Graphics::Green);
     Graphics::buffer_fill(pix);
     map.render(camera, dt);
 

+ 1 - 1
src/map/StateMap.h

@@ -1,7 +1,7 @@
 #ifndef INCLUDE_STATEMAP_H
 #define INCLUDE_STATEMAP_H
 
-#include "State.h"
+#include "../engine/State.h"
 #include "Map.h"
 
 namespace WalrusRPG

+ 4 - 4
src/render/Animator.cpp

@@ -1,10 +1,10 @@
 #include "Animator.h"
-#include "Graphics.h"
-#include "Rect.h"
+#include "../drivers/Graphics.h"
+#include "../utility/Rect.h"
 
 #define ANIMATOR WalrusRPG::Animator
-#define FRAME WalrusRPG::Frame
-#define UTILS WalrusRPG::Utils
+
+using namespace WalrusRPG;
 
 namespace
 {

+ 1 - 1
src/render/Animator.h

@@ -3,7 +3,7 @@
 
 #include <TINYSTL/vector.h>
 #include <TINYSTL/unordered_map.h>
-#include "Rect.h"
+#include "../utility/Rect.h"
 
 namespace WalrusRPG
 {

+ 2 - 2
src/render/Camera.cpp

@@ -1,7 +1,7 @@
 #include <os.h>
 #include "Camera.h"
-#include "Entity.h"
-#include "misc.h"
+#include "../map/Entity.h"
+#include "../utility/misc.h"
 
 #define CAMERA WalrusRPG::Camera
 

+ 1 - 1
src/render/Camera.h

@@ -1,7 +1,7 @@
 #ifndef INCLUDE_CAMERA_H
 #define INCLUDE_CAMERA_H
 
-#include "Rect.h"
+#include "../utility/Rect.h"
 
 namespace WalrusRPG
 {

+ 1 - 1
src/render/Pixel.cpp

@@ -1,4 +1,4 @@
-#include <Pixel.h>
+#include "Pixel.h"
 
 #define PIXEL WalrusRPG::Graphics::Pixel
 

+ 1 - 1
src/render/Renderer.h

@@ -1,7 +1,7 @@
 #ifndef INCLUDE_RENDERER_H
 #define INCLUDE_RENDERER_H
 
-#include "Rect.h"
+#include "../utility/Rect.h"
 
 namespace WalrusRPG
 {

+ 6 - 6
src/render/SpriteRenderer.cpp

@@ -1,11 +1,11 @@
 #include "SpriteRenderer.h"
-#include "Graphics.h"
-#include "Rect.h"
+#include "../drivers/Graphics.h"
+#include "../utility/Rect.h"
 #include <TINYSTL/unordered_map.h>
 
 #define SPRITERENDERER WalrusRPG::SpriteRenderer
-#define GRAPHICS WalrusRPG::Graphics
-#define RECT WalrusRPG::Utils::Rect
+using namespace WalrusRPG;
+using namespace WalrusRPG::Utils;
 
 SPRITERENDERER::SpriteRenderer(unsigned short *_tilesheet) : tilesheet(_tilesheet)
 {
@@ -16,7 +16,7 @@ void SPRITERENDERER::add_sprite(unsigned id, WalrusRPG::Utils::Rect rect)
     sprites[id] = rect;
 }
 
-void SPRITERENDERER::render(const unsigned id, const RECT &rect)
+void SPRITERENDERER::render(const unsigned id, const Rect &rect)
 {
-    GRAPHICS::draw_sprite_sheet(tilesheet, rect.x, rect.y, sprites[id]);
+    Graphics::draw_sprite_sheet(tilesheet, rect.x, rect.y, sprites[id]);
 }

+ 2 - 2
src/render/SpriteRenderer.h

@@ -2,8 +2,8 @@
 #define INCLUDE_SPRITERENDERER_H
 
 #include <TINYSTL/unordered_map.h>
-#include "Rect.h"
-#include "Renderer.h"
+#include "../utility/Rect.h"
+#include "../render/Renderer.h"
 
 namespace WalrusRPG
 {

+ 6 - 6
src/render/Text.cpp

@@ -1,22 +1,22 @@
-#include "sprites.h"
-#include "Graphics.h"
+#include <sprites.h>
+#include "../drivers/Graphics.h"
 #include "Text.h"
 #include <cstdio>
 #include <cstdarg>
 #include <string>
 
 #define TEXT WalrusRPG::Graphics::Text
-#define GRAPHICS WalrusRPG::Graphics
-#define UTILS WalrusRPG::Utils
+using namespace WalrusRPG::Graphics;
+using namespace WalrusRPG::Utils;
 
 void TEXT::print_char(char c, unsigned x, unsigned y)
 {
-    draw_sprite_sheet(font, x, y, UTILS::Rect((c % 16) * 8, (c / 16) * 8, 8, 8));
+    draw_sprite_sheet(font, x, y, Rect((c % 16) * 8, (c / 16) * 8, 8, 8));
 }
 
 void TEXT::print_string(const char *str, unsigned x, unsigned y)
 {
-    UTILS::Rect rect;
+    Rect rect;
     rect.width = 8;
     rect.height = 8;
     for (unsigned index = 0; str[index]; index++)

+ 7 - 7
src/render/TileRenderer.cpp

@@ -1,10 +1,10 @@
 #include "TileRenderer.h"
-#include "Graphics.h"
-#include "Rect.h"
+#include "../drivers/Graphics.h"
+#include "../utility/Rect.h"
 
-#define GRAPHICS WalrusRPG::Graphics
 #define TILERENDERER WalrusRPG::TileRenderer
-#define RECT WalrusRPG::Utils::Rect
+using namespace WalrusRPG;
+using namespace WalrusRPG::Utils;
 
 TILERENDERER::TileRenderer(unsigned short *_tilesheet, unsigned tile_width,
                            unsigned tile_height)
@@ -12,12 +12,12 @@ TILERENDERER::TileRenderer(unsigned short *_tilesheet, unsigned tile_width,
 {
 }
 
-void TILERENDERER::render(const unsigned id, const RECT &rect)
+void TILERENDERER::render(const unsigned id, const Rect &rect)
 {
     unsigned num_tiles_x = tilesheet[0] / tile_width;
     // unsigned num_tiles_y = sheet_height / tile_height;
-    GRAPHICS::draw_sprite_sheet(tilesheet, rect.x, rect.y,
-                                RECT(tile_width * (id % num_tiles_x),
+    Graphics::draw_sprite_sheet(tilesheet, rect.x, rect.y,
+                                Rect(tile_width * (id % num_tiles_x),
                                      tile_height * (id / num_tiles_x), tile_width,
                                      tile_height));
 }

+ 1 - 1
src/render/TileRenderer.h

@@ -1,7 +1,7 @@
 #ifndef INCLUDE_TILERENDERER_H
 #define INCLUDE_TILERENDERER_H
 
-#include "Rect.h"
+#include "../utility/Rect.h"
 #include "Renderer.h"
 
 namespace WalrusRPG