Начало savemanager
This commit is contained in:
@@ -3,7 +3,6 @@ package com.ea.ironmonkey
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.ActivityManager
|
||||
import android.app.AlertDialog
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.content.pm.PackageManager
|
||||
@@ -11,22 +10,14 @@ import android.content.res.AssetManager
|
||||
import android.content.res.Configuration
|
||||
import android.hardware.SensorManager
|
||||
import android.media.AudioManager
|
||||
import android.net.Uri
|
||||
import android.opengl.GLES20
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.os.Handler
|
||||
import android.os.PowerManager
|
||||
import android.os.PowerManager.WakeLock
|
||||
import android.os.Process
|
||||
import android.provider.Settings
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.DisplayCutout
|
||||
import android.view.KeyEvent
|
||||
import android.view.OrientationEventListener
|
||||
import android.view.View
|
||||
import android.view.ViewParent
|
||||
import android.view.WindowManager
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.FrameLayout
|
||||
@@ -36,17 +27,13 @@ import com.ea.EAMIO.StorageDirectory
|
||||
import com.ea.ironmonkey.Log.d
|
||||
import com.ea.ironmonkey.Log.i
|
||||
import com.ea.ironmonkey.Log.setEnable
|
||||
import com.ea.ironmonkey.Log.w
|
||||
import com.ea.ironmonkey.ObbHelper.getObbFileName
|
||||
import com.ea.ironmonkey.domain.AssetLocationType
|
||||
import com.ea.nimble.ApplicationLifecycle
|
||||
import com.ea.nimble.Global
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import nfs.mod.mpcore.MultiplayerCore.loadCore
|
||||
import org.fmod.FMODAudioDevice
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.util.Locale
|
||||
@@ -152,7 +139,7 @@ class GameActivityMain : AppCompatActivity(), DrawFrameListener {
|
||||
|
||||
external fun nativeOnPause()
|
||||
|
||||
external fun nativeOnPhysicalKeyDown(i: Int, i2: Int)
|
||||
external fun nativeOnPhysicalKeyDown(keyCode: Int, scanCode: Int)
|
||||
|
||||
external fun nativeOnPhysicalKeyUp(i: Int, i2: Int)
|
||||
|
||||
@@ -383,9 +370,6 @@ class GameActivityMain : AppCompatActivity(), DrawFrameListener {
|
||||
i(TAG, "onPause state=$state")
|
||||
super.onPause()
|
||||
mFMODAudioDevice.stop()
|
||||
/*if (mOrientationListener.canDetectOrientation()) {
|
||||
mOrientationListener.disable()
|
||||
}*/
|
||||
gameGLSurfaceView.onPause()
|
||||
ApplicationLifecycle.onActivityPause(this)
|
||||
nativeOnPause()
|
||||
@@ -465,23 +449,19 @@ class GameActivityMain : AppCompatActivity(), DrawFrameListener {
|
||||
ApplicationLifecycle.onActivityResult(i, i2, intent, this)
|
||||
}
|
||||
|
||||
override fun onKeyDown(i: Int, keyEvent: KeyEvent): Boolean {
|
||||
super.onKeyDown(i, keyEvent)
|
||||
override fun onKeyDown(keyCode: Int, keyEvent: KeyEvent): Boolean {
|
||||
super.onKeyDown(keyCode, keyEvent)
|
||||
if (state != 8) {
|
||||
return true
|
||||
}
|
||||
if ((i == 4 || i == 108) && keyEvent.getRepeatCount() > 0) {
|
||||
if ((keyCode == 4 || keyCode == 108) && keyEvent.repeatCount > 0) {
|
||||
return true
|
||||
}
|
||||
val scanCode = keyEvent.getScanCode()
|
||||
gameGLSurfaceView!!.queueEvent(object : Runnable {
|
||||
// from class: com.ea.ironmonkey.GameActivityMain.3
|
||||
// java.lang.Runnable
|
||||
override fun run() {
|
||||
this@GameActivityMain.nativeOnPhysicalKeyDown(i, scanCode)
|
||||
}
|
||||
})
|
||||
return !IsSystemKey(i)
|
||||
val scanCode = keyEvent.scanCode
|
||||
gameGLSurfaceView.queueEvent {
|
||||
nativeOnPhysicalKeyDown(keyCode, scanCode)
|
||||
}
|
||||
return !IsSystemKey(keyCode)
|
||||
}
|
||||
|
||||
override fun onKeyUp(i: Int, keyEvent: KeyEvent): Boolean {
|
||||
@@ -630,7 +610,7 @@ class GameActivityMain : AppCompatActivity(), DrawFrameListener {
|
||||
override fun onDrawFrame(gl10: GL10?) {
|
||||
var inputStream: InputStream?
|
||||
var shouldCleanupSplash = false
|
||||
|
||||
Log.d("state::game", "onDrawFrame state=$state")
|
||||
// Логирование изменения состояния
|
||||
if (state != laststate) {
|
||||
Log.d(TAG, "onDrawFrame state=$state")
|
||||
@@ -639,7 +619,7 @@ class GameActivityMain : AppCompatActivity(), DrawFrameListener {
|
||||
|
||||
when (state) {
|
||||
STATE_SPLASH -> {
|
||||
splash = SplashScreen(this)
|
||||
//splash = SplashScreen(this)
|
||||
splash.init(
|
||||
gl10,
|
||||
gameRenderer.width,
|
||||
@@ -650,51 +630,14 @@ class GameActivityMain : AppCompatActivity(), DrawFrameListener {
|
||||
}
|
||||
|
||||
STATE_SPLASH_PROCESS -> {
|
||||
if (splashCounter > 0) {
|
||||
splashCounter--
|
||||
} else {
|
||||
splashTimer = System.currentTimeMillis() + 2500
|
||||
if (!isAssetsReady) {
|
||||
inputStream = try {
|
||||
assets.open(DOWNLOAD_PROPERTIES)
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
if (inputStream != null) {
|
||||
handler!!.postDelayed({ }, 20L)
|
||||
Log.i(TAG, "state ADC start")
|
||||
state = STATE_ADC_START
|
||||
} else {
|
||||
Log.i(TAG, "STATE_GAME_START 1")
|
||||
state = STATE_GAME_START
|
||||
}
|
||||
} else {
|
||||
Log.i(TAG, "STATE_GAME_START 2")
|
||||
state = STATE_GAME_START
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
STATE_ADC_START -> {
|
||||
Log.i(TAG, "ADC start")
|
||||
// Здесь должен быть код для обработки ADC start
|
||||
// state = ... // переходим в следующее состояние
|
||||
splashTimer = System.currentTimeMillis() + 2000
|
||||
state = STATE_GAME_START
|
||||
}
|
||||
|
||||
STATE_RESTORE_CONTEXT -> {
|
||||
if (splash == null) {
|
||||
splash = SplashScreen(this)
|
||||
splash!!.init(
|
||||
gl10,
|
||||
gameRenderer!!.width,
|
||||
gameRenderer!!.height
|
||||
)
|
||||
splashDelay = System.currentTimeMillis() + 2000
|
||||
}
|
||||
|
||||
if (splashDelay < System.currentTimeMillis() && hasWindowFocus()) {
|
||||
state = if (oldState == STATE_GAME_START) {
|
||||
splashTimer = System.currentTimeMillis() + 300
|
||||
splashTimer = System.currentTimeMillis() + 2000
|
||||
STATE_GAME_START
|
||||
} else {
|
||||
oldState
|
||||
@@ -707,32 +650,15 @@ class GameActivityMain : AppCompatActivity(), DrawFrameListener {
|
||||
isAssetsReady = true
|
||||
nativeOnStart()
|
||||
nativeOnResume()
|
||||
gameRenderer!!.setDrawFrameListener(null)
|
||||
gameRenderer.setDrawFrameListener(null)
|
||||
shouldCleanupSplash = true
|
||||
}
|
||||
}
|
||||
|
||||
// Добавляем обработку остальных состояний
|
||||
STATE_GOOGLE_DRM -> {
|
||||
// Обработка Google DRM
|
||||
}
|
||||
|
||||
STATE_ADC_PROCESS -> {
|
||||
// Обработка ADC процесса
|
||||
}
|
||||
|
||||
STATE_FULL_START -> {
|
||||
// Обработка Full start
|
||||
}
|
||||
|
||||
STATE_FULL_PROCESS -> {
|
||||
// Обработка Full процесса
|
||||
}
|
||||
}
|
||||
|
||||
// Очистка экрана
|
||||
GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f)
|
||||
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT or GLES20.GL_DEPTH_BUFFER_BIT)
|
||||
GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f)
|
||||
//GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT or GLES20.GL_DEPTH_BUFFER_BIT)
|
||||
|
||||
// Отрисовка сплеш-скрина если он существует
|
||||
splash.draw(
|
||||
@@ -742,9 +668,9 @@ class GameActivityMain : AppCompatActivity(), DrawFrameListener {
|
||||
)
|
||||
|
||||
// Очистка сплеш-скрина если нужно
|
||||
if (shouldCleanupSplash) {
|
||||
/*if (shouldCleanupSplash) {
|
||||
splash.destroy(gl10)
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
val totalMemory: Int
|
||||
|
||||
@@ -48,7 +48,7 @@ class SplashScreen(private val activity: Activity) {
|
||||
private var textureId = IntArray(1)
|
||||
|
||||
fun init(gl10: GL10?, width: Int, height: Int) {
|
||||
Log.i("splash", "Я родился!")
|
||||
Log.i(TAG, "init")
|
||||
if (!initRenderer()) {
|
||||
destroy(gl10)
|
||||
return
|
||||
@@ -236,6 +236,7 @@ class SplashScreen(private val activity: Activity) {
|
||||
}
|
||||
|
||||
fun destroy(gl10: GL10?) {
|
||||
Log.i(TAG, "destroy!")
|
||||
if (textureId[0] != 0) {
|
||||
GLES20.glDeleteTextures(1, textureId, 0)
|
||||
textureId[0] = 0
|
||||
|
||||
Reference in New Issue
Block a user