1
0
Fork 0

CEff correction

This commit is contained in:
Carlos Galindo 2015-02-23 23:53:28 +01:00
parent 58da5de755
commit ca51347522
15 changed files with 108 additions and 131 deletions

View file

@ -1,64 +0,0 @@
package com.kauron.dungeonmanager;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
public class HealthDialogFragment extends DialogFragment {
//TODO: convert to method and dialog, without class
static HealthDialogFragment newInstance(int curativeEfforts) {
HealthDialogFragment f = new HealthDialogFragment();
Bundle args = new Bundle();
args.putInt("curativeEfforts", curativeEfforts);
f.setArguments(args);
return f;
}
public interface HealthDialogListener {
public void heal(DialogFragment dialog, boolean uses);
}
HealthDialogListener mListener;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try{
mListener = (HealthDialogListener) activity;
}catch(ClassCastException e){
throw new ClassCastException(activity.toString() + " must implement HealthDialogListener");
}
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(com.kauron.dungeonmanager.R.string.new_energies_message)
.setTitle(com.kauron.dungeonmanager.R.string.new_energies)
.setPositiveButton(com.kauron.dungeonmanager.R.string.me, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
mListener.heal(HealthDialogFragment.this, true);
}
})
.setNegativeButton(com.kauron.dungeonmanager.R.string.other, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
mListener.heal(HealthDialogFragment.this, false);
}
})
.setNeutralButton(com.kauron.dungeonmanager.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
return builder.create();
}
}

View file

