From ea6f48adb59810bd03b262533a4472bb0fb33160 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 18 Nov 2022 08:35:55 +0800 Subject: [PATCH 1/2] update TransitionScreen fix progressBar location --- forge-gui-mobile/src/forge/screens/TransitionScreen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forge-gui-mobile/src/forge/screens/TransitionScreen.java b/forge-gui-mobile/src/forge/screens/TransitionScreen.java index b081874e880..faaf130aa2a 100644 --- a/forge-gui-mobile/src/forge/screens/TransitionScreen.java +++ b/forge-gui-mobile/src/forge/screens/TransitionScreen.java @@ -98,7 +98,7 @@ public class TransitionScreen extends FContainer { float x = (Forge.getScreenWidth() - w) / 2; float y = ymod + 10; int multi = ((int) (percentage*100)) < 97 ? (int) (percentage*100) : 100; - progressBar.setBounds(x, y, w, h); + progressBar.setBounds(x, Forge.getScreenHeight() - h * 2f, w, h); progressBar.setValue(multi); if (multi == 100 && !message.isEmpty()) { progressBar.setDescription(message); From ce635aabe4d66149235c38ba0177e5a096c931a5 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 18 Nov 2022 13:44:15 +0800 Subject: [PATCH 2/2] update Adventure DayNight transition --- forge-game/src/main/java/forge/game/Game.java | 12 +- .../src/forge/adventure/util/Controls.java | 2 + .../src/forge/screens/TransitionScreen.java | 2 +- .../src/forge/screens/match/MatchScreen.java | 148 ++++++++++++------ 4 files changed, 115 insertions(+), 49 deletions(-) diff --git a/forge-game/src/main/java/forge/game/Game.java b/forge-game/src/main/java/forge/game/Game.java index d82691a9944..8ab2a0474bc 100644 --- a/forge-game/src/main/java/forge/game/Game.java +++ b/forge-game/src/main/java/forge/game/Game.java @@ -139,6 +139,7 @@ public class Game { private Direction turnOrder = Direction.getDefaultDirection(); private Boolean daytime = null; + private Boolean previous = null; private long timestamp = 0; public final GameAction action; @@ -1227,12 +1228,21 @@ public class Game { public boolean isNeitherDayNorNight() { return this.daytime == null; } + public boolean previousTimeIsDay() { + return this.previous != null && this.previous == false; + } + public boolean previousTimeIsNight() { + return this.previous != null && this.previous == true; + } + public boolean previousTimeisNeitherDayNorNight() { + return this.previous == null; + } public Boolean getDayTime() { return this.daytime; } public void setDayTime(Boolean value) { - Boolean previous = this.daytime; + previous = this.daytime; this.daytime = value; if (previous != null && value != null && previous != value) { diff --git a/forge-gui-mobile/src/forge/adventure/util/Controls.java b/forge-gui-mobile/src/forge/adventure/util/Controls.java index cce9c746adc..6bee7e12943 100644 --- a/forge-gui-mobile/src/forge/adventure/util/Controls.java +++ b/forge-gui-mobile/src/forge/adventure/util/Controls.java @@ -80,6 +80,8 @@ public class Controls { return new Rectangle(actor.getX(),actor.getY(),actor.getWidth(),actor.getHeight()); } static public boolean actorContainsVector (Actor actor, Vector2 point) { + if (actor == null) + return false; if (!actor.isVisible()) return false; return getBoundingRect(actor).contains(point); diff --git a/forge-gui-mobile/src/forge/screens/TransitionScreen.java b/forge-gui-mobile/src/forge/screens/TransitionScreen.java index faaf130aa2a..0ca1c325212 100644 --- a/forge-gui-mobile/src/forge/screens/TransitionScreen.java +++ b/forge-gui-mobile/src/forge/screens/TransitionScreen.java @@ -82,7 +82,7 @@ public class TransitionScreen extends FContainer { g.setAlphaComposite(oldAlpha); } float xmod = Forge.getScreenHeight() > 2000 ? 1.5f : 1f; - xmod *= Forge.isMobileAdventureMode ? 1 : percentage; + xmod *= percentage; float ymod; if (FSkin.getLogo() != null) { ymod = Forge.getScreenHeight()/2 + (FSkin.getLogo().getHeight()*xmod)/2; diff --git a/forge-gui-mobile/src/forge/screens/match/MatchScreen.java b/forge-gui-mobile/src/forge/screens/match/MatchScreen.java index ec5ea670e00..5118eab10bf 100644 --- a/forge-gui-mobile/src/forge/screens/match/MatchScreen.java +++ b/forge-gui-mobile/src/forge/screens/match/MatchScreen.java @@ -800,7 +800,8 @@ public class MatchScreen extends FScreen { pnl.setNextPanelInStack(null); } } - + private String daytime2 = null; + FSkinTexture currentBG = FSkinTexture.ADV_BG_MATCH; private class BGAnimation extends ForgeAnimation { private static final float DURATION = 1.5f; private float progress = 0; @@ -814,12 +815,36 @@ public class MatchScreen extends FScreen { } else if (percentage > 1) { percentage = 1; } - g.setAlphaComposite(percentage); - if (!daynightTransition) - g.drawGrayTransitionImage(image, x, y, w, h, darkoverlay, 1-(percentage*1)); - else - g.drawUnderWaterImage(image, x, y, w, h, 1-(percentage*1), darkoverlay); - g.setAlphaComposite(oldAlpha); + if (Forge.isMobileAdventureMode) { + FSkinTexture bgDay = FSkinTexture.ADV_BG_MATCH_DAY; + FSkinTexture bgNight = FSkinTexture.ADV_BG_MATCH_NIGHT; + FSkinTexture bgNeither = FSkinTexture.ADV_BG_MATCH; + //back bg + FSkinTexture backBG = bgNeither; + //front bg + FSkinTexture frontBG = bgNeither; + if (MatchController.instance.getGameView().getGame().isDay()) + backBG = bgDay; + if (MatchController.instance.getGameView().getGame().isNight()) + backBG = bgNight; + if (MatchController.instance.getGameView().getGame().previousTimeIsDay()) + frontBG = bgDay; + if (MatchController.instance.getGameView().getGame().previousTimeIsNight()) + frontBG = bgNight; + //draw backBG + g.drawImage(backBG, x, y, w, h); + //draw frontBG with alpha difference + g.setAlphaComposite(1 - (percentage * 1)); + g.drawImage(frontBG, x, y, w, h); + g.setAlphaComposite(oldAlpha); + } else { + g.setAlphaComposite(percentage); + if (!daynightTransition) + g.drawGrayTransitionImage(image, x, y, w, h, darkoverlay, 1 - (percentage * 1)); + else + g.drawUnderWaterImage(image, x, y, w, h, 1 - (percentage * 1), darkoverlay); + g.setAlphaComposite(oldAlpha); + } } @Override @@ -831,6 +856,14 @@ public class MatchScreen extends FScreen { @Override protected void onEnd(boolean endingAll) { finished = true; + if (Forge.isMobileAdventureMode) { + //set currentBG + if (MatchController.instance.getGameView().getGame().isDay()) + currentBG = FSkinTexture.ADV_BG_MATCH_DAY; + if (MatchController.instance.getGameView().getGame().isNight()) + currentBG = FSkinTexture.ADV_BG_MATCH_NIGHT; + daytime2 = MatchController.instance.getDayTime(); + } } } private class FieldScroller extends FScrollPane { @@ -851,62 +884,83 @@ public class MatchScreen extends FScreen { int multiplier = playerPanels.keySet().size() - 1; //fix scaling of background when zoomed in multiplayer float bgHeight = (midField + bottomPlayerPanel.getField().getHeight() * multiplier) - y; - if (MatchController.instance.getDayTime() != null) { - //override BG - String dayTime = MatchController.instance.getDayTime(); - if (!daytime.equals(dayTime)) { + if (Forge.isMobileAdventureMode) { + if (bgAnimation == null) bgAnimation = new BGAnimation(); - bgAnimation.start(); - daytime = dayTime; - } - FSkinTexture bgDay = Forge.isMobileAdventureMode ? FSkinTexture.ADV_BG_MATCH_DAY : FSkinTexture.BG_MATCH_DAY; - FSkinTexture bgNight = Forge.isMobileAdventureMode ? FSkinTexture.ADV_BG_MATCH_NIGHT : FSkinTexture.BG_MATCH_NIGHT; - FSkinTexture matchBG = MatchController.instance.getGameView().getGame().isDay() ? bgDay : bgNight; - bgFullWidth = bgHeight * matchBG.getWidth() / matchBG.getHeight(); + + bgFullWidth = bgHeight * currentBG.getWidth() / currentBG.getHeight(); if (bgFullWidth < w) { scaledbgHeight = w * (bgHeight / bgFullWidth); bgFullWidth = w; bgHeight = scaledbgHeight; } - if (bgAnimation != null && !isGameFast && !MatchController.instance.getGameView().isMatchOver()) { - bgAnimation.drawBackground(g, matchBG, x + (w - bgFullWidth) / 2, y, bgFullWidth, bgHeight, !Forge.isMobileAdventureMode, true); + + String dayTime = MatchController.instance.getDayTime(); + if (daytime2 != dayTime) { + bgAnimation.start(); + bgAnimation.drawBackground(g, currentBG, x + (w - bgFullWidth) / 2, y, bgFullWidth, bgHeight, false, true); } else { - g.drawImage(matchBG, x + (w - bgFullWidth) / 2, y, bgFullWidth, bgHeight, !Forge.isMobileAdventureMode); + bgAnimation.progress = 0; + g.drawImage(currentBG, x + (w - bgFullWidth) / 2, y, bgFullWidth, bgHeight); } - } else if (FModel.getPreferences().getPrefBoolean(FPref.UI_MATCH_IMAGE_VISIBLE) || Forge.isMobileAdventureMode) { - if(FModel.getPreferences().getPrefBoolean(FPref.UI_DYNAMIC_PLANECHASE_BG) - && hasActivePlane()) { - String imageName = getPlaneName() - .replace(" ", "_") - .replace("'", "") - .replace("-", ""); - if (!plane.equals(imageName)) { + } else { //non adventure needs update to accomodate multiple BG Effect ie Planchase + Daytime effect... + if (MatchController.instance.getDayTime() != null) { + //override BG + String dayTime = MatchController.instance.getDayTime(); + if (!daytime.equals(dayTime)) { bgAnimation = new BGAnimation(); bgAnimation.start(); - plane = imageName; + daytime = dayTime; } - if (FSkinTexture.getValues().contains(imageName)) { - bgFullWidth = bgHeight * FSkinTexture.valueOf(imageName).getWidth() / FSkinTexture.valueOf(imageName).getHeight(); - if (bgFullWidth < w) { - scaledbgHeight = w * (bgHeight / bgFullWidth); - bgFullWidth = w; - bgHeight = scaledbgHeight; - } - if (bgAnimation != null && !isGameFast && !MatchController.instance.getGameView().isMatchOver()) { - bgAnimation.drawBackground(g, FSkinTexture.valueOf(imageName), x + (w - bgFullWidth) / 2, y, bgFullWidth, bgHeight, true, false); - } else { - g.drawImage(FSkinTexture.valueOf(imageName), x + (w - bgFullWidth) / 2, y, bgFullWidth, bgHeight, true); - } - } - } else { - FSkinTexture matchBackground = Forge.isMobileAdventureMode ? FSkinTexture.ADV_BG_MATCH : FSkinTexture.BG_MATCH; - bgFullWidth = bgHeight * matchBackground.getWidth() / matchBackground.getHeight(); + FSkinTexture bgDay = Forge.isMobileAdventureMode ? FSkinTexture.ADV_BG_MATCH_DAY : FSkinTexture.BG_MATCH_DAY; + FSkinTexture bgNight = Forge.isMobileAdventureMode ? FSkinTexture.ADV_BG_MATCH_NIGHT : FSkinTexture.BG_MATCH_NIGHT; + FSkinTexture matchBG = MatchController.instance.getGameView().getGame().isDay() ? bgDay : bgNight; + bgFullWidth = bgHeight * matchBG.getWidth() / matchBG.getHeight(); if (bgFullWidth < w) { scaledbgHeight = w * (bgHeight / bgFullWidth); bgFullWidth = w; bgHeight = scaledbgHeight; } - g.drawImage(matchBackground, x + (w - bgFullWidth) / 2, y, bgFullWidth, bgHeight); + if (bgAnimation != null && !isGameFast && !MatchController.instance.getGameView().isMatchOver()) { + bgAnimation.drawBackground(g, matchBG, x + (w - bgFullWidth) / 2, y, bgFullWidth, bgHeight, !Forge.isMobileAdventureMode, true); + } else { + g.drawImage(matchBG, x + (w - bgFullWidth) / 2, y, bgFullWidth, bgHeight, !Forge.isMobileAdventureMode); + } + } else if (FModel.getPreferences().getPrefBoolean(FPref.UI_MATCH_IMAGE_VISIBLE)) { + if(FModel.getPreferences().getPrefBoolean(FPref.UI_DYNAMIC_PLANECHASE_BG) + && hasActivePlane()) { + String imageName = getPlaneName() + .replace(" ", "_") + .replace("'", "") + .replace("-", ""); + if (!plane.equals(imageName)) { + bgAnimation = new BGAnimation(); + bgAnimation.start(); + plane = imageName; + } + if (FSkinTexture.getValues().contains(imageName)) { + bgFullWidth = bgHeight * FSkinTexture.valueOf(imageName).getWidth() / FSkinTexture.valueOf(imageName).getHeight(); + if (bgFullWidth < w) { + scaledbgHeight = w * (bgHeight / bgFullWidth); + bgFullWidth = w; + bgHeight = scaledbgHeight; + } + if (bgAnimation != null && !isGameFast && !MatchController.instance.getGameView().isMatchOver()) { + bgAnimation.drawBackground(g, FSkinTexture.valueOf(imageName), x + (w - bgFullWidth) / 2, y, bgFullWidth, bgHeight, true, false); + } else { + g.drawImage(FSkinTexture.valueOf(imageName), x + (w - bgFullWidth) / 2, y, bgFullWidth, bgHeight, true); + } + } + } else { + FSkinTexture matchBackground = Forge.isMobileAdventureMode ? FSkinTexture.ADV_BG_MATCH : FSkinTexture.BG_MATCH; + bgFullWidth = bgHeight * matchBackground.getWidth() / matchBackground.getHeight(); + if (bgFullWidth < w) { + scaledbgHeight = w * (bgHeight / bgFullWidth); + bgFullWidth = w; + bgHeight = scaledbgHeight; + } + g.drawImage(matchBackground, x + (w - bgFullWidth) / 2, y, bgFullWidth, bgHeight); + } } } }