Xrasher/src/in/celest/xash3d/LauncherActivity.java

108 lines
3.6 KiB
Java
Raw Normal View History

2015-05-26 00:11:50 +06:00
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;
2015-07-24 06:56:03 +06:00
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.content.ComponentName;
import android.content.pm.PackageManager;
import android.content.SharedPreferences;
2015-05-26 00:11:50 +06:00
import in.celest.xash3d.hl.R;
2015-07-24 06:56:03 +06:00
import com.beloko.touchcontrols.TouchControlsSettings;
2015-05-26 00:11:50 +06:00
public class LauncherActivity extends Activity {
2015-07-24 06:56:03 +06:00
// public final static String ARGV = "in.celest.xash3d.MESSAGE";
static TouchControlsSettings mSettings;
static EditText cmdArgs;
static CheckBox useControls;
static EditText resPath;
static CheckBox showIcon;
static SharedPreferences mPref;
2015-05-26 00:11:50 +06:00
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_launcher);
2015-07-24 06:56:03 +06:00
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/"));
showIcon = ( CheckBox ) findViewById( R.id.showIcon );
showIcon.setChecked(mPref.getBoolean("show_icon",true));
// it is broken, so disable it now
showIcon.setEnabled(false);
showIcon.setActivated(false);
/*showIcon.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
ComponentName componentName = new ComponentName("in.celest.xash3d.hl","org.libsdl.app.SDLActivity");
PackageManager p = getPackageManager();
if ( isChecked )
{
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
}
else
{
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
}
}
});
*/
2015-05-26 00:11:50 +06:00
}
public void startXash(View view)
{
2015-06-16 22:45:30 +07:00
Intent intent = new Intent(this, org.libsdl.app.SDLActivity.class);
2015-07-24 06:56:03 +06:00
SharedPreferences.Editor editor = mPref.edit();
editor.putString("argv", cmdArgs.getText().toString());
editor.putBoolean("controls",useControls.isChecked());
editor.putString("basedir", resPath.getText().toString());
editor.putBoolean("show_icon", showIcon.isChecked());
editor.commit();
editor.apply();
2015-05-26 00:11:50 +06:00
startActivity(intent);
}
2015-07-24 06:56:03 +06:00
public void controlsSettings(View view)
{
mSettings.loadSettings(this);
mSettings.showSettings();
}
2015-05-26 00:11:50 +06:00
@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);
}
}