Launcher (command line arguments)
This commit is contained in:
parent
c9e93071c2
commit
017797a668
7 changed files with 128 additions and 5 deletions
|
@ -22,16 +22,19 @@
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
|
||||||
android:hardwareAccelerated="true">
|
android:hardwareAccelerated="true">
|
||||||
<activity android:name="org.libsdl.app.SDLActivity"
|
<activity android:name="in.celest.xash3d.LauncherActivity"
|
||||||
android:screenOrientation="landscape"
|
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|screenSize"
|
|
||||||
>
|
>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity android:name="org.libsdl.app.SDLActivity"
|
||||||
|
android:screenOrientation="sensorLandscape"
|
||||||
|
android:configChanges="orientation|screenSize"
|
||||||
|
>
|
||||||
|
</activity>
|
||||||
<!-- <activity android:name=".XashActivity"
|
<!-- <activity android:name=".XashActivity"
|
||||||
android:screenOrientation="landscape"
|
android:screenOrientation="landscape"
|
||||||
android:label="@string/app_name">
|
android:label="@string/app_name">
|
||||||
|
|
35
res/layout/activity_launcher.xml
Normal file
35
res/layout/activity_launcher.xml
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<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">
|
||||||
|
|
||||||
|
<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"/>
|
||||||
|
|
||||||
|
<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" />
|
||||||
|
|
||||||
|
<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" />
|
||||||
|
</RelativeLayout>
|
7
res/values-ru/strings.xml
Normal file
7
res/values-ru/strings.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<string name="cmd_args_text">Аргументы командной строки(только для экспертов)</string>
|
||||||
|
<string name="launch_button">Запустить Xash3D</string>
|
||||||
|
<string name="title_section1">Команды</string>
|
||||||
|
|
||||||
|
</resources>
|
5
res/values/dimens.xml
Normal file
5
res/values/dimens.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<resources>
|
||||||
|
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||||
|
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||||
|
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||||
|
</resources>
|
|
@ -1,12 +1,22 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<string name="app_name">Half-life</string>
|
<string name="app_name">Half-life</string>
|
||||||
|
|
||||||
<string-array name="double_tap_actions">
|
<string-array name="double_tap_actions">
|
||||||
<item>None</item>
|
<item>None</item>
|
||||||
<item>Shoot</item>
|
<item>Shoot</item>
|
||||||
<item>Jump</item>
|
<item>Jump</item>
|
||||||
<item>Use</item>
|
<item>Use</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string name="title_activity_launcher">LauncherActivity</string>
|
||||||
|
<string name="title_section1">Section 1</string>
|
||||||
|
<string name="title_section2">Section 2</string>
|
||||||
|
<string name="title_section3">Section 3</string>
|
||||||
|
<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="hello_world">Hello world!</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
55
src/in/celest/xash3d/LauncherActivity.java
Normal file
55
src/in/celest/xash3d/LauncherActivity.java
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,6 +14,7 @@ import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
|
@ -121,7 +122,14 @@ public class SDLActivity extends Activity {
|
||||||
* @return arguments for the native application.
|
* @return arguments for the native application.
|
||||||
*/
|
*/
|
||||||
protected String[] getArguments() {
|
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() {
|
public static void initialize() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue