This commit is contained in:
Henrik Rydgard committed 2012-09-28 10:01:01 +02:00
1 parent 743631c217
commit 1c1889c726
8 files changed
+63 -13

No files matched your search

+2 -1
View File
@@ -88,7 +88,8 @@ std::string GetJavaString(JNIEnv *env, jstring jstr)
return cpp_string;
}
extern "C" jboolean Java_com_turboviking_libnative_NativeApp_isLandscape(JNIEnv *env, jclass) {
extern "C" jboolean Java_com_turboviking_libnative_NativeApp_isLandscape(JNIEnv *env, jclass)
{
std::string app_name, app_nice_name;
bool landscape;
NativeGetAppInfo(&app_name, &app_nice_name, &landscape);
+1 -2
View File
@@ -49,8 +49,7 @@ static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context) {
short *nextBuffer = buffer[curBuffer];
int nextSize = sizeof(buffer[0]);
SLresult result;
result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, nextBuffer, nextSize);
SLresult result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, nextBuffer, nextSize);
// Comment from sample code:
// the most likely other result is SL_RESULT_BUFFER_INSUFFICIENT,
@@ -1,11 +1,12 @@
package com.turboviking.libnative;
public class NativeApp {
public static native boolean isLandscape();
public static native boolean isAtTopLevel();
public static native void init(
int xxres, int yyres, int dpi, String apkPath,
String dataDir, String externalDir, String libraryDir, String installID, boolean useOpenSL);
public static native boolean isLandscape();
public static native boolean isAtTopLevel();
// These have Android semantics: Resume is always called on bootup, after init
public static native void pause();
@@ -24,4 +25,4 @@ public class NativeApp {
public static native void accelerometer(float x, float y, float z);
public static native void sendMessage(String msg, String arg);
}
}
+4
View File
@@ -217,7 +217,11 @@ int main(int argc, char *argv[]) {
}
#endif
#ifdef _WIN32
NativeInit(argc, (const char **)argv, path, "D:\\", "BADCOFFEE");
#else
NativeInit(argc, (const char **)argv, path, "/tmp", "BADCOFFEE");
#endif
float density = 1.0f;
dp_xres = (float)pixel_xres * density / zoom;
-1
View File
@@ -2016,7 +2016,6 @@ void dct_iv_slow(float *buffer, int n)
//acc += x[j] * cos(M_PI / n * (i + 0.5) * (j + 0.5));
buffer[i] = acc;
}
free(x);
}
void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype)
+1
View File
@@ -1,3 +1,4 @@
#define PNG_AVAILABLE
#ifdef PNG_AVAILABLE
#include <png.h>
#include <stdlib.h>
+39 -3
View File
@@ -8,8 +8,8 @@ Screen::Screen() { }
Screen::~Screen() { }
ScreenManager::ScreenManager() {
currentScreen_=0;
nextScreen_=0;
currentScreen_ = 0;
nextScreen_ = 0;
}
ScreenManager::~ScreenManager() {
@@ -17,6 +17,13 @@ ScreenManager::~ScreenManager() {
}
void ScreenManager::switchScreen(Screen *screen) {
if (dialog_.size())
{
WLOG("Switching screens - dropping the whole dialog stack");
while (dialog_.size())
pop();
}
// TODO: is this still true?
// Note that if a dialog is found, this will be a silent background switch that
// will only become apparent if the dialog is closed. The previous screen will stick around
// until that switch.
@@ -35,12 +42,14 @@ void ScreenManager::update(const InputState &input) {
}
if (nextScreen_) {
ILOG("Screen switch!");
Screen *temp = currentScreen_;
currentScreen_ = nextScreen_;
delete temp;
temp = 0;
nextScreen_ = 0;
}
if (currentScreen_) {
currentScreen_->update(input);
}
@@ -59,6 +68,13 @@ void ScreenManager::render() {
}
}
Screen *ScreenManager::topScreen() {
if (dialog_.size())
return dialog_.back();
else
return currentScreen_;
}
void ScreenManager::shutdown() {
if (nextScreen_) {
delete nextScreen_;
@@ -81,4 +97,24 @@ void ScreenManager::pop() {
} else {
ELOG("Can't push when no dialog is shown");
}
}
}
void ScreenManager::finishDialog(const Screen *dialog, DialogResult result)
{
if (!dialog_.size()) {
ELOG("Must be in a dialog to finishDialog");
return;
}
Screen *dlg = dialog_.back();
if (dialog != dialog_.back())
{
ELOG("Wrong dialog being finished!");
return;
}
if (dialog_.size()) {
dialog_.pop_back();
}
Screen *caller = topScreen();
caller->dialogFinished(dialog, result);
delete dialog;
}
+12 -3
View File
@@ -20,6 +20,13 @@
struct InputState;
enum DialogResult {
DR_OK,
DR_CANCEL,
DR_YES,
DR_NO,
};
class Screen {
public:
Screen();
@@ -27,7 +34,7 @@ public:
virtual void update(const InputState &input) = 0;
virtual void render() {}
virtual void dialogFinished(const Screen &dialog) {}
virtual void dialogFinished(const Screen *dialog, DialogResult result) {}
private:
DISALLOW_COPY_AND_ASSIGN(Screen);
};
@@ -51,9 +58,11 @@ public:
void push(Screen *screen);
// Pops the dialog away.
void pop();
void finishDialog(const Screen *dialog, DialogResult result = DR_OK);
private:
void pop();
Screen *topScreen();
// Base screen. These don't "stack" and you can move in any order between them.
Screen *currentScreen_;
Screen *nextScreen_;