From 4c623111321408d3023f455151b5f76cc445a86e Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sat, 27 Oct 2012 16:40:42 +0200 Subject: [PATCH] Screens need to know when the device is lost. Cleanup. --- Android.mk | 2 +- native.vcxproj | 2 -- native.vcxproj.filters | 6 ------ ui/list_screen.cpp | 6 ------ ui/list_screen.h | 10 ---------- ui/screen.cpp | 10 +++++++++- ui/screen.h | 8 +++++--- ui/virtual_input.h | 4 ++++ 8 files changed, 19 insertions(+), 29 deletions(-) delete mode 100644 ui/list_screen.cpp delete mode 100644 ui/list_screen.h diff --git a/Android.mk b/Android.mk index f59e4f9cc5..c1debdd761 100644 --- a/Android.mk +++ b/Android.mk @@ -51,7 +51,7 @@ LOCAL_SRC_FILES :=\ util/random/perlin.cpp -LOCAL_CFLAGS := -O2 +LOCAL_CFLAGS := -O2 -DGL_GLEXT_PROTOTYPES -fsigned-char LOCAL_CPPFLAGS := -fno-exceptions -fno-rtti -std=gnu++0x LOCAL_LDLIBS := -lz LOCAL_C_INCLUDES := $(LOCAL_PATH)/ext/libzip diff --git a/native.vcxproj b/native.vcxproj index 0ec36aea90..f83b166621 100644 --- a/native.vcxproj +++ b/native.vcxproj @@ -237,7 +237,6 @@ - @@ -317,7 +316,6 @@ - diff --git a/native.vcxproj.filters b/native.vcxproj.filters index e9e8ef028d..fff6d79d76 100644 --- a/native.vcxproj.filters +++ b/native.vcxproj.filters @@ -194,9 +194,6 @@ base - - ui - base @@ -373,9 +370,6 @@ ui - - ui - base diff --git a/ui/list_screen.cpp b/ui/list_screen.cpp deleted file mode 100644 index c3cedcd59b..0000000000 --- a/ui/list_screen.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "ui/list_screen.h" - -ListScreen::ListScreen() { - -} - diff --git a/ui/list_screen.h b/ui/list_screen.h deleted file mode 100644 index 9dc08f17e2..0000000000 --- a/ui/list_screen.h +++ /dev/null @@ -1,10 +0,0 @@ -#include "ui/screen.h" - - -class ListScreen { -public: - ListScreen(); - -private: - -}; \ No newline at end of file diff --git a/ui/screen.cpp b/ui/screen.cpp index b050e02b9c..47034700ef 100644 --- a/ui/screen.cpp +++ b/ui/screen.cpp @@ -33,7 +33,7 @@ void ScreenManager::switchScreen(Screen *screen) { } } -void ScreenManager::update(const InputState &input) { +void ScreenManager::update(InputState &input) { if (dialog_.size()) { dialog_.back()->update(input); return; @@ -66,6 +66,14 @@ void ScreenManager::render() { } } +void ScreenManager::deviceLost() +{ + if (currentScreen_) + currentScreen_->deviceLost(); + // Dialogs too? Nah, they should only use the standard UI texture anyway. + // TODO: Change this when it becomes necessary. +} + Screen *ScreenManager::topScreen() { if (dialog_.size()) return dialog_.back(); diff --git a/ui/screen.h b/ui/screen.h index 10404626cb..8fdcae7581 100644 --- a/ui/screen.h +++ b/ui/screen.h @@ -31,10 +31,11 @@ class Screen { public: Screen(); virtual ~Screen(); - virtual void update(const InputState &input) = 0; + virtual void update(InputState &input) = 0; virtual void render() {} - + virtual void deviceLost() {} virtual void dialogFinished(const Screen *dialog, DialogResult result) {} + private: DISALLOW_COPY_AND_ASSIGN(Screen); }; @@ -50,8 +51,9 @@ public: virtual ~ScreenManager(); void switchScreen(Screen *screen); - void update(const InputState &input); + void update(InputState &input); void render(); + void deviceLost(); void shutdown(); // Push a dialog box in front. Currently 1-level only. diff --git a/ui/virtual_input.h b/ui/virtual_input.h index 567c5f9580..765bdccb55 100644 --- a/ui/virtual_input.h +++ b/ui/virtual_input.h @@ -1,5 +1,9 @@ #pragma once +#include "gfx/texture_atlas.h" + +class DrawBuffer; + // Multitouch-enabled emulation of a hardware button. // (any finger will work, simultaneously with other virtual button/stick actions). class TouchButton