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
bc79d9e2
Commit
bc79d9e2
authored
Feb 24, 2016
by
Gavin Bisesi
Browse files
Merge pull request #1796 from zebington/feat/custom-set-import
Add "Import custom set" function
parents
66634c9b
aa658f95
Changes
5
Hide whitespace changes
Inline
Side-by-side
cockatrice/CMakeLists.txt
View file @
bc79d9e2
...
...
@@ -7,6 +7,7 @@ PROJECT(cockatrice)
SET
(
cockatrice_SOURCES
src/abstractcounter.cpp
src/counter_general.cpp
src/dlg_add_set_result.cpp
src/dlg_creategame.cpp
src/dlg_filter_games.cpp
src/dlg_connect.cpp
...
...
cockatrice/src/dlg_add_set_result.cpp
0 → 100644
View file @
bc79d9e2
#include
"dlg_add_set_result.h"
#include
<QDialogButtonBox>
#include
<QPushButton>
#include
<QVBoxLayout>
DlgAddSetResult
::
DlgAddSetResult
(
QWidget
*
parent
,
bool
success
,
QString
msg
)
:
QDialog
(
parent
)
{
status
=
new
QLabel
(
this
);
message
=
new
QLabel
(
this
);
if
(
success
)
{
setWindowTitle
(
tr
(
"Success"
));
status
->
setText
(
QString
(
"Sets/cards added to Cockatrice."
));
message
->
setText
(
QString
(
"You must restart Cockatrice to use the new sets/cards."
));
}
else
{
setWindowTitle
(
tr
(
"Failed"
));
status
->
setText
(
QString
(
"Sets/cards failed to import."
));
message
->
setText
(
msg
);
}
QDialogButtonBox
*
buttonBox
=
new
QDialogButtonBox
(
this
);
ok
=
new
QPushButton
(
tr
(
"Ok"
),
this
);
buttonBox
->
addButton
(
ok
,
QDialogButtonBox
::
AcceptRole
);
connect
(
ok
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
closeDialog
()));
QVBoxLayout
*
parentLayout
=
new
QVBoxLayout
(
this
);
parentLayout
->
addWidget
(
status
);
parentLayout
->
addWidget
(
message
);
parentLayout
->
addWidget
(
buttonBox
);
setLayout
(
parentLayout
);
}
void
DlgAddSetResult
::
closeDialog
()
{
accept
();
}
\ No newline at end of file
cockatrice/src/dlg_add_set_result.h
0 → 100644
View file @
bc79d9e2
#ifndef DLG_ADD_SET_RESULT_H
#define DLG_ADD_SET_RESULT_H
#include
<QDialog>
#include
<QLabel>
#include
<QString>
class
DlgAddSetResult
:
public
QDialog
{
Q_OBJECT
public:
DlgAddSetResult
(
QWidget
*
parent
,
bool
success
,
QString
msg
);
private
slots
:
void
closeDialog
();
private:
QLabel
*
status
,
*
message
;
QPushButton
*
ok
;
};
#endif
\ No newline at end of file
cockatrice/src/tab_deck_editor.cpp
View file @
bc79d9e2
...
...
@@ -32,6 +32,7 @@
#include
"cardinfowidget.h"
#include
"dlg_load_deck_from_clipboard.h"
#include
"dlg_edit_tokens.h"
#include
"dlg_add_set_result.h"
#include
"main.h"
#include
"settingscache.h"
#include
"priceupdater.h"
...
...
@@ -45,6 +46,10 @@
#include
"cardframe.h"
#include
"filterbuilder.h"
const
QStringList
TabDeckEditor
::
fileNameFilters
=
QStringList
()
<<
QObject
::
tr
(
"Cockatrice card database (*.xml)"
)
<<
QObject
::
tr
(
"All files (*.*)"
);
void
SearchLineEdit
::
keyPressEvent
(
QKeyEvent
*
event
)
{
if
(
treeView
&&
((
event
->
key
()
==
Qt
::
Key_Up
)
||
(
event
->
key
()
==
Qt
::
Key_Down
)))
...
...
@@ -267,6 +272,9 @@ void TabDeckEditor::createMenus()
aOpenCustomFolder
=
new
QAction
(
QString
(),
this
);
connect
(
aOpenCustomFolder
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actOpenCustomFolder
()));
aAddCustomSet
=
new
QAction
(
QString
(),
this
);
connect
(
aAddCustomSet
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actAddCustomSet
()));
aEditSets
=
new
QAction
(
QString
(),
this
);
connect
(
aEditSets
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actEditSets
()));
...
...
@@ -303,11 +311,12 @@ void TabDeckEditor::createMenus()
dbMenu
->
addSeparator
();
dbMenu
->
addAction
(
aClearFilterOne
);
dbMenu
->
addAction
(
aClearFilterAll
);
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
dbMenu
->
addSeparator
();
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
dbMenu
->
addAction
(
aOpenCustomFolder
);
dbMenu
->
addAction
(
aOpenCustomsetsFolder
);
#endif
dbMenu
->
addAction
(
aAddCustomSet
);
addTabMenu
(
dbMenu
);
viewMenu
=
new
QMenu
(
this
);
...
...
@@ -584,7 +593,8 @@ void TabDeckEditor::retranslateUi()
aPrintDeck
->
setText
(
tr
(
"&Print deck..."
));
aAnalyzeDeck
->
setText
(
tr
(
"&Analyze deck on deckstats.net"
));
aOpenCustomFolder
->
setText
(
tr
(
"Open custom image folder"
));
aOpenCustomsetsFolder
->
setText
(
tr
(
"Open custom sets folder"
));
aOpenCustomsetsFolder
->
setText
(
tr
(
"Open custom sets folder"
));
aAddCustomSet
->
setText
(
tr
(
"Add custom sets/cards"
));
aClose
->
setText
(
tr
(
"&Close"
));
aAddCard
->
setText
(
tr
(
"Add card to &maindeck"
));
...
...
@@ -704,9 +714,6 @@ void TabDeckEditor::actNewDeck()
void
TabDeckEditor
::
actLoadDeck
()
{
if
(
!
confirmClose
())
return
;
QFileDialog
dialog
(
this
,
tr
(
"Load deck"
));
dialog
.
setDirectory
(
settingsCache
->
getDeckPath
());
dialog
.
setNameFilters
(
DeckLoader
::
fileNameFilters
);
...
...
@@ -863,6 +870,55 @@ void TabDeckEditor::actOpenCustomsetsFolder() {
}
void
TabDeckEditor
::
actAddCustomSet
()
{
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
QString
dataDir
=
QDesktopServices
::
storageLocation
(
QDesktopServices
::
DataLocation
);
#else
QString
dataDir
=
QStandardPaths
::
standardLocations
(
QStandardPaths
::
DataLocation
).
first
();
#endif
QFileDialog
dialog
(
this
,
tr
(
"Load sets/cards"
));
dialog
.
setDirectory
(
dataDir
);
dialog
.
setNameFilters
(
TabDeckEditor
::
fileNameFilters
);
if
(
!
dialog
.
exec
())
return
;
QString
fileName
=
dialog
.
selectedFiles
().
at
(
0
);
if
(
!
QFile
::
exists
(
fileName
))
{
DlgAddSetResult
dlg
(
this
,
false
,
QString
(
"Selected file cannot be found."
));
dlg
.
exec
();
return
;
}
QDir
dir
(
dataDir
+
"/customsets"
);
int
nextPrefix
=
getNextCustomSetPrefix
(
dir
);
bool
res
=
QFile
::
copy
(
fileName
,
dir
.
absolutePath
()
+
"/"
+
(
nextPrefix
>
9
?
""
:
"0"
)
+
QString
::
number
(
nextPrefix
)
+
"."
+
QFileInfo
(
fileName
).
fileName
()
);
DlgAddSetResult
dlg
(
this
,
res
,
QString
());
dlg
.
exec
();
}
int
TabDeckEditor
::
getNextCustomSetPrefix
(
QDir
dataDir
)
{
QStringList
files
=
dataDir
.
entryList
();
int
maxIndex
=
0
;
QStringList
::
const_iterator
filesIterator
;
for
(
filesIterator
=
files
.
constBegin
();
filesIterator
!=
files
.
constEnd
();
++
filesIterator
)
{
int
fileIndex
=
(
*
filesIterator
).
split
(
"."
).
at
(
0
).
toInt
();
if
(
fileIndex
>
maxIndex
)
maxIndex
=
fileIndex
;
}
return
maxIndex
+
1
;
}
void
TabDeckEditor
::
actEditSets
()
{
WndSets
*
w
=
new
WndSets
;
...
...
cockatrice/src/tab_deck_editor.h
View file @
bc79d9e2
...
...
@@ -3,6 +3,7 @@
#include
"tab.h"
#include
<QAbstractItemModel>
#include
<QDir>
#include
<QLineEdit>
#include
"keysignals.h"
...
...
@@ -54,6 +55,7 @@ class TabDeckEditor : public Tab {
void
actAnalyzeDeck
();
void
actOpenCustomFolder
();
void
actOpenCustomsetsFolder
();
void
actAddCustomSet
();
void
actEditSets
();
void
actEditTokens
();
...
...
@@ -88,11 +90,13 @@ class TabDeckEditor : public Tab {
void
dockFloatingTriggered
();
void
dockTopLevelChanged
(
bool
topLevel
);
private:
static
const
QStringList
fileNameFilters
;
CardInfo
*
currentCardInfo
()
const
;
void
addCardHelper
(
QString
zoneName
);
void
offsetCountAtIndex
(
const
QModelIndex
&
idx
,
int
offset
);
void
decrementCardHelper
(
QString
zoneName
);
void
recursiveExpand
(
const
QModelIndex
&
index
);
int
getNextCustomSetPrefix
(
QDir
dataDir
);
CardDatabaseModel
*
databaseModel
;
CardDatabaseDisplayModel
*
databaseDisplayModel
;
...
...
@@ -116,7 +120,7 @@ private:
QWidget
*
filterBox
;
QMenu
*
deckMenu
,
*
dbMenu
,
*
viewMenu
,
*
cardInfoDockMenu
,
*
deckDockMenu
,
*
filterDockMenu
;
QAction
*
aNewDeck
,
*
aLoadDeck
,
*
aSaveDeck
,
*
aSaveDeckAs
,
*
aLoadDeckFromClipboard
,
*
aSaveDeckToClipboard
,
*
aPrintDeck
,
*
aAnalyzeDeck
,
*
aClose
,
*
aOpenCustomFolder
,
*
aOpenCustomsetsFolder
;
QAction
*
aNewDeck
,
*
aLoadDeck
,
*
aSaveDeck
,
*
aSaveDeckAs
,
*
aLoadDeckFromClipboard
,
*
aSaveDeckToClipboard
,
*
aPrintDeck
,
*
aAnalyzeDeck
,
*
aClose
,
*
aOpenCustomFolder
,
*
aOpenCustomsetsFolder
,
*
aAddCustomSet
;
QAction
*
aEditSets
,
*
aEditTokens
,
*
aClearFilterAll
,
*
aClearFilterOne
;
QAction
*
aAddCard
,
*
aAddCardToSideboard
,
*
aRemoveCard
,
*
aIncrement
,
*
aDecrement
;
// *aUpdatePrices;
QAction
*
aResetLayout
;
...
...
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