Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOProUnity_V2
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
赤子奈落
YGOProUnity_V2
Commits
ab7b6822
Commit
ab7b6822
authored
Aug 22, 2020
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update picture loading
parent
a0c8e33c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
167 additions
and
118 deletions
+167
-118
Assets/SibylSystem/Ocgcore/OCGobjects/gameField.cs
Assets/SibylSystem/Ocgcore/OCGobjects/gameField.cs
+25
-27
Assets/SibylSystem/Program.cs
Assets/SibylSystem/Program.cs
+3
-1
Assets/SibylSystem/ResourceManagers/GameTextureManager.cs
Assets/SibylSystem/ResourceManagers/GameTextureManager.cs
+139
-90
No files found.
Assets/SibylSystem/Ocgcore/OCGobjects/gameField.cs
View file @
ab7b6822
...
...
@@ -2,6 +2,7 @@
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Text.RegularExpressions
;
using
UnityEngine
;
using
YGOSharp.OCGWrapper.Enums
;
...
...
@@ -424,38 +425,35 @@ public class GameField : OCGobject
fieldCode
[
player
]
=
code
;
if
(
code
>
0
)
{
Texture2D
tex
;
if
(
File
.
Exists
(
"picture/field/"
+
code
.
ToString
()
+
".png"
))
Texture2D
tex
=
null
;
bool
found
=
false
;
foreach
(
ZipFile
zip
in
GameZipManager
.
Zips
)
{
tex
=
UIHelper
.
getTexture2D
(
"picture/field/"
+
code
.
ToString
()
+
".png"
);
}
else
if
(
File
.
Exists
(
"picture/field/"
+
code
.
ToString
()
+
".jpg"
))
{
tex
=
UIHelper
.
getTexture2D
(
"picture/field/"
+
code
.
ToString
()
+
".jpg"
);
}
else
{
tex
=
null
;
bool
found
=
false
;
foreach
(
ZipFile
zip
in
GameZipManager
.
Zips
)
if
(
zip
.
Name
.
ToLower
().
EndsWith
(
"script.zip"
))
continue
;
foreach
(
string
file
in
zip
.
EntryFileNames
)
{
foreach
(
string
file
in
zip
.
EntryFileNames
)
if
(
Regex
.
IsMatch
(
file
.
ToLower
(),
"field/"
+
code
.
ToString
()
+
"\\.(jpg|png)$"
)
)
{
string
file1
=
file
.
ToLower
();
if
(
file1
.
EndsWith
(
code
.
ToString
()
+
".jpg"
)
&&
file1
.
Contains
(
"field"
))
{
MemoryStream
ms
=
new
MemoryStream
();
ZipEntry
e
=
zip
[
file
];
e
.
Extract
(
ms
);
tex
=
new
Texture2D
(
1024
,
600
);
tex
.
LoadImage
(
ms
.
ToArray
());
found
=
true
;
break
;
}
}
if
(
found
)
MemoryStream
ms
=
new
MemoryStream
();
ZipEntry
e
=
zip
[
file
];
e
.
Extract
(
ms
);
tex
=
new
Texture2D
(
1024
,
600
);
tex
.
LoadImage
(
ms
.
ToArray
());
found
=
true
;
break
;
}
}
if
(
found
)
break
;
}
if
(
tex
==
null
)
{
tex
=
UIHelper
.
getTexture2D
(
"picture/field/"
+
code
.
ToString
()
+
".png"
);
}
if
(
tex
==
null
)
{
tex
=
UIHelper
.
getTexture2D
(
"picture/field/"
+
code
.
ToString
()
+
".jpg"
);
}
if
(
tex
!=
null
)
{
...
...
Assets/SibylSystem/Program.cs
View file @
ab7b6822
...
...
@@ -287,7 +287,7 @@ public class Program : MonoBehaviour
});
go
(
300
,
()
=>
{
InterString
.
initialize
(
"config/translation.conf"
);
InterString
.
initialize
(
"config/translation.conf"
);
GameTextureManager
.
initialize
();
Config
.
initialize
(
"config/config.conf"
);
...
...
@@ -324,6 +324,8 @@ public class Program : MonoBehaviour
foreach
(
ZipFile
zip
in
GameZipManager
.
Zips
)
{
if
(
zip
.
Name
.
ToLower
().
EndsWith
(
"script.zip"
))
continue
;
foreach
(
string
file
in
zip
.
EntryFileNames
)
{
if
(
file
.
ToLower
().
EndsWith
(
".conf"
))
...
...
Assets/SibylSystem/ResourceManagers/GameTextureManager.cs
View file @
ab7b6822
...
...
@@ -8,6 +8,7 @@ using UnityEngine;
using
YGOSharp.OCGWrapper.Enums
;
using
Ionic.Zip
;
using
System.Text
;
using
System.Text.RegularExpressions
;
public
enum
GameTextureType
{
...
...
@@ -47,6 +48,32 @@ public class GameTextureManager
}
}
}
init
(
bitmap
);
}
public
BitmapHelper
(
MemoryStream
stream
)
{
Bitmap
bitmap
;
try
{
bitmap
=
(
Bitmap
)
Image
.
FromStream
(
stream
);
}
catch
(
Exception
)
{
bitmap
=
new
Bitmap
(
10
,
10
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
w
=
0
;
w
<
10
;
w
++)
{
bitmap
.
SetPixel
(
i
,
w
,
System
.
Drawing
.
Color
.
White
);
}
}
}
init
(
bitmap
);
}
private
void
init
(
Bitmap
bitmap
)
{
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
;
...
...
@@ -67,6 +94,7 @@ public class GameTextureManager
bitmap
.
UnlockBits
(
bmpData
);
bitmap
.
Dispose
();
}
public
System
.
Drawing
.
Color
GetPixel
(
int
a
,
int
b
)
{
return
colors
[
a
,
b
];
...
...
@@ -269,12 +297,94 @@ public class GameTextureManager
}
}
private
static
BitmapHelper
getCloseup
(
PictureResource
pic
)
{
BitmapHelper
bitmap
=
null
;
bool
found
=
false
;
string
code
=
pic
.
code
.
ToString
();
foreach
(
ZipFile
zip
in
GameZipManager
.
Zips
)
{
if
(
zip
.
Name
.
ToLower
().
EndsWith
(
"script.zip"
))
continue
;
foreach
(
string
file
in
zip
.
EntryFileNames
)
{
if
(
Regex
.
IsMatch
(
file
.
ToLower
(),
"closeup/"
+
code
+
"\\.png$"
))
{
MemoryStream
ms
=
new
MemoryStream
();
ZipEntry
e
=
zip
[
file
];
e
.
Extract
(
ms
);
bitmap
=
new
BitmapHelper
(
ms
);
found
=
true
;
break
;
}
}
if
(
found
)
break
;
}
if
(!
found
)
{
string
path
=
"picture/closeup/"
+
code
+
".png"
;
if
(
File
.
Exists
(
path
))
{
bitmap
=
new
BitmapHelper
(
path
);
}
}
return
bitmap
;
}
private
static
byte
[]
getPicture
(
PictureResource
pic
,
out
bool
EightEdition
)
{
EightEdition
=
false
;
string
code
=
pic
.
code
.
ToString
();
foreach
(
ZipFile
zip
in
GameZipManager
.
Zips
)
{
if
(
zip
.
Name
.
ToLower
().
EndsWith
(
"script.zip"
))
continue
;
foreach
(
string
file
in
zip
.
EntryFileNames
)
{
if
(
Regex
.
IsMatch
(
file
.
ToLower
(),
"pics/"
+
code
+
"\\.(jpg|png)$"
))
{
MemoryStream
ms
=
new
MemoryStream
();
ZipEntry
e
=
zip
[
file
];
e
.
Extract
(
ms
);
return
ms
.
ToArray
();
}
}
}
string
path
=
"picture/card/"
+
code
+
".png"
;
if
(!
File
.
Exists
(
path
))
{
path
=
"picture/card/"
+
code
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
))
{
EightEdition
=
true
;
path
=
"picture/cardIn8thEdition/"
+
code
+
".png"
;
}
if
(!
File
.
Exists
(
path
))
{
EightEdition
=
true
;
path
=
"picture/cardIn8thEdition/"
+
code
+
".jpg"
;
}
if
(
File
.
Exists
(
path
))
{
using
(
FileStream
file
=
new
FileStream
(
path
,
FileMode
.
Open
,
FileAccess
.
Read
))
{
file
.
Seek
(
0
,
SeekOrigin
.
Begin
);
var
data
=
new
byte
[
file
.
Length
];
file
.
Read
(
data
,
0
,
(
int
)
file
.
Length
);
return
data
;
}
}
return
new
byte
[
0
];
}
private
static
void
ProcessingCardFeature
(
PictureResource
pic
)
{
if
(
File
.
Exists
(
"picture/closeup/"
+
pic
.
code
.
ToString
()
+
".png"
))
bool
EightEdition
=
false
;
BitmapHelper
bitmap
=
getCloseup
(
pic
);
if
(
bitmap
!=
null
)
{
string
path
=
"picture/closeup/"
+
pic
.
code
.
ToString
()
+
".png"
;
BitmapHelper
bitmap
=
new
BitmapHelper
(
path
);
int
left
;
int
right
;
int
up
;
...
...
@@ -311,18 +421,8 @@ public class GameTextureManager
}
else
{
string
path
=
"picture/card/"
+
pic
.
code
.
ToString
()
+
".png"
;
if
(!
File
.
Exists
(
path
))
{
path
=
"picture/card/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
bool
Iam8
=
false
;
if
(!
File
.
Exists
(
path
))
{
Iam8
=
true
;
path
=
"picture/cardIn8thEdition/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
))
var
data
=
getPicture
(
pic
,
out
EightEdition
);
if
(
data
.
Length
==
0
)
{
pic
.
hashed_data
=
new
float
[
10
,
10
,
4
];
for
(
int
w
=
0
;
w
<
10
;
w
++)
...
...
@@ -342,7 +442,9 @@ public class GameTextureManager
}
else
{
pic
.
hashed_data
=
getCuttedPic
(
path
,
pic
.
pCard
,
Iam8
);
MemoryStream
stream
=
new
MemoryStream
(
data
);
bitmap
=
new
BitmapHelper
(
stream
);
pic
.
hashed_data
=
getCuttedPic
(
bitmap
,
pic
.
pCard
,
EightEdition
);
int
width
=
pic
.
hashed_data
.
GetLength
(
0
);
int
height
=
pic
.
hashed_data
.
GetLength
(
1
);
int
size
=
(
int
)(
height
*
0.8
);
...
...
@@ -440,9 +542,8 @@ public class GameTextureManager
}
}
private
static
float
[,,]
getCuttedPic
(
string
path
,
bool
pCard
,
bool
EightEdition
)
private
static
float
[,,]
getCuttedPic
(
BitmapHelper
bitmap
,
bool
pCard
,
bool
EightEdition
)
{
BitmapHelper
bitmap
=
new
BitmapHelper
(
path
);
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
)
...
...
@@ -569,36 +670,24 @@ public class GameTextureManager
private
static
void
ProcessingVerticleDrawing
(
PictureResource
pic
)
{
string
path
=
"picture/closeup/"
+
pic
.
code
.
ToString
()
+
".png"
;
if
(
!
File
.
Exists
(
path
)
)
var
bitmap
=
getCloseup
(
pic
)
;
if
(
bitmap
==
null
)
{
path
=
"picture/card/"
+
pic
.
code
.
ToString
()
+
".png"
;
if
(!
File
.
Exists
(
path
))
{
path
=
"picture/card/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
bool
Iam8
=
false
;
if
(!
File
.
Exists
(
path
))
{
Iam8
=
true
;
path
=
"picture/cardIn8thEdition/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
))
{
path
=
"texture/duel/unknown.jpg"
;
}
if
(!
File
.
Exists
(
path
))
bool
EightEdition
;
var
data
=
getPicture
(
pic
,
out
EightEdition
);
if
(
data
.
Length
==
0
)
{
return
;
}
pic
.
hashed_data
=
getCuttedPic
(
path
,
pic
.
pCard
,
Iam8
);
MemoryStream
stream
=
new
MemoryStream
(
data
);
bitmap
=
new
BitmapHelper
(
stream
);
pic
.
hashed_data
=
getCuttedPic
(
bitmap
,
pic
.
pCard
,
EightEdition
);
softVtype
(
pic
,
0.5f
);
pic
.
k
=
1
;
//pic.autoMade = true;
}
else
{
BitmapHelper
bitmap
=
new
BitmapHelper
(
path
);
int
left
;
int
right
;
int
up
;
...
...
@@ -709,66 +798,26 @@ public class GameTextureManager
private
static
void
ProcessingCardPicture
(
PictureResource
pic
)
{
string
path
=
"picture/card/"
+
pic
.
code
.
ToString
()
+
".png"
;
if
(!
File
.
Exists
(
path
))
bool
EightEdition
;
var
data
=
getPicture
(
pic
,
out
EightEdition
);
if
(
data
.
Length
>
0
)
{
path
=
"picture/card/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
))
{
path
=
"picture/cardIn8thEdition/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
))
{
bool
found
=
false
;
foreach
(
ZipFile
zip
in
GameZipManager
.
Zips
)
{
foreach
(
string
file
in
zip
.
EntryFileNames
)
{
string
file1
=
file
.
ToLower
();
if
(
file1
.
EndsWith
(
pic
.
code
.
ToString
()
+
".jpg"
)
&&
!
file1
.
Contains
(
"field"
))
{
MemoryStream
ms
=
new
MemoryStream
();
ZipEntry
e
=
zip
[
file
];
e
.
Extract
(
ms
);
pic
.
data
=
ms
.
ToArray
();
if
(!
loadedList
.
ContainsKey
(
hashPic
(
pic
.
code
,
pic
.
type
)))
{
loadedList
.
Add
(
hashPic
(
pic
.
code
,
pic
.
type
),
pic
);
}
found
=
true
;
break
;
}
}
if
(
found
)
break
;
}
if
(!
found
)
pic
.
data
=
data
;
if
(!
loadedList
.
ContainsKey
(
hashPic
(
pic
.
code
,
pic
.
type
)))
{
if
(
pic
.
code
>
0
)
{
pic
.
u_data
=
unknown
;
}
else
{
pic
.
u_data
=
myBack
;
}
if
(!
loadedList
.
ContainsKey
(
hashPic
(
pic
.
code
,
pic
.
type
)))
{
loadedList
.
Add
(
hashPic
(
pic
.
code
,
pic
.
type
),
pic
);
}
loadedList
.
Add
(
hashPic
(
pic
.
code
,
pic
.
type
),
pic
);
}
}
else
{
byte
[]
data
;
using
(
FileStream
file
=
new
FileStream
(
path
,
FileMode
.
Open
,
FileAccess
.
Read
))
if
(
pic
.
code
>
0
)
{
file
.
Seek
(
0
,
SeekOrigin
.
Begin
);
data
=
new
byte
[
file
.
Length
];
file
.
Read
(
data
,
0
,
(
int
)
file
.
Length
);
pic
.
u_data
=
unknown
;
}
else
{
pic
.
u_data
=
myBack
;
}
pic
.
data
=
data
;
if
(!
loadedList
.
ContainsKey
(
hashPic
(
pic
.
code
,
pic
.
type
)))
{
loadedList
.
Add
(
hashPic
(
pic
.
code
,
pic
.
type
),
pic
);
...
...
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