Browse Source

Divide source and include files into diretories for better oversight.

Beoran 7 years ago
parent
commit
bc3ab2a200

+ 2 - 0
CMakeLists.txt

@@ -49,6 +49,8 @@ include_directories(${ALLEGRO_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${JPEG_INCLUDE_DIR
 set(ERUTA_LIBS ${LIBS} ${OBJC_LIBRARIES} ${ALLEGRO_LIBRARIES} ${PNG_LIBRARY} ${JPEG_LIBRARY} ${MRUBY_LIBRARIES})
 
 include_directories("include")
+include_directories("include/zori")
+include_directories("include/tr")
 # add_subdirectory("src")
 include(ErutaFiles)
 set_source_files_properties(${ERUTA_SRC_FILES} PROPERTIES LANGUAGE C)

+ 9 - 8
cmake/ErutaFiles.cmake

@@ -68,15 +68,16 @@ set(ERUTA_SRC_FILES
   src/tarray.c
   src/tmatrix.c
   src/toruby.c
-  src/tr_audio.c
-  src/tr_path.c
-  src/tr_store.c
-  src/tr_graph.c
-  src/tr_sprite.c
-  src/tr_thing.c
+  src/tr/tr_audio.c
+  src/tr/tr_path.c
+  src/tr/tr_store.c
+  src/tr/tr_graph.c
+  src/tr/tr_sprite.c
+  src/tr/tr_thing.c
   src/ui.c
   src/utf8.c
   src/xresor.c
-  src/zori.c
-  src/zori_screen.c
+  src/zori/zori.c
+  src/zori/zori_screen.c
+  src/zori/zori_page.c
 )

+ 0 - 0
include/tr_audio.h → include/tr/tr_audio.h


+ 0 - 0
include/tr_graph.h → include/tr/tr_graph.h


+ 0 - 0
include/tr_macro.h → include/tr/tr_macro.h


+ 0 - 0
include/tr_path.h → include/tr/tr_path.h


+ 0 - 0
include/tr_sprite.h → include/tr/tr_sprite.h


+ 0 - 0
include/tr_store.h → include/tr/tr_store.h


+ 0 - 0
include/tr_thing.h → include/tr/tr_thing.h


+ 0 - 0
include/tr_thing.h.gch → include/tr/tr_thing.h.gch


+ 0 - 0
include/zori.h → include/zori/zori.h


+ 10 - 0
include/zori/zori_page.h

@@ -0,0 +1,10 @@
+#ifndef zori_page_H_INCLUDED
+#define zori_page_H_INCLUDED
+
+
+
+#endif
+
+
+
+

+ 0 - 0
include/zori_screen.h → include/zori/zori_screen.h


+ 37 - 12
src/state.c

@@ -20,6 +20,14 @@
 #include "callrb.h"
 #include "store.h"
 #include "zori.h"
+#include "zori_screen.h"
+
+
+/* Sub data struct for the particular GUI state */
+struct GuiState {
+  zori_id screen;
+  zori_id console;
+};
 
 /* The data struct contains all global state and other data of the application.
 */
@@ -76,7 +84,7 @@ struct State_ {
   
   /* Logical and physical game objects. This one is always active, regardless of the tile map. */
   Area                * area;
-  // View camera for the area, tile map and particle engine. 
+  /* View camera for the area, tile map and particle engine. */
   Camera              * camera;
   
   /* Mode is removed, this will be handled on the scripting side. */
@@ -90,6 +98,11 @@ struct State_ {
    Implemented in C so it's usable even if there are script bugs.   
   */
   struct zori_console * console;   
+  
+  /* GUI data. */
+  struct GuiState ui;
+  
+  
   /* The current actor, controlled by the player. */
   Thing               * actor;
 
@@ -486,6 +499,26 @@ int state_initjoystick(State * self) {
   return num;
 }
 
+/* Initialize the GUI for the Eruta engine. */
+State * state_init_gui(State * self, BOOL fullscreen) {
+  /* Set up Zori GUI. */
+  struct zori_style style;
+  memset(&style, 0, sizeof(style));
+  style.text.font  = self->font;
+  style.text.color = color_rgb(255,255,255);
+  style.back.color = color_rgba(64,0,0, 191);
+  if ( !ZORI_ID_OK_P(zori_start(&style)) ) {
+    return state_errmsg_(self, "Out of memory when allocating GUI.");
+  }
+  
+  self->ui.screen = zori_new_screen(-1, self->display);
+  
+  if(!ZORI_ID_OK_P(self->ui.screen)) {
+    return state_errmsg_(self, "Could not init GUI screen.\n");
+  }
+  
+  return self;
+}
 
 
 /** Initializes the state. It opens the screen, keyboards,
@@ -623,17 +656,9 @@ State * state_init(State * self, BOOL fullscreen) {
   if(!self->camera) {
       return state_errmsg_(self, "Out of memory when allocating camera.");
   }
-  /* Set up Zori GUI. */
-  {
-    struct zori_style style;
-    memset(&style, 0, sizeof(style));
-    style.text.font  = self->font;
-    style.text.color = color_rgb(255,255,255);
-    style.back.color = color_rgba(64,0,0, 191);
-    if ( !ZORI_ID_OK_P(zori_start(&style)) ) {
-        return state_errmsg_(self, "Out of memory when allocating GUI.");
-    }
-  }
+  
+  /* Set up GUI. */
+  if (!state_init_gui(self, fullscreen)) return NULL;
   
   /* Set up console. */
   {

+ 0 - 0
src/tr_audio.c → src/tr/tr_audio.c


+ 0 - 0
src/tr_graph.c → src/tr/tr_graph.c


+ 0 - 0
src/tr_path.c → src/tr/tr_path.c


+ 0 - 0
src/tr_sprite.c → src/tr/tr_sprite.c


+ 0 - 0
src/tr_store.c → src/tr/tr_store.c


+ 0 - 0
src/tr_thing.c → src/tr/tr_thing.c


+ 0 - 0
src/zori.c → src/zori/zori.c


+ 9 - 0
src/zori/zori_page.c

@@ -0,0 +1,9 @@
+
+#include "zori_page.h"
+
+
+
+
+
+
+

+ 0 - 0
src/zori_screen.c → src/zori/zori_screen.c


+ 20 - 0
test/test_zori_page.c

@@ -0,0 +1,20 @@
+/**
+* This is a test for zori_page in $package$
+*/
+#include "si_test.h"
+#include "zori_page.h"
+
+
+TEST_FUNC(zori_page) {
+  TEST_DONE();
+}
+
+
+int main(void) {
+  TEST_INIT();
+  TEST_RUN(zori_page);
+  TEST_REPORT();
+}
+
+
+