mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-14 17:58:01 +00:00
test commit
This commit is contained in:
@@ -10,6 +10,48 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>forge-adventure</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Forge Adventure</name>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<attach>false</attach>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>forge.adventure.Main</mainClass>
|
||||
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<!-- this is used for inheritance merges -->
|
||||
<phase>package</phase>
|
||||
<!-- bind to the packaging phase -->
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.badlogicgames.gdx</groupId>
|
||||
@@ -39,6 +81,12 @@
|
||||
<version>1.10.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.badlogicgames.gdx</groupId>
|
||||
<artifactId>gdx-freetype-platform</artifactId>
|
||||
<version>1.10.0</version>
|
||||
<classifier>natives-desktop</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>forge</groupId>
|
||||
<artifactId>forge-gui</artifactId>
|
||||
|
||||
14
forge-adventure/sentry.properties
Normal file
14
forge-adventure/sentry.properties
Normal file
@@ -0,0 +1,14 @@
|
||||
# ideally this should be using HTTPS, but this is fine for now
|
||||
dsn=http://a0b8dbad9b8a49cfa51bf65d462e8dae@sentry.cardforge.org:9000/2
|
||||
stacktrace.app.packages=forge
|
||||
|
||||
# where to store events if offline or can't reach the above server
|
||||
buffer.dir=sentry-events
|
||||
buffer.size=100
|
||||
|
||||
# allow ample time for graceful shutdown
|
||||
buffer.shutdowntimeout=5000
|
||||
async.shutdowntimeout=5000
|
||||
|
||||
# allow longer messages
|
||||
maxmessagelength=1500
|
||||
@@ -1,36 +1,55 @@
|
||||
package forge.adventure;
|
||||
|
||||
import com.badlogic.gdx.ApplicationAdapter;
|
||||
import forge.adventure.scene.*;
|
||||
import forge.Graphics;
|
||||
import forge.adventure.scene.Scene;
|
||||
import forge.adventure.scene.SceneType;
|
||||
import forge.adventure.util.Res;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class AdventureApplicationAdapter extends ApplicationAdapter {
|
||||
public static AdventureApplicationAdapter CurrentAdapter;
|
||||
String strPlane;
|
||||
Scene currentScene=null;
|
||||
HashMap<SceneType,Scene> allScenes= new HashMap<>();
|
||||
Scene lastScene=null;
|
||||
Res resourcesLoader;
|
||||
private int currentWidth;
|
||||
private int currentHeight;
|
||||
private Graphics graphics;
|
||||
|
||||
public int getCurrentWidth(){return currentWidth;}
|
||||
public int getCurrentHeight(){return currentHeight;}
|
||||
public Graphics getGraphics(){return graphics;}
|
||||
@Override
|
||||
public void resize(int w,int h)
|
||||
{
|
||||
currentWidth=w;
|
||||
currentHeight=h;
|
||||
super.resize(w,h);
|
||||
}
|
||||
public AdventureApplicationAdapter(String plane) {
|
||||
CurrentAdapter=this;
|
||||
strPlane=plane;
|
||||
allScenes.put(SceneType.StartScene,new StartScene());
|
||||
allScenes.put(SceneType.NewGameScene,new NewGameScene());
|
||||
allScenes.put(SceneType.GameScene,new GameScene());
|
||||
allScenes.put(SceneType.DuelScene,new DuelScene());
|
||||
}
|
||||
public boolean SwitchScene(SceneType newScene)
|
||||
public boolean SwitchScene(Scene newScene)
|
||||
{
|
||||
if(currentScene!=null)
|
||||
{
|
||||
if(!currentScene.Leave())
|
||||
return false;
|
||||
}
|
||||
currentScene=allScenes.get(newScene);
|
||||
lastScene=currentScene;
|
||||
currentScene=newScene;
|
||||
currentScene.Enter();
|
||||
return true;
|
||||
}
|
||||
public void ResLoaded()
|
||||
{
|
||||
for( forge.adventure.scene.SceneType entry:SceneType.values())
|
||||
{
|
||||
entry.instance.ResLoaded();
|
||||
}
|
||||
|
||||
}
|
||||
public Res GetRes()
|
||||
{
|
||||
return resourcesLoader;
|
||||
@@ -38,12 +57,13 @@ public class AdventureApplicationAdapter extends ApplicationAdapter {
|
||||
@Override
|
||||
public void create ()
|
||||
{
|
||||
graphics = new Graphics();
|
||||
resourcesLoader=new Res(strPlane);
|
||||
for(HashMap.Entry<SceneType, Scene> entry:allScenes.entrySet())
|
||||
for( forge.adventure.scene.SceneType entry:SceneType.values())
|
||||
{
|
||||
entry.getValue().create();
|
||||
entry.instance.create();
|
||||
}
|
||||
SwitchScene(SceneType.StartScene);
|
||||
SwitchScene(SceneType.StartScene.instance);
|
||||
}
|
||||
@Override
|
||||
public void render(){
|
||||
@@ -53,4 +73,8 @@ public class AdventureApplicationAdapter extends ApplicationAdapter {
|
||||
public void dispose(){
|
||||
currentScene.dispose();
|
||||
}
|
||||
|
||||
public Scene GetLastScene() {
|
||||
return lastScene;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package forge.adventure;
|
||||
|
||||
import com.badlogic.gdx.Application;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Clipboard;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.utils.Clipboard;
|
||||
import forge.Forge;
|
||||
import forge.FrameRate;
|
||||
import forge.Graphics;
|
||||
import forge.GuiMobile;
|
||||
import forge.adventure.scene.SettingsScene;
|
||||
import forge.assets.AssetsDownloader;
|
||||
import forge.assets.FSkin;
|
||||
import forge.assets.FSkinFont;
|
||||
@@ -39,9 +39,6 @@ class StartAdvanture extends AdventureApplicationAdapter
|
||||
{
|
||||
private static Clipboard clipboard;
|
||||
private static IDeviceAdapter deviceAdapter;
|
||||
private static int screenWidth;
|
||||
private static int screenHeight;
|
||||
private static Graphics graphics;
|
||||
private static FrameRate frameRate;
|
||||
private static FScreen currentScreen;
|
||||
private static SplashScreen splashScreen;
|
||||
@@ -75,22 +72,62 @@ class StartAdvanture extends AdventureApplicationAdapter
|
||||
public StartAdvanture(String plane) {
|
||||
|
||||
super(plane);
|
||||
|
||||
Forge.isTabletDevice=true;
|
||||
Forge.isPortraitMode=false;
|
||||
Forge.hdbuttons = true;
|
||||
Forge.hdstart = true;
|
||||
Forge app= (Forge) Forge.getApp(new Lwjgl3Clipboard(),null,"../forge-gui/",true,false,0,true,0,"","");
|
||||
|
||||
app.resize(1920,1080);
|
||||
clipboard = new Lwjgl3Clipboard();
|
||||
GuiBase.setUsingAppDirectory(false); //obb directory on android uses the package name as entrypoint
|
||||
GuiBase.setInterface(new GuiMobile("../forge-gui/"));
|
||||
GuiBase.enablePropertyConfig(true);
|
||||
isPortraitMode = true;
|
||||
totalDeviceRAM = 0;
|
||||
|
||||
|
||||
GuiBase.setDeviceInfo("", "", 0, 0);
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void render()
|
||||
{
|
||||
if(splashScreen!=null)
|
||||
{
|
||||
Gdx.gl.glClearColor(1,0,1,1);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // Clear the screen.
|
||||
getGraphics().begin(getCurrentWidth(), getCurrentHeight());
|
||||
splashScreen.setSize(getCurrentWidth(), getCurrentHeight());
|
||||
splashScreen.screenPos.setSize(getCurrentWidth(), getCurrentHeight());
|
||||
if (splashScreen.getRotate180()) {
|
||||
getGraphics().startRotateTransform(getCurrentWidth() / 2, getCurrentHeight() / 2, 180);
|
||||
}
|
||||
splashScreen.draw(getGraphics());
|
||||
if (splashScreen.getRotate180()) {
|
||||
getGraphics().endTransform();
|
||||
}
|
||||
|
||||
getGraphics().end();
|
||||
}
|
||||
else
|
||||
{
|
||||
super.render();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void resize(int width, int height) {
|
||||
super.resize(width,height);
|
||||
if (splashScreen != null)
|
||||
splashScreen.setSize(width, height);
|
||||
}
|
||||
@Override
|
||||
public void create()
|
||||
{
|
||||
//install our error handler
|
||||
ExceptionHandler.registerErrorHandling();
|
||||
|
||||
GuiBase.setIsAndroid(Gdx.app.getType() == Application.ApplicationType.Android);
|
||||
|
||||
graphics = new Graphics();
|
||||
splashScreen = new SplashScreen();
|
||||
frameRate = new FrameRate();
|
||||
/*
|
||||
@@ -101,7 +138,7 @@ class StartAdvanture extends AdventureApplicationAdapter
|
||||
*/
|
||||
Gdx.input.setCatchKey(Input.Keys.BACK, true);
|
||||
destroyThis = true; //Prevent back()
|
||||
ForgePreferences prefs = new ForgePreferences();
|
||||
ForgePreferences prefs = SettingsScene.Preference = new ForgePreferences();
|
||||
|
||||
String skinName;
|
||||
if (FileUtil.doesFileExist(ForgeConstants.MAIN_PREFS_FILE)) {
|
||||
@@ -137,6 +174,7 @@ class StartAdvanture extends AdventureApplicationAdapter
|
||||
final Localizer localizer = Localizer.getInstance();
|
||||
|
||||
//load model on background thread (using progress bar to report progress)
|
||||
super.create();
|
||||
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -144,7 +182,7 @@ class StartAdvanture extends AdventureApplicationAdapter
|
||||
AssetsDownloader.checkForUpdates(splashScreen);
|
||||
if (exited) { return; } //don't continue if user chose to exit or couldn't download required assets
|
||||
|
||||
FModel.initialize(splashScreen.getProgressBar(), null);
|
||||
FModel.initialize(splashScreen.getProgressBar(),null);
|
||||
|
||||
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblLoadingFonts"));
|
||||
FSkinFont.preloadAll(locale);
|
||||
@@ -176,8 +214,24 @@ class StartAdvanture extends AdventureApplicationAdapter
|
||||
SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS); //start background music
|
||||
destroyThis = false; //Allow back()
|
||||
Gdx.input.setCatchKey(Input.Keys.MENU, true);
|
||||
//openHomeScreen(-1); //default for startup
|
||||
splashScreen = null;
|
||||
/*
|
||||
boolean isLandscapeMode = isLandscapeMode();
|
||||
if (isLandscapeMode) { //open preferred new game screen by default if landscape mode
|
||||
NewGameMenu.getPreferredScreen().open();
|
||||
}
|
||||
*/
|
||||
|
||||
//adjust height modifier
|
||||
|
||||
//update landscape mode preference if it doesn't match what the app loaded as
|
||||
if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_LANDSCAPE_MODE) != true) {
|
||||
FModel.getPreferences().setPref(ForgePreferences.FPref.UI_LANDSCAPE_MODE, true);
|
||||
FModel.getPreferences().save();
|
||||
}
|
||||
|
||||
ResLoaded();
|
||||
if (!enablePreloadExtendedArt)
|
||||
return;
|
||||
List<String> borderlessCardlistkeys = FileUtil.readFile(ForgeConstants.BORDERLESS_CARD_LIST_FILE);
|
||||
@@ -198,23 +252,17 @@ class StartAdvanture extends AdventureApplicationAdapter
|
||||
});
|
||||
}
|
||||
});
|
||||
super.create();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
AdventureApplicationConfiguration config=new AdventureApplicationConfiguration();
|
||||
|
||||
config.SetPlane("Shandalar");
|
||||
config.setFullScreen(false);
|
||||
|
||||
new Lwjgl3Application(new StartAdvanture(config.Plane), config);
|
||||
new Lwjgl3Application(new StartAdvanture(config.Plane), config );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package forge.adventure.data;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
|
||||
public class BiomData
|
||||
{
|
||||
public double startPointX;
|
||||
public double startPointY;
|
||||
public double noiceWeight;
|
||||
public double distWeight;
|
||||
public String name;
|
||||
|
||||
public double sizeX;
|
||||
public double sizeY;
|
||||
public String color;
|
||||
public boolean invertHeight;
|
||||
public Color GetColor(){return Color.valueOf(color);}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package forge.adventure.data;
|
||||
|
||||
import java.util.List;
|
||||
public class WorldData
|
||||
{
|
||||
|
||||
public int sizeX;
|
||||
public int sizeY;
|
||||
|
||||
public int tileSize;
|
||||
public List<BiomData> bioms;
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package forge.adventure.scene;
|
||||
|
||||
import com.badlogic.gdx.Input;
|
||||
import forge.Forge;
|
||||
import forge.gamemodes.match.HostedMatch;
|
||||
import forge.gui.error.BugReporter;
|
||||
import forge.screens.match.MatchController;
|
||||
import forge.toolbox.FContainer;
|
||||
@@ -21,7 +20,7 @@ public class DuelInput extends FGestureAdapter {
|
||||
private static boolean keyTyped, shiftKeyDown;
|
||||
private Forge.KeyInputAdapter keyInputAdapter=null;
|
||||
|
||||
public DuelInput(HostedMatch hMatch) {
|
||||
public DuelInput() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,22 +2,25 @@ package forge.adventure.scene;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.utils.viewport.StretchViewport;
|
||||
import forge.Graphics;
|
||||
import forge.adventure.AdventureApplicationAdapter;
|
||||
import forge.animation.ForgeAnimation;
|
||||
import forge.assets.ImageCache;
|
||||
import forge.deck.io.DeckSerializer;
|
||||
import forge.game.GameType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.RegisteredPlayer;
|
||||
import forge.gamemodes.match.GameLobby;
|
||||
import forge.gamemodes.match.HostedMatch;
|
||||
import forge.gamemodes.match.LobbySlotType;
|
||||
import forge.gui.GuiBase;
|
||||
import forge.gui.interfaces.IGuiGame;
|
||||
import forge.interfaces.IUpdateable;
|
||||
import forge.player.GamePlayerUtil;
|
||||
import forge.player.PlayerControllerHuman;
|
||||
import forge.screens.FScreen;
|
||||
import forge.screens.match.MatchController;
|
||||
import forge.toolbox.FOverlay;
|
||||
import forge.trackable.TrackableCollection;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
@@ -26,7 +29,7 @@ public class DuelScene extends Scene implements IUpdateable {
|
||||
|
||||
//GameLobby lobby;
|
||||
FScreen screen;
|
||||
Graphics graphics;
|
||||
Graphics localGraphics;
|
||||
HostedMatch hostedMatch;
|
||||
public DuelScene() {
|
||||
|
||||
@@ -34,7 +37,8 @@ public class DuelScene extends Scene implements IUpdateable {
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
Stage.dispose();
|
||||
if(Stage!=null)
|
||||
Stage.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,45 +53,50 @@ public class DuelScene extends Scene implements IUpdateable {
|
||||
Stage.act(Gdx.graphics.getDeltaTime());
|
||||
Stage.draw();
|
||||
*/
|
||||
ImageCache.allowSingleLoad();
|
||||
ForgeAnimation.advanceAll();
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // Clear the screen.
|
||||
if(hostedMatch== null || hostedMatch .getGameView()==null)
|
||||
return;
|
||||
if (screen==null)
|
||||
{
|
||||
|
||||
screen = MatchController.getView();
|
||||
screen.setSize(IntendedWidth, IntendedHeight);
|
||||
return;
|
||||
}
|
||||
|
||||
graphics.begin(IntendedWidth, IntendedHeight);
|
||||
screen.screenPos.setSize(IntendedWidth, IntendedHeight);
|
||||
localGraphics.begin(AdventureApplicationAdapter.CurrentAdapter.getCurrentWidth(), AdventureApplicationAdapter.CurrentAdapter.getCurrentHeight());
|
||||
screen.screenPos.setSize(AdventureApplicationAdapter.CurrentAdapter.getCurrentWidth(), AdventureApplicationAdapter.CurrentAdapter.getCurrentHeight());
|
||||
if (screen.getRotate180()) {
|
||||
graphics.startRotateTransform(IntendedWidth / 2, IntendedHeight / 2, 180);
|
||||
localGraphics.startRotateTransform(AdventureApplicationAdapter.CurrentAdapter.getCurrentWidth() / 2, AdventureApplicationAdapter.CurrentAdapter.getCurrentHeight() / 2, 180);
|
||||
}
|
||||
screen.draw(graphics);
|
||||
screen.draw(localGraphics);
|
||||
if (screen.getRotate180()) {
|
||||
graphics.endTransform();
|
||||
localGraphics.endTransform();
|
||||
}
|
||||
for (FOverlay overlay : FOverlay.getOverlays()) {
|
||||
if (overlay.isVisibleOnScreen(screen)) {
|
||||
overlay.screenPos.setSize(IntendedWidth, IntendedHeight);
|
||||
overlay.setSize(IntendedWidth, IntendedHeight); //update overlay sizes as they're rendered
|
||||
overlay.screenPos.setSize(AdventureApplicationAdapter.CurrentAdapter.getCurrentWidth(), AdventureApplicationAdapter.CurrentAdapter.getCurrentHeight());
|
||||
overlay.setSize(AdventureApplicationAdapter.CurrentAdapter.getCurrentWidth(), AdventureApplicationAdapter.CurrentAdapter.getCurrentHeight()); //update overlay sizes as they're rendered
|
||||
if (overlay.getRotate180()) {
|
||||
graphics.startRotateTransform(IntendedWidth / 2, IntendedHeight / 2, 180);
|
||||
localGraphics.startRotateTransform(AdventureApplicationAdapter.CurrentAdapter.getCurrentHeight() / 2, AdventureApplicationAdapter.CurrentAdapter.getCurrentHeight() / 2, 180);
|
||||
}
|
||||
overlay.draw(graphics);
|
||||
overlay.draw(localGraphics);
|
||||
if (overlay.getRotate180()) {
|
||||
graphics.endTransform();
|
||||
localGraphics.endTransform();
|
||||
}
|
||||
}
|
||||
}
|
||||
graphics.end();
|
||||
|
||||
localGraphics.end();
|
||||
|
||||
//Batch.end();
|
||||
}
|
||||
|
||||
public void GameEnd()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private DuelInput duelInput;
|
||||
@Override
|
||||
public void Enter()
|
||||
{
|
||||
@@ -105,26 +114,37 @@ public class DuelScene extends Scene implements IUpdateable {
|
||||
final Map<RegisteredPlayer, IGuiGame> guiMap = new HashMap<>();
|
||||
guiMap.put(humanPlayer, MatchController.instance);
|
||||
|
||||
hostedMatch = GuiBase.getInterface().hostMatch();
|
||||
hostedMatch = MatchController.instance.hostMatch();
|
||||
|
||||
hostedMatch.setEndGameHook(()->GameEnd());
|
||||
hostedMatch.startMatch(GameType.Constructed, appliedVariants, players, guiMap);
|
||||
|
||||
Gdx.input.setInputProcessor(new DuelInput(hostedMatch));
|
||||
MatchController.instance.setGameView(hostedMatch.getGameView());
|
||||
|
||||
|
||||
for (final Player p : hostedMatch.getGame().getPlayers()) {
|
||||
if (p.getController() instanceof PlayerControllerHuman) {
|
||||
final PlayerControllerHuman humanController = (PlayerControllerHuman) p.getController();
|
||||
humanController.setGui(MatchController.instance);
|
||||
MatchController.instance.setOriginalGameController(p.getView(), humanController);
|
||||
MatchController.instance.openView(new TrackableCollection<>(p.getView()));
|
||||
}
|
||||
}
|
||||
|
||||
screen = MatchController.getView();
|
||||
screen.setHeaderCaption("DUUUUUUUELLL");
|
||||
screen.setSize(AdventureApplicationAdapter.CurrentAdapter.getCurrentWidth(), AdventureApplicationAdapter.CurrentAdapter.getCurrentHeight());
|
||||
|
||||
|
||||
Gdx.input.setInputProcessor(duelInput);
|
||||
|
||||
}
|
||||
public boolean Resume()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public boolean Exit()
|
||||
{
|
||||
Gdx.app.exit();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
Stage = new Stage(new StretchViewport(IntendedWidth,IntendedHeight));
|
||||
duelInput=new DuelInput();
|
||||
localGraphics= AdventureApplicationAdapter.CurrentAdapter.getGraphics();
|
||||
//lobby = new LocalLobby();
|
||||
graphics=new Graphics();
|
||||
//initLobby(lobby);
|
||||
|
||||
|
||||
|
||||
@@ -2,13 +2,16 @@ package forge.adventure.scene;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
|
||||
import com.badlogic.gdx.utils.viewport.StretchViewport;
|
||||
import forge.adventure.AdventureApplicationAdapter;
|
||||
import forge.adventure.util.Controls;
|
||||
import forge.localinstance.properties.ForgePreferences;
|
||||
import forge.model.FModel;
|
||||
import forge.adventure.world.WorldSave;
|
||||
|
||||
public class NewGameScene extends Scene {
|
||||
Texture Background;
|
||||
@@ -22,7 +25,7 @@ public class NewGameScene extends Scene {
|
||||
Stage.dispose();
|
||||
Background.dispose();
|
||||
}
|
||||
|
||||
Texture image;
|
||||
@Override
|
||||
public void render() {
|
||||
|
||||
@@ -33,6 +36,8 @@ public class NewGameScene extends Scene {
|
||||
Stage.getBatch().disableBlending();
|
||||
Stage.getBatch().draw(Background,0,0,IntendedWidth,IntendedHeight);
|
||||
Stage.getBatch().enableBlending();
|
||||
if(image!=null)
|
||||
Stage.getBatch().draw(image,0,0);
|
||||
Stage.getBatch().end();
|
||||
Stage.act(Gdx.graphics.getDeltaTime());
|
||||
Stage.draw();
|
||||
@@ -41,51 +46,34 @@ public class NewGameScene extends Scene {
|
||||
|
||||
public boolean Start()
|
||||
{
|
||||
|
||||
AdventureApplicationAdapter.CurrentAdapter.SwitchScene(SceneType.GameScene);
|
||||
FModel.getPreferences().setPref(ForgePreferences.FPref.UI_ENABLE_MUSIC,false);
|
||||
//AdventureApplicationAdapter.CurrentAdapter.SwitchScene(SceneType.GameScene);
|
||||
Pixmap img=WorldSave.GenerateNewWorld();
|
||||
image = new Texture(img);
|
||||
return true;
|
||||
}
|
||||
public boolean Back()
|
||||
{
|
||||
AdventureApplicationAdapter.CurrentAdapter.SwitchScene(SceneType.StartScene);
|
||||
AdventureApplicationAdapter.CurrentAdapter.SwitchScene(SceneType.StartScene.instance);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void create() {
|
||||
// FModel.getPreferences().setPref(ForgePreferences.FPref.UI_ENABLE_MUSIC,false);
|
||||
Stage = new Stage(new StretchViewport(IntendedWidth,IntendedHeight));
|
||||
Background = new Texture(AdventureApplicationAdapter.CurrentAdapter.GetRes().GetFile("img/title_bg.png"));
|
||||
|
||||
VerticalGroup nameGroup =new VerticalGroup();
|
||||
|
||||
|
||||
TextButton button = new TextButton("Start",AdventureApplicationAdapter.CurrentAdapter.GetRes().GetSkin()) ;
|
||||
button.setPosition(100,600);
|
||||
button.setSize(400,150);
|
||||
button.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
try {
|
||||
Start();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}});
|
||||
nameGroup.addActor(Controls.newTextButton("Start",()->Start()));
|
||||
nameGroup.addActor(Controls.newTextButton("Back",()->Back()));
|
||||
|
||||
Stage.addActor(button);
|
||||
|
||||
button = new TextButton("Back",AdventureApplicationAdapter.CurrentAdapter.GetRes().GetSkin()) ;
|
||||
button.setPosition(100,400);
|
||||
button.setSize(400,150);
|
||||
button.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
try {
|
||||
Back();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}});
|
||||
Stage.addActor(button);
|
||||
nameGroup.addActor(Controls.newTextButton("Start",()->Start()));
|
||||
nameGroup.addActor(Controls.newTextButton("Back",()->Back()));
|
||||
|
||||
|
||||
nameGroup.setPosition(900,500);
|
||||
Stage.addActor(nameGroup);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public abstract class Scene implements Disposable {
|
||||
public static int IntendedWidth = 1920;
|
||||
public static int IntendedHeight = 1080;
|
||||
protected com.badlogic.gdx.scenes.scene2d.Stage Stage;
|
||||
Scene()
|
||||
public Scene()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -25,6 +25,9 @@ public abstract class Scene implements Disposable {
|
||||
return new TextureRegionDrawable(new Texture(AdventureApplicationAdapter.CurrentAdapter.GetRes().GetFile(path)));
|
||||
}
|
||||
|
||||
public void ResLoaded()
|
||||
{
|
||||
}
|
||||
public boolean Leave(){return true;}
|
||||
public void Enter()
|
||||
{
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
package forge.adventure.scene;
|
||||
|
||||
|
||||
public enum SceneType {
|
||||
StartScene,
|
||||
NewGameScene,
|
||||
GameScene,
|
||||
DuelScene
|
||||
StartScene(new forge.adventure.scene.StartScene()),
|
||||
NewGameScene(new forge.adventure.scene.NewGameScene()),
|
||||
SettingsScene(new forge.adventure.scene.SettingsScene()),
|
||||
GameScene(new forge.adventure.scene.GameScene()),
|
||||
DuelScene(new forge.adventure.scene.DuelScene())
|
||||
;
|
||||
public final forge.adventure.scene.Scene instance;
|
||||
private SceneType(forge.adventure.scene.Scene scene) {
|
||||
this.instance = scene;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
package forge.adventure.scene;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
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.CheckBox;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Slider;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.utils.viewport.StretchViewport;
|
||||
import forge.adventure.AdventureApplicationAdapter;
|
||||
import forge.adventure.util.Controls;
|
||||
import forge.localinstance.properties.ForgePreferences;
|
||||
import forge.util.Localizer;
|
||||
|
||||
|
||||
public class SettingsScene extends Scene {
|
||||
|
||||
|
||||
static public ForgePreferences Preference;
|
||||
private VerticalGroup settingGroup;
|
||||
private VerticalGroup nameGroup;
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if(Stage!=null)
|
||||
Stage.dispose();
|
||||
}
|
||||
Texture Background;
|
||||
@Override
|
||||
public void render() {
|
||||
|
||||
|
||||
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,IntendedWidth,IntendedHeight);
|
||||
Stage.getBatch().enableBlending();
|
||||
Stage.getBatch().end();
|
||||
Stage.act(Gdx.graphics.getDeltaTime());
|
||||
Stage.draw();
|
||||
|
||||
}
|
||||
|
||||
public boolean Back()
|
||||
{
|
||||
AdventureApplicationAdapter.CurrentAdapter.SwitchScene(AdventureApplicationAdapter.CurrentAdapter.GetLastScene());
|
||||
return true;
|
||||
}
|
||||
private void AddSettingButton(String name, Class type, ForgePreferences.FPref pref, Object[] para)
|
||||
{
|
||||
|
||||
|
||||
Actor control;
|
||||
if (boolean.class.equals(type))
|
||||
{
|
||||
CheckBox box = Controls.newCheckBox("");
|
||||
control =box;
|
||||
box.setChecked(Preference.getPrefBoolean(pref));
|
||||
control.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor)
|
||||
{
|
||||
Preference.setPref(pref, ((CheckBox)actor).isChecked());
|
||||
Preference.save();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
else if (int.class.equals(type))
|
||||
{
|
||||
Slider slide = Controls.newSlider((int)para[0],(int)para[1],1,false);
|
||||
control=slide;
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
control=Controls.newLabel("");
|
||||
|
||||
}
|
||||
control.setHeight(40);
|
||||
Label label=Controls.newLabel(name);
|
||||
nameGroup.addActor(label);
|
||||
settingGroup.addActor(control);
|
||||
}
|
||||
@Override
|
||||
public void ResLoaded()
|
||||
{
|
||||
Stage = new Stage(new StretchViewport(IntendedWidth,IntendedHeight));
|
||||
Background = new Texture( forge.adventure.AdventureApplicationAdapter.CurrentAdapter.GetRes().GetFile("img/title_bg.png"));
|
||||
settingGroup=new VerticalGroup();
|
||||
nameGroup =new VerticalGroup();
|
||||
if(Preference==null)
|
||||
{
|
||||
Preference = new ForgePreferences();
|
||||
}
|
||||
Localizer localizer = Localizer.getInstance();
|
||||
|
||||
AddSettingButton("Enable Music", boolean.class,ForgePreferences.FPref.UI_ENABLE_MUSIC, new Object[]{});
|
||||
AddSettingButton(localizer.getMessage("lblCardName"), boolean.class,ForgePreferences.FPref.UI_OVERLAY_CARD_NAME, new Object[]{});
|
||||
AddSettingButton(localizer.getMessage("cbAdjustMusicVolume"), int.class,ForgePreferences.FPref.UI_VOL_MUSIC, new Object[]{0,100});
|
||||
AddSettingButton(localizer.getMessage("cbAdjustSoundsVolume"), int.class,ForgePreferences.FPref.UI_VOL_SOUNDS, new Object[]{0,100});
|
||||
AddSettingButton(localizer.getMessage("lblManaCost"), boolean.class,ForgePreferences.FPref.UI_OVERLAY_CARD_MANA_COST, new Object[]{});
|
||||
AddSettingButton(localizer.getMessage("lblPowerOrToughness"), boolean.class,ForgePreferences.FPref.UI_OVERLAY_CARD_POWER, new Object[]{});
|
||||
AddSettingButton(localizer.getMessage("lblCardID"), boolean.class,ForgePreferences.FPref.UI_OVERLAY_CARD_ID, new Object[]{});
|
||||
AddSettingButton(localizer.getMessage("lblAbilityIcon"), boolean.class,ForgePreferences.FPref.UI_OVERLAY_ABILITY_ICONS, new Object[]{});
|
||||
|
||||
|
||||
|
||||
//settingGroup.pack();
|
||||
// nameGroup.pack();
|
||||
nameGroup.setPosition(130,600);
|
||||
settingGroup.setPosition(500,600);
|
||||
|
||||
nameGroup.addActor(Controls.newTextButton("Return",()->Back()));
|
||||
|
||||
Stage.addActor(settingGroup);
|
||||
Stage.addActor(nameGroup);
|
||||
}
|
||||
@Override
|
||||
public void create() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,11 @@ import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Button;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.utils.viewport.StretchViewport;
|
||||
import forge.adventure.AdventureApplicationAdapter;
|
||||
import forge.adventure.util.Controls;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@@ -47,14 +47,10 @@ public class StartScene extends Scene {
|
||||
|
||||
private void AddButton(String name, Callable func, int ypos)
|
||||
{
|
||||
|
||||
ImageButton button = new ImageButton(DrawableImage("img/title_"+name+".png")) ;
|
||||
Button.ButtonStyle style=new ImageButton.ImageButtonStyle();
|
||||
style.up=DrawableImage("img/title_"+name+".png");
|
||||
style.down=DrawableImage("img/title_"+name+"_pressed.png");
|
||||
style.over=DrawableImage("img/title_"+name+"_hover.png");
|
||||
button.setStyle(style);
|
||||
button.setPosition((IntendedWidth/2)-(button.getWidth()/2),ypos);
|
||||
TextButton button = Controls.newTextButton(name) ;
|
||||
button.getLabel().setFontScale(3);
|
||||
button.setPosition(1200,ypos);
|
||||
button.setSize(400,80);
|
||||
button.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
@@ -68,7 +64,7 @@ public class StartScene extends Scene {
|
||||
}
|
||||
public boolean NewGame()
|
||||
{
|
||||
AdventureApplicationAdapter.CurrentAdapter.SwitchScene(SceneType.NewGameScene);
|
||||
AdventureApplicationAdapter.CurrentAdapter.SwitchScene(forge.adventure.scene.SceneType.NewGameScene.instance);
|
||||
return true;
|
||||
}
|
||||
public boolean Load()
|
||||
@@ -79,6 +75,11 @@ public class StartScene extends Scene {
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public boolean settings()
|
||||
{
|
||||
AdventureApplicationAdapter.CurrentAdapter.SwitchScene(forge.adventure.scene.SceneType.SettingsScene.instance);
|
||||
return true;
|
||||
}
|
||||
public boolean Exit()
|
||||
{
|
||||
Gdx.app.exit();
|
||||
@@ -90,10 +91,12 @@ public class StartScene extends Scene {
|
||||
Background = new Texture( AdventureApplicationAdapter.CurrentAdapter.GetRes().GetFile("img/title_bg.png"));
|
||||
Title = new Texture( AdventureApplicationAdapter.CurrentAdapter.GetRes().GetFile("img/title.png"));
|
||||
|
||||
AddButton("new_game", () -> NewGame(), (IntendedHeight / 6) * 3);
|
||||
AddButton("load",() -> Load(),(IntendedHeight/6)*2);
|
||||
AddButton("resume",() -> Resume(),(IntendedHeight/6)*1);
|
||||
AddButton("exit",() -> Exit(),0);
|
||||
AddButton("new game", () -> NewGame(), 800);
|
||||
AddButton("load",() -> Load(),700);
|
||||
AddButton("save",() -> Load(),600);
|
||||
AddButton("resume",() -> Resume(),500);
|
||||
AddButton("settings",() -> settings(),400);
|
||||
AddButton("exit",() -> Exit(),300);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package forge.adventure.stage;
|
||||
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.utils.viewport.StretchViewport;
|
||||
import forge.adventure.AdventureApplicationAdapter;
|
||||
@@ -15,6 +16,7 @@ public class GameStage extends Stage {
|
||||
private int playerMovementX;
|
||||
private int playerMovementY;
|
||||
private int playerSpeed=6;
|
||||
private Vector2 target;
|
||||
MobSprite mob;
|
||||
PlayerSprite player;
|
||||
public GameStage()
|
||||
@@ -31,17 +33,33 @@ public class GameStage extends Stage {
|
||||
public void act(float delta)
|
||||
{
|
||||
super.act(delta);
|
||||
if(target!=null)
|
||||
{
|
||||
if(target.x<player.getX())
|
||||
playerMovementX=-playerSpeed;
|
||||
else if(target.x>player.getX())
|
||||
playerMovementX=+playerSpeed;
|
||||
else
|
||||
playerMovementX=0;
|
||||
if(target.y<player.getY())
|
||||
playerMovementY=-playerSpeed;
|
||||
else if(target.y>player.getY())
|
||||
playerMovementY=+playerSpeed;
|
||||
else
|
||||
playerMovementY=0;
|
||||
}
|
||||
player.moveBy(playerMovementX,playerMovementY);
|
||||
|
||||
if(player.collideWith(mob))
|
||||
{
|
||||
|
||||
AdventureApplicationAdapter.CurrentAdapter.SwitchScene(SceneType.DuelScene);
|
||||
AdventureApplicationAdapter.CurrentAdapter.SwitchScene(SceneType.DuelScene.instance);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyDown(int keycode) {
|
||||
|
||||
super.keyDown(keycode);
|
||||
if(keycode == Input.Keys.LEFT||keycode==Input.Keys.A)//todo config
|
||||
{
|
||||
playerMovementX=-playerSpeed;
|
||||
@@ -61,6 +79,30 @@ public class GameStage extends Stage {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean touchDragged(int screenX, int screenY, int pointer)
|
||||
{
|
||||
|
||||
target=this.screenToStageCoordinates(new Vector2((float)screenX, (float)screenY));
|
||||
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean touchDown(int screenX, int screenY, int pointer, int button)
|
||||
{
|
||||
target=this.screenToStageCoordinates(new Vector2((float)screenX, (float)screenY));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean touchUp(int screenX, int screenY, int pointer, int button)
|
||||
{
|
||||
target=null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyUp(int keycode) {
|
||||
if(keycode == Input.Keys.LEFT||keycode==Input.Keys.A||keycode == Input.Keys.RIGHT||keycode==Input.Keys.D)//todo config
|
||||
{
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package forge.adventure.util;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.utils.Scaling;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class Controls {
|
||||
private static Skin SelectedSkin=null;
|
||||
public static int DEFAULTHEIGHT=40;
|
||||
static public TextButton newTextButton(String text)
|
||||
{
|
||||
TextButton ret=new TextButton(text,GetSkin());
|
||||
|
||||
return ret;
|
||||
}
|
||||
static public TextButton newTextButton(String text, Callable func)
|
||||
{
|
||||
TextButton ret=new TextButton(text,GetSkin());
|
||||
ret.addListener(new ClickListener(){
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
try {
|
||||
func.call();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
static public Slider newSlider(float min,float max,float step,boolean vertical)
|
||||
{
|
||||
Slider ret=new Slider(min,max,step,vertical,GetSkin());
|
||||
ret.getStyle().knob.setMinHeight(DEFAULTHEIGHT);
|
||||
return ret;
|
||||
}
|
||||
static public CheckBox newCheckBox(String text)
|
||||
{
|
||||
CheckBox ret=new CheckBox(text,GetSkin());
|
||||
ret.getImage().setScaling(Scaling.fill);
|
||||
ret.getImageCell().size(DEFAULTHEIGHT);
|
||||
return ret;
|
||||
}
|
||||
static public Skin GetSkin() {
|
||||
|
||||
if(SelectedSkin==null)
|
||||
{
|
||||
SelectedSkin=new Skin(Res.CurrentRes.GetFile("skin/uiskin.json"));
|
||||
SelectedSkin.getFont("default-font").getData().setScale(2);
|
||||
}
|
||||
return SelectedSkin;
|
||||
}
|
||||
|
||||
public static Label newLabel(String name) {
|
||||
|
||||
Label ret=new Label(name,GetSkin());
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.adventure.util;
|
||||
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import forge.gui.GuiBase;
|
||||
import forge.localinstance.properties.ForgePreferences;
|
||||
import forge.model.FModel;
|
||||
@@ -13,8 +12,9 @@ public class Res {
|
||||
public static Res CurrentRes;
|
||||
private String Prefix;
|
||||
private String Lang="en-us";
|
||||
private Skin SelectedSkin=null;
|
||||
private HashMap<String,FileHandle> Cache=new HashMap<String,FileHandle>();
|
||||
|
||||
public String GetPrefix(){return Prefix;}
|
||||
public Res(String plane) {
|
||||
CurrentRes=this;
|
||||
Prefix= GuiBase.getInterface().getAssetsDir()+"/res/adventure/"+plane+"/";
|
||||
@@ -28,6 +28,7 @@ public class Res {
|
||||
String fullPath=Prefix+path;
|
||||
if(!Cache.containsKey(fullPath))
|
||||
{
|
||||
|
||||
String fileName = fullPath.replaceFirst("[.][^.]+$", "");
|
||||
String ext= fullPath.substring(fullPath.lastIndexOf('.'));
|
||||
String langFile=fileName+"-"+Lang+ext;
|
||||
@@ -43,10 +44,7 @@ public class Res {
|
||||
return Cache.get(fullPath);
|
||||
}
|
||||
|
||||
public Skin GetSkin() {
|
||||
|
||||
if(SelectedSkin==null)
|
||||
SelectedSkin=new Skin(GetFile("skin/uiskin.json"));
|
||||
return SelectedSkin;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package forge.adventure.world;
|
||||
|
||||
public class AdventurePlayer {
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,97 @@
|
||||
package forge.adventure.world;
|
||||
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import forge.adventure.data.BiomData;
|
||||
import forge.adventure.data.WorldData;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Random;
|
||||
|
||||
public class World {
|
||||
|
||||
|
||||
public Pixmap GenerateNew() {
|
||||
|
||||
FileHandle handle= forge.adventure.util.Res.CurrentRes.GetFile("world/word.json");
|
||||
String rawJson=handle.readString();
|
||||
WorldData data = (new Json()).fromJson(WorldData.class,rawJson);
|
||||
int seed= new Random().nextInt();
|
||||
OpenSimplexNoise noise=new OpenSimplexNoise(seed);
|
||||
|
||||
double noiceZoom=10;
|
||||
|
||||
//save at all data
|
||||
double[][] noiseData=new double[data.sizeX][data.sizeY];
|
||||
|
||||
for(int x=0;x<data.sizeX;x++)
|
||||
{
|
||||
for(int y=0;y<data.sizeY;y++)
|
||||
{
|
||||
noiseData[x][y]=noise.eval(x/data.sizeX*noiceZoom,y/data.sizeY*noiceZoom);
|
||||
}
|
||||
}
|
||||
BufferedImage image = new BufferedImage(data.sizeX, data.sizeY, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
byte[] imagedata = new byte[data.sizeX* data.sizeY*4];
|
||||
|
||||
Pixmap pix=new Pixmap(data.sizeX,data.sizeY, Pixmap.Format.RGB888);
|
||||
pix.setColor(1,0,0,1);
|
||||
pix.fill();
|
||||
|
||||
/*for(long x=0;x<data.sizeX;x++)
|
||||
{
|
||||
for(long y=0;y<data.sizeY;y++)
|
||||
{
|
||||
//value 0-1 based on noise
|
||||
;
|
||||
float value=(float)noise.eval((double) x/(double)data.sizeX*noiceZoom,(double)y/(double)data.sizeY*noiceZoom);
|
||||
value=(value+1)/2;
|
||||
pix.setColor(value,value,value,1);
|
||||
pix.drawPixel((int)x,(int)y);
|
||||
|
||||
}
|
||||
}*/
|
||||
for(BiomData biom:data.bioms)
|
||||
{
|
||||
long biomXStart=Math.round(biom.startPointX * (double)data.sizeX);
|
||||
long biomYStart=Math.round(biom.startPointY * (double)data.sizeY);
|
||||
long biomXSize=Math.round(biom.sizeX * (double)data.sizeX);
|
||||
long biomYSize=Math.round(biom.sizeY * (double)data.sizeY);
|
||||
|
||||
if(biom.sizeX==1.0&&biom.sizeY==1.0)
|
||||
{
|
||||
pix.setColor(biom.GetColor().r,biom.GetColor().g,biom.GetColor().b,1);
|
||||
pix.fill();
|
||||
}
|
||||
else
|
||||
{
|
||||
for(long x=Math.max(biomXStart-biomXSize/2,0);x<biomXStart+biomXSize;x++)
|
||||
{
|
||||
for(long y=Math.max(biomYStart-biomYSize/2,0);y<biomYStart+biomYSize;y++)
|
||||
{
|
||||
//value 0-1 based on noise
|
||||
double noiseValue=noise.eval((double) x/(double)data.sizeX*noiceZoom,(double)y/(double)data.sizeY*noiceZoom);
|
||||
noiseValue*=biom.noiceWeight;
|
||||
//value 0-1 based on dist to origin
|
||||
double distanceValue=(Math.sqrt((x-biomXStart)*(x-biomXStart) + (y-biomYStart)*(y-biomYStart)))/(Math.max(biomXSize,biomYSize)/2);
|
||||
distanceValue*=biom.distWeight;
|
||||
if(noiseValue+distanceValue<1.0||biom.invertHeight&&(1-noiseValue)+distanceValue<1.0)
|
||||
{
|
||||
imagedata[(((int)y*data.sizeX)+(int)x*4)]=(byte)(biom.GetColor().r*255);
|
||||
imagedata[(((int)y*data.sizeX)+(int)x*4)+1]=(byte)(biom.GetColor().g*255);
|
||||
imagedata[(((int)y*data.sizeX)+(int)x*4)+2]=(byte)(biom.GetColor().b*255);
|
||||
pix.setColor(biom.GetColor().r,biom.GetColor().g,biom.GetColor().b,1);
|
||||
pix.drawPixel((int)x,(int)y);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return pix;//new World();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package forge.adventure.world;
|
||||
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
|
||||
public class WorldSave {
|
||||
public AdventurePlayer player;
|
||||
public World world;
|
||||
static WorldSave currentSave;
|
||||
|
||||
public static WorldSave getCurrentSave()
|
||||
{
|
||||
return currentSave;
|
||||
}
|
||||
public static Pixmap GenerateNewWorld()
|
||||
{
|
||||
WorldSave ret=new WorldSave();
|
||||
ret.world=new World();
|
||||
return ret.world.GenerateNew();
|
||||
//return currentSave = ret;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,18 @@
|
||||
package forge.deck;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import forge.Forge;
|
||||
import forge.assets.ImageCache;
|
||||
import forge.deck.FDeckEditor.EditorType;
|
||||
@@ -30,15 +41,18 @@ import forge.screens.FScreen;
|
||||
import forge.screens.LoadingOverlay;
|
||||
import forge.screens.home.NewGameMenu.NewGameScreen;
|
||||
import forge.screens.match.MatchController;
|
||||
import forge.toolbox.*;
|
||||
import forge.toolbox.FButton;
|
||||
import forge.toolbox.FComboBox;
|
||||
import forge.toolbox.FContainer;
|
||||
import forge.toolbox.FEvent;
|
||||
import forge.toolbox.FEvent.FEventHandler;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.toolbox.GuiChoose;
|
||||
import forge.toolbox.ListChooser;
|
||||
import forge.util.Callback;
|
||||
import forge.util.Localizer;
|
||||
import forge.util.Utils;
|
||||
import forge.util.storage.IStorage;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class FDeckChooser extends FScreen {
|
||||
public static final float PADDING = Utils.scale(5);
|
||||
|
||||
@@ -165,6 +165,7 @@ public class MatchController extends AbstractGuiGame {
|
||||
|
||||
actuateMatchPreferences();
|
||||
|
||||
Forge.openScreen(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -279,7 +279,7 @@ public class HostedMatch {
|
||||
public Game getGame() {
|
||||
return game;
|
||||
}
|
||||
public GameView getGameView() {
|
||||
public GameView getGameView() {
|
||||
return game == null ? null : game.getView();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user