From b743bd62cc82650d8bd2a85d9ad7bfc494d1f171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Fri, 17 Jun 2016 11:41:54 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20ajout=20de=20la=20gestion=20de=20l'upgr?= =?UTF-8?q?ade=20et=20du=20d=C3=A9blocage.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/fr/evolving/UI/Translist.java | 15 +++-- core/src/fr/evolving/dialogs/PrefWindow.java | 9 ++- core/src/fr/evolving/dialogs/UpDialog.java | 59 +++++++++++++++++++ .../fr/evolving/dialogs/WarningDialog.java | 10 ++-- core/src/fr/evolving/screens/GameScreen.java | 22 ++++++- core/src/fr/evolving/screens/LevelScreen.java | 13 ++-- 6 files changed, 107 insertions(+), 21 deletions(-) create mode 100644 core/src/fr/evolving/dialogs/UpDialog.java diff --git a/core/src/fr/evolving/UI/Translist.java b/core/src/fr/evolving/UI/Translist.java index 5355d3f..89a4dc9 100644 --- a/core/src/fr/evolving/UI/Translist.java +++ b/core/src/fr/evolving/UI/Translist.java @@ -69,8 +69,13 @@ public class Translist extends Actor{ public void setTransmuters(Array transmuters) { this.transmuters=transmuters; - whereis=0; - assignTransmuter(whereis); + whereis=0; + if (transmuters!=null && transmuters.size>0) + assignTransmuter(whereis); + } + + public Array getTransmuters() { + return this.transmuters; } public void assignTransmuter(int where) { @@ -116,7 +121,8 @@ public class Translist extends Actor{ } public void redraw() { - Selected.setBounds(this.getX(), this.getY(), this.getWidth(), this.getHeight()); + if (Selected!=null) + Selected.setBounds(this.getX(), this.getY(), this.getWidth(), this.getHeight()); table.setBounds(this.getX(), this.getY(), this.getWidth(), this.getHeight()); table.clear(); table.add(Previous).left().pad(this.getWidth()/4).padTop(this.getHeight()).size(this.getWidth()/512*64, this.getHeight()/512*64); @@ -154,7 +160,8 @@ public class Translist extends Actor{ @Override public void draw(Batch batch, float parentAlpha) { - Selected.draw(batch, parentAlpha); + if (Selected!=null) + Selected.draw(batch, (float) 1.0); table.draw(batch, parentAlpha); } } diff --git a/core/src/fr/evolving/dialogs/PrefWindow.java b/core/src/fr/evolving/dialogs/PrefWindow.java index 406c1d7..c6ed08b 100644 --- a/core/src/fr/evolving/dialogs/PrefWindow.java +++ b/core/src/fr/evolving/dialogs/PrefWindow.java @@ -54,7 +54,12 @@ public class PrefWindow extends Window { this.setVisible(false); this.pack(); this.setPosition(100, 250); - dialog = new WarningDialog(AssetLoader.Skin_ui); + dialog = new WarningDialog(); + } + + public void show() { + if (dialog.getStage()==null) + this.getParent().getStage().addActor(dialog); } public void refresh() { @@ -202,7 +207,7 @@ public class PrefWindow extends Window { private void onSaveClicked() { this.setVisible(false); writepref(); - dialog.Show(AssetLoader.language.get("[dialog-gamescreen-preference]"), this.getStage()); + dialog.show(AssetLoader.language.get("[dialog-gamescreen-preference]"),this.getStage()); } private void onCancelClicked() { diff --git a/core/src/fr/evolving/dialogs/UpDialog.java b/core/src/fr/evolving/dialogs/UpDialog.java new file mode 100644 index 0000000..9dc0f2d --- /dev/null +++ b/core/src/fr/evolving/dialogs/UpDialog.java @@ -0,0 +1,59 @@ +package fr.evolving.dialogs; + +import com.badlogic.gdx.Input; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.g2d.Batch; +import com.badlogic.gdx.scenes.scene2d.Actor; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.ui.Container; +import com.badlogic.gdx.scenes.scene2d.ui.Dialog; +import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; +import com.badlogic.gdx.scenes.scene2d.ui.Label; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; +import com.badlogic.gdx.utils.Array; + +import fr.evolving.UI.Translist; +import fr.evolving.assets.AssetLoader; +import fr.evolving.automata.Transmuter; + +public class UpDialog extends Dialog { + private Translist translist; + private Container container; + + public UpDialog() { + super(AssetLoader.language.get("[dialog-window]"), AssetLoader.Skin_ui); + translist=new Translist(AssetLoader.allTransmuter, new Color(0.5f,0.5f,0.5f,1f)); + container=new Container(translist); + this.getContentTable().add(container).left(); + this.setModal(true); + this.button("Ok"); + this.key(Input.Keys.ENTER, true); + + } + + public void setTransmuters(Array transmuters) { + translist.setTransmuters(transmuters); + } + + public Array getTransmuters() { + return translist.getTransmuters(); + } + + public void draw(Batch batch, float parentAlpha) + { + super.draw(batch, parentAlpha); + this.getContentTable().draw(batch, parentAlpha); + + //container.draw(batch, parentAlpha); + } + /* + public Actor hit(float x, float y, boolean touchable){ + Actor actor=super.hit(x, y, touchable); + if (actor==null) + return translist.hit(x, y, touchable); + else + return actor; + }*/ + + +} \ No newline at end of file diff --git a/core/src/fr/evolving/dialogs/WarningDialog.java b/core/src/fr/evolving/dialogs/WarningDialog.java index 34a2130..dd0f746 100644 --- a/core/src/fr/evolving/dialogs/WarningDialog.java +++ b/core/src/fr/evolving/dialogs/WarningDialog.java @@ -12,12 +12,10 @@ import fr.evolving.assets.AssetLoader; public class WarningDialog extends Dialog { Label thelabel; - public WarningDialog(Skin skin) { - super(AssetLoader.language.get("[dialog-window]"), skin); + public WarningDialog() { + super(AssetLoader.language.get("[dialog-window]"), AssetLoader.Skin_ui); // TODO Auto-generated constructor stub - this.getContentTable() - .add(new ImageButton(AssetLoader.Skin_level, "Warnerbros")) - .left(); + this.getContentTable().add(new ImageButton(AssetLoader.Skin_level, "Warnerbros")).left(); thelabel = new Label("", AssetLoader.Skin_level); this.getContentTable().add(thelabel).right(); this.setModal(true); @@ -25,7 +23,7 @@ public class WarningDialog extends Dialog { this.key(Input.Keys.ENTER, true); } - public void Show(String info, Stage stage) { + public void show(String info, Stage stage) { this.thelabel.setText(info); this.show(stage); } diff --git a/core/src/fr/evolving/screens/GameScreen.java b/core/src/fr/evolving/screens/GameScreen.java index 08a141b..a708a36 100644 --- a/core/src/fr/evolving/screens/GameScreen.java +++ b/core/src/fr/evolving/screens/GameScreen.java @@ -74,6 +74,7 @@ import fr.evolving.automata.Transmuter.CaseType; import fr.evolving.automata.Worlds; import fr.evolving.dialogs.PrefWindow; import fr.evolving.dialogs.SavingWindow; +import fr.evolving.dialogs.UpDialog; import fr.evolving.dialogs.WarningDialog; import fr.evolving.renderers.GameRenderer; @@ -87,7 +88,8 @@ public class GameScreen implements Screen { public Level level; private PrefWindow winOptions; private SavingWindow winSave; - private ImageButton info_up_nrj, info_up_temp, info_up, info_up_rayon, + private UpDialog updialog; + private ImageButton info_up_nrj, info_up_temp, info_up, info_up2, info_up_rayon, info_up_cycle, info_up_nrjval, info_up_tempval, info_up_rayonval, info_up_cycleval, nextpage, previouspage; private ImageTextButton info_cout, info_tech, info_research, info_activation; @@ -319,6 +321,19 @@ public class GameScreen implements Screen { hideInfo(); } }); + info_up2=new ImageButton(AssetLoader.Skin_level,"evolution2"); + info_up2.setPosition(1450, AssetLoader.height - 720); + info_up2.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + //updialog.setTransmuters(menu.getTransmuter().getUnlock()); + updialog.show(stage); + if (menu.getTransmuter()!=null && menu.getTransmuter().isUnlockable(worlds.ReadResearch())) { + + hideInfo(); + } + } + }); Gdx.app.debug("wirechem-GameScreen", "Création d'une tilemap"); map = new TouchMaptiles(worlds,level, 128, 128); if (Preference.prefs.getBoolean("Grid")) @@ -672,7 +687,8 @@ public class GameScreen implements Screen { @Override public void show() { - Gdx.app.debug("wirechem-GameScreen","Création de la fenêtre d'option"); + Gdx.app.debug("wirechem-GameScreen","Création des fenêtres"); + updialog=new UpDialog(); winOptions = new PrefWindow(); stage.addActor(winOptions); winSave = new SavingWindow(worlds); @@ -698,6 +714,7 @@ public class GameScreen implements Screen { stage_info.addActor(info_nom); stage_info.addActor(info_cout); stage_info.addActor(info_up); + stage_info.addActor(info_up2); stage_info.addActor(info_desc); //stage_tooltip.addActor(tooltip); stage.addActor(horizbar); @@ -887,6 +904,7 @@ public class GameScreen implements Screen { + transmuter.getUpgradeRayon())); info_up_rayonval.setColor(AssetLoader.Levelcolors[2]); info_up.setVisible(transmuter.isUpgradable(worlds.ReadResearch())); + info_up2.setVisible(true); } diff --git a/core/src/fr/evolving/screens/LevelScreen.java b/core/src/fr/evolving/screens/LevelScreen.java index 9463ad9..d5c6215 100644 --- a/core/src/fr/evolving/screens/LevelScreen.java +++ b/core/src/fr/evolving/screens/LevelScreen.java @@ -53,8 +53,7 @@ public class LevelScreen implements Screen { private ImageButton Previous, Next, Exit, logosmall, databaseSave, adder, signer; public Image MenuSolo, MenuMulti, MenuScenario; private ImageTextButton cout, tech, cycle, temp, rayon, nrj, up_cycle, up_temp, up_rayon, up_nrj, research, up; - private TextButton buttonConnect, buttonPlay, buttonStat, buttonSave, - buttonApply, buttonPlaythis; + private TextButton buttonConnect, buttonPlay, buttonStat, buttonSave, buttonApply, buttonPlaythis; private ServerList Statdata, Userdata, Gamedata; private Worldlist Worlddata; private Label Statdatalabel, Userdatalabel, Gamedatalabel, Worlddatalabel; @@ -314,7 +313,7 @@ public class LevelScreen implements Screen { stage = new Stage(AssetLoader.viewport); table = new Table(); Renderer = new LevelRenderer(this); - dialog = new WarningDialog(AssetLoader.Skin_ui); + dialog = new WarningDialog(); Gdx.app.debug("wirechem-LevelScreen", "Mise en place du timer."); ScrollTimer = new Timer(); ScrollTask = new TimerTask() { @@ -427,7 +426,7 @@ public class LevelScreen implements Screen { AssetLoader.Datahandler.Attach(Gamedata.getModel(), Gamedata.getUrl()); if (!AssetLoader.Datahandler.verifyall()) { - dialog.Show(AssetLoader.language.get("[dialog-levelscreen-errorloading]"),stage); + dialog.show(AssetLoader.language.get("[dialog-levelscreen-errorloading]"),stage); initlevel(); } else menu(); @@ -456,7 +455,7 @@ public class LevelScreen implements Screen { Preference.prefs.putString("gamedata", Gamedata.getUrl()); Preference.prefs.putString("statdata", Statdata.getUrl()); Preference.prefs.flush(); - dialog.Show( + dialog.show( AssetLoader.language.get("[dialog-levelscreen-savedatabase]"),stage); } }); @@ -490,10 +489,10 @@ public class LevelScreen implements Screen { buttonPlaythis.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { if (!AssetLoader.Datahandler.verifyall()) - dialog.Show(AssetLoader.language.get("[dialog-levelscreen-errorlevels]"),stage); + dialog.show(AssetLoader.language.get("[dialog-levelscreen-errorlevels]"),stage); else { if (Worlddata.getSelected() == null) - dialog.Show(AssetLoader.language.get("[dialog-levelscreen-errornoworld]"), stage); + dialog.show(AssetLoader.language.get("[dialog-levelscreen-errornoworld]"), stage); else { worlds.set((String) Worlddata.getSelected()); Preference.prefs.flush();