Merge pull request #14 from mittorn/android-test-0.15pre
Android test 0.15pre
This commit is contained in:
commit
837c384e86
19 changed files with 421 additions and 87 deletions
|
@ -5,7 +5,7 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="in.celest.xash3d.hl"
|
||||
android:versionCode="0"
|
||||
android:versionName="0.14.1"
|
||||
android:versionName="0.15"
|
||||
android:installLocation="auto">
|
||||
|
||||
<!-- Create a Java class extending SDLActivity and place it in a
|
||||
|
@ -23,29 +23,51 @@
|
|||
|
||||
android:hardwareAccelerated="true">
|
||||
<activity android:name="in.celest.xash3d.LauncherActivity"
|
||||
android:label="@string/app_name"
|
||||
android:label="@string/launcher_name"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
>
|
||||
<intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="in.celest.xash3d.LauncherActivity"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="in.celest.xash3d.ShortcutActivity" android:label="@string/text_shortcut" android:theme="@android:style/Theme.Dialog">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.CREATE_SHORTCUT" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="org.libsdl.app.SDLActivity"
|
||||
android:screenOrientation="sensorLandscape"
|
||||
android:configChanges="orientation|screenSize"
|
||||
>
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:label="@string/app_name"
|
||||
android:taskAffinity="org.libsdl.app.SDLActivity"
|
||||
>
|
||||
<!--<intent-filter>
|
||||
As user can add now empty shortcut, disable this
|
||||
<action android:name="org.libsdl.app.SDLActivity"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>-->
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="xash3d.android/game"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="in.celest.xash3d.XashActivity"
|
||||
<activity android:name="in.celest.xash3d.XashActivity"
|
||||
android:screenOrientation="landscape"
|
||||
android:label="@string/app_name">
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
<!-- Android 2.3.3 -->
|
||||
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14" />
|
||||
<!-- Android 2.3 -->
|
||||
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="14" />
|
||||
|
||||
<!-- OpenGL ES 2.0 -->
|
||||
<uses-feature android:glEsVersion="0x00020000" />
|
||||
<!-- OpenGL ES 1.1 -->
|
||||
<uses-feature android:glEsVersion="0x00010000" />
|
||||
|
||||
<!-- Allow writing to external storage -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
|
13
build-test.sh
Normal file
13
build-test.sh
Normal file
|
@ -0,0 +1,13 @@
|
|||
ANDROID_JAR=../android-13.jar
|
||||
AAPT=./../aapt
|
||||
DX=./../dx
|
||||
APKBUILDER=./../apkbuilder
|
||||
mkdir gen
|
||||
mkdir bin
|
||||
$AAPT package -m -J gen/ --rename-manifest-package in.celest.xash3d.hl -M AndroidManifest.xml -S test/res -I $ANDROID_JAR
|
||||
$JAVA_HOME/bin/javac -d bin/classes -s bin/classes -cp $ANDROID_JAR:libs/com.bda.controller.jar src/org/libsdl/app/SDLActivity.java src/com/beloko/games/hl/NativeLib.java src/com/beloko/touchcontrols/* gen/in/celest/xash3d/hl/R.java src/in/celest/xash3d/*
|
||||
$DX --dex --output=bin/classes.dex bin/classes/ libs/com.bda.controller.jar
|
||||
/mnt/app/apktool/aapt package -f -M test/AndroidManifest.xml -S test/res -I $ANDROID_JAR -F bin/xash3d.apk.unaligned
|
||||
zip bin/xash3d.apk.unaligned assets/*
|
||||
$APKBUILDER bin/xash3d.apk -u -nf libs/ -rj libs -f bin/classes.dex -z bin/xash3d.apk.unaligned
|
||||
java -jar /mnt/app/apktool/signapk.jar /mnt/app/apktool/testkey.x509.pem /mnt/app/apktool/testkey.pk8 bin/xash3d.apk bin/xash3d-signed.apk
|
|
@ -1,35 +1,75 @@
|
|||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context="in.celest.xash3d.LauncherActivity"
|
||||
android:id="@+id/layout">
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context="in.celest.xash3d.LauncherActivity"
|
||||
android:id="@+id/layout_shortcut">
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/launch_button"
|
||||
android:id="@+id/button"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:onClick="startXash"/>
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/launch_button"
|
||||
android:id="@+id/button_launch"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:onClick="startXash"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/touch_set"
|
||||
android:id="@+id/touch_set"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:onClick="controlsSettings"/>
|
||||
|
||||
<EditText
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/cmdArgs"
|
||||
android:layout_below="@+id/textView"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignRight="@+id/textView" />
|
||||
<EditText
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/cmdArgs"
|
||||
android:layout_below="@+id/textView_args"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignRight="@+id/textView_args"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="@string/cmd_args_text"
|
||||
android:id="@+id/textView"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="@string/cmd_args_text"
|
||||
android:id="@+id/textView_args"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"/>
|
||||
|
||||
<CheckBox
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_below="@+id/cmdArgs"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="@string/use_controls"
|
||||
android:id="@+id/useControls"/>
|
||||
|
||||
<EditText
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/cmdPath"
|
||||
android:layout_below="@+id/textView_path"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignRight="@+id/textView_path"/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="@string/text_res_path"
|
||||
android:id="@+id/textView_path"
|
||||
android:layout_below="@+id/useControls"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
|
72
res/layout/activity_shortcut.xml
Normal file
72
res/layout/activity_shortcut.xml
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context="in.celest.xash3d.ShortcutActivity"
|
||||
android:id="@+id/layout_shortcut">
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/shortcut_button_save"
|
||||
android:id="@+id/shortcut_buttonOk"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:onClick="saveShortcut"/>
|
||||
|
||||
<EditText
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:id="@+id/shortcut_name"
|
||||
android:layout_below="@+id/shortcut_name_text"
|
||||
android:layout_alignParentRight="true"/>
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/shortcut_name_text"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="@string/shortcut_name"
|
||||
/>
|
||||
|
||||
<EditText
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/shortcut_cmdArgs"
|
||||
android:layout_below="@+id/shortcut_textView_args"
|
||||
android:layout_alignParentRight="true"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="@string/cmd_args_text"
|
||||
android:id="@+id/shortcut_textView_args"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@+id/shortcut_name"/>
|
||||
|
||||
<EditText
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/shortcut_gamedir"
|
||||
android:layout_below="@+id/shortcut_gamedir_text"
|
||||
android:layout_alignParentRight="true"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="@string/gamedir"
|
||||
android:id="@+id/shortcut_gamedir_text"
|
||||
android:layout_below="@+id/shortcut_cmdArgs"
|
||||
android:layout_alignParentRight="true"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
@ -3,5 +3,11 @@
|
|||
<string name="cmd_args_text">Аргументы командной строки(только для экспертов)</string>
|
||||
<string name="launch_button">Запустить Xash3D</string>
|
||||
<string name="title_section1">Команды</string>
|
||||
|
||||
</resources>
|
||||
<string name="use_controls">Включить экранное управление</string>
|
||||
<string name="text_res_path">Путь к ресурсам игры</string>
|
||||
<string name="touch_set">Настройки управления</string>
|
||||
<string name="text_shortcut">Ярлык Xash3D</string>
|
||||
<string name="shortcut_button_save">Сохранить ярлык</string>
|
||||
<string name="gamedir">Каталог мода</string>
|
||||
<string name="shortcut_name">Название ярлыка</string>
|
||||
</resources>
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Half-life</string>
|
||||
|
||||
<string name="app_name">Xash3D</string>
|
||||
<string name="launcher_name">Xash3D</string>
|
||||
<string name="launcher_name_test">Xash3D_test</string>
|
||||
<string-array name="double_tap_actions">
|
||||
<item>None</item>
|
||||
<item>Shoot</item>
|
||||
|
@ -17,6 +18,13 @@
|
|||
<string name="launch_button">Launch Xash3D!</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="cmd_args_text">Command line arguments(experts only)</string>
|
||||
<string name="use_controls">Enable touch controls</string>
|
||||
<string name="text_res_path">Path to game resources</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
|
||||
<string name="touch_set">Controls settings</string>
|
||||
<string name="text_shortcut">Xash3D shortcut</string>
|
||||
<string name="text_shortcut_test">Xash3D_test shortcut</string>
|
||||
<string name="shortcut_button_save">Save shortcut</string>
|
||||
<string name="gamedir">Mod directory</string>
|
||||
<string name="shortcut_name">Shortcut name</string>
|
||||
</resources>
|
||||
|
|
|
@ -71,12 +71,17 @@ public class TouchControlsSettings {
|
|||
}
|
||||
*/
|
||||
Button add_rem_button = (Button)dialog.findViewById(R.id.add_remove_button);
|
||||
if(quakeIf != null)
|
||||
{
|
||||
add_rem_button.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
TouchControlsEditing.show(activity);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
add_rem_button.setEnabled(false);
|
||||
|
||||
alphaSeek.setProgress(alpha);
|
||||
fwdSeek.setProgress(fwdSens);
|
||||
|
@ -201,7 +206,8 @@ public class TouchControlsSettings {
|
|||
|
||||
public static void sendToQuake()
|
||||
{
|
||||
|
||||
if(quakeIf == null) return;
|
||||
|
||||
int other = 0;
|
||||
other += showWeaponCycle?0x1:0;
|
||||
other += mouseMode?0x2:0;
|
||||
|
|
|
@ -7,30 +7,56 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.content.Intent;
|
||||
import android.widget.EditText;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.content.ComponentName;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import in.celest.xash3d.hl.R;
|
||||
import com.beloko.touchcontrols.TouchControlsSettings;
|
||||
|
||||
public class LauncherActivity extends Activity {
|
||||
|
||||
public final static String ARGV = "in.celest.xash3d.MESSAGE";
|
||||
// public final static String ARGV = "in.celest.xash3d.MESSAGE";
|
||||
static TouchControlsSettings mSettings;
|
||||
static EditText cmdArgs;
|
||||
static CheckBox useControls;
|
||||
static EditText resPath;
|
||||
static SharedPreferences mPref;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_launcher);
|
||||
}
|
||||
mSettings=new TouchControlsSettings();
|
||||
mSettings.setup(this, null);
|
||||
mSettings.loadSettings(this);
|
||||
mPref = getSharedPreferences("engine", 0);
|
||||
cmdArgs = (EditText)findViewById(R.id.cmdArgs);
|
||||
cmdArgs.setText(mPref.getString("argv","-dev 3 -console -log"));
|
||||
useControls = ( CheckBox ) findViewById( R.id.useControls );
|
||||
useControls.setChecked(mPref.getBoolean("controls",true));
|
||||
resPath = ( EditText ) findViewById( R.id.cmdPath );
|
||||
resPath.setText(mPref.getString("basedir","/sdcard/xash/"));
|
||||
}
|
||||
|
||||
public void startXash(View view)
|
||||
{
|
||||
Intent intent = new Intent(this, org.libsdl.app.SDLActivity.class);
|
||||
//Intent intent = new Intent(this, in.celest.xash3d.XashActivity.class);
|
||||
EditText cmdArgs = (EditText)findViewById(R.id.cmdArgs);
|
||||
String sArgv = cmdArgs.getText().toString();
|
||||
|
||||
intent.putExtra(ARGV, sArgv);
|
||||
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
SharedPreferences.Editor editor = mPref.edit();
|
||||
editor.putString("argv", cmdArgs.getText().toString());
|
||||
editor.putBoolean("controls",useControls.isChecked());
|
||||
editor.putString("basedir", resPath.getText().toString());
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
public void controlsSettings(View view)
|
||||
{
|
||||
mSettings.loadSettings(this);
|
||||
mSettings.showSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
|
|
42
src/in/celest/xash3d/ShortcutActivity.java
Normal file
42
src/in/celest/xash3d/ShortcutActivity.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
package in.celest.xash3d;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.view.View;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import in.celest.xash3d.hl.R;
|
||||
import android.widget.EditText;
|
||||
|
||||
import android.os.*;
|
||||
|
||||
public class ShortcutActivity extends Activity
|
||||
{
|
||||
static EditText name;
|
||||
@Override
|
||||
protected void onCreate(Bundle bundle)
|
||||
{
|
||||
super.onCreate(bundle);
|
||||
setContentView(R.layout.activity_shortcut);
|
||||
name=(EditText)findViewById(R.id.shortcut_name);
|
||||
name.setText("Name");
|
||||
}
|
||||
public void saveShortcut(View view)
|
||||
{
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW,null);
|
||||
intent.setType("xash3d.android/game");
|
||||
EditText argv = (EditText)findViewById(R.id.shortcut_cmdArgs);
|
||||
if(argv.length() != 0) intent.putExtra("argv",argv.getText().toString());
|
||||
EditText gamedir = (EditText)findViewById(R.id.shortcut_gamedir);
|
||||
if(gamedir.length() != 0) intent.putExtra("gamedir",gamedir.getText().toString());
|
||||
Intent wrapIntent = new Intent();
|
||||
wrapIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
|
||||
wrapIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name.getText().toString());
|
||||
Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
|
||||
/// TODO: Load icon from path+gamedir+"game.ico"
|
||||
int size = (int) getResources().getDimension(android.R.dimen.app_icon_size);
|
||||
wrapIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, Bitmap.createScaledBitmap(icon, size, size, false));
|
||||
setResult(RESULT_OK, wrapIntent);
|
||||
finish();
|
||||
}
|
||||
}
|
|
@ -54,7 +54,7 @@ public class XashActivity extends Activity {
|
|||
// So we can call stuff from static callbacks
|
||||
mSingleton = this;
|
||||
Intent intent = getIntent();
|
||||
mArgv = intent.getStringExtra(in.celest.xash3d.LauncherActivity.ARGV);
|
||||
// mArgv = intent.getStringExtra(in.celest.xash3d.LauncherActivity.ARGV);
|
||||
// Set up the surface
|
||||
mSurface = new EngineSurface(getApplication());
|
||||
setContentView(mSurface);
|
||||
|
|
|
@ -58,6 +58,7 @@ import com.beloko.games.hl.NativeLib;
|
|||
import com.beloko.touchcontrols.ControlInterpreter;
|
||||
import com.beloko.touchcontrols.Settings;
|
||||
import com.beloko.touchcontrols.TouchControlsSettings;
|
||||
import android.content.*;
|
||||
|
||||
/**
|
||||
SDL Activity
|
||||
|
@ -66,7 +67,7 @@ public class SDLActivity extends Activity {
|
|||
private static final String TAG = "SDL";
|
||||
|
||||
// Keep track of the paused state
|
||||
public static boolean mIsPaused, mIsSurfaceReady, mHasFocus;
|
||||
public static boolean mIsPaused, mIsSurfaceReady, mHasFocus, mUseControls;
|
||||
public static boolean mExitCalledFromJava;
|
||||
|
||||
/** If shared libraries (e.g. SDL or the native application) could not be loaded. */
|
||||
|
@ -89,9 +90,11 @@ public class SDLActivity extends Activity {
|
|||
// Audio
|
||||
protected static AudioTrack mAudioTrack;
|
||||
|
||||
//Touch control interp
|
||||
// Touch control interp
|
||||
public static ControlInterpreter controlInterp;
|
||||
|
||||
|
||||
// Preferences
|
||||
public static SharedPreferences mPref;
|
||||
/**
|
||||
* This method is called by SDL before loading the native shared libraries.
|
||||
* It can be overridden to provide names of shared libraries to be loaded.
|
||||
|
@ -122,14 +125,10 @@ public class SDLActivity extends Activity {
|
|||
* @return arguments for the native application.
|
||||
*/
|
||||
protected String[] getArguments() {
|
||||
Intent intent = getIntent();
|
||||
String sArgv = intent.getStringExtra(in.celest.xash3d.LauncherActivity.ARGV);
|
||||
|
||||
Log.v("ArgvDebug", "Got args: " + sArgv);
|
||||
|
||||
if(sArgv == null || sArgv.isEmpty())
|
||||
return "-dev 3 -log -console".split(" ");
|
||||
else return sArgv.split(" ");
|
||||
String argv=getIntent().getStringExtra("argv");
|
||||
if(argv != null)
|
||||
return argv.split(" ");
|
||||
return mPref.getString("argv","-dev 3 -log -console").split(" ");
|
||||
}
|
||||
|
||||
public static void initialize() {
|
||||
|
@ -169,7 +168,8 @@ public class SDLActivity extends Activity {
|
|||
SDLActivity.initialize();
|
||||
// So we can call stuff from static callbacks
|
||||
mSingleton = this;
|
||||
|
||||
mPref = this.getSharedPreferences("engine", 0);
|
||||
mUseControls = mPref.getBoolean("controls", false);
|
||||
// Load shared libraries
|
||||
String errorMsgBrokenLib = "";
|
||||
try {
|
||||
|
@ -205,6 +205,21 @@ public class SDLActivity extends Activity {
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
Intent intent=getIntent();
|
||||
String gamelibdir = intent.getStringExtra("gamelibdir");
|
||||
if(gamelibdir == null)
|
||||
gamelibdir = getFilesDir().getParentFile().getPath() + "/lib";
|
||||
String gamedir = intent.getStringExtra("gamedir");
|
||||
if(gamedir == null)
|
||||
gamedir = "valve";
|
||||
String basedir = intent.getStringExtra("basedir");
|
||||
if(basedir == null)
|
||||
basedir = mPref.getString("basedir","/sdcard/xash/");
|
||||
setenv("XASH3D_BASEDIR", basedir, true);
|
||||
setenv("XASH3D_ENGLIBDIR", getFilesDir().getParentFile().getPath() + "/lib", true);
|
||||
setenv("XASH3D_GAMELIBDIR", gamelibdir, true);
|
||||
setenv("XASH3D_GAMEDIR", gamedir, true);
|
||||
|
||||
// Set up the surface
|
||||
mSurface = new SDLSurface(getApplication());
|
||||
|
@ -467,7 +482,8 @@ public class SDLActivity extends Activity {
|
|||
int naxes, int nhats, int nballs);
|
||||
public static native int nativeRemoveJoystick(int device_id);
|
||||
public static native String nativeGetHint(String name);
|
||||
|
||||
public static native int setenv(String key, String value, boolean overwrite);
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
|
@ -965,21 +981,23 @@ class SDLMain implements Runnable {
|
|||
@Override
|
||||
public void run() {
|
||||
// Runs SDL_main()
|
||||
if(SDLActivity.mUseControls)
|
||||
{
|
||||
NativeLib engine = new NativeLib();
|
||||
engine.initTouchControls_if(SDLActivity.mSingleton.getFilesDir().toString() + "/",
|
||||
(int)SDLSurface.mWidth, (int)SDLSurface.mHeight);
|
||||
|
||||
NativeLib engine = new NativeLib();
|
||||
engine.initTouchControls_if(SDLActivity.mSingleton.getFilesDir().toString() + "/",
|
||||
(int)SDLSurface.mWidth, (int)SDLSurface.mHeight);
|
||||
SDLActivity.controlInterp = new ControlInterpreter(engine,Settings.IDGame.Doom,Settings.gamePadControlsFile,Settings.gamePadEnabled);
|
||||
|
||||
SDLActivity.controlInterp = new ControlInterpreter(engine,Settings.IDGame.Doom,Settings.gamePadControlsFile,Settings.gamePadEnabled);
|
||||
SDLActivity.controlInterp.setScreenSize((int)SDLSurface.mWidth, (int)SDLSurface.mHeight);
|
||||
|
||||
SDLActivity.controlInterp.setScreenSize((int)SDLSurface.mWidth, (int)SDLSurface.mHeight);
|
||||
|
||||
TouchControlsSettings.setup(SDLActivity.mSingleton, engine);
|
||||
TouchControlsSettings.loadSettings(SDLActivity.mSingleton);
|
||||
TouchControlsSettings.sendToQuake();
|
||||
|
||||
Settings.copyPNGAssets(SDLActivity.mSingleton,SDLActivity.mSingleton.getFilesDir().toString() + "/",null);
|
||||
TouchControlsSettings.setup(SDLActivity.mSingleton, engine);
|
||||
TouchControlsSettings.loadSettings(SDLActivity.mSingleton);
|
||||
TouchControlsSettings.sendToQuake();
|
||||
|
||||
Settings.copyPNGAssets(SDLActivity.mSingleton,SDLActivity.mSingleton.getFilesDir().toString() + "/",null);
|
||||
|
||||
}
|
||||
SDLActivity.nativeInit(SDLActivity.mSingleton.getArguments());
|
||||
//Log.v("SDL", "SDL thread terminated");
|
||||
}
|
||||
|
@ -1189,12 +1207,14 @@ View.OnKeyListener, View.OnTouchListener, SensorEventListener {
|
|||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
|
||||
|
||||
SDLActivity.controlInterp.onTouchEvent(event);
|
||||
return true;
|
||||
if(SDLActivity.mUseControls)
|
||||
{
|
||||
SDLActivity.controlInterp.onTouchEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Ref: http://developer.android.com/training/gestures/multi.html */
|
||||
/*
|
||||
|
||||
final int touchDevId = event.getDeviceId();
|
||||
final int pointerCount = event.getPointerCount();
|
||||
int action = event.getActionMasked();
|
||||
|
@ -1262,7 +1282,6 @@ View.OnKeyListener, View.OnTouchListener, SensorEventListener {
|
|||
}
|
||||
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
|
||||
// Sensor events
|
||||
|
|
76
test/AndroidManifest.xml
Normal file
76
test/AndroidManifest.xml
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Replace org.libsdl.app with the identifier of your game below, e.g.
|
||||
com.gamemaker.game
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="in.celest.xash3d.hl.test"
|
||||
android:versionCode="0"
|
||||
android:versionName="0.15pre"
|
||||
android:installLocation="auto">
|
||||
|
||||
<!-- Create a Java class extending SDLActivity and place it in a
|
||||
directory under src matching the package, e.g.
|
||||
src/com/gamemaker/game/MyGame.java
|
||||
|
||||
then replace "SDLActivity" with the name of your class (e.g. "MyGame")
|
||||
in the XML below.
|
||||
|
||||
An example Java class can be found in README-android.txt
|
||||
-->
|
||||
<application android:label="@string/launcher_name_test"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:allowBackup="true"
|
||||
|
||||
android:hardwareAccelerated="true">
|
||||
<activity android:name="in.celest.xash3d.LauncherActivity"
|
||||
android:label="@string/launcher_name_test"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
>
|
||||
<intent-filter>
|
||||
<action android:name="in.celest.xash3d.LauncherActivity"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="in.celest.xash3d.ShortcutActivity" android:label="@string/text_shortcut_test" android:theme="@android:style/Theme.Dialog">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.CREATE_SHORTCUT" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="org.libsdl.app.SDLActivity"
|
||||
android:screenOrientation="sensorLandscape"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:label="@string/app_name"
|
||||
android:taskAffinity="org.libsdl.app.SDLActivity"
|
||||
>
|
||||
<!--<intent-filter>
|
||||
As user can add now empty shortcut, disable this
|
||||
<action android:name="org.libsdl.app.SDLActivity"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>-->
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="xash3d.android/game"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="in.celest.xash3d.XashActivity"
|
||||
android:screenOrientation="landscape"
|
||||
android:label="@string/app_name">
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
<!-- Android 2.3 -->
|
||||
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="9" />
|
||||
|
||||
<!-- OpenGL ES 1.1 -->
|
||||
<uses-feature android:glEsVersion="0x00010000" />
|
||||
|
||||
<!-- Allow writing to external storage -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
</manifest>
|
1
test/res/drawable
Symbolic link
1
test/res/drawable
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../res/drawable
|
BIN
test/res/drawable-hdpi/ic_launcher.png
Normal file
BIN
test/res/drawable-hdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.9 KiB |
BIN
test/res/drawable-mdpi/ic_launcher.png
Normal file
BIN
test/res/drawable-mdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
BIN
test/res/drawable-xhdpi/ic_launcher.png
Normal file
BIN
test/res/drawable-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.1 KiB |
1
test/res/layout
Symbolic link
1
test/res/layout
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../res/layout/
|
1
test/res/values
Symbolic link
1
test/res/values
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../res/values/
|
1
test/res/values-ru
Symbolic link
1
test/res/values-ru
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../res/values-ru/
|
Loading…
Add table
Reference in a new issue