Skip to content

Commit

Permalink
Merge branch 'FCL-Team:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Redstone2337 authored Sep 16, 2024
2 parents f669ec7 + 234fd32 commit a33ac82
Show file tree
Hide file tree
Showing 1,573 changed files with 11,953 additions and 426,524 deletions.
6 changes: 3 additions & 3 deletions FCL/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ android {
applicationId "com.tungsten.fcl"
minSdk 26
targetSdk 34
versionCode 1178
versionName "1.1.7.8"
versionCode 1179
versionName "1.1.7.9"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -187,7 +187,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.github.Mathias-Boulay:android_gamepad_remapper:06184ddbce'
implementation 'com.github.Mathias-Boulay:android_gamepad_remapper:2.0.3'
implementation 'com.github.bumptech.glide:glide:4.16.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
Expand Down
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion FCL/src/main/assets/app_runtime/caciocavallo/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5
6
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion FCL/src/main/assets/app_runtime/caciocavallo17/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2
3
Binary file modified FCL/src/main/assets/app_runtime/lwjgl/lwjgl.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion FCL/src/main/assets/app_runtime/lwjgl/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1712051464002
1726320625815
6 changes: 6 additions & 0 deletions FCL/src/main/java/com/mio/util/AnimUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,11 @@ class AnimUtil {
this.interpolator = interpolator
return this
}

@JvmStatic
fun ObjectAnimator.startAfter(delayTime: Long) {
this.startDelay = delayTime
this.start()
}
}
}
61 changes: 61 additions & 0 deletions FCL/src/main/java/com/mio/util/PerfUtil.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.mio.util

import android.os.Handler
import android.os.HandlerThread
import android.os.Looper
import android.util.Log
import android.util.Printer

class PerfUtil : Printer {
companion object {
@JvmStatic
fun install() {
Looper.getMainLooper().setMessageLogging(PerfUtil())
}
}

private val sampler = StackSampler(300)
private var isStarted = false
private var startTime = 0L

override fun println(x: String?) {
if (!isStarted) {
isStarted = true
startTime = System.currentTimeMillis()
sampler.startDump()
} else {
isStarted = false
val endTime = System.currentTimeMillis()
if (endTime - startTime > 300) {
Log.e("FCL PerfUtil", "block time = ${endTime - startTime}")
}
sampler.stopDump()
}
}

inner class StackSampler(val interval: Long) {
private val handler: Handler
private val runnable = Runnable {
val sb = StringBuilder()
Looper.getMainLooper().thread.stackTrace.forEach {
sb.append(it.toString())
sb.append("\n")
}
Log.e("FCL PerfUtil", sb.toString())
}

init {
val handlerThread = HandlerThread("")
handlerThread.start()
handler = Handler(handlerThread.looper)
}

fun startDump() {
handler.postDelayed(runnable, interval)
}

fun stopDump() {
handler.removeCallbacks(runnable)
}
}
}
8 changes: 6 additions & 2 deletions FCL/src/main/java/com/tungsten/fcl/FCLApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ public void onCreate() {
// enabledStrictMode();
super.onCreate();
this.registerActivityLifecycleCallbacks(this);
// PerfUtil.install();
}

public static Activity getCurrentActivity() {
return currentActivity.get();
if (currentActivity != null) {
return currentActivity.get();
}
return null;
}

