Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
ygopro2
Commits
68b5410a
Commit
68b5410a
authored
Mar 13, 2019
by
Unicorn369
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update
parent
a3791faa
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
376 additions
and
335 deletions
+376
-335
Assets/SibylSystem/Menu/Menu.cs
Assets/SibylSystem/Menu/Menu.cs
+7
-5
Assets/SibylSystem/Program.cs
Assets/SibylSystem/Program.cs
+1
-0
Assets/SibylSystem/ResourceManagers/GameTextureManager.cs
Assets/SibylSystem/ResourceManagers/GameTextureManager.cs
+319
-316
Assets/SibylSystem/ResourceManagers/HttpDldFile.cs
Assets/SibylSystem/ResourceManagers/HttpDldFile.cs
+49
-14
No files found.
Assets/SibylSystem/Menu/Menu.cs
View file @
68b5410a
...
...
@@ -141,14 +141,16 @@ public class Menu : WindowServantSP
void
onClickDownload
()
{
#if UNITY_EDITOR || UNITY_STANDALONE_WIN //编译器、Windows
Application
.
OpenURL
(
"https://github.com/Unicorn369/pro2_android_closeup/releases/
download/1.0/closeup_version1.0.zip
"
);
Application
.
OpenURL
(
"https://github.com/Unicorn369/pro2_android_closeup/releases/
tag/1.0
"
);
#elif UNITY_ANDROID //Android
AndroidJavaObject
jo
=
new
AndroidJavaObject
(
"cn.unicorn369.library.API"
);
if
(!
File
.
Exists
(
"updates/closeup_version1.0.txt"
))
{
//用于检查更新
if
(
File
.
Exists
(
"closeup_version1.0.zip"
))
{
//如果有则直接解压
jo
.
Call
(
"doExtractZipFile"
,
"closeup_version1.0.zip"
,
Program
.
ANDROID_GAME_PATH
);
if
(!
File
.
Exists
(
"updates/closeup_version1.1.txt"
))
{
//用于检查更新
if
(
File
.
Exists
(
"closeup_version1.1.zip"
))
{
//如果有则直接解压
jo
.
Call
(
"doExtractZipFile"
,
"closeup_version1.1.zip"
,
Program
.
ANDROID_GAME_PATH
);
}
else
if
(
File
.
Exists
(
"updates/closeup_version1.0.txt"
)){
//如果有则下载更新包
jo
.
Call
(
"doDownloadZipFile"
,
"https://github.com/Unicorn369/pro2_android_closeup/releases/download/1.0/up_closeup_version1.1.zip"
);
}
else
{
//否则下载并解压,锁定目录:/ygocore
jo
.
Call
(
"doDownloadZipFile"
,
"https://github.com/Unicorn369/pro2_android_closeup/releases/download/1.0/closeup_version1.
0
.zip"
);
jo
.
Call
(
"doDownloadZipFile"
,
"https://github.com/Unicorn369/pro2_android_closeup/releases/download/1.0/closeup_version1.
1
.zip"
);
}
}
else
{
jo
.
Call
(
"showToast"
,
"已下载,无需再次下载!"
);
...
...
Assets/SibylSystem/Program.cs
View file @
68b5410a
...
...
@@ -379,6 +379,7 @@ public class Program : MonoBehaviour
File
.
Create
(
"updates/image_version1.1.txt"
);
}
else
{
jo
.
Call
(
"showToast"
,
"没有发现卡图包,是否未安装YGOMobile"
);
Application
.
OpenURL
(
"https://www.taptap.com/app/37972"
);
}
}
#endif
...
...
Assets/SibylSystem/ResourceManagers/GameTextureManager.cs
View file @
68b5410a
This diff is collapsed.
Click to expand it.
Assets/SibylSystem/ResourceManagers/HttpDldFile.cs
View file @
68b5410a
...
...
@@ -10,25 +10,36 @@ using UnityEngine;
public
class
HttpDldFile
{
private
readonly
System
.
Threading
.
Semaphore
semaphore
=
new
System
.
Threading
.
Semaphore
(
6
,
6
);
public
bool
Download
(
string
url
,
string
filename
)
{
bool
flag
=
false
;
try
{
if
(!
Directory
.
Exists
(
Path
.
GetDirectoryName
(
filename
))){
Directory
.
CreateDirectory
(
Path
.
GetDirectoryName
(
filename
));
}
using
(
var
client
=
new
WebClient
())
{
ServicePointManager
.
ServerCertificateValidationCallback
=
MyRemoteCertificateValidationCallback
;
//client.Headers.Add(HttpRequestHeader.Authorization, string.Concat("token ", RepoData.GetToken()));
client
.
Headers
.
Add
(
HttpRequestHeader
.
ContentType
,
"application/x-www-form-urlencoded; charset=UTF-8"
);
client
.
Headers
.
Add
(
HttpRequestHeader
.
UserAgent
,
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063"
);
client
.
DownloadFile
(
new
Uri
(
url
),
filename
+
".tmp"
);
}
flag
=
true
;
if
(
File
.
Exists
(
filename
))
if
(!
Directory
.
Exists
(
Path
.
GetDirectoryName
(
filename
)))
{
Directory
.
CreateDirectory
(
Path
.
GetDirectoryName
(
filename
));
}
using
(
var
client
=
new
TimeoutWebClient
())
{
ServicePointManager
.
ServerCertificateValidationCallback
=
MyRemoteCertificateValidationCallback
;
//authorization needed to acces github
if
(
Path
.
GetExtension
(
filename
).
Contains
(
"png"
))
{
//client.Headers.Add(HttpRequestHeader.Authorization, string.Concat("token ", RepoData.GetToken()));
client
.
Timeout
=
6500
;
}
if
(
Path
.
GetExtension
(
filename
).
Contains
(
"jpg"
))
{
client
.
Timeout
=
3500
;
}
semaphore
.
WaitOne
();
client
.
DownloadFile
(
new
Uri
(
url
),
filename
+
".tmp"
);
}
flag
=
true
;
if
(
File
.
Exists
(
filename
))
{
File
.
Delete
(
filename
);
}
...
...
@@ -38,6 +49,10 @@ public class HttpDldFile
{
flag
=
false
;
}
finally
{
semaphore
.
Release
();
}
return
flag
;
}
public
static
bool
MyRemoteCertificateValidationCallback
(
System
.
Object
sender
,
...
...
@@ -68,5 +83,25 @@ public class HttpDldFile
}
return
isOk
;
}
}
public
class
TimeoutWebClient
:
WebClient
{
public
int
Timeout
{
get
;
set
;
}
public
TimeoutWebClient
()
{
Timeout
=
10000
;
}
public
TimeoutWebClient
(
int
timeout
)
{
Timeout
=
timeout
;
}
protected
override
WebRequest
GetWebRequest
(
Uri
address
)
{
WebRequest
request
=
base
.
GetWebRequest
(
address
);
request
.
Timeout
=
Timeout
;
return
request
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment