Merge pull request #2988 from kevlahnota/newmaster2

Add AdventureWinLose Overlay
This commit is contained in:
Anthony Calosa
2023-04-24 00:51:39 +08:00
committed by GitHub
15 changed files with 124 additions and 34 deletions

View File

@@ -19,4 +19,5 @@ public class SettingData {
public Float rewardCardAdjLandscape;
public Float cardTooltipAdjLandscape;
public boolean dayNightBG;
public boolean disableWinLose;
}

View File

@@ -34,6 +34,7 @@ import forge.player.GamePlayerUtil;
import forge.player.PlayerControllerHuman;
import forge.screens.FScreen;
import forge.screens.LoadingOverlay;
import forge.screens.TransitionScreen;
import forge.screens.match.MatchController;
import forge.sound.MusicPlaylist;
import forge.sound.SoundSystem;
@@ -130,18 +131,20 @@ public class DuelScene extends ForgeScene {
@Override
public void run(Integer result) {
if (result == 0) {
afterGameEnd(enemyName, finalWinner, true, true);
afterGameEnd(enemyName, finalWinner);
if (Config.instance().getSettingData().disableWinLose)
exitDuelScene();
}
fb.dispose();
}
}));
} else {
afterGameEnd(enemyName, winner, false, false);
afterGameEnd(enemyName, winner);
}
}
void afterGameEnd(String enemyName, boolean winner, boolean showOverlay, boolean alternate) {
Runnable runnable = () -> Gdx.app.postRunnable(()-> {
Runnable endRunnable = null;
void afterGameEnd(String enemyName, boolean winner) {
endRunnable = () -> Gdx.app.postRunnable(()-> {
if (GameScene.instance().isNotInWorldMap()) {
SoundSystem.instance.pause();
GameHUD.getInstance().playAudio();
@@ -160,14 +163,9 @@ public class DuelScene extends ForgeScene {
((IAfterMatch) last).setWinner(winner);
}
});
if (showOverlay) {
FThreads.invokeInEdtNowOrLater(() -> {
matchOverlay = new LoadingOverlay(runnable, true, alternate);
matchOverlay.show();
});
} else {
runnable.run();
}
public void exitDuelScene() {
Forge.setTransitionScreen(new TransitionScreen(endRunnable, Forge.takeScreenshot(), false, false));
}
void addEffects(RegisteredPlayer player, Array<EffectData> effects) {

View File

@@ -17,7 +17,6 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalTime;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Stream;
@@ -203,7 +202,6 @@ public class SettingsScene extends UIScene {
boolean value = ((CheckBox) actor).isChecked();
Config.instance().getSettingData().fullScreen = value;
Config.instance().saveSettings();
setTargetTime(LocalTime.now().getHour());
//update
if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_FULLSCREEN_MODE) != value) {
FModel.getPreferences().setPref(ForgePreferences.FPref.UI_LANDSCAPE_MODE, value);
@@ -223,6 +221,14 @@ public class SettingsScene extends UIScene {
}
}
});
addSettingField(Forge.getLocalizer().getMessage("lblDisableWinLose"), Config.instance().getSettingData().disableWinLose, new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
boolean value = ((CheckBox) actor).isChecked();
Config.instance().getSettingData().disableWinLose = value;
Config.instance().saveSettings();
}
});
addCheckBox(Forge.getLocalizer().getMessage("lblCardName"), ForgePreferences.FPref.UI_OVERLAY_CARD_NAME);
addSettingSlider(Forge.getLocalizer().getMessage("cbAdjustMusicVolume"), ForgePreferences.FPref.UI_VOL_MUSIC, 0, 100);
addSettingSlider(Forge.getLocalizer().getMessage("cbAdjustSoundsVolume"), ForgePreferences.FPref.UI_VOL_SOUNDS, 0, 100);

View File

@@ -338,12 +338,14 @@ public class GameHUD extends Stage {
//unequip and reequip abilities
updateAbility();
}
void updateAbility() {
void clearAbility() {
for (TextraButton button : abilityButtonMap) {
button.remove();
}
abilityButtonMap.clear();
}
void updateAbility() {
clearAbility();
setAbilityButton(AdventurePlayer.current().getEquippedAbility1());
setAbilityButton(AdventurePlayer.current().getEquippedAbility2());
float x = Forge.isLandscapeMode() ? 426f : 216f;
@@ -570,6 +572,14 @@ public class GameHUD extends Stage {
}
opacity = visible ? 1f : 0.4f;
}
void toggleConsole() {
console.toggle();
if (console.isVisible()) {
clearAbility();
} else {
updateAbility();
}
}
@Override
public boolean keyUp(int keycode) {
@@ -584,12 +594,12 @@ public class GameHUD extends Stage {
}
ui.pressDown(keycode);
if (keycode == Input.Keys.F9 || keycode == Input.Keys.F10) {
console.toggle();
toggleConsole();
return true;
}
if (keycode == Input.Keys.BACK) {
if (console.isVisible()) {
console.toggle();
toggleConsole();
}
}
if (console.isVisible())
@@ -701,7 +711,7 @@ public class GameHUD extends Stage {
@Override
public boolean longPress(Actor actor, float x, float y) {
console.toggle();
toggleConsole();
return super.longPress(actor, x, y);
}
}

View File

@@ -6,11 +6,11 @@ import java.util.List;
import java.util.Map;
import forge.adventure.scene.DuelScene;
import forge.adventure.util.Config;
import forge.ai.GameState;
import forge.deck.Deck;
import forge.game.player.Player;
import forge.item.IPaperCard;
import forge.screens.TransitionScreen;
import forge.util.collect.FCollection;
import org.apache.commons.lang3.StringUtils;
@@ -312,15 +312,13 @@ public class MatchController extends AbstractGuiGame {
@Override
public void finishGame() {
if (Forge.isMobileAdventureMode) {
if (Config.instance().getSettingData().disableWinLose) {
Forge.setCursor(null, "0");
if (DuelScene.instance().hasCallbackExit())
return;
Forge.setTransitionScreen(new TransitionScreen(() -> {
Forge.clearTransitionScreen();
Forge.clearCurrentScreen();
}, Forge.takeScreenshot(), false, false));
if (!DuelScene.instance().hasCallbackExit())
DuelScene.instance().exitDuelScene();
return;
}
}
if (hasLocalPlayers() || getGameView().isMatchOver()) {
view.setViewWinLose(new ViewWinLose(getGameView()));
view.getViewWinLose().setVisible(true);

View File

@@ -0,0 +1,46 @@
package forge.screens.match.winlose;
import forge.Forge;
import forge.adventure.scene.DuelScene;
import forge.game.GameView;
public class AdventureWinLose extends ControlWinLose {
/**
* @param v &emsp; ViewWinLose
* @param game
*/
public AdventureWinLose(ViewWinLose v, GameView game) {
super(v, game);
v.getBtnContinue().setVisible(false);
v.getBtnRestart().setVisible(false);
v.getLabelShowBattlefield().setVisible(false);
v.getBtnQuit().setText(Forge.getLocalizer().getMessage("lblBackToAdventure"));
Forge.setCursor(null, "0");
}
@Override
public void actionOnContinue() {
//Do Nothing
}
@Override
public void actionOnRestart() {
//Do Nothing
}
@Override
public void actionOnQuit() {
getView().hide();
DuelScene.instance().exitDuelScene();
}
@Override
public void saveOptions() {
//Do Nothing
}
@Override
public void showRewards() {
//Do Nothing
}
}

View File

@@ -123,6 +123,9 @@ public class ViewWinLose extends FOverlay implements IWinLoseView<FButton> {
}).build());
lblTitle.setText(composeTitle(game0));
if (Forge.isMobileAdventureMode)
control = new AdventureWinLose(this, game0);
showGameOutcomeSummary();
showPlayerScores();
control.showRewards();
@@ -152,6 +155,10 @@ public class ViewWinLose extends FOverlay implements IWinLoseView<FButton> {
return this.btnQuit;
}
public FLabel getLabelShowBattlefield() {
return this.btnShowBattlefield;
}
private void showGameOutcomeSummary() {
for (GameLogEntry o : game.getGameLog().getLogEntriesExact(GameLogEntryType.GAME_OUTCOME)) {
pnlOutcomes.add(new FLabel.Builder().text(o.message).font(FSkinFont.get(14)).build());
@@ -191,12 +198,20 @@ public class ViewWinLose extends FOverlay implements IWinLoseView<FButton> {
y += h + dy;
h = height / 12;
if (Forge.isMobileAdventureMode) {
btnQuit.setBounds(x, y, w, h);
y += h + dy;
btnContinue.setVisible(false);
btnRestart.setVisible(false);
} else {
btnContinue.setBounds(x, y, w, h);
y += h + dy;
btnRestart.setBounds(x, y, w, h);
y += h + dy;
btnQuit.setBounds(x, y, w, h);
y += h + dy;
}
h = lblLog.getAutoSizeBounds().height + dy;
lblLog.setBounds(x, y, w, h);

View File

@@ -2962,6 +2962,8 @@ lblZoom=Zoomen
lblEffect=Wirkung
lblEmblem=Emblem
lblBoon=Vorteil
lblBackToAdventure=Zurück zum Abenteuer
lblDisableWinLose=Deaktivieren Sie Winslose Overlay
lblExitToWoldMap=Zurück zur Weltkarte?
lblStartArena=Willst du in die Arena gehen?
lblWouldYouLikeDestroy=Möchten Sie {0} zerstören?

View File

@@ -2972,6 +2972,8 @@ lblZoom=Zoom
lblEffect=Effect
lblEmblem=Emblem
lblBoon=Boon
lblBackToAdventure=Back to Adventure
lblDisableWinLose=Disable WinLose Overlay
lblExitToWoldMap=Exit to the World Map?
lblStartArena=Do you want to go into the Arena?
lblWouldYouLikeDestroy=Would you like to destroy {0}?

View File

@@ -2965,6 +2965,8 @@ lblZoom=Zoom
lblEffect=Efecto
lblEmblem=Emblem
lblBoon=Boon
lblBackToAdventure=Volver a la aventura
lblDisableWinLose=Desactivar WinLose Overlay
lblExitToWoldMap=Salir al mapa del mundo?
lblStartArena=¿Quieres ir a la arena?
lblWouldYouLikeDestroy=¿Le gustaría destruir {0}?

View File

@@ -2968,6 +2968,8 @@ lblZoom=Zoom
lblEffect=Effet
lblEmblem=Emblème
lblBoon=Aubaine
lblBackToAdventure=Retour à l'aventure
lblDisableWinLose=Désactiver la superposition Winlose
lblExitToWoldMap=Sortir sur la carte du monde?
lblStartArena=Voulez-vous entrer dans l'arène?
lblWouldYouLikeDestroy=Souhaitez-vous détruire {0}?

View File

@@ -2968,6 +2968,8 @@ lblZoom=Ingrandisci
lblEffect=Effetto
lblEmblem=Emblema
lblBoon=Boon
lblBackToAdventure=Torna all'avventura
lblDisableWinLose=Disabilita overlay winlose
lblExitToWoldMap=Esci alla mappa del mondo?
lblStartArena=Vuoi andare nell'arena?
lblWouldYouLikeDestroy=Vorresti distruggere {0}?

View File

@@ -2964,6 +2964,8 @@ lblZoom=ズーム
lblEffect=効果
lblEmblem=エンブレム
lblBoon=ブーン
lblBackToAdventure=冒険に戻ります
lblDisableWinLose=Winloseオーバーレイを無効にします
lblExitToWoldMap=世界地図に終了しますか?
lblStartArena=アリーナに行きたいですか?
lblWouldYouLikeDestroy={0}を破壊しますか?

View File

@@ -3054,6 +3054,8 @@ lblZoom=Ampliação
lblEffect=Efeito
lblEmblem=Emblem
lblBoon=Boon
lblBackToAdventure=De volta à aventura
lblDisableWinLose=Desative a sobreposição de Winlose
lblExitToWoldMap=Sair para o mapa do mundo?
lblStartArena=Você quer entrar na arena?
lblWouldYouLikeDestroy=Você gostaria de destruir {0}?

View File

@@ -2947,6 +2947,8 @@ lblZoom=飞涨
lblEffect=影响
lblEmblem=象征
lblBoon=恩赐
lblBackToAdventure=回到冒险
lblDisableWinLose=禁用Winlose覆盖
lblExitToWoldMap=退出世界地图?
lblStartArena=您想进入竞技场吗?
lblWouldYouLikeDestroy=您想销毁{0}吗?