Added support for showing publisher logo at startup screen (we have to show button "Change phone config" there anyway).

Guys from Korean market asked to show game rating (an image with text "18+" and some more korean text) in startup screen, so I've added more-less generic solution.
This commit is contained in:
pelya
2010-10-20 17:04:00 +03:00
parent 6ca9693f53
commit 5a39746b2a
7 changed files with 129 additions and 183 deletions

View File

@@ -1,8 +1,8 @@
APP_PROJECT_PATH := $(call my-dir)/..
# Available libraries: mad sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx intl xml2 lua jpeg png tremor freetype xerces
# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces
APP_MODULES := application sdl-1.2 sdl_main stlport tremor png jpeg freetype xerces sdl_mixer sdl_image sdl_ttf intl lua png xerces
APP_MODULES := application sdl-1.2 sdl_main stlport ogg flac tremor vorbis png jpeg freetype xerces sdl_mixer sdl_image sdl_ttf intl lua png xerces
# To filter out static libs from all libs in makefile
APP_AVAILABLE_STATIC_LIBS := jpeg png tremor freetype xerces

View File

@@ -35,6 +35,9 @@ LOCAL_CFLAGS += \
-I$(LOCAL_PATH)/../xml2/include \
-I$(LOCAL_PATH)/../xerces/src \
-I$(LOCAL_PATH)/../lua/src \
-I$(LOCAL_PATH)/../flac/include \
-I$(LOCAL_PATH)/../ogg/include \
-I$(LOCAL_PATH)/../vorbis/include \
-I$(LOCAL_PATH)/..
LOCAL_CFLAGS += $(APPLICATION_ADDITIONAL_CFLAGS)

View File

@@ -4,15 +4,24 @@ include $(CLEAR_VARS)
LOCAL_MODULE := sdl_mixer
LOCAL_CFLAGS := -I$(LOCAL_PATH) -I$(LOCAL_PATH)/.. -I$(LOCAL_PATH)/../sdl-$(SDL_VERSION)/include -I$(LOCAL_PATH)/../mad \
-DWAV_MUSIC -DOGG_USE_TREMOR -DOGG_MUSIC
LOCAL_CFLAGS := -I$(LOCAL_PATH) -I$(LOCAL_PATH)/.. -I$(LOCAL_PATH)/../sdl-$(SDL_VERSION)/include \
-I$(LOCAL_PATH)/../mad -I$(LOCAL_PATH)/../flac/include -I$(LOCAL_PATH)/../ogg/include -I$(LOCAL_PATH)/../vorbis/include \
-DWAV_MUSIC -DOGG_USE_TREMOR -DOGG_MUSIC -DFLAC_MUSIC
LOCAL_CPP_EXTENSION := .cpp
LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
LOCAL_SHARED_LIBRARIES := sdl-$(SDL_VERSION)
LOCAL_STATIC_LIBRARIES := tremor
LOCAL_STATIC_LIBRARIES := flac
ifeq "$(TARGET_ARCH_ABI)" "armeabi"
LOCAL_CFLAGS += -DOGG_USE_TREMOR
LOCAL_STATIC_LIBRARIES += tremor
else
LOCAL_STATIC_LIBRARIES += vorbis
endif
LOCAL_STATIC_LIBRARIES += ogg
ifneq ($(SDL_MIXER_USE_LIBMAD),)
LOCAL_CFLAGS += -DMP3_MAD_MUSIC

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@@ -1,105 +0,0 @@
// This string is autogenerated by ChangeAppSettings.sh, do not change
// spaces amount
package org.enigmagame.enigma;
import java.util.zip.*;
import java.io.*;
import android.util.Log;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import android.content.res.AssetManager;
class AssetExtract {
private AssetManager mAssetManager = null;
AssetExtract(AssetManager am) {
mAssetManager = am;
}
public boolean extract(String asset, String target) {
byte buf[] = new byte[1024 * 1024];
InputStream assetStream = null;
try {
assetStream = mAssetManager.open(asset, AssetManager.ACCESS_RANDOM);
} catch (IOException e) {
// TODO: Report error.
return false;
}
ZipInputStream zip = new ZipInputStream(assetStream);
while (true) {
ZipEntry entry = null;
try {
entry = zip.getNextEntry();
} catch ( java.io.IOException e ) {
// Todo: Error out.
return false;
}
if ( entry == null ) {
break;
}
Log.i("AssetExtract", "Extracting " + entry.getName());
if (entry.isDirectory()) {
try {
new File(target +"/" + entry.getName()).mkdirs();
} catch ( SecurityException e ) { };
continue;
}
OutputStream out = null;
String path = target + "/" + entry.getName();
try {
out = new FileOutputStream( path );
} catch ( FileNotFoundException e ) {
} catch ( SecurityException e ) { };
if ( out == null ) {
// TODO: Error.
return false;
}
try {
while (true) {
int len = zip.read(buf);
if (len == -1) {
break;
}
out.write(buf, 0, len);
}
out.flush();
out.close();
} catch ( java.io.IOException e ) {
// TODO: Deal w/ error.
return false;
}
}
try {
zip.close();
assetStream.close();
} catch (IOException e) {
// pass
}
return true;
}
}