@ -67,7 +67,7 @@ public class Introduction extends ActionBarActivity {
int id = item.getItemId(); int id = item.getItemId();
//noinspection SimplifiableIfStatement //noinspection SimplifiableIfStatement
if (id == com.kauron.dungeonmanager.R.id.action_finish) { if (id == com.kauron.dungeonmanager.R.id.action_save) {
if(finished()) { if(finished()) {
this.finish(); this.finish();
} else { } else {

View file

@ -19,8 +19,7 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
public class MainActivity extends ActionBarActivity public class MainActivity extends ActionBarActivity{
implements HealthDialogFragment.HealthDialogListener{
public static final int CURRENT_PG = 1, NULL = 0; public static final int CURRENT_PG = 1, NULL = 0;
@ -49,8 +48,6 @@ public class MainActivity extends ActionBarActivity
return true; return true;
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will // Handle action bar item clicks here. The action bar will
@ -60,7 +57,15 @@ public class MainActivity extends ActionBarActivity
//noinspection SimplifiableIfStatement //noinspection SimplifiableIfStatement
if (id == com.kauron.dungeonmanager.R.id.action_cure) { if (id == com.kauron.dungeonmanager.R.id.action_cure) {
showHealthDialog(); if(player.getMaxPg() <= player.getPg()){
Toast.makeText(
getApplicationContext(),
R.string.maxed_curative,
Toast.LENGTH_LONG
).show();
} else {
healDialog();
}
return true; return true;
} else if (id == com.kauron.dungeonmanager.R.id.action_edit_basics) { } else if (id == com.kauron.dungeonmanager.R.id.action_edit_basics) {
//TODO: try this startChildActivity() //TODO: try this startChildActivity()
@ -76,7 +81,6 @@ public class MainActivity extends ActionBarActivity
undo(); undo();
return true; return true;
} else if (id == com.kauron.dungeonmanager.R.id.action_reset) { } else if (id == com.kauron.dungeonmanager.R.id.action_reset) {
AlertDialog.Builder alert = new AlertDialog.Builder(this); AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle(getString(com.kauron.dungeonmanager.R.string.reset_confirmation_title)); alert.setTitle(getString(com.kauron.dungeonmanager.R.string.reset_confirmation_title));
alert.setMessage(getString(com.kauron.dungeonmanager.R.string.reset_confirmation)); alert.setMessage(getString(com.kauron.dungeonmanager.R.string.reset_confirmation));
@ -99,50 +103,22 @@ public class MainActivity extends ActionBarActivity
}); });
alert.show(); alert.show();
// } else if (id == R.id.action_save) {
// saveData();
// } else if (id == R.id.action_load) {
// restoreData();
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
public void showHealthDialog(){
DialogFragment dialog = HealthDialogFragment.newInstance(player.getCurativeEfforts());
dialog.show(getFragmentManager(), "HealthDialogFragment");
}
@Override
protected void onPause() {
super.onPause();
Log.e("UTIL", "pause");
}
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
Log.e("UTIL", "resume");
restoreData(); restoreData();
healthStatusCheck(); healthStatusCheck();
updateCurativeString(); updateCurativeString();
} }
@Override public void heal(boolean usesEffort
protected void onStop() { ) {
super.onStop(); int hasCured = player.recoverPg(Player.USE_CURATIVE_EFFORT, usesEffort);
Log.e("UTIL", "stop");
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.e("UTIL", "destroy");
}
@Override
public void heal(DialogFragment dialog, boolean uses) {
int hasCured = player.recoverPg(Player.USE_CURATIVE_EFFORT, uses);
if (hasCured == Player.NOT_CURED) { if (hasCured == Player.NOT_CURED) {
Toast.makeText( Toast.makeText(
getApplicationContext(), getApplicationContext(),
@ -166,6 +142,30 @@ public class MainActivity extends ActionBarActivity
} }
} }
public void healDialog() {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setMessage(com.kauron.dungeonmanager.R.string.new_energies_message)
.setTitle(com.kauron.dungeonmanager.R.string.new_energies)
.setPositiveButton(com.kauron.dungeonmanager.R.string.me, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
heal(true);
}
})
.setNegativeButton(com.kauron.dungeonmanager.R.string.other, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
heal(false);
}
})
.setNeutralButton(com.kauron.dungeonmanager.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
alert.show();
}
public void damage(final View view){ public void damage(final View view){
AlertDialog.Builder alert = new AlertDialog.Builder(this); AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle(getString(com.kauron.dungeonmanager.R.string.suffer_damage)); alert.setTitle(getString(com.kauron.dungeonmanager.R.string.suffer_damage));
@ -310,8 +310,8 @@ public class MainActivity extends ActionBarActivity
}); });
} }
player.setCurativeEffort(p.getInt("curativeEfforts", player.getCurativeEfforts()));
player.setPg(p.getInt("pg", player.getMaxPg())); player.setPg(p.getInt("pg", player.getPg()));
healthStatusCheck(); healthStatusCheck();
updateCurativeString(); updateCurativeString();
//set restored values to the respective fields //set restored values to the respective fields
@ -371,11 +371,11 @@ public class MainActivity extends ActionBarActivity
private void updateCurativeString() { private void updateCurativeString() {
((TextView) findViewById(com.kauron.dungeonmanager.R.id.curativeEffortsText)).setText( ((TextView) findViewById(com.kauron.dungeonmanager.R.id.curativeEffortsText)).setText(
getString(com.kauron.dungeonmanager.R.string.curative_display_text1) + " " + getString(
player.getCurativeEfforts() + " " + R.string.curative_display_text,
getString(com.kauron.dungeonmanager.R.string.curative_display_text2) + " " + player.getCurativeEfforts(),
player.getMaxCurativeEfforts() + " " + player.getMaxCurativeEfforts()
getString(com.kauron.dungeonmanager.R.string.curative_display_text3) )
); );
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 B

After

Width:  |  Height:  |  Size: 721 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 200 B

After

Width:  |  Height:  |  Size: 483 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 315 B

After

Width:  |  Height:  |  Size: 966 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 871 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 435 B

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -2,8 +2,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
tools:context="com.kauron.dungeonmanager.Introduction"> tools:context="com.kauron.dungeonmanager.Introduction">
<item android:id="@+id/action_finish" <item android:id="@+id/action_save"
android:title="@string/action_finish" android:title="@string/action_save"
android:orderInCategory="100" android:orderInCategory="100"
android:icon="@drawable/ic_action_save" android:icon="@drawable/ic_action_save"
app:showAsAction="ifRoom" /> app:showAsAction="ifRoom" />

View file

@ -5,13 +5,50 @@
android:id="@+id/action_undo" android:id="@+id/action_undo"
android:title="@string/action_undo" android:title="@string/action_undo"
android:orderInCategory="1" android:orderInCategory="1"
app:showAsAction="always" app:showAsAction="never"
android:icon="@drawable/ic_action_undo"/> android:icon="@drawable/ic_action_undo"/>
<item <item
android:id="@+id/action_cure" android:id="@+id/action_cure"
android:title="@string/action_cure" android:title="@string/action_cure"
android:orderInCategory="2" android:orderInCategory="2"
app:showAsAction="always"/> android:icon="@drawable/ic_action_heal"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/action_time"
android:title="@string/action_time"
android:orderInCategory="3"
app:showAsAction="ifRoom"
android:icon="@drawable/ic_action_time">
<menu>
<item
android:title="@string/action_time_turn"
android:id="@+id/action_time_turn"
android:orderInCategory="1"
app:showAsAction="never"/>
<item
android:title="@string/action_time_rest"
android:id="@+id/action_time_rest"
android:orderInCategory="2"
app:showAsAction="never"/>
<item
android:title="@string/action_time_day"
android:id="@+id/action_time_day"
android:orderInCategory="5"
app:showAsAction="never"/>
<item
android:title="@string/action_time_long_rest"
android:id="@+id/action_time_long_rest"
android:orderInCategory="4"
app:showAsAction="never"/>
<item
android:title="@string/action_time_encounter_end"
android:id="@+id/action_time_encounter_end"
android:orderInCategory="5"
app:showAsAction="never"/>
</menu>
</item>
<item <item
android:id="@+id/action_edit_basics" android:id="@+id/action_edit_basics"

View file

@ -2,7 +2,7 @@
<resources> <resources>
<string name="action_cure">Curar</string> <string name="action_cure">Curar</string>
<string name="action_edit_basics">Editar personaje</string> <string name="action_edit_basics">Editar personaje</string>
<string name="action_finish">Hecho</string> <string name="action_finish">PG Máx.</string>
<string name="adventurer_name">Nombre</string> <string name="adventurer_name">Nombre</string>
<string name="cancel">Cancelar</string> <string name="cancel">Cancelar</string>
<string name="class_name">Clase</string> <string name="class_name">Clase</string>
@ -17,6 +17,7 @@
<string name="no">No</string> <string name="no">No</string>
<string name="no_curative_efforts_error">No te quedan esfuerzos curativos</string> <string name="no_curative_efforts_error">No te quedan esfuerzos curativos</string>
<string name="ok">Ok</string> <string name="ok">Ok</string>
<string name="action_save">Guardar</string>
<string name="race_name">Raza</string> <string name="race_name">Raza</string>
<string name="suffer_damage">Indica el daño sufrido</string> <string name="suffer_damage">Indica el daño sufrido</string>
<string name="title_activity_introduction">Editar personaje</string> <string name="title_activity_introduction">Editar personaje</string>
@ -24,16 +25,10 @@
<string name="max_curative_efforts">Máx. esfuerzos curativos</string> <string name="max_curative_efforts">Máx. esfuerzos curativos</string>
<string name="suffer_damage_hint">PG perdidos</string> <string name="suffer_damage_hint">PG perdidos</string>
<string name="action_undo">Deshacer</string> <string name="action_undo">Deshacer</string>
<string name="action_save">Guardar</string>
<string name="action_undo_current_pg">Acción deshecha</string> <string name="action_undo_current_pg">Acción deshecha</string>
<string name="dungeons_and_dragons">Dragones y Mazmorras</string>
<string name="action_load">Cargar</string>
<string name="curative_efforts">Esfuerzos curativos</string> <string name="curative_efforts">Esfuerzos curativos</string>
<string name="pg">PG</string> <string name="pg">PG</string>
<string name="action_reset">Borrar datos</string> <string name="action_reset">Borrar datos</string>
<string name="curative_display_text1">Te quedan</string>
<string name="curative_display_text2">de</string>
<string name="curative_display_text3">esfuerzos curativos diarios</string>
<string name="die">Morir</string> <string name="die">Morir</string>
<string name="message_death">Has muerto</string> <string name="message_death">Has muerto</string>
<string name="message_reset">Los datos han sido borrados</string> <string name="message_reset">Los datos han sido borrados</string>
@ -45,8 +40,8 @@
<string name="FUE">FUE</string> <string name="FUE">FUE</string>
<string name="INT">INT</string> <string name="INT">INT</string>
<string name="SAB">SAB</string> <string name="SAB">SAB</string>
<string name="state_changed_debilitado">Te has caído al suelo debilitado, no puedes moverte ni hacer nada.</string> <string name="state_changed_debilitado">Te has caído al suelo inconsciente, no puedes hacer nada.</string>
<string name="state_changed_malherido">¡Sólo tienes la mitad de la vida!</string> <string name="state_changed_malherido">Estás maltrecho</string>
<string name="new_energies_message">¿Quién va a usar un esfuerzo curativo?</string> <string name="new_energies_message">¿Quién va a usar un esfuerzo curativo?</string>
<string name="me">Yo</string> <string name="me">Yo</string>
<string name="other">Otro</string> <string name="other">Otro</string>
@ -56,4 +51,11 @@
<string name="FORT">FORT</string> <string name="FORT">FORT</string>
<string name="REF">REF</string> <string name="REF">REF</string>
<string name="VOL">VOL</string> <string name="VOL">VOL</string>
<string name="action_time">Avanzar tiempo</string>
<string name="action_time_day">Día</string>
<string name="action_time_encounter_end">Fin de encuentro</string>
<string name="action_time_long_rest">Descanso largo</string>
<string name="action_time_rest">Descanso corto</string>
<string name="action_time_turn">Turno siguiente</string>
<string name="curative_display_text">Tienes %1$d de %2$d esfuerzos curativos</string>
</resources> </resources>

View file

@ -13,36 +13,37 @@
<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="curative_display_text1">You have</string> <string name="curative_display_text">You have %1$d out of %2$d curative efforts</string>
<string name="curative_display_text2">out of</string>
<string name="curative_display_text3">daily curative efforts.</string>
<string name="action_load">Load</string>
<string name="dungeons_and_dragons">Dungeons and Dragons</string>
<string name="action_save">Save</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>
<string name="reset_confirmation">All data will be lost!</string> <string name="reset_confirmation">All data will be lost!</string>
<string name="action_undo_current_pg">Action undone</string> <string name="action_undo_current_pg">Action undone</string>
<string name="action_edit_basics">Edit character</string> <string name="action_edit_basics">Edit character</string>
<string name="action_time">Time events</string>
<string name="action_time_turn">Next turn</string>
<string name="action_time_rest">Short rest</string>
<string name="action_time_long_rest">Long rest</string>
<string name="action_time_day">Next day</string>
<string name="action_time_encounter_end">Encounter ended</string>
<string name="adventurer_name">Adventurer name</string> <string name="adventurer_name">Adventurer name</string>
<string name="state_changed_malherido">You have less than half of your maximum health</string> <string name="state_changed_malherido">You have less than half of your maximum health</string>
<string name="new_energies_message">Who is using a curative effort?</string> <string name="new_energies_message">Who is using a curative effort?</string>
<string name="class_name">Class</string> <string name="class_name">Class</string>
<string name="race_name">Race</string> <string name="race_name">Race</string>
<string name="state_changed_debilitado">You have fainted. You can\'t move or do anything!</string> <string name="state_changed_debilitado">You have fainted. You can\'t do anything!</string>
<string name="cancel">Cancel</string> <string name="cancel">Cancel</string>
<string name="ok">Ok</string> <string name="ok">Ok</string>
<string name="yes">Yes</string> <string name="yes">Yes</string>
<string name="no">No</string> <string name="no">No</string>
<string name="edit_PG_Title">Suffer damage</string> <string name="edit_PG_Title">Suffer damage</string>
<string name="message_death">Your character has died</string> <string name="message_death">You have died</string>
<string name="new_energies1">You have</string> <string name="new_energies1">You have</string>
<string name="new_energies2">curative efforts</string> <string name="new_energies2">curative efforts</string>
<string name="new_energies">New energies</string> <string name="new_energies">New energies</string>
<string name="title_activity_introduction">Edit character</string> <string name="title_activity_introduction">Edit character</string>
<string name="action_finish">Done</string> <string name="action_finish">Save</string>
<string name="level">Level</string> <string name="level">Level</string>
<string name="max_curative_efforts">Max curative efforts</string> <string name="max_curative_efforts">Max curative efforts</string>
@ -61,4 +62,5 @@
<string name="INT">INT</string> <string name="INT">INT</string>
<string name="CAR">CAR</string> <string name="CAR">CAR</string>
<string name="SAB">SAB</string> <string name="SAB">SAB</string>
<string name="action_save">Save</string>
</resources> </resources>