Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
MDPro3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Merge Requests
4
Merge Requests
4
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
赤子奈落
MDPro3
Commits
7e6627b8
Commit
7e6627b8
authored
Mar 18, 2026
by
SherryChaos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update CardsManager.cs
parent
a3c4ef1f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
68 deletions
+39
-68
Assets/Scripts/MDPro3/Duel/YGOSharp/CardsManager.cs
Assets/Scripts/MDPro3/Duel/YGOSharp/CardsManager.cs
+39
-68
No files found.
Assets/Scripts/MDPro3/Duel/YGOSharp/CardsManager.cs
View file @
7e6627b8
...
@@ -6,6 +6,7 @@ using Mono.Data.Sqlite;
...
@@ -6,6 +6,7 @@ using Mono.Data.Sqlite;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.Data
;
using
System.Diagnostics
;
using
System.Globalization
;
using
System.Globalization
;
using
System.IO
;
using
System.IO
;
using
System.Text.RegularExpressions
;
using
System.Text.RegularExpressions
;
...
@@ -18,9 +19,11 @@ namespace MDPro3.Duel.YGOSharp
...
@@ -18,9 +19,11 @@ namespace MDPro3.Duel.YGOSharp
public
static
string
nullName
=
string
.
Empty
;
public
static
string
nullName
=
string
.
Empty
;
public
static
string
nullString
=
string
.
Empty
;
public
static
string
nullString
=
string
.
Empty
;
public
static
string
nameInSearch
=
string
.
Empty
;
public
static
string
nameInSearch
=
string
.
Empty
;
private
const
string
EXPANSION_CDB
=
".cdb"
;
public
static
IDictionary
<
int
,
Card
>
_cards
=
new
Dictionary
<
int
,
Card
>();
public
static
IDictionary
<
int
,
Card
>
_cardsForRender
=
new
Dictionary
<
int
,
Card
>();
public
static
Dictionary
<
int
,
Card
>
_cards
=
new
();
public
static
Dictionary
<
int
,
Card
>
_cardsForRender
=
new
();
private
static
readonly
CompareInfo
SearchCompareInfo
=
CultureInfo
.
InvariantCulture
.
CompareInfo
;
private
static
readonly
CompareInfo
SearchCompareInfo
=
CultureInfo
.
InvariantCulture
.
CompareInfo
;
private
const
CompareOptions
SearchCompareOptions
=
private
const
CompareOptions
SearchCompareOptions
=
CompareOptions
.
IgnoreCase
|
CompareOptions
.
IgnoreWidth
|
CompareOptions
.
IgnoreKanaType
;
CompareOptions
.
IgnoreCase
|
CompareOptions
.
IgnoreWidth
|
CompareOptions
.
IgnoreKanaType
;
...
@@ -62,58 +65,38 @@ namespace MDPro3.Duel.YGOSharp
...
@@ -62,58 +65,38 @@ namespace MDPro3.Duel.YGOSharp
internal
static
void
Initialize
()
internal
static
void
Initialize
()
{
{
nullName
=
InterString
.
Get
(
"未知卡片"
);
nullName
=
InterString
.
Get
(
"未知卡片"
);
nullString
=
string
.
Empty
;
IDictionary
<
int
,
Card
>
previousCards
=
_cards
;
IDictionary
<
int
,
Card
>
previousRenderCards
=
_cardsForRender
;
var
loadedCards
=
new
Dictionary
<
int
,
Card
>(
Math
.
Max
(
previousCards
?.
Count
??
0
,
16384
))
;
var
preCards
=
_cards
;
var
loadedRenderCards
=
new
Dictionary
<
int
,
Card
>(
Math
.
Max
(
previousRenderCards
?.
Count
??
0
,
16384
))
;
var
preRenderCards
=
_cardsForRender
;
bool
loadedMain
=
TryLoadCardsForLanguage
(
loadedCards
,
Language
.
GetConfig
(),
render
:
false
);
var
language
=
Language
.
GetConfig
(
);
bool
loadedRender
=
TryLoadCardsForLanguage
(
loadedRenderCards
,
Language
.
GetCardConfig
(),
render
:
true
);
var
cardLanguage
=
Language
.
GetCardConfig
(
);
if
(!
loadedMain
||
loadedCards
.
Count
==
0
)
_cards
=
new
();
if
(!
TryLoadCardsForLanguage
(
_cards
,
language
))
{
{
if
(
string
.
IsNullOrEmpty
(
MDPro3
.
MessageManager
.
messageFromSubString
))
UnityEngine
.
Debug
.
LogError
(
"Load CDB Error."
);
{
_cards
=
preCards
;
MDPro3
.
MessageManager
.
messageFromSubString
=
InterString
.
Get
(
"Failed to load card database. Some cards may be shown as unknown."
);
}
if
(
previousCards
!=
null
&&
previousCards
.
Count
>
0
)
_cards
=
previousCards
;
else
_cards
=
loadedCards
;
if
(
previousRenderCards
!=
null
&&
previousRenderCards
.
Count
>
0
)
_cardsForRender
=
previousRenderCards
;
else
_cardsForRender
=
loadedRenderCards
;
return
;
}
}
if
(
!
loadedRender
)
if
(
language
==
cardLanguage
)
{
{
if
(
previousRenderCards
!=
null
&&
previousRenderCards
.
Count
>
0
)
_cardsForRender
=
_cards
;
loadedRenderCards
=
new
Dictionary
<
int
,
Card
>(
previousRenderCards
);
}
else
else
loadedRenderCards
=
new
Dictionary
<
int
,
Card
>(
loadedCards
);
{
_cardsForRender
=
new
();
if
(!
TryLoadCardsForLanguage
(
_cardsForRender
,
cardLanguage
))
{
UnityEngine
.
Debug
.
LogError
(
"Load CDB Error."
);
_cardsForRender
=
preRenderCards
;
}
}
}
_cards
=
loadedCards
;
_cardsForRender
=
loadedRenderCards
;
UpdateSetNames
();
UpdateSetNames
();
PacksManager
.
Initialize
();
PacksManager
.
Initialize
();
}
}
internal
static
void
LoadCDB
(
string
databaseFullPath
,
bool
render
=
false
,
bool
isPreCards
=
false
)
{
var
targetCards
=
render
?
_cardsForRender
:
_cards
;
TryLoadCDB
(
databaseFullPath
,
targetCards
,
isPreCards
,
render
,
optionalDatabase
:
false
);
}
internal
static
void
UpdateSetNames
()
internal
static
void
UpdateSetNames
()
{
{
foreach
(
var
item
in
_cards
)
foreach
(
var
item
in
_cards
)
...
@@ -188,17 +171,17 @@ namespace MDPro3.Duel.YGOSharp
...
@@ -188,17 +171,17 @@ namespace MDPro3.Duel.YGOSharp
return
returnValue
;
return
returnValue
;
}
}
private
static
bool
TryLoadCardsForLanguage
(
IDictionary
<
int
,
Card
>
targetCards
,
string
language
,
bool
render
)
private
static
bool
TryLoadCardsForLanguage
(
IDictionary
<
int
,
Card
>
targetCards
,
string
language
)
{
{
string
databaseFullPath
=
ResolveCardsDatabasePath
(
language
);
string
databaseFullPath
=
ResolveCardsDatabasePath
(
language
);
if
(!
TryLoadCDB
(
databaseFullPath
,
targetCards
,
isPreCards
:
false
,
render
,
optionalDatabase
:
false
))
if
(!
TryLoadCDB
(
databaseFullPath
,
targetCards
,
isPreCards
:
false
))
return
false
;
return
false
;
if
(
Config
.
Get
(
"Expansions"
,
"1"
)
!=
"1"
)
if
(
Config
.
Get
Bool
(
"Expansions"
,
true
)
)
return
true
;
return
true
;
foreach
(
var
cdb
in
Directory
.
GetFiles
(
"Expansions"
,
"*.cdb"
))
foreach
(
var
cdb
in
Directory
.
GetFiles
(
Program
.
PATH_EXPANSIONS
,
EXPANSION_CDB
))
TryLoadCDB
(
cdb
,
targetCards
,
isPreCards
:
false
,
render
,
optionalDatabase
:
true
);
TryLoadCDB
(
cdb
,
targetCards
,
isPreCards
:
false
);
foreach
(
var
zip
in
ZipHelper
.
zips
)
foreach
(
var
zip
in
ZipHelper
.
zips
)
{
{
...
@@ -207,7 +190,7 @@ namespace MDPro3.Duel.YGOSharp
...
@@ -207,7 +190,7 @@ namespace MDPro3.Duel.YGOSharp
foreach
(
var
file
in
zip
.
EntryFileNames
)
foreach
(
var
file
in
zip
.
EntryFileNames
)
{
{
if
(!
file
.
ToLower
().
EndsWith
(
".cdb"
))
if
(!
file
.
ToLower
().
EndsWith
(
EXPANSION_CDB
))
continue
;
continue
;
string
tempRoot
=
Path
.
GetFullPath
(
Program
.
PATH_TEMP_FOLDER
);
string
tempRoot
=
Path
.
GetFullPath
(
Program
.
PATH_TEMP_FOLDER
);
...
@@ -223,12 +206,13 @@ namespace MDPro3.Duel.YGOSharp
...
@@ -223,12 +206,13 @@ namespace MDPro3.Duel.YGOSharp
bool
fromPrereleasePack
=
Path
.
GetFileName
(
zip
.
Name
)
bool
fromPrereleasePack
=
Path
.
GetFileName
(
zip
.
Name
)
.
Equals
(
"ygopro-super-pre.ypk"
,
StringComparison
.
OrdinalIgnoreCase
);
.
Equals
(
"ygopro-super-pre.ypk"
,
StringComparison
.
OrdinalIgnoreCase
);
isPreCards
=
fromPrereleasePack
&&
(
render
||
file
.
ToLower
().
StartsWith
(
"test-release"
));
isPreCards
=
fromPrereleasePack
&&
file
.
ToLower
().
StartsWith
(
"test-release"
);
TryLoadCDB
(
tempFile
,
targetCards
,
isPreCards
);
TryLoadCDB
(
tempFile
,
targetCards
,
isPreCards
,
render
,
optionalDatabase
:
true
);
}
}
catch
(
Exception
)
catch
(
Exception
e
)
{
{
UnityEngine
.
Debug
.
LogException
(
e
);
return
false
;
}
}
finally
finally
{
{
...
@@ -237,9 +221,7 @@ namespace MDPro3.Duel.YGOSharp
...
@@ -237,9 +221,7 @@ namespace MDPro3.Duel.YGOSharp
if
(
File
.
Exists
(
tempFile
))
if
(
File
.
Exists
(
tempFile
))
File
.
Delete
(
tempFile
);
File
.
Delete
(
tempFile
);
}
}
catch
(
Exception
)
catch
{}
{
}
}
}
}
}
}
}
...
@@ -258,9 +240,7 @@ namespace MDPro3.Duel.YGOSharp
...
@@ -258,9 +240,7 @@ namespace MDPro3.Duel.YGOSharp
private
static
bool
TryLoadCDB
(
private
static
bool
TryLoadCDB
(
string
databaseFullPath
,
string
databaseFullPath
,
IDictionary
<
int
,
Card
>
targetCards
,
IDictionary
<
int
,
Card
>
targetCards
,
bool
isPreCards
,
bool
isPreCards
)
bool
render
,
bool
optionalDatabase
)
{
{
try
try
{
{
...
@@ -271,19 +251,10 @@ namespace MDPro3.Duel.YGOSharp
...
@@ -271,19 +251,10 @@ namespace MDPro3.Duel.YGOSharp
new
SqliteCommand
(
"SELECT datas.*, texts.* FROM datas,texts WHERE datas.id=texts.id;"
,
connection
);
new
SqliteCommand
(
"SELECT datas.*, texts.* FROM datas,texts WHERE datas.id=texts.id;"
,
connection
);
using
IDataReader
reader
=
command
.
ExecuteReader
();
using
IDataReader
reader
=
command
.
ExecuteReader
();
while
(
reader
.
Read
())
while
(
reader
.
Read
())
{
LoadCard
(
reader
,
targetCards
,
isPreCards
);
try
{
LoadCard
(
reader
,
targetCards
,
isPreCards
);
}
catch
(
Exception
)
{
}
}
return
true
;
return
true
;
}
}
catch
(
Exception
)
catch
{
{
return
false
;
return
false
;
}
}
...
...
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