From 124bedcc59c1219ceeda51ef77de2eca3b952e31 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 30 Jan 2018 21:37:15 +0300 Subject: [PATCH] Fix tutorial pages --- res/values/pages.xml | 6 +- src/in/celest/xash3d/LauncherActivity.java | 136 ++++++++++----------- 2 files changed, 66 insertions(+), 76 deletions(-) diff --git a/res/values/pages.xml b/res/values/pages.xml index 15949767..e74f0244 100644 --- a/res/values/pages.xml +++ b/res/values/pages.xml @@ -1,13 +1,13 @@ Welcome! - Welcome to Xash3D FWGS! Before continue, we recommend you to read our installation guide. Press "Next" to continue. Press "Skip" to close this dialog, if you already have installed the game data files.]]> +
Welcome to Xash3D FWGS! Before continue, we recommend you to read our installation guide. Press "Next" to continue. Press "Skip" to close this dialog, if you already have installed the game data files.]]>
Purchase Half-Life in Steam - To play, you need to have Half-Life on your Steam account. Install Steam client on your PC. Purchase the game, if you still not. Press "Install" button. Wait until download finishes.]]> +
To play, you need to have Half-Life on your Steam account. Install Steam client on your PC. Purchase the game, if you still not. Press "Install" button. Wait until download finishes.]]>
Get game files directory - Open game properties in Steam, move to "Local Files" tab and press "Browse local files..." button. File manager window will appear.]]> +
Open game properties in Steam, move to "Local Files" tab and press "Browse local files..." button. File manager window will appear.]]>
Copy game files to device diff --git a/src/in/celest/xash3d/LauncherActivity.java b/src/in/celest/xash3d/LauncherActivity.java index 100dae3f..ea62c3c5 100644 --- a/src/in/celest/xash3d/LauncherActivity.java +++ b/src/in/celest/xash3d/LauncherActivity.java @@ -408,96 +408,86 @@ public class LauncherActivity extends Activity { }); } - int m_iFirstRunCounter; + int m_iFirstRunCounter = 0; public void showFirstRun() { - if(m_iFirstRunCounter < 0) + 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() { - 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) + final TextView content = new TextView(LauncherActivity.this); + content.setMovementMethod(LinkMovementMethod.getInstance()); + AlertDialog.Builder builder = new AlertDialog.Builder(a) .setTitle(titleres) .setView(content); - if( sdk >= 21 ) + DialogInterface.OnClickListener nextClick = new DialogInterface.OnClickListener() + { + public void onClick(DialogInterface d, int p1) { - 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); + m_iFirstRunCounter++; + showFirstRun(); } - else + }; + DialogInterface.OnClickListener prevClick = new DialogInterface.OnClickListener() + { + public void onClick(DialogInterface d, int p1) { - 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); + m_iFirstRunCounter--; + showFirstRun(); } - - builder.setCancelable(false); - builder.show(); - - + }; + + if( sdk >= 21 ) + { + builder.setPositiveButton(R.string.next, nextClick); + if( m_iFirstRunCounter > 0 ) + { + builder.setNegativeButton(R.string.prev, prevClick); + } + builder.setNeutralButton(R.string.skip, null); } - }); + else + { + builder.setNegativeButton(R.string.next, nextClick); + if( m_iFirstRunCounter > 0 ) + { + builder.setNeutralButton(R.string.prev, prevClick); + } + builder.setPositiveButton(R.string.skip, null); + } + builder.setCancelable(false); + final AlertDialog dialog = builder.create(); + dialog.show(); + content.setText(Html.fromHtml(getResources().getText(contentres).toString(), + new Html.ImageGetter() + { + @Override + public Drawable getDrawable(String source) + { + int dourceId = getApplicationContext().getResources().getIdentifier(source, "drawable", getPackageName()); + Drawable drawable = getApplicationContext().getResources().getDrawable(dourceId); + final int visibleWidth = dialog.getWindow().getDecorView().getWidth(); + final int picWidth = drawable.getIntrinsicWidth(); + final int picHeight = drawable.getIntrinsicHeight(); + + final int calcWidth = visibleWidth < picWidth ? visibleWidth : picWidth; + // final int calcHeight = (int)((float)picHeight * ((float)calcWidth / (float)picWidth)); + final int calcHeight = (int)((float)picHeight); + + drawable.setBounds( 0, 0, calcWidth, calcHeight); + return drawable; + } + }, null)); + } + }); } public void selectFolder(View view)