fix: modification du code pour fonctionnement de la base sous android correction de bogue sur la base de donnée animation du menu
This commit is contained in:
parent
3a6ac43a75
commit
b53166cca0
|
@ -61,10 +61,11 @@ public class ServerList extends List {
|
||||||
|
|
||||||
Gdx.net.sendHttpRequest (httpGet, new HttpResponseListener() {
|
Gdx.net.sendHttpRequest (httpGet, new HttpResponseListener() {
|
||||||
public void handleHttpResponse(HttpResponse httpResponse) {
|
public void handleHttpResponse(HttpResponse httpResponse) {
|
||||||
|
if (httpResponse.getStatus().getStatusCode()==200)
|
||||||
|
{
|
||||||
String Response = "";
|
String Response = "";
|
||||||
Array<Element> resultxml;
|
Array<Element> resultxml;
|
||||||
Array<String> resultstring=new Array<String>();
|
Array<String> resultstring=new Array<String>();
|
||||||
if (httpResponse.getStatus().getStatusCode()==200)
|
|
||||||
Response = httpResponse.getResultAsString();
|
Response = httpResponse.getResultAsString();
|
||||||
XmlReader xml = new XmlReader();
|
XmlReader xml = new XmlReader();
|
||||||
XmlReader.Element xml_element = xml.parse(Response);
|
XmlReader.Element xml_element = xml.parse(Response);
|
||||||
|
@ -80,6 +81,7 @@ public class ServerList extends List {
|
||||||
if (list!=null && ServerList.this.model==Base.datatype.gamedata)
|
if (list!=null && ServerList.this.model==Base.datatype.gamedata)
|
||||||
list.Refresh();
|
list.Refresh();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void failed(Throwable t) {
|
public void failed(Throwable t) {
|
||||||
Array<String> resultstring=new Array<String>();
|
Array<String> resultstring=new Array<String>();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package fr.evolving.UI;
|
package fr.evolving.UI;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.List;
|
import com.badlogic.gdx.scenes.scene2d.ui.List;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
@ -15,10 +16,11 @@ public class Worldlist extends List {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Refresh() {
|
public void Refresh() {
|
||||||
Array<String> worlds=AssetLoader.Datahandler.game().getworlds();
|
Array<String> worlds=null;
|
||||||
String world=Preference.prefs.getString("world");
|
if (AssetLoader.Datahandler.game()!=null)
|
||||||
if (!worlds.contains(world, false))
|
worlds=AssetLoader.Datahandler.game().getworlds();
|
||||||
worlds.add(world);
|
if (worlds==null)
|
||||||
|
worlds=new Array<String>();
|
||||||
this.setItems(worlds);
|
this.setItems(worlds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,9 +208,18 @@ public class AssetLoader {
|
||||||
|
|
||||||
public static void Databasemanagerfrompref() {
|
public static void Databasemanagerfrompref() {
|
||||||
Datahandler.CloseAll();
|
Datahandler.CloseAll();
|
||||||
Datahandler.Attach(datatype.userdata, Preference.prefs.getString("userdata"));
|
if (Datahandler.Attach(datatype.userdata, Preference.prefs.getString("userdata")))
|
||||||
Datahandler.Attach(datatype.statdata, Preference.prefs.getString("statdata"));
|
Gdx.app.debug("AssetLoader","Base user ok");
|
||||||
Datahandler.Attach(datatype.gamedata, Preference.prefs.getString("gamedata"));
|
else
|
||||||
|
Gdx.app.debug("AssetLoader","Base user erreur");
|
||||||
|
if (Datahandler.Attach(datatype.statdata, Preference.prefs.getString("statdata")))
|
||||||
|
Gdx.app.debug("AssetLoader","Base stat ok");
|
||||||
|
else
|
||||||
|
Gdx.app.debug("AssetLoader","Base stat erreur");
|
||||||
|
if (Datahandler.Attach(datatype.gamedata, Preference.prefs.getString("gamedata")))
|
||||||
|
Gdx.app.debug("AssetLoader","Base jeu ok");
|
||||||
|
else
|
||||||
|
Gdx.app.debug("AssetLoader","Base jeu erreur");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Transmuter getTransmuter(String Name) {
|
public static Transmuter getTransmuter(String Name) {
|
||||||
|
|
|
@ -25,6 +25,10 @@ public class DatabaseManager {
|
||||||
return bases[Base.datatype.gamedata.ordinal()];
|
return bases[Base.datatype.gamedata.ordinal()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean verifyall() {
|
||||||
|
return (bases[0]!=null && bases[1]!=null && bases[2]!=null);
|
||||||
|
}
|
||||||
|
|
||||||
public DatabaseManager(){
|
public DatabaseManager(){
|
||||||
bases=new Base[3];
|
bases=new Base[3];
|
||||||
old=new String[3];
|
old=new String[3];
|
||||||
|
@ -53,8 +57,12 @@ public class DatabaseManager {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
bases[model.ordinal()]=null;
|
||||||
|
old[model.ordinal()]=null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Base getBackend(Base.datatype model, String Url) {
|
public Base getBackend(Base.datatype model, String Url) {
|
||||||
String Type=Url.split(":")[0];
|
String Type=Url.split(":")[0];
|
||||||
|
@ -64,9 +72,11 @@ public class DatabaseManager {
|
||||||
for(Class<?> classe:backends) {
|
for(Class<?> classe:backends) {
|
||||||
Base back;
|
Base back;
|
||||||
try {
|
try {
|
||||||
|
back = (Base) classe.newInstance();
|
||||||
|
if (back.getprefix().equals(Type)) {
|
||||||
back = (Base) classe.getDeclaredConstructor(cArg).newInstance(model,Url);
|
back = (Base) classe.getDeclaredConstructor(cArg).newInstance(model,Url);
|
||||||
if (back.getprefix().equals(Type))
|
|
||||||
return back;
|
return back;
|
||||||
|
}
|
||||||
} catch (InstantiationException | IllegalAccessException
|
} catch (InstantiationException | IllegalAccessException
|
||||||
| IllegalArgumentException | InvocationTargetException
|
| IllegalArgumentException | InvocationTargetException
|
||||||
| NoSuchMethodException | SecurityException e) {
|
| NoSuchMethodException | SecurityException e) {
|
||||||
|
|
|
@ -20,6 +20,7 @@ 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 com.badlogic.gdx.utils.Base64Coder;
|
||||||
|
|
||||||
import fr.evolving.assets.AssetLoader;
|
import fr.evolving.assets.AssetLoader;
|
||||||
import fr.evolving.automata.Grid;
|
import fr.evolving.automata.Grid;
|
||||||
|
@ -51,26 +52,35 @@ public class LocalBase extends Base {
|
||||||
switch(Gdx.app.getType()) {
|
switch(Gdx.app.getType()) {
|
||||||
case Android:
|
case Android:
|
||||||
try {
|
try {
|
||||||
FileChannel source = ((FileInputStream) Gdx.files.internal("bases/"+databasename).read()).getChannel();
|
if (!Gdx.files.absolute("/data/data/fr.evolving.game.android/databases/"+databasename).exists()) {
|
||||||
FileChannel destination = new FileOutputStream("/data/data/fr.evolving.game.android/databases/"+databasename).getChannel();
|
Gdx.app.log("Base", "Copie de la base de donnee android");
|
||||||
destination.transferFrom(source, 0, source.size());
|
byte[] ByteSource = Gdx.files.internal("bases/"+databasename).readBytes();
|
||||||
source.close();
|
FileOutputStream destination = new FileOutputStream("/data/data/fr.evolving.game.android/databases/"+databasename);
|
||||||
|
destination.write(ByteSource);
|
||||||
destination.close();
|
destination.close();
|
||||||
|
}
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case Desktop:
|
case Desktop:
|
||||||
|
Gdx.app.log("Base", "Copie de la base de donnee desktop");
|
||||||
FileHandle newbase=Gdx.files.local(databasename);
|
FileHandle newbase=Gdx.files.local(databasename);
|
||||||
|
try {
|
||||||
if (!newbase.exists())
|
if (!newbase.exists())
|
||||||
Gdx.files.internal("bases/"+databasename).copyTo(newbase);
|
Gdx.files.internal("bases/"+databasename).copyTo(newbase);
|
||||||
|
} catch (Exception e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
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
|
||||||
{
|
{
|
||||||
Gdx.app.log("Local", "Utilisation de la base '"+databasename+"', table:"+model.toString());
|
Gdx.app.log("Local", "Utilisation de la base '"+databasename+"', table:"+model.toString());
|
||||||
dbHandler = DatabaseFactory.getNewDatabase(databasename,1, "", null);
|
dbHandler = DatabaseFactory.getNewDatabase(databasename,1, null, null);
|
||||||
dbHandler.setupDatabase();
|
dbHandler.setupDatabase();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -78,6 +88,7 @@ public class LocalBase extends Base {
|
||||||
}
|
}
|
||||||
catch (SQLiteGdxException e) {
|
catch (SQLiteGdxException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Gdx.app.log("Local", "Erreur à l'ouverture de la base");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -88,7 +99,6 @@ public class LocalBase extends Base {
|
||||||
dbHandler.execSQL("CREATE TABLE if not exists grids(date DATETIME DEFAULT CURRENT_TIMESTAMP, level INTEGER NOT NULL, user INTEGER NOT NULL, object TEXT, PRIMARY KEY(level,user,date));");
|
dbHandler.execSQL("CREATE TABLE if not exists grids(date DATETIME DEFAULT CURRENT_TIMESTAMP, level INTEGER NOT NULL, user INTEGER NOT NULL, object TEXT, PRIMARY KEY(level,user,date));");
|
||||||
dbHandler.execSQL("CREATE TABLE if not exists transmuters(date DATETIME DEFAULT CURRENT_TIMESTAMP, user INTEGER NOT NULL, object TEXT, PRIMARY KEY(user));");
|
dbHandler.execSQL("CREATE TABLE if not exists transmuters(date DATETIME DEFAULT CURRENT_TIMESTAMP, user INTEGER NOT NULL, object TEXT, PRIMARY KEY(user));");
|
||||||
dbHandler.execSQL("CREATE TABLE if not exists research(date DATETIME DEFAULT CURRENT_TIMESTAMP, user INTEGER NOT NULL, value INT, PRIMARY KEY(user));");
|
dbHandler.execSQL("CREATE TABLE if not exists research(date DATETIME DEFAULT CURRENT_TIMESTAMP, user INTEGER NOT NULL, value INT, PRIMARY KEY(user));");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dbHandler.execSQL("CREATE TABLE if not exists worlds(date DATETIME DEFAULT CURRENT_TIMESTAMP, desc TEXT NOT NULL, object TEXT, PRIMARY KEY(desc));");
|
dbHandler.execSQL("CREATE TABLE if not exists worlds(date DATETIME DEFAULT CURRENT_TIMESTAMP, desc TEXT NOT NULL, object TEXT, PRIMARY KEY(desc));");
|
||||||
|
@ -122,7 +132,9 @@ public class LocalBase extends Base {
|
||||||
Level[] mc=null;
|
Level[] mc=null;
|
||||||
if (cursor.next())
|
if (cursor.next())
|
||||||
try {
|
try {
|
||||||
byte[] bytes = DatatypeConverter.parseBase64Binary(cursor.getString(0));
|
Gdx.app.debug(getClass().getSimpleName(),"TEST2");
|
||||||
|
byte[] bytes = Base64Coder.decodeLines(cursor.getString(0));
|
||||||
|
Gdx.app.debug(getClass().getSimpleName(),"TEST3");
|
||||||
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
|
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
|
||||||
ObjectInputStream ins = new ObjectInputStream(bais);
|
ObjectInputStream ins = new ObjectInputStream(bais);
|
||||||
mc=(Level[]) ins.readObject();
|
mc=(Level[]) ins.readObject();
|
||||||
|
@ -154,7 +166,7 @@ public class LocalBase extends Base {
|
||||||
oos.close();
|
oos.close();
|
||||||
bos.close();
|
bos.close();
|
||||||
byte[] bytes = bos.toByteArray();
|
byte[] bytes = bos.toByteArray();
|
||||||
encoded = DatatypeConverter.printBase64Binary(bytes);
|
encoded = Base64Coder.encodeLines(bytes);
|
||||||
dbHandler.rawQuery("replace into worlds (desc,object) values ('"+description+"','"+encoded+"');");
|
dbHandler.rawQuery("replace into worlds (desc,object) values ('"+description+"','"+encoded+"');");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -7,7 +7,10 @@ import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.actions.Actions.*;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Button;
|
import com.badlogic.gdx.scenes.scene2d.ui.Button;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.List;
|
import com.badlogic.gdx.scenes.scene2d.ui.List;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||||
|
@ -30,6 +33,7 @@ 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.WarnDialog;
|
||||||
import fr.evolving.UI.Worldlist;
|
import fr.evolving.UI.Worldlist;
|
||||||
import fr.evolving.game.main;
|
import fr.evolving.game.main;
|
||||||
|
|
||||||
|
@ -55,8 +59,10 @@ public class LevelScreen implements Screen {
|
||||||
private TimerTask ScrollTask;
|
private TimerTask ScrollTask;
|
||||||
private Stage stage;
|
private Stage stage;
|
||||||
private Table table;
|
private Table table;
|
||||||
|
private WarnDialog dialog;
|
||||||
private ImageButton Previous,Next,Exit;
|
private ImageButton Previous,Next,Exit;
|
||||||
public ImageButton logosmall,MenuSolo,MenuMulti,MenuScenario;
|
public ImageButton logosmall;
|
||||||
|
public Image MenuSolo,MenuMulti,MenuScenario;
|
||||||
private ImageTextButton cout,tech,cycle,temp,rayon,nrj;
|
private ImageTextButton cout,tech,cycle,temp,rayon,nrj;
|
||||||
private TextButton buttonConnect,buttonPlay,buttonStat,buttonSave, buttonApply, buttonPlaythis;
|
private TextButton buttonConnect,buttonPlay,buttonStat,buttonSave, buttonApply, buttonPlaythis;
|
||||||
private ServerList Statdata,Userdata,Gamedata;
|
private ServerList Statdata,Userdata,Gamedata;
|
||||||
|
@ -79,6 +85,10 @@ public class LevelScreen implements Screen {
|
||||||
|
|
||||||
public void play() {
|
public void play() {
|
||||||
//thelevels= InitWorlds.go();
|
//thelevels= InitWorlds.go();
|
||||||
|
if (!AssetLoader.Datahandler.verifyall())
|
||||||
|
Gdx.app.debug(getClass().getSimpleName(),"Pilotes de bases de donnée défaillant.");
|
||||||
|
else
|
||||||
|
{
|
||||||
Gdx.app.debug(getClass().getSimpleName(),"Chargement des mondes depuis la base.");
|
Gdx.app.debug(getClass().getSimpleName(),"Chargement des mondes depuis la base.");
|
||||||
try {
|
try {
|
||||||
if (world<0)
|
if (world<0)
|
||||||
|
@ -97,6 +107,7 @@ public class LevelScreen implements Screen {
|
||||||
TextDescriptive.setVisible(false);
|
TextDescriptive.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void menu() {
|
public void menu() {
|
||||||
selected=null;
|
selected=null;
|
||||||
|
@ -128,6 +139,38 @@ public class LevelScreen implements Screen {
|
||||||
Worlddata.setVisible(false);
|
Worlddata.setVisible(false);
|
||||||
buttonSave.setVisible(false);
|
buttonSave.setVisible(false);
|
||||||
buttonApply.setVisible(false);
|
buttonApply.setVisible(false);
|
||||||
|
initlevel();
|
||||||
|
MenuSolo.setRotation(0);
|
||||||
|
MenuSolo.setScale(1f);
|
||||||
|
MenuSolo.setColor(1f, 1f, 1f, 1f);
|
||||||
|
MenuSolo.setPosition(0, AssetLoader.height*17/20-300);
|
||||||
|
MenuMulti.setRotation(0);
|
||||||
|
MenuMulti.setScale(1f);
|
||||||
|
MenuMulti.setColor(1f, 1f, 1f, 1f);
|
||||||
|
MenuMulti.setPosition(0, AssetLoader.height*12/20-300);
|
||||||
|
MenuScenario.setRotation(0);
|
||||||
|
MenuScenario.setScale(1f);
|
||||||
|
MenuScenario.setColor(1f, 1f, 1f, 1f);
|
||||||
|
MenuScenario.setPosition(0, AssetLoader.height*7/20-300);
|
||||||
|
MenuSolo.addAction(Actions.sequence(Actions.moveTo((AssetLoader.width-MenuSolo.getWidth())/2, AssetLoader.height*17/20-300, 0.25f)));
|
||||||
|
MenuMulti.addAction(Actions.sequence(Actions.fadeIn(0.1f),Actions.moveTo((AssetLoader.width-MenuMulti.getWidth())/2, AssetLoader.height*12/20-300, 0.25f)));
|
||||||
|
MenuScenario.addAction(Actions.sequence(Actions.fadeIn(0.2f),Actions.moveTo((AssetLoader.width-MenuScenario.getWidth())/2, AssetLoader.height*7/20-300, 0.25f)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initlevel() {
|
||||||
|
selected=null;
|
||||||
|
buttonPlay.setVisible(false);
|
||||||
|
TextDescriptive.setVisible(false);
|
||||||
|
cout.setVisible(false);
|
||||||
|
tech.setVisible(false);
|
||||||
|
cycle.setVisible(false);
|
||||||
|
temp.setVisible(false);
|
||||||
|
rayon.setVisible(false);
|
||||||
|
nrj.setVisible(false);
|
||||||
|
Previous.setVisible(false);
|
||||||
|
Next.setVisible(false);
|
||||||
|
Victory.setVisible(false);
|
||||||
if (buttonLevels!=null)
|
if (buttonLevels!=null)
|
||||||
for (int j=0;j<10;j++)
|
for (int j=0;j<10;j++)
|
||||||
if (buttonLevels[j]!=null) {
|
if (buttonLevels[j]!=null) {
|
||||||
|
@ -149,7 +192,7 @@ public class LevelScreen implements Screen {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetButtonConnect() {
|
public void SetButtonConnect() {
|
||||||
buttonStat.setColor(buttonConnect.getColor());
|
buttonStat.setColor(1f,1f,1f,1f);
|
||||||
buttonConnect.setColor(1f,0,0,1f);
|
buttonConnect.setColor(1f,0,0,1f);
|
||||||
Statdata.setVisible(true);
|
Statdata.setVisible(true);
|
||||||
Userdata.setVisible(true);
|
Userdata.setVisible(true);
|
||||||
|
@ -165,7 +208,8 @@ public class LevelScreen implements Screen {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetButtonStat() {
|
public void SetButtonStat() {
|
||||||
buttonConnect.setColor(buttonStat.getColor());
|
buttonConnect.setColor(1f,1f,1f,1f);
|
||||||
|
buttonStat.setColor(1f,0,0,1f);
|
||||||
buttonStat.setColor(1f,0,0,1f);
|
buttonStat.setColor(1f,0,0,1f);
|
||||||
Statdata.setVisible(false);
|
Statdata.setVisible(false);
|
||||||
Userdata.setVisible(false);
|
Userdata.setVisible(false);
|
||||||
|
@ -235,6 +279,7 @@ public class LevelScreen implements Screen {
|
||||||
stage = new Stage(AssetLoader.viewport);
|
stage = new Stage(AssetLoader.viewport);
|
||||||
table = new Table();
|
table = new Table();
|
||||||
Renderer=new LevelRenderer(this);
|
Renderer=new LevelRenderer(this);
|
||||||
|
dialog=new WarnDialog(AssetLoader.Skin_ui);
|
||||||
Gdx.app.debug(getClass().getSimpleName(),"Mise en place du timer.");
|
Gdx.app.debug(getClass().getSimpleName(),"Mise en place du timer.");
|
||||||
ScrollTimer=new Timer();
|
ScrollTimer=new Timer();
|
||||||
ScrollTask = new TimerTask()
|
ScrollTask = new TimerTask()
|
||||||
|
@ -247,17 +292,48 @@ public class LevelScreen implements Screen {
|
||||||
};
|
};
|
||||||
ScrollTimer.scheduleAtFixedRate(ScrollTask, 0, 30);
|
ScrollTimer.scheduleAtFixedRate(ScrollTask, 0, 30);
|
||||||
Gdx.app.debug(getClass().getSimpleName(),"Création du menu.");
|
Gdx.app.debug(getClass().getSimpleName(),"Création du menu.");
|
||||||
MenuSolo=new ImageButton(AssetLoader.Skin_level,"MenuSolo");
|
MenuSolo=new Image(AssetLoader.Skin_level,"menu1");
|
||||||
MenuSolo.setPosition((AssetLoader.width-MenuSolo.getWidth())/2, AssetLoader.height-550);
|
MenuSolo.setOrigin(MenuSolo.getWidth()/2, MenuSolo.getHeight()/2);
|
||||||
MenuSolo.addListener(new ClickListener() {
|
MenuSolo.addListener(new ClickListener() {
|
||||||
public void clicked(InputEvent event, float x, float y) {
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
|
MenuMulti.addAction(Actions.fadeOut(0.5f));
|
||||||
|
MenuScenario.addAction(Actions.fadeOut(0.5f));
|
||||||
|
MenuSolo.addAction(Actions.sequence(Actions.parallel(Actions.rotateBy(640, 0.5f),Actions.scaleTo(0.05f, 0.05f, 0.5f)),Actions.run(new Runnable() {
|
||||||
|
public void run() {
|
||||||
level();
|
level();
|
||||||
}
|
}
|
||||||
|
})));
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
MenuMulti=new Image(AssetLoader.Skin_level,"menu2");
|
||||||
|
MenuMulti.setOrigin(MenuMulti.getWidth()/2, MenuMulti.getHeight()/2);
|
||||||
|
MenuMulti.addListener(new ClickListener() {
|
||||||
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
|
MenuSolo.addAction(Actions.fadeOut(0.5f));
|
||||||
|
MenuScenario.addAction(Actions.fadeOut(0.5f));
|
||||||
|
MenuMulti.addAction(Actions.sequence(Actions.parallel(Actions.rotateBy(640, 0.5f),Actions.scaleTo(0.05f, 0.05f, 0.5f)),Actions.run(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
level();
|
||||||
|
}
|
||||||
|
})));
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
MenuScenario=new Image(AssetLoader.Skin_level,"menu3");
|
||||||
|
MenuScenario.setOrigin(MenuScenario.getWidth()/2, MenuScenario.getHeight()/2);
|
||||||
|
MenuScenario.addListener(new ClickListener() {
|
||||||
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
|
MenuMulti.addAction(Actions.fadeOut(0.5f));
|
||||||
|
MenuSolo.addAction(Actions.fadeOut(0.5f));
|
||||||
|
MenuScenario.addAction(Actions.sequence(Actions.parallel(Actions.rotateBy(640, 0.5f),Actions.scaleTo(0.05f, 0.05f, 0.5f)),Actions.run(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
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);
|
||||||
|
@ -267,11 +343,29 @@ public class LevelScreen implements Screen {
|
||||||
buttonApply.setBounds(1680, 350, 190, 40);
|
buttonApply.setBounds(1680, 350, 190, 40);
|
||||||
buttonApply.addListener(new ClickListener() {
|
buttonApply.addListener(new ClickListener() {
|
||||||
public void clicked(InputEvent event, float x, float y) {
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
menu();
|
|
||||||
AssetLoader.Datahandler.CloseAll();
|
AssetLoader.Datahandler.CloseAll();
|
||||||
AssetLoader.Datahandler.Attach(Userdata.getModel(),Userdata.getUrl());
|
AssetLoader.Datahandler.Attach(Userdata.getModel(),Userdata.getUrl());
|
||||||
AssetLoader.Datahandler.Attach(Gamedata.getModel(),Gamedata.getUrl());
|
|
||||||
AssetLoader.Datahandler.Attach(Statdata.getModel(),Statdata.getUrl());
|
AssetLoader.Datahandler.Attach(Statdata.getModel(),Statdata.getUrl());
|
||||||
|
AssetLoader.Datahandler.Attach(Gamedata.getModel(),Gamedata.getUrl());
|
||||||
|
if (!AssetLoader.Datahandler.verifyall()) {
|
||||||
|
dialog.Show("Un problème est survenu lors du changement de base de donnée.",stage);
|
||||||
|
initlevel();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
menu();
|
||||||
|
if (AssetLoader.Datahandler.stat()==null)
|
||||||
|
Statdata.setColor(1f,0,0,1f);
|
||||||
|
else
|
||||||
|
Statdata.setColor(1f,1f,1f,1f);
|
||||||
|
if (AssetLoader.Datahandler.game()==null)
|
||||||
|
Gamedata.setColor(1f,0,0,1f);
|
||||||
|
else
|
||||||
|
Gamedata.setColor(1f,1f,1f,1f);
|
||||||
|
if (AssetLoader.Datahandler.user()==null)
|
||||||
|
Userdata.setColor(1f,0,0,1f);
|
||||||
|
else
|
||||||
|
Userdata.setColor(1f,1f,1f,1f);
|
||||||
|
Worlddata.Refresh();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
buttonSave = new TextButton("Sauvegarder", AssetLoader.Skin_ui);
|
buttonSave = new TextButton("Sauvegarder", AssetLoader.Skin_ui);
|
||||||
|
@ -282,6 +376,7 @@ public class LevelScreen implements Screen {
|
||||||
Preference.prefs.putString("userdata", Userdata.getUrl());
|
Preference.prefs.putString("userdata", Userdata.getUrl());
|
||||||
Preference.prefs.putString("gamedata", Gamedata.getUrl());
|
Preference.prefs.putString("gamedata", Gamedata.getUrl());
|
||||||
Preference.prefs.putString("statdata", Statdata.getUrl());
|
Preference.prefs.putString("statdata", Statdata.getUrl());
|
||||||
|
dialog.Show("Vous devez redemarrer pour bénéfier des changements.",stage);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
buttonConnect = new TextButton("Connexions", AssetLoader.Skin_ui);
|
buttonConnect = new TextButton("Connexions", AssetLoader.Skin_ui);
|
||||||
|
@ -312,16 +407,29 @@ public class LevelScreen implements Screen {
|
||||||
buttonPlaythis.setBounds(1480, 50, 190, 40);
|
buttonPlaythis.setBounds(1480, 50, 190, 40);
|
||||||
buttonPlaythis.addListener(new ClickListener() {
|
buttonPlaythis.addListener(new ClickListener() {
|
||||||
public void clicked(InputEvent event, float x, float y) {
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
|
if (!AssetLoader.Datahandler.verifyall())
|
||||||
|
dialog.Show("Impossible de jouer sans bases de données correctement configurée, cliquer sur RAZ si vous ne savez pas revenir à une situation jouable.", stage);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Worlddata.getSelected()==null)
|
||||||
|
dialog.Show("Aucun monde n'a été sélectionné", stage);
|
||||||
|
else
|
||||||
|
{
|
||||||
Preference.prefs.putString("world", (String)Worlddata.getSelected());
|
Preference.prefs.putString("world", (String)Worlddata.getSelected());
|
||||||
Preference.prefs.flush();
|
Preference.prefs.flush();
|
||||||
play();
|
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(){
|
||||||
@Override
|
@Override
|
||||||
public void clicked(InputEvent event, float x, float y) {
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
|
if (Exit.getX()<1210)
|
||||||
|
menu();
|
||||||
|
else
|
||||||
Gdx.app.exit();
|
Gdx.app.exit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -384,7 +492,19 @@ public class LevelScreen implements Screen {
|
||||||
Worlddatalabel.setPosition(1480, 300);
|
Worlddatalabel.setPosition(1480, 300);
|
||||||
Gamedata.setWorldlist(Worlddata);
|
Gamedata.setWorldlist(Worlddata);
|
||||||
Statdata.Refresh();
|
Statdata.Refresh();
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
Userdata.Refresh();
|
Userdata.Refresh();
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
Gamedata.Refresh();
|
Gamedata.Refresh();
|
||||||
Gdx.app.debug(getClass().getSimpleName(),"Affichage du menu.");
|
Gdx.app.debug(getClass().getSimpleName(),"Affichage du menu.");
|
||||||
if (aworld!=-1)
|
if (aworld!=-1)
|
||||||
|
|
Loading…
Reference in New Issue