Switched to playersList
The players are generated brand-new, as if they were just created
This commit is contained in:
parent
ce44393121
commit
aebb20542e
14 changed files with 440 additions and 262 deletions
|
@ -13,8 +13,7 @@
|
||||||
<ConfirmationsSetting value="0" id="Add" />
|
<ConfirmationsSetting value="0" id="Add" />
|
||||||
<ConfirmationsSetting value="0" id="Remove" />
|
<ConfirmationsSetting value="0" id="Remove" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<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_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
|
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
|
@ -26,7 +26,7 @@ class AttackAdapter extends ArrayAdapter<Power> {
|
||||||
View mView = mInflater.inflate(R.layout.attack_row, parent, false);
|
View mView = mInflater.inflate(R.layout.attack_row, parent, false);
|
||||||
|
|
||||||
final Power attack = getItem(position);
|
final Power attack = getItem(position);
|
||||||
|
if ( attack != null ) {
|
||||||
((TextView) mView.findViewById(R.id.name)).setText(attack.getName());
|
((TextView) mView.findViewById(R.id.name)).setText(attack.getName());
|
||||||
((TextView) mView.findViewById(R.id.keywords)).setText(attack.getKeywords());
|
((TextView) mView.findViewById(R.id.keywords)).setText(attack.getKeywords());
|
||||||
((TextView) mView.findViewById(R.id.frequency)).setText(attack.getFrequencyString());
|
((TextView) mView.findViewById(R.id.frequency)).setText(attack.getFrequencyString());
|
||||||
|
@ -46,6 +46,9 @@ class AttackAdapter extends ArrayAdapter<Power> {
|
||||||
//TODO: convert text to resource
|
//TODO: convert text to resource
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
this.remove(attack);
|
||||||
|
}
|
||||||
|
|
||||||
return mView;
|
return mView;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,18 @@ package com.kauron.dungeonmanager;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.nispok.snackbar.Snackbar;
|
||||||
|
import com.nispok.snackbar.SnackbarManager;
|
||||||
|
|
||||||
|
|
||||||
public class Introduction extends ActionBarActivity {
|
public class Introduction extends ActionBarActivity {
|
||||||
|
|
||||||
|
@ -23,6 +28,8 @@ public class Introduction extends ActionBarActivity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
setContentView(R.layout.activity_introduction);
|
setContentView(R.layout.activity_introduction);
|
||||||
|
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
|
||||||
|
|
||||||
name = (EditText) findViewById(R.id.editNameIntro);
|
name = (EditText) findViewById(R.id.editNameIntro);
|
||||||
name.requestFocus();
|
name.requestFocus();
|
||||||
level = (EditText) findViewById(R.id.editPxIntro);
|
level = (EditText) findViewById(R.id.editPxIntro);
|
||||||
|
@ -96,9 +103,20 @@ public class Introduction extends ActionBarActivity {
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void finishButton(View view){
|
||||||
|
if(finished()) {
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
SnackbarManager.show(
|
||||||
|
Snackbar.with(getApplicationContext()).text(R.string.missing_info_error), this
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean finished() {
|
private boolean finished() {
|
||||||
SharedPreferences p = getSharedPreferences(Welcome.PREFERENCES, MODE_PRIVATE);
|
SharedPreferences p = getSharedPreferences(Welcome.PREFERENCES, MODE_PRIVATE);
|
||||||
SharedPreferences.Editor ed = p.edit();
|
int i = p.getInt("players", 0);
|
||||||
|
SharedPreferences.Editor ed = getSharedPreferences("player" + i, MODE_PRIVATE).edit();
|
||||||
String nameString = name.getText().toString().trim();
|
String nameString = name.getText().toString().trim();
|
||||||
int classInt = classSpinner.getSelectedItemPosition();
|
int classInt = classSpinner.getSelectedItemPosition();
|
||||||
int raceInt = raceSpinner.getSelectedItemPosition();
|
int raceInt = raceSpinner.getSelectedItemPosition();
|
||||||
|
@ -146,8 +164,6 @@ public class Introduction extends ActionBarActivity {
|
||||||
ed.putInt("sab", sab);
|
ed.putInt("sab", sab);
|
||||||
ed.putInt("con", con);
|
ed.putInt("con", con);
|
||||||
ed.putInt("des", des);
|
ed.putInt("des", des);
|
||||||
|
|
||||||
ed.putBoolean("saved", true);
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -165,6 +181,8 @@ public class Introduction extends ActionBarActivity {
|
||||||
if (des != 0) ed.putInt("des", des);
|
if (des != 0) ed.putInt("des", des);
|
||||||
}
|
}
|
||||||
ed.apply();
|
ed.apply();
|
||||||
|
getSharedPreferences(Welcome.PREFERENCES, MODE_PRIVATE).edit()
|
||||||
|
.putInt("players", i + 1).apply();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.kauron.dungeonmanager;
|
package com.kauron.dungeonmanager;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
@ -43,11 +44,10 @@ public class MainActivity extends ActionBarActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
setContentView(R.layout.activity_main);
|
p = getSharedPreferences("player" + getIntent().getIntExtra("player", 0), MODE_PRIVATE);
|
||||||
|
|
||||||
p = getSharedPreferences(Welcome.PREFERENCES, MODE_PRIVATE);
|
|
||||||
xpBar = (ProgressBar) findViewById(R.id.xpBar);
|
xpBar = (ProgressBar) findViewById(R.id.xpBar);
|
||||||
curativeEffortsBar = (ProgressBar) findViewById(R.id.curativeEffortsBar);
|
curativeEffortsBar = (ProgressBar) findViewById(R.id.curativeEffortsBar);
|
||||||
pgBar = (ProgressBar) findViewById(R.id.pgBar);
|
pgBar = (ProgressBar) findViewById(R.id.pgBar);
|
||||||
|
@ -60,11 +60,11 @@ public class MainActivity extends ActionBarActivity {
|
||||||
currentXp = (TextView) findViewById(R.id.currentXp);
|
currentXp = (TextView) findViewById(R.id.currentXp);
|
||||||
currentCurativeEfforts = (TextView) findViewById(R.id.currentCurativeEfforts);
|
currentCurativeEfforts = (TextView) findViewById(R.id.currentCurativeEfforts);
|
||||||
|
|
||||||
//TODO: change references to xml and do not change progressbar background
|
//TODO: do not change progressbar background
|
||||||
xpBar.getProgressDrawable()
|
xpBar.getProgressDrawable()
|
||||||
.setColorFilter(Color.parseColor("#62BACE"), PorterDuff.Mode.SRC_IN);
|
.setColorFilter(getResources().getColor(R.color.px_bar), PorterDuff.Mode.SRC_IN);
|
||||||
curativeEffortsBar.getProgressDrawable()
|
curativeEffortsBar.getProgressDrawable()
|
||||||
.setColorFilter(Color.parseColor("#FFD700"), PorterDuff.Mode.SRC_IN);
|
.setColorFilter(getResources().getColor(R.color.surges_bar), PorterDuff.Mode.SRC_IN);
|
||||||
undo = false;
|
undo = false;
|
||||||
//begin
|
//begin
|
||||||
restoreData();
|
restoreData();
|
||||||
|
@ -257,6 +257,9 @@ public class MainActivity extends ActionBarActivity {
|
||||||
|
|
||||||
alert.setView(input);
|
alert.setView(input);
|
||||||
|
|
||||||
|
final Context context = getApplicationContext();
|
||||||
|
final MainActivity activity = this;
|
||||||
|
|
||||||
alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
try {
|
try {
|
||||||
|
@ -274,7 +277,7 @@ public class MainActivity extends ActionBarActivity {
|
||||||
undoPreviousValue = preValue;
|
undoPreviousValue = preValue;
|
||||||
undoObject = CURRENT_PG;
|
undoObject = CURRENT_PG;
|
||||||
SnackbarManager.show(
|
SnackbarManager.show(
|
||||||
Snackbar.with(getApplicationContext()).text("Lost " + damage + " PG's")
|
Snackbar.with(context).text("Lost " + damage + " PG's")
|
||||||
.actionLabel("Undo") // action button label
|
.actionLabel("Undo") // action button label
|
||||||
.actionListener(new ActionClickListener() {
|
.actionListener(new ActionClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -282,7 +285,8 @@ public class MainActivity extends ActionBarActivity {
|
||||||
undo();
|
undo();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
,getParent()); // action button's
|
.actionColor(getResources().getColor(R.color.yellow))
|
||||||
|
,activity); // action button's
|
||||||
p.edit().putInt("pg", player.getPg()).apply();
|
p.edit().putInt("pg", player.getPg()).apply();
|
||||||
pgUpdate();
|
pgUpdate();
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
|
@ -383,7 +387,9 @@ public class MainActivity extends ActionBarActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreData(){
|
private void restoreData(){
|
||||||
|
int i = getIntent().getIntExtra("player", 0);
|
||||||
if (!p.getBoolean("saved", false)) {
|
if (!p.getBoolean("saved", false)) {
|
||||||
|
if (i == -1) {
|
||||||
Intent intent = new Intent(this, Introduction.class);
|
Intent intent = new Intent(this, Introduction.class);
|
||||||
startActivity(intent.putExtra(
|
startActivity(intent.putExtra(
|
||||||
"first_time",
|
"first_time",
|
||||||
|
@ -431,6 +437,7 @@ public class MainActivity extends ActionBarActivity {
|
||||||
}
|
}
|
||||||
player.setCurativeEffort(p.getInt("curativeEfforts", player.getMaxCurativeEfforts()));
|
player.setCurativeEffort(p.getInt("curativeEfforts", player.getMaxCurativeEfforts()));
|
||||||
player.setPg(p.getInt("pg", player.getMaxPg()));
|
player.setPg(p.getInt("pg", player.getMaxPg()));
|
||||||
|
|
||||||
pgBar.setMax(player.getMaxPg());
|
pgBar.setMax(player.getMaxPg());
|
||||||
negPgBar.setMax(player.getMaxPg() / 2);
|
negPgBar.setMax(player.getMaxPg() / 2);
|
||||||
// incrementProgressBar(
|
// incrementProgressBar(
|
||||||
|
|
|
@ -57,7 +57,7 @@ class Player {
|
||||||
* Names for the races
|
* Names for the races
|
||||||
*/
|
*/
|
||||||
public static final String[] RACE_STRINGS = new String[] {
|
public static final String[] RACE_STRINGS = new String[] {
|
||||||
"Raza", "Dracónido", "Eladrín", "Elfo", "Enano", "Gitzherai", "Humanos", "Medianos",
|
"Raza", "Dracónido", "Eladrín", "Elfo", "Enano", "Gitzherai", "Humano", "Mediano",
|
||||||
"Mente del Fragmento", "Minotauro", "Salvaje", "Semielfo", "Tiflin"
|
"Mente del Fragmento", "Minotauro", "Salvaje", "Semielfo", "Tiflin"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -110,6 +110,7 @@ class Player {
|
||||||
//TODO: implement fully operational powers displayed as cards
|
//TODO: implement fully operational powers displayed as cards
|
||||||
private Power[] powers;
|
private Power[] powers;
|
||||||
|
|
||||||
|
/** Constructor for creating a new character*/
|
||||||
Player(
|
Player(
|
||||||
String name, int classInt, int raceInt,
|
String name, int classInt, int raceInt,
|
||||||
int px, int[] atk, int[] abilities,
|
int px, int[] atk, int[] abilities,
|
||||||
|
@ -130,6 +131,25 @@ class Player {
|
||||||
this.powers = powers;
|
this.powers = powers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Constructor for restoring the Player in the middle of the game*/
|
||||||
|
Player(
|
||||||
|
int pg, int maxPg, int px, int curativeEfforts, int maxCurativeEfforts, int classInt,
|
||||||
|
int raceInt, String name, int[] atk, int[] def, int[] abilities, Power[] powers) {
|
||||||
|
this.pg = pg;
|
||||||
|
this.maxPg = maxPg;
|
||||||
|
this.px = px;
|
||||||
|
setLevel();
|
||||||
|
setState();
|
||||||
|
this.curativeEfforts = curativeEfforts;
|
||||||
|
this.maxCurativeEfforts = maxCurativeEfforts;
|
||||||
|
this.classInt = classInt;
|
||||||
|
this.raceInt = raceInt;
|
||||||
|
this.name = name;
|
||||||
|
this.atk = atk;
|
||||||
|
this.def = def;
|
||||||
|
this.abilities = abilities;
|
||||||
|
this.powers = powers;
|
||||||
|
}
|
||||||
|
|
||||||
int getPx() {return px;}
|
int getPx() {return px;}
|
||||||
void setPx (int px) {this.px = px; setLevel();}
|
void setPx (int px) {this.px = px; setLevel();}
|
||||||
|
@ -216,7 +236,7 @@ class Player {
|
||||||
String getClassName() {return CLASS_STRINGS[classInt];}
|
String getClassName() {return CLASS_STRINGS[classInt];}
|
||||||
|
|
||||||
String getRaceName() {return RACE_STRINGS[raceInt];}
|
String getRaceName() {return RACE_STRINGS[raceInt];}
|
||||||
void setRaceInt(int raceInt) {this.raceInt= raceInt;}
|
void setRaceInt(int raceInt) {this.raceInt = raceInt;}
|
||||||
int getRaceInt() {return raceInt;}
|
int getRaceInt() {return raceInt;}
|
||||||
|
|
||||||
//TODO: implement turns (for bonuses and continuous damage in the app
|
//TODO: implement turns (for bonuses and continuous damage in the app
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package com.kauron.dungeonmanager;
|
package com.kauron.dungeonmanager;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.AvoidXfermode;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -28,10 +31,27 @@ class PlayerAdapter extends ArrayAdapter<Player> {
|
||||||
.setText(
|
.setText(
|
||||||
getContext().getResources().getString(R.string.level) + " " + player.getLevel()
|
getContext().getResources().getString(R.string.level) + " " + player.getLevel()
|
||||||
);
|
);
|
||||||
|
int pg = player.getPg();
|
||||||
|
int maxPg = player.getMaxPg();
|
||||||
|
ProgressBar neg = (ProgressBar) mView.findViewById(R.id.negPgBar);
|
||||||
|
ProgressBar pos = (ProgressBar) mView.findViewById(R.id.pgBar);
|
||||||
|
|
||||||
ProgressBar pg = (ProgressBar) mView.findViewById(R.id.progressBar);
|
neg.setMax(maxPg / 2);
|
||||||
pg.setMax(player.getMaxPg());
|
pos.setMax(maxPg);
|
||||||
pg.setProgress(player.getPg());
|
|
||||||
|
neg.setProgress(pg < 0 ? -pg : 0);
|
||||||
|
pos.setProgress(pg > 0 ? pg : 0);
|
||||||
|
|
||||||
|
int c;
|
||||||
|
if ( pg <= 0 )
|
||||||
|
c = getContext().getResources().getColor(R.color.red);
|
||||||
|
else if ( pg <= maxPg / 2 )
|
||||||
|
c = getContext().getResources().getColor(R.color.yellow);
|
||||||
|
else
|
||||||
|
c = getContext().getResources().getColor(R.color.green);
|
||||||
|
|
||||||
|
neg.getProgressDrawable().setColorFilter(c, PorterDuff.Mode.SRC_IN);
|
||||||
|
pos.getProgressDrawable().setColorFilter(c, PorterDuff.Mode.SRC_IN);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mView;
|
return mView;
|
||||||
|
|
|
@ -4,41 +4,90 @@ import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ListAdapter;
|
import android.widget.ListAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
import com.nispok.snackbar.Snackbar;
|
|
||||||
import com.nispok.snackbar.SnackbarManager;
|
|
||||||
|
|
||||||
|
|
||||||
public class Welcome extends ActionBarActivity {
|
public class Welcome extends ActionBarActivity {
|
||||||
|
|
||||||
public static final String PREFERENCES = "basics";
|
public static final String PREFERENCES = "basics";
|
||||||
|
|
||||||
private Button load;
|
|
||||||
private SharedPreferences p;
|
private SharedPreferences p;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_welcome);
|
setContentView(R.layout.activity_welcome);
|
||||||
|
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
|
||||||
p = getSharedPreferences(PREFERENCES, MODE_PRIVATE);
|
p = getSharedPreferences(PREFERENCES, MODE_PRIVATE);
|
||||||
load = (Button) findViewById(R.id.loadCharacter);
|
load();
|
||||||
if (p.getBoolean("saved", false)) {
|
|
||||||
load.setEnabled(true);
|
|
||||||
load.setText(String.format(getString(R.string.load_text), p.getString("playerName", "")));
|
|
||||||
} else {
|
|
||||||
load.setEnabled(false);
|
|
||||||
load.setText(R.string.load_character);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
|
getMenuInflater().inflate(R.menu.menu_welcome, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
// Handle action bar item clicks here. The action bar will
|
||||||
|
// automatically handle clicks on the Home/Up button, so long
|
||||||
|
// as you specify a parent activity in AndroidManifest.xml.
|
||||||
|
int id = item.getItemId();
|
||||||
|
|
||||||
|
//noinspection SimplifiableIfStatement
|
||||||
|
if ( id == R.id.action_add_player ) {
|
||||||
|
startActivity(new Intent(this, Introduction.class).putExtra("first_time", true));
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void load() {
|
||||||
int n = p.getInt("players",0);
|
int n = p.getInt("players",0);
|
||||||
if ( n != 0 ) {
|
ListView playerList = (ListView) findViewById(R.id.listView);
|
||||||
|
PlayerAdapter adapter = (PlayerAdapter) playerList.getAdapter();
|
||||||
|
int elements = 0;
|
||||||
|
if ( adapter != null )
|
||||||
|
elements = adapter.getCount();
|
||||||
|
if ( elements < n && adapter != null ) {
|
||||||
|
playerList.setVisibility(View.VISIBLE);
|
||||||
|
findViewById(R.id.no_players_text).setVisibility(View.GONE);
|
||||||
|
for ( int i = elements; i < n; i++ ) {
|
||||||
|
SharedPreferences sav = getSharedPreferences("player" + i, MODE_PRIVATE);
|
||||||
|
adapter.add(
|
||||||
|
new Player(
|
||||||
|
sav.getString(Player.NAME, "player" + i),
|
||||||
|
sav.getInt(Player.CLASS, 0),
|
||||||
|
sav.getInt(Player.RACE, 0),
|
||||||
|
sav.getInt(Player.PX, 0),
|
||||||
|
new int[] {
|
||||||
|
sav.getInt("fue", 10),
|
||||||
|
sav.getInt("con", 10),
|
||||||
|
sav.getInt("des", 10),
|
||||||
|
sav.getInt("int", 10),
|
||||||
|
sav.getInt("sab", 10),
|
||||||
|
sav.getInt("car", 10)
|
||||||
|
},
|
||||||
|
new int[18],
|
||||||
|
new Power[4]
|
||||||
|
));
|
||||||
|
}
|
||||||
|
} else if ( n != 0 ) {
|
||||||
|
playerList.setVisibility(View.VISIBLE);
|
||||||
|
findViewById(R.id.no_players_text).setVisibility(View.GONE);
|
||||||
Player[] players = new Player[n];
|
Player[] players = new Player[n];
|
||||||
for ( int i = 0; i < n; i++ ) {
|
for ( int i = 0; i < n; i++ ) {
|
||||||
//TODO: fill the information for the player creation
|
//TODO: fill the information for the player creation
|
||||||
|
@ -60,9 +109,8 @@ public class Welcome extends ActionBarActivity {
|
||||||
new Power[4]
|
new Power[4]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ListView playerList = (ListView) findViewById(R.id.listView);
|
|
||||||
ListAdapter adapter = new PlayerAdapter(this, players);
|
playerList.setAdapter(new PlayerAdapter(this, players));
|
||||||
playerList.setAdapter(adapter);
|
|
||||||
|
|
||||||
playerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
playerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -73,49 +121,8 @@ public class Welcome extends ActionBarActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
findViewById(R.id.listView).setVisibility(View.GONE);
|
playerList.setVisibility(View.GONE);
|
||||||
}
|
findViewById(R.id.no_players_text).setVisibility(View.VISIBLE);
|
||||||
}
|
|
||||||
|
|
||||||
public void onNewClick(View view) {startActivity(new Intent(this, Introduction.class).putExtra("first_time", true));}
|
|
||||||
public void onLoadClick(View view) {startActivity(new Intent(this, MainActivity.class).putExtra("player", -1));}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
|
||||||
getMenuInflater().inflate(R.menu.menu_welcome, menu);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
// Handle action bar item clicks here. The action bar will
|
|
||||||
// automatically handle clicks on the Home/Up button, so long
|
|
||||||
// as you specify a parent activity in AndroidManifest.xml.
|
|
||||||
int id = item.getItemId();
|
|
||||||
|
|
||||||
//noinspection SimplifiableIfStatement
|
|
||||||
if (id == R.id.action_settings) {
|
|
||||||
SnackbarManager.show(
|
|
||||||
Snackbar.with(getApplicationContext()).text("This doesn't work yet")
|
|
||||||
);
|
|
||||||
return true;
|
|
||||||
} else if ( id == R.id.action_add_player ) {
|
|
||||||
startActivity(new Intent(this, Introduction.class).putExtra("first_time", true));
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
if (p.getBoolean("saved", false)) {
|
|
||||||
load.setEnabled(true);
|
|
||||||
load.setText(String.format(getString(R.string.load_text), p.getString("playerName", "")));
|
|
||||||
} else {
|
|
||||||
load.setEnabled(false);
|
|
||||||
load.setText(R.string.load_character);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,49 @@
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout
|
||||||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context=".Introduction">
|
||||||
|
|
||||||
|
<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"
|
||||||
|
android:text="Character creation"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/finish_button"
|
||||||
|
android:onClick="finishButton"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:text="Save character" />
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
android:paddingTop="@dimen/activity_vertical_margin"
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
android:paddingBottom="@dimen/activity_vertical_margin">
|
||||||
tools:context=".Introduction">
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -151,7 +190,8 @@
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:layout_below="@+id/thirdLayout"
|
android:layout_below="@+id/thirdLayout"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_alignParentStart="true">
|
android:layout_alignParentStart="true"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -160,9 +200,12 @@
|
||||||
android:id="@+id/new_attack_button" />
|
android:id="@+id/new_attack_button" />
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/listView" />
|
android:id="@+id/listView" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -52,7 +52,6 @@
|
||||||
<HorizontalScrollView
|
<HorizontalScrollView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:onClick="selectPlayer"
|
|
||||||
android:id="@+id/scroll1">
|
android:id="@+id/scroll1">
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
@ -139,7 +138,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="right"
|
android:gravity="end"
|
||||||
android:id="@+id/currentPg"
|
android:id="@+id/currentPg"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
|
@ -165,7 +164,7 @@
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="5dp"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="5dp"
|
||||||
android:text="0"/>
|
android:text="@string/zero"/>
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -199,7 +198,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:gravity="right"
|
android:gravity="end"
|
||||||
android:id="@+id/currentCurativeEfforts"
|
android:id="@+id/currentCurativeEfforts"
|
||||||
android:textAllCaps="true"/>
|
android:textAllCaps="true"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -232,7 +231,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="right"
|
android:gravity="end"
|
||||||
android:id="@+id/currentXp"
|
android:id="@+id/currentXp"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
|
@ -251,7 +250,6 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:onClick="onAttackClick"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
|
@ -6,4 +6,37 @@
|
||||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
tools:context="com.kauron.dungeonmanager.PowerEditor">
|
tools:context="com.kauron.dungeonmanager.PowerEditor">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/editText"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:capitalize="words" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/editText2"
|
||||||
|
android:capitalize="words"
|
||||||
|
android:layout_below="@+id/editText"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignRight="@+id/editText"
|
||||||
|
android:layout_alignEnd="@+id/editText" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/editText3"
|
||||||
|
android:capitalize="words"
|
||||||
|
android:layout_below="@+id/editText2"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignRight="@+id/editText2"
|
||||||
|
android:layout_alignEnd="@+id/editText2" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
|
@ -33,20 +33,13 @@
|
||||||
android:paddingTop="@dimen/activity_vertical_margin"
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
<Button
|
<TextView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="fill_parent"
|
||||||
android:text="@string/new_character"
|
android:id="@+id/no_players_text"
|
||||||
android:id="@+id/newCharacter"
|
android:text="@string/no_players"
|
||||||
android:onClick="onNewClick"/>
|
android:gravity="center"
|
||||||
|
android:visibility="gone"/>
|
||||||
<Button
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/load_character"
|
|
||||||
android:id="@+id/loadCharacter"
|
|
||||||
android:onClick="onLoadClick"/>
|
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/relativeLayout"
|
||||||
|
android:paddingTop="5dp"
|
||||||
|
android:paddingBottom="5dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -15,16 +18,41 @@
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_alignParentStart="true" />
|
android:layout_alignParentStart="true" />
|
||||||
|
|
||||||
<ProgressBar
|
<LinearLayout
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
android:layout_width="fill_parent"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/progressBar"
|
|
||||||
android:layout_below="@+id/name"
|
android:layout_below="@+id/name"
|
||||||
|
android:paddingTop="3dp"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_alignParentStart="true" />
|
android:layout_alignParentStart="true"
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
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"
|
||||||
|
tools:progress="30"
|
||||||
|
tools:progressTint="#FF0"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -41,7 +69,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
tools:text="LVL 1"
|
tools:text="Level 1"
|
||||||
android:id="@+id/level"
|
android:id="@+id/level"
|
||||||
android:layout_above="@+id/progressBar"
|
android:layout_above="@+id/progressBar"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
|
|
|
@ -8,6 +8,13 @@
|
||||||
<color name="secondary_text">#727272</color>
|
<color name="secondary_text">#727272</color>
|
||||||
<color name="icons">#FFFFFF</color>
|
<color name="icons">#FFFFFF</color>
|
||||||
<color name="divider">#B6B6B6</color>
|
<color name="divider">#B6B6B6</color>
|
||||||
|
|
||||||
|
<color name="red">#F00</color>
|
||||||
|
<color name="yellow">#ff0</color>
|
||||||
|
<color name="green">#0f0</color>
|
||||||
|
|
||||||
|
<color name="surges_bar">#FFD700</color>
|
||||||
|
<color name="px_bar">#62BACE</color>
|
||||||
<!--<color name="primary">#5D4037</color>-->
|
<!--<color name="primary">#5D4037</color>-->
|
||||||
<!--<color name="primaryDark">#3E2723</color>-->
|
<!--<color name="primaryDark">#3E2723</color>-->
|
||||||
</resources>
|
</resources>
|
|
@ -88,4 +88,6 @@
|
||||||
|
|
||||||
<string name="hello_world">Hello world!</string>
|
<string name="hello_world">Hello world!</string>
|
||||||
<string name="add_player">Add player</string>
|
<string name="add_player">Add player</string>
|
||||||
|
<string name="zero" translatable="false">0</string>
|
||||||
|
<string name="no_players">No players, please add one</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Reference in a new issue