initial files
No files matched your search
@@ -0,0 +1 @@
|
||||
/build
|
||||
@@ -0,0 +1,65 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk 32
|
||||
|
||||
defaultConfig {
|
||||
applicationId "dev.xyze.geodelauncher"
|
||||
minSdk 23
|
||||
targetSdk 32
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
useSupportLibrary true
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '1.8'
|
||||
}
|
||||
buildFeatures {
|
||||
compose true
|
||||
}
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion compose_version
|
||||
}
|
||||
packagingOptions {
|
||||
resources {
|
||||
excludes += '/META-INF/{AL2.0,LGPL2.1}'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation 'androidx.core:core-ktx:1.7.0'
|
||||
implementation "androidx.compose.ui:ui:$compose_version"
|
||||
implementation 'androidx.compose.material3:material3:1.0.0-alpha12'
|
||||
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
|
||||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'
|
||||
implementation 'androidx.activity:activity-compose:1.4.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'com.google.android.material:material:1.6.0'
|
||||
implementation files('../libs/fmod.jar')
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
|
||||
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
|
||||
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="dev.xyze.geodelauncher">
|
||||
|
||||
<queries>
|
||||
<package android:name="com.robtopx.geometryjump" />
|
||||
</queries>
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.wifi"
|
||||
android:required="false" />
|
||||
<uses-feature
|
||||
android:glEsVersion="0x00020000"
|
||||
android:required="true" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:theme="@style/Theme.Geodelauncher"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".GeometryDashActivity"
|
||||
android:exported="false"
|
||||
android:hardwareAccelerated="true"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||
android:windowSoftInputMode="stateAlwaysHidden">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="cocos2dcpp" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:theme="@style/Theme.Geodelauncher">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
After Width: | Height: | Size: 50 KiB |
@@ -0,0 +1,112 @@
|
||||
package com.customRobTop
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.NetworkCapabilities
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
import java.util.*
|
||||
|
||||
|
||||
@Suppress("unused", "UNUSED_PARAMETER")
|
||||
open class BaseRobTopActivity : DefaultRobTopActivity() {
|
||||
companion object {
|
||||
private var isLoaded_ = false
|
||||
lateinit var me: Activity
|
||||
var blockBackButton_ = false
|
||||
private var keyboardActive_ = false
|
||||
|
||||
fun setCurrentActivity(currentActivity: Activity) {
|
||||
me = currentActivity
|
||||
}
|
||||
|
||||
@SuppressLint("HardwareIds")
|
||||
@JvmStatic
|
||||
fun getUserID(): String {
|
||||
// this is how RobTop does it in 2.2, based on the meltdown leaks
|
||||
val androidId = Settings.Secure.getString(me.contentResolver, Settings.Secure.ANDROID_ID)
|
||||
return if ("9774d56d682e549c" != androidId) {
|
||||
UUID.nameUUIDFromBytes(androidId.toByteArray()).toString()
|
||||
} else return UUID.randomUUID().toString()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isNetworkAvailable(): Boolean {
|
||||
val connectivityManager = me.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
|
||||
val activeNetwork = connectivityManager.activeNetwork
|
||||
val networkCapabilities = connectivityManager.getNetworkCapabilities(activeNetwork) ?: return false
|
||||
|
||||
if (networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun setKeyboardState(value: Boolean) {
|
||||
keyboardActive_ = value
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun setBlockBackButton(value: Boolean) {
|
||||
blockBackButton_ = value
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun loadingFinished() {
|
||||
isLoaded_ = true
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun gameServicesIsSignedIn(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
// everyplay doesn't even exist anymore lol
|
||||
@JvmStatic
|
||||
fun isEveryplaySupported(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isRecordingSupported(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun stopRecording() { }
|
||||
|
||||
@JvmStatic
|
||||
fun unlockAchievement(id: String) {}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
me = this
|
||||
|
||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
|
||||
|
||||
hideSystemUi()
|
||||
}
|
||||
|
||||
private fun hideSystemUi() {
|
||||
val windowInsetsController =
|
||||
ViewCompat.getWindowInsetsController(window.decorView) ?: return
|
||||
|
||||
windowInsetsController.systemBarsBehavior =
|
||||
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.customRobTop
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Bundle
|
||||
|
||||
open class DefaultRobTopActivity : Activity() {
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.customRobTop
|
||||
|
||||
object JniToCpp {
|
||||
@JvmStatic
|
||||
external fun didCacheInterstitial(str: String?)
|
||||
|
||||
@JvmStatic
|
||||
external fun didClickInterstitial()
|
||||
|
||||
@JvmStatic
|
||||
external fun didCloseInterstitial()
|
||||
|
||||
@JvmStatic
|
||||
external fun didDismissInterstitial()
|
||||
|
||||
@JvmStatic
|
||||
external fun everyplayRecordingStopped()
|
||||
|
||||
@JvmStatic
|
||||
external fun googlePlaySignedIn()
|
||||
|
||||
@JvmStatic
|
||||
external fun hideLoadingCircle()
|
||||
|
||||
@JvmStatic
|
||||
external fun itemPurchased(str: String)
|
||||
|
||||
@JvmStatic
|
||||
external fun itemRefunded(str: String)
|
||||
|
||||
@JvmStatic
|
||||
external fun promoImageDownloaded()
|
||||
|
||||
@JvmStatic
|
||||
external fun resumeSound()
|
||||
|
||||
@JvmStatic
|
||||
external fun rewardedVideoAdFinished(i: Int)
|
||||
|
||||
@JvmStatic
|
||||
external fun rewardedVideoAdHidden()
|
||||
|
||||
@JvmStatic
|
||||
external fun setupHSSAssets(str: String?, str2: String?)
|
||||
|
||||
@JvmStatic
|
||||
external fun showInterstitialFailed()
|
||||
|
||||
@JvmStatic
|
||||
external fun userDidAttemptToRateApp()
|
||||
|
||||
@JvmStatic
|
||||
external fun videoAdHidden()
|
||||
|
||||
@JvmStatic
|
||||
external fun videoAdShowed()
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.robtopx.geometryjump
|
||||
|
||||
object GJConstants {
|
||||
const val PACKAGE_NAME = "com.robtopx.geometryjump"
|
||||
|
||||
const val COCOS_LIB_NAME = "cocos2dcpp"
|
||||
const val FMOD_LIB_NAME = "fmod"
|
||||
const val MOD_CORE_LIB_NAME = "geode"
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.robtopx.geometryjump
|
||||
|
||||
import dalvik.system.BaseDexClassLoader
|
||||
import java.io.File
|
||||
|
||||
object LaunchUtils {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun addDirectoryToClassPath(directory: String, classLoader: ClassLoader) {
|
||||
// uses code from zhuowei/MCPELauncher
|
||||
try {
|
||||
val clazz = classLoader.javaClass
|
||||
val plField = clazz.superclass.getDeclaredField("pathList")
|
||||
plField.isAccessible = true
|
||||
|
||||
val pathListInst = plField.get(classLoader)
|
||||
val pathListClazz = pathListInst.javaClass
|
||||
val nldField = pathListClazz.getDeclaredField("nativeLibraryDirectories")
|
||||
nldField.isAccessible = true
|
||||
|
||||
val pathList = nldField.get(pathListInst)
|
||||
|
||||
println(pathList)
|
||||
|
||||
if (pathList is ArrayList<*>) {
|
||||
// no safe way to check this type afaik, so casting is needed
|
||||
(pathList as ArrayList<File>).add(
|
||||
File(directory)
|
||||
)
|
||||
}
|
||||
|
||||
if (classLoader is BaseDexClassLoader && classLoader.findLibrary(GJConstants.COCOS_LIB_NAME) == null) {
|
||||
val anpMethod = pathListClazz.getDeclaredMethod("addNativePath", Collection::class.java)
|
||||
|
||||
anpMethod.invoke(
|
||||
pathListInst,
|
||||
listOf(directory)
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package dev.xyze.geodelauncher
|
||||
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.util.Log
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.material3.SnackbarHost
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
import com.customRobTop.BaseRobTopActivity
|
||||
import com.customRobTop.JniToCpp
|
||||
import com.robtopx.geometryjump.GJConstants
|
||||
import com.robtopx.geometryjump.LaunchUtils
|
||||
import dev.xyze.geodelauncher.ui.theme.GeodeLauncherTheme
|
||||
import org.cocos2dx.lib.Cocos2dxGLSurfaceView
|
||||
import org.cocos2dx.lib.Cocos2dxHelper
|
||||
import org.cocos2dx.lib.Cocos2dxRenderer
|
||||
import org.fmod.FMOD
|
||||
|
||||
class GeometryDashActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setupUIState()
|
||||
|
||||
val gdPackageInfo = packageManager.getPackageInfo(GJConstants.PACKAGE_NAME, 0)
|
||||
val gdNativeLibraryPath = "${gdPackageInfo.applicationInfo.nativeLibraryDir}/"
|
||||
|
||||
LaunchUtils.addDirectoryToClassPath(gdNativeLibraryPath, classLoader)
|
||||
|
||||
System.loadLibrary(GJConstants.FMOD_LIB_NAME)
|
||||
System.loadLibrary(GJConstants.COCOS_LIB_NAME)
|
||||
|
||||
val loadSuccess = try {
|
||||
System.loadLibrary(GJConstants.MOD_CORE_LIB_NAME)
|
||||
true
|
||||
} catch (e: UnsatisfiedLinkError) {
|
||||
false
|
||||
}
|
||||
|
||||
FMOD.init(this)
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContent {
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
|
||||
GeodeLauncherTheme {
|
||||
AndroidView(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
factory = {
|
||||
Cocos2dxGLSurfaceView(this).apply {
|
||||
setEGLConfigChooser(5, 6, 5, 0, 16, 8)
|
||||
initView()
|
||||
setCocos2dxRenderer(Cocos2dxRenderer())
|
||||
}
|
||||
}
|
||||
)
|
||||
SnackbarHost(
|
||||
hostState = snackbarHostState,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
|
||||
if (!loadSuccess) {
|
||||
LaunchedEffect(snackbarHostState) {
|
||||
snackbarHostState.showSnackbar("Failed to load mod core.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
JniToCpp.setupHSSAssets(
|
||||
applicationInfo.sourceDir,
|
||||
Environment.getExternalStorageDirectory().absolutePath
|
||||
)
|
||||
Cocos2dxHelper.nativeSetApkPath(gdPackageInfo.applicationInfo.sourceDir)
|
||||
|
||||
BaseRobTopActivity.setCurrentActivity(this)
|
||||
}
|
||||
|
||||
private fun setupUIState() {
|
||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
|
||||
|
||||
hideSystemUi()
|
||||
}
|
||||
|
||||
private fun hideSystemUi() {
|
||||
val windowInsetsController =
|
||||
ViewCompat.getWindowInsetsController(window.decorView) ?: return
|
||||
|
||||
windowInsetsController.systemBarsBehavior =
|
||||
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
FMOD.close()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package dev.xyze.geodelauncher
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.PlayArrow
|
||||
import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.robtopx.geometryjump.GJConstants
|
||||
import dev.xyze.geodelauncher.ui.theme.GeodeLauncherTheme
|
||||
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
val gdInstalled = isGeometryDashInstalled(packageManager)
|
||||
|
||||
setContent {
|
||||
GeodeLauncherTheme {
|
||||
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
|
||||
MainScreen(gdInstalled)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onLaunch(context: Context) {
|
||||
val launchIntent = Intent(context, GeometryDashActivity::class.java)
|
||||
launchIntent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
|
||||
context.startActivity(launchIntent)
|
||||
}
|
||||
|
||||
fun onSettings(context: Context) {
|
||||
Toast.makeText(context, "Settings are not implemented yet!", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
fun isGeometryDashInstalled(packageManager: PackageManager): Boolean {
|
||||
return try {
|
||||
packageManager.getPackageInfo(GJConstants.PACKAGE_NAME, 0)
|
||||
true
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun MainScreen(gdInstalled: Boolean = true) {
|
||||
val context = LocalContext.current
|
||||
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(id = R.drawable.geode_logo),
|
||||
contentDescription = "Geode Logo",
|
||||
modifier = Modifier.size(136.dp, 136.dp)
|
||||
)
|
||||
Text(
|
||||
"Geode",
|
||||
fontSize = 32.sp,
|
||||
modifier = Modifier.padding(12.dp)
|
||||
)
|
||||
if (gdInstalled) {
|
||||
Row {
|
||||
Button(onClick = { onLaunch(context) }, enabled = gdInstalled) {
|
||||
Icon(
|
||||
Icons.Filled.PlayArrow,
|
||||
contentDescription = "Play Icon"
|
||||
)
|
||||
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
|
||||
Text("Launch")
|
||||
}
|
||||
IconButton(onClick = { onSettings(context) }) {
|
||||
Icon(
|
||||
Icons.Filled.Settings,
|
||||
contentDescription = "Settings Icon"
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Text(
|
||||
"Geometry Dash cannot be found.",
|
||||
modifier = Modifier.padding(12.dp)
|
||||
)
|
||||
Button(onClick = { onSettings(context) }) {
|
||||
Icon(
|
||||
Icons.Filled.Settings,
|
||||
contentDescription = "Settings Icon"
|
||||
)
|
||||
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
|
||||
Text("Settings")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(showSystemUi = true)
|
||||
@Composable
|
||||
fun MainScreenLightPreview() {
|
||||
GeodeLauncherTheme {
|
||||
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
|
||||
MainScreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Preview(showSystemUi = true)
|
||||
@Composable
|
||||
fun MainScreenDarkPreview() {
|
||||
GeodeLauncherTheme(darkTheme = true) {
|
||||
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
|
||||
MainScreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun MainScreenNoGeometryDashPreview() {
|
||||
GeodeLauncherTheme {
|
||||
MainScreen(gdInstalled = false)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package dev.xyze.geodelauncher.ui.theme
|
||||
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
||||
val Purple80 = Color(0xFFD0BCFF)
|
||||
val PurpleGrey80 = Color(0xFFCCC2DC)
|
||||
val Pink80 = Color(0xFFEFB8C8)
|
||||
|
||||
val Purple40 = Color(0xFF6650a4)
|
||||
val PurpleGrey40 = Color(0xFF625b71)
|
||||
val Pink40 = Color(0xFF7D5260)
|
||||
@@ -0,0 +1,75 @@
|
||||
package dev.xyze.geodelauncher.ui.theme
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Build
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.darkColorScheme
|
||||
import androidx.compose.material3.dynamicDarkColorScheme
|
||||
import androidx.compose.material3.dynamicLightColorScheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.ui.graphics.toArgb
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.core.view.ViewCompat
|
||||
|
||||
private val DarkColorScheme = darkColorScheme(
|
||||
primary = Purple80,
|
||||
secondary = PurpleGrey80,
|
||||
tertiary = Pink80
|
||||
)
|
||||
|
||||
private val LightColorScheme = lightColorScheme(
|
||||
primary = Purple40,
|
||||
secondary = PurpleGrey40,
|
||||
tertiary = Pink40
|
||||
|
||||
/* Other default colors to override
|
||||
background = Color(0xFFFFFBFE),
|
||||
surface = Color(0xFFFFFBFE),
|
||||
onPrimary = Color.White,
|
||||
onSecondary = Color.White,
|
||||
onTertiary = Color.White,
|
||||
onBackground = Color(0xFF1C1B1F),
|
||||
onSurface = Color(0xFF1C1B1F),
|
||||
*/
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun GeodeLauncherTheme(
|
||||
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||
// Dynamic color is available on Android 12+
|
||||
dynamicColor: Boolean = true,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
val colorScheme = when {
|
||||
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
|
||||
val context = LocalContext.current
|
||||
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
|
||||
}
|
||||
darkTheme -> DarkColorScheme
|
||||
else -> LightColorScheme
|
||||
}
|
||||
|
||||
val view = LocalView.current
|
||||
if (!view.isInEditMode) {
|
||||
SideEffect {
|
||||
with ((view.context as Activity).window) {
|
||||
statusBarColor = colorScheme.background.toArgb()
|
||||
navigationBarColor = colorScheme.background.toArgb()
|
||||
}
|
||||
with (ViewCompat.getWindowInsetsController(view)) {
|
||||
this?.isAppearanceLightStatusBars = !darkTheme
|
||||
this?.isAppearanceLightNavigationBars = !darkTheme
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MaterialTheme(
|
||||
colorScheme = colorScheme,
|
||||
typography = Typography,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package dev.xyze.geodelauncher.ui.theme
|
||||
|
||||
import androidx.compose.material3.Typography
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
||||
// Set of Material typography styles to start with
|
||||
val Typography = Typography(
|
||||
bodyLarge = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Normal,
|
||||
fontSize = 16.sp,
|
||||
lineHeight = 24.sp,
|
||||
letterSpacing = 0.5.sp
|
||||
)
|
||||
/* Other default text styles to override
|
||||
titleLarge = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Normal,
|
||||
fontSize = 22.sp,
|
||||
lineHeight = 28.sp,
|
||||
letterSpacing = 0.sp
|
||||
),
|
||||
labelSmall = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Medium,
|
||||
fontSize = 11.sp,
|
||||
lineHeight = 16.sp,
|
||||
letterSpacing = 0.5.sp
|
||||
)
|
||||
*/
|
||||
)
|
||||
@@ -0,0 +1,116 @@
|
||||
package org.cocos2dx.lib
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import com.customRobTop.BaseRobTopActivity
|
||||
|
||||
|
||||
open class Cocos2dxActivity : BaseRobTopActivity(), Cocos2dxHelper.Cocos2dxHelperListener {
|
||||
private val sTag = Cocos2dxActivity::class.java.simpleName
|
||||
private lateinit var mGLSurfaceView: Cocos2dxGLSurfaceView
|
||||
private var hasWindowFocus = false
|
||||
private var mIsOnPause = false
|
||||
private var mIsRunning = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
init()
|
||||
Cocos2dxHelper.init(this, this)
|
||||
}
|
||||
|
||||
private fun resumeGame() {
|
||||
this.mIsRunning = true
|
||||
mGLSurfaceView.onResume()
|
||||
}
|
||||
|
||||
private fun pauseGame() {
|
||||
this.mIsRunning = false
|
||||
mGLSurfaceView.onPause()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
this.mIsOnPause = false
|
||||
if (this.hasWindowFocus && !this.mIsRunning) {
|
||||
resumeGame()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
this.mIsOnPause = true
|
||||
if (this.mIsRunning) {
|
||||
pauseGame()
|
||||
}
|
||||
}
|
||||
|
||||
override fun showDialog(pTitle: String, pMessage: String) {
|
||||
/*
|
||||
val msg = Message()
|
||||
msg.what = 1
|
||||
msg.obj = DialogMessage(pTitle, pMessage)
|
||||
this.mHandler.sendMessage(msg)
|
||||
*/
|
||||
}
|
||||
|
||||
override fun showEditTextDialog(
|
||||
pTitle: String,
|
||||
pMessage: String,
|
||||
pInputMode: Int,
|
||||
pInputFlag: Int,
|
||||
pReturnType: Int,
|
||||
pMaxLength: Int
|
||||
) {
|
||||
/*
|
||||
val msg = Message()
|
||||
msg.what = 2
|
||||
msg.obj = EditBoxMessage(pTitle, pContent, pInputMode, pInputFlag, pReturnType, pMaxLength)
|
||||
this.mHandler.sendMessage(msg)
|
||||
*/
|
||||
}
|
||||
|
||||
override fun runOnGLThread(pRunnable: Runnable) {
|
||||
mGLSurfaceView.queueEvent(pRunnable)
|
||||
}
|
||||
|
||||
private fun init() {
|
||||
val frameLayoutParams = ViewGroup.LayoutParams(-1, -1)
|
||||
val frameLayout = FrameLayout(this)
|
||||
frameLayout.layoutParams = frameLayoutParams
|
||||
// val edittextLayoutParams = ViewGroup.LayoutParams(-1, -2)
|
||||
// val edittext = Cocos2dxEditText(this)
|
||||
// edittext.setLayoutParams(edittextLayoutParams)
|
||||
// frameLayout.addView(edittext)
|
||||
this.mGLSurfaceView = onCreateView()
|
||||
frameLayout.addView(this.mGLSurfaceView)
|
||||
if (isAndroidEmulator()) {
|
||||
this.mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0)
|
||||
}
|
||||
this.mGLSurfaceView.setCocos2dxRenderer(Cocos2dxRenderer())
|
||||
// edittext.setInputType(145)
|
||||
// this.mGLSurfaceView.setCocos2dxEditText(edittext)
|
||||
setContentView(frameLayout)
|
||||
}
|
||||
|
||||
|
||||
open fun onCreateView(): Cocos2dxGLSurfaceView {
|
||||
val glSurfaceView = Cocos2dxGLSurfaceView(this)
|
||||
glSurfaceView.initView()
|
||||
return glSurfaceView
|
||||
}
|
||||
|
||||
private fun isAndroidEmulator(): Boolean {
|
||||
Log.d(sTag, "model=" + Build.MODEL)
|
||||
val product = Build.PRODUCT
|
||||
Log.d(sTag, "product=$product")
|
||||
var isEmulator = false
|
||||
if (product != null) {
|
||||
isEmulator = product == "sdk" || product.contains("_sdk") || product.contains("sdk_")
|
||||
}
|
||||
Log.d(sTag, "isEmulator=$isEmulator")
|
||||
return isEmulator
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,395 @@
|
||||
package org.cocos2dx.lib
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.*
|
||||
import android.graphics.Paint.FontMetricsInt
|
||||
import android.text.TextPaint
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import android.view.MotionEvent
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import java.util.*
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.ceil
|
||||
|
||||
@Suppress("unused")
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
object Cocos2dxBitmap {
|
||||
private lateinit var sContext: Context
|
||||
private external fun nativeInitBitmapDC(i: Int, i2: Int, bArr: ByteArray)
|
||||
fun setContext(pContext: Context) {
|
||||
sContext = pContext
|
||||
}
|
||||
|
||||
fun createTextBitmap(
|
||||
pString: String,
|
||||
pFontName: String,
|
||||
pFontSize: Int,
|
||||
pAlignment: Int,
|
||||
pWidth: Int,
|
||||
pHeight: Int
|
||||
) {
|
||||
createTextBitmapShadowStroke(
|
||||
pString,
|
||||
pFontName,
|
||||
pFontSize,
|
||||
1.0f,
|
||||
1.0f,
|
||||
1.0f,
|
||||
pAlignment,
|
||||
pWidth,
|
||||
pHeight,
|
||||
false,
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.0f,
|
||||
false,
|
||||
1.0f,
|
||||
1.0f,
|
||||
1.0f,
|
||||
1.0f
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun createTextBitmapShadowStroke(
|
||||
pString: String,
|
||||
pFontName: String,
|
||||
pFontSize: Int,
|
||||
fontTintR: Float,
|
||||
fontTintG: Float,
|
||||
fontTintB: Float,
|
||||
pAlignment: Int,
|
||||
pWidth: Int,
|
||||
pHeight: Int,
|
||||
shadow: Boolean,
|
||||
shadowDX: Float,
|
||||
shadowDY: Float,
|
||||
shadowBlur: Float,
|
||||
stroke: Boolean,
|
||||
strokeR: Float,
|
||||
strokeG: Float,
|
||||
strokeB: Float,
|
||||
strokeSize: Float
|
||||
) {
|
||||
val bitmapTotalHeight: Int
|
||||
val horizontalAlignment = pAlignment and 15
|
||||
val verticalAlignment = pAlignment shr 4 and 15
|
||||
val pString2 = refactorString(pString)
|
||||
val paint = newPaint(pFontName, pFontSize, horizontalAlignment)
|
||||
paint.setARGB(
|
||||
MotionEvent.ACTION_MASK,
|
||||
(255.0 * fontTintR.toDouble()).toInt(),
|
||||
(255.0 * fontTintG.toDouble()).toInt(),
|
||||
(255.0 * fontTintB.toDouble()).toInt()
|
||||
)
|
||||
val textProperty = computeTextProperty(pString2, pWidth, pHeight, paint)
|
||||
bitmapTotalHeight = if (pHeight == 0) {
|
||||
textProperty.mTotalHeight
|
||||
} else {
|
||||
pHeight
|
||||
}
|
||||
var bitmapPaddingX = 0.0f
|
||||
var bitmapPaddingY = 0.0f
|
||||
var renderTextDeltaX = 0.0f
|
||||
var renderTextDeltaY = 0.0f
|
||||
if (shadow) {
|
||||
paint.setShadowLayer(shadowBlur, shadowDX, shadowDY, -8553091)
|
||||
bitmapPaddingX = abs(shadowDX)
|
||||
bitmapPaddingY = abs(shadowDY)
|
||||
if (shadowDX.toDouble() < 0.0) {
|
||||
renderTextDeltaX = bitmapPaddingX
|
||||
}
|
||||
if (shadowDY.toDouble() < 0.0) {
|
||||
renderTextDeltaY = bitmapPaddingY
|
||||
}
|
||||
}
|
||||
val bitmap = Bitmap.createBitmap(
|
||||
textProperty.mMaxWidth + bitmapPaddingX.toInt(),
|
||||
bitmapPaddingY.toInt() + bitmapTotalHeight,
|
||||
Bitmap.Config.ARGB_8888
|
||||
)
|
||||
val canvas = Canvas(bitmap)
|
||||
val fontMetricsInt = paint.fontMetricsInt
|
||||
var y = computeY(fontMetricsInt, pHeight, textProperty.mTotalHeight, verticalAlignment)
|
||||
val lines = textProperty.mLines
|
||||
val length = lines.size
|
||||
for (i in 0 until length) {
|
||||
val line = lines[i]
|
||||
canvas.drawText(
|
||||
line!!,
|
||||
computeX(
|
||||
line,
|
||||
textProperty.mMaxWidth,
|
||||
horizontalAlignment
|
||||
).toFloat() + renderTextDeltaX,
|
||||
y.toFloat() + renderTextDeltaY,
|
||||
paint
|
||||
)
|
||||
y += textProperty.mHeightPerLine
|
||||
}
|
||||
if (stroke) {
|
||||
val paintStroke = newPaint(pFontName, pFontSize, horizontalAlignment)
|
||||
paintStroke.style = Paint.Style.STROKE
|
||||
paintStroke.strokeWidth = 0.5f * strokeSize
|
||||
paintStroke.setARGB(
|
||||
MotionEvent.ACTION_MASK,
|
||||
strokeR.toInt() * MotionEvent.ACTION_MASK,
|
||||
strokeG.toInt() * MotionEvent.ACTION_MASK,
|
||||
strokeB.toInt() * MotionEvent.ACTION_MASK
|
||||
)
|
||||
var y2 = computeY(fontMetricsInt, pHeight, textProperty.mTotalHeight, verticalAlignment)
|
||||
val lines2 = textProperty.mLines
|
||||
val length2 = lines2.size
|
||||
for (i2 in 0 until length2) {
|
||||
val line2 = lines2[i2]
|
||||
canvas.drawText(
|
||||
line2!!,
|
||||
computeX(
|
||||
line2,
|
||||
textProperty.mMaxWidth,
|
||||
horizontalAlignment
|
||||
).toFloat() + renderTextDeltaX,
|
||||
y2.toFloat() + renderTextDeltaY,
|
||||
paintStroke
|
||||
)
|
||||
y2 += textProperty.mHeightPerLine
|
||||
}
|
||||
}
|
||||
initNativeObject(bitmap)
|
||||
}
|
||||
|
||||
private fun newPaint(pFontName: String, pFontSize: Int, pHorizontalAlignment: Int): Paint {
|
||||
val paint = Paint()
|
||||
paint.color = -1
|
||||
paint.textSize = pFontSize.toFloat()
|
||||
paint.isAntiAlias = true
|
||||
if (pFontName.endsWith(".ttf")) {
|
||||
try {
|
||||
paint.typeface = Cocos2dxTypefaces[sContext, pFontName]
|
||||
} catch (e: Exception) {
|
||||
Log.e("Cocos2dxBitmap", "error to create ttf type face: $pFontName")
|
||||
paint.typeface = Typeface.create(pFontName, Typeface.NORMAL)
|
||||
}
|
||||
} else {
|
||||
paint.typeface = Typeface.create(pFontName, Typeface.NORMAL)
|
||||
}
|
||||
when (pHorizontalAlignment) {
|
||||
2 -> paint.textAlign = Paint.Align.RIGHT
|
||||
3 -> paint.textAlign = Paint.Align.CENTER
|
||||
else -> paint.textAlign = Paint.Align.LEFT
|
||||
}
|
||||
return paint
|
||||
}
|
||||
|
||||
private fun computeTextProperty(
|
||||
pString: String,
|
||||
pWidth: Int,
|
||||
pHeight: Int,
|
||||
pPaint: Paint
|
||||
): TextProperty {
|
||||
val fm = pPaint.fontMetricsInt
|
||||
val h = ceil((fm.bottom - fm.top).toDouble()).toInt()
|
||||
var maxContentWidth = 0
|
||||
val lines = splitString(pString, pWidth, pHeight, pPaint)
|
||||
if (pWidth != 0) {
|
||||
maxContentWidth = pWidth
|
||||
} else {
|
||||
for (line in lines) {
|
||||
val temp = ceil(pPaint.measureText(line, 0, line!!.length).toDouble()).toInt()
|
||||
if (temp > maxContentWidth) {
|
||||
maxContentWidth = temp
|
||||
}
|
||||
}
|
||||
}
|
||||
return TextProperty(maxContentWidth, h, lines)
|
||||
}
|
||||
|
||||
private fun computeX(@Suppress("UNUSED_PARAMETER") pText: String?, pMaxWidth: Int, pHorizontalAlignment: Int): Int {
|
||||
return when (pHorizontalAlignment) {
|
||||
2 -> pMaxWidth
|
||||
3 -> pMaxWidth / 2
|
||||
else -> 0
|
||||
}
|
||||
}
|
||||
|
||||
private fun computeY(
|
||||
pFontMetricsInt: FontMetricsInt,
|
||||
pConstrainHeight: Int,
|
||||
pTotalHeight: Int,
|
||||
pVerticalAlignment: Int
|
||||
): Int {
|
||||
val y = -pFontMetricsInt.top
|
||||
return if (pConstrainHeight <= pTotalHeight) {
|
||||
y
|
||||
} else when (pVerticalAlignment) {
|
||||
1 -> -pFontMetricsInt.top
|
||||
2 -> -pFontMetricsInt.top + (pConstrainHeight - pTotalHeight)
|
||||
3 -> -pFontMetricsInt.top + (pConstrainHeight - pTotalHeight) / 2
|
||||
else -> y
|
||||
}
|
||||
}
|
||||
|
||||
private fun splitString(
|
||||
pString: String,
|
||||
pMaxWidth: Int,
|
||||
pMaxHeight: Int,
|
||||
pPaint: Paint
|
||||
): Array<String?> {
|
||||
val lines: Array<String?> = pString.split("\\n").toTypedArray()
|
||||
val fm = pPaint.fontMetricsInt
|
||||
val maxLines = pMaxHeight / ceil((fm.bottom - fm.top).toDouble()).toInt()
|
||||
return if (pMaxWidth != 0) {
|
||||
val strList = LinkedList<String?>()
|
||||
for (line in lines) {
|
||||
if (ceil(pPaint.measureText(line).toDouble()).toInt() > pMaxWidth) {
|
||||
strList.addAll(divideStringWithMaxWidth(line, pMaxWidth, pPaint))
|
||||
} else {
|
||||
strList.add(line)
|
||||
}
|
||||
if (maxLines > 0 && strList.size >= maxLines) {
|
||||
break
|
||||
}
|
||||
}
|
||||
if (maxLines > 0 && strList.size > maxLines) {
|
||||
while (strList.size > maxLines) {
|
||||
strList.removeLast()
|
||||
}
|
||||
}
|
||||
val ret = arrayOfNulls<String>(strList.size)
|
||||
strList.toArray(ret)
|
||||
ret
|
||||
} else if (pMaxHeight == 0 || lines.size <= maxLines) {
|
||||
lines
|
||||
} else {
|
||||
val strList2 = LinkedList<String?>()
|
||||
for (i in 0 until maxLines) {
|
||||
strList2.add(lines[i])
|
||||
}
|
||||
val ret2 = arrayOfNulls<String>(strList2.size)
|
||||
strList2.toArray(ret2)
|
||||
ret2
|
||||
}
|
||||
}
|
||||
|
||||
private fun divideStringWithMaxWidth(
|
||||
pString: String?,
|
||||
pMaxWidth: Int,
|
||||
pPaint: Paint
|
||||
): LinkedList<String?> {
|
||||
val charLength = pString!!.length
|
||||
var start = 0
|
||||
val strList = LinkedList<String?>()
|
||||
var i = 1
|
||||
while (i <= charLength) {
|
||||
val tempWidth = ceil(pPaint.measureText(pString, start, i).toDouble()).toInt()
|
||||
if (tempWidth >= pMaxWidth) {
|
||||
val lastIndexOfSpace = pString.substring(0, i).lastIndexOf(" ")
|
||||
if (lastIndexOfSpace != -1 && lastIndexOfSpace > start) {
|
||||
strList.add(pString.substring(start, lastIndexOfSpace))
|
||||
i = lastIndexOfSpace + 1
|
||||
} else if (tempWidth > pMaxWidth) {
|
||||
strList.add(pString.substring(start, i - 1))
|
||||
i--
|
||||
} else {
|
||||
strList.add(pString.substring(start, i))
|
||||
}
|
||||
while (i < charLength && pString[i] == ' ') {
|
||||
i++
|
||||
}
|
||||
start = i
|
||||
}
|
||||
i++
|
||||
}
|
||||
if (start < charLength) {
|
||||
strList.add(pString.substring(start))
|
||||
}
|
||||
return strList
|
||||
}
|
||||
|
||||
private fun refactorString(pString: String): String {
|
||||
if (pString.compareTo("") == 0) {
|
||||
return " "
|
||||
}
|
||||
val strBuilder = StringBuilder(pString)
|
||||
var start = 0
|
||||
var index = strBuilder.indexOf("\n")
|
||||
while (index != -1) {
|
||||
start = if (index == 0 || strBuilder[index - 1].code == 10) {
|
||||
strBuilder.insert(start, " ")
|
||||
index + 2
|
||||
} else {
|
||||
index + 1
|
||||
}
|
||||
if (start > strBuilder.length || index == strBuilder.length) {
|
||||
break
|
||||
}
|
||||
index = strBuilder.indexOf("\n", start)
|
||||
}
|
||||
return strBuilder.toString()
|
||||
}
|
||||
|
||||
private fun initNativeObject(pBitmap: Bitmap) {
|
||||
val pixels = getPixels(pBitmap)
|
||||
if (pixels != null) {
|
||||
nativeInitBitmapDC(pBitmap.width, pBitmap.height, pixels)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getPixels(pBitmap: Bitmap?): ByteArray? {
|
||||
if (pBitmap == null) {
|
||||
return null
|
||||
}
|
||||
val pixels = ByteArray(pBitmap.width * pBitmap.height * 4)
|
||||
val buf = ByteBuffer.wrap(pixels)
|
||||
buf.order(ByteOrder.nativeOrder())
|
||||
pBitmap.copyPixelsToBuffer(buf)
|
||||
return pixels
|
||||
}
|
||||
|
||||
private fun getFontSizeAccordingHeight(height: Int): Int {
|
||||
val paint = Paint()
|
||||
val bounds = Rect()
|
||||
paint.typeface = Typeface.DEFAULT
|
||||
var incrTextSize = 1
|
||||
var foundDesiredSize = false
|
||||
while (!foundDesiredSize) {
|
||||
paint.textSize = incrTextSize.toFloat()
|
||||
paint.getTextBounds("SghMNy", 0, "SghMNy".length, bounds)
|
||||
incrTextSize++
|
||||
if (height - bounds.height() <= 2) {
|
||||
foundDesiredSize = true
|
||||
}
|
||||
Log.d("font size", "incr size:$incrTextSize")
|
||||
}
|
||||
return incrTextSize
|
||||
}
|
||||
|
||||
private fun getStringWithEllipsis(pString: String, width: Float, fontSize: Float): String {
|
||||
if (TextUtils.isEmpty(pString)) {
|
||||
return ""
|
||||
}
|
||||
val paint = TextPaint()
|
||||
paint.typeface = Typeface.DEFAULT
|
||||
paint.textSize = fontSize
|
||||
return TextUtils.ellipsize(pString, paint, width, TextUtils.TruncateAt.END).toString()
|
||||
}
|
||||
|
||||
private class TextProperty constructor(/* access modifiers changed from: private */
|
||||
val mMaxWidth: Int, /* access modifiers changed from: private */
|
||||
val mHeightPerLine: Int, pLines: Array<String?>
|
||||
) {
|
||||
/* access modifiers changed from: private */
|
||||
val mLines: Array<String?>
|
||||
|
||||
/* access modifiers changed from: private */
|
||||
val mTotalHeight: Int
|
||||
|
||||
init {
|
||||
mTotalHeight = pLines.size * mHeightPerLine
|
||||
mLines = pLines
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
package org.cocos2dx.lib
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.opengl.GLSurfaceView
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.os.Message
|
||||
import android.view.KeyEvent
|
||||
import android.view.MotionEvent
|
||||
import com.customRobTop.BaseRobTopActivity
|
||||
|
||||
|
||||
class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
|
||||
companion object {
|
||||
lateinit var mCocos2dxGLSurfaceView: Cocos2dxGLSurfaceView
|
||||
private var sHandler: Handler? = null
|
||||
}
|
||||
|
||||
private lateinit var mCocos2dxRenderer: Cocos2dxRenderer
|
||||
|
||||
fun initView() {
|
||||
setEGLContextClientVersion(2)
|
||||
isFocusableInTouchMode = true
|
||||
// if (Build.VERSION.SDK_INT >= 11) {
|
||||
preserveEGLContextOnPause = true
|
||||
// }
|
||||
mCocos2dxGLSurfaceView = this
|
||||
// sCocos2dxTextInputWraper = Cocos2dxTextInputWraper(this)
|
||||
sHandler = @SuppressLint("HandlerLeak")
|
||||
object : Handler(Looper.getMainLooper()) {
|
||||
override fun handleMessage(msg: Message) {
|
||||
/* when (msg.what) {
|
||||
2 -> {
|
||||
if (this@Cocos2dxGLSurfaceView.mCocos2dxEditText != null && this@Cocos2dxGLSurfaceView.mCocos2dxEditText.requestFocus()) {
|
||||
this@Cocos2dxGLSurfaceView.mCocos2dxEditText.removeTextChangedListener(
|
||||
Cocos2dxGLSurfaceView.sCocos2dxTextInputWraper
|
||||
)
|
||||
this@Cocos2dxGLSurfaceView.mCocos2dxEditText.setText("")
|
||||
val text = msg.obj as String
|
||||
this@Cocos2dxGLSurfaceView.mCocos2dxEditText.append(text)
|
||||
Cocos2dxGLSurfaceView.sCocos2dxTextInputWraper.setOriginText(text)
|
||||
this@Cocos2dxGLSurfaceView.mCocos2dxEditText.addTextChangedListener(
|
||||
Cocos2dxGLSurfaceView.sCocos2dxTextInputWraper
|
||||
)
|
||||
(Cocos2dxGLSurfaceView.mCocos2dxGLSurfaceView.getContext()
|
||||
.getSystemService("input_method") as InputMethodManager).showSoftInput(
|
||||
this@Cocos2dxGLSurfaceView.mCocos2dxEditText,
|
||||
0
|
||||
)
|
||||
Log.d("GLSurfaceView", "showSoftInput")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
3 -> {
|
||||
if (this@Cocos2dxGLSurfaceView.mCocos2dxEditText != null) {
|
||||
this@Cocos2dxGLSurfaceView.mCocos2dxEditText.removeTextChangedListener(
|
||||
Cocos2dxGLSurfaceView.sCocos2dxTextInputWraper
|
||||
)
|
||||
(Cocos2dxGLSurfaceView.mCocos2dxGLSurfaceView.getContext()
|
||||
.getSystemService("input_method") as InputMethodManager).hideSoftInputFromWindow(
|
||||
this@Cocos2dxGLSurfaceView.mCocos2dxEditText.getWindowToken(),
|
||||
0
|
||||
)
|
||||
this@Cocos2dxGLSurfaceView.requestFocus()
|
||||
Log.d("GLSurfaceView", "HideSoftInput")
|
||||
this@Cocos2dxGLSurfaceView.mCocos2dxRenderer.handleTextClosed()
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
else -> return
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onTouchEvent(pMotionEvent: MotionEvent): Boolean {
|
||||
val pointerNumber = pMotionEvent.pointerCount
|
||||
val ids = IntArray(pointerNumber)
|
||||
val xs = FloatArray(pointerNumber)
|
||||
val ys = FloatArray(pointerNumber)
|
||||
for (i in 0 until pointerNumber) {
|
||||
ids[i] = pMotionEvent.getPointerId(i)
|
||||
xs[i] = pMotionEvent.getX(i)
|
||||
ys[i] = pMotionEvent.getY(i)
|
||||
}
|
||||
return when (pMotionEvent.action and MotionEvent.ACTION_MASK) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
val idDown = pMotionEvent.getPointerId(0)
|
||||
val xDown = xs[0]
|
||||
val f = ys[0]
|
||||
queueEvent {
|
||||
mCocos2dxRenderer.handleActionDown(
|
||||
idDown,
|
||||
xDown,
|
||||
f
|
||||
)
|
||||
}
|
||||
true
|
||||
}
|
||||
MotionEvent.ACTION_UP -> {
|
||||
val idUp = pMotionEvent.getPointerId(0)
|
||||
val f2 = xs[0]
|
||||
val f3 = ys[0]
|
||||
queueEvent { mCocos2dxRenderer.handleActionUp(idUp, f2, f3) }
|
||||
true
|
||||
}
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
queueEvent {
|
||||
mCocos2dxRenderer.handleActionMove(
|
||||
ids,
|
||||
xs,
|
||||
ys
|
||||
)
|
||||
}
|
||||
true
|
||||
}
|
||||
MotionEvent.ACTION_CANCEL -> {
|
||||
queueEvent {
|
||||
mCocos2dxRenderer.handleActionCancel(
|
||||
ids,
|
||||
xs,
|
||||
ys
|
||||
)
|
||||
}
|
||||
true
|
||||
}
|
||||
MotionEvent.ACTION_POINTER_DOWN -> {
|
||||
val indexPointerDown = pMotionEvent.action shr 8
|
||||
val idPointerDown = pMotionEvent.getPointerId(indexPointerDown)
|
||||
val xPointerDown = pMotionEvent.getX(indexPointerDown)
|
||||
val y = pMotionEvent.getY(indexPointerDown)
|
||||
queueEvent {
|
||||
mCocos2dxRenderer.handleActionDown(
|
||||
idPointerDown,
|
||||
xPointerDown,
|
||||
y
|
||||
)
|
||||
}
|
||||
true
|
||||
}
|
||||
MotionEvent.ACTION_POINTER_UP -> {
|
||||
val indexPointUp = pMotionEvent.action shr 8
|
||||
val idPointerUp = pMotionEvent.getPointerId(indexPointUp)
|
||||
val xPointerUp = pMotionEvent.getX(indexPointUp)
|
||||
val y2 = pMotionEvent.getY(indexPointUp)
|
||||
queueEvent {
|
||||
mCocos2dxRenderer.handleActionUp(
|
||||
idPointerUp,
|
||||
xPointerUp,
|
||||
y2
|
||||
)
|
||||
}
|
||||
true
|
||||
}
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSizeChanged(
|
||||
pNewSurfaceWidth: Int,
|
||||
pNewSurfaceHeight: Int,
|
||||
pOldSurfaceWidth: Int,
|
||||
pOldSurfaceHeight: Int
|
||||
) {
|
||||
if (!isInEditMode) {
|
||||
mCocos2dxRenderer.setScreenWidthAndHeight(pNewSurfaceWidth, pNewSurfaceHeight)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onKeyDown(pKeyCode: Int, pKeyEvent: KeyEvent): Boolean {
|
||||
return when (pKeyCode) {
|
||||
KeyEvent.KEYCODE_BACK, KeyEvent.KEYCODE_MENU -> {
|
||||
if (pKeyEvent.repeatCount != 0 || BaseRobTopActivity.blockBackButton_) {
|
||||
return true
|
||||
}
|
||||
queueEvent { mCocos2dxRenderer.handleKeyDown(pKeyCode) }
|
||||
true
|
||||
}
|
||||
else -> super.onKeyDown(pKeyCode, pKeyEvent)
|
||||
}
|
||||
}
|
||||
|
||||
fun setCocos2dxRenderer(renderer: Cocos2dxRenderer) {
|
||||
this.mCocos2dxRenderer = renderer
|
||||
setRenderer(this.mCocos2dxRenderer)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package org.cocos2dx.lib
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.pm.ApplicationInfo
|
||||
|
||||
|
||||
@Suppress("unused")
|
||||
class Cocos2dxHelper {
|
||||
companion object {
|
||||
// private val sCocos2dMusic: Cocos2dxMusic? = null
|
||||
// private val sCocos2dSound: Cocos2dxSound? = null
|
||||
// private val sAssetManager: AssetManager? = null
|
||||
// private val sCocos2dxAccelerometer: Cocos2dxAccelerometer? = null
|
||||
// private val sAccelerometerEnabled = false
|
||||
private var sPackageName: String? = null
|
||||
private var sFileDirectory: String? = null
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private var sContext: Context? = null
|
||||
private var sCocos2dxHelperListener: Cocos2dxHelperListener? = null
|
||||
|
||||
@JvmStatic
|
||||
external fun nativeSetApkPath(pApkPath: String)
|
||||
|
||||
@JvmStatic
|
||||
fun getCocos2dxWritablePath(): String? {
|
||||
return sFileDirectory
|
||||
}
|
||||
|
||||
fun init(pContext: Context, pCocos2dxHelperListener: Cocos2dxHelperListener) {
|
||||
val applicationInfo: ApplicationInfo = pContext.applicationInfo
|
||||
sContext = pContext
|
||||
sCocos2dxHelperListener = pCocos2dxHelperListener
|
||||
sPackageName = applicationInfo.packageName
|
||||
sFileDirectory = pContext.filesDir.absolutePath
|
||||
|
||||
nativeSetApkPath(applicationInfo.sourceDir)
|
||||
// Cocos2dxHelper.sCocos2dxAccelerometer = Cocos2dxAccelerometer(pContext)
|
||||
// Cocos2dxHelper.sCocos2dMusic = Cocos2dxMusic(pContext)
|
||||
// var simultaneousStreams: Int = Cocos2dxSound.MAX_SIMULTANEOUS_STREAMS_DEFAULT
|
||||
// if (Cocos2dxHelper.getDeviceModel().indexOf("GT-I9100") !== -1) {
|
||||
// simultaneousStreams = Cocos2dxSound.MAX_SIMULTANEOUS_STREAMS_I9100
|
||||
// }
|
||||
// Cocos2dxHelper.sCocos2dSound = Cocos2dxSound(pContext, simultaneousStreams)
|
||||
// Cocos2dxHelper.sAssetManager = pContext.getAssets()
|
||||
Cocos2dxBitmap.setContext(pContext)
|
||||
// Cocos2dxETCLoader.setContext(pContext)
|
||||
}
|
||||
}
|
||||
|
||||
interface Cocos2dxHelperListener {
|
||||
fun runOnGLThread(pRunnable: Runnable)
|
||||
|
||||
fun showDialog(pTitle: String, pMessage: String)
|
||||
|
||||
fun showEditTextDialog(
|
||||
pTitle: String,
|
||||
pMessage: String,
|
||||
pInputMode: Int,
|
||||
pInputFlag: Int,
|
||||
pReturnType: Int,
|
||||
pMaxLength: Int
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package org.cocos2dx.lib
|
||||
|
||||
import android.opengl.GLSurfaceView
|
||||
import javax.microedition.khronos.egl.EGLConfig
|
||||
import javax.microedition.khronos.opengles.GL10
|
||||
|
||||
@Suppress("unused")
|
||||
class Cocos2dxRenderer : GLSurfaceView.Renderer {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun setAnimationInterval(@Suppress("UNUSED_PARAMETER") pAnimationInterval: Double) {
|
||||
// this function is useless for gd
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
private external fun nativeRender()
|
||||
|
||||
@JvmStatic
|
||||
private external fun nativeKeyDown(pKeyCode: Int): Boolean
|
||||
|
||||
@JvmStatic
|
||||
private external fun nativeTouchesBegin(pID: Int, pX: Float, pY: Float)
|
||||
|
||||
@JvmStatic
|
||||
private external fun nativeTouchesCancel(
|
||||
pIDs: IntArray,
|
||||
pXs: FloatArray,
|
||||
pYs: FloatArray
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
private external fun nativeTouchesEnd(pID: Int, pX: Float, pY: Float)
|
||||
|
||||
@JvmStatic
|
||||
private external fun nativeTouchesMove(pIDs: IntArray, pXs: FloatArray, pYs: FloatArray)
|
||||
}
|
||||
|
||||
private var mLastTickInNanoSeconds: Long = 0
|
||||
private var mScreenWidth = 0
|
||||
private var mScreenHeight = 0
|
||||
private external fun nativeInit(pWidth: Int, pHeight: Int)
|
||||
|
||||
fun setScreenWidthAndHeight(pSurfaceWidth: Int, pSurfaceHeight: Int) {
|
||||
mScreenWidth = pSurfaceWidth
|
||||
mScreenHeight = pSurfaceHeight
|
||||
}
|
||||
|
||||
override fun onSurfaceCreated(pGL10: GL10?, pEGLConfig: EGLConfig?) {
|
||||
nativeInit(this.mScreenWidth, this.mScreenHeight)
|
||||
this.mLastTickInNanoSeconds = System.nanoTime()
|
||||
}
|
||||
|
||||
override fun onSurfaceChanged(pGL10: GL10?, pWidth: Int, pHeight: Int) {}
|
||||
|
||||
override fun onDrawFrame(gl: GL10?) {
|
||||
nativeRender()
|
||||
}
|
||||
|
||||
fun handleActionDown(pID: Int, pX: Float, pY: Float) {
|
||||
nativeTouchesBegin(pID, pX, pY)
|
||||
}
|
||||
|
||||
fun handleActionUp(pID: Int, pX: Float, pY: Float) {
|
||||
nativeTouchesEnd(pID, pX, pY)
|
||||
}
|
||||
|
||||
fun handleActionCancel(pIDs: IntArray, pXs: FloatArray, pYs: FloatArray) {
|
||||
nativeTouchesCancel(pIDs, pXs, pYs)
|
||||
}
|
||||
|
||||
fun handleActionMove(pIDs: IntArray, pXs: FloatArray, pYs: FloatArray) {
|
||||
nativeTouchesMove(pIDs, pXs, pYs)
|
||||
}
|
||||
|
||||
fun handleKeyDown(pKeyCode: Int) {
|
||||
nativeKeyDown(pKeyCode)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.cocos2dx.lib
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Typeface
|
||||
import kotlin.jvm.Synchronized
|
||||
import java.util.HashMap
|
||||
|
||||
object Cocos2dxTypefaces {
|
||||
private val sTypefaceCache = HashMap<String, Typeface>()
|
||||
|
||||
@Synchronized
|
||||
operator fun get(pContext: Context, pAssetName: String): Typeface? {
|
||||
var typeface: Typeface?
|
||||
var typeface2: Typeface
|
||||
synchronized(Cocos2dxTypefaces::class.java) {
|
||||
if (!sTypefaceCache.containsKey(pAssetName)) {
|
||||
typeface2 = if (pAssetName.startsWith("/")) {
|
||||
Typeface.createFromFile(pAssetName)
|
||||
} else {
|
||||
Typeface.createFromAsset(pContext.assets, pAssetName)
|
||||
}
|
||||
sTypefaceCache[pAssetName] = typeface2
|
||||
}
|
||||
typeface = sTypefaceCache[pAssetName]
|
||||
}
|
||||
return typeface
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 187 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 6.6 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 9.6 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 7.5 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 18 KiB |
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="purple_200">#FFBB86FC</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#282828</color>
|
||||
</resources>
|
||||
@@ -0,0 +1,4 @@
|
||||
<resources>
|
||||
<string name="app_name">Geode</string>
|
||||
<string name="title_activity_geometry_dash">GeometryDash</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="Theme.Geodelauncher" parent="android:Theme.Material.Light.NoActionBar" />
|
||||
</resources>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample backup rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/guide/topics/data/autobackup
|
||||
for details.
|
||||
Note: This file is ignored for devices older that API 31
|
||||
See https://developer.android.com/about/versions/12/backup-restore
|
||||
-->
|
||||
<full-backup-content>
|
||||
<!--
|
||||
<include domain="sharedpref" path="."/>
|
||||
<exclude domain="sharedpref" path="device.xml"/>
|
||||
-->
|
||||
</full-backup-content>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample data extraction rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||
for details.
|
||||
-->
|
||||
<data-extraction-rules>
|
||||
<cloud-backup>
|
||||
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
-->
|
||||
</cloud-backup>
|
||||
<!--
|
||||
<device-transfer>
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
</device-transfer>
|
||||
-->
|
||||
</data-extraction-rules>
|
||||