Screens need to know when the device is lost. Cleanup.

This commit is contained in:
Henrik Rydgard 2012-10-27 16:40:42 +02:00
parent da61ce3950
commit 4c62311132
8 changed files with 19 additions and 29 deletions

View file

@ -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

View file

@ -237,7 +237,6 @@
<ClInclude Include="net\http_client.h" />
<ClInclude Include="net\resolve.h" />
<ClInclude Include="profiler\profiler.h" />
<ClInclude Include="ui\list_screen.h" />
<ClInclude Include="ui\screen.h" />
<ClInclude Include="ui\ui.h" />
<ClInclude Include="ui\virtual_input.h" />
@ -317,7 +316,6 @@
<ClCompile Include="net\http_client.cpp" />
<ClCompile Include="net\resolve.cpp" />
<ClCompile Include="profiler\profiler.cpp" />
<ClCompile Include="ui\list_screen.cpp" />
<ClCompile Include="ui\screen.cpp" />
<ClCompile Include="ui\ui.cpp" />
<ClCompile Include="ui\virtual_input.cpp" />

View file

@ -194,9 +194,6 @@
<ClInclude Include="base\linked_ptr.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="ui\list_screen.h">
<Filter>ui</Filter>
</ClInclude>
<ClInclude Include="base\backtrace.h">
<Filter>base</Filter>
</ClInclude>
@ -373,9 +370,6 @@
<ClCompile Include="ui\screen.cpp">
<Filter>ui</Filter>
</ClCompile>
<ClCompile Include="ui\list_screen.cpp">
<Filter>ui</Filter>
</ClCompile>
<ClCompile Include="base\backtrace.cpp">
<Filter>base</Filter>
</ClCompile>

View file

@ -1,6 +0,0 @@
#include "ui/list_screen.h"
ListScreen::ListScreen() {
}

View file

@ -1,10 +0,0 @@
#include "ui/screen.h"
class ListScreen {
public:
ListScreen();
private:
};

View file

@ -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();

View file

@ -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.

View file

@ -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