fix: ajout du composant worldlist, affinage du système de gestion de base de donnée, correction de nombreux bogues, ajout du menu principal

This commit is contained in:
Nicolas Hordé 2016-01-14 23:49:43 +01:00
parent 7fe9f6804c
commit 2d8a6a7124
12 changed files with 292 additions and 41 deletions

View File

@ -1,6 +1,6 @@
apply plugin: "java" apply plugin: "java"
sourceCompatibility = 1.6 sourceCompatibility = 1.7
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.java.srcDirs = [ "src/" ] sourceSets.main.java.srcDirs = [ "src/" ]

View File

@ -16,6 +16,7 @@ import com.badlogic.gdx.utils.Base64Coder;
import com.badlogic.gdx.utils.XmlReader; import com.badlogic.gdx.utils.XmlReader;
import com.badlogic.gdx.utils.XmlReader.Element; import com.badlogic.gdx.utils.XmlReader.Element;
import fr.evolving.assets.AssetLoader;
import fr.evolving.database.Base; import fr.evolving.database.Base;
import fr.evolving.database.Base.datatype; import fr.evolving.database.Base.datatype;
import fr.evolving.database.LocalBase; import fr.evolving.database.LocalBase;
@ -25,6 +26,7 @@ public class ServerList extends List {
HashMap parameters; HashMap parameters;
String url; String url;
Base.datatype model; Base.datatype model;
Worldlist list;
public ServerList(String url,Base.datatype model,Skin skin) { public ServerList(String url,Base.datatype model,Skin skin) {
super(skin); super(skin);
@ -32,15 +34,18 @@ public class ServerList extends List {
this.model=model; this.model=model;
parameters = new HashMap(); parameters = new HashMap();
parameters.put("version", "last"); parameters.put("version", "last");
Refresh();
} }
public boolean getBackend(String base,datatype model) { public String getUrl() {
String[] realbase=base.split(":"); return (String)this.getSelected();
if (realbase[0].contains("mysql")) }
return SqlBase.isHandling(model);
else public Base.datatype getModel() {
return LocalBase.isHandling(model); return model;
}
public void setWorldlist(Worldlist list) {
this.list=list;
} }
public void Refresh() { public void Refresh() {
@ -65,13 +70,25 @@ public class ServerList extends List {
XmlReader.Element xml_element = xml.parse(Response); XmlReader.Element xml_element = xml.parse(Response);
resultxml= xml_element.getChildrenByName("server"); resultxml= xml_element.getChildrenByName("server");
for(Element child : resultxml) for(Element child : resultxml)
if (getBackend(child.getText(),ServerList.this.model)) if (AssetLoader.Datahandler.isBackend(ServerList.this.model,child.getText()))
resultstring.add(child.getText()); resultstring.add(child.getText());
String old=AssetLoader.Datahandler.getOld(ServerList.this.model);
if (!resultstring.contains(old,false))
resultstring.add(old);
ServerList.this.setItems(resultstring); ServerList.this.setItems(resultstring);
ServerList.this.setSelectedIndex(resultstring.indexOf(old, false));
if (list!=null && ServerList.this.model==Base.datatype.gamedata)
list.Refresh();
} }
@Override @Override
public void failed(Throwable t) { public void failed(Throwable t) {
Array<String> resultstring=new Array<String>();
String old=AssetLoader.Datahandler.getOld(ServerList.this.model);
resultstring.add(old);
ServerList.this.setItems(resultstring);
ServerList.this.setSelectedIndex(resultstring.indexOf(old, false));
if (list!=null && ServerList.this.model==Base.datatype.gamedata)
list.Refresh();
} }
public void cancelled() { public void cancelled() {

View File

@ -0,0 +1,24 @@
package fr.evolving.UI;
import com.badlogic.gdx.scenes.scene2d.ui.List;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.utils.Array;
import fr.evolving.assets.AssetLoader;
import fr.evolving.assets.Preference;
public class Worldlist extends List {
public Worldlist(Skin skin) {
super(skin);
// TODO Auto-generated constructor stub
}
public void Refresh() {
Array<String> worlds=AssetLoader.Datahandler.game().getworlds();
String world=Preference.prefs.getString("world");
if (!worlds.contains(world, false))
worlds.add(world);
this.setItems(worlds);
}
}

View File

@ -203,12 +203,16 @@ public class AssetLoader {
Datahandler= new DatabaseManager(); Datahandler= new DatabaseManager();
Datahandler.RegisterBackend(LocalBase.class); Datahandler.RegisterBackend(LocalBase.class);
Datahandler.RegisterBackend(SqlBase.class); Datahandler.RegisterBackend(SqlBase.class);
Datahandler.Attach(datatype.userdata, "local:test.db"); Databasemanagerfrompref();
Datahandler.Attach(datatype.statdata, "local:test.db");
Datahandler.Attach(datatype.gamedata, "local:test.db");
} }
public static void Databasemanagerfrompref() {
Datahandler.CloseAll();
Datahandler.Attach(datatype.userdata, Preference.prefs.getString("userdata"));
Datahandler.Attach(datatype.statdata, Preference.prefs.getString("statdata"));
Datahandler.Attach(datatype.gamedata, Preference.prefs.getString("gamedata"));
}
public static Transmuter getTransmuter(String Name) { public static Transmuter getTransmuter(String Name) {
for(Transmuter transmuter:allTransmuter) { for(Transmuter transmuter:allTransmuter) {
if (transmuter.isTransmuter(Name)) if (transmuter.isTransmuter(Name))

View File

@ -39,6 +39,9 @@ public class Preference {
public static void defaults() { public static void defaults() {
Vector2 maxres=getmaxresolution(); Vector2 maxres=getmaxresolution();
Gdx.app.log("Preferences","Preference par defaut avec resolution native :"+maxres.x+"x"+maxres.y); Gdx.app.log("Preferences","Preference par defaut avec resolution native :"+maxres.x+"x"+maxres.y);
Preference.prefs.putString("userdata", "local:test.db");
Preference.prefs.putString("gamedata", "local:test.db");
Preference.prefs.putString("statdata", "local:test.db");
Preference.prefs.putInteger("ResolutionX", (int)maxres.x); Preference.prefs.putInteger("ResolutionX", (int)maxres.x);
Preference.prefs.putInteger("ResolutionY", (int)maxres.y); Preference.prefs.putInteger("ResolutionY", (int)maxres.y);
Preference.prefs.putInteger("Resolution", 9); Preference.prefs.putInteger("Resolution", 9);
@ -49,9 +52,10 @@ public class Preference {
Preference.prefs.putBoolean("Refresh", false); Preference.prefs.putBoolean("Refresh", false);
Preference.prefs.putBoolean("Animation", true); Preference.prefs.putBoolean("Animation", true);
Preference.prefs.putBoolean("Language", false); Preference.prefs.putBoolean("Language", false);
Preference.prefs.putString("world", "test pour voir");
Preference.prefs.putFloat("Effect", 1.0f); Preference.prefs.putFloat("Effect", 1.0f);
Preference.prefs.putFloat("Music",0.75f); Preference.prefs.putFloat("Music",0.75f);
Preference.prefs.putInteger("Adaptation", 1); Preference.prefs.putInteger("Adaptation", 2);
Preference.prefs.putInteger("Quality", 2); Preference.prefs.putInteger("Quality", 2);
Preference.prefs.putInteger("log", Gdx.app.LOG_INFO); Preference.prefs.putInteger("log", Gdx.app.LOG_INFO);
Preference.prefs.flush(); Preference.prefs.flush();

View File

@ -15,6 +15,10 @@ public abstract class Base {
public Base() { public Base() {
} }
public String getParam() {
return null;
}
//Gestion type Gamebase //Gestion type Gamebase
public Array<String> getworlds() { public Array<String> getworlds() {

View File

@ -6,8 +6,13 @@ import com.badlogic.gdx.utils.Array;
public class DatabaseManager { public class DatabaseManager {
private static Base[] bases; private static Base[] bases;
private static String[] old;
private static Array<Class<?>> backends; private static Array<Class<?>> backends;
public Base getType(Base.datatype model) {
return bases[model.ordinal()];
}
public Base user(){ public Base user(){
return bases[Base.datatype.userdata.ordinal()]; return bases[Base.datatype.userdata.ordinal()];
} }
@ -22,20 +27,29 @@ public class DatabaseManager {
public DatabaseManager(){ public DatabaseManager(){
bases=new Base[3]; bases=new Base[3];
old=new String[3];
backends=new Array<Class<?>>(); backends=new Array<Class<?>>();
} }
public void CloseAll() { public void CloseAll() {
for(Base base:bases) for(int i=0;i<3;i++)
base.Close(); if (bases[i]!=null) {
bases[i].Close();
bases[i]=null;
}
}
public String getOld(Base.datatype model) {
return old[model.ordinal()];
} }
public boolean Attach(Base.datatype model, String Url) { public boolean Attach(Base.datatype model, String Url) {
if (bases[model.ordinal()]!=null) if (bases[model.ordinal()]!=null || model==null || Url==null)
return false; return false;
Base backend=getBackend(model,Url); Base backend=getBackend(model,Url);
if (backend!=null) { if (backend!=null) {
bases[model.ordinal()]=backend; bases[model.ordinal()]=backend;
old[model.ordinal()]=Url;
return true; return true;
} }
else else
@ -61,7 +75,23 @@ public class DatabaseManager {
} }
} }
return null; return null;
}
public boolean isBackend(Base.datatype model, String Url) {
String Type=Url.split(":")[0];
for(Class<?> classe:backends) {
Base back;
try {
back = (Base) classe.newInstance();
if (back.getprefix().equals(Type))
return true;
} catch (InstantiationException | IllegalAccessException
| IllegalArgumentException | SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return false;
} }
public void RegisterBackend(Class<?> classe) { public void RegisterBackend(Class<?> classe) {

View File

@ -2,19 +2,26 @@ package fr.evolving.database;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import javax.xml.bind.DatatypeConverter; import javax.xml.bind.DatatypeConverter;
import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.sql.Database; import com.badlogic.gdx.sql.Database;
import com.badlogic.gdx.sql.DatabaseCursor; import com.badlogic.gdx.sql.DatabaseCursor;
import com.badlogic.gdx.sql.DatabaseFactory; import com.badlogic.gdx.sql.DatabaseFactory;
import com.badlogic.gdx.sql.SQLiteGdxException; import com.badlogic.gdx.sql.SQLiteGdxException;
import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Array;
import fr.evolving.assets.AssetLoader;
import fr.evolving.automata.Grid; import fr.evolving.automata.Grid;
import fr.evolving.automata.Level; import fr.evolving.automata.Level;
import fr.evolving.automata.Transmuter; import fr.evolving.automata.Transmuter;
@ -24,16 +31,40 @@ public class LocalBase extends Base {
private static Database dbHandler; private static Database dbHandler;
private String databasename = "base.db"; private String databasename = "base.db";
private String creation; private String creation;
private String param;
//Contructeur de la base de donnée //Contructeur de la base de donnée
public LocalBase(){
public String getParam() {
return this.param;
}
public LocalBase() {
} }
public LocalBase(datatype model,String param) { public LocalBase(datatype model,String param) {
super(model,param); super(model,param);
String[] params=param.split(":"); String[] params=param.split(":");
this.param=param;
if (params.length>1) if (params.length>1)
databasename=params[1]; databasename=params[1];
switch(Gdx.app.getType()) {
case Android:
try {
FileChannel source = ((FileInputStream) Gdx.files.internal("bases/"+databasename).read()).getChannel();
FileChannel destination = new FileOutputStream("/data/data/fr.evolving.game.android/databases/"+databasename).getChannel();
destination.transferFrom(source, 0, source.size());
source.close();
destination.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
case Desktop:
FileHandle newbase=Gdx.files.local(databasename);
if (!newbase.exists())
Gdx.files.internal("bases/"+databasename).copyTo(newbase);
}
if (dbHandler!=null) if (dbHandler!=null)
Gdx.app.log("Local", "Reprise de la base '"+databasename+"', table:"+model.toString()); Gdx.app.log("Local", "Reprise de la base '"+databasename+"', table:"+model.toString());
else else
@ -292,7 +323,10 @@ public class LocalBase extends Base {
public void Close() { public void Close() {
try { try {
dbHandler.closeDatabase(); if (dbHandler!=null) {
dbHandler.closeDatabase();
dbHandler=null;
}
} catch (SQLiteGdxException e) { } catch (SQLiteGdxException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();

View File

@ -12,6 +12,13 @@ public class SqlBase extends Base{
super(model,param); super(model,param);
} }
public SqlBase() {
}
public String getprefix() {
return "mysql";
}
public static boolean isHandling(datatype base){ public static boolean isHandling(datatype base){
if (base==datatype.statdata) if (base==datatype.statdata)
return false; return false;

View File

@ -68,7 +68,8 @@ public class LevelRenderer {
public void render(float delta, float runTime) { public void render(float delta, float runTime) {
Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
font.setColor(AssetLoader.Levelcolors[LevelScreen.world]); if (LevelScreen.world>=0)
font.setColor(AssetLoader.Levelcolors[LevelScreen.world]);
batcher.begin(); batcher.begin();
batcher.setProjectionMatrix(AssetLoader.Camera.combined); batcher.setProjectionMatrix(AssetLoader.Camera.combined);
batcher.setColor(0.25f,0.25f,0.25f,1f); batcher.setColor(0.25f,0.25f,0.25f,1f);
@ -113,7 +114,8 @@ public class LevelRenderer {
if (LevelScreen.selected.level.Tech>0) if (LevelScreen.selected.level.Tech>0)
shapeRenderer.rect(1210, 620,250, AssetLoader.height-630); shapeRenderer.rect(1210, 620,250, AssetLoader.height-630);
} }
shapeRenderer.rect(1470, 10, 440, AssetLoader.height-20); if (!LevelScreen.MenuSolo.isVisible())
shapeRenderer.rect(1470, 10, 440, AssetLoader.height-20);
shapeRenderer.end(); shapeRenderer.end();
if (LevelScreen.buttonLevels!=null) if (LevelScreen.buttonLevels!=null)
for (int i=0;i<LevelScreen.buttonLevels.length;i++) { for (int i=0;i<LevelScreen.buttonLevels.length;i++) {

View File

@ -30,12 +30,14 @@ import fr.evolving.renderers.LevelRenderer;
import fr.evolving.UI.ButtonLevel; import fr.evolving.UI.ButtonLevel;
import fr.evolving.UI.Objectives; import fr.evolving.UI.Objectives;
import fr.evolving.UI.ServerList; import fr.evolving.UI.ServerList;
import fr.evolving.UI.Worldlist;
import fr.evolving.game.main; import fr.evolving.game.main;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import fr.evolving.assets.AssetLoader; import fr.evolving.assets.AssetLoader;
import fr.evolving.assets.InitWorlds; import fr.evolving.assets.InitWorlds;
import fr.evolving.assets.Preference;
import fr.evolving.automata.Level; import fr.evolving.automata.Level;
import fr.evolving.automata.Transmuter; import fr.evolving.automata.Transmuter;
import fr.evolving.database.Base; import fr.evolving.database.Base;
@ -54,11 +56,12 @@ public class LevelScreen implements Screen {
private Stage stage; private Stage stage;
private Table table; private Table table;
private ImageButton Previous,Next,Exit; private ImageButton Previous,Next,Exit;
public ImageButton logosmall; public ImageButton logosmall,MenuSolo,MenuMulti,MenuScenario;
private ImageTextButton cout,tech,cycle,temp,rayon,nrj; private ImageTextButton cout,tech,cycle,temp,rayon,nrj;
private TextButton buttonConnect,buttonPlay,buttonStat; private TextButton buttonConnect,buttonPlay,buttonStat,buttonSave, buttonApply, buttonPlaythis;
private ServerList Statdata,Userdata,Gamedata; private ServerList Statdata,Userdata,Gamedata;
private Label Statdatalabel, Userdatalabel, Gamedatalabel; private Worldlist Worlddata;
private Label Statdatalabel, Userdatalabel, Gamedatalabel,Worlddatalabel;
private Array<Level> thelevels; private Array<Level> thelevels;
private TextArea TextDescriptive; private TextArea TextDescriptive;
public int world; public int world;
@ -74,7 +77,29 @@ public class LevelScreen implements Screen {
return max; return max;
} }
public void play() {
//thelevels= InitWorlds.go();
Gdx.app.debug(getClass().getSimpleName(),"Chargement des mondes depuis la base.");
try {
if (world<0)
world=0;
thelevels=AssetLoader.Datahandler.game().getworld(Preference.prefs.getString("world"));
loadWorld(world);
Previous.setVisible(true);
Next.setVisible(true);
buttonPlay.setVisible(true);
TextDescriptive.setVisible(true);
}
catch (Exception e) {
Previous.setVisible(false);
Next.setVisible(false);
buttonPlay.setVisible(false);
TextDescriptive.setVisible(false);
}
}
public void menu() { public void menu() {
selected=null;
cout.setVisible(false); cout.setVisible(false);
tech.setVisible(false); tech.setVisible(false);
cycle.setVisible(false); cycle.setVisible(false);
@ -83,10 +108,44 @@ public class LevelScreen implements Screen {
nrj.setVisible(false); nrj.setVisible(false);
Previous.setVisible(false); Previous.setVisible(false);
Next.setVisible(false); Next.setVisible(false);
Exit.setVisible(false); Victory.setVisible(false);
Exit.setPosition(1820,AssetLoader.height-100);
buttonPlay.setVisible(false); buttonPlay.setVisible(false);
TextDescriptive.setVisible(false); TextDescriptive.setVisible(false);
MenuSolo.setVisible(true);
MenuMulti.setVisible(true);
MenuScenario.setVisible(true);
buttonConnect.setVisible(false);
buttonStat.setVisible(false);
Statdata.setVisible(false);
Userdata.setVisible(false);
Gamedata.setVisible(false);
Statdatalabel.setVisible(false);
Userdatalabel.setVisible(false);
Gamedatalabel.setVisible(false);
Worlddatalabel.setVisible(false);
buttonPlaythis.setVisible(false);
Worlddata.setVisible(false);
buttonSave.setVisible(false);
buttonApply.setVisible(false);
if (buttonLevels!=null)
for (int j=0;j<10;j++)
if (buttonLevels[j]!=null) {
buttonLevels[j].remove();
buttonLevels[j]=null;
}
}
public void level() {
Exit.setPosition(1110, AssetLoader.height-Exit.getHeight()-5);
MenuSolo.setVisible(false);
MenuMulti.setVisible(false);
MenuScenario.setVisible(false);
buttonConnect.setVisible(true);
buttonStat.setVisible(true);
SetButtonStat(); SetButtonStat();
if (Preference.prefs.contains("world"))
play();
} }
public void SetButtonConnect() { public void SetButtonConnect() {
@ -98,6 +157,11 @@ public class LevelScreen implements Screen {
Statdatalabel.setVisible(true); Statdatalabel.setVisible(true);
Userdatalabel.setVisible(true); Userdatalabel.setVisible(true);
Gamedatalabel.setVisible(true); Gamedatalabel.setVisible(true);
buttonSave.setVisible(true);
buttonApply.setVisible(true);
Worlddatalabel.setVisible(true);
Worlddata.setVisible(true);
buttonPlaythis.setVisible(true);
} }
public void SetButtonStat() { public void SetButtonStat() {
@ -108,7 +172,12 @@ public class LevelScreen implements Screen {
Gamedata.setVisible(false); Gamedata.setVisible(false);
Statdatalabel.setVisible(false); Statdatalabel.setVisible(false);
Userdatalabel.setVisible(false); Userdatalabel.setVisible(false);
Gamedatalabel.setVisible(false); Gamedatalabel.setVisible(false);
buttonSave.setVisible(false);
buttonApply.setVisible(false);
Worlddatalabel.setVisible(false);
Worlddata.setVisible(false);
buttonPlaythis.setVisible(false);
} }
public void loadWorld(int aworld) { public void loadWorld(int aworld) {
@ -117,6 +186,7 @@ public class LevelScreen implements Screen {
for (int j=0;j<10;j++) { for (int j=0;j<10;j++) {
if (buttonLevels[j]!=null) { if (buttonLevels[j]!=null) {
buttonLevels[j].remove(); buttonLevels[j].remove();
buttonLevels[j]=null;
} }
} }
buttonLevels = null; buttonLevels = null;
@ -176,11 +246,44 @@ public class LevelScreen implements Screen {
} }
}; };
ScrollTimer.scheduleAtFixedRate(ScrollTask, 0, 30); ScrollTimer.scheduleAtFixedRate(ScrollTask, 0, 30);
Gdx.app.debug(getClass().getSimpleName(),"Création du menu.");
MenuSolo=new ImageButton(AssetLoader.Skin_level,"MenuSolo");
MenuSolo.setPosition((AssetLoader.width-MenuSolo.getWidth())/2, AssetLoader.height-550);
MenuSolo.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
level();
}
});
MenuMulti=new ImageButton(AssetLoader.Skin_level,"MenuMulti");
MenuMulti.setPosition((AssetLoader.width-MenuMulti.getWidth())/2, AssetLoader.height-900);
MenuScenario=new ImageButton(AssetLoader.Skin_level,"MenuScenario");
MenuScenario.setPosition((AssetLoader.width-MenuScenario.getWidth())/2, AssetLoader.height-1250);
Gdx.app.debug(getClass().getSimpleName(),"Création des boutons."); Gdx.app.debug(getClass().getSimpleName(),"Création des boutons.");
logosmall=new ImageButton(AssetLoader.Skin_level,"logosmall"); logosmall=new ImageButton(AssetLoader.Skin_level,"logosmall");
logosmall.setPosition(20, AssetLoader.height-175+logosmall.getHeight()/2); logosmall.setPosition(20, AssetLoader.height-175+logosmall.getHeight()/2);
TextDescriptive = new TextArea("Descriptif", AssetLoader.Skin_level,"Descriptif"); TextDescriptive = new TextArea("Descriptif", AssetLoader.Skin_level,"Descriptif");
TextDescriptive.setBounds(15, 15, 1185, 100); TextDescriptive.setBounds(15, 15, 1185, 100);
buttonApply = new TextButton("Appliquer", AssetLoader.Skin_ui);
buttonApply.setBounds(1680, 350, 190, 40);
buttonApply.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
menu();
AssetLoader.Datahandler.CloseAll();
AssetLoader.Datahandler.Attach(Userdata.getModel(),Userdata.getUrl());
AssetLoader.Datahandler.Attach(Gamedata.getModel(),Gamedata.getUrl());
AssetLoader.Datahandler.Attach(Statdata.getModel(),Statdata.getUrl());
}
});
buttonSave = new TextButton("Sauvegarder", AssetLoader.Skin_ui);
buttonSave.setBounds(1480, 350, 190, 40);
buttonSave.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
menu();
Preference.prefs.putString("userdata", Userdata.getUrl());
Preference.prefs.putString("gamedata", Gamedata.getUrl());
Preference.prefs.putString("statdata", Statdata.getUrl());
}
});
buttonConnect = new TextButton("Connexions", AssetLoader.Skin_ui); buttonConnect = new TextButton("Connexions", AssetLoader.Skin_ui);
buttonConnect.setBounds(1480, AssetLoader.height-60, 190, 40); buttonConnect.setBounds(1480, AssetLoader.height-60, 190, 40);
buttonConnect.addListener(new ClickListener() { buttonConnect.addListener(new ClickListener() {
@ -205,6 +308,15 @@ public class LevelScreen implements Screen {
SetButtonStat(); SetButtonStat();
} }
}); });
buttonPlaythis = new TextButton("Jouer ce monde", AssetLoader.Skin_ui);
buttonPlaythis.setBounds(1480, 50, 190, 40);
buttonPlaythis.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
Preference.prefs.putString("world", (String)Worlddata.getSelected());
Preference.prefs.flush();
play();
}
});
Exit=new ImageButton(AssetLoader.Skin_level,"Exit"); Exit=new ImageButton(AssetLoader.Skin_level,"Exit");
Exit.setPosition(1110, AssetLoader.height-Exit.getHeight()-5); Exit.setPosition(1110, AssetLoader.height-Exit.getHeight()-5);
Exit.addListener(new ClickListener(){ Exit.addListener(new ClickListener(){
@ -256,24 +368,29 @@ public class LevelScreen implements Screen {
String url="http://evolving.fr/servers/list.xml"; String url="http://evolving.fr/servers/list.xml";
Statdata=new ServerList(url,Base.datatype.statdata,AssetLoader.Skin_ui); Statdata=new ServerList(url,Base.datatype.statdata,AssetLoader.Skin_ui);
Statdatalabel=new Label("Stockage des statistiques:", AssetLoader.Skin_ui, "grey"); Statdatalabel=new Label("Stockage des statistiques:", AssetLoader.Skin_ui, "grey");
Statdata.setBounds(1480, AssetLoader.height-300, 420, 200); Statdata.setBounds(1480, AssetLoader.height-250, 420, 150);
Statdatalabel.setPosition(1480, AssetLoader.height-100); Statdatalabel.setPosition(1480, AssetLoader.height-100);
Userdata=new ServerList(url,Base.datatype.userdata,AssetLoader.Skin_ui); Userdata=new ServerList(url,Base.datatype.userdata,AssetLoader.Skin_ui);
Userdatalabel=new Label("Stockage des données du joueur:", AssetLoader.Skin_ui, "grey"); Userdatalabel=new Label("Stockage des données du joueur:", AssetLoader.Skin_ui, "grey");
Userdata.setBounds(1480, AssetLoader.height-600, 420, 200); Userdata.setBounds(1480, AssetLoader.height-450, 420, 150);
Userdatalabel.setPosition(1480, AssetLoader.height-400); Userdatalabel.setPosition(1480, AssetLoader.height-300);
Gamedata=new ServerList(url,Base.datatype.gamedata,AssetLoader.Skin_ui); Gamedata=new ServerList(url,Base.datatype.gamedata,AssetLoader.Skin_ui);
Gamedatalabel=new Label("Stockage des données du jeu:", AssetLoader.Skin_ui, "grey"); Gamedatalabel=new Label("Stockage des données du jeu:", AssetLoader.Skin_ui, "grey");
Gamedata.setBounds(1480, AssetLoader.height-900, 420, 200); Gamedata.setBounds(1480, AssetLoader.height-650, 420, 150);
Gamedatalabel.setPosition(1480, AssetLoader.height-700); Gamedatalabel.setPosition(1480, AssetLoader.height-500);
Worlddata=new Worldlist(AssetLoader.Skin_ui);
Worlddatalabel=new Label("Mondes disponibles:", AssetLoader.Skin_ui, "grey");
Worlddata.setBounds(1480, 100, 420, 200);
Worlddatalabel.setPosition(1480, 300);
Gamedata.setWorldlist(Worlddata);
Statdata.Refresh();
Userdata.Refresh();
Gamedata.Refresh();
Gdx.app.debug(getClass().getSimpleName(),"Affichage du menu."); Gdx.app.debug(getClass().getSimpleName(),"Affichage du menu.");
//menu(); if (aworld!=-1)
level();
//thelevels= InitWorlds.go(); else
menu();
Gdx.app.debug(getClass().getSimpleName(),"Chargement des mondes depuis la base.");
thelevels=AssetLoader.Datahandler.game().getworld("test pour voir");
loadWorld(world);
} }
@Override @Override
@ -293,9 +410,15 @@ public class LevelScreen implements Screen {
public void show() { public void show() {
Gdx.app.log("*****","Affichage du choix des mondes & niveaux."); Gdx.app.log("*****","Affichage du choix des mondes & niveaux.");
table.setFillParent(true); table.setFillParent(true);
stage.addActor(MenuSolo);
stage.addActor(MenuMulti);
stage.addActor(MenuScenario);
stage.addActor(TextDescriptive); stage.addActor(TextDescriptive);
stage.addActor(buttonPlaythis);
stage.addActor(Exit); stage.addActor(Exit);
stage.addActor(Next); stage.addActor(Next);
stage.addActor(buttonApply);
stage.addActor(buttonSave);
stage.addActor(buttonPlay); stage.addActor(buttonPlay);
stage.addActor(buttonConnect); stage.addActor(buttonConnect);
stage.addActor(buttonStat); stage.addActor(buttonStat);
@ -314,6 +437,8 @@ public class LevelScreen implements Screen {
stage.addActor(Userdatalabel); stage.addActor(Userdatalabel);
stage.addActor(Gamedata); stage.addActor(Gamedata);
stage.addActor(Gamedatalabel); stage.addActor(Gamedatalabel);
stage.addActor(Worlddata);
stage.addActor(Worlddatalabel);
Gdx.input.setInputProcessor(stage); Gdx.input.setInputProcessor(stage);
Gdx.app.debug("AssetLoader","Début dans la bande son \'intro\'"); Gdx.app.debug("AssetLoader","Début dans la bande son \'intro\'");
AssetLoader.intro.setLooping(true); AssetLoader.intro.setLooping(true);

View File

@ -46,7 +46,7 @@ public class SplashScreen implements Screen {
}),Actions.run(new Runnable() { }),Actions.run(new Runnable() {
@Override @Override
public void run() { public void run() {
((Game)Gdx.app.getApplicationListener()).setScreen(new LevelScreen(0)); ((Game)Gdx.app.getApplicationListener()).setScreen(new LevelScreen(-1));
} }
}))); })));
} }