Skip to content

Commit

Permalink
调整[游戏内分辨率缩放]: 使用静态浮点
Browse files Browse the repository at this point in the history
  • Loading branch information
Vera-Firefly committed Oct 18, 2024
1 parent fa15a16 commit 266be18
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,24 @@
import android.widget.TextView;
import android.widget.LinearLayout;

import net.kdt.pojavlaunch.MinecraftGLSurface;
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
import net.kdt.pojavlaunch.R;
import net.kdt.pojavlaunch.Tools;

public class ResolutionAdjuster {

private float mScaleFactor;
private static float mScaleFactor;
private final Context context;
private final OnResolutionChangeListener listener;
private MinecraftGLSurface glSurface;

public ResolutionAdjuster(Context context, MinecraftGLSurface glSurface, OnResolutionChangeListener listener) {
public ResolutionAdjuster(Context context, OnResolutionChangeListener listener) {
this.context = context;
this.glSurface = glSurface;
this.listener = listener;
}

// 显示滑动条弹窗
public void showSeekBarDialog() {
if (glSurface == null) {
glSurface = new MinecraftGLSurface(context);
}
mScaleFactor = glSurface.mScaleFactor;
if (mScaleFactor == 0.0f) mScaleFactor = LauncherPreferences.PREF_SCALE_FACTOR / 100f;
int percentage = Math.round(mScaleFactor * 100);

// 动态创建一个LinearLayout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ protected void initLayout(int resId) {
openCustomControls();
break;
case 6:{
ResolutionAdjuster adjuster = new ResolutionAdjuster(this, minecraftGLView, value -> {
ResolutionAdjuster adjuster = new ResolutionAdjuster(this, value -> {
minecraftGLView.refreshSize(value);
mHotbarView.refreshScaleFactor(value);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class MinecraftGLSurface extends View implements GrabListener {
.remapDpad(true));

/* Resolution scaler option, allow downsizing a window */
public float mScaleFactor = LauncherPreferences.PREF_SCALE_FACTOR / 100f;
private float mScaleFactor = LauncherPreferences.PREF_SCALE_FACTOR / 100f;
/* Sensitivity, adjusted according to screen size */
private final double mSensitivityFactor = (1.4 * (1080f / Tools.getDisplayMetrics((Activity) getContext()).heightPixels));

Expand Down

0 comments on commit 266be18

Please sign in to comment.