private void enabledStrictMode() {
Expand All @@ -43,7 +47,7 @@ private void enabledStrictMode() {

@Override
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle bundle) {

currentActivity = new WeakReference<>(activity);
}

@Override
Expand Down
23 changes: 20 additions & 3 deletions FCL/src/main/java/com/tungsten/fcl/activity/JVMActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
import com.tungsten.fcl.setting.GameOption;
import com.tungsten.fclauncher.bridge.FCLBridge;
import com.tungsten.fclauncher.keycodes.FCLKeycodes;
import com.tungsten.fclauncher.keycodes.LwjglGlfwKeycode;
import com.tungsten.fclcore.util.Logging;
import com.tungsten.fcllibrary.component.FCLActivity;

import org.lwjgl.glfw.CallbackBridge;

import java.util.Objects;
import java.util.logging.Level;

Expand Down Expand Up @@ -82,7 +85,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
public void onSurfaceTextureAvailable(@NonNull SurfaceTexture surfaceTexture, int i, int i1) {
Logging.LOG.log(Level.INFO, "surface ready, start jvm now!");
fclBridge.setSurfaceDestroyed(false);
int width = menuType == MenuType.GAME ? (int) (i * fclBridge.getScaleFactor()) : FCLBridge.DEFAULT_WIDTH;
int width = menuType == MenuType.GAME ? (int) ((i + ((GameMenu) menu).getMenuSetting().getCursorOffset()) * fclBridge.getScaleFactor()) : FCLBridge.DEFAULT_WIDTH;
int height = menuType == MenuType.GAME ? (int) (i1 * fclBridge.getScaleFactor()) : FCLBridge.DEFAULT_HEIGHT;
if (menuType == MenuType.GAME) {
GameOption gameOption = new GameOption(Objects.requireNonNull(menu.getBridge()).getGameDir());
Expand All @@ -99,7 +102,7 @@ public void onSurfaceTextureAvailable(@NonNull SurfaceTexture surfaceTexture, in

@Override
public void onSurfaceTextureSizeChanged(@NonNull SurfaceTexture surfaceTexture, int i, int i1) {
int width = menuType == MenuType.GAME ? (int) (i * fclBridge.getScaleFactor()) : FCLBridge.DEFAULT_WIDTH;
int width = menuType == MenuType.GAME ? (int) ((i + ((GameMenu) menu).getMenuSetting().getCursorOffset()) * fclBridge.getScaleFactor()) : FCLBridge.DEFAULT_WIDTH;
int height = menuType == MenuType.GAME ? (int) (i1 * fclBridge.getScaleFactor()) : FCLBridge.DEFAULT_HEIGHT;
surfaceTexture.setDefaultBufferSize(width, height);
fclBridge.pushEventWindow(width, height);
Expand All @@ -108,7 +111,7 @@ public void onSurfaceTextureSizeChanged(@NonNull SurfaceTexture surfaceTexture,
@Override
public boolean onSurfaceTextureDestroyed(@NonNull SurfaceTexture surfaceTexture) {
fclBridge.setSurfaceDestroyed(true);
return false;
return true;
}

private int output = 0;
Expand All @@ -129,6 +132,7 @@ protected void onPause() {
if (menu != null) {
menu.onPause();
}
CallbackBridge.nativeSetWindowAttrib(LwjglGlfwKeycode.GLFW_HOVERED, 0);
super.onPause();
}

Expand All @@ -137,9 +141,22 @@ protected void onResume() {
if (menu != null) {
menu.onResume();
}
CallbackBridge.nativeSetWindowAttrib(LwjglGlfwKeycode.GLFW_HOVERED, 1);
super.onResume();
}

@Override
protected void onStart() {
super.onStart();
CallbackBridge.nativeSetWindowAttrib(LwjglGlfwKeycode.GLFW_VISIBLE, 1);
}

@Override
protected void onStop() {
CallbackBridge.nativeSetWindowAttrib(LwjglGlfwKeycode.GLFW_VISIBLE, 0);
super.onStop();
}

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
boolean handleEvent = true;
Expand Down
90 changes: 59 additions & 31 deletions FCL/src/main/java/com/tungsten/fcl/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ import android.os.Bundle
import android.view.KeyEvent
import android.view.View
import android.view.ViewGroup
import android.view.animation.BounceInterpolator
import android.widget.RelativeLayout
import androidx.appcompat.app.AlertDialog
import androidx.core.view.forEach
import androidx.databinding.DataBindingUtil
import com.mio.util.AnimUtil
import com.mio.util.AnimUtil.Companion.interpolator
import com.tungsten.fcl.R
import com.tungsten.fcl.databinding.ActivityMainBinding
import com.tungsten.fcl.game.JarExecutorHelper
Expand Down Expand Up @@ -173,7 +176,10 @@ class MainActivity : FCLActivity(), OnSelectListener, View.OnClickListener {
.setView(layout)
.setPositiveButton(com.tungsten.fcllibrary.R.string.dialog_positive) { _: DialogInterface?, _: Int ->
JarExecutorHelper.exec(
this@MainActivity, null, 8, editText.text.toString()
this@MainActivity,
null,
JarExecutorHelper.getJava(null),
editText.text.toString()
)
}
.setNegativeButton(com.tungsten.fcllibrary.R.string.dialog_negative, null)
Expand Down Expand Up @@ -225,6 +231,7 @@ class MainActivity : FCLActivity(), OnSelectListener, View.OnClickListener {
setupVersionDisplay()
UpdateChecker.getInstance().checkAuto(this@MainActivity).start()
}
playAnim()
}
}
}
Expand Down Expand Up @@ -256,7 +263,7 @@ class MainActivity : FCLActivity(), OnSelectListener, View.OnClickListener {
}

manage -> {
val version = Profiles.getSelectedVersion()
val version = Profiles.getSelectedProfile().selectedVersion
if (version == null) {
refreshMenuView(null)
title.setTextWithAnim(getString(R.string.version))
Expand Down Expand Up @@ -381,6 +388,7 @@ class MainActivity : FCLActivity(), OnSelectListener, View.OnClickListener {

@SuppressLint("UseCompatLoadingForDrawables")
private fun loadVersion(version: String?) {
bind.versionProgress.visibility = View.VISIBLE
if (Profiles.getSelectedProfile() != profile) {
profile = Profiles.getSelectedProfile()
if (profile != null) {
Expand All @@ -394,42 +402,45 @@ class MainActivity : FCLActivity(), OnSelectListener, View.OnClickListener {
version
)
) {
val game = Profiles.getSelectedProfile().repository.getGameVersion(version)
.orElse(getString(R.string.message_unknown))
val libraries = StringBuilder(game)
val analyzer = LibraryAnalyzer.analyze(
Profiles.getSelectedProfile().repository.getResolvedPreservingPatchesVersion(version)
)
for (mark in analyzer) {
val libraryId = mark.libraryId
val libraryVersion = mark.libraryVersion
if (libraryId == LibraryType.MINECRAFT.patchId) continue
if (AndroidUtils.hasStringId(
this,
"install_installer_" + libraryId.replace("-", "_")
)
) {
libraries.append(", ").append(
AndroidUtils.getLocalizedText(
Schedulers.defaultScheduler().execute {
val game = Profiles.getSelectedProfile().repository.getGameVersion(version)
.orElse(getString(R.string.message_unknown))
val libraries = StringBuilder(game)
val analyzer = LibraryAnalyzer.analyze(
Profiles.getSelectedProfile().repository.getResolvedPreservingPatchesVersion(version)
)
for (mark in analyzer) {
val libraryId = mark.libraryId
val libraryVersion = mark.libraryVersion
if (libraryId == LibraryType.MINECRAFT.patchId) continue
if (AndroidUtils.hasStringId(
this,
"install_installer_" + libraryId.replace("-", "_")
)
)
if (libraryVersion != null) libraries.append(": ").append(
libraryVersion.replace(
"(?i)$libraryId".toRegex(), ""
) {
libraries.append(", ").append(
AndroidUtils.getLocalizedText(
this,
"install_installer_" + libraryId.replace("-", "_")
)
)
)
if (libraryVersion != null) libraries.append(": ").append(
libraryVersion.replace(
"(?i)$libraryId".toRegex(), ""
)
)
}
}
val drawable = Profiles.getSelectedProfile().repository.getVersionIconImage(version)
Schedulers.androidUIThread().execute {
bind.versionProgress.visibility = View.GONE
bind.versionName.text = version
bind.versionHint.text = libraries.toString()
bind.icon.setBackgroundDrawable(drawable)
}
}
bind.versionName.text = version
bind.versionHint.text = libraries.toString()
bind.icon.setBackgroundDrawable(
Profiles.getSelectedProfile().repository.getVersionIconImage(
version
)
)
} else {
bind.versionProgress.visibility = View.GONE
bind.versionName.text = getString(R.string.version_no_version)
bind.versionHint.text = getString(R.string.version_manage)
bind.icon.setBackgroundDrawable(getDrawable(R.drawable.img_grass))
Expand All @@ -454,4 +465,21 @@ class MainActivity : FCLActivity(), OnSelectListener, View.OnClickListener {
})
}
}

private fun playAnim() {
bind.apply {
AnimUtil.playTranslationX(
leftMenu,
ThemeEngine.getInstance().getTheme().animationSpeed * 100L,
-100f,
0f
).interpolator(BounceInterpolator()).start()
AnimUtil.playTranslationX(
rightMenu,
ThemeEngine.getInstance().getTheme().animationSpeed * 100L,
100f,
0f
).interpolator(BounceInterpolator()).start()
}
}
}
13 changes: 2 additions & 11 deletions FCL/src/main/java/com/tungsten/fcl/activity/SplashActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ public class SplashActivity extends FCLActivity {

public ConstraintLayout background;

private EulaFragment eulaFragment;
private RuntimeFragment runtimeFragment;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -103,21 +100,15 @@ private void init() {
FCLPath.loadPaths(this);
transFile();
Logging.start(Paths.get(FCLPath.LOG_DIR));
initFragments();
start();
}

private void initFragments() {
eulaFragment = new EulaFragment();
runtimeFragment = new RuntimeFragment();
}

public void start() {
SharedPreferences sharedPreferences = getSharedPreferences("launcher", MODE_PRIVATE);
if (sharedPreferences.getBoolean("isFirstLaunch", true)) {
getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.frag_start_anim, R.anim.frag_stop_anim).replace(R.id.fragment, eulaFragment).commit();
getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.frag_start_anim, R.anim.frag_stop_anim).replace(R.id.fragment, EulaFragment.class, null).commit();
} else {
getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.frag_start_anim, R.anim.frag_stop_anim).replace(R.id.fragment, runtimeFragment).commit();
getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.frag_start_anim, R.anim.frag_stop_anim).replace(R.id.fragment, RuntimeFragment.class, null).commit();
}
}

Expand Down
Loading

0 comments on commit a33ac82

Please sign in to comment.