From 017797a668fb6c02732610ca53d1d567ef12882a Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 26 May 2015 00:11:50 +0600 Subject: [PATCH] Launcher (command line arguments) --- AndroidManifest.xml | 9 ++-- res/layout/activity_launcher.xml | 35 ++++++++++++++ res/values-ru/strings.xml | 7 +++ res/values/dimens.xml | 5 ++ res/values/strings.xml | 12 ++++- src/in/celest/xash3d/LauncherActivity.java | 55 ++++++++++++++++++++++ src/org/libsdl/app/SDLActivity.java | 10 +++- 7 files changed, 128 insertions(+), 5 deletions(-) create mode 100644 res/layout/activity_launcher.xml create mode 100644 res/values-ru/strings.xml create mode 100644 res/values/dimens.xml create mode 100644 src/in/celest/xash3d/LauncherActivity.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index cf81d0cc..44151049 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -22,16 +22,19 @@ android:allowBackup="true" android:hardwareAccelerated="true"> - + + + 16dp + 16dp + diff --git a/res/values/strings.xml b/res/values/strings.xml index 8e943570..85420570 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,12 +1,22 @@ + Half-life - + None Shoot Jump Use + LauncherActivity + Section 1 + Section 2 + Section 3 + Launch Xash3D! + Settings + Command line arguments(experts only) + Hello world! + diff --git a/src/in/celest/xash3d/LauncherActivity.java b/src/in/celest/xash3d/LauncherActivity.java new file mode 100644 index 00000000..4cb606a9 --- /dev/null +++ b/src/in/celest/xash3d/LauncherActivity.java @@ -0,0 +1,55 @@ +package in.celest.xash3d; + +import android.app.Activity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.content.Intent; +import android.widget.EditText; + +import in.celest.xash3d.hl.R; + +public class LauncherActivity extends Activity { + + public final static String ARGV = "in.celest.xash3d.MESSAGE"; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_launcher); + } + + public void startXash(View view) + { + Intent intent = new Intent(this, org.libsdl.app.SDLActivity.class); + EditText cmdArgs = (EditText)findViewById(R.id.cmdArgs); + String sArgv = cmdArgs.getText().toString(); + + intent.putExtra(ARGV, sArgv); + + startActivity(intent); + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + //getMenuInflater().inflate(R.menu.menu_launcher, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + /*if (id == R.id.action_settings) { + return true; + }*/ + + return super.onOptionsItemSelected(item); + } +} diff --git a/src/org/libsdl/app/SDLActivity.java b/src/org/libsdl/app/SDLActivity.java index f1f12c0f..c13b4abb 100644 --- a/src/org/libsdl/app/SDLActivity.java +++ b/src/org/libsdl/app/SDLActivity.java @@ -14,6 +14,7 @@ import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; +import android.content.Intent; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.PixelFormat; @@ -121,7 +122,14 @@ public class SDLActivity extends Activity { * @return arguments for the native application. */ protected String[] getArguments() { - return "-dev 3 -log -console".split(" "); + 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(" "); } public static void initialize() {