Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
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
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
magicseteditor
Commits
7fad3ad9
Commit
7fad3ad9
authored
Oct 20, 2006
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(formating)
parent
eac09654
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
38 deletions
+38
-38
src/data/format/formats.cpp
src/data/format/formats.cpp
+26
-26
src/data/format/formats.hpp
src/data/format/formats.hpp
+6
-6
src/gui/set/window.cpp
src/gui/set/window.cpp
+5
-5
src/main.cpp
src/main.cpp
+1
-1
No files found.
src/data/format/formats.cpp
View file @
7fad3ad9
...
...
@@ -15,56 +15,56 @@ DECLARE_TYPEOF_COLLECTION(FileFormatP);
// ----------------------------------------------------------------------------- : Formats
// All supported file formats
vector
<
FileFormatP
>
file
F
ormats
;
vector
<
FileFormatP
>
file
_f
ormats
;
void
init
FileF
ormats
()
{
//file
F
ormats.push_back(new_shared<MSE2FileFilter>());
//file
F
ormats.push_back(new_shared<MSE1FileFilter>());
//file
F
ormats.push_back(new_shared<MtgEditorFileFilter>());
void
init
_file_f
ormats
()
{
//file
_f
ormats.push_back(new_shared<MSE2FileFilter>());
//file
_f
ormats.push_back(new_shared<MSE1FileFilter>());
//file
_f
ormats.push_back(new_shared<MtgEditorFileFilter>());
}
String
import
F
ormats
()
{
String
all
E
xtensions
;
// type1;type2
String
type
S
trings
;
// |name1|type1|name2|type2
FOR_EACH
(
f
,
file
F
ormats
)
{
String
import
_f
ormats
()
{
String
all
_e
xtensions
;
// type1;type2
String
type
_s
trings
;
// |name1|type1|name2|type2
FOR_EACH
(
f
,
file
_f
ormats
)
{
if
(
f
->
canImport
())
{
if
(
!
all
Extensions
.
empty
())
allE
xtensions
+=
_
(
";"
);
all
E
xtensions
+=
_
(
"*."
)
+
f
->
extension
();
type
S
trings
+=
_
(
"|"
)
+
f
->
name
()
+
_
(
"|*."
)
+
f
->
extension
();
if
(
!
all
_extensions
.
empty
())
all_e
xtensions
+=
_
(
";"
);
all
_e
xtensions
+=
_
(
"*."
)
+
f
->
extension
();
type
_s
trings
+=
_
(
"|"
)
+
f
->
name
()
+
_
(
"|*."
)
+
f
->
extension
();
}
}
return
_
(
"Set files|"
)
+
all
Extensions
+
typeS
trings
+
_
(
"|All files (*.*)|*.*"
);
return
_
(
"Set files|"
)
+
all
_extensions
+
type_s
trings
+
_
(
"|All files (*.*)|*.*"
);
}
String
export
F
ormats
(
const
Game
&
game
)
{
String
type
S
trings
;
// name1|type1|name2|type2
FOR_EACH
(
f
,
file
F
ormats
)
{
String
export
_f
ormats
(
const
Game
&
game
)
{
String
type
_s
trings
;
// name1|type1|name2|type2
FOR_EACH
(
f
,
file
_f
ormats
)
{
if
(
f
->
canExport
(
game
))
{
if
(
!
type
Strings
.
empty
())
typeS
trings
+=
_
(
"|"
);
type
S
trings
+=
f
->
name
()
+
_
(
"|*."
)
+
f
->
extension
();
if
(
!
type
_strings
.
empty
())
type_s
trings
+=
_
(
"|"
);
type
_s
trings
+=
f
->
name
()
+
_
(
"|*."
)
+
f
->
extension
();
}
}
return
type
S
trings
;
return
type
_s
trings
;
}
void
export
Set
(
const
Set
&
set
,
const
String
&
filename
,
size_t
formatT
ype
)
{
FileFormatP
format
=
file
Formats
.
at
(
formatT
ype
);
void
export
_set
(
const
Set
&
set
,
const
String
&
filename
,
size_t
format_t
ype
)
{
FileFormatP
format
=
file
_formats
.
at
(
format_t
ype
);
if
(
!
format
->
canExport
(
*
set
.
game
))
{
throw
InternalError
(
_
(
"File format doesn't apply to set"
));
}
format
->
exportSet
(
set
,
filename
);
}
SetP
import
S
et
(
String
name
)
{
SetP
import
_s
et
(
String
name
)
{
size_t
pos
=
name
.
find_last_of
(
_
(
'.'
));
String
extension
=
pos
==
String
::
npos
?
_
(
""
)
:
name
.
substr
(
pos
+
1
);
// determine format
FOR_EACH
(
f
,
file
F
ormats
)
{
FOR_EACH
(
f
,
file
_f
ormats
)
{
if
(
f
->
extension
()
==
extension
)
{
return
f
->
importSet
(
name
);
}
}
// default
: use first format = MSE2 format
assert
(
!
file
Formats
.
empty
()
&&
fileF
ormats
[
0
]
->
canImport
());
return
file
F
ormats
[
0
]
->
importSet
(
name
);
// default: use first format = MSE2 format
assert
(
!
file
_formats
.
empty
()
&&
file_f
ormats
[
0
]
->
canImport
());
return
file
_f
ormats
[
0
]
->
importSet
(
name
);
}
\ No newline at end of file
src/data/format/formats.hpp
View file @
7fad3ad9
...
...
@@ -42,18 +42,18 @@ class FileFormat {
/// Initialize the list of file formats
/** Must be called before any other methods of this header */
void
init
FileF
ormats
();
void
init
_file_f
ormats
();
/// List of supported import formats
/** Formated as _("All supported (type1,...)|type1,...|name|type|...|All files(*.*)|*.*").
* For use in file selection dialogs.
*/
String
import
F
ormats
();
String
import
_f
ormats
();
// List of supported export formats that a set in a specific game can be exported.
/** Similair format as importFormats, except for
_('all supported') and _('all files')
/** Similair format as importFormats, except for
'all supported' and 'all files'
*/
String
export
F
ormats
(
const
Game
&
game
);
String
export
_f
ormats
(
const
Game
&
game
);
/// Opens a set with the specified filename.
/** File format is chosen based on the extension, default is fileFormats[0]
...
...
@@ -64,12 +64,12 @@ String exportFormats(const Game& game);
* changing the recent set list could change the filename while we are opening it
* (which would be bad)
*/
SetP
import
S
et
(
String
name
);
SetP
import
_s
et
(
String
name
);
/// Save a set under the specified name.
/** filterType specifies what format to use for saving, used as index in the list of file formats
*/
void
export
Set
(
const
Set
&
set
,
const
String
&
filename
,
size_t
formatT
ype
);
void
export
_set
(
const
Set
&
set
,
const
String
&
filename
,
size_t
format_t
ype
);
// ----------------------------------------------------------------------------- : Export
...
...
src/gui/set/window.cpp
View file @
7fad3ad9
...
...
@@ -294,7 +294,7 @@ bool SetWindow::askSaveAndContinue() {
/* try {
if (set->needSaveAs()) {
// need save as
FileDialog dlg(&this, _("Save a set"), _(""), _(""), export
F
ormats(set->game), wxSAVE | wxOVERWRITE_PROMPT);
FileDialog dlg(&this, _("Save a set"), _(""), _(""), export
_f
ormats(set->game), wxSAVE | wxOVERWRITE_PROMPT);
if (dlg.showModal() == wxID_OK) {
exportSet(set, dlg.path, dlg.filterIndex);
return true;
...
...
@@ -374,9 +374,9 @@ void SetWindow::onFileNew(wxCommandEvent&) {
void
SetWindow
::
onFileOpen
(
wxCommandEvent
&
)
{
if
(
!
askSaveAndContinue
())
return
;
wxFileDialog
dlg
(
this
,
_
(
"Open a set"
),
_
(
""
),
_
(
""
),
import
F
ormats
(),
wxOPEN
);
wxFileDialog
dlg
(
this
,
_
(
"Open a set"
),
_
(
""
),
_
(
""
),
import
_f
ormats
(),
wxOPEN
);
if
(
dlg
.
ShowModal
()
==
wxID_OK
)
{
set
=
import
S
et
(
dlg
.
GetPath
());
set
=
import
_s
et
(
dlg
.
GetPath
());
}
}
...
...
@@ -391,9 +391,9 @@ void SetWindow::onFileSave(wxCommandEvent& ev) {
}
void
SetWindow
::
onFileSaveAs
(
wxCommandEvent
&
)
{
wxFileDialog
dlg
(
this
,
_
(
"Save a set"
),
_
(
""
),
_
(
""
),
export
F
ormats
(
*
set
->
game
),
wxSAVE
|
wxOVERWRITE_PROMPT
);
wxFileDialog
dlg
(
this
,
_
(
"Save a set"
),
_
(
""
),
_
(
""
),
export
_f
ormats
(
*
set
->
game
),
wxSAVE
|
wxOVERWRITE_PROMPT
);
if
(
dlg
.
ShowModal
()
==
wxID_OK
)
{
export
S
et
(
*
set
,
dlg
.
GetPath
(),
dlg
.
GetFilterIndex
());
export
_s
et
(
*
set
,
dlg
.
GetPath
(),
dlg
.
GetFilterIndex
());
}
}
...
...
src/main.cpp
View file @
7fad3ad9
...
...
@@ -37,7 +37,7 @@ IMPLEMENT_APP(MSE)
bool
MSE
::
OnInit
()
{
try
{
wxInitAllImageHandlers
();
init
FileF
ormats
();
init
_file_f
ormats
();
settings
.
read
();
//Window* wnd = new SymbolWindow(nullptr);
//GameP g = Game::byName(_("magic"))
...
...
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