Commit 4694efba authored by hex's avatar hex

set default resolution to 1600x900

parent b8b5d27a
Pipeline #37628 failed
using UnityEngine;
using System;
using System;
using System.Collections.Generic;
using UnityEngine;
using YGOSharp.OCGWrapper.Enums;
public class CardDescription : Servant
......@@ -20,14 +20,13 @@ public class CardDescription : Servant
public override void initialize()
{
gameObject = create
(
gameObject = create(
Program.I().new_ui_cardDescription,
Program.camera_main_2d.ScreenToWorldPoint(new Vector3(-256, Screen.height /2, 600)),
Program.camera_main_2d.ScreenToWorldPoint(new Vector3(-256, Screen.height / 2, 600)),
new Vector3(0, 0, 0),
true,
Program.ui_back_ground_2d
);
);
picLoader = gameObject.AddComponent<cardPicLoader>();
picLoader.code = 0;
picLoader.uiTexture = UIHelper.getByName<UITexture>(gameObject, "pic_");
......@@ -39,19 +38,17 @@ public class CardDescription : Servant
monitor = UIHelper.getByName<UIPanel>(gameObject, "monitor");
deckPanel = gameObject.GetComponentInChildren<UIDeckPanel>();
line = UIHelper.getByName(gameObject, "line");
UIHelper.registEvent(gameObject,"pre_", onPre);
UIHelper.registEvent(gameObject, "next_", onNext);
UIHelper.registEvent(gameObject, "pre_", onPre);
UIHelper.registEvent(gameObject, "next_", onNext);
UIHelper.registEvent(gameObject, "big_", onb);
UIHelper.registEvent(gameObject, "small_", ons);
picSprite = UIHelper.getByName<UITexture>(gameObject, "pic_");
lineSprite = UIHelper.getByName<UISprite>(gameObject, "line");
try
{
description.textLabel.fontSize = int.Parse(Config.Get("fontSize","24"));
}
catch (System.Exception e)
{
description.textLabel.fontSize = int.Parse(Config.Get("fontSize", "24"));
}
catch (System.Exception e) { }
read();
myGraveStr = InterString.Get("我方墓地:");
myExtraStr = InterString.Get("我方额外:");
......@@ -103,7 +100,13 @@ public class CardDescription : Servant
if (gameObject != null)
{
underSprite.height = Screen.height + 4;
iTween.MoveTo(gameObject, Program.camera_main_2d.ScreenToWorldPoint(new Vector3(-underSprite.width-20, Screen.height / 2, 0)), 1.2f);
iTween.MoveTo(
gameObject,
Program.camera_main_2d.ScreenToWorldPoint(
new Vector3(-underSprite.width - 20, Screen.height / 2, 0)
),
1.2f
);
setTitle("");
resizer.gameObject.GetComponent<BoxCollider>().enabled = false;
}
......@@ -114,7 +117,11 @@ public class CardDescription : Servant
if (gameObject != null)
{
underSprite.height = Screen.height + 4;
iTween.MoveTo(gameObject, Program.camera_main_2d.ScreenToWorldPoint(new Vector3(-2, Screen.height / 2, 0)), 1.2f);
iTween.MoveTo(
gameObject,
Program.camera_main_2d.ScreenToWorldPoint(new Vector3(-2, Screen.height / 2, 0)),
1.2f
);
resizer.gameObject.GetComponent<BoxCollider>().enabled = true;
}
}
......@@ -132,11 +139,9 @@ public class CardDescription : Servant
ca = (int)(cb * 0.68) + 50;
}
underSprite.width = ca;
picSprite.height = cb;
}
catch (System.Exception e)
{
picSprite.height = cb;
}
catch (System.Exception e) { }
}
public void save()
......@@ -176,7 +181,7 @@ public class CardDescription : Servant
YGOSharp.Card currentCard = null;
public bool ifShowingThisCard(YGOSharp.Card card)
public bool ifShowingThisCard(YGOSharp.Card card)
{
return currentCard == card;
}
......@@ -210,7 +215,13 @@ public class CardDescription : Servant
picLoader.loaded_code = -1;
currentCard = card;
shiftCardShower(true);
Program.go(50, () => { shiftCardShower(true); });
Program.go(
50,
() =>
{
shiftCardShower(true);
}
);
}
public void shiftCardShower(bool show)
......@@ -244,7 +255,6 @@ public class CardDescription : Servant
string opExtraStr = "";
string opBanishedStr = "";
public void realizeMonitor()
{
if (monitor.gameObject.activeInHierarchy)
......@@ -322,14 +332,18 @@ public class CardDescription : Servant
int eachLine = 0;
float monitorHeight = 0;
void handleMonitorArea(List<gameCard> list,string hint)
void handleMonitorArea(List<gameCard> list, string hint)
{
if (list.Count > 0)
{
deckPanel.labs[currentLabelIndex].gameObject.SetActive(true);
deckPanel.labs[currentLabelIndex].text = hint;
deckPanel.labs[currentLabelIndex].width = (int)(monitor.width - 12);
deckPanel.labs[currentLabelIndex].transform.localPosition = new Vector3(monitor.width / 2, (monitor.height - 8) / 2 - 12 - currentHeight, 0);
deckPanel.labs[currentLabelIndex].transform.localPosition = new Vector3(
monitor.width / 2,
(monitor.height - 8) / 2 - 12 - currentHeight,
0
);
currentLabelIndex++;
currentHeight += 24;
float beginX = 6 + 22;
......@@ -339,7 +353,11 @@ public class CardDescription : Servant
{
var gp = UIHelper.get_hang_lie(i, eachLine);
quickCards[currentCardIndex].reCode(list[i].get_data().Id);
quickCards[currentCardIndex].transform.localPosition = new Vector3(beginX + 44 * gp.y, beginY - 60 * gp.x, 0);
quickCards[currentCardIndex].transform.localPosition = new Vector3(
beginX + 44 * gp.y,
beginY - 60 * gp.x,
0
);
currentCardIndex++;
}
int hangshu = list.Count / eachLine;
......@@ -351,7 +369,7 @@ public class CardDescription : Servant
currentHeight += 60 * hangshu;
}
}
public void onResized()
{
if (monitor.gameObject.activeInHierarchy)
......@@ -366,9 +384,9 @@ public class CardDescription : Servant
}
}
public void setData(YGOSharp.Card card, Texture2D def, string tail = "",bool force=false)
public void setData(YGOSharp.Card card, Texture2D def, string tail = "", bool force = false)
{
if (cardShowerWidget.alpha == 0&&force==false)
if (cardShowerWidget.alpha == 0 && force == false)
{
return;
}
......@@ -378,7 +396,7 @@ public class CardDescription : Servant
}
if (card.Id == 0)
{
apply(card,def,tail);
apply(card, def, tail);
return;
}
if (datas.Count > 0)
......@@ -389,7 +407,7 @@ public class CardDescription : Servant
{
card = card,
def = def,
tail = tail
tail = tail,
};
if (datas.Count > 300)
{
......@@ -400,13 +418,15 @@ public class CardDescription : Servant
return;
}
}
datas.Add(new data
{
card = card,
def = def,
tail = tail
});
if (datas.Count>300)
datas.Add(
new data
{
card = card,
def = def,
tail = tail,
}
);
if (datas.Count > 300)
{
datas.RemoveAt(0);
}
......@@ -416,7 +436,7 @@ public class CardDescription : Servant
public void setTitle(string title)
{
UIHelper.trySetLableText(gameObject,"title_",title);
UIHelper.trySetLableText(gameObject, "title_", title);
}
List<string> Logs = new List<string>();
......@@ -442,7 +462,7 @@ public class CardDescription : Servant
void clearOneLog()
{
if (Logs.Count>0)
if (Logs.Count > 0)
{
Logs.RemoveAt(0);
string all = "";
......@@ -454,17 +474,15 @@ public class CardDescription : Servant
{
all = all.Substring(0, all.Length - 1);
}
catch (System.Exception e)
{
}
catch (System.Exception e) { }
UIHelper.trySetLableTextList(UIHelper.getByName(gameObject, "chat_"), all);
}
else
{
UIHelper.trySetLableTextList(UIHelper.getByName(gameObject, "chat_"), "");
}
}
public void clearAllLog()
{
Program.notGo(clearOneLog);
......
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using UnityEngine;
......@@ -29,6 +29,7 @@ public class GameTextureManager
public class BitmapHelper
{
public System.Drawing.Color[,] colors = null;
public BitmapHelper(string path)
{
Bitmap bitmap;
......@@ -47,7 +48,11 @@ public class GameTextureManager
}
}
}
var bmpData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
var bmpData = bitmap.LockBits(
new Rectangle(0, 0, bitmap.Width, bitmap.Height),
ImageLockMode.ReadOnly,
PixelFormat.Format32bppArgb
);
IntPtr ptr = bmpData.Scan0;
int bytes = Math.Abs(bmpData.Stride) * bitmap.Height;
byte[] rgbValues = new byte[bytes];
......@@ -56,22 +61,21 @@ public class GameTextureManager
for (int counter = 0; counter < rgbValues.Length; counter += 4)
{
int i_am = counter / 4;
colors[i_am % bitmap.Width, i_am / bitmap.Width]
=
System.Drawing.Color.FromArgb(
colors[i_am % bitmap.Width, i_am / bitmap.Width] = System.Drawing.Color.FromArgb(
rgbValues[counter + 3],
rgbValues[counter + 2],
rgbValues[counter + 1],
rgbValues[counter + 0]);
rgbValues[counter + 0]
);
}
bitmap.UnlockBits(bmpData);
bitmap.Dispose();
}
public System.Drawing.Color GetPixel(int a, int b)
{
return colors[a, b];
}
}
public static void clearUnloaded()
......@@ -120,11 +124,13 @@ public class GameTextureManager
public long code;
public bool pCard = false;
public float k = 1;
//public bool autoMade = false;
public byte[] data = null;
public float[,,] hashed_data = null;
public Texture2D u_data = null;
public Texture2D nullReturen = null;
public PictureResource(GameTextureType t, long c, Texture2D n)
{
type = t;
......@@ -172,7 +178,6 @@ public class GameTextureManager
public static Texture2D LINK = null;
public static Texture2D LINKm = null;
public static Texture2D nt = null;
public static Texture2D bp = null;
......@@ -187,8 +192,6 @@ public class GameTextureManager
public static Texture2D sp = null;
public static Texture2D phase = null;
public static bool AutoPicDownload;
......@@ -220,7 +223,11 @@ public class GameTextureManager
pic = waitLoadStack.Pop();
try
{
pic.pCard = (YGOSharp.CardsManager.Get((int)pic.code).Type & (int)CardType.Pendulum) > 0;
pic.pCard =
(
YGOSharp.CardsManager.Get((int)pic.code).Type
& (int)CardType.Pendulum
) > 0;
}
catch (Exception e)
{
......@@ -261,7 +268,8 @@ public class GameTextureManager
if (File.Exists("picture/closeup/" + pic.code.ToString() + ".png"))
{
string path = "picture/closeup/" + pic.code.ToString() + ".png";
if (Program.ANDROID_API_N) {
if (Program.ANDROID_API_N)
{
BitmapHelper bitmap = new BitmapHelper(path);
int left;
int right;
......@@ -280,10 +288,18 @@ public class GameTextureManager
{
System.Drawing.Color color = bitmap.GetPixel(left + w, up + h);
float a = (float)color.A / 255f;
if (w < 40) if (a > (float)w / (float)40) a = (float)w / (float)40;
if (w > (width - 40)) if (a > 1f - (float)(w - (width - 40)) / (float)40) a = 1f - (float)(w - (width - 40)) / (float)40;
if (h < 40) if (a > (float)h / (float)40) a = (float)h / (float)40;
if (h > (height - 40)) if (a > 1f - (float)(h - (height - 40)) / (float)40) a = 1f - (float)(h - (height - 40)) / (float)40;
if (w < 40)
if (a > (float)w / (float)40)
a = (float)w / (float)40;
if (w > (width - 40))
if (a > 1f - (float)(w - (width - 40)) / (float)40)
a = 1f - (float)(w - (width - 40)) / (float)40;
if (h < 40)
if (a > (float)h / (float)40)
a = (float)h / (float)40;
if (h > (height - 40))
if (a > 1f - (float)(h - (height - 40)) / (float)40)
a = 1f - (float)(h - (height - 40)) / (float)40;
pic.hashed_data[w, height - h - 1, 0] = (float)color.R / 255f;
pic.hashed_data[w, height - h - 1, 1] = (float)color.G / 255f;
pic.hashed_data[w, height - h - 1, 2] = (float)color.B / 255f;
......@@ -291,7 +307,9 @@ public class GameTextureManager
}
}
caculateK(pic);
} else {
}
else
{
byte[] data;
using (FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read))
{
......@@ -350,7 +368,7 @@ public class GameTextureManager
}
else
{
pic.hashed_data = getCuttedPic(path, pic.pCard,Iam8);
pic.hashed_data = getCuttedPic(path, pic.pCard, Iam8);
int width = pic.hashed_data.GetLength(0);
int height = pic.hashed_data.GetLength(1);
int size = (int)(height * 0.8);
......@@ -456,7 +474,10 @@ public class GameTextureManager
private static float[,,] getCuttedPic(string path, bool pCard, bool EightEdition)
{
BitmapHelper bitmap = new BitmapHelper(path);
int left = 0, top = 0, right = bitmap.colors.GetLength(0), buttom = bitmap.colors.GetLength(1);
int left = 0,
top = 0,
right = bitmap.colors.GetLength(0),
buttom = bitmap.colors.GetLength(1);
//right is width and buttom is height now
if (EightEdition)
{
......@@ -497,7 +518,10 @@ public class GameTextureManager
{
for (int h = 0; h < buttom - top; h++)
{
System.Drawing.Color color = bitmap.GetPixel((int)(left + w), (int)(buttom - 1 - h));
System.Drawing.Color color = bitmap.GetPixel(
(int)(left + w),
(int)(buttom - 1 - h)
);
returnValue[w, h, 0] = (float)color.R / 255f;
returnValue[w, h, 1] = (float)color.G / 255f;
returnValue[w, h, 2] = (float)color.B / 255f;
......@@ -559,7 +583,13 @@ public class GameTextureManager
return up;
}
private static void CutTop(BitmapHelper bitmap, out int left, out int right, out int up, out int down)
private static void CutTop(
BitmapHelper bitmap,
out int left,
out int right,
out int up,
out int down
)
{
///////切边算法
left = 0;
......@@ -587,7 +617,8 @@ public class GameTextureManager
string path = "picture/closeup/" + pic.code.ToString() + ".png";
if (!File.Exists(path))
{
if (Program.ANDROID_API_N) {
if (Program.ANDROID_API_N)
{
path = "picture/card/" + pic.code.ToString() + ".png";
if (!File.Exists(path))
{
......@@ -610,7 +641,9 @@ public class GameTextureManager
path = "picture/cardIn8thEdition/" + pic.code.ToString() + ".jpg";
}
LoadCloseupFromCardPicture(pic, path, Iam8);
} else {
}
else
{
path = "picture/null.png";
byte[] data;
using (FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read))
......@@ -648,7 +681,7 @@ public class GameTextureManager
}
if (!File.Exists(path))
{
path = "textures/unknown.jpg";//YGOMobile Paths
path = "textures/unknown.jpg"; //YGOMobile Paths
}
pic.hashed_data = getCuttedPic(path, pic.pCard, Iam8);
softVtype(pic, 0.5f);
......@@ -658,18 +691,15 @@ public class GameTextureManager
loadedList.Add(hashPic(pic.code, pic.type), pic);
}
}
catch
{
}
catch { }
}
private static void LoadCloseupPicture(PictureResource pic, string path)
{
try
{
if (Program.ANDROID_API_N) {
if (Program.ANDROID_API_N)
{
BitmapHelper bitmap = new BitmapHelper(path);
int left;
int right;
......@@ -721,7 +751,9 @@ public class GameTextureManager
softVtype(pic, 0.7f);
}
caculateK(pic);
} else {
}
else
{
byte[] data;
using (FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read))
{
......@@ -737,11 +769,7 @@ public class GameTextureManager
loadedList.Add(hashPic(pic.code, pic.type), pic);
}
}
catch
{
}
catch { }
}
private static void softVtype(PictureResource pic, float si)
......@@ -762,7 +790,10 @@ public class GameTextureManager
if (h < height / 2)
{
float l = (float)Math.Sqrt((width / 2 - w) * (width / 2 - w) + (height / 2 - h) * (height / 2 - h));
float l = (float)
Math.Sqrt(
(width / 2 - w) * (width / 2 - w) + (height / 2 - h) * (height / 2 - h)
);
l -= width * 0.3f;
if (l < 0)
{
......@@ -818,7 +849,12 @@ public class GameTextureManager
if (!File.Exists(path) && pic.code != 0 && AutoPicDownload)
{
//YGOMobile (177x254)
df.Download("http://cdn01.moestart.com/images/ygopro-images-zh-CN/" + pic.code.ToString() + ".jpg", "picture/card/" + pic.code.ToString() + ".jpg");
df.Download(
"http://cdn01.moestart.com/images/ygopro-images-zh-CN/"
+ pic.code.ToString()
+ ".jpg",
"picture/card/" + pic.code.ToString() + ".jpg"
);
path = "picture/card/" + pic.code.ToString() + ".jpg";
}
/*if (!File.Exists(path) && pic.code != 0 && AutoPicDownload)
......@@ -917,7 +953,12 @@ public class GameTextureManager
{
for (int w = 0; w < width; w++)
{
cols[h * width + w] = new UnityEngine.Color(r.hashed_data[w, h, 0], r.hashed_data[w, h, 1], r.hashed_data[w, h, 2], r.hashed_data[w, h, 3]);
cols[h * width + w] = new UnityEngine.Color(
r.hashed_data[w, h, 0],
r.hashed_data[w, h, 1],
r.hashed_data[w, h, 2],
r.hashed_data[w, h, 3]
);
}
}
re.SetPixels(0, 0, width, height, cols);
......@@ -963,7 +1004,7 @@ public class GameTextureManager
if (uiLoaded == false)
{
uiLoaded = true;
FileInfo[] fileInfos = (new DirectoryInfo("textures/ui")).GetFiles();//YGOMobile Paths
FileInfo[] fileInfos = (new DirectoryInfo("textures/ui")).GetFiles(); //YGOMobile Paths
for (int i = 0; i < fileInfos.Length; i++)
{
if (fileInfos[i].Name.Length > 4)
......@@ -972,7 +1013,7 @@ public class GameTextureManager
{
UIPictureResource r = new UIPictureResource();
r.name = fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4);
r.data = UIHelper.getTexture2D("textures/ui/" + fileInfos[i].Name);//YGOMobile Paths
r.data = UIHelper.getTexture2D("textures/ui/" + fileInfos[i].Name); //YGOMobile Paths
allUI.Add(r);
}
}
......@@ -987,47 +1028,44 @@ public class GameTextureManager
break;
}
}
if (re == null)
{
}
if (re == null) { }
return re;
}
public static UnityEngine.Color chainColor= UnityEngine.Color.white;
public static UnityEngine.Color chainColor = UnityEngine.Color.white;
internal static void initialize()
{
attack = UIHelper.getTexture2D("textures/attack.png");//YGOMobile Paths
myBack = UIHelper.getTexture2D("textures/cover.jpg");//YGOMobile Paths
opBack = UIHelper.getTexture2D("textures/cover2.jpg");//YGOMobile Paths
unknown = UIHelper.getTexture2D("textures/unknown.jpg");//YGOMobile Paths
negated = UIHelper.getTexture2D("textures/negated.png");//YGOMobile Paths
bar = UIHelper.getTexture2D("textures/duel/healthBar/bg.png");//YGOMobile Paths
exBar = UIHelper.getTexture2D("textures/duel/healthBar/excited.png");//YGOMobile Paths
time = UIHelper.getTexture2D("textures/duel/healthBar/t.png");//YGOMobile Paths
lp = UIHelper.getTexture2D("textures/duel/healthBar/lp.png");//YGOMobile Paths
L = UIHelper.getTexture2D("textures/duel/L.png");//YGOMobile Paths
R = UIHelper.getTexture2D("textures/duel/R.png");//YGOMobile Paths
LINK = UIHelper.getTexture2D("textures/duel/link.png");//YGOMobile Paths
LINKm = UIHelper.getTexture2D("textures/duel/linkMask.png");//YGOMobile Paths
Chain = UIHelper.getTexture2D("textures/chain.png");//YGOMobile Paths
Mask = UIHelper.getTexture2D("textures/mask.png");//YGOMobile Paths
nt = UIHelper.getTexture2D("textures/duel/phase/nt.png");//YGOMobile Paths
bp = UIHelper.getTexture2D("textures/duel/phase/bp.png");//YGOMobile Paths
ep = UIHelper.getTexture2D("textures/duel/phase/ep.png");//YGOMobile Paths
mp1 = UIHelper.getTexture2D("textures/duel/phase/mp1.png");//YGOMobile Paths
mp2 = UIHelper.getTexture2D("textures/duel/phase/mp2.png");//YGOMobile Paths
dp = UIHelper.getTexture2D("textures/duel/phase/dp.png");//YGOMobile Paths
sp = UIHelper.getTexture2D("textures/duel/phase/sp.png");//YGOMobile Paths
phase = UIHelper.getTexture2D("textures/duel/phase/phase.png");//YGOMobile Paths
rs = UIHelper.getTexture2D("textures/duel/phase/rs.png");//YGOMobile Paths
ts = UIHelper.getTexture2D("textures/duel/phase/ts.png");//YGOMobile Paths
N = new Texture2D(10,10);
attack = UIHelper.getTexture2D("textures/attack.png"); //YGOMobile Paths
myBack = UIHelper.getTexture2D("textures/cover.jpg"); //YGOMobile Paths
opBack = UIHelper.getTexture2D("textures/cover2.jpg"); //YGOMobile Paths
unknown = UIHelper.getTexture2D("textures/unknown.jpg"); //YGOMobile Paths
negated = UIHelper.getTexture2D("textures/negated.png"); //YGOMobile Paths
bar = UIHelper.getTexture2D("textures/duel/healthBar/bg.png"); //YGOMobile Paths
exBar = UIHelper.getTexture2D("textures/duel/healthBar/excited.png"); //YGOMobile Paths
time = UIHelper.getTexture2D("textures/duel/healthBar/t.png"); //YGOMobile Paths
lp = UIHelper.getTexture2D("textures/duel/healthBar/lp.png"); //YGOMobile Paths
L = UIHelper.getTexture2D("textures/duel/L.png"); //YGOMobile Paths
R = UIHelper.getTexture2D("textures/duel/R.png"); //YGOMobile Paths
LINK = UIHelper.getTexture2D("textures/duel/link.png"); //YGOMobile Paths
LINKm = UIHelper.getTexture2D("textures/duel/linkMask.png"); //YGOMobile Paths
Chain = UIHelper.getTexture2D("textures/chain.png"); //YGOMobile Paths
Mask = UIHelper.getTexture2D("textures/mask.png"); //YGOMobile Paths
nt = UIHelper.getTexture2D("textures/duel/phase/nt.png"); //YGOMobile Paths
bp = UIHelper.getTexture2D("textures/duel/phase/bp.png"); //YGOMobile Paths
ep = UIHelper.getTexture2D("textures/duel/phase/ep.png"); //YGOMobile Paths
mp1 = UIHelper.getTexture2D("textures/duel/phase/mp1.png"); //YGOMobile Paths
mp2 = UIHelper.getTexture2D("textures/duel/phase/mp2.png"); //YGOMobile Paths
dp = UIHelper.getTexture2D("textures/duel/phase/dp.png"); //YGOMobile Paths
sp = UIHelper.getTexture2D("textures/duel/phase/sp.png"); //YGOMobile Paths
phase = UIHelper.getTexture2D("textures/duel/phase/phase.png"); //YGOMobile Paths
rs = UIHelper.getTexture2D("textures/duel/phase/rs.png"); //YGOMobile Paths
ts = UIHelper.getTexture2D("textures/duel/phase/ts.png"); //YGOMobile Paths
N = new Texture2D(10, 10);
for (int i = 0; i < 10; i++)
{
for (int a = 0; a < 10; a++)
......@@ -1038,12 +1076,12 @@ public class GameTextureManager
N.Apply();
try
{
ColorUtility.TryParseHtmlString(File.ReadAllText("textures/duel/chainColor.txt"), out chainColor);//YGOMobile Paths
}
catch (Exception)
{
ColorUtility.TryParseHtmlString(
File.ReadAllText("textures/duel/chainColor.txt"),
out chainColor
); //YGOMobile Paths
}
catch (Exception) { }
Thread main = new Thread(thread_run);
main.Start();
}
......
......@@ -51,7 +51,6 @@ public class UnityFileDownloader
File.Delete(filePath);
}
File.Move(tempFilePath, filePath);
// 使用 string.Format 替换了插值字符串
Debug.Log(string.Format("下载成功: {0} -> {1}", url, filePath));
if (onComplete != null)
......@@ -61,7 +60,6 @@ public class UnityFileDownloader
}
else
{
// 使用 string.Format 替换了插值字符串
Debug.LogError(string.Format("下载失败: {0}\n错误信息: {1}", url, uwr.error));
if (File.Exists(tempFilePath))
{
......
using UnityEngine;
using System;
using System;
using UnityEngine;
public class Setting : WindowServant2D
{
private EventDelegate onChange;
......@@ -15,15 +16,31 @@ public class Setting : WindowServant2D
UIHelper.registEvent(gameObject, "full_", resizeScreen);
UIHelper.registEvent(gameObject, "resize_", resizeScreen);
UIHelper.getByName<UIToggle>(gameObject, "full_").value = Screen.fullScreen;
UIHelper.getByName<UIToggle>(gameObject, "ignoreWatcher_").value = UIHelper.fromStringToBool(Config.Get("ignoreWatcher_", "0"));
UIHelper.getByName<UIToggle>(gameObject, "ignoreOP_").value = UIHelper.fromStringToBool(Config.Get("ignoreOP_", "0"));
UIHelper.getByName<UIToggle>(gameObject, "smartSelect_").value = UIHelper.fromStringToBool(Config.Get("smartSelect_", "1"));
UIHelper.getByName<UIToggle>(gameObject, "autoChain_").value = UIHelper.fromStringToBool(Config.Get("autoChain_", "1"));
UIHelper.getByName<UIToggle>(gameObject, "handPosition_").value = UIHelper.fromStringToBool(Config.Get("handPosition_", "1"));
UIHelper.getByName<UIToggle>(gameObject, "handmPosition_").value = UIHelper.fromStringToBool(Config.Get("handmPosition_", "1"));
UIHelper.getByName<UIToggle>(gameObject, "spyer_").value = UIHelper.fromStringToBool(Config.Get("spyer_", "1"));
UIHelper.getByName<UIToggle>(gameObject, "resize_").value = UIHelper.fromStringToBool(Config.Get("resize_", "0"));
UIHelper.getByName<UIToggle>(gameObject, "longField_").value = UIHelper.fromStringToBool(Config.Get("longField_", "0"));
UIHelper.getByName<UIToggle>(gameObject, "ignoreWatcher_").value =
UIHelper.fromStringToBool(Config.Get("ignoreWatcher_", "0"));
UIHelper.getByName<UIToggle>(gameObject, "ignoreOP_").value = UIHelper.fromStringToBool(
Config.Get("ignoreOP_", "0")
);
UIHelper.getByName<UIToggle>(gameObject, "smartSelect_").value = UIHelper.fromStringToBool(
Config.Get("smartSelect_", "1")
);
UIHelper.getByName<UIToggle>(gameObject, "autoChain_").value = UIHelper.fromStringToBool(
Config.Get("autoChain_", "1")
);
UIHelper.getByName<UIToggle>(gameObject, "handPosition_").value = UIHelper.fromStringToBool(
Config.Get("handPosition_", "1")
);
UIHelper.getByName<UIToggle>(gameObject, "handmPosition_").value =
UIHelper.fromStringToBool(Config.Get("handmPosition_", "1"));
UIHelper.getByName<UIToggle>(gameObject, "spyer_").value = UIHelper.fromStringToBool(
Config.Get("spyer_", "1")
);
UIHelper.getByName<UIToggle>(gameObject, "resize_").value = UIHelper.fromStringToBool(
Config.Get("resize_", "0")
);
UIHelper.getByName<UIToggle>(gameObject, "longField_").value = UIHelper.fromStringToBool(
Config.Get("longField_", "0")
);
if (QualitySettings.GetQualityLevel() < 3)
{
UIHelper.getByName<UIToggle>(gameObject, "high_").value = false;
......@@ -53,13 +70,22 @@ public class Setting : WindowServant2D
{
if (collection[i].name.Length > 0 && collection[i].name[0] == '*')
{
if (collection[i].name == "*mouseParticle" || collection[i].name == "*showOff" || collection[i].name == "*Efield" || collection[i].name == "*AutoPicDownload")
if (
collection[i].name == "*mouseParticle"
|| collection[i].name == "*showOff"
|| collection[i].name == "*Efield"
|| collection[i].name == "*AutoPicDownload"
)
{
collection[i].value = UIHelper.fromStringToBool(Config.Get(collection[i].name, "1"));
collection[i].value = UIHelper.fromStringToBool(
Config.Get(collection[i].name, "1")
);
}
else
{
collection[i].value = UIHelper.fromStringToBool(Config.Get(collection[i].name, "0"));
collection[i].value = UIHelper.fromStringToBool(
Config.Get(collection[i].name, "0")
);
}
}
}
......@@ -83,9 +109,12 @@ public class Setting : WindowServant2D
private void onchangeFPS()
{
if (setting.LimFPS.value == "Auto") {
if (setting.LimFPS.value == "Auto")
{
Application.targetFrameRate = -1;
} else {
}
else
{
int FPS = int.Parse(setting.LimFPS.value);
Application.targetFrameRate = FPS;
}
......@@ -97,7 +126,9 @@ public class Setting : WindowServant2D
{
setting.sliderVolum.forceValue(((float)(int.Parse(Config.Get("vol_", "750")))) / 1000f);
setting.sliderSize.forceValue(((float)(int.Parse(Config.Get("size_", "500")))) / 1000f);
setting.sliderSizeDrawing.forceValue(((float)(int.Parse(Config.Get("vSize_", "500")))) / 1000f);
setting.sliderSizeDrawing.forceValue(
((float)(int.Parse(Config.Get("vSize_", "500")))) / 1000f
);
//setting.sliderAlpha.forceValue(((float)(int.Parse(Config.Get("alpha_", "666")))) / 1000f);
onChangeAlpha();
onChangeSize();
......@@ -128,7 +159,10 @@ public class Setting : WindowServant2D
public void setScreenSizeValue()
{
//dontResizeTwice = 3;
UIHelper.getByName<UIPopupList>(gameObject, "screen_").value = Screen.width.ToString() + "*" + Screen.height.ToString();
// UIHelper.getByName<UIPopupList>(gameObject, "screen_").value =
// Screen.width.ToString() + "*" + Screen.height.ToString();
string res = Config.Get("screen_", "1600*900");
UIHelper.getByName<UIPopupList>(gameObject, "screen_").value = res;
}
void onCP()
......@@ -137,12 +171,9 @@ public class Setting : WindowServant2D
{
Program.I().ocgcore.realize(true);
}
catch (Exception e)
{
}
catch (Exception e) { }
}
public void onchangeCloseUp()
{
if (setting.closeUp.value == false)
......@@ -170,22 +201,16 @@ public class Setting : WindowServant2D
{
atk = int.Parse(setting.showoffATK.value);
}
catch (Exception)
{
}
catch (Exception) { }
try
{
star = int.Parse(setting.showoffStar.value);
}
catch (Exception)
{
}
catch (Exception) { }
}
UISlider sliderAlpha;
void onChangeAlpha()
{
if (sliderAlpha != null)
......@@ -202,6 +227,7 @@ public class Setting : WindowServant2D
}
UISlider sliderVsize;
void onChangeVsize()
{
if (sliderVsize != null)
......@@ -211,6 +237,7 @@ public class Setting : WindowServant2D
}
UISlider sliderSize;
void onChangeSize()
{
if (sliderSize != null)
......@@ -245,21 +272,45 @@ public class Setting : WindowServant2D
//dontResizeTwice = 2;
if (UIHelper.isMaximized())
UIHelper.RestoreWindow();
string[] mats = UIHelper.getByName<UIPopupList>(gameObject, "screen_").value.Split(new string[] { "*" }, StringSplitOptions.RemoveEmptyEntries);
string[] mats = UIHelper
.getByName<UIPopupList>(gameObject, "screen_")
.value.Split(new string[] { "*" }, StringSplitOptions.RemoveEmptyEntries);
if (mats.Length == 2)
{
Screen.SetResolution(int.Parse(mats[0]), int.Parse(mats[1]), UIHelper.getByName<UIToggle>(gameObject, "full_").value);
Screen.SetResolution(
int.Parse(mats[0]),
int.Parse(mats[1]),
UIHelper.getByName<UIToggle>(gameObject, "full_").value
);
}
Program.go(100, () => { Program.I().fixScreenProblems(); });
Program.go(
100,
() =>
{
Program.I().fixScreenProblems();
}
);
}
public void saveWhenQuit()
{
Config.Set("vol_", ((int)(UIHelper.getByName<UISlider>(gameObject, "vol_").value * 1000)).ToString());
Config.Set("size_", ((int)(UIHelper.getByName<UISlider>(gameObject, "size_").value * 1000)).ToString());
Config.Set("vSize_", ((int)(UIHelper.getByName<UISlider>(gameObject, "vSize_").value * 1000)).ToString());
Config.Set(
"vol_",
((int)(UIHelper.getByName<UISlider>(gameObject, "vol_").value * 1000)).ToString()
);
Config.Set(
"size_",
((int)(UIHelper.getByName<UISlider>(gameObject, "size_").value * 1000)).ToString()
);
Config.Set(
"vSize_",
((int)(UIHelper.getByName<UISlider>(gameObject, "vSize_").value * 1000)).ToString()
);
//Config.Set("alpha_", ((int)(UIHelper.getByName<UISlider>(gameObject, "alpha_").value * 1000)).ToString());
Config.Set("longField_", UIHelper.fromBoolToString(UIHelper.getByName<UIToggle>(gameObject, "longField_").value));
Config.Set(
"longField_",
UIHelper.fromBoolToString(UIHelper.getByName<UIToggle>(gameObject, "longField_").value)
);
var collection = gameObject.GetComponentsInChildren<UIToggle>();
for (int i = 0; i < collection.Length; i++)
{
......@@ -271,19 +322,52 @@ public class Setting : WindowServant2D
Config.Set("showoffATK", setting.showoffATK.value.ToString());
Config.Set("showoffStar", setting.showoffStar.value.ToString());
Config.Set("LimFPS", setting.LimFPS.value.ToString());
Config.Set("resize_", UIHelper.fromBoolToString(UIHelper.getByName<UIToggle>(gameObject, "resize_").value));
Config.Set(
"resize_",
UIHelper.fromBoolToString(UIHelper.getByName<UIToggle>(gameObject, "resize_").value)
);
Config.Set("maximize_", UIHelper.fromBoolToString(UIHelper.isMaximized()));
Config.Set("screen_", UIHelper.getByName<UIPopupList>(gameObject, "screen_").value);
}
public void save()
{
Config.Set("ignoreWatcher_", UIHelper.fromBoolToString(UIHelper.getByName<UIToggle>(gameObject, "ignoreWatcher_").value));
Config.Set("ignoreOP_", UIHelper.fromBoolToString(UIHelper.getByName<UIToggle>(gameObject, "ignoreOP_").value));
Config.Set("smartSelect_", UIHelper.fromBoolToString(UIHelper.getByName<UIToggle>(gameObject, "smartSelect_").value));
Config.Set("autoChain_", UIHelper.fromBoolToString(UIHelper.getByName<UIToggle>(gameObject, "autoChain_").value));
Config.Set("handPosition_", UIHelper.fromBoolToString(UIHelper.getByName<UIToggle>(gameObject, "handPosition_").value));
Config.Set("handmPosition_", UIHelper.fromBoolToString(UIHelper.getByName<UIToggle>(gameObject, "handmPosition_").value));
Config.Set("spyer_", UIHelper.fromBoolToString(UIHelper.getByName<UIToggle>(gameObject, "spyer_").value));
Config.Set(
"ignoreWatcher_",
UIHelper.fromBoolToString(
UIHelper.getByName<UIToggle>(gameObject, "ignoreWatcher_").value
)
);
Config.Set(
"ignoreOP_",
UIHelper.fromBoolToString(UIHelper.getByName<UIToggle>(gameObject, "ignoreOP_").value)
);
Config.Set(
"smartSelect_",
UIHelper.fromBoolToString(
UIHelper.getByName<UIToggle>(gameObject, "smartSelect_").value
)
);
Config.Set(
"autoChain_",
UIHelper.fromBoolToString(UIHelper.getByName<UIToggle>(gameObject, "autoChain_").value)
);
Config.Set(
"handPosition_",
UIHelper.fromBoolToString(
UIHelper.getByName<UIToggle>(gameObject, "handPosition_").value
)
);
Config.Set(
"handmPosition_",
UIHelper.fromBoolToString(
UIHelper.getByName<UIToggle>(gameObject, "handmPosition_").value
)
);
Config.Set(
"spyer_",
UIHelper.fromBoolToString(UIHelper.getByName<UIToggle>(gameObject, "spyer_").value)
);
if (UIHelper.getByName<UIToggle>(gameObject, "high_").value)
{
QualitySettings.SetQualityLevel(5);
......
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