v0.7.4b: Initial LibGDX commit! more details below:

Large sections of game logic are now working through libgdx instead of
android libraries. There is still work to do but this is the first
major step. Big changes include:
- Graphics code is now through LibGDX (except for text rendering)
- Initialization and screen-handling logic is now mostly through LibGDX
- Audio is now through LibGDX
- Input handling is now through LibGDX
- Most misc functions are now through LibGDX
This commit is contained in:
Evan Debenham
2019-07-30 16:50:40 -04:00
parent f10be84a10
commit 2a523f2ea2
42 changed files with 828 additions and 972 deletions

View File

@@ -25,7 +25,8 @@
<activity
android:label="${appName}"
android:name="com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon"
android:screenOrientation="nosensor">
android:screenOrientation="nosensor"
android:configChanges="keyboard|keyboardHidden|orientation">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 B

After

Width:  |  Height:  |  Size: 74 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 B

After

Width:  |  Height:  |  Size: 186 B

View File

@@ -21,12 +21,14 @@
package com.shatteredpixel.shatteredpixeldungeon;
import android.annotation.SuppressLint;
import android.content.pm.ActivityInfo;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.scenes.WelcomeScene;
import com.watabou.noosa.Game;
@@ -35,8 +37,6 @@ import com.watabou.noosa.audio.Music;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.DeviceCompat;
import javax.microedition.khronos.opengles.GL10;
public class ShatteredPixelDungeon extends Game {
//variable constants for specific older versions of shattered, used for data conversion
@@ -108,8 +108,8 @@ public class ShatteredPixelDungeon extends Game {
}
@Override
protected void onCreate( Bundle savedInstanceState ) {
super.onCreate(savedInstanceState);
public void create() {
super.create();
updateSystemUI();
SPDSettings.landscape ( SPDSettings.landscape() );
@@ -118,8 +118,6 @@ public class ShatteredPixelDungeon extends Game {
Music.INSTANCE.volume( SPDSettings.musicVol()/10f );
Sample.INSTANCE.enable( SPDSettings.soundFx() );
Sample.INSTANCE.volume( SPDSettings.SFXVol()/10f );
Music.setMuteListener();
Sample.INSTANCE.load(
Assets.SND_CLICK,
@@ -179,27 +177,6 @@ public class ShatteredPixelDungeon extends Game {
}
@Override
protected void onSaveInstanceState(Bundle outState) {
if (scene instanceof PixelScene){
((PixelScene) scene).saveWindows();
}
super.onSaveInstanceState(outState);
}
@Override
public void onWindowFocusChanged( boolean hasFocus ) {
super.onWindowFocusChanged( hasFocus );
if (hasFocus) updateSystemUI();
}
@Override
@SuppressWarnings("deprecation")
public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
super.onMultiWindowModeChanged(isInMultiWindowMode);
updateSystemUI();
}
public static void switchNoFade(Class<? extends PixelScene> c){
switchNoFade(c, null);
}
@@ -231,14 +208,14 @@ public class ShatteredPixelDungeon extends Game {
}
@Override
public void onSurfaceChanged( GL10 gl, int width, int height ) {
public void resize( int width, int height ) {
if (scene instanceof PixelScene &&
(height != Game.height || width != Game.width)) {
((PixelScene) scene).saveWindows();
}
super.onSurfaceChanged( gl, width, height );
super.resize( width, height );
updateDisplaySize();
@@ -302,31 +279,42 @@ public class ShatteredPixelDungeon extends Game {
}
public static void updateSystemUI() {
boolean fullscreen = Build.VERSION.SDK_INT < Build.VERSION_CODES.N
|| !instance.isInMultiWindowMode();
if (fullscreen){
instance.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
} else {
instance.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
if (DeviceCompat.supportsFullScreen()){
if (fullscreen && SPDSettings.fullscreen()) {
instance.getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION );
} else {
instance.getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE );
instance.runOnUiThread(new Runnable() {
@SuppressLint("NewApi")
@Override
public void run() {
boolean fullscreen = Build.VERSION.SDK_INT < Build.VERSION_CODES.N
|| !instance.isInMultiWindowMode();
if (fullscreen){
instance.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
} else {
instance.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
if (DeviceCompat.supportsFullScreen()){
if (SPDSettings.fullscreen()) {
instance.getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION );
} else {
instance.getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE );
}
}
}
}
});
}
@Override
public void resume() {
super.resume();
updateSystemUI();
}
}

View File

@@ -398,9 +398,9 @@ public abstract class Level implements Bundlable {
bundle.put( ENTRANCE, entrance );
bundle.put( EXIT, exit );
bundle.put( LOCKED, locked );
bundle.put( HEAPS, heaps.values() );
bundle.put( PLANTS, plants.values() );
bundle.put( TRAPS, traps.values() );
bundle.put( HEAPS, heaps.toList() );
bundle.put( PLANTS, plants.toList() );
bundle.put( TRAPS, traps.toList() );
bundle.put( CUSTOM_TILES, customTiles );
bundle.put( CUSTOM_WALLS, customWalls );
bundle.put( MOBS, mobs );

View File

@@ -229,9 +229,8 @@ public class GameScene extends PixelScene {
heaps = new Group();
add( heaps );
int size = Dungeon.level.heaps.size();
for (int i=0; i < size; i++) {
addHeapSprite( Dungeon.level.heaps.valueAt( i ) );
for ( Heap heap : Dungeon.level.heaps.values() ) {
addHeapSprite( heap );
}
emitters = new Group();

View File

@@ -431,9 +431,9 @@ public class DungeonTileSheet {
}
public static int getVisualWithAlts(int visual, int pos){
if (tileVariance[pos] >= 95 && rareAltVisuals.indexOfKey(visual) >= 0)
if (tileVariance[pos] >= 95 && rareAltVisuals.containsKey(visual))
return rareAltVisuals.get(visual);
else if (tileVariance[pos] >= 50 && commonAltVisuals.indexOfKey(visual) >= 0)
else if (tileVariance[pos] >= 50 && commonAltVisuals.containsKey(visual))
return commonAltVisuals.get(visual);
else
return visual;