1
0
Fork 0

Powers display

This commit is contained in:
Carlos Galindo 2015-04-23 15:39:45 +02:00
parent 9a9af9d6e5
commit 2fc2ff61ba
11 changed files with 370 additions and 68 deletions

View file

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

View file

@ -36,45 +36,6 @@ class AttackAdapter extends ArrayAdapter<Power> {
((TextView) mView.findViewById(R.id.keywords)).setText(attack.getKeywords());
((TextView) mView.findViewById(R.id.frequency)).setText(attack.getFrequencyString());
((TextView) mView.findViewById(R.id.extra)).setText(attack.getRangeString() + " " + attack.getDistance());
final AttackAdapter current = this;
mView.findViewById(R.id.delete);
// mView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// SnackbarManager.show(
// Snackbar.with(getContext()).text("¿Quieres borrarlo?").actionLabel("").actionListener(new ActionClickListener() {
// @Override
// public void onActionClicked(Snackbar snackbar) {
// //delete the item
// String name = p.getString("power" + position, "");
// if (name != null && !name.isEmpty()) {
// getContext().getSharedPreferences(name, Context.MODE_PRIVATE).edit().clear().apply();
// Log.d("Tag", activity.getApplicationContext().getFilesDir().getParent()
// + File.separator + "shared_prefs" + File.separator + name + ".xml");
// try {
// if (!new File(activity.getApplicationContext().getFilesDir().getParent()
// + File.separator + "shared_prefs" + File.separator + name + ".xml").delete())
// throw new Exception();
// } catch (Exception e) {
// Toast.makeText(getContext(), "Error deleting player files", Toast.LENGTH_SHORT).show();
// }
// int max = p.getInt("powers", 0);
// SharedPreferences.Editor ed = p.edit();
// for (int i = position; i < max - 1; i++)
// ed.putString("power" + i, p.getString("power" + (i + 1), "max"));
// ed.putInt("powers", max - 1).apply();
// load();
// ed.remove("power" + (max - 1)).apply();
// }
// }
//
// ));
// //TODO: convert text to resource
// }
// }
//
// );
// };
}
return mView;
}

View file

