Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile-Cn-Ko-En
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
List
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
fallenstardust
YGOMobile-Cn-Ko-En
Commits
0891ecd8
Commit
0891ecd8
authored
Apr 07, 2019
by
feihuaduo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
读取额外卡库压缩包内strings
parent
b5e80eab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
1 deletion
+65
-1
mobile/src/main/java/ocgcore/StringManager.java
mobile/src/main/java/ocgcore/StringManager.java
+65
-1
No files found.
mobile/src/main/java/ocgcore/StringManager.java
View file @
0891ecd8
...
...
@@ -7,11 +7,16 @@ import java.io.BufferedReader;
import
java.io.Closeable
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipFile
;
import
cn.garymb.ygomobile.App
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.utils.IOUtils
;
...
...
@@ -41,11 +46,70 @@ public class StringManager implements Closeable {
File
stringFile
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
Constants
.
CORE_STRING_PATH
);
boolean
rs1
=
loadFile
(
stringFile
.
getAbsolutePath
());
boolean
rs2
=
true
;
boolean
res3
=
true
;
if
(
AppsSettings
.
get
().
isReadExpansions
())
{
File
stringFile2
=
new
File
(
AppsSettings
.
get
().
getExpansionsPath
(),
Constants
.
CORE_STRING_PATH
);
rs2
=
loadFile
(
stringFile2
.
getAbsolutePath
());
File
[]
files
=
AppsSettings
.
get
().
getExpansionsPath
().
listFiles
();
if
(
files
!=
null
){
for
(
File
file:
files
){
if
(
file
.
isFile
()&&
file
.
getName
().
endsWith
(
".zip"
)){
try
{
ZipFile
zipFile
=
new
ZipFile
(
file
.
getAbsoluteFile
());
ZipEntry
entry
=
zipFile
.
getEntry
(
Constants
.
CORE_STRING_PATH
);
if
(
entry
!=
null
){
res3
&=
loadFile
(
zipFile
.
getInputStream
(
entry
));
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
res3
=
false
;
}
}
}
}
}
return
rs1
&&
rs2
&&
res3
;
}
public
boolean
loadFile
(
InputStream
inputStream
)
{
InputStreamReader
in
=
null
;
try
{
in
=
new
InputStreamReader
(
inputStream
,
"utf-8"
);
BufferedReader
reader
=
new
BufferedReader
(
in
);
String
line
=
null
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
if
(
line
.
startsWith
(
"#"
)
||
(!
line
.
startsWith
(
PRE_SYSTEM
)
&&
!
line
.
startsWith
(
PRE_SETNAME
)))
{
continue
;
}
String
[]
words
=
line
.
split
(
"[\t| ]+"
);
//
if
(
words
.
length
>=
3
)
{
if
(
PRE_SETNAME
.
equals
(
words
[
0
]))
{
// System.out.println(Arrays.toString(words));
//setcode
long
id
=
toNumber
(
words
[
1
]);
CardSet
cardSet
=
new
CardSet
(
id
,
words
[
2
]);
int
i
=
mCardSets
.
indexOf
(
cardSet
);
if
(
i
>=
0
)
{
CardSet
cardSet1
=
mCardSets
.
get
(
i
);
cardSet1
.
setName
(
cardSet
.
getName
());
}
else
{
mCardSets
.
add
(
cardSet
);
}
}
else
{
mSystem
.
put
((
int
)
toNumber
(
words
[
1
]),
words
[
2
]);
}
}
}
}
catch
(
Exception
e
)
{
}
finally
{
IOUtils
.
close
(
inputStream
);
IOUtils
.
close
(
in
);
}
return
rs1
&&
rs2
;
Collections
.
sort
(
mCardSets
,
CardSet
.
NAME_ASC
);
return
true
;
}
public
boolean
loadFile
(
String
path
)
{
...
...
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