Skip to content

Commit

Permalink
added show unowned toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Fic committed Apr 8, 2022
1 parent 84dfabd commit 762b98c
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ public class FilterWindowActor extends Window {
ComputerCombatGame game;
TextButton applyButton;
CardFilter filter;
CardFilter nameFilter, rarityFilter, collectionFilter;
CardFilter nameFilter, rarityFilter, collectionFilter, unownedFilter;
int rarity = -1;
boolean showUnowned = false;
Table rarityTable, collectionTable;

List<Integer> collections;
Expand Down Expand Up @@ -98,6 +99,29 @@ public boolean filter(Card card, MatchState state, Move move) {
}
}
};
unownedFilter = new CardFilter() {
@Override
public boolean filter(Card card, MatchState state, Move move) {
if (showUnowned) {
return true;
}
return card.getOwnerUID() != null;
}
};

TextButton showUnownedButton = new TextButton("Off", skin) {
@Override
public void act(float delta) {
super.act(delta); //To change body of generated methods, choose Tools | Templates.
this.setText(showUnowned ? "On" : "Off");
}
};
showUnownedButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
showUnowned = !showUnowned;
}
});

applyButton = new TextButton("Apply", skin);
applyButton.addListener(new ClickListener() {
Expand All @@ -110,12 +134,15 @@ public void clicked(InputEvent event, float x, float y) {
Label searchLabel = new Label("Name:", skin);
Label rarityLabel = new Label("Rarity: ", skin);
Label collectionLabel = new Label("Collection: ", skin);
Label showUnowned = new Label("Show Unowned: ", skin);
add(searchLabel).expandX();
add(searchPanel).growX().row();
add(rarityLabel).expandX();
add(rarityTable).growX().row();
add(collectionLabel).expandX();
add(collectionTable).growX().row();
add(showUnowned).expandX();
add(showUnownedButton).expandX().width(100).row();

Table buttons = new Table(skin);
buttons.add(applyButton).growX();
Expand Down Expand Up @@ -143,7 +170,8 @@ public void clicked(InputEvent event, float x, float y) {
public boolean filter(Card card, MatchState state, Move move) {
return nameFilter.filter(card, state, move)
&& collectionFilter.filter(card, state, move)
&& rarityFilter.filter(card, state, move);
&& rarityFilter.filter(card, state, move)
&& unownedFilter.filter(card, state, move);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public LEDActor(Skin skin) {

@Override
public void draw(Batch batch, float parentAlpha) {
batch.setColor(Color.WHITE);
Color c = batch.getColor();
batch.setColor(getColor());
ledBorder.draw(batch, getX(), getY(), getWidth(), getHeight());
if (lightOn == false) {
batch.setColor(ledColor.cpy().mul(0.75f, 0.75f, 0.75f, 1));
Expand All @@ -45,7 +46,7 @@ public void draw(Batch batch, float parentAlpha) {
if (lightOn) {
ledGlow.draw(batch, getX() - 2, getY() - 2, getWidth() + 4, getHeight() + 4);
}
batch.setColor(Color.WHITE);
batch.setColor(c);
}

public void setLightOn(boolean lightOn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public Panel(Skin skin) {

@Override
public void draw(Batch batch, float parentAlpha) {
Color c = batch.getColor();
batch.setColor(getColor());
panel.draw(batch, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(), getScaleY(), getRotation());
super.draw(batch, parentAlpha); //To change body of generated methods, choose Tools | Templates.
batch.setColor(Color.WHITE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,18 @@ public void buildCollection() {
Profile profile = game.getCurrentProfile();
Map<Card, Integer> playerCards = new HashMap<>();
Map<Card, Integer> allCards = new HashMap<>();
List<Card> ac = SQLAPI.getSingleton().getCardsInfo(new ArrayList<>(), profile.getUID());
List<Card> ac = SQLAPI.getSingleton().getCardsInfo(new ArrayList<>(), null);
playerCards = SQLAPI.getSingleton().getPlayerOwnedCards(profile.getUID());

for (Card card : ac) {
for (Card c : playerCards.keySet()) {
if (card.getID() == c.getID()) {
card.setOwnerUID(profile.getUID());
break;
}
}
}

for (Card card : ac) {
allCards.put(card, 0);
}
Expand Down

0 comments on commit 762b98c

Please sign in to comment.