1
0
Fork 0

Fixed remove and add Player and Power

Also improved Power display and use. Set basis for the tutorial for creating players.
This commit is contained in:
Carlos Galindo 2015-04-28 23:03:28 +02:00
parent 3b9fc620b4
commit 3fc3dbdd37
26 changed files with 1000 additions and 545 deletions

View file

@ -0,0 +1,7 @@
<component name="ProjectDictionaryState">
<dictionary name="Carlos">
<words>
<w>snackbar</w>
</words>
</dictionary>
</component>

View file

@ -87,6 +87,7 @@
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" /> <orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" /> <orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" name="support-v13-22.0.0" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-22.0.0" level="project" /> <orderEntry type="library" exported="" name="recyclerview-v7-22.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.0.0" level="project" /> <orderEntry type="library" exported="" name="support-v4-22.0.0" level="project" />
<orderEntry type="library" exported="" name="snackbar-2.10.6" level="project" /> <orderEntry type="library" exported="" name="snackbar-2.10.6" level="project" />

View file

@ -7,12 +7,12 @@ android {
applicationId 'com.kauron.dungeonmanager' applicationId 'com.kauron.dungeonmanager'
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 21 targetSdkVersion 21
versionCode 2 versionCode 3
versionName '0.2' versionName '0.2.1'
} }
buildTypes { buildTypes {
release { release {
minifyEnabled false minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }
} }
@ -25,4 +25,5 @@ dependencies {
compile 'com.android.support:appcompat-v7:21.0.3' compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:cardview-v7:21.0.3' compile 'com.android.support:cardview-v7:21.0.3'
compile 'com.nispok:snackbar:2.10.6' compile 'com.nispok:snackbar:2.10.6'
compile 'com.android.support:support-v13:22.0.0'
} }

View file

@ -9,29 +9,43 @@
android:theme="@style/AppTheme" > android:theme="@style/AppTheme" >
<activity <activity
android:name=".ShowPlayer" android:name=".ShowPlayer"
android:label="@string/app_name" > android:label="@string/app_name"
android:parentActivityName=".Welcome" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".Welcome" />
</activity> </activity>
<activity <activity
android:name=".PlayerEditor" android:name=".PlayerEditor"
android:label="@string/title_activity_introduction" > android:label="@string/title_activity_introduction"
android:parentActivityName=".Welcome">
<!-- android:parentActivityName=".ShowPlayer" --> <meta-data
<!-- <meta-data --> android:name="android.support.PARENT_ACTIVITY"
<!-- android:name="android.support.PARENT_ACTIVITY" --> android:value=".Welcome" />
<!-- android:value=".ShowPlayer" /> -->
</activity> </activity>
<activity <activity
android:name=".Welcome" android:name=".Welcome"
android:label="@string/app_name" > android:label="@string/app_name" >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity
android:name=".PowerEditor" android:name=".PowerEditor"
android:label="@string/title_activity_power_editor" > android:label="@string/title_activity_power_editor"
android:parentActivityName=".ShowPlayer" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ShowPlayer" />
</activity>
<activity
android:name=".PlayerCreator"
android:label="@string/title_activity_player_creator"
android:parentActivityName=".Welcome" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".Welcome" />
</activity> </activity>
</application> </application>

View file

@ -20,9 +20,10 @@ import com.nispok.snackbar.SnackbarManager;
import com.nispok.snackbar.listeners.ActionClickListener; import com.nispok.snackbar.listeners.ActionClickListener;
import java.io.File; import java.io.File;
import java.util.ArrayList;
class AttackAdapter extends ArrayAdapter<Power> { class AttackAdapter extends ArrayAdapter<Power> {
AttackAdapter(Context context, Power[] powers) { AttackAdapter(Context context, ArrayList<Power> powers) {
super(context, R.layout.attack_row, powers); super(context, R.layout.attack_row, powers);
} }
@ -41,7 +42,7 @@ class AttackAdapter extends ArrayAdapter<Power> {
if (attack.isUsed()) if (attack.isUsed())
mView.getBackground().setAlpha(0); mView.getBackground().setAlpha(0);
else else
mView.getBackground().setAlpha((position % 2) * 127 + 128); mView.getBackground().setAlpha((position % 2) * 50 + 205);
} }
return mView; return mView;
} }

View file

@ -112,6 +112,10 @@ class Player implements Serializable {
private int[] atk, def; private int[] atk, def;
//TODO: implement fully operational powers (die rolling) //TODO: implement fully operational powers (die rolling)
/**
* Builds a whole player from its saved stats
* @param p SharedPreferences object containing data for a player.
*/
Player (SharedPreferences p) { Player (SharedPreferences p) {
this.name = p.getString(NAME, "Player"); this.name = p.getString(NAME, "Player");
this.px = p.getInt(PX, 0); this.px = p.getInt(PX, 0);
@ -160,7 +164,6 @@ class Player implements Serializable {
this.pg = maxPg; this.pg = maxPg;
this.maxPg = maxPg; this.maxPg = maxPg;
} }
private void setMaxPgOnLevelUp() {maxPg += CLASS_STATS[PG_ON_LEVEL_UP][classInt];}
int getPg() {return pg;} int getPg() {return pg;}
void setPg(int pg) {this.pg = pg; setState();} void setPg(int pg) {this.pg = pg; setState();}
@ -221,8 +224,10 @@ class Player implements Serializable {
int getVol() {return def[VOL];} int getVol() {return def[VOL];}
private void setClass() { private void setClass() {
if(level == 1) maxPg = atk[CON] + CLASS_STATS[INITIAL_PG][classInt]; maxPg = atk[CON] + CLASS_STATS[INITIAL_PG][classInt]
maxCurativeEfforts = Player.getModifier(atk[CON]) + CLASS_STATS[DAILY_CURATIVE_EFFORTS][classInt]; + ( level - 1 ) * CLASS_STATS[PG_ON_LEVEL_UP][classInt];
maxCurativeEfforts =
Player.getModifier(atk[CON]) + CLASS_STATS[DAILY_CURATIVE_EFFORTS][classInt];
//TODO: implement armor! //TODO: implement armor!
def[CA] = 10 + level / 2 + Math.max(0, Player.getModifier(Math.max(atk[DES], atk[INT]))); def[CA] = 10 + level / 2 + Math.max(0, Player.getModifier(Math.max(atk[DES], atk[INT])));
def[FORT] = 10 + level / 2 + Player.getModifier(Math.max(atk[CON], atk[FUE])) + def[FORT] = 10 + level / 2 + Player.getModifier(Math.max(atk[CON], atk[FUE])) +
@ -247,4 +252,12 @@ class Player implements Serializable {
else else
return context.getResources().getColor(R.color.black); return context.getResources().getColor(R.color.black);
} }
void rest (boolean isLong) {
if ( isLong ) {
pg = maxPg;
curativeEfforts = maxCurativeEfforts;
}
//TODO: here implement action points!
}
} }

View file

@ -11,9 +11,11 @@ import android.widget.ArrayAdapter;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import java.util.ArrayList;
class PlayerAdapter extends ArrayAdapter<Player> { class PlayerAdapter extends ArrayAdapter<Player> {
PlayerAdapter(Context context, Player[] players) { PlayerAdapter(Context context, ArrayList<Player> players) {
super(context, R.layout.player_row, players); super(context, R.layout.player_row, players);
} }

View file

@ -0,0 +1,86 @@
package com.kauron.dungeonmanager;
import android.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.app.FragmentManager;
import android.support.v13.app.FragmentStatePagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class PlayerCreator extends FragmentActivity {
/**
* The number of pages (wizard steps) to show in this demo.
*/
private static final int NUM_PAGES = 5;
/**
* The pager widget, which handles animation and allows swiping horizontally to access previous
* and next wizard steps.
*/
private ViewPager mPager;
/**
* The pager adapter, which provides the pages to the view pager widget.
*/
private PagerAdapter mPagerAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player_creator);
// Instantiate a ViewPager and a PagerAdapter.
mPager = (ViewPager) findViewById(R.id.pager);
mPagerAdapter = new PlayerCreatorPagerAdapter(getFragmentManager());
mPager.setAdapter(mPagerAdapter);
mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
// When changing pages, reset the action bar actions since they are dependent
// on which page is currently active. An alternative approach is to have each
// fragment expose actions itself (rather than the activity exposing actions),
// but for simplicity, the activity provides the actions in this sample.
invalidateOptionsMenu();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.menu_player_creator, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}
/**
* A simple pager adapter that represents 5 {@link PlayerCreatorFragment} objects, in
* sequence.
*/
private class PlayerCreatorPagerAdapter extends FragmentStatePagerAdapter {
public PlayerCreatorPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
return PlayerCreatorFragment.create(position);
}
@Override
public int getCount() {
return NUM_PAGES;
}
}
}

View file

@ -0,0 +1,62 @@
package com.kauron.dungeonmanager;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
/**
* A placeholder fragment containing a simple view.
*/
public class PlayerCreatorFragment extends Fragment {
/**
* The argument key for the page number this fragment represents.
*/
public static final String ARG_PAGE = "page";
/**
* The fragment's page number, which is set to the argument value for {@link #ARG_PAGE}.
*/
private int mPageNumber;
/**
* Factory method for this fragment class. Constructs a new fragment for the given page number.
*/
public static PlayerCreatorFragment create(int pageNumber) {
PlayerCreatorFragment fragment = new PlayerCreatorFragment();
Bundle args = new Bundle();
args.putInt(ARG_PAGE, pageNumber);
fragment.setArguments(args);
return fragment;
}
public PlayerCreatorFragment() {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mPageNumber = getArguments().getInt(ARG_PAGE);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout containing a title and body text.
ViewGroup rootView = (ViewGroup) inflater
.inflate(R.layout.fragment_player_creator, container, false);
return rootView;
}
/**
* Returns the page number represented by this fragment object.
*/
public int getPageNumber() {
return mPageNumber;
}
}

View file

@ -26,7 +26,9 @@ public class PlayerEditor extends ActionBarActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true); // getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.activity_player_editor); setContentView(R.layout.activity_player_editor);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(true);
name = (EditText) findViewById(R.id.editNameIntro); name = (EditText) findViewById(R.id.editNameIntro);
name.requestFocus(); name.requestFocus();

