Skip to content

Commit

Permalink
调整[游戏内分辨率缩放]: 使用自定义dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Vera-Firefly committed Oct 26, 2024
1 parent eafbb10 commit 5be3c1d
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.firefly.utils;

import android.app.AlertDialog;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.LinearLayout;

import com.firefly.ui.dialog.CustomDialog;

import net.kdt.pojavlaunch.prefs.LauncherPreferences;
import net.kdt.pojavlaunch.R;
import net.kdt.pojavlaunch.Tools;
Expand All @@ -36,7 +36,7 @@ public void showSeekBarDialog() {
// 因为麻烦
LinearLayout layout = new LinearLayout(context);
layout.setOrientation(LinearLayout.HORIZONTAL); // 设置水平排列
layout.setPadding(50, 40, 50, 20);
layout.setPadding(50, 8, 50, 8);
layout.setGravity(Gravity.CENTER);

// 动态创建一个 SeekBar ,用于调整缩放因子
Expand Down Expand Up @@ -91,13 +91,14 @@ public void onStopTrackingTouch(SeekBar seekBar) {
});

// 创建并显示弹窗
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(context.getString(R.string.mcl_setting_title_resolution_scaler));
builder.setView(layout);
builder.setCancelable(false); // 不允许点击外部关闭弹窗,防止进程错误
// 设置确认按钮, 点击关闭弹窗
builder.setPositiveButton(android.R.string.ok, (d, i) -> d.dismiss());
builder.show();
new CustomDialog.Builder(context)
.setTitle(context.getString(R.string.mcl_setting_title_resolution_scaler))
.setCustomView(layout)
.setCancelable(false)
.setDraggable(true)
.setConfirmListener(android.R.string.ok, customView -> true)
.build()
.show();
}

private void changeResolutionRatioPreview(int progress, TextView resolutionTextView) {
Expand Down

0 comments on commit 5be3c1d

Please sign in to comment.