mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Android Launcher: Remove unused settings + add scaling (#2239)
* Remove Resolution Config * Remove swipe option * Add scaling as a setting
This commit is contained in:
		| @@ -26,7 +26,8 @@ import eu.vcmi.vcmi.settings.ModsBtnController; | ||||
| import eu.vcmi.vcmi.settings.MusicSettingController; | ||||
| import eu.vcmi.vcmi.settings.PointerModeSettingController; | ||||
| import eu.vcmi.vcmi.settings.PointerMultiplierSettingController; | ||||
| import eu.vcmi.vcmi.settings.ScreenResSettingController; | ||||
| import eu.vcmi.vcmi.settings.ScreenScaleSettingController; | ||||
| import eu.vcmi.vcmi.settings.ScreenScaleSettingDialog; | ||||
| import eu.vcmi.vcmi.settings.SoundSettingController; | ||||
| import eu.vcmi.vcmi.settings.StartGameController; | ||||
| import eu.vcmi.vcmi.util.FileUtil; | ||||
| @@ -44,11 +45,11 @@ public class ActivityLauncher extends ActivityWithToolbar | ||||
|     private View mProgress; | ||||
|     private TextView mErrorMessage; | ||||
|     private Config mConfig; | ||||
|     private LauncherSettingController<ScreenResSettingController.ScreenRes, Config> mCtrlScreenRes; | ||||
|     private LauncherSettingController<String, Config> mCtrlLanguage; | ||||
|     private LauncherSettingController<PointerModeSettingController.PointerMode, Config> mCtrlPointerMode; | ||||
|     private LauncherSettingController<Void, Void> mCtrlStart; | ||||
|     private LauncherSettingController<Float, Config> mCtrlPointerMulti; | ||||
|     private LauncherSettingController<ScreenScaleSettingController.ScreenScale, Config> mCtrlScreenScale; | ||||
|     private LauncherSettingController<Integer, Config> mCtrlSoundVol; | ||||
|     private LauncherSettingController<Integer, Config> mCtrlMusicVol; | ||||
|     private LauncherSettingController<String, Config> mAiController; | ||||
| @@ -202,19 +203,19 @@ public class ActivityLauncher extends ActivityWithToolbar | ||||
|         (mCtrlCopy = new CopyDataController(this)).init(R.id.launcher_btn_copy); | ||||
|         (mCtrlExport = new ExportDataController(this)).init(R.id.launcher_btn_export); | ||||
|         new ModsBtnController(this, v -> startActivity(new Intent(ActivityLauncher.this, ActivityMods.class))).init(R.id.launcher_btn_mods); | ||||
|         mCtrlScreenRes = new ScreenResSettingController(this).init(R.id.launcher_btn_res, mConfig); | ||||
|         mCtrlLanguage = new LanguageSettingController(this).init(R.id.launcher_btn_cp, mConfig); | ||||
|         mCtrlPointerMode = new PointerModeSettingController(this).init(R.id.launcher_btn_pointer_mode, mConfig); | ||||
|         mCtrlPointerMulti = new PointerMultiplierSettingController(this).init(R.id.launcher_btn_pointer_multi, mConfig); | ||||
|         mCtrlScreenScale = new ScreenScaleSettingController(this).init(R.id.launcher_btn_scale, mConfig); | ||||
|         mCtrlSoundVol = new SoundSettingController(this).init(R.id.launcher_btn_volume_sound, mConfig); | ||||
|         mCtrlMusicVol = new MusicSettingController(this).init(R.id.launcher_btn_volume_music, mConfig); | ||||
|         mAiController = new AdventureAiController(this).init(R.id.launcher_btn_adventure_ai, mConfig); | ||||
|  | ||||
|         mActualSettings.clear(); | ||||
|         mActualSettings.add(mCtrlLanguage); | ||||
|         mActualSettings.add(mCtrlScreenRes); | ||||
|         mActualSettings.add(mCtrlPointerMode); | ||||
|         mActualSettings.add(mCtrlPointerMulti); | ||||
|         mActualSettings.add(mCtrlScreenScale); | ||||
|         mActualSettings.add(mCtrlSoundVol); | ||||
|         mActualSettings.add(mCtrlMusicVol); | ||||
|         mActualSettings.add(mAiController); | ||||
| @@ -266,10 +267,13 @@ public class ActivityLauncher extends ActivityWithToolbar | ||||
|  | ||||
|     private void onConfigUpdated() | ||||
|     { | ||||
|         updateCtrlConfig(mCtrlScreenRes, mConfig); | ||||
|         if(mConfig.mScreenScale == -1) | ||||
|             mConfig.updateScreenScale(ScreenScaleSettingDialog.getSupportedScalingRange(ActivityLauncher.this)[1]); | ||||
|  | ||||
|         updateCtrlConfig(mCtrlLanguage, mConfig); | ||||
|         updateCtrlConfig(mCtrlPointerMode, mConfig); | ||||
|         updateCtrlConfig(mCtrlPointerMulti, mConfig); | ||||
|         updateCtrlConfig(mCtrlScreenScale, mConfig); | ||||
|         updateCtrlConfig(mCtrlSoundVol, mConfig); | ||||
|         updateCtrlConfig(mCtrlMusicVol, mConfig); | ||||
|         updateCtrlConfig(mAiController, mConfig); | ||||
|   | ||||
| @@ -17,13 +17,9 @@ public class Config | ||||
|     public static final String DEFAULT_LANGUAGE = "english"; | ||||
|     public static final int DEFAULT_MUSIC_VALUE = 5; | ||||
|     public static final int DEFAULT_SOUND_VALUE = 5; | ||||
|     public static final int DEFAULT_SCREEN_RES_W = 800; | ||||
|     public static final int DEFAULT_SCREEN_RES_H = 600; | ||||
|  | ||||
|     public String mLanguage; | ||||
|     public int mResolutionWidth; | ||||
|     public int mResolutionHeight; | ||||
|     public boolean mSwipeEnabled; | ||||
|     public int mScreenScale; | ||||
|     public int mVolumeSound; | ||||
|     public int mVolumeMusic; | ||||
|     private String adventureAi; | ||||
| @@ -43,7 +39,7 @@ public class Config | ||||
|         return baseObj.optJSONObject(type); | ||||
|     } | ||||
|  | ||||
|     private static JSONObject accessScreenResNode(final JSONObject baseObj) | ||||
|     private static JSONObject accessResolutionNode(final JSONObject baseObj) | ||||
|     { | ||||
|         if (baseObj == null) | ||||
|         { | ||||
| @@ -53,7 +49,7 @@ public class Config | ||||
|         final JSONObject video = baseObj.optJSONObject("video"); | ||||
|         if (video != null) | ||||
|         { | ||||
|             return video.optJSONObject("screenRes"); | ||||
|             return video.optJSONObject("resolution"); | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
| @@ -85,18 +81,15 @@ public class Config | ||||
|         final Config config = new Config(); | ||||
|         final JSONObject general = accessNode(obj, "general"); | ||||
|         final JSONObject server = accessNode(obj, "server"); | ||||
|         final JSONObject resolution = accessResolutionNode(obj); | ||||
|         config.mLanguage = loadEntry(general, "language", DEFAULT_LANGUAGE); | ||||
|         config.mScreenScale = loadEntry(resolution, "scaling", -1); | ||||
|         config.mVolumeSound = loadEntry(general, "sound", DEFAULT_SOUND_VALUE); | ||||
|         config.mVolumeMusic = loadEntry(general, "music", DEFAULT_MUSIC_VALUE); | ||||
|         config.mSwipeEnabled = loadEntry(general, "swipe", true); | ||||
|         config.adventureAi = loadEntry(server, "playerAI", "Nullkiller"); | ||||
|         config.mUseRelativePointer = loadEntry(general, "userRelativePointer", false); | ||||
|         config.mPointerSpeedMultiplier = loadDouble(general, "relativePointerSpeedMultiplier", 1.0); | ||||
|  | ||||
|         final JSONObject screenRes = accessScreenResNode(obj); | ||||
|         config.mResolutionWidth = loadEntry(screenRes, "width", DEFAULT_SCREEN_RES_W); | ||||
|         config.mResolutionHeight = loadEntry(screenRes, "height", DEFAULT_SCREEN_RES_H); | ||||
|  | ||||
|         config.mRawObject = obj; | ||||
|         return config; | ||||
|     } | ||||
| @@ -107,16 +100,9 @@ public class Config | ||||
|         mIsModified = true; | ||||
|     } | ||||
|  | ||||
|     public void updateResolution(final int x, final int y) | ||||
|     public void updateScreenScale(final int scale) | ||||
|     { | ||||
|         mResolutionWidth = x; | ||||
|         mResolutionHeight = y; | ||||
|         mIsModified = true; | ||||
|     } | ||||
|  | ||||
|     public void updateSwipe(final boolean b) | ||||
|     { | ||||
|         mSwipeEnabled = b; | ||||
|         mScreenScale = scale; | ||||
|         mIsModified = true; | ||||
|     } | ||||
|  | ||||
| @@ -194,12 +180,12 @@ public class Config | ||||
|     { | ||||
|         final JSONObject generalNode = accessNode(mRawObject, "general"); | ||||
|         final JSONObject serverNode = accessNode(mRawObject, "server"); | ||||
|         final JSONObject screenResNode = accessScreenResNode(mRawObject); | ||||
|         final JSONObject resolutionNode = accessResolutionNode(mRawObject); | ||||
|  | ||||
|         final JSONObject root = mRawObject == null ? new JSONObject() : mRawObject; | ||||
|         final JSONObject general = generalNode == null ? new JSONObject() : generalNode; | ||||
|         final JSONObject video = new JSONObject(); | ||||
|         final JSONObject screenRes = screenResNode == null ? new JSONObject() : screenResNode; | ||||
|         final JSONObject resolution = resolutionNode == null ? new JSONObject() : resolutionNode; | ||||
|         final JSONObject server = serverNode == null ? new JSONObject() : serverNode; | ||||
|  | ||||
|         if (mLanguage != null) | ||||
| @@ -207,7 +193,6 @@ public class Config | ||||
|             general.put("language", mLanguage); | ||||
|         } | ||||
|  | ||||
|         general.put("swipe", mSwipeEnabled); | ||||
|         general.put("music", mVolumeMusic); | ||||
|         general.put("sound", mVolumeSound); | ||||
|         general.put("userRelativePointer", mUseRelativePointer); | ||||
| @@ -220,11 +205,10 @@ public class Config | ||||
|             root.put("server", server); | ||||
|         } | ||||
|  | ||||
|         if (mResolutionHeight > 0 && mResolutionWidth > 0) | ||||
|         if (mScreenScale > 0) | ||||
|         { | ||||
|             screenRes.put("width", mResolutionWidth); | ||||
|             screenRes.put("height", mResolutionHeight); | ||||
|             video.put("screenRes", screenRes); | ||||
|             resolution.put("scaling", mScreenScale); | ||||
|             video.put("resolution", resolution); | ||||
|             root.put("video", video); | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -25,7 +25,6 @@ public class PointerModeSettingController | ||||
|     public void onItemChosen(final PointerMode item) | ||||
|     { | ||||
|         mConfig.setPointerMode(item == PointerMode.RELATIVE); | ||||
|         mConfig.updateSwipe(item.supportsSwipe()); | ||||
|         updateContent(); | ||||
|     } | ||||
|  | ||||
| @@ -53,23 +52,12 @@ public class PointerModeSettingController | ||||
|             return PointerMode.RELATIVE; | ||||
|         } | ||||
|  | ||||
|         if(mConfig.mSwipeEnabled) | ||||
|         { | ||||
|             return PointerMode.NORMAL_WITH_SWIPE; | ||||
|         } | ||||
|  | ||||
|         return PointerMode.NORMAL; | ||||
|     } | ||||
|  | ||||
|     public enum PointerMode | ||||
|     { | ||||
|         NORMAL, | ||||
|         NORMAL_WITH_SWIPE, | ||||
|         RELATIVE; | ||||
|  | ||||
|         public boolean supportsSwipe() | ||||
|         { | ||||
|             return this == NORMAL_WITH_SWIPE; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -17,7 +17,6 @@ public class PointerModeSettingDialog extends LauncherSettingDialog<PointerModeS | ||||
|     static | ||||
|     { | ||||
|         POINTER_MODES.add(PointerModeSettingController.PointerMode.NORMAL); | ||||
|         POINTER_MODES.add(PointerModeSettingController.PointerMode.NORMAL_WITH_SWIPE); | ||||
|         POINTER_MODES.add(PointerModeSettingController.PointerMode.RELATIVE); | ||||
|     } | ||||
|  | ||||
| @@ -36,8 +35,6 @@ public class PointerModeSettingDialog extends LauncherSettingDialog<PointerModeS | ||||
|                 return ""; | ||||
|             case NORMAL: | ||||
|                 return ctx.getString(R.string.misc_pointermode_normal); | ||||
|             case NORMAL_WITH_SWIPE: | ||||
|                 return ctx.getString(R.string.misc_pointermode_swipe); | ||||
|             case RELATIVE: | ||||
|                 return ctx.getString(R.string.misc_pointermode_relative); | ||||
|         } | ||||
|   | ||||
| @@ -1,66 +0,0 @@ | ||||
| package eu.vcmi.vcmi.settings; | ||||
|  | ||||
| import androidx.appcompat.app.AppCompatActivity; | ||||
|  | ||||
| import eu.vcmi.vcmi.Config; | ||||
| import eu.vcmi.vcmi.R; | ||||
|  | ||||
| /** | ||||
|  * @author F | ||||
|  */ | ||||
| public class ScreenResSettingController extends LauncherSettingWithDialogController<ScreenResSettingController.ScreenRes, Config> | ||||
| { | ||||
|     public ScreenResSettingController(final AppCompatActivity activity) | ||||
|     { | ||||
|         super(activity); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected LauncherSettingDialog<ScreenRes> dialog() | ||||
|     { | ||||
|         return new ScreenResSettingDialog(mActivity); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void onItemChosen(final ScreenRes item) | ||||
|     { | ||||
|         mConfig.updateResolution(item.mWidth, item.mHeight); | ||||
|         updateContent(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected String mainText() | ||||
|     { | ||||
|         return mActivity.getString(R.string.launcher_btn_res_title); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected String subText() | ||||
|     { | ||||
|         if (mConfig == null) | ||||
|         { | ||||
|             return ""; | ||||
|         } | ||||
|         return mConfig.mResolutionWidth <= 0 || mConfig.mResolutionHeight <= 0 | ||||
|                ? mActivity.getString(R.string.launcher_btn_res_subtitle_unknown) | ||||
|                : mActivity.getString(R.string.launcher_btn_res_subtitle, mConfig.mResolutionWidth, mConfig.mResolutionHeight); | ||||
|     } | ||||
|  | ||||
|     public static class ScreenRes | ||||
|     { | ||||
|         public int mWidth; | ||||
|         public int mHeight; | ||||
|  | ||||
|         public ScreenRes(final int width, final int height) | ||||
|         { | ||||
|             mWidth = width; | ||||
|             mHeight = height; | ||||
|         } | ||||
|  | ||||
|         @Override | ||||
|         public String toString() | ||||
|         { | ||||
|             return mWidth + "x" + mHeight; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -1,104 +0,0 @@ | ||||
| package eu.vcmi.vcmi.settings; | ||||
|  | ||||
| import android.app.Activity; | ||||
|  | ||||
| import org.json.JSONArray; | ||||
| import org.json.JSONObject; | ||||
| import java.io.File; | ||||
| import java.util.ArrayDeque; | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.Queue; | ||||
| import eu.vcmi.vcmi.R; | ||||
| import eu.vcmi.vcmi.Storage; | ||||
| import eu.vcmi.vcmi.util.FileUtil; | ||||
|  | ||||
| /** | ||||
|  * @author F | ||||
|  */ | ||||
| public class ScreenResSettingDialog extends LauncherSettingDialog<ScreenResSettingController.ScreenRes> | ||||
| { | ||||
|     public ScreenResSettingDialog(Activity mActivity) | ||||
|     { | ||||
|         super(loadResolutions(mActivity)); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected int dialogTitleResId() | ||||
|     { | ||||
|         return R.string.launcher_btn_res_title; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected CharSequence itemName(final ScreenResSettingController.ScreenRes item) | ||||
|     { | ||||
|         return item.toString(); | ||||
|     } | ||||
|  | ||||
|     private static List<ScreenResSettingController.ScreenRes> loadResolutions(Activity activity) | ||||
|     { | ||||
|         List<ScreenResSettingController.ScreenRes> availableResolutions = new ArrayList<>(); | ||||
|  | ||||
|         try | ||||
|         { | ||||
|             File modsFolder = new File(Storage.getVcmiDataDir(activity), "Mods"); | ||||
|             Queue<File> folders = new ArrayDeque<File>(); | ||||
|             folders.offer(modsFolder); | ||||
|  | ||||
|             while (!folders.isEmpty()) | ||||
|             { | ||||
|                 File folder = folders.poll(); | ||||
|                 File[] children = folder.listFiles(); | ||||
|  | ||||
|                 if(children == null) continue; | ||||
|  | ||||
|                 for (File child : children) | ||||
|                 { | ||||
|                     if (child.isDirectory()) | ||||
|                     { | ||||
|                         folders.add(child); | ||||
|                     } | ||||
|                     else if (child.getName().equals("resolutions.json")) | ||||
|                     { | ||||
|                         JSONArray resolutions = new JSONObject(FileUtil.read(child)) | ||||
|                                 .getJSONArray("GUISettings"); | ||||
|  | ||||
|                         for(int index = 0; index < resolutions.length(); index++) | ||||
|                         { | ||||
|                             try | ||||
|                             { | ||||
|                                 JSONObject resolution = resolutions | ||||
|                                         .getJSONObject(index) | ||||
|                                         .getJSONObject("resolution"); | ||||
|  | ||||
|                                 availableResolutions.add(new ScreenResSettingController.ScreenRes( | ||||
|                                         resolution.getInt("x"), | ||||
|                                         resolution.getInt("y") | ||||
|                                 )); | ||||
|                             } | ||||
|                             catch (Exception ex) | ||||
|                             { | ||||
|                                 ex.printStackTrace(); | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             if(availableResolutions.isEmpty()) | ||||
|             { | ||||
|                 availableResolutions.add(new ScreenResSettingController.ScreenRes(800, 600)); | ||||
|             } | ||||
|         } | ||||
|         catch(Exception ex) | ||||
|         { | ||||
|             ex.printStackTrace(); | ||||
|  | ||||
|             availableResolutions.clear(); | ||||
|  | ||||
|             availableResolutions.add(new ScreenResSettingController.ScreenRes(800, 600)); | ||||
|         } | ||||
|  | ||||
|         return availableResolutions; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,64 @@ | ||||
| package eu.vcmi.vcmi.settings; | ||||
|  | ||||
| import androidx.appcompat.app.AppCompatActivity; | ||||
|  | ||||
| import eu.vcmi.vcmi.Config; | ||||
| import eu.vcmi.vcmi.R; | ||||
|  | ||||
| /** | ||||
|  * @author F | ||||
|  */ | ||||
| public class ScreenScaleSettingController extends LauncherSettingWithDialogController<ScreenScaleSettingController.ScreenScale, Config> | ||||
| { | ||||
|     public ScreenScaleSettingController(final AppCompatActivity activity) | ||||
|     { | ||||
|         super(activity); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected LauncherSettingDialog<ScreenScale> dialog() | ||||
|     { | ||||
|         return new ScreenScaleSettingDialog(mActivity); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void onItemChosen(final ScreenScale item) | ||||
|     { | ||||
|         mConfig.updateScreenScale(item.mScreenScale); | ||||
|         updateContent(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected String mainText() | ||||
|     { | ||||
|         return mActivity.getString(R.string.launcher_btn_scale_title); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected String subText() | ||||
|     { | ||||
|         if (mConfig == null) | ||||
|         { | ||||
|             return ""; | ||||
|         } | ||||
|         return mConfig.mScreenScale <= 0 | ||||
|                ? mActivity.getString(R.string.launcher_btn_scale_subtitle_unknown) | ||||
|                : mActivity.getString(R.string.launcher_btn_scale_subtitle, mConfig.mScreenScale); | ||||
|     } | ||||
|  | ||||
|     public static class ScreenScale | ||||
|     { | ||||
|         public int mScreenScale; | ||||
|  | ||||
|         public ScreenScale(final int scale) | ||||
|         { | ||||
|             mScreenScale = scale; | ||||
|         } | ||||
|  | ||||
|         @Override | ||||
|         public String toString() | ||||
|         { | ||||
|             return mScreenScale + "%"; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,98 @@ | ||||
| package eu.vcmi.vcmi.settings; | ||||
|  | ||||
| import android.app.Activity; | ||||
| import android.graphics.Point; | ||||
| import android.view.WindowMetrics; | ||||
|  | ||||
| import org.json.JSONArray; | ||||
| import org.json.JSONObject; | ||||
| import java.io.File; | ||||
| import java.util.ArrayDeque; | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.Queue; | ||||
| import eu.vcmi.vcmi.R; | ||||
| import eu.vcmi.vcmi.Storage; | ||||
| import eu.vcmi.vcmi.util.FileUtil; | ||||
|  | ||||
| /** | ||||
|  * @author F | ||||
|  */ | ||||
| public class ScreenScaleSettingDialog extends LauncherSettingDialog<ScreenScaleSettingController.ScreenScale> | ||||
| { | ||||
|     public ScreenScaleSettingDialog(Activity mActivity) | ||||
|     { | ||||
|         super(loadScales(mActivity)); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected int dialogTitleResId() | ||||
|     { | ||||
|         return R.string.launcher_btn_scale_title; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected CharSequence itemName(final ScreenScaleSettingController.ScreenScale item) | ||||
|     { | ||||
|         return item.toString(); | ||||
|     } | ||||
|  | ||||
|     public static int[] getSupportedScalingRange(Activity activity) { | ||||
|         Point screenRealSize = new Point(); | ||||
|         if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) { | ||||
|             WindowMetrics windowMetrics = activity.getWindowManager().getCurrentWindowMetrics(); | ||||
|             screenRealSize.x = windowMetrics.getBounds().width(); | ||||
|             screenRealSize.y = windowMetrics.getBounds().height(); | ||||
|         } else { | ||||
|             activity.getWindowManager().getDefaultDisplay().getRealSize(screenRealSize); | ||||
|         } | ||||
|  | ||||
|         if (screenRealSize.x < screenRealSize.y) { | ||||
|             int tmp = screenRealSize.x; | ||||
|             screenRealSize.x = screenRealSize.y; | ||||
|             screenRealSize.y = tmp; | ||||
|         } | ||||
|  | ||||
|         // H3 resolution, any resolution smaller than that is not correctly supported | ||||
|         Point minResolution = new Point(800, 600); | ||||
|         // arbitrary limit on *downscaling*. Allow some downscaling, if requested by user. Should be generally limited to 100+ for all but few devices | ||||
|         double minimalScaling = 50; | ||||
|  | ||||
|         Point renderResolution = screenRealSize; | ||||
|         double maximalScalingWidth = 100.0 * renderResolution.x / minResolution.x; | ||||
|         double maximalScalingHeight = 100.0 * renderResolution.y / minResolution.y; | ||||
|         double maximalScaling = Math.min(maximalScalingWidth, maximalScalingHeight); | ||||
|  | ||||
|         return new int[] { (int)minimalScaling, (int)maximalScaling }; | ||||
|     } | ||||
|  | ||||
|     private static List<ScreenScaleSettingController.ScreenScale> loadScales(Activity activity) | ||||
|     { | ||||
|         List<ScreenScaleSettingController.ScreenScale> availableScales = new ArrayList<>(); | ||||
|  | ||||
|         try | ||||
|         { | ||||
|             int[] supportedScalingRange = getSupportedScalingRange(activity); | ||||
|             for (int i = 0; i <= supportedScalingRange[1] + 10 - 1; i += 10) | ||||
|             { | ||||
|                 if (i >= supportedScalingRange[0]) | ||||
|                     availableScales.add(new ScreenScaleSettingController.ScreenScale(i)); | ||||
|             } | ||||
|  | ||||
|             if(availableScales.isEmpty()) | ||||
|             { | ||||
|                 availableScales.add(new ScreenScaleSettingController.ScreenScale(100)); | ||||
|             } | ||||
|         } | ||||
|         catch(Exception ex) | ||||
|         { | ||||
|             ex.printStackTrace(); | ||||
|  | ||||
|             availableScales.clear(); | ||||
|  | ||||
|             availableScales.add(new ScreenScaleSettingController.ScreenScale(100)); | ||||
|         } | ||||
|  | ||||
|         return availableScales; | ||||
|     } | ||||
| } | ||||
| @@ -76,7 +76,7 @@ | ||||
|             layout="@layout/inc_launcher_btn" /> | ||||
|  | ||||
|         <include | ||||
|             android:id="@+id/launcher_btn_res" | ||||
|             android:id="@+id/launcher_btn_scale" | ||||
|             layout="@layout/inc_launcher_btn" /> | ||||
|  | ||||
|         <include | ||||
|   | ||||
| @@ -2,10 +2,10 @@ | ||||
| <resources> | ||||
|     <string name="app_name">VCMI</string> | ||||
|     <string name="launcher_btn_start_title">VCMI starten</string> | ||||
|     <string name="launcher_btn_res_subtitle">Aktuell: %1$dx%2$d</string> | ||||
|     <string name="launcher_btn_res_subtitle_unknown">Aktuell: unbekannt (wahrscheinlich 800х600)</string> | ||||
|     <string name="launcher_btn_res_title">Bildschirmauflösung ändern</string> | ||||
|     <string name="launcher_title">VCMI-Starter</string> | ||||
|     <string name="launcher_btn_scale_title">Skalierung der Spielauflösung</string> | ||||
|     <string name="launcher_btn_scale_subtitle_unknown">Aktuell: unbekannt</string> | ||||
|     <string name="launcher_btn_scale_subtitle">Aktuell: %1$d%%</string> | ||||
|     <string name="server_name">VCMI-Server</string> | ||||
|     <string name="launcher_btn_start_subtitle">Aktuelle VCMI-Version: %1$s</string> | ||||
|     <string name="launcher_btn_mods_title">Mods</string> | ||||
| @@ -35,7 +35,6 @@ | ||||
|     <string name="launcher_section_settings">Einstellungen</string> | ||||
|     <string name="menu_mods_download_repo">Liste der Mods herunterladen</string> | ||||
|     <string name="misc_pointermode_normal">Normal</string> | ||||
|     <string name="misc_pointermode_swipe">Normal mit einer \"Ziehen\"-Geste auf der Karte</string> | ||||
|     <string name="misc_pointermode_relative">Relativ</string> | ||||
|     <string name="menu_launcher_about">Über</string> | ||||
|     <string name="mods_title">Installierte Mods</string> | ||||
|   | ||||
| @@ -3,9 +3,6 @@ | ||||
|     <string name="app_name">VCMI</string> | ||||
|     <string name="server_name">VCMI Serwer</string> | ||||
|     <string name="launcher_title">VCMI Launcher</string> | ||||
|     <string name="launcher_btn_res_title">Zmień natywną rozdzielczość gry</string> | ||||
|     <string name="launcher_btn_res_subtitle_unknown">Obecnie: nieznana (prawdopodobnie 800x600)</string> | ||||
|     <string name="launcher_btn_res_subtitle">Obecnie: %1$dx%2$d</string> | ||||
|     <string name="launcher_btn_start_title">Włącz VCMI</string> | ||||
|     <string name="launcher_btn_start_subtitle">Obecna wersja VCMI: %1$s</string> | ||||
|     <string name="launcher_btn_mods_title">Mody</string> | ||||
| @@ -35,7 +32,6 @@ | ||||
|     <string name="menu_mods_download_repo">Pobierz dane modów z repozytorium</string> | ||||
|  | ||||
|     <string name="misc_pointermode_normal">Normalny</string> | ||||
|     <string name="misc_pointermode_swipe">Normalny z przesuwaniem mapy</string> | ||||
|     <string name="misc_pointermode_relative">Relatywny</string> | ||||
|     <string name="menu_launcher_about">O programie</string> | ||||
|  | ||||
|   | ||||
| @@ -2,9 +2,6 @@ | ||||
| <resources> | ||||
|     <string name="app_name">VCMI</string> | ||||
|     <string name="launcher_btn_start_title">Запустить VCMI</string> | ||||
|     <string name="launcher_btn_res_subtitle">Текущее: %1$dx%2$d</string> | ||||
|     <string name="launcher_btn_res_subtitle_unknown">Текущее: неизвестно (вероятно 800х600)</string> | ||||
|     <string name="launcher_btn_res_title">Изменить разрешение экрана</string> | ||||
|     <string name="launcher_title">VCMI лаунчер</string> | ||||
|     <string name="server_name">VCMI сервер</string> | ||||
|     <string name="launcher_btn_start_subtitle">Текущая версия VCMI: %1$s</string> | ||||
| @@ -35,7 +32,6 @@ | ||||
|     <string name="launcher_section_settings">Настройки</string> | ||||
|     <string name="menu_mods_download_repo">Скачать список модов</string> | ||||
|     <string name="misc_pointermode_normal">Обычное</string> | ||||
|     <string name="misc_pointermode_swipe">Обычное с возможностью таскать карту</string> | ||||
|     <string name="misc_pointermode_relative">Относительное</string> | ||||
|     <string name="menu_launcher_about">О приложении</string> | ||||
|     <string name="mods_title">Установленные моды</string> | ||||
|   | ||||
| @@ -2,9 +2,6 @@ | ||||
| <resources> | ||||
|     <string name="app_name">VCMI</string> | ||||
|     <string name="launcher_btn_start_title">Запустити VCMI</string> | ||||
|     <string name="launcher_btn_res_subtitle">Поточне: %1$dx%2$d</string> | ||||
|     <string name="launcher_btn_res_subtitle_unknown">Поточне: невідомо (верогідно 800х600)</string> | ||||
|     <string name="launcher_btn_res_title">Змінити розмір екрану</string> | ||||
|     <string name="launcher_title">VCMI лаунчер</string> | ||||
|     <string name="server_name">VCMI сервер</string> | ||||
|     <string name="launcher_btn_start_subtitle">Поточна версія VCMI: %1$s</string> | ||||
| @@ -35,7 +32,6 @@ | ||||
|     <string name="launcher_section_settings">Налаштування</string> | ||||
|     <string name="menu_mods_download_repo">Завантажити список модів</string> | ||||
|     <string name="misc_pointermode_normal">Звичайне</string> | ||||
|     <string name="misc_pointermode_swipe">Звичайне з можливосттю тягати мапу</string> | ||||
|     <string name="misc_pointermode_relative">Відносне</string> | ||||
|     <string name="menu_launcher_about">О VCMI</string> | ||||
|     <string name="mods_title">Встановлені моди</string> | ||||
|   | ||||
| @@ -8,9 +8,9 @@ | ||||
|     <string name="app_name">VCMI</string> | ||||
|     <string name="server_name">VCMI Server</string> | ||||
|     <string name="launcher_title">VCMI Launcher</string> | ||||
|     <string name="launcher_btn_res_title">Change game native resolution</string> | ||||
|     <string name="launcher_btn_res_subtitle_unknown">Currently: unknown (probably 800x600)</string> | ||||
|     <string name="launcher_btn_res_subtitle">Currently: %1$dx%2$d</string> | ||||
|     <string name="launcher_btn_scale_title">Game resolution scale</string> | ||||
|     <string name="launcher_btn_scale_subtitle_unknown">Currently: unknown</string> | ||||
|     <string name="launcher_btn_scale_subtitle">Currently: %1$d%%</string> | ||||
|     <string name="launcher_btn_start_title">Start VCMI</string> | ||||
|     <string name="launcher_btn_start_subtitle">Current VCMI version: %1$s</string> | ||||
|     <string name="launcher_btn_mods_title">Mods</string> | ||||
| @@ -45,7 +45,6 @@ | ||||
|     <string name="menu_mods_download_repo">Download repository data</string> | ||||
|  | ||||
|     <string name="misc_pointermode_normal">Normal</string> | ||||
|     <string name="misc_pointermode_swipe">Normal with map dragging</string> | ||||
|     <string name="misc_pointermode_relative">Relative</string> | ||||
|     <string name="menu_launcher_about">About</string> | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user