View file

@ -24,8 +24,8 @@ class Power implements Serializable{
public static final int[] DIE = {0, 2, 4, 6, 8, 10, 12, 20, 100, 0}; public static final int[] DIE = {0, 2, 4, 6, 8, 10, 12, 20, 100, 0};
private boolean used; private boolean used;
private int freq, action, distance, range, objectives; private int freq, action, range;
private String name, impact, objective; private String name, impact, objective, distance;
private String keywords; //fire, spell... private String keywords; //fire, spell...
private int atk, def; //constants from Player to denote atk and defense private int atk, def; //constants from Player to denote atk and defense
@ -33,7 +33,7 @@ class Power implements Serializable{
this.name = p.getString("s0", "Name"); this.name = p.getString("s0", "Name");
this.keywords = p.getString("s1", "Keywords"); this.keywords = p.getString("s1", "Keywords");
this.impact = p.getString("s2", "2d10"); this.impact = p.getString("s2", "2d10");
this.distance = Integer.parseInt(p.getString("s3", "10")); this.distance = p.getString("s3", "10");
this.objective = p.getString("s4", "One creature"); this.objective = p.getString("s4", "One creature");
this.used = p.getBoolean("used", false); this.used = p.getBoolean("used", false);
@ -55,8 +55,7 @@ class Power implements Serializable{
int getDef() {return def;} int getDef() {return def;}
int getFreq() {return freq;} int getFreq() {return freq;}
int getDistance() {return distance;} String getDistance() {return distance;}
String getName(){return name;} String getName(){return name;}
String getImpact() {return impact;} String getImpact() {return impact;}
String getObjective() {return objective;} String getObjective() {return objective;}
@ -85,10 +84,8 @@ class Power implements Serializable{
return context.getResources().getColor(R.color.daily); return context.getResources().getColor(R.color.daily);
case ENCUENTRO: case ENCUENTRO:
return context.getResources().getColor(R.color.encounter); return context.getResources().getColor(R.color.encounter);
case A_VOLUNTAD:
return context.getResources().getColor(R.color.at_will);
default: default:
return context.getResources().getColor(R.color.green); //TODO: find other color return context.getResources().getColor(R.color.at_will);
} }
} }
} }

View file

