Commit 3606ed65 authored by hex's avatar hex

Remove saved window position offsets, always center popup windows

parent d7adc838
Pipeline #38385 failed
using UnityEngine; using System;
using System; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Collections.Generic; using UnityEngine;
public class Menu : WindowServantSP public class Menu : WindowServantSP
{ {
//GameObject screen; //GameObject screen;
public override void initialize() public override void initialize()
...@@ -40,6 +40,7 @@ public class Menu : WindowServantSP ...@@ -40,6 +40,7 @@ public class Menu : WindowServantSP
static int Version = 0; static int Version = 0;
string upurl = ""; string upurl = "";
void up() void up()
{ {
try try
...@@ -80,6 +81,7 @@ public class Menu : WindowServantSP ...@@ -80,6 +81,7 @@ public class Menu : WindowServantSP
} }
bool outed = false; bool outed = false;
public override void preFrameFunction() public override void preFrameFunction()
{ {
base.preFrameFunction(); base.preFrameFunction();
...@@ -154,15 +156,29 @@ public class Menu : WindowServantSP ...@@ -154,15 +156,29 @@ public class Menu : WindowServantSP
Application.OpenURL("https://github.com/Unicorn369/closeup_mobile/releases/tag/0.1"); Application.OpenURL("https://github.com/Unicorn369/closeup_mobile/releases/tag/0.1");
#elif UNITY_ANDROID //Android #elif UNITY_ANDROID //Android
AndroidJavaObject jo = new AndroidJavaObject("cn.unicorn369.library.API"); AndroidJavaObject jo = new AndroidJavaObject("cn.unicorn369.library.API");
if (!File.Exists("updates/closeup_0.1.txt")) {//用于检查更新 if (!File.Exists("updates/closeup_0.1.txt"))
if (File.Exists("closeup_0.1.zip")) {//如果有则直接解压 { //用于检查更新
if (File.Exists("closeup_0.1.zip"))
{ //如果有则直接解压
jo.Call("doExtractZipFile", "closeup_0.1.zip", Program.ANDROID_GAME_PATH); jo.Call("doExtractZipFile", "closeup_0.1.zip", Program.ANDROID_GAME_PATH);
} else if (File.Exists("updates/closeup_0.1.txt")){//如果有则下载更新包
jo.Call("doDownloadZipFile", "https://github.com/Unicorn369/closeup_mobile/releases/download/0.1/closeup_0.1.zip");
} else {//否则下载并解压,锁定目录:ANDROID_GAME_PATH
jo.Call("doDownloadZipFile", "https://github.com/Unicorn369/closeup_mobile/releases/download/0.1/closeup_0.1.zip");
} }
} else { else if (File.Exists("updates/closeup_0.1.txt"))
{ //如果有则下载更新包
jo.Call(
"doDownloadZipFile",
"https://github.com/Unicorn369/closeup_mobile/releases/download/0.1/closeup_0.1.zip"
);
}
else
{ //否则下载并解压,锁定目录:ANDROID_GAME_PATH
jo.Call(
"doDownloadZipFile",
"https://github.com/Unicorn369/closeup_mobile/releases/download/0.1/closeup_0.1.zip"
);
}
}
else
{
jo.Call("showToast", "已是最新,无需再次下载!"); jo.Call("showToast", "已是最新,无需再次下载!");
Program.PrintToChat(InterString.Get("已是最新,无需再次下载!")); Program.PrintToChat(InterString.Get("已是最新,无需再次下载!"));
} }
...@@ -178,12 +194,11 @@ public class Menu : WindowServantSP ...@@ -178,12 +194,11 @@ public class Menu : WindowServantSP
File.Delete("commamd.shell"); File.Delete("commamd.shell");
} }
} }
catch (Exception) catch (Exception) { }
{
}
} }
static int lastTime = 0; static int lastTime = 0;
public static void checkCommend() public static void checkCommend()
{ {
if (Program.TimePassed() - lastTime > 1000) if (Program.TimePassed() - lastTime > 1000)
...@@ -223,7 +238,7 @@ public class Menu : WindowServantSP ...@@ -223,7 +238,7 @@ public class Menu : WindowServantSP
string all = ""; string all = "";
try try
{ {
all = File.ReadAllText("commamd.shell",Encoding.UTF8); all = File.ReadAllText("commamd.shell", Encoding.UTF8);
string[] mats = all.Split(" "); string[] mats = all.Split(" ");
if (mats.Length > 0) if (mats.Length > 0)
{ {
...@@ -232,33 +247,43 @@ public class Menu : WindowServantSP ...@@ -232,33 +247,43 @@ public class Menu : WindowServantSP
case "online": case "online":
if (mats.Length == 5) if (mats.Length == 5)
{ {
UIHelper.iniFaces();//加载用户头像 UIHelper.iniFaces(); //加载用户头像
Program.I().selectServer.KF_onlineGame(mats[1], mats[2], mats[3], mats[4]); Program
.I()
.selectServer.KF_onlineGame(mats[1], mats[2], mats[3], mats[4]);
} }
if (mats.Length == 6) if (mats.Length == 6)
{ {
UIHelper.iniFaces(); UIHelper.iniFaces();
Program.I().selectServer.KF_onlineGame(mats[1], mats[2], mats[3], mats[4], mats[5]); Program
.I()
.selectServer.KF_onlineGame(
mats[1],
mats[2],
mats[3],
mats[4],
mats[5]
);
} }
break; break;
case "edit": case "edit":
if (mats.Length == 2) if (mats.Length == 2)
{ {
Program.I().selectDeck.KF_editDeck(mats[1]);//编辑卡组 Program.I().selectDeck.KF_editDeck(mats[1]); //编辑卡组
} }
break; break;
case "replay": case "replay":
if (mats.Length == 2) if (mats.Length == 2)
{ {
UIHelper.iniFaces(); UIHelper.iniFaces();
Program.I().selectReplay.KF_replay(mats[1]);//编辑录像 Program.I().selectReplay.KF_replay(mats[1]); //编辑录像
} }
break; break;
case "puzzle": case "puzzle":
if (mats.Length == 2) if (mats.Length == 2)
{ {
UIHelper.iniFaces(); UIHelper.iniFaces();
Program.I().puzzleMode.KF_puzzle(mats[1]);//运行残局 Program.I().puzzleMode.KF_puzzle(mats[1]); //运行残局
} }
break; break;
default: default:
......
using System; using System;
using UnityEngine; using UnityEngine;
public class WindowServantSP : Servant
public class WindowServantSP : Servant
{ {
public bool instanceHide = false; public bool instanceHide = false;
...@@ -31,7 +32,7 @@ public class WindowServantSP : Servant ...@@ -31,7 +32,7 @@ public class WindowServantSP : Servant
base.applyHideArrangement(); base.applyHideArrangement();
if (gameObject != null) if (gameObject != null)
{ {
if (instanceHide) if (instanceHide)
{ {
return; return;
} }
...@@ -51,7 +52,7 @@ public class WindowServantSP : Servant ...@@ -51,7 +52,7 @@ public class WindowServantSP : Servant
resize(); resize();
} }
public void SetActiveFalse() public void SetActiveFalse()
{ {
gameObject.SetActive(false); gameObject.SetActive(false);
} }
...@@ -101,19 +102,17 @@ public class WindowServantSP : Servant ...@@ -101,19 +102,17 @@ public class WindowServantSP : Servant
public void createWindow(GameObject mod) public void createWindow(GameObject mod)
{ {
gameObject = create gameObject = create(mod, Vector3.zero, Vector3.zero, false, Program.ui_windows_2d);
(
mod,
Vector3.zero,
Vector3.zero,
false,
Program.ui_windows_2d
);
UIHelper.InterGameObject(gameObject); UIHelper.InterGameObject(gameObject);
Vector3 v=new Vector3(); // Vector3 v = new Vector3();
v.x = Mathf.Clamp(Config.getFloat("x_" + gameObject.name), -0.5f, 0.5f) * (float)Screen.width; // v.x =
v.y = Mathf.Clamp(Config.getFloat("y_" + gameObject.name), -0.5f, 0.5f) * (float)Screen.height; // Mathf.Clamp(Config.getFloat("x_" + gameObject.name), -0.5f, 0.5f) * (float)Screen.width;
gameObject.transform.localPosition = v; // v.y =
// Mathf.Clamp(Config.getFloat("y_" + gameObject.name), -0.5f, 0.5f)
// * (float)Screen.height;
// gameObject.transform.localPosition = v;
// 原本是从配置读取坐标——删除或注释掉, 只进行居中显示
gameObject.transform.localPosition = Vector3.zero;
var panelKIller = gameObject.GetComponent<panelKIller>(); var panelKIller = gameObject.GetComponent<panelKIller>();
if (panelKIller == null) if (panelKIller == null)
{ {
...@@ -125,10 +124,13 @@ public class WindowServantSP : Servant ...@@ -125,10 +124,13 @@ public class WindowServantSP : Servant
public override void ES_quit() public override void ES_quit()
{ {
base.ES_quit(); base.ES_quit();
// 不再保存坐标
/*
if (gameObject != null) if (gameObject != null)
{ {
Config.setFloat("x_" + gameObject.name, gameObject.transform.localPosition.x / (float)Screen.width); Config.setFloat("x_" + gameObject.name, gameObject.transform.localPosition.x / (float)Screen.width);
Config.setFloat("y_" + gameObject.name, gameObject.transform.localPosition.y / (float)Screen.height); Config.setFloat("y_" + gameObject.name, gameObject.transform.localPosition.y / (float)Screen.height);
} }
*/
} }
} }
...@@ -1221,7 +1221,7 @@ MonoBehaviour: ...@@ -1221,7 +1221,7 @@ MonoBehaviour:
generateNormals: 0 generateNormals: 0
widgetsAreStatic: 0 widgetsAreStatic: 0
cullWhileDragging: 1 cullWhileDragging: 1
alwaysOnScreen: 0 alwaysOnScreen: 1
anchorOffset: 0 anchorOffset: 0
softBorderPadding: 1 softBorderPadding: 1
renderQueue: 0 renderQueue: 0
......
...@@ -184,7 +184,7 @@ PlayerSettings: ...@@ -184,7 +184,7 @@ PlayerSettings:
serializedVersion: 2 serializedVersion: 2
m_Bits: 238 m_Bits: 238
iPhoneSdkVersion: 988 iPhoneSdkVersion: 988
iOSTargetOSVersionString: 15.0 iOSTargetOSVersionString: 13.0
tvOSSdkVersion: 0 tvOSSdkVersion: 0
tvOSRequireExtendedGameController: 0 tvOSRequireExtendedGameController: 0
tvOSTargetOSVersionString: 9.0 tvOSTargetOSVersionString: 9.0
......
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