@ -160,7 +160,7 @@ class Player implements Serializable {
this.pg = maxPg;
this.maxPg = maxPg;
}
void setMaxPgOnLevelUp() {maxPg += CLASS_STATS[PG_ON_LEVEL_UP][classInt];}
private void setMaxPgOnLevelUp() {maxPg += CLASS_STATS[PG_ON_LEVEL_UP][classInt];}
int getPg() {return pg;}
void setPg(int pg) {this.pg = pg; setState();}
@ -206,10 +206,8 @@ class Player implements Serializable {
String getName() {return name;}
String getClassName() {return CLASS_STRINGS[classInt];}
String getRaceName() {return RACE_STRINGS[raceInt];}
void setRaceInt(int raceInt) {this.raceInt = raceInt;}
int getRaceInt() {return raceInt;}
void setAtk(int[] atk) {this.atk = atk; if(classInt != NULL) setClass();}
private void setAtk(int[] atk) {this.atk = atk; if(classInt != NULL) setClass();}
int getFue() {return atk[FUE];}
int getCon() {return atk[CON];}
@ -222,7 +220,7 @@ class Player implements Serializable {
int getRef() {return def[REF];}
int getVol() {return def[VOL];}
void setClass() {
private void setClass() {
if(level == 1) maxPg = atk[CON] + CLASS_STATS[INITIAL_PG][classInt];
maxCurativeEfforts = Player.getModifier(atk[CON]) + CLASS_STATS[DAILY_CURATIVE_EFFORTS][classInt];
//TODO: implement armor!

View file

@ -1,6 +1,7 @@
package com.kauron.dungeonmanager;
import android.content.SharedPreferences;
import android.graphics.Color;
import java.io.Serializable;
@ -45,16 +46,22 @@ class Power implements Serializable{
String getKeywords() {return keywords;}
String getTypeString() {return ACTIONS[action];}
String getFrequencyString() {return FREQ[freq];}
int getFreq() {return freq;}
String getRangeString() {return DISTANCES[range];}
int getRange() {return range;}
int getAtk() {return atk;}
int getDef() {return def;}
int getFreq() {return freq;}
int getDistance() {return distance;}
String getName(){return name;}
String getImpact() {return impact;}
String getObjective() {return objective;}
String getOther() {return "";}
//TODO: add other element to include further description
boolean isUsed(){return used;}

View file

@ -1,10 +1,13 @@
package com.kauron.dungeonmanager;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
@ -131,9 +134,7 @@ public class ShowPlayer extends ActionBarActivity {
try {
boolean levelUp = player.addPx(Integer.parseInt(input.getText().toString()));
if (levelUp) {
//levelUp
//TODO: improve leveling up by using a sliding guide
player.setMaxPgOnLevelUp();
}
p.edit().putInt("px", player.getPx()).apply();
if(levelUp)
@ -479,12 +480,82 @@ public class ShowPlayer extends ActionBarActivity {
}
attackList.setAdapter(new AttackAdapter(this, powers));
final Activity thisActivity = this;
attackList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(getApplicationContext(), ((Power)parent.getItemAtPosition(position)).getName(), Toast.LENGTH_LONG).show();
//TODO: show here dialog with power's complete information, and buttons to use, recharge or delete
final Dialog dialog = new Dialog(ShowPlayer.this);
dialog.setContentView(R.layout.attack_display);
// set the custom dialog components - text, image and button
// Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
// // if button is clicked, close the custom dialog
// dialogButton.setOnClickListener(new OnClickListener() {
// @Override
// public void onClick(View v) {
// dialog.dismiss();
// }
// });
//identify all the elements from the VIEW and then add LISTENERS
Power power = (Power) parent.getItemAtPosition(position);
View nameText = dialog.findViewById(R.id.nameText);
switch(power.getFreq()){
case Power.A_VOLUNTAD:
nameText.setBackgroundColor(getResources().getColor(R.color.at_will));
break;
case Power.ENCUENTRO:
nameText.setBackgroundColor(getResources().getColor(R.color.encounter));
break;
case Power.DIARIO:
nameText.setBackgroundColor(getResources().getColor(R.color.daily));
break;
default:
nameText.setBackgroundColor(getResources().getColor(R.color.green));
}
//TODO: fix the title gap
((TextView) nameText) .setText(power.getName());
((TextView) dialog.findViewById(R.id.typeText)) .setText(power.getTypeString());
((TextView) dialog.findViewById(R.id.rangeText)) .setText(power.getRangeString() + " ");
((TextView) dialog.findViewById(R.id.freqText)) .setText(power.getFrequencyString());
((TextView) dialog.findViewById(R.id.keywordsText)) .setText(power.getKeywords());
((TextView) dialog.findViewById(R.id.distanceText)) .setText(String.valueOf(power.getDistance()));
((TextView) dialog.findViewById(R.id.objectiveText)).setText(power.getObjective());
((TextView) dialog.findViewById(R.id.impactText)) .setText(power.getImpact());
((TextView) dialog.findViewById(R.id.otherText)) .setText(power.getOther());
String[] attack = getResources().getStringArray(R.array.attack_array);
String[] defense = getResources().getStringArray(R.array.defense_array);
//TODO: add attack and defense array
((TextView) dialog.findViewById(R.id.attackText)) .setText(attack[power.getAtk()]
+ " " + getResources().getString(R.string.vs)
+ " " + defense[power.getDef()]);
dialog.findViewById(R.id.useButton).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//TODO: use power
Toast.makeText(getApplicationContext(), "Use it", Toast.LENGTH_LONG).show();
}
});
dialog.findViewById(R.id.deleteButton).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//TODO: delete power
Toast.makeText(getApplicationContext(), "Delete it", Toast.LENGTH_LONG).show();
}
});
dialog.findViewById(R.id.editButton).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//TODO: edit power
Toast.makeText(getApplicationContext(), "Edit it", Toast.LENGTH_LONG).show();
}
});
dialog.show();
}
});
}

View file

@ -147,8 +147,8 @@
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:hint="@string/impactEditHint"
android:layout_toRightOf="@+id/impactText"
android:layout_toEndOf="@+id/impactText" />
android:layout_toRightOf="@+id/attackText"
android:layout_toEndOf="@+id/attackText" />
<TextView
@ -156,7 +156,7 @@
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/impact"
android:id="@+id/impactText"
android:id="@+id/attackText"
android:gravity="center_vertical"
android:layout_below="@+id/vsLayout"
android:layout_alignParentLeft="true"

View file