View File

@@ -8,7 +8,12 @@ import android.view.MotionEvent;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.content.res.Configuration;
@@ -25,27 +30,110 @@ public class MainActivity extends Activity {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
_tv = new TextView(this);
_tv.setText(R.string.init);
setContentView(_tv);
System.out.println("libSDL: Creating startup screen");
_layout = new LinearLayout(this);
_layout.setOrientation(LinearLayout.VERTICAL);
_layout.setLayoutParams(new LinearLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
_layout2 = new LinearLayout(this);
_layout2.setLayoutParams(new LinearLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
_btn = new Button(this);
_btn.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
_btn.setText(getResources().getString(R.string.device_change_cfg));
class onClickListener implements View.OnClickListener
{
public MainActivity p;
onClickListener( MainActivity _p ) { p = _p; }
public void onClick(View v)
{
System.out.println("libSDL: User clicked change phone config button");
Settings.showConfig(p);
}
};
_btn.setOnClickListener(new onClickListener(this));
_layout2.addView(_btn);
_layout.addView(_layout2);
ImageView img = new ImageView(this);
img.setScaleType(ImageView.ScaleType.FIT_CENTER /* FIT_XY */ );
img.setImageResource(R.drawable.publisherlogo);
img.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
_layout.addView(img);
setContentView(_layout);
if(mAudioThread == null) // Starting from background (should not happen)
{
System.out.println("libSDL: Loading libraries");
mLoadLibraryStub = new LoadLibrary();
mAudioThread = new AudioThread(this);
System.out.println("libSDL: Loading settings");
Settings.Load(this);
}
if( !Settings.settingsChanged )
{
System.out.println("libSDL: 3-second timeout in startup screen");
class Callback implements Runnable
{
MainActivity p;
Callback( MainActivity _p ) { p = _p; }
public void run()
{
try {
Thread.sleep(3000);
} catch( InterruptedException e ) {};
if( Settings.settingsChanged )
return;
System.out.println("libSDL: Timeout reached in startup screen, process with downloader");
p.startDownloader();
}
};
Thread changeConfigAlertThread = null;
changeConfigAlertThread = new Thread(new Callback(this));
changeConfigAlertThread.start();
}
}
public void startDownloader()
{
if( downloader == null )
downloader = new DataDownloader(this, _tv);
System.out.println("libSDL: Starting data downloader");
class Callback implements Runnable
{
public MainActivity Parent;
public void run()
{
System.out.println("libSDL: Removing button from startup screen and adding status text");
if( Parent._btn != null )
{
Parent._layout2.removeView(Parent._btn);
Parent._btn = null;
}
if( Parent._tv == null )
{
Parent._tv = new TextView(Parent);
Parent._tv.setText(R.string.init);
Parent._layout2.addView(Parent._tv);
}
System.out.println("libSDL: Starting downloader");
if( Parent.downloader == null )
Parent.downloader = new DataDownloader(Parent, Parent._tv);
}
}
Callback cb = new Callback();
cb.Parent = this;
this.runOnUiThread(cb);
}
public void initSDL()
{
if(sdlInited)
return;
System.out.println("libSDL: Initializing video and SDL application");
sdlInited = true;
if(Globals.UseAccelerometerAsArrowKeys)
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
@@ -126,6 +214,8 @@ public class MainActivity extends Activity {
public boolean dispatchTouchEvent(final MotionEvent ev) {
if(mGLView != null)
mGLView.onTouchEvent(ev);
else if( _btn != null )
return _btn.dispatchTouchEvent(ev);
return true;
}
@@ -158,6 +248,9 @@ public class MainActivity extends Activity {
private static AudioThread mAudioThread = null;
private static DataDownloader downloader = null;
private TextView _tv = null;
private Button _btn = null;
private LinearLayout _layout = null;
private LinearLayout _layout2 = null;
private boolean sdlInited = false;
}

View File

@@ -28,9 +28,8 @@ class Settings
{
static String SettingsFileName = "libsdl-settings.cfg";
static AlertDialog changeConfigAlert = null;
static Thread changeConfigAlertThread = null;
static boolean settingsLoaded = false;
static boolean settingsChanged = false;
static void Save(final MainActivity p)
{
@@ -43,6 +42,7 @@ class Settings
out.writeBoolean(Globals.UseTouchscreenKeyboard);
out.writeInt(Globals.TouchscreenKeyboardSize);
out.writeInt(Globals.AccelerometerSensitivity);
out.writeInt(Globals.AccelerometerCenterPos);
out.writeInt(Globals.TrackballDampening);
out.writeInt(Globals.AudioBufferConfig);
out.writeInt(Globals.OptionalDataDownload.length);
@@ -61,9 +61,9 @@ class Settings
{
if(settingsLoaded) // Prevent starting twice
{
startDownloader(p);
return;
}
System.out.println("libSDL: Settings.Load(): enter");
try {
ObjectInputStream settingsFile = new ObjectInputStream(new FileInputStream( p.getFilesDir().getAbsolutePath() + "/" + SettingsFileName ));
Globals.DownloadToSdcard = settingsFile.readBoolean();
@@ -73,6 +73,7 @@ class Settings
Globals.UseTouchscreenKeyboard = settingsFile.readBoolean();
Globals.TouchscreenKeyboardSize = settingsFile.readInt();
Globals.AccelerometerSensitivity = settingsFile.readInt();
Globals.AccelerometerCenterPos = settingsFile.readInt();
Globals.TrackballDampening = settingsFile.readInt();
Globals.AudioBufferConfig = settingsFile.readInt();
Globals.OptionalDataDownload = new boolean[settingsFile.readInt()];
@@ -81,54 +82,9 @@ class Settings
Globals.TouchscreenKeyboardTheme = settingsFile.readInt();
settingsLoaded = true;
System.out.println("libSDL: Settings.Load(): loaded settings successfully");
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.device_config));
builder.setPositiveButton(p.getResources().getString(R.string.device_change_cfg),
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
changeConfigAlert = null;
dialog.dismiss();
showDownloadConfig(p);
}
});
/*
builder.setNegativeButton("Start", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
changeConfigAlert = null;
dialog.dismiss();
startDownloader(p);
}
});
*/
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
changeConfigAlert = alert;
class Callback implements Runnable
{
MainActivity p;
Callback( MainActivity _p ) { p = _p; }
public void run()
{
try {
Thread.sleep(2000);
} catch( InterruptedException e ) {};
if( changeConfigAlert == null )
return;
changeConfigAlert.dismiss();
startDownloader(p);
}
};
changeConfigAlertThread = new Thread(new Callback(p));
changeConfigAlertThread.start();
alert.show();
return;
} catch( FileNotFoundException e ) {
@@ -156,6 +112,12 @@ class Settings
"Unknown" ) );
*/
System.out.println("libSDL: Settings.Load(): loading settings failed, running config dialog");
showConfig(p);
}
public static void showConfig(final MainActivity p) {
settingsChanged = true;
showDownloadConfig(p);
}
@@ -478,7 +440,7 @@ class Settings
Globals.AudioBufferConfig = item;
dialog.dismiss();
Save(p);
startDownloader(p);
p.startDownloader();
}
});
AlertDialog alert = builder.create();
@@ -546,22 +508,6 @@ class Settings
}
}
static void startDownloader(MainActivity p)
{
class Callback implements Runnable
{
public MainActivity Parent;
public void run()
{
Parent.startDownloader();
}
}
Callback cb = new Callback();
cb.Parent = p;
p.runOnUiThread(cb);
};
private static native void nativeIsSdcardUsed(int flag);
private static native void nativeSetTrackballUsed();
private static native void nativeSetTrackballDampening(int value);