diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/CharacterSheetFragment.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/CharacterSheetFragment.java
index 9ac928f..d091309 100644
--- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/CharacterSheetFragment.java
+++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/CharacterSheetFragment.java
@@ -21,7 +21,7 @@
* Created by Thorin Schmidt on 4/1/2017.
*/
-public class CharacterSheetFragment extends Fragment {
+public class CharacterSheetFragment extends Fragment implements StatChangeFragment.OnStatChangeListener{
public static final String ROLL_RESULT = "RollResult";
public static final String TAG = "CharacterSheetFragment";
@@ -85,6 +85,13 @@ public View onCreateView(LayoutInflater li, ViewGroup vg, Bundle b){
mMightButton = (Button) rootView.findViewById(R.id.might_score_button);
mMightButton.setText(Integer.toString(mSheetPlayerCharacter.
getScore(Score.MIGHT).getScore()));
+ mMightButton.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View view) {
+ onScoreLongClick(Score.MIGHT, "Might");
+ return true;
+ }
+ });
mMightButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -95,6 +102,13 @@ public void onClick(View v) {
mSkillButton = (Button) rootView.findViewById(R.id.skill_score_button);
mSkillButton.setText(Integer.toString(mSheetPlayerCharacter.
getScore(Score.SKILL).getScore()));
+ mSkillButton.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View view) {
+ onScoreLongClick(Score.SKILL, "Skill");
+ return true;
+ }
+ });
mSkillButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
@@ -105,6 +119,13 @@ public void onClick(View v){
mWitsButton = (Button) rootView.findViewById(R.id.wits_score_button);
mWitsButton.setText(Integer.toString(mSheetPlayerCharacter.
getScore(Score.WITS).getScore()));
+ mWitsButton.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View view) {
+ onScoreLongClick(Score.WITS, "Wits");
+ return true;
+ }
+ });
mWitsButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
@@ -115,6 +136,13 @@ public void onClick(View v){
mLuckButton = (Button) rootView.findViewById(R.id.luck_score_button);
mLuckButton.setText(Integer.toString(mSheetPlayerCharacter.
getScore(Score.LUCK).getScore()));
+ mLuckButton.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View view) {
+ onScoreLongClick(Score.LUCK, "Luck");
+ return true;
+ }
+ });
mLuckButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
@@ -125,6 +153,13 @@ public void onClick(View v){
mWillButton = (Button) rootView.findViewById(R.id.will_score_button);
mWillButton.setText(Integer.toString(mSheetPlayerCharacter.
getScore(Score.WILL).getScore()));
+ mWillButton.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View view) {
+ onScoreLongClick(Score.WILL, "Will");
+ return true;
+ }
+ });
mWillButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
@@ -135,6 +170,13 @@ public void onClick(View v){
mGraceButton = (Button) rootView.findViewById(R.id.grace_score_button);
mGraceButton.setText(Integer.toString(mSheetPlayerCharacter.
getScore(Score.GRACE).getScore()));
+ mGraceButton.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View view) {
+ onScoreLongClick(Score.GRACE, "Grace");
+ return true;
+ }
+ });
mGraceButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
@@ -268,6 +310,14 @@ public void onScoreClick(Score skill, String name){
dialog.show(fm, ROLL_RESULT);
}
+ public void onScoreLongClick(Score skill, String name) {
+ FragmentManager fm = getFragmentManager();
+ StatChangeFragment dialog = StatChangeFragment.newInstance(name,
+ mSheetPlayerCharacter.getScore(skill).getScore());
+ dialog.setStatChangeListener(this);
+ dialog.show(fm, ROLL_RESULT);
+ }
+
public void onAttackClick(int attackType, boolean wocEquipped){
int modifier;
int attackRoll1 = Util.roll(20);
@@ -278,6 +328,7 @@ public void onAttackClick(int attackType, boolean wocEquipped){
modifier = mSheetPlayerCharacter.getMeleeMod();
}
else if (attackType == R.string.missile){
+ //TODO make missile mod
modifier = mSheetPlayerCharacter.getMeleeMod();
}
else{
@@ -319,4 +370,33 @@ public void onSaveCharacterClick(){
SaveAndLoadDialog dialog = SaveAndLoadDialog.newInstance(mCurrentCharacterIndex);
dialog.show(fm, ROLL_RESULT);
}
+
+ @Override
+ public void onStatChange(Score score, int newValue) {
+ if (mSheetPlayerCharacter.getScore(score).getScore() != newValue) {
+ mSheetPlayerCharacter.getScore(score).setScore(newValue);
+ mSheetPlayerCharacter.validateScores();
+ }
+ refreshView();
+ }
+
+ private void refreshView() {
+ mMightButton.setText(Integer.toString(mSheetPlayerCharacter.
+ getScore(Score.MIGHT).getScore()));
+ mSkillButton.setText(Integer.toString(mSheetPlayerCharacter.
+ getScore(Score.SKILL).getScore()));
+ mWitsButton.setText(Integer.toString(mSheetPlayerCharacter.
+ getScore(Score.WITS).getScore()));
+ mLuckButton.setText(Integer.toString(mSheetPlayerCharacter.
+ getScore(Score.LUCK).getScore()));
+ mWillButton.setText(Integer.toString(mSheetPlayerCharacter.
+ getScore(Score.WILL).getScore()));
+ mGraceButton.setText(Integer.toString(mSheetPlayerCharacter.
+ getScore(Score.GRACE).getScore()));
+ mInitiativeButton.setText(Integer.toString(mSheetPlayerCharacter.getInitiative()));
+ mAPbutton.setText(Integer.toString(mSheetPlayerCharacter.getAthleticProwess()));
+ mDEbutton.setText(Integer.toString(mSheetPlayerCharacter.getDangerEvasion()));
+ mMFbutton.setText(Integer.toString(mSheetPlayerCharacter.getMysticFortitude()));
+ mPVbutton.setText(Integer.toString(mSheetPlayerCharacter.getPhysicalVigor()));
+ }
}
diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/StatChangeFragment.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/StatChangeFragment.java
new file mode 100644
index 0000000..4979595
--- /dev/null
+++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/StatChangeFragment.java
@@ -0,0 +1,103 @@
+package com.example.cis.mazeminotaurs;
+
+import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import com.example.cis.mazeminotaurs.character.stats.Score;
+
+/**
+ * Created by jsmith on 9/19/17.
+ *
+ * Variant of Thorin Schmidt's RollResultFragment
+ */
+
+public class StatChangeFragment extends DialogFragment {
+ public interface OnStatChangeListener {
+ void onStatChange(Score score, int newValue);
+ }
+ OnStatChangeListener mStatChangeListener;
+
+ String mStringScore;
+ Score mScore;
+ int mOldValue;
+
+ EditText mNewValue;
+ /**
+ * Create a new instance of StatChangeFragment, providing "score"
+ * and "value" as arguments.
+ */
+ static StatChangeFragment newInstance(String score, int value) {
+ StatChangeFragment f = new StatChangeFragment();
+
+ // Supply num input as an argument.
+ Bundle args = new Bundle();
+ args.putString("stat", score);
+ args.putInt("value", value);
+ f.setArguments(args);
+
+ return f;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState){
+ super.onCreate(savedInstanceState);
+
+ mStringScore = getArguments().getString("stat");
+ if (mStringScore != null) {
+ switch (mStringScore) {
+ case "Might":
+ mScore = Score.MIGHT;
+ break;
+ case "Grace":
+ mScore = Score.GRACE;
+ break;
+ case "Skill":
+ mScore = Score.SKILL;
+ break;
+ case "Will":
+ mScore = Score.WILL;
+ break;
+ case "Wits":
+ mScore = Score.WITS;
+ break;
+ case "Luck":
+ mScore = Score.LUCK;
+ break;
+ }
+ }
+ mOldValue = getArguments().getInt("value");
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ final View v = inflater.inflate(R.layout.dialog_attribute_edit, container, false);
+ View oldTv = v.findViewById(R.id.attribute_old_base);
+ ((TextView) oldTv).setText(getContext().getString(R.string.old_attribute_value, mStringScore, mOldValue));
+ mNewValue = (EditText) v.findViewById(R.id.attribute_new_base_edit);
+ v.findViewById(R.id.attribute_confirm_button).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ int newValue = Integer.valueOf(mNewValue.getText().toString());
+ getStatChangeListener().onStatChange(mScore, newValue);
+ dismiss();
+ }
+ });
+
+ return v;
+
+ }
+
+ public OnStatChangeListener getStatChangeListener() {
+ return this.mStatChangeListener;
+ }
+
+ public void setStatChangeListener(OnStatChangeListener statChangeListener) {
+ this.mStatChangeListener = statChangeListener;
+ }
+}
\ No newline at end of file
diff --git a/MazesAndMinotaurs/app/src/main/res/layout/dialog_attribute_edit.xml b/MazesAndMinotaurs/app/src/main/res/layout/dialog_attribute_edit.xml
new file mode 100644
index 0000000..99b4426
--- /dev/null
+++ b/MazesAndMinotaurs/app/src/main/res/layout/dialog_attribute_edit.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MazesAndMinotaurs/app/src/main/res/values/strings.xml b/MazesAndMinotaurs/app/src/main/res/values/strings.xml
index 3f2139c..cb79715 100644
--- a/MazesAndMinotaurs/app/src/main/res/values/strings.xml
+++ b/MazesAndMinotaurs/app/src/main/res/values/strings.xml
@@ -51,4 +51,8 @@
Talent Name
Power
+
+ Confirm
+ %s Old Value\n%2d
+ New Value