Added progress bars
Fixed PX increment not saved
This commit is contained in:
parent
8a781561e3
commit
7a20121c10
2 changed files with 112 additions and 16 deletions
|
@ -5,6 +5,7 @@ import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
|
@ -15,6 +16,7 @@ import android.view.View;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
@ -31,6 +33,12 @@ public class MainActivity extends ActionBarActivity{
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
((ProgressBar) findViewById(R.id.xpBar))
|
||||||
|
.getProgressDrawable()
|
||||||
|
.setColorFilter(Color.parseColor("#62BACE"), PorterDuff.Mode.SRC_IN);
|
||||||
|
((ProgressBar) findViewById(R.id.curativeEffortsBar))
|
||||||
|
.getProgressDrawable()
|
||||||
|
.setColorFilter(Color.parseColor("#FFD700"), PorterDuff.Mode.SRC_IN);
|
||||||
undo = false;
|
undo = false;
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
|
@ -120,11 +128,23 @@ public class MainActivity extends ActionBarActivity{
|
||||||
//TODO: update defenses
|
//TODO: update defenses
|
||||||
//TODO: add attack points when necessary
|
//TODO: add attack points when necessary
|
||||||
//TODO: update currentPg button
|
//TODO: update currentPg button
|
||||||
|
//TODO: improve leveling up
|
||||||
player.setMaxPgOnLevelUp();
|
player.setMaxPgOnLevelUp();
|
||||||
((TextView) findViewById(R.id.lvl)).setText(
|
((TextView) findViewById(R.id.lvl)).setText(
|
||||||
String.valueOf(player.getLevel())
|
String.valueOf(player.getLevel())
|
||||||
);
|
);
|
||||||
|
((ProgressBar) findViewById(R.id.xpBar))
|
||||||
|
.setMax(
|
||||||
|
Player.LEVEL_PX[player.getLevel()] -
|
||||||
|
Player.LEVEL_PX[player.getLevel() - 1]
|
||||||
|
);
|
||||||
|
healthStatusCheck();
|
||||||
|
updateCurativeString();
|
||||||
}
|
}
|
||||||
|
getSharedPreferences("basics", MODE_PRIVATE)
|
||||||
|
.edit().putInt("px", player.getPx()).apply();
|
||||||
|
((ProgressBar) findViewById(R.id.xpBar))
|
||||||
|
.setProgress(player.getPx() - Player.LEVEL_PX[player.getLevel() - 1]);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
getApplicationContext(),
|
getApplicationContext(),
|
||||||
|
@ -173,10 +193,14 @@ public class MainActivity extends ActionBarActivity{
|
||||||
Toast.LENGTH_LONG
|
Toast.LENGTH_LONG
|
||||||
).show();
|
).show();
|
||||||
}
|
}
|
||||||
getSharedPreferences("basics", MODE_PRIVATE).edit()
|
SharedPreferences.Editor e = getSharedPreferences("basics", MODE_PRIVATE).edit();
|
||||||
.putInt("pg", player.getPg())
|
e.putInt("pg", player.getPg());
|
||||||
.putInt("curativeEfforts", player.getCurativeEfforts())
|
if(usesEffort) {
|
||||||
.apply();
|
e.putInt("curativeEfforts", player.getCurativeEfforts());
|
||||||
|
((ProgressBar) findViewById(R.id.curativeEffortsBar))
|
||||||
|
.setProgress(player.getCurativeEfforts());
|
||||||
|
}
|
||||||
|
e.apply();
|
||||||
updateCurativeString();
|
updateCurativeString();
|
||||||
healthStatusCheck();
|
healthStatusCheck();
|
||||||
}
|
}
|
||||||
|
@ -252,6 +276,8 @@ public class MainActivity extends ActionBarActivity{
|
||||||
private void healthStatusCheck() {
|
private void healthStatusCheck() {
|
||||||
int status = player.getState();
|
int status = player.getState();
|
||||||
int lastState = player.getLastState();
|
int lastState = player.getLastState();
|
||||||
|
ProgressBar pgBar = (ProgressBar) findViewById(R.id.pgBar);
|
||||||
|
pgBar.setProgress(Math.abs(player.getPg()));
|
||||||
Button pg = (Button) findViewById(R.id.pgCurrent);
|
Button pg = (Button) findViewById(R.id.pgCurrent);
|
||||||
pg.setText(String.valueOf(player.getPg()));
|
pg.setText(String.valueOf(player.getPg()));
|
||||||
if (status == Player.MUERTO) {
|
if (status == Player.MUERTO) {
|
||||||
|
@ -283,6 +309,7 @@ public class MainActivity extends ActionBarActivity{
|
||||||
} else if (status == Player.DEBILITADO) {
|
} else if (status == Player.DEBILITADO) {
|
||||||
pg.setBackgroundColor(android.R.drawable.btn_default);
|
pg.setBackgroundColor(android.R.drawable.btn_default);
|
||||||
pg.setTextColor(Color.RED);
|
pg.setTextColor(Color.RED);
|
||||||
|
pgBar.getProgressDrawable().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
|
||||||
if(lastState != Player.SAME) {
|
if(lastState != Player.SAME) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
getApplicationContext(),
|
getApplicationContext(),
|
||||||
|
@ -293,6 +320,7 @@ public class MainActivity extends ActionBarActivity{
|
||||||
} else if (status == Player.MALHERIDO) {
|
} else if (status == Player.MALHERIDO) {
|
||||||
pg.setBackgroundColor(android.R.drawable.btn_default);
|
pg.setBackgroundColor(android.R.drawable.btn_default);
|
||||||
pg.setTextColor(Color.YELLOW);
|
pg.setTextColor(Color.YELLOW);
|
||||||
|
pgBar.getProgressDrawable().setColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_IN);
|
||||||
if(lastState != Player.SAME) {
|
if(lastState != Player.SAME) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
getApplicationContext(),
|
getApplicationContext(),
|
||||||
|
@ -308,6 +336,7 @@ public class MainActivity extends ActionBarActivity{
|
||||||
R.color.abc_primary_text_material_dark
|
R.color.abc_primary_text_material_dark
|
||||||
));
|
));
|
||||||
pg.setBackgroundColor(android.R.drawable.btn_default);
|
pg.setBackgroundColor(android.R.drawable.btn_default);
|
||||||
|
pgBar.getProgressDrawable().setColorFilter(Color.GREEN, PorterDuff.Mode.SRC_IN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,6 +366,11 @@ public class MainActivity extends ActionBarActivity{
|
||||||
},
|
},
|
||||||
new int[18],
|
new int[18],
|
||||||
new Power[4]);
|
new Power[4]);
|
||||||
|
((ProgressBar) findViewById(R.id.xpBar))
|
||||||
|
.setMax(
|
||||||
|
Player.LEVEL_PX[player.getLevel()] -
|
||||||
|
Player.LEVEL_PX[player.getLevel() - 1]
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
player.setName(p.getString("playerName", getString(R.string.adventurer_name)));
|
player.setName(p.getString("playerName", getString(R.string.adventurer_name)));
|
||||||
player.setClassInt(p.getInt("classInt", Player.NULL));
|
player.setClassInt(p.getInt("classInt", Player.NULL));
|
||||||
|
@ -357,6 +391,12 @@ public class MainActivity extends ActionBarActivity{
|
||||||
}
|
}
|
||||||
player.setCurativeEffort(p.getInt("curativeEfforts", player.getCurativeEfforts()));
|
player.setCurativeEffort(p.getInt("curativeEfforts", player.getCurativeEfforts()));
|
||||||
player.setPg(p.getInt("pg", player.getPg()));
|
player.setPg(p.getInt("pg", player.getPg()));
|
||||||
|
((ProgressBar) findViewById(R.id.pgBar)).setMax(player.getMaxPg());
|
||||||
|
((ProgressBar) findViewById(R.id.xpBar))
|
||||||
|
.setProgress(player.getPx() - Player.LEVEL_PX[player.getLevel() - 1]);
|
||||||
|
ProgressBar curativeEffortsBar = (ProgressBar) findViewById(R.id.curativeEffortsBar);
|
||||||
|
curativeEffortsBar.setProgress(player.getCurativeEfforts());
|
||||||
|
curativeEffortsBar.setMax(player.getMaxCurativeEfforts());
|
||||||
healthStatusCheck();
|
healthStatusCheck();
|
||||||
updateCurativeString();
|
updateCurativeString();
|
||||||
//set restored values to the respective fields
|
//set restored values to the respective fields
|
||||||
|
@ -365,8 +405,6 @@ public class MainActivity extends ActionBarActivity{
|
||||||
((TextView) findViewById(R.id.classText)).setText(player.getClassName());
|
((TextView) findViewById(R.id.classText)).setText(player.getClassName());
|
||||||
((TextView) findViewById(R.id.lvl)).setText(String.valueOf(player.getLevel()));
|
((TextView) findViewById(R.id.lvl)).setText(String.valueOf(player.getLevel()));
|
||||||
|
|
||||||
((Button) findViewById(R.id.pgCurrent)).setText(String.valueOf(player.getPg()));
|
|
||||||
|
|
||||||
//attacks
|
//attacks
|
||||||
((TextView) findViewById(R.id.FUE)).setText(
|
((TextView) findViewById(R.id.FUE)).setText(
|
||||||
getString(R.string.FUE) + ":" + player.getFue()
|
getString(R.string.FUE) + ":" + player.getFue()
|
||||||
|
@ -484,6 +522,7 @@ public class MainActivity extends ActionBarActivity{
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: show on screen the max pg's
|
//TODO: show on screen the max pg's
|
||||||
|
//TODO: show in the bars the max and current values
|
||||||
|
//TODO: create secondary thread to move slower the value of the
|
||||||
//TODO: show the current px and progress bar
|
//TODO: show the current px and progress bar
|
||||||
}
|
}
|
|
@ -93,18 +93,74 @@
|
||||||
</HorizontalScrollView>
|
</HorizontalScrollView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<TextView
|
||||||
android:orientation="horizontal"
|
android:id="@+id/titlePgBar"
|
||||||
|
android:text="@string/pg"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
android:drawableBottom="?android:attr/listChoiceBackgroundIndicator"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingLeft="8dip"
|
||||||
|
android:paddingRight="8dip"/>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/curativeEffortsContainer">
|
android:id="@+id/pgBar"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/titleCurativeEffortsBar"
|
||||||
android:layout_height="wrap_content"
|
android:text="@string/curative_efforts"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAllCaps="true"
|
||||||
android:id="@+id/curativeEffortsText"/>
|
android:drawableBottom="?android:attr/listChoiceBackgroundIndicator"
|
||||||
</LinearLayout>
|
android:layout_marginBottom="5dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingLeft="8dip"
|
||||||
|
android:paddingRight="8dip"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:id="@+id/curativeEffortsText"/>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/curativeEffortsBar"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/titleXpBar"
|
||||||
|
android:text="@string/px"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
android:drawableBottom="?android:attr/listChoiceBackgroundIndicator"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingLeft="8dip"
|
||||||
|
android:paddingRight="8dip"/>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/xpBar"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/attackContainer"
|
android:id="@+id/attackContainer"
|
||||||
|
@ -279,5 +335,6 @@
|
||||||
android:hint="@string/VOL" />
|
android:hint="@string/VOL" />
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
Reference in a new issue