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
cded62cb
Commit
cded62cb
authored
Apr 13, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added actions for adding/removing keywords
parent
7a33fa32
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
233 additions
and
5 deletions
+233
-5
src/data/action/keyword.cpp
src/data/action/keyword.cpp
+71
-0
src/data/action/keyword.hpp
src/data/action/keyword.hpp
+66
-0
src/data/action/set.hpp
src/data/action/set.hpp
+1
-0
src/data/action/value.hpp
src/data/action/value.hpp
+1
-1
src/data/keyword.hpp
src/data/keyword.hpp
+3
-0
src/gui/print_window.cpp
src/gui/print_window.cpp
+35
-0
src/gui/set/cards_panel.cpp
src/gui/set/cards_panel.cpp
+1
-1
src/gui/set/keywords_panel.cpp
src/gui/set/keywords_panel.cpp
+7
-3
src/mse.vcproj
src/mse.vcproj
+48
-0
No files found.
src/data/action/keyword.cpp
0 → 100644
View file @
cded62cb
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <data/action/keyword.hpp>
#include <data/keyword.hpp>
#include <data/set.hpp>
#include <data/game.hpp>
DECLARE_TYPEOF_COLLECTION
(
KeywordModeP
);
// ----------------------------------------------------------------------------- : Add Keyword
AddKeywordAction
::
AddKeywordAction
(
Set
&
set
)
:
KeywordListAction
(
set
),
keyword
(
new
Keyword
())
{
// find default mode
FOR_EACH
(
mode
,
set
.
game
->
keyword_modes
)
{
if
(
mode
->
is_default
)
{
keyword
->
mode
=
mode
->
name
;
break
;
}
}
}
AddKeywordAction
::
AddKeywordAction
(
Set
&
set
,
const
KeywordP
&
keyword
)
:
KeywordListAction
(
set
),
keyword
(
keyword
)
{}
String
AddKeywordAction
::
getName
(
bool
to_undo
)
const
{
return
_
(
"Add keyword"
);
}
void
AddKeywordAction
::
perform
(
bool
to_undo
)
{
if
(
!
to_undo
)
{
set
.
keywords
.
push_back
(
keyword
);
}
else
{
assert
(
!
set
.
keywords
.
empty
());
set
.
keywords
.
pop_back
();
}
}
// ----------------------------------------------------------------------------- : Remove Keyword
RemoveKeywordAction
::
RemoveKeywordAction
(
Set
&
set
,
const
KeywordP
&
keyword
)
:
KeywordListAction
(
set
),
keyword
(
keyword
)
// find the keyword_id of the keyword we want to remove
,
keyword_id
(
find
(
set
.
keywords
.
begin
(),
set
.
keywords
.
end
(),
keyword
)
-
set
.
keywords
.
begin
())
{
if
(
keyword_id
>=
set
.
keywords
.
size
())
{
throw
InternalError
(
_
(
"Keyword to remove not found in set"
));
}
}
String
RemoveKeywordAction
::
getName
(
bool
to_undo
)
const
{
return
_
(
"Remove keyword"
);
}
void
RemoveKeywordAction
::
perform
(
bool
to_undo
)
{
if
(
!
to_undo
)
{
assert
(
keyword_id
<
set
.
keywords
.
size
());
set
.
keywords
.
erase
(
set
.
keywords
.
begin
()
+
keyword_id
);
}
else
{
assert
(
keyword_id
<=
set
.
keywords
.
size
());
set
.
keywords
.
insert
(
set
.
keywords
.
begin
()
+
keyword_id
,
keyword
);
}
}
src/data/action/keyword.hpp
0 → 100644
View file @
cded62cb
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_DATA_ACTION_KEYWORD
#define HEADER_DATA_ACTION_KEYWORD
/** @file data/action/keyword.hpp
*
* Actions operating on Keywords and the keyword list of a set
*/
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <util/action_stack.hpp>
class
Set
;
DECLARE_POINTER_TYPE
(
Keyword
);
// ----------------------------------------------------------------------------- : Add Keyword
/// An Action the changes the keyword list of a set
class
KeywordListAction
:
public
Action
{
public:
inline
KeywordListAction
(
Set
&
set
)
:
set
(
set
)
{}
protected:
Set
&
set
;
// the set owns this action, so the set will not be destroyed before this
// therefore we don't need a smart pointer
};
/// Adding a new keyword to a set
class
AddKeywordAction
:
public
KeywordListAction
{
public:
AddKeywordAction
(
Set
&
set
);
AddKeywordAction
(
Set
&
set
,
const
KeywordP
&
keyword
);
virtual
String
getName
(
bool
to_undo
)
const
;
virtual
void
perform
(
bool
to_undo
);
//private:
const
KeywordP
keyword
;
///< The new keyword
};
// ----------------------------------------------------------------------------- : Remove Keyword
/// Removing a keyword from a set
class
RemoveKeywordAction
:
public
KeywordListAction
{
public:
RemoveKeywordAction
(
Set
&
set
,
const
KeywordP
&
keyword
);
virtual
String
getName
(
bool
to_undo
)
const
;
virtual
void
perform
(
bool
to_undo
);
//private:
const
KeywordP
keyword
;
///< The removed keyword
const
size_t
keyword_id
;
///< Position of the keyword in the set
};
// ----------------------------------------------------------------------------- : Changing keywords
// ----------------------------------------------------------------------------- : EOF
#endif
src/data/action/set.hpp
View file @
cded62cb
...
...
@@ -30,6 +30,7 @@ class CardListAction : public Action {
protected:
Set
&
set
;
// the set owns this action, so the set will not be destroyed before this
// therefore we don't need a smart pointer
};
/// Adding a new card to a set
...
...
src/data/action/value.hpp
View file @
cded62cb
...
...
@@ -7,7 +7,7 @@
#ifndef HEADER_DATA_ACTION_VALUE
#define HEADER_DATA_ACTION_VALUE
/** @file data/action/
set
.hpp
/** @file data/action/
value
.hpp
*
* Actions operating on Values (and derived classes, "*Value")
*/
...
...
src/data/keyword.hpp
View file @
cded62cb
...
...
@@ -39,6 +39,7 @@ class KeywordParam {
/// Information on when and how to use a keyword
class
KeywordMode
{
public:
String
name
;
///< Name of the mode
String
description
;
///< Description of the type
bool
is_default
;
///< This is the default mode for new keywords
...
...
@@ -51,6 +52,8 @@ class KeywordMode {
/// A keyword for a set or a game
class
Keyword
{
public:
Keyword
()
:
fixed
(
false
)
{}
String
keyword
;
///< The keyword, only for human use
String
rules
;
///< Rules/explanation
String
match
;
///< String to match, <param> tags are used for parameters
...
...
src/gui/print_window.cpp
View file @
cded62cb
...
...
@@ -10,6 +10,7 @@
#include <gui/card_select_window.hpp>
#include <gui/util.hpp>
#include <data/set.hpp>
#include <wx/print.h>
DECLARE_TYPEOF_COLLECTION
(
CardP
);
...
...
@@ -88,8 +89,42 @@ void TextBufferDC::drawToDevice(DC& dc, int x, int y) {
}
}
// ----------------------------------------------------------------------------- : Layout
/// Layout of a page of cards
class
PageLayout
{
public:
RealSize
card_size
;
///< Size of a card
RealSize
card_space
;
///< Spacing between cards
double
margin_left
,
margin_right
,
margin_top
,
margin_bottom
;
///< Page margins
int
rows
,
cols
;
///< Number of rows/columns of cards
bool
landscape
;
///< Are cards rotated to landscape orientation?
};
// ----------------------------------------------------------------------------- : Printout
/// A printout object specifying how to print a specified set of cards
class
CardsPrintout
:
wxPrintout
{
public:
CardsPrintout
(
const
SetP
&
set
,
const
vector
<
CardP
>&
cards
);
/// Determine card size, cards per row
void
OnPreparePrinting
();
/// Number of pages, and something else I don't understand...
void
GetPageInfo
(
int
*
pageMin
,
int
*
pageMax
,
int
*
pageFrom
,
int
*
pageTo
);
/// Again, 'number of pages', strange wx interface
bool
HasPage
(
int
page
);
/// Print a page
bool
OnPrintPage
(
int
page
);
private:
PageLayout
layout
;
/// Draw a card, that is card_nr on this page, find the postion by asking the layout
void
drawCard
(
DC
&
dc
,
const
CardP
&
card
,
UInt
card_nr
);
/// Draw a card at the specified coordinates
void
drawCard
(
DC
&
dc
,
const
CardP
&
card
,
double
x
,
double
y
,
int
rotation
=
0
);
};
// ----------------------------------------------------------------------------- : PrintWindow
void
print_preview
(
Window
*
parent
,
const
SetP
&
set
)
{
...
...
src/gui/set/cards_panel.cpp
View file @
cded62cb
...
...
@@ -30,7 +30,7 @@ CardsPanel::CardsPanel(Window* parent, int id)
editor
=
new
CardEditor
(
this
,
ID_EDITOR
);
splitter
=
new
wxSplitterWindow
(
this
,
wxID_ANY
,
wxDefaultPosition
,
wxDefaultSize
,
0
);
card_list
=
new
ImageCardList
(
splitter
,
ID_CARD_LIST
);
notesP
=
new
Panel
(
splitter
,
wxID_ANY
);
notesP
=
new
Panel
(
splitter
,
wxID_ANY
,
wxDefaultPosition
,
wxDefaultSize
,
0
/* no tab traversal*/
);
notes
=
new
TextCtrl
(
notesP
,
ID_NOTES
,
true
);
collapse_notes
=
new
HoverButton
(
notesP
,
ID_COLLAPSE_NOTES
,
_
(
"btn_collapse"
),
wxNullColour
);
collapse_notes
->
SetExtraStyle
(
wxWS_EX_PROCESS_UI_UPDATES
);
...
...
src/gui/set/keywords_panel.cpp
View file @
cded62cb
...
...
@@ -12,6 +12,7 @@
#include <gui/icon_menu.hpp>
#include <gui/util.hpp>
#include <data/keyword.hpp>
#include <data/action/keyword.hpp>
#include <data/field/text.hpp>
#include <util/window_id.hpp>
#include <wx/listctrl.h>
...
...
@@ -25,7 +26,7 @@ KeywordsPanel::KeywordsPanel(Window* parent, int id)
// init controls
splitter
=
new
wxSplitterWindow
(
this
,
wxID_ANY
,
wxDefaultPosition
,
wxDefaultSize
,
0
);
list
=
new
KeywordList
(
splitter
,
wxID_ANY
);
panel
=
new
Panel
(
splitter
,
wxID_ANY
);
panel
=
new
Panel
(
splitter
,
wxID_ANY
,
wxDefaultPosition
,
wxDefaultSize
,
0
/* no tab traversal*/
);
keyword
=
new
TextCtrl
(
panel
,
wxID_ANY
,
false
);
match
=
new
TextCtrl
(
panel
,
wxID_ANY
,
false
);
reminder
=
new
TextCtrl
(
panel
,
wxID_ANY
,
false
);
...
...
@@ -114,10 +115,13 @@ void KeywordsPanel::onCommand(int id) {
list
->
selectNext
();
break
;
case
ID_KEYWORD_ADD
:
//
set->actions.add(new AddKeywordAction(*set));
set
->
actions
.
add
(
new
AddKeywordAction
(
*
set
));
break
;
case
ID_KEYWORD_REMOVE
:
// set->actions.add(new RemoveKeywordAction(*set, list->getKeyword()));
if
(
!
list
->
getKeyword
()
->
fixed
)
{
// only remove set keywords
set
->
actions
.
add
(
new
RemoveKeywordAction
(
*
set
,
list
->
getKeyword
()));
}
break
;
}
}
...
...
src/mse.vcproj
View file @
cded62cb
...
...
@@ -875,6 +875,12 @@
<File
RelativePath=
".\gui\drop_down_list.hpp"
>
</File>
<File
RelativePath=
".\gui\html_export_window.cpp"
>
</File>
<File
RelativePath=
".\gui\html_export_window.hpp"
>
</File>
<File
RelativePath=
".\gui\image_slice_window.cpp"
>
</File>
...
...
@@ -1219,6 +1225,48 @@
<Filter
Name=
"action"
Filter=
""
>
<File
RelativePath=
".\data\action\keyword.cpp"
>
<FileConfiguration
Name=
"Debug|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
ObjectFile=
"$(IntDir)/$(InputName)1.obj"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Release|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
ObjectFile=
"$(IntDir)/$(InputName)1.obj"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Debug Unicode|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
ObjectFile=
"$(IntDir)/$(InputName)1.obj"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Release Unicode|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
ObjectFile=
"$(IntDir)/$(InputName)1.obj"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Release Profile Unicode|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
ObjectFile=
"$(IntDir)/$(InputName)1.obj"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Release Unicode fast build|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
ObjectFile=
"$(IntDir)/$(InputName)1.obj"
/>
</FileConfiguration>
</File>
<File
RelativePath=
".\data\action\keyword.hpp"
>
</File>
<File
RelativePath=
".\data\action\set.cpp"
>
<FileConfiguration
...
...
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