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 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) {

View File

@@ -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);

View File

@@ -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;

View File

@@ -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,6 +815,29 @@ public class MatchScreen extends FScreen {
} else if (percentage > 1) {
percentage = 1;
}
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));
@@ -821,6 +845,7 @@ public class MatchScreen extends FScreen {
g.drawUnderWaterImage(image, x, y, w, h, 1 - (percentage * 1), darkoverlay);
g.setAlphaComposite(oldAlpha);
}
}
@Override
protected boolean advance(float dt) {
@@ -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,6 +884,26 @@ 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 (Forge.isMobileAdventureMode) {
if (bgAnimation == null)
bgAnimation = new BGAnimation();
bgFullWidth = bgHeight * currentBG.getWidth() / currentBG.getHeight();
if (bgFullWidth < w) {
scaledbgHeight = w * (bgHeight / bgFullWidth);
bgFullWidth = w;
bgHeight = scaledbgHeight;
}
String dayTime = MatchController.instance.getDayTime();
if (daytime2 != dayTime) {
bgAnimation.start();
bgAnimation.drawBackground(g, currentBG, x + (w - bgFullWidth) / 2, y, bgFullWidth, bgHeight, false, true);
} else {
bgAnimation.progress = 0;
g.drawImage(currentBG, x + (w - bgFullWidth) / 2, y, bgFullWidth, bgHeight);
}
} 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();
@@ -873,7 +926,7 @@ public class MatchScreen extends FScreen {
} else {
g.drawImage(matchBG, x + (w - bgFullWidth) / 2, y, bgFullWidth, bgHeight, !Forge.isMobileAdventureMode);
}
} else if (FModel.getPreferences().getPrefBoolean(FPref.UI_MATCH_IMAGE_VISIBLE) || 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()
@@ -910,6 +963,7 @@ public class MatchScreen extends FScreen {
}
}
}
}
//auto adjust zoom for local multiplayer landscape mode
List<VPlayerPanel> losers = new ArrayList<>();
@Override