1
0
Fork 0

Added powers and powersList

Still don't have powerDisplay or deletion process
This commit is contained in:
Carlos Galindo 2015-04-22 17:50:18 +02:00
parent 8451167c94
commit 9a9af9d6e5
21 changed files with 832 additions and 798 deletions

View file

@ -13,7 +13,7 @@
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View file

@ -8,17 +8,17 @@
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:name=".ShowPlayer"
android:label="@string/app_name" >
</activity>
<activity
android:name=".Introduction"
android:name=".PlayerEditor"
android:label="@string/title_activity_introduction" >
<!-- android:parentActivityName=".MainActivity" -->
<!-- android:parentActivityName=".ShowPlayer" -->
<!-- <meta-data -->
<!-- android:name="android.support.PARENT_ACTIVITY" -->
<!-- android:value=".MainActivity" /> -->
<!-- android:value=".ShowPlayer" /> -->
</activity>
<activity
android:name=".Welcome"

View file

@ -3,6 +3,8 @@ package com.kauron.dungeonmanager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -10,11 +12,14 @@ import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.nispok.snackbar.Snackbar;
import com.nispok.snackbar.SnackbarManager;
import com.nispok.snackbar.listeners.ActionClickListener;
import java.io.File;
class AttackAdapter extends ArrayAdapter<Power> {
AttackAdapter(Context context, Power[] powers) {
super(context, R.layout.attack_row, powers);
@ -32,24 +37,45 @@ class AttackAdapter extends ArrayAdapter<Power> {
((TextView) mView.findViewById(R.id.frequency)).setText(attack.getFrequencyString());
((TextView) mView.findViewById(R.id.extra)).setText(attack.getRangeString() + " " + attack.getDistance());
final AttackAdapter current = this;
((ImageView) mView.findViewById(R.id.delete)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SnackbarManager.show(
Snackbar.with(getContext()).text("¿Quieres borrarlo?").actionLabel("").actionListener(new ActionClickListener() {
@Override
public void onActionClicked(Snackbar snackbar) {
current.remove(attack);
}
})
);
//TODO: convert text to resource
}
});
} else {
this.remove(attack);
mView.findViewById(R.id.delete);
// mView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// SnackbarManager.show(
// Snackbar.with(getContext()).text("¿Quieres borrarlo?").actionLabel("").actionListener(new ActionClickListener() {
// @Override
// public void onActionClicked(Snackbar snackbar) {
// //delete the item
// String name = p.getString("power" + position, "");
// if (name != null && !name.isEmpty()) {
// getContext().getSharedPreferences(name, Context.MODE_PRIVATE).edit().clear().apply();
// Log.d("Tag", activity.getApplicationContext().getFilesDir().getParent()
// + File.separator + "shared_prefs" + File.separator + name + ".xml");
// try {
// if (!new File(activity.getApplicationContext().getFilesDir().getParent()
// + File.separator + "shared_prefs" + File.separator + name + ".xml").delete())
// throw new Exception();
// } catch (Exception e) {
// Toast.makeText(getContext(), "Error deleting player files", Toast.LENGTH_SHORT).show();
// }
// int max = p.getInt("powers", 0);
// SharedPreferences.Editor ed = p.edit();
// for (int i = position; i < max - 1; i++)
// ed.putString("power" + i, p.getString("power" + (i + 1), "max"));
// ed.putInt("powers", max - 1).apply();
// load();
// ed.remove("power" + (max - 1)).apply();
// }
// }
//
// ));
// //TODO: convert text to resource
// }
// }
//
// );
// };
}
return mView;
}
}

View file

