Commit 96320e5d authored by 神楽坂玲奈's avatar 神楽坂玲奈

fix

parent 4d0be090
...@@ -23,19 +23,21 @@ public class BackGroundPic : Servant ...@@ -23,19 +23,21 @@ public class BackGroundPic : Servant
public override void applyShowArrangement() public override void applyShowArrangement()
{ {
var s = (float) Utils.UIHeight() / Screen.height; var component = backGround.GetComponent<UITexture>();
var tex = backGround.GetComponent<UITexture>().mainTexture; var texture = component.mainTexture;
var ss = tex.height / (float) tex.width;
var width = (int) (Screen.width * s); if (texture.width <= texture.height * Screen.width / Screen.height)
var height = (int) (width * ss);
if (height < Screen.height)
{ {
height = (int) (Screen.height * s); // 图窄屏幕宽,用宽度
width = (int) (height / ss); component.width = Utils.UIWidth();
component.height = component.width * texture.height / texture.width;
}
else
{
// 图宽屏幕窄,用高度
component.height = Utils.UIHeight();
component.width = component.height * texture.width / texture.height;
} }
backGround.GetComponent<UITexture>().height = height + 2;
backGround.GetComponent<UITexture>().width = width + 2;
} }
public override void applyHideArrangement() public override void applyHideArrangement()
......
using System; using System;
using System.Linq;
using UnityEngine; using UnityEngine;
using UnityEngine.Assertions;
public class Setting : WindowServant2D public class Setting : WindowServant2D
{ {
...@@ -16,10 +18,19 @@ public class Setting : WindowServant2D ...@@ -16,10 +18,19 @@ public class Setting : WindowServant2D
private UISlider sliderVsize; private UISlider sliderVsize;
public int star = 5; public int star = 5;
private UIPopupList _screen;
public override void initialize() public override void initialize()
{ {
gameObject = SetWindow(this, Program.I().new_ui_setting); gameObject = SetWindow(this, Program.I().new_ui_setting);
setting = gameObject.GetComponentInChildren<LAZYsetting>(); setting = gameObject.GetComponentInChildren<LAZYsetting>();
_screen = UIHelper.getByName<UIPopupList>(gameObject, "screen_");
_screen.items = new[] {new UnityEngine.Resolution {width = 1300, height = 700}}.Concat(Screen.resolutions)
.Select(r => $"{r.width} x {r.height}")
.Distinct()
.ToList();
UIHelper.registEvent(gameObject, "exit_", onClickExit); UIHelper.registEvent(gameObject, "exit_", onClickExit);
UIHelper.registEvent(gameObject, "screen_", resizeScreen); UIHelper.registEvent(gameObject, "screen_", resizeScreen);
UIHelper.registEvent(gameObject, "full_", resizeScreen); UIHelper.registEvent(gameObject, "full_", resizeScreen);
...@@ -85,7 +96,7 @@ public class Setting : WindowServant2D ...@@ -85,7 +96,7 @@ public class Setting : WindowServant2D
UIHelper.registEvent(setting.Vlink.gameObject, onCP); UIHelper.registEvent(setting.Vlink.gameObject, onCP);
onchangeMouse(); onchangeMouse();
onchangeCloud(); onchangeCloud();
setScreenSizeValue(); SetScreenSizeValue();
} }
private void readVales() private void readVales()
...@@ -117,10 +128,10 @@ public class Setting : WindowServant2D ...@@ -117,10 +128,10 @@ public class Setting : WindowServant2D
//private int dontResizeTwice = 2; //private int dontResizeTwice = 2;
public void setScreenSizeValue() public void SetScreenSizeValue()
{ {
//dontResizeTwice = 3; var target = $"{Screen.currentResolution.width} x {Screen.currentResolution.height}";
UIHelper.getByName<UIPopupList>(gameObject, "screen_").value = Screen.width + "*" + Screen.height; if (_screen.value != target) _screen.value = target;
} }
private void onCP() private void onCP()
...@@ -220,12 +231,17 @@ public class Setting : WindowServant2D ...@@ -220,12 +231,17 @@ public class Setting : WindowServant2D
//dontResizeTwice = 2; //dontResizeTwice = 2;
if (UIHelper.isMaximized()) if (UIHelper.isMaximized())
UIHelper.RestoreWindow(); UIHelper.RestoreWindow();
var mats = UIHelper.getByName<UIPopupList>(gameObject, "screen_").value var mats = UIHelper.getByName<UIPopupList>(gameObject, "screen_").value
.Split(new[] {"*"}, StringSplitOptions.RemoveEmptyEntries); .Split(new[] {" x "}, StringSplitOptions.RemoveEmptyEntries);
if (mats.Length == 2) Assert.IsTrue(mats.Length == 2);
Screen.SetResolution(int.Parse(mats[0]), int.Parse(mats[1]), Screen.SetResolution(int.Parse(mats[0]), int.Parse(mats[1]),
UIHelper.getByName<UIToggle>(gameObject, "full_").value); UIHelper.getByName<UIToggle>(gameObject, "full_").value);
Program.go(100, () => { Program.I().fixScreenProblems(); }); Program.go(100, () =>
{
SetScreenSizeValue();
Program.I().fixScreenProblems();
});
} }
public void saveWhenQuit() public void saveWhenQuit()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment