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
40241ca8
Commit
40241ca8
authored
Nov 20, 2006
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented most of DataEditor; fixed some bugs in Settings
parent
4fac3f44
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
288 additions
and
28 deletions
+288
-28
src/data/settings.cpp
src/data/settings.cpp
+27
-7
src/data/settings.hpp
src/data/settings.hpp
+8
-4
src/data/stylesheet.hpp
src/data/stylesheet.hpp
+3
-0
src/gui/control/card_editor.cpp
src/gui/control/card_editor.cpp
+168
-2
src/gui/control/card_editor.hpp
src/gui/control/card_editor.hpp
+62
-0
src/gui/value/editor.hpp
src/gui/value/editor.hpp
+8
-8
src/render/card/viewer.cpp
src/render/card/viewer.cpp
+4
-2
src/render/card/viewer.hpp
src/render/card/viewer.hpp
+0
-2
src/util/defaultable.hpp
src/util/defaultable.hpp
+7
-2
src/util/string.cpp
src/util/string.cpp
+1
-1
No files found.
src/data/settings.cpp
View file @
40241ca8
...
...
@@ -8,6 +8,7 @@
#include <data/settings.hpp>
#include <data/game.hpp>
#include <data/stylesheet.hpp>
#include <data/field.hpp>
#include <util/reflect.hpp>
#include <util/io/reader.hpp>
...
...
@@ -39,6 +40,10 @@ IMPLEMENT_REFLECTION(ColumnSettings) {
REFLECT
(
visible
);
}
GameSettings
::
GameSettings
()
:
sort_cards_ascending
(
true
)
{}
IMPLEMENT_REFLECTION
(
GameSettings
)
{
REFLECT
(
default_stylesheet
);
REFLECT
(
default_export
);
...
...
@@ -47,6 +52,23 @@ IMPLEMENT_REFLECTION(GameSettings) {
REFLECT
(
sort_cards_ascending
);
}
StyleSheetSettings
::
StyleSheetSettings
()
:
card_zoom
(
1.0
,
true
)
,
card_angle
(
0
,
true
)
,
card_anti_alias
(
true
,
true
)
,
card_borders
(
true
,
true
)
,
card_normal_export
(
true
,
true
)
{}
void
StyleSheetSettings
::
useDefault
(
const
StyleSheetSettings
&
ss
)
{
if
(
card_zoom
.
isDefault
())
card_zoom
.
assignDefault
(
ss
.
card_zoom
());
if
(
card_angle
.
isDefault
())
card_angle
.
assignDefault
(
ss
.
card_angle
());
if
(
card_anti_alias
.
isDefault
())
card_anti_alias
.
assignDefault
(
ss
.
card_anti_alias
());
if
(
card_borders
.
isDefault
())
card_borders
.
assignDefault
(
ss
.
card_borders
());
if
(
card_normal_export
.
isDefault
())
card_normal_export
.
assignDefault
(
ss
.
card_normal_export
());
}
IMPLEMENT_REFLECTION
(
StyleSheetSettings
)
{
REFLECT
(
card_zoom
);
REFLECT
(
card_angle
);
...
...
@@ -85,7 +107,7 @@ void Settings::addRecentFile(const String& filename) {
}
GameSettings
&
Settings
::
gameSettingsFor
(
const
Game
&
game
)
{
GameSettingsP
&
gs
=
settings
.
game_settings
[
game
.
name
()];
GameSettingsP
&
gs
=
game_settings
[
game
.
name
()];
if
(
!
gs
)
gs
.
reset
(
new
GameSettings
);
return
*
gs
;
}
...
...
@@ -102,14 +124,12 @@ ColumnSettings& Settings::columnSettingsFor(const Game& game, const Field& field
}
return
cs
;
}
/*
StyleSettings& Settings::styleSettingsFor(const CardStyle& style) {
StyleSettingsP& ss = settings.styleSettings#(style.name());
if (!ss) ss = new_shared<StyleSettings>();
ss->useDefault(defaultStyleSettings); // update default settings
StyleSheetSettings
&
Settings
::
stylesheetSettingsFor
(
const
StyleSheet
&
stylesheet
)
{
StyleSheetSettingsP
&
ss
=
stylesheet_settings
[
stylesheet
.
name
()];
if
(
!
ss
)
ss
.
reset
(
new
StyleSheetSettings
);
ss
->
useDefault
(
default_stylesheet_settings
);
// update default settings
return
*
ss
;
}
*/
String
user_settings_dir
()
{
return
_
(
""
);
// TODO
...
...
src/data/settings.hpp
View file @
40241ca8
...
...
@@ -43,6 +43,8 @@ class ColumnSettings {
/// Settings for a Game
class
GameSettings
{
public:
GameSettings
();
String
default_stylesheet
;
String
default_export
;
map
<
String
,
ColumnSettings
>
columns
;
...
...
@@ -55,6 +57,8 @@ class GameSettings {
/// Settings for a StyleSheet
class
StyleSheetSettings
{
public:
StyleSheetSettings
();
// Rendering/display settings
Defaultable
<
double
>
card_zoom
;
Defaultable
<
int
>
card_angle
;
...
...
@@ -62,10 +66,10 @@ class StyleSheetSettings {
Defaultable
<
bool
>
card_borders
;
Defaultable
<
bool
>
card_normal_export
;
DECLARE_REFLECTION
();
/// Where the settings are the default, use the value from ss
void
useDefault
(
const
StyleSheetSettings
&
ss
);
// /// Where the settings are the default, use the value from ss
// void useDefault(const StyleSheetSettings& ss);
DECLARE_REFLECTION
();
};
// ----------------------------------------------------------------------------- : Settings
...
...
@@ -102,7 +106,7 @@ class Settings {
/// Get the settings for a column for a specific field in a game
ColumnSettings
&
columnSettingsFor
(
const
Game
&
game
,
const
Field
&
field
);
/// Get the settings object for a specific stylesheet
StyleSheetSettings
&
style
S
heetSettingsFor
(
const
StyleSheet
&
stylesheet
);
StyleSheetSettings
&
style
s
heetSettingsFor
(
const
StyleSheet
&
stylesheet
);
private:
map
<
String
,
GameSettingsP
>
game_settings
;
...
...
src/data/stylesheet.hpp
View file @
40241ca8
...
...
@@ -11,6 +11,7 @@
#include <util/prec.hpp>
#include <util/io/package.hpp>
#include <util/real_point.hpp>
#include <script/scriptable.hpp>
DECLARE_POINTER_TYPE
(
Game
);
...
...
@@ -47,6 +48,8 @@ class StyleSheet : public Packaged {
bool
dependencies_initialized
;
///< are the script dependencies comming from this stylesheet all initialized?
inline
RealRect
getCardRect
()
const
{
return
RealRect
(
0
,
0
,
card_width
,
card_height
);
}
/// Load a StyleSheet, given a Game and the name of the StyleSheet
static
StyleSheetP
byGameAndName
(
const
Game
&
game
,
const
String
&
name
);
/// name of the package without the game name
...
...
src/gui/control/card_editor.cpp
View file @
40241ca8
...
...
@@ -8,23 +8,189 @@
#include <gui/control/card_editor.hpp>
#include <gui/value/editor.hpp>
#include <gui/icon_menu.hpp>
#include <data/field.hpp>
#include <data/stylesheet.hpp>
#include <data/settings.hpp>
DECLARE_TYPEOF_COLLECTION
(
ValueViewerP
);
// ----------------------------------------------------------------------------- : DataEditor
#define FOR_EACH_EDITOR \
FOR_EACH
(
v
,
viewers
)
\
#define FOR_EACH_EDITOR \
FOR_EACH
(
v
,
viewers
)
\
if
(
ValueEditor
*
e
=
v
->
getEditor
())
#define FOR_EACH_EDITOR_REVERSE \
FOR_EACH_REVERSE
(
v
,
viewers
)
\
if
(
ValueEditor
*
e
=
v
->
getEditor
())
DataEditor
::
DataEditor
(
Window
*
parent
,
int
id
,
long
style
)
:
CardViewer
(
parent
,
id
,
style
)
,
current_viewer
(
nullptr
)
,
current_editor
(
nullptr
)
{}
ValueViewerP
DataEditor
::
makeViewer
(
const
StyleP
&
style
)
{
return
style
->
makeEditor
(
*
this
,
style
);
}
// ----------------------------------------------------------------------------- : Utility for ValueViewers
bool
DataEditor
::
drawBorders
()
const
{
return
!
nativeLook
()
&&
settings
.
stylesheetSettingsFor
(
*
set
->
stylesheetFor
(
card
)).
card_borders
();
}
bool
DataEditor
::
drawEditing
()
const
{
return
true
;
}
wxPen
DataEditor
::
borderPen
(
bool
active
)
const
{
return
active
?
wxPen
(
Color
(
0
,
128
,
255
),
1
,
wxSOLID
)
:
wxPen
(
Color
(
128
,
128
,
128
),
1
,
wxDOT
);
}
ValueViewer
*
DataEditor
::
focusedViewer
()
const
{
return
current_viewer
;
}
// ----------------------------------------------------------------------------- : Selection
// ----------------------------------------------------------------------------- : Clipboard & Formatting
bool
DataEditor
::
canCut
()
const
{
return
current_editor
&&
current_editor
->
canCut
();
}
bool
DataEditor
::
canCopy
()
const
{
return
current_editor
&&
current_editor
->
canCopy
();
}
bool
DataEditor
::
canPaste
()
const
{
return
current_editor
&&
current_editor
->
canPaste
();
}
bool
DataEditor
::
canFormat
(
int
type
)
const
{
return
current_editor
&&
current_editor
->
canFormat
(
type
);
}
bool
DataEditor
::
hasFormat
(
int
type
)
const
{
return
current_editor
&&
current_editor
->
hasFormat
(
type
);
}
void
DataEditor
::
doCut
()
{
if
(
current_editor
)
current_editor
->
doCut
();
}
void
DataEditor
::
doCopy
()
{
if
(
current_editor
)
current_editor
->
doCopy
();
}
void
DataEditor
::
doPaste
()
{
if
(
current_editor
)
current_editor
->
doPaste
();
}
void
DataEditor
::
doFormat
(
int
type
)
{
if
(
current_editor
)
current_editor
->
doFormat
(
type
);
}
// ----------------------------------------------------------------------------- : Mouse events
void
DataEditor
::
onLeftDown
(
wxMouseEvent
&
ev
)
{
ev
.
Skip
();
// for focus
CaptureMouse
();
// change selection?
selectField
(
ev
,
&
ValueEditor
::
onLeftDown
);
}
void
DataEditor
::
onLeftUp
(
wxMouseEvent
&
ev
)
{
if
(
HasCapture
())
ReleaseMouse
();
if
(
current_editor
)
current_editor
->
onLeftUp
(
mousePoint
(
ev
),
ev
);
}
void
DataEditor
::
onLeftDClick
(
wxMouseEvent
&
ev
)
{
if
(
current_editor
)
current_editor
->
onLeftDClick
(
mousePoint
(
ev
),
ev
);
}
void
DataEditor
::
onRightDown
(
wxMouseEvent
&
ev
)
{
ev
.
Skip
();
// for context menu
// change selection?
selectField
(
ev
,
&
ValueEditor
::
onRightDown
);
}
void
DataEditor
::
onMouseWheel
(
wxMouseEvent
&
ev
)
{
if
(
current_editor
)
current_editor
->
onMouseWheel
(
mousePoint
(
ev
),
ev
);
}
void
DataEditor
::
onMotion
(
wxMouseEvent
&
ev
)
{
RealPoint
pos
=
mousePoint
(
ev
);
if
(
current_editor
&&
ev
.
LeftIsDown
())
{
current_editor
->
onMotion
(
pos
,
ev
);
}
if
(
!
HasCapture
())
{
// change cursor and set status text
wxFrame
*
frame
=
dynamic_cast
<
wxFrame
*>
(
wxGetTopLevelParent
(
this
)
);
FOR_EACH_EDITOR_REVERSE
{
// find high z index fields first
if
(
v
->
containsPoint
(
pos
)
&&
v
->
getField
()
->
editable
)
{
wxCursor
c
=
e
->
cursor
();
if
(
c
.
Ok
())
SetCursor
(
c
);
else
SetCursor
(
wxCURSOR_ARROW
);
if
(
frame
)
frame
->
SetStatusText
(
v
->
getField
()
->
description
);
return
;
}
}
// no field under cursor
SetCursor
(
wxCURSOR_ARROW
);
if
(
frame
)
frame
->
SetStatusText
(
wxEmptyString
);
}
}
void
DataEditor
::
onMouseLeave
(
wxMouseEvent
&
ev
)
{
wxFrame
*
frame
=
dynamic_cast
<
wxFrame
*>
(
wxGetTopLevelParent
(
this
)
);
if
(
frame
)
frame
->
SetStatusText
(
wxEmptyString
);
}
void
DataEditor
::
selectField
(
wxMouseEvent
&
ev
,
void
(
ValueEditor
::*
event
)(
const
RealPoint
&
,
wxMouseEvent
&
))
{
RealPoint
pos
=
mousePoint
(
ev
);
// change viewer/editor
ValueEditor
*
old_editor
=
current_editor
;
selectFieldNoEvents
(
pos
);
if
(
old_editor
!=
current_editor
)
{
// selection has changed, send focus events
if
(
old_editor
)
old_editor
->
onLoseFocus
();
if
(
current_editor
)
current_editor
->
onFocus
();
}
// pass event
if
(
current_editor
)
(
current_editor
->*
event
)(
pos
,
ev
);
// refresh?
if
(
old_editor
!=
current_editor
)
{
// selection has changed, refresh viewers
// NOTE: after passing mouse down event, otherwise opening combo box produces flicker
onChange
();
}
}
void
DataEditor
::
selectFieldNoEvents
(
const
RealPoint
&
p
)
{
FOR_EACH_EDITOR_REVERSE
{
// find high z index fields first
if
(
v
->
containsPoint
(
p
)
&&
v
->
getField
()
->
editable
)
{
current_viewer
=
v
.
get
();
current_editor
=
e
;
return
;
}
}
current_viewer
=
nullptr
;
current_editor
=
nullptr
;
}
RealPoint
DataEditor
::
mousePoint
(
const
wxMouseEvent
&
ev
)
{
StyleSheetP
stylesheet
=
set
->
stylesheetFor
(
card
);
StyleSheetSettings
&
ss
=
settings
.
stylesheetSettingsFor
(
*
stylesheet
);
Rotation
rot
(
ss
.
card_angle
(),
stylesheet
->
getCardRect
(),
ss
.
card_zoom
());
return
rot
.
trInv
(
RealPoint
(
ev
.
GetX
(),
ev
.
GetY
()));
}
// ----------------------------------------------------------------------------- : Keyboard events
// ----------------------------------------------------------------------------- : Menu events
void
DataEditor
::
onContextMenu
(
wxContextMenuEvent
&
ev
)
{
if
(
current_editor
)
{
IconMenu
m
;
m
.
Append
(
wxID_CUT
,
_
(
"TOOL_CUT"
),
_
(
"Cu&t"
),
_
(
"Move the selected text to the clipboard"
));
m
.
Append
(
wxID_COPY
,
_
(
"TOOL_COPY"
),
_
(
"&Copy"
),
_
(
"Place the selected text on the clipboard"
));
m
.
Append
(
wxID_PASTE
,
_
(
"TOOL_PASTE"
),
_
(
"&Paste"
),
_
(
"Inserts the text from the clipboard"
));
m
.
Enable
(
wxID_CUT
,
canCut
());
m
.
Enable
(
wxID_COPY
,
canCopy
());
m
.
Enable
(
wxID_PASTE
,
canPaste
());
if
(
current_editor
->
onContextMenu
(
m
,
ev
))
{
PopupMenu
(
&
m
);
}
}
}
// ----------------------------------------------------------------------------- : Focus events
// ----------------------------------------------------------------------------- : Event table
BEGIN_EVENT_TABLE
(
DataEditor
,
CardViewer
)
EVT_LEFT_DOWN
(
DataEditor
::
onLeftDown
)
EVT_LEFT_UP
(
DataEditor
::
onLeftUp
)
EVT_LEFT_DCLICK
(
DataEditor
::
onLeftDClick
)
EVT_RIGHT_DOWN
(
DataEditor
::
onRightDown
)
EVT_MOTION
(
DataEditor
::
onMotion
)
EVT_MOUSEWHEEL
(
DataEditor
::
onMouseWheel
)
EVT_LEAVE_WINDOW
(
DataEditor
::
onMouseLeave
)
// EVT_CONTEXT_MENU (DataEditor::onContextMenu)
// EVT_CHAR (DataEditor::onChar)
// EVT_SET_FOCUS (DataEditor::onFocus)
// EVT_KILL_FOCUS (DataEditor::onLoseFocus)
// EVT_MENU (wxID_ANY, DataEditor::onMenu)
END_EVENT_TABLE
()
src/gui/control/card_editor.hpp
View file @
40241ca8
...
...
@@ -12,6 +12,8 @@
#include <util/prec.hpp>
#include <gui/control/card_viewer.hpp>
class
ValueEditor
;
// ----------------------------------------------------------------------------- : DataEditor
/// An editor for data values (usually a card)
...
...
@@ -19,12 +21,72 @@ class DataEditor : public CardViewer {
public:
DataEditor
(
Window
*
parent
,
int
id
,
long
style
=
0
);
// --------------------------------------------------- : Utility for ValueViewers
virtual
bool
drawBorders
()
const
;
virtual
bool
drawEditing
()
const
;
virtual
wxPen
borderPen
(
bool
active
)
const
;
virtual
ValueViewer
*
focusedViewer
()
const
;
// --------------------------------------------------- : Selection
// TODO
// --------------------------------------------------- : Clipboard
bool
canCut
()
const
;
bool
canCopy
()
const
;
bool
canPaste
()
const
;
void
doCut
();
void
doCopy
();
void
doPaste
();
// --------------------------------------------------- : Formatting
bool
canFormat
(
int
type
)
const
;
bool
hasFormat
(
int
type
)
const
;
void
doFormat
(
int
type
);
// --------------------------------------------------- : ValueViewers
protected:
/// Create an editor for the given style (as opposed to a normal viewer)
virtual
ValueViewerP
makeViewer
(
const
StyleP
&
);
// --------------------------------------------------- : Data
private:
DECLARE_EVENT_TABLE
();
ValueViewer
*
current_viewer
;
///< The currently selected viewer
ValueEditor
*
current_editor
;
///< The currently selected editor, corresponding to the viewer
// --------------------------------------------------- : Events
void
onLeftDown
(
wxMouseEvent
&
);
void
onLeftUp
(
wxMouseEvent
&
);
void
onLeftDClick
(
wxMouseEvent
&
);
void
onRightDown
(
wxMouseEvent
&
);
void
onMotion
(
wxMouseEvent
&
);
void
onMouseWheel
(
wxMouseEvent
&
);
void
onMouseLeave
(
wxMouseEvent
&
);
void
onChar
(
wxKeyEvent
&
);
void
onContextMenu
(
wxContextMenuEvent
&
);
void
onMenu
(
wxCommandEvent
&
e
);
void
onFocus
(
wxFocusEvent
&
);
void
onLoseFocus
(
wxFocusEvent
&
);
// --------------------------------------------------- : Functions
/// Changes the selection to the field at the specified coordinates
/** Sends an event to the event function of the current viewer */
void
selectField
(
wxMouseEvent
&
ev
,
void
(
ValueEditor
::*
event
)(
const
RealPoint
&
,
wxMouseEvent
&
));
// selectField, but don't send events
void
selectFieldNoEvents
(
const
RealPoint
&
pos
);
/// Convert mouse coordinates to internal coordinates
RealPoint
mousePoint
(
const
wxMouseEvent
&
e
);
};
/// By default a DataEditor edits cards
...
...
src/gui/value/editor.hpp
View file @
40241ca8
...
...
@@ -39,21 +39,21 @@ class ValueEditor {
virtual
void
onLoseFocus
()
{}
/// Handle mouse events
virtual
void
on
MouseLeftDown
(
RealPoint
pos
,
wxMouseEvent
&
ev
)
{}
virtual
void
on
MouseLeftUp
(
RealPoint
pos
,
wxMouseEvent
&
ev
)
{}
virtual
void
on
MouseDClick
(
RealPoint
pos
,
wxMouseEvent
&
ev
)
{}
virtual
void
on
MouseRightDown
(
RealPoint
pos
,
wxMouseEvent
&
ev
)
{}
virtual
void
onMo
useMove
(
RealPoint
pos
,
wxMouseEvent
&
ev
)
{}
virtual
void
onMouseWheel
(
RealPoint
pos
,
wxMouseEvent
&
ev
)
{}
virtual
void
on
LeftDown
(
const
RealPoint
&
pos
,
wxMouseEvent
&
ev
)
{}
virtual
void
on
LeftUp
(
const
RealPoint
&
pos
,
wxMouseEvent
&
ev
)
{}
virtual
void
on
LeftDClick
(
const
RealPoint
&
pos
,
wxMouseEvent
&
ev
)
{}
virtual
void
on
RightDown
(
const
RealPoint
&
pos
,
wxMouseEvent
&
ev
)
{}
virtual
void
onMo
tion
(
const
RealPoint
&
pos
,
wxMouseEvent
&
ev
)
{}
virtual
void
onMouseWheel
(
const
RealPoint
&
pos
,
wxMouseEvent
&
ev
)
{}
/// Key events
virtual
void
onChar
(
wxKeyEvent
ev
)
{}
/// A menu item was selected
virtual
void
onMenu
(
wxCommandEvent
&
ev
)
{
ev
.
Skip
();
}
/// a context menu is requested, add extra items to the menu m
/** return false to suppress menu */
virtual
bool
onContextMenu
(
wxMenu
&
m
,
wxContextMenuEvent
&
ev
)
{
return
true
;
}
/// A menu item was selected
virtual
void
onMenu
(
wxCommandEvent
&
ev
)
{
ev
.
Skip
();
}
// --------------------------------------------------- : Clipboard
...
...
src/render/card/viewer.cpp
View file @
40241ca8
...
...
@@ -12,6 +12,7 @@
#include <data/stylesheet.hpp>
#include <data/card.hpp>
#include <data/field.hpp>
#include <data/settings.hpp>
DECLARE_TYPEOF_COLLECTION
(
ValueViewerP
);
typedef
IndexMap
<
FieldP
,
StyleP
>
IndexMap_FieldP_StyleP
;
...
...
@@ -23,8 +24,9 @@ DECLARE_TYPEOF_NO_REV(IndexMap_FieldP_StyleP);
// ----------------------------------------------------------------------------- : Drawing
void
DataViewer
::
draw
(
DC
&
dc
)
{
// RotatedDC rdc(dc, rotation, settings.styleSettingsFor(*style).cardAntiAlias && !nativeLook())
RotatedDC
rdc
(
dc
,
0
,
RealRect
(
0
,
0
,
400
,
400
),
1.0
,
false
);
StyleSheetP
stylesheet
=
set
->
stylesheetFor
(
card
);
StyleSheetSettings
&
ss
=
settings
.
stylesheetSettingsFor
(
*
stylesheet
);
RotatedDC
rdc
(
dc
,
ss
.
card_angle
(),
stylesheet
->
getCardRect
(),
ss
.
card_zoom
(),
ss
.
card_anti_alias
()
&&
!
nativeLook
());
draw
(
rdc
);
}
void
DataViewer
::
draw
(
RotatedDC
&
dc
)
{
...
...
src/render/card/viewer.hpp
View file @
40241ca8
...
...
@@ -73,9 +73,7 @@ class DataViewer : public SetView {
/// Notification that the total image has changed
virtual
void
onChange
()
{}
private:
vector
<
ValueViewerP
>
viewers
;
///< The viewers for the different values in the data
protected:
CardP
card
;
///< The card that is currently displayed, if any
};
...
...
src/util/defaultable.hpp
View file @
40241ca8
...
...
@@ -20,14 +20,19 @@
template
<
typename
T
>
class
Defaultable
{
public:
inline
Defaultable
()
:
is_default
(
true
)
{}
inline
Defaultable
(
const
T
&
v
)
:
value
(
v
),
is_default
(
false
)
{}
inline
Defaultable
()
:
is_default
(
true
)
{}
inline
Defaultable
(
const
T
&
v
,
bool
def
=
false
)
:
value
(
v
),
is_default
(
def
)
{}
/// Assigning a value takes this object out of the default state
inline
void
assign
(
const
T
&
new_value
)
{
value
=
new_value
;
is_default
=
false
;
}
/// Assigning a value keep this object in the default state
inline
void
assignDefault
(
const
T
&
new_value
)
{
assert
(
is_default
);
value
=
new_value
;
}
/// Get access to the value
inline
const
T
&
operator
()
()
const
{
return
value
;
}
...
...
src/util/string.cpp
View file @
40241ca8
...
...
@@ -124,7 +124,7 @@ String cannocial_name_form(const String& str) {
FOR_EACH_CONST
(
c
,
str
)
{
if
((
c
==
_
(
'_'
)
||
c
==
_
(
' '
))
&&
!
leading
)
{
ret
+=
_
(
' '
);
}
else
if
(
isAlnum
(
c
))
{
}
else
if
(
isAlnum
(
c
)
||
c
==
_
(
'-'
)
)
{
ret
+=
toLower
(
c
);
leading
=
false
;
}
else
{
...
...
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