2019-11-28 23:06:56 +03:00
|
|
|
package su.xash.engine;
|
2015-05-26 00:11:50 +06:00
|
|
|
|
2017-07-23 04:01:21 +07:00
|
|
|
import android.app.*;
|
|
|
|
import android.content.*;
|
2019-11-29 19:42:48 +03:00
|
|
|
import android.content.pm.*;
|
2017-07-23 04:01:21 +07:00
|
|
|
import android.graphics.*;
|
|
|
|
import android.graphics.drawable.*;
|
|
|
|
import android.net.*;
|
|
|
|
import android.os.*;
|
|
|
|
import android.text.*;
|
|
|
|
import android.text.method.*;
|
|
|
|
import android.text.style.*;
|
|
|
|
import android.util.*;
|
|
|
|
import android.view.*;
|
|
|
|
import android.widget.*;
|
2019-11-28 23:06:56 +03:00
|
|
|
import su.xash.engine.*;
|
2017-07-23 04:01:21 +07:00
|
|
|
import java.io.*;
|
|
|
|
import java.net.*;
|
2016-05-20 23:46:35 +03:00
|
|
|
import org.json.*;
|
2017-09-24 06:26:51 +07:00
|
|
|
import android.preference.*;
|
2017-09-30 02:29:55 +03:00
|
|
|
import su.xash.fwgslib.*;
|
2019-11-29 19:42:48 +03:00
|
|
|
import android.Manifest;
|
|
|
|
|
2015-05-26 00:11:50 +06:00
|
|
|
|
2018-03-21 02:18:25 +03:00
|
|
|
public class LauncherActivity extends Activity
|
|
|
|
{
|
2019-11-28 23:06:56 +03:00
|
|
|
// public final static String ARGV = "su.xash.engine.MESSAGE";
|
2018-03-21 02:18:25 +03:00
|
|
|
public final static int sdk = FWGSLib.sdk;
|
2019-11-28 23:06:56 +03:00
|
|
|
public final static String UPDATE_LINK = "https://api.github.com/repos/FWGS/xash3d-fwgs/releases"; // releases/latest doesn't return prerelease and drafts
|
2015-07-24 06:56:03 +06:00
|
|
|
static SharedPreferences mPref;
|
2018-03-21 02:18:25 +03:00
|
|
|
|
|
|
|
static EditText cmdArgs, resPath, writePath, resScale, resWidth, resHeight;
|
|
|
|
static ToggleButton useVolume, resizeWorkaround, useRoDir;
|
|
|
|
static CheckBox checkUpdates, immersiveMode, useRoDirAuto;
|
|
|
|
static TextView tvResPath, resResult;
|
2017-09-24 06:26:51 +07:00
|
|
|
static RadioButton radioScale, radioCustom;
|
2017-09-30 02:29:55 +03:00
|
|
|
static RadioGroup scaleGroup;
|
2017-09-24 06:26:51 +07:00
|
|
|
static CheckBox resolution;
|
2018-03-21 02:18:25 +03:00
|
|
|
static Spinner pixelSpinner;
|
|
|
|
static LinearLayout rodirSettings; // to easy show/hide
|
2017-09-28 23:33:13 +03:00
|
|
|
|
2017-09-30 02:29:55 +03:00
|
|
|
static int mEngineWidth, mEngineHeight;
|
2019-11-29 19:42:48 +03:00
|
|
|
final static int REQUEST_PERMISSIONS = 42;
|
2018-04-05 22:08:11 +07:00
|
|
|
|
2019-11-29 19:42:48 +03:00
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState)
|
|
|
|
{
|
2016-05-20 23:46:35 +03:00
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
|
|
|
//super.setTheme( 0x01030005 );
|
|
|
|
if ( sdk >= 21 )
|
2016-07-26 17:07:01 +06:00
|
|
|
super.setTheme( 0x01030224 );
|
2016-09-13 21:06:41 +03:00
|
|
|
else super.setTheme( 0x01030005 );
|
2018-03-21 02:18:25 +03:00
|
|
|
|
2018-04-05 22:08:11 +07:00
|
|
|
if( sdk >= 8 && CertCheck.dumbAntiPDALifeCheck( this ) )
|
2016-08-13 00:12:19 +06:00
|
|
|
{
|
|
|
|
finish();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-05-20 23:46:35 +03:00
|
|
|
setContentView(R.layout.activity_launcher);
|
2020-07-07 07:28:43 +07:00
|
|
|
|
2020-07-08 01:03:18 +07:00
|
|
|
/* if( sdk > 17 )
|
2020-07-07 07:28:43 +07:00
|
|
|
{
|
|
|
|
ImageView icon = (ImageView) findViewById(R.id.launcherIcon);
|
|
|
|
icon.setImageDrawable(getResources().getDrawable(R.mipmap.ic_launcher));
|
|
|
|
}
|
2020-07-08 01:03:18 +07:00
|
|
|
*/
|
2016-05-20 23:46:35 +03:00
|
|
|
TabHost tabHost = (TabHost) findViewById(R.id.tabhost);
|
2017-07-23 04:01:21 +07:00
|
|
|
|
2016-05-20 23:46:35 +03:00
|
|
|
tabHost.setup();
|
|
|
|
|
|
|
|
TabHost.TabSpec tabSpec;
|
|
|
|
tabSpec = tabHost.newTabSpec("tabtag1");
|
|
|
|
tabSpec.setIndicator(getString(R.string.text_tab1));
|
|
|
|
tabSpec.setContent(R.id.tab1);
|
|
|
|
tabHost.addTab(tabSpec);
|
|
|
|
|
|
|
|
tabSpec = tabHost.newTabSpec("tabtag2");
|
|
|
|
tabSpec.setIndicator(getString(R.string.text_tab2));
|
|
|
|
tabSpec.setContent(R.id.tab2);
|
|
|
|
tabHost.addTab(tabSpec);
|
2017-07-23 04:01:21 +07:00
|
|
|
if( sdk < 21 )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
tabHost.invalidate();
|
|
|
|
for(int i = 0; i < tabHost.getTabWidget().getChildCount(); i++)
|
|
|
|
{
|
2018-03-21 02:18:25 +03:00
|
|
|
tabHost.getTabWidget().getChildAt(i).getBackground().setAlpha(255);
|
|
|
|
tabHost.getTabWidget().getChildAt(i).getLayoutParams().height = (int) (40 * getResources().getDisplayMetrics().density);
|
2017-07-23 04:01:21 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception e){}
|
|
|
|
}
|
|
|
|
|
2016-05-20 23:46:35 +03:00
|
|
|
|
2016-07-26 17:54:29 +06:00
|
|
|
mPref = getSharedPreferences("engine", 0);
|
2016-08-05 19:17:03 +06:00
|
|
|
cmdArgs = (EditText) findViewById(R.id.cmdArgs);
|
2016-07-26 17:54:29 +06:00
|
|
|
useVolume = (ToggleButton) findViewById( R.id.useVolume );
|
2018-03-21 02:18:25 +03:00
|
|
|
resPath = (EditText) findViewById( R.id.cmd_path );
|
2016-08-05 19:17:03 +06:00
|
|
|
checkUpdates = (CheckBox)findViewById( R.id.check_updates );
|
2018-03-01 21:50:13 +03:00
|
|
|
//updateToBeta = (CheckBox)findViewById( R.id.check_betas );
|
2016-08-05 19:17:03 +06:00
|
|
|
pixelSpinner = (Spinner) findViewById( R.id.pixelSpinner );
|
2016-07-26 17:07:01 +06:00
|
|
|
resizeWorkaround = (ToggleButton) findViewById( R.id.enableResizeWorkaround );
|
2016-07-26 17:54:29 +06:00
|
|
|
tvResPath = (TextView) findViewById( R.id.textView_path );
|
2016-08-05 19:17:03 +06:00
|
|
|
immersiveMode = (CheckBox) findViewById( R.id.immersive_mode );
|
2017-09-24 06:26:51 +07:00
|
|
|
resolution = (CheckBox) findViewById(R.id.resolution);
|
|
|
|
resWidth = (EditText) findViewById(R.id.resolution_width);
|
|
|
|
resHeight = (EditText) findViewById(R.id.resolution_height);
|
|
|
|
resScale = (EditText) findViewById(R.id.resolution_scale);
|
|
|
|
radioCustom = (RadioButton) findViewById(R.id.resolution_custom_r);
|
|
|
|
radioScale = (RadioButton) findViewById(R.id.resolution_scale_r);
|
2017-09-30 02:29:55 +03:00
|
|
|
scaleGroup = (RadioGroup) findViewById( R.id.scale_group );
|
|
|
|
resResult = (TextView) findViewById( R.id.resolution_result );
|
2018-03-21 02:18:25 +03:00
|
|
|
writePath = (EditText) findViewById( R.id.cmd_path_rw );
|
|
|
|
useRoDir = (ToggleButton) findViewById( R.id.use_rodir );
|
|
|
|
useRoDirAuto = (CheckBox) findViewById( R.id.use_rodir_auto );
|
|
|
|
rodirSettings = (LinearLayout) findViewById( R.id.rodir_settings );
|
2016-07-26 17:54:29 +06:00
|
|
|
|
2016-05-20 23:46:35 +03:00
|
|
|
final String[] list = {
|
2016-07-26 17:54:29 +06:00
|
|
|
"32 bit (RGBA8888)",
|
|
|
|
"16 bit (RGB565)",
|
|
|
|
"8 bit (RGB332)"
|
2016-05-20 23:46:35 +03:00
|
|
|
};
|
2017-09-30 02:29:55 +03:00
|
|
|
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item, list);
|
|
|
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
2016-05-20 23:46:35 +03:00
|
|
|
pixelSpinner.setAdapter(adapter);
|
2016-08-05 17:43:46 +00:00
|
|
|
Button selectFolderButton = ( Button ) findViewById( R.id.button_select );
|
2017-09-30 02:29:55 +03:00
|
|
|
selectFolderButton.setOnClickListener(new View.OnClickListener()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void onClick(View v)
|
|
|
|
{
|
|
|
|
selectFolder(v);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
((Button)findViewById( R.id.button_launch )).setOnClickListener(new View.OnClickListener()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void onClick(View v)
|
|
|
|
{
|
|
|
|
startXash(v);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
((Button)findViewById( R.id.button_shortcut )).setOnClickListener(new View.OnClickListener()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void onClick(View v)
|
|
|
|
{
|
|
|
|
createShortcut(v);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
((Button)findViewById( R.id.button_about )).setOnClickListener(new View.OnClickListener()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void onClick(View v)
|
|
|
|
{
|
|
|
|
aboutXash(v);
|
|
|
|
}
|
|
|
|
});
|
2016-05-20 23:46:35 +03:00
|
|
|
useVolume.setChecked(mPref.getBoolean("usevolume",true));
|
|
|
|
checkUpdates.setChecked(mPref.getBoolean("check_updates",true));
|
2018-03-01 21:50:13 +03:00
|
|
|
//updateToBeta.setChecked(mPref.getBoolean("check_betas", false));
|
2017-09-30 02:29:55 +03:00
|
|
|
updatePath(mPref.getString("basedir", FWGSLib.getDefaultXashPath() ) );
|
2016-05-20 23:46:35 +03:00
|
|
|
cmdArgs.setText(mPref.getString("argv","-dev 3 -log"));
|
|
|
|
pixelSpinner.setSelection(mPref.getInt("pixelformat", 0));
|
2016-07-26 17:54:29 +06:00
|
|
|
resizeWorkaround.setChecked(mPref.getBoolean("enableResizeWorkaround", true));
|
2018-03-21 02:18:25 +03:00
|
|
|
useRoDir.setChecked( mPref.getBoolean("use_rodir", false) );
|
|
|
|
useRoDirAuto.setChecked( mPref.getBoolean("use_rodir_auto", true) );
|
|
|
|
writePath.setText(mPref.getString("writedir", FWGSLib.getExternalFilesDir(this)));
|
|
|
|
resolution.setChecked( mPref.getBoolean("resolution_fixed", false ) );
|
2017-09-28 23:33:13 +03:00
|
|
|
|
|
|
|
DisplayMetrics metrics = new DisplayMetrics();
|
|
|
|
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
|
|
|
|
2017-09-30 02:29:55 +03:00
|
|
|
// Swap resolution here, because engine is always(should be always) run in landscape mode
|
|
|
|
if( FWGSLib.isLandscapeOrientation( this ) )
|
|
|
|
{
|
|
|
|
mEngineWidth = metrics.widthPixels;
|
|
|
|
mEngineHeight = metrics.heightPixels;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mEngineWidth = metrics.heightPixels;
|
|
|
|
mEngineHeight = metrics.widthPixels;
|
|
|
|
}
|
|
|
|
|
|
|
|
resWidth.setText(String.valueOf(mPref.getInt("resolution_width", mEngineWidth )));
|
|
|
|
resHeight.setText(String.valueOf(mPref.getInt("resolution_height", mEngineHeight )));
|
|
|
|
resScale.setText(String.valueOf(mPref.getFloat("resolution_scale", 2.0f)));
|
|
|
|
|
2018-05-12 02:56:17 +07:00
|
|
|
resWidth.addTextChangedListener( resWidthTextChangeWatcher );
|
2017-09-30 02:29:55 +03:00
|
|
|
resHeight.addTextChangedListener( resTextChangeWatcher );
|
|
|
|
resScale.addTextChangedListener( resTextChangeWatcher );
|
|
|
|
|
2017-09-24 06:26:51 +07:00
|
|
|
if( mPref.getBoolean("resolution_custom", false) )
|
|
|
|
radioCustom.setChecked(true);
|
|
|
|
else radioScale.setChecked(true);
|
2017-09-30 02:29:55 +03:00
|
|
|
|
|
|
|
radioCustom.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged( CompoundButton v, boolean isChecked )
|
|
|
|
{
|
|
|
|
updateResolutionResult();
|
|
|
|
toggleResolutionFields();
|
|
|
|
}
|
|
|
|
} );
|
2017-09-28 23:33:13 +03:00
|
|
|
resolution.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged( CompoundButton v, boolean isChecked )
|
|
|
|
{
|
|
|
|
hideResolutionSettings( !isChecked );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-03-21 02:18:25 +03:00
|
|
|
useRoDir.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged( CompoundButton v, boolean isChecked )
|
|
|
|
{
|
2018-03-21 17:54:45 +03:00
|
|
|
hideRodirSettings( !isChecked );
|
2018-03-21 02:18:25 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-08-05 19:17:03 +06:00
|
|
|
if( sdk >= 19 )
|
|
|
|
{
|
|
|
|
immersiveMode.setChecked(mPref.getBoolean("immersive_mode", true));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
immersiveMode.setVisibility(View.GONE); // not available
|
|
|
|
}
|
2018-03-21 02:18:25 +03:00
|
|
|
|
2016-07-26 17:54:29 +06:00
|
|
|
resPath.setOnFocusChangeListener( new View.OnFocusChangeListener()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void onFocusChange(View v, boolean hasFocus)
|
|
|
|
{
|
|
|
|
updatePath( resPath.getText().toString() );
|
2017-09-28 23:33:13 +03:00
|
|
|
|
|
|
|
// I know what I am doing, so don't ask me about folder!
|
|
|
|
XashActivity.setFolderAsk( LauncherActivity.this, false );
|
2016-07-26 17:54:29 +06:00
|
|
|
}
|
|
|
|
} );
|
2018-03-21 02:18:25 +03:00
|
|
|
|
|
|
|
useRoDirAuto.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged( CompoundButton b, boolean isChecked )
|
|
|
|
{
|
|
|
|
if( isChecked )
|
|
|
|
{
|
|
|
|
writePath.setText( FWGSLib.getExternalFilesDir( LauncherActivity.this ) );
|
|
|
|
}
|
|
|
|
writePath.setEnabled( !isChecked );
|
|
|
|
}
|
|
|
|
});
|
2016-05-20 23:46:35 +03:00
|
|
|
|
2018-03-21 02:18:25 +03:00
|
|
|
// disable autoupdater for Google Play
|
|
|
|
if( !XashConfig.GP_VERSION && mPref.getBoolean("check_updates", true))
|
2016-05-31 12:23:09 +00:00
|
|
|
{
|
2018-05-12 02:56:17 +07:00
|
|
|
new CheckUpdate(getBaseContext(),true, false).execute(UPDATE_LINK);
|
2016-05-31 12:23:09 +00:00
|
|
|
}
|
2018-04-05 22:08:11 +07:00
|
|
|
FWGSLib.changeButtonsStyle((ViewGroup)tabHost.getParent());
|
2018-03-21 02:18:25 +03:00
|
|
|
hideResolutionSettings( !resolution.isChecked() );
|
2018-03-21 17:54:45 +03:00
|
|
|
hideRodirSettings( !useRoDir.isChecked() );
|
2017-09-30 02:29:55 +03:00
|
|
|
updateResolutionResult();
|
|
|
|
toggleResolutionFields();
|
2020-07-07 07:28:43 +07:00
|
|
|
FWGSLib.cmp.applyPermissions( this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, REQUEST_PERMISSIONS );
|
2017-10-02 04:14:26 +07:00
|
|
|
if( !mPref.getBoolean("successfulRun",false) )
|
|
|
|
showFirstRun();
|
2015-11-08 01:09:57 +06:00
|
|
|
}
|
2019-11-29 19:42:48 +03:00
|
|
|
|
|
|
|
public void onRequestPermissionsResult( int requestCode, String[] permissions, int[] grantResults )
|
|
|
|
{
|
|
|
|
if( requestCode == REQUEST_PERMISSIONS )
|
|
|
|
{
|
|
|
|
if( grantResults[0] == PackageManager.PERMISSION_DENIED )
|
|
|
|
{
|
|
|
|
Toast.makeText( this, R.string.no_permissions, Toast.LENGTH_LONG ).show();
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// open again?
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-21 17:54:45 +03:00
|
|
|
@Override
|
|
|
|
public void onResume()
|
|
|
|
{
|
|
|
|
super.onResume();
|
|
|
|
|
|
|
|
useRoDir.setChecked( mPref.getBoolean("use_rodir", false) );
|
|
|
|
useRoDirAuto.setChecked( mPref.getBoolean("use_rodir_auto", true) );
|
|
|
|
writePath.setText(mPref.getString("writedir", FWGSLib.getExternalFilesDir(this)));
|
|
|
|
|
|
|
|
hideRodirSettings( !useRoDir.isChecked() );
|
|
|
|
}
|
2016-05-06 08:58:01 +00:00
|
|
|
|
2016-05-31 12:23:09 +00:00
|
|
|
void updatePath( String text )
|
|
|
|
{
|
2017-09-30 02:29:55 +03:00
|
|
|
tvResPath.setText(getString(R.string.text_res_path) + ":\n" + text );
|
2016-05-31 12:23:09 +00:00
|
|
|
resPath.setText(text);
|
2017-09-28 23:33:13 +03:00
|
|
|
}
|
2016-05-31 12:23:09 +00:00
|
|
|
|
2017-09-28 23:33:13 +03:00
|
|
|
void hideResolutionSettings( boolean hide )
|
|
|
|
{
|
2017-09-30 02:29:55 +03:00
|
|
|
scaleGroup.setVisibility( hide ? View.GONE : View.VISIBLE );
|
|
|
|
}
|
2018-03-21 02:18:25 +03:00
|
|
|
|
2018-03-21 17:54:45 +03:00
|
|
|
void hideRodirSettings( boolean hide )
|
2018-03-21 02:18:25 +03:00
|
|
|
{
|
2018-03-21 17:54:45 +03:00
|
|
|
rodirSettings.setVisibility( hide ? View.GONE : View.VISIBLE );
|
2018-03-21 02:18:25 +03:00
|
|
|
}
|
2017-09-30 02:29:55 +03:00
|
|
|
|
2018-05-12 02:56:17 +07:00
|
|
|
TextWatcher resWidthTextChangeWatcher = new TextWatcher()
|
2017-09-30 02:29:55 +03:00
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void afterTextChanged(Editable s){}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after){}
|
|
|
|
|
2018-05-12 02:56:17 +07:00
|
|
|
@Override
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count)
|
|
|
|
{
|
|
|
|
int h = (int)((float)mEngineHeight / mEngineWidth * getCustomEngineWidth());
|
|
|
|
resHeight.setText(String.valueOf(h));
|
|
|
|
updateResolutionResult();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TextWatcher resTextChangeWatcher = new TextWatcher()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void afterTextChanged(Editable s){}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after){}
|
|
|
|
|
2017-09-30 02:29:55 +03:00
|
|
|
@Override
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count)
|
2017-09-28 23:33:13 +03:00
|
|
|
{
|
2017-09-30 02:29:55 +03:00
|
|
|
updateResolutionResult();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void updateResolutionResult( )
|
|
|
|
{
|
|
|
|
int w, h;
|
|
|
|
if( radioCustom.isChecked() )
|
|
|
|
{
|
|
|
|
w = getCustomEngineWidth();
|
|
|
|
h = getCustomEngineHeight();
|
2018-05-12 02:56:17 +07:00
|
|
|
|
|
|
|
// some fool-proof
|
|
|
|
if( Math.abs((float)w/(float)h - 4.0/3.0) < 0.001 )
|
|
|
|
{
|
|
|
|
w = (int)((float)mEngineWidth / mEngineHeight * h+0.5);
|
|
|
|
resWidth.setText(String.valueOf(w));
|
|
|
|
}
|
2017-09-28 23:33:13 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-30 02:29:55 +03:00
|
|
|
final float scale = getResolutionScale();
|
|
|
|
w = (int)((float)mEngineWidth / scale);
|
|
|
|
h = (int)((float)mEngineHeight / scale);
|
2017-09-28 23:33:13 +03:00
|
|
|
}
|
2017-09-30 02:29:55 +03:00
|
|
|
|
|
|
|
resResult.setText( getString( R.string.resolution_result ) + w + "x" + h );
|
|
|
|
}
|
|
|
|
|
|
|
|
void toggleResolutionFields()
|
|
|
|
{
|
|
|
|
boolean isChecked = radioCustom.isChecked();
|
|
|
|
resWidth.setEnabled( isChecked );
|
|
|
|
resHeight.setEnabled( isChecked );
|
|
|
|
resScale.setEnabled( !isChecked );
|
|
|
|
}
|
|
|
|
|
|
|
|
float getResolutionScale()
|
|
|
|
{
|
|
|
|
return FWGSLib.atof( resScale.getText().toString(), 1.0f );
|
|
|
|
}
|
|
|
|
|
|
|
|
int getCustomEngineHeight()
|
|
|
|
{
|
|
|
|
return FWGSLib.atoi( resHeight.getText().toString(), mEngineHeight );
|
|
|
|
}
|
|
|
|
|
|
|
|
int getCustomEngineWidth()
|
|
|
|
{
|
|
|
|
return FWGSLib.atoi( resWidth.getText().toString(), mEngineWidth );
|
2016-05-31 12:23:09 +00:00
|
|
|
}
|
2017-09-28 23:33:13 +03:00
|
|
|
|
2015-05-26 00:11:50 +06:00
|
|
|
public void startXash(View view)
|
|
|
|
{
|
2016-05-20 23:46:35 +03:00
|
|
|
Intent intent = new Intent(this, XashActivity.class);
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
|
|
|
|
SharedPreferences.Editor editor = mPref.edit();
|
|
|
|
editor.putString("argv", cmdArgs.getText().toString());
|
|
|
|
editor.putBoolean("usevolume",useVolume.isChecked());
|
2018-03-21 02:18:25 +03:00
|
|
|
editor.putBoolean("use_rodir", useRoDir.isChecked() );
|
|
|
|
editor.putBoolean("use_rodir_auto", useRoDirAuto.isChecked() );
|
|
|
|
editor.putString("writedir", writePath.getText().toString());
|
2016-05-20 23:46:35 +03:00
|
|
|
editor.putString("basedir", resPath.getText().toString());
|
|
|
|
editor.putInt("pixelformat", pixelSpinner.getSelectedItemPosition());
|
2016-07-26 17:07:01 +06:00
|
|
|
editor.putBoolean("enableResizeWorkaround",resizeWorkaround.isChecked());
|
2016-05-20 23:46:35 +03:00
|
|
|
editor.putBoolean("check_updates", checkUpdates.isChecked());
|
2017-09-24 06:26:51 +07:00
|
|
|
editor.putBoolean("resolution_fixed", resolution.isChecked());
|
|
|
|
editor.putBoolean("resolution_custom", radioCustom.isChecked());
|
2017-09-30 02:29:55 +03:00
|
|
|
editor.putFloat("resolution_scale", getResolutionScale() );
|
|
|
|
editor.putInt("resolution_width", getCustomEngineWidth() );
|
|
|
|
editor.putInt("resolution_height", getCustomEngineHeight() );
|
2017-09-24 06:26:51 +07:00
|
|
|
|
2016-08-05 19:17:03 +06:00
|
|
|
if( sdk >= 19 )
|
|
|
|
editor.putBoolean("immersive_mode", immersiveMode.isChecked());
|
|
|
|
else
|
|
|
|
editor.putBoolean("immersive_mode", false); // just in case...
|
2016-05-20 23:46:35 +03:00
|
|
|
editor.commit();
|
|
|
|
startActivity(intent);
|
2015-05-26 00:11:50 +06:00
|
|
|
}
|
|
|
|
|
2015-08-16 22:52:54 +06:00
|
|
|
public void aboutXash(View view)
|
|
|
|
{
|
|
|
|
final Activity a = this;
|
2016-05-20 23:46:35 +03:00
|
|
|
this.runOnUiThread(new Runnable()
|
|
|
|
{
|
2015-08-16 22:52:54 +06:00
|
|
|
public void run()
|
|
|
|
{
|
|
|
|
final Dialog dialog = new Dialog(a);
|
|
|
|
dialog.setContentView(R.layout.about);
|
|
|
|
dialog.setCancelable(true);
|
|
|
|
dialog.show();
|
2020-07-08 01:03:18 +07:00
|
|
|
/* if( sdk > 17 )
|
2020-07-07 07:28:43 +07:00
|
|
|
{
|
|
|
|
ImageView icon = (ImageView) dialog.findViewById(R.id.aboutIcon);
|
|
|
|
icon.setImageDrawable(getResources().getDrawable(R.mipmap.ic_launcher));
|
|
|
|
}
|
2020-07-08 01:03:18 +07:00
|
|
|
*/
|
2016-05-13 22:49:45 +02:00
|
|
|
TextView tView6 = (TextView) dialog.findViewById(R.id.textView6);
|
|
|
|
tView6.setMovementMethod(LinkMovementMethod.getInstance());
|
2017-08-08 13:27:53 +07:00
|
|
|
((Button)dialog.findViewById( R.id.button_about_ok )).setOnClickListener(new View.OnClickListener(){
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
dialog.cancel();
|
|
|
|
}
|
|
|
|
});
|
2017-10-02 04:14:26 +07:00
|
|
|
((Button)dialog.findViewById( R.id.show_firstrun )).setOnClickListener(new View.OnClickListener(){
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
dialog.cancel();
|
2018-01-30 23:19:07 +03:00
|
|
|
Intent intent = new Intent(a, XashTutorialActivity.class);
|
|
|
|
startActivity(intent);
|
2017-10-02 04:14:26 +07:00
|
|
|
}
|
|
|
|
});
|
2018-04-05 22:08:11 +07:00
|
|
|
FWGSLib.changeButtonsStyle((ViewGroup)dialog.findViewById( R.id.show_firstrun ).getParent());
|
2017-08-08 13:27:53 +07:00
|
|
|
|
2015-08-16 22:52:54 +06:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2015-11-08 01:09:57 +06:00
|
|
|
|
2018-01-30 21:37:15 +03:00
|
|
|
int m_iFirstRunCounter = 0;
|
2017-10-02 04:14:26 +07:00
|
|
|
public void showFirstRun()
|
|
|
|
{
|
2019-11-28 23:06:56 +03:00
|
|
|
startActivity(new Intent(this, su.xash.engine.XashTutorialActivity.class));
|
2017-10-02 04:14:26 +07:00
|
|
|
}
|
|
|
|
|
2018-05-12 03:02:37 +07:00
|
|
|
public static final int ID_SELECT_FOLDER = 42, ID_SELECT_RW_FOLDER = 43;
|
|
|
|
|
2015-11-08 01:09:57 +06:00
|
|
|
public void selectFolder(View view)
|
|
|
|
{
|
2019-11-28 23:06:56 +03:00
|
|
|
Intent intent = new Intent(this, su.xash.engine.FPicker.class);
|
2018-05-12 03:02:37 +07:00
|
|
|
startActivityForResult(intent, ID_SELECT_FOLDER);
|
2015-11-08 01:09:57 +06:00
|
|
|
resPath.setEnabled(false);
|
2017-09-28 23:33:13 +03:00
|
|
|
XashActivity.setFolderAsk( this, false );
|
2015-11-08 01:09:57 +06:00
|
|
|
}
|
2018-03-21 02:18:25 +03:00
|
|
|
|
|
|
|
public void selectRwFolder(View view)
|
|
|
|
{
|
2019-11-28 23:06:56 +03:00
|
|
|
Intent intent = new Intent(this, su.xash.engine.FPicker.class);
|
2018-05-12 03:02:37 +07:00
|
|
|
startActivityForResult(intent, ID_SELECT_RW_FOLDER);
|
2018-03-21 02:18:25 +03:00
|
|
|
writePath.setEnabled(false);
|
|
|
|
XashActivity.setFolderAsk( this, false );
|
|
|
|
}
|
|
|
|
|
2015-11-08 01:09:57 +06:00
|
|
|
|
2016-05-20 23:46:35 +03:00
|
|
|
public void onActivityResult(int requestCode, int resultCode, Intent resultData)
|
|
|
|
{
|
2018-03-21 02:18:25 +03:00
|
|
|
switch(requestCode)
|
|
|
|
{
|
2018-05-12 03:02:37 +07:00
|
|
|
case ID_SELECT_FOLDER:
|
2015-11-08 01:09:57 +06:00
|
|
|
{
|
2018-03-21 02:18:25 +03:00
|
|
|
if (resultCode == RESULT_OK)
|
2016-05-20 23:46:35 +03:00
|
|
|
{
|
2018-03-21 02:18:25 +03:00
|
|
|
try
|
|
|
|
{
|
|
|
|
if( resPath == null )
|
|
|
|
return;
|
|
|
|
updatePath(resultData.getStringExtra("GetPath"));
|
|
|
|
resPath.setEnabled( true );
|
|
|
|
}
|
|
|
|
catch(Exception e)
|
|
|
|
{
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2016-05-20 23:46:35 +03:00
|
|
|
}
|
2018-03-21 02:18:25 +03:00
|
|
|
resPath.setEnabled(true);
|
|
|
|
break;
|
|
|
|
}
|
2018-05-12 03:02:37 +07:00
|
|
|
case ID_SELECT_RW_FOLDER:
|
2018-03-21 02:18:25 +03:00
|
|
|
{
|
|
|
|
if (resultCode == RESULT_OK)
|
2016-05-20 23:46:35 +03:00
|
|
|
{
|
2018-03-21 02:18:25 +03:00
|
|
|
try
|
|
|
|
{
|
|
|
|
if( writePath == null )
|
|
|
|
return;
|
|
|
|
writePath.setText(resultData.getStringExtra("GetPath"));
|
|
|
|
writePath.setEnabled( true );
|
|
|
|
}
|
|
|
|
catch(Exception e)
|
|
|
|
{
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2016-05-20 23:46:35 +03:00
|
|
|
}
|
2018-03-21 02:18:25 +03:00
|
|
|
writePath.setEnabled(true);
|
|
|
|
break;
|
|
|
|
}
|
2015-11-08 01:09:57 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-04 20:55:37 +07:00
|
|
|
public void createShortcut(View view)
|
|
|
|
{
|
|
|
|
Intent intent = new Intent(this, ShortcutActivity.class);
|
2015-12-20 18:52:09 +06:00
|
|
|
intent.putExtra( "basedir", resPath.getText().toString() );
|
2019-11-28 23:06:56 +03:00
|
|
|
intent.putExtra( "name", "Xash3D FWGS" );
|
2015-12-20 18:52:09 +06:00
|
|
|
intent.putExtra( "argv", cmdArgs.getText().toString() );
|
2015-09-04 20:55:37 +07:00
|
|
|
startActivity(intent);
|
|
|
|
}
|
2015-08-16 22:52:54 +06:00
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|