2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-11-23 10:20:08 +01:00

Add firstrun dialog (WIP)

This commit is contained in:
mittorn 2017-10-02 04:14:26 +07:00
parent 2f4f36d407
commit 67a296d304
4 changed files with 116 additions and 3 deletions

View File

@ -89,9 +89,14 @@
android:singleLine="false"
android:id="@+id/textView2"
android:layout_weight="0.58" />
<Button
android:id="@+id/show_firstrun"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/firstrun"/>
<Button
android:id="@+id/button_about_ok"
android:text="Ok"
android:text="@string/ok"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
/>

View File

@ -74,6 +74,10 @@
<string name="resolution_scale">Scale screen keeping aspect ratio</string>
<string name="resolution_custom">Specify custom screen width and height</string>
<string name="resolution_result">Resolution: </string>
<string name="resolution_mod_warn">Use with caution! Some games does not support too low resolution, in case of bugs increase resolution to 640x480 or higher.\n
Resolution lower than 320x240 is not allowed.</string>
<string name="resolution_mod_warn"><img src="https://ya.ru/favicon.ico" /> <br />Use with caution! Some games does not support too low resolution, in case of bugs increase resolution to 640x480 or higher.\n
Resolution lower than 320x240 is not allowed.</string>
<string name="firstrun">Show firstrun dialog</string>
<string name="next">Next</string>
<string name="prev">Prev</string>
<string name="skip">Skip</string>
</resources>

View File

@ -280,6 +280,8 @@ public class LauncherActivity extends Activity {
hideResolutionSettings( !enableResolutionChange );
updateResolutionResult();
toggleResolutionFields();
if( !mPref.getBoolean("successfulRun",false) )
showFirstRun();
}
void updatePath( String text )
@ -394,11 +396,110 @@ public class LauncherActivity extends Activity {
dialog.cancel();
}
});
((Button)dialog.findViewById( R.id.show_firstrun )).setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
dialog.cancel();
showFirstRun();
}
});
}
});
}
int m_iFirstRunCounter;
public void showFirstRun()
{
if(m_iFirstRunCounter < 0)
m_iFirstRunCounter = 0;
final int titleres = getResources().getIdentifier("page_title" + String.valueOf(m_iFirstRunCounter), "string", getPackageName());
final int contentres = getResources().getIdentifier("page_content" + String.valueOf(m_iFirstRunCounter), "string", getPackageName());
final Activity a = this;
if( titleres == 0 || contentres == 0 )
return;
this.runOnUiThread(new Runnable()
{
public void run()
{
TextView content = new TextView(LauncherActivity.this);
content.setText(Html.fromHtml(getResources().getText(contentres).toString(), new Html.ImageGetter(){
@Override
public Drawable getDrawable(String source) {
Drawable drawable;
int dourceId =
getApplicationContext()
.getResources()
.getIdentifier(source, "drawable", getPackageName());
drawable =
getApplicationContext()
.getResources()
.getDrawable(dourceId);
drawable.setBounds(
0,
0,
drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight());
return drawable;
}
}, null));
content.setMovementMethod(LinkMovementMethod.getInstance());
AlertDialog.Builder builder = new AlertDialog.Builder(a)
.setTitle(titleres)
.setView(content);
if( sdk >= 21 )
{
builder.setPositiveButton(R.string.next, new DialogInterface.OnClickListener(){
public void onClick(DialogInterface d, int p1)
{
m_iFirstRunCounter++;
showFirstRun();
}
});
if( m_iFirstRunCounter > 0 )
builder.setNegativeButton(R.string.prev, new DialogInterface.OnClickListener(){
public void onClick(DialogInterface d, int p1)
{
m_iFirstRunCounter--;
showFirstRun();
}
});
builder.setNeutralButton(R.string.skip, null);
}
else
{
builder.setNegativeButton(R.string.next, new DialogInterface.OnClickListener(){
public void onClick(DialogInterface d, int p1)
{
m_iFirstRunCounter++;
showFirstRun();
}
});
if( m_iFirstRunCounter > 0 )
builder.setNeutralButton(R.string.prev, new DialogInterface.OnClickListener(){
public void onClick(DialogInterface d, int p1)
{
m_iFirstRunCounter--;
showFirstRun();
}
});
builder.setPositiveButton(R.string.skip,null);
}
builder.setCancelable(false);
builder.show();
}
});
}
public void selectFolder(View view)
{
Intent intent = new Intent(this, in.celest.xash3d.FPicker.class);

View File

@ -887,6 +887,9 @@ public class XashActivity extends Activity {
public static void setTitle( String title )
{
Log.v( TAG, "setTitle(" + title + ")" );
SharedPreferences.Editor editor = mPref.edit();
editor.putBoolean("successfulRun", true);
editor.commit();
if( sdk < 5 )
return;