v0.8.0: added window size/fullscreen support to desktop, refactored landscape code
This commit is contained in:
parent
f038bde5cc
commit
b88036da0b
|
@ -62,6 +62,10 @@ public class Scene extends Group {
|
|||
|
||||
}
|
||||
|
||||
public static boolean landscape(){
|
||||
return Game.width > Game.height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
package com.watabou.utils;
|
||||
|
||||
import com.badlogic.gdx.Application;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.watabou.noosa.Game;
|
||||
|
||||
|
@ -34,10 +35,14 @@ public class DeviceCompat {
|
|||
return Gdx.app.getVersion() >= 19;
|
||||
default:
|
||||
//TODO implement functionality for other platforms here
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isDesktop(){
|
||||
return Gdx.app.getType() == Application.ApplicationType.Desktop;
|
||||
}
|
||||
|
||||
public static boolean legacyDevice(){
|
||||
switch (Gdx.app.getType()){
|
||||
case Android:
|
||||
|
|
|
@ -70,12 +70,10 @@ public class AndroidGame extends AndroidApplication {
|
|||
SPDSettings.set(instance.getPreferences("ShatteredPixelDungeon"));
|
||||
|
||||
//set desired orientation (if it exists) before initializing the app.
|
||||
if (SPDSettings.landscapeFromSettings() != null) {
|
||||
if (SPDSettings.landscapeFromSettings()){
|
||||
instance.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
|
||||
} else {
|
||||
instance.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
|
||||
}
|
||||
if (SPDSettings.landscape() != null) {
|
||||
AndroidGame.instance.setRequestedOrientation( SPDSettings.landscape() ?
|
||||
ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE :
|
||||
ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT );
|
||||
}
|
||||
|
||||
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
|
||||
|
|
|
@ -45,11 +45,11 @@ import java.util.regex.Pattern;
|
|||
public class AndroidPlatformSupport extends PlatformSupport {
|
||||
|
||||
public void updateDisplaySize(){
|
||||
boolean landscape = SPDSettings.landscape();
|
||||
|
||||
AndroidGame.instance.setRequestedOrientation(landscape ?
|
||||
ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE :
|
||||
ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
|
||||
if (SPDSettings.landscape() != null) {
|
||||
AndroidGame.instance.setRequestedOrientation( SPDSettings.landscape() ?
|
||||
ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE :
|
||||
ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT );
|
||||
}
|
||||
|
||||
if (AndroidGame.view.getMeasuredWidth() == 0 || AndroidGame.view.getMeasuredHeight() == 0)
|
||||
return;
|
||||
|
@ -57,7 +57,7 @@ public class AndroidPlatformSupport extends PlatformSupport {
|
|||
Game.dispWidth = AndroidGame.view.getMeasuredWidth();
|
||||
Game.dispHeight = AndroidGame.view.getMeasuredHeight();
|
||||
|
||||
if ((Game.dispWidth > Game.dispHeight) != landscape){
|
||||
if ((Game.dispWidth >= Game.dispHeight) != PixelScene.landscape()){
|
||||
int tmp = Game.dispWidth;
|
||||
Game.dispWidth = Game.dispHeight;
|
||||
Game.dispHeight = tmp;
|
||||
|
|
|
@ -71,14 +71,14 @@ public class WndAndroidTextInput extends Window {
|
|||
super();
|
||||
|
||||
//need to offset to give space for the soft keyboard
|
||||
if (SPDSettings.landscape()) {
|
||||
if (PixelScene.landscape()) {
|
||||
offset( multiLine ? -45 : -45 );
|
||||
} else {
|
||||
offset( multiLine ? -60 : -45 );
|
||||
}
|
||||
|
||||
final int width;
|
||||
if (SPDSettings.landscape() && multiLine){
|
||||
if (PixelScene.landscape() && multiLine){
|
||||
width = W_LAND_MULTI; //more editing space for landscape users
|
||||
} else {
|
||||
width = WIDTH;
|
||||
|
|
|
@ -23,10 +23,11 @@ package com.shatteredpixel.shatteredpixeldungeon;
|
|||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Languages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.watabou.noosa.audio.Music;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.utils.GameSettings;
|
||||
import com.watabou.utils.Point;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -69,13 +70,9 @@ public class SPDSettings extends GameSettings {
|
|||
((ShatteredPixelDungeon)ShatteredPixelDungeon.instance).updateDisplaySize();
|
||||
}
|
||||
|
||||
//FIXME in certain multi-window cases this can disagree with the actual screen size
|
||||
//there should be an option to check for landscape the setting, and actual screen size
|
||||
public static boolean landscape() {
|
||||
return getBoolean(KEY_LANDSCAPE, Game.dispWidth > Game.dispHeight);
|
||||
}
|
||||
|
||||
public static Boolean landscapeFromSettings(){
|
||||
//can return null because we need to directly handle the case of landscape not being set
|
||||
// as there are different defaults for different devices
|
||||
public static Boolean landscape(){
|
||||
if (contains(KEY_LANDSCAPE)){
|
||||
return getBoolean(KEY_LANDSCAPE, false);
|
||||
} else {
|
||||
|
@ -154,7 +151,7 @@ public class SPDSettings extends GameSettings {
|
|||
}
|
||||
|
||||
public static String toolbarMode() {
|
||||
return getString(KEY_BARMODE, !SPDSettings.landscape() ? "SPLIT" : "GROUP");
|
||||
return getString(KEY_BARMODE, PixelScene.landscape() ? "GROUP" : "SPLIT");
|
||||
}
|
||||
|
||||
//Game State
|
||||
|
@ -257,4 +254,30 @@ public class SPDSettings extends GameSettings {
|
|||
(language() == Languages.KOREAN || language() == Languages.CHINESE || language() == Languages.JAPANESE));
|
||||
}
|
||||
|
||||
//Window management (desktop only atm)
|
||||
|
||||
public static final String KEY_WINDOW_WIDTH = "window_width";
|
||||
public static final String KEY_WINDOW_HEIGHT = "window_height";
|
||||
public static final String KEY_WINDOW_MAXIMIZED = "window_maximized";
|
||||
|
||||
public static void windowResolution( Point p ){
|
||||
put(KEY_WINDOW_WIDTH, p.x);
|
||||
put(KEY_WINDOW_HEIGHT, p.y);
|
||||
}
|
||||
|
||||
public static Point windowResolution(){
|
||||
return new Point(
|
||||
getInt( KEY_WINDOW_WIDTH, 960 ),
|
||||
getInt( KEY_WINDOW_HEIGHT, 640 )
|
||||
);
|
||||
}
|
||||
|
||||
public static void windowMaximized( boolean value ){
|
||||
put( KEY_WINDOW_MAXIMIZED, value );
|
||||
}
|
||||
|
||||
public static boolean windowMaximized(){
|
||||
return getBoolean( KEY_WINDOW_MAXIMIZED, false );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.scenes;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Flare;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Archs;
|
||||
|
@ -56,9 +55,9 @@ public class AboutScene extends PixelScene {
|
|||
public void create() {
|
||||
super.create();
|
||||
|
||||
final float colWidth = Camera.main.width / (SPDSettings.landscape() ? 2 : 1);
|
||||
final float colTop = (Camera.main.height / 2) - (SPDSettings.landscape() ? 30 : 90);
|
||||
final float wataOffset = SPDSettings.landscape() ? colWidth : 0;
|
||||
final float colWidth = Camera.main.width / (landscape() ? 2 : 1);
|
||||
final float colTop = (Camera.main.height / 2) - (landscape() ? 30 : 90);
|
||||
final float wataOffset = landscape() ? colWidth : 0;
|
||||
|
||||
Image shpx = Icons.SHPX.get();
|
||||
shpx.x = (colWidth - shpx.width()) / 2;
|
||||
|
@ -103,9 +102,7 @@ public class AboutScene extends PixelScene {
|
|||
|
||||
Image wata = Icons.WATA.get();
|
||||
wata.x = wataOffset + (colWidth - wata.width()) / 2;
|
||||
wata.y = SPDSettings.landscape() ?
|
||||
colTop:
|
||||
shpxlink.top() + wata.height + 20;
|
||||
wata.y = landscape() ? colTop: shpxlink.top() + wata.height + 20;
|
||||
align(wata);
|
||||
add( wata );
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
|
@ -258,7 +257,7 @@ public class AlchemyScene extends PixelScene {
|
|||
{
|
||||
WndJournal.AlchemyTab t = new WndJournal.AlchemyTab();
|
||||
int w, h;
|
||||
if (SPDSettings.landscape()) {
|
||||
if (landscape()) {
|
||||
w = WndJournal.WIDTH_L; h = WndJournal.HEIGHT_L;
|
||||
} else {
|
||||
w = WndJournal.WIDTH_P; h = WndJournal.HEIGHT_P;
|
||||
|
|
|
@ -23,7 +23,6 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes;
|
|||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.BadgeBanner;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
|
@ -83,8 +82,8 @@ public class BadgesScene extends PixelScene {
|
|||
blankBadges = Math.max(0, blankBadges);
|
||||
|
||||
//guarantees a max of 5 rows in landscape, and 8 in portrait, assuming a max of 40 buttons
|
||||
int nCols = SPDSettings.landscape() ? 7 : 4;
|
||||
if (badges.size() + blankBadges > 32 && !SPDSettings.landscape()) nCols++;
|
||||
int nCols = landscape() ? 7 : 4;
|
||||
if (badges.size() + blankBadges > 32 && !landscape()) nCols++;
|
||||
|
||||
int nRows = 1 + (blankBadges + badges.size())/nCols;
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public class PixelScene extends Scene {
|
|||
GameScene.scene = null;
|
||||
|
||||
float minWidth, minHeight;
|
||||
if (SPDSettings.landscape()) {
|
||||
if (landscape()) {
|
||||
minWidth = MIN_WIDTH_L;
|
||||
minHeight = MIN_HEIGHT_L;
|
||||
} else {
|
||||
|
|
|
@ -24,7 +24,6 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Journal;
|
||||
|
@ -80,12 +79,12 @@ public class StartScene extends PixelScene {
|
|||
|
||||
ArrayList<GamesInProgress.Info> games = GamesInProgress.checkAll();
|
||||
|
||||
int slotGap = SPDSettings.landscape() ? 5 : 10;
|
||||
int slotGap = landscape() ? 5 : 10;
|
||||
int slotCount = Math.min(GamesInProgress.MAX_SLOTS, games.size()+1);
|
||||
int slotsHeight = slotCount*SLOT_HEIGHT + (slotCount-1)* slotGap;
|
||||
|
||||
float yPos = (h - slotsHeight)/2f;
|
||||
if (SPDSettings.landscape()) yPos += 8;
|
||||
if (landscape()) yPos += 8;
|
||||
|
||||
for (GamesInProgress.Info game : games) {
|
||||
SaveSlotButton existingGame = new SaveSlotButton();
|
||||
|
|
|
@ -24,7 +24,6 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.BannerSprites;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Fireball;
|
||||
|
@ -69,7 +68,7 @@ public class TitleScene extends PixelScene {
|
|||
float topRegion = Math.max(title.height, h*0.45f);
|
||||
|
||||
title.x = (w - title.width()) / 2f;
|
||||
if (SPDSettings.landscape()) {
|
||||
if (landscape()) {
|
||||
title.y = (topRegion - title.height()) / 2f;
|
||||
} else {
|
||||
title.y = 20 + (topRegion - title.height() - 20) / 2f;
|
||||
|
@ -181,11 +180,11 @@ public class TitleScene extends PixelScene {
|
|||
add(btnAbout);
|
||||
|
||||
final int BTN_HEIGHT = 21;
|
||||
int GAP = (int)(h - topRegion - (SPDSettings.landscape() ? 3 : 4)*BTN_HEIGHT)/3;
|
||||
GAP /= SPDSettings.landscape() ? 3 : 4;
|
||||
int GAP = (int)(h - topRegion - (landscape() ? 3 : 4)*BTN_HEIGHT)/3;
|
||||
GAP /= landscape() ? 3 : 4;
|
||||
GAP = Math.max(GAP, 2);
|
||||
|
||||
if (SPDSettings.landscape()) {
|
||||
if (landscape()) {
|
||||
btnPlay.setRect(title.x-50, topRegion+GAP, ((title.width()+100)/2)-1, BTN_HEIGHT);
|
||||
align(btnPlay);
|
||||
btnSupport.setRect(btnPlay.right()+2, btnPlay.top(), btnPlay.width(), BTN_HEIGHT);
|
||||
|
|
|
@ -68,7 +68,7 @@ public class WelcomeScene extends PixelScene {
|
|||
float topRegion = Math.max(title.height, h*0.45f);
|
||||
|
||||
title.x = (w - title.width()) / 2f;
|
||||
if (SPDSettings.landscape()) {
|
||||
if (landscape()) {
|
||||
title.y = (topRegion - title.height()) / 2f;
|
||||
} else {
|
||||
title.y = 20 + (topRegion - title.height() - 20) / 2f;
|
||||
|
|
|
@ -23,7 +23,6 @@ package com.shatteredpixel.shatteredpixeldungeon.windows;
|
|||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem;
|
||||
|
@ -131,7 +130,7 @@ public class WndBag extends WndTabbed {
|
|||
lastMode = mode;
|
||||
lastBag = bag;
|
||||
|
||||
nCols = SPDSettings.landscape() ? COLS_L : COLS_P;
|
||||
nCols = PixelScene.landscape() ? COLS_L : COLS_P;
|
||||
nRows = (int)Math.ceil((Belongings.BACKPACK_SIZE + 4) / (float)nCols);
|
||||
|
||||
int slotsWidth = SLOT_WIDTH * nCols + SLOT_MARGIN * (nCols - 1);
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
|
@ -54,8 +53,8 @@ public class WndDocument extends Window {
|
|||
|
||||
public WndDocument( Document doc ){
|
||||
|
||||
int w = SPDSettings.landscape() ? WIDTH_L : WIDTH_P;
|
||||
int h = SPDSettings.landscape() ? HEIGHT_L : HEIGHT_P;
|
||||
int w = PixelScene.landscape() ? WIDTH_L : WIDTH_P;
|
||||
int h = PixelScene.landscape() ? HEIGHT_L : HEIGHT_P;
|
||||
|
||||
resize(w, h);
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
|
@ -57,7 +56,7 @@ public class WndInfoItem extends Window {
|
|||
|
||||
private void fillFields( Heap heap ) {
|
||||
|
||||
int width = SPDSettings.landscape() ? WIDTH_L : WIDTH_P;
|
||||
int width = PixelScene.landscape() ? WIDTH_L : WIDTH_P;
|
||||
|
||||
IconTitle titlebar = new IconTitle( heap );
|
||||
titlebar.color( TITLE_COLOR );
|
||||
|
@ -81,7 +80,7 @@ public class WndInfoItem extends Window {
|
|||
color = ItemSlot.DEGRADED;
|
||||
}
|
||||
|
||||
int width = SPDSettings.landscape() ? WIDTH_L : WIDTH_P;
|
||||
int width = PixelScene.landscape() ? WIDTH_L : WIDTH_P;
|
||||
|
||||
IconTitle titlebar = new IconTitle( item );
|
||||
titlebar.color( color );
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
|
@ -65,7 +64,7 @@ public class WndItem extends Window {
|
|||
info.maxWidth(width);
|
||||
|
||||
//info box can go out of the screen on landscape, so widen it
|
||||
while (SPDSettings.landscape()
|
||||
while (PixelScene.landscape()
|
||||
&& info.height() > 100
|
||||
&& width < WIDTH_MAX){
|
||||
width += 20;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.armor.ClassArmor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
||||
|
@ -71,8 +70,8 @@ public class WndJournal extends WndTabbed {
|
|||
|
||||
public WndJournal(){
|
||||
|
||||
int width = SPDSettings.landscape() ? WIDTH_L : WIDTH_P;
|
||||
int height = SPDSettings.landscape() ? HEIGHT_L : HEIGHT_P;
|
||||
int width = PixelScene.landscape() ? WIDTH_L : WIDTH_P;
|
||||
int height = PixelScene.landscape() ? HEIGHT_L : HEIGHT_P;
|
||||
|
||||
resize(width, height);
|
||||
|
||||
|
@ -342,7 +341,7 @@ public class WndJournal extends WndTabbed {
|
|||
protected void layout() {
|
||||
super.layout();
|
||||
|
||||
if (SPDSettings.landscape()){
|
||||
if (PixelScene.landscape()){
|
||||
float buttonWidth = width()/pageButtons.length;
|
||||
for (int i = 0; i < NUM_BUTTONS; i++) {
|
||||
pageButtons[i].setRect(i*buttonWidth, 0, buttonWidth, ITEM_HEIGHT);
|
||||
|
|
|
@ -94,18 +94,18 @@ public class WndLangs extends Window {
|
|||
}
|
||||
}
|
||||
btn.setSize(BTN_WIDTH, BTN_HEIGHT);
|
||||
if (SPDSettings.landscape() && i % 2 == 1){
|
||||
if (PixelScene.landscape() && i % 2 == 1){
|
||||
btn.setPos(BTN_WIDTH+1, y-(BTN_HEIGHT + 1));
|
||||
} else {
|
||||
btn.setPos(0, y);
|
||||
y += BTN_HEIGHT;
|
||||
if (SPDSettings.landscape()) y++;
|
||||
if (PixelScene.landscape()) y++;
|
||||
}
|
||||
|
||||
add(btn);
|
||||
}
|
||||
y = Math.max(MIN_HEIGHT, y);
|
||||
resize(SPDSettings.landscape() ? WIDTH_L : WIDTH_P, y);
|
||||
resize(PixelScene.landscape() ? WIDTH_L : WIDTH_P, y);
|
||||
|
||||
int textLeft = width - 65;
|
||||
int textWidth = width - textLeft;
|
||||
|
@ -155,7 +155,7 @@ public class WndLangs extends Window {
|
|||
String[] translators = currLang.translators();
|
||||
|
||||
boolean wide = false;
|
||||
if (SPDSettings.landscape() && (reviewers.length + translators.length) > 10){
|
||||
if (PixelScene.landscape() && (reviewers.length + translators.length) > 10){
|
||||
wide = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
|
@ -37,7 +36,7 @@ public class WndMessage extends Window {
|
|||
super();
|
||||
|
||||
RenderedTextBlock info = PixelScene.renderTextBlock( text, 6 );
|
||||
info.maxWidth((SPDSettings.landscape() ? WIDTH_L : WIDTH_P) - MARGIN * 2);
|
||||
info.maxWidth((PixelScene.landscape() ? WIDTH_L : WIDTH_P) - MARGIN * 2);
|
||||
info.setPos(MARGIN, MARGIN);
|
||||
add( info );
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
||||
|
@ -38,7 +37,7 @@ public class WndOptions extends Window {
|
|||
public WndOptions( String title, String message, String... options ) {
|
||||
super();
|
||||
|
||||
int width = SPDSettings.landscape() ? WIDTH_L : WIDTH_P;
|
||||
int width = PixelScene.landscape() ? WIDTH_L : WIDTH_P;
|
||||
|
||||
RenderedTextBlock tfTitle = PixelScene.renderTextBlock( title, 9 );
|
||||
tfTitle.hardlight( TITLE_COLOR );
|
||||
|
|
|
@ -37,6 +37,7 @@ import com.watabou.noosa.Group;
|
|||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.utils.DeviceCompat;
|
||||
|
||||
//TODO seeing as a fair bit of this is platform-dependant, might be better to have a per-platform wndsettings
|
||||
public class WndSettings extends WndTabbed {
|
||||
|
||||
private static final int WIDTH = 112;
|
||||
|
@ -154,18 +155,18 @@ public class WndSettings extends WndTabbed {
|
|||
add(chkSaver);
|
||||
}
|
||||
|
||||
RedButton btnOrientation = new RedButton( SPDSettings.landscape() ?
|
||||
//TODO need to disable this in some situations. (desktop, android splitscreen)
|
||||
RedButton btnOrientation = new RedButton( PixelScene.landscape() ?
|
||||
Messages.get(this, "portrait")
|
||||
: Messages.get(this, "landscape") ) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
SPDSettings.landscape(!SPDSettings.landscape());
|
||||
SPDSettings.landscape(!PixelScene.landscape());
|
||||
}
|
||||
};
|
||||
btnOrientation.setRect(0, chkSaver.bottom() + GAP_TINY, WIDTH, BTN_HEIGHT);
|
||||
add( btnOrientation );
|
||||
|
||||
|
||||
OptionSlider brightness = new OptionSlider(Messages.get(this, "brightness"),
|
||||
Messages.get(this, "dark"), Messages.get(this, "bright"), -2, 2) {
|
||||
@Override
|
||||
|
@ -267,17 +268,20 @@ public class WndSettings extends WndTabbed {
|
|||
slots.setRect(0, chkFlipTags.bottom() + GAP_TINY, WIDTH, SLIDER_HEIGHT);
|
||||
add(slots);
|
||||
|
||||
CheckBox chkImmersive = new CheckBox( Messages.get(this, "nav_bar") ) {
|
||||
CheckBox chkFullscreen = new CheckBox( Messages.get(this, "nav_bar") ) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
super.onClick();
|
||||
SPDSettings.fullscreen(checked());
|
||||
}
|
||||
};
|
||||
chkImmersive.setRect( 0, slots.bottom() + GAP_SML, WIDTH, BTN_HEIGHT );
|
||||
chkImmersive.checked(SPDSettings.fullscreen());
|
||||
chkImmersive.enable(DeviceCompat.supportsFullScreen());
|
||||
add(chkImmersive);
|
||||
chkFullscreen.setRect( 0, slots.bottom() + GAP_SML, WIDTH, BTN_HEIGHT );
|
||||
chkFullscreen.checked(SPDSettings.fullscreen());
|
||||
if (DeviceCompat.isDesktop()){
|
||||
chkFullscreen.text( "Fullscreen" );
|
||||
}
|
||||
chkFullscreen.enable(DeviceCompat.supportsFullScreen());
|
||||
add(chkFullscreen);
|
||||
|
||||
CheckBox chkFont = new CheckBox(Messages.get(this, "system_font")){
|
||||
@Override
|
||||
|
@ -296,7 +300,7 @@ public class WndSettings extends WndTabbed {
|
|||
});
|
||||
}
|
||||
};
|
||||
chkFont.setRect(0, chkImmersive.bottom() + GAP_TINY, WIDTH, BTN_HEIGHT);
|
||||
chkFont.setRect(0, chkFullscreen.bottom() + GAP_TINY, WIDTH, BTN_HEIGHT);
|
||||
chkFont.checked(SPDSettings.systemFont());
|
||||
add(chkFont);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ package com.shatteredpixel.shatteredpixeldungeon.windows;
|
|||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
||||
|
@ -67,7 +66,7 @@ public class WndStory extends Window {
|
|||
super( 0, 0, Chrome.get( Chrome.Type.SCROLL ) );
|
||||
|
||||
tf = PixelScene.renderTextBlock( text, 6 );
|
||||
tf.maxWidth(SPDSettings.landscape() ?
|
||||
tf.maxWidth(PixelScene.landscape() ?
|
||||
WIDTH_L - MARGIN * 2:
|
||||
WIDTH_P - MARGIN *2);
|
||||
tf.invert();
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
|
@ -44,7 +43,7 @@ public class WndTitledMessage extends Window {
|
|||
|
||||
super();
|
||||
|
||||
int width = SPDSettings.landscape() ? WIDTH_L : WIDTH_P;
|
||||
int width = PixelScene.landscape() ? WIDTH_L : WIDTH_P;
|
||||
|
||||
titlebar.setRect( 0, 0, width, 0 );
|
||||
add(titlebar);
|
||||
|
|
|
@ -31,6 +31,7 @@ import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.utils.FileUtils;
|
||||
import com.watabou.utils.Point;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
@ -94,8 +95,14 @@ public class DesktopLauncher {
|
|||
SPDSettings.set( new Lwjgl3Preferences( "pd-prefs", basePath) );
|
||||
FileUtils.setDefaultFileProperties( Files.FileType.External, basePath );
|
||||
|
||||
config.setWindowSizeLimits( 800, 450, -1, -1 );
|
||||
config.setWindowedMode( 1920, 1080 );
|
||||
config.setWindowSizeLimits( 960, 640, -1, -1 );
|
||||
Point p = SPDSettings.windowResolution();
|
||||
config.setWindowedMode( p.x, p.y );
|
||||
config.setAutoIconify( true );
|
||||
|
||||
//we set fullscreen/maximized in the listener as doing it through the config seems to be buggy
|
||||
DesktopWindowListener listener = new DesktopWindowListener();
|
||||
config.setWindowListener( listener );
|
||||
|
||||
new Lwjgl3Application(new ShatteredPixelDungeon(new DesktopPlatformSupport()), config);
|
||||
}
|
||||
|
|
|
@ -26,8 +26,10 @@ import com.badlogic.gdx.graphics.Pixmap;
|
|||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.PixmapPacker;
|
||||
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.utils.PlatformSupport;
|
||||
import com.watabou.utils.Point;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -36,12 +38,24 @@ public class DesktopPlatformSupport extends PlatformSupport {
|
|||
|
||||
@Override
|
||||
public void updateDisplaySize() {
|
||||
|
||||
if (!SPDSettings.fullscreen()) {
|
||||
SPDSettings.windowResolution( new Point( Game.width, Game.height ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSystemUI() {
|
||||
|
||||
Gdx.app.postRunnable( new Runnable() {
|
||||
@Override
|
||||
public void run () {
|
||||
if (SPDSettings.fullscreen()){
|
||||
Gdx.graphics.setFullscreenMode( Gdx.graphics.getDisplayMode() );
|
||||
} else {
|
||||
Point p = SPDSettings.windowResolution();
|
||||
Gdx.graphics.setWindowedMode( p.x, p.y );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2019 Evan Debenham
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.desktop;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3WindowListener;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
|
||||
public class DesktopWindowListener implements Lwjgl3WindowListener {
|
||||
|
||||
@Override
|
||||
public void created ( Lwjgl3Window lwjgl3Window ) {
|
||||
if (SPDSettings.fullscreen()){
|
||||
lwjgl3Window.postRunnable( new Runnable() {
|
||||
@Override
|
||||
public void run () {
|
||||
Gdx.graphics.setFullscreenMode( Gdx.graphics.getDisplayMode() );
|
||||
}
|
||||
} );
|
||||
}
|
||||
if (SPDSettings.windowMaximized()) {
|
||||
lwjgl3Window.maximizeWindow();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void maximized ( boolean b ) {
|
||||
SPDSettings.windowMaximized( b );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void iconified ( boolean b ) { }
|
||||
public void focusLost () { }
|
||||
public void focusGained () { }
|
||||
public boolean closeRequested () { return true; }
|
||||
public void filesDropped ( String[] strings ) { }
|
||||
public void refreshRequested () { }
|
||||
}
|
Loading…
Reference in New Issue
Block a user