1
0
Fork 0

Added init activity, broken

This commit is contained in:
Carlos Galindo 2015-03-03 23:42:21 +01:00
parent 381d13c3a0
commit c5c5daef07
13 changed files with 347 additions and 176 deletions

View file

@ -4,6 +4,7 @@
<option name="myLocal" value="false" /> <option name="myLocal" value="false" />
<inspection_tool class="AndroidLintButtonOrder" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="AndroidLintButtonOrder" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="AndroidLintDeprecated" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="AndroidLintDeprecated" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="AndroidLintInvalidId" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="AndroidLintRelativeOverlap" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="AndroidLintRelativeOverlap" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="AndroidLintRtlCompat" enabled="false" level="ERROR" enabled_by_default="false" /> <inspection_tool class="AndroidLintRtlCompat" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="AndroidLintRtlHardcoded" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="AndroidLintRtlHardcoded" enabled="false" level="WARNING" enabled_by_default="false" />

View file

@ -10,20 +10,25 @@
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:label="@string/app_name" > android:label="@string/app_name" >
</activity>
<activity
android:name=".Introduction"
android:label="@string/title_activity_introduction" >
<!-- android:parentActivityName=".MainActivity" -->
<!-- <meta-data -->
<!-- android:name="android.support.PARENT_ACTIVITY" -->
<!-- android:value=".MainActivity" /> -->
</activity>
<activity
android:name=".Welcome"
android:label="@string/app_name" >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity
android:name=".Introduction"
android:label="@string/title_activity_introduction" >
<!--android:parentActivityName=".MainActivity"-->
<!--<meta-data-->
<!--android:name="android.support.PARENT_ACTIVITY"-->
<!--android:value=".MainActivity" />-->
</activity>
</application> </application>
</manifest> </manifest>

View file

@ -13,9 +13,10 @@ import android.widget.Toast;
public class Introduction extends ActionBarActivity { public class Introduction extends ActionBarActivity {
EditText name, level; private EditText name, level;
EditText fue, con, des, sab, intel, car; private EditText fue, con, des, sab, intel, car;
Spinner classSpinner, raceSpinner; private Spinner classSpinner, raceSpinner;
private boolean first;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -49,6 +50,8 @@ public class Introduction extends ActionBarActivity {
Player.RACE_STRINGS Player.RACE_STRINGS
) )
); );
first = getIntent().getExtras() == null || getIntent().getExtras().getBoolean("first_time");
} }
@ -78,7 +81,7 @@ public class Introduction extends ActionBarActivity {
//noinspection SimplifiableIfStatement //noinspection SimplifiableIfStatement
if (id == R.id.action_save) { if (id == R.id.action_save) {
if(finished()) { if(finished()) {
this.finish(); finish();
} else { } else {
Toast.makeText( Toast.makeText(
getApplicationContext(), getApplicationContext(),
@ -117,7 +120,7 @@ public class Introduction extends ActionBarActivity {
if (!this.sab.getText().toString().isEmpty()) if (!this.sab.getText().toString().isEmpty())
sab = Integer.parseInt(this.sab.getText().toString()); sab = Integer.parseInt(this.sab.getText().toString());
if(getIntent().getExtras().getBoolean("first_time")) { if(first) {
if ( if (
!nameString.isEmpty() && !nameString.isEmpty() &&
classInt != Player.NULL && classInt != Player.NULL &&
@ -151,7 +154,7 @@ public class Introduction extends ActionBarActivity {
if (!nameString.isEmpty()) ed.putString("playerName", nameString); if (!nameString.isEmpty()) ed.putString("playerName", nameString);
if (classInt != Player.NULL) ed.putInt("classInt", classInt); if (classInt != Player.NULL) ed.putInt("classInt", classInt);
if (raceInt != Player.NULL) ed.putInt("raceInt", raceInt); if (raceInt != Player.NULL) ed.putInt("raceInt", raceInt);
if (pxInt != 0) ed.putInt("px", pxInt); if (pxInt != -1) ed.putInt("px", pxInt);
if (fue != 0) ed.putInt("fue", fue); if (fue != 0) ed.putInt("fue", fue);
if (car != 0) ed.putInt("car", car); if (car != 0) ed.putInt("car", car);

View file

@ -27,20 +27,44 @@ public class MainActivity extends ActionBarActivity{
public Player player; public Player player;
private boolean undo; private boolean undo;
private int undoObject, undoPreviousValue; private int undoObject, undoPreviousValue;
//TODO: change curativeEffortsBar() color
private ProgressBar pgBar, negPgBar, xpBar, curativeEffortsBar;
private Button pgCurrent;
private TextView currentPg, currentXp, currentCurativeEfforts, lvl;
private SharedPreferences p;
@Override @Override
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() p = getSharedPreferences("basics", MODE_PRIVATE);
xpBar = (ProgressBar) findViewById(R.id.xpBar);
curativeEffortsBar = (ProgressBar) findViewById(R.id.curativeEffortsBar);
pgBar = (ProgressBar) findViewById(R.id.pgBar);
negPgBar = (ProgressBar) findViewById(R.id.negPgBar);
pgCurrent = (Button) findViewById(R.id.pgCurrent);
lvl = (TextView) findViewById(R.id.lvl);
currentPg = (TextView) findViewById(R.id.currentPg);
currentXp = (TextView) findViewById(R.id.currentXp);
currentCurativeEfforts = (TextView) findViewById(R.id.currentCurativeEfforts);
xpBar.getProgressDrawable()
.setColorFilter(Color.parseColor("#62BACE"), PorterDuff.Mode.SRC_IN); .setColorFilter(Color.parseColor("#62BACE"), PorterDuff.Mode.SRC_IN);
((ProgressBar) findViewById(R.id.curativeEffortsBar)) curativeEffortsBar.getProgressDrawable()
.getProgressDrawable()
.setColorFilter(Color.parseColor("#FFD700"), PorterDuff.Mode.SRC_IN); .setColorFilter(Color.parseColor("#FFD700"), PorterDuff.Mode.SRC_IN);
//TODO: use the negative PG bar, not curativeEfforts one //TODO: use the negative PG bar, not curativeEfforts one
// findViewById(R.id.negCurativeEffortsBar).setRotation(180);
undo = false; undo = false;
//begin
restoreData();
pgUpdate();
ceUpdate();
pxUpdate();
//end
invalidateOptionsMenu(); invalidateOptionsMenu();
} }
@ -77,7 +101,6 @@ public class MainActivity extends ActionBarActivity{
} }
return true; return true;
} else if (id == R.id.action_edit_basics) { } else if (id == R.id.action_edit_basics) {
SharedPreferences p = getSharedPreferences("basics", MODE_PRIVATE);
Intent intent = new Intent(this, Introduction.class); Intent intent = new Intent(this, Introduction.class);
startActivity(intent.putExtra( startActivity(intent.putExtra(
"first_time", "first_time",
@ -99,7 +122,7 @@ public class MainActivity extends ActionBarActivity{
R.string.message_reset, R.string.message_reset,
Toast.LENGTH_LONG Toast.LENGTH_LONG
).show(); ).show();
getSharedPreferences("basics", MODE_PRIVATE).edit().clear().apply(); p.edit().clear().apply();
player = null; player = null;
restoreData(); restoreData();
} }
@ -132,21 +155,23 @@ public class MainActivity extends ActionBarActivity{
//TODO: update currentPg button //TODO: update currentPg button
//TODO: improve leveling up //TODO: improve leveling up
player.setMaxPgOnLevelUp(); player.setMaxPgOnLevelUp();
((TextView) findViewById(R.id.lvl)).setText( lvl.setText(
String.valueOf(player.getLevel()) String.valueOf(player.getLevel())
); );
healthStatusCheck();
updateCurativeString();
} }
getSharedPreferences("basics", MODE_PRIVATE) p.edit().putInt("px", player.getPx()).apply();
.edit().putInt("px", player.getPx()).apply(); if(levelUp)
incrementProgressBar( xpBar.setMax(Player.LEVEL_PX[player.getLevel()] -
(ProgressBar) findViewById(R.id.xpBar), Player.LEVEL_PX[player.getLevel() - 1]);
(TextView) findViewById(R.id.currentXp), pxUpdate();
1, levelUp, Player.LEVEL_PX[player.getLevel()] - ceUpdate();
Player.LEVEL_PX[player.getLevel() - 1], pgUpdate();
true, player.getPx() - Player.LEVEL_PX[player.getLevel() - 1] // incrementProgressBar(
); // xpBar, currentXp,
// 1, levelUp, Player.LEVEL_PX[player.getLevel()] -
// Player.LEVEL_PX[player.getLevel() - 1],
// true, player.getPx() - Player.LEVEL_PX[player.getLevel() - 1]
// );
} catch(Exception e) { } catch(Exception e) {
Toast.makeText( Toast.makeText(
getApplicationContext(), getApplicationContext(),
@ -167,6 +192,24 @@ public class MainActivity extends ActionBarActivity{
Toast.LENGTH_LONG Toast.LENGTH_LONG
).show(); ).show();
return true; return true;
} else if (id == R.id.action_time_long_rest) {
player.rest(true);
Toast.makeText(
getApplicationContext(), R.string.long_rest_done, Toast.LENGTH_LONG
).show();
p.edit()
.putInt("pg", player.getPg())
.putInt("curativeEfforts", player.getCurativeEfforts())
.apply();
pgUpdate();
ceUpdate();
} else if (id == R.id.action_time_rest) {
player.rest(false);
Toast.makeText(
getApplicationContext(), R.string.rest_done, Toast.LENGTH_LONG
).show();
pgUpdate();
ceUpdate();
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
@ -176,8 +219,9 @@ public class MainActivity extends ActionBarActivity{
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
restoreData(); restoreData();
healthStatusCheck(); pgUpdate();
updateCurativeString(); ceUpdate();
pxUpdate();
} }
public void heal(boolean usesEffort) { public void heal(boolean usesEffort) {
@ -196,20 +240,19 @@ public class MainActivity extends ActionBarActivity{
Toast.LENGTH_LONG Toast.LENGTH_LONG
).show(); ).show();
} }
SharedPreferences.Editor e = getSharedPreferences("basics", MODE_PRIVATE).edit(); SharedPreferences.Editor e = p.edit();
e.putInt("pg", player.getPg()); e.putInt("pg", player.getPg());
if(usesEffort) { if(usesEffort) {
e.putInt("curativeEfforts", player.getCurativeEfforts()); e.putInt("curativeEfforts", player.getCurativeEfforts());
incrementProgressBar( // incrementProgressBar(
(ProgressBar) findViewById(R.id.curativeEffortsBar), // curativeEffortsBar, currentCurativeEfforts,
(TextView) findViewById(R.id.currentCurativeEfforts), // 100, false, 0,
100, false, 0, // true, player.getCurativeEfforts()
true, player.getCurativeEfforts() // );
); ceUpdate();
} }
e.apply(); e.apply();
updateCurativeString(); pgUpdate();
healthStatusCheck();
} }
} }
@ -250,28 +293,22 @@ public class MainActivity extends ActionBarActivity{
alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) { public void onClick(DialogInterface dialog, int whichButton) {
Button pg = (Button) findViewById(R.id.pgCurrent);
try { try {
int preValue = Integer.parseInt(pg.getText().toString()); int preValue = Integer.parseInt(pgCurrent.getText().toString());
int damage = Integer.parseInt(input.getText().toString()); int damage = Integer.parseInt(input.getText().toString());
player.losePg(damage); player.losePg(damage);
pg.setText( pgCurrent.setText(String.valueOf(player.getPg()));
String.valueOf(player.getPg()) // incrementProgressBar(
); // pgBar, currentPg,
incrementProgressBar( // 100, false, 0,
(ProgressBar) findViewById(R.id.pgBar), // true, player.getPg()
(TextView) findViewById(R.id.currentPg), // );
100, false, 0,
true, player.getPg()
);
//finished correctly, then apply values to undo's //finished correctly, then apply values to undo's
undo = true; undo = true;
undoPreviousValue = preValue; undoPreviousValue = preValue;
undoObject = CURRENT_PG; undoObject = CURRENT_PG;
getSharedPreferences("basics", MODE_PRIVATE).edit() p.edit().putInt("pg", player.getPg()).apply();
.putInt("pg", player.getPg()) pgUpdate();
.apply();
healthStatusCheck();
invalidateOptionsMenu(); invalidateOptionsMenu();
} catch (Exception e) {} } catch (Exception e) {}
} }
@ -286,23 +323,30 @@ public class MainActivity extends ActionBarActivity{
alert.show(); alert.show();
} }
private void healthStatusCheck() { private void pgUpdate() {
int status = player.getState(); int status = player.getState();
int lastState = player.getLastState(); int lastState = player.getLastState();
// ProgressBar pgBar = (ProgressBar) findViewById(R.id.pgBar); int pg = player.getPg();
if (pg < 0) {
pgBar.setProgress(0);
negPgBar.setProgress(-pg);
} else if (pg > 0) {
pgBar.setProgress(pg);
negPgBar.setProgress(0);
} else {
pgBar.setProgress(0);
negPgBar.setProgress(0);
}
currentPg.setText(player.getPg() + " / " + player.getMaxPg());
// incrementProgressBar( // incrementProgressBar(
// pgBar, // pgBar, currentPg,
// (TextView) findViewById(R.id.currentPg), // 100, false, 0,
// Math.abs(player.getPg()), // true, Math.abs(player.getPg())
// 100,
// false,
// CURRENT_PG
// ); // );
Button pg = (Button) findViewById(R.id.pgCurrent); pgCurrent.setText(String.valueOf(player.getPg()));
pg.setText(String.valueOf(player.getPg()));
if (status == Player.MUERTO) { if (status == Player.MUERTO) {
pg.setTextColor(Color.BLACK); pgCurrent.setTextColor(Color.BLACK);
pg.setBackgroundColor(Color.RED); pgCurrent.setBackgroundColor(Color.RED);
AlertDialog.Builder alert = new AlertDialog.Builder(this); AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle(getString(R.string.reset_confirmation_title)); alert.setTitle(getString(R.string.reset_confirmation_title));
@ -320,16 +364,17 @@ public class MainActivity extends ActionBarActivity{
R.string.message_death, R.string.message_death,
Toast.LENGTH_LONG Toast.LENGTH_LONG
).show(); ).show();
getSharedPreferences("basics", MODE_PRIVATE).edit().clear().apply(); p.edit().clear().apply();
restoreData(); restoreData();
} }
}); });
alert.show(); alert.show();
} else if (status == Player.DEBILITADO) { } else if (status == Player.DEBILITADO) {
pg.setBackgroundColor(android.R.drawable.btn_default); pgCurrent.setBackgroundColor(android.R.drawable.btn_default);
pg.setTextColor(Color.RED); pgCurrent.setTextColor(Color.RED);
// pgBar.getProgressDrawable().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN); pgBar.getProgressDrawable().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
negPgBar.getProgressDrawable().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
if(lastState != Player.SAME) { if(lastState != Player.SAME) {
Toast.makeText( Toast.makeText(
getApplicationContext(), getApplicationContext(),
@ -338,9 +383,10 @@ public class MainActivity extends ActionBarActivity{
).show(); ).show();
} }
} else if (status == Player.MALHERIDO) { } else if (status == Player.MALHERIDO) {
pg.setBackgroundColor(android.R.drawable.btn_default); pgCurrent.setBackgroundColor(android.R.drawable.btn_default);
pg.setTextColor(Color.YELLOW); pgCurrent.setTextColor(Color.YELLOW);
// pgBar.getProgressDrawable().setColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_IN); pgBar.getProgressDrawable().setColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_IN);
negPgBar.getProgressDrawable().setColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_IN);
if(lastState != Player.SAME) { if(lastState != Player.SAME) {
Toast.makeText( Toast.makeText(
getApplicationContext(), getApplicationContext(),
@ -349,27 +395,20 @@ public class MainActivity extends ActionBarActivity{
).show(); ).show();
} }
} else { } else {
if(player.getPg() >= player.getMaxPg()) pgCurrent.setTextColor(Color.GREEN);
pg.setTextColor(Color.GREEN); pgCurrent.setBackgroundColor(android.R.drawable.btn_default);
else pgBar.getProgressDrawable().setColorFilter(Color.GREEN, PorterDuff.Mode.SRC_IN);
pg.setTextColor(getResources().getColor( negPgBar.getProgressDrawable().setColorFilter(Color.GREEN, PorterDuff.Mode.SRC_IN);
R.color.abc_primary_text_material_dark
));
pg.setBackgroundColor(android.R.drawable.btn_default);
// pgBar.getProgressDrawable().setColorFilter(Color.GREEN, PorterDuff.Mode.SRC_IN);
} }
} }
private void restoreData(){ private void restoreData(){
SharedPreferences p = getSharedPreferences("basics", MODE_PRIVATE);
//restore state
if (!p.getBoolean("saved", false)) { if (!p.getBoolean("saved", false)) {
Intent intent = new Intent(this, Introduction.class); Intent intent = new Intent(this, Introduction.class);
startActivity(intent.putExtra( startActivity(intent.putExtra(
"first_time", "first_time",
!p.getBoolean("saved", false) !p.getBoolean("saved", false)
)); ));
while(!p.getBoolean("saved", false));
} }
if (player == null) { if (player == null) {
player = new Player( player = new Player(
@ -383,15 +422,10 @@ public class MainActivity extends ActionBarActivity{
p.getInt("des", 10), p.getInt("des", 10),
p.getInt("int", 10), p.getInt("int", 10),
p.getInt("sab", 10), p.getInt("sab", 10),
p.getInt("car", 10), p.getInt("car", 10)
}, },
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));
@ -403,35 +437,40 @@ public class MainActivity extends ActionBarActivity{
p.getInt("des", 10), p.getInt("des", 10),
p.getInt("int", 10), p.getInt("int", 10),
p.getInt("sab", 10), p.getInt("sab", 10),
p.getInt("car", 10), p.getInt("car", 10)
}); });
} }
pxUpdate();
xpBar.setMax(
Player.LEVEL_PX[player.getLevel()] -
Player.LEVEL_PX[player.getLevel() - 1]
);
if (player.getMaxPg() == 0) { if (player.getMaxPg() == 0) {
pgDialog(); pgDialog();
} }
player.setCurativeEffort(p.getInt("curativeEfforts", player.getMaxCurativeEfforts())); player.setCurativeEffort(p.getInt("curativeEfforts", player.getMaxCurativeEfforts()));
player.setPg(p.getInt("pg", player.getMaxPg())); player.setPg(p.getInt("pg", player.getMaxPg()));
incrementProgressBar( pgBar.setMax(player.getMaxPg());
(ProgressBar) findViewById(R.id.pgBar), negPgBar.setMax(player.getMaxPg() / 2);
(TextView) findViewById(R.id.currentPg), // incrementProgressBar(
100, true, player.getMaxPg(), // pgBar, currentPg,
true, player.getPg() // 100, true, player.getMaxPg(),
); // true, player.getPg()
ProgressBar curativeEffortsBar = (ProgressBar) findViewById(R.id.curativeEffortsBar); // );
incrementProgressBar( curativeEffortsBar.setMax(player.getMaxCurativeEfforts());
curativeEffortsBar, // incrementProgressBar(
(TextView) findViewById(R.id.currentCurativeEfforts), // curativeEffortsBar, currentCurativeEfforts,
100, true, player.getMaxCurativeEfforts(), // 100, true, player.getMaxCurativeEfforts(),
true, player.getCurativeEfforts() // true, player.getCurativeEfforts()
); // );
healthStatusCheck(); pgUpdate();
updateCurativeString(); ceUpdate();
//set restored values to the respective fields //set restored values to the respective fields
((TextView) findViewById(R.id.nameText)).setText(player.getName()); ((TextView) findViewById(R.id.nameText)).setText(player.getName());
((TextView) findViewById(R.id.raceText)).setText(player.getRaceName()); ((TextView) findViewById(R.id.raceText)).setText(player.getRaceName());
((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())); lvl.setText(String.valueOf(player.getLevel()));
//attacks //attacks
((TextView) findViewById(R.id.FUE)).setText( ((TextView) findViewById(R.id.FUE)).setText(
@ -466,17 +505,25 @@ public class MainActivity extends ActionBarActivity{
((TextView) findViewById(R.id.VOL)).setText( ((TextView) findViewById(R.id.VOL)).setText(
getString(R.string.VOL) + ": " + player.getVol() getString(R.string.VOL) + ": " + player.getVol()
); );
} }
private void updateCurativeString() { private void ceUpdate() {
((TextView) findViewById(R.id.currentCurativeEfforts)).setText( curativeEffortsBar.setProgress(player.getCurativeEfforts());
currentCurativeEfforts.setText(
player.getCurativeEfforts() + " / " + player.getCurativeEfforts() + " / " +
player.getMaxCurativeEfforts() player.getMaxCurativeEfforts()
); );
} }
private void pxUpdate() {
xpBar.setProgress(player.getPx());
currentXp.setText(
player.getPx() + " / " +
Player.LEVEL_PX[player.getLevel()]
);
}
public void selectPlayer(View view) { public void selectPlayer(View view) {
//TODO: implement players and switch between them //TODO: implement players and switch between them
} }
@ -484,7 +531,7 @@ public class MainActivity extends ActionBarActivity{
private void undo() { private void undo() {
String message = ""; String message = "";
if(undoObject == CURRENT_PG){ if(undoObject == CURRENT_PG){
((Button) findViewById(R.id.pgCurrent)).setText(String.valueOf(undoPreviousValue)); pgCurrent.setText(String.valueOf(undoPreviousValue));
player.setPg(undoPreviousValue); player.setPg(undoPreviousValue);
undoObject = NULL; undoObject = NULL;
message = getString(R.string.action_undo_current_pg); message = getString(R.string.action_undo_current_pg);
@ -494,6 +541,7 @@ public class MainActivity extends ActionBarActivity{
message, message,
Toast.LENGTH_LONG Toast.LENGTH_LONG
).show(); ).show();
pgUpdate();
undo = false; undo = false;
invalidateOptionsMenu(); invalidateOptionsMenu();
} }
@ -501,7 +549,6 @@ public class MainActivity extends ActionBarActivity{
private void pgDialog() { private void pgDialog() {
AlertDialog.Builder dialog = new AlertDialog.Builder(this); AlertDialog.Builder dialog = new AlertDialog.Builder(this);
final EditText input = new EditText(this); final EditText input = new EditText(this);
final AlertDialog d;
input.setHint(R.string.dialog_resolve_max_pg_hint); input.setHint(R.string.dialog_resolve_max_pg_hint);
input.setInputType(InputType.TYPE_CLASS_NUMBER); input.setInputType(InputType.TYPE_CLASS_NUMBER);
input.setImeOptions(EditorInfo.IME_ACTION_DONE); input.setImeOptions(EditorInfo.IME_ACTION_DONE);
@ -530,50 +577,38 @@ public class MainActivity extends ActionBarActivity{
} }
//TODO: fix the display of maxPg and levelUp //TODO: fix the display of maxPg and levelUp
//TODO: use this for px and curativeEfforts
//TODO: set up a partial barCommand to raise only between the ratios, then a manager, then another //TODO: set up a partial barCommand to raise only between the ratios, then a manager, then another
//TODO: if pgBar, change color accordingly with the pg //TODO: if pgBar, change color accordingly with the pg
private void incrementProgressBar(final ProgressBar progressBar, final TextView textView, private void incrementProgressBar(final ProgressBar progressBar, final TextView textView,
final int factor, final int factor,
final boolean setMax, int max, final boolean setMax, int max,
final boolean setVal, int end) { final boolean setVal, int end) {
if(factor == 1){
textView.setText(
(progressBar.getProgress() + Player.LEVEL_PX[player.getLevel() - 1])
+ " / " +
(progressBar.getMax() + Player.LEVEL_PX[player.getLevel() - 1])
);
} else {
textView.setText(
(progressBar.getProgress()/factor) + " / " +
(progressBar.getMax()/factor)
);
}
if(setMax) progressBar.setMax(factor*max); if(setMax) progressBar.setMax(factor*max);
if(!setVal) return; if(!setVal) return;
if(progressBar.getProgress() - end*factor == 0) return; if(progressBar.getProgress() - end*factor == 0) return;
final Handler handler = new Handler(); final Handler handler = new Handler();
final int finalEnd = end * factor; final int finalEnd = (end < 0 ? 0 : -1) * end * factor;
final boolean negative = finalEnd < 0; final int time = Math.max(2000 / Math.abs(progressBar.getProgress() - finalEnd), 1);
final int time = 2000 / Math.abs(progressBar.getProgress() - finalEnd);
new Thread(new Runnable() { new Thread(new Runnable() {
public void run() { public void run() {
int current = progressBar.getProgress(); int current = progressBar.getProgress();
boolean bigger = current < finalEnd; boolean bigger = current < finalEnd;
while ((bigger && current < finalEnd) || (!bigger && current > finalEnd)) { while ((bigger && current < finalEnd) || (!bigger && current > finalEnd)) {
if(bigger) current++; if(bigger) current += 2;
else current--; else current -= 2;
// if(progressBar.getId() == R.id.pgBar) {
// double rate = (double)current / progressBar.getMax() * (negative ? -1:1);
// if (rate <= 0) {
// progressBar.getProgressDrawable()
// .setColorFilter(
// Color.RED,
// PorterDuff.Mode.SRC_IN
// );
// } else if (rate <= 0.5) {
// progressBar.getProgressDrawable()
// .setColorFilter(
// Color.YELLOW,
// PorterDuff.Mode.SRC_IN
// );
// } else {
// progressBar.getProgressDrawable()
// .setColorFilter(
// Color.GREEN,
// PorterDuff.Mode.SRC_IN
// );
// }
// }
// Update the progress bar and display the // Update the progress bar and display the
//current value in the text view //current value in the text view
final int finalCurrent = Math.abs(current); final int finalCurrent = Math.abs(current);
@ -601,11 +636,30 @@ public class MainActivity extends ActionBarActivity{
} }
} }
}).start(); }).start();
} }
//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 // if(progressBar.getId() == R.id.pgBar) {
//TODO: create secondary thread to move slower the value of the progressBar // double rate = (double)current / progressBar.getMax() * (negative ? -1:1);
// if (rate <= 0) {
// progressBar.getProgressDrawable()
// .setColorFilter(
// Color.RED,
// PorterDuff.Mode.SRC_IN
// );
// } else if (rate <= 0.5) {
// progressBar.getProgressDrawable()
// .setColorFilter(
// Color.YELLOW,
// PorterDuff.Mode.SRC_IN
// );
// } else {
// progressBar.getProgressDrawable()
// .setColorFilter(
// Color.GREEN,
// PorterDuff.Mode.SRC_IN
// );
// }
// }
} }

View file

@ -86,6 +86,10 @@ public class Player {
"Religión", "Sanar", "Sigilo" "Religión", "Sanar", "Sigilo"
}; };
public static final int[] ABILITY_BOOST = new int[] {
-1, DES, CON, INT, FUE, CAR, SAB, CAR, INT, CAR, DES, SAB, SAB, SAB, CAR, INT, SAB, DES
};
/** /**
* Values for the current living state * Values for the current living state
*/ */
@ -214,13 +218,18 @@ public class Player {
public int getRaceInt() {return raceInt;} public int getRaceInt() {return raceInt;}
//TODO: implement time in the app //TODO: implement time in the app
public void rest(boolean length) { public void rest(boolean isLong) {
if(length) { if(isLong) {
pg = maxPg;
curativeEfforts = maxCurativeEfforts; curativeEfforts = maxCurativeEfforts;
for(Power p : powers){ for (Power p : powers)
if(p != null) p.recover(); if (p != null && p.getType() == Power.DIARIO)
} p.recover();
setState();
} }
for (Power p : powers)
if (p != null && p.getType() == Power.ENCUENTRO)
p.recover();
} }
public void setAtk(int[] atk) {this.atk = atk; if(classInt != NULL) setClass();} public void setAtk(int[] atk) {this.atk = atk; if(classInt != NULL) setClass();}

View file

@ -1,7 +1,7 @@
package com.kauron.dungeonmanager; package com.kauron.dungeonmanager;
public class Power { public class Power {
public static final int DIARIO = 1, A_VOLUNTAD = 2, ENCUENTRO = 3, OPORTUNIDAD = 4; public static final int DIARIO = 4, A_VOLUNTAD = 2, ENCUENTRO = 3, OPORTUNIDAD = 1;
private boolean used; private boolean used;
private int type; private int type;
@ -20,6 +20,9 @@ public class Power {
public boolean isUsed(){return used;} public boolean isUsed(){return used;}
public void use(){used = true;} public void use(){
if(type >= ENCUENTRO && !used)
used = true;
}
public void recover(){used = false;} public void recover(){used = false;}
} }

View file

@ -0,0 +1,58 @@
package com.kauron.dungeonmanager;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
public class Welcome extends ActionBarActivity {
private Button load, newChar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
newChar = (Button) findViewById(R.id.newCharacter);
load = (Button) findViewById(R.id.loadCharacter);
load.setEnabled(
getSharedPreferences("basics", MODE_PRIVATE).getBoolean("basics", false)
);
}
//TODO: putBoolean in the intent correctly
public void onNewClick(View view) {
startActivity(new Intent(this, Introduction.class).putExtra("first_time", true));
}
//TODO: get correctly the state of the saved game
public void onLoadClick(View view) {
startActivity(new Intent(this, MainActivity.class));
}
@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_welcome, 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);
}
}

View file

@ -131,10 +131,17 @@
style="?android:attr/progressBarStyleHorizontal" 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/negCurativeEffortsBar" android:id="@+id/negPgBar"
android:layout_weight="2" android:layout_weight="2"
android:rotation="180" android:rotation="180"/>
android:progress="25"/> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="true"
android:textStyle="bold"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:text="0"/>
<ProgressBar <ProgressBar
style="?android:attr/progressBarStyleHorizontal" style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent" android:layout_width="fill_parent"

View file

@ -0,0 +1,24 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.kauron.dungeonmanager.Welcome"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Load character"
android:id="@+id/loadCharacter"
android:onClick="onLoadClick" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/new_character"
android:id="@+id/newCharacter"
android:onClick="onNewClick" />
</LinearLayout>

View file

@ -21,21 +21,11 @@
app:showAsAction="ifRoom" app:showAsAction="ifRoom"
android:icon="@drawable/ic_action_time"> android:icon="@drawable/ic_action_time">
<menu> <menu>
<item
android:title="@string/action_time_turn"
android:id="@+id/action_time_turn"
android:orderInCategory="1"
app:showAsAction="never"/>
<item <item
android:title="@string/action_time_rest" android:title="@string/action_time_rest"
android:id="@+id/action_time_rest" android:id="@+id/action_time_rest"
android:orderInCategory="4" android:orderInCategory="4"
app:showAsAction="never"/> app:showAsAction="never"/>
<item
android:title="@string/action_time_day"
android:id="@+id/action_time_day"
android:orderInCategory="3"
app:showAsAction="never"/>
<item <item
android:title="@string/action_time_long_rest" android:title="@string/action_time_long_rest"
android:id="@+id/action_time_long_rest" android:id="@+id/action_time_long_rest"

View file

@ -0,0 +1,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.kauron.dungeonmanager.Welcome">
<item android:id="@+id/action_settings" android:title="@string/action_settings"
android:orderInCategory="100" app:showAsAction="never" />
</menu>

View file

@ -57,7 +57,6 @@
<string name="action_time_long_rest">Descanso largo</string> <string name="action_time_long_rest">Descanso largo</string>
<string name="action_time_rest">Descanso corto</string> <string name="action_time_rest">Descanso corto</string>
<string name="action_time_turn">Turno siguiente</string> <string name="action_time_turn">Turno siguiente</string>
<string name="curative_display_text">Tienes %1$d de %2$d esfuerzos curativos</string>
<string name="px">PX</string> <string name="px">PX</string>
<string name="px_awarded_hint">PX del encuentro</string> <string name="px_awarded_hint">PX del encuentro</string>
<string name="px_awarded_title">Introduce los PX ganados</string> <string name="px_awarded_title">Introduce los PX ganados</string>
@ -66,4 +65,8 @@
<string name="dialog_resolve_max_pg_message">No se han podido calcular tus PG a partir de tu nivel</string> <string name="dialog_resolve_max_pg_message">No se han podido calcular tus PG a partir de tu nivel</string>
<string name="dialog_resolve_max_pg_title">Atención</string> <string name="dialog_resolve_max_pg_title">Atención</string>
<string name="empty_field">Por favor, escribe algo</string> <string name="empty_field">Por favor, escribe algo</string>
<string name="action_download">Actualizar app</string>
<string name="message_no_back_button_intro">No puedes volver atrás. Para crear tu personaje pulsa el botón de guardar</string>
<string name="long_rest_done">Has descansado y restaurado todos tus poderes</string>
<string name="rest_done">Tus poderes de encuentro han sido restaurados</string>
</resources> </resources>

View file

@ -13,6 +13,8 @@
<string name="VOL">VOL</string> <string name="VOL">VOL</string>
<string name="defense">Defense</string> <string name="defense">Defense</string>
<string name="curative_efforts">Curative efforts</string> <string name="curative_efforts">Curative efforts</string>
<string name="rest_done">Your encounter powers have been restored</string>
<string name="long_rest_done">All your stats have been restored</string>
<string name="action_reset">Reset</string> <string name="action_reset">Reset</string>
<string name="message_reset">All the data has been cleared</string> <string name="message_reset">All the data has been cleared</string>
<string name="reset_confirmation_title">Are you sure?</string> <string name="reset_confirmation_title">Are you sure?</string>
@ -72,4 +74,9 @@
<string name="dialog_resolve_max_pg_message">Couldn\'t compute your max PG based on your level</string> <string name="dialog_resolve_max_pg_message">Couldn\'t compute your max PG based on your level</string>
<string name="action_download">Update app</string> <string name="action_download">Update app</string>
<string name="message_no_back_button_intro">You can\'t go back. Fill the information and press the save button.</string> <string name="message_no_back_button_intro">You can\'t go back. Fill the information and press the save button.</string>
<string name="title_activity_welcome">Welcome</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="new_character">New character</string>
</resources> </resources>