Merge pull request #1920 from kevlahnota/newmaster2

update Adventure Daytime effect & Transition screen
This commit is contained in:
Anthony Calosa
2022-11-18 14:01:52 +08:00
committed by GitHub
4 changed files with 115 additions and 49 deletions

View File

@@ -139,6 +139,7 @@ public class Game {
private Direction turnOrder = Direction.getDefaultDirection(); private Direction turnOrder = Direction.getDefaultDirection();
private Boolean daytime = null; private Boolean daytime = null;
private Boolean previous = null;
private long timestamp = 0; private long timestamp = 0;
public final GameAction action; public final GameAction action;
@@ -1227,12 +1228,21 @@ public class Game {
public boolean isNeitherDayNorNight() { public boolean isNeitherDayNorNight() {
return this.daytime == null; 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() { public Boolean getDayTime() {
return this.daytime; return this.daytime;
} }
public void setDayTime(Boolean value) { public void setDayTime(Boolean value) {
Boolean previous = this.daytime; previous = this.daytime;
this.daytime = value; this.daytime = value;
if (previous != null && value != null && previous != value) { if (previous != null && value != null && previous != value) {

View File

@@ -80,6 +80,8 @@ public class Controls {
return new Rectangle(actor.getX(),actor.getY(),actor.getWidth(),actor.getHeight()); return new Rectangle(actor.getX(),actor.getY(),actor.getWidth(),actor.getHeight());
} }
static public boolean actorContainsVector (Actor actor, Vector2 point) { static public boolean actorContainsVector (Actor actor, Vector2 point) {
if (actor == null)
return false;
if (!actor.isVisible()) if (!actor.isVisible())
return false; return false;
return getBoundingRect(actor).contains(point); return getBoundingRect(actor).contains(point);

View File

@@ -82,7 +82,7 @@ public class TransitionScreen extends FContainer {
g.setAlphaComposite(oldAlpha); g.setAlphaComposite(oldAlpha);
} }
float xmod = Forge.getScreenHeight() > 2000 ? 1.5f : 1f; float xmod = Forge.getScreenHeight() > 2000 ? 1.5f : 1f;
xmod *= Forge.isMobileAdventureMode ? 1 : percentage; xmod *= percentage;
float ymod; float ymod;
if (FSkin.getLogo() != null) { if (FSkin.getLogo() != null) {
ymod = Forge.getScreenHeight()/2 + (FSkin.getLogo().getHeight()*xmod)/2; ymod = Forge.getScreenHeight()/2 + (FSkin.getLogo().getHeight()*xmod)/2;

View File

@@ -800,7 +800,8 @@ public class MatchScreen extends FScreen {
pnl.setNextPanelInStack(null); pnl.setNextPanelInStack(null);
} }
} }
private String daytime2 = null;
FSkinTexture currentBG = FSkinTexture.ADV_BG_MATCH;
private class BGAnimation extends ForgeAnimation { private class BGAnimation extends ForgeAnimation {
private static final float DURATION = 1.5f; private static final float DURATION = 1.5f;
private float progress = 0; private float progress = 0;
@@ -814,12 +815,36 @@ public class MatchScreen extends FScreen {
} else if (percentage > 1) { } else if (percentage > 1) {
percentage = 1; percentage = 1;
} }
g.setAlphaComposite(percentage); if (Forge.isMobileAdventureMode) {
if (!daynightTransition) FSkinTexture bgDay = FSkinTexture.ADV_BG_MATCH_DAY;
g.drawGrayTransitionImage(image, x, y, w, h, darkoverlay, 1-(percentage*1)); FSkinTexture bgNight = FSkinTexture.ADV_BG_MATCH_NIGHT;
else FSkinTexture bgNeither = FSkinTexture.ADV_BG_MATCH;
g.drawUnderWaterImage(image, x, y, w, h, 1-(percentage*1), darkoverlay); //back bg
g.setAlphaComposite(oldAlpha); 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 @Override
@@ -831,6 +856,14 @@ public class MatchScreen extends FScreen {
@Override @Override
protected void onEnd(boolean endingAll) { protected void onEnd(boolean endingAll) {
finished = true; 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 { 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 int multiplier = playerPanels.keySet().size() - 1; //fix scaling of background when zoomed in multiplayer
float bgHeight = (midField + bottomPlayerPanel.getField().getHeight() * multiplier) - y; float bgHeight = (midField + bottomPlayerPanel.getField().getHeight() * multiplier) - y;
if (MatchController.instance.getDayTime() != null) { if (Forge.isMobileAdventureMode) {
//override BG if (bgAnimation == null)
String dayTime = MatchController.instance.getDayTime();
if (!daytime.equals(dayTime)) {
bgAnimation = new BGAnimation(); bgAnimation = new BGAnimation();
bgAnimation.start();
daytime = dayTime; bgFullWidth = bgHeight * currentBG.getWidth() / currentBG.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) { if (bgFullWidth < w) {
scaledbgHeight = w * (bgHeight / bgFullWidth); scaledbgHeight = w * (bgHeight / bgFullWidth);
bgFullWidth = w; bgFullWidth = w;
bgHeight = scaledbgHeight; 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 { } 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) { } else { //non adventure needs update to accomodate multiple BG Effect ie Planchase + Daytime effect...
if(FModel.getPreferences().getPrefBoolean(FPref.UI_DYNAMIC_PLANECHASE_BG) if (MatchController.instance.getDayTime() != null) {
&& hasActivePlane()) { //override BG
String imageName = getPlaneName() String dayTime = MatchController.instance.getDayTime();
.replace(" ", "_") if (!daytime.equals(dayTime)) {
.replace("'", "")
.replace("-", "");
if (!plane.equals(imageName)) {
bgAnimation = new BGAnimation(); bgAnimation = new BGAnimation();
bgAnimation.start(); bgAnimation.start();
plane = imageName; daytime = dayTime;
} }
if (FSkinTexture.getValues().contains(imageName)) { FSkinTexture bgDay = Forge.isMobileAdventureMode ? FSkinTexture.ADV_BG_MATCH_DAY : FSkinTexture.BG_MATCH_DAY;
bgFullWidth = bgHeight * FSkinTexture.valueOf(imageName).getWidth() / FSkinTexture.valueOf(imageName).getHeight(); FSkinTexture bgNight = Forge.isMobileAdventureMode ? FSkinTexture.ADV_BG_MATCH_NIGHT : FSkinTexture.BG_MATCH_NIGHT;
if (bgFullWidth < w) { FSkinTexture matchBG = MatchController.instance.getGameView().getGame().isDay() ? bgDay : bgNight;
scaledbgHeight = w * (bgHeight / bgFullWidth); bgFullWidth = bgHeight * matchBG.getWidth() / matchBG.getHeight();
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) { if (bgFullWidth < w) {
scaledbgHeight = w * (bgHeight / bgFullWidth); scaledbgHeight = w * (bgHeight / bgFullWidth);
bgFullWidth = w; bgFullWidth = w;
bgHeight = scaledbgHeight; 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);
}
} }
} }
} }