add AdventureScreen launchscreen

This commit is contained in:
Anthony Calosa
2023-02-15 22:15:43 +08:00
parent 609dd9dba0
commit 47b4f77f1a
17 changed files with 120 additions and 14 deletions

View File

@@ -35,6 +35,7 @@ import forge.screens.ClosingScreen;
import forge.screens.FScreen;
import forge.screens.SplashScreen;
import forge.screens.TransitionScreen;
import forge.screens.home.AdventureScreen;
import forge.screens.home.HomeScreen;
import forge.screens.home.NewGameMenu;
import forge.screens.match.MatchController;
@@ -354,6 +355,7 @@ public class Forge implements ApplicationListener {
Forge.getAssets().fallback_skins().put(1, new Texture(transitionFile));
if (titleBGFile.exists())
Forge.getAssets().fallback_skins().put(0, new Texture(titleBGFile));
AdventureScreen.preload();
} catch (Exception e) {
e.printStackTrace();
}
@@ -641,7 +643,6 @@ public class Forge implements ApplicationListener {
final List<String> options = new ArrayList<>();
options.add(getLocalizer().getMessage("lblExit"));
options.add(getLocalizer().getMessage("lblAdventure"));
options.add(getLocalizer().getMessage("lblCancel"));
Callback<Integer> callback = new Callback<Integer>() {
@@ -650,8 +651,6 @@ public class Forge implements ApplicationListener {
if (result == 0) {
exited = true;
exitAnimation(false);
} else if (result == 1) {
switchToAdventure();
}
}
};

View File

@@ -16,6 +16,10 @@ public class GifAnimation extends ForgeAnimation {
animation = GifDecoder.loadGIFAnimation(PlayMode.NORMAL, Gdx.files.absolute(filename).read());
}
public GifAnimation(String filename, PlayMode mode) {
animation = GifDecoder.loadGIFAnimation(mode, Gdx.files.absolute(filename).read());
}
@Override
public void start() {
currentFrame = animation.getKeyFrame(0);

View File

@@ -232,6 +232,7 @@ public enum FSkinImage implements FImage {
//adventure
MANASHARD (FSkinProp.ICO_MANASHARD, SourceFile.ADVENTURE),
MENU_ADVLOGO (FSkinProp.ICO_ADVLOGO, SourceFile.ADVENTURE),
//menu icon
MENU_GALAXY (FSkinProp.ICO_MENU_GALAXY, SourceFile.ICONS),

View File

@@ -0,0 +1,71 @@
package forge.screens.home;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.utils.Align;
import forge.Forge;
import forge.Graphics;
import forge.animation.GifAnimation;
import forge.assets.FSkinColor;
import forge.assets.FSkinFont;
import forge.localinstance.properties.ForgeConstants;
import forge.screens.LaunchScreen;
import forge.toolbox.FLabel;
import forge.toolbox.FTextArea;
import forge.util.Callback;
import forge.util.Utils;
public class AdventureScreen extends LaunchScreen {
private static final float PADDING = Utils.scale(10);
private boolean loaded = false;
private static GifAnimation animation = null;
private final FTextArea lblDesc = new FTextArea(false, Forge.getLocalizer().getMessage("lblAdventureDescription"), animation);
public AdventureScreen() {
super(null, NewGameMenu.getMenu());
lblDesc.setFont(FSkinFont.get(12));
lblDesc.setTextColor(FLabel.getInlineLabelColor());
}
@Override
protected void doLayoutAboveBtnStart(float startY, float width, float height) {
float x = PADDING;
float y = startY + PADDING;
float w = width - 2 * PADDING;
float h = height - y - PADDING;
lblDesc.setBounds(x, y, w, h);
}
@Override
public void onActivate() {
if (!loaded) {
loaded = true;
add(lblDesc);
}
if (animation != null) {
animation.start();
}
Forge.startContinuousRendering();
super.onActivate();
}
@Override
public void onSwitchAway(Callback<Boolean> canSwitchCallback) {
if (animation != null) {
animation.stop();
}
Forge.stopContinuousRendering();
super.onSwitchAway(canSwitchCallback);
}
@Override
protected void startMatch() {
Forge.switchToAdventure();
}
public static void preload() {
//keep low frame and under 1mb for performance
String demo = ForgeConstants.EFFECTS_DIR+"demo.gif";
if (Gdx.files.absolute(demo).exists())
animation = new GifAnimation(demo, Animation.PlayMode.LOOP);
}
}

View File

@@ -28,7 +28,8 @@ public class NewGameMenu extends FPopupMenu {
QuestMode(Forge.getLocalizer().getMessageorUseDefault("lblQuestMode", "Quest Mode"), FSkinImage.QUEST_ZEP, NewQuestScreen.class),
PuzzleMode(Forge.getLocalizer().getMessageorUseDefault("lblPuzzleMode", "Puzzle Mode"), FSkinImage.MENU_PUZZLE, PuzzleScreen.class),
PlanarConquest(Forge.getLocalizer().getMessageorUseDefault("lblPlanarConquest", "Planar Conquest"), FSkinImage.MENU_GALAXY, NewConquestScreen.class),
Gauntlet(Forge.getLocalizer().getMessageorUseDefault("lblGauntlet", "Gauntlet"), FSkinImage.MENU_GAUNTLET, NewGauntletScreen.class);
Gauntlet(Forge.getLocalizer().getMessageorUseDefault("lblGauntlet", "Gauntlet"), FSkinImage.MENU_GAUNTLET, NewGauntletScreen.class),
Adventure(Forge.getLocalizer().getMessageorUseDefault("lblAdventureMode", "Adventure Mode"), FSkinImage.MENU_ADVLOGO, AdventureScreen.class);
private final FMenuItem item;
private final Class<? extends FScreen> screenClass;
@@ -98,7 +99,11 @@ public class NewGameMenu extends FPopupMenu {
public static void setPreferredScreen(NewGameScreen preferredScreen0) {
if (preferredScreen == preferredScreen0) { return; }
preferredScreen = preferredScreen0;
prefs.setPref(FPref.NEW_GAME_SCREEN, preferredScreen.name());
String prefName = preferredScreen.name();
//don't save adventure mode launchscreen, default to constructed
if (NewGameScreen.Adventure.equals(preferredScreen))
prefName = NewGameScreen.Constructed.name();
prefs.setPref(FPref.NEW_GAME_SCREEN, prefName);
prefs.save();
}

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Align;
import forge.Graphics;
import forge.animation.GifAnimation;
import forge.assets.FSkinColor;
import forge.assets.FSkinFont;
import forge.assets.TextRenderer;
@@ -15,17 +16,22 @@ public class FTextArea extends FScrollPane {
private Vector2 insets;
private FSkinColor textColor;
private final TextRenderer renderer;
private GifAnimation animation;
private boolean centerVertically;
public FTextArea(boolean parseReminderText0) {
this(parseReminderText0, "");
}
public FTextArea(boolean parseReminderText0, String text0) {
this(parseReminderText0, text0, null);
}
public FTextArea(boolean parseReminderText0, String text0, GifAnimation gifAnimation) {
text = text0;
font = FSkinFont.get(14);
alignment = Align.left;
insets = new Vector2(1, 1); //prevent text getting cut off by clip
textColor = FLabel.getDefaultTextColor();
animation = gifAnimation;
renderer = new TextRenderer(parseReminderText0);
}
@@ -81,4 +87,15 @@ public class FTextArea extends FScrollPane {
protected void drawBackground(Graphics g) {
renderer.drawText(g, text, font, textColor, insets.x - getScrollLeft(), insets.y - getScrollTop(), getScrollWidth() - 2 * insets.x, getScrollHeight() - 2 * insets.y, 0, getHeight(), true, alignment, centerVertically);
}
@Override
public void draw(Graphics g) {
if (animation != null) {
float w = getScrollWidth() - 2 * insets.x;
float h = w * 0.6f;
float y = getPreferredHeight(w);
animation.draw(g, insets.x - getScrollLeft(), (insets.y - getScrollTop()) + y, w, h);
}
super.draw(g);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

View File

@@ -2939,4 +2939,5 @@ lblEffect=Wirkung
lblEmblem=Emblem
lblBoon=Vorteil
lblExitToWoldMap=Zurück zur Weltkarte?
lblWouldYouLikeDestroy=Would you like to destroy {0} ?
lblWouldYouLikeDestroy=Möchten Sie {0} zerstören?
lblAdventureDescription=In Abenteuermodus erkunden Sie die sich ständig ändernde Landschaft von Shandalar und Duell-Kreaturen, um Gold, Scherben, Ausrüstung und neue Karten zu gewinnen, um sie alle zu werden und alle zu sammeln!

View File

@@ -2946,4 +2946,5 @@ lblEffect=Effect
lblEmblem=Emblem
lblBoon=Boon
lblExitToWoldMap=Exit to the World Map?
lblWouldYouLikeDestroy=Would you like to destroy {0} ?
lblWouldYouLikeDestroy=Would you like to destroy {0}?
lblAdventureDescription=Adventure mode is where you explore the ever-changing landscape of Shandalar, and duel creatures to gain gold, shards, equipment and new cards to become the best and collect them all!

View File

@@ -2942,4 +2942,5 @@ lblEffect=Efecto
lblEmblem=Emblem
lblBoon=Boon
lblExitToWoldMap=Salir al mapa del mundo?
lblWouldYouLikeDestroy=Would you like to destroy {0} ?
lblWouldYouLikeDestroy=¿Le gustaría destruir {0}?
lblAdventureDescription=¡El modo de aventura es donde exploras el paisaje siempre cambiante de Shandalar, y criaturas de duelo para ganar oro, fragmentos, equipos y nuevas tarjetas para convertirte en el mejor y recogerlas a todos!

View File

@@ -2944,4 +2944,5 @@ lblEffect=Effet
lblEmblem=Emblème
lblBoon=Aubaine
lblExitToWoldMap=Sortir sur la carte du monde?
lblWouldYouLikeDestroy=Would you like to destroy {0} ?
lblWouldYouLikeDestroy=Souhaitez-vous détruire {0}?
lblAdventureDescription=Le mode aventure est l'endroit où vous explorez le paysage en constante évolution de Shandalar, et des créatures duel pour gagner de l'or, des éclats, de l'équipement et de nouvelles cartes pour devenir les meilleurs et les récupérer tous!

View File

@@ -2945,4 +2945,5 @@ lblEffect=Effetto
lblEmblem=Emblema
lblBoon=Boon
lblExitToWoldMap=Esci alla mappa del mondo?
lblWouldYouLikeDestroy=Would you like to destroy {0} ?
lblWouldYouLikeDestroy=Vorresti distruggere {0}?
lblAdventureDescription=La modalità Adventure è dove esplori il paesaggio in continua evoluzione di Shandalar e le creature di duello per guadagnare oro, frammenti, attrezzature e nuove carte per diventare i migliori e raccoglierle tutte!

View File

@@ -2942,3 +2942,4 @@ lblEmblem=エンブレム
lblBoon=ブーン
lblExitToWoldMap=世界地図に終了しますか?
lblWouldYouLikeDestroy={0}を破壊しますか?
lblAdventureDescription=アドベンチャーモードは、金、破片、機器、新しいカードを獲得して最高のものになり、すべてを集めるために、Shandalarの絶えず変化する風景と決闘の生き物を探求する場所です

View File

@@ -3031,4 +3031,5 @@ lblEffect=Efeito
lblEmblem=Emblem
lblBoon=Boon
lblExitToWoldMap=Sair para o mapa do mundo?
lblWouldYouLikeDestroy=Would you like to destroy {0} ?
lblWouldYouLikeDestroy=Você gostaria de destruir {0}?
lblAdventureDescription=O modo de aventura é onde você explora a paisagem em constante mudança de Shandalar, e duelo para ganhar ouro, fragmentos, equipamentos e novos cartões para se tornarem os melhores e colecioná-los!

View File

@@ -2924,4 +2924,5 @@ lblEffect=影响
lblEmblem=象征
lblBoon=恩赐
lblExitToWoldMap=退出世界地图?
lblWouldYouLikeDestroy=Would you like to destroy {0} ?
lblWouldYouLikeDestroy=您想销毁{0}吗?
lblAdventureDescription=冒险模式是您探索山达尔Shandalar不断变化的景观以及决斗生物获得黄金碎片设备和新卡片使其成为最好的并收集所有这些

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

@@ -268,7 +268,8 @@ public enum FSkinProp {
ICO_QUEST_BIG_BAG (new int[] {480, 1360, 160, 160}, PropType.ICON),
//adventure icons
ICO_MANASHARD (new int[] {0,0, 100,100}, PropType.ICON),
ICO_MANASHARD (new int[] {2, 304, 100, 100}, PropType.ADVENTURE),
ICO_ADVLOGO (new int[] {2, 2, 300, 300}, PropType.ADVENTURE),
//menu icon
ICO_MENU_GALAXY (new int[] {0, 1520, 80, 80}, PropType.ICON),