diff --git a/core/src/fr/evolving/UI/Menu.java b/core/src/fr/evolving/UI/Menu.java index 2650209..8a6271c 100644 --- a/core/src/fr/evolving/UI/Menu.java +++ b/core/src/fr/evolving/UI/Menu.java @@ -61,6 +61,8 @@ public Menu(int tilesizex,int tilesizey) { Gdx.app.debug(getClass().getSimpleName(),"Caméra pour tilemap:"+(tilesizex*size)+"x"+(tilesizey*size)); decx=-102f; decy=-20f; + if (AssetLoader.ratio==1.44f) + decy-=24; camera.translate(decx,decy); Gdx.app.debug(getClass().getSimpleName(),"Décalage:"+decx+"x"+decy); } diff --git a/core/src/fr/evolving/assets/AssetLoader.java b/core/src/fr/evolving/assets/AssetLoader.java index 12f883d..13133cf 100644 --- a/core/src/fr/evolving/assets/AssetLoader.java +++ b/core/src/fr/evolving/assets/AssetLoader.java @@ -7,6 +7,7 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Preferences; import com.badlogic.gdx.assets.AssetManager; import com.badlogic.gdx.assets.loaders.SkinLoader; +import com.badlogic.gdx.assets.loaders.TextureLoader; import com.badlogic.gdx.audio.Music; import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.files.FileHandle; @@ -52,9 +53,10 @@ import fr.evolving.automata.Positiver_I; import fr.evolving.automata.Positiver_II; import fr.evolving.automata.Positiver_III; import fr.evolving.automata.Transmuter; +import fr.evolving.screens.GameScreen; public class AssetLoader { - public static Skin Skin_level; + public static Skin Skin_level,Skin_ui; public static TextureAtlas Atlas_level; public static Texture Texture_fond; public static Texture Texture_fond2; @@ -66,8 +68,6 @@ public class AssetLoader { public static String[] Typenames; public static int height; public static float ratio; - public static boolean stretch=false; - public static Preferences prefs; public static ScalingViewport viewport; public static OrthographicCamera Camera; private static Texture emptyT; @@ -79,71 +79,52 @@ public class AssetLoader { public static Array allTransmuter; public static TooltipManager Tooltipmanager; public static I18NBundle french,usa,language; - - public static void addstyle(TextureAtlas Atlas_level,String Name) { - AtlasRegion AnAtlasRegion = Atlas_level.findRegion(Name); - if (AnAtlasRegion==null) return; - TextureData ATextureData = AnAtlasRegion.getTexture().getTextureData(); - ATextureData.prepare(); - Pixmap Pixmap_Ori=ATextureData.consumePixmap(); - Pixmap Pixmap_Over=new Pixmap(AnAtlasRegion.getRegionWidth(), AnAtlasRegion.getRegionHeight(), Pixmap.Format.RGBA8888); - Pixmap Pixmap_Disable=new Pixmap(AnAtlasRegion.getRegionWidth(), AnAtlasRegion.getRegionHeight(), Pixmap.Format.RGBA8888); - Pixmap Pixmap_Down=new Pixmap(AnAtlasRegion.getRegionWidth(), AnAtlasRegion.getRegionHeight(), Pixmap.Format.RGBA8888); - Color acolor; - for(int x=0; x < AnAtlasRegion.getRegionWidth(); x++) - { - for(int y =0; y < AnAtlasRegion.getRegionHeight(); y++) - { - acolor= new Color(Pixmap_Ori.getPixel(AnAtlasRegion.getRegionX()+x, AnAtlasRegion.getRegionY()+y)); - Pixmap_Down.drawPixel(x, y,Color.rgba8888(acolor.a,0f,0f,acolor.a)); - Pixmap_Disable.drawPixel(x, y, Color.rgba8888(acolor.r*0.352f,acolor.g*0.352f,acolor.b*0.352f,acolor.a)); - Pixmap_Over.drawPixel(x, y, Color.rgba8888(acolor.r,acolor.g*0.2f,acolor.b*0.2f,acolor.a)); - } - } - Atlas_level.addRegion(Name+"_disabled", new TextureRegion(new Texture(Pixmap_Disable))); - Atlas_level.addRegion(Name+"_over", new TextureRegion(new Texture(Pixmap_Over))); - Atlas_level.addRegion(Name+"_down", new TextureRegion(new Texture(Pixmap_Down))); - } + public static TextureFilter quality; public static void loadall() { + TextureLoader.TextureParameter params = new TextureLoader.TextureParameter(); + params.minFilter = quality; + params.magFilter = quality; + params.genMipMaps=(quality==TextureFilter.MipMap); Gdx.app.debug("AssetLoader","Initialisation du asset manager"); manager = new AssetManager(); Gdx.app.debug("AssetLoader","Initialisation du chargement des éléments multimédia"); manager.load("textures/level.pack", TextureAtlas.class); - manager.load("pictures/fond.png", Texture.class); - manager.load("pictures/fond2.png", Texture.class); + manager.load("textures/ui.pack", TextureAtlas.class); + manager.load("pictures/fond.png", Texture.class,params); + manager.load("pictures/fond2.png", Texture.class,params); manager.load("musics/intro.mp3", Music.class); + manager.load("textures/level.json", Skin.class, new SkinLoader.SkinParameter("textures/level.pack")); + manager.load("textures/ui.json", Skin.class, new SkinLoader.SkinParameter("textures/ui.pack")); } public static void finishall() { - Gdx.app.debug("AssetLoader","Ajout des textures disabled,over et down"); - Atlas_level = manager.get("textures/level.pack"); - if (manager.isLoaded("textures/level.pack")) { - for(String toload: new String[]{"leveler0","leveler1","leveler2","leveler3","leveler4","arrows","arrows2","exit2","cout","tech","cycle","temp","nrj","rayon","logo2"}) - addstyle(Atlas_level,toload); - } - Gdx.app.debug("AssetLoader","Chargement des skins et attente fin chargement"); - manager.load("textures/level.json", Skin.class, new SkinLoader.SkinParameter("textures/level.pack")); + Gdx.app.debug("AssetLoader","Attente fin chargement..."); manager.finishLoading(); Gdx.app.debug("AssetLoader","Affectation des éléments multimédia"); + Atlas_level = manager.get("textures/level.pack"); intro = manager.get("musics/intro.mp3"); Texture_fond = manager.get("pictures/fond.png"); Texture_fond.setWrap(TextureWrap.Repeat, TextureWrap.Repeat); + Texture_fond.setFilter(quality, quality); Texture_fond2 = manager.get("pictures/fond2.png"); Texture_fond2.setWrap(TextureWrap.Repeat, TextureWrap.Repeat); + Texture_fond2.setFilter(quality, quality); Skin_level = manager.get("textures/level.json"); - Skin_level.addRegions(Atlas_level); + Skin_ui = manager.get("textures/ui.json"); Gdx.app.debug("AssetLoader","Definition des constantes"); Levelcolors=new Color[5]; - Levelcolors=new Color[]{AssetLoader.Skin_level.getColor("world1"),AssetLoader.Skin_level.getColor("world2"),AssetLoader.Skin_level.getColor("world3"),AssetLoader.Skin_level.getColor("world4"),AssetLoader.Skin_level.getColor("world5")}; + Levelcolors=new Color[]{AssetLoader.Skin_level.getColor("world0"),AssetLoader.Skin_level.getColor("world1"),AssetLoader.Skin_level.getColor("world2"),AssetLoader.Skin_level.getColor("world3"),AssetLoader.Skin_level.getColor("world4")}; Typecolors=new Color[13]; Typecolors=new Color[]{new Color(0,0,1f,1),new Color(0,0.6f,0,1),new Color(0.196f,0.803f,0.196f,1),new Color(0.5f,0.5f,0.5f,1),new Color(0.8f,0.8f,0.8f,1),new Color(0.6f,0,0,1),new Color(1f,0,0,1),new Color(0,0,0.6f,1),new Color(0,0,0.6f,1),new Color(0,0,0.6f,1),new Color(0,0,0.6f,1),new Color(0.294f,0.466f,0.615f,1),new Color(0.478f,0.192f,0.098f,1)}; Typenames=new String[13]; Typenames=new String[]{"E-","e-","Ph","e0","E0","e+","E+","K","L","M","N","n","p"}; - Gdx.app.debug("AssetLoader","Création des tiles..."); + Gdx.app.debug("AssetLoader","Création des tiles..."); tileSet = new TiledMapTileSet(); Array allregions=Atlas_level.getRegions(); + Gdx.app.debug("AssetLoader",allregions.size+" régions disponibles"); for (int i=0;i0 && AssetLoader.prefs.getInteger("ResolutionY")>0) { + if (Preference.prefs.getInteger("ResolutionX")>0 && Preference.prefs.getInteger("ResolutionY")>0) { try { - int ResolutionX=AssetLoader.prefs.getInteger("ResolutionX"); - int ResolutionY=AssetLoader.prefs.getInteger("ResolutionY"); - boolean Fullscreen=AssetLoader.prefs.getBoolean("Fullscreen"); - boolean VSync=AssetLoader.prefs.getBoolean("VSync"); + int ResolutionX=Preference.prefs.getInteger("ResolutionX"); + int ResolutionY=Preference.prefs.getInteger("ResolutionY"); + boolean Fullscreen=Preference.prefs.getBoolean("Fullscreen"); + boolean VSync=Preference.prefs.getBoolean("VSync"); Gdx.graphics.setDisplayMode(ResolutionX, ResolutionY, Fullscreen); Gdx.graphics.setVSync(VSync); } catch (ClassCastException e) { @@ -37,26 +36,6 @@ public class main extends Game { setScreen(new SplashScreen(this)); } - public void debug() { - AssetLoader.prefs.putInteger("ResolutionX", 1280); - AssetLoader.prefs.putInteger("ResolutionY", 720); - AssetLoader.prefs.putBoolean("Fullscreen", false); - AssetLoader.prefs.putBoolean("VSync", false); - AssetLoader.prefs.putInteger("log", Gdx.app.LOG_DEBUG); - Gdx.app.setLogLevel(Gdx.app.LOG_DEBUG); - AssetLoader.prefs.flush(); - } - - public void test() { - AssetLoader.prefs.putInteger("ResolutionX", 1920); - AssetLoader.prefs.putInteger("ResolutionY", 1080); - AssetLoader.prefs.putBoolean("Fullscreen", true); - AssetLoader.prefs.putBoolean("VSync", true); - AssetLoader.prefs.putInteger("log", Gdx.app.LOG_INFO); - Gdx.app.setLogLevel(Gdx.app.LOG_INFO); - AssetLoader.prefs.flush(); - } - @Override public void dispose() { super.dispose(); diff --git a/core/src/fr/evolving/screens/GameScreen.java b/core/src/fr/evolving/screens/GameScreen.java index d54d5af..6364207 100644 --- a/core/src/fr/evolving/screens/GameScreen.java +++ b/core/src/fr/evolving/screens/GameScreen.java @@ -13,8 +13,10 @@ import com.badlogic.gdx.Graphics.DisplayMode; import com.badlogic.gdx.InputMultiplexer; import com.badlogic.gdx.InputProcessor; import com.badlogic.gdx.Screen; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.OrthographicCamera; +import com.badlogic.gdx.graphics.Texture.TextureFilter; import com.badlogic.gdx.input.GestureDetector; import com.badlogic.gdx.maps.MapLayers; import com.badlogic.gdx.maps.MapProperties; @@ -29,16 +31,22 @@ import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputListener; import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup; import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; import com.badlogic.gdx.scenes.scene2d.ui.Label; +import com.badlogic.gdx.scenes.scene2d.ui.SelectBox; +import com.badlogic.gdx.scenes.scene2d.ui.Slider; import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.TextArea; +import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.ui.Tooltip; import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup; +import com.badlogic.gdx.scenes.scene2d.ui.Window; import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener; +import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.badlogic.gdx.utils.Array; @@ -54,6 +62,7 @@ import fr.evolving.UI.ButtonLevel; import fr.evolving.UI.Objectives; import fr.evolving.UI.TouchMaptiles; import fr.evolving.assets.AssetLoader; +import fr.evolving.assets.Preference; import fr.evolving.automata.Level; import fr.evolving.automata.Positiver_I; import fr.evolving.automata.Positiver_II; @@ -75,8 +84,15 @@ public class GameScreen implements Screen { private GameRenderer Renderer; private float runTime; public Level level; + private Window winOptions; private ImageButton[] Barre; - private ImageButton info_up_nrj,info_up_temp,info_up_rayon,info_up_cycle,info_up_nrjval,info_up_tempval,info_up_rayonval,info_up_cycleval; + private CheckBox SetSound,SetVsynch,SetFullscreen,SetAnimation,Settuto,Setdebog,Setrefresh; + private Slider SetEffectvolume,SetMusicvolume; + private TextButton Setcancel,Setsave; + private SelectBox selResolution; + private SelectBox selTexturequal; + private SelectBox selAdaptscreen; + private ImageButton Setflag,info_up_nrj,info_up_temp,info_up_rayon,info_up_cycle,info_up_nrjval,info_up_tempval,info_up_rayonval,info_up_cycleval,SetFlag; private ImageTextButton cycle,temp,nrj,rayon,cout,tech,research,info_cout,info_tech,info_research,info_activation; private ImageTextButton[] Barre2; String[] tocreate={"run","stop","speed","separator","move","zoomp","zoomm","infos","separator","raz","save","levels","tree","exits","separator","screen","sound","tuto","settings","separator","stat"}; @@ -92,6 +108,68 @@ public class GameScreen implements Screen { private TextArea info_desc,tooltip; public boolean unroll,mapexit; public enum calling{mouseover,mouseclick,mousedrag,longpress,tap,taptap,zoom,fling,pan,pinch}; + public enum quality{ + Bas("Bas", TextureFilter.Nearest ), + Moyen("Moyen", TextureFilter.MipMap), + Eleve("Eleve", TextureFilter.Linear) + ; + private final String text; + private final TextureFilter aquality; + private quality(final String text, TextureFilter aquality) { + this.text = text; + this.aquality=aquality; + } + @Override + public String toString() { + return text; + } + public TextureFilter getQuality() { + return this.aquality; + } + }; + public enum adaptation { + fit("Aspect conserve"), + fill("Remplissage") + ; + private final String text; + private adaptation(final String text) { + this.text = text; + } + @Override + public String toString() { + return text; + } + } + public enum resolutions{ + r1024_768("XGA (1024x768) 4:3",1024,768), + r1280_720("720p (1280x720) 16:9",1280,720), + r1280_768("WXGA (1280x768) 5:3",1280,768), + r1280_1024("SXGA (1280x1024) 5:4",1280,1024), + r1400_1050("SXGA+ (1400x1050) 4:3",1400,1050), + r1680_1050("WSXGA (1680x1050) 16:10",1680,1050), + r1600_1200("UXGA (1600x1200) 4:3",1600,1200), + r1920_1080("1080p (1920x1080) 16:9",1920,1080), + r1920_1200("WUXGA (1920x1200) 16:10",1920,1200), + rmax("resolution Native",0,0) + ; + private final String text; + private final int resx,resy; + private resolutions(final String text,int resx,int resy) { + this.text = text; + this.resx=resx; + this.resy=resy; + } + @Override + public String toString() { + return text; + } + public int getResolutionX() { + return resx; + } + public int getResolutionY() { + return resy; + } + } GestureDetector gesturedetector; // This is the constructor, not the class declaration @@ -100,7 +178,7 @@ public class GameScreen implements Screen { table = new HorizontalGroup(); table.bottom().padLeft(5f).padBottom(8f).space(10f); table2 = new VerticalGroup(); - table2.setPosition(AssetLoader.width, AssetLoader.height*2/3); + table2.setPosition(AssetLoader.width, AssetLoader.height-360); table2.right(); table2.space(10f); Gdx.app.debug(getClass().getSimpleName(),"Création des elements primordiaux du screen (stage, renderer, table, level, world)"); @@ -522,9 +600,11 @@ public class GameScreen implements Screen { @Override public void render(float delta) { + stage.act(); runTime += delta; world.update(delta); - fpsLabel.setText(Gdx.graphics.getFramesPerSecond()+"FPS"); + if (Preference.prefs.getBoolean("Refresh")) + fpsLabel.setText(Gdx.graphics.getFramesPerSecond()+"FPS"); Renderer.render(delta, runTime,0); stage_menu.draw(); Renderer.render(delta, runTime,1); @@ -542,6 +622,9 @@ public class GameScreen implements Screen { @Override public void show() { + Gdx.app.debug(getClass().getSimpleName(),"Création de la fenêtre d'option"); + Table Optiontable=Createoption(); + stage.addActor(winOptions); Gdx.app.log("*****","Affichage du niveau."); for (int i=0;i(AssetLoader.Skin_ui); + selResolution.setItems(resolutions.values()); + tablev1.add(selResolution).left().row(); + table.add(tablev1).left(); + table.row(); + + SetFullscreen = new CheckBox("Plein ecran", AssetLoader.Skin_ui); + table.add(SetFullscreen).left(); + Table tablev2 = new Table(); + tablev2.add(new Label("Remplissage de l'ecran:", AssetLoader.Skin_ui, "default-font", Color.WHITE)).left().row(); + selAdaptscreen = new SelectBox(AssetLoader.Skin_ui); + selAdaptscreen.setItems(adaptation.values()); + tablev2.add(selAdaptscreen).left().row(); + table.add(tablev2).left(); + table.row(); + + Table tablev3 = new Table(); + tablev3.add(new Label("Qualite des textures:", AssetLoader.Skin_ui, "default-font", Color.WHITE)).left().row(); + SetAnimation = new CheckBox("Activer les animations", AssetLoader.Skin_ui); + table.add(SetAnimation).left(); + selTexturequal = new SelectBox(AssetLoader.Skin_ui); + selTexturequal.setItems(quality.values()); + tablev3.add(selTexturequal).left().row(); + table.add(tablev3).left(); + table.row(); + return table; + } + + + private Table SettingsAudio() { + Table table = new Table(); + table.pad(10, 10, 0, 10); + table.add(new Label("Audio", AssetLoader.Skin_level, "Fluoxetine-25", Color.ORANGE)).colspan(3); + table.row(); + table.columnDefaults(0).padRight(10); + table.columnDefaults(1).padRight(10); + SetSound = new CheckBox("Activation du son", AssetLoader.Skin_ui); + table.add(SetSound).left(); + table.row(); + table.add(new Label("Volume des effets", AssetLoader.Skin_ui)); + SetEffectvolume = new Slider(0.0f, 1.0f, 0.1f, false, AssetLoader.Skin_ui); + table.add(SetEffectvolume).left(); + table.row(); + table.add(new Label("Volume de la musiques", AssetLoader.Skin_ui)); + SetMusicvolume = new Slider(0.0f, 1.0f, 0.1f, false, AssetLoader.Skin_ui); + table.add(SetMusicvolume).left(); + table.row(); + return table; + } + + private void onSaveClicked() { + winOptions.setVisible(false); + writepref(); + } + + private void onCancelClicked() { + winOptions.setVisible(false); + } + private Table SettingsButtons() { + Table table = new Table(); + table.pad(10, 10, 0, 10); + Setsave = new TextButton("Save", AssetLoader.Skin_ui); + table.add(Setsave).padRight(30); + Setsave.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + onSaveClicked(); + } + }); + Setcancel = new TextButton("Cancel", AssetLoader.Skin_ui); + table.add(Setcancel); + Setcancel.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + onCancelClicked(); + } + }); + return table; + } }