@ -0,0 +1,193 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/at_will"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingLeft="10dp"
tools:text="Explosión"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="@color/white"
android:id="@+id/nameText" />
<RelativeLayout
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="Diario"
android:id="@+id/freqText"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginRight="25dp"
android:textColor="@color/black"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="Fuego, arcano"
android:id="@+id/keywordsText"
android:layout_toRightOf="@+id/freqText"
android:textColor="@color/black"
android:layout_toEndOf="@+id/freqText"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="Acción estándar"
android:textColor="@color/black"
android:id="@+id/typeText"
android:layout_below="@+id/freqText"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginRight="25dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="Ranged "
android:id="@+id/rangeText"
android:textStyle="bold"
android:layout_alignTop="@+id/typeText"
android:layout_toRightOf="@+id/typeText"
android:layout_toEndOf="@+id/typeText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
tools:text="8"
android:id="@+id/distanceText"
android:layout_toRightOf="@+id/rangeText"
android:layout_alignTop="@+id/rangeText"/>
<TextView
android:textColor="@color/black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Objective: "
android:id="@+id/objective"
android:layout_below="@+id/typeText"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Attack: "
android:textStyle="bold"
android:textColor="@color/black"
android:id="@+id/attack"
android:layout_below="@+id/objective"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:textColor="@color/black"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Impact: "
android:textStyle="bold"
android:id="@+id/impact"
android:layout_below="@+id/attack"
android:background="@color/darkened_text"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:textColor="@color/black"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="Constitución contra Reflejos"
android:id="@+id/attackText"
android:layout_below="@+id/objective"
android:layout_toRightOf="@+id/attack"
android:layout_toEndOf="@+id/attack" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="one creature"
android:textColor="@color/black"
android:id="@+id/objectiveText"
android:layout_below="@+id/typeText"
android:layout_toRightOf="@+id/objective"
android:layout_toEndOf="@+id/objective" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/darkened_text"
android:textColor="@color/black"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="1d8"
android:id="@+id/impactText"
android:layout_below="@+id/attackText"
android:layout_toRightOf="@+id/impact"
android:layout_toEndOf="@+id/impact" />
<TextView
android:layout_width="wrap_content"
android:textColor="@color/black"
android:layout_height="wrap_content"
android:id="@+id/otherText"
android:layout_below="@+id/impact"
tools:text="If you are reading this the description has been displayed"
android:layout_alignParentLeft="true"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/otherText">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Use"
android:background="@android:color/transparent"
android:layout_weight="1"
android:id="@+id/useButton" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/delete"
android:layout_weight="1"
android:background="@android:color/transparent"
android:id="@+id/deleteButton" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/edit"
android:layout_weight="1"
android:background="@android:color/transparent"
android:id="@+id/editButton" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>

View file

@ -5,18 +5,6 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/delete"
android:src="@drawable/ic_delete"
android:padding="5dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:contentDescription="@string/edit"
android:tint="@color/black" />
<TextView
tools:text="Happiness"
android:layout_width="wrap_content"

View file

@ -95,4 +95,65 @@
<string name="save">Guardar</string>
<string name="save_player">Guardar personaje</string>
<string name="title_activity_power_editor">Editor de poderes</string>
<string-array name="freq_array">
<item>Frecuencia</item>
<item>Oportunidad</item>
<item>A voluntad</item>
<item>Encuentro</item>
<item>Diario</item>
</string-array>
<string-array name="actions_array">
<item>Tipo de acción</item>
<item>Acción estándar</item>
<item>Acción de movimiento</item>
<item>Acción menor</item>
<item>Acción gratuita</item>
</string-array>
<string-array name="ranges_array">
<item>Rango de ataque</item>
<item>Cuerpo a cuerpo</item>
<item>A distancia</item>
<item>Área</item>
<item>Cercano</item>
<item>Aura</item>
</string-array>
<string-array name="atk_array">
<item>ATK</item>
<item>FUE</item>
<item>CON</item>
<item>DES</item>
<item>INT</item>
<item>SAB</item>
<item>CAR</item>
</string-array>
<string-array name="def_array">
<item>DEF</item>
<item>CA</item>
<item>FORT</item>
<item>REF</item>
<item>VOL</item>
</string-array>
<string-array name="attack_array">
<item>Ataque</item>
<item>Fuerza</item>
<item>Constitución</item>
<item>Destreza</item>
<item>Inteligencia</item>
<item>Sabiduría</item>
<item>Carisma</item>
</string-array>
<string-array name="defense_array">
<item>Defensa</item>
<item>CA</item>
<item>Fortaleza</item>
<item>Reflejos</item>
<item>Voluntad</item>
</string-array>
</resources>

View file

@ -14,6 +14,11 @@
<color name="green">#0f0</color>
<color name="white">#EEEEEE</color>
<color name="daily">#33292A</color>
<color name="encounter">#6B0617</color>
<color name="at_will">#4F7448</color>
<color name="darkened_text">#DDD6D1</color>
<color name="surges_bar">#989F2B</color>
<color name="px_bar">#005874</color>
<color name="black">#000000</color>

View file

@ -148,4 +148,22 @@
<item>REF</item>
<item>WILL</item>
</string-array>
<string-array name="attack_array">
<item>Attack</item>
<item>Strength</item>
<item>Constitution</item>
<item>Dexterity</item>
<item>Intelligence</item>
<item>Wisdom</item>
<item>Charisma</item>
</string-array>
<string-array name="defense_array">
<item>Defense</item>
<item>AC</item>
<item>Fortitude</item>
<item>Reflexes</item>
<item>Will</item>
</string-array>
</resources>