mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 02:08:00 +00:00
update Transitionscreen, RewardScene & Hud
This commit is contained in:
@@ -3,8 +3,10 @@ package forge.app;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
|
import android.view.InputDevice;
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Version;
|
import com.badlogic.gdx.Version;
|
||||||
import com.badlogic.gdx.backends.android.AndroidApplication;
|
import com.badlogic.gdx.backends.android.AndroidApplication;
|
||||||
@@ -59,11 +61,12 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||||||
|
|
||||||
public class Main extends AndroidApplication {
|
public class Main extends AndroidApplication {
|
||||||
AndroidAdapter Gadapter;
|
AndroidAdapter Gadapter;
|
||||||
|
ArrayList<String> gamepads;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
gamepads = getGameControllers();
|
||||||
//init Sentry
|
//init Sentry
|
||||||
//SentryAndroid.init(this);
|
//SentryAndroid.init(this);
|
||||||
|
|
||||||
@@ -475,6 +478,31 @@ public class Main extends AndroidApplication {
|
|||||||
}
|
}
|
||||||
return Pair.of(size.x, size.y);
|
return Pair.of(size.x, size.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<String> getGamepads() {
|
||||||
|
return gamepads;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private ArrayList<String> getGameControllers() {
|
||||||
|
ArrayList<String> gameControllerDeviceIds = new ArrayList<String>();
|
||||||
|
int[] deviceIds = InputDevice.getDeviceIds();
|
||||||
|
for (int deviceId : deviceIds) {
|
||||||
|
InputDevice dev = InputDevice.getDevice(deviceId);
|
||||||
|
int sources = dev.getSources();
|
||||||
|
String devNameId = dev.getName()+"["+deviceId+"]";
|
||||||
|
|
||||||
|
// Verify that the device has gamepad buttons, control sticks, or both.
|
||||||
|
if (((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
|
||||||
|
|| ((sources & InputDevice.SOURCE_JOYSTICK)
|
||||||
|
== InputDevice.SOURCE_JOYSTICK)) {
|
||||||
|
// This device is a game controller. Store its device ID.
|
||||||
|
if (!gameControllerDeviceIds.contains(devNameId)) {
|
||||||
|
gameControllerDeviceIds.add(devNameId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return gameControllerDeviceIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDeviceName() {
|
public String getDeviceName() {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package forge.ios;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.robovm.apple.foundation.NSAutoreleasePool;
|
import org.robovm.apple.foundation.NSAutoreleasePool;
|
||||||
@@ -120,5 +121,10 @@ public class Main extends IOSApplication.Delegate {
|
|||||||
public Pair<Integer, Integer> getRealScreenSize(boolean real) {
|
public Pair<Integer, Integer> getRealScreenSize(boolean real) {
|
||||||
return Pair.of(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
return Pair.of(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<String> getGamepads() {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,6 +26,7 @@ import java.io.InputStream;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@@ -247,5 +248,10 @@ public class Main {
|
|||||||
public Pair<Integer, Integer> getRealScreenSize(boolean real) {
|
public Pair<Integer, Integer> getRealScreenSize(boolean real) {
|
||||||
return Pair.of(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
return Pair.of(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<String> getGamepads() {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.badlogic.gdx.controllers.Controller;
|
|||||||
import com.badlogic.gdx.controllers.ControllerAdapter;
|
import com.badlogic.gdx.controllers.ControllerAdapter;
|
||||||
import com.badlogic.gdx.controllers.ControllerListener;
|
import com.badlogic.gdx.controllers.ControllerListener;
|
||||||
import com.badlogic.gdx.controllers.Controllers;
|
import com.badlogic.gdx.controllers.Controllers;
|
||||||
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.graphics.*;
|
import com.badlogic.gdx.graphics.*;
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
@@ -326,7 +327,8 @@ public class Forge implements ApplicationListener {
|
|||||||
altZoneTabs = true;
|
altZoneTabs = true;
|
||||||
//pixl cursor for adventure
|
//pixl cursor for adventure
|
||||||
setCursor(null, "0");
|
setCursor(null, "0");
|
||||||
enableControllerListener();
|
if (!GuiBase.isAndroid() || !getDeviceAdapter().getGamepads().isEmpty())
|
||||||
|
enableControllerListener();
|
||||||
loadAdventureResources(true);
|
loadAdventureResources(true);
|
||||||
}
|
}
|
||||||
private static void loadAdventureResources(boolean startScene) {
|
private static void loadAdventureResources(boolean startScene) {
|
||||||
@@ -339,6 +341,17 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected void afterDbLoaded() {
|
protected void afterDbLoaded() {
|
||||||
|
//override transition & title bg
|
||||||
|
try {
|
||||||
|
FileHandle transitionFile = Config.instance().getFile("ui/transition.png");
|
||||||
|
FileHandle titleBGFile = Forge.isLandscapeMode() ? Config.instance().getFile("ui/title_bg.png") : Config.instance().getFile("ui/title_bg_portrait.png");
|
||||||
|
if (transitionFile.exists())
|
||||||
|
Forge.getAssets().fallback_skins().put(1, new Texture(transitionFile));
|
||||||
|
if (titleBGFile.exists())
|
||||||
|
Forge.getAssets().fallback_skins().put(0, new Texture(titleBGFile));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
destroyThis = false; //Allow back()
|
destroyThis = false; //Allow back()
|
||||||
Gdx.input.setCatchKey(Keys.MENU, true);
|
Gdx.input.setCatchKey(Keys.MENU, true);
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class MapViewScene extends UIScene {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyPressed(int keycode) {
|
public boolean keyPressed(int keycode) {
|
||||||
if (keycode == Input.Keys.ESCAPE || keycode == Input.Keys.BACK) {
|
if (keycode == Input.Keys.ESCAPE || keycode == Input.Keys.BACK || keycode == Input.Keys.BUTTON_B) {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import forge.sound.SoundSystem;
|
|||||||
* Displays the rewards of a fight or a treasure
|
* Displays the rewards of a fight or a treasure
|
||||||
*/
|
*/
|
||||||
public class RewardScene extends UIScene {
|
public class RewardScene extends UIScene {
|
||||||
private final TextraButton doneButton;
|
private final TextraButton doneButton, detailButton;
|
||||||
private final TextraLabel goldLabel;
|
private final TextraLabel goldLabel;
|
||||||
|
|
||||||
private static RewardScene object;
|
private static RewardScene object;
|
||||||
@@ -53,6 +53,9 @@ public class RewardScene extends UIScene {
|
|||||||
goldLabel=ui.findActor("gold");
|
goldLabel=ui.findActor("gold");
|
||||||
ui.onButtonPress("done", () -> RewardScene.this.done());
|
ui.onButtonPress("done", () -> RewardScene.this.done());
|
||||||
ui.onButtonPress("detail",()->RewardScene.this.toggleToolTip());
|
ui.onButtonPress("detail",()->RewardScene.this.toggleToolTip());
|
||||||
|
detailButton = ui.findActor("detail");
|
||||||
|
if (Forge.getDeviceAdapter().getGamepads().isEmpty())
|
||||||
|
detailButton.setVisible(false);
|
||||||
doneButton = ui.findActor("done");
|
doneButton = ui.findActor("done");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,42 +106,27 @@ public class RewardScene extends UIScene {
|
|||||||
ImageCache.unloadCardTextures(true);
|
ImageCache.unloadCardTextures(true);
|
||||||
Forge.switchToLast();
|
Forge.switchToLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean done() {
|
public boolean done() {
|
||||||
|
return done(false);
|
||||||
|
}
|
||||||
|
boolean done(boolean skipShowLoot) {
|
||||||
GameHUD.getInstance().getTouchpad().setVisible(false);
|
GameHUD.getInstance().getTouchpad().setVisible(false);
|
||||||
if (doneClicked) {
|
if (!skipShowLoot) {
|
||||||
if(exitCountDown > 0.2f) {
|
doneButton.setText(Forge.getLocalizer().getMessage("lblLeave"));
|
||||||
clearGenerated();
|
showLootOrDone();
|
||||||
quitScene();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
switch (type) {
|
||||||
if (type == Type.Loot) {
|
case Shop:
|
||||||
boolean wait = false;
|
doneButton.setText(Forge.getLocalizer().getMessage("lblLeave"));
|
||||||
for (Actor actor : new Array.ArrayIterator<>(generated)) {
|
break;
|
||||||
if (!(actor instanceof RewardActor)) {
|
case Loot:
|
||||||
continue;
|
doneButton.setText(Forge.getLocalizer().getMessage("lblDone"));
|
||||||
}
|
break;
|
||||||
RewardActor reward = (RewardActor) actor;
|
|
||||||
AdventurePlayer.current().addReward(reward.getReward());
|
|
||||||
if (!reward.isFlipped()) {
|
|
||||||
wait = true;
|
|
||||||
reward.flip();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (wait) {
|
|
||||||
flipCountDown = Math.min(1.0f + (generated.size * 0.3f), 5.0f);
|
|
||||||
exitCountDown = 0.0f;
|
|
||||||
doneClicked = true;
|
|
||||||
} else {
|
|
||||||
clearGenerated();
|
|
||||||
quitScene();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
clearGenerated();
|
|
||||||
quitScene();
|
|
||||||
}
|
}
|
||||||
|
shown = false;
|
||||||
|
clearGenerated();
|
||||||
|
quitScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void clearGenerated() {
|
void clearGenerated() {
|
||||||
@@ -182,7 +170,7 @@ public class RewardScene extends UIScene {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (exit)
|
if (exit)
|
||||||
performTouch(doneButton);
|
done(true);
|
||||||
else if (type == Type.Loot && !shown) {
|
else if (type == Type.Loot && !shown) {
|
||||||
shown = true;
|
shown = true;
|
||||||
for (Actor actor : new Array.ArrayIterator<>(generated)) {
|
for (Actor actor : new Array.ArrayIterator<>(generated)) {
|
||||||
@@ -201,7 +189,7 @@ public class RewardScene extends UIScene {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
performTouch(doneButton);
|
done(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public enum KeyBinding {
|
|||||||
Inventory("Inventory", Input.Keys.I,Input.Keys.BUTTON_X),
|
Inventory("Inventory", Input.Keys.I,Input.Keys.BUTTON_X),
|
||||||
Status("Status", Input.Keys.Q,Input.Keys.BUTTON_Y),
|
Status("Status", Input.Keys.Q,Input.Keys.BUTTON_Y),
|
||||||
Deck("Deck", Input.Keys.E,Input.Keys.BUTTON_A),
|
Deck("Deck", Input.Keys.E,Input.Keys.BUTTON_A),
|
||||||
Map("Map", Input.Keys.M,Input.Keys.BUTTON_B),
|
Map("Map", Input.Keys.M,Input.Keys.BUTTON_SELECT),
|
||||||
Equip("Equip", Input.Keys.E,Input.Keys.BUTTON_X),
|
Equip("Equip", Input.Keys.E,Input.Keys.BUTTON_X),
|
||||||
Use("Use", Input.Keys.ENTER,Input.Keys.BUTTON_A),
|
Use("Use", Input.Keys.ENTER,Input.Keys.BUTTON_A),
|
||||||
Back("Back", Input.Keys.ESCAPE,Input.Keys.BUTTON_B),
|
Back("Back", Input.Keys.ESCAPE,Input.Keys.BUTTON_B),
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class TransitionScreen extends FContainer {
|
|||||||
Runnable runnable;
|
Runnable runnable;
|
||||||
TextureRegion textureRegion;
|
TextureRegion textureRegion;
|
||||||
private String message = "";
|
private String message = "";
|
||||||
boolean matchTransition, isloading, isIntro, isFadeMusic;
|
boolean matchTransition, isloading, isIntro, isFadeMusic, advStartup;
|
||||||
|
|
||||||
public TransitionScreen(Runnable proc, TextureRegion screen, boolean enterMatch, boolean loading) {
|
public TransitionScreen(Runnable proc, TextureRegion screen, boolean enterMatch, boolean loading) {
|
||||||
this(proc, screen, enterMatch, loading, false, false);
|
this(proc, screen, enterMatch, loading, false, false);
|
||||||
@@ -43,6 +43,7 @@ public class TransitionScreen extends FContainer {
|
|||||||
isIntro = intro;
|
isIntro = intro;
|
||||||
isFadeMusic = fadeMusic;
|
isFadeMusic = fadeMusic;
|
||||||
message = loadingMessage;
|
message = loadingMessage;
|
||||||
|
advStartup = Forge.selector.equals("Adventure");
|
||||||
}
|
}
|
||||||
|
|
||||||
public FProgressBar getProgressBar() {
|
public FProgressBar getProgressBar() {
|
||||||
@@ -110,10 +111,17 @@ public class TransitionScreen extends FContainer {
|
|||||||
g.drawWarpImage(textureRegion, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight(), percentage);
|
g.drawWarpImage(textureRegion, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight(), percentage);
|
||||||
} else if (isIntro) {
|
} else if (isIntro) {
|
||||||
if (textureRegion != null) {
|
if (textureRegion != null) {
|
||||||
g.drawImage(Forge.isMobileAdventureMode ? FSkinTexture.ADV_BG_TEXTURE : FSkinTexture.BG_TEXTURE, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
|
if (advStartup) {
|
||||||
g.setAlphaComposite(1-percentage);
|
g.drawGrayTransitionImage(Forge.getAssets().fallback_skins().get(0), 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight(), false, percentage);
|
||||||
g.drawImage(textureRegion, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
|
g.setAlphaComposite(1-percentage);
|
||||||
g.setAlphaComposite(oldAlpha);
|
g.drawImage(textureRegion, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
|
||||||
|
g.setAlphaComposite(oldAlpha);
|
||||||
|
} else {
|
||||||
|
g.drawImage(Forge.isMobileAdventureMode ? FSkinTexture.ADV_BG_TEXTURE : FSkinTexture.BG_TEXTURE, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
|
||||||
|
g.setAlphaComposite(1-percentage);
|
||||||
|
g.drawImage(textureRegion, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
|
||||||
|
g.setAlphaComposite(oldAlpha);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (textureRegion != null)
|
if (textureRegion != null)
|
||||||
|
|||||||
@@ -131,6 +131,7 @@
|
|||||||
"type": "TextButton",
|
"type": "TextButton",
|
||||||
"name": "openmap",
|
"name": "openmap",
|
||||||
"text": "{Scale=80%}tr(lblZoom)",
|
"text": "{Scale=80%}tr(lblZoom)",
|
||||||
|
"binding": "Map",
|
||||||
"width": 80,
|
"width": 80,
|
||||||
"height": 18,
|
"height": 18,
|
||||||
"x": 0,
|
"x": 0,
|
||||||
|
|||||||
@@ -131,6 +131,7 @@
|
|||||||
"type": "TextButton",
|
"type": "TextButton",
|
||||||
"name": "openmap",
|
"name": "openmap",
|
||||||
"text": "{Scale=80%}tr(lblZoom)",
|
"text": "{Scale=80%}tr(lblZoom)",
|
||||||
|
"binding": "Map",
|
||||||
"width": 80,
|
"width": 80,
|
||||||
"height": 18,
|
"height": 18,
|
||||||
"x": 0,
|
"x": 0,
|
||||||
|
|||||||
@@ -130,6 +130,7 @@
|
|||||||
"type": "TextButton",
|
"type": "TextButton",
|
||||||
"name": "openmap",
|
"name": "openmap",
|
||||||
"text": "{Scale=80%}tr(lblZoom)",
|
"text": "{Scale=80%}tr(lblZoom)",
|
||||||
|
"binding": "Map",
|
||||||
"width": 80,
|
"width": 80,
|
||||||
"height": 18,
|
"height": 18,
|
||||||
"x": 0,
|
"x": 0,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public interface IDeviceAdapter {
|
public interface IDeviceAdapter {
|
||||||
boolean isConnectedToInternet();
|
boolean isConnectedToInternet();
|
||||||
@@ -18,4 +19,5 @@ public interface IDeviceAdapter {
|
|||||||
void exit();
|
void exit();
|
||||||
void convertToJPEG(InputStream input, OutputStream output) throws IOException;
|
void convertToJPEG(InputStream input, OutputStream output) throws IOException;
|
||||||
Pair<Integer, Integer> getRealScreenSize(boolean real);
|
Pair<Integer, Integer> getRealScreenSize(boolean real);
|
||||||
|
ArrayList<String> getGamepads();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user