@ -1,6 +1,7 @@
package com.kauron.dungeonmanager; package com.kauron.dungeonmanager;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarActivity;
import android.os.Bundle; import android.os.Bundle;
@ -24,12 +25,15 @@ public class PowerEditor extends ActionBarActivity {
private String originalName; private String originalName;
private int power; private int power;
private SharedPreferences p; private SharedPreferences p;
private Drawable background;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_power_editor); setContentView(R.layout.activity_power_editor);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(true);
power = getIntent().getIntExtra("power", -1); power = getIntent().getIntExtra("power", -1);
@ -84,6 +88,7 @@ public class PowerEditor extends ActionBarActivity {
getResources().getStringArray(R.array.actions_array) getResources().getStringArray(R.array.actions_array)
) )
); );
background = spinners[0].getBackground();
if (power != -1) { if (power != -1) {
@ -97,7 +102,6 @@ public class PowerEditor extends ActionBarActivity {
} }
public void saveClick(View view) { public void saveClick(View view) {
boolean readyToSave = true; boolean readyToSave = true;
@ -116,8 +120,9 @@ public class PowerEditor extends ActionBarActivity {
if ( n == 0) { if ( n == 0) {
spinners[i].setBackgroundColor(getResources().getColor(R.color.red)); spinners[i].setBackgroundColor(getResources().getColor(R.color.red));
readyToSave = false; readyToSave = false;
//TODO: remove the color when the user has made a choice //TODO: TEST THIS remove the color when the user has made a choice
} else { } else {
spinners[i].setBackground(background);
ints[i] = n; ints[i] = n;
} }
} }

View file

@ -13,6 +13,7 @@ import android.os.Bundle;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.text.InputType; import android.text.InputType;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -31,6 +32,7 @@ import com.nispok.snackbar.SnackbarManager;
import com.nispok.snackbar.listeners.ActionClickListener; import com.nispok.snackbar.listeners.ActionClickListener;
import java.io.File; import java.io.File;
import java.util.ArrayList;
public class ShowPlayer extends ActionBarActivity { public class ShowPlayer extends ActionBarActivity {
@ -42,11 +44,13 @@ public class ShowPlayer extends ActionBarActivity {
private int undoObject, undoPreviousValue; private int undoObject, undoPreviousValue;
private ProgressBar posPgBar, negPgBar, xpBar, curativeEffortsBar; private ProgressBar posPgBar, negPgBar, xpBar, curativeEffortsBar;
private TextView currentPg, currentXp, currentCurativeEfforts; private TextView currentPg, currentXp, currentCurativeEfforts, level;
private SharedPreferences p; private SharedPreferences p;
private Toolbar toolbar; private Toolbar toolbar;
private ListView attackList;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -54,7 +58,7 @@ public class ShowPlayer extends ActionBarActivity {
setContentView(R.layout.activity_show_player); setContentView(R.layout.activity_show_player);
toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//Loading player //Loading player
try{ try{
String name = getSharedPreferences(Welcome.PREFERENCES, MODE_PRIVATE) String name = getSharedPreferences(Welcome.PREFERENCES, MODE_PRIVATE)
@ -74,6 +78,7 @@ public class ShowPlayer extends ActionBarActivity {
currentPg = (TextView) findViewById(R.id.currentPg); currentPg = (TextView) findViewById(R.id.currentPg);
currentXp = (TextView) findViewById(R.id.currentXp); currentXp = (TextView) findViewById(R.id.currentXp);
currentCurativeEfforts = (TextView) findViewById(R.id.currentCurativeEfforts); currentCurativeEfforts = (TextView) findViewById(R.id.currentCurativeEfforts);
level = (TextView) findViewById(R.id.level);
xpBar.getProgressDrawable() xpBar.getProgressDrawable()
.setColorFilter(getResources().getColor(R.color.px_bar), PorterDuff.Mode.SRC_IN); .setColorFilter(getResources().getColor(R.color.px_bar), PorterDuff.Mode.SRC_IN);
@ -104,6 +109,18 @@ public class ShowPlayer extends ActionBarActivity {
return true; return true;
} }
private void addPx(EditText input) {
try {
if (player.addPx(Integer.parseInt(input.getText().toString()))) levelUp();
p.edit().putInt("px", player.getPx()).apply();
pxUpdate();
ceUpdate();
pgUpdate();
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "There was an error leveling up", Toast.LENGTH_LONG).show();
}
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will // Handle action bar item clicks here. The action bar will
@ -129,63 +146,97 @@ public class ShowPlayer extends ActionBarActivity {
alert.setTitle(R.string.px_awarded_title); alert.setTitle(R.string.px_awarded_title);
final EditText input = new EditText(this); final EditText input = new EditText(this);
input.setInputType(InputType.TYPE_CLASS_NUMBER); input.setInputType(InputType.TYPE_CLASS_NUMBER);
input.setImeOptions(EditorInfo.IME_ACTION_DONE);
input.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
addPx(input);
}
return false;
}
});
input.setHint(R.string.px_awarded_hint); input.setHint(R.string.px_awarded_hint);
alert.setCancelable(false);
alert.setView(input); alert.setView(input);
alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
try { addPx(input);
boolean levelUp = player.addPx(Integer.parseInt(input.getText().toString())); }
if (levelUp) { });
//TODO: improve leveling up by using a sliding guide alert.setNegativeButton(R.string.level_up, new DialogInterface.OnClickListener() {
} @Override
p.edit().putInt("px", player.getPx()).apply(); public void onClick(DialogInterface dialog, int which) {
if(levelUp) player.setPx(Player.LEVEL_PX[player.getLevel()]);
xpBar.setMax(Player.LEVEL_PX[player.getLevel()] - levelUp();
Player.LEVEL_PX[player.getLevel() - 1]); p.edit().putInt(Player.PX, player.getPx()).apply();
pxUpdate(); pxUpdate();
ceUpdate();
pgUpdate();
} catch(Exception e) {
Toast.makeText(getApplicationContext(), "There was an error leveling up", Toast.LENGTH_LONG).show();
}
} }
}); });
alert.show(); alert.show();
input.requestFocus(); input.requestFocus();
return true; return true;
//TODO: the player no longer contains the powers, therefore the resting action affects the array of powers //TODO: TEST fix restoring powers
//TODO: fix restoring powers } else if (id == R.id.action_time_long_rest) {
// } else if (id == R.id.action_time_long_rest) { AttackAdapter attackAdapter = (AttackAdapter)attackList.getAdapter();
// player.rest(true); if (attackAdapter != null) {
// SnackbarManager.show( for (int i = 0; i < attackAdapter.getCount(); i++) {
// Snackbar Power power = attackAdapter.getItem(i);
// .with(this) if ( power.getFreq() != Power.A_VOLUNTAD ) {
// .text(R.string.long_rest_done) power.recover(Power.DIARIO);
// .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE) getSharedPreferences(p.getString("power" + i, ""), MODE_PRIVATE)
// ); .edit().putBoolean("used", false);
// p.edit() }
// .putInt("pg", player.getPg()) }
// .putInt("curativeEfforts", player.getCurativeEfforts()) //TODO: substitute all calls to refreshList for an update on the single view that changed
// .apply(); refreshList();
// pgUpdate(); }
// ceUpdate(); player.rest(true);
// } else if (id == R.id.action_time_rest) { SnackbarManager.show(
// player.rest(false); Snackbar
// SnackbarManager.show( .with(this)
// Snackbar .text(R.string.long_rest_done)
// .with(this) .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE)
// .text(R.string.rest_done) );
// .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE) p.edit()
// ); .putInt("pg", player.getPg())
// pgUpdate(); .putInt("curativeEfforts", player.getCurativeEfforts())
// ceUpdate(); .apply();
pgUpdate();
ceUpdate();
} else if (id == R.id.action_time_rest) {
AttackAdapter attackAdapter = (AttackAdapter) attackList.getAdapter();
if (attackAdapter != null) {
for (int i = 0; i < attackAdapter.getCount(); i++) {
Power power = attackAdapter.getItem(i);
if ( power.getFreq() == Power.ENCUENTRO) {
power.recover(Power.ENCUENTRO);
getSharedPreferences(p.getString("power" + i, ""), MODE_PRIVATE)
.edit().putBoolean("used", false);
}
}
refreshList();
}
// player.rest(false); TODO: this isn't needed without action points
SnackbarManager.show(
Snackbar
.with(this)
.text(R.string.rest_done)
.duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE)
);
pgUpdate();
ceUpdate();
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
private void levelUp() {
//TODO: improve leveling up by using a sliding guide
xpBar.setMax(Player.LEVEL_PX[player.getLevel()] -
Player.LEVEL_PX[player.getLevel() - 1]);
}
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
@ -195,7 +246,12 @@ public class ShowPlayer extends ActionBarActivity {
pxUpdate(); pxUpdate();
} }
public void heal(boolean usesEffort) { /**
* Heals the player and displays an error if the healing wasn't possible
* @param usesEffort boolean Whether if the healing consumes a surge or not
* @return boolean ! ( usesEffort && error )
*/
public boolean heal(boolean usesEffort) {
int hasCured = player.recoverPg(Player.USE_CURATIVE_EFFORT, usesEffort); int hasCured = player.recoverPg(Player.USE_CURATIVE_EFFORT, usesEffort);
if (hasCured == Player.NOT_CURED) { if (hasCured == Player.NOT_CURED) {
SnackbarManager.show( SnackbarManager.show(
@ -204,15 +260,8 @@ public class ShowPlayer extends ActionBarActivity {
.text(R.string.no_curative_efforts_error) .text(R.string.no_curative_efforts_error)
.duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE) .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE)
); );
return false;
} else { } else {
if(hasCured == Player.MAXED){
SnackbarManager.show(
Snackbar
.with(this)
.text(R.string.maxed_curative)
.duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE)
);
}
SharedPreferences.Editor e = p.edit(); SharedPreferences.Editor e = p.edit();
e.putInt("pg", player.getPg()); e.putInt("pg", player.getPg());
if(usesEffort) { if(usesEffort) {
@ -221,22 +270,81 @@ public class ShowPlayer extends ActionBarActivity {
} }
e.apply(); e.apply();
pgUpdate(); pgUpdate();
return true;
} }
} }
/**
* Healing dialog that let's the player choose between using or not a surge to heal themselves.
* If the healing action is successful, a Snackbar is displayed to let the player undo it.
*/
public void healDialog() { public void healDialog() {
final Activity activity = this;
AlertDialog.Builder alert = new AlertDialog.Builder(this); AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setMessage(R.string.new_energies_message) alert.setMessage(R.string.new_energies_message)
.setTitle(R.string.new_energies) .setTitle(R.string.new_energies)
.setPositiveButton(R.string.me, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.me, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
heal(true); undoPreviousValue = player.getPg();
if (heal(true)) {
SnackbarManager.show(
Snackbar.with(getApplicationContext())
.text(String.format(getString(R.string.healed), player.getMaxPg() / 4))
.duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE)
.actionLabel(R.string.action_undo)
.actionColor(getResources().getColor(R.color.yellow))
.actionListener(new ActionClickListener() {
@Override
public void onActionClicked(Snackbar snackbar) {
player.setPg(undoPreviousValue);
player.setCurativeEffort(player.getCurativeEfforts() + 1);
p.edit().putInt("pg", undoPreviousValue)
.putInt("curativeEfforts", player.getCurativeEfforts())
.apply();
pgUpdate();
ceUpdate();
SnackbarManager.show(
Snackbar
.with(getApplicationContext())
.text(R.string.restored)
.duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE),
activity
);
}
}),
activity
);
}
} }
}) })
.setNegativeButton(R.string.other, new DialogInterface.OnClickListener() { .setNegativeButton(R.string.other, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
undoPreviousValue = player.getPg();
heal(false); heal(false);
SnackbarManager.show(
Snackbar.with(getApplicationContext())
.text(String.format(getString(R.string.healed), player.getMaxPg() / 4))
.duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE)
.actionLabel(R.string.action_undo)
.actionColor(getResources().getColor(R.color.yellow))
.actionListener(new ActionClickListener() {
@Override
public void onActionClicked(Snackbar snackbar) {
player.setPg(undoPreviousValue);
p.edit().putInt("pg", undoPreviousValue).apply();
SnackbarManager.show(
Snackbar
.with(getApplicationContext())
.text(R.string.restored)
.duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE),
activity
);
pgUpdate();
}
}),
activity
);
} }
}) })
.setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() { .setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() {
@ -248,6 +356,12 @@ public class ShowPlayer extends ActionBarActivity {
alert.show(); alert.show();
} }
/**
* Damage dialog with an Edittext to input a number (damage), which then is done to the player
* If the input is not empty, the hit points are updated and an undo Snackbar is added
*
* @param view View pressed to trigger this method (onClick attribute on xml)
*/
public void damage(final View view){ public void damage(final View view){
AlertDialog.Builder alert = new AlertDialog.Builder(this); AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle(R.string.suffer_damage); alert.setTitle(R.string.suffer_damage);
@ -272,16 +386,16 @@ public class ShowPlayer extends ActionBarActivity {
undoPreviousValue = preValue; undoPreviousValue = preValue;
undoObject = CURRENT_PG; undoObject = CURRENT_PG;
SnackbarManager.show( SnackbarManager.show(
Snackbar.with(context).text("Lost " + damage + " PG's") Snackbar.with(context).text(String.format(getString(R.string.lost_hp), damage))
.actionLabel("Undo") // action button label .actionLabel(R.string.action_undo) // action button label
.actionListener(new ActionClickListener() { .actionListener(new ActionClickListener() {
@Override @Override
public void onActionClicked(Snackbar snackbar) { public void onActionClicked(Snackbar snackbar) {
undo(); undo();
} }
}) })
.actionColor(getResources().getColor(R.color.yellow)) .actionColor(getResources().getColor(R.color.yellow))
.duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE) .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE)
,activity); // action button's ,activity); // action button's
p.edit().putInt("pg", player.getPg()).apply(); p.edit().putInt("pg", player.getPg()).apply();
pgUpdate(); pgUpdate();
@ -301,8 +415,11 @@ public class ShowPlayer extends ActionBarActivity {
alert.show(); alert.show();
} }
/**
* Sets the hit points progress bars to the adequate value and color.
* Sets the text indicating the numerical value of the hit points
*/
private void pgUpdate() { private void pgUpdate() {
int status = player.getState();
int pg = player.getPg(); int pg = player.getPg();
negPgBar.setProgress(pg < 0 ? -pg : 0); negPgBar.setProgress(pg < 0 ? -pg : 0);
posPgBar.setProgress(pg > 0 ? pg : 0); posPgBar.setProgress(pg > 0 ? pg : 0);
@ -314,6 +431,10 @@ public class ShowPlayer extends ActionBarActivity {
negPgBar.getProgressDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN); negPgBar.getProgressDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
} }
/**
* Recovers the player's data from the sharedPreferences and then updates all the layouts
* This includes an update for the attackList layout.
*/
private void restoreData(){ private void restoreData(){
//Loading player //Loading player
@ -325,9 +446,6 @@ public class ShowPlayer extends ActionBarActivity {
Player.LEVEL_PX[player.getLevel() - 1] Player.LEVEL_PX[player.getLevel() - 1]
); );
if (player.getMaxPg() == 0) {
pgDialog();
}
player.setCurativeEffort(p.getInt("curativeEfforts", player.getMaxCurativeEfforts())); player.setCurativeEffort(p.getInt("curativeEfforts", player.getMaxCurativeEfforts()));
player.setPg(p.getInt("pg", player.getMaxPg())); player.setPg(p.getInt("pg", player.getMaxPg()));
@ -339,11 +457,9 @@ public class ShowPlayer extends ActionBarActivity {
//set restored values to the respective fields //set restored values to the respective fields
toolbar.setTitle(player.getName()); toolbar.setTitle(player.getName());
toolbar.setSubtitle( toolbar.setSubtitle(
player.getClassName() + " " + player.getRaceName() + " " + player.getLevel() player.getClassName() + " " + player.getRaceName()
); );
toolbar.setTitleTextColor(getResources().getColor(R.color.white));
toolbar.setSubtitleTextColor(getResources().getColor(R.color.white));
//
// //attacks // //attacks
// ((TextView) findViewById(R.id.FUE)).setText( // ((TextView) findViewById(R.id.FUE)).setText(
// getString(R.string.FUE) + ":" + player.getFue() // getString(R.string.FUE) + ":" + player.getFue()
@ -383,6 +499,9 @@ public class ShowPlayer extends ActionBarActivity {
refreshList(); refreshList();
} }
/**
* This updates the progress and indicator text of the available surges.
*/
private void ceUpdate() { private void ceUpdate() {
curativeEffortsBar.setProgress(player.getCurativeEfforts()); curativeEffortsBar.setProgress(player.getCurativeEfforts());
currentCurativeEfforts.setText( currentCurativeEfforts.setText(
@ -391,8 +510,12 @@ public class ShowPlayer extends ActionBarActivity {
); );
} }
/**
* Updates the progress and indicator text of the XP
*/
private void pxUpdate() { private void pxUpdate() {
xpBar.setProgress(player.getPx()); xpBar.setProgress(player.getPx() - Player.LEVEL_PX[player.getLevel() - 1]);
level.setText(getString(R.string.level) + " " + player.getLevel());
currentXp.setText( currentXp.setText(
player.getPx() + " / " + player.getPx() + " / " +
Player.LEVEL_PX[player.getLevel()] Player.LEVEL_PX[player.getLevel()]
@ -400,12 +523,15 @@ public class ShowPlayer extends ActionBarActivity {
} }
/**
* Undoes the last change done by the player. Only used in damage(). Healing is not yet included
*/
private void undo() { private void undo() {
String message = ""; String message = "";
if(undoObject == CURRENT_PG){ if(undoObject == CURRENT_PG){
player.setPg(undoPreviousValue); player.setPg(undoPreviousValue);
undoObject = NULL; undoObject = NULL;
message = getString(R.string.action_undo_current_pg); message = getString(R.string.restored);
} }
if (!message.isEmpty()) { if (!message.isEmpty()) {
SnackbarManager.show( SnackbarManager.show(
@ -420,29 +546,11 @@ public class ShowPlayer extends ActionBarActivity {
invalidateOptionsMenu(); invalidateOptionsMenu();
} }
private void pgDialog() {
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
final EditText input = new EditText(this);
input.setHint(R.string.dialog_resolve_max_pg_hint);
input.setInputType(InputType.TYPE_CLASS_NUMBER);
input.setImeOptions(EditorInfo.IME_ACTION_DONE);
dialog
.setView(input)
.setCancelable(false)
.setTitle(R.string.dialog_resolve_max_pg_title)
.setMessage(R.string.dialog_resolve_max_pg_message)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (!input.getText().toString().isEmpty()) {
player.setMaxPg(Integer.parseInt(input.getText().toString()));
}
}
});
dialog.show();
input.requestFocus();
}
/**
* Launches the PowerEditor to create a new attack inside the current player
* @param view View Button that called this method (onClick)
*/
public void addToList (View view) { public void addToList (View view) {
startActivity( startActivity(
new Intent( new Intent(
@ -454,12 +562,20 @@ public class ShowPlayer extends ActionBarActivity {
); );
} }
/**
* Checks which list is currently displayed and shows on screen a list of the elements in that list
* No abilities are displayed yet, INCOMING FEATURE
*
* Also has a popup for the attacks (displaying all info)
* INCOMING FEATURE: onClicking one ability a dialog with a d20 appears and onClicking rolls,
* then displays the sum of the dice result plus the player's ability bonus
*/
private void refreshList() { private void refreshList() {
//TODO: check which is active (now there is only a power list), so there is only one possibility //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 n = p.getInt("powers",0);
int elements = 0; int elements = 0;
ListView attackList = (ListView) findViewById(R.id.attackList); attackList = (ListView) findViewById(R.id.attackList);
final AttackAdapter adapter = (AttackAdapter) attackList.getAdapter(); final AttackAdapter adapter = (AttackAdapter) attackList.getAdapter();
if ( adapter != null ) if ( adapter != null )
@ -471,16 +587,17 @@ public class ShowPlayer extends ActionBarActivity {
adapter.add( new Power ( sav ) ); adapter.add( new Power ( sav ) );
} }
} else if ( n != 0 ) { } else if ( n != 0 ) {
Power[] powers = new Power[n]; ArrayList<Power> powers = new ArrayList<>();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
SharedPreferences sav = getSharedPreferences(p.getString("power" + i, ""), MODE_PRIVATE); SharedPreferences sav = getSharedPreferences(p.getString("power" + i, ""), MODE_PRIVATE);
powers[i] = new Power(sav); powers.add( new Power(sav) );
} }
attackList.setAdapter(new AttackAdapter(this, powers)); attackList.setAdapter(new AttackAdapter(this, powers));
final Activity activity = this;
attackList.setOnItemClickListener(new AdapterView.OnItemClickListener() { attackList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
final Dialog dialog = new Dialog(ShowPlayer.this); final Dialog dialog = new Dialog(ShowPlayer.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
@ -498,7 +615,7 @@ public class ShowPlayer extends ActionBarActivity {
//identify all the elements from the VIEW and then add LISTENERS //identify all the elements from the VIEW and then add LISTENERS
final Power power = (Power) parent.getItemAtPosition(position); final Power power = (Power) parent.getItemAtPosition(position);
View nameText = dialog.findViewById(R.id.nameText); View nameText = dialog.findViewById(R.id.nameText);
int color = power.getFreqColor(getApplicationContext()); final int color = power.getFreqColor(getApplicationContext());
nameText.setBackgroundColor(color); nameText.setBackgroundColor(color);
((TextView) nameText).setText(power.getName()); ((TextView) nameText).setText(power.getName());
@ -517,17 +634,63 @@ public class ShowPlayer extends ActionBarActivity {
+ " " + getResources().getString(R.string.vs) + " " + getResources().getString(R.string.vs)
+ " " + defense[power.getDef()]); + " " + defense[power.getDef()]);
Button useButton = (Button) dialog.findViewById(R.id.useButton); final Button useButton = (Button) dialog.findViewById(R.id.useButton);
useButton.setBackgroundColor(color);
useButton.setTextColor(getResources().getColor(R.color.white));
if (power.isUsed()) { if (power.isUsed()) {
useButton.getBackground().setAlpha(0); useButton.getBackground().setAlpha(128);
useButton.setEnabled(false);
useButton.setClickable(false);
} else {
useButton.setBackgroundColor(color);
useButton.setTextColor(getResources().getColor(R.color.white));
useButton.getBackground().setAlpha(255);
useButton.setEnabled(true);
useButton.setClickable(true);
useButton.setOnClickListener(new View.OnClickListener() { useButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
//TODO: use power //TODO: use power
Toast.makeText(getApplicationContext(), "Power used!", Toast.LENGTH_LONG).show();
power.use(); power.use();
if (power.isUsed()) {
useButton.getBackground().setAlpha(128);
useButton.setTextColor(getResources().getColor(R.color.black));
useButton.setEnabled(false);
useButton.setClickable(false);
getSharedPreferences(p.getString("power" + position, ""), MODE_PRIVATE)
.edit().putBoolean("used", true).apply();
refreshList();
SnackbarManager.show(
Snackbar.with(getApplicationContext())
.text(getString(R.string.used) + " " + power.getName())
.actionListener(new ActionClickListener() {
@Override
public void onActionClicked(Snackbar snackbar) {
power.recover(Power.DIARIO);
useButton.setBackgroundColor(color);
useButton.setTextColor(getResources().getColor(R.color.white));
useButton.getBackground().setAlpha(255);
useButton.setEnabled(true);
useButton.setClickable(true);
getSharedPreferences(p.getString("power" + position, ""), MODE_PRIVATE)
.edit().putBoolean("used", false).apply();
refreshList();
}
})
.actionLabel(getString(R.string.action_undo))
.actionColor(getResources().getColor(R.color.yellow))
.duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE),
activity
);
} else {
SnackbarManager.show(
Snackbar.with(getApplicationContext())
.text(getString(R.string.used) + " " + power.getName())
.duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE),
activity
);
}
dialog.dismiss();
} }
}); });
} }
@ -541,40 +704,56 @@ public class ShowPlayer extends ActionBarActivity {
@Override @Override
public boolean onItemLongClick(final AdapterView<?> parent, View view, final int position, long id) { public boolean onItemLongClick(final AdapterView<?> parent, View view, final int position, long id) {
AlertDialog.Builder alert = new AlertDialog.Builder(thisActivity); AlertDialog.Builder alert = new AlertDialog.Builder(thisActivity);
alert.setItems(new String[]{"Delete", "Edit"}, new DialogInterface.OnClickListener() { alert.setItems(
@Override new String[]{getString(R.string.delete), getString(R.string.edit)},
public void onClick(DialogInterface dialog, int which) { new DialogInterface.OnClickListener()
if ( which == 0 ) { {
//delete the item @Override
String name = p.getString("power" + position, ""); public void onClick(DialogInterface dialog, int which) {
if (name != null && !name.isEmpty()) { if ( which == 0 ) {
getSharedPreferences(name, MODE_PRIVATE).edit().clear().apply(); SnackbarManager.show(
Log.d("Tag", thisActivity.getApplicationContext().getFilesDir().getParent() Snackbar.with(getApplicationContext())
+ File.separator + "shared_prefs" + File.separator + name + ".xml"); .text(R.string.sure)
try { .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE)
if(!new File(thisActivity.getApplicationContext().getFilesDir().getParent() .actionLabel(R.string.delete)
+ File.separator + "shared_prefs" + File.separator + name + ".xml").delete()) .actionColor(getResources().getColor(R.color.yellow))
throw new Exception(); .actionListener(new ActionClickListener() {
} catch (Exception e) { @Override
Toast.makeText(getApplicationContext(), "Error deleting attack files", Toast.LENGTH_SHORT).show(); public void onActionClicked(Snackbar snackbar) {
//delete the item
String name = p.getString("power" + position, "");
if (name != null && !name.isEmpty()) {
getSharedPreferences(name, MODE_PRIVATE).edit().clear().apply();
Log.d("Tag", thisActivity.getApplicationContext().getFilesDir().getParent()
+ File.separator + "shared_prefs" + File.separator + name + ".xml");
try {
if (!new File(thisActivity.getApplicationContext().getFilesDir().getParent()
+ File.separator + "shared_prefs" + File.separator + name + ".xml").delete())
throw new Exception();
} catch (Exception e) {
Log.e("POWER:DELETION", "Error deleting attack files\n" + e.getMessage() + "\n" + e.getStackTrace().toString());
}
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();
refreshList();
ed.remove("power" + (max - 1)).apply();
}
}
}),
thisActivity
);
} else {
//edit the item
startActivity(
new Intent(getApplicationContext(), PowerEditor.class)
.putExtra("power", position)
.putExtra("player", player.getName())
);
} }
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();
refreshList();
ed.remove("power" + (max - 1)).apply();
} }
} else {
//edit the item
startActivity(
new Intent(getApplicationContext(), PowerEditor.class)
.putExtra("power", position)
.putExtra("player", player.getName())
);
}
}
}); });
alert.show(); alert.show();
return true; return true;

View file

@ -4,6 +4,7 @@ import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.support.annotation.NonNull;
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.support.v7.widget.Toolbar;
@ -15,7 +16,12 @@ import android.widget.AdapterView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.Toast; import android.widget.Toast;
import com.nispok.snackbar.Snackbar;
import com.nispok.snackbar.SnackbarManager;
import com.nispok.snackbar.listeners.ActionClickListener;
import java.io.File; import java.io.File;
import java.util.ArrayList;
public class Welcome extends ActionBarActivity { public class Welcome extends ActionBarActivity {
@ -23,12 +29,13 @@ public class Welcome extends ActionBarActivity {
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)); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setTitleTextColor(getResources().getColor(R.color.white));
p = getSharedPreferences(PREFERENCES, MODE_PRIVATE); p = getSharedPreferences(PREFERENCES, MODE_PRIVATE);
load(); load();
} }
@ -65,7 +72,7 @@ public class Welcome extends ActionBarActivity {
private void load() { private void load() {
int n = p.getInt("players",0); int n = p.getInt("players",0);
ListView playerList = (ListView) findViewById(R.id.listView); ListView playerList = (ListView) findViewById(R.id.listView);
PlayerAdapter adapter = (PlayerAdapter) playerList.getAdapter(); final PlayerAdapter adapter = (PlayerAdapter) playerList.getAdapter();
int elements = 0; int elements = 0;
if ( adapter != null ) if ( adapter != null )
elements = adapter.getCount(); elements = adapter.getCount();
@ -78,17 +85,16 @@ public class Welcome extends ActionBarActivity {
if (sav.contains(Player.NAME)) if (sav.contains(Player.NAME))
adapter.add( new Player( sav ) ); adapter.add( new Player( sav ) );
} }
//int pg, int maxPg, int px, int curativeEfforts, int maxCurativeEfforts, int classInt, adapter.notifyDataSetChanged();
//int raceInt, String name, int[] atk, int[] def, int[] abilities, Power[] powers
} else if ( n != 0 ) { } else if ( n != 0 ) {
playerList.setVisibility(View.VISIBLE); playerList.setVisibility(View.VISIBLE);
findViewById(R.id.help_text).setVisibility(View.VISIBLE); findViewById(R.id.help_text).setVisibility(View.VISIBLE);
findViewById(R.id.no_players_text).setVisibility(View.GONE); findViewById(R.id.no_players_text).setVisibility(View.GONE);
Player[] players = new Player[n]; ArrayList<Player> players = new ArrayList<>();
for ( int i = 0; i < n; i++ ) { for ( int i = 0; i < n; i++ ) {
SharedPreferences sav = getSharedPreferences(p.getString("player" + i, ""), MODE_PRIVATE); SharedPreferences sav = getSharedPreferences(p.getString("player" + i, ""), MODE_PRIVATE);
if (sav.contains(Player.NAME)) if (sav.contains(Player.NAME)) //TODO: adding a second player causes an error
players[i] = new Player( sav ); players.add( new Player( sav ) );
} }
playerList.setAdapter(new PlayerAdapter(this, players)); playerList.setAdapter(new PlayerAdapter(this, players));
@ -106,45 +112,70 @@ public class Welcome extends ActionBarActivity {
@Override @Override
public boolean onItemLongClick(final AdapterView<?> parent, View view, final int position, long id) { public boolean onItemLongClick(final AdapterView<?> parent, View view, final int position, long id) {
AlertDialog.Builder alert = new AlertDialog.Builder(activity); AlertDialog.Builder alert = new AlertDialog.Builder(activity);
alert.setItems(new String[]{"Delete", "Edit", "Export"}, new DialogInterface.OnClickListener() { alert.setItems(
@Override new String[]{
public void onClick(DialogInterface dialog, int which) { getString(R.string.delete),
if ( which == 0 ) { getString(R.string.edit),
//delete the item getString(R.string.export)},
String name = p.getString("player" + position, ""); new DialogInterface.OnClickListener() {
if (name != null && !name.isEmpty()) { @Override
getSharedPreferences(name, MODE_PRIVATE).edit().clear().apply(); public void onClick(DialogInterface dialog, int which) {
Log.d("Tag", activity.getApplicationContext().getFilesDir().getParent() if (which == 0) {
+ File.separator + "shared_prefs" + File.separator + name + ".xml"); //delete the item
try { SnackbarManager.show(
if(!new File(activity.getApplicationContext().getFilesDir().getParent() Snackbar.with(getApplicationContext())
+ File.separator + "shared_prefs" + File.separator + name + ".xml").delete()) .text(R.string.sure)
throw new Exception(); .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE)
} catch (Exception e) { .actionLabel(R.string.delete)
Toast.makeText(getApplicationContext(), "Error deleting player files", Toast.LENGTH_SHORT).show(); .actionColor(getResources().getColor(R.color.yellow))
} .actionListener(new ActionClickListener() {
int max = p.getInt("players", 0); @Override
SharedPreferences.Editor ed = p.edit(); public void onActionClicked(Snackbar snackbar) {
for (int i = position; i < max - 1; i++) String name = p.getString("player" + position, "");
ed.putString("player" + i, p.getString("player" + (i + 1), "max")); if (name != null && !name.isEmpty()) {
ed.putInt("players", max - 1).apply(); getSharedPreferences(name, MODE_PRIVATE).edit().clear().apply();
load(); Log.d("Tag", activity.getApplicationContext().getFilesDir().getParent()
ed.remove("player" + (max - 1)).apply(); + 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(getApplicationContext(), "Error deleting player files", Toast.LENGTH_SHORT).show();
}
int max = p.getInt("players", 0);
SharedPreferences.Editor ed = p.edit();
for (int i = position; i < max - 1; i++)
ed.putString("player" + i, p.getString("player" + (i + 1), "max"));
ed.putInt("players", max - 1).apply();
load();
ed.remove("player" + (max - 1)).apply();
}
}
}),
activity
);
} else if(which==1) {
//TODO: edit the player
/**TEMP*/
Toast.makeText(
activity, "Editor not implemented yet", Toast.LENGTH_LONG)
.show();
} else {
//TODO: export as files
/**TEMP*/
Toast.makeText(
activity, "Exporting feature not implemented yet", Toast.LENGTH_LONG)
.show();
} }
} else if (which == 1) {
//TODO: edit the player
Toast.makeText(
activity, "Editor not implemented yet", Toast.LENGTH_LONG)
.show();
} else {
//TODO: export as filesh
} }
}
});
alert.show();
return true;
} }
});
);
alert.show();
return true;
}
});
} else { } else {
playerList.setVisibility(View.GONE); playerList.setVisibility(View.GONE);
findViewById(R.id.help_text).setVisibility(View.GONE); findViewById(R.id.help_text).setVisibility(View.GONE);

View file

@ -0,0 +1,5 @@
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

View file

@ -1,6 +1,7 @@
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
@ -11,9 +12,9 @@
android:minHeight="?attr/actionBarSize" android:minHeight="?attr/actionBarSize"
android:background="@color/primary" android:background="@color/primary"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
</android.support.v7.widget.Toolbar> app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -169,7 +170,7 @@
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="visible" android:visibility="gone"
android:id="@+id/fourthLayout"> android:id="@+id/fourthLayout">
<Button <Button

View file

@ -1,6 +1,7 @@
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
@ -13,8 +14,9 @@
android:minHeight="?attr/actionBarSize" android:minHeight="?attr/actionBarSize"
android:background="@color/primary" android:background="@color/primary"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
</android.support.v7.widget.Toolbar> app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<ScrollView <ScrollView
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent"> android:layout_height="fill_parent">
@ -31,6 +33,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/nameEdit" android:id="@+id/nameEdit"
android:capitalize="sentences"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
@ -41,6 +44,7 @@
<EditText <EditText
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:capitalize="sentences"
android:id="@+id/keywordsEdit" android:id="@+id/keywordsEdit"
android:layout_below="@+id/nameEdit" android:layout_below="@+id/nameEdit"
android:layout_alignRight="@+id/nameEdit" android:layout_alignRight="@+id/nameEdit"
@ -147,6 +151,7 @@
android:layout_below="@+id/vsLayout" android:layout_below="@+id/vsLayout"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:capitalize="sentences"
android:hint="@string/impactEditHint" android:hint="@string/impactEditHint"
android:layout_toRightOf="@+id/attackText" android:layout_toRightOf="@+id/attackText"
android:layout_toEndOf="@+id/attackText" /> android:layout_toEndOf="@+id/attackText" />
@ -194,6 +199,7 @@
android:hint="@string/objectiveHint" android:hint="@string/objectiveHint"
android:layout_below="@+id/actionTypeSpinner" android:layout_below="@+id/actionTypeSpinner"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:capitalize="sentences"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_toRightOf="@+id/objectiveText" android:layout_toRightOf="@+id/objectiveText"
android:layout_toEndOf="@+id/objectiveText" /> android:layout_toEndOf="@+id/objectiveText" />

View file

@ -1,35 +1,100 @@
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
tools:context=".ShowPlayer"> tools:context=".ShowPlayer">
<android.support.v7.widget.Toolbar <android.support.v7.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:minHeight="?attr/actionBarSize" android:minHeight="?attr/actionBarSize"
android:background="@color/primary" android:background="@color/primary"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
</android.support.v7.widget.Toolbar> app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<LinearLayout <LinearLayout
android:layout_marginBottom="@dimen/activity_vertical_margin" android:layout_width="match_parent"
android:layout_marginTop="@dimen/activity_vertical_margin" android:layout_height="match_parent"
android:layout_marginLeft="@dimen/activity_horizontal_margin" android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin" android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_width="match_parent" android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_height="match_parent" android:layout_marginRight="@dimen/activity_horizontal_margin"
android:orientation="vertical"> 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 <LinearLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:onClick="damage"
android:clickable="true"
android:layout_marginBottom="@dimen/bar_margin"> android:layout_marginBottom="@dimen/bar_margin">
<LinearLayout <LinearLayout
@ -38,8 +103,47 @@
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
android:id="@+id/titlePgBar" android:id="@+id/titleCurativeEffortsBar"
android:text="@string/pg" 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:textAllCaps="true"
android:drawableBottom="?android:attr/listChoiceBackgroundIndicator" android:drawableBottom="?android:attr/listChoiceBackgroundIndicator"
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -50,189 +154,200 @@
android:paddingLeft="8dip" android:paddingLeft="8dip"
android:paddingRight="8dip" android:paddingRight="8dip"
android:layout_weight="1"/> android:layout_weight="1"/>
<TextView
android:id="@+id/level"
tools:text="Level 1"
android:textAllCaps="true"
android:gravity="center_horizontal"
android:drawableBottom="?android:attr/listChoiceBackgroundIndicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="?android:textColorSecondary"
android:layout_weight="1"/>
<TextView <TextView
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="end" android:gravity="end"
android:id="@+id/currentPg" android:id="@+id/currentXp"
android:textSize="14sp" android:textSize="14sp"
android:textStyle="bold" android:textStyle="bold"
android:textAllCaps="true" android:textAllCaps="true"
android:layout_weight="1"/> android:layout_weight="1"/>
</LinearLayout> </LinearLayout>
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/xpBar"/>
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:layout_gravity="center_horizontal">
<ProgressBar
style="?android:attr/progressBarStyleHorizontal" <Button
android:layout_width="fill_parent" style="?android:attr/buttonBarButtonStyle"
android:layout_height="wrap_content"
android:id="@+id/negPgBar"
android:layout_weight="2"
android:rotation="180"/>
<TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAllCaps="true" android:id="@+id/addElement"
android:text="@string/new_attack"
android:textColor="@color/primary"
android:textStyle="bold" android:textStyle="bold"
android:layout_marginRight="5dp" android:onClick="addToList"/>
android:layout_marginLeft="5dp"
android:text="@string/zero"/> <Button
<ProgressBar style="?android:attr/buttonBarButtonStyle"
style="?android:attr/progressBarStyleHorizontal" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/listSelectButton"
android:textStyle="bold"
android:textColor="@color/primary"
android:text="Go to abilities"/>
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/attackList"
android:layout_gravity="center_horizontal"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
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_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/pgBar" android:id="@+id/defenseGrid"
android:layout_weight="1"/> android:columnCount="2"
</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"
android: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"> android:rowCount="2">
<TextView <TextView
@ -240,143 +355,45 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace" android:typeface="monospace"
android:ems="4" android:ems="5"
android:layout_row="0" android:layout_row="0"
android:layout_column="0" android:layout_column="0"
android:id="@+id/FUE" android:id="@+id/CA"
tools:text="@string/FUE" /> tools:text="@string/CA" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace" android:typeface="monospace"
android:ems="4" 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_row="1"
android:layout_column="0" android:layout_column="0"
android:id="@+id/CON" android:id="@+id/REF"
tools:text="@string/CON" /> tools:text="@string/REF" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace" android:typeface="monospace"
android:ems="4" android:ems="5"
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_row="1"
android:layout_column="1" android:layout_column="1"
android:id="@+id/INT" android:id="@+id/VOL"
tools:text="@string/INT" /> tools:text="@string/VOL" />
<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> </GridLayout>
</HorizontalScrollView> </LinearLayout>
</LinearLayout> </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> </LinearLayout>

View file

@ -9,20 +9,9 @@
android:minHeight="?attr/actionBarSize" android:minHeight="?attr/actionBarSize"
android:background="@color/primary" android:background="@color/primary"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:title="@string/app_name">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#EEEEEE"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/app_name"
android:id="@+id/title" />
</RelativeLayout>
</android.support.v7.widget.Toolbar> </android.support.v7.widget.Toolbar>

View file

@ -2,24 +2,25 @@
<RelativeLayout <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:background="@color/at_will"> tools:background="@color/at_will"
android:paddingLeft="5dp"
android:paddingRight="5dp">
<TextView <TextView
tools:text="Happiness" tools:text="Happiness"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textAppearance="?android:attr/textAppearanceLarge" android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/name" /> android:id="@+id/name" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:text="Melee 1" tools:text="Melee 1"
android:textAppearance="?android:attr/textAppearanceMedium" android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/extra" android:id="@+id/extra"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:layout_below="@+id/name" android:layout_below="@+id/name"
@ -29,7 +30,7 @@
<TextView <TextView
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/textAppearanceSmall"
android:id="@+id/keywords" android:id="@+id/keywords"
tools:text="(fire, explosion)" tools:text="(fire, explosion)"
android:textColor="@android:color/white" android:textColor="@android:color/white"
@ -41,7 +42,7 @@
<TextView <TextView
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/textAppearanceSmall"
android:id="@+id/frequency" android:id="@+id/frequency"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:layout_alignBottom="@+id/name" android:layout_alignBottom="@+id/name"

View file

@ -0,0 +1,12 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.kauron.dungeonmanager.PlayerCreatorFragment">
<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>

View file

@ -0,0 +1,5 @@
<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.PlayerCreator">
</menu>

View file

@ -80,8 +80,7 @@
<string name="character_creation">Creación de personaje</string> <string name="character_creation">Creación de personaje</string>
<string name="delete">Borrar</string> <string name="delete">Borrar</string>
<string name="edit">Editar</string> <string name="edit">Editar</string>
<string name="hello_world"></string> <string name="help_welcome_text">Toca un jugador para seleccionarlo, mantén pulsado para opciones</string>
<string name="help_welcome_text">Toca un jugador para seleccionarlo, pulsación larga para opciones</string>
<string name="impact">Impacto</string> <string name="impact">Impacto</string>
<string name="impactEditHint">1d6 + 4 y eres invisible</string> <string name="impactEditHint">1d6 + 4 y eres invisible</string>
<string name="keywords">Palabras clave</string> <string name="keywords">Palabras clave</string>
@ -156,5 +155,15 @@
<item>Reflejos</item> <item>Reflejos</item>
<item>Voluntad</item> <item>Voluntad</item>
</string-array> </string-array>
<string name="required">Este campo es obligatorio</string> <string name="required">Este campo es obligatorio</string>
<string name="sure">¿Estás seguro?</string>
<string name="used">Has usado</string>
<string name="restored">Valores restaurados</string>
<string name="export">Exportar</string>
<string name="healed">Has recuperado %d PG</string>
<string name="title_activity_player_creator">Creador de personaje</string>
<string name="lost_hp">Has perdido %d PG</string>
<string name="level_up">Subir un nivel</string>
</resources> </resources>

View file

@ -11,8 +11,9 @@
<color name="red">#9F0D0A</color> <color name="red">#9F0D0A</color>
<color name="yellow">#FFBB00</color> <color name="yellow">#FFBB00</color>
<color name="green">#0f0</color> <color name="green">#4F8C17</color>
<color name="white">#EEEEEE</color> <color name="white">#EEEEEE</color>
<color name="black">#000000</color>
<color name="daily">#33292A</color> <color name="daily">#33292A</color>
<color name="encounter">#6B0617</color> <color name="encounter">#6B0617</color>
@ -21,7 +22,6 @@
<color name="surges_bar">#989F2B</color> <color name="surges_bar">#989F2B</color>
<color name="px_bar">#005874</color> <color name="px_bar">#005874</color>
<color name="black">#000000</color>
<!--<color name="primary">#5D4037</color>--> <!--<color name="primary">#5D4037</color>-->
<!--<color name="primaryDark">#3E2723</color>--> <!--<color name="primaryDark">#3E2723</color>-->
</resources> </resources>

View file

@ -84,13 +84,12 @@
<string name="new_attack">New attack</string> <string name="new_attack">New attack</string>
<string name="edit">Edit</string> <string name="edit">Edit</string>
<string name="delete">Delete</string> <string name="delete">Delete</string>
<string name="title_activity_power_editor">PowerEditor</string> <string name="title_activity_power_editor">Power Editor</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="zero" translatable="false">0</string>
<string name="no_players">No players, please add one</string> <string name="no_players">No players, please add one</string>
<string name="help_welcome_text">Press a player to open, long press for options</string> <string name="help_welcome_text">Press a player to open, hold for options</string>
<string name="character_creation">Character creation</string> <string name="character_creation">Character creation</string>
<string name="name">Name</string> <string name="name">Name</string>
<string name="keywords">Keywords</string> <string name="keywords">Keywords</string>
@ -106,6 +105,11 @@
<string name="power_editor">Power Editor</string> <string name="power_editor">Power Editor</string>
<string name="save_player">Save player</string> <string name="save_player">Save player</string>
<string name="required">This field is required</string> <string name="required">This field is required</string>
<string name="used">You have used</string>
<string name="sure">Are you sure?</string>
<string name="healed">You have restored %d HP</string>
<string name="restored">Values restored</string>
<string name="export">Exportar</string>
<string-array name="freq_array"> <string-array name="freq_array">
<item>Frequency</item> <item>Frequency</item>
@ -167,4 +171,9 @@
<item>Reflexes</item> <item>Reflexes</item>
<item>Will</item> <item>Will</item>
</string-array> </string-array>
<string name="title_activity_player_creator">Player Creator</string>
<string name="hello_world">Hello world!</string>
<string name="lost_hp">Lost %d HP</string>
<string name="level_up">Level up</string>
</resources> </resources>

View file

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