|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 77 KiB |
@@ -19,6 +19,13 @@
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>4thline-repo</id>
|
||||
<url>http://4thline.org/m2</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
@@ -58,11 +65,11 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<headerType>gui</headerType>
|
||||
<outfile>${project.build.directory}/forge-adventure-java8.exe</outfile>
|
||||
<outfile>${project.build.directory}/forge-adventure-editor-java8.exe</outfile>
|
||||
<jar>${project.build.finalName}-jar-with-dependencies.jar</jar>
|
||||
<dontWrapJar>true</dontWrapJar>
|
||||
<errTitle>forge</errTitle>
|
||||
<icon>src/main/config/forge-adventure.ico</icon>
|
||||
<icon>src/main/config/forge-adventure-editor.ico</icon>
|
||||
<classPath>
|
||||
<mainClass>forge.adventure.Main</mainClass>
|
||||
<addDependencies>false</addDependencies>
|
||||
@@ -90,9 +97,9 @@
|
||||
<txtProductVersion>
|
||||
1.0.0.0
|
||||
</txtProductVersion>
|
||||
<productName>forge-adventure</productName>
|
||||
<internalName>forge-adventure</internalName>
|
||||
<originalFilename>forge-adventure-java8.exe</originalFilename>
|
||||
<productName>forge-adventure-editor</productName>
|
||||
<internalName>forge-adventure-editor</internalName>
|
||||
<originalFilename>forge-adventure-editor-java8.exe</originalFilename>
|
||||
</versionInfo>
|
||||
</configuration>
|
||||
</execution>
|
||||
@@ -105,12 +112,12 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<headerType>gui</headerType>
|
||||
<outfile>${project.build.directory}/forge-adventure.exe</outfile>
|
||||
<outfile>${project.build.directory}/forge-adventure-editor.exe</outfile>
|
||||
<jar>${project.build.finalName}-jar-with-dependencies.jar</jar>
|
||||
<dontWrapJar>true</dontWrapJar>
|
||||
<errTitle>forge</errTitle>
|
||||
<downloadUrl>https://www.oracle.com/java/technologies/downloads/</downloadUrl>
|
||||
<icon>src/main/config/forge-adventure.ico</icon>
|
||||
<icon>src/main/config/forge-adventure-editor.ico</icon>
|
||||
<classPath>
|
||||
<mainClass>forge.adventure.Main</mainClass>
|
||||
<addDependencies>false</addDependencies>
|
||||
@@ -160,9 +167,9 @@
|
||||
<txtProductVersion>
|
||||
1.0.0.0
|
||||
</txtProductVersion>
|
||||
<productName>forge-adventure</productName>
|
||||
<internalName>forge-adventure</internalName>
|
||||
<originalFilename>forge-adventure.exe</originalFilename>
|
||||
<productName>forge-adventure-editor</productName>
|
||||
<internalName>forge-adventure-editor</internalName>
|
||||
<originalFilename>forge-adventure-editor.exe</originalFilename>
|
||||
</versionInfo>
|
||||
</configuration>
|
||||
</execution>
|
||||
@@ -184,7 +191,7 @@
|
||||
</executions>
|
||||
<configuration>
|
||||
<basedir>${basedir}/${configSourceDirectory}</basedir>
|
||||
<filesToInclude>forge-adventure.sh, forge-adventure-mac.sh, forge-adventure.command, forge-adventure.cmd</filesToInclude>
|
||||
<filesToInclude>forge-adventure-editor.sh, forge-adventure-editor-mac.sh, forge-adventure-editor.command, forge-adventure-editor.cmd</filesToInclude>
|
||||
<outputBasedir>${project.build.directory}</outputBasedir>
|
||||
<outputDir>.</outputDir>
|
||||
<regex>false</regex>
|
||||
@@ -250,7 +257,13 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.badlogicgames.gdx</groupId>
|
||||
<artifactId>gdx-backend-lwjgl3</artifactId>
|
||||
<artifactId>gdx-backend-lwjgl</artifactId>
|
||||
<version>1.11.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.badlogicgames.gdx</groupId>
|
||||
<artifactId>gdx-tools</artifactId>
|
||||
<version>1.11.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
@@ -291,12 +304,6 @@
|
||||
<version>22.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>forge</groupId>
|
||||
<artifactId>forge-gui-mobile</artifactId>
|
||||
<version>1.6.54-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.badlogicgames.gdx-controllers</groupId>
|
||||
<artifactId>gdx-controllers-desktop</artifactId>
|
||||
|
||||
BIN
forge-adventure/src/main/config/forge-adventure-editor.ico
Normal file
|
After Width: | Height: | Size: 90 KiB |
@@ -1,26 +1,10 @@
|
||||
package forge.adventure;
|
||||
|
||||
import com.badlogic.gdx.ApplicationListener;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.backends.lwjgl3.*;
|
||||
import com.badlogic.gdx.graphics.glutils.HdpiMode;
|
||||
import forge.Forge;
|
||||
import forge.GuiMobile;
|
||||
import forge.adventure.editor.EditorMainWindow;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.interfaces.IDeviceAdapter;
|
||||
import forge.util.BuildInfo;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.OperatingSystem;
|
||||
import forge.util.RestartUtil;
|
||||
import io.sentry.Sentry;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import forge.gui.GuiBase;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@@ -30,169 +14,9 @@ import java.nio.file.Paths;
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Sentry.init(options -> {
|
||||
options.setEnableExternalConfiguration(true);
|
||||
options.setRelease(BuildInfo.getVersionString());
|
||||
options.setEnvironment(System.getProperty("os.name"));
|
||||
options.setTag("Java Version", System.getProperty("java.version"));
|
||||
}, true);
|
||||
|
||||
// HACK - temporary solution to "Comparison method violates it's general contract!" crash
|
||||
System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
|
||||
|
||||
//Turn off the Java 2D system's use of Direct3D to improve rendering speed (particularly when Full Screen)
|
||||
System.setProperty("sun.java2d.d3d", "false");
|
||||
|
||||
|
||||
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
|
||||
config.setResizable(false);
|
||||
ApplicationListener start = Forge.getApp(new Lwjgl3Clipboard(), new DesktopAdapter(""), Files.exists(Paths.get("./res"))?"./":"../forge-gui/", true, false, 0, true, 0, "", "");
|
||||
|
||||
if (Config.instance().getSettingData().fullScreen) {
|
||||
config.setFullscreenMode(Lwjgl3ApplicationConfiguration.getDisplayMode());
|
||||
config.setAutoIconify(true);
|
||||
config.setHdpiMode(HdpiMode.Logical);
|
||||
} else {
|
||||
config.setWindowedMode(Config.instance().getSettingData().width, Config.instance().getSettingData().height);
|
||||
}
|
||||
config.setTitle("Forge Adventure Mobile");
|
||||
config.setWindowIcon(Config.instance().getFilePath("forge-adventure.png"));
|
||||
config.setWindowListener(new Lwjgl3WindowListener() {
|
||||
@Override
|
||||
public void created(Lwjgl3Window lwjgl3Window) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void iconified(boolean b) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void maximized(boolean b) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusGained() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean closeRequested() {
|
||||
//use the device adpater to exit properly
|
||||
if (Forge.safeToClose)
|
||||
Forge.exit(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void filesDropped(String[] strings) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshRequested() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
for(int i=0;i<args.length;i++)
|
||||
{
|
||||
if(args[i].equals("testMap"))
|
||||
{
|
||||
Forge.createNewAdventureMap=true;
|
||||
}
|
||||
}
|
||||
new Lwjgl3Application(start, config);
|
||||
|
||||
}
|
||||
|
||||
private static class DesktopAdapter implements IDeviceAdapter {
|
||||
private final String switchOrientationFile;
|
||||
|
||||
private DesktopAdapter(String switchOrientationFile0) {
|
||||
switchOrientationFile = switchOrientationFile0;
|
||||
}
|
||||
|
||||
//just assume desktop always connected to wifi
|
||||
@Override
|
||||
public boolean isConnectedToInternet() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnectedToWifi() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDownloadsDir() {
|
||||
return System.getProperty("user.home") + "/Downloads/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean openFile(String filename) {
|
||||
try {
|
||||
Desktop.getDesktop().open(new File(filename));
|
||||
return true;
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restart() {
|
||||
if (RestartUtil.prepareForRestart()) {
|
||||
Gdx.app.exit();
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
Gdx.app.exit(); //can just use Gdx.app.exit for desktop
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTablet() {
|
||||
return true; //treat desktop the same as a tablet
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLandscapeMode(boolean landscapeMode) {
|
||||
//create file to indicate that landscape mode should be used
|
||||
if (landscapeMode) {
|
||||
FileUtil.writeFile(switchOrientationFile, "1");
|
||||
}
|
||||
else {
|
||||
FileUtil.deleteFile(switchOrientationFile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preventSystemSleep(boolean preventSleep) {
|
||||
OperatingSystem.preventSystemSleep(preventSleep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convertToJPEG(InputStream input, OutputStream output) throws IOException {
|
||||
BufferedImage image = ImageIO.read(input);
|
||||
ImageIO.write(image, "jpg", output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> getRealScreenSize(boolean real) {
|
||||
return Pair.of(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
}
|
||||
GuiBase.setInterface(new GuiMobile(Files.exists(Paths.get("./res"))?"./":"../forge-gui/"));
|
||||
GuiBase.setDeviceInfo("", "", 0, 0);
|
||||
Config.instance();
|
||||
new EditorMainWindow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package forge.adventure.editor;
|
||||
|
||||
|
||||
|
||||
import com.badlogic.gdx.tools.particleeditor.ParticleEditor;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
@@ -12,13 +16,32 @@ public class EditorMainWindow extends JFrame {
|
||||
|
||||
public EditorMainWindow()
|
||||
{
|
||||
UIManager.LookAndFeelInfo[] var1 = UIManager.getInstalledLookAndFeels();
|
||||
int var2 = var1.length;
|
||||
|
||||
for(int var3 = 0; var3 < var2; ++var3) {
|
||||
UIManager.LookAndFeelInfo info = var1[var3];
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
try {
|
||||
UIManager.setLookAndFeel(info.getClassName());
|
||||
} catch (Throwable var6) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
BorderLayout layout=new BorderLayout();
|
||||
JToolBar toolBar = new JToolBar("toolbar");
|
||||
JButton newButton=new JButton("open ParticleEditor");
|
||||
newButton.addActionListener(e -> EventQueue.invokeLater(() ->new ParticleEditor()));
|
||||
toolBar.add(newButton);
|
||||
setLayout(layout);
|
||||
add(tabs);
|
||||
add(toolBar, BorderLayout.NORTH);
|
||||
add(tabs, BorderLayout.CENTER);
|
||||
tabs.addTab("World",worldEditor);
|
||||
tabs.addTab("POI",new PointOfInterestEditor());
|
||||
tabs.addTab("Items",new ItemsEditor());
|
||||
tabs.addTab("Enemies",new EnemyEditor());
|
||||
|
||||
setVisible(true);
|
||||
setSize(800,600);
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package forge.adventure.editor;
|
||||
|
||||
import forge.GuiMobile;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.gui.GuiBase;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
/**
|
||||
* Editor class to edit configuration, maybe moved or removed
|
||||
*/
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
GuiBase.setInterface(new GuiMobile(Files.exists(Paths.get("./res"))?"./":"../forge-gui/"));
|
||||
GuiBase.setDeviceInfo("", "", 0, 0);
|
||||
Config.instance();
|
||||
new EditorMainWindow();
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ public class PointOfInterestEdit extends JComponent {
|
||||
JTextField sprite = new JTextField();
|
||||
FilePicker map = new FilePicker(new String[]{"tmx"});
|
||||
JSpinner radiusFactor= new JSpinner(new SpinnerNumberModel(0.0f, 0.0f, 2.0f, 0.1f));
|
||||
SwingAtlasPreview preview=new SwingAtlasPreview(256,2000);
|
||||
|
||||
|
||||
private boolean updating=false;
|
||||
@@ -34,6 +35,7 @@ public class PointOfInterestEdit extends JComponent {
|
||||
parameters.add("Sprite:",sprite);
|
||||
parameters.add("Map:",map);
|
||||
parameters.add("Radius factor:",radiusFactor);
|
||||
parameters.add(preview);
|
||||
|
||||
add(parameters);
|
||||
|
||||
@@ -80,6 +82,7 @@ public class PointOfInterestEdit extends JComponent {
|
||||
map.getEdit().setText(currentData.map);
|
||||
radiusFactor.setValue(currentData.radiusFactor);
|
||||
|
||||
preview.setSpritePath(currentData.spriteAtlas,currentData.sprite);
|
||||
updating=false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public class PointOfInterestEditor extends JComponent {
|
||||
JList<PointOfInterestData> list = new JList<>(model);
|
||||
JToolBar toolBar = new JToolBar("toolbar");
|
||||
PointOfInterestEdit edit=new PointOfInterestEdit();
|
||||
|
||||
static HashMap<String,SwingAtlas> atlas=new HashMap<>();
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.Arrays;
|
||||
public class RewardEdit extends FormPanel {
|
||||
RewardData currentData;
|
||||
|
||||
JComboBox typeField =new JComboBox(new String[] { "card", "gold", "life", "deckCard", "item"});
|
||||
JComboBox typeField =new JComboBox(new String[] { "card", "gold", "life", "deckCard", "item","mana"});
|
||||
JSpinner probability = new JSpinner(new SpinnerNumberModel(0f, 0, 1, 0.1f));
|
||||
JSpinner count = new JSpinner(new SpinnerNumberModel(0, 0, 1000, 1));
|
||||
JSpinner addMaxCount = new JSpinner(new SpinnerNumberModel(0, 0, 1000, 1));
|
||||
@@ -83,7 +83,7 @@ public class RewardEdit extends FormPanel {
|
||||
currentData.count= (int) count.getValue();
|
||||
currentData.addMaxCount= (int) addMaxCount.getValue();
|
||||
currentData.cardName = cardName.getText().isEmpty()?null:cardName.getText();
|
||||
currentData.itemName = itemName.getText().isEmpty()?null:itemName.getText();
|
||||
currentData.itemNames = itemName.getText().isEmpty()?null:itemName.getText().split(",");
|
||||
currentData.editions = editions.getList();
|
||||
currentData.colors = colors.getList();
|
||||
currentData.rarity = rarity.getList();
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -17,9 +18,13 @@ public class SwingAtlasPreview extends Box {
|
||||
private String sprite="";
|
||||
private String spriteName="";
|
||||
Timer timer;
|
||||
public SwingAtlasPreview() {
|
||||
public SwingAtlasPreview()
|
||||
{
|
||||
this(32,200);
|
||||
}
|
||||
public SwingAtlasPreview(int imageSize,int timeDelay) {
|
||||
super(BoxLayout.Y_AXIS);
|
||||
timer = new Timer(200, new AbstractAction() {
|
||||
timer = new Timer(timeDelay, new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
counter++;
|
||||
@@ -28,7 +33,9 @@ public class SwingAtlasPreview extends Box {
|
||||
}
|
||||
}
|
||||
});
|
||||
this.imageSize=imageSize;
|
||||
}
|
||||
static Map<String,Map<Integer,SwingAtlas>> cache=new HashMap<>();
|
||||
public SwingAtlasPreview(int size) {
|
||||
this();
|
||||
imageSize=size;
|
||||
@@ -47,7 +54,16 @@ public class SwingAtlasPreview extends Box {
|
||||
labels.clear();
|
||||
this.sprite=sprite;
|
||||
this.spriteName=name;
|
||||
SwingAtlas atlas=new SwingAtlas(Config.instance().getFile(sprite),imageSize);
|
||||
SwingAtlas atlas;
|
||||
if(!cache.containsKey(sprite))
|
||||
{
|
||||
cache.put(sprite,new HashMap<>() );
|
||||
}
|
||||
if(!cache.get(sprite).containsKey(imageSize))
|
||||
{
|
||||
cache.get(sprite).put(imageSize,new SwingAtlas(Config.instance().getFile(sprite),imageSize) );
|
||||
}
|
||||
atlas=cache.get(sprite).get(imageSize);
|
||||
int maxCount=0;
|
||||
for(Map.Entry<String, ArrayList<ImageIcon>> element:atlas.getImages().entrySet())
|
||||
{
|
||||
|
||||
@@ -131,6 +131,15 @@ public class WorldEditor extends JComponent {
|
||||
newButton=new JButton("test map");
|
||||
newButton.addActionListener(e -> WorldEditor.this.test());
|
||||
toolBar.add(newButton);
|
||||
|
||||
|
||||
newButton=new JButton("edit effects");
|
||||
newButton.addActionListener(e -> WorldEditor.this.startEffectEditor());
|
||||
toolBar.add(newButton);
|
||||
}
|
||||
|
||||
private void startEffectEditor() {
|
||||
|
||||
}
|
||||
|
||||
private void test() {
|
||||
|
||||
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 77 KiB |
@@ -560,11 +560,17 @@
|
||||
<fileset dir="${project.build.directory}" includes="forge-java8.exe" />
|
||||
<fileset dir="${project.build.directory}" includes="forge.exe" />
|
||||
<fileset dir="${project.build.directory}" includes="${project.build.finalName}-jar-with-dependencies.jar" />
|
||||
<fileset dir="${project.build.directory}/../../forge-adventure/target" includes="forge-adventure.exe" />
|
||||
<fileset dir="${project.build.directory}/../../forge-adventure/target" includes="forge-adventure-java8.exe" />
|
||||
<fileset dir="${project.build.directory}/../../forge-adventure/target" includes="forge-adventure.sh" />
|
||||
<fileset dir="${project.build.directory}/../../forge-adventure/target" includes="forge-adventure.command" />
|
||||
<fileset dir="${project.build.directory}/../../forge-adventure/target" includes="forge-adventure.cmd" />
|
||||
<fileset dir="${project.build.directory}/../../forge-gui-mobile-dev/target" includes="forge-adventure.exe" />
|
||||
<fileset dir="${project.build.directory}/../../forge-gui-mobile-dev/target" includes="forge-adventure-java8.exe" />
|
||||
<fileset dir="${project.build.directory}/../../forge-gui-mobile-dev/target" includes="forge-adventure.sh" />
|
||||
<fileset dir="${project.build.directory}/../../forge-gui-mobile-dev/target" includes="forge-adventure.command" />
|
||||
<fileset dir="${project.build.directory}/../../forge-gui-mobile-dev/target" includes="forge-adventure.cmd" />
|
||||
<fileset dir="${project.build.directory}/../../forge-gui-mobile-dev/target" includes="forge-gui-mobile-dev-${project.version}-jar-with-dependencies.jar" />
|
||||
<fileset dir="${project.build.directory}/../../forge-adventure/target" includes="forge-adventure-editor.exe" />
|
||||
<fileset dir="${project.build.directory}/../../forge-adventure/target" includes="forge-adventure-editor-java8.exe" />
|
||||
<fileset dir="${project.build.directory}/../../forge-adventure/target" includes="forge-adventure-editor.sh" />
|
||||
<fileset dir="${project.build.directory}/../../forge-adventure/target" includes="forge-adventure-editor.command" />
|
||||
<fileset dir="${project.build.directory}/../../forge-adventure/target" includes="forge-adventure-editor.cmd" />
|
||||
<fileset dir="${project.build.directory}/../../forge-adventure/target" includes="forge-adventure-${project.version}-jar-with-dependencies.jar" />
|
||||
</copy>
|
||||
<mkdir dir="${project.build.directory}/${project.build.finalName}/res/cardsfolder" />
|
||||
@@ -575,10 +581,15 @@
|
||||
<chmod file="${project.build.directory}/${project.build.finalName}/forge-adventure.sh" perm="a+rx" />
|
||||
<chmod file="${project.build.directory}/${project.build.finalName}/forge-adventure.command" perm="a+rx" />
|
||||
<chmod file="${project.build.directory}/${project.build.finalName}/forge-adventure.cmd" perm="a+rx" />
|
||||
<chmod file="${project.build.directory}/${project.build.finalName}/forge-adventure-editor.sh" perm="a+rx" />
|
||||
<chmod file="${project.build.directory}/${project.build.finalName}/forge-adventure-editor.command" perm="a+rx" />
|
||||
<chmod file="${project.build.directory}/${project.build.finalName}/forge-adventure-editor.cmd" perm="a+rx" />
|
||||
<chmod file="${project.build.directory}/${project.build.finalName}/forge-java8.exe" perm="a+rx" />
|
||||
<chmod file="${project.build.directory}/${project.build.finalName}/forge.exe" perm="a+rx" />
|
||||
<chmod file="${project.build.directory}/${project.build.finalName}/forge-adventure.exe" perm="a+rx" />
|
||||
<chmod file="${project.build.directory}/${project.build.finalName}/forge-adventure-java8.exe" perm="a+rx" />
|
||||
<chmod file="${project.build.directory}/${project.build.finalName}/forge-adventure-editor.exe" perm="a+rx" />
|
||||
<chmod file="${project.build.directory}/${project.build.finalName}/forge-adventure-editor-java8.exe" perm="a+rx" />
|
||||
<tar destfile="${project.build.directory}/${project.build.finalName}.tar.bz2" compression="bzip2">
|
||||
<tarfileset filemode="755" dir="${project.build.directory}/${project.build.finalName}">
|
||||
<include name="forge.sh" />
|
||||
@@ -586,6 +597,16 @@
|
||||
<include name="forge.cmd" />
|
||||
<include name="forge-java8.exe" />
|
||||
<include name="forge.exe" />
|
||||
<include name="forge-adventure.sh" />
|
||||
<include name="forge-adventure.command" />
|
||||
<include name="forge-adventure.cmd" />
|
||||
<include name="forge-adventure-java8.exe" />
|
||||
<include name="forge-adventure.exe" />
|
||||
<include name="forge-adventure-editor.sh" />
|
||||
<include name="forge-adventure-editor.command" />
|
||||
<include name="forge-adventure-editor.cmd" />
|
||||
<include name="forge-adventure-editor-java8.exe" />
|
||||
<include name="forge-adventure-editor.exe" />
|
||||
</tarfileset>
|
||||
<tarfileset dir="${project.build.directory}/${project.build.finalName}">
|
||||
<include name="**" />
|
||||
@@ -594,6 +615,16 @@
|
||||
<exclude name="forge.cmd" />
|
||||
<exclude name="forge-java8.exe" />
|
||||
<exclude name="forge.exe" />
|
||||
<exclude name="forge-adventure.sh" />
|
||||
<exclude name="forge-adventure.command" />
|
||||
<exclude name="forge-adventure.cmd" />
|
||||
<exclude name="forge-adventure-java8.exe" />
|
||||
<exclude name="forge-adventure.exe" />
|
||||
<exclude name="forge-adventure-editor.sh" />
|
||||
<exclude name="forge-adventure-editor.command" />
|
||||
<exclude name="forge-adventure-editor.cmd" />
|
||||
<exclude name="forge-adventure-editor-java8.exe" />
|
||||
<exclude name="forge-adventure-editor.exe" />
|
||||
</tarfileset>
|
||||
</tar>
|
||||
</target>
|
||||
|
||||
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 77 KiB |
@@ -36,6 +36,156 @@
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>replacer</artifactId>
|
||||
<version>1.5.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<basedir>${basedir}/${configSourceDirectory}</basedir>
|
||||
<filesToInclude>forge-adventure.sh, forge-adventure-mac.sh, forge-adventure.command, forge-adventure.cmd</filesToInclude>
|
||||
<outputBasedir>${project.build.directory}</outputBasedir>
|
||||
<outputDir>.</outputDir>
|
||||
<regex>false</regex>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>$project.build.finalName$</token>
|
||||
<value>${project.build.finalName}-jar-with-dependencies.jar</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.akathist.maven.plugins.launch4j</groupId>
|
||||
<artifactId>launch4j-maven-plugin</artifactId>
|
||||
<version>1.7.25</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>l4j-adv</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>launch4j</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<headerType>gui</headerType>
|
||||
<outfile>${project.build.directory}/forge-adventure-java8.exe</outfile>
|
||||
<jar>${project.build.finalName}-jar-with-dependencies.jar</jar>
|
||||
<dontWrapJar>true</dontWrapJar>
|
||||
<errTitle>forge</errTitle>
|
||||
<icon>src/main/config/forge-adventure.ico</icon>
|
||||
<classPath>
|
||||
<mainClass>forge.app.Main</mainClass>
|
||||
<addDependencies>false</addDependencies>
|
||||
<preCp>anything</preCp>
|
||||
</classPath>
|
||||
<jre>
|
||||
<minVersion>1.8.0</minVersion>
|
||||
<maxHeapSize>4096</maxHeapSize>
|
||||
<opts>
|
||||
<opt>-Dfile.encoding=UTF-8</opt>
|
||||
</opts>
|
||||
</jre>
|
||||
<versionInfo>
|
||||
<fileVersion>
|
||||
1.0.0.0
|
||||
</fileVersion>
|
||||
<txtFileVersion>
|
||||
1.0.0.0
|
||||
</txtFileVersion>
|
||||
<fileDescription>Forge</fileDescription>
|
||||
<copyright>Forge</copyright>
|
||||
<productVersion>
|
||||
1.0.0.0
|
||||
</productVersion>
|
||||
<txtProductVersion>
|
||||
1.0.0.0
|
||||
</txtProductVersion>
|
||||
<productName>forge-adventure</productName>
|
||||
<internalName>forge-adventure</internalName>
|
||||
<originalFilename>forge-adventure-java8.exe</originalFilename>
|
||||
</versionInfo>
|
||||
</configuration>
|
||||
</execution>
|
||||
<!--extra-->
|
||||
<execution>
|
||||
<id>l4j-adv2</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>launch4j</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<headerType>gui</headerType>
|
||||
<outfile>${project.build.directory}/forge-adventure.exe</outfile>
|
||||
<jar>${project.build.finalName}-jar-with-dependencies.jar</jar>
|
||||
<dontWrapJar>true</dontWrapJar>
|
||||
<errTitle>forge</errTitle>
|
||||
<downloadUrl>https://www.oracle.com/java/technologies/downloads/</downloadUrl>
|
||||
<icon>src/main/config/forge-adventure.ico</icon>
|
||||
<classPath>
|
||||
<mainClass>forge.app.Main</mainClass>
|
||||
<addDependencies>false</addDependencies>
|
||||
<preCp>anything</preCp>
|
||||
</classPath>
|
||||
<jre>
|
||||
<minVersion>11.0.1</minVersion>
|
||||
<jdkPreference>jdkOnly</jdkPreference>
|
||||
<maxHeapSize>4096</maxHeapSize>
|
||||
<opts>
|
||||
<opt>-Dfile.encoding=UTF-8</opt>
|
||||
<opt>--add-opens java.base/java.lang=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.base/java.math=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.base/jdk.internal.misc=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.base/java.nio=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens=java.base/sun.nio.ch=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.base/java.util=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.base/java.lang.reflect=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.base/java.text=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.desktop/java.awt=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.desktop/java.awt.font=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.desktop/java.awt.image=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.desktop/java.awt.color=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.desktop/sun.awt.image=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.desktop/javax.swing=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.desktop/javax.swing.border=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.desktop/javax.swing.event=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.desktop/sun.swing=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.desktop/java.beans=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.base/java.util.concurrent=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.base/java.net=ALL-UNNAMED</opt>
|
||||
<opt>-Dio.netty.tryReflectionSetAccessible=true</opt>
|
||||
</opts>
|
||||
</jre>
|
||||
<versionInfo>
|
||||
<fileVersion>
|
||||
1.0.0.0
|
||||
</fileVersion>
|
||||
<txtFileVersion>
|
||||
1.0.0.0
|
||||
</txtFileVersion>
|
||||
<fileDescription>Forge</fileDescription>
|
||||
<copyright>Forge</copyright>
|
||||
<productVersion>
|
||||
1.0.0.0
|
||||
</productVersion>
|
||||
<txtProductVersion>
|
||||
1.0.0.0
|
||||
</txtProductVersion>
|
||||
<productName>forge-adventure</productName>
|
||||
<internalName>forge-adventure</internalName>
|
||||
<originalFilename>forge-adventure.exe</originalFilename>
|
||||
</versionInfo>
|
||||
</configuration>
|
||||
</execution>
|
||||
<!--extra-->
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
|
||||
@@ -22,6 +22,8 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
@@ -46,18 +48,27 @@ public class Main {
|
||||
}
|
||||
|
||||
// Set this to "true" to make the mobile game port run as a full-screen desktop application
|
||||
boolean desktopMode = cmd.hasOption("fullscreen");
|
||||
boolean desktopMode = true;//cmd.hasOption("fullscreen");
|
||||
// Set this to the location where you want the mobile game port to look for assets when working as a full-screen desktop application
|
||||
// (uncomment the bottom version and comment the top one to load the res folder from the current folder the .jar is in if you would
|
||||
// like to make the game load from a desktop game folder configuration).
|
||||
String desktopModeAssetsDir = "../forge-gui/";
|
||||
//String desktopModeAssetsDir = "./";
|
||||
//String desktopModeAssetsDir = "../forge-gui/";
|
||||
String desktopModeAssetsDir = "./";
|
||||
if(!Files.exists(Paths.get(desktopModeAssetsDir+"res")))
|
||||
desktopModeAssetsDir = "../forge-gui/";//try IDE run
|
||||
|
||||
// Assets directory used when the game fully emulates smartphone/tablet mode (desktopMode = false), useful when debugging from IDE
|
||||
String assetsDir = AssetsDownloader.SHARE_DESKTOP_ASSETS ? "../forge-gui/" : "testAssets/";
|
||||
String assetsDir ;
|
||||
if (!AssetsDownloader.SHARE_DESKTOP_ASSETS) {
|
||||
assetsDir= "testAssets/";
|
||||
FileUtil.ensureDirectoryExists(assetsDir);
|
||||
}
|
||||
else
|
||||
{
|
||||
assetsDir= "./";
|
||||
if(!Files.exists(Paths.get(assetsDir+"res")))
|
||||
assetsDir = "../forge-gui/";
|
||||
}
|
||||
|
||||
// Place the file "switch_orientation.ini" to your assets folder to make the game switch to landscape orientation (unless desktopMode = true)
|
||||
String switchOrientationFile = assetsDir + "switch_orientation.ini";
|
||||
@@ -73,6 +84,7 @@ public class Main {
|
||||
screenWidth = Integer.parseInt(res[0].trim());
|
||||
screenHeight = Integer.parseInt(res[1].trim());
|
||||
}
|
||||
desktopMode=false;
|
||||
}
|
||||
|
||||
// Fullscreen width and height for desktop mode (desktopMode = true)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
cd $(dirname "${0}")
|
||||
java -XstartOnFirstThread -Xmx4096m -Dfile.encoding=UTF-8 -jar $project.build.finalName$
|
||||
25
forge-gui-mobile-dev/src/main/config/forge-adventure.cmd
Normal file
@@ -0,0 +1,25 @@
|
||||
@echo off
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
java -version 1>nul 2>nul || (
|
||||
echo no java installed
|
||||
popd
|
||||
exit /b 2
|
||||
)
|
||||
for /f tokens^=2^ delims^=.-_^+^" %%j in ('java -fullversion 2^>^&1') do set "jver=%%j"
|
||||
|
||||
if %jver% GEQ 17 (
|
||||
java --add-opens java.desktop/java.beans=ALL-UNNAMED --add-opens java.desktop/javax.swing.border=ALL-UNNAMED --add-opens java.desktop/javax.swing.event=ALL-UNNAMED --add-opens java.desktop/sun.swing=ALL-UNNAMED --add-opens java.desktop/java.awt.image=ALL-UNNAMED --add-opens java.desktop/java.awt.color=ALL-UNNAMED --add-opens java.desktop/sun.awt.image=ALL-UNNAMED --add-opens java.desktop/javax.swing=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED -Dio.netty.tryReflectionSetAccessible=true -Xmx4096m -Dfile.encoding=UTF-8 -jar $project.build.finalName$
|
||||
popd
|
||||
exit /b 0
|
||||
)
|
||||
|
||||
if %jver% GEQ 11 (
|
||||
java --illegal-access=permit -Xmx4096m -Dfile.encoding=UTF-8 -jar $project.build.finalName$
|
||||
popd
|
||||
exit /b 0
|
||||
)
|
||||
|
||||
java -Xmx4096m -Dfile.encoding=UTF-8 -jar $project.build.finalName$
|
||||
popd
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
cd $(dirname "${0}")
|
||||
java -Xmx4096m -Dfile.encoding=UTF-8 -jar $project.build.finalName$
|
||||
BIN
forge-gui-mobile-dev/src/main/config/forge-adventure.ico
Normal file
|
After Width: | Height: | Size: 90 KiB |
3
forge-gui-mobile-dev/src/main/config/forge-adventure.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
cd $(dirname "${0}")
|
||||
java -Xmx4096m -Dfile.encoding=UTF-8 -jar $project.build.finalName$
|
||||
BIN
forge-gui-mobile-dev/src/main/config/forge.ico
Normal file
|
After Width: | Height: | Size: 222 KiB |
@@ -123,7 +123,6 @@ public class Forge implements ApplicationListener {
|
||||
public static InputProcessor inputProcessor;
|
||||
private static Cursor cursor0, cursor1, cursor2, cursorA0, cursorA1, cursorA2;
|
||||
public static boolean forcedEnglishonCJKMissing = false;
|
||||
public static boolean adventureLoaded = false;
|
||||
public static boolean createNewAdventureMap = false;
|
||||
private static Localizer localizer;
|
||||
|
||||
@@ -342,15 +341,8 @@ public class Forge implements ApplicationListener {
|
||||
}
|
||||
private static void loadAdventureResources(boolean startScene) {
|
||||
try {
|
||||
if(!adventureLoaded)
|
||||
{
|
||||
for (SceneType sceneType : SceneType.values()) {
|
||||
sceneType.instance.resLoaded();
|
||||
}
|
||||
adventureLoaded=true;
|
||||
}
|
||||
if (startScene)
|
||||
switchScene(SceneType.StartScene.instance);
|
||||
switchScene(StartScene.instance());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.adventure.character;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.*;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
@@ -19,7 +20,7 @@ public class CharacterSprite extends MapActor {
|
||||
private Animation<TextureRegion> currentAnimation = null;
|
||||
private AnimationTypes currentAnimationType = AnimationTypes.Idle;
|
||||
private AnimationDirections currentAnimationDir = AnimationDirections.None;
|
||||
private Array<Sprite> avatar=new Array<>();
|
||||
private final Array<Sprite> avatar=new Array<>();
|
||||
public boolean hidden = false;
|
||||
|
||||
public CharacterSprite(int id,String path) {
|
||||
@@ -37,11 +38,8 @@ public class CharacterSprite extends MapActor {
|
||||
}
|
||||
|
||||
protected void load(String path) {
|
||||
if(path==null||path.isEmpty())return;
|
||||
TextureAtlas atlas = Config.instance().getAtlas(path);
|
||||
/*
|
||||
for (Texture texture : new ObjectSet.ObjectSetIterator<>( atlas.getTextures()))
|
||||
texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
|
||||
*/
|
||||
animations.clear();
|
||||
for (AnimationTypes stand : AnimationTypes.values()) {
|
||||
if (stand == AnimationTypes.Avatar) {
|
||||
@@ -216,16 +214,25 @@ public class CharacterSprite extends MapActor {
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
if (currentAnimation == null || hidden)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
super.draw(batch,parentAlpha);
|
||||
beforeDraw(batch,parentAlpha);
|
||||
TextureRegion currentFrame = currentAnimation.getKeyFrame(timer, true);
|
||||
setHeight(currentFrame.getRegionHeight());
|
||||
setWidth(currentFrame.getRegionWidth());
|
||||
Color oldColor=batch.getColor().cpy();
|
||||
batch.setColor(getColor());
|
||||
batch.draw(currentFrame, getX(), getY());
|
||||
batch.setColor(oldColor);
|
||||
super.draw(batch,parentAlpha);
|
||||
//batch.draw(getDebugTexture(),getX(),getY());
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Sprite getAvatar() {
|
||||
return avatar.first();
|
||||
}
|
||||
|
||||
@@ -8,17 +8,23 @@ import forge.adventure.util.MapDialog;
|
||||
/**
|
||||
* Map actor that will show a text message with optional choices
|
||||
*/
|
||||
public class DialogActor extends MapActor {
|
||||
public class DialogActor extends CharacterSprite {
|
||||
private final MapStage stage;
|
||||
private final TextureRegion textureRegion;
|
||||
private final MapDialog dialog;
|
||||
|
||||
public DialogActor(MapStage stage, int id, String S, TextureRegion textureRegion) {
|
||||
super(id);
|
||||
super(id,"");
|
||||
this.stage = stage;
|
||||
dialog = new MapDialog(S, stage, id);
|
||||
this.textureRegion = textureRegion;
|
||||
}
|
||||
public DialogActor(MapStage stage, int id, String S, String sprite) {
|
||||
super(id,sprite);
|
||||
this.stage = stage;
|
||||
dialog = new MapDialog(S, stage, id);
|
||||
this.textureRegion = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerCollide() {
|
||||
@@ -29,8 +35,10 @@ public class DialogActor extends MapActor {
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float alpha) {
|
||||
batch.draw(textureRegion, getX(), getY(), getWidth(), getHeight());
|
||||
super.draw(batch, alpha);
|
||||
if(textureRegion!=null)
|
||||
batch.draw(textureRegion, getX(), getY(), getWidth(), getHeight());
|
||||
else
|
||||
super.draw(batch, alpha);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.adventure.character;
|
||||
|
||||
import forge.adventure.scene.SceneType;
|
||||
import forge.adventure.scene.TileMapScene;
|
||||
import forge.adventure.stage.MapStage;
|
||||
|
||||
@@ -12,29 +11,28 @@ public class EntryActor extends MapActor{
|
||||
private final MapStage stage;
|
||||
String targetMap;
|
||||
|
||||
public EntryActor(MapStage stage,String sourceMap, int id,String targetMap,float x,float y,float w,float h,String direction)
|
||||
public EntryActor(MapStage stage, int id,String targetMap,float x,float y,float w,float h,String direction,boolean spawnPlayerThere)
|
||||
{
|
||||
super(id);
|
||||
this.stage = stage;
|
||||
this.targetMap = targetMap;
|
||||
|
||||
|
||||
if((targetMap==null||targetMap.isEmpty()&&sourceMap.isEmpty())||//if target is null and "from world"
|
||||
!sourceMap.isEmpty()&&targetMap.equals(sourceMap)) //or if source is this target
|
||||
if(spawnPlayerThere) //or if source is this target
|
||||
{
|
||||
switch(direction)
|
||||
{
|
||||
case "up":
|
||||
stage.GetPlayer().setPosition(x,y+h);
|
||||
stage.getPlayerSprite().setPosition(x+w/2-stage.getPlayerSprite().getWidth()/2,y+h);
|
||||
break;
|
||||
case "down":
|
||||
stage.GetPlayer().setPosition(x,y-stage.GetPlayer().getHeight());
|
||||
stage.getPlayerSprite().setPosition(x+w/2-stage.getPlayerSprite().getWidth()/2,y-stage.getPlayerSprite().getHeight());
|
||||
break;
|
||||
case "right":
|
||||
stage.GetPlayer().setPosition(x-stage.GetPlayer().getWidth(),y);
|
||||
stage.getPlayerSprite().setPosition(x-stage.getPlayerSprite().getWidth(),y+h/2-stage.getPlayerSprite().getHeight()/2);
|
||||
break;
|
||||
case "left":
|
||||
stage.GetPlayer().setPosition(x+w,y);
|
||||
stage.getPlayerSprite().setPosition(x+w,y+h/2-stage.getPlayerSprite().getHeight()/2);
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -56,7 +54,7 @@ public class EntryActor extends MapActor{
|
||||
}
|
||||
else
|
||||
{
|
||||
((TileMapScene)SceneType.TileMapScene.instance).loadNext(targetMap);
|
||||
TileMapScene.instance().loadNext(targetMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,14 @@ package forge.adventure.character;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
|
||||
import com.badlogic.gdx.graphics.g2d.ParticleEmitter;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
/**
|
||||
* Map Actor base class for Actors on the map
|
||||
@@ -13,9 +19,74 @@ import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
public class MapActor extends Actor {
|
||||
|
||||
|
||||
private boolean removeIfEffectsAreFinished;
|
||||
|
||||
public void removeAfterEffects() {
|
||||
removeIfEffectsAreFinished=true;
|
||||
}
|
||||
|
||||
static class CurrentEffect
|
||||
{
|
||||
public CurrentEffect(String path,ParticleEffect effect,Vector2 offset,boolean overlay)
|
||||
{
|
||||
this.path = path;
|
||||
this.effect=effect;
|
||||
this.offset=offset;
|
||||
this.overlay=overlay;
|
||||
}
|
||||
|
||||
private final String path;
|
||||
public ParticleEffect effect;
|
||||
public Vector2 offset;
|
||||
public boolean overlay=true;
|
||||
}
|
||||
|
||||
Texture debugTexture;
|
||||
protected float collisionHeight=1.0f;
|
||||
final int objectId;
|
||||
Array<CurrentEffect> effects=new Array<>();
|
||||
|
||||
public void removeEffect(String effectFly) {
|
||||
|
||||
for(int i=0;i<effects.size;i++)
|
||||
{
|
||||
CurrentEffect currentEffect =effects.get(i);
|
||||
if(currentEffect.path.equals(effectFly))
|
||||
{
|
||||
for(ParticleEmitter emitter:currentEffect.effect.getEmitters()) {
|
||||
emitter.setContinuous(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void playEffect(String path,float duration,boolean overlay,Vector2 offset)
|
||||
{
|
||||
ParticleEffect effect = new ParticleEffect();
|
||||
effect.load(Config.instance().getFile(path),Config.instance().getFile(path).parent());
|
||||
effects.add(new CurrentEffect(path, effect, offset, overlay));
|
||||
if(duration!=0)//ParticleEffect.setDuration uses an integer for some reason
|
||||
{
|
||||
for(ParticleEmitter emitter:effect.getEmitters()){
|
||||
emitter.setContinuous(false);
|
||||
emitter.duration = duration;
|
||||
emitter.durationTimer = 0.0F;
|
||||
}
|
||||
|
||||
}
|
||||
effect.start();
|
||||
}
|
||||
public void playEffect(String path,float duration,boolean overlay)
|
||||
{
|
||||
playEffect(path,duration,overlay,Vector2.Zero);
|
||||
}
|
||||
public void playEffect(String path,float duration)
|
||||
{
|
||||
playEffect(path,duration,true,Vector2.Zero);
|
||||
}
|
||||
public void playEffect(String path)
|
||||
{
|
||||
playEffect(path,0,true,Vector2.Zero);
|
||||
}
|
||||
public MapActor(int objectId)
|
||||
{
|
||||
this.objectId=objectId;
|
||||
@@ -27,7 +98,9 @@ public class MapActor extends Actor {
|
||||
private Texture getDebugTexture() {
|
||||
if (debugTexture == null) {
|
||||
Pixmap pixmap = new Pixmap((int) getWidth(), (int) getHeight(), Pixmap.Format.RGBA8888);
|
||||
pixmap.setColor(1.0f,0,0,0.5f);
|
||||
//pixmap.setColor(1.0f,0,0,0.5f);
|
||||
pixmap.setColor(MyRandom.getRandom().nextFloat(),MyRandom.getRandom().nextFloat(),MyRandom.getRandom().nextFloat(),0.5f);
|
||||
|
||||
pixmap.fillRectangle((int)(boundingRect.x - getX()), (int)(getHeight()- boundingRect.getHeight()) + (int)(boundingRect.y - getY()), (int)boundingRect.getWidth(), (int)boundingRect.getHeight());
|
||||
debugTexture = new Texture(pixmap);
|
||||
pixmap.dispose();
|
||||
@@ -51,7 +124,49 @@ public class MapActor extends Actor {
|
||||
public void draw(Batch batch, float alpha) {
|
||||
|
||||
if(boundDebug)
|
||||
{
|
||||
batch.draw(getDebugTexture(),getX(),getY());
|
||||
}
|
||||
|
||||
|
||||
|
||||
for(CurrentEffect effect:effects)
|
||||
{
|
||||
|
||||
if(effect.overlay)
|
||||
effect.effect.draw(batch);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void beforeDraw(Batch batch, float parentAlpha) {
|
||||
|
||||
for(CurrentEffect effect:effects)
|
||||
{
|
||||
if(!effect.overlay)
|
||||
effect.effect.draw(batch);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
super.act(delta);
|
||||
|
||||
|
||||
for(int i=0;i<effects.size;i++)
|
||||
{
|
||||
CurrentEffect effect=effects.get(i);
|
||||
effect.effect.update(delta);
|
||||
effect.effect.setPosition(getX()+getHeight()/2+effect.offset.x,getY()+getWidth()/2+effect.offset.y);
|
||||
if(effect.effect.isComplete())
|
||||
{
|
||||
effects.removeIndex(i);
|
||||
i--;
|
||||
effect.effect.dispose();
|
||||
}
|
||||
}
|
||||
if(effects.size==0&&removeIfEffectsAreFinished&&getParent()!=null)
|
||||
getParent().removeActor(this);
|
||||
|
||||
}
|
||||
@Override
|
||||
protected void positionChanged() {
|
||||
|
||||
@@ -11,7 +11,7 @@ import forge.adventure.util.Reward;
|
||||
*/
|
||||
|
||||
public class RewardSprite extends CharacterSprite {
|
||||
private final String default_reward = "[\n" +
|
||||
private final static String default_reward = "[\n" +
|
||||
"\t\t{\n" +
|
||||
"\t\t\t\"type\": \"gold\",\n" +
|
||||
"\t\t\t\"count\": 10,\n" +
|
||||
|
||||
@@ -3,7 +3,6 @@ package forge.adventure.character;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import forge.Forge;
|
||||
import forge.adventure.scene.RewardScene;
|
||||
import forge.adventure.scene.SceneType;
|
||||
import forge.adventure.stage.MapStage;
|
||||
import forge.adventure.util.Reward;
|
||||
|
||||
@@ -33,9 +32,9 @@ public class ShopActor extends MapActor{
|
||||
public void onPlayerCollide()
|
||||
{
|
||||
|
||||
stage.GetPlayer().stop();
|
||||
((RewardScene) SceneType.RewardScene.instance).loadRewards(rewardData, RewardScene.Type.Shop,this);
|
||||
Forge.switchScene(SceneType.RewardScene.instance);
|
||||
stage.getPlayerSprite().stop();
|
||||
RewardScene.instance().loadRewards(rewardData, RewardScene.Type.Shop,this);
|
||||
Forge.switchScene(RewardScene.instance());
|
||||
}
|
||||
|
||||
|
||||
|
||||
10
forge-gui-mobile/src/forge/adventure/data/ArenaData.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package forge.adventure.data;
|
||||
|
||||
public class ArenaData {
|
||||
|
||||
public String[] enemyPool;
|
||||
public int rounds;
|
||||
public int entryFee;
|
||||
public RewardData[][] rewards;
|
||||
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class BiomeSpriteData implements SaveFileContent {
|
||||
startArea=data.readDouble("startArea");
|
||||
endArea=data.readDouble("endArea");
|
||||
density=data.readDouble("density");
|
||||
resolution=data.readDouble("resolution");;
|
||||
resolution=data.readDouble("resolution");
|
||||
layer=data.readInt("layer");
|
||||
}
|
||||
|
||||
|
||||
@@ -45,10 +45,14 @@ public class BiomeStructureData {
|
||||
this.structureAtlasPath=biomeStructureData.structureAtlasPath;
|
||||
this.sourcePath=biomeStructureData.sourcePath;
|
||||
this.maskPath=biomeStructureData.maskPath;
|
||||
this.periodicInput=biomeStructureData.periodicInput;
|
||||
this.x=biomeStructureData.x;
|
||||
this.y=biomeStructureData.y;
|
||||
this.width=biomeStructureData.width;
|
||||
this.height=biomeStructureData.height;
|
||||
this.periodicOutput=biomeStructureData.periodicOutput;
|
||||
this.symmetry=biomeStructureData.symmetry;
|
||||
this.ground=biomeStructureData.ground;
|
||||
this.randomPosition=biomeStructureData.randomPosition;
|
||||
if(biomeStructureData.mappingInfo!=null)
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.badlogic.gdx.utils.ObjectMap;
|
||||
public class DifficultyData {
|
||||
public String name="";
|
||||
public int startingLife=10;
|
||||
public int startingMana=100;
|
||||
public int staringMoney=10;
|
||||
public float enemyLifeFactor=1;
|
||||
public boolean startingDifficulty;
|
||||
|
||||
@@ -65,7 +65,7 @@ public class EffectData implements Serializable {
|
||||
if(name != null && !name.isEmpty()) description += name + "\n";
|
||||
if(colorView) description += "Manasight.\n";
|
||||
if(lifeModifier != 0)
|
||||
description += "Life: " + ((lifeModifier > 0) ? "+" : "") + lifeModifier + "\n";
|
||||
description += "[+Life] " + ((lifeModifier > 0) ? "+" : "") + lifeModifier + "\n";
|
||||
if(startBattleWithCard != null && startBattleWithCard.length != 0)
|
||||
description+="Cards on battlefield: \n" + cardNames() + "\n";
|
||||
if(changeStartCards != 0)
|
||||
|
||||
@@ -42,6 +42,8 @@ public class EnemyData {
|
||||
life = enemyData.life;
|
||||
equipment = enemyData.equipment;
|
||||
colors = enemyData.colors;
|
||||
teamNumber = enemyData.teamNumber;
|
||||
nextEnemy =enemyData.nextEnemy==null?null: new EnemyData(enemyData.nextEnemy);
|
||||
if(enemyData.rewards == null) {
|
||||
rewards=null;
|
||||
} else {
|
||||
|
||||
@@ -23,19 +23,30 @@ public class ItemData {
|
||||
public String iconName;
|
||||
public boolean questItem=false;
|
||||
public int cost=1000;
|
||||
|
||||
public boolean usableOnWorldMap;
|
||||
public boolean usableInPoi;
|
||||
public String commandOnUse;
|
||||
public int manaNeeded;
|
||||
|
||||
|
||||
public ItemData()
|
||||
{
|
||||
|
||||
}
|
||||
public ItemData(ItemData cpy)
|
||||
{
|
||||
name = cpy.name ;
|
||||
equipmentSlot = cpy.equipmentSlot;
|
||||
effect = new EffectData(cpy.effect);
|
||||
description = cpy.description ;
|
||||
iconName = cpy.iconName ;
|
||||
questItem = cpy.questItem ;
|
||||
cost = cpy.cost ;
|
||||
name = cpy.name;
|
||||
equipmentSlot = cpy.equipmentSlot;
|
||||
effect = new EffectData(cpy.effect);
|
||||
description = cpy.description;
|
||||
iconName = cpy.iconName;
|
||||
questItem = cpy.questItem;
|
||||
cost = cpy.cost;
|
||||
usableInPoi = cpy.usableInPoi;
|
||||
usableOnWorldMap = cpy.usableOnWorldMap;
|
||||
commandOnUse = cpy.commandOnUse;
|
||||
manaNeeded = cpy.manaNeeded;
|
||||
}
|
||||
|
||||
public Sprite sprite()
|
||||
@@ -54,7 +65,7 @@ public class ItemData {
|
||||
Json json = new Json();
|
||||
FileHandle handle = Config.instance().getFile(Paths.ITEMS);
|
||||
if (handle.exists()) {
|
||||
Array readJson = json.fromJson(Array.class, ItemData.class, handle);
|
||||
Array<ItemData> readJson = json.fromJson(Array.class, ItemData.class, handle);
|
||||
itemList = readJson;
|
||||
|
||||
}
|
||||
@@ -79,6 +90,8 @@ public class ItemData {
|
||||
result += "Slot: " + this.equipmentSlot + "\n";
|
||||
if(effect != null)
|
||||
result += effect.getDescription();
|
||||
if(manaNeeded != 0)
|
||||
result += manaNeeded+" [+Mana]";
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@ public class PointOfInterestData {
|
||||
public String sprite;
|
||||
public String map;
|
||||
public float radiusFactor;
|
||||
public float offsetX=0f;
|
||||
public float offsetY=0f;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -55,5 +58,7 @@ public class PointOfInterestData {
|
||||
sprite=other.sprite;
|
||||
map=other.map;
|
||||
radiusFactor=other.radiusFactor;
|
||||
offsetX=other.offsetX;
|
||||
offsetY=other.offsetY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public class RewardData {
|
||||
public int addMaxCount;
|
||||
public String cardName;
|
||||
public String itemName;
|
||||
public String[] itemNames;
|
||||
public String[] editions;
|
||||
public String[] colors;
|
||||
public String[] rarity;
|
||||
@@ -51,6 +52,7 @@ public class RewardData {
|
||||
addMaxCount =rewardData.addMaxCount;
|
||||
cardName =rewardData.cardName;
|
||||
itemName =rewardData.itemName;
|
||||
itemNames =rewardData.itemNames==null?null:rewardData.itemNames.clone();
|
||||
editions =rewardData.editions==null?null:rewardData.editions.clone();
|
||||
colors =rewardData.colors==null?null:rewardData.colors.clone();
|
||||
rarity =rewardData.rarity==null?null:rewardData.rarity.clone();
|
||||
@@ -67,10 +69,12 @@ public class RewardData {
|
||||
private static Iterable<PaperCard> allCards;
|
||||
private static Iterable<PaperCard> allEnemyCards;
|
||||
|
||||
private void initializeAllCards(){
|
||||
static private void initializeAllCards(){
|
||||
RewardData legals = Config.instance().getConfigData().legalCards;
|
||||
if(legals==null) allCards = FModel.getMagicDb().getCommonCards().getUniqueCardsNoAltNoOnline();
|
||||
else allCards = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCardsNoAltNoOnline(), new CardUtil.CardPredicate(legals, true));
|
||||
if(legals==null)
|
||||
allCards = FModel.getMagicDb().getCommonCards().getUniqueCardsNoAlt();
|
||||
else
|
||||
allCards = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCardsNoAlt(), new CardUtil.CardPredicate(legals, true));
|
||||
//Filter out specific cards.
|
||||
allCards = Iterables.filter(allCards, new Predicate<PaperCard>() {
|
||||
@Override
|
||||
@@ -90,7 +94,7 @@ public class RewardData {
|
||||
});
|
||||
}
|
||||
|
||||
public Iterable<PaperCard> getAllCards() {
|
||||
static public Iterable<PaperCard> getAllCards() {
|
||||
if(allCards == null) initializeAllCards();
|
||||
return allCards;
|
||||
}
|
||||
@@ -134,7 +138,13 @@ public class RewardData {
|
||||
}
|
||||
break;
|
||||
case "item":
|
||||
if(itemName!=null&&!itemName.isEmpty()) {
|
||||
if(itemNames!=null)
|
||||
{
|
||||
for(int i=0;i<count+addedCount;i++) {
|
||||
ret.add(new Reward(ItemData.getItem(itemNames[WorldSave.getCurrentSave().getWorld().getRandom().nextInt(itemNames.length)])));
|
||||
}
|
||||
}
|
||||
else if(itemName!=null&&!itemName.isEmpty()) {
|
||||
for(int i=0;i<count+addedCount;i++) {
|
||||
ret.add(new Reward(ItemData.getItem(itemName)));
|
||||
}
|
||||
@@ -152,6 +162,9 @@ public class RewardData {
|
||||
case "life":
|
||||
ret.add(new Reward(Reward.Type.Life, count + addedCount));
|
||||
break;
|
||||
case "mana":
|
||||
ret.add(new Reward(Reward.Type.Mana, count + addedCount));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -24,6 +24,7 @@ public class WorldData implements Serializable {
|
||||
public float playerStartPosY;
|
||||
public float noiseZoomBiome;
|
||||
public int tileSize;
|
||||
public int miniMapTileSize;
|
||||
public BiomeData roadTileset;
|
||||
public String biomesSprites;
|
||||
public float maxRoadDistance;
|
||||
|
||||
@@ -50,6 +50,8 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
private int gold = 0;
|
||||
private int maxLife= 20;
|
||||
private int life = 20;
|
||||
private int maxMana= 100;
|
||||
private int mana = 100;
|
||||
private EffectData blessing; //Blessing to apply for next battle.
|
||||
private final PlayerStatistic statistic = new PlayerStatistic();
|
||||
private final Map<String, Byte> questFlags = new HashMap<>();
|
||||
@@ -64,11 +66,12 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
private boolean announceCustom = false;
|
||||
|
||||
// Signals
|
||||
SignalList onLifeTotalChangeList = new SignalList();
|
||||
SignalList onGoldChangeList = new SignalList();
|
||||
SignalList onPlayerChangeList = new SignalList();
|
||||
SignalList onEquipmentChange = new SignalList();
|
||||
SignalList onBlessing = new SignalList();
|
||||
final SignalList onLifeTotalChangeList = new SignalList();
|
||||
final SignalList onManaTotalChangeList = new SignalList();
|
||||
final SignalList onGoldChangeList = new SignalList();
|
||||
final SignalList onPlayerChangeList = new SignalList();
|
||||
final SignalList onEquipmentChange = new SignalList();
|
||||
final SignalList onBlessing = new SignalList();
|
||||
|
||||
public AdventurePlayer() { clear(); }
|
||||
|
||||
@@ -90,6 +93,8 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
gold = 0;
|
||||
maxLife = 20;
|
||||
life = 20;
|
||||
maxMana = 10;
|
||||
mana = 10;
|
||||
clearDecks();
|
||||
inventoryItems.clear();
|
||||
equippedItems.clear();
|
||||
@@ -134,10 +139,12 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
setColorIdentity(DeckProxy.getColorIdentity(deck));
|
||||
|
||||
life = maxLife = difficultyData.startingLife;
|
||||
mana = maxMana = difficultyData.startingMana;
|
||||
|
||||
inventoryItems.addAll(difficultyData.startItems);
|
||||
onGoldChangeList.emit();
|
||||
onLifeTotalChangeList.emit();
|
||||
onManaTotalChangeList.emit();
|
||||
}
|
||||
|
||||
public void setSelectedDeckSlot(int slot) {
|
||||
@@ -149,6 +156,8 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
}
|
||||
public void updateDifficulty(DifficultyData diff) {
|
||||
maxLife = diff.startingLife;
|
||||
maxMana = diff.startingMana;
|
||||
this.difficultyData.startingMana = diff.startingMana;
|
||||
this.difficultyData.startingLife = diff.startingLife;
|
||||
this.difficultyData.staringMoney = diff.staringMoney;
|
||||
this.difficultyData.startingDifficulty = diff.startingDifficulty;
|
||||
@@ -171,6 +180,8 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
public int getGold() { return gold; }
|
||||
public int getLife() { return life; }
|
||||
public int getMaxLife() { return maxLife; }
|
||||
public int getMana() { return mana; }
|
||||
public int getMaxMana() { return maxMana; }
|
||||
public @Null EffectData getBlessing() { return blessing; }
|
||||
|
||||
public Collection<String> getEquippedItems() { return equippedItems.values(); }
|
||||
@@ -229,6 +240,8 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
gold = data.readInt("gold");
|
||||
maxLife = data.readInt("maxLife");
|
||||
life = data.readInt("life");
|
||||
maxMana = data.containsKey("maxMana")?data.readInt("maxMana"):100;
|
||||
mana = data.containsKey("mana")?data.readInt("mana"):100;
|
||||
worldPosX = data.readFloat("worldPosX");
|
||||
worldPosY = data.readFloat("worldPosY");
|
||||
|
||||
@@ -297,6 +310,7 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
announceCustom = data.containsKey("announceCustom") ? data.readBool("announceCustom") : false;
|
||||
|
||||
onLifeTotalChangeList.emit();
|
||||
onManaTotalChangeList.emit();
|
||||
onGoldChangeList.emit();
|
||||
onBlessing.emit();
|
||||
}
|
||||
@@ -329,6 +343,8 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
data.store("gold",gold);
|
||||
data.store("life",life);
|
||||
data.store("maxLife",maxLife);
|
||||
data.store("mana",mana);
|
||||
data.store("maxMana",maxMana);
|
||||
data.store("deckName",deck.getName());
|
||||
|
||||
data.storeObject("inventory",inventoryItems.toArray(String.class));
|
||||
@@ -401,6 +417,9 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
case Life:
|
||||
addMaxLife(reward.getCount());
|
||||
break;
|
||||
case Mana:
|
||||
addMaxMana(reward.getCount());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,6 +427,10 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
gold+=goldCount;
|
||||
onGoldChangeList.emit();
|
||||
}
|
||||
public void onManaChange(Runnable o) {
|
||||
onManaTotalChangeList.add(o);
|
||||
o.run();
|
||||
}
|
||||
|
||||
public void onLifeChange(Runnable o) {
|
||||
onLifeTotalChangeList.add(o);
|
||||
@@ -435,7 +458,7 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
|
||||
public boolean fullHeal() {
|
||||
if (life < maxLife) {
|
||||
life = Math.max(maxLife, life);
|
||||
life = maxLife;
|
||||
onLifeTotalChangeList.emit();
|
||||
return true;
|
||||
}
|
||||
@@ -458,21 +481,41 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
return 200 + (int)(50 * getStatistic().winLossRatio());
|
||||
}
|
||||
|
||||
public void addMana(int addedValue) {
|
||||
mana = Math.min(maxMana,Math.max(mana + addedValue, 0));
|
||||
onManaTotalChangeList.emit();
|
||||
}
|
||||
public void addManaPercent(float percent) {
|
||||
mana = Math.min(mana + (int)(maxMana*percent), maxMana);
|
||||
onManaTotalChangeList.emit();
|
||||
}
|
||||
public void heal(int amount) {
|
||||
life = Math.min(life + amount, maxLife);
|
||||
onLifeTotalChangeList.emit();
|
||||
}
|
||||
public void heal(float percent) {
|
||||
life = Math.min(life + (int)(maxLife*percent), maxLife);
|
||||
onLifeTotalChangeList.emit();
|
||||
}
|
||||
public void defeated() {
|
||||
gold= (int) (gold-(gold*difficultyData.goldLoss));
|
||||
life=Math.max(1,(int)(life-(maxLife*difficultyData.lifeLoss)));
|
||||
onLifeTotalChangeList.emit();
|
||||
onGoldChangeList.emit();
|
||||
}
|
||||
public void win() {
|
||||
Current.player().addManaPercent(0.1f);
|
||||
}
|
||||
public void addMaxLife(int count) {
|
||||
maxLife += count;
|
||||
life += count;
|
||||
onLifeTotalChangeList.emit();
|
||||
}
|
||||
public void addMaxMana(int count) {
|
||||
maxMana += count;
|
||||
mana += count;
|
||||
onManaTotalChangeList.emit();
|
||||
}
|
||||
public void giveGold(int price) {
|
||||
takeGold(-price);
|
||||
}
|
||||
@@ -646,4 +689,5 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
public void resetQuestFlags(){
|
||||
questFlags.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.HashSet;
|
||||
public class PointOfInterestChanges implements SaveFileContent {
|
||||
private final HashSet<Integer> deletedObjects=new HashSet<>();
|
||||
private final HashMap<Integer, HashSet<Integer>> cardsBought = new HashMap<>();
|
||||
private java.util.Map<String, Byte> mapFlags = new HashMap<>();
|
||||
private final java.util.Map<String, Byte> mapFlags = new HashMap<>();
|
||||
|
||||
public static class Map extends HashMap<String,PointOfInterestChanges> implements SaveFileContent {
|
||||
@Override
|
||||
|
||||
@@ -97,7 +97,7 @@ import java.util.Map;
|
||||
private final FLabel btnMoreOptions = deckHeader.add(new FLabel.Builder().text("...").font(FSkinFont.get(20)).align(Align.center).pressedColor(Header.BTN_PRESSED_COLOR).build());
|
||||
|
||||
|
||||
boolean isShop=false;
|
||||
boolean isShop;
|
||||
public AdventureDeckEditor(boolean createAsShop) {
|
||||
super(e -> leave(),getPages());
|
||||
|
||||
|
||||
371
forge-gui-mobile/src/forge/adventure/scene/ArenaScene.java
Normal file
@@ -0,0 +1,371 @@
|
||||
package forge.adventure.scene;
|
||||
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.character.EnemySprite;
|
||||
import forge.adventure.data.ArenaData;
|
||||
import forge.adventure.data.WorldData;
|
||||
import forge.adventure.stage.GameHUD;
|
||||
import forge.adventure.stage.IAfterMatch;
|
||||
import forge.adventure.stage.WorldStage;
|
||||
import forge.adventure.util.*;
|
||||
import forge.gui.FThreads;
|
||||
import forge.screens.TransitionScreen;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Displays the rewards of a fight or a treasure
|
||||
*/
|
||||
public class ArenaScene extends UIScene implements IAfterMatch {
|
||||
private static ArenaScene object;
|
||||
private final float gridSize;
|
||||
private ArenaData arenaData;
|
||||
private final TextraButton startButton;
|
||||
|
||||
public static ArenaScene instance() {
|
||||
if(object==null)
|
||||
object=new ArenaScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
private final TextraButton doneButton;
|
||||
Dialog startDialog;
|
||||
Dialog areYouSureDialog;
|
||||
private final TextraLabel goldLabel;
|
||||
|
||||
private final Group arenaPlane;
|
||||
private final Random rand=new Random();
|
||||
|
||||
final Sprite fighterSpot;
|
||||
final Sprite lostOverlay;
|
||||
final Sprite up;
|
||||
final Sprite upWin;
|
||||
final Sprite side;
|
||||
final Sprite sideWin;
|
||||
final Sprite edge;
|
||||
final Sprite edgeM;
|
||||
final Sprite edgeWin;
|
||||
final Sprite edgeWinM;
|
||||
boolean arenaStarted=false;
|
||||
private ArenaScene() {
|
||||
super(Forge.isLandscapeMode() ? "ui/arena.json" : "ui/arena_portrait.json");
|
||||
|
||||
|
||||
|
||||
TextureAtlas atlas=Config.instance().getAtlas(Paths.ARENA_ATLAS);
|
||||
fighterSpot=atlas.createSprite("Spot");
|
||||
lostOverlay=atlas.createSprite("Lost");
|
||||
up=atlas.createSprite("Up");
|
||||
upWin=atlas.createSprite("UpWin");
|
||||
side=atlas.createSprite("Side");
|
||||
sideWin=atlas.createSprite("SideWin");
|
||||
edge=atlas.createSprite("Edge");
|
||||
edgeM=atlas.createSprite("Edge");
|
||||
edgeM.setFlip(true,false);
|
||||
edgeWin=atlas.createSprite("EdgeWin");
|
||||
edgeWinM=atlas.createSprite("EdgeWin");
|
||||
edgeWinM.setFlip(true,false);
|
||||
gridSize=fighterSpot.getRegionWidth();
|
||||
|
||||
goldLabel=ui.findActor("gold");
|
||||
ui.onButtonPress("done", () -> {
|
||||
if(!arenaStarted)
|
||||
ArenaScene.this.done();
|
||||
else
|
||||
areYouSureDialog.show(stage);
|
||||
});
|
||||
ui.onButtonPress("start", () -> startButton());
|
||||
doneButton = ui.findActor("done");
|
||||
ScrollPane pane= ui.findActor("arena");
|
||||
arenaPlane=new Table();
|
||||
pane.setActor(arenaPlane);
|
||||
|
||||
startButton=ui.findActor("start");
|
||||
|
||||
startDialog = new Dialog(Forge.getLocalizer().getMessage("lblStart"), Controls.getSkin())
|
||||
{
|
||||
protected void result(Object object)
|
||||
{
|
||||
if(object!=null&&object.equals(true))
|
||||
startArena();
|
||||
startDialog.hide();
|
||||
}
|
||||
};
|
||||
startDialog.text("Do you want to go into the Arena?");
|
||||
startDialog.button(Forge.getLocalizer().getMessage("lblYes"), true);
|
||||
startDialog.button(Forge.getLocalizer().getMessage("lblNo"), false);
|
||||
ui.addActor(startDialog);
|
||||
startDialog.hide();
|
||||
startDialog.getColor().a = 0;
|
||||
|
||||
|
||||
areYouSureDialog= new Dialog(Forge.getLocalizer().getMessage("lblConcedeTitle"), Controls.getSkin())
|
||||
{
|
||||
protected void result(Object object)
|
||||
{
|
||||
if(object!=null&&object.equals(true))
|
||||
loose();
|
||||
startDialog.hide();
|
||||
}
|
||||
};
|
||||
areYouSureDialog.text(Forge.getLocalizer().getMessage("lblConcedeCurrentGame"));
|
||||
areYouSureDialog.button(Forge.getLocalizer().getMessage("lblYes"), true);
|
||||
areYouSureDialog.button(Forge.getLocalizer().getMessage("lblNo"), false);
|
||||
ui.addActor(areYouSureDialog);
|
||||
areYouSureDialog.hide();
|
||||
areYouSureDialog.getColor().a = 0;
|
||||
}
|
||||
|
||||
private void loose() {
|
||||
doneButton.setText(Forge.getLocalizer().getMessage("lblLeave"));
|
||||
startButton.setDisabled(true);
|
||||
arenaStarted=false;
|
||||
}
|
||||
|
||||
private void startButton() {
|
||||
if(roundsWon ==0)
|
||||
{
|
||||
startDialog.show(stage);
|
||||
}
|
||||
else
|
||||
{
|
||||
startRound();
|
||||
}
|
||||
}
|
||||
|
||||
int roundsWon =0;
|
||||
private void startArena() {
|
||||
goldLabel.setVisible(false);
|
||||
arenaStarted=true;
|
||||
startButton.setText(Forge.getLocalizer().getMessage("lblContinue"));
|
||||
doneButton.setText(Forge.getLocalizer().getMessage("lblConcede"));
|
||||
Forge.setCursor(null, Forge.magnifyToggle ? "1" : "2");
|
||||
Current.player().takeGold(arenaData.entryFee);
|
||||
startRound();
|
||||
}
|
||||
@Override
|
||||
public void setWinner(boolean winner) {
|
||||
Array<Actor> winners=new Array<>();
|
||||
Array<EnemySprite> winnersEnemies=new Array<>();
|
||||
for(int i=0;i<fighters.size-2;i+=2)
|
||||
{
|
||||
boolean leftWon=rand.nextBoolean();
|
||||
if(leftWon)
|
||||
{
|
||||
winners.add(fighters.get(i));
|
||||
winnersEnemies.add(enemies.get(i));
|
||||
moveFighter(fighters.get(i),true);
|
||||
markLostFighter(fighters.get(i+1));
|
||||
}
|
||||
else
|
||||
{
|
||||
markLostFighter(fighters.get(i));
|
||||
moveFighter(fighters.get(i+1),false);
|
||||
winners.add(fighters.get(i+1));
|
||||
winnersEnemies.add(enemies.get(i+1));
|
||||
}
|
||||
}
|
||||
if(winner)
|
||||
{
|
||||
markLostFighter(fighters.get(fighters.size-2));
|
||||
moveFighter(fighters.get(fighters.size-1),false);
|
||||
winners.add(fighters.get(fighters.size-1));
|
||||
roundsWon++;
|
||||
}
|
||||
else
|
||||
{
|
||||
markLostFighter(fighters.get(fighters.size-1));
|
||||
moveFighter(fighters.get(fighters.size-2),true);
|
||||
winners.add(fighters.get(fighters.size-2));
|
||||
loose();
|
||||
}
|
||||
|
||||
fighters=winners;
|
||||
enemies=winnersEnemies;
|
||||
if(roundsWon >=arenaData.rounds )
|
||||
{
|
||||
arenaStarted=false;
|
||||
startButton.setDisabled(true);
|
||||
doneButton.setText(Forge.getLocalizer().getMessage("lblDone"));
|
||||
}
|
||||
}
|
||||
|
||||
private void moveFighter(Actor actor, boolean leftPlayer) {
|
||||
|
||||
Image spotImg=new Image(upWin);
|
||||
double stepsToTheSide=Math.pow(2, roundsWon);
|
||||
float widthDiff=actor.getWidth()-spotImg.getWidth();
|
||||
spotImg.setPosition(actor.getX()+widthDiff/2,actor.getY()+gridSize+widthDiff/2);
|
||||
arenaPlane.addActor(spotImg);
|
||||
for(int i=0;i<stepsToTheSide;i++)
|
||||
{
|
||||
Image leftImg;
|
||||
if(i==0)
|
||||
leftImg=new Image(leftPlayer?edgeWin:edgeWinM);
|
||||
else
|
||||
leftImg=new Image(sideWin);
|
||||
leftImg.setPosition(actor.getX()+(i*(leftPlayer?1:-1))*gridSize+widthDiff/2,actor.getY()+gridSize*2+widthDiff/2);
|
||||
arenaPlane.addActor(leftImg);
|
||||
}
|
||||
|
||||
|
||||
actor.moveBy((float) (gridSize*stepsToTheSide*(leftPlayer?1:-1)),gridSize*2f);
|
||||
}
|
||||
|
||||
private void markLostFighter(Actor fighter) {
|
||||
|
||||
Image lost=new Image(lostOverlay);
|
||||
float widthDiff=fighter.getWidth()-lost.getWidth();
|
||||
lost.setPosition(fighter.getX()+widthDiff/2,fighter.getY()+widthDiff/2);
|
||||
arenaPlane.addActor(lost);
|
||||
}
|
||||
|
||||
private void startRound() {
|
||||
DuelScene duelScene = DuelScene.instance();
|
||||
FThreads.invokeInEdtNowOrLater(() -> {
|
||||
Forge.setTransitionScreen(new TransitionScreen(() -> {
|
||||
duelScene.initDuels(WorldStage.getInstance().getPlayerSprite(), enemies.get(enemies.size-1));
|
||||
Forge.clearTransitionScreen();
|
||||
Forge.switchScene(DuelScene.instance());
|
||||
}, Forge.takeScreenshot(), true, false));
|
||||
});
|
||||
}
|
||||
|
||||
public boolean start() {
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public boolean done() {
|
||||
GameHUD.getInstance().getTouchpad().setVisible(false);
|
||||
Forge.switchToLast();
|
||||
if(roundsWon !=0)
|
||||
{
|
||||
Array<Reward> data=new Array<>();
|
||||
for(int i = 0; i< roundsWon; i++)
|
||||
{
|
||||
for(int j=0;j<arenaData.rewards[i].length;j++)
|
||||
{
|
||||
data.addAll(arenaData.rewards[i][j].generate(false, null ));
|
||||
}
|
||||
}
|
||||
RewardScene.instance().loadRewards(data, RewardScene.Type.Loot, null);
|
||||
Forge.switchScene(RewardScene.instance());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
stage.act(delta);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keycode) {
|
||||
if (keycode == Input.Keys.ESCAPE || keycode == Input.Keys.BACK) {
|
||||
done();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Array<EnemySprite> enemies = new Array<>();
|
||||
Array<Actor> fighters = new Array<>();
|
||||
Actor player;
|
||||
|
||||
public void loadArenaData(ArenaData data,long seed) {
|
||||
startButton.setText(Forge.getLocalizer().getMessage("lblStart"));
|
||||
doneButton.setText(Forge.getLocalizer().getMessage("lblDone"));
|
||||
arenaData=data;
|
||||
//rand.setSeed(seed); allow to reshuffle arena enemies for now
|
||||
|
||||
enemies.clear();
|
||||
fighters.clear();
|
||||
arenaPlane.clear();
|
||||
roundsWon =0;
|
||||
int numberOfEnemies= (int) (Math.pow(2f, data.rounds)-1);
|
||||
|
||||
|
||||
for(int i=0;i<numberOfEnemies;i++)
|
||||
{
|
||||
EnemySprite enemy=new EnemySprite(WorldData.getEnemy(data.enemyPool[rand.nextInt(data.enemyPool.length)]));
|
||||
enemies.add(enemy);
|
||||
fighters.add(new Image(enemy.getAvatar()));
|
||||
}
|
||||
fighters.add(new Image(Current.player().avatar()));
|
||||
player=fighters.get(fighters.size-1);
|
||||
|
||||
|
||||
goldLabel.setText(data.entryFee +" [+Gold]");
|
||||
goldLabel.setVisible(true);
|
||||
|
||||
startButton.setDisabled(data.entryFee>Current.player().getGold());
|
||||
int currentSpots=numberOfEnemies+1;
|
||||
int gridWidth=currentSpots*2;
|
||||
int gridHeight=data.rounds+1;
|
||||
arenaPlane.setSize(gridWidth*gridSize,gridHeight*gridSize*2);
|
||||
int fighterIndex=0;
|
||||
for(int x=0;x<gridWidth;x++)
|
||||
{
|
||||
for(int y=0;y<gridHeight;y++)
|
||||
{
|
||||
if(x % Math.pow(2,y+1) == Math.pow(2,y))
|
||||
{
|
||||
if(y==0)
|
||||
{
|
||||
if(fighterIndex<fighters.size)
|
||||
{
|
||||
float widthDiff=gridSize-fighters.get(fighterIndex).getWidth();
|
||||
fighters.get(fighterIndex).setPosition(x*gridSize+widthDiff/2,y*gridSize*2+widthDiff/2);
|
||||
arenaPlane.addActor(fighters.get(fighterIndex));
|
||||
fighterIndex++;
|
||||
}
|
||||
}
|
||||
Image spotImg=new Image(fighterSpot);
|
||||
spotImg.setPosition(x*gridSize,y*gridSize*2);
|
||||
arenaPlane.addActor(spotImg);
|
||||
|
||||
if(y!=gridHeight-1)
|
||||
{
|
||||
Image upImg=new Image(up);
|
||||
upImg.setPosition(x*gridSize,y*gridSize*2+gridSize);
|
||||
arenaPlane.addActor(upImg);
|
||||
}
|
||||
if(y!=0)
|
||||
{
|
||||
for(int i=0;i<Math.pow(2,(y-1));i++)
|
||||
{
|
||||
Image leftImg;
|
||||
Image rightImg;
|
||||
if(i==Math.pow(2,(y-1))-1)
|
||||
{
|
||||
leftImg=new Image(edge);
|
||||
rightImg=new Image(edgeM);
|
||||
}
|
||||
else
|
||||
{
|
||||
leftImg=new Image(side);
|
||||
rightImg=new Image(side);
|
||||
}
|
||||
leftImg.setPosition((x-(i+1))*gridSize,y*gridSize*2);
|
||||
rightImg.setPosition((x+(i+1))*gridSize,y*gridSize*2);
|
||||
arenaPlane.addActor(leftImg);
|
||||
arenaPlane.addActor(rightImg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,10 +12,19 @@ public class DeckEditScene extends ForgeScene {
|
||||
AdventureDeckEditor screen;
|
||||
Stage stage;
|
||||
|
||||
public DeckEditScene() {
|
||||
private DeckEditScene() {
|
||||
|
||||
}
|
||||
|
||||
private static DeckEditScene object;
|
||||
|
||||
public static DeckEditScene getInstance() {
|
||||
if(object==null)
|
||||
object=new DeckEditScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (stage != null)
|
||||
|
||||
@@ -7,28 +7,75 @@ import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.IntMap;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.player.AdventurePlayer;
|
||||
import forge.adventure.util.Controls;
|
||||
import forge.adventure.util.Current;
|
||||
|
||||
public class DeckSelectScene extends UIScene {
|
||||
private final IntMap<TextButton> buttons = new IntMap<>();
|
||||
private final IntMap<TextraButton> buttons = new IntMap<>();
|
||||
Color defColor;
|
||||
Dialog dialog;
|
||||
TextField textInput;
|
||||
Table layout;
|
||||
Label header;
|
||||
TextButton back, edit, rename, dialogRenameBtn, dialogAbortBtn;
|
||||
TextraLabel header;
|
||||
TextraButton back, edit, rename, dialogRenameBtn, dialogAbortBtn;
|
||||
int currentSlot = 0;
|
||||
ScrollPane scrollPane;
|
||||
|
||||
private static DeckSelectScene object;
|
||||
|
||||
public static DeckSelectScene instance() {
|
||||
if(object==null)
|
||||
object=new DeckSelectScene();
|
||||
return object;
|
||||
}
|
||||
public DeckSelectScene() {
|
||||
super(Forge.isLandscapeMode() ? "ui/deck_selector.json" : "ui/deck_selector_portrait.json");
|
||||
|
||||
layout = new Table();
|
||||
stage.addActor(layout);
|
||||
|
||||
header = Controls.newTextraLabel(Forge.getLocalizer().getMessage("lblSelectYourDeck"));
|
||||
layout.add(header).colspan(2).align(Align.center).pad(2, 5, 2, 5);
|
||||
layout.row();
|
||||
for (int i = 0; i < AdventurePlayer.NUMBER_OF_DECKS; i++)
|
||||
addDeckSlot(Forge.getLocalizer().getMessage("lblDeck")+": " + (i + 1), i);
|
||||
|
||||
dialog = Controls.newDialog(Forge.getLocalizer().getMessage("lblSave"));
|
||||
textInput = Controls.newTextField("");
|
||||
dialog.getButtonTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblNameYourSaveFile"))).colspan(2);
|
||||
dialog.getButtonTable().row();
|
||||
dialog.getButtonTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblName")+": ")).align(Align.left);
|
||||
dialog.getButtonTable().add(textInput).fillX().expandX();
|
||||
dialog.getButtonTable().row();
|
||||
dialogRenameBtn = Controls.newTextButton(Forge.getLocalizer().getMessage("lblRename"), () -> DeckSelectScene.this.rename());
|
||||
dialog.getButtonTable().add(dialogRenameBtn).align(Align.left).padLeft(15);
|
||||
dialogAbortBtn = Controls.newTextButton(Forge.getLocalizer().getMessage("lblAbort"), () -> dialog.hide());
|
||||
dialog.getButtonTable().add(dialogAbortBtn).align(Align.right).padRight(15);
|
||||
dialog.getColor().a = 0f;
|
||||
dialog.hide();
|
||||
|
||||
back = ui.findActor("return");
|
||||
edit = ui.findActor("edit");
|
||||
rename = ui.findActor("rename");
|
||||
ui.onButtonPress("return", () -> DeckSelectScene.this.back());
|
||||
ui.onButtonPress("edit", () -> DeckSelectScene.this.edit());
|
||||
ui.onButtonPress("rename", () -> {
|
||||
textInput.setText(Current.player().getSelectedDeck().getName());
|
||||
dialog.show(stage);
|
||||
selectActor(textInput, false);
|
||||
});
|
||||
defColor = ui.findActor("return").getColor();
|
||||
|
||||
scrollPane = ui.findActor("deckSlots");
|
||||
scrollPane.setActor(layout);
|
||||
}
|
||||
|
||||
private TextButton addDeckSlot(String name, int i) {
|
||||
TextButton button = Controls.newTextButton("-");
|
||||
private TextraButton addDeckSlot(String name, int i) {
|
||||
TextraButton button = Controls.newTextButton("-");
|
||||
button.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
@@ -55,13 +102,12 @@ public class DeckSelectScene extends UIScene {
|
||||
public boolean select(int slot) {
|
||||
currentSlot = slot;
|
||||
|
||||
for (IntMap.Entry<TextButton> butt : new IntMap.Entries<TextButton>(buttons)) {
|
||||
for (IntMap.Entry<TextraButton> butt : new IntMap.Entries<TextraButton>(buttons)) {
|
||||
butt.value.setColor(defColor);
|
||||
}
|
||||
if (buttons.containsKey(slot)) {
|
||||
TextButton button = buttons.get(slot);
|
||||
TextraButton button = buttons.get(slot);
|
||||
button.setColor(Color.RED);
|
||||
selectActor(button, false);
|
||||
}
|
||||
Current.player().setSelectedDeckSlot(slot);
|
||||
|
||||
@@ -74,85 +120,6 @@ public class DeckSelectScene extends UIScene {
|
||||
if (keycode == Input.Keys.ESCAPE || keycode == Input.Keys.BACK) {
|
||||
back();
|
||||
}
|
||||
if (kbVisible) {
|
||||
if (keycode == Input.Keys.BUTTON_START)
|
||||
keyOK();
|
||||
else if (keycode == Input.Keys.BUTTON_L1)
|
||||
toggleShiftOrBackspace(true);
|
||||
else if (keycode == Input.Keys.BUTTON_R1)
|
||||
toggleShiftOrBackspace(false);
|
||||
else if (keycode == Input.Keys.BUTTON_B)
|
||||
hideOnScreenKeyboard();
|
||||
else if (keycode == Input.Keys.BUTTON_A) {
|
||||
if (selectedKey != null)
|
||||
performTouch(selectedKey);
|
||||
} else if (keycode == Input.Keys.DPAD_UP || keycode == Input.Keys.DPAD_DOWN || keycode == Input.Keys.DPAD_LEFT || keycode == Input.Keys.DPAD_RIGHT)
|
||||
setSelectedKey(keycode);
|
||||
} else if (dialog.getColor().a == 1f) {
|
||||
if (keycode == Input.Keys.BUTTON_A) {
|
||||
if (selectedActor == textInput) {
|
||||
lastInputField = textInput;
|
||||
showOnScreenKeyboard(textInput.getText());
|
||||
} else if (selectedActor == dialogAbortBtn || selectedActor == dialogRenameBtn) {
|
||||
performTouch(selectedActor);
|
||||
select(Current.player().getSelectedDeckIndex());
|
||||
}
|
||||
} else if (keycode == Input.Keys.BUTTON_B) {
|
||||
performTouch(dialogAbortBtn);
|
||||
select(Current.player().getSelectedDeckIndex());
|
||||
}
|
||||
else if (keycode == Input.Keys.DPAD_DOWN) {
|
||||
if (selectedActor == null) {
|
||||
selectActor(textInput, false);
|
||||
} else if (selectedActor == textInput)
|
||||
selectActor(dialogRenameBtn, false);
|
||||
} else if (keycode == Input.Keys.DPAD_UP) {
|
||||
if (selectedActor == null)
|
||||
selectActor(dialogRenameBtn, false);
|
||||
else if (selectedActor == dialogRenameBtn || selectedActor == dialogAbortBtn) {
|
||||
selectActor(textInput, false);
|
||||
}
|
||||
} else if (keycode == Input.Keys.DPAD_LEFT) {
|
||||
if (selectedActor == dialogAbortBtn)
|
||||
selectActor(dialogRenameBtn, false);
|
||||
} else if (keycode == Input.Keys.DPAD_RIGHT) {
|
||||
if (selectedActor == dialogRenameBtn)
|
||||
selectActor(dialogAbortBtn, false);
|
||||
}
|
||||
} else {
|
||||
if (keycode == Input.Keys.BUTTON_B)
|
||||
performTouch(back);
|
||||
else if (keycode == Input.Keys.BUTTON_Y)
|
||||
performTouch(rename);
|
||||
else if (keycode == Input.Keys.BUTTON_X)
|
||||
performTouch(edit);
|
||||
else if (keycode == Input.Keys.BUTTON_L1) {
|
||||
scrollPane.fling(1f, 0, -300);
|
||||
}
|
||||
else if (keycode == Input.Keys.BUTTON_R1) {
|
||||
scrollPane.fling(1f, 0, +300);
|
||||
} else if (keycode == Input.Keys.BUTTON_A)
|
||||
performTouch(selectedActor);
|
||||
else if (keycode == Input.Keys.DPAD_DOWN) {
|
||||
if (selectedActorIndex == 9) {
|
||||
selectActor(actorObjectMap.get(0), false);
|
||||
scrollPane.fling(1f, 0, +300);
|
||||
} else {
|
||||
selectNextActor(false);
|
||||
}
|
||||
if (selectedActorIndex == 6)
|
||||
scrollPane.fling(1f, 0, -300);
|
||||
} else if (keycode == Input.Keys.DPAD_UP) {
|
||||
if (selectedActorIndex == 0) {
|
||||
selectActor(actorObjectMap.get(9), false);
|
||||
scrollPane.fling(1f, 0, -300);
|
||||
} else {
|
||||
selectPreviousActor(false);
|
||||
}
|
||||
if (selectedActorIndex == 5)
|
||||
scrollPane.fling(1f, 0, +300);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -175,51 +142,7 @@ public class DeckSelectScene extends UIScene {
|
||||
super.enter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
super.resLoaded();
|
||||
layout = new Table();
|
||||
stage.addActor(layout);
|
||||
|
||||
header = Controls.newLabel(Forge.getLocalizer().getMessage("lblSelectYourDeck"));
|
||||
layout.add(header).colspan(2).align(Align.center).pad(2, 5, 2, 5);
|
||||
layout.row();
|
||||
for (int i = 0; i < AdventurePlayer.NUMBER_OF_DECKS; i++)
|
||||
addDeckSlot(Forge.getLocalizer().getMessage("lblDeck")+": " + (i + 1), i);
|
||||
|
||||
dialog = Controls.newDialog(Forge.getLocalizer().getMessage("lblSave"));
|
||||
textInput = Controls.newTextField("");
|
||||
dialog.getButtonTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblNameYourSaveFile"))).colspan(2);
|
||||
dialog.getButtonTable().row();
|
||||
dialog.getButtonTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblName")+": ")).align(Align.left);
|
||||
dialog.getButtonTable().add(textInput).fillX().expandX();
|
||||
dialog.getButtonTable().row();
|
||||
dialogRenameBtn = Controls.newTextButton(Forge.getLocalizer().getMessage("lblRename"), () -> DeckSelectScene.this.rename());
|
||||
dialog.getButtonTable().add(dialogRenameBtn).align(Align.left).padLeft(15);
|
||||
dialogAbortBtn = Controls.newTextButton(Forge.getLocalizer().getMessage("lblAbort"), () -> dialog.hide());
|
||||
dialog.getButtonTable().add(dialogAbortBtn).align(Align.right).padRight(15);
|
||||
dialog.getColor().a = 0f;
|
||||
dialog.hide();
|
||||
|
||||
back = ui.findActor("return");
|
||||
back.getLabel().setText(Forge.getLocalizer().getMessage("lblBack"));
|
||||
edit = ui.findActor("edit");
|
||||
edit.getLabel().setText(Forge.getLocalizer().getMessage("lblEdit"));
|
||||
rename = ui.findActor("rename");
|
||||
rename.getLabel().setText(Forge.getLocalizer().getMessage("lblRename"));
|
||||
ui.onButtonPress("return", () -> DeckSelectScene.this.back());
|
||||
ui.onButtonPress("edit", () -> DeckSelectScene.this.edit());
|
||||
ui.onButtonPress("rename", () -> {
|
||||
textInput.setText(Current.player().getSelectedDeck().getName());
|
||||
dialog.show(stage);
|
||||
selectActor(textInput, false);
|
||||
});
|
||||
defColor = ui.findActor("return").getColor();
|
||||
|
||||
scrollPane = ui.findActor("deckSlots");
|
||||
scrollPane.setActor(layout);
|
||||
|
||||
}
|
||||
|
||||
private void rename() {
|
||||
dialog.hide();
|
||||
@@ -229,6 +152,6 @@ public class DeckSelectScene extends UIScene {
|
||||
}
|
||||
|
||||
private void edit() {
|
||||
Forge.switchScene(SceneType.DeckEditScene.instance);
|
||||
Forge.switchScene(DeckEditScene.getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import forge.adventure.data.EffectData;
|
||||
import forge.adventure.data.EnemyData;
|
||||
import forge.adventure.data.ItemData;
|
||||
import forge.adventure.player.AdventurePlayer;
|
||||
import forge.adventure.stage.IAfterMatch;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.adventure.util.Current;
|
||||
import forge.assets.FBufferedImage;
|
||||
@@ -46,6 +47,13 @@ import java.util.*;
|
||||
* Forge screen scene that contains the duel screen
|
||||
*/
|
||||
public class DuelScene extends ForgeScene {
|
||||
private static DuelScene object;
|
||||
|
||||
public static DuelScene instance() {
|
||||
if(object==null)
|
||||
object=new DuelScene();
|
||||
return object;
|
||||
}
|
||||
//GameLobby lobby;
|
||||
HostedMatch hostedMatch;
|
||||
EnemySprite enemy;
|
||||
@@ -59,9 +67,10 @@ public class DuelScene extends ForgeScene {
|
||||
List<IPaperCard> AIExtras = new ArrayList<>();
|
||||
|
||||
|
||||
public DuelScene() {
|
||||
private DuelScene() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
}
|
||||
@@ -117,10 +126,10 @@ public class DuelScene extends ForgeScene {
|
||||
Forge.clearTransitionScreen();
|
||||
Forge.clearCurrentScreen();
|
||||
Scene last = Forge.switchToLast();
|
||||
Current.player().getStatistic().setResult(enemyName, winner);
|
||||
|
||||
if (last instanceof HudScene) {
|
||||
Current.player().getStatistic().setResult(enemyName, winner);
|
||||
((HudScene) last).stage.setWinner(winner);
|
||||
if (last instanceof IAfterMatch) {
|
||||
((IAfterMatch) last).setWinner(winner);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -77,10 +77,6 @@ public abstract class ForgeScene extends Scene implements IUpdateable {
|
||||
getScreen().buildTouchListeners(x, y, potentialListeners);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean leave() {
|
||||
|
||||
@@ -10,9 +10,18 @@ import forge.adventure.stage.WorldStage;
|
||||
* does render the WorldStage and HUD
|
||||
*/
|
||||
public class GameScene extends HudScene {
|
||||
private float cameraWidth = 0f, cameraHeight = 0f;
|
||||
public GameScene() {
|
||||
super(WorldStage.getInstance());
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static GameScene object;
|
||||
|
||||
public static GameScene instance() {
|
||||
if(object==null)
|
||||
object=new GameScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,20 +41,13 @@ public class GameScene extends HudScene {
|
||||
hud.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
//set initial camera width and height
|
||||
if (cameraWidth == 0f)
|
||||
cameraWidth = stage.getCamera().viewportWidth;
|
||||
if (cameraHeight == 0f)
|
||||
cameraHeight = stage.getCamera().viewportHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
Forge.clearTransitionScreen();
|
||||
Forge.clearCurrentScreen();
|
||||
super.enter();
|
||||
WorldStage.getInstance().handlePointsOfInterestCollision();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,12 +6,13 @@ import com.badlogic.gdx.graphics.GL20;
|
||||
import forge.Forge;
|
||||
import forge.adventure.stage.GameHUD;
|
||||
import forge.adventure.stage.GameStage;
|
||||
import forge.adventure.stage.IAfterMatch;
|
||||
import forge.adventure.stage.MapStage;
|
||||
|
||||
/**
|
||||
* Hud base scene
|
||||
*/
|
||||
public abstract class HudScene extends Scene implements InputProcessor {
|
||||
public abstract class HudScene extends Scene implements InputProcessor, IAfterMatch {
|
||||
|
||||
GameHUD hud;
|
||||
GameStage stage;
|
||||
@@ -52,12 +53,6 @@ public abstract class HudScene extends Scene implements InputProcessor {
|
||||
stage.draw();
|
||||
hud.draw();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,9 +64,8 @@ public abstract class HudScene extends Scene implements InputProcessor {
|
||||
}
|
||||
if (hud.keyDown(keycode))
|
||||
return true;
|
||||
if(isInHudOnlyMode()) {
|
||||
if(isInHudOnlyMode())
|
||||
return false;
|
||||
}
|
||||
return stage.keyDown(keycode);
|
||||
}
|
||||
|
||||
@@ -140,6 +134,10 @@ public abstract class HudScene extends Scene implements InputProcessor {
|
||||
return stage.scrolled(amountX, amountY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWinner(boolean winner) {
|
||||
stage.setWinner(winner);
|
||||
}
|
||||
public boolean isInHudOnlyMode()
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -2,8 +2,7 @@ package forge.adventure.scene;
|
||||
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import forge.Forge;
|
||||
import forge.adventure.stage.GameHUD;
|
||||
import forge.adventure.util.Current;
|
||||
@@ -12,14 +11,35 @@ import forge.adventure.util.Current;
|
||||
* Scene for the Inn in towns
|
||||
*/
|
||||
public class InnScene extends UIScene {
|
||||
TextButton tempHitPointCost, sell, leave;
|
||||
Label tempHitPoints;
|
||||
private static InnScene object;
|
||||
|
||||
public static InnScene instance() {
|
||||
if(object==null)
|
||||
object=new InnScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
TextraButton tempHitPointCost, sell, leave;
|
||||
Image healIcon, sellIcon, leaveIcon;
|
||||
|
||||
public InnScene() {
|
||||
private InnScene() {
|
||||
|
||||
super(Forge.isLandscapeMode() ? "ui/inn.json" : "ui/inn_portrait.json");
|
||||
tempHitPointCost = ui.findActor("tempHitPointCost");
|
||||
ui.onButtonPress("done", InnScene.this::done);
|
||||
ui.onButtonPress("tempHitPointCost", InnScene.this::potionOfFalseLife);
|
||||
ui.onButtonPress("sell", InnScene.this::sell);
|
||||
leave = ui.findActor("done");
|
||||
sell = ui.findActor("sell");
|
||||
|
||||
|
||||
leaveIcon = ui.findActor("leaveIcon");
|
||||
healIcon = ui.findActor("healIcon");
|
||||
sellIcon = ui.findActor("sellIcon");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void done() {
|
||||
GameHUD.getInstance().getTouchpad().setVisible(false);
|
||||
Forge.switchToLast();
|
||||
@@ -34,39 +54,6 @@ public class InnScene extends UIScene {
|
||||
stage.act(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
super.resLoaded();
|
||||
ui.onButtonPress("done", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
InnScene.this.done();
|
||||
}
|
||||
});
|
||||
ui.onButtonPress("tempHitPointCost", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
InnScene.this.potionOfFalseLife();
|
||||
}
|
||||
});
|
||||
ui.onButtonPress("sell", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
InnScene.this.sell();
|
||||
}
|
||||
});
|
||||
leave = ui.findActor("done");
|
||||
leave.getLabel().setText(Forge.getLocalizer().getMessage("lblLeave"));
|
||||
sell = ui.findActor("sell");
|
||||
sell.getLabel().setText(Forge.getLocalizer().getMessage("lblSell"));
|
||||
|
||||
tempHitPoints = ui.findActor("tempHitPoints");
|
||||
tempHitPoints.setText(Forge.getLocalizer().getMessageorUseDefault("lblTempHitPoints", "Temporary Hit Points"));
|
||||
|
||||
leaveIcon = ui.findActor("leaveIcon");
|
||||
healIcon = ui.findActor("healIcon");
|
||||
sellIcon = ui.findActor("sellIcon");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
@@ -82,9 +69,8 @@ public class InnScene extends UIScene {
|
||||
boolean purchaseable = Current.player().getMaxLife() == Current.player().getLife() &&
|
||||
tempHealthCost <= Current.player().getGold();
|
||||
|
||||
tempHitPointCost = ui.findActor("tempHitPointCost");
|
||||
tempHitPointCost.setDisabled(!purchaseable);
|
||||
tempHitPointCost.getLabel().setText("$" + tempHealthCost);
|
||||
tempHitPointCost.setText( tempHealthCost+"[+Gold]");
|
||||
clearActorObjects();
|
||||
addActorObject(tempHitPointCost);
|
||||
addActorObject(sell);
|
||||
@@ -92,7 +78,7 @@ public class InnScene extends UIScene {
|
||||
}
|
||||
|
||||
private void sell() {
|
||||
Forge.switchScene(SceneType.ShopScene.instance);
|
||||
Forge.switchScene(ShopScene.instance());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,9 +8,13 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Timer;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.data.ItemData;
|
||||
import forge.adventure.stage.ConsoleCommandInterpreter;
|
||||
import forge.adventure.stage.GameHUD;
|
||||
import forge.adventure.stage.MapStage;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.adventure.util.Controls;
|
||||
import forge.adventure.util.Current;
|
||||
@@ -20,64 +24,36 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class InventoryScene extends UIScene {
|
||||
TextButton leave;
|
||||
TextraButton leave;
|
||||
Button equipButton;
|
||||
Label itemDescription;
|
||||
TextraButton useButton;
|
||||
TextraLabel itemDescription;
|
||||
Dialog confirm;
|
||||
private Table inventory;
|
||||
Array<Button> inventoryButtons=new Array<>();
|
||||
HashMap<String,Button> equipmentSlots=new HashMap<>();
|
||||
Dialog useDialog;
|
||||
private final Table inventory;
|
||||
private final Array<Button> inventoryButtons=new Array<>();
|
||||
private final HashMap<String,Button> equipmentSlots=new HashMap<>();
|
||||
HashMap<Button,String> itemLocation=new HashMap<>();
|
||||
Button selected;
|
||||
Button deleteButton;
|
||||
Texture equipOverlay;
|
||||
int columns=0;
|
||||
public InventoryScene() {
|
||||
public InventoryScene()
|
||||
{
|
||||
super(Forge.isLandscapeMode() ? "ui/inventory.json" : "ui/inventory_portrait.json");
|
||||
}
|
||||
|
||||
public void done() {
|
||||
GameHUD.getInstance().getTouchpad().setVisible(false);
|
||||
Forge.switchToLast();
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
|
||||
ItemData data = ItemData.getItem(itemLocation.get(selected));
|
||||
if(data != null) {
|
||||
Current.player().removeItem(data.name);
|
||||
}
|
||||
updateInventory();
|
||||
|
||||
}
|
||||
public void equip() {
|
||||
if(selected == null) return;
|
||||
ItemData data = ItemData.getItem(itemLocation.get(selected));
|
||||
Current.player().equip(data);
|
||||
updateInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
stage.act(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
super.resLoaded();
|
||||
equipOverlay = new Texture(Config.instance().getFile(Paths.ITEMS_EQUIP));
|
||||
ui.onButtonPress("return", () -> done());
|
||||
leave = ui.findActor("return");
|
||||
ui.onButtonPress("delete", () -> confirm.show(stage));
|
||||
ui.onButtonPress("equip", () -> equip());
|
||||
ui.onButtonPress("use", () -> use());
|
||||
equipButton = ui.findActor("equip");
|
||||
useButton= ui.findActor("use");
|
||||
useButton.setDisabled(true);
|
||||
deleteButton = ui.findActor("delete");
|
||||
itemDescription = ui.findActor("item_description");
|
||||
itemDescription.setAlignment(Align.topLeft);
|
||||
leave.getLabel().setText(Forge.getLocalizer().getMessage("lblBack"));
|
||||
|
||||
inventoryButtons=new Array<>();
|
||||
equipmentSlots=new HashMap<>();
|
||||
|
||||
Array<Actor> children = ui.getChildren();
|
||||
for (int i = 0, n = children.size; i < n; i++)
|
||||
@@ -101,7 +77,7 @@ public class InventoryScene extends UIScene {
|
||||
}
|
||||
}
|
||||
String item=Current.player().itemInSlot(slotName);
|
||||
if(item!=null&&item!="")
|
||||
if(item!=null&& !item.equals(""))
|
||||
{
|
||||
Button changeButton=null;
|
||||
for(Button invButton:inventoryButtons)
|
||||
@@ -125,7 +101,7 @@ public class InventoryScene extends UIScene {
|
||||
});
|
||||
}
|
||||
}
|
||||
inventory = new Table(Controls.GetSkin());
|
||||
inventory = new Table(Controls.getSkin());
|
||||
ScrollPane scrollPane = ui.findActor("inventory");
|
||||
scrollPane.setScrollingDisabled(true,false);
|
||||
scrollPane.setActor(inventory);
|
||||
@@ -133,15 +109,16 @@ public class InventoryScene extends UIScene {
|
||||
columns-=1;
|
||||
if(columns<=0)columns=1;
|
||||
scrollPane.setActor(inventory);
|
||||
confirm = new Dialog("\n "+Forge.getLocalizer().getMessage("lblDelete"), Controls.GetSkin())
|
||||
confirm = new Dialog("", Controls.getSkin())
|
||||
{
|
||||
protected void result(Object object)
|
||||
{
|
||||
if(object!=null&&object.equals(true))
|
||||
delete();
|
||||
confirm.hide();
|
||||
};
|
||||
if(object!=null&&object.equals(true))
|
||||
delete();
|
||||
confirm.hide();
|
||||
}
|
||||
};
|
||||
confirm.text( Controls.newLabel(Forge.getLocalizer().getMessage("lblDelete")));
|
||||
|
||||
confirm.button(Forge.getLocalizer().getMessage("lblYes"), true);
|
||||
confirm.button(Forge.getLocalizer().getMessage("lblNo"), false);
|
||||
@@ -151,6 +128,80 @@ public class InventoryScene extends UIScene {
|
||||
itemDescription.setWrap(true);
|
||||
//makes confirm dialog hidden immediately when you open inventory first time..
|
||||
confirm.getColor().a = 0;
|
||||
|
||||
|
||||
useDialog = new Dialog("", Controls.getSkin())
|
||||
{
|
||||
protected void result(Object object)
|
||||
{
|
||||
useDialog.hide();
|
||||
if(object!=null&&object.equals(true))
|
||||
{
|
||||
triggerUse();
|
||||
useDialog.getColor().a = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
useDialog.button(Forge.getLocalizer().getMessage("lblYes"), true);
|
||||
useDialog.button(Forge.getLocalizer().getMessage("lblNo"), false);
|
||||
ui.addActor(useDialog);
|
||||
useDialog.hide();
|
||||
useDialog.getColor().a = 0;
|
||||
}
|
||||
|
||||
private static InventoryScene object;
|
||||
|
||||
public static InventoryScene instance() {
|
||||
if(object==null)
|
||||
object=new InventoryScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
public void done() {
|
||||
GameHUD.getInstance().getTouchpad().setVisible(false);
|
||||
Forge.switchToLast();
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
|
||||
ItemData data = ItemData.getItem(itemLocation.get(selected));
|
||||
if(data != null) {
|
||||
Current.player().removeItem(data.name);
|
||||
}
|
||||
updateInventory();
|
||||
|
||||
}
|
||||
public void equip() {
|
||||
if(selected == null) return;
|
||||
ItemData data = ItemData.getItem(itemLocation.get(selected));
|
||||
if(data==null)return;
|
||||
Current.player().equip(data);
|
||||
updateInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
stage.act(delta);
|
||||
}
|
||||
|
||||
|
||||
private void triggerUse() {
|
||||
if(selected==null)return;
|
||||
|
||||
ItemData data = ItemData.getItem(itemLocation.get(selected));
|
||||
if(data==null)return;
|
||||
Current.player().addMana(-data.manaNeeded);
|
||||
done();
|
||||
ConsoleCommandInterpreter.getInstance().command(data.commandOnUse);
|
||||
}
|
||||
private void use() {
|
||||
useDialog.getContentTable().clear();
|
||||
ItemData data = ItemData.getItem(itemLocation.get(selected));
|
||||
if(data==null)return;
|
||||
useDialog.getContentTable().add(Controls.newTextraLabel("Use "+data.name+"?\n"+data.getDescription()));
|
||||
useDialog.show(stage);
|
||||
}
|
||||
|
||||
private void setSelected(Button actor) {
|
||||
@@ -160,6 +211,7 @@ public class InventoryScene extends UIScene {
|
||||
itemDescription.setText("");
|
||||
deleteButton.setDisabled(true);
|
||||
equipButton.setDisabled(true);
|
||||
useButton.setDisabled(true);
|
||||
for(Button button:inventoryButtons)
|
||||
{
|
||||
button.setChecked(false);
|
||||
@@ -167,17 +219,30 @@ public class InventoryScene extends UIScene {
|
||||
return;
|
||||
}
|
||||
ItemData data = ItemData.getItem(itemLocation.get(actor));
|
||||
|
||||
if(data==null) return;
|
||||
deleteButton.setDisabled(data.questItem);
|
||||
if(data.equipmentSlot==null||data.equipmentSlot=="")
|
||||
|
||||
boolean isInPoi = MapStage.getInstance().isInMap();
|
||||
useButton.setDisabled(!(isInPoi&&data.usableInPoi||!isInPoi&&data.usableOnWorldMap));
|
||||
if(data.manaNeeded==0)
|
||||
useButton.setText("Use");
|
||||
else
|
||||
useButton.setText("Use "+data.manaNeeded+"[+Mana]");
|
||||
useButton.layout();
|
||||
if(Current.player().getMana()<data.manaNeeded)
|
||||
useButton.setDisabled(true);
|
||||
|
||||
if(data.equipmentSlot==null|| data.equipmentSlot.equals(""))
|
||||
{
|
||||
equipButton.setDisabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
equipButton.setDisabled(false);
|
||||
if(equipButton instanceof TextButton)
|
||||
if(equipButton instanceof TextraButton)
|
||||
{
|
||||
TextButton button=(TextButton) equipButton;
|
||||
TextraButton button=(TextraButton) equipButton;
|
||||
String item=Current.player().itemInSlot(data.equipmentSlot);
|
||||
if(item!=null&&item.equals(data.name))
|
||||
{
|
||||
@@ -187,6 +252,7 @@ public class InventoryScene extends UIScene {
|
||||
{
|
||||
button.setText("Equip");
|
||||
}
|
||||
button.layout();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,7 +337,7 @@ public class InventoryScene extends UIScene {
|
||||
|
||||
public Button createInventorySlot() {
|
||||
|
||||
ImageButton button=new ImageButton(Controls.GetSkin(),"item_frame");
|
||||
ImageButton button=new ImageButton(Controls.getSkin(),"item_frame");
|
||||
return button;
|
||||
}
|
||||
|
||||
|
||||
90
forge-gui-mobile/src/forge/adventure/scene/MapViewScene.java
Normal file
@@ -0,0 +1,90 @@
|
||||
package forge.adventure.scene;
|
||||
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import forge.Forge;
|
||||
import forge.adventure.stage.GameHUD;
|
||||
import forge.adventure.stage.WorldStage;
|
||||
import forge.adventure.util.Current;
|
||||
import forge.adventure.world.WorldSave;
|
||||
|
||||
/**
|
||||
* Displays the rewards of a fight or a treasure
|
||||
*/
|
||||
public class MapViewScene extends UIScene {
|
||||
private static MapViewScene object;
|
||||
private final ScrollPane scroll;
|
||||
private final Image img;
|
||||
private Texture miniMapTexture;
|
||||
private final Image miniMapPlayer;
|
||||
|
||||
public static MapViewScene instance() {
|
||||
if(object==null)
|
||||
object=new MapViewScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
private MapViewScene() {
|
||||
super(Forge.isLandscapeMode() ? "ui/map.json" : "ui/map_portrait.json");
|
||||
|
||||
|
||||
ui.onButtonPress("done", () -> done());
|
||||
|
||||
scroll = ui.findActor("map");
|
||||
Group table=new Group();
|
||||
scroll.setActor(table);
|
||||
img=new Image();
|
||||
miniMapPlayer=new Image();
|
||||
img.setPosition(0,0);
|
||||
table.addActor(img);
|
||||
table.addActor(miniMapPlayer);
|
||||
//img.setFillParent(true);
|
||||
|
||||
}
|
||||
|
||||
public boolean done() {
|
||||
GameHUD.getInstance().getTouchpad().setVisible(false);
|
||||
Forge.switchToLast();
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void enter() {
|
||||
if(miniMapTexture!=null)
|
||||
miniMapTexture.dispose();
|
||||
miniMapTexture=new Texture(WorldSave.getCurrentSave().getWorld().getBiomeImage());
|
||||
//img.setSize(miniMapTexture.getWidth(),miniMapTexture.getHeight());
|
||||
img.setSize(WorldSave.getCurrentSave().getWorld().getBiomeImage().getWidth(),WorldSave.getCurrentSave().getWorld().getBiomeImage().getHeight());
|
||||
img.getParent().setSize(WorldSave.getCurrentSave().getWorld().getBiomeImage().getWidth(),WorldSave.getCurrentSave().getWorld().getBiomeImage().getHeight());
|
||||
img.setDrawable(new TextureRegionDrawable(miniMapTexture));
|
||||
miniMapPlayer.setDrawable(new TextureRegionDrawable(Current.player().avatar()));
|
||||
|
||||
int yPos = (int) WorldStage.getInstance().getPlayerSprite().getY();
|
||||
int xPos = (int) WorldStage.getInstance().getPlayerSprite().getX();
|
||||
int xPosMini = (int) (((float) xPos / (float) WorldSave.getCurrentSave().getWorld().getTileSize() / (float) WorldSave.getCurrentSave().getWorld().getWidthInTiles()) * img.getWidth());
|
||||
int yPosMini = (int) (((float) yPos / (float) WorldSave.getCurrentSave().getWorld().getTileSize() / (float) WorldSave.getCurrentSave().getWorld().getHeightInTiles()) * img.getHeight());
|
||||
|
||||
miniMapPlayer.setSize(Current.player().avatar().getRegionWidth(),Current.player().avatar().getRegionHeight());
|
||||
miniMapPlayer.setPosition( xPosMini - miniMapPlayer.getWidth()/2, yPosMini - miniMapPlayer.getHeight()/2);
|
||||
miniMapPlayer.layout();
|
||||
scroll.scrollTo(xPosMini - miniMapPlayer.getWidth()/2, yPosMini - miniMapPlayer.getHeight()/2,miniMapPlayer.getWidth(),
|
||||
miniMapPlayer.getHeight(),true,true);
|
||||
//img.setAlign(Align.center);
|
||||
|
||||
|
||||
super.enter();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keycode) {
|
||||
if (keycode == Input.Keys.ESCAPE || keycode == Input.Keys.BACK) {
|
||||
done();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,10 +5,13 @@ import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.data.DifficultyData;
|
||||
import forge.adventure.data.HeroListData;
|
||||
@@ -33,49 +36,23 @@ import java.util.Random;
|
||||
public class NewGameScene extends UIScene {
|
||||
TextField selectedName;
|
||||
ColorSet[] colorIds;
|
||||
private Image avatarImage;
|
||||
private final Image avatarImage;
|
||||
private int avatarIndex = 0;
|
||||
private Selector race;
|
||||
private Selector colorId;
|
||||
private Selector gender;
|
||||
private Selector mode;
|
||||
private Selector difficulty;
|
||||
private Array<String> stringList, random, custom;
|
||||
private Label colorLabel;
|
||||
private int selected = -1;
|
||||
private final Selector race;
|
||||
private final Selector colorId;
|
||||
private final Selector gender;
|
||||
private final Selector mode;
|
||||
private final Selector difficulty;
|
||||
private final Array<String> stringList;
|
||||
private final Array<String> random;
|
||||
private final Array<String> custom;
|
||||
private final TextraLabel colorLabel;
|
||||
private final int selected = -1;
|
||||
|
||||
private NewGameScene() {
|
||||
|
||||
public NewGameScene() {
|
||||
super(Forge.isLandscapeMode() ? "ui/new_game.json" : "ui/new_game_portrait.json");
|
||||
}
|
||||
|
||||
public boolean start() {
|
||||
if (selectedName.getText().isEmpty()) {
|
||||
selectedName.setText(NameGenerator.getRandomName("Any", "Any", ""));
|
||||
}
|
||||
Runnable runnable = () -> {
|
||||
FModel.getPreferences().setPref(ForgePreferences.FPref.UI_ENABLE_MUSIC, false);
|
||||
WorldSave.generateNewWorld(selectedName.getText(),
|
||||
gender.getCurrentIndex() == 0,
|
||||
race.getCurrentIndex(),
|
||||
avatarIndex,
|
||||
colorIds[colorId.getCurrentIndex()],
|
||||
Config.instance().getConfigData().difficulties[difficulty.getCurrentIndex()],
|
||||
mode.getCurrentIndex() == 2, mode.getCurrentIndex() == 1, mode.getCurrentIndex() == 3, colorId.getCurrentIndex(), 0);//maybe replace with enum
|
||||
GamePlayerUtil.getGuiPlayer().setName(selectedName.getText());
|
||||
Forge.switchScene(SceneType.GameScene.instance);
|
||||
};
|
||||
Forge.setTransitionScreen(new TransitionScreen(runnable, null, false, true, "Generating World..."));
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean back() {
|
||||
Forge.switchScene(SceneType.StartScene.instance);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
super.resLoaded();
|
||||
selectedName = ui.findActor("nameField");
|
||||
selectedName.setText(NameGenerator.getRandomName("Any", "Any", ""));
|
||||
selectedName.addListener(new InputListener() {
|
||||
@@ -92,7 +69,7 @@ public class NewGameScene extends UIScene {
|
||||
gender = ui.findActor("gender");
|
||||
mode = ui.findActor("mode");
|
||||
colorLabel = ui.findActor("colorIdL");
|
||||
String colorIdLabel = colorLabel.getText().toString();
|
||||
String colorIdLabel = colorLabel.storedText;
|
||||
custom = new Array<>();
|
||||
for (DeckProxy deckProxy : DeckProxy.getAllCustomStarterDecks())
|
||||
custom.add(deckProxy.getName());
|
||||
@@ -151,6 +128,41 @@ public class NewGameScene extends UIScene {
|
||||
ui.onButtonPress("rightAvatar", () -> NewGameScene.this.rightAvatar());
|
||||
}
|
||||
|
||||
private static NewGameScene object;
|
||||
|
||||
public static NewGameScene instance() {
|
||||
if(object==null)
|
||||
object=new NewGameScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
public boolean start() {
|
||||
if (selectedName.getText().isEmpty()) {
|
||||
selectedName.setText(NameGenerator.getRandomName("Any", "Any", ""));
|
||||
}
|
||||
Runnable runnable = () -> {
|
||||
FModel.getPreferences().setPref(ForgePreferences.FPref.UI_ENABLE_MUSIC, false);
|
||||
WorldSave.generateNewWorld(selectedName.getText(),
|
||||
gender.getCurrentIndex() == 0,
|
||||
race.getCurrentIndex(),
|
||||
avatarIndex,
|
||||
colorIds[colorId.getCurrentIndex()],
|
||||
Config.instance().getConfigData().difficulties[difficulty.getCurrentIndex()],
|
||||
mode.getCurrentIndex() == 2, mode.getCurrentIndex() == 1, mode.getCurrentIndex() == 3, colorId.getCurrentIndex(), 0);//maybe replace with enum
|
||||
GamePlayerUtil.getGuiPlayer().setName(selectedName.getText());
|
||||
Forge.switchScene(GameScene.instance());
|
||||
};
|
||||
Forge.setTransitionScreen(new TransitionScreen(runnable, null, false, true, "Generating World..."));
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean back() {
|
||||
Forge.switchScene(StartScene.instance());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void rightAvatar() {
|
||||
|
||||
avatarIndex++;
|
||||
@@ -187,7 +199,7 @@ public class NewGameScene extends UIScene {
|
||||
Config.instance().getConfigData().difficulties[difficulty.getCurrentIndex()],
|
||||
mode.getCurrentIndex() == 2, mode.getCurrentIndex() == 1, mode.getCurrentIndex() == 3, colorId.getCurrentIndex(), 0);//maybe replace with enum
|
||||
GamePlayerUtil.getGuiPlayer().setName(selectedName.getText());
|
||||
Forge.switchScene(SceneType.GameScene.instance);
|
||||
Forge.switchScene(GameScene.instance());
|
||||
}
|
||||
clearActorObjects();
|
||||
addActorObject(selectedName);
|
||||
@@ -199,6 +211,7 @@ public class NewGameScene extends UIScene {
|
||||
addActorObject(ui.findActor("back"));
|
||||
addActorObject(ui.findActor("start"));
|
||||
unselectActors();
|
||||
super.enter();
|
||||
}
|
||||
@Override
|
||||
public boolean pointerMoved(int screenX, int screenY) {
|
||||
@@ -307,7 +320,7 @@ public class NewGameScene extends UIScene {
|
||||
performTouch(selectedKey);
|
||||
} else {
|
||||
if (selectedActor != null) {
|
||||
if (selectedActor instanceof TextButton)
|
||||
if (selectedActor instanceof TextraButton)
|
||||
performTouch(selectedActor);
|
||||
else if (selectedActor instanceof TextField && !kbVisible) {
|
||||
lastInputField = selectedActor;
|
||||
|
||||
@@ -3,9 +3,13 @@ package forge.adventure.scene;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.character.EnemySprite;
|
||||
import forge.adventure.data.EnemyData;
|
||||
@@ -26,20 +30,58 @@ import java.util.Map;
|
||||
public class PlayerStatisticScene extends UIScene {
|
||||
Image avatar, avatarBorder, lifeIcon, goldIcon;
|
||||
Image colorFrame;
|
||||
Label money, life;
|
||||
Label wins, totalWins;
|
||||
Label loss, totalLoss;
|
||||
Label winloss, lossWinRatio;
|
||||
Label playerName;
|
||||
TextButton back;
|
||||
private Table enemiesGroup;
|
||||
Label blessingScroll;
|
||||
TextraLabel money, life;
|
||||
TextraLabel wins, totalWins;
|
||||
TextraLabel loss, totalLoss;
|
||||
TextraLabel winloss, lossWinRatio;
|
||||
TextraLabel playerName;
|
||||
TextraButton back;
|
||||
private final Table enemiesGroup;
|
||||
TextraLabel blessingScroll;
|
||||
ScrollPane scrollPane, blessing;
|
||||
|
||||
public PlayerStatisticScene() {
|
||||
private PlayerStatisticScene() {
|
||||
super(Forge.isLandscapeMode() ? "ui/statistic.json" : "ui/statistic_portrait.json");
|
||||
|
||||
|
||||
enemiesGroup = new Table(Controls.getSkin());
|
||||
enemiesGroup.row();
|
||||
blessingScroll = Controls.newTextraLabel("");
|
||||
blessingScroll.setColor(Color.BLACK);
|
||||
blessingScroll.setAlignment(Align.topLeft);
|
||||
blessingScroll.setWrap(true);
|
||||
ui.onButtonPress("return", PlayerStatisticScene.this::back);
|
||||
|
||||
avatar = ui.findActor("avatar");
|
||||
avatarBorder = ui.findActor("avatarBorder");
|
||||
playerName = ui.findActor("playerName");
|
||||
life = ui.findActor("lifePoints");
|
||||
money = ui.findActor("money");
|
||||
lifeIcon = ui.findActor("lifeIcon");
|
||||
goldIcon = ui.findActor("goldIcon");
|
||||
wins = ui.findActor("wins");
|
||||
colorFrame = ui.findActor("colorFrame");
|
||||
totalWins = ui.findActor("totalWins");
|
||||
loss = ui.findActor("loss");
|
||||
totalLoss = ui.findActor("totalLoss");
|
||||
winloss = ui.findActor("winloss");
|
||||
lossWinRatio = ui.findActor("lossWinRatio");
|
||||
back = ui.findActor("return");
|
||||
ScrollPane scrollPane = ui.findActor("enemies");
|
||||
scrollPane.setActor(enemiesGroup);
|
||||
ScrollPane blessing = ui.findActor("blessingInfo");
|
||||
blessing.setActor(blessingScroll);
|
||||
}
|
||||
|
||||
private static PlayerStatisticScene object;
|
||||
|
||||
public static PlayerStatisticScene instance() {
|
||||
if(object==null)
|
||||
object=new PlayerStatisticScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
@@ -110,10 +152,10 @@ public class PlayerStatisticScene extends UIScene {
|
||||
WorldSave.getCurrentSave().getPlayer().onGoldChange(() -> money.setText(String.valueOf(AdventurePlayer.current().getGold())));
|
||||
}
|
||||
if (totalWins != null) {
|
||||
totalWins.setText(Current.player().getStatistic().totalWins());
|
||||
totalWins.setText(String.valueOf(Current.player().getStatistic().totalWins()));
|
||||
}
|
||||
if (totalLoss != null) {
|
||||
totalLoss.setText(Current.player().getStatistic().totalLoss());
|
||||
totalLoss.setText(String.valueOf(Current.player().getStatistic().totalLoss()));
|
||||
}
|
||||
if (lossWinRatio != null) {
|
||||
lossWinRatio.setText(Float.toString(Current.player().getStatistic().winLossRatio()));
|
||||
@@ -143,47 +185,11 @@ public class PlayerStatisticScene extends UIScene {
|
||||
enemiesGroup.add((entry.getValue().getRight().toString())).align(Align.center).space(3, 2, 3, 2);
|
||||
enemiesGroup.row().space(8);
|
||||
}
|
||||
clearActorObjects();
|
||||
addActorObject(back);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
super.resLoaded();
|
||||
enemiesGroup = new Table(Controls.GetSkin());
|
||||
enemiesGroup.row();
|
||||
blessingScroll = Controls.newLabel("");
|
||||
blessingScroll.setStyle(new Label.LabelStyle(Controls.getBitmapFont("default"), Color.BLACK));
|
||||
blessingScroll.setAlignment(Align.topLeft);
|
||||
blessingScroll.setWrap(true);
|
||||
ui.onButtonPress("return", () -> PlayerStatisticScene.this.back());
|
||||
|
||||
avatar = ui.findActor("avatar");
|
||||
avatarBorder = ui.findActor("avatarBorder");
|
||||
playerName = ui.findActor("playerName");
|
||||
life = ui.findActor("lifePoints");
|
||||
money = ui.findActor("money");
|
||||
lifeIcon = ui.findActor("lifeIcon");
|
||||
goldIcon = ui.findActor("goldIcon");
|
||||
wins = ui.findActor("wins");
|
||||
colorFrame = ui.findActor("colorFrame");
|
||||
wins.setText(Forge.getLocalizer().getMessage("lblWinProper")+":");
|
||||
totalWins = ui.findActor("totalWins");
|
||||
loss = ui.findActor("loss");
|
||||
loss.setText(Forge.getLocalizer().getMessage("lblLossProper")+":");
|
||||
totalLoss = ui.findActor("totalLoss");
|
||||
winloss = ui.findActor("winloss");
|
||||
winloss.setText(Forge.getLocalizer().getMessage("lblWinProper")+"/"+Forge.getLocalizer().getMessage("lblLossProper"));
|
||||
lossWinRatio = ui.findActor("lossWinRatio");
|
||||
back = ui.findActor("return");
|
||||
back.getLabel().setText(Forge.getLocalizer().getMessage("lblBack"));
|
||||
scrollPane = ui.findActor("enemies");
|
||||
scrollPane.setActor(enemiesGroup);
|
||||
blessing = ui.findActor("blessingInfo");
|
||||
blessing.setActor(blessingScroll);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Timer;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.character.ShopActor;
|
||||
import forge.adventure.player.AdventurePlayer;
|
||||
@@ -24,8 +24,17 @@ import forge.sound.SoundSystem;
|
||||
* Displays the rewards of a fight or a treasure
|
||||
*/
|
||||
public class RewardScene extends UIScene {
|
||||
private TextButton doneButton;
|
||||
private Label goldLabel;
|
||||
private final TextraButton doneButton;
|
||||
private final TextraLabel goldLabel;
|
||||
|
||||
private static RewardScene object;
|
||||
|
||||
public static RewardScene instance() {
|
||||
if(object==null)
|
||||
object=new RewardScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
private boolean showTooltips = false;
|
||||
public enum Type {
|
||||
Shop,
|
||||
@@ -38,8 +47,13 @@ public class RewardScene extends UIScene {
|
||||
static public final float CARD_HEIGHT = 400f;
|
||||
static public final float CARD_WIDTH_TO_HEIGHT = CARD_WIDTH / CARD_HEIGHT;
|
||||
|
||||
public RewardScene() {
|
||||
private RewardScene() {
|
||||
|
||||
super(Forge.isLandscapeMode() ? "ui/items.json" : "ui/items_portrait.json");
|
||||
|
||||
goldLabel=ui.findActor("gold");
|
||||
ui.onButtonPress("done", () -> RewardScene.this.done());
|
||||
doneButton = ui.findActor("done");
|
||||
}
|
||||
|
||||
boolean doneClicked = false, shown = false;
|
||||
@@ -126,13 +140,6 @@ public class RewardScene extends UIScene {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
super.resLoaded();
|
||||
goldLabel=ui.findActor("gold");
|
||||
ui.onButtonPress("done", () -> RewardScene.this.done());
|
||||
doneButton = ui.findActor("done");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keycode) {
|
||||
@@ -266,7 +273,7 @@ public class RewardScene extends UIScene {
|
||||
switch (type) {
|
||||
case Shop:
|
||||
doneButton.setText(Forge.getLocalizer().getMessage("lblLeave"));
|
||||
goldLabel.setText("Gold:"+Current.player().getGold());
|
||||
goldLabel.setText(Current.player().getGold()+"[+Gold]");
|
||||
break;
|
||||
case Loot:
|
||||
goldLabel.setText("");
|
||||
@@ -354,7 +361,7 @@ public class RewardScene extends UIScene {
|
||||
if (currentRow != ((i + 1) / numberOfColumns))
|
||||
yOff += doneButton.getHeight();
|
||||
|
||||
TextButton buyCardButton = new BuyButton(shopActor.getObjectId(), i, shopActor.isUnlimited()?null:shopActor.getMapStage().getChanges(), actor, doneButton);
|
||||
TextraButton buyCardButton = new BuyButton(shopActor.getObjectId(), i, shopActor.isUnlimited()?null:shopActor.getMapStage().getChanges(), actor, doneButton);
|
||||
generated.add(buyCardButton);
|
||||
if (!skipCard) {
|
||||
stage.addActor(buyCardButton);
|
||||
@@ -380,7 +387,7 @@ public class RewardScene extends UIScene {
|
||||
}
|
||||
}
|
||||
|
||||
private class BuyButton extends TextButton {
|
||||
private class BuyButton extends TextraButton {
|
||||
private final int objectID;
|
||||
private final int index;
|
||||
private final PointOfInterestChanges changes;
|
||||
@@ -391,8 +398,8 @@ public class RewardScene extends UIScene {
|
||||
setDisabled(WorldSave.getCurrentSave().getPlayer().getGold() < price);
|
||||
}
|
||||
|
||||
public BuyButton(int id, int i, PointOfInterestChanges ch, RewardActor actor, TextButton style) {
|
||||
super("", style.getStyle());
|
||||
public BuyButton(int id, int i, PointOfInterestChanges ch, RewardActor actor, TextraButton style) {
|
||||
super("", style.getStyle(),Controls.getTextraFont());
|
||||
this.objectID = id;
|
||||
this.index = i;
|
||||
this.changes = ch;
|
||||
@@ -403,7 +410,7 @@ public class RewardScene extends UIScene {
|
||||
setY(actor.getY() - getHeight());
|
||||
price = CardUtil.getRewardPrice(actor.getReward());
|
||||
price *= Current.player().goldModifier();
|
||||
setText("$ " + price);
|
||||
setText(price+"[+Gold]");
|
||||
addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
@@ -417,7 +424,7 @@ public class RewardScene extends UIScene {
|
||||
SoundSystem.instance.play(SoundEffectType.FlipCoin, false);
|
||||
|
||||
updateBuyButtons();
|
||||
goldLabel.setText("Gold: " + String.valueOf(AdventurePlayer.current().getGold()));
|
||||
goldLabel.setText(AdventurePlayer.current().getGold()+"[+Gold]");
|
||||
if(changes==null)
|
||||
return;
|
||||
setDisabled(true);
|
||||
|
||||
@@ -12,6 +12,8 @@ import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.GdxRuntimeException;
|
||||
import com.badlogic.gdx.utils.IntMap;
|
||||
import com.badlogic.gdx.utils.Scaling;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.data.DifficultyData;
|
||||
import forge.adventure.util.Config;
|
||||
@@ -32,31 +34,101 @@ import java.util.zip.InflaterInputStream;
|
||||
* Scene to load and save the game.
|
||||
*/
|
||||
public class SaveLoadScene extends UIScene {
|
||||
private final IntMap<TextButton> buttons = new IntMap<>();
|
||||
private final IntMap<TextraButton> buttons = new IntMap<>();
|
||||
IntMap<WorldSaveHeader> previews = new IntMap<>();
|
||||
Color defColor;
|
||||
Table layout;
|
||||
Modes mode;
|
||||
Dialog dialog;
|
||||
TextField textInput;
|
||||
Label header;
|
||||
TextraLabel header;
|
||||
int currentSlot = -3, lastSelectedSlot = 0;
|
||||
Image previewImage;
|
||||
Label previewDate;
|
||||
TextraLabel previewDate;
|
||||
Image previewBorder;
|
||||
TextButton saveLoadButton, back, quickSave, autoSave, dialogSaveBtn, dialogAbortBtn;
|
||||
TextraButton saveLoadButton, back, quickSave, autoSave, dialogSaveBtn, dialogAbortBtn;
|
||||
Actor lastHighlightedSave;
|
||||
SelectBox difficulty;
|
||||
ScrollPane scrollPane;
|
||||
|
||||
public SaveLoadScene() {
|
||||
private SaveLoadScene() {
|
||||
super(Forge.isLandscapeMode() ? "ui/save_load.json" : "ui/save_load_portrait.json");
|
||||
|
||||
layout = new Table();
|
||||
stage.addActor(layout);
|
||||
dialog = Controls.newDialog(Forge.getLocalizer().getMessage("lblSave"));
|
||||
textInput = Controls.newTextField("");
|
||||
int c = 0;
|
||||
String[] diffList = new String[Config.instance().getConfigData().difficulties.length];
|
||||
for (DifficultyData diff : Config.instance().getConfigData().difficulties) {
|
||||
diffList[c] = diff.name;
|
||||
c++;
|
||||
}
|
||||
|
||||
difficulty = Controls.newComboBox(diffList, null, o -> {
|
||||
//DifficultyData difficulty1 = Config.instance().getConfigData().difficulties[difficulty.getSelectedIndex()];
|
||||
return null;
|
||||
});
|
||||
dialog.getButtonTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblNameYourSaveFile"))).colspan(2).pad(2, 15, 2, 15);
|
||||
dialog.getButtonTable().row();
|
||||
dialog.getButtonTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblName") + ": ")).align(Align.left).pad(2, 15, 2, 2);
|
||||
dialog.getButtonTable().add(textInput).fillX().expandX().padRight(15);
|
||||
dialog.getButtonTable().row();
|
||||
dialogSaveBtn = Controls.newTextButton(Forge.getLocalizer().getMessage("lblSave"), () -> SaveLoadScene.this.save());
|
||||
dialog.getButtonTable().add(dialogSaveBtn).align(Align.left).padLeft(15);
|
||||
dialogAbortBtn = Controls.newTextButton(Forge.getLocalizer().getMessage("lblAbort"), () -> SaveLoadScene.this.saveAbort());
|
||||
dialog.getButtonTable().add(dialogAbortBtn).align(Align.right).padRight(15);
|
||||
|
||||
//makes dialog hidden immediately when you open saveload scene..
|
||||
dialog.getColor().a = 0;
|
||||
dialog.hide();
|
||||
previewImage = ui.findActor("preview");
|
||||
previewDate = ui.findActor("saveDate");
|
||||
header = Controls.newTextraLabel(Forge.getLocalizer().getMessage("lblSave"));
|
||||
header.setAlignment(Align.center);
|
||||
layout.add(header).pad(2).colspan(4).align(Align.center).expandX();
|
||||
layout.row();
|
||||
autoSave = addSaveSlot(Forge.getLocalizer().getMessage("lblAutoSave"), WorldSave.AUTO_SAVE_SLOT);
|
||||
quickSave = addSaveSlot(Forge.getLocalizer().getMessage("lblQuickSave"), WorldSave.QUICK_SAVE_SLOT);
|
||||
for (int i = 1; i < 11; i++)
|
||||
addSaveSlot(Forge.getLocalizer().getMessage("lblSlot") + ": " + i, i);
|
||||
|
||||
saveLoadButton = ui.findActor("save");
|
||||
saveLoadButton.setText(Forge.getLocalizer().getMessage("lblSave"));
|
||||
ui.onButtonPress("save", () -> SaveLoadScene.this.loadSave());
|
||||
back = ui.findActor("return");
|
||||
ui.onButtonPress("return", () -> SaveLoadScene.this.back());
|
||||
|
||||
defColor = saveLoadButton.getColor();
|
||||
|
||||
scrollPane = ui.findActor("saveSlots");
|
||||
scrollPane.setActor(layout);
|
||||
ui.addActor(difficulty);
|
||||
difficulty.setSelectedIndex(1);
|
||||
difficulty.setAlignment(Align.center);
|
||||
difficulty.getStyle().fontColor = Color.GOLD;
|
||||
if (Forge.isLandscapeMode()) {
|
||||
difficulty.setX(280);
|
||||
difficulty.setY(220);
|
||||
} else {
|
||||
difficulty.setX(190);
|
||||
difficulty.setY(336);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private TextButton addSaveSlot(String name, int i) {
|
||||
private static SaveLoadScene object;
|
||||
|
||||
public static SaveLoadScene instance() {
|
||||
if(object==null)
|
||||
object=new SaveLoadScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
private TextraButton addSaveSlot(String name, int i) {
|
||||
layout.add(Controls.newLabel(name)).align(Align.left).pad(2, 5, 2, 10);
|
||||
TextButton button = Controls.newTextButton("...");
|
||||
TextraButton button = Controls.newTextButton("...");
|
||||
button.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
@@ -68,7 +140,7 @@ public class SaveLoadScene extends UIScene {
|
||||
}
|
||||
}
|
||||
});
|
||||
layout.add(button).align(Align.left).expandX();
|
||||
layout.add(button).fill(true,false).expand(true,false).align(Align.left).expandX();
|
||||
buttons.put(i, button);
|
||||
layout.row();
|
||||
return button;
|
||||
@@ -102,11 +174,11 @@ public class SaveLoadScene extends UIScene {
|
||||
if (previewDate != null)
|
||||
previewDate.setVisible(false);
|
||||
}
|
||||
for (IntMap.Entry<TextButton> butt : new IntMap.Entries<TextButton>(buttons)) {
|
||||
for (IntMap.Entry<TextraButton> butt : new IntMap.Entries<TextraButton>(buttons)) {
|
||||
butt.value.setColor(defColor);
|
||||
}
|
||||
if (buttons.containsKey(slot)) {
|
||||
TextButton button = buttons.get(slot);
|
||||
TextraButton button = buttons.get(slot);
|
||||
button.setColor(Color.RED);
|
||||
selectActor(button, false);
|
||||
}
|
||||
@@ -129,7 +201,7 @@ public class SaveLoadScene extends UIScene {
|
||||
try {
|
||||
Forge.setTransitionScreen(new TransitionScreen(() -> {
|
||||
if (WorldSave.load(currentSlot)) {
|
||||
Forge.switchScene(SceneType.GameScene.instance);
|
||||
Forge.switchScene(GameScene.instance());
|
||||
} else {
|
||||
Forge.clearTransitionScreen();
|
||||
}
|
||||
@@ -148,7 +220,7 @@ public class SaveLoadScene extends UIScene {
|
||||
Current.player().updateDifficulty(Config.instance().getConfigData().difficulties[difficulty.getSelectedIndex()]);
|
||||
Current.player().setWorldPosY((int) (WorldSave.getCurrentSave().getWorld().getData().playerStartPosY * WorldSave.getCurrentSave().getWorld().getData().height * WorldSave.getCurrentSave().getWorld().getTileSize()));
|
||||
Current.player().setWorldPosX((int) (WorldSave.getCurrentSave().getWorld().getData().playerStartPosX * WorldSave.getCurrentSave().getWorld().getData().width * WorldSave.getCurrentSave().getWorld().getTileSize()));
|
||||
Forge.switchScene(SceneType.GameScene.instance);
|
||||
Forge.switchScene(GameScene.instance());
|
||||
} else {
|
||||
Forge.clearTransitionScreen();
|
||||
}
|
||||
@@ -305,7 +377,7 @@ public class SaveLoadScene extends UIScene {
|
||||
}
|
||||
|
||||
if (restoreScene == null) {
|
||||
restoreScene = SceneType.GameScene.instance;
|
||||
restoreScene = GameScene.instance();
|
||||
}
|
||||
|
||||
Forge.switchScene(restoreScene);
|
||||
@@ -379,8 +451,8 @@ public class SaveLoadScene extends UIScene {
|
||||
else
|
||||
select(-3);
|
||||
updateFiles();
|
||||
autoSave.getLabel().setText(Forge.getLocalizer().getMessage("lblAutoSave"));
|
||||
quickSave.getLabel().setText(Forge.getLocalizer().getMessage("lblQuickSave"));
|
||||
autoSave.setText(Forge.getLocalizer().getMessage("lblAutoSave"));
|
||||
quickSave.setText(Forge.getLocalizer().getMessage("lblQuickSave"));
|
||||
if (mode == Modes.NewGamePlus) {
|
||||
if (difficulty != null) {
|
||||
difficulty.setVisible(true);
|
||||
@@ -416,70 +488,4 @@ public class SaveLoadScene extends UIScene {
|
||||
super.enter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
super.resLoaded();
|
||||
layout = new Table();
|
||||
stage.addActor(layout);
|
||||
dialog = Controls.newDialog(Forge.getLocalizer().getMessage("lblSave"));
|
||||
textInput = Controls.newTextField("");
|
||||
int c = 0;
|
||||
String[] diffList = new String[Config.instance().getConfigData().difficulties.length];
|
||||
for (DifficultyData diff : Config.instance().getConfigData().difficulties) {
|
||||
diffList[c] = diff.name;
|
||||
c++;
|
||||
}
|
||||
;
|
||||
|
||||
difficulty = Controls.newComboBox(diffList, null, o -> {
|
||||
//DifficultyData difficulty1 = Config.instance().getConfigData().difficulties[difficulty.getSelectedIndex()];
|
||||
return null;
|
||||
});
|
||||
dialog.getButtonTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblNameYourSaveFile"))).colspan(2).pad(2, 15, 2, 15);
|
||||
dialog.getButtonTable().row();
|
||||
dialog.getButtonTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblName") + ": ")).align(Align.left).pad(2, 15, 2, 2);
|
||||
dialog.getButtonTable().add(textInput).fillX().expandX().padRight(15);
|
||||
dialog.getButtonTable().row();
|
||||
dialogSaveBtn = Controls.newTextButton(Forge.getLocalizer().getMessage("lblSave"), () -> SaveLoadScene.this.save());
|
||||
dialog.getButtonTable().add(dialogSaveBtn).align(Align.left).padLeft(15);
|
||||
dialogAbortBtn = Controls.newTextButton(Forge.getLocalizer().getMessage("lblAbort"), () -> SaveLoadScene.this.saveAbort());
|
||||
dialog.getButtonTable().add(dialogAbortBtn).align(Align.right).padRight(15);
|
||||
|
||||
//makes dialog hidden immediately when you open saveload scene..
|
||||
dialog.getColor().a = 0;
|
||||
dialog.hide();
|
||||
previewImage = ui.findActor("preview");
|
||||
previewDate = ui.findActor("saveDate");
|
||||
header = Controls.newLabel(Forge.getLocalizer().getMessage("lblSave"));
|
||||
header.setAlignment(Align.center);
|
||||
layout.add(header).pad(2).colspan(4).align(Align.center).expandX();
|
||||
layout.row();
|
||||
autoSave = addSaveSlot(Forge.getLocalizer().getMessage("lblAutoSave"), WorldSave.AUTO_SAVE_SLOT);
|
||||
quickSave = addSaveSlot(Forge.getLocalizer().getMessage("lblQuickSave"), WorldSave.QUICK_SAVE_SLOT);
|
||||
for (int i = 1; i < 11; i++)
|
||||
addSaveSlot(Forge.getLocalizer().getMessage("lblSlot") + ": " + i, i);
|
||||
|
||||
saveLoadButton = ui.findActor("save");
|
||||
saveLoadButton.getLabel().setText(Forge.getLocalizer().getMessage("lblSave"));
|
||||
ui.onButtonPress("save", () -> SaveLoadScene.this.loadSave());
|
||||
back = ui.findActor("return");
|
||||
back.getLabel().setText(Forge.getLocalizer().getMessage("lblBack"));
|
||||
ui.onButtonPress("return", () -> SaveLoadScene.this.back());
|
||||
|
||||
defColor = saveLoadButton.getColor();
|
||||
|
||||
scrollPane = ui.findActor("saveSlots");
|
||||
scrollPane.setActor(layout);
|
||||
ui.addActor(difficulty);
|
||||
difficulty.setSelectedIndex(1);
|
||||
difficulty.setAlignment(Align.center);
|
||||
difficulty.getStyle().fontColor = Color.GOLD;
|
||||
if (Forge.isLandscapeMode()) {
|
||||
difficulty.setX(280);
|
||||
difficulty.setY(220);
|
||||
} else {
|
||||
difficulty.setX(190);
|
||||
difficulty.setY(336);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,9 @@ import forge.adventure.util.Config;
|
||||
/**
|
||||
* Base class for all rendered scenes
|
||||
*/
|
||||
public abstract class Scene implements Disposable {
|
||||
public abstract class Scene<T> implements Disposable {
|
||||
|
||||
public Scene() {
|
||||
|
||||
}
|
||||
|
||||
public static int getIntendedWidth() {
|
||||
@@ -35,8 +34,6 @@ public abstract class Scene implements Disposable {
|
||||
return new TextureRegionDrawable(new Texture(Config.instance().getFile(path)));
|
||||
}
|
||||
|
||||
public void resLoaded() {
|
||||
}
|
||||
|
||||
public boolean leave() {
|
||||
return true;
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package forge.adventure.scene;
|
||||
|
||||
/**
|
||||
* Enum of all scenes
|
||||
*/
|
||||
public enum SceneType {
|
||||
StartScene(new StartScene()),
|
||||
NewGameScene(new NewGameScene()),
|
||||
SettingsScene(new SettingsScene()),
|
||||
GameScene(new GameScene()),
|
||||
DuelScene(new DuelScene()),
|
||||
SaveLoadScene(new SaveLoadScene()),
|
||||
DeckEditScene(new DeckEditScene()),
|
||||
TileMapScene(new TileMapScene()),
|
||||
RewardScene(new RewardScene()),
|
||||
InnScene(new InnScene()),
|
||||
DeckSelectScene(new DeckSelectScene()),
|
||||
ShopScene(new ShopScene()),
|
||||
PlayerStatisticScene(new PlayerStatisticScene()),
|
||||
InventoryScene(new InventoryScene()),
|
||||
SpellSmithScene(new SpellSmithScene());
|
||||
|
||||
public final Scene instance;
|
||||
SceneType(Scene scene) {
|
||||
this.instance = scene;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
package forge.adventure.scene;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.adventure.util.Controls;
|
||||
@@ -23,124 +23,13 @@ public class SettingsScene extends UIScene {
|
||||
static public ForgePreferences Preference;
|
||||
Stage stage;
|
||||
Texture Background;
|
||||
private Table settingGroup;
|
||||
TextButton back;
|
||||
private final Table settingGroup;
|
||||
TextraButton backButton;
|
||||
ScrollPane scrollPane;
|
||||
|
||||
public SettingsScene() {
|
||||
private SettingsScene() {
|
||||
super(Forge.isLandscapeMode() ? "ui/settings.json" : "ui/settings_portrait.json");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (stage != null)
|
||||
stage.dispose();
|
||||
}
|
||||
|
||||
public void renderAct(float delta) {
|
||||
Gdx.gl.glClearColor(1, 0, 1, 1);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
stage.getBatch().begin();
|
||||
stage.getBatch().disableBlending();
|
||||
stage.getBatch().draw(Background, 0, 0, getIntendedWidth(), getIntendedHeight());
|
||||
stage.getBatch().enableBlending();
|
||||
stage.getBatch().end();
|
||||
stage.act(delta);
|
||||
stage.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keycode) {
|
||||
if (keycode == Input.Keys.ESCAPE || keycode == Input.Keys.BACK) {
|
||||
back();
|
||||
}
|
||||
if (keycode == Input.Keys.BUTTON_B)
|
||||
performTouch(back);
|
||||
else if (keycode == Input.Keys.BUTTON_L1) {
|
||||
scrollPane.fling(1f, 0, -300);
|
||||
} else if (keycode == Input.Keys.BUTTON_R1) {
|
||||
scrollPane.fling(1f, 0, +300);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean back() {
|
||||
Forge.switchToLast();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void addInputField(String name, ForgePreferences.FPref pref) {
|
||||
TextField box = Controls.newTextField("");
|
||||
box.setText(Preference.getPref(pref));
|
||||
box.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
Preference.setPref(pref, ((TextField) actor).getText());
|
||||
Preference.save();
|
||||
}
|
||||
});
|
||||
|
||||
addLabel(name);
|
||||
settingGroup.add(box).align(Align.right);
|
||||
}
|
||||
|
||||
private void addCheckBox(String name, ForgePreferences.FPref pref) {
|
||||
CheckBox box = Controls.newCheckBox("");
|
||||
box.setChecked(Preference.getPrefBoolean(pref));
|
||||
box.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
Preference.setPref(pref, ((CheckBox) actor).isChecked());
|
||||
Preference.save();
|
||||
}
|
||||
});
|
||||
|
||||
addLabel(name);
|
||||
settingGroup.add(box).align(Align.right);
|
||||
}
|
||||
|
||||
private void addSettingSlider(String name, ForgePreferences.FPref pref, int min, int max) {
|
||||
Slider slide = Controls.newSlider(min, max, 1, false);
|
||||
slide.setValue(Preference.getPrefInt(pref));
|
||||
slide.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
Preference.setPref(pref, String.valueOf((int) ((Slider) actor).getValue()));
|
||||
Preference.save();
|
||||
}
|
||||
});
|
||||
addLabel(name);
|
||||
settingGroup.add(slide).align(Align.right);
|
||||
}
|
||||
|
||||
private void addSettingField(String name, boolean value, ChangeListener change) {
|
||||
CheckBox box = Controls.newCheckBox("");
|
||||
box.setChecked(value);
|
||||
box.addListener(change);
|
||||
addLabel(name);
|
||||
settingGroup.add(box).align(Align.right);
|
||||
}
|
||||
|
||||
private void addSettingField(String name, int value, ChangeListener change) {
|
||||
TextField text = Controls.newTextField(String.valueOf(value));
|
||||
text.setTextFieldFilter((textField, c) -> Character.isDigit(c));
|
||||
text.addListener(change);
|
||||
addLabel(name);
|
||||
settingGroup.add(text).align(Align.right);
|
||||
}
|
||||
|
||||
void addLabel(String name) {
|
||||
Label label = Controls.newLabel(name);
|
||||
label.setWrap(true);
|
||||
settingGroup.row().space(5);
|
||||
int w = Forge.isLandscapeMode() ? 160 : 80;
|
||||
settingGroup.add(label).align(Align.left).pad(2, 2, 2, 5).width(w).expand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
super.resLoaded();
|
||||
settingGroup = new Table();
|
||||
if (Preference == null) {
|
||||
Preference = new ForgePreferences();
|
||||
@@ -271,15 +160,121 @@ public class SettingsScene extends UIScene {
|
||||
|
||||
|
||||
settingGroup.row();
|
||||
back = ui.findActor("return");
|
||||
back.getLabel().setText(Forge.getLocalizer().getMessage("lblBack"));
|
||||
ui.onButtonPress("return", () -> SettingsScene.this.back());
|
||||
backButton = ui.findActor("return");
|
||||
ui.onButtonPress("return", SettingsScene.this::back);
|
||||
|
||||
scrollPane = ui.findActor("settings");
|
||||
ScrollPane scrollPane = ui.findActor("settings");
|
||||
scrollPane.setActor(settingGroup);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keycode) {
|
||||
if (keycode == Input.Keys.ESCAPE || keycode == Input.Keys.BACK) {
|
||||
back();
|
||||
}
|
||||
if (keycode == Input.Keys.BUTTON_B)
|
||||
performTouch(backButton);
|
||||
else if (keycode == Input.Keys.BUTTON_L1) {
|
||||
scrollPane.fling(1f, 0, -300);
|
||||
} else if (keycode == Input.Keys.BUTTON_R1) {
|
||||
scrollPane.fling(1f, 0, +300);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean back() {
|
||||
Forge.switchToLast();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void addInputField(String name, ForgePreferences.FPref pref) {
|
||||
TextField box = Controls.newTextField("");
|
||||
box.setText(Preference.getPref(pref));
|
||||
box.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
Preference.setPref(pref, ((TextField) actor).getText());
|
||||
Preference.save();
|
||||
}
|
||||
});
|
||||
|
||||
addLabel(name);
|
||||
settingGroup.add(box).align(Align.right);
|
||||
}
|
||||
|
||||
private void addCheckBox(String name, ForgePreferences.FPref pref) {
|
||||
CheckBox box = Controls.newCheckBox("");
|
||||
box.setChecked(Preference.getPrefBoolean(pref));
|
||||
box.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
Preference.setPref(pref, ((CheckBox) actor).isChecked());
|
||||
Preference.save();
|
||||
}
|
||||
});
|
||||
|
||||
addLabel(name);
|
||||
settingGroup.add(box).align(Align.right);
|
||||
}
|
||||
|
||||
private void addSettingSlider(String name, ForgePreferences.FPref pref, int min, int max) {
|
||||
Slider slide = Controls.newSlider(min, max, 1, false);
|
||||
slide.setValue(Preference.getPrefInt(pref));
|
||||
slide.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
Preference.setPref(pref, String.valueOf((int) ((Slider) actor).getValue()));
|
||||
Preference.save();
|
||||
}
|
||||
});
|
||||
addLabel(name);
|
||||
settingGroup.add(slide).align(Align.right);
|
||||
}
|
||||
|
||||
private void addSettingField(String name, boolean value, ChangeListener change) {
|
||||
CheckBox box = Controls.newCheckBox("");
|
||||
box.setChecked(value);
|
||||
box.addListener(change);
|
||||
addLabel(name);
|
||||
settingGroup.add(box).align(Align.right);
|
||||
}
|
||||
|
||||
private void addSettingField(String name, int value, ChangeListener change) {
|
||||
TextField text = Controls.newTextField(String.valueOf(value));
|
||||
text.setTextFieldFilter((textField, c) -> Character.isDigit(c));
|
||||
text.addListener(change);
|
||||
addLabel(name);
|
||||
settingGroup.add(text).align(Align.right);
|
||||
}
|
||||
|
||||
void addLabel(String name) {
|
||||
TextraLabel label = Controls.newTextraLabel(name);
|
||||
label.setWrap(true);
|
||||
settingGroup.row().space(5);
|
||||
int w = Forge.isLandscapeMode() ? 160 : 80;
|
||||
settingGroup.add(label).align(Align.left).pad(2, 2, 2, 5).width(w).expand();
|
||||
}
|
||||
|
||||
|
||||
private static SettingsScene object;
|
||||
|
||||
public static SettingsScene instance() {
|
||||
if(object==null)
|
||||
object=new SettingsScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (stage != null)
|
||||
stage.dispose();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
|
||||
|
||||
@@ -8,10 +8,17 @@ import forge.screens.FScreen;
|
||||
* scene class that contains the Deck editor
|
||||
*/
|
||||
public class ShopScene extends ForgeScene {
|
||||
private static ShopScene object;
|
||||
|
||||
public static ShopScene instance() {
|
||||
if(object==null)
|
||||
object=new ShopScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
AdventureDeckEditor screen;
|
||||
|
||||
public ShopScene() {
|
||||
private ShopScene() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@ package forge.adventure.scene;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.StaticData;
|
||||
import forge.adventure.data.RewardData;
|
||||
@@ -19,6 +19,7 @@ import forge.adventure.util.RewardActor;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.ColorSet;
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.*;
|
||||
@@ -27,26 +28,117 @@ import java.util.stream.StreamSupport;
|
||||
|
||||
|
||||
public class SpellSmithScene extends UIScene {
|
||||
|
||||
private static SpellSmithScene object;
|
||||
|
||||
public static SpellSmithScene instance() {
|
||||
if(object==null)
|
||||
object=new SpellSmithScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
private List<PaperCard> cardPool = new ArrayList<>();
|
||||
private Label goldLabel;
|
||||
private TextButton pullButton;
|
||||
private ScrollPane rewardDummy;
|
||||
private final TextraLabel goldLabel;
|
||||
private final TextraButton pullButton;
|
||||
private final ScrollPane rewardDummy;
|
||||
private RewardActor rewardActor;
|
||||
SelectBox<CardEdition> editionList;
|
||||
//Button containers.
|
||||
final private HashMap<String, TextButton> rarityButtons = new HashMap<>();
|
||||
final private HashMap<String, TextButton> costButtons = new HashMap<>();
|
||||
final private HashMap<String, TextButton> colorButtons = new HashMap<>();
|
||||
final private HashMap<String, TextraButton> rarityButtons = new HashMap<>();
|
||||
final private HashMap<String, TextraButton> costButtons = new HashMap<>();
|
||||
final private HashMap<String, TextraButton> colorButtons = new HashMap<>();
|
||||
//Filter variables.
|
||||
private String edition = "";
|
||||
private String rarity = "";
|
||||
private int cost_low = -1;
|
||||
private int cost_high = 9999;
|
||||
//Other
|
||||
private float basePrice = 125f;
|
||||
private final float basePrice = 125f;
|
||||
private int currentPrice = 0;
|
||||
|
||||
public SpellSmithScene() { super(Forge.isLandscapeMode() ? "ui/spellsmith.json" : "ui/spellsmith_portrait.json"); }
|
||||
private SpellSmithScene() { super(Forge.isLandscapeMode() ? "ui/spellsmith.json" : "ui/spellsmith_portrait.json");
|
||||
|
||||
List<CardEdition> editions = StaticData.instance().getSortedEditions();
|
||||
editions = editions.stream().filter(input -> {
|
||||
if(input == null)
|
||||
return false;
|
||||
if(input.getType()== CardEdition.Type.REPRINT||input.getType()== CardEdition.Type.PROMO||input.getType()== CardEdition.Type.COLLECTOR_EDITION)
|
||||
return false;
|
||||
List<PaperCard> it = StreamSupport.stream(RewardData.getAllCards().spliterator(), false)
|
||||
.filter(input2 -> input2.getEdition().equals(input.getCode())).collect(Collectors.toList());
|
||||
if(it.size()==0)
|
||||
return false;
|
||||
return(!Arrays.asList(Config.instance().getConfigData().restrictedEditions).contains(input.getCode()));
|
||||
}).collect(Collectors.toList());
|
||||
editionList = ui.findActor("BSelectPlane");
|
||||
rewardDummy = ui.findActor("RewardDummy");
|
||||
rewardDummy.setVisible(false);
|
||||
editionList.clearItems();
|
||||
editionList.showScrollPane();
|
||||
editionList.setItems(editions.toArray(new CardEdition[editions.size()]));
|
||||
editionList.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor){
|
||||
CardEdition E = editionList.getSelected();
|
||||
edition = E.getCode();
|
||||
editionList.setColor(Color.RED);
|
||||
filterResults();
|
||||
}
|
||||
});
|
||||
|
||||
goldLabel = ui.findActor("gold");
|
||||
pullButton = ui.findActor("pull");
|
||||
pullButton.setDisabled(true);
|
||||
goldLabel.setText("Gold: "+ Current.player().getGold());
|
||||
for(String i : new String[]{"BBlack", "BBlue", "BGreen", "BRed", "BWhite", "BColorless"} ){
|
||||
TextraButton button = ui.findActor(i);
|
||||
if(button != null){
|
||||
colorButtons.put(i, button);
|
||||
button.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y){
|
||||
selectColor(i);
|
||||
filterResults();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
for(String i : new String[]{"BCommon", "BUncommon", "BRare", "BMythic"} ){
|
||||
TextraButton button = ui.findActor(i);
|
||||
if(button != null) {
|
||||
rarityButtons.put(i, button);
|
||||
button.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
if(selectRarity(i)) button.setColor(Color.RED);
|
||||
filterResults();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
for(String i : new String[]{"B02", "B35", "B68", "B9X"} ){
|
||||
TextraButton button = ui.findActor(i);
|
||||
if(button != null) {
|
||||
costButtons.put(i, button);
|
||||
button.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
if(selectCost(i)) button.setColor(Color.RED);
|
||||
filterResults();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ui.onButtonPress("done", () -> SpellSmithScene.this.done());
|
||||
ui.onButtonPress("pull", () -> SpellSmithScene.this.pullCard());
|
||||
ui.onButtonPress("BResetEdition", () -> {
|
||||
editionList.setColor(Color.WHITE);
|
||||
edition = "";
|
||||
filterResults();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public boolean done() {
|
||||
if(rewardActor != null) rewardActor.remove();
|
||||
@@ -56,7 +148,7 @@ public class SpellSmithScene extends UIScene {
|
||||
}
|
||||
|
||||
private boolean selectRarity(String what){
|
||||
for(Map.Entry<String, TextButton> B : rarityButtons.entrySet())
|
||||
for(Map.Entry<String, TextraButton> B : rarityButtons.entrySet())
|
||||
B.getValue().setColor(Color.WHITE);
|
||||
switch(what){
|
||||
case "BCommon":
|
||||
@@ -78,11 +170,11 @@ public class SpellSmithScene extends UIScene {
|
||||
}
|
||||
|
||||
private void selectColor(String what){
|
||||
TextButton B = colorButtons.get(what);
|
||||
TextraButton B = colorButtons.get(what);
|
||||
switch(what){
|
||||
case "BColorless":
|
||||
if(B.getColor().equals(Color.RED)) B.setColor(Color.WHITE); else {
|
||||
for (Map.Entry<String, TextButton> BT : colorButtons.entrySet())
|
||||
for (Map.Entry<String, TextraButton> BT : colorButtons.entrySet())
|
||||
BT.getValue().setColor(Color.WHITE);
|
||||
B.setColor(Color.RED);
|
||||
}
|
||||
@@ -99,7 +191,7 @@ public class SpellSmithScene extends UIScene {
|
||||
}
|
||||
|
||||
private boolean selectCost(String what){
|
||||
for(Map.Entry<String, TextButton> B : costButtons.entrySet())
|
||||
for(Map.Entry<String, TextraButton> B : costButtons.entrySet())
|
||||
B.getValue().setColor(Color.WHITE);
|
||||
switch(what){
|
||||
case "B02":
|
||||
@@ -126,113 +218,23 @@ public class SpellSmithScene extends UIScene {
|
||||
cost_low = -1; cost_high = 9999;
|
||||
rarity = "";
|
||||
currentPrice = (int)basePrice;
|
||||
goldLabel.setText("Gold: "+ Current.player().getGold());
|
||||
goldLabel.setText(Current.player().getGold()+"[+Gold]");
|
||||
|
||||
for(Map.Entry<String, TextButton> B : colorButtons.entrySet()) B.getValue().setColor(Color.WHITE);
|
||||
for(Map.Entry<String, TextButton> B : costButtons.entrySet()) B.getValue().setColor(Color.WHITE);
|
||||
for(Map.Entry<String, TextButton> B : rarityButtons.entrySet()) B.getValue().setColor(Color.WHITE);
|
||||
for(Map.Entry<String, TextraButton> B : colorButtons.entrySet()) B.getValue().setColor(Color.WHITE);
|
||||
for(Map.Entry<String, TextraButton> B : costButtons.entrySet()) B.getValue().setColor(Color.WHITE);
|
||||
for(Map.Entry<String, TextraButton> B : rarityButtons.entrySet()) B.getValue().setColor(Color.WHITE);
|
||||
editionList.setColor(Color.WHITE);
|
||||
filterResults();
|
||||
super.enter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
super.resLoaded();
|
||||
List<CardEdition> editions = StaticData.instance().getSortedEditions();
|
||||
editions = editions.stream().filter(input -> {
|
||||
if(input == null) return false;
|
||||
return(!Arrays.asList(Config.instance().getConfigData().restrictedEditions).contains(input.getCode()));
|
||||
}).collect(Collectors.toList());
|
||||
editionList = ui.findActor("BSelectPlane");
|
||||
rewardDummy = ui.findActor("RewardDummy");
|
||||
rewardDummy.setVisible(false);
|
||||
editionList.clearItems();
|
||||
editionList.showScrollPane();
|
||||
editionList.setItems(editions.toArray(new CardEdition[editions.size()]));
|
||||
editionList.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor){
|
||||
CardEdition E = editionList.getSelected();
|
||||
edition = E.getCode();
|
||||
editionList.setColor(Color.RED);
|
||||
filterResults();
|
||||
}
|
||||
});
|
||||
|
||||
goldLabel = ui.findActor("gold");
|
||||
pullButton = ui.findActor("pull");
|
||||
pullButton.setDisabled(true);
|
||||
goldLabel.setText("Gold: "+ Current.player().getGold());
|
||||
for(String i : new String[]{"BBlack", "BBlue", "BGreen", "BRed", "BWhite", "BColorless"} ){
|
||||
TextButton button = ui.findActor(i);
|
||||
if(button != null){
|
||||
colorButtons.put(i, button);
|
||||
button.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y){
|
||||
selectColor(i);
|
||||
filterResults();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
for(String i : new String[]{"BCommon", "BUncommon", "BRare", "BMythic"} ){
|
||||
TextButton button = ui.findActor(i);
|
||||
if(button != null) {
|
||||
rarityButtons.put(i, button);
|
||||
button.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
if(selectRarity(i)) button.setColor(Color.RED);
|
||||
filterResults();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
for(String i : new String[]{"B02", "B35", "B68", "B9X"} ){
|
||||
TextButton button = ui.findActor(i);
|
||||
if(button != null) {
|
||||
costButtons.put(i, button);
|
||||
button.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
if(selectCost(i)) button.setColor(Color.RED);
|
||||
filterResults();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ui.onButtonPress("done", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SpellSmithScene.this.done();
|
||||
}
|
||||
});
|
||||
ui.onButtonPress("pull", new Runnable() {
|
||||
@Override
|
||||
public void run() { SpellSmithScene.this.pullCard(); }
|
||||
});
|
||||
ui.onButtonPress("BResetEdition", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
editionList.setColor(Color.WHITE);
|
||||
edition = "";
|
||||
filterResults();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void filterResults() {
|
||||
RewardData R = new RewardData();
|
||||
Iterable<PaperCard> P = R.getAllCards();
|
||||
goldLabel.setText("Gold: "+ Current.player().getGold());
|
||||
Iterable<PaperCard> P = RewardData.getAllCards();
|
||||
goldLabel.setText( Current.player().getGold()+"[+Gold]");
|
||||
float totalCost = basePrice * Current.player().goldModifier();
|
||||
final List<String> colorFilter = new ArrayList<>();
|
||||
for(Map.Entry<String, TextButton> B : colorButtons.entrySet())
|
||||
for(Map.Entry<String, TextraButton> B : colorButtons.entrySet())
|
||||
switch (B.getKey()){
|
||||
case "BColorless":
|
||||
if(B.getValue().getColor().equals(Color.RED)) colorFilter.add("Colorless");
|
||||
@@ -256,7 +258,9 @@ public class SpellSmithScene extends UIScene {
|
||||
P = StreamSupport.stream(P.spliterator(), false).filter(input -> {
|
||||
//L|Basic Land, C|Common, U|Uncommon, R|Rare, M|Mythic Rare, S|Special, N|None
|
||||
if (input == null) return false;
|
||||
if(!edition.isEmpty()) if (!input.getEdition().equals(edition)) return false;
|
||||
final CardEdition cardEdition = FModel.getMagicDb().getEditions().get(edition);
|
||||
|
||||
if(cardEdition!=null&&cardEdition.getCardInSet(input.getName()).size()==0) return false;
|
||||
if(colorFilter.size() > 0) if(input.getRules().getColor() != ColorSet.fromNames(colorFilter)) return false;
|
||||
if(!rarity.isEmpty()) if (!input.getRarity().toString().equals(rarity)) return false;
|
||||
if(cost_low > -1) {
|
||||
|
||||
@@ -3,8 +3,8 @@ package forge.adventure.scene;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import forge.Forge;
|
||||
import forge.adventure.stage.GameHUD;
|
||||
import forge.adventure.stage.GameStage;
|
||||
@@ -20,37 +20,73 @@ import forge.screens.TransitionScreen;
|
||||
*/
|
||||
public class StartScene extends UIScene {
|
||||
|
||||
TextButton saveButton, resumeButton, continueButton, newGameButton, newGameButtonPlus, loadButton, settingsButton, exitButton, switchButton, dialogOk, dialogCancel, dialogButtonSelected;
|
||||
private static StartScene object;
|
||||
TextraButton saveButton, resumeButton, continueButton, newGameButton, newGameButtonPlus, loadButton, settingsButton, exitButton, switchButton, dialogOk, dialogCancel, dialogButtonSelected;
|
||||
Dialog dialog;
|
||||
private int selected = -1;
|
||||
|
||||
public StartScene() {
|
||||
super(Forge.isLandscapeMode() ? "ui/start_menu.json" : "ui/start_menu_portrait.json");
|
||||
ui.onButtonPress("Start", () -> StartScene.this.NewGame());
|
||||
ui.onButtonPress("Start+", () -> NewGamePlus());
|
||||
ui.onButtonPress("Load", () -> StartScene.this.Load());
|
||||
ui.onButtonPress("Save", () -> StartScene.this.Save());
|
||||
ui.onButtonPress("Resume", () -> StartScene.this.Resume());
|
||||
ui.onButtonPress("Continue", () -> StartScene.this.Continue());
|
||||
ui.onButtonPress("Settings", () -> StartScene.this.settings());
|
||||
ui.onButtonPress("Exit", () -> StartScene.this.Exit());
|
||||
ui.onButtonPress("Switch", () -> Forge.switchToClassic());
|
||||
|
||||
newGameButton = ui.findActor("Start");
|
||||
loadButton = ui.findActor("Load");
|
||||
saveButton = ui.findActor("Save");
|
||||
resumeButton = ui.findActor("Resume");
|
||||
continueButton = ui.findActor("Continue");
|
||||
settingsButton = ui.findActor("Settings");
|
||||
exitButton = ui.findActor("Exit");
|
||||
switchButton = ui.findActor("Switch");
|
||||
|
||||
saveButton.setVisible(false);
|
||||
resumeButton.setVisible(false);
|
||||
dialog = Controls.newDialog(Forge.getLocalizer().getMessage("lblExitForge"));
|
||||
dialog.getButtonTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblAreYouSureYouWishExitForge"))).colspan(2).pad(2, 15, 2, 15);
|
||||
dialog.getButtonTable().row();
|
||||
dialogOk = Controls.newTextButton(Forge.getLocalizer().getMessage("lblExit"), () -> Forge.exit(true));
|
||||
dialogButtonSelected = dialogOk;
|
||||
dialog.getButtonTable().add(dialogOk).width(60).align(Align.left).padLeft(15);
|
||||
dialogCancel = Controls.newTextButton(Forge.getLocalizer().getMessage("lblCancel"), () -> dialog.hide());
|
||||
dialog.getButtonTable().add(dialogCancel).width(60).align(Align.right).padRight(15);
|
||||
dialog.getColor().a = 0;
|
||||
}
|
||||
|
||||
public static StartScene instance() {
|
||||
if(object==null)
|
||||
object=new StartScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
public boolean NewGame() {
|
||||
Forge.switchScene(SceneType.NewGameScene.instance);
|
||||
Forge.switchScene(NewGameScene.instance());
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean Save() {
|
||||
((SaveLoadScene) SceneType.SaveLoadScene.instance).setMode(SaveLoadScene.Modes.Save);
|
||||
Forge.switchScene(SceneType.SaveLoadScene.instance);
|
||||
SaveLoadScene.instance().setMode(SaveLoadScene.Modes.Save);
|
||||
Forge.switchScene(SaveLoadScene.instance());
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean Load() {
|
||||
((SaveLoadScene) SceneType.SaveLoadScene.instance).setMode(SaveLoadScene.Modes.Load);
|
||||
Forge.switchScene(SceneType.SaveLoadScene.instance);
|
||||
SaveLoadScene.instance().setMode(SaveLoadScene.Modes.Load);
|
||||
Forge.switchScene(SaveLoadScene.instance());
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean Resume() {
|
||||
if (MapStage.getInstance().isInMap())
|
||||
Forge.switchScene(SceneType.TileMapScene.instance);
|
||||
Forge.switchScene(TileMapScene.instance());
|
||||
else
|
||||
Forge.switchScene(SceneType.GameScene.instance);
|
||||
Forge.switchScene(GameScene.instance());
|
||||
GameHUD.getInstance().getTouchpad().setVisible(false);
|
||||
return true;
|
||||
}
|
||||
@@ -62,7 +98,7 @@ public class StartScene extends UIScene {
|
||||
try {
|
||||
Forge.setTransitionScreen(new TransitionScreen(() -> {
|
||||
if (WorldSave.load(WorldSave.filenameToSlot(lastActiveSave))) {
|
||||
Forge.switchScene(SceneType.GameScene.instance);
|
||||
Forge.switchScene(GameScene.instance());
|
||||
} else {
|
||||
Forge.clearTransitionScreen();
|
||||
}
|
||||
@@ -76,15 +112,13 @@ public class StartScene extends UIScene {
|
||||
}
|
||||
|
||||
public boolean settings() {
|
||||
Forge.switchScene(SceneType.SettingsScene.instance);
|
||||
Forge.switchScene(SettingsScene.instance());
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean Exit() {
|
||||
if (dialog != null)
|
||||
dialog.show(stage);
|
||||
if (showGamepadSelector)
|
||||
dialogOk.fire(eventEnter);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -92,7 +126,7 @@ public class StartScene extends UIScene {
|
||||
public void enter() {
|
||||
boolean hasSaveButton = WorldSave.getCurrentSave().getWorld().getData() != null;
|
||||
if (hasSaveButton) {
|
||||
TileMapScene scene = (TileMapScene) SceneType.TileMapScene.instance;
|
||||
TileMapScene scene = TileMapScene.instance();
|
||||
hasSaveButton = !scene.currentMap().isInMap() || scene.inTown();
|
||||
}
|
||||
saveButton.setVisible(hasSaveButton);
|
||||
@@ -119,6 +153,8 @@ public class StartScene extends UIScene {
|
||||
Current.setDebug(true);
|
||||
GameStage.maximumScrollDistance=4f;
|
||||
}
|
||||
|
||||
super.enter();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -126,17 +162,6 @@ public class StartScene extends UIScene {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pointerMoved(int screenX, int screenY) {
|
||||
ui.screenToLocalCoordinates(pointer.set(screenX,screenY));
|
||||
if (showGamepadSelector) {
|
||||
unSelectAll();
|
||||
showGamepadSelector = false;
|
||||
}
|
||||
updateSelected();
|
||||
return super.pointerMoved(screenX, screenY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keycode) {
|
||||
if (Forge.hasGamepad())
|
||||
@@ -346,53 +371,9 @@ public class StartScene extends UIScene {
|
||||
selected = Forge.isLandscapeMode() ? 8 : 7;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
super.resLoaded();
|
||||
ui.onButtonPress("Start", () -> StartScene.this.NewGame());
|
||||
ui.onButtonPress("Start+", () -> NewGamePlus());
|
||||
ui.onButtonPress("Load", () -> StartScene.this.Load());
|
||||
ui.onButtonPress("Save", () -> StartScene.this.Save());
|
||||
ui.onButtonPress("Resume", () -> StartScene.this.Resume());
|
||||
ui.onButtonPress("Continue", () -> StartScene.this.Continue());
|
||||
ui.onButtonPress("Settings", () -> StartScene.this.settings());
|
||||
ui.onButtonPress("Exit", () -> StartScene.this.Exit());
|
||||
ui.onButtonPress("Switch", () -> Forge.switchToClassic());
|
||||
|
||||
newGameButton = ui.findActor("Start");
|
||||
newGameButton.getLabel().setText(Forge.getLocalizer().getMessage("lblNewGame"));
|
||||
newGameButtonPlus = ui.findActor("Start+");
|
||||
newGameButtonPlus.getLabel().setText(Forge.getLocalizer().getMessage("lblNewGame") + "+");
|
||||
loadButton = ui.findActor("Load");
|
||||
loadButton.getLabel().setText(Forge.getLocalizer().getMessage("lblLoad"));
|
||||
saveButton = ui.findActor("Save");
|
||||
saveButton.getLabel().setText(Forge.getLocalizer().getMessage("lblSave"));
|
||||
resumeButton = ui.findActor("Resume");
|
||||
resumeButton.getLabel().setText(Forge.getLocalizer().getMessage("lblResume"));
|
||||
continueButton = ui.findActor("Continue");
|
||||
continueButton.getLabel().setText(Forge.getLocalizer().getMessage("lblContinue"));
|
||||
settingsButton = ui.findActor("Settings");
|
||||
settingsButton.getLabel().setText(Forge.getLocalizer().getMessage("lblSettings"));
|
||||
exitButton = ui.findActor("Exit");
|
||||
exitButton.getLabel().setText(Forge.getLocalizer().getMessage("lblExit"));
|
||||
switchButton = ui.findActor("Switch");
|
||||
switchButton.getLabel().setText(Forge.getLocalizer().getMessage("lblClassic"));
|
||||
|
||||
saveButton.setVisible(false);
|
||||
resumeButton.setVisible(false);
|
||||
dialog = Controls.newDialog(Forge.getLocalizer().getMessage("lblExitForge"));
|
||||
dialog.getButtonTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblAreYouSureYouWishExitForge"))).colspan(2).pad(2, 15, 2, 15);
|
||||
dialog.getButtonTable().row();
|
||||
dialogOk = Controls.newTextButton(Forge.getLocalizer().getMessage("lblExit"), () -> Forge.exit(true));
|
||||
dialogButtonSelected = dialogOk;
|
||||
dialog.getButtonTable().add(dialogOk).width(60).align(Align.left).padLeft(15);
|
||||
dialogCancel = Controls.newTextButton(Forge.getLocalizer().getMessage("lblCancel"), () -> dialog.hide());
|
||||
dialog.getButtonTable().add(dialogCancel).width(60).align(Align.right).padRight(15);
|
||||
dialog.getColor().a = 0;
|
||||
}
|
||||
|
||||
private void NewGamePlus() {
|
||||
((SaveLoadScene) SceneType.SaveLoadScene.instance).setMode(SaveLoadScene.Modes.NewGamePlus);
|
||||
Forge.switchScene(SceneType.SaveLoadScene.instance);
|
||||
SaveLoadScene.instance().setMode(SaveLoadScene.Modes.NewGamePlus);
|
||||
Forge.switchScene(SaveLoadScene.instance());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import forge.adventure.stage.MapStage;
|
||||
import forge.adventure.stage.PointOfInterestMapRenderer;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.adventure.util.Current;
|
||||
import forge.adventure.util.Paths;
|
||||
import forge.adventure.util.TemplateTmxMapLoader;
|
||||
import forge.adventure.world.WorldSave;
|
||||
import forge.sound.SoundEffectType;
|
||||
@@ -18,16 +19,27 @@ import forge.sound.SoundSystem;
|
||||
* Scene that will render tiled maps.
|
||||
* Used for towns dungeons etc
|
||||
*/
|
||||
public class TileMapScene extends HudScene {
|
||||
public class TileMapScene extends HudScene {
|
||||
TiledMap map;
|
||||
PointOfInterestMapRenderer tiledMapRenderer;
|
||||
private String nextMap;
|
||||
private boolean autoheal = false;
|
||||
private float cameraWidth = 0f, cameraHeight = 0f;
|
||||
|
||||
public TileMapScene() {
|
||||
private TileMapScene() {
|
||||
super(MapStage.getInstance());
|
||||
tiledMapRenderer = new PointOfInterestMapRenderer((MapStage) stage);
|
||||
|
||||
|
||||
//set initial camera width and height
|
||||
MapStage.getInstance().setDialogStage(hud);
|
||||
}
|
||||
|
||||
private static TileMapScene object;
|
||||
|
||||
public static TileMapScene instance() {
|
||||
if(object==null)
|
||||
object=new TileMapScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
public MapStage currentMap() {
|
||||
@@ -50,7 +62,8 @@ public class TileMapScene extends HudScene {
|
||||
}
|
||||
stage.act(Gdx.graphics.getDeltaTime());
|
||||
hud.act(Gdx.graphics.getDeltaTime());
|
||||
if (autoheal) { //todo add simple bg animation or effect
|
||||
if (autoheal) { //todo add better effect
|
||||
stage.getPlayerSprite().playEffect(Paths.EFFECT_HEAL,2);
|
||||
SoundSystem.instance.play(SoundEffectType.Enchantment, false);
|
||||
autoheal = false;
|
||||
}
|
||||
@@ -67,23 +80,12 @@ public class TileMapScene extends HudScene {
|
||||
tiledMapRenderer.setView(stage.getCamera().combined, stage.getCamera().position.x - Scene.getIntendedWidth() / 2.0f, stage.getCamera().position.y - Scene.getIntendedHeight() / 2.0f, Scene.getIntendedWidth(), Scene.getIntendedHeight());
|
||||
|
||||
if (!Forge.isLandscapeMode()) {
|
||||
stage.getCamera().position.x = stage.GetPlayer().pos().x;
|
||||
stage.getCamera().position.x = stage.getPlayerSprite().pos().x;
|
||||
}
|
||||
tiledMapRenderer.render();
|
||||
hud.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
MapStage.getInstance().resLoaded();
|
||||
//set initial camera width and height
|
||||
if (cameraWidth == 0f)
|
||||
cameraWidth = stage.getCamera().viewportWidth;
|
||||
if (cameraHeight == 0f)
|
||||
cameraHeight = stage.getCamera().viewportHeight;
|
||||
MapStage.getInstance().setDialogStage(hud);
|
||||
super.resLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
@@ -100,7 +102,7 @@ public class TileMapScene extends HudScene {
|
||||
oldMap = point.getData().map;
|
||||
map = new TemplateTmxMapLoader().load(Config.instance().getFilePath(point.getData().map));
|
||||
((MapStage) stage).setPointOfInterest(WorldSave.getCurrentSave().getPointOfInterestChanges(point.getID() + oldMap));
|
||||
stage.GetPlayer().setPosition(0, 0);
|
||||
stage.getPlayerSprite().setPosition(0, 0);
|
||||
WorldSave.getCurrentSave().getWorld().setSeed(point.getSeedOffset());
|
||||
tiledMapRenderer.loadMap(map, "");
|
||||
}
|
||||
@@ -115,7 +117,7 @@ public class TileMapScene extends HudScene {
|
||||
private void load(String targetMap) {
|
||||
map = new TemplateTmxMapLoader().load(Config.instance().getFilePath(targetMap));
|
||||
((MapStage) stage).setPointOfInterest(WorldSave.getCurrentSave().getPointOfInterestChanges(rootPoint.getID() + targetMap));
|
||||
stage.GetPlayer().setPosition(0, 0);
|
||||
stage.getPlayerSprite().setPosition(0, 0);
|
||||
WorldSave.getCurrentSave().getWorld().setSeed(rootPoint.getSeedOffset());
|
||||
tiledMapRenderer.loadMap(map, oldMap);
|
||||
oldMap = targetMap;
|
||||
@@ -130,5 +132,6 @@ public class TileMapScene extends HudScene {
|
||||
public void loadNext(String targetMap) {
|
||||
nextMap = targetMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,18 +9,14 @@ import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import com.badlogic.gdx.utils.Scaling;
|
||||
import com.badlogic.gdx.utils.Timer;
|
||||
import com.badlogic.gdx.utils.viewport.ScalingViewport;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import forge.Forge;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.adventure.util.Controls;
|
||||
@@ -35,9 +31,9 @@ public class UIScene extends Scene {
|
||||
Stage stage;
|
||||
|
||||
String uiFile;
|
||||
private Dialog keyboardDialog;
|
||||
private Label kbLabel;
|
||||
private TextButton keyA, keyB, keyC, keyD, keyE, keyF, keyG, keyH, keyI, keyJ, keyK, keyL, keyM, keyN, keyO, keyP,
|
||||
private final Dialog keyboardDialog;
|
||||
private final Label kbLabel;
|
||||
private final TextraButton keyA, keyB, keyC, keyD, keyE, keyF, keyG, keyH, keyI, keyJ, keyK, keyL, keyM, keyN, keyO, keyP,
|
||||
keyQ, keyR, keyS, keyT, keyU, keyV, keyW, keyX, keyY, keyZ, key1, key2, key3, key4, key5, key6, key7, key8,
|
||||
key9, key0, keyDot, keyComma, keyShift, keyBackspace, keySpace, keyOK;
|
||||
public Actor lastInputField;
|
||||
@@ -53,52 +49,6 @@ public class UIScene extends Scene {
|
||||
public UIScene(String uiFilePath) {
|
||||
|
||||
uiFile = uiFilePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (stage != null)
|
||||
stage.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
stage.act(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
Gdx.gl.glClearColor(0, 0, 0, 1);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
stage.draw();
|
||||
}
|
||||
|
||||
public UIActor getUI() {
|
||||
return ui;
|
||||
}
|
||||
|
||||
public boolean keyPressed(int keycode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean pointerMoved(int screenX, int screenY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void performTouch(Actor actor) {
|
||||
if (actor == null)
|
||||
return;
|
||||
actor.fire(eventTouchDown);
|
||||
Timer.schedule(new Timer.Task() {
|
||||
@Override
|
||||
public void run() {
|
||||
actor.fire(eventTouchUp);
|
||||
}
|
||||
}, 0.10f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
stage = new Stage(new ScalingViewport(Scaling.stretch, getIntendedWidth(), getIntendedHeight())) {
|
||||
@Override
|
||||
public boolean keyUp(int keycode) {
|
||||
@@ -232,8 +182,50 @@ public class UIScene extends Scene {
|
||||
keyboardDialog.getButtonTable().add(keyOK).width(100).height(20).colspan(4);
|
||||
keyboardDialog.setKeepWithinStage(true);
|
||||
keyboardDialog.setResizable(false);
|
||||
//keyboardDialog.getColor().a = 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (stage != null)
|
||||
stage.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
stage.act(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
Gdx.gl.glClearColor(0, 0, 0, 1);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
stage.draw();
|
||||
}
|
||||
|
||||
public UIActor getUI() {
|
||||
return ui;
|
||||
}
|
||||
|
||||
public boolean keyPressed(int keycode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean pointerMoved(int screenX, int screenY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void performTouch(Actor actor) {
|
||||
if (actor == null)
|
||||
return;
|
||||
actor.fire(eventTouchDown);
|
||||
Timer.schedule(new Timer.Task() {
|
||||
@Override
|
||||
public void run() {
|
||||
actor.fire(eventTouchUp);
|
||||
}
|
||||
}, 0.10f);
|
||||
}
|
||||
|
||||
private String transformKey(String c) {
|
||||
return lowercaseKey ? c.toLowerCase() : c.toUpperCase();
|
||||
}
|
||||
@@ -250,33 +242,33 @@ public class UIScene extends Scene {
|
||||
}
|
||||
private void shiftKey() {
|
||||
lowercaseKey = !lowercaseKey;
|
||||
keyShift.getLabel().setColor(lowercaseKey ? Color.WHITE : Color.CYAN);
|
||||
keyA.getLabel().setText(lowercaseKey ? "a" : "A");
|
||||
keyB.getLabel().setText(lowercaseKey ? "b" : "B");
|
||||
keyC.getLabel().setText(lowercaseKey ? "c" : "C");
|
||||
keyD.getLabel().setText(lowercaseKey ? "d" : "D");
|
||||
keyE.getLabel().setText(lowercaseKey ? "e" : "E");
|
||||
keyF.getLabel().setText(lowercaseKey ? "f" : "F");
|
||||
keyG.getLabel().setText(lowercaseKey ? "g" : "G");
|
||||
keyH.getLabel().setText(lowercaseKey ? "h" : "H");
|
||||
keyI.getLabel().setText(lowercaseKey ? "i" : "I");
|
||||
keyJ.getLabel().setText(lowercaseKey ? "j" : "J");
|
||||
keyK.getLabel().setText(lowercaseKey ? "k" : "K");
|
||||
keyL.getLabel().setText(lowercaseKey ? "l" : "L");
|
||||
keyM.getLabel().setText(lowercaseKey ? "m" : "M");
|
||||
keyN.getLabel().setText(lowercaseKey ? "n" : "N");
|
||||
keyO.getLabel().setText(lowercaseKey ? "o" : "O");
|
||||
keyP.getLabel().setText(lowercaseKey ? "p" : "P");
|
||||
keyQ.getLabel().setText(lowercaseKey ? "q" : "Q");
|
||||
keyR.getLabel().setText(lowercaseKey ? "r" : "R");
|
||||
keyS.getLabel().setText(lowercaseKey ? "s" : "S");
|
||||
keyT.getLabel().setText(lowercaseKey ? "t" : "T");
|
||||
keyU.getLabel().setText(lowercaseKey ? "u" : "U");
|
||||
keyV.getLabel().setText(lowercaseKey ? "v" : "V");
|
||||
keyW.getLabel().setText(lowercaseKey ? "w" : "W");
|
||||
keyX.getLabel().setText(lowercaseKey ? "x" : "X");
|
||||
keyY.getLabel().setText(lowercaseKey ? "y" : "Y");
|
||||
keyZ.getLabel().setText(lowercaseKey ? "z" : "Z");
|
||||
keyShift.setColor(lowercaseKey ? Color.WHITE : Color.CYAN);
|
||||
keyA.setText(lowercaseKey ? "a" : "A");
|
||||
keyB.setText(lowercaseKey ? "b" : "B");
|
||||
keyC.setText(lowercaseKey ? "c" : "C");
|
||||
keyD.setText(lowercaseKey ? "d" : "D");
|
||||
keyE.setText(lowercaseKey ? "e" : "E");
|
||||
keyF.setText(lowercaseKey ? "f" : "F");
|
||||
keyG.setText(lowercaseKey ? "g" : "G");
|
||||
keyH.setText(lowercaseKey ? "h" : "H");
|
||||
keyI.setText(lowercaseKey ? "i" : "I");
|
||||
keyJ.setText(lowercaseKey ? "j" : "J");
|
||||
keyK.setText(lowercaseKey ? "k" : "K");
|
||||
keyL.setText(lowercaseKey ? "l" : "L");
|
||||
keyM.setText(lowercaseKey ? "m" : "M");
|
||||
keyN.setText(lowercaseKey ? "n" : "N");
|
||||
keyO.setText(lowercaseKey ? "o" : "O");
|
||||
keyP.setText(lowercaseKey ? "p" : "P");
|
||||
keyQ.setText(lowercaseKey ? "q" : "Q");
|
||||
keyR.setText(lowercaseKey ? "r" : "R");
|
||||
keyS.setText(lowercaseKey ? "s" : "S");
|
||||
keyT.setText(lowercaseKey ? "t" : "T");
|
||||
keyU.setText(lowercaseKey ? "u" : "U");
|
||||
keyV.setText(lowercaseKey ? "v" : "V");
|
||||
keyW.setText(lowercaseKey ? "w" : "W");
|
||||
keyX.setText(lowercaseKey ? "x" : "X");
|
||||
keyY.setText(lowercaseKey ? "y" : "Y");
|
||||
keyZ.setText(lowercaseKey ? "z" : "Z");
|
||||
}
|
||||
public void setSelectedKey(int keyCode) {
|
||||
switch(keyCode) {
|
||||
@@ -636,7 +628,7 @@ public class UIScene extends Scene {
|
||||
if (actor instanceof TextButton)
|
||||
((TextButton) actor).fire(eventExit);
|
||||
else if (actor instanceof Selector)
|
||||
((Selector) actor).getLabel().fire(eventExit);
|
||||
((Selector) actor).fire(eventExit);
|
||||
else if (actor instanceof TextField) {
|
||||
if (stage.getKeyboardFocus() == actor)
|
||||
stage.setKeyboardFocus(null);
|
||||
@@ -672,8 +664,8 @@ public class UIScene extends Scene {
|
||||
if (kbVisible) {
|
||||
if (selectedKey != null) {
|
||||
selectedKey.fire(eventExit);
|
||||
if (selectedKey instanceof TextButton)
|
||||
if (!(((TextButton) selectedKey) == keyOK || ((TextButton) selectedKey) == keySpace))
|
||||
if (selectedKey instanceof TextraButton)
|
||||
if (!(selectedKey == keyOK || selectedKey == keySpace))
|
||||
lastSelectedKey = selectedKey;
|
||||
}
|
||||
selectedKey = actor;
|
||||
@@ -689,10 +681,10 @@ public class UIScene extends Scene {
|
||||
return;
|
||||
Actor a = actorObjectMap.get(key);
|
||||
if (a != null) {
|
||||
if (a instanceof TextButton)
|
||||
((TextButton) a).fire(eventEnter);
|
||||
if (a instanceof TextraButton)
|
||||
a.fire(eventEnter);
|
||||
else if (a instanceof Selector)
|
||||
((Selector) a).getLabel().fire(eventEnter);
|
||||
((Selector) a).fire(eventEnter);
|
||||
else if (a instanceof TextField) {
|
||||
stage.setKeyboardFocus(a);
|
||||
} else if (a instanceof ImageButton) {
|
||||
|
||||
@@ -8,10 +8,9 @@ import forge.adventure.util.Controls;
|
||||
|
||||
public class Console extends Window {
|
||||
private final ScrollPane scroll;
|
||||
private String last = "";
|
||||
private String last = "";
|
||||
private final InputLine input;
|
||||
private final Table content;
|
||||
private final ConsoleCommandInterpreter interpreter = new ConsoleCommandInterpreter();
|
||||
|
||||
public void toggle() {
|
||||
if(isVisible()) {
|
||||
@@ -23,11 +22,11 @@ public class Console extends Window {
|
||||
}
|
||||
}
|
||||
|
||||
class InputLine extends TextField {
|
||||
private Console console;
|
||||
static class InputLine extends TextField {
|
||||
private final Console console;
|
||||
|
||||
public InputLine(Console console) {
|
||||
super("", Controls.GetSkin());
|
||||
super("", Controls.getSkin());
|
||||
this.console = console;
|
||||
writeEnters=true;
|
||||
}
|
||||
@@ -44,8 +43,15 @@ public class Console extends Window {
|
||||
case BACKSPACE:
|
||||
break;
|
||||
case TAB:
|
||||
self.setText(console.complete(self.getText()));
|
||||
self.setCursorPosition(Integer.MAX_VALUE);
|
||||
if(self.getText().isEmpty())
|
||||
{
|
||||
self.setText(console.last);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.setText(console.complete(self.getText()));
|
||||
self.setCursorPosition(Integer.MAX_VALUE);
|
||||
}
|
||||
break;
|
||||
case NEWLINE:
|
||||
case CARRIAGE_RETURN:
|
||||
@@ -62,7 +68,7 @@ public class Console extends Window {
|
||||
}
|
||||
|
||||
private String complete(String text) {
|
||||
return interpreter.complete(text);
|
||||
return ConsoleCommandInterpreter.getInstance().complete(text);
|
||||
}
|
||||
|
||||
public void command(String text) {
|
||||
@@ -70,7 +76,7 @@ public class Console extends Window {
|
||||
newLine.getActor().setColor(1,1,1,1);
|
||||
newLine.growX().align(Align.left|Align.bottom).row();
|
||||
last = text; //Preserve last command.
|
||||
newLine=content.add(interpreter.command(text));
|
||||
newLine=content.add(ConsoleCommandInterpreter.getInstance().command(text));
|
||||
newLine.getActor().setColor(0.6f,0.6f,0.6f,1);
|
||||
newLine.growX().align(Align.left|Align.bottom).row();
|
||||
scroll.layout();
|
||||
@@ -78,8 +84,8 @@ public class Console extends Window {
|
||||
}
|
||||
|
||||
public Console() {
|
||||
super("", Controls.GetSkin());
|
||||
content = new Table(Controls.GetSkin());
|
||||
super("", Controls.getSkin());
|
||||
content = new Table(Controls.getSkin());
|
||||
input = new InputLine(this);
|
||||
scroll = new ScrollPane(content,new ScrollPane.ScrollPaneStyle());
|
||||
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package forge.adventure.stage;
|
||||
|
||||
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import forge.StaticData;
|
||||
import forge.adventure.character.PlayerSprite;
|
||||
import forge.adventure.data.EnemyData;
|
||||
import forge.adventure.data.WorldData;
|
||||
import forge.adventure.pointofintrest.PointOfInterest;
|
||||
import forge.adventure.scene.SceneType;
|
||||
import forge.adventure.util.Current;
|
||||
import forge.adventure.util.Paths;
|
||||
import forge.card.ColorSet;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckProxy;
|
||||
@@ -23,9 +25,10 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ConsoleCommandInterpreter {
|
||||
private static ConsoleCommandInterpreter instance;
|
||||
Command root = new Command();
|
||||
|
||||
class Command {
|
||||
static class Command {
|
||||
HashMap<String, Command> children = new HashMap<>();
|
||||
Function<String[], String> function;
|
||||
}
|
||||
@@ -90,20 +93,34 @@ public class ConsoleCommandInterpreter {
|
||||
|
||||
for(String name:path) {
|
||||
if(!currentCommand.children.containsKey(name))
|
||||
currentCommand.children.put(name,new Command());
|
||||
currentCommand.children.put(name, new Command());
|
||||
currentCommand = currentCommand.children.get(name);
|
||||
}
|
||||
currentCommand.function = function;
|
||||
}
|
||||
|
||||
public ConsoleCommandInterpreter() {
|
||||
public static ConsoleCommandInterpreter getInstance()
|
||||
{
|
||||
if(instance==null)
|
||||
instance=new ConsoleCommandInterpreter();
|
||||
return instance;
|
||||
}
|
||||
GameStage currentGameStage()
|
||||
{
|
||||
return MapStage.getInstance().isInMap()?MapStage.getInstance():WorldStage.getInstance();
|
||||
}
|
||||
PlayerSprite currentSprite()
|
||||
{
|
||||
return currentGameStage().getPlayerSprite();
|
||||
}
|
||||
private ConsoleCommandInterpreter() {
|
||||
registerCommand(new String[]{"teleport", "to"}, s -> {
|
||||
if(s.length<2)
|
||||
return "Command needs 2 parameter";
|
||||
try {
|
||||
int x = Integer.parseInt(s[0]);
|
||||
int y = Integer.parseInt(s[1]);
|
||||
WorldStage.getInstance().GetPlayer().setPosition(x,y);
|
||||
WorldStage.getInstance().setPosition(new Vector2(x,y));
|
||||
WorldStage.getInstance().player.playEffect(Paths.EFFECT_TELEPORT,10);
|
||||
return "teleport to ("+s[0]+","+s[1]+")";
|
||||
} catch (Exception e) {
|
||||
return "Exception occured, Invalid input";
|
||||
@@ -114,7 +131,8 @@ public class ConsoleCommandInterpreter {
|
||||
PointOfInterest poi=Current.world().findPointsOfInterest(s[0]);
|
||||
if(poi==null)
|
||||
return "PoI " + s[0] + " not found";
|
||||
WorldStage.getInstance().GetPlayer().setPosition(poi.getPosition());
|
||||
WorldStage.getInstance().setPosition(poi.getPosition());
|
||||
WorldStage.getInstance().player.playEffect(Paths.EFFECT_TELEPORT,10);
|
||||
return "Teleported to " + s[0] + "(" + poi.getPosition() + ")";
|
||||
});
|
||||
registerCommand(new String[]{"spawn","enemy"}, s -> {
|
||||
@@ -136,6 +154,18 @@ public class ConsoleCommandInterpreter {
|
||||
Current.player().giveGold(amount);
|
||||
return "Added "+amount+" gold";
|
||||
});
|
||||
registerCommand(new String[]{"give", "mana"}, s -> {
|
||||
if(s.length<1) return "Command needs 1 parameter: Amount.";
|
||||
int amount;
|
||||
try {
|
||||
amount=Integer.parseInt(s[0]);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return "Can not convert " + s[0] + " to number";
|
||||
}
|
||||
Current.player().addMaxMana(amount);
|
||||
return "Added " + amount + " max mana";
|
||||
});
|
||||
registerCommand(new String[]{"give", "life"}, s -> {
|
||||
if(s.length<1) return "Command needs 1 parameter: Amount.";
|
||||
int amount;
|
||||
@@ -163,6 +193,7 @@ public class ConsoleCommandInterpreter {
|
||||
});
|
||||
registerCommand(new String[]{"fullHeal"}, s -> {
|
||||
Current.player().fullHeal();
|
||||
currentSprite().playEffect(Paths.EFFECT_HEAL);
|
||||
return "Player fully healed. Health set to " + Current.player().getLife() + ".";
|
||||
});
|
||||
registerCommand(new String[]{"setColorID"}, s -> {
|
||||
@@ -170,11 +201,6 @@ public class ConsoleCommandInterpreter {
|
||||
Current.player().setColorIdentity(s[0]);
|
||||
return "Player color identity set to " + Current.player().getColorIdentity() + ".";
|
||||
});
|
||||
registerCommand(new String[]{"reloadScenes"}, s -> {
|
||||
SceneType.InventoryScene.instance.resLoaded();
|
||||
SceneType.PlayerStatisticScene.instance.resLoaded();
|
||||
return "Force reload status scenes. WARNING: Game might be unstable.";
|
||||
});
|
||||
registerCommand(new String[]{"resetQuests"}, s -> {
|
||||
Current.player().resetQuestFlags();
|
||||
return "All global quest flags have been reset.";
|
||||
@@ -226,6 +252,42 @@ public class ConsoleCommandInterpreter {
|
||||
try { N = Integer.parseInt(s[0]); }
|
||||
catch (Exception e) { return "Can not convert " + s[0] + " to integer"; }
|
||||
Current.player().heal(N);
|
||||
currentSprite().playEffect(Paths.EFFECT_HEAL);
|
||||
return "Player healed to " + Current.player().getLife() + "/" + Current.player().getMaxLife();
|
||||
});
|
||||
registerCommand(new String[]{"heal", "percent"}, s -> {
|
||||
if(s.length<1) return "Command needs 1 parameter: Amount";
|
||||
float value = 0;
|
||||
try { value = Float.parseFloat(s[0]); }
|
||||
catch (Exception e) { return "Can not convert " + s[0] + " to integer"; }
|
||||
Current.player().heal(value);
|
||||
currentSprite().playEffect(Paths.EFFECT_HEAL);
|
||||
return "Player healed to " + Current.player().getLife() + "/" + Current.player().getMaxLife();
|
||||
});
|
||||
registerCommand(new String[]{"heal", "full"}, s -> {
|
||||
Current.player().fullHeal();
|
||||
currentSprite().playEffect(Paths.EFFECT_HEAL);
|
||||
return "Player healed to " + Current.player().getLife() + "/" + Current.player().getMaxLife();
|
||||
});
|
||||
|
||||
registerCommand(new String[]{"getMana", "amount"}, s -> {
|
||||
if(s.length<1) return "Command needs 1 parameter: Amount";
|
||||
int value;
|
||||
try { value = Integer.parseInt(s[0]); }
|
||||
catch (Exception e) { return "Can not convert " + s[0] + " to integer"; }
|
||||
Current.player().addMana(value);
|
||||
return "Player healed to " + Current.player().getLife() + "/" + Current.player().getMaxLife();
|
||||
});
|
||||
registerCommand(new String[]{"getMana", "percent"}, s -> {
|
||||
if(s.length<1) return "Command needs 1 parameter: Amount";
|
||||
float value = 0;
|
||||
try { value = Float.parseFloat(s[0]); }
|
||||
catch (Exception e) { return "Can not convert " + s[0] + " to integer"; }
|
||||
Current.player().addManaPercent(value);
|
||||
return "Player healed to " + Current.player().getLife() + "/" + Current.player().getMaxLife();
|
||||
});
|
||||
registerCommand(new String[]{"getMana", "full"}, s -> {
|
||||
Current.player().addManaPercent(1.0f);
|
||||
return "Player healed to " + Current.player().getLife() + "/" + Current.player().getMaxLife();
|
||||
});
|
||||
registerCommand(new String[]{"debug","on"}, s -> {
|
||||
@@ -244,6 +306,36 @@ public class ConsoleCommandInterpreter {
|
||||
MapStage.getInstance().removeAllEnemies();
|
||||
return "removed all enemies";
|
||||
});
|
||||
|
||||
registerCommand(new String[]{"hide"}, s -> {
|
||||
if(s.length<1) return "Command needs 1 parameter: Amount";
|
||||
float value = 0;
|
||||
try { value = Float.parseFloat(s[0]); }
|
||||
catch (Exception e) { return "Can not convert " + s[0] + " to float"; }
|
||||
currentGameStage().hideFor(value);
|
||||
return "removed all enemies";
|
||||
});
|
||||
|
||||
registerCommand(new String[]{"fly"}, s -> {
|
||||
if(s.length<1) return "Command needs 1 parameter: Amount";
|
||||
float value = 0;
|
||||
try { value = Float.parseFloat(s[0]); }
|
||||
catch (Exception e) { return "Can not convert " + s[0] + " to float"; }
|
||||
currentGameStage().flyFor(value);
|
||||
return "removed all enemies";
|
||||
});
|
||||
registerCommand(new String[]{"sprint"}, s -> {
|
||||
if(s.length<1) return "Command needs 1 parameter: Amount";
|
||||
float value = 0;
|
||||
try { value = Float.parseFloat(s[0]); }
|
||||
catch (Exception e) { return "Can not convert " + s[0] + " to float"; }
|
||||
currentGameStage().sprintFor(value);
|
||||
return "removed all enemies";
|
||||
});
|
||||
registerCommand(new String[]{"remove","enemy","nearest"}, s -> {
|
||||
WorldStage.getInstance().removeNearestEnemy();
|
||||
return "removed all enemies";
|
||||
});
|
||||
registerCommand(new String[]{"remove","enemy"}, s -> {
|
||||
if(s.length<1) return "Command needs 1 parameter: Enemy map ID.";
|
||||
int id;
|
||||
|
||||
@@ -13,20 +13,19 @@ import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Touchpad;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Scaling;
|
||||
import com.badlogic.gdx.utils.Timer;
|
||||
import com.badlogic.gdx.utils.viewport.ScalingViewport;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.player.AdventurePlayer;
|
||||
import forge.adventure.scene.HudScene;
|
||||
import forge.adventure.scene.Scene;
|
||||
import forge.adventure.scene.SceneType;
|
||||
import forge.adventure.scene.UIScene;
|
||||
import forge.adventure.scene.*;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.adventure.util.Controls;
|
||||
import forge.adventure.util.Current;
|
||||
@@ -45,18 +44,22 @@ public class GameHUD extends Stage implements ControllerListener {
|
||||
private final GameStage gameStage;
|
||||
private final Image avatar;
|
||||
private final Image miniMapPlayer;
|
||||
private final Label lifePoints;
|
||||
private final Label money;
|
||||
private final Image miniMap,miniMapTooltip, gamehud, mapborder, avatarborder, blank;
|
||||
private Tooltip<Image> toolTip;
|
||||
private TextButton deckActor, menuActor, statsActor, inventoryActor;
|
||||
private UIActor ui;
|
||||
private Touchpad touchpad;
|
||||
private Console console;
|
||||
private final TextraLabel lifePoints;
|
||||
private final TextraLabel money;
|
||||
private final TextraLabel mana;
|
||||
private final Image miniMap, gamehud, mapborder, avatarborder, blank;
|
||||
private final InputEvent eventTouchDown;
|
||||
private final InputEvent eventTouchUp;
|
||||
private final TextraButton deckActor;
|
||||
private final TextraButton menuActor;
|
||||
private final TextraButton statsActor;
|
||||
private final TextraButton inventoryActor;
|
||||
private final UIActor ui;
|
||||
private final Touchpad touchpad;
|
||||
private final Console console;
|
||||
float TOUCHPAD_SCALE = 70f, referenceX;
|
||||
boolean isHiding = false, isShowing = false;
|
||||
float opacity = 1f;
|
||||
private InputEvent eventTouchDown, eventTouchUp;
|
||||
|
||||
private GameHUD(GameStage gameStage) {
|
||||
super(new ScalingViewport(Scaling.stretch, Scene.getIntendedWidth(), Scene.getIntendedHeight()), gameStage.getBatch());
|
||||
@@ -71,39 +74,27 @@ public class GameHUD extends Stage implements ControllerListener {
|
||||
miniMap = ui.findActor("map");
|
||||
mapborder = ui.findActor("mapborder");
|
||||
|
||||
miniMapTooltip=new Image();
|
||||
miniMapTooltip.setScaling(Scaling.contain);
|
||||
miniMapTooltip.setSize(miniMap.getWidth()*3,miniMap.getHeight()*3);
|
||||
miniMapTooltip.setPosition(0,0,Align.topLeft);
|
||||
ui.addActor(miniMapTooltip);
|
||||
toolTip=new Tooltip<Image>(miniMapTooltip);
|
||||
toolTip.setInstant(true);
|
||||
mapborder.addListener(toolTip);
|
||||
avatarborder = ui.findActor("avatarborder");
|
||||
deckActor = ui.findActor("deck");
|
||||
deckActor.getLabel().setText(Forge.getLocalizer().getMessage("lblDeck"));
|
||||
menuActor = ui.findActor("menu");
|
||||
referenceX = menuActor.getX();
|
||||
menuActor.getLabel().setText(Forge.getLocalizer().getMessage("lblMenu"));
|
||||
statsActor = ui.findActor("statistic");
|
||||
statsActor.getLabel().setText(Forge.getLocalizer().getMessage("lblStatus"));
|
||||
inventoryActor = ui.findActor("inventory");
|
||||
inventoryActor.getLabel().setText(Forge.getLocalizer().getMessage("lblItem"));
|
||||
gamehud = ui.findActor("gamehud");
|
||||
|
||||
miniMapPlayer = new Image(new Texture(Config.instance().getFile("ui/minimap_player.png")));
|
||||
//create touchpad
|
||||
touchpad = new Touchpad(10, Controls.GetSkin());
|
||||
touchpad = new Touchpad(10, Controls.getSkin());
|
||||
touchpad.setBounds(15, 15, TOUCHPAD_SCALE, TOUCHPAD_SCALE);
|
||||
touchpad.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent changeEvent, Actor actor) {
|
||||
if (MapStage.getInstance().isInMap()) {
|
||||
MapStage.getInstance().GetPlayer().getMovementDirection().x+=((Touchpad) actor).getKnobPercentX();
|
||||
MapStage.getInstance().GetPlayer().getMovementDirection().y+=((Touchpad) actor).getKnobPercentY();
|
||||
MapStage.getInstance().getPlayerSprite().getMovementDirection().x+=((Touchpad) actor).getKnobPercentX();
|
||||
MapStage.getInstance().getPlayerSprite().getMovementDirection().y+=((Touchpad) actor).getKnobPercentY();
|
||||
} else {
|
||||
WorldStage.getInstance().GetPlayer().getMovementDirection().x+=((Touchpad) actor).getKnobPercentX();
|
||||
WorldStage.getInstance().GetPlayer().getMovementDirection().y+=((Touchpad) actor).getKnobPercentY();
|
||||
WorldStage.getInstance().getPlayerSprite().getMovementDirection().x+=((Touchpad) actor).getKnobPercentX();
|
||||
WorldStage.getInstance().getPlayerSprite().getMovementDirection().y+=((Touchpad) actor).getKnobPercentY();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -116,9 +107,13 @@ public class GameHUD extends Stage implements ControllerListener {
|
||||
ui.onButtonPress("statistic", () -> statistic());
|
||||
ui.onButtonPress("deck", () -> openDeck());
|
||||
lifePoints = ui.findActor("lifePoints");
|
||||
mana = ui.findActor("mana");
|
||||
money = ui.findActor("money");
|
||||
mana.setText("0/0");
|
||||
lifePoints.setText("20/20");
|
||||
AdventurePlayer.current().onLifeChange(() -> lifePoints.setText(AdventurePlayer.current().getLife() + "/" + AdventurePlayer.current().getMaxLife()));
|
||||
money = ui.findActor("money");
|
||||
AdventurePlayer.current().onManaChange(() -> mana.setText(AdventurePlayer.current().getMana() + "/" + AdventurePlayer.current().getMaxMana()));
|
||||
|
||||
WorldSave.getCurrentSave().getPlayer().onGoldChange(() -> money.setText(String.valueOf(AdventurePlayer.current().getGold()))) ;
|
||||
addActor(ui);
|
||||
addActor(miniMapPlayer);
|
||||
@@ -141,8 +136,12 @@ public class GameHUD extends Stage implements ControllerListener {
|
||||
Controllers.addListener(this);
|
||||
}
|
||||
|
||||
private void openMap() {
|
||||
Forge.switchScene(MapViewScene.instance());
|
||||
}
|
||||
|
||||
private void statistic() {
|
||||
Forge.switchScene(SceneType.PlayerStatisticScene.instance);
|
||||
Forge.switchScene(PlayerStatisticScene.instance());
|
||||
}
|
||||
|
||||
public static GameHUD getInstance() {
|
||||
@@ -156,8 +155,8 @@ public class GameHUD extends Stage implements ControllerListener {
|
||||
@Override
|
||||
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
|
||||
touchpad.setVisible(false);
|
||||
MapStage.getInstance().GetPlayer().setMovementDirection(Vector2.Zero);
|
||||
WorldStage.getInstance().GetPlayer().setMovementDirection(Vector2.Zero);
|
||||
MapStage.getInstance().getPlayerSprite().setMovementDirection(Vector2.Zero);
|
||||
WorldStage.getInstance().getPlayerSprite().setMovementDirection(Vector2.Zero);
|
||||
return super.touchUp(screenX, screenY, pointer, button);
|
||||
}
|
||||
|
||||
@@ -171,10 +170,9 @@ public class GameHUD extends Stage implements ControllerListener {
|
||||
//map bounds
|
||||
if (Controls.actorContainsVector(miniMap,c)) {
|
||||
touchpad.setVisible(false);
|
||||
if (MapStage.getInstance().isInMap())
|
||||
return true;
|
||||
|
||||
if(Current.isInDebug())
|
||||
WorldStage.getInstance().GetPlayer().setPosition(x*WorldSave.getCurrentSave().getWorld().getWidthInPixels(),y*WorldSave.getCurrentSave().getWorld().getHeightInPixels());
|
||||
WorldStage.getInstance().getPlayerSprite().setPosition(x*WorldSave.getCurrentSave().getWorld().getWidthInPixels(),y*WorldSave.getCurrentSave().getWorld().getHeightInPixels());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -196,11 +194,11 @@ public class GameHUD extends Stage implements ControllerListener {
|
||||
return true;
|
||||
}
|
||||
if (Controls.actorContainsVector(miniMap,c)) {
|
||||
if (MapStage.getInstance().isInMap())
|
||||
return true;
|
||||
if(Current.isInDebug())
|
||||
WorldStage.getInstance().GetPlayer().setPosition(x*WorldSave.getCurrentSave().getWorld().getWidthInPixels(),y*WorldSave.getCurrentSave().getWorld().getHeightInPixels());
|
||||
return true;
|
||||
WorldStage.getInstance().getPlayerSprite().setPosition(x*WorldSave.getCurrentSave().getWorld().getWidthInPixels(),y*WorldSave.getCurrentSave().getWorld().getHeightInPixels());
|
||||
else
|
||||
openMap();
|
||||
return true;
|
||||
}
|
||||
//auto follow touchpad
|
||||
if (GuiBase.isAndroid() && !MapStage.getInstance().getDialogOnlyInput() && !console.isVisible()) {
|
||||
@@ -262,23 +260,22 @@ public class GameHUD extends Stage implements ControllerListener {
|
||||
miniMapToolTipPixmap.drawPixmap(WorldSave.getCurrentSave().getWorld().getBiomeImage(),0,0,WorldSave.getCurrentSave().getWorld().getBiomeImage().getWidth(),WorldSave.getCurrentSave().getWorld().getBiomeImage().getHeight(),0,0,miniMapToolTipPixmap.getWidth(),miniMapToolTipPixmap.getHeight());
|
||||
miniMapToolTipTexture=new Texture(miniMapToolTipPixmap);
|
||||
miniMap.setDrawable(new TextureRegionDrawable(miniMapTexture));
|
||||
miniMapTooltip.setDrawable(new TextureRegionDrawable(miniMapToolTipTexture));
|
||||
avatar.setDrawable(new TextureRegionDrawable(Current.player().avatar()));
|
||||
Deck deck = AdventurePlayer.current().getSelectedDeck();
|
||||
if (deck == null || deck.isEmpty() || deck.getMain().toFlatList().size() < 30) {
|
||||
deckActor.getLabel().setColor(Color.RED);
|
||||
deckActor.setColor(Color.RED);
|
||||
} else {
|
||||
deckActor.getLabel().setColor(menuActor.getLabel().getColor());
|
||||
deckActor.setColor(menuActor.getColor());
|
||||
}
|
||||
}
|
||||
|
||||
private void openDeck() {
|
||||
Forge.switchScene(SceneType.DeckSelectScene.instance);
|
||||
Forge.switchScene(DeckSelectScene.instance());
|
||||
}
|
||||
|
||||
private void openInventory() {
|
||||
WorldSave.getCurrentSave().header.createPreview();
|
||||
Forge.switchScene(SceneType.InventoryScene.instance);
|
||||
Forge.switchScene(InventoryScene.instance());
|
||||
}
|
||||
private void menu() {
|
||||
gameStage.openMenu();
|
||||
@@ -289,6 +286,7 @@ public class GameHUD extends Stage implements ControllerListener {
|
||||
miniMapPlayer.setVisible(visible);
|
||||
gamehud.setVisible(visible);
|
||||
lifePoints.setVisible(visible);
|
||||
mana.setVisible(visible);
|
||||
money.setVisible(visible);
|
||||
blank.setVisible(visible);
|
||||
if (visible) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Scaling;
|
||||
import com.badlogic.gdx.utils.viewport.ScalingViewport;
|
||||
import forge.Forge;
|
||||
@@ -15,12 +16,16 @@ import forge.adventure.character.PlayerSprite;
|
||||
import forge.adventure.data.PointOfInterestData;
|
||||
import forge.adventure.pointofintrest.PointOfInterest;
|
||||
import forge.adventure.scene.Scene;
|
||||
import forge.adventure.scene.SceneType;
|
||||
import forge.adventure.scene.StartScene;
|
||||
import forge.adventure.scene.TileMapScene;
|
||||
import forge.adventure.util.Paths;
|
||||
import forge.adventure.world.WorldSave;
|
||||
import forge.gui.GuiBase;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Base class to render a player sprite on a map
|
||||
* used for the over world and dungeons
|
||||
@@ -39,6 +44,38 @@ public abstract class GameStage extends Stage {
|
||||
public static float maximumScrollDistance=1.5f;
|
||||
public static float minimumScrollDistance=0.3f;
|
||||
|
||||
enum PlayerModification
|
||||
{
|
||||
Sprint,
|
||||
Hide,
|
||||
Fly
|
||||
|
||||
}
|
||||
|
||||
|
||||
HashMap<PlayerModification,Float> currentModifications=new HashMap<>();
|
||||
public void modifyPlayer(PlayerModification mod,float value) {
|
||||
float currentValue=0;
|
||||
if(currentModifications.containsKey(mod))
|
||||
{
|
||||
currentValue=currentModifications.get(mod);
|
||||
}
|
||||
currentModifications.put(mod,currentValue+value);
|
||||
}
|
||||
|
||||
public void flyFor(float value) {
|
||||
modifyPlayer(PlayerModification.Fly,value);
|
||||
player.playEffect(Paths.EFFECT_FLY);
|
||||
}
|
||||
public void hideFor(float value) {
|
||||
modifyPlayer(PlayerModification.Hide,value);
|
||||
player.setColor(player.getColor().r,player.getColor().g,player.getColor().b,0.5f);
|
||||
player.playEffect(Paths.EFFECT_HIDE);
|
||||
}
|
||||
public void sprintFor(float value) {
|
||||
modifyPlayer(PlayerModification.Sprint,value);
|
||||
player.playEffect(Paths.EFFECT_SPRINT);
|
||||
}
|
||||
public void startPause(float i) {
|
||||
startPause(i, null);
|
||||
}
|
||||
@@ -48,19 +85,21 @@ public abstract class GameStage extends Stage {
|
||||
animationTimeout = i;
|
||||
player.setMovementDirection(Vector2.Zero);
|
||||
}
|
||||
|
||||
public boolean isPaused() {
|
||||
return animationTimeout > 0;
|
||||
}
|
||||
|
||||
public GameStage() {
|
||||
super(new ScalingViewport(Scaling.stretch, Scene.getIntendedWidth(), Scene.getIntendedHeight(), new OrthographicCamera()));
|
||||
WorldSave.getCurrentSave().onLoad(() -> {
|
||||
if (player == null)
|
||||
return;
|
||||
foregroundSprites.removeActor(player);
|
||||
player = null;
|
||||
GameStage.this.GetPlayer();
|
||||
WorldSave.getCurrentSave().onLoad(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (player == null)
|
||||
return;
|
||||
foregroundSprites.removeActor(player);
|
||||
player = null;
|
||||
GameStage.this.getPlayerSprite();
|
||||
}
|
||||
});
|
||||
camera = (OrthographicCamera) getCamera();
|
||||
|
||||
@@ -81,7 +120,7 @@ public abstract class GameStage extends Stage {
|
||||
getViewport().setWorldSize(width, height);
|
||||
}
|
||||
|
||||
public PlayerSprite GetPlayer() {
|
||||
public PlayerSprite getPlayerSprite() {
|
||||
if (player == null) {
|
||||
player = new PlayerSprite(this);
|
||||
foregroundSprites.addActor(player);
|
||||
@@ -90,11 +129,11 @@ public abstract class GameStage extends Stage {
|
||||
}
|
||||
|
||||
|
||||
public SpriteGroup GetSpriteGroup() {
|
||||
public SpriteGroup getSpriteGroup() {
|
||||
return foregroundSprites;
|
||||
}
|
||||
|
||||
public Group GetBackgroundSprites() {
|
||||
public Group getBackgroundSprites() {
|
||||
return backgroundSprites;
|
||||
}
|
||||
|
||||
@@ -109,6 +148,19 @@ public abstract class GameStage extends Stage {
|
||||
animationTimeout -= delta;
|
||||
return;
|
||||
}
|
||||
Array<PlayerModification> modsToRemove=new Array<>();
|
||||
for(Map.Entry<PlayerModification, Float> mod:currentModifications.entrySet())
|
||||
{
|
||||
mod.setValue(mod.getValue()-delta);
|
||||
if(mod.getValue()<0)
|
||||
modsToRemove.add(mod.getKey());
|
||||
}
|
||||
for(PlayerModification mod:modsToRemove)
|
||||
{
|
||||
currentModifications.remove(mod);
|
||||
onRemoveEffect(mod);
|
||||
}
|
||||
|
||||
if (isPaused()) {
|
||||
return;
|
||||
}
|
||||
@@ -131,13 +183,6 @@ public abstract class GameStage extends Stage {
|
||||
}
|
||||
player.setMovementDirection(diff);
|
||||
}
|
||||
//debug speed up
|
||||
/*
|
||||
if (Gdx.input.isKeyPressed(Input.Keys.CONTROL_LEFT))
|
||||
player.setMoveModifier(20);
|
||||
else
|
||||
player.setMoveModifier(1);*/
|
||||
|
||||
camera.position.x = Math.min(Math.max(Scene.getIntendedWidth() / 2f, player.pos().x), getViewport().getWorldWidth() - Scene.getIntendedWidth() / 2f);
|
||||
camera.position.y = Math.min(Math.max(Scene.getIntendedHeight() / 2f, player.pos().y), getViewport().getWorldHeight() - Scene.getIntendedHeight() / 2f);
|
||||
|
||||
@@ -145,6 +190,21 @@ public abstract class GameStage extends Stage {
|
||||
onActing(delta);
|
||||
}
|
||||
|
||||
private void onRemoveEffect(PlayerModification mod) {
|
||||
switch (mod)
|
||||
{
|
||||
case Hide:
|
||||
player.setColor(player.getColor().r,player.getColor().g,player.getColor().b,1f);
|
||||
break;
|
||||
case Fly:
|
||||
player.removeEffect(Paths.EFFECT_FLY);
|
||||
break;
|
||||
case Sprint:
|
||||
player.removeEffect(Paths.EFFECT_SPRINT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
abstract protected void onActing(float delta);
|
||||
|
||||
|
||||
@@ -169,8 +229,8 @@ public abstract class GameStage extends Stage {
|
||||
}
|
||||
if (keycode == Input.Keys.F5)//todo config
|
||||
{
|
||||
if (!((TileMapScene) SceneType.TileMapScene.instance).currentMap().isInMap()) {
|
||||
GetPlayer().storePos();
|
||||
if (!TileMapScene.instance().currentMap().isInMap()) {
|
||||
getPlayerSprite().storePos();
|
||||
WorldSave.getCurrentSave().header.createPreview();
|
||||
WorldSave.getCurrentSave().quickSave();
|
||||
}
|
||||
@@ -178,7 +238,7 @@ public abstract class GameStage extends Stage {
|
||||
}
|
||||
if (keycode == Input.Keys.F8)//todo config
|
||||
{
|
||||
if (!((TileMapScene) SceneType.TileMapScene.instance).currentMap().isInMap()) {
|
||||
if (!TileMapScene.instance().currentMap().isInMap()) {
|
||||
WorldSave.getCurrentSave().quickLoad();
|
||||
enter();
|
||||
}
|
||||
@@ -194,11 +254,14 @@ public abstract class GameStage extends Stage {
|
||||
player.setBoundDebug(true);
|
||||
}
|
||||
if (keycode == Input.Keys.F2) {
|
||||
TileMapScene S = ((TileMapScene)SceneType.TileMapScene.instance);
|
||||
TileMapScene S = TileMapScene.instance();
|
||||
PointOfInterestData P = PointOfInterestData.getPointOfInterest("DEBUGZONE");
|
||||
PointOfInterest PoI = new PointOfInterest(P,new Vector2(0,0), MyRandom.getRandom());
|
||||
S.load(PoI);
|
||||
Forge.switchScene(S);
|
||||
if( P != null)
|
||||
{
|
||||
PointOfInterest PoI = new PointOfInterest(P,new Vector2(0,0), MyRandom.getRandom());
|
||||
S.load(PoI);
|
||||
Forge.switchScene(S);
|
||||
}
|
||||
}
|
||||
if (keycode == Input.Keys.F11) {
|
||||
debugCollision(false);
|
||||
@@ -254,8 +317,8 @@ public abstract class GameStage extends Stage {
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
WorldStage.getInstance().GetPlayer().setMovementDirection(Vector2.Zero);
|
||||
MapStage.getInstance().GetPlayer().setMovementDirection(Vector2.Zero);
|
||||
WorldStage.getInstance().getPlayerSprite().setMovementDirection(Vector2.Zero);
|
||||
MapStage.getInstance().getPlayerSprite().setMovementDirection(Vector2.Zero);
|
||||
touchX = -1;
|
||||
touchY = -1;
|
||||
player.stop();
|
||||
@@ -292,7 +355,7 @@ public abstract class GameStage extends Stage {
|
||||
public void openMenu() {
|
||||
|
||||
WorldSave.getCurrentSave().header.createPreview();
|
||||
Forge.switchScene(SceneType.StartScene.instance);
|
||||
Forge.switchScene(StartScene.instance());
|
||||
}
|
||||
|
||||
public void enter() {
|
||||
@@ -315,6 +378,8 @@ public abstract class GameStage extends Stage {
|
||||
Vector2 adjDirY = direction.cpy();
|
||||
boolean foundX = false;
|
||||
boolean foundY = false;
|
||||
if(isColliding(boundingRect))//if player is already colliding (after flying or teleport) allow to move off collision
|
||||
return direction;
|
||||
while (true) {
|
||||
|
||||
if (!isColliding(new Rectangle(boundingRect.x + adjDirX.x, boundingRect.y + adjDirX.y, boundingRect.width, boundingRect.height))) {
|
||||
@@ -351,4 +416,13 @@ public abstract class GameStage extends Stage {
|
||||
return Vector2.Zero.cpy();
|
||||
}
|
||||
|
||||
protected void teleported(Vector2 position)
|
||||
{
|
||||
|
||||
}
|
||||
public void setPosition(Vector2 position) {
|
||||
getPlayerSprite().setPosition(position);
|
||||
teleported(position);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package forge.adventure.stage;
|
||||
|
||||
public interface IAfterMatch {
|
||||
void setWinner(boolean winner);
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.controllers.Controllers;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.maps.MapLayer;
|
||||
import com.badlogic.gdx.maps.MapObject;
|
||||
@@ -24,25 +23,18 @@ import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import com.badlogic.gdx.utils.Scaling;
|
||||
import com.badlogic.gdx.utils.Timer;
|
||||
import com.badlogic.gdx.utils.*;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import com.github.tommyettinger.textra.TypingAdapter;
|
||||
import com.github.tommyettinger.textra.TypingLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.character.*;
|
||||
import forge.adventure.data.*;
|
||||
import forge.adventure.pointofintrest.PointOfInterestChanges;
|
||||
import forge.adventure.scene.DuelScene;
|
||||
import forge.adventure.scene.RewardScene;
|
||||
import forge.adventure.scene.SceneType;
|
||||
import forge.adventure.scene.*;
|
||||
import forge.adventure.util.*;
|
||||
import forge.adventure.world.WorldSave;
|
||||
import forge.card.ColorSet;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckProxy;
|
||||
import forge.gui.FThreads;
|
||||
@@ -50,24 +42,18 @@ import forge.screens.TransitionScreen;
|
||||
import forge.sound.SoundEffectType;
|
||||
import forge.sound.SoundSystem;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static forge.adventure.util.Paths.MANA_ATLAS;
|
||||
|
||||
/**
|
||||
* Stage to handle tiled maps for points of interests
|
||||
*/
|
||||
public class MapStage extends GameStage {
|
||||
public static MapStage instance;
|
||||
Array<MapActor> actors = new Array<>();
|
||||
final Array<MapActor> actors = new Array<>();
|
||||
|
||||
TiledMap map;
|
||||
Array<Rectangle>[][] collision;
|
||||
private float tileHeight;
|
||||
private float tileWidth;
|
||||
private float width;
|
||||
private float height;
|
||||
Array<Rectangle> collisionRect=new Array<>();
|
||||
private boolean isInMap = false;
|
||||
MapLayer spriteLayer;
|
||||
private PointOfInterestChanges changes;
|
||||
@@ -77,9 +63,9 @@ public class MapStage extends GameStage {
|
||||
private final Vector2 oldPosition3 = new Vector2();
|
||||
private final Vector2 oldPosition4 = new Vector2();
|
||||
private boolean isLoadingMatch = false;
|
||||
private HashMap<String, Byte> mapFlags = new HashMap<>(); //Stores local map flags. These aren't available outside this map.
|
||||
//private HashMap<String, Byte> mapFlags = new HashMap<>(); //Stores local map flags. These aren't available outside this map.
|
||||
|
||||
private Dialog dialog;
|
||||
private final Dialog dialog;
|
||||
private Stage dialogStage;
|
||||
private boolean dialogOnlyInput;
|
||||
|
||||
@@ -87,10 +73,11 @@ public class MapStage extends GameStage {
|
||||
//These maps are defined as embedded properties within the Tiled maps.
|
||||
private EffectData effect; //"Dungeon Effect": Character Effect applied to all adversaries within the map.
|
||||
private boolean preventEscape = false; //Prevents player from escaping the dungeon by any means that aren't an exit.
|
||||
private ObjectMap<Integer, TextButton> dialogButtonMap;
|
||||
private ObjectMap<Integer, TextraButton> dialogButtonMap;
|
||||
private int selected = 0;
|
||||
public InputEvent eventEnter, eventExit, eventTouchDown, eventTouchUp;
|
||||
TextButton selectedKey;
|
||||
TextraButton selectedKey;
|
||||
private boolean foundPlayerSpawn=false;
|
||||
|
||||
|
||||
public boolean getDialogOnlyInput() {
|
||||
@@ -102,7 +89,7 @@ public class MapStage extends GameStage {
|
||||
}
|
||||
|
||||
public boolean canEscape() {
|
||||
return (preventEscape ? true : false);
|
||||
return !preventEscape;
|
||||
} //Check if escape is possible.
|
||||
|
||||
public void clearIsInMap() {
|
||||
@@ -128,11 +115,8 @@ public class MapStage extends GameStage {
|
||||
return changes;
|
||||
}
|
||||
|
||||
public static MapStage getInstance() {
|
||||
return instance == null ? instance = new MapStage() : instance;
|
||||
}
|
||||
|
||||
public void resLoaded() {
|
||||
private MapStage()
|
||||
{
|
||||
dialog = Controls.newDialog("");
|
||||
eventTouchDown = new InputEvent();
|
||||
eventTouchDown.setPointer(-1);
|
||||
@@ -147,6 +131,9 @@ public class MapStage extends GameStage {
|
||||
eventExit.setPointer(-1);
|
||||
eventExit.setType(InputEvent.Type.exit);
|
||||
}
|
||||
public static MapStage getInstance() {
|
||||
return instance == null ? instance = new MapStage() : instance;
|
||||
}
|
||||
|
||||
public void addMapActor(MapObject obj, MapActor newActor) {
|
||||
newActor.setWidth(Float.parseFloat(obj.getProperties().get("width").toString()));
|
||||
@@ -164,7 +151,7 @@ public class MapStage extends GameStage {
|
||||
|
||||
@Override
|
||||
public boolean isColliding(Rectangle adjustedBoundingRect) {
|
||||
for (Rectangle collision : currentCollidingRectangles) {
|
||||
for (Rectangle collision : collisionRect) {
|
||||
if (collision.overlaps(adjustedBoundingRect)) {
|
||||
return true;
|
||||
}
|
||||
@@ -172,24 +159,10 @@ public class MapStage extends GameStage {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Array<Rectangle> currentCollidingRectangles = new Array<>();
|
||||
|
||||
@Override
|
||||
public void prepareCollision(Vector2 pos, Vector2 direction, Rectangle boundingRect) {
|
||||
currentCollidingRectangles.clear();
|
||||
int x1 = (int) (Math.min(boundingRect.x, boundingRect.x + direction.x) / tileWidth);
|
||||
int y1 = (int) (Math.min(boundingRect.y, boundingRect.y + direction.y) / tileHeight);
|
||||
int x2 = (int) (Math.min(boundingRect.x + boundingRect.width, boundingRect.x + boundingRect.width + direction.x) / tileWidth);
|
||||
int y2 = (int) (Math.min(boundingRect.y + boundingRect.height, boundingRect.y + boundingRect.height + direction.y) / tileHeight);
|
||||
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
for (int y = y1; y <= y2; y++) {
|
||||
if (x < 0 || x >= width || y < 0 || y >= height) {
|
||||
continue;
|
||||
}
|
||||
currentCollidingRectangles.addAll(collision[x][y]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -201,18 +174,14 @@ public class MapStage extends GameStage {
|
||||
if (collisionGroup == null) {
|
||||
collisionGroup = new Group();
|
||||
|
||||
for (int x = 0; x < collision.length; x++) {
|
||||
for (int y = 0; y < collision[x].length; y++) {
|
||||
for (Rectangle rectangle : collision[x][y]) {
|
||||
MapActor collisionActor = new MapActor(0);
|
||||
collisionActor.setBoundDebug(true);
|
||||
collisionActor.setWidth(rectangle.width);
|
||||
collisionActor.setHeight(rectangle.height);
|
||||
collisionActor.setX(rectangle.x);
|
||||
collisionActor.setY(rectangle.y);
|
||||
collisionGroup.addActor(collisionActor);
|
||||
}
|
||||
}
|
||||
for (Rectangle rectangle : collisionRect) {
|
||||
MapActor collisionActor = new MapActor(0);
|
||||
collisionActor.setBoundDebug(true);
|
||||
collisionActor.setWidth(rectangle.width);
|
||||
collisionActor.setHeight(rectangle.height);
|
||||
collisionActor.setX(rectangle.x);
|
||||
collisionActor.setY(rectangle.y);
|
||||
collisionGroup.addActor(collisionActor);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -224,12 +193,12 @@ public class MapStage extends GameStage {
|
||||
|
||||
}
|
||||
|
||||
private void effectDialog(EffectData E) {
|
||||
private void effectDialog(EffectData effectData) {
|
||||
dialog.getButtonTable().clear();
|
||||
dialog.getContentTable().clear();
|
||||
TextButton ok = Controls.newTextButton("OK", this::hideDialog);
|
||||
TextraButton ok = Controls.newTextButton("OK", this::hideDialog);
|
||||
ok.setVisible(false);
|
||||
TypingLabel L = Controls.newTypingLabel("{GRADIENT=CYAN;WHITE;1;1}Strange magical energies flow within this place...{ENDGRADIENT}\nAll opponents get:\n" + E.getDescription());
|
||||
TypingLabel L = Controls.newTypingLabel("{GRADIENT=CYAN;WHITE;1;1}Strange magical energies flow within this place...{ENDGRADIENT}\nAll opponents get:\n" + effectData.getDescription());
|
||||
L.setWrap(true);
|
||||
L.setTypingListener(new TypingAdapter() {
|
||||
@Override
|
||||
@@ -254,7 +223,7 @@ public class MapStage extends GameStage {
|
||||
dialog.getContentTable().add(image).height(100);
|
||||
dialog.getContentTable().add().row();
|
||||
}
|
||||
Label L = Controls.newLabel(message);
|
||||
TextraLabel L = Controls.newTextraLabel(message);
|
||||
L.setWrap(true);
|
||||
dialog.getContentTable().add(L).width(250f);
|
||||
dialog.getButtonTable().add(Controls.newTextButton("OK", this::hideDialog)).width(250f);
|
||||
@@ -266,81 +235,14 @@ public class MapStage extends GameStage {
|
||||
public void showDeckAwardDialog(String message, Deck deck) {
|
||||
dialog.getContentTable().clear();
|
||||
dialog.getButtonTable().clear();
|
||||
if (deck != null) {
|
||||
TextureAtlas atlas = Config.instance().getAtlas(MANA_ATLAS);
|
||||
ColorSet deckColor = DeckProxy.getColorIdentity(deck);
|
||||
if (deckColor.isColorless()) {
|
||||
Image pixC = new Image(atlas.createSprite("pixC"));
|
||||
pixC.setScaling(Scaling.fit);
|
||||
dialog.getContentTable().add(pixC).height(20).width(20);
|
||||
dialog.getContentTable().add().row();
|
||||
} else if (deckColor.isMonoColor()) {
|
||||
Image pix = new Image(atlas.createSprite("pixC"));
|
||||
if (deckColor.hasWhite())
|
||||
pix = new Image(atlas.createSprite("pixW"));
|
||||
else if (deckColor.hasBlue())
|
||||
pix = new Image(atlas.createSprite("pixU"));
|
||||
else if (deckColor.hasBlack())
|
||||
pix = new Image(atlas.createSprite("pixB"));
|
||||
else if (deckColor.hasRed())
|
||||
pix = new Image(atlas.createSprite("pixR"));
|
||||
else if (deckColor.hasGreen())
|
||||
pix = new Image(atlas.createSprite("pixG"));
|
||||
pix.setScaling(Scaling.fit);
|
||||
dialog.getContentTable().add(pix).height(20).width(20);
|
||||
dialog.getContentTable().add().row();
|
||||
} else if (deckColor.isMulticolor()) {
|
||||
Group group = new Group();
|
||||
int mul = 0;
|
||||
if (deckColor.hasWhite()) {
|
||||
Image pix = new Image(atlas.createSprite("pixW"));
|
||||
pix.setScaling(Scaling.fit);
|
||||
pix.setSize(20, 20);
|
||||
pix.setPosition(0, 0);
|
||||
group.addActor(pix);
|
||||
mul++;
|
||||
}
|
||||
if (deckColor.hasBlue()) {
|
||||
Image pix = new Image(atlas.createSprite("pixU"));
|
||||
pix.setScaling(Scaling.fit);
|
||||
pix.setSize(20, 20);
|
||||
pix.setPosition(20 * mul, 0);
|
||||
mul++;
|
||||
group.addActor(pix);
|
||||
}
|
||||
if (deckColor.hasBlack()) {
|
||||
Image pix = new Image(atlas.createSprite("pixB"));
|
||||
pix.setScaling(Scaling.fit);
|
||||
pix.setSize(20, 20);
|
||||
pix.setPosition(20 * mul, 0);
|
||||
mul++;
|
||||
group.addActor(pix);
|
||||
}
|
||||
if (deckColor.hasRed()) {
|
||||
Image pix = new Image(atlas.createSprite("pixR"));
|
||||
pix.setScaling(Scaling.fit);
|
||||
pix.setSize(20, 20);
|
||||
pix.setPosition(20 * mul, 0);
|
||||
mul++;
|
||||
group.addActor(pix);
|
||||
}
|
||||
if (deckColor.hasGreen()) {
|
||||
Image pix = new Image(atlas.createSprite("pixG"));
|
||||
pix.setScaling(Scaling.fit);
|
||||
pix.setSize(20, 20);
|
||||
pix.setPosition(20 * mul, 0);
|
||||
mul++;
|
||||
group.addActor(pix);
|
||||
}
|
||||
group.setHeight(20);
|
||||
group.setWidth(20 * mul);
|
||||
dialog.getContentTable().add(group).align(Align.center);
|
||||
dialog.getContentTable().add().row();
|
||||
}
|
||||
}
|
||||
|
||||
dialog.getContentTable().add(Controls.newTypingLabel(Controls.colorIdToTypingString(DeckProxy.getColorIdentity(deck)))).align(Align.center);
|
||||
dialog.getContentTable().add().row();
|
||||
|
||||
TypingLabel L = Controls.newTypingLabel(message);
|
||||
L.setWrap(true);
|
||||
L.skipToTheEnd();
|
||||
|
||||
dialog.getContentTable().add(L).width(240);
|
||||
dialog.getButtonTable().add(Controls.newTextButton("OK", this::hideDialog)).width(240);
|
||||
dialog.setKeepWithinStage(true);
|
||||
@@ -358,13 +260,14 @@ public class MapStage extends GameStage {
|
||||
foregroundSprites.removeActor(actor);
|
||||
}
|
||||
|
||||
actors = new Array<>();
|
||||
width = Float.parseFloat(map.getProperties().get("width").toString());
|
||||
height = Float.parseFloat(map.getProperties().get("height").toString());
|
||||
tileHeight = Float.parseFloat(map.getProperties().get("tileheight").toString());
|
||||
tileWidth = Float.parseFloat(map.getProperties().get("tilewidth").toString());
|
||||
actors.clear();
|
||||
collisionRect.clear();
|
||||
float width = Float.parseFloat(map.getProperties().get("width").toString());
|
||||
float height = Float.parseFloat(map.getProperties().get("height").toString());
|
||||
float tileHeight = Float.parseFloat(map.getProperties().get("tileheight").toString());
|
||||
float tileWidth = Float.parseFloat(map.getProperties().get("tilewidth").toString());
|
||||
setBounds(width * tileWidth, height * tileHeight);
|
||||
collision = new Array[(int) width][(int) height];
|
||||
//collision = new Array[(int) width][(int) height];
|
||||
|
||||
//Load dungeon effects.
|
||||
MapProperties MP = map.getProperties();
|
||||
@@ -379,8 +282,9 @@ public class MapStage extends GameStage {
|
||||
//TODO: Add a way to play a music file directly without using a playlist.
|
||||
}
|
||||
|
||||
GetPlayer().stop();
|
||||
getPlayerSprite().stop();
|
||||
spriteLayer = null;
|
||||
foundPlayerSpawn=false;
|
||||
for (MapLayer layer : map.getLayers()) {
|
||||
if (layer.getProperties().containsKey("spriteLayer") && layer.getProperties().get("spriteLayer", boolean.class)) {
|
||||
spriteLayer = layer;
|
||||
@@ -391,23 +295,57 @@ public class MapStage extends GameStage {
|
||||
loadObjects(layer, sourceMap);
|
||||
}
|
||||
}
|
||||
|
||||
//reduce geometry in collision rectangles
|
||||
int oldSize;
|
||||
do {
|
||||
oldSize=collisionRect.size;
|
||||
for(int i=0;i<collisionRect.size;i++)
|
||||
{
|
||||
Rectangle r1= collisionRect.get(i);
|
||||
for(int j=i+1;j<collisionRect.size;j++)
|
||||
{
|
||||
Rectangle r2= collisionRect.get(j);
|
||||
if((Math.abs(r1.x-r2.x+r2.width)<1&&Math.abs(r1.y-r2.y)<1&&Math.abs(r1.height-r2.height)<1)//left edge is the same as right edge
|
||||
|
||||
||(Math.abs(r1.x+r1.width-r2.x)<1&&Math.abs(r1.y-r2.y)<1&&Math.abs(r1.height-r2.height)<1)//right edge is the same as left edge
|
||||
|
||||
||(Math.abs(r1.x - r2.x )<1&& Math.abs(r1.y+r1.height-r2.y)<1&&Math.abs(r1.width-r2.width)<1)//top edge is the same as bottom edge
|
||||
|
||||
||(Math.abs(r1.x - r2.x )<1&& Math.abs(r1.y-r2.y+r2.height)<1&&Math.abs(r1.width-r2.width)<1)//bottom edge is the same as left edge
|
||||
|
||||
||containsOrEquals(r1,r2)||containsOrEquals(r2,r1)
|
||||
)
|
||||
{
|
||||
r1.merge(r2);
|
||||
collisionRect.removeIndex(j);
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}while (oldSize!=collisionRect.size);
|
||||
if (spriteLayer == null) System.err.print("Warning: No spriteLayer present in map.\n");
|
||||
|
||||
}
|
||||
|
||||
static public boolean containsOrEquals(Rectangle r1,Rectangle r2) {
|
||||
float xmi = r2.x;
|
||||
float xma = xmi + r2.width;
|
||||
float ymi = r2.y;
|
||||
float yma = ymi + r2.height;
|
||||
return xmi >= r1.x && xmi <= r1.x + r1.width && xma >= r1.x && xma <= r1.x + r1.width && ymi >= r1.y && ymi <= r1.y + r1.height && yma >= r1.y && yma <= r1.y + r1.height;
|
||||
}
|
||||
private void loadCollision(TiledMapTileLayer layer) {
|
||||
for (int x = 0; x < layer.getWidth(); x++) {
|
||||
for (int y = 0; y < layer.getHeight(); y++) {
|
||||
if (collision[x][y] == null)
|
||||
collision[x][y] = new Array<>();
|
||||
Array<Rectangle> map = collision[x][y];
|
||||
TiledMapTileLayer.Cell cell = layer.getCell(x, y);
|
||||
if (cell == null)
|
||||
continue;
|
||||
for (MapObject collision : cell.getTile().getObjects()) {
|
||||
if (collision instanceof RectangleMapObject) {
|
||||
Rectangle r = ((RectangleMapObject) collision).getRectangle();
|
||||
map.add(new Rectangle((Math.round(layer.getTileWidth() * x) + r.x), (Math.round(layer.getTileHeight() * y) + r.y), Math.round(r.width), Math.round(r.height)));
|
||||
collisionRect.add(new Rectangle((Math.round(layer.getTileWidth() * x) + r.x), (Math.round(layer.getTileHeight() * y) + r.y), Math.round(r.width), Math.round(r.height)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -415,13 +353,13 @@ public class MapStage extends GameStage {
|
||||
}
|
||||
|
||||
private boolean canSpawn(MapProperties prop) {
|
||||
DifficultyData DF = Current.player().getDifficulty();
|
||||
DifficultyData difficultyData = Current.player().getDifficulty();
|
||||
boolean spawnEasy = prop.get("spawn.Easy", Boolean.class);
|
||||
boolean spawnNorm = prop.get("spawn.Normal", Boolean.class);
|
||||
boolean spawnHard = prop.get("spawn.Hard", Boolean.class);
|
||||
if (DF.spawnRank == 2 && !spawnHard) return false;
|
||||
if (DF.spawnRank == 1 && !spawnNorm) return false;
|
||||
if (DF.spawnRank == 0 && !spawnEasy) return false;
|
||||
if (difficultyData.spawnRank == 2 && !spawnHard) return false;
|
||||
if (difficultyData.spawnRank == 1 && !spawnNorm) return false;
|
||||
if (difficultyData.spawnRank == 0 && !spawnEasy) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -429,8 +367,8 @@ public class MapStage extends GameStage {
|
||||
player.setMoveModifier(2);
|
||||
for (MapObject obj : layer.getObjects()) {
|
||||
MapProperties prop = obj.getProperties();
|
||||
if (prop.containsKey("type")) {
|
||||
String type = prop.get("type", String.class);
|
||||
String type = prop.get("type", String.class);
|
||||
if (type!=null) {
|
||||
int id = prop.get("id", int.class);
|
||||
if (changes.isObjectDeleted(id))
|
||||
continue;
|
||||
@@ -442,7 +380,18 @@ public class MapStage extends GameStage {
|
||||
float y = Float.parseFloat(prop.get("y").toString());
|
||||
float w = Float.parseFloat(prop.get("width").toString());
|
||||
float h = Float.parseFloat(prop.get("height").toString());
|
||||
EntryActor entry = new EntryActor(this, sourceMap, id, prop.get("teleport").toString(), x, y, w, h, prop.get("direction").toString());
|
||||
|
||||
String targetMap=prop.get("teleport").toString();
|
||||
boolean spawnPlayerThere=(targetMap==null||targetMap.isEmpty()&&sourceMap.isEmpty())||//if target is null and "from world"
|
||||
!sourceMap.isEmpty()&&targetMap.equals(sourceMap);
|
||||
|
||||
if(foundPlayerSpawn)
|
||||
spawnPlayerThere=false;
|
||||
if((prop.containsKey("spawn")&& prop.get("spawn").toString().equals("true"))&&spawnPlayerThere)
|
||||
{
|
||||
foundPlayerSpawn=true;
|
||||
}//set spawn to option with "spawn" over other entries
|
||||
EntryActor entry = new EntryActor(this, id, prop.get("teleport").toString(), x, y, w, h, prop.get("direction").toString(),spawnPlayerThere);
|
||||
addMapActor(obj, entry);
|
||||
break;
|
||||
case "reward":
|
||||
@@ -462,33 +411,33 @@ public class MapStage extends GameStage {
|
||||
break;
|
||||
case "enemy":
|
||||
if (!canSpawn(prop)) break;
|
||||
Object E = prop.get("enemy");
|
||||
if (E != null && !E.toString().isEmpty()) {
|
||||
EnemyData EN = WorldData.getEnemy(E.toString());
|
||||
Object enemy = prop.get("enemy");
|
||||
if (enemy != null && !enemy.toString().isEmpty()) {
|
||||
EnemyData EN = WorldData.getEnemy(enemy.toString());
|
||||
if (EN == null) {
|
||||
System.err.printf("Enemy \"%s\" not found.", E.toString());
|
||||
System.err.printf("Enemy \"%s\" not found.", enemy);
|
||||
break;
|
||||
}
|
||||
EnemySprite mob = new EnemySprite(id, EN);
|
||||
Object D = prop.get("dialog"); //Check if the enemy has a dialogue attached to it.
|
||||
if (D != null && !D.toString().isEmpty()) {
|
||||
mob.dialog = new MapDialog(D.toString(), this, mob.getId());
|
||||
Object dialogObject = prop.get("dialog"); //Check if the enemy has a dialogue attached to it.
|
||||
if (dialogObject != null && !dialogObject.toString().isEmpty()) {
|
||||
mob.dialog = new MapDialog(dialogObject.toString(), this, mob.getId());
|
||||
}
|
||||
D = prop.get("defeatDialog"); //Check if the enemy has a defeat dialogue attached to it.
|
||||
if (D != null && !D.toString().isEmpty()) {
|
||||
mob.defeatDialog = new MapDialog(D.toString(), this, mob.getId());
|
||||
dialogObject = prop.get("defeatDialog"); //Check if the enemy has a defeat dialogue attached to it.
|
||||
if (dialogObject != null && !dialogObject.toString().isEmpty()) {
|
||||
mob.defeatDialog = new MapDialog(dialogObject.toString(), this, mob.getId());
|
||||
}
|
||||
D = prop.get("name"); //Check for name override.
|
||||
if (D != null && !D.toString().isEmpty()) {
|
||||
mob.nameOverride = D.toString();
|
||||
dialogObject = prop.get("name"); //Check for name override.
|
||||
if (dialogObject != null && !dialogObject.toString().isEmpty()) {
|
||||
mob.nameOverride = dialogObject.toString();
|
||||
}
|
||||
D = prop.get("effect"); //Check for special effects.
|
||||
if (D != null && !D.toString().isEmpty()) {
|
||||
mob.effect = JSONStringLoader.parse(EffectData.class, D.toString(), "");
|
||||
dialogObject = prop.get("effect"); //Check for special effects.
|
||||
if (dialogObject != null && !dialogObject.toString().isEmpty()) {
|
||||
mob.effect = JSONStringLoader.parse(EffectData.class, dialogObject.toString(), "");
|
||||
}
|
||||
D = prop.get("reward"); //Check for additional rewards.
|
||||
if (D != null && !D.toString().isEmpty()) {
|
||||
mob.rewards = JSONStringLoader.parse(RewardData[].class, D.toString(), "[]");
|
||||
dialogObject = prop.get("reward"); //Check for additional rewards.
|
||||
if (dialogObject != null && !dialogObject.toString().isEmpty()) {
|
||||
mob.rewards = JSONStringLoader.parse(RewardData[].class, dialogObject.toString(), "[]");
|
||||
}
|
||||
mob.hidden = hidden; //Evil.
|
||||
addMapActor(obj, mob);
|
||||
@@ -502,18 +451,30 @@ public class MapStage extends GameStage {
|
||||
//TODO: Ability to move them (using a sequence such as "UULU" for up, up, left, up).
|
||||
break;
|
||||
case "inn":
|
||||
addMapActor(obj, new OnCollide(() -> Forge.switchScene(SceneType.InnScene.instance)));
|
||||
addMapActor(obj, new OnCollide(() -> Forge.switchScene(InnScene.instance())));
|
||||
break;
|
||||
case "spellsmith":
|
||||
addMapActor(obj, new OnCollide(() -> Forge.switchScene(SceneType.SpellSmithScene.instance)));
|
||||
addMapActor(obj, new OnCollide(() -> Forge.switchScene(SpellSmithScene.instance())));
|
||||
break;
|
||||
case "arena":
|
||||
|
||||
addMapActor(obj, new OnCollide(() -> {
|
||||
ArenaData arenaData = JSONStringLoader.parse(ArenaData.class, prop.get("arena").toString(), "");
|
||||
ArenaScene.instance().loadArenaData(arenaData,WorldSave.getCurrentSave().getWorld().getRandom().nextLong());
|
||||
Forge.switchScene(ArenaScene.instance());
|
||||
}));
|
||||
break;
|
||||
case "exit":
|
||||
addMapActor(obj, new OnCollide(() -> MapStage.this.exit()));
|
||||
addMapActor(obj, new OnCollide(MapStage.this::exit));
|
||||
break;
|
||||
case "dialog":
|
||||
if (obj instanceof TiledMapTileMapObject) {
|
||||
TiledMapTileMapObject tiledObj = (TiledMapTileMapObject) obj;
|
||||
DialogActor dialog = new DialogActor(this, id, prop.get("dialog").toString(), tiledObj.getTextureRegion());
|
||||
DialogActor dialog;
|
||||
if(prop.containsKey("sprite"))
|
||||
dialog= new DialogActor(this, id, prop.get("dialog").toString(), prop.get("sprite").toString());
|
||||
else
|
||||
dialog= new DialogActor(this, id, prop.get("dialog").toString(), tiledObj.getTextureRegion());
|
||||
addMapActor(obj, dialog);
|
||||
}
|
||||
break;
|
||||
@@ -563,7 +524,7 @@ public class MapStage extends GameStage {
|
||||
isLoadingMatch = false;
|
||||
effect = null; //Reset dungeon effects.
|
||||
clearIsInMap();
|
||||
Forge.switchScene(SceneType.GameScene.instance);
|
||||
Forge.switchScene(GameScene.instance());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -572,9 +533,11 @@ public class MapStage extends GameStage {
|
||||
public void setWinner(boolean playerWins) {
|
||||
isLoadingMatch = false;
|
||||
if (playerWins) {
|
||||
|
||||
Current.player().win();
|
||||
player.setAnimation(CharacterSprite.AnimationTypes.Attack);
|
||||
currentMob.setAnimation(CharacterSprite.AnimationTypes.Death);
|
||||
startPause(0.3f, () -> MapStage.this.getReward());
|
||||
startPause(0.3f, MapStage.this::getReward);
|
||||
} else {
|
||||
player.setAnimation(CharacterSprite.AnimationTypes.Hit);
|
||||
currentMob.setAnimation(CharacterSprite.AnimationTypes.Attack);
|
||||
@@ -621,8 +584,8 @@ public class MapStage extends GameStage {
|
||||
|
||||
protected void getReward() {
|
||||
isLoadingMatch = false;
|
||||
((RewardScene) SceneType.RewardScene.instance).loadRewards(currentMob.getRewards(), RewardScene.Type.Loot, null);
|
||||
Forge.switchScene(SceneType.RewardScene.instance);
|
||||
RewardScene.instance().loadRewards(currentMob.getRewards(), RewardScene.Type.Loot, null);
|
||||
Forge.switchScene(RewardScene.instance());
|
||||
if (currentMob.defeatDialog == null) {
|
||||
currentMob.remove();
|
||||
actors.removeValue(currentMob, true);
|
||||
@@ -647,6 +610,8 @@ public class MapStage extends GameStage {
|
||||
|
||||
@Override
|
||||
protected void onActing(float delta) {
|
||||
float sprintingMod=currentModifications.containsKey(PlayerModification.Sprint)?2:1;
|
||||
player.setMoveModifier(2*sprintingMod);
|
||||
oldPosition4.set(oldPosition3);
|
||||
oldPosition3.set(oldPosition2);
|
||||
oldPosition2.set(oldPosition);
|
||||
@@ -669,11 +634,11 @@ public class MapStage extends GameStage {
|
||||
Controllers.getCurrent().startVibration(100,1);
|
||||
startPause(0.1f, () -> { //Switch to item pickup scene.
|
||||
RewardSprite RS = (RewardSprite) actor;
|
||||
((RewardScene) SceneType.RewardScene.instance).loadRewards(RS.getRewards(), RewardScene.Type.Loot, null);
|
||||
RewardScene.instance().loadRewards(RS.getRewards(), RewardScene.Type.Loot, null);
|
||||
RS.remove();
|
||||
actors.removeValue(RS, true);
|
||||
changes.deleteObject(RS.getId());
|
||||
Forge.switchScene(SceneType.RewardScene.instance);
|
||||
Forge.switchScene(RewardScene.instance());
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -694,7 +659,7 @@ public class MapStage extends GameStage {
|
||||
startPause(0.8f, () -> {
|
||||
Forge.setCursor(null, Forge.magnifyToggle ? "1" : "2");
|
||||
SoundSystem.instance.play(SoundEffectType.ManaBurn, false);
|
||||
DuelScene duelScene = ((DuelScene) SceneType.DuelScene.instance);
|
||||
DuelScene duelScene = DuelScene.instance();
|
||||
FThreads.invokeInEdtNowOrLater(() -> {
|
||||
if (!isLoadingMatch) {
|
||||
isLoadingMatch = true;
|
||||
@@ -703,7 +668,7 @@ public class MapStage extends GameStage {
|
||||
Forge.clearTransitionScreen();
|
||||
startPause(0.3f, () -> {
|
||||
if (isInMap && effect != null) duelScene.setDungeonEffect(effect);
|
||||
Forge.switchScene(SceneType.DuelScene.instance);
|
||||
Forge.switchScene(DuelScene.instance());
|
||||
});
|
||||
}, Forge.takeScreenshot(), true, false));
|
||||
}
|
||||
@@ -728,7 +693,7 @@ public class MapStage extends GameStage {
|
||||
else
|
||||
dialogButtonMap.clear();
|
||||
for (int i = 0; i < dialog.getButtonTable().getCells().size; i++) {
|
||||
dialogButtonMap.put(i, (TextButton) dialog.getButtonTable().getCells().get(i).getActor());
|
||||
dialogButtonMap.put(i, (TextraButton) dialog.getButtonTable().getCells().get(i).getActor());
|
||||
}
|
||||
dialog.show(dialogStage, Actions.show());
|
||||
dialog.setPosition((dialogStage.getWidth() - dialog.getWidth()) / 2, (dialogStage.getHeight() - dialog.getHeight()) / 2);
|
||||
@@ -793,7 +758,7 @@ public class MapStage extends GameStage {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void selectDialogButton(TextButton dialogButton, boolean press) {
|
||||
private void selectDialogButton(TextraButton dialogButton, boolean press) {
|
||||
if (dialogOnlyInput) {
|
||||
if (selectedKey != null)
|
||||
selectedKey.fire(eventExit);
|
||||
@@ -817,7 +782,7 @@ public class MapStage extends GameStage {
|
||||
}
|
||||
}, 0.10f);
|
||||
}
|
||||
private int getButtonIndexKey(TextButton dialogbutton) {
|
||||
private int getButtonIndexKey(TextraButton dialogbutton) {
|
||||
if (dialogButtonMap.isEmpty())
|
||||
return 0;
|
||||
Integer key = dialogButtonMap.findKey(dialogbutton, true);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.adventure.stage;
|
||||
|
||||
import com.badlogic.gdx.graphics.Camera;
|
||||
import com.badlogic.gdx.maps.MapLayer;
|
||||
import com.badlogic.gdx.maps.tiled.TiledMap;
|
||||
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
|
||||
@@ -18,6 +19,9 @@ public class PointOfInterestMapRenderer extends OrthogonalTiledMapRenderer {
|
||||
|
||||
@Override
|
||||
public void render () {
|
||||
Camera camera = stage.getCamera();
|
||||
camera.update();
|
||||
batch.setProjectionMatrix(camera.combined);
|
||||
beginRender();
|
||||
for (MapLayer layer : map.getLayers()) {
|
||||
renderMapLayer(layer);
|
||||
@@ -27,7 +31,6 @@ public class PointOfInterestMapRenderer extends OrthogonalTiledMapRenderer {
|
||||
}
|
||||
}
|
||||
endRender();
|
||||
stage.getCamera().update();
|
||||
}
|
||||
|
||||
public void loadMap(TiledMap map,String sourceMap)
|
||||
|
||||
@@ -81,17 +81,17 @@ public class WorldBackground extends Actor {
|
||||
|
||||
}
|
||||
|
||||
private void loadChunk(int x, int y) {
|
||||
public void loadChunk(int x, int y) {
|
||||
if (chunksSprites[x][y] == null)
|
||||
chunksSprites[x][y] = MapSprite.GetMapSprites(x, y);
|
||||
|
||||
for (Actor sprite : chunksSprites[x][y]) {
|
||||
stage.GetSpriteGroup().addActor(sprite);
|
||||
stage.getSpriteGroup().addActor(sprite);
|
||||
}
|
||||
if (chunksSpritesBackground[x][y] == null)
|
||||
chunksSpritesBackground[x][y] = MapSprite.GetMapSpritesBackground(x, y);
|
||||
for (Actor sprite : chunksSpritesBackground[x][y]) {
|
||||
stage.GetBackgroundSprites().addActor(sprite);
|
||||
stage.getBackgroundSprites().addActor(sprite);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,13 +99,13 @@ public class WorldBackground extends Actor {
|
||||
Array<Actor> sprites = chunksSprites[x][y];
|
||||
if (sprites != null) {
|
||||
for (Actor sprite : sprites) {
|
||||
stage.GetSpriteGroup().removeActor(sprite);
|
||||
stage.getSpriteGroup().removeActor(sprite);
|
||||
}
|
||||
}
|
||||
sprites = chunksSpritesBackground[x][y];
|
||||
if (sprites != null) {
|
||||
for (Actor sprite : sprites) {
|
||||
stage.GetBackgroundSprites().removeActor(sprite);
|
||||
stage.getBackgroundSprites().removeActor(sprite);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,7 +129,7 @@ public class WorldBackground extends Actor {
|
||||
chunkSize = WorldSave.getCurrentSave().getWorld().getChunkSize();
|
||||
if(chunks!=null)
|
||||
{
|
||||
stage.GetSpriteGroup().clear();
|
||||
stage.getSpriteGroup().clear();
|
||||
for(int i=0;i<chunks.length;i++)
|
||||
for(int j=0;j<chunks[i].length;j++)
|
||||
if(chunks[i][j]!=null)
|
||||
|
||||
@@ -2,6 +2,7 @@ package forge.adventure.stage;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.controllers.Controllers;
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
@@ -12,8 +13,12 @@ import forge.adventure.character.EnemySprite;
|
||||
import forge.adventure.data.BiomeData;
|
||||
import forge.adventure.data.EnemyData;
|
||||
import forge.adventure.data.WorldData;
|
||||
import forge.adventure.scene.*;
|
||||
import forge.adventure.scene.DuelScene;
|
||||
import forge.adventure.scene.RewardScene;
|
||||
import forge.adventure.scene.Scene;
|
||||
import forge.adventure.scene.TileMapScene;
|
||||
import forge.adventure.util.Current;
|
||||
import forge.adventure.util.Paths;
|
||||
import forge.adventure.util.SaveFileContent;
|
||||
import forge.adventure.util.SaveFileData;
|
||||
import forge.adventure.world.World;
|
||||
@@ -41,10 +46,10 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
protected Random rand = MyRandom.getRandom();
|
||||
WorldBackground background;
|
||||
private float spawnDelay = 0;
|
||||
private final float spawnInterval = 4;//todo config
|
||||
private static final float spawnInterval = 4;//todo config
|
||||
private PointOfInterestMapSprite collidingPoint;
|
||||
protected ArrayList<Pair<Float, EnemySprite>> enemies = new ArrayList<>();
|
||||
private final Float dieTimer=20f;//todo config
|
||||
private final static Float dieTimer=20f;//todo config
|
||||
private Float globalTimer=0f;
|
||||
|
||||
public WorldStage() {
|
||||
@@ -64,7 +69,7 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
@Override
|
||||
protected void onActing(float delta) {
|
||||
if (player.isMoving()) {
|
||||
HandleMonsterSpawn(delta);
|
||||
handleMonsterSpawn(delta);
|
||||
handlePointsOfInterestCollision();
|
||||
globalTimer+=delta;
|
||||
Iterator<Pair<Float, EnemySprite>> it = enemies.iterator();
|
||||
@@ -79,31 +84,35 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
}
|
||||
EnemySprite mob=pair.getValue();
|
||||
|
||||
enemyMoveVector.set(player.getX(), player.getY()).sub(mob.pos());
|
||||
enemyMoveVector.setLength(mob.speed()*delta);
|
||||
tempBoundingRect.set(mob.getX()+ enemyMoveVector.x,mob.getY()+ enemyMoveVector.y,mob.getWidth(),mob.getHeight()*mob.getCollisionHeight());
|
||||
|
||||
if(!mob.getData().flying && WorldSave.getCurrentSave().getWorld().collidingTile(tempBoundingRect))//if direct path is not possible
|
||||
if(!currentModifications.containsKey(PlayerModification.Hide))
|
||||
{
|
||||
tempBoundingRect.set(mob.getX()+ enemyMoveVector.x,mob.getY(),mob.getWidth(),mob.getHeight());
|
||||
if(WorldSave.getCurrentSave().getWorld().collidingTile(tempBoundingRect))//if only x path is not possible
|
||||
enemyMoveVector.set(player.getX(), player.getY()).sub(mob.pos());
|
||||
enemyMoveVector.setLength(mob.speed()*delta);
|
||||
tempBoundingRect.set(mob.getX()+ enemyMoveVector.x,mob.getY()+ enemyMoveVector.y,mob.getWidth(),mob.getHeight()*mob.getCollisionHeight());
|
||||
|
||||
if(!mob.getData().flying && WorldSave.getCurrentSave().getWorld().collidingTile(tempBoundingRect))//if direct path is not possible
|
||||
{
|
||||
tempBoundingRect.set(mob.getX(),mob.getY()+ enemyMoveVector.y,mob.getWidth(),mob.getHeight());
|
||||
if(!WorldSave.getCurrentSave().getWorld().collidingTile(tempBoundingRect))//if y path is possible
|
||||
tempBoundingRect.set(mob.getX()+ enemyMoveVector.x,mob.getY(),mob.getWidth(),mob.getHeight());
|
||||
if(WorldSave.getCurrentSave().getWorld().collidingTile(tempBoundingRect))//if only x path is not possible
|
||||
{
|
||||
mob.moveBy(0, enemyMoveVector.y);
|
||||
tempBoundingRect.set(mob.getX(),mob.getY()+ enemyMoveVector.y,mob.getWidth(),mob.getHeight());
|
||||
if(!WorldSave.getCurrentSave().getWorld().collidingTile(tempBoundingRect))//if y path is possible
|
||||
{
|
||||
mob.moveBy(0, enemyMoveVector.y);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
mob.moveBy(enemyMoveVector.x, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
mob.moveBy(enemyMoveVector.x, 0);
|
||||
mob.moveBy(enemyMoveVector.x, enemyMoveVector.y);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mob.moveBy(enemyMoveVector.x, enemyMoveVector.y);
|
||||
}
|
||||
|
||||
|
||||
if (player.collideWith(mob)) {
|
||||
player.setAnimation(CharacterSprite.AnimationTypes.Attack);
|
||||
@@ -116,12 +125,12 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
startPause(0.8f, () -> {
|
||||
Forge.setCursor(null, Forge.magnifyToggle ? "1" : "2");
|
||||
SoundSystem.instance.play(SoundEffectType.ManaBurn, false);
|
||||
DuelScene duelScene = ((DuelScene) SceneType.DuelScene.instance);
|
||||
DuelScene duelScene = DuelScene.instance();
|
||||
FThreads.invokeInEdtNowOrLater(() -> {
|
||||
Forge.setTransitionScreen(new TransitionScreen(() -> {
|
||||
duelScene.initDuels(player, mob);
|
||||
Forge.clearTransitionScreen();
|
||||
startPause(0.3f, () -> Forge.switchScene(SceneType.DuelScene.instance));
|
||||
startPause(0.3f, () -> Forge.switchScene(DuelScene.instance()));
|
||||
}, Forge.takeScreenshot(), true, false));
|
||||
currentMob = mob;
|
||||
WorldSave.getCurrentSave().autoSave();
|
||||
@@ -140,7 +149,7 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
}
|
||||
private void removeEnemy(EnemySprite currentMob) {
|
||||
|
||||
foregroundSprites.removeActor(currentMob);
|
||||
currentMob.removeAfterEffects();
|
||||
Iterator<Pair<Float, EnemySprite>> it = enemies.iterator();
|
||||
while (it.hasNext()) {
|
||||
Pair<Float, EnemySprite> pair = it.next();
|
||||
@@ -154,13 +163,14 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
public void setWinner(boolean playerIsWinner) {
|
||||
|
||||
if (playerIsWinner) {
|
||||
Current.player().win();
|
||||
player.setAnimation(CharacterSprite.AnimationTypes.Attack);
|
||||
currentMob.setAnimation(CharacterSprite.AnimationTypes.Death);
|
||||
startPause(0.5f, () -> {
|
||||
((RewardScene) SceneType.RewardScene.instance).loadRewards(currentMob.getRewards(), RewardScene.Type.Loot, null);
|
||||
RewardScene.instance().loadRewards(currentMob.getRewards(), RewardScene.Type.Loot, null);
|
||||
WorldStage.this.removeEnemy(currentMob);
|
||||
currentMob = null;
|
||||
Forge.switchScene(SceneType.RewardScene.instance);
|
||||
Forge.switchScene(RewardScene.instance());
|
||||
});
|
||||
} else {
|
||||
player.setAnimation(CharacterSprite.AnimationTypes.Hit);
|
||||
@@ -174,7 +184,7 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
}
|
||||
|
||||
}
|
||||
private void handlePointsOfInterestCollision() {
|
||||
public void handlePointsOfInterestCollision() {
|
||||
|
||||
for (Actor actor : foregroundSprites.getChildren()) {
|
||||
if (actor.getClass() == PointOfInterestMapSprite.class) {
|
||||
@@ -183,8 +193,8 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
if (point == collidingPoint) {
|
||||
continue;
|
||||
}
|
||||
((TileMapScene) SceneType.TileMapScene.instance).load(point.getPointOfInterest());
|
||||
Forge.switchScene(SceneType.TileMapScene.instance);
|
||||
TileMapScene.instance().load(point.getPointOfInterest());
|
||||
Forge.switchScene(TileMapScene.instance());
|
||||
} else {
|
||||
if (point == collidingPoint) {
|
||||
collidingPoint = null;
|
||||
@@ -197,7 +207,8 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
@Override
|
||||
public boolean isColliding(Rectangle boundingRect)
|
||||
{
|
||||
|
||||
if(currentModifications.containsKey(PlayerModification.Fly))
|
||||
return false;
|
||||
return WorldSave.getCurrentSave().getWorld().collidingTile(boundingRect);
|
||||
}
|
||||
public boolean spawn(String enemy)
|
||||
@@ -205,15 +216,16 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
return spawn(WorldData.getEnemy(enemy));
|
||||
}
|
||||
|
||||
private void HandleMonsterSpawn(float delta) {
|
||||
private void handleMonsterSpawn(float delta) {
|
||||
World world = WorldSave.getCurrentSave().getWorld();
|
||||
int currentBiome = World.highestBiome(world.getBiome((int) player.getX() / world.getTileSize(), (int) player.getY() / world.getTileSize()));
|
||||
List<BiomeData> biomeData = WorldSave.getCurrentSave().getWorld().getData().GetBiomes();
|
||||
if (biomeData.size() <= currentBiome) {
|
||||
player.setMoveModifier(1.5f);
|
||||
float sprintingMod=currentModifications.containsKey(PlayerModification.Sprint)?2:1;
|
||||
if (biomeData.size() <= currentBiome) {// "if isOnRoad
|
||||
player.setMoveModifier(1.5f*sprintingMod);
|
||||
return;
|
||||
}
|
||||
player.setMoveModifier(1.0f);
|
||||
player.setMoveModifier(1.0f*sprintingMod);
|
||||
BiomeData data = biomeData.get(currentBiome);
|
||||
if (data == null) return;
|
||||
|
||||
@@ -277,8 +289,8 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
GetPlayer().LoadPos();
|
||||
GetPlayer().setMovementDirection(Vector2.Zero);
|
||||
getPlayerSprite().LoadPos();
|
||||
getPlayerSprite().setMovementDirection(Vector2.Zero);
|
||||
for (Actor actor : foregroundSprites.getChildren()) {
|
||||
if (actor.getClass() == PointOfInterestMapSprite.class) {
|
||||
PointOfInterestMapSprite point = (PointOfInterestMapSprite) actor;
|
||||
@@ -289,11 +301,15 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
|
||||
}
|
||||
setBounds(WorldSave.getCurrentSave().getWorld().getWidthInPixels(), WorldSave.getCurrentSave().getWorld().getHeightInPixels());
|
||||
|
||||
GridPoint2 pos = background.translateFromWorldToChunk(player.getX(), player.getY());
|
||||
background.loadChunk(pos.x,pos.y);
|
||||
handlePointsOfInterestCollision();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void leave() {
|
||||
GetPlayer().storePos();
|
||||
getPlayerSprite().storePos();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -358,4 +374,26 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
public Viewport getViewport() {
|
||||
return super.getViewport();
|
||||
}
|
||||
|
||||
|
||||
public void removeNearestEnemy() {
|
||||
|
||||
float shortestDist=Float.MAX_VALUE;
|
||||
EnemySprite enemy=null;
|
||||
for (Pair<Float, EnemySprite> pair : enemies) {
|
||||
float dist= pair.getValue().pos().sub(player.pos()).len();
|
||||
if(dist<shortestDist)
|
||||
{
|
||||
shortestDist=dist;
|
||||
enemy=pair.getValue();
|
||||
}
|
||||
}
|
||||
if(enemy!=null)
|
||||
{
|
||||
enemy.playEffect(Paths.EFFECT_KILL);
|
||||
removeEnemy(enemy);
|
||||
player.playEffect(Paths.TRIGGER_KILL);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,9 +280,16 @@ public class CardUtil {
|
||||
return getCardPrice(card);
|
||||
if(reward.getItem()!=null)
|
||||
return reward.getItem().cost;
|
||||
if(reward.getType()== Reward.Type.Life)
|
||||
return reward.getCount()*500;
|
||||
if(reward.getType()== Reward.Type.Mana)
|
||||
return reward.getCount()*500;
|
||||
if(reward.getType()== Reward.Type.Gold)
|
||||
return reward.getCount();
|
||||
return 1000;
|
||||
}
|
||||
|
||||
static List<PrintSheet> jumpStartSheetsCandidates=null;
|
||||
public static Deck generateDeck(GeneratedDeckData data)
|
||||
{
|
||||
Deck deck= new Deck(data.name);
|
||||
@@ -309,16 +316,19 @@ public class CardUtil {
|
||||
case MagicColor.RED: targetName = "Mountain";break;
|
||||
case MagicColor.GREEN: targetName = "Forest"; break;
|
||||
}
|
||||
|
||||
List<PrintSheet> candidates=new ArrayList<>();
|
||||
for(PrintSheet sheet : StaticData.instance().getPrintSheets())
|
||||
if(jumpStartSheetsCandidates==null)
|
||||
{
|
||||
if(sheet.containsCardNamed(targetName,3)&&sheet.getName().startsWith("JMP"))//dodge the rainbow jumpstart sheet
|
||||
jumpStartSheetsCandidates=new ArrayList<>();
|
||||
for(PrintSheet sheet : StaticData.instance().getPrintSheets())
|
||||
{
|
||||
candidates.add(sheet);
|
||||
if(sheet.containsCardNamed(targetName,3) && sheet.getName().startsWith("JMP") && sheet.all().size() == 20)//dodge the rainbow jumpstart sheet and the sheet for every card
|
||||
{
|
||||
jumpStartSheetsCandidates.add(sheet);
|
||||
}
|
||||
}
|
||||
}
|
||||
deck.getOrCreate(DeckSection.Main).addAllFlat(candidates.get(Current.world().getRandom().nextInt(candidates.size())).all());
|
||||
PrintSheet sheet=jumpStartSheetsCandidates.get(Current.world().getRandom().nextInt(jumpStartSheetsCandidates.size()));
|
||||
deck.getOrCreate(DeckSection.Main).addAllFlat(sheet.all());
|
||||
}
|
||||
return deck;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package forge.adventure.util;
|
||||
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
@@ -11,8 +12,13 @@ import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Null;
|
||||
import com.github.tommyettinger.textra.Font;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import com.github.tommyettinger.textra.TypingLabel;
|
||||
import forge.Forge;
|
||||
import forge.card.ColorSet;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -20,8 +26,48 @@ import java.util.function.Function;
|
||||
* Class to create ui elements in the correct style
|
||||
*/
|
||||
public class Controls {
|
||||
static public TextButton newTextButton(String text) {
|
||||
return new TextButton(text, GetSkin());
|
||||
static class LabelFix extends TextraLabel
|
||||
{
|
||||
public LabelFix(String text)
|
||||
{
|
||||
super(text, getSkin(),getTextraFont());
|
||||
}
|
||||
@Override
|
||||
public void setText(@Null String text) {
|
||||
this.storedText = text;
|
||||
this.layout.setTargetWidth(this.getMaxWidth());
|
||||
this.getFont().markup(text, this.layout.clear());
|
||||
this.setWidth(this.layout.getWidth() + (this.style != null && this.style.background != null ? this.style.background.getLeftWidth() + this.style.background.getRightWidth() : 0.0F));
|
||||
layout();
|
||||
}
|
||||
}
|
||||
static class TextButtonFix extends TextraButton
|
||||
{
|
||||
public TextButtonFix(@Null String text)
|
||||
{
|
||||
super(text, Controls.getSkin(),Controls.getTextraFont()) ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStyle(Button.ButtonStyle style, boolean makeGridGlyphs) {
|
||||
super.setStyle(style,makeGridGlyphs);
|
||||
this.getTextraLabel().setFont( Controls.getTextraFont());
|
||||
|
||||
}
|
||||
@Override
|
||||
public void setText(@Null String text) {
|
||||
getTextraLabel().storedText = text;
|
||||
getTextraLabel().layout.setTargetWidth(getTextraLabel().getMaxWidth());
|
||||
getTextraLabel().getFont().markup(text, getTextraLabel().layout.clear());
|
||||
getTextraLabel().setWidth(getTextraLabel().layout.getWidth() + (getTextraLabel().style != null && getTextraLabel().style.background != null ? getTextraLabel().style.background.getLeftWidth() + getTextraLabel().style.background.getRightWidth() : 0.0F));
|
||||
layout();
|
||||
}
|
||||
}
|
||||
static public TextraButton newTextButton(String text) {
|
||||
TextraButton button= new TextButtonFix(text);
|
||||
// button.getTextraLabelCell().fill(true,false).expand(true,false);//keep it the same as TextButton
|
||||
button.getTextraLabel().setWrap(false);
|
||||
return button;
|
||||
}
|
||||
static public Rectangle getBoundingRect(Actor actor) {
|
||||
return new Rectangle(actor.getX(),actor.getY(),actor.getWidth(),actor.getHeight());
|
||||
@@ -33,7 +79,7 @@ public class Controls {
|
||||
}
|
||||
|
||||
static public SelectBox newComboBox(String[] text, String item, Function<Object, Void> func) {
|
||||
SelectBox ret = new SelectBox<String>(GetSkin());
|
||||
SelectBox ret = new SelectBox<String>(getSkin());
|
||||
ret.getStyle().listStyle.selection.setTopHeight(4);
|
||||
ret.setItems(text);
|
||||
ret.addListener(new ChangeListener() {
|
||||
@@ -54,7 +100,7 @@ public class Controls {
|
||||
}
|
||||
|
||||
static public SelectBox newComboBox(Float[] text, float item, Function<Object, Void> func) {
|
||||
SelectBox ret = new SelectBox<Float>(GetSkin());
|
||||
SelectBox ret = new SelectBox<Float>(getSkin());
|
||||
ret.getStyle().listStyle.selection.setTopHeight(4);
|
||||
ret.setItems(text);
|
||||
ret.addListener(new ChangeListener() {
|
||||
@@ -75,11 +121,11 @@ public class Controls {
|
||||
}
|
||||
|
||||
static public TextField newTextField(String text) {
|
||||
return new TextField(text, GetSkin());
|
||||
return new TextField(text, getSkin());
|
||||
}
|
||||
|
||||
static public TextField newTextField(String text, Function<String, Void> func) {
|
||||
TextField ret = new TextField(text, GetSkin());
|
||||
TextField ret = new TextField(text, getSkin());
|
||||
ret.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
@@ -94,8 +140,8 @@ public class Controls {
|
||||
return ret;
|
||||
}
|
||||
|
||||
static public TextButton newTextButton(String text, Runnable func) {
|
||||
TextButton ret = newTextButton(text);
|
||||
static public TextraButton newTextButton(String text, Runnable func) {
|
||||
TextraButton ret = newTextButton(text);
|
||||
ret.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
@@ -111,12 +157,12 @@ public class Controls {
|
||||
}
|
||||
|
||||
static public Slider newSlider(float min, float max, float step, boolean vertical) {
|
||||
Slider ret = new Slider(min, max, step, vertical, GetSkin());
|
||||
Slider ret = new Slider(min, max, step, vertical, getSkin());
|
||||
return ret;
|
||||
}
|
||||
|
||||
static public CheckBox newCheckBox(String text) {
|
||||
CheckBox ret = new CheckBox(text, GetSkin());
|
||||
CheckBox ret = new CheckBox(text, getSkin());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -124,15 +170,15 @@ public class Controls {
|
||||
switch (fontName) {
|
||||
case "blackbig":
|
||||
case "big":
|
||||
GetSkin().getFont("default").getData().setScale(2, 2);
|
||||
return GetSkin().getFont("default");
|
||||
getSkin().getFont("default").getData().setScale(2, 2);
|
||||
return getSkin().getFont("default");
|
||||
default:
|
||||
GetSkin().getFont("default").getData().setScale(1, 1);
|
||||
return GetSkin().getFont("default");
|
||||
getSkin().getFont("default").getData().setScale(1, 1);
|
||||
return getSkin().getFont("default");
|
||||
}
|
||||
}
|
||||
|
||||
static public Skin GetSkin() {
|
||||
static public Skin getSkin() {
|
||||
FileHandle skinFile = Config.instance().getFile(Paths.SKIN);
|
||||
if (!Forge.getAssets().manager().contains(skinFile.path(), Skin.class)) {
|
||||
Forge.getAssets().manager().load(skinFile.path(), Skin.class);
|
||||
@@ -140,32 +186,151 @@ public class Controls {
|
||||
FileHandle atlasFile = skinFile.sibling(skinFile.nameWithoutExtension() + ".atlas");
|
||||
Forge.getAssets().manager().load(atlasFile.path(), TextureAtlas.class);
|
||||
Forge.getAssets().manager().finishLoadingAsset(atlasFile.path());
|
||||
//font
|
||||
/*/font skin will load the LanaPixel.fnt now
|
||||
FileHandle pixelFont = Config.instance().getFile(Paths.SKIN).sibling("LanaPixel.fnt");
|
||||
Forge.getAssets().manager().load(pixelFont.path(), BitmapFont.class);
|
||||
Forge.getAssets().manager().finishLoadingAsset(pixelFont.path());
|
||||
Forge.getAssets().manager().get(skinFile.path(), Skin.class).add("default", Forge.getAssets().manager().get(pixelFont.path(), BitmapFont.class), BitmapFont.class);
|
||||
Forge.getAssets().manager().get(skinFile.path(), Skin.class).addRegions(Forge.getAssets().manager().get(atlasFile.path(), TextureAtlas.class));
|
||||
Forge.getAssets().manager().finishLoadingAsset(skinFile.path());
|
||||
*/
|
||||
|
||||
}
|
||||
return Forge.getAssets().manager().get(skinFile.path(), Skin.class);
|
||||
}
|
||||
|
||||
public static Label newLabel(String name) {
|
||||
Label ret = new Label(name, GetSkin());
|
||||
Label ret = new Label(name, getSkin());
|
||||
return ret;
|
||||
}
|
||||
static public Color colorFromString(String name)
|
||||
{
|
||||
String upperCase=name.toUpperCase();
|
||||
if(upperCase.startsWith("0X")||upperCase.startsWith("#"))
|
||||
{
|
||||
return new Color( Long.decode(upperCase).intValue());
|
||||
}
|
||||
if(upperCase.equals("WHITE"))
|
||||
return Color.WHITE;
|
||||
if(upperCase.equals("LIGHT_GRAY"))
|
||||
return Color.LIGHT_GRAY;
|
||||
if(upperCase.equals("GRAY"))
|
||||
return Color.GRAY;
|
||||
if(upperCase.equals("DARK_GRAY"))
|
||||
return Color.DARK_GRAY;
|
||||
if(upperCase.equals("BLACK"))
|
||||
return Color.BLACK;
|
||||
if(upperCase.equals("CLEAR"))
|
||||
return Color.CLEAR;
|
||||
if(upperCase.equals("BLUE"))
|
||||
return Color.BLUE;
|
||||
if(upperCase.equals("NAVY"))
|
||||
return Color.NAVY;
|
||||
if(upperCase.equals("ROYAL"))
|
||||
return Color.ROYAL;
|
||||
if(upperCase.equals("SLATE"))
|
||||
return Color.SLATE;
|
||||
if(upperCase.equals("SKY"))
|
||||
return Color.SKY;
|
||||
if(upperCase.equals("CYAN"))
|
||||
return Color.CYAN;
|
||||
if(upperCase.equals("TEAL"))
|
||||
return Color.TEAL;
|
||||
if(upperCase.equals("GREEN"))
|
||||
return Color.GREEN;
|
||||
if(upperCase.equals("CHARTREUSE"))
|
||||
return Color.CHARTREUSE;
|
||||
if(upperCase.equals("LIME"))
|
||||
return Color.LIME;
|
||||
if(upperCase.equals("FOREST"))
|
||||
return Color.FOREST;
|
||||
if(upperCase.equals("OLIVE"))
|
||||
return Color.OLIVE;
|
||||
if(upperCase.equals("YELLOW"))
|
||||
return Color.YELLOW;
|
||||
if(upperCase.equals("GOLD"))
|
||||
return Color.GOLD;
|
||||
if(upperCase.equals("GOLDENROD"))
|
||||
return Color.GOLDENROD;
|
||||
if(upperCase.equals("ORANGE"))
|
||||
return Color.ORANGE;
|
||||
if(upperCase.equals("TAN"))
|
||||
return Color.TAN;
|
||||
if(upperCase.equals("FIREBRICK"))
|
||||
return Color.FIREBRICK;
|
||||
if(upperCase.equals("RED"))
|
||||
return Color.RED;
|
||||
if(upperCase.equals("SCARLET"))
|
||||
return Color.SCARLET;
|
||||
if(upperCase.equals("CORAL"))
|
||||
return Color.CORAL;
|
||||
if(upperCase.equals("SALMON"))
|
||||
return Color.SALMON;
|
||||
if(upperCase.equals("PINK"))
|
||||
return Color.PINK;
|
||||
if(upperCase.equals("MAGENTA"))
|
||||
return Color.MAGENTA;
|
||||
if(upperCase.equals("PURPLE"))
|
||||
return Color.PURPLE;
|
||||
if(upperCase.equals("VIOLET"))
|
||||
return Color.VIOLET;
|
||||
if(upperCase.equals("MAROON"))
|
||||
return Color.MAROON;
|
||||
return Color.BLACK;
|
||||
}
|
||||
|
||||
public static TextraLabel newTextraLabel(String name) {
|
||||
TextraLabel ret = new LabelFix(name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String colorIdToTypingString(ColorSet color)
|
||||
{
|
||||
String coloerId="";
|
||||
if(color.hasWhite())
|
||||
coloerId+="[+w]";
|
||||
if(color.hasBlue())
|
||||
coloerId+="[+u]";
|
||||
if(color.hasBlack())
|
||||
coloerId+="[+b]";
|
||||
if(color.hasRed())
|
||||
coloerId+="[+r]";
|
||||
if(color.hasGreen())
|
||||
coloerId+="[+g]";
|
||||
if(color.isColorless())
|
||||
coloerId+="[+c]";
|
||||
return coloerId;
|
||||
}
|
||||
public static TypingLabel newTypingLabel(String name) {
|
||||
TypingLabel ret = new TypingLabel(name, GetSkin());
|
||||
TypingLabel ret = new TypingLabel(name==null?"":name, getSkin(),getTextraFont());
|
||||
ret.setVariable("player_name",Current.player().getName());
|
||||
ret.setVariable("player_color_id",colorIdToTypingString(Current.player().getColorIdentity()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public static Dialog newDialog(String title) {
|
||||
Dialog ret = new Dialog(title, GetSkin());
|
||||
Dialog ret = new Dialog(title, getSkin());
|
||||
ret.setMovable(false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static Font textraFont=null;
|
||||
static public Font getTextraFont()
|
||||
{
|
||||
if(textraFont==null)
|
||||
{
|
||||
textraFont=new Font(getSkin().getFont("default"));
|
||||
textraFont.addAtlas(Config.instance().getAtlas(Paths.ITEMS_ATLAS));
|
||||
textraFont.adjustLineHeight(0.8f);//not sure why this is needed maybe the font is bad
|
||||
}
|
||||
return textraFont;
|
||||
}
|
||||
static public Font getTextraFont(String name)
|
||||
{
|
||||
Font font=new Font(getSkin().getFont(name));
|
||||
font.addAtlas(Config.instance().getAtlas(Paths.ITEMS_ATLAS));
|
||||
return font;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ public abstract class DrawOnPixmap {
|
||||
textureData.prepare();
|
||||
}
|
||||
on.drawPixmap(textureData.consumePixmap(), x, y, from.getRegionX(), from.getRegionY(), from.getRegionWidth(), from.getRegionHeight());
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void drawText(Pixmap drawingMap, String itemText, int x, int y, float width, boolean bigText, Color color) {
|
||||
//used for big numbers on Gold/Life for reward...
|
||||
BitmapFont font = bigText ? Controls.getBitmapFont("big") : Controls.getBitmapFont("default");
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package forge.adventure.util;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TypingLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.character.EnemySprite;
|
||||
import forge.adventure.data.DialogData;
|
||||
@@ -19,9 +19,9 @@ import forge.util.Localizer;
|
||||
|
||||
public class MapDialog {
|
||||
private final MapStage stage;
|
||||
private Array<DialogData> data;
|
||||
private final Array<DialogData> data;
|
||||
private final int parentID;
|
||||
private final float WIDTH = 260f;
|
||||
private final static float WIDTH = 260f;
|
||||
static private final String defaultJSON = "[\n" +
|
||||
" {\n" +
|
||||
" \"effect\":[],\n" +
|
||||
@@ -54,7 +54,7 @@ public class MapDialog {
|
||||
String text; //Check for localized string (locname), otherwise print text.
|
||||
if(dialog.loctext != null && !dialog.loctext.isEmpty()) text = L.getMessage(dialog.loctext);
|
||||
else text = dialog.text;
|
||||
Label A = Controls.newLabel(text);
|
||||
TypingLabel A = Controls.newTypingLabel(text);
|
||||
A.setWrap(true);
|
||||
D.getContentTable().add(A).width(WIDTH); //Add() returns a Cell, which is what the width is being applied to.
|
||||
if(dialog.options != null) {
|
||||
@@ -63,8 +63,8 @@ public class MapDialog {
|
||||
String name; //Get localized label if present.
|
||||
if(option.locname != null && !option.locname.isEmpty()) name = L.getMessage(option.locname);
|
||||
else name = option.name;
|
||||
TextButton B = Controls.newTextButton(name,() -> loadDialog(option));
|
||||
B.getLabel().setWrap(true); //We want this to wrap in case it's a wordy choice.
|
||||
TextraButton B = Controls.newTextButton(name,() -> loadDialog(option));
|
||||
B.getTextraLabel().setWrap(true); //We want this to wrap in case it's a wordy choice.
|
||||
D.getButtonTable().add(B).width(WIDTH - 10); //The button table also returns a Cell when adding.
|
||||
//TODO: Reducing the space a tiny bit could help. But should be fine as long as there aren't more than 4-5 options.
|
||||
D.getButtonTable().row(); //Add a row. Tried to allow a few per row but it was a bit erratic.
|
||||
|
||||
@@ -14,6 +14,16 @@ public class Paths {
|
||||
public static final String SKIN_FONT = "skin/LanaPixel.ttf";
|
||||
public static final String ITEMS_EQUIP = "skin/equip.png";
|
||||
public static final String ITEMS_ATLAS = "sprites/items.atlas";
|
||||
public static final String MANA_ATLAS = "sprites/pixelmana.atlas";
|
||||
public static final String COLOR_FRAME_ATLAS = "ui/color_frames.atlas";
|
||||
public static final String ARENA_ATLAS = "ui/arena.atlas";
|
||||
public static final String MAP_MARKER = "sprites/map_marker.atlas";
|
||||
|
||||
|
||||
public static final String EFFECT_HEAL = "particle_effects/heal.p";
|
||||
public static final String EFFECT_KILL = "particle_effects/killed.p";
|
||||
public static final String TRIGGER_KILL = "particle_effects/kill.p";
|
||||
public static final String EFFECT_HIDE = "particle_effects/hide.p";
|
||||
public static final String EFFECT_SPRINT = "particle_effects/sprint.p";
|
||||
public static final String EFFECT_FLY = "particle_effects/fly.p";
|
||||
public static final String EFFECT_TELEPORT = "particle_effects/teleport.p";
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ public class Reward {
|
||||
Card,
|
||||
Gold,
|
||||
Item,
|
||||
Life
|
||||
Life,
|
||||
Mana
|
||||
}
|
||||
Type type;
|
||||
PaperCard card;
|
||||
|
||||
@@ -17,13 +17,13 @@ import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Tooltip;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import forge.Forge;
|
||||
import forge.Graphics;
|
||||
import forge.ImageKeys;
|
||||
@@ -115,17 +115,17 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
||||
if (toolTipImage.getDrawable() instanceof TextureRegionDrawable) {
|
||||
((TextureRegionDrawable) toolTipImage.getDrawable()).getRegion().getTexture().dispose();
|
||||
}
|
||||
}
|
||||
toolTipImage.remove();
|
||||
toolTipImage = new Image(processDrawable(image));
|
||||
if (GuiBase.isAndroid()||Forge.hasGamepad()) {
|
||||
if (holdTooltip.tooltip_image.getDrawable() instanceof TextureRegionDrawable) {
|
||||
((TextureRegionDrawable) holdTooltip.tooltip_image.getDrawable()).getRegion().getTexture().dispose();
|
||||
toolTipImage.remove();
|
||||
toolTipImage = new Image(processDrawable(image));
|
||||
if (GuiBase.isAndroid()||Forge.hasGamepad()) {
|
||||
if (holdTooltip.tooltip_image.getDrawable() instanceof TextureRegionDrawable) {
|
||||
((TextureRegionDrawable) holdTooltip.tooltip_image.getDrawable()).getRegion().getTexture().dispose();
|
||||
}
|
||||
holdTooltip.tooltip_actor.clear();
|
||||
holdTooltip.tooltip_actor.add(toolTipImage);
|
||||
} else {
|
||||
tooltip.setActor(toolTipImage);
|
||||
}
|
||||
holdTooltip.tooltip_actor.clear();
|
||||
holdTooltip.tooltip_actor.add(toolTipImage);
|
||||
} else {
|
||||
tooltip.setActor(toolTipImage);
|
||||
}
|
||||
if (T != null)
|
||||
T.dispose();
|
||||
@@ -231,13 +231,15 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
||||
needsToBeDisposed = true;
|
||||
break;
|
||||
}
|
||||
case Life:
|
||||
case Mana:
|
||||
case Gold: {
|
||||
TextureAtlas atlas = Config.instance().getAtlas(ITEMS_ATLAS);
|
||||
Sprite backSprite = atlas.createSprite("CardBack");
|
||||
Pixmap drawingMap = new Pixmap((int) backSprite.getWidth(), (int) backSprite.getHeight(), Pixmap.Format.RGBA8888);
|
||||
|
||||
DrawOnPixmap.draw(drawingMap, backSprite);
|
||||
Sprite gold = atlas.createSprite("Gold");
|
||||
Sprite gold = atlas.createSprite(reward.type.toString());
|
||||
DrawOnPixmap.draw(drawingMap, (int) ((backSprite.getWidth() / 2f) - gold.getWidth() / 2f), (int) ((backSprite.getHeight() / 4f) * 1f), gold);
|
||||
DrawOnPixmap.drawText(drawingMap, String.valueOf(reward.getCount()), 0, (int) ((backSprite.getHeight() / 4f) * 2f)-1, backSprite.getWidth(), true,Color.WHITE);
|
||||
|
||||
@@ -246,21 +248,6 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
||||
needsToBeDisposed = true;
|
||||
break;
|
||||
}
|
||||
case Life: {
|
||||
TextureAtlas atlas = Config.instance().getAtlas(ITEMS_ATLAS);
|
||||
Sprite backSprite = atlas.createSprite("CardBack");
|
||||
Pixmap drawingMap = new Pixmap((int) backSprite.getWidth(), (int) backSprite.getHeight(), Pixmap.Format.RGBA8888);
|
||||
|
||||
DrawOnPixmap.draw(drawingMap, backSprite);
|
||||
Sprite gold = atlas.createSprite("Life");
|
||||
DrawOnPixmap.draw(drawingMap, (int) ((backSprite.getWidth() / 2f) - gold.getWidth() / 2f), (int) ((backSprite.getHeight() / 4f) * 1f), gold);
|
||||
DrawOnPixmap.drawText(drawingMap, String.valueOf(reward.getCount()), 0, (int) ((backSprite.getHeight() / 4f) * 2f)-1, backSprite.getWidth(), true,Color.WHITE);
|
||||
|
||||
image = new Texture(drawingMap);
|
||||
drawingMap.dispose();
|
||||
needsToBeDisposed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (GuiBase.isAndroid()||Forge.hasGamepad()) {
|
||||
addListener(new ClickListener() {
|
||||
@@ -693,7 +680,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
||||
Image tooltip_image;
|
||||
Table tooltip_actor;
|
||||
float height;
|
||||
TextButton switchButton;
|
||||
TextraButton switchButton;
|
||||
//Vector2 tmp = new Vector2();
|
||||
|
||||
public HoldTooltip(Image tooltip_image) {
|
||||
@@ -717,7 +704,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
||||
|
||||
@Override
|
||||
public boolean longPress(Actor actor, float x, float y) {
|
||||
TextButton done = actor.getStage().getRoot().findActor("done");
|
||||
TextraButton done = actor.getStage().getRoot().findActor("done");
|
||||
if (done != null && Reward.Type.Card.equals(reward.type)) {
|
||||
switchButton.setBounds(done.getX(), done.getY(), done.getWidth(), done.getHeight());
|
||||
if (reward.getCard().hasBackFace())
|
||||
@@ -734,8 +721,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
||||
tooltip_actor.setX(Scene.getIntendedWidth() / 2 - tooltip_actor.getWidth() / 2);
|
||||
}
|
||||
tooltip_actor.setY(Scene.getIntendedHeight() / 2 - tooltip_actor.getHeight() / 2);
|
||||
//tooltip_actor.setX(480/2 - tooltip_actor.getWidth()/2); //480 hud width
|
||||
//tooltip_actor.setY(270/2-tooltip_actor.getHeight()/2); //270 hud height
|
||||
|
||||
actor.getStage().addActor(tooltip_actor);
|
||||
return super.longPress(actor, x, y);
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ public class SaveFileData extends HashMap<String,byte[]>
|
||||
try {
|
||||
|
||||
ByteArrayInputStream stream=new ByteArrayInputStream(get(key));
|
||||
ObjectInputStream objStream=new DecompressibleInputStream(stream);
|
||||
ObjectInputStream objStream= new DecompressibleInputStream(stream);
|
||||
return (SaveFileData)objStream.readObject();
|
||||
|
||||
} catch (IOException | ClassNotFoundException e) {
|
||||
@@ -177,7 +177,7 @@ public class SaveFileData extends HashMap<String,byte[]>
|
||||
try {
|
||||
|
||||
ByteArrayInputStream stream=new ByteArrayInputStream(get(key));
|
||||
ObjectInputStream objStream=new DecompressibleInputStream(stream);
|
||||
ObjectInputStream objStream= new DecompressibleInputStream(stream);
|
||||
return objStream.readObject();
|
||||
|
||||
} catch (IOException | ClassNotFoundException e) {
|
||||
@@ -193,7 +193,7 @@ public class SaveFileData extends HashMap<String,byte[]>
|
||||
try {
|
||||
|
||||
ByteArrayInputStream stream=new ByteArrayInputStream(get(key));
|
||||
ObjectInputStream objStream=new DecompressibleInputStream(stream);
|
||||
ObjectInputStream objStream= new DecompressibleInputStream(stream);
|
||||
return objStream.readUTF();
|
||||
|
||||
} catch (IOException e) {
|
||||
@@ -208,7 +208,7 @@ public class SaveFileData extends HashMap<String,byte[]>
|
||||
try {
|
||||
|
||||
ByteArrayInputStream stream=new ByteArrayInputStream(get(key));
|
||||
ObjectInputStream objStream=new DecompressibleInputStream(stream);
|
||||
ObjectInputStream objStream= new DecompressibleInputStream(stream);
|
||||
return objStream.readLong();
|
||||
|
||||
} catch (IOException e) {
|
||||
@@ -223,7 +223,7 @@ public class SaveFileData extends HashMap<String,byte[]>
|
||||
try {
|
||||
|
||||
ByteArrayInputStream stream=new ByteArrayInputStream(get(key));
|
||||
ObjectInputStream objStream=new DecompressibleInputStream(stream);
|
||||
ObjectInputStream objStream= new DecompressibleInputStream(stream);
|
||||
return objStream.readFloat();
|
||||
|
||||
} catch (IOException e) {
|
||||
@@ -239,7 +239,7 @@ public class SaveFileData extends HashMap<String,byte[]>
|
||||
try {
|
||||
|
||||
ByteArrayInputStream stream=new ByteArrayInputStream(get(key));
|
||||
ObjectInputStream objStream=new DecompressibleInputStream(stream);
|
||||
ObjectInputStream objStream= new DecompressibleInputStream(stream);
|
||||
return objStream.readDouble();
|
||||
|
||||
} catch (IOException e) {
|
||||
@@ -254,7 +254,7 @@ public class SaveFileData extends HashMap<String,byte[]>
|
||||
try {
|
||||
|
||||
ByteArrayInputStream stream=new ByteArrayInputStream(get(key));
|
||||
ObjectInputStream objStream=new DecompressibleInputStream(stream);
|
||||
ObjectInputStream objStream= new DecompressibleInputStream(stream);
|
||||
float x= objStream.readFloat();
|
||||
float y= objStream.readFloat();
|
||||
return new Vector2(x,y);
|
||||
@@ -271,7 +271,7 @@ public class SaveFileData extends HashMap<String,byte[]>
|
||||
try {
|
||||
|
||||
ByteArrayInputStream stream=new ByteArrayInputStream(get(key));
|
||||
ObjectInputStream objStream=new DecompressibleInputStream(stream);
|
||||
ObjectInputStream objStream= new DecompressibleInputStream(stream);
|
||||
float x= objStream.readFloat();
|
||||
float y= objStream.readFloat();
|
||||
float width= objStream.readFloat();
|
||||
@@ -299,7 +299,7 @@ public class SaveFileData extends HashMap<String,byte[]>
|
||||
try {
|
||||
|
||||
ByteArrayInputStream stream=new ByteArrayInputStream(get(key));
|
||||
ObjectInputStream objStream=new DecompressibleInputStream(stream);
|
||||
ObjectInputStream objStream= new DecompressibleInputStream(stream);
|
||||
return objStream.readInt();
|
||||
|
||||
} catch (IOException e) {
|
||||
@@ -314,7 +314,7 @@ public class SaveFileData extends HashMap<String,byte[]>
|
||||
try {
|
||||
|
||||
ByteArrayInputStream stream=new ByteArrayInputStream(get(key));
|
||||
ObjectInputStream objStream=new DecompressibleInputStream(stream);
|
||||
ObjectInputStream objStream= new DecompressibleInputStream(stream);
|
||||
return objStream.readBoolean();
|
||||
|
||||
} catch (IOException e) {
|
||||
@@ -326,7 +326,7 @@ public class SaveFileData extends HashMap<String,byte[]>
|
||||
|
||||
|
||||
|
||||
class DecompressibleInputStream extends ObjectInputStream {
|
||||
static class DecompressibleInputStream extends ObjectInputStream {
|
||||
|
||||
/*https://stackoverflow.com/questions/1816559/make-java-runtime-ignore-serialversionuids*/
|
||||
|
||||
@@ -355,8 +355,7 @@ public class SaveFileData extends HashMap<String,byte[]>
|
||||
final StringBuffer s = new StringBuffer("Overriding serialized class version mismatch: ");
|
||||
s.append("local serialVersionUID = ").append(localSUID);
|
||||
s.append(" stream serialVersionUID = ").append(streamSUID);
|
||||
//Exception e = new InvalidClassException(s.toString());
|
||||
//logger.error("Potentially Fatal Deserialization Operation.", e);
|
||||
|
||||
System.err.println("[Invalid Class Exception]\n"+s);
|
||||
resultClassDescriptor = localClassDescriptor; // Use local class descriptor for deserialization
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ package forge.adventure.util;
|
||||
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Pools;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
|
||||
/**
|
||||
* UI element to click through options, can be configured in an UiActor
|
||||
@@ -15,19 +15,19 @@ import com.badlogic.gdx.utils.Pools;
|
||||
public class Selector extends Group {
|
||||
private final ImageButton leftArrow;
|
||||
private final ImageButton rightArrow;
|
||||
private final TextButton label;
|
||||
private final TextraButton label;
|
||||
private int currentIndex = 0;
|
||||
private Array<String> textList;
|
||||
|
||||
|
||||
public Selector() {
|
||||
ImageButton.ImageButtonStyle leftArrowStyle = Controls.GetSkin().get("leftarrow", ImageButton.ImageButtonStyle.class);
|
||||
ImageButton.ImageButtonStyle leftArrowStyle = Controls.getSkin().get("leftarrow", ImageButton.ImageButtonStyle.class);
|
||||
leftArrow = new ImageButton(leftArrowStyle);
|
||||
|
||||
ImageButton.ImageButtonStyle rightArrowStyle = Controls.GetSkin().get("rightarrow", ImageButton.ImageButtonStyle.class);
|
||||
ImageButton.ImageButtonStyle rightArrowStyle = Controls.getSkin().get("rightarrow", ImageButton.ImageButtonStyle.class);
|
||||
rightArrow = new ImageButton(rightArrowStyle);
|
||||
|
||||
label = new TextButton("", Controls.GetSkin());
|
||||
label = Controls.newTextButton("");
|
||||
addActor(leftArrow);
|
||||
addActor(rightArrow);
|
||||
addActor(label);
|
||||
@@ -80,10 +80,12 @@ public class Selector extends Group {
|
||||
int oldIndex = currentIndex;
|
||||
this.currentIndex = currentIndex;
|
||||
label.setText(textList.get(currentIndex));
|
||||
label.layout();
|
||||
ChangeListener.ChangeEvent changeEvent = Pools.obtain(ChangeListener.ChangeEvent.class);
|
||||
if (fire(changeEvent)) {
|
||||
this.currentIndex = oldIndex;
|
||||
label.setText(textList.get(currentIndex));
|
||||
label.layout();
|
||||
}
|
||||
Pools.free(changeEvent);
|
||||
}
|
||||
@@ -91,7 +93,7 @@ public class Selector extends Group {
|
||||
public String getText() {
|
||||
return textList.get(currentIndex);
|
||||
}
|
||||
public TextButton getLabel() {
|
||||
public TextraButton getLabel() {
|
||||
return label;
|
||||
}
|
||||
public ImageButton getLeftArrow() {
|
||||
|
||||
@@ -196,6 +196,8 @@ public class TemplateTmxMapLoader extends TmxMapLoader {
|
||||
protected void loadObject(TiledMap map, MapObjects objects, XmlReader.Element element, float heightInPixels) {
|
||||
if (element.getName().equals("object")) {
|
||||
|
||||
if( element.hasAttribute("class")&& !element.hasAttribute("type"))
|
||||
element.setAttribute("type",element.getAttribute("class"));//set type to class value for Tiled 1.9 compatibility
|
||||
if (!element.hasAttribute("template")) {
|
||||
super.loadObject(map, objects, element, heightInPixels);
|
||||
return;
|
||||
|
||||
@@ -13,6 +13,8 @@ import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import com.badlogic.gdx.utils.OrderedMap;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.data.UIData;
|
||||
|
||||
@@ -44,11 +46,11 @@ public class UIActor extends Group {
|
||||
readSelectorProperties((Selector) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
break;
|
||||
case "Label":
|
||||
newActor = new Label("", Controls.GetSkin());
|
||||
readLabelProperties((Label) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
newActor = Controls.newTextraLabel("");
|
||||
readLabelProperties((TextraLabel) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
break;
|
||||
case "Table":
|
||||
newActor = new Table(Controls.GetSkin());
|
||||
newActor = new Table(Controls.getSkin());
|
||||
readTableProperties((Table) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
break;
|
||||
case "Image":
|
||||
@@ -56,31 +58,31 @@ public class UIActor extends Group {
|
||||
readImageProperties((Image) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
break;
|
||||
case "ImageButton":
|
||||
newActor = new ImageButton(Controls.GetSkin());
|
||||
newActor = new ImageButton(Controls.getSkin());
|
||||
readImageButtonProperties((ImageButton) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
break;
|
||||
case "Window":
|
||||
newActor = new Window("", Controls.GetSkin());
|
||||
newActor = new Window("", Controls.getSkin());
|
||||
readWindowProperties((Window) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
break;
|
||||
case "TextButton":
|
||||
newActor = new TextButton("", Controls.GetSkin());
|
||||
readButtonProperties((TextButton) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
newActor = Controls.newTextButton("");
|
||||
readButtonProperties((TextraButton) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
break;
|
||||
case "TextField":
|
||||
newActor = new TextField("", Controls.GetSkin());
|
||||
newActor = new TextField("", Controls.getSkin());
|
||||
readTextFieldProperties((TextField) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
break;
|
||||
case "Scroll":
|
||||
newActor = new ScrollPane(null, Controls.GetSkin());
|
||||
newActor = new ScrollPane(null, Controls.getSkin());
|
||||
readScrollPaneProperties((ScrollPane) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
break;
|
||||
case "CheckBox":
|
||||
newActor = new CheckBox("", Controls.GetSkin());
|
||||
newActor = new CheckBox("", Controls.getSkin());
|
||||
readCheckBoxProperties((CheckBox) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
break;
|
||||
case "SelectBox":
|
||||
newActor = new SelectBox<>(Controls.GetSkin());
|
||||
newActor = new SelectBox<>(Controls.getSkin());
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + type);
|
||||
@@ -135,11 +137,11 @@ public class UIActor extends Group {
|
||||
}
|
||||
|
||||
private void readScrollPaneProperties(ScrollPane newActor, ObjectMap.Entries<String, String> entries) {
|
||||
newActor.setActor(new Label("", Controls.GetSkin()));
|
||||
newActor.setActor(Controls.newTextraLabel(""));
|
||||
for (ObjectMap.Entry property : entries) {
|
||||
switch (property.key.toString()) {
|
||||
case "style":
|
||||
newActor.setStyle(Controls.GetSkin().get(property.value.toString(), ScrollPane.ScrollPaneStyle.class));
|
||||
newActor.setStyle(Controls.getSkin().get(property.value.toString(), ScrollPane.ScrollPaneStyle.class));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -149,7 +151,7 @@ public class UIActor extends Group {
|
||||
for (ObjectMap.Entry property : entries) {
|
||||
switch (property.key.toString()) {
|
||||
case "style":
|
||||
newActor.setStyle(Controls.GetSkin().get(property.value.toString(), Window.WindowStyle.class));
|
||||
newActor.setStyle(Controls.getSkin().get(property.value.toString(), Window.WindowStyle.class));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -170,13 +172,13 @@ public class UIActor extends Group {
|
||||
}
|
||||
|
||||
public static String localize(String str) {
|
||||
Pattern regex=Pattern.compile("\\{[^\\}]*\\}");
|
||||
Pattern regex=Pattern.compile("tr\\([^\\)]*\\)");
|
||||
for(int i=0;i<100;i++)
|
||||
{
|
||||
Matcher matcher= regex.matcher(str);
|
||||
if(!matcher.find())
|
||||
return str;
|
||||
str=matcher.replaceAll(Forge.getLocalizer().getMessage(matcher.group().substring(1,matcher.group().length()-1)));
|
||||
str=matcher.replaceFirst(Forge.getLocalizer().getMessage(matcher.group().substring(3,matcher.group().length()-1)));
|
||||
}
|
||||
return str;
|
||||
}
|
||||
@@ -185,39 +187,34 @@ public class UIActor extends Group {
|
||||
for (ObjectMap.Entry property : entries) {
|
||||
switch (property.key.toString()) {
|
||||
case "style":
|
||||
newActor.setStyle(Controls.GetSkin().get(property.value.toString(), ImageButton.ImageButtonStyle.class));
|
||||
newActor.setStyle(Controls.getSkin().get(property.value.toString(), ImageButton.ImageButtonStyle.class));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void readLabelProperties(Label newActor, ObjectMap.Entries<String, String> entries) {
|
||||
Label.LabelStyle style = new Label.LabelStyle(newActor.getStyle());
|
||||
private void readLabelProperties(TextraLabel newActor, ObjectMap.Entries<String, String> entries) {
|
||||
for (ObjectMap.Entry property : entries) {
|
||||
switch (property.key.toString()) {
|
||||
case "text":
|
||||
newActor.setText(localize(property.value.toString()));
|
||||
break;
|
||||
case "font"://legacy
|
||||
style.font = Controls.getBitmapFont(property.value.toString());
|
||||
if (property.value.toString().contains("black"))
|
||||
style.fontColor = Color.BLACK;
|
||||
if (property.value.toString().contains("big"))
|
||||
newActor.setFontScale(2, 2);
|
||||
newActor.setStyle(style);
|
||||
break;
|
||||
case "fontSize":
|
||||
newActor.setFontScale((Float)property.value, (Float)property.value);
|
||||
break;
|
||||
case "font":
|
||||
case "fontName":
|
||||
style.font = Controls.getBitmapFont(property.value.toString());
|
||||
newActor.setStyle(style);
|
||||
if(!property.value.toString().equals("default"))
|
||||
newActor.setFont(Controls.getTextraFont(property.value.toString()));
|
||||
break;
|
||||
case "style":
|
||||
newActor.style=(Controls.getSkin().get(property.value.toString(), Label.LabelStyle.class));
|
||||
break;
|
||||
case "color":
|
||||
case "fontColor":
|
||||
newActor.setColor(new Color(Integer.decode(property.value.toString()) ));
|
||||
newActor.layout.setBaseColor(Controls.colorFromString(property.value.toString()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
newActor.setText(newActor.storedText);//necessary if color changes after text inserted
|
||||
newActor.layout();
|
||||
}
|
||||
|
||||
private void readTableProperties(Table newActor, ObjectMap.Entries<String, String> entries) {
|
||||
@@ -247,14 +244,18 @@ public class UIActor extends Group {
|
||||
}
|
||||
}
|
||||
|
||||
private void readButtonProperties(TextButton newActor, ObjectMap.Entries<String, String> entries) {
|
||||
private void readButtonProperties(TextraButton newActor, ObjectMap.Entries<String, String> entries) {
|
||||
for (ObjectMap.Entry property : entries) {
|
||||
switch (property.key.toString()) {
|
||||
case "text":
|
||||
newActor.setText(localize(property.value.toString()));
|
||||
break;
|
||||
case "style":
|
||||
newActor.setStyle(Controls.getSkin().get(property.value.toString(), TextButton.TextButtonStyle.class));
|
||||
break;
|
||||
}
|
||||
}
|
||||
newActor.layout();
|
||||
}
|
||||
|
||||
private void readImageProperties(Image newActor, ObjectMap.Entries<String, String> entries) {
|
||||
|
||||
@@ -20,9 +20,6 @@ public class BiomeSprites {
|
||||
public Sprite getSprite(String name, int seed) {
|
||||
if (textureAtlasBuffer == null) {
|
||||
textureAtlasBuffer = Config.instance().getAtlas(textureAtlas);
|
||||
/*for (Texture texture : new ObjectSet.ObjectSetIterator<>(textureAtlasBuffer.getTextures())) {
|
||||
texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
|
||||
}*/
|
||||
}
|
||||
if (!spriteBuffer.containsKey(name)) {
|
||||
spriteBuffer.put(name, new Array<Sprite>());
|
||||
|
||||
@@ -9,12 +9,12 @@ import java.util.HashMap;
|
||||
|
||||
public class BiomeStructure {
|
||||
|
||||
private BiomeStructureData data;
|
||||
long seed;
|
||||
private int biomeWidth;
|
||||
private int biomeHeight;
|
||||
private int dataMap[][];
|
||||
private boolean collisionMap[][];
|
||||
private final BiomeStructureData data;
|
||||
final long seed;
|
||||
private final int biomeWidth;
|
||||
private final int biomeHeight;
|
||||
private int[][] dataMap;
|
||||
private boolean[][] collisionMap;
|
||||
boolean init=false;
|
||||
private TextureAtlas structureAtlas;
|
||||
public ColorMap image;
|
||||
@@ -61,7 +61,7 @@ public class BiomeStructure {
|
||||
|
||||
init=true;
|
||||
int targetWidth=(int) (data.width* biomeWidth);
|
||||
int targetHeight=(int) (data.width* biomeWidth);
|
||||
int targetHeight=(int) (data.height* biomeHeight);
|
||||
dataMap=new int[targetWidth][ targetHeight];
|
||||
collisionMap=new boolean[targetWidth][ targetHeight];
|
||||
ColorMap finalImage=new ColorMap(targetWidth, targetHeight);
|
||||
|
||||
@@ -121,7 +121,7 @@ public class BiomeTexture implements Serializable {
|
||||
ArrayList<Pixmap> spics = new ArrayList<>();
|
||||
if(!region.getTexture().getTextureData().isPrepared())
|
||||
region.getTexture().getTextureData().prepare();
|
||||
Pixmap completePicture = region.getTexture().getTextureData().consumePixmap();
|
||||
Pixmap completePicture = region.getTexture().getTextureData().consumePixmap();
|
||||
for (int y = 0; y < 4; y++) {
|
||||
for (int x = 0; x < 3; x++) {
|
||||
int px = region.getRegionX() + (x * tileSize);
|
||||
@@ -285,6 +285,7 @@ public class BiomeTexture implements Serializable {
|
||||
}
|
||||
}
|
||||
}
|
||||
//noinspection ConstantConditions
|
||||
if (false)//debug neighbors
|
||||
{
|
||||
subPixmap.setColor(Color.GREEN);
|
||||
@@ -340,7 +341,7 @@ public class BiomeTexture implements Serializable {
|
||||
BottomEdge(10),
|
||||
RightBottomEdge(11);
|
||||
|
||||
public int value;
|
||||
public final int value;
|
||||
|
||||
BigPictures(int i) {
|
||||
value = i;
|
||||
@@ -398,7 +399,7 @@ public class BiomeTexture implements Serializable {
|
||||
RightBottomEdge01(46),
|
||||
RightBottomEdge11(47);
|
||||
|
||||
public int value;
|
||||
public final int value;
|
||||
|
||||
SmallPictures(int i) {
|
||||
value = i;
|
||||
|
||||
@@ -17,7 +17,7 @@ public class OverlappingModel extends Model {
|
||||
|
||||
@FunctionalInterface
|
||||
interface Agrees<One, Two, Three, Four, Five> {
|
||||
public Five apply(One one, Two two, Three three, Four four);
|
||||
Five apply(One one, Two two, Three three, Four four);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,10 +51,10 @@ public class OverlappingModel extends Model {
|
||||
|
||||
this.colors = new ArrayList<Color>();
|
||||
|
||||
for (int y = 0; y < SMY; y++) for (int x = 0; x < SMX; x++) {
|
||||
Color color = data.getColor(x, y);
|
||||
if(color==null)
|
||||
break;
|
||||
for (int y = 0; y < SMY; y++) for (int x = 0; x < SMX; x++) {
|
||||
Color color = data.getColor(x, y);
|
||||
if(color==null)
|
||||
break;
|
||||
int i = 0;
|
||||
for (Color c : colors) {
|
||||
if (c.equals(color)) break;
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
* Class that hold all sprites as a list for each chunk
|
||||
*/
|
||||
public class SpritesDataMap implements SaveFileContent {
|
||||
public class BiomeSpriteDataMap extends HashMap<Integer, BiomeSpriteData> implements SaveFileContent
|
||||
public static class BiomeSpriteDataMap extends HashMap<Integer, BiomeSpriteData> implements SaveFileContent
|
||||
{
|
||||
@Override
|
||||
public void load(SaveFileData data) {
|
||||
|
||||
@@ -4,9 +4,12 @@ import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.TextureData;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import forge.adventure.data.*;
|
||||
@@ -29,7 +32,7 @@ import java.util.*;
|
||||
* Class that will create the world from the configuration
|
||||
*/
|
||||
public class World implements Disposable, SaveFileContent {
|
||||
private WorldData data;
|
||||
private WorldData data;
|
||||
private Pixmap biomeImage;
|
||||
private long[][] biomeMap;
|
||||
private int[][] terrainMap;
|
||||
@@ -137,7 +140,7 @@ public class World implements Disposable, SaveFileContent {
|
||||
return mapObjectIds.get(id);
|
||||
}
|
||||
|
||||
private class DrawingInformation {
|
||||
private static class DrawingInformation {
|
||||
|
||||
private int neighbors;
|
||||
private final BiomeTexture regions;
|
||||
@@ -288,6 +291,9 @@ public class World implements Disposable, SaveFileContent {
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
loadWorldData();
|
||||
//////////////////
|
||||
///////// initialize
|
||||
//////////////////
|
||||
|
||||
if (seed == 0) {
|
||||
seed = random.nextLong();
|
||||
@@ -302,7 +308,6 @@ public class World implements Disposable, SaveFileContent {
|
||||
//save at all data
|
||||
biomeMap = new long[width][height];
|
||||
terrainMap = new int[width][height];
|
||||
Pixmap pix = new Pixmap(width, height, Pixmap.Format.RGBA8888);
|
||||
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
@@ -311,14 +316,13 @@ public class World implements Disposable, SaveFileContent {
|
||||
}
|
||||
}
|
||||
|
||||
pix.setColor(1, 0, 0, 1);
|
||||
pix.fill();
|
||||
|
||||
final int[] biomeIndex = {-1};
|
||||
currentTime[0] = measureGenerationTime("loading data", currentTime[0]);
|
||||
HashMap<BiomeStructureData, BiomeStructure> structureDataMap = new HashMap<>();
|
||||
|
||||
|
||||
//////////////////
|
||||
///////// calculation structure position with wavefunctioncollapse
|
||||
//////////////////
|
||||
for (BiomeData biome : data.GetBiomes()) {
|
||||
if (biome.structures != null) {
|
||||
int biomeWidth = (int) Math.round(biome.width * (double) width);
|
||||
@@ -335,6 +339,10 @@ public class World implements Disposable, SaveFileContent {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////
|
||||
///////// calculation each biome position based on noise and radius
|
||||
//////////////////
|
||||
FThreads.invokeInEdtNowOrLater(() -> {
|
||||
for (BiomeData biome : data.GetBiomes()) {
|
||||
|
||||
@@ -368,9 +376,6 @@ public class World implements Disposable, SaveFileContent {
|
||||
color.toHsv(hsv);
|
||||
int count = (int) ((noiseValue - 0.5) * 10 / 4);
|
||||
//hsv[2]+=(count*0.2);
|
||||
color.fromHsv(hsv);
|
||||
pix.setColor(color.r, color.g, color.b, 1);
|
||||
pix.drawPixel(x, y);
|
||||
biomeMap[x][y] |= (1L << biomeIndex[0]);
|
||||
int terrainCounter = 1;
|
||||
terrainMap[x][y] = 0;
|
||||
@@ -379,6 +384,7 @@ public class World implements Disposable, SaveFileContent {
|
||||
float terrainNoise = ((float) noise.eval(x / (float) width * (noiseZoom * terrain.resolution), y / (float) height * (noiseZoom * terrain.resolution)) + 1) / 2;
|
||||
if (terrainNoise >= terrain.min && terrainNoise <= terrain.max) {
|
||||
terrainMap[x][y] = terrainCounter;
|
||||
//pix.fillRectangle(x*data.miniMapTileSize, y*data.miniMapTileSize,data.miniMapTileSize,data.miniMapTileSize);
|
||||
}
|
||||
terrainCounter++;
|
||||
}
|
||||
@@ -401,8 +407,7 @@ public class World implements Disposable, SaveFileContent {
|
||||
|
||||
int structureIndex = structure.objectID(structureXStart, structureYStart);
|
||||
if (structureIndex >= 0) {
|
||||
pix.setColor(data.mappingInfo[structureIndex].getColor());
|
||||
pix.drawPixel(x, y);
|
||||
|
||||
terrainMap[x][y] = terrainCounter + structureIndex;
|
||||
if (structure.collision(structureXStart, structureYStart))
|
||||
terrainMap[x][y] |= collisionBit;
|
||||
@@ -420,13 +425,21 @@ public class World implements Disposable, SaveFileContent {
|
||||
}
|
||||
currentTime[0] = measureGenerationTime("biomes in total", currentTime[0]);
|
||||
|
||||
//////////////////
|
||||
///////// set poi placement
|
||||
//////////////////
|
||||
mapPoiIds = new PointOfInterestMap(getChunkSize(), data.tileSize, data.width / getChunkSize(), data.height / getChunkSize());
|
||||
List<PointOfInterest> towns = new ArrayList<>();
|
||||
List<PointOfInterest> notTowns = new ArrayList<>();
|
||||
List<Rectangle> otherPoints = new ArrayList<>();
|
||||
|
||||
TextureAtlas mapMarker=Config.instance().getAtlas(Paths.MAP_MARKER);
|
||||
TextureData texture=mapMarker.getTextures().first().getTextureData();
|
||||
if(!texture.isPrepared())
|
||||
texture.prepare();
|
||||
Pixmap mapMarkerPixmap=texture.consumePixmap();
|
||||
clearTerrain((int) (data.width * data.playerStartPosX), (int) (data.height * data.playerStartPosY), 10);
|
||||
otherPoints.add(new Rectangle(((float) data.width * data.playerStartPosX * (float) data.tileSize) - data.tileSize * 3, ((float) data.height * data.playerStartPosY * data.tileSize) - data.tileSize * 3, data.tileSize * 6, data.tileSize * 6));
|
||||
//otherPoints.add(new Rectangle(((float) data.width * data.playerStartPosX * (float) data.tileSize) - data.tileSize * 3, ((float) data.height * data.playerStartPosY * data.tileSize) - data.tileSize * 3, data.tileSize * 6, data.tileSize * 6));
|
||||
int biomeIndex2 = -1;
|
||||
for (BiomeData biome : data.GetBiomes()) {
|
||||
biomeIndex2++;
|
||||
@@ -443,6 +456,9 @@ public class World implements Disposable, SaveFileContent {
|
||||
y *= (biome.height * height / 2);
|
||||
y += (height - (biome.startPointY * height));
|
||||
|
||||
y += (poi.offsetY * (biome.height * height));
|
||||
x += (poi.offsetX * (biome.width * width));
|
||||
|
||||
if ((int) x < 0 || (int) y <= 0 || (int) y >= height || (int) x >= width || biomeIndex2 != highestBiome(getBiome((int) x, (int) y))) {
|
||||
continue;
|
||||
}
|
||||
@@ -490,13 +506,20 @@ public class World implements Disposable, SaveFileContent {
|
||||
clearTerrain((int) (x / data.tileSize), (int) (y / data.tileSize), 3);
|
||||
mapPoiIds.add(newPoint);
|
||||
|
||||
TextureAtlas.AtlasRegion marker=mapMarker.findRegion(poi.type);
|
||||
|
||||
Color color = biome.GetColor();
|
||||
pix.setColor(color.r, 0.1f, 0.1f, 1);
|
||||
pix.fillRectangle((int) x / data.tileSize - 3, height - (int) y / data.tileSize - 3, 6, 6);
|
||||
if(marker!=null)
|
||||
{
|
||||
int xInPixels= (int) ((x / data.tileSize)*data.miniMapTileSize);
|
||||
int yInPixels= (int) ((height-(y / data.tileSize))*data.miniMapTileSize);
|
||||
xInPixels-=(marker.getRegionWidth() /2);
|
||||
yInPixels-=(marker.getRegionHeight() /2);
|
||||
drawPixmapLater(mapMarkerPixmap,marker.getRegionX(),marker.getRegionY(),
|
||||
marker.getRegionWidth(),marker.getRegionHeight(),xInPixels,yInPixels,marker.getRegionWidth(),marker.getRegionHeight());
|
||||
}
|
||||
|
||||
|
||||
if (poi.type != null && poi.type.equals("town")) {
|
||||
if (poi.type != null && (poi.type.equals("town")|| poi.type.equals("capital"))) {
|
||||
towns.add(newPoint);
|
||||
} else {
|
||||
notTowns.add(newPoint);
|
||||
@@ -506,11 +529,12 @@ public class World implements Disposable, SaveFileContent {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
currentTime[0] = measureGenerationTime("poi placement", currentTime[0]);
|
||||
|
||||
//sort towns
|
||||
//////////////////
|
||||
///////// sort towns and build roads in between
|
||||
//////////////////
|
||||
List<Pair<PointOfInterest, PointOfInterest>> allSortedTowns = new ArrayList<>();
|
||||
|
||||
HashSet<Long> usedEdges = new HashSet<>();//edge is first 32 bits id of first id and last 32 bits id of second
|
||||
@@ -566,7 +590,6 @@ public class World implements Disposable, SaveFileContent {
|
||||
allPOIPathsToNextTown.add(Pair.of(poi, towns.get(smallestIndex)));
|
||||
}
|
||||
biomeIndex[0]++;
|
||||
pix.setColor(1, 1, 1, 1);
|
||||
|
||||
//reset terrain path to the next town
|
||||
for (Pair<PointOfInterest, PointOfInterest> poiToTown : allPOIPathsToNextTown) {
|
||||
@@ -581,11 +604,10 @@ public class World implements Disposable, SaveFileContent {
|
||||
int sy = startY < y1 ? 1 : -1;
|
||||
int err = dx - dy;
|
||||
int e2;
|
||||
while (true) {
|
||||
for(int i=0;i<1000;i++) {
|
||||
if (startX < 0 || startY <= 0 || startX >= width || startY > height) continue;
|
||||
if ((terrainMap[startX][height - startY] & collisionBit) != 0)//clear terrain if it has collision
|
||||
terrainMap[startX][height - startY] = 0;
|
||||
pix.drawPixel(startX, height - startY);
|
||||
|
||||
if (startX == x1 && startY == y1)
|
||||
break;
|
||||
@@ -608,12 +630,9 @@ public class World implements Disposable, SaveFileContent {
|
||||
int y1 = (int) townPair.getValue().getTilePosition(data.tileSize).y;
|
||||
for (int x = startX - 1; x < startX + 2; x++) {
|
||||
for (int y = startY - 1; y < startY + 2; y++) {
|
||||
if (x < 0 || y <= 0 || x >= width || y > height) continue;
|
||||
if (x < 0 || y < 0 || x >= width || y >= height) continue;
|
||||
biomeMap[x][height - y - 1] |= (1L << biomeIndex[0]);
|
||||
terrainMap[x][height - y - 1] = 0;
|
||||
|
||||
|
||||
pix.drawPixel(x, height - y);
|
||||
}
|
||||
}
|
||||
int dx = Math.abs(x1 - startX);
|
||||
@@ -622,11 +641,10 @@ public class World implements Disposable, SaveFileContent {
|
||||
int sy = startY < y1 ? 1 : -1;
|
||||
int err = dx - dy;
|
||||
int e2;
|
||||
while (true) {
|
||||
for (int i=0;i<1000;i++) {
|
||||
if (startX < 0 || startY <= 0 || startX >= width || startY > height) continue;
|
||||
biomeMap[startX][height - startY] |= (1L << biomeIndex[0]);
|
||||
terrainMap[startX][height - startY] = 0;
|
||||
pix.drawPixel(startX, height - startY);
|
||||
|
||||
if (startX == x1 && startY == y1)
|
||||
break;
|
||||
@@ -642,6 +660,70 @@ public class World implements Disposable, SaveFileContent {
|
||||
}
|
||||
currentTime[0] = measureGenerationTime("roads", currentTime[0]);
|
||||
|
||||
//////////////////
|
||||
///////// draw mini map
|
||||
//////////////////
|
||||
|
||||
Pixmap pix = new Pixmap(width*data.miniMapTileSize, height*data.miniMapTileSize, Pixmap.Format.RGBA8888);
|
||||
pix.setColor(1, 0, 0, 1);
|
||||
pix.fill();
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
if(highestBiome(biomeMap[x][y])>=data.GetBiomes().size())
|
||||
{
|
||||
Pixmap smallPixmap=createSmallPixmap(data.roadTileset.tilesetAtlas,data.roadTileset.tilesetName,0);
|
||||
pix.drawPixmap(smallPixmap,x*data.miniMapTileSize, y*data.miniMapTileSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
BiomeData biome=data.GetBiomes().get( highestBiome(biomeMap[x][y]));
|
||||
int terrainIndex=terrainMap[x][y]&~terrainMask;
|
||||
if(terrainIndex>biome.terrain.length)
|
||||
{
|
||||
Pixmap smallPixmap=createSmallPixmap(biome.tilesetAtlas,biome.tilesetName,0);
|
||||
pix.drawPixmap(smallPixmap,x*data.miniMapTileSize, y*data.miniMapTileSize);
|
||||
|
||||
terrainIndex-=biome.terrain.length;
|
||||
terrainIndex--;
|
||||
for(BiomeStructureData structData:biome.structures)
|
||||
{
|
||||
if(terrainIndex>=structData.mappingInfo.length)
|
||||
{
|
||||
terrainIndex-=structData.mappingInfo.length;
|
||||
continue;
|
||||
}
|
||||
smallPixmap=createSmallPixmap(structData.structureAtlasPath,structData.mappingInfo[terrainIndex].name,0);
|
||||
pix.drawPixmap(smallPixmap,x*data.miniMapTileSize, y*data.miniMapTileSize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Pixmap smallPixmap=createSmallPixmap(biome.tilesetAtlas,biome.tilesetName,terrainIndex);
|
||||
pix.drawPixmap(smallPixmap,x*data.miniMapTileSize, y*data.miniMapTileSize);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
for(Map.Entry<String, Pair<Pixmap, HashMap<String, Pixmap>>> entry:pixmapHash.entrySet())
|
||||
{
|
||||
entry.getValue().getLeft().dispose();
|
||||
for(Map.Entry<String, Pixmap> pairEntry:entry.getValue().getRight().entrySet())
|
||||
{
|
||||
pairEntry.getValue().dispose();
|
||||
}
|
||||
}
|
||||
drawPixmapNow(pix);
|
||||
currentTime[0] = measureGenerationTime("mini map", currentTime[0]);
|
||||
|
||||
|
||||
//////////////////
|
||||
///////// distribute small rocks and trees across the map
|
||||
//////////////////
|
||||
mapObjectIds = new SpritesDataMap(getChunkSize(), data.tileSize, data.width / getChunkSize());
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
@@ -672,6 +754,7 @@ public class World implements Disposable, SaveFileContent {
|
||||
}
|
||||
}
|
||||
}
|
||||
mapMarkerPixmap.dispose();
|
||||
biomeImage = pix;
|
||||
measureGenerationTime("sprites", currentTime[0]);
|
||||
});
|
||||
@@ -684,6 +767,75 @@ public class World implements Disposable, SaveFileContent {
|
||||
return this;
|
||||
}
|
||||
|
||||
HashMap<String,Pair<Pixmap,HashMap<String,Pixmap>>> pixmapHash=new HashMap<>();
|
||||
private Pixmap createSmallPixmap(String tilesetName, String key, int i) {
|
||||
|
||||
if(i>2)i=2;
|
||||
String tileSetNameWithIndex;
|
||||
if(i==0)
|
||||
tileSetNameWithIndex=(key);
|
||||
else
|
||||
tileSetNameWithIndex=(key+"_"+i);
|
||||
if(!pixmapHash.containsKey(tilesetName))
|
||||
{
|
||||
TextureAtlas.AtlasRegion region;
|
||||
TextureAtlas atlas=Config.instance().getAtlas(tilesetName);
|
||||
region=atlas.findRegion(tileSetNameWithIndex);
|
||||
TextureData data=region.getTexture().getTextureData();
|
||||
if (!data.isPrepared()) {
|
||||
data.prepare();
|
||||
}
|
||||
pixmapHash.put(tilesetName,Pair.of(data.consumePixmap(),new HashMap<>()));
|
||||
}
|
||||
Pair<Pixmap,HashMap<String,Pixmap>> pair=pixmapHash.get(tilesetName);
|
||||
if(!pair.getRight().containsKey(tileSetNameWithIndex))
|
||||
{
|
||||
TextureAtlas atlas=Config.instance().getAtlas(tilesetName);
|
||||
TextureAtlas.AtlasRegion region=atlas.findRegion(tileSetNameWithIndex);
|
||||
int tileSize=data.tileSize;
|
||||
Pixmap smallPixmap=new Pixmap(data.miniMapTileSize,data.miniMapTileSize, Pixmap.Format.RGBA8888);
|
||||
smallPixmap.setColor(0,0,0,0);
|
||||
smallPixmap.fill();
|
||||
smallPixmap.drawPixmap(pair.getLeft(),0,0,region.getRegionX(),region.getRegionY(),data.miniMapTileSize,data.miniMapTileSize);
|
||||
pair.getRight().put(tileSetNameWithIndex,smallPixmap);
|
||||
}
|
||||
return pair.getRight().get(tileSetNameWithIndex);
|
||||
|
||||
}
|
||||
|
||||
static class DrawInfo
|
||||
{
|
||||
Pixmap mapMarkerPixmap;
|
||||
int regionX;
|
||||
int regionY;
|
||||
int regionWidth;
|
||||
int regionHeight;
|
||||
int x;
|
||||
int y;
|
||||
int regionWidth1;
|
||||
int regionHeight1;
|
||||
}
|
||||
final Array<DrawInfo> storedInfo=new Array<>();
|
||||
private void drawPixmapLater(Pixmap mapMarkerPixmap, int regionX, int regionY, int regionWidth, int regionHeight, int x, int y, int regionWidth1, int regionHeight1) {
|
||||
DrawInfo info= new DrawInfo();
|
||||
info.mapMarkerPixmap=mapMarkerPixmap;
|
||||
info.regionX=regionX;
|
||||
info.regionY=regionY;
|
||||
info.regionWidth=regionWidth;
|
||||
info.regionHeight=regionHeight;
|
||||
info.x=x;
|
||||
info.y=y;
|
||||
info.regionWidth1=regionWidth1;
|
||||
info.regionHeight1=regionHeight1;
|
||||
storedInfo.add(info);
|
||||
}
|
||||
private void drawPixmapNow(Pixmap map)
|
||||
{
|
||||
for(DrawInfo info:storedInfo)
|
||||
map.drawPixmap(info.mapMarkerPixmap,info.regionX,info.regionY,info.regionWidth,info.regionHeight,info.x,info.y,info.regionWidth1,info.regionHeight1);
|
||||
storedInfo.clear();
|
||||
}
|
||||
|
||||
public int getWidthInTiles() {
|
||||
return width;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.adventure.scene.DuelScene;
|
||||
import forge.adventure.scene.SceneType;
|
||||
import forge.ai.GameState;
|
||||
import forge.deck.Deck;
|
||||
import forge.game.player.Player;
|
||||
@@ -313,7 +312,7 @@ public class MatchController extends AbstractGuiGame {
|
||||
public void finishGame() {
|
||||
if (Forge.isMobileAdventureMode) {
|
||||
Forge.setCursor(null, "0");
|
||||
if (((DuelScene) SceneType.DuelScene.instance).hasCallbackExit())
|
||||
if (DuelScene.instance().hasCallbackExit())
|
||||
return;
|
||||
Forge.setTransitionScreen(new TransitionScreen(() -> {
|
||||
Forge.clearTransitionScreen();
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.tommyettinger</groupId>
|
||||
<artifactId>textratypist</artifactId>
|
||||
<version>0.7.1</version>
|
||||
<version>0.7.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.thoughtworks.xstream</groupId>
|
||||
|
||||