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
8fb06838
Commit
8fb06838
authored
Jan 17, 2019
by
Szefo09
Committed by
Unicorn
Jan 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AutoUpdate written?
parent
58ec23e4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
142 additions
and
41 deletions
+142
-41
Assets/SibylSystem/Program.cs
Assets/SibylSystem/Program.cs
+68
-9
Assets/SibylSystem/ResourceManagers/ApiFile.cs
Assets/SibylSystem/ResourceManagers/ApiFile.cs
+20
-0
Assets/SibylSystem/ResourceManagers/ApiFile.cs.meta
Assets/SibylSystem/ResourceManagers/ApiFile.cs.meta
+12
-0
Assets/SibylSystem/ResourceManagers/HttpDldFile.cs
Assets/SibylSystem/ResourceManagers/HttpDldFile.cs
+42
-32
No files found.
Assets/SibylSystem/Program.cs
View file @
8fb06838
...
@@ -3,6 +3,8 @@ using System.Collections;
...
@@ -3,6 +3,8 @@ using System.Collections;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.IO
;
using
System
;
using
System
;
using
System.Linq
;
using
System.Net
;
public
class
Program
:
MonoBehaviour
public
class
Program
:
MonoBehaviour
{
{
...
@@ -280,8 +282,6 @@ public class Program : MonoBehaviour
...
@@ -280,8 +282,6 @@ public class Program : MonoBehaviour
//保持唤醒
//保持唤醒
Screen
.
sleepTimeout
=
SleepTimeout
.
NeverSleep
;
Screen
.
sleepTimeout
=
SleepTimeout
.
NeverSleep
;
//创建资源目录
//创建资源目录
if
(!
Directory
.
Exists
(
"/storage/emulated/0/ygocore"
))
{
DirPaths
(
"/storage/emulated/0/ygocore/cdb/"
);
DirPaths
(
"/storage/emulated/0/ygocore/cdb/"
);
DirPaths
(
"/storage/emulated/0/ygocore/config/"
);
DirPaths
(
"/storage/emulated/0/ygocore/config/"
);
DirPaths
(
"/storage/emulated/0/ygocore/deck/"
);
DirPaths
(
"/storage/emulated/0/ygocore/deck/"
);
...
@@ -296,8 +296,18 @@ public class Program : MonoBehaviour
...
@@ -296,8 +296,18 @@ public class Program : MonoBehaviour
DirPaths
(
"/storage/emulated/0/ygocore/textures/duel/healthBar/"
);
DirPaths
(
"/storage/emulated/0/ygocore/textures/duel/healthBar/"
);
DirPaths
(
"/storage/emulated/0/ygocore/textures/duel/phase/"
);
DirPaths
(
"/storage/emulated/0/ygocore/textures/duel/phase/"
);
DirPaths
(
"/storage/emulated/0/ygocore/textures/ui/"
);
DirPaths
(
"/storage/emulated/0/ygocore/textures/ui/"
);
DirPaths
(
"/storage/emulated/0/ygocore/updates/"
);
if
(!
File
.
Exists
(
"/storage/emulated/0/ygocore/.nomedia"
))
{
File
.
Create
(
"/storage/emulated/0/ygocore/.nomedia"
);
File
.
Create
(
"/storage/emulated/0/ygocore/.nomedia"
);
File
.
Create
(
"/storage/emulated/0/ygocore/expansions/pics/.nomedia"
);
}
if
(!
File
.
Exists
(
"/storage/emulated/0/ygocore/expansions/.nomedia"
))
{
File
.
Create
(
"/storage/emulated/0/ygocore/expansions/.nomedia"
);
}
if
(!
File
.
Exists
(
"/storage/emulated/0/ygocore/picture/.nomedia"
))
{
File
.
Create
(
"/storage/emulated/0/ygocore/picture/.nomedia"
);
}
}
Environment
.
CurrentDirectory
=
"/storage/emulated/0/ygocore"
;
Environment
.
CurrentDirectory
=
"/storage/emulated/0/ygocore"
;
System
.
IO
.
Directory
.
SetCurrentDirectory
(
"/storage/emulated/0/ygocore"
);
System
.
IO
.
Directory
.
SetCurrentDirectory
(
"/storage/emulated/0/ygocore"
);
...
@@ -316,23 +326,26 @@ public class Program : MonoBehaviour
...
@@ -316,23 +326,26 @@ public class Program : MonoBehaviour
});
});
go
(
300
,
()
=>
go
(
300
,
()
=>
{
{
UpdateClient
();
InterString
.
initialize
(
"config/translation.conf"
);
InterString
.
initialize
(
"config/translation.conf"
);
//InterString.initialize("config" + AppLanguage.LanguageDir() + "/translation.conf"); //System Language
//InterString.initialize("config" + AppLanguage.LanguageDir() + "/translation.conf"); //System Language
GameTextureManager
.
initialize
();
GameTextureManager
.
initialize
();
Config
.
initialize
(
"config/config.conf"
);
Config
.
initialize
(
"config/config.conf"
);
//GameStringManager.initialize("config/strings.conf");
GameStringManager
.
initialize
(
"strings.conf"
);
GameStringManager
.
initialize
(
"strings.conf"
);
if
(
File
.
Exists
(
"c
db
/strings.conf"
))
if
(
File
.
Exists
(
"c
onfig
/strings.conf"
))
{
{
GameStringManager
.
initialize
(
"c
db
/strings.conf"
);
GameStringManager
.
initialize
(
"c
onfig
/strings.conf"
);
}
}
if
(
File
.
Exists
(
"expansions/strings.conf"
))
if
(
File
.
Exists
(
"expansions/strings.conf"
))
{
{
GameStringManager
.
initialize
(
"expansions/strings.conf"
);
GameStringManager
.
initialize
(
"expansions/strings.conf"
);
}
}
//YGOSharp.BanlistManager.initialize("config/lflist.conf");
YGOSharp
.
BanlistManager
.
initialize
(
"lflist.conf"
);
YGOSharp
.
BanlistManager
.
initialize
(
"lflist.conf"
);
var
fileInfos
=
(
new
DirectoryInfo
(
"cdb"
)).
GetFiles
();
FileInfo
[]
fileInfos
=
(
new
DirectoryInfo
(
"cdb"
)).
GetFiles
().
OrderByDescending
(
x
=>
x
.
Name
).
ToArray
();
//
var fileInfos = (new DirectoryInfo("cdb" + AppLanguage.LanguageDir())).GetFiles
();//System Language
//
FileInfo[] fileInfos = (new DirectoryInfo("cdb" + AppLanguage.LanguageDir())).GetFiles().OrderByDescending(x => x.Name).ToArray
();//System Language
for
(
int
i
=
0
;
i
<
fileInfos
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
fileInfos
.
Length
;
i
++)
{
{
if
(
fileInfos
[
i
].
Name
.
Length
>
4
)
if
(
fileInfos
[
i
].
Name
.
Length
>
4
)
...
@@ -348,8 +361,8 @@ public class Program : MonoBehaviour
...
@@ -348,8 +361,8 @@ public class Program : MonoBehaviour
if
(
Directory
.
Exists
(
"expansions"
))
if
(
Directory
.
Exists
(
"expansions"
))
//if (Directory.Exists("expansions" + AppLanguage.LanguageDir()))
//if (Directory.Exists("expansions" + AppLanguage.LanguageDir()))
{
{
fileInfos
=
(
new
DirectoryInfo
(
"expansions"
)).
GetFiles
();
fileInfos
=
(
new
DirectoryInfo
(
"expansions"
)).
GetFiles
()
.
OrderByDescending
(
x
=>
x
.
Name
).
ToArray
()
;
//fileInfos = (new DirectoryInfo("expansions" + AppLanguage.LanguageDir())).GetFiles();
//fileInfos = (new DirectoryInfo("expansions" + AppLanguage.LanguageDir())).GetFiles()
.OrderByDescending(x => x.Name).ToArray()
;
for
(
int
i
=
0
;
i
<
fileInfos
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
fileInfos
.
Length
;
i
++)
{
{
if
(
fileInfos
[
i
].
Name
.
Length
>
4
)
if
(
fileInfos
[
i
].
Name
.
Length
>
4
)
...
@@ -385,6 +398,52 @@ public class Program : MonoBehaviour
...
@@ -385,6 +398,52 @@ public class Program : MonoBehaviour
}
}
private
void
UpdateClient
()
{
try
{
WWW
w
=
new
WWW
(
"https://api.github.com/repos/szefo09/updateYGOPro2/contents/"
);
while
(!
w
.
isDone
)
{
}
List
<
ApiFile
>
toDownload
=
new
List
<
ApiFile
>();
List
<
ApiFile
>
apiFromGit
=
new
System
.
Web
.
Script
.
Serialization
.
JavaScriptSerializer
().
Deserialize
<
List
<
ApiFile
>>(
w
.
text
);
if
(!
File
.
Exists
(
"updates/SHAs.txt"
))
{
toDownload
.
AddRange
(
apiFromGit
);
}
if
(
File
.
Exists
(
"updates/SHAs.txt"
))
{
List
<
ApiFile
>
local
=
new
System
.
Web
.
Script
.
Serialization
.
JavaScriptSerializer
().
Deserialize
<
List
<
ApiFile
>>(
File
.
ReadAllText
(
"updates/SHAs.txt"
));
foreach
(
ApiFile
file
in
apiFromGit
)
{
if
(
file
.
sha
!=
local
.
First
(
x
=>
x
.
name
==
file
.
name
).
sha
)
{
toDownload
.
Add
(
file
);
}
}
}
HttpDldFile
httpDldFile
=
new
HttpDldFile
();
foreach
(
var
dl
in
toDownload
)
{
if
(
Path
.
GetExtension
(
dl
.
name
)==
".cdb"
)
{
httpDldFile
.
Download
(
dl
.
download_url
,
Path
.
Combine
(
"cdb"
,
dl
.
name
));
}
if
(
Path
.
GetExtension
(
dl
.
name
)
==
".conf"
)
{
httpDldFile
.
Download
(
dl
.
download_url
,
Path
.
Combine
(
"config"
,
dl
.
name
));
}
}
File
.
WriteAllText
(
"updates/SHAs.txt"
,
w
.
text
);
}
catch
(
Exception
e
)
{
Debug
.
Log
(
e
);
}
}
public
GameObject
mouseParticle
;
public
GameObject
mouseParticle
;
static
int
lastChargeTime
=
0
;
static
int
lastChargeTime
=
0
;
...
...
Assets/SibylSystem/ResourceManagers/ApiFile.cs
0 → 100644
View file @
8fb06838
public
class
Links
{
public
string
self
{
get
;
set
;
}
public
string
git
{
get
;
set
;
}
public
string
html
{
get
;
set
;
}
}
public
class
ApiFile
{
public
string
name
{
get
;
set
;
}
public
string
path
{
get
;
set
;
}
public
string
sha
{
get
;
set
;
}
public
int
size
{
get
;
set
;
}
public
string
url
{
get
;
set
;
}
public
string
html_url
{
get
;
set
;
}
public
string
git_url
{
get
;
set
;
}
public
string
download_url
{
get
;
set
;
}
public
string
type
{
get
;
set
;
}
public
Links
_links
{
get
;
set
;
}
}
\ No newline at end of file
Assets/SibylSystem/ResourceManagers/ApiFile.cs.meta
0 → 100644
View file @
8fb06838
fileFormatVersion: 2
guid: 40ff7876fde6c9c4982e888bf428b76e
timeCreated: 1547757047
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/SibylSystem/ResourceManagers/HttpDldFile.cs
View file @
8fb06838
...
@@ -4,47 +4,30 @@ using System.Linq;
...
@@ -4,47 +4,30 @@ using System.Linq;
using
System.Text
;
using
System.Text
;
using
System.IO
;
using
System.IO
;
using
System.Net
;
using
System.Net
;
using
System.Security.Cryptography.X509Certificates
;
using
System.Net.Security
;
public
class
HttpDldFile
public
class
HttpDldFile
{
{
public
bool
Download
(
string
url
,
string
filename
)
public
bool
Download
(
string
url
,
string
filename
)
{
{
bool
flag
=
false
;
bool
flag
=
false
;
long
startPosition
=
0
;
try
FileStream
writeStream
;
if
(
File
.
Exists
(
filename
+
".tmp"
))
{
{
writeStream
=
File
.
OpenWrite
(
filename
+
".tmp"
);
if
(!
Directory
.
Exists
(
Path
.
GetDirectoryName
(
filename
))){
startPosition
=
writeStream
.
Length
;
Directory
.
CreateDirectory
(
Path
.
GetDirectoryName
(
filename
));
writeStream
.
Seek
(
startPosition
,
SeekOrigin
.
Current
);
}
}
else
using
(
var
client
=
new
WebClient
())
{
{
writeStream
=
new
FileStream
(
filename
+
".tmp"
,
FileMode
.
Create
);
ServicePointManager
.
ServerCertificateValidationCallback
=
MyRemoteCertificateValidationCallback
;
startPosition
=
0
;
//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"
);
}
}
try
flag
=
true
;
{
if
(
File
.
Exists
(
filename
))
HttpWebRequest
myRequest
=
(
HttpWebRequest
)
HttpWebRequest
.
Create
(
url
);
if
(
startPosition
>
0
)
{
myRequest
.
AddRange
((
int
)
startPosition
);
}
Stream
readStream
=
myRequest
.
GetResponse
().
GetResponseStream
();
byte
[]
btArray
=
new
byte
[
2048
];
int
contentSize
=
readStream
.
Read
(
btArray
,
0
,
btArray
.
Length
);
while
(
contentSize
>
0
)
{
writeStream
.
Write
(
btArray
,
0
,
contentSize
);
contentSize
=
readStream
.
Read
(
btArray
,
0
,
btArray
.
Length
);
}
writeStream
.
Close
();
readStream
.
Close
();
flag
=
true
;
if
(
File
.
Exists
(
filename
))
{
{
File
.
Delete
(
filename
);
File
.
Delete
(
filename
);
}
}
...
@@ -52,10 +35,37 @@ public class HttpDldFile
...
@@ -52,10 +35,37 @@ public class HttpDldFile
}
}
catch
(
Exception
)
catch
(
Exception
)
{
{
writeStream
.
Close
();
flag
=
false
;
flag
=
false
;
}
}
return
flag
;
return
flag
;
}
}
public
static
bool
MyRemoteCertificateValidationCallback
(
System
.
Object
sender
,
X509Certificate
certificate
,
X509Chain
chain
,
SslPolicyErrors
sslPolicyErrors
)
{
bool
isOk
=
true
;
// If there are errors in the certificate chain,
// look at each error to determine the cause.
if
(
sslPolicyErrors
!=
SslPolicyErrors
.
None
)
{
for
(
int
i
=
0
;
i
<
chain
.
ChainStatus
.
Length
;
i
++)
{
if
(
chain
.
ChainStatus
[
i
].
Status
==
X509ChainStatusFlags
.
RevocationStatusUnknown
)
{
continue
;
}
chain
.
ChainPolicy
.
RevocationFlag
=
X509RevocationFlag
.
EntireChain
;
chain
.
ChainPolicy
.
RevocationMode
=
X509RevocationMode
.
Online
;
chain
.
ChainPolicy
.
UrlRetrievalTimeout
=
new
TimeSpan
(
0
,
1
,
0
);
chain
.
ChainPolicy
.
VerificationFlags
=
X509VerificationFlags
.
AllFlags
;
bool
chainIsValid
=
chain
.
Build
((
X509Certificate2
)
certificate
);
if
(!
chainIsValid
)
{
isOk
=
false
;
break
;
}
}
}
return
isOk
;
}
}
}
\ 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