Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kevlahnota committed Nov 16, 2024
1 parent 5597d0b commit f46e22c
Showing 1 changed file with 26 additions and 38 deletions.
64 changes: 26 additions & 38 deletions forge-gui-mobile/src/forge/screens/match/MatchScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,7 @@ protected void drawOverlay(Graphics g) {
if (Forge.isLandscapeMode() && (!GuiBase.isAndroid() || Forge.hasGamepad()) && !CardZoom.isOpen() && potentialListener != null) {
for (FDisplayObject object : potentialListener) {
if (object != null) {
if (object instanceof FCardPanel) {
FCardPanel cardPanel = (FCardPanel) object;
if (object instanceof FCardPanel cardPanel) {
try {
if (cardPanel.isHovered()) {
VPlayerPanel vPlayerPanel = getPlayerPanel(cardPanel.getCard().getController());
Expand Down Expand Up @@ -431,9 +430,9 @@ protected void drawOverlay(Graphics g) {
} catch (Exception e) {
e.printStackTrace();
}
} else if (object instanceof VStack.StackInstanceDisplay) {
} else if (object instanceof VStack.StackInstanceDisplay vstackDisplay) {
try {
CardView cardView = ((VStack.StackInstanceDisplay) object).stackInstance.getSourceCard();
CardView cardView = vstackDisplay.stackInstance.getSourceCard();
if (object.isHovered() && cardView != null && getStack().isVisible()) {
float cardW = getHeight() * 0.45f;
float cardH = FCardPanel.ASPECT_RATIO * cardW;
Expand Down Expand Up @@ -524,7 +523,7 @@ public boolean keyDown(int keyCode) {
}
}
revalidate(true);
} catch (Exception e) {
} catch (Exception ignored) {
}
}
break;
Expand All @@ -538,7 +537,7 @@ public boolean keyDown(int keyCode) {
selectedPlayerPanel().getSelectedRow().setNextSelected(1);
}
revalidate(true);
} catch (Exception e) {
} catch (Exception ignored) {
}
}
break;
Expand All @@ -562,7 +561,7 @@ public boolean keyDown(int keyCode) {
}
}
revalidate(true);
} catch (Exception e) {
} catch (Exception ignored) {
}
}
break;
Expand All @@ -576,7 +575,7 @@ public boolean keyDown(int keyCode) {
selectedPlayerPanel().getSelectedRow().setPreviousSelected(1);
}
revalidate(true);
} catch (Exception e) {
} catch (Exception ignored) {
}
}
break;
Expand All @@ -589,7 +588,7 @@ public boolean keyDown(int keyCode) {
} else {
selectedPlayerPanel().getSelectedRow().showZoom();
}
} catch (Exception e) {
} catch (Exception ignored) {
}
}
break;
Expand All @@ -604,7 +603,7 @@ public boolean keyDown(int keyCode) {
//nullPotentialListener();
selectedPlayerPanel().getSelectedRow().tapChild();
}
} catch (Exception e) {
} catch (Exception ignored) {
}
}
break;
Expand All @@ -628,7 +627,7 @@ public boolean keyDown(int keyCode) {
return getActivePrompt().getBtnCancel().trigger(); //trigger Cancel if can't trigger OK
case Keys.ESCAPE:
if (!FModel.getPreferences().getPrefBoolean(FPref.UI_ALLOW_ESC_TO_END_TURN) && !Forge.hasGamepad()) {//bypass check
if (getActivePrompt().getBtnCancel().getText().equals(Forge.getLocalizer().getInstance().getMessage("lblEndTurn"))) {
if (getActivePrompt().getBtnCancel().getText().equals(Forge.getLocalizer().getMessage("lblEndTurn"))) {
return false;
}
}
Expand Down Expand Up @@ -809,12 +808,11 @@ public void hideZones(final PlayerView controller, final Iterable<PlayerZoneUpda
}

public void updateSingleCard(final CardView card) {
final CardAreaPanel pnl = CardAreaPanel.get(card);
if (pnl == null) {
if (card == null)
return;
}
final CardAreaPanel pnl = CardAreaPanel.get(card);
final ZoneType zone = card.getZone();
if (zone != null && zone == ZoneType.Battlefield) {
if (zone == ZoneType.Battlefield) {
pnl.updateCard(card);
} else { //ensure card not on battlefield is reset such that it no longer thinks it's on the battlefield
pnl.setTapped(false);
Expand All @@ -831,28 +829,18 @@ public void updateSingleCard(final CardView card) {

FSkinTexture getBG() {
if (Forge.isMobileAdventureMode) {
switch (GameScene.instance().getAdventurePlayerLocation(false, true)) {
case "green":
return FSkinTexture.ADV_BG_FOREST;
case "black":
return FSkinTexture.ADV_BG_SWAMP;
case "red":
return FSkinTexture.ADV_BG_MOUNTAIN;
case "blue":
return FSkinTexture.ADV_BG_ISLAND;
case "white":
return FSkinTexture.ADV_BG_PLAINS;
case "waste":
return FSkinTexture.ADV_BG_WASTE;
case "cave":
return FSkinTexture.ADV_BG_CAVE;
case "dungeon":
return FSkinTexture.ADV_BG_DUNGEON;
case "castle":
return FSkinTexture.ADV_BG_CASTLE;
default:
return FSkinTexture.ADV_BG_COMMON;
}
return switch (GameScene.instance().getAdventurePlayerLocation(false, true)) {
case "green" -> FSkinTexture.ADV_BG_FOREST;
case "black" -> FSkinTexture.ADV_BG_SWAMP;
case "red" -> FSkinTexture.ADV_BG_MOUNTAIN;
case "blue" -> FSkinTexture.ADV_BG_ISLAND;
case "white" -> FSkinTexture.ADV_BG_PLAINS;
case "waste" -> FSkinTexture.ADV_BG_WASTE;
case "cave" -> FSkinTexture.ADV_BG_CAVE;
case "dungeon" -> FSkinTexture.ADV_BG_DUNGEON;
case "castle" -> FSkinTexture.ADV_BG_CASTLE;
default -> FSkinTexture.ADV_BG_COMMON;
};
}
return FSkinTexture.BG_MATCH;
}
Expand Down Expand Up @@ -965,7 +953,7 @@ public void drawBackground(Graphics g) {
if (!hasActivePlane())
return;
}
boolean isGameFast = MatchController.instance.isGameFast();
//boolean isGameFast = MatchController.instance.isGameFast(); //this used to control animation speed
float midField = topPlayerPanel.getBottom();
float promptHeight = !Forge.isLandscapeMode() || bottomPlayerPrompt == null ? 0f : bottomPlayerPrompt.getHeight() / 1.3f;
float x = topPlayerPanel.getField().getLeft();
Expand Down

0 comments on commit f46e22c

Please sign in to comment.