@ -1,7 +1,6 @@
package com.kauron.dungeonmanager;
import android.content.SharedPreferences;
import java.io.Serializable;
class Player implements Serializable {
@ -110,10 +109,8 @@ class Player implements Serializable {
private String name;
private int level;
//TODO: use dice dialogs
private int[] atk, def, abilities;
private boolean[] abilitiesTrained;
private int[] atk, def;
//TODO: implement fully operational powers displayed as cards
private Power[] powers;
Player (SharedPreferences p) {
this.name = p.getString(NAME, "Player");
@ -133,40 +130,6 @@ class Player implements Serializable {
setState();
this.pg = p.getInt( "pg" , maxPg);
this.curativeEfforts = p.getInt( "curativeEfforts" , maxCurativeEfforts );
//TODO: load powers from wherever they are saved
}
/** Constructor for creating a new character*/
Player( String name, int classInt, int raceInt,
int px, int[] atk, Power[] powers){
this.name = name;
this.px = px;
setLevel();
this.raceInt = raceInt;
this.classInt = classInt;
this.def = new int[4];
setAtk(atk);
setState();
pg = maxPg;
curativeEfforts = maxCurativeEfforts;
this.powers = powers;
}
/** Constructor for restoring the Player in the middle of the game*/
Player( int pg, int px, int curativeEfforts, int classInt, int raceInt, int[] atk, String name, Power[] powers) {
this.px = px;
setLevel();
setAtk(atk);
this.classInt = classInt;
this.raceInt = raceInt;
setClass();
this.name = name;
this.powers = powers;
this.pg = pg;
this.curativeEfforts = curativeEfforts;
setState();
}
int getPx() {return px;}
@ -241,34 +204,11 @@ class Player implements Serializable {
}
String getName() {return name;}
void setName(String name) {this.name = name;}
int getClassInt() {return classInt;}
void setClassInt(int classInt) {
this.classInt = classInt;
if (atk != null) setClass();
}
String getClassName() {return CLASS_STRINGS[classInt];}
String getRaceName() {return RACE_STRINGS[raceInt];}
void setRaceInt(int raceInt) {this.raceInt = raceInt;}
int getRaceInt() {return raceInt;}
//TODO: implement turns (for bonuses and continuous damage in the app
void rest(boolean isLong) {
if(isLong) {
pg = maxPg;
curativeEfforts = maxCurativeEfforts;
for (Power p : powers)
if (p != null)
p.recover(Power.DIARIO);
setState();
}
for (Power p : powers)
if (p != null)
p.recover(Power.ENCUENTRO);
}
void setAtk(int[] atk) {this.atk = atk; if(classInt != NULL) setClass();}
int getFue() {return atk[FUE];}

View file

@ -15,7 +15,7 @@ import com.nispok.snackbar.Snackbar;
import com.nispok.snackbar.SnackbarManager;
public class Introduction extends ActionBarActivity {
public class PlayerEditor extends ActionBarActivity {
private EditText name, level;
private EditText fue, con, des, sab, intel, car;
@ -25,7 +25,7 @@ public class Introduction extends ActionBarActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.activity_introduction);
setContentView(R.layout.activity_player_editor);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
name = (EditText) findViewById(R.id.editNameIntro);
@ -61,7 +61,7 @@ public class Introduction extends ActionBarActivity {
@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_introduction, menu);
getMenuInflater().inflate(R.menu.menu_player_editor, menu);
return true;
}

View file

@ -1,5 +1,7 @@
package com.kauron.dungeonmanager;
import android.content.SharedPreferences;
import java.io.Serializable;
class Power implements Serializable{
@ -15,37 +17,33 @@ class Power implements Serializable{
/**dies
* They are represented by its max size
* 0 corresponds to [A], the weapon
* any other is represented by d2, d4, d6, d8, d10, d12, d20, d100
* any other is represented by [A], d2, d4, d6, d8, d10, d12, d20, d100, extra damage
*/
public static final int[] DIE = {0, 2, 4, 6, 8, 10, 12, 20, 100};
public static final int[] DIE = {0, 2, 4, 6, 8, 10, 12, 20, 100, 0};
private boolean used;
private int freq, action, distance, range, objectives;
private String name, description;
private String[] keywords; //fire, spell...
private String name, impact, objective;
private String keywords; //fire, spell...
private int atk, def; //constants from Player to denote atk and defense
private int[] damage; //the max sizes of the different dies
Power ( SharedPreferences p ) {
this.name = p.getString("s0", "Name");
this.keywords = p.getString("s1", "Keywords");
this.impact = p.getString("s2", "2d10");
this.distance = Integer.parseInt(p.getString("s3", "10"));
this.objective = p.getString("s4", "One creature");
Power(String name, String desc, int freq, int action, int distance, String[] keywords,
int atk, int def, int[] damage){
used = false;
this.name = name; this.description = desc;
this.freq = freq; this.action = action;
this.distance = distance;
this.keywords = keywords;
this.used = p.getBoolean("used", false);
this.freq = p.getInt("i0", 0);
this.range = p.getInt("i1", 0);
this.atk = p.getInt("i2", 0);
this.def = p.getInt("i3", 0);
this.action = p.getInt("i4", 0);
}
String getKeywords() {
if ( keywords != null && keywords.length != 0 ) {
String r = keywords[0];
for (String k : keywords) r += ", " + k;
return r;
} else {
return "";
}
}
String getKeywords() {return keywords;}
String getFrequencyString() {return FREQ[freq];}
int getFreq() {return freq;}
@ -56,7 +54,7 @@ class Power implements Serializable{
int getDistance() {return distance;}
String getName(){return name;}
String getDescription() {return description;}
String getImpact() {return impact;}
boolean isUsed(){return used;}
@ -68,13 +66,6 @@ class Power implements Serializable{
}
int rollAttack() {return atk + (int)(Math.random()*20) + 1;}
int rollDamage() {
int roll = 0;
for(int i : damage) {
roll += (int)(Math.random()*i + 1);
}
return roll;
}
void recover(int type){
if(this.freq <= type) used = false;

View file

@ -1,23 +1,134 @@
package com.kauron.dungeonmanager;
import android.content.SharedPreferences;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
public class PowerEditor extends ActionBarActivity {
public static final String NAME="name", FREQ="freq", KEYWORDS="keywords", RANGE="range", DISTANCE="distance";
private EditText [] edits = new EditText[5];
private Spinner [] spinners = new Spinner[5];
private String[] strings = new String[5];
private int[] ints = new int[5];
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_power_editor);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
//EditText
edits[0] = (EditText) findViewById(R.id.nameEdit);
edits[0].requestFocus();
edits[1] = (EditText) findViewById(R.id.keywordsEdit);
edits[2] = (EditText) findViewById(R.id.impactEdit);
edits[3] = (EditText) findViewById(R.id.distanceNumEdit);
edits[4] = (EditText) findViewById(R.id.objectiveEdit);
//Spinners
spinners[0] = (Spinner) findViewById(R.id.freqSpinner);
spinners[0].setAdapter(
new ArrayAdapter<>(
this,
android.R.layout.simple_spinner_dropdown_item,
getResources().getStringArray(R.array.freq_array)
)
);
spinners[1] = (Spinner) findViewById(R.id.rangeSpinner);
spinners[1].setAdapter(
new ArrayAdapter<>(
this,
android.R.layout.simple_spinner_dropdown_item,
getResources().getStringArray(R.array.ranges_array)
)
);
spinners[2] = (Spinner) findViewById(R.id.atkSpinner);
spinners[2].setAdapter(
new ArrayAdapter<>(
this,
android.R.layout.simple_spinner_dropdown_item,
getResources().getStringArray(R.array.atk_array)
)
);
spinners[3] = (Spinner) findViewById(R.id.defSpinner);
spinners[3].setAdapter(
new ArrayAdapter<>(
this,
android.R.layout.simple_spinner_dropdown_item,
getResources().getStringArray(R.array.def_array)
)
);
spinners[4] = (Spinner) findViewById(R.id.actionTypeSpinner);
spinners[4].setAdapter(
new ArrayAdapter<>(
this,
android.R.layout.simple_spinner_dropdown_item,
getResources().getStringArray(R.array.actions_array)
)
);
}
public void saveClick(View view) {
//TODO: save powers
//TODO: change strings per resources
boolean readyToSave = true;
for ( int i = 0; i < edits.length; i++ )
if ( edits[i].getText().toString().trim().length() == 0 ) {
edits[i].setError("This field is required");
readyToSave = false;
} else {
strings[i] = edits[i].getText().toString().trim();
}
for ( int i = 0; i < spinners.length; i++)
if ( spinners[i].getSelectedItemPosition() == 0 ) {
spinners[i].setBackgroundColor(getResources().getColor(R.color.red));
readyToSave = false;
} else {
ints[i] = spinners[i].getSelectedItemPosition();
spinners[i].setBackgroundColor(getResources().getColor(R.color.green));
}
if ( readyToSave ) {
String player = getIntent().getStringExtra("player");
SharedPreferences p = getSharedPreferences(player, MODE_PRIVATE);
int powers = p.getInt("powers", 0);
for (int i = 0; i < powers; i++) {
if ( p.getString("power" + i, "") == strings[0] ) {
edits[0].setError("This power has already been defined. Use another name.");
return;
}
}
p.edit().putString("power" + powers, strings[0])
.putInt("powers", powers + 1)
.apply();
SharedPreferences.Editor ed = getSharedPreferences(strings[0], MODE_PRIVATE).edit();
for (int i = 0; i < strings.length; i++)
ed.putString("s" + i, strings[i]);
for (int i = 0; i < ints.length; i++)
ed.putInt("i" + i, ints[i]);
ed.apply();
finish();
}
}
}

View file

@ -1,11 +1,10 @@
package com.kauron.dungeonmanager;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
@ -15,8 +14,9 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
@ -25,26 +25,27 @@ import com.nispok.snackbar.Snackbar;
import com.nispok.snackbar.SnackbarManager;
import com.nispok.snackbar.listeners.ActionClickListener;
public class MainActivity extends ActionBarActivity {
public class ShowPlayer extends ActionBarActivity {
public static final int CURRENT_PG = 1, NULL = 0;
public Player player;
private boolean undo;
//TODO: fix undo (show snackbar with button in each case, without timing).
private int undoObject, undoPreviousValue;
private ProgressBar pgBar, negPgBar, xpBar, curativeEffortsBar;
private Button pgCurrent;
private TextView currentPg, currentXp, currentCurativeEfforts, lvl;
private TextView currentPg, currentXp, currentCurativeEfforts;
private SharedPreferences p;
private Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Initializing activity (setting toolbar as actionbar)
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setContentView(R.layout.activity_show_player);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
//Loading player
@ -63,9 +64,6 @@ public class MainActivity extends ActionBarActivity {
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);
@ -83,18 +81,19 @@ public class MainActivity extends ActionBarActivity {
@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_main, menu);
getMenuInflater().inflate(R.menu.menu_show_player, menu);
return true;
}
@Override
public boolean onPrepareOptionsMenu (Menu menu) {
MenuItem menuUndo = menu.findItem(R.id.action_undo);
menuUndo.setEnabled(undo);
if (undo)
menuUndo.getIcon().setAlpha(255);
MenuItem menuHeal = menu.findItem(R.id.action_cure);
boolean maxed = player.getPg() == player.getMaxPg();
menuHeal.setEnabled(!maxed);
if (maxed)
menuHeal.getIcon().setAlpha(128);
else
menuUndo.getIcon().setAlpha(128);
menuHeal.getIcon().setAlpha(255);
return true;
}
@ -112,14 +111,12 @@ public class MainActivity extends ActionBarActivity {
Snackbar
.with(this)
.text(R.string.maxed_curative)
.duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE)
);
} else {
healDialog();
}
return true;
} else if (id == R.id.action_undo) {
undo();
return true;
} else if (id == R.id.action_time_encounter_end) {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle(R.string.px_awarded_title);
@ -137,9 +134,6 @@ public class MainActivity extends ActionBarActivity {
//levelUp
//TODO: improve leveling up by using a sliding guide
player.setMaxPgOnLevelUp();
lvl.setText(
String.valueOf(player.getLevel())
);
}
p.edit().putInt("px", player.getPx()).apply();
if(levelUp)
@ -148,12 +142,6 @@ public class MainActivity extends ActionBarActivity {
pxUpdate();
ceUpdate();
pgUpdate();
// 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) {
Toast.makeText(getApplicationContext(), "There was an error leveling up", Toast.LENGTH_LONG).show();
}
@ -162,28 +150,31 @@ public class MainActivity extends ActionBarActivity {
alert.show();
input.requestFocus();
return true;
} else if (id == R.id.action_time_long_rest) {
player.rest(true);
SnackbarManager.show(
Snackbar
.with(this)
.text(R.string.long_rest_done)
);
p.edit()
.putInt("pg", player.getPg())
.putInt("curativeEfforts", player.getCurativeEfforts())
.apply();
pgUpdate();
ceUpdate();
} else if (id == R.id.action_time_rest) {
player.rest(false);
SnackbarManager.show(
Snackbar
.with(this)
.text(R.string.rest_done)
);
pgUpdate();
ceUpdate();
//TODO: the player no longer contains the powers, therefore the
// } else if (id == R.id.action_time_long_rest) {
// player.rest(true);
// SnackbarManager.show(
// Snackbar
// .with(this)
// .text(R.string.long_rest_done)
// .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE)
// );
// p.edit()
// .putInt("pg", player.getPg())
// .putInt("curativeEfforts", player.getCurativeEfforts())
// .apply();
// pgUpdate();
// ceUpdate();
// } else if (id == R.id.action_time_rest) {
// player.rest(false);
// SnackbarManager.show(
// Snackbar
// .with(this)
// .text(R.string.rest_done)
// .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE)
// );
// pgUpdate();
// ceUpdate();
}
return super.onOptionsItemSelected(item);
@ -205,6 +196,7 @@ public class MainActivity extends ActionBarActivity {
Snackbar
.with(this)
.text(R.string.no_curative_efforts_error)
.duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE)
);
} else {
if(hasCured == Player.MAXED){
@ -212,17 +204,13 @@ public class MainActivity extends ActionBarActivity {
Snackbar
.with(this)
.text(R.string.maxed_curative)
.duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE)
);
}
SharedPreferences.Editor e = p.edit();
e.putInt("pg", player.getPg());
if(usesEffort) {
e.putInt("curativeEfforts", player.getCurativeEfforts());
// incrementProgressBar(
// curativeEffortsBar, currentCurativeEfforts,
// 100, false, 0,
// true, player.getCurativeEfforts()
// );
ceUpdate();
}
e.apply();
@ -266,21 +254,14 @@ public class MainActivity extends ActionBarActivity {
alert.setView(input);
final Context context = getApplicationContext();
final MainActivity activity = this;
final ShowPlayer activity = this;
alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
try {
int preValue = Integer.parseInt(pgCurrent.getText().toString());
int preValue = player.getPg();
int damage = Integer.parseInt(input.getText().toString());
player.losePg(damage);
pgCurrent.setText(String.valueOf(player.getPg()));
// incrementProgressBar(
// pgBar, currentPg,
// 100, false, 0,
// true, player.getPg()
// );
//finished correctly, then apply values to undo's
undo = true;
undoPreviousValue = preValue;
undoObject = CURRENT_PG;
@ -294,6 +275,7 @@ public class MainActivity extends ActionBarActivity {
}
})
.actionColor(getResources().getColor(R.color.yellow))
.duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE)
,activity); // action button's
p.edit().putInt("pg", player.getPg()).apply();
pgUpdate();
@ -315,104 +297,43 @@ public class MainActivity extends ActionBarActivity {
private void pgUpdate() {
int status = player.getState();
int lastState = player.getLastState();
int pg = player.getPg();
if (pg < 0) {
if (status == Player.MUERTO)
negPgBar.setProgress(negPgBar.getMax());
else
negPgBar.setProgress(-pg);
pgBar.setProgress(0);
negPgBar.setProgress(-pg);
} else if (pg > 0) {
} else {
pgBar.setProgress(pg);
negPgBar.setProgress(0);
} else {
pgBar.setProgress(0);
negPgBar.setProgress(0);
}
currentPg.setText(player.getPg() + " / " + player.getMaxPg());
// incrementProgressBar(
// pgBar, currentPg,
// 100, false, 0,
// true, Math.abs(player.getPg())
// );
pgCurrent.setText(String.valueOf(player.getPg()));
if (status == Player.MUERTO) {
pgCurrent.setTextColor(Color.BLACK);
pgCurrent.setBackgroundColor(getResources().getColor(R.color.red));
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle(getString(R.string.reset_confirmation_title));
alert.setMessage(getString(R.string.reset_confirmation));
alert.setPositiveButton(R.string.action_undo, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
undo();
}
});
final Activity activity = this;
alert.setNegativeButton(R.string.die, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
SnackbarManager.show(
Snackbar
.with(activity)
.text(R.string.message_death)
);
p.edit().clear().apply();
restoreData();
}
});
alert.show();
pgBar.getProgressDrawable().setColorFilter(getResources().getColor(R.color.black), PorterDuff.Mode.SRC_IN);
} else if (status == Player.DEBILITADO) {
pgCurrent.setBackgroundColor(android.R.drawable.btn_default);
pgCurrent.setTextColor(getResources().getColor(R.color.red));
pgBar.getProgressDrawable().setColorFilter(getResources().getColor(R.color.red), PorterDuff.Mode.SRC_IN);
negPgBar.getProgressDrawable().setColorFilter(getResources().getColor(R.color.red), PorterDuff.Mode.SRC_IN);
if(lastState != Player.SAME) {
SnackbarManager.show(
Snackbar
.with(this)
.text(R.string.state_changed_debilitado)
);
}
} else if (status == Player.MALHERIDO) {
pgCurrent.setBackgroundColor(android.R.drawable.btn_default);
pgCurrent.setTextColor(getResources().getColor(R.color.yellow));
pgBar.getProgressDrawable().setColorFilter(getResources().getColor(R.color.yellow), PorterDuff.Mode.SRC_IN);
negPgBar.getProgressDrawable().setColorFilter(getResources().getColor(R.color.yellow), PorterDuff.Mode.SRC_IN);
if(lastState != Player.SAME) {
SnackbarManager.show(
Snackbar
.with(this)
.text(R.string.state_changed_malherido)
);
}
} else {
pgCurrent.setTextColor(getResources().getColor(R.color.green));
pgCurrent.setBackgroundColor(android.R.drawable.btn_default);
pgBar.getProgressDrawable().setColorFilter(getResources().getColor(R.color.green), PorterDuff.Mode.SRC_IN);
negPgBar.getProgressDrawable().setColorFilter(getResources().getColor(R.color.green), PorterDuff.Mode.SRC_IN);
}
}
private void restoreData(){
if (player == null) {
player = new Player( p );
} else {
player.setName(p.getString(Player.NAME, player.getName()));
player.setClassInt(p.getInt(Player.CLASS, player.getClassInt()));
player.setRaceInt(p.getInt(Player.RACE, player.getRaceInt()));
player.setPx(p.getInt(Player.PX, player.getPx()));
player.setAtk(new int[]{
p.getInt("fue", player.getFue()),
p.getInt("con", player.getCon()),
p.getInt("des", player.getDes()),
p.getInt("int", player.getInt()),
p.getInt("sab", player.getSab()),
p.getInt("car", player.getCar())
});
}
//Loading player
player = new Player( p );
pxUpdate();
xpBar.setMax(
Player.LEVEL_PX[player.getLevel()] -
Player.LEVEL_PX[player.getLevel() - 1]
Player.LEVEL_PX[player.getLevel() - 1]
);
if (player.getMaxPg() == 0) {
@ -427,44 +348,50 @@ public class MainActivity extends ActionBarActivity {
pgUpdate();
ceUpdate();
//set restored values to the respective fields
((TextView) findViewById(R.id.nameText)).setText(player.getName());
((TextView) findViewById(R.id.raceText)).setText(player.getRaceName());
((TextView) findViewById(R.id.classText)).setText(player.getClassName());
lvl.setText(String.valueOf(player.getLevel()));
//attacks
((TextView) findViewById(R.id.FUE)).setText(
getString(R.string.FUE) + ":" + player.getFue()
);
((TextView) findViewById(R.id.CON)).setText(
getString(R.string.CON) + ":" + player.getCon()
);
((TextView) findViewById(R.id.DES)).setText(
getString(R.string.DES) + ":" + player.getDes()
);
((TextView) findViewById(R.id.INT)).setText(
getString(R.string.INT) + ":" + player.getInt()
);
((TextView) findViewById(R.id.SAB)).setText(
getString(R.string.SAB) + ":" + player.getSab()
);
((TextView) findViewById(R.id.CAR)).setText(
getString(R.string.CAR) + ":" + player.getCar()
);
//defenses
((TextView) findViewById(R.id.CA)).setText(
getString(R.string.CA) + ":" + player.getCa()
);
((TextView) findViewById(R.id.FORT)).setText(
getString(R.string.FORT) + ":" + player.getFort()
);
((TextView) findViewById(R.id.REF)).setText(
getString(R.string.REF) + ":" + player.getRef()
);
((TextView) findViewById(R.id.VOL)).setText(
getString(R.string.VOL) + ":" + player.getVol()
toolbar.setTitle(player.getName());
toolbar.setSubtitle(
player.getClassName() + " " + player.getRaceName() + " " + player.getLevel()
);
toolbar.setTitleTextColor(getResources().getColor(R.color.white));
toolbar.setSubtitleTextColor(getResources().getColor(R.color.white));
//
// //attacks
// ((TextView) findViewById(R.id.FUE)).setText(
// getString(R.string.FUE) + ":" + player.getFue()
// );
// ((TextView) findViewById(R.id.CON)).setText(
// getString(R.string.CON) + ":" + player.getCon()
// );
// ((TextView) findViewById(R.id.DES)).setText(
// getString(R.string.DES) + ":" + player.getDes()
// );
// ((TextView) findViewById(R.id.INT)).setText(
// getString(R.string.INT) + ":" + player.getInt()
// );
// ((TextView) findViewById(R.id.SAB)).setText(
// getString(R.string.SAB) + ":" + player.getSab()
// );
// ((TextView) findViewById(R.id.CAR)).setText(
// getString(R.string.CAR) + ":" + player.getCar()
// );
//
// //defenses
// ((TextView) findViewById(R.id.CA)).setText(
// getString(R.string.CA) + ":" + player.getCa()
// );
// ((TextView) findViewById(R.id.FORT)).setText(
// getString(R.string.FORT) + ":" + player.getFort()
// );
// ((TextView) findViewById(R.id.REF)).setText(
// getString(R.string.REF) + ":" + player.getRef()
// );
// ((TextView) findViewById(R.id.VOL)).setText(
// getString(R.string.VOL) + ":" + player.getVol()
// );
//
//
//Loading powers and abilities (not implemented yet)
refreshList();
}
private void ceUpdate() {
@ -487,7 +414,6 @@ public class MainActivity extends ActionBarActivity {
private void undo() {
String message = "";
if(undoObject == CURRENT_PG){
pgCurrent.setText(String.valueOf(undoPreviousValue));
player.setPg(undoPreviousValue);
undoObject = NULL;
message = getString(R.string.action_undo_current_pg);
@ -497,6 +423,7 @@ public class MainActivity extends ActionBarActivity {
Snackbar
.with(this)
.text(message)
.duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE)
);
}
pgUpdate();
@ -526,4 +453,40 @@ public class MainActivity extends ActionBarActivity {
dialog.show();
input.requestFocus();
}
public void addToList (View view) { startActivity(new Intent(this, PowerEditor.class).putExtra("player", player.getName())); }
private void refreshList() {
//TODO: check which is active (now there is only a power list), so there is only one possibility
int n = p.getInt("powers",0);
int elements = 0;
ListView attackList = (ListView) findViewById(R.id.attackList);
AttackAdapter adapter = (AttackAdapter) attackList.getAdapter();
if ( adapter != null )
elements = adapter.getCount();
if ( elements < n && adapter != null ) {
for ( int i = elements; i < n; i++ ) {
SharedPreferences sav = getSharedPreferences(p.getString("power" + i, ""), MODE_PRIVATE);
adapter.add( new Power ( sav ) );
}
} else if ( n != 0 ) {
Power[] powers = new Power[n];
for (int i = 0; i < n; i++) {
SharedPreferences sav = getSharedPreferences(p.getString("power" + i, ""), MODE_PRIVATE);
powers[i] = new Power(sav);
}
attackList.setAdapter(new AttackAdapter(this, powers));
attackList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(getApplicationContext(), ((Power)parent.getItemAtPosition(position)).getName(), Toast.LENGTH_LONG).show();
//TODO: show here dialog with power's complete information, and buttons to use, recharge or delete
}
});
}
}
}

View file

@ -49,7 +49,7 @@ public class Welcome extends ActionBarActivity {
//noinspection SimplifiableIfStatement
if ( id == R.id.action_add_player ) {
startActivity(new Intent(this, Introduction.class).putExtra("first_time", true));
startActivity(new Intent(this, PlayerEditor.class).putExtra("first_time", true));
}
return super.onOptionsItemSelected(item);
@ -61,7 +61,7 @@ public class Welcome extends ActionBarActivity {
load();
}
//TODO: load all players with secondary constructor (except the ones created by introduction and haven't passed by MainActivity)
//TODO: load all players with secondary constructor (except the ones created by introduction and haven't passed by ShowPlayer)
private void load() {
int n = p.getInt("players",0);
ListView playerList = (ListView) findViewById(R.id.listView);
@ -86,7 +86,6 @@ public class Welcome extends ActionBarActivity {
findViewById(R.id.no_players_text).setVisibility(View.GONE);
Player[] players = new Player[n];
for ( int i = 0; i < n; i++ ) {
//TODO: fill the information for the player creation
SharedPreferences sav = getSharedPreferences(p.getString("player" + i, ""), MODE_PRIVATE);
if (sav.contains(Player.NAME))
players[i] = new Player( sav );
@ -98,7 +97,7 @@ public class Welcome extends ActionBarActivity {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
startActivity(new Intent(
getApplicationContext(), MainActivity.class
getApplicationContext(), ShowPlayer.class
).putExtra("player", position));
}
});

View file

@ -1,423 +0,0 @@
<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:orientation="vertical"
tools:context=".MainActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:minHeight="?attr/actionBarSize"
android:background="@color/primary"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
tools:text="Kauron"/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<ScrollView
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/pgCurrent"
android:textSize="40sp"
android:onClick="damage" />
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/scroll1">
<RelativeLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/basicInfoContainer">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/adventurer_name"
android:id="@+id/nameText"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/race_name"
android:id="@+id/raceText"
android:layout_alignTop="@+id/classText"
android:layout_toRightOf="@+id/classText"
android:layout_toEndOf="@+id/classText"
android:layout_marginLeft="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/class_name"
android:id="@+id/classText"
android:layout_below="@+id/nameText"
android:layout_alignParentStart="false"
android:layout_alignParentLeft="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/level"
android:id="@+id/lvlText"
android:layout_alignParentBottom="false"
android:layout_toRightOf="@+id/raceText"
android:layout_toEndOf="@+id/raceText"
android:layout_alignTop="@+id/raceText"
android:layout_marginLeft="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/lvl"
android:layout_alignParentBottom="false"
android:layout_toRightOf="@+id/lvlText"
android:layout_toEndOf="@+id/lvlText"
android:layout_alignTop="@+id/lvlText"
android:layout_marginLeft="10dp" />
</RelativeLayout>
</HorizontalScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/titlePgBar"
android:text="@string/pg"
android:textAllCaps="true"
android:drawableBottom="?android:attr/listChoiceBackgroundIndicator"
android:layout_marginBottom="5dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:layout_weight="1"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:id="@+id/currentPg"
android:textSize="14sp"
android:textStyle="bold"
android:textAllCaps="true"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/negPgBar"
android:layout_weight="2"
android:rotation="180"/>
<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="@string/zero"/>
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/pgBar"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/titleCurativeEffortsBar"
android:text="@string/curative_efforts"
android:textAllCaps="true"
android:drawableBottom="?android:attr/listChoiceBackgroundIndicator"
android:layout_marginBottom="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
android:paddingLeft="8dip"
android:paddingRight="8dip"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold"
android:gravity="end"
android:id="@+id/currentCurativeEfforts"
android:textAllCaps="true"/>
</LinearLayout>
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/curativeEffortsBar"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/titleXpBar"
android:text="@string/px"
android:textAllCaps="true"
android:drawableBottom="?android:attr/listChoiceBackgroundIndicator"
android:layout_marginBottom="5dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:layout_weight="1"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:id="@+id/currentXp"
android:textSize="14sp"
android:textStyle="bold"
android:textAllCaps="true"
android:layout_weight="1"/>
</LinearLayout>
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/xpBar"/>
<LinearLayout
android:id="@+id/attackContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:id="@+id/titleAttack"
android:text="@string/attack"
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"/>
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<GridLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/attackGrid"
android:columnCount="3"
android:rowCount="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="4"
android:layout_row="0"
android:layout_column="0"
android:id="@+id/FUE"
tools:text="@string/FUE" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="4"
android:layout_row="1"
android:layout_column="0"
android:id="@+id/CON"
tools:text="@string/CON" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="4"
android:layout_row="0"
android:layout_column="1"
android:id="@+id/DES"
tools:text="@string/DES" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="4"
android:layout_row="1"
android:layout_column="1"
android:id="@+id/INT"
tools:text="@string/INT" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="4"
android:layout_row="0"
android:layout_column="2"
android:id="@+id/SAB"
tools:text="@string/SAB" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="4"
android:layout_row="1"
android:layout_column="2"
android:id="@+id/CAR"
tools:text="@string/CAR" />
</GridLayout>
</HorizontalScrollView>
</LinearLayout>
<LinearLayout
android:id="@+id/defenseContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:id="@+id/titleDefense"
android:text="@string/defense"
android:textAllCaps="true"
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"/>
<GridLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/defenseGrid"
android:columnCount="2"
android:rowCount="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="5"
android:layout_row="0"
android:layout_column="0"
android:id="@+id/CA"
tools:text="@string/CA" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="5"
android:layout_row="0"
android:layout_column="1"
android:id="@+id/FORT"
tools:text="@string/FORT" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="5"
android:layout_row="1"
android:layout_column="0"
android:id="@+id/REF"
tools:text="@string/REF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="5"
android:layout_row="1"
android:layout_column="1"
android:id="@+id/VOL"
tools:text="@string/VOL" />
</GridLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>

View file

@ -4,7 +4,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".Introduction">
tools:context=".PlayerEditor">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
@ -13,14 +13,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/character_creation"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</android.support.v7.widget.Toolbar>
<RelativeLayout

View file

@ -11,15 +11,6 @@
android:background="@color/primary"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/power_editor"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</android.support.v7.widget.Toolbar>
<ScrollView
android:layout_width="fill_parent"
@ -43,7 +34,7 @@
android:layout_alignParentEnd="true"
android:layout_toEndOf="@+id/keywordsText"
android:layout_toRightOf="@+id/keywordsText"
android:hint="@string/powerNameHint" />
android:hint="@string/powerNameHint"/>
<EditText
android:layout_width="wrap_content"
@ -91,7 +82,7 @@
android:layout_below="@+id/keywordsEdit"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/linearLayout">
android:id="@+id/spinnersLayout">
<Spinner
android:layout_width="match_parent"
@ -118,38 +109,33 @@
android:focusableInTouchMode="true" />
</LinearLayout>
<Spinner
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/atkSpinner"
android:spinnerMode="dropdown"
android:layout_below="@+id/linearLayout"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="@+id/vsText"
android:layout_toStartOf="@+id/vsText" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/defSpinner"
android:spinnerMode="dropdown"
android:layout_below="@+id/linearLayout"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_toRightOf="@+id/vsText"
android:layout_toEndOf="@+id/vsText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/vs"
android:id="@+id/vsText"
android:layout_below="@id/spinnersLayout"
android:orientation="horizontal"
android:gravity="center"
android:layout_below="@+id/linearLayout"
android:layout_centerHorizontal="true"
android:layout_alignBottom="@+id/atkSpinner" />
android:id="@+id/vsLayout">
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/atkSpinner"
android:spinnerMode="dropdown" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/vs"
android:id="@+id/vsText" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/defSpinner"
android:spinnerMode="dropdown" />
</LinearLayout>
<EditText
android:layout_width="wrap_content"
@ -157,13 +143,14 @@
android:inputType="textMultiLine"
android:ems="10"
android:id="@+id/impactEdit"
android:layout_below="@+id/defSpinner"
android:layout_below="@+id/vsLayout"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:hint="@string/impactEditHint"
android:layout_toRightOf="@+id/impactText"
android:layout_toEndOf="@+id/impactText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -171,7 +158,7 @@
android:text="@string/impact"
android:id="@+id/impactText"
android:gravity="center_vertical"
android:layout_below="@+id/atkSpinner"
android:layout_below="@+id/vsLayout"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignBottom="@+id/impactEdit"
@ -220,10 +207,9 @@
android:layout_below="@+id/objectiveEdit"
android:layout_alignRight="@+id/impactEdit"
android:layout_alignEnd="@+id/impactEdit"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@android:color/transparent"
android:onClick="saveClick"/>
android:onClick="saveClick"
android:textColor="@color/primary_dark"/>
</RelativeLayout>
</ScrollView>

View file

@ -0,0 +1,382 @@
<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:orientation="vertical"
tools:context=".ShowPlayer">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:minHeight="?attr/actionBarSize"
android:background="@color/primary"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.Toolbar>
<LinearLayout
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:onClick="damage"
android:clickable="true"
android:layout_marginBottom="@dimen/bar_margin">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/titlePgBar"
android:text="@string/pg"
android:textAllCaps="true"
android:drawableBottom="?android:attr/listChoiceBackgroundIndicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:layout_weight="1"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:id="@+id/currentPg"
android:textSize="14sp"
android:textStyle="bold"
android:textAllCaps="true"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/negPgBar"
android:layout_weight="2"
android:rotation="180"/>
<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="@string/zero"/>
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/pgBar"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginBottom="@dimen/bar_margin">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/titleCurativeEffortsBar"
android:text="@string/curative_efforts"
android:textAllCaps="true"
android:drawableBottom="?android:attr/listChoiceBackgroundIndicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
android:paddingLeft="8dip"
android:paddingRight="8dip"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold"
android:gravity="end"
android:id="@+id/currentCurativeEfforts"
android:textAllCaps="true"/>
</LinearLayout>
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/curativeEffortsBar"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginBottom="@dimen/bar_margin">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/titleXpBar"
android:text="@string/px"
android:textAllCaps="true"
android:drawableBottom="?android:attr/listChoiceBackgroundIndicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:layout_weight="1"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:id="@+id/currentXp"
android:textSize="14sp"
android:textStyle="bold"
android:textAllCaps="true"
android:layout_weight="1"/>
</LinearLayout>
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/xpBar"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/addElement"
android:text="@string/new_attack"
android:textColor="@color/primary"
android:background="@android:color/transparent"
android:onClick="addToList"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/listSelectButton"
android:textColor="@color/primary"
android:background="@android:color/transparent"
tools:text="Go to abilities"/>
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/attackList"
android:layout_gravity="center_horizontal"
android:choiceMode="none" />
<LinearLayout
android:id="@+id/attackContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="@+id/titleAttack"
android:text="@string/attack"
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"/>
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<GridLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/attackGrid"
android:columnCount="3"
android:rowCount="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="4"
android:layout_row="0"
android:layout_column="0"
android:id="@+id/FUE"
tools:text="@string/FUE" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="4"
android:layout_row="1"
android:layout_column="0"
android:id="@+id/CON"
tools:text="@string/CON" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="4"
android:layout_row="0"
android:layout_column="1"
android:id="@+id/DES"
tools:text="@string/DES" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="4"
android:layout_row="1"
android:layout_column="1"
android:id="@+id/INT"
tools:text="@string/INT" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="4"
android:layout_row="0"
android:layout_column="2"
android:id="@+id/SAB"
tools:text="@string/SAB" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="4"
android:layout_row="1"
android:layout_column="2"
android:id="@+id/CAR"
tools:text="@string/CAR" />
</GridLayout>
</HorizontalScrollView>
</LinearLayout>
<LinearLayout
android:id="@+id/defenseContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:visibility="gone"
android:orientation="vertical">
<TextView
android:id="@+id/titleDefense"
android:text="@string/defense"
android:textAllCaps="true"
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"/>
<GridLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/defenseGrid"
android:columnCount="2"
android:rowCount="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="5"
android:layout_row="0"
android:layout_column="0"
android:id="@+id/CA"
tools:text="@string/CA" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="5"
android:layout_row="0"
android:layout_column="1"
android:id="@+id/FORT"
tools:text="@string/FORT" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="5"
android:layout_row="1"
android:layout_column="0"
android:id="@+id/REF"
tools:text="@string/REF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="5"
android:layout_row="1"
android:layout_column="1"
android:id="@+id/VOL"
tools:text="@string/VOL" />
</GridLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View file

@ -14,7 +14,8 @@
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:contentDescription="@string/edit" />
android:contentDescription="@string/edit"
android:tint="@color/black" />
<TextView
tools:text="Happiness"

View file

@ -1,7 +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.Introduction">
tools:context="com.kauron.dungeonmanager.PlayerEditor">
<item android:id="@+id/action_save"
android:title="@string/action_save"
android:orderInCategory="100"

View file

@ -1,13 +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=".MainActivity">
<!--TODO: create fancy responsive toasts for undo's-->
<item
android:id="@+id/action_undo"
android:title="@string/action_undo"
android:orderInCategory="1"
app:showAsAction="ifRoom"
android:icon="@drawable/ic_action_undo"/>
xmlns:tools="http://schemas.android.com/tools" tools:context=".ShowPlayer">
<item
android:id="@+id/action_cure"
android:title="@string/action_cure"

View file

@ -2,7 +2,7 @@
<resources>
<string name="action_cure">Curar</string>
<string name="action_edit_basics">Editar personaje</string>
<string name="action_finish">PG Máx.</string>
<string name="action_finish">Guardar</string>
<string name="adventurer_name">Nombre</string>
<string name="cancel">Cancelar</string>
<string name="class_name">Clase</string>
@ -76,4 +76,23 @@
<string name="load_character">Cargar personaje</string>
<string name="new_character_warning">Esto borrará al personaje anterior</string>
<string name="new_attack">Nuevo ataque</string>
<string name="add_player">Añadir personaje</string>
<string name="character_creation">Creación de personaje</string>
<string name="delete">Borrar</string>
<string name="edit">Editar</string>
<string name="hello_world"></string>
<string name="help_welcome_text">Toca un jugador para seleccionarlo, pulsación larga para opciones</string>
<string name="impact">Impacto</string>
<string name="impactEditHint">1d6 + 4 y eres invisible</string>
<string name="keywords">Palabras clave</string>
<string name="keywordsPowerHint">Arcano, hechizo, psíquico</string>
<string name="name">Nombre</string>
<string name="no_players">No hay personajes, añade uno</string>
<string name="objective">Objetivo</string>
<string name="objectiveHint">Una criatura</string>
<string name="powerNameHint">Mordedura visual</string>
<string name="power_editor">Editor de ataques</string>
<string name="save">Guardar</string>
<string name="save_player">Guardar personaje</string>
<string name="title_activity_power_editor">Editor de poderes</string>
</resources>

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="primary">#795548</color>
<color name="primary_dark">#5D4037</color>
<color name="primary">#5D4037</color>
<color name="primary_dark">#3E2723</color>
<color name="primary_light">#D7CCC8</color>
<color name="accent">#FF5252</color>
<color name="primary_text">#212121</color>
@ -12,9 +12,11 @@
<color name="red">#9F0D0A</color>
<color name="yellow">#FFBB00</color>
<color name="green">#0f0</color>
<color name="white">#EEEEEE</color>
<color name="surges_bar">#989F2B</color>
<color name="px_bar">#005874</color>
<color name="black">#000000</color>
<!--<color name="primary">#5D4037</color>-->
<!--<color name="primaryDark">#3E2723</color>-->
</resources>

View file

@ -3,6 +3,8 @@
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="bar_margin">15dp</dimen>
<dimen name="fab_button_diameter">56dp</dimen>
<dimen name="fab_button_margin_bottom">16dp</dimen>
<dimen name="fab_button_margin_right">16dp</dimen>

View file

@ -35,7 +35,7 @@
<string name="race_name">Race</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="ok">OK</string>
<string name="yes">Yes</string>
<string name="no">No</string>
@ -62,12 +62,12 @@
<string name="other">Otro</string>
<string name="px">XP</string>
<string name="FUE">FUE</string>
<string name="FUE">STR</string>
<string name="CON">CON</string>
<string name="DES">DES</string>
<string name="DES">DEX</string>
<string name="INT">INT</string>
<string name="CAR">CAR</string>
<string name="SAB">SAB</string>
<string name="CAR">CHA</string>
<string name="SAB">WIS</string>
<string name="action_save">Save</string>
<string name="dialog_resolve_max_pg_hint">Max PG</string>
<string name="empty_field">Please input something</string>
@ -94,15 +94,58 @@
<string name="character_creation">Character creation</string>
<string name="name">Name</string>
<string name="keywords">Keywords</string>
<string name="powerNameHint">Mordedura visual</string>
<string name="keywordsPowerHint">Arcano, hechizo, psíquico</string>
<string name="number10">10</string>
<string name="vs">VS</string>
<string name="powerNameHint">Blasting charm</string>
<string name="keywordsPowerHint">Magic, fire, weapon</string>
<string name="number10" translatable="false">10</string>
<string name="vs" translatable="false">VS</string>
<string name="save">Save</string>
<string name="impactEditHint">1d6 + mod. CAR y eres invisible hasta el comienzo del siguiente turno</string>
<string name="impactEditHint">1d6 + mod. CHAR and you become invisible</string>
<string name="impact">Impact</string>
<string name="objective">Objective</string>
<string name="objectiveHint">One creature</string>
<string name="power_editor">Power Editor</string>
<string name="save_player">Save player</string>
<string-array name="freq_array">
<item>Frequency</item>
<item>Opportunity</item>
<item>At will</item>
<item>Encounter</item>
<item>Daily</item>
</string-array>
<string-array name="actions_array">
<item>Action type</item>
<item>Standard</item>
<item>Movement</item>
<item>Minor</item>
<item>Free</item>
</string-array>
<string-array name="ranges_array">
<item>Range</item>
<item>Melee</item>
<item>Ranged</item>
<item>Area</item>
<item>Close</item>
<item>Aura</item>
</string-array>
<string-array name="atk_array">
<item>ATK</item>
<item>STR</item>
<item>CON</item>
<item>DEX</item>
<item>INT</item>
<item>WIS</item>
<item>CHA</item>
</string-array>
<string-array name="def_array">
<item>DEF</item>
<item>AC</item>
<item>FORT</item>
<item>REF</item>
<item>WILL</item>
</string-array>
</resources>

View file

@ -13,4 +13,10 @@
<!--<item name="colorDivider">@color/divider</item>-->
</style>
<!-- TODO: fix-->
<style name="MaterialButton" parent="@android:style/Widget.Button">
<item name="android:textColor">@color/primary</item>
<item name="android:background">@android:color/transparent</item>
</style>
</resources>