mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-24 09:00:34 +00:00
Android improvements and version update
This commit is contained in:
parent
f5e5977bbe
commit
3267c2dc23
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.roguetemple.hyperroid"
|
||||
android:versionCode="10003" android:versionName="10.0c"
|
||||
android:versionCode="10005" android:versionName="10.0e"
|
||||
android:installLocation="auto">
|
||||
<!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> -->
|
||||
<!-- <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="9" /> -->
|
||||
|
@ -5,8 +5,11 @@ import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
// import android.graphics.Paint;
|
||||
// import android.graphics.Path;
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.opengl.GLSurfaceView;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
// bimport android.widget.Toast;
|
||||
|
||||
import com.android.texample.GLText;
|
||||
@ -25,7 +28,13 @@ public class HyperRenderer implements GLSurfaceView.Renderer {
|
||||
|
||||
public void onDrawFrame(GL10 gl) {
|
||||
if(game.forceCanvas) return;
|
||||
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
PowerManager pm = (PowerManager) game.getSystemService(Context.POWER_SERVICE);
|
||||
boolean isScreenOn = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH ? pm.isInteractive() : pm.isScreenOn();
|
||||
if(!isScreenOn) return;
|
||||
if(!game.activityVisible) return;
|
||||
|
||||
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
|
||||
synchronized(game) {
|
||||
game.hv.updateGame();
|
||||
game.draw();
|
||||
|
@ -339,10 +339,13 @@ public class HyperRogue extends Activity {
|
||||
int lastland;
|
||||
int curpos[];
|
||||
float curvol;
|
||||
|
||||
|
||||
public static boolean activityVisible = true;
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
activityVisible = false;
|
||||
|
||||
boolean keep;
|
||||
|
||||
@ -392,6 +395,7 @@ public class HyperRogue extends Activity {
|
||||
}
|
||||
|
||||
protected void onResume() {
|
||||
activityVisible = true;
|
||||
super.onResume();
|
||||
if(backgroundmusic != null) {
|
||||
try {backgroundmusic.prepare(); } catch(Exception e) {}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.roguetemple.hyperroid;
|
||||
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
@ -8,6 +9,7 @@ import android.graphics.Path;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
import android.os.SystemClock;
|
||||
import android.util.AttributeSet;
|
||||
@ -169,7 +171,7 @@ public class HyperView extends View {
|
||||
public void updateGame() {
|
||||
lasttick = curtick;
|
||||
curtick = (int)SystemClock.elapsedRealtime();
|
||||
|
||||
|
||||
if(clickcnt > 0) clickcnt--;
|
||||
|
||||
game.update(width, height, curtick, mousex, mousey, clicked | ((clickcnt & 1) > 0));
|
||||
@ -184,9 +186,10 @@ public class HyperView extends View {
|
||||
super.onDraw(canvas);
|
||||
|
||||
PowerManager pm = (PowerManager) game.getSystemService(Context.POWER_SERVICE);
|
||||
boolean isScreenOn = pm.isScreenOn();
|
||||
boolean isScreenOn = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH ? pm.isInteractive() : pm.isScreenOn();
|
||||
if(!isScreenOn) return;
|
||||
|
||||
if(!game.activityVisible) return;
|
||||
|
||||
dc = canvas;
|
||||
width = getWidth();
|
||||
height = getHeight();
|
||||
|
Loading…
Reference in New Issue
Block a user