Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
I
ImgGen
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
MyCard
ImgGen
Commits
edcd0708
Commit
edcd0708
authored
Apr 29, 2020
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cache cards database
parent
b72f75f3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
66 deletions
+43
-66
Data.cs
Data.cs
+2
-8
DataManager.cs
DataManager.cs
+41
-58
No files found.
Data.cs
View file @
edcd0708
...
...
@@ -88,14 +88,6 @@
LINK_MARKER_TOP_RIGHT
=
0x100
}
[
StructLayout
(
LayoutKind
.
Sequential
)]
public
struct
Text
{
public
string
name
;
public
string
text
;
public
string
[]
desc
;
}
[
StructLayout
(
LayoutKind
.
Sequential
)]
public
struct
Data
{
...
...
@@ -108,6 +100,8 @@
public
Race
race
;
public
int
attack
;
public
int
defence
;
public
string
name
;
public
string
text
;
public
bool
isType
(
Type
typ
)
{
...
...
DataManager.cs
View file @
edcd0708
...
...
@@ -18,6 +18,8 @@ namespace ImgGen
private
static
Bitmap
[]
bLinkNums
=
new
Bitmap
[
8
];
private
static
Bitmap
[]
bLinkMarkers
=
new
Bitmap
[
9
];
private
static
Dictionary
<
int
,
Data
>
cardDatas
=
new
Dictionary
<
int
,
Data
>();
private
static
SQLiteConnection
conn
;
private
static
object
locker
=
new
object
();
...
...
@@ -149,68 +151,49 @@ namespace ImgGen
if
(
i
==
5
)
continue
;
bLinkMarkers
[
i
-
1
]
=
new
Bitmap
(
$"./textures/link_marker_on_
{
i
}
.png"
);
}
conn
.
Open
();
SQLiteCommand
command
=
new
SQLiteCommand
(
conn
);
command
.
CommandText
=
"SELECT * FROM datas JOIN texts on datas.id = texts.id"
;
SQLiteDataReader
reader
=
command
.
ExecuteReader
();
while
(
reader
.
Read
())
{
Data
data
=
new
Data
();
data
.
code
=
(
int
)(
long
)
reader
[
"id"
];
data
.
alias
=
(
int
)(
long
)
reader
[
"alias"
];
data
.
setcode
=
(
int
)(
long
)
reader
[
"setcode"
];
data
.
type
=
(
Type
)(
long
)
reader
[
"type"
];
data
.
attack
=
(
int
)(
long
)
reader
[
"atk"
];
data
.
defence
=
(
int
)(
long
)
reader
[
"def"
];
data
.
level
=
(
int
)(
long
)
reader
[
"level"
];
data
.
race
=
(
Race
)(
long
)
reader
[
"race"
];
data
.
attribute
=
(
Attribute
)(
long
)
reader
[
"attribute"
];
data
.
name
=
(
string
)
reader
[
"name"
];
data
.
text
=
(
string
)
reader
[
"desc"
];
cardDatas
.
Add
(
data
.
code
,
data
);
}
reader
.
Close
();
command
.
Dispose
();
conn
.
Close
();
}
public
static
Bitmap
GetImage
(
int
code
)
{
lock
(
locker
)
Data
data
;
if
(
cardDatas
.
ContainsKey
(
code
))
{
Data
data
=
new
Data
();
Text
text
=
new
Text
();
data
=
cardDatas
[
code
];
}
else
{
Console
.
WriteLine
(
$"Card
{
code
}
not found!"
);
data
=
new
Data
();
data
.
code
=
code
;
text
.
name
=
"???"
;
text
.
text
=
"???"
;
SQLiteCommand
command
=
null
;
SQLiteDataReader
reader
=
null
;
try
{
conn
.
Open
();
command
=
new
SQLiteCommand
(
conn
);
command
.
CommandText
=
$"SELECT * FROM datas WHERE id=
{
code
}
"
;
reader
=
command
.
ExecuteReader
();
if
(
reader
.
Read
())
{
data
.
code
=
(
int
)(
long
)
reader
[
"id"
];
data
.
alias
=
(
int
)(
long
)
reader
[
"alias"
];
data
.
setcode
=
(
int
)(
long
)
reader
[
"setcode"
];
data
.
type
=
(
Type
)(
long
)
reader
[
"type"
];
data
.
attack
=
(
int
)(
long
)
reader
[
"atk"
];
data
.
defence
=
(
int
)(
long
)
reader
[
"def"
];
data
.
level
=
(
int
)(
long
)
reader
[
"level"
];
data
.
race
=
(
Race
)(
long
)
reader
[
"race"
];
data
.
attribute
=
(
Attribute
)(
long
)
reader
[
"attribute"
];
}
reader
.
Close
();
reader
=
null
;
// for Exception -> finally GC
command
.
CommandText
=
$"SELECT * FROM texts WHERE id=
{
code
}
"
;
reader
=
command
.
ExecuteReader
();
if
(
reader
.
Read
())
{
text
.
name
=
(
string
)
reader
[
"name"
];
text
.
text
=
(
string
)
reader
[
"desc"
];
}
reader
.
Close
();
return
DrawCard
(
data
,
text
);
}
catch
(
Exception
e
)
#if DEBUG
when
(
false
)
#endif
{
Console
.
WriteLine
(
$"Error when parsing
{
code
}
-
{
e
}
"
);
return
null
;
}
finally
{
reader
?.
Close
();
command
?.
Dispose
();
conn
.
Close
();
}
data
.
name
=
"???"
;
data
.
text
=
"???"
;
}
return
DrawCard
(
data
);
}
private
static
string
FormatCardDesc
(
string
r
)
...
...
@@ -607,7 +590,7 @@ namespace ImgGen
graphics
.
ResetTransform
();
}
private
static
Bitmap
DrawCard
(
Data
data
,
Text
text
)
private
static
Bitmap
DrawCard
(
Data
data
)
{
Bitmap
bitmap
=
new
Bitmap
(
400
,
580
);
Graphics
graphics
=
Graphics
.
FromImage
(
bitmap
);
...
...
@@ -618,8 +601,8 @@ namespace ImgGen
graphics
.
SmoothingMode
=
SmoothingMode
.
AntiAlias
;
graphics
.
TextRenderingHint
=
TextRenderingHint
.
AntiAlias
;
string
name
=
FormatCardName
(
text
.
name
);
string
desc
=
FormatCardDesc
(
text
.
text
);
string
name
=
FormatCardName
(
data
.
name
);
string
desc
=
FormatCardDesc
(
data
.
text
);
DrawPicture
(
graphics
,
data
);
DrawTemplate
(
graphics
,
data
);
...
...
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