Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
aaa56acf
Commit
aaa56acf
authored
Aug 10, 2009
by
marcus
Browse files
picURL added to oracleimporter and carddatabase
parent
e79b1941
Changes
4
Show whitespace changes
Inline
Side-by-side
cockatrice/src/carddatabase.cpp
View file @
aaa56acf
...
...
@@ -54,8 +54,8 @@ void SetList::sortByKey()
qSort
(
begin
(),
end
(),
CompareFunctor
());
}
CardInfo
::
CardInfo
(
CardDatabase
*
_db
,
const
QString
&
_name
,
const
QString
&
_manacost
,
const
QString
&
_cardtype
,
const
QString
&
_powtough
,
const
QString
&
_text
,
const
QStringList
&
_colors
,
int
_tableRow
,
const
SetList
&
_sets
)
:
db
(
_db
),
name
(
_name
),
sets
(
_sets
),
manacost
(
_manacost
),
cardtype
(
_cardtype
),
powtough
(
_powtough
),
text
(
_text
),
colors
(
_colors
),
tableRow
(
_tableRow
),
pixmap
(
NULL
)
CardInfo
::
CardInfo
(
CardDatabase
*
_db
,
const
QString
&
_name
,
const
QString
&
_manacost
,
const
QString
&
_cardtype
,
const
QString
&
_powtough
,
const
QString
&
_text
,
const
QStringList
&
_colors
,
int
_tableRow
,
const
SetList
&
_sets
,
const
QString
&
_picURL
)
:
db
(
_db
),
name
(
_name
),
sets
(
_sets
),
manacost
(
_manacost
),
cardtype
(
_cardtype
),
powtough
(
_powtough
),
text
(
_text
),
colors
(
_colors
),
tableRow
(
_tableRow
),
pixmap
(
NULL
)
,
picURL
(
_picURL
)
{
for
(
int
i
=
0
;
i
<
sets
.
size
();
i
++
)
sets
[
i
]
->
append
(
this
);
...
...
@@ -194,6 +194,7 @@ QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
xml
.
writeTextElement
(
"pt"
,
info
->
getPowTough
());
xml
.
writeTextElement
(
"tablerow"
,
QString
::
number
(
info
->
getTableRow
()));
xml
.
writeTextElement
(
"text"
,
info
->
getText
());
xml
.
writeTextElement
(
"picURL"
,
info
->
getPicURL
());
xml
.
writeEndElement
();
// card
return
xml
;
...
...
cockatrice/src/carddatabase.h
View file @
aaa56acf
...
...
@@ -42,6 +42,7 @@ private:
QString
powtough
;
QString
text
;
QStringList
colors
;
QString
picURL
;
int
tableRow
;
QPixmap
*
pixmap
;
QMap
<
int
,
QPixmap
*>
scaledPixmapCache
;
...
...
@@ -54,7 +55,8 @@ public:
const
QString
&
_text
=
QString
(),
const
QStringList
&
_colors
=
QStringList
(),
int
_tableRow
=
0
,
const
SetList
&
_sets
=
SetList
());
const
SetList
&
_sets
=
SetList
(),
const
QString
&
_picURL
=
QString
());
~
CardInfo
();
QString
getName
()
const
{
return
name
;
}
SetList
getSets
()
const
{
return
sets
;
}
...
...
@@ -63,9 +65,11 @@ public:
QString
getPowTough
()
const
{
return
powtough
;
}
QString
getText
()
const
{
return
text
;
}
QStringList
getColors
()
const
{
return
colors
;
}
QString
getPicURL
()
const
{
return
picURL
;
}
QString
getMainCardType
()
const
;
int
getTableRow
()
const
{
return
tableRow
;
}
void
setTableRow
(
int
_tableRow
)
{
tableRow
=
_tableRow
;
}
void
setPicURL
(
QString
_picURL
)
{
picURL
=
_picURL
;
}
void
addToSet
(
CardSet
*
set
);
QPixmap
*
loadPixmap
();
QPixmap
*
getPixmap
(
QSize
size
);
...
...
oracle/src/oracleimporter.cpp
View file @
aaa56acf
...
...
@@ -73,6 +73,7 @@ OracleImporter::OracleImporter()
setsToDownload
<<
SetToDownload
(
"PR"
,
"Promo cards"
,
"pr.txt"
);
setsToDownload
<<
SetToDownload
(
"UG"
,
"Unglued"
,
"http://www.crystalkeep.com/magic/rules/oracle/oracle-ug.txt"
);
setsToDownload
<<
SetToDownload
(
"UNH"
,
"Unhinged"
,
"http://www.crystalkeep.com/magic/rules/oracle/oracle-uh.txt"
);
setsToDownload
<<
SetToDownload
(
"M10"
,
"Magic 2010"
,
"http://www.crystalkeep.com/magic/rules/oracle/oracle-m10.txt"
);
colorOverride
.
insert
(
"Ancestral Vision"
,
QStringList
(
"U"
));
colorOverride
.
insert
(
"Crimson Kobolds"
,
QStringList
(
"R"
));
...
...
@@ -203,6 +204,10 @@ void OracleImporter::importOracleFile(CardSet *set)
QString
cardname
=
in
.
readLine
();
if
(
cardname
.
isEmpty
())
continue
;
if
(
cardname
.
contains
(
"XX"
)){
cardname
.
remove
(
"XX"
);
}
QString
manacost
=
in
.
readLine
();
QString
cardtype
,
powtough
;
QStringList
text
;
...
...
@@ -238,7 +243,7 @@ void OracleImporter::importOracleFile(CardSet *set)
colors
=
colorOverride
.
value
(
cardname
);
card
=
new
CardInfo
(
this
,
cardname
,
manacost
,
cardtype
,
powtough
,
text
.
join
(
"
\n
"
),
colors
);
card
->
setPicURL
(
getURLFromName
(
normalizeName
(
cardname
)));
int
tableRow
=
1
;
QString
mainCardType
=
card
->
getMainCardType
();
if
(
tableRowOverride
.
contains
(
cardname
))
...
...
@@ -259,6 +264,28 @@ void OracleImporter::importOracleFile(CardSet *set)
qDebug
(
QString
(
"%1: %2 cards imported"
).
arg
(
set
->
getLongName
()).
arg
(
cards
).
toLatin1
());
}
QString
OracleImporter
::
normalizeName
(
QString
cardname
)
{
QString
normalized
=
cardname
;
normalized
.
remove
(
"'"
,
Qt
::
CaseInsensitive
);
normalized
.
remove
(
"//"
,
Qt
::
CaseInsensitive
);
normalized
.
remove
(
","
,
Qt
::
CaseInsensitive
);
normalized
.
remove
(
":"
,
Qt
::
CaseInsensitive
);
normalized
.
remove
(
"."
,
Qt
::
CaseInsensitive
);
normalized
.
remove
(
QRegExp
(
"
\\
(.*
\\
)"
));
normalized
=
normalized
.
trimmed
();
normalized
=
normalized
.
simplified
();
normalized
=
normalized
.
replace
(
" "
,
"_"
);
normalized
=
normalized
.
replace
(
"-"
,
"_"
);
return
normalized
;
}
QString
OracleImporter
::
getURLFromName
(
QString
normalizedName
)
{
return
"http://www.wizards.com/global/images/magic/general/"
+
normalizedName
+
".jpg"
;
}
void
OracleImporter
::
downloadNextFile
()
{
if
(
setIndex
==
-
1
)
{
...
...
oracle/src/oracleimporter.h
View file @
aaa56acf
...
...
@@ -29,6 +29,8 @@ private:
QBuffer
*
buffer
;
QHttp
*
http
;
QProgressDialog
*
progressDialog
;
QString
normalizeName
(
QString
);
QString
getURLFromName
(
QString
);
private
slots
:
void
httpRequestFinished
(
int
requestId
,
bool
error
);
void
readResponseHeader
(
const
QHttpResponseHeader
&
responseHeader
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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