Skip to content

Commit

Permalink
Fixed #30.
Browse files Browse the repository at this point in the history
  • Loading branch information
JayTSmith committed Oct 12, 2017
1 parent ecb3bf5 commit a175d94
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,26 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;

import com.example.cis.mazeminotaurs.CharacterSheetFragment;
import com.example.cis.mazeminotaurs.DetailedWeaponAdapter;
import com.example.cis.mazeminotaurs.Equipment;
import com.example.cis.mazeminotaurs.Portfolio;
import com.example.cis.mazeminotaurs.R;
import com.example.cis.mazeminotaurs.Weapon;
import com.example.cis.mazeminotaurs.character.PlayerCharacter;
import com.example.cis.mazeminotaurs.character.classes.BaseClass;
import com.example.cis.mazeminotaurs.character.stats.Score;

import java.util.ArrayList;

/**
* Created by ckling on 4/10/17.
*/
Expand All @@ -45,7 +54,7 @@ public class CreateCharacter extends Fragment {
Button mPVButton;
Button mInitButton;

Button mWeaponNameButton;
Spinner mWeaponNameSpinner;
Button mWeaponTypeButton;

public CreateCharacter() {
Expand Down Expand Up @@ -103,7 +112,29 @@ public void afterTextChanged(Editable editable) {
mMFButton = (Button) rootView.findViewById(R.id.mystic_fortitude_button);
mPVButton = (Button) rootView.findViewById(R.id.physical_vigor_button);
mInitButton = (Button) rootView.findViewById(R.id.initiative_modifier_button);
mWeaponNameButton = (Button) rootView.findViewById(R.id.equipped_weapon_spinner);
mWeaponNameSpinner = (Spinner) rootView.findViewById(R.id.equipped_weapon_spinner);

final ArrayList<Weapon> weps = new ArrayList<>();
for (Equipment equipment : mBaseClass.getStartGear()) {
if (equipment instanceof Weapon) {
weps.add((Weapon) equipment);
}
}
DetailedWeaponAdapter adapter = new DetailedWeaponAdapter(getContext(), weps);
mWeaponNameSpinner.setAdapter(adapter);

mWeaponNameSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
mWeaponTypeButton.setText(weps.get(i).getWeaponType());
}

@Override
public void onNothingSelected(AdapterView<?> adapterView) {

}
});

mWeaponTypeButton = (Button) rootView.findViewById(R.id.attack_button);

// Confirm button
Expand Down Expand Up @@ -136,11 +167,9 @@ private void updateStatButtons() {
mPVButton.setText(Integer.toString(character.getPhysicalVigor()));
mInitButton.setText(Integer.toString(character.getInitiative()));
if (character.getCurrentWeapon() != null) {
mWeaponNameButton.setText(character.getCurrentWeapon().getResId());
mWeaponTypeButton.setText(character.getCurrentWeapon().getWeaponType());
}
else {
mWeaponNameButton.setText("-");
mWeaponTypeButton.setText("-");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
android:textAlignment="center"
android:textSize="24sp"/>

<Button
<Spinner
android:id="@+id/equipped_weapon_spinner"
android:layout_width="63dp"
android:layout_column="2"
Expand Down

0 comments on commit a175d94

Please sign in to comment.