From bc02b51d7da8b74f945e94074cd28b34256285cf Mon Sep 17 00:00:00 2001 From: Willem Date: Sat, 5 Feb 2022 00:21:55 +0100 Subject: [PATCH] Fixed scroll override bug --- ...Adapter.java => AbstractScrollScreen.java} | 25 +++++++++++++------ .../gdxapp/screen/ScreenCredits.java | 6 ++--- .../gdxapp/screen/ScreenHelp.java | 6 ++--- .../gdxapp/screen/ScreenIntroMission.java | 4 +-- 4 files changed, 26 insertions(+), 15 deletions(-) rename demo4d-gdxapp/src/main/love/distributedrebirth/gdxapp/screen/{ScrollScreenAdapter.java => AbstractScrollScreen.java} (84%) diff --git a/demo4d-gdxapp/src/main/love/distributedrebirth/gdxapp/screen/ScrollScreenAdapter.java b/demo4d-gdxapp/src/main/love/distributedrebirth/gdxapp/screen/AbstractScrollScreen.java similarity index 84% rename from demo4d-gdxapp/src/main/love/distributedrebirth/gdxapp/screen/ScrollScreenAdapter.java rename to demo4d-gdxapp/src/main/love/distributedrebirth/gdxapp/screen/AbstractScrollScreen.java index 4812c653..c5d2de4e 100644 --- a/demo4d-gdxapp/src/main/love/distributedrebirth/gdxapp/screen/ScrollScreenAdapter.java +++ b/demo4d-gdxapp/src/main/love/distributedrebirth/gdxapp/screen/AbstractScrollScreen.java @@ -11,7 +11,7 @@ import love.distributedrebirth.gdxapp.Demo4DMain; import love.distributedrebirth.gdxapp.Demo4DMainAdapter; @BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") -abstract public class ScrollScreenAdapter extends Demo4DMainAdapter { +abstract public class AbstractScrollScreen extends Demo4DMainAdapter { private static final int LINE_HEIGHT = 16; private float scrollDeltaTime = 0f; private String scrollText = ""; @@ -19,7 +19,7 @@ abstract public class ScrollScreenAdapter extends Demo4DMainAdapter { private int scrollLine = LINE_HEIGHT; private final Texture backgroundImage; - public ScrollScreenAdapter(final Demo4DMain main, String background) { + public AbstractScrollScreen(final Demo4DMain main, String background) { super(main); backgroundImage = new Texture(Gdx.files.internal(background)); } @@ -64,19 +64,30 @@ abstract public class ScrollScreenAdapter extends Demo4DMainAdapter { } @Override - public void hide() { + public final void show() { + showScroll(); + } + + protected void showScroll() { + } + + @Override + public final void hide() { scrollText = ""; scrollIndex = 0; scrollLine = LINE_HEIGHT; + hideScroll(); } - + + protected void hideScroll() { + } + @Override public final void dispose() { backgroundImage.dispose(); - disposeScreen(main); + disposeScroll(); } - protected void disposeScreen(Demo4DMain main) { - // override if needed + protected void disposeScroll() { } } diff --git a/demo4d-gdxapp/src/main/love/distributedrebirth/gdxapp/screen/ScreenCredits.java b/demo4d-gdxapp/src/main/love/distributedrebirth/gdxapp/screen/ScreenCredits.java index d50788d9..8bb9457f 100644 --- a/demo4d-gdxapp/src/main/love/distributedrebirth/gdxapp/screen/ScreenCredits.java +++ b/demo4d-gdxapp/src/main/love/distributedrebirth/gdxapp/screen/ScreenCredits.java @@ -7,7 +7,7 @@ import love.distributedrebirth.gdxapp.Demo4DMain; import love.distributedrebirth.gdxapp.music.MusicSongType; @BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") -public class ScreenCredits extends ScrollScreenAdapter { +public class ScreenCredits extends AbstractScrollScreen { private final String creditsText = String.join("\n", "Credits;", "At-Ohm-Allah-to-the-power-of-Four", @@ -78,12 +78,12 @@ public class ScreenCredits extends ScrollScreenAdapter { } @Override - public void show () { + public void showScroll() { main.music.play(MusicSongType.CREDITS); } @Override - public void hide () { + public void hideScroll() { main.music.play(MusicSongType.BACKGROUND); } } diff --git a/demo4d-gdxapp/src/main/love/distributedrebirth/gdxapp/screen/ScreenHelp.java b/demo4d-gdxapp/src/main/love/distributedrebirth/gdxapp/screen/ScreenHelp.java index d2771df2..5e0d7d43 100644 --- a/demo4d-gdxapp/src/main/love/distributedrebirth/gdxapp/screen/ScreenHelp.java +++ b/demo4d-gdxapp/src/main/love/distributedrebirth/gdxapp/screen/ScreenHelp.java @@ -7,7 +7,7 @@ import love.distributedrebirth.gdxapp.Demo4DMain; import love.distributedrebirth.gdxapp.music.MusicSongType; @BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") -public class ScreenHelp extends ScrollScreenAdapter { +public class ScreenHelp extends AbstractScrollScreen { private final String creditsText = String.join("\n", "Genesis 11", " ", @@ -61,12 +61,12 @@ public class ScreenHelp extends ScrollScreenAdapter { } @Override - public void show () { + public void showScroll() { main.music.play(MusicSongType.INTRO); } @Override - public void hide () { + public void hideScroll() { main.music.play(MusicSongType.BACKGROUND); } } diff --git a/demo4d-gdxapp/src/main/love/distributedrebirth/gdxapp/screen/ScreenIntroMission.java b/demo4d-gdxapp/src/main/love/distributedrebirth/gdxapp/screen/ScreenIntroMission.java index 1feb810c..c259ed24 100644 --- a/demo4d-gdxapp/src/main/love/distributedrebirth/gdxapp/screen/ScreenIntroMission.java +++ b/demo4d-gdxapp/src/main/love/distributedrebirth/gdxapp/screen/ScreenIntroMission.java @@ -7,7 +7,7 @@ import love.distributedrebirth.gdxapp.Demo4DMain; import love.distributedrebirth.gdxapp.music.MusicSongType; @BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") -public class ScreenIntroMission extends ScrollScreenAdapter { +public class ScreenIntroMission extends AbstractScrollScreen { private final String missionText = String.join("\n", "To a Waterfowl", " -- by William Cullen Bryant --", @@ -71,7 +71,7 @@ public class ScreenIntroMission extends ScrollScreenAdapter { } @Override - public void hide () { + public void hideScroll() { main.music.play(MusicSongType.BACKGROUND); } }