fix: gestion des résolution plein écran ou non création de préférences par défaut desactivation des résolutions sous android correction bogues affichages
This commit is contained in:
parent
1b5cc4ad5c
commit
5f91eb41ca
|
@ -22,12 +22,14 @@ public class ButtonLevel extends ImageTextButton {
|
|||
TextureRegion Finalled,Locked;
|
||||
Label Thelabel;
|
||||
float scale;
|
||||
float ratio;
|
||||
ImageTextButtonStyle style;
|
||||
LabelStyle stylelabel;
|
||||
|
||||
public ButtonLevel(Level level, boolean Activated) {
|
||||
public ButtonLevel(Level level, boolean Activated,float ratio) {
|
||||
super(level.Name, AssetLoader.Skin_level, "world"+String.valueOf(level.aWorld));
|
||||
this.level=level;
|
||||
this.ratio=ratio;
|
||||
this.Activated=Activated;
|
||||
if (level.Special==true) {
|
||||
Finalled=AssetLoader.Skin_level.getAtlas().findRegion("boss");
|
||||
|
@ -38,17 +40,17 @@ public class ButtonLevel extends ImageTextButton {
|
|||
}
|
||||
this.setColor(1f, 0.47f+(float)level.X/1024f*0.529f,0.607f+(float)level.X/768f*0.392f, 1f);
|
||||
this.scale=1f;
|
||||
this.setBounds(level.X, level.Y*AssetLoader.ratio, 111*scale, 125*scale);
|
||||
this.setBounds(level.X, level.Y*ratio, 111*scale, 125*scale);
|
||||
Thelabel=new Label(level.Element, AssetLoader.Skin_level,"Levelshort");
|
||||
Thelabel.setColor(level.X/1024f,level.X/1024f,level.X/1024f,1f);
|
||||
Thelabel.setPosition(level.X+54*scale, level.Y*AssetLoader.ratio+20*scale, Align.bottom | Align.center);
|
||||
Thelabel.setPosition(level.X+54*scale, level.Y*ratio+20*scale, Align.bottom | Align.center);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScale(float scale) {
|
||||
this.scale=scale;
|
||||
this.setBounds(level.X, level.Y*AssetLoader.ratio, 111*scale, 125*scale);
|
||||
Thelabel.setPosition(level.X+54*scale, level.Y*AssetLoader.ratio+20*scale, Align.bottom | Align.center);
|
||||
this.setBounds(level.X, level.Y*ratio, 111*scale, 125*scale);
|
||||
Thelabel.setPosition(level.X+54*scale, level.Y*ratio+20*scale, Align.bottom | Align.center);
|
||||
stylelabel=Thelabel.getStyle();
|
||||
//stylelabel.font.setScale(scale);
|
||||
Thelabel.setStyle(stylelabel);
|
||||
|
@ -71,7 +73,7 @@ public class ButtonLevel extends ImageTextButton {
|
|||
level.X=x;
|
||||
level.Y=y;
|
||||
Thelabel.setColor(level.X/1024f,level.X/1024f,level.X/1024f,1f);
|
||||
Thelabel.setPosition(level.X+54*scale, level.Y*AssetLoader.ratio+20*scale, Align.bottom | Align.center);
|
||||
Thelabel.setPosition(level.X+54*scale, level.Y*ratio+20*scale, Align.bottom | Align.center);
|
||||
this.setColor(1f, 0.47f+(float)level.X/1024f*0.529f,0.607f+(float)level.X/768f*0.392f, 1f);
|
||||
}
|
||||
|
||||
|
@ -79,10 +81,10 @@ public class ButtonLevel extends ImageTextButton {
|
|||
public void draw(Batch batch, float parentAlpha) {
|
||||
super.draw(batch, parentAlpha);
|
||||
if (level.Special) {
|
||||
batch.draw(Finalled,level.X,level.Y*AssetLoader.ratio,Finalled.getRegionWidth()*scale,Finalled.getRegionHeight()*scale);
|
||||
batch.draw(Finalled,level.X,level.Y*ratio,Finalled.getRegionWidth()*scale,Finalled.getRegionHeight()*scale);
|
||||
}
|
||||
if (!Activated) {
|
||||
batch.draw(Locked,level.X+this.getWidth()-Locked.getRegionWidth(),level.Y*AssetLoader.ratio+this.getHeight()-Locked.getRegionHeight(),Locked.getRegionWidth()*scale,Locked.getRegionHeight()*scale);
|
||||
batch.draw(Locked,level.X+this.getWidth()-Locked.getRegionWidth(),level.Y*ratio+this.getHeight()-Locked.getRegionHeight(),Locked.getRegionWidth()*scale,Locked.getRegionHeight()*scale);
|
||||
}
|
||||
Thelabel.draw(batch, 1f);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package fr.evolving.assets;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Graphics;
|
||||
import com.badlogic.gdx.Graphics.DisplayMode;
|
||||
import com.badlogic.gdx.Preferences;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
public class Preference {
|
||||
public static Preferences prefs;
|
||||
|
@ -13,8 +16,46 @@ public class Preference {
|
|||
if (prefs.contains("log"))
|
||||
return prefs.getInteger("log");
|
||||
else
|
||||
{
|
||||
defaults();
|
||||
return Gdx.app.LOG_INFO;
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector2 getmaxresolution() {
|
||||
Graphics.DisplayMode[] modes=Gdx.graphics.getDisplayModes();
|
||||
int totalpixel=0;
|
||||
int res;
|
||||
for(DisplayMode mode:modes) {
|
||||
int temppixel=mode.height*mode.width;
|
||||
if (temppixel>totalpixel) totalpixel=temppixel;
|
||||
}
|
||||
for(DisplayMode mode:modes)
|
||||
if (totalpixel==mode.height*mode.width)
|
||||
return new Vector2(mode.width,mode.height);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void defaults() {
|
||||
Vector2 maxres=getmaxresolution();
|
||||
Gdx.app.log("Preferences","Preference par defaut avec resolution native :"+maxres.x+"x"+maxres.y);
|
||||
Preference.prefs.putInteger("ResolutionX", (int)maxres.x);
|
||||
Preference.prefs.putInteger("ResolutionY", (int)maxres.y);
|
||||
Preference.prefs.putInteger("Resolution", 9);
|
||||
Preference.prefs.putBoolean("Fullscreen", true);
|
||||
Preference.prefs.putBoolean("Sound", true);
|
||||
Preference.prefs.putBoolean("Tutorial", true);
|
||||
Preference.prefs.putBoolean("VSync", true);
|
||||
Preference.prefs.putBoolean("Refresh", false);
|
||||
Preference.prefs.putBoolean("Animation", true);
|
||||
Preference.prefs.putBoolean("Language", false);
|
||||
Preference.prefs.putFloat("Effect", 1.0f);
|
||||
Preference.prefs.putFloat("Music",0.75f);
|
||||
Preference.prefs.putInteger("Adaptation", 1);
|
||||
Preference.prefs.putInteger("Quality", 2);
|
||||
Preference.prefs.putInteger("log", Gdx.app.LOG_INFO);
|
||||
Preference.prefs.flush();
|
||||
}
|
||||
|
||||
public static void debug() {
|
||||
Preference.prefs.putInteger("ResolutionX", 1280);
|
||||
|
|
|
@ -7,9 +7,11 @@ import java.util.Iterator;
|
|||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import com.badlogic.gdx.Application.ApplicationType;
|
||||
import com.badlogic.gdx.Game;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Graphics.DisplayMode;
|
||||
import com.badlogic.gdx.Graphics;
|
||||
import com.badlogic.gdx.InputMultiplexer;
|
||||
import com.badlogic.gdx.InputProcessor;
|
||||
import com.badlogic.gdx.Screen;
|
||||
|
@ -153,22 +155,36 @@ public class GameScreen implements Screen {
|
|||
rmax("resolution Native",0,0)
|
||||
;
|
||||
private final String text;
|
||||
private final int resx,resy;
|
||||
private int resx,resy;
|
||||
boolean full;
|
||||
private resolutions(final String text,int resx,int resy) {
|
||||
this.text = text;
|
||||
this.resx=resx;
|
||||
this.resy=resy;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
public String toString()
|
||||
{
|
||||
if (full)
|
||||
return text+" Fullscreen";
|
||||
else
|
||||
return text;
|
||||
}
|
||||
public void SetFull(boolean fullscreen) {
|
||||
full=fullscreen;
|
||||
}
|
||||
public int getResolutionX() {
|
||||
return resx;
|
||||
}
|
||||
public int getResolutionY() {
|
||||
return resy;
|
||||
}
|
||||
public void setResolutionX(int x) {
|
||||
resx=x;
|
||||
}
|
||||
public void setResolutionY(int y) {
|
||||
resy=y;
|
||||
}
|
||||
}
|
||||
GestureDetector gesturedetector;
|
||||
|
||||
|
@ -262,7 +278,7 @@ public class GameScreen implements Screen {
|
|||
objectives=new Objectives();
|
||||
objectives.setVictory(level.Victory);
|
||||
objectives.setPosition(890,AssetLoader.height-95);
|
||||
buttonlevel=new ButtonLevel(level,true);
|
||||
buttonlevel=new ButtonLevel(level,true,1.0f);
|
||||
buttonlevel.setPosition(1760,AssetLoader.height-125);
|
||||
Gdx.app.debug(getClass().getSimpleName(),"Création de la barre d'information");
|
||||
info_tech=new ImageTextButton("0",AssetLoader.Skin_level,"info_tech");
|
||||
|
@ -645,7 +661,7 @@ public class GameScreen implements Screen {
|
|||
stage_info.addActor(info_cout);
|
||||
stage_info.addActor(info_desc);
|
||||
stage_menu.addActor(map);
|
||||
stage_tooltip.addActor(tooltip);
|
||||
//stage_tooltip.addActor(tooltip);
|
||||
stage.addActor(objectives);
|
||||
stage.addActor(buttonlevel);
|
||||
stage.addActor(rayon);
|
||||
|
@ -886,7 +902,6 @@ public class GameScreen implements Screen {
|
|||
}
|
||||
|
||||
public Table Createoption() {
|
||||
Table layer = new Table();
|
||||
winOptions = new Window("Options", AssetLoader.Skin_ui);
|
||||
winOptions.add(SettingsVideo()).row();
|
||||
winOptions.add(SettingsAudio()).row();
|
||||
|
@ -997,6 +1012,22 @@ public class GameScreen implements Screen {
|
|||
tablev3.add(selTexturequal).left().row();
|
||||
table.add(tablev3).left();
|
||||
table.row();
|
||||
if(Gdx.app.getType() == ApplicationType.Desktop) {
|
||||
Graphics.DisplayMode[] modes=Gdx.graphics.getDisplayModes();
|
||||
for(resolutions res:resolutions.values()) {
|
||||
res.SetFull(false);
|
||||
for(DisplayMode mode:modes) {
|
||||
if (res.resx==mode.width && res.resy==mode.height)
|
||||
res.SetFull(true);
|
||||
}
|
||||
}
|
||||
Vector2 maxres=Preference.getmaxresolution();
|
||||
resolutions.rmax.SetFull(true);
|
||||
resolutions.rmax.setResolutionX((int)maxres.x);
|
||||
resolutions.rmax.setResolutionY((int)maxres.y);
|
||||
}
|
||||
else
|
||||
selResolution.setDisabled(true);
|
||||
return table;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public class LevelScreen implements Screen {
|
|||
buttonLevels = new ButtonLevel[10];
|
||||
for (Level level :thelevels) {
|
||||
if (level!=null && level.aWorld==aworld) {
|
||||
buttonLevels[i]=new ButtonLevel(level,true);
|
||||
buttonLevels[i]=new ButtonLevel(level,true,AssetLoader.ratio);
|
||||
Gdx.app.debug(getClass().getSimpleName(),"Ajout du niveau :"+level.Name+" N°"+String.valueOf(level.aLevel));
|
||||
buttonLevels[i++].addListener(new ClickListener(){
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue