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.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.view.InputDevice;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Version;
|
||||
import com.badlogic.gdx.backends.android.AndroidApplication;
|
||||
@@ -59,11 +61,12 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class Main extends AndroidApplication {
|
||||
AndroidAdapter Gadapter;
|
||||
ArrayList<String> gamepads;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
gamepads = getGameControllers();
|
||||
//init Sentry
|
||||
//SentryAndroid.init(this);
|
||||
|
||||
@@ -475,6 +478,31 @@ public class Main extends AndroidApplication {
|
||||
}
|
||||
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() {
|
||||
|
||||
@@ -3,6 +3,7 @@ package forge.ios;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.robovm.apple.foundation.NSAutoreleasePool;
|
||||
@@ -120,5 +121,10 @@ public class Main extends IOSApplication.Delegate {
|
||||
public Pair<Integer, Integer> getRealScreenSize(boolean real) {
|
||||
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.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
@@ -247,5 +248,10 @@ public class Main {
|
||||
public Pair<Integer, Integer> getRealScreenSize(boolean real) {
|
||||
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.ControllerListener;
|
||||
import com.badlogic.gdx.controllers.Controllers;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.*;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
@@ -326,7 +327,8 @@ public class Forge implements ApplicationListener {
|
||||
altZoneTabs = true;
|
||||
//pixl cursor for adventure
|
||||
setCursor(null, "0");
|
||||
enableControllerListener();
|
||||
if (!GuiBase.isAndroid() || !getDeviceAdapter().getGamepads().isEmpty())
|
||||
enableControllerListener();
|
||||
loadAdventureResources(true);
|
||||
}
|
||||
private static void loadAdventureResources(boolean startScene) {
|
||||
@@ -339,6 +341,17 @@ public class Forge implements ApplicationListener {
|
||||
}
|
||||
}
|
||||
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()
|
||||
Gdx.input.setCatchKey(Keys.MENU, true);
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ public class MapViewScene extends UIScene {
|
||||
|
||||
@Override
|
||||
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();
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -23,7 +23,7 @@ import forge.sound.SoundSystem;
|
||||
* Displays the rewards of a fight or a treasure
|
||||
*/
|
||||
public class RewardScene extends UIScene {
|
||||
private final TextraButton doneButton;
|
||||
private final TextraButton doneButton, detailButton;
|
||||
private final TextraLabel goldLabel;
|
||||
|
||||
private static RewardScene object;
|
||||
@@ -53,6 +53,9 @@ public class RewardScene extends UIScene {
|
||||
goldLabel=ui.findActor("gold");
|
||||
ui.onButtonPress("done", () -> RewardScene.this.done());
|
||||
ui.onButtonPress("detail",()->RewardScene.this.toggleToolTip());
|
||||
detailButton = ui.findActor("detail");
|
||||
if (Forge.getDeviceAdapter().getGamepads().isEmpty())
|
||||
detailButton.setVisible(false);
|
||||
doneButton = ui.findActor("done");
|
||||
}
|
||||
|
||||
@@ -103,42 +106,27 @@ public class RewardScene extends UIScene {
|
||||
ImageCache.unloadCardTextures(true);
|
||||
Forge.switchToLast();
|
||||
}
|
||||
|
||||
public boolean done() {
|
||||
return done(false);
|
||||
}
|
||||
boolean done(boolean skipShowLoot) {
|
||||
GameHUD.getInstance().getTouchpad().setVisible(false);
|
||||
if (doneClicked) {
|
||||
if(exitCountDown > 0.2f) {
|
||||
clearGenerated();
|
||||
quitScene();
|
||||
}
|
||||
if (!skipShowLoot) {
|
||||
doneButton.setText(Forge.getLocalizer().getMessage("lblLeave"));
|
||||
showLootOrDone();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (type == Type.Loot) {
|
||||
boolean wait = false;
|
||||
for (Actor actor : new Array.ArrayIterator<>(generated)) {
|
||||
if (!(actor instanceof RewardActor)) {
|
||||
continue;
|
||||
}
|
||||
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();
|
||||
switch (type) {
|
||||
case Shop:
|
||||
doneButton.setText(Forge.getLocalizer().getMessage("lblLeave"));
|
||||
break;
|
||||
case Loot:
|
||||
doneButton.setText(Forge.getLocalizer().getMessage("lblDone"));
|
||||
break;
|
||||
}
|
||||
shown = false;
|
||||
clearGenerated();
|
||||
quitScene();
|
||||
return true;
|
||||
}
|
||||
void clearGenerated() {
|
||||
@@ -182,7 +170,7 @@ public class RewardScene extends UIScene {
|
||||
}
|
||||
}
|
||||
if (exit)
|
||||
performTouch(doneButton);
|
||||
done(true);
|
||||
else if (type == Type.Loot && !shown) {
|
||||
shown = true;
|
||||
for (Actor actor : new Array.ArrayIterator<>(generated)) {
|
||||
@@ -201,7 +189,7 @@ public class RewardScene extends UIScene {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
performTouch(doneButton);
|
||||
done(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public enum KeyBinding {
|
||||
Inventory("Inventory", Input.Keys.I,Input.Keys.BUTTON_X),
|
||||
Status("Status", Input.Keys.Q,Input.Keys.BUTTON_Y),
|
||||
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),
|
||||
Use("Use", Input.Keys.ENTER,Input.Keys.BUTTON_A),
|
||||
Back("Back", Input.Keys.ESCAPE,Input.Keys.BUTTON_B),
|
||||
|
||||
@@ -19,7 +19,7 @@ public class TransitionScreen extends FContainer {
|
||||
Runnable runnable;
|
||||
TextureRegion textureRegion;
|
||||
private String message = "";
|
||||
boolean matchTransition, isloading, isIntro, isFadeMusic;
|
||||
boolean matchTransition, isloading, isIntro, isFadeMusic, advStartup;
|
||||
|
||||
public TransitionScreen(Runnable proc, TextureRegion screen, boolean enterMatch, boolean loading) {
|
||||
this(proc, screen, enterMatch, loading, false, false);
|
||||
@@ -43,6 +43,7 @@ public class TransitionScreen extends FContainer {
|
||||
isIntro = intro;
|
||||
isFadeMusic = fadeMusic;
|
||||
message = loadingMessage;
|
||||
advStartup = Forge.selector.equals("Adventure");
|
||||
}
|
||||
|
||||
public FProgressBar getProgressBar() {
|
||||
@@ -110,10 +111,17 @@ public class TransitionScreen extends FContainer {
|
||||
g.drawWarpImage(textureRegion, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight(), percentage);
|
||||
} else if (isIntro) {
|
||||
if (textureRegion != null) {
|
||||
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);
|
||||
if (advStartup) {
|
||||
g.drawGrayTransitionImage(Forge.getAssets().fallback_skins().get(0), 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight(), false, percentage);
|
||||
g.setAlphaComposite(1-percentage);
|
||||
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 {
|
||||
if (textureRegion != null)
|
||||
|
||||
@@ -131,6 +131,7 @@
|
||||
"type": "TextButton",
|
||||
"name": "openmap",
|
||||
"text": "{Scale=80%}tr(lblZoom)",
|
||||
"binding": "Map",
|
||||
"width": 80,
|
||||
"height": 18,
|
||||
"x": 0,
|
||||
|
||||
@@ -131,6 +131,7 @@
|
||||
"type": "TextButton",
|
||||
"name": "openmap",
|
||||
"text": "{Scale=80%}tr(lblZoom)",
|
||||
"binding": "Map",
|
||||
"width": 80,
|
||||
"height": 18,
|
||||
"x": 0,
|
||||
|
||||
@@ -130,6 +130,7 @@
|
||||
"type": "TextButton",
|
||||
"name": "openmap",
|
||||
"text": "{Scale=80%}tr(lblZoom)",
|
||||
"binding": "Map",
|
||||
"width": 80,
|
||||
"height": 18,
|
||||
"x": 0,
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface IDeviceAdapter {
|
||||
boolean isConnectedToInternet();
|
||||
@@ -18,4 +19,5 @@ public interface IDeviceAdapter {
|
||||
void exit();
|
||||
void convertToJPEG(InputStream input, OutputStream output) throws IOException;
|
||||
Pair<Integer, Integer> getRealScreenSize(boolean real);
|
||||
ArrayList<String> getGamepads();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user