CEff correction
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -67,7 +67,7 @@ public class Introduction extends ActionBarActivity {
|
|||
int id = item.getItemId();
|
||||
|
||||
//noinspection SimplifiableIfStatement
|
||||
if (id == com.kauron.dungeonmanager.R.id.action_finish) {
|
||||
if (id == com.kauron.dungeonmanager.R.id.action_save) {
|
||||
if(finished()) {
|
||||
this.finish();
|
||||
} else {
|
||||
|
|
|
@ -19,8 +19,7 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
|
||||
|
||||
public class MainActivity extends ActionBarActivity
|
||||
implements HealthDialogFragment.HealthDialogListener{
|
||||
public class MainActivity extends ActionBarActivity{
|
||||
|
||||
public static final int CURRENT_PG = 1, NULL = 0;
|
||||
|
||||
|
@ -49,8 +48,6 @@ public class MainActivity extends ActionBarActivity
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
|
@ -60,7 +57,15 @@ public class MainActivity extends ActionBarActivity
|
|||
|
||||
//noinspection SimplifiableIfStatement
|
||||
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;
|
||||
} else if (id == com.kauron.dungeonmanager.R.id.action_edit_basics) {
|
||||
//TODO: try this startChildActivity()
|
||||
|
@ -76,7 +81,6 @@ public class MainActivity extends ActionBarActivity
|
|||
undo();
|
||||
return true;
|
||||
} else if (id == com.kauron.dungeonmanager.R.id.action_reset) {
|
||||
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||
alert.setTitle(getString(com.kauron.dungeonmanager.R.string.reset_confirmation_title));
|
||||
alert.setMessage(getString(com.kauron.dungeonmanager.R.string.reset_confirmation));
|
||||
|
@ -99,50 +103,22 @@ public class MainActivity extends ActionBarActivity
|
|||
});
|
||||
|
||||
alert.show();
|
||||
// } else if (id == R.id.action_save) {
|
||||
// saveData();
|
||||
// } else if (id == R.id.action_load) {
|
||||
// restoreData();
|
||||
}
|
||||
|
||||
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
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
Log.e("UTIL", "resume");
|
||||
restoreData();
|
||||
healthStatusCheck();
|
||||
updateCurativeString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
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);
|
||||
public void heal(boolean usesEffort
|
||||
) {
|
||||
int hasCured = player.recoverPg(Player.USE_CURATIVE_EFFORT, usesEffort);
|
||||
if (hasCured == Player.NOT_CURED) {
|
||||
Toast.makeText(
|
||||
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){
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||
alert.setTitle(getString(com.kauron.dungeonmanager.R.string.suffer_damage));
|
||||
|
@ -310,8 +310,8 @@ public class MainActivity extends ActionBarActivity
|
|||
});
|
||||
|
||||
}
|
||||
|
||||
player.setPg(p.getInt("pg", player.getMaxPg()));
|
||||
player.setCurativeEffort(p.getInt("curativeEfforts", player.getCurativeEfforts()));
|
||||
player.setPg(p.getInt("pg", player.getPg()));
|
||||
healthStatusCheck();
|
||||
updateCurativeString();
|
||||
//set restored values to the respective fields
|
||||
|
@ -371,11 +371,11 @@ public class MainActivity extends ActionBarActivity
|
|||
|
||||
private void updateCurativeString() {
|
||||
((TextView) findViewById(com.kauron.dungeonmanager.R.id.curativeEffortsText)).setText(
|
||||
getString(com.kauron.dungeonmanager.R.string.curative_display_text1) + " " +
|
||||
player.getCurativeEfforts() + " " +
|
||||
getString(com.kauron.dungeonmanager.R.string.curative_display_text2) + " " +
|
||||
player.getMaxCurativeEfforts() + " " +
|
||||
getString(com.kauron.dungeonmanager.R.string.curative_display_text3)
|
||||
getString(
|
||||
R.string.curative_display_text,
|
||||
player.getCurativeEfforts(),
|
||||
player.getMaxCurativeEfforts()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Before Width: | Height: | Size: 254 B After Width: | Height: | Size: 721 B |
BIN
app/src/main/res/drawable-hdpi/ic_action_time.png
Normal file
After Width: | Height: | Size: 647 B |
Before Width: | Height: | Size: 200 B After Width: | Height: | Size: 483 B |
BIN
app/src/main/res/drawable-mdpi/ic_action_time.png
Normal file
After Width: | Height: | Size: 460 B |
Before Width: | Height: | Size: 315 B After Width: | Height: | Size: 966 B |
BIN
app/src/main/res/drawable-xhdpi/ic_action_time.png
Normal file
After Width: | Height: | Size: 871 B |
Before Width: | Height: | Size: 435 B After Width: | Height: | Size: 1.4 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_action_time.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
|
@ -2,8 +2,8 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.kauron.dungeonmanager.Introduction">
|
||||
<item android:id="@+id/action_finish"
|
||||
android:title="@string/action_finish"
|
||||
<item android:id="@+id/action_save"
|
||||
android:title="@string/action_save"
|
||||
android:orderInCategory="100"
|
||||
android:icon="@drawable/ic_action_save"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
|
|
@ -5,13 +5,50 @@
|
|||
android:id="@+id/action_undo"
|
||||
android:title="@string/action_undo"
|
||||
android:orderInCategory="1"
|
||||
app:showAsAction="always"
|
||||
app:showAsAction="never"
|
||||
android:icon="@drawable/ic_action_undo"/>
|
||||
<item
|
||||
android:id="@+id/action_cure"
|
||||
android:title="@string/action_cure"
|
||||
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
|
||||
android:id="@+id/action_edit_basics"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<resources>
|
||||
<string name="action_cure">Curar</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="cancel">Cancelar</string>
|
||||
<string name="class_name">Clase</string>
|
||||
|
@ -17,6 +17,7 @@
|
|||
<string name="no">No</string>
|
||||
<string name="no_curative_efforts_error">No te quedan esfuerzos curativos</string>
|
||||
<string name="ok">Ok</string>
|
||||
<string name="action_save">Guardar</string>
|
||||
<string name="race_name">Raza</string>
|
||||
<string name="suffer_damage">Indica el daño sufrido</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="suffer_damage_hint">PG perdidos</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="dungeons_and_dragons">Dragones y Mazmorras</string>
|
||||
<string name="action_load">Cargar</string>
|
||||
<string name="curative_efforts">Esfuerzos curativos</string>
|
||||
<string name="pg">PG</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="message_death">Has muerto</string>
|
||||
<string name="message_reset">Los datos han sido borrados</string>
|
||||
|
@ -45,8 +40,8 @@
|
|||
<string name="FUE">FUE</string>
|
||||
<string name="INT">INT</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_malherido">¡Sólo tienes la mitad de la vida!</string>
|
||||
<string name="state_changed_debilitado">Te has caído al suelo inconsciente, no puedes hacer nada.</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="me">Yo</string>
|
||||
<string name="other">Otro</string>
|
||||
|
@ -56,4 +51,11 @@
|
|||
<string name="FORT">FORT</string>
|
||||
<string name="REF">REF</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>
|
|
@ -13,36 +13,37 @@
|
|||
<string name="VOL">VOL</string>
|
||||
<string name="defense">Defense</string>
|
||||
<string name="curative_efforts">Curative efforts</string>
|
||||
<string name="curative_display_text1">You have</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="curative_display_text">You have %1$d out of %2$d curative efforts</string>
|
||||
<string name="action_reset">Reset</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">All data will be lost!</string>
|
||||
<string name="action_undo_current_pg">Action undone</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="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="class_name">Class</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="ok">Ok</string>
|
||||
<string name="yes">Yes</string>
|
||||
<string name="no">No</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_energies2">curative efforts</string>
|
||||
<string name="new_energies">New energies</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="max_curative_efforts">Max curative efforts</string>
|
||||
|
@ -61,4 +62,5 @@
|
|||
<string name="INT">INT</string>
|
||||
<string name="CAR">CAR</string>
|
||||
<string name="SAB">SAB</string>
|
||||
<string name="action_save">Save</string>
|
||||
</resources>
|
||||
|
|