From 01f2b5ada046719189fbc4ec2e3a20f17eee585f Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Tue, 18 Sep 2012 09:46:58 +0200 Subject: [PATCH] Remove the screenManager global, other assorted cleanup --- base/NativeApp.h | 11 +++++++++++ math/CMakeLists.txt | 1 + ui/screen.cpp | 4 +--- ui/screen.h | 3 --- util/CMakeLists.txt | 15 +++++++++++++++ util/bits/varint.cpp | 6 +++--- util/bits/varint.h | 6 +++--- util/hash/hash.cpp | 2 +- 8 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 util/CMakeLists.txt diff --git a/base/NativeApp.h b/base/NativeApp.h index c567b1d9a1..c2e187b549 100644 --- a/base/NativeApp.h +++ b/base/NativeApp.h @@ -69,6 +69,17 @@ void NativeMix(short *audio, int num_samples); void NativeShutdownGraphics(); void NativeShutdown(); +// Called on app.onCreate and app.onDestroy (?). Tells the app to save/restore +// light state. If app was fully rebooted between these calls, it's okay if some minor +// state is lost (position in level) but the level currently playihg, or the song +// currently being edited, or whatever, should be restored properly. In this case, +// firstTime will be set so that appropriate action can be taken (or not taken when +// it's not set). +// +// Note that NativeRestore is always called on bootup. +void NativeRestoreState(bool firstTime); // onCreate +void NativeSaveState(); // onDestroy + // Calls back into Java / SDL // These APIs must be implemented by every port (for example app-android.cpp, PCMain.cpp). // You are free to call these. diff --git a/math/CMakeLists.txt b/math/CMakeLists.txt index b05acac409..6bd2d91ab2 100644 --- a/math/CMakeLists.txt +++ b/math/CMakeLists.txt @@ -2,6 +2,7 @@ set(SRCS lin/matrix4x4.cpp lin/vec3.cpp lin/quat.cpp + lin/aabb.cpp ) set(SRCS ${SRCS}) diff --git a/ui/screen.cpp b/ui/screen.cpp index 548ae4fb58..4d9ebb9637 100644 --- a/ui/screen.cpp +++ b/ui/screen.cpp @@ -2,8 +2,6 @@ #include "input/input_state.h" #include "ui/screen.h" -ScreenManager screenManager; - Screen::Screen() { } Screen::~Screen() { } @@ -81,4 +79,4 @@ void ScreenManager::pop() { } else { ELOG("Can't push when no dialog is shown"); } -} \ No newline at end of file +} diff --git a/ui/screen.h b/ui/screen.h index 87d2b00b75..23472328fc 100644 --- a/ui/screen.h +++ b/ui/screen.h @@ -62,6 +62,3 @@ private: // Used for options, in-game menus and other things you expect to be able to back out from onto something. std::list dialog_; }; - -// Yeah, an old school non enforced singleton. Good enough (not?) -extern ScreenManager screenManager; diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt new file mode 100644 index 0000000000..3a05cb15bb --- /dev/null +++ b/util/CMakeLists.txt @@ -0,0 +1,15 @@ +set(SRCS + bits/bits.cpp + bits/varint.cpp + random/perlin.cpp + hash/hash.cpp +) + +set(SRCS ${SRCS}) + +add_library(util STATIC ${SRCS}) + +if(UNIX) + add_definitions(-fPIC) +endif(UNIX) + diff --git a/util/bits/varint.cpp b/util/bits/varint.cpp index 8cd94d052c..fc29c069d1 100644 --- a/util/bits/varint.cpp +++ b/util/bits/varint.cpp @@ -2,7 +2,7 @@ namespace varint { -void Encode32(uint32 value, char **dest) { +void Encode32(uint32_t value, char **dest) { // Simple varint char *p = *dest; while (value > 127) { @@ -13,8 +13,8 @@ void Encode32(uint32 value, char **dest) { *dest = p; } -uint32 Decode32(const char **ptr) { - uint32 value = 0; +uint32_t Decode32(const char **ptr) { + uint32_t value = 0; const char *p = *ptr; while (true) { uint8 b = *p++; diff --git a/util/bits/varint.h b/util/bits/varint.h index aa7d3e8788..e2fdd20583 100644 --- a/util/bits/varint.h +++ b/util/bits/varint.h @@ -1,12 +1,12 @@ #ifndef _UTIL_BITS_VARINT #define _UTIL_BITS_VARINT -#include "base/base.h" +#include "base/basictypes.h" namespace varint { -void Encode32(uint32 value, char **dest); -uint32 Decode32(const char **ptr); +void Encode32(uint32_t value, char **dest); +uint32_t Decode32(const char **ptr); } // namespace varint diff --git a/util/hash/hash.cpp b/util/hash/hash.cpp index 264450dabe..277509ac89 100644 --- a/util/hash/hash.cpp +++ b/util/hash/hash.cpp @@ -1,4 +1,4 @@ -#include "base/base.h" +#include "base/basictypes.h" #include "util/hash/hash.h" namespace hash {