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
f0bcff4e
Commit
f0bcff4e
authored
Nov 20, 2006
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Statistics dimension/categories
parent
04182cee
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
315 additions
and
77 deletions
+315
-77
src/data/field.cpp
src/data/field.cpp
+1
-0
src/data/field.hpp
src/data/field.hpp
+1
-0
src/data/game.cpp
src/data/game.cpp
+26
-0
src/data/game.hpp
src/data/game.hpp
+4
-0
src/data/set.cpp
src/data/set.cpp
+2
-2
src/data/set.hpp
src/data/set.hpp
+1
-1
src/data/statistics.cpp
src/data/statistics.cpp
+61
-0
src/data/statistics.hpp
src/data/statistics.hpp
+65
-0
src/gui/control/gallery_list.cpp
src/gui/control/gallery_list.cpp
+52
-43
src/gui/control/gallery_list.hpp
src/gui/control/gallery_list.hpp
+7
-3
src/gui/control/package_list.cpp
src/gui/control/package_list.cpp
+1
-1
src/gui/set/stats_panel.cpp
src/gui/set/stats_panel.cpp
+73
-14
src/gui/set/stats_panel.hpp
src/gui/set/stats_panel.hpp
+2
-2
src/gui/set/window.cpp
src/gui/set/window.cpp
+2
-0
src/gui/util.cpp
src/gui/util.cpp
+5
-5
src/mse.vcproj
src/mse.vcproj
+6
-0
src/script/script_manager.hpp
src/script/script_manager.hpp
+0
-4
src/util/string.cpp
src/util/string.cpp
+6
-2
No files found.
src/data/field.cpp
View file @
f0bcff4e
...
@@ -42,6 +42,7 @@ IMPLEMENT_REFLECTION(Field) {
...
@@ -42,6 +42,7 @@ IMPLEMENT_REFLECTION(Field) {
REFLECT
(
name
);
REFLECT
(
name
);
if
(
tag
.
reading
())
name
=
cannocial_name_form
(
name
);
if
(
tag
.
reading
())
name
=
cannocial_name_form
(
name
);
REFLECT
(
description
);
REFLECT
(
description
);
REFLECT_N
(
"icon"
,
icon_filename
);
REFLECT
(
editable
);
REFLECT
(
editable
);
REFLECT
(
save_value
);
REFLECT
(
save_value
);
REFLECT
(
show_statistics
);
REFLECT
(
show_statistics
);
...
...
src/data/field.hpp
View file @
f0bcff4e
...
@@ -38,6 +38,7 @@ class Field {
...
@@ -38,6 +38,7 @@ class Field {
size_t
index
;
///< Used by IndexMap
size_t
index
;
///< Used by IndexMap
String
name
;
///< Name of the field, for refering to it from scripts and files
String
name
;
///< Name of the field, for refering to it from scripts and files
String
description
;
///< Description, used in status bar
String
description
;
///< Description, used in status bar
String
icon_filename
;
///< Filename for an icon (for list of fields)
bool
editable
;
///< Can values of this field be edited?
bool
editable
;
///< Can values of this field be edited?
bool
save_value
;
///< Should values of this field be written to files? Can be false for script generated fields.
bool
save_value
;
///< Should values of this field be written to files? Can be false for script generated fields.
bool
show_statistics
;
///< Should this field appear as a group by choice in the statistics panel?
bool
show_statistics
;
///< Should this field appear as a group by choice in the statistics panel?
...
...
src/data/game.cpp
View file @
f0bcff4e
...
@@ -8,10 +8,14 @@
...
@@ -8,10 +8,14 @@
#include <data/game.hpp>
#include <data/game.hpp>
#include <data/field.hpp>
#include <data/field.hpp>
#include <data/statistics.hpp>
#include <util/io/package_manager.hpp>
#include <util/io/package_manager.hpp>
#include <script/script.hpp>
#include <script/script.hpp>
#include <script/value.hpp>
#include <script/value.hpp>
DECLARE_TYPEOF_COLLECTION
(
FieldP
);
DECLARE_TYPEOF_COLLECTION
(
StatsDimensionP
);
// ----------------------------------------------------------------------------- : Game
// ----------------------------------------------------------------------------- : Game
IMPLEMENT_DYNAMIC_ARG
(
Game
*
,
game_for_reading
,
nullptr
);
IMPLEMENT_DYNAMIC_ARG
(
Game
*
,
game_for_reading
,
nullptr
);
...
@@ -46,6 +50,8 @@ IMPLEMENT_REFLECTION(Game) {
...
@@ -46,6 +50,8 @@ IMPLEMENT_REFLECTION(Game) {
REFLECT
(
init_script
);
REFLECT
(
init_script
);
REFLECT
(
set_fields
);
REFLECT
(
set_fields
);
REFLECT
(
card_fields
);
REFLECT
(
card_fields
);
REFLECT
(
statistics_dimensions
);
REFLECT
(
statistics_categories
);
// REFLECT_N("keyword parameter type", keyword_params);
// REFLECT_N("keyword parameter type", keyword_params);
// REFLECT_N("keyword separator type", keyword_separators);
// REFLECT_N("keyword separator type", keyword_separators);
// REFLECT(keywords);
// REFLECT(keywords);
...
@@ -55,8 +61,28 @@ IMPLEMENT_REFLECTION(Game) {
...
@@ -55,8 +61,28 @@ IMPLEMENT_REFLECTION(Game) {
void
Game
::
validate
(
Version
)
{
void
Game
::
validate
(
Version
)
{
// a default for the full name
// a default for the full name
if
(
full_name
.
empty
())
full_name
=
name
();
if
(
full_name
.
empty
())
full_name
=
name
();
// automatic statistics dimensions
{
vector
<
StatsDimensionP
>
dims
;
FOR_EACH
(
f
,
card_fields
)
{
if
(
f
->
show_statistics
)
{
dims
.
push_back
(
new_shared1
<
StatsDimension
>
(
*
f
));
}
}
statistics_dimensions
.
insert
(
statistics_dimensions
.
begin
(),
dims
.
begin
(),
dims
.
end
());
// push front
}
// automatic statistics categories
{
vector
<
StatsCategoryP
>
cats
;
FOR_EACH
(
dim
,
statistics_dimensions
)
{
cats
.
push_back
(
new_shared1
<
StatsCategory
>
(
dim
));
}
statistics_categories
.
insert
(
statistics_categories
.
begin
(),
cats
.
begin
(),
cats
.
end
());
// push front
}
}
}
void
addStatsDimensionsForFields
();
// special behaviour of reading/writing GamePs: only read/write the name
// special behaviour of reading/writing GamePs: only read/write the name
void
Reader
::
handle
(
GameP
&
game
)
{
void
Reader
::
handle
(
GameP
&
game
)
{
...
...
src/data/game.hpp
View file @
f0bcff4e
...
@@ -17,6 +17,8 @@
...
@@ -17,6 +17,8 @@
DECLARE_POINTER_TYPE
(
Field
);
DECLARE_POINTER_TYPE
(
Field
);
DECLARE_POINTER_TYPE
(
Game
);
DECLARE_POINTER_TYPE
(
Game
);
DECLARE_POINTER_TYPE
(
StatsDimension
);
DECLARE_POINTER_TYPE
(
StatsCategory
);
// ----------------------------------------------------------------------------- : Game
// ----------------------------------------------------------------------------- : Game
...
@@ -33,6 +35,8 @@ class Game : public Packaged {
...
@@ -33,6 +35,8 @@ class Game : public Packaged {
OptionalScript
init_script
;
///< Script of variables available to other scripts in this game
OptionalScript
init_script
;
///< Script of variables available to other scripts in this game
vector
<
FieldP
>
set_fields
;
///< Fields for set information
vector
<
FieldP
>
set_fields
;
///< Fields for set information
vector
<
FieldP
>
card_fields
;
///< Fields on each card
vector
<
FieldP
>
card_fields
;
///< Fields on each card
vector
<
StatsDimensionP
>
statistics_dimensions
;
///< (Additional) statistics dimensions
vector
<
StatsCategoryP
>
statistics_categories
;
///< (Additional) statistics categories
vector
<
Dependency
>
dependent_scripts_cards
;
///< scripts that depend on the card list
vector
<
Dependency
>
dependent_scripts_cards
;
///< scripts that depend on the card list
vector
<
Dependency
>
dependent_scripts_keywords
;
///< scripts that depend on the keywords
vector
<
Dependency
>
dependent_scripts_keywords
;
///< scripts that depend on the keywords
...
...
src/data/set.cpp
View file @
f0bcff4e
...
@@ -43,8 +43,8 @@ Set::~Set() {}
...
@@ -43,8 +43,8 @@ Set::~Set() {}
Context
&
Set
::
getContext
()
{
Context
&
Set
::
getContext
()
{
return
script_manager
->
getContext
(
stylesheet
);
return
script_manager
->
getContext
(
stylesheet
);
}
}
Context
&
Set
::
getContext
(
const
Card
&
card
)
{
Context
&
Set
::
getContext
(
const
Card
P
&
card
)
{
return
script_manager
->
getContext
(
card
.
stylesheet
?
card
.
stylesheet
:
stylesheet
);
return
script_manager
->
getContext
(
card
);
}
}
void
Set
::
updateFor
(
const
CardP
&
card
)
{
void
Set
::
updateFor
(
const
CardP
&
card
)
{
script_manager
->
updateStyles
(
card
);
script_manager
->
updateStyles
(
card
);
...
...
src/data/set.hpp
View file @
f0bcff4e
...
@@ -60,7 +60,7 @@ class Set : public Packaged {
...
@@ -60,7 +60,7 @@ class Set : public Packaged {
Context
&
getContext
();
Context
&
getContext
();
/// A context for performing scripts on a particular card
/// A context for performing scripts on a particular card
/** Should only be used from the main thread! */
/** Should only be used from the main thread! */
Context
&
getContext
(
const
Card
&
card
);
Context
&
getContext
(
const
Card
P
&
card
);
/// Update styles for a card
/// Update styles for a card
void
updateFor
(
const
CardP
&
card
);
void
updateFor
(
const
CardP
&
card
);
...
...
src/data/statistics.cpp
0 → 100644
View file @
f0bcff4e
//+----------------------------------------------------------------------------+
//| 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/statistics.hpp>
#include <data/field.hpp>
// ----------------------------------------------------------------------------- : Statistics dimension
StatsDimension
::
StatsDimension
()
:
automatic
(
false
)
{}
StatsDimension
::
StatsDimension
(
const
Field
&
field
)
:
automatic
(
true
)
,
name
(
field
.
name
)
,
description
(
field
.
description
)
,
icon_filename
(
field
.
icon_filename
)
{
// init script!
}
IMPLEMENT_REFLECTION
(
StatsDimension
)
{
REFLECT
(
name
);
REFLECT
(
description
);
REFLECT_N
(
"icon"
,
icon_filename
);
REFLECT
(
script
);
}
// ----------------------------------------------------------------------------- : Statistics category
StatsCategory
::
StatsCategory
()
:
automatic
(
false
)
,
type
(
GRAPH_TYPE_BAR
)
{}
StatsCategory
::
StatsCategory
(
const
StatsDimensionP
&
dim
)
:
automatic
(
true
)
,
name
(
dim
->
name
)
,
description
(
dim
->
description
)
,
icon_filename
(
dim
->
icon_filename
)
,
type
(
GRAPH_TYPE_BAR
)
,
dimensions
(
1
,
dim
)
{}
IMPLEMENT_REFLECTION_ENUM
(
GraphType
)
{
VALUE_N
(
"bar"
,
GRAPH_TYPE_BAR
);
VALUE_N
(
"pie"
,
GRAPH_TYPE_PIE
);
}
IMPLEMENT_REFLECTION
(
StatsCategory
)
{
REFLECT
(
name
);
REFLECT
(
description
);
REFLECT_N
(
"icon"
,
icon_filename
);
REFLECT
(
type
);
REFLECT
(
dimensions
);
}
src/data/statistics.hpp
0 → 100644
View file @
f0bcff4e
//+----------------------------------------------------------------------------+
//| 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_STATISTICS
#define HEADER_DATA_STATISTICS
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <util/reflect.hpp>
#include <script/scriptable.hpp>
class
Field
;
DECLARE_POINTER_TYPE
(
StatsDimension
);
DECLARE_POINTER_TYPE
(
StatsCategory
);
// ----------------------------------------------------------------------------- : Statistics dimension
/// A dimension that can be plotted as an axis in a graph
/** Dimensions can be generated automatically based on card fields */
class
StatsDimension
{
public:
StatsDimension
();
StatsDimension
(
const
Field
&
);
String
name
;
///< Name of this dimension
String
description
;
///< Description, used in status bar
String
icon_filename
;
///< Icon for lists
OptionalScript
script
;
///< Script that determines the value(s)
bool
automatic
;
///< Based on a card field?
DECLARE_REFLECTION
();
};
// ----------------------------------------------------------------------------- : Statistics category
/// Types of graphs
enum
GraphType
{
GRAPH_TYPE_BAR
,
GRAPH_TYPE_PIE
};
/// A category for statistics
/** Can be generated automatically based on a dimension */
class
StatsCategory
{
public:
StatsCategory
();
StatsCategory
(
const
StatsDimensionP
&
);
String
name
;
///< Name/label
String
description
;
///< Description, used in status bar
String
icon_filename
;
///< Icon for lists
Bitmap
icon
;
///< The loaded icon (optional of course)
vector
<
StatsDimensionP
>
dimensions
;
///< The dimensions to use, higher dimensions may be null
GraphType
type
;
///< Type of graph to use
bool
automatic
;
///< Automatically generated?
DECLARE_REFLECTION
();
};
// ----------------------------------------------------------------------------- : EOF
#endif
src/gui/control/gallery_list.cpp
View file @
f0bcff4e
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
#include <gui/control/gallery_list.hpp>
#include <gui/control/gallery_list.hpp>
#include <gfx/gfx.hpp>
#include <gfx/gfx.hpp>
#include <wx/dcbuffer.h>
// ----------------------------------------------------------------------------- : Events
// ----------------------------------------------------------------------------- : Events
...
@@ -16,66 +17,62 @@ DEFINE_EVENT_TYPE(EVENT_GALLERY_ACTIVATE);
...
@@ -16,66 +17,62 @@ DEFINE_EVENT_TYPE(EVENT_GALLERY_ACTIVATE);
// ----------------------------------------------------------------------------- : GalleryList
// ----------------------------------------------------------------------------- : GalleryList
const
int
MARGIN
=
2
;
// margin around items
const
int
MARGIN
=
1
;
// margin between items
const
int
BORDER
=
1
;
// margin between items
GalleryList
::
GalleryList
(
Window
*
parent
,
int
id
,
int
direction
)
GalleryList
::
GalleryList
(
Window
*
parent
,
int
id
,
int
direction
)
:
wxScrolledWindow
(
parent
,
id
,
wxDefaultPosition
,
wxDefaultSize
,
wxSUNKEN_BORDER
)
:
wxScrolledWindow
(
parent
,
id
,
wxDefaultPosition
,
wxDefaultSize
,
wxSUNKEN_BORDER
|
(
direction
==
wxHORIZONTAL
?
wxHSCROLL
:
wxVSCROLL
)
)
,
direction
(
direction
)
,
direction
(
direction
)
{}
{}
void
GalleryList
::
update
()
{
void
GalleryList
::
update
()
{
const
int
w
=
item_size
.
GetWidth
()
+
2
*
MARGIN
;
const
int
w
=
item_size
.
width
+
MARGIN
+
2
*
BORDER
;
const
int
h
=
item_size
.
GetHeight
()
+
2
*
MARGIN
;
const
int
h
=
item_size
.
height
+
MARGIN
+
2
*
BORDER
;
// resize and scroll
// resize and scroll
if
(
direction
==
wxHORIZONTAL
)
{
if
(
direction
==
wxHORIZONTAL
)
{
// resize window
SetVirtualSize
(
w
*
(
int
)
itemCount
()
+
MARGIN
,
h
+
MARGIN
);
SetVirtualSize
(
w
,
h
*
(
int
)
itemCount
());
SetScrollRate
(
w
,
0
);
SetScrollRate
(
w
,
0
);
// ensure selected item is visible
if
(
selection
<
itemCount
())
{
int
x
,
cw
;
GetViewStart
(
&
x
,
0
);
GetClientSize
(
&
cw
,
0
);
cw
/=
w
;
if
((
int
)
selection
<
x
)
{
Scroll
((
int
)
selection
,
-
1
);
// scroll up
}
else
if
((
int
)
selection
>=
x
+
cw
)
{
Scroll
((
int
)
selection
-
cw
-
1
,
-
1
);
// scroll up
}
}
}
else
{
// wxVERTICAL
}
else
{
// wxVERTICAL
// resize window
SetVirtualSize
(
w
,
h
*
(
int
)
itemCount
()
+
MARGIN
+
MARGIN
);
SetVirtualSize
(
w
*
(
int
)
itemCount
(),
h
);
SetScrollRate
(
0
,
h
);
SetScrollRate
(
0
,
h
);
// ensure selected item is visible
}
if
(
selection
<
itemCount
())
{
// ensure selected item + its margin is visible
int
y
,
ch
;
if
(
selection
<
itemCount
())
{
GetViewStart
(
0
,
&
y
);
int
x
,
y
,
cw
,
ch
;
GetClientSize
(
0
,
&
ch
);
GetViewStart
(
&
x
,
&
y
);
ch
/=
w
;
GetClientSize
(
&
cw
,
&
ch
);
if
((
int
)
selection
<
y
)
{
cw
=
(
cw
-
w
+
1
)
/
w
;
ch
=
(
ch
-
h
+
1
)
/
h
;
Scroll
((
int
)
selection
,
-
1
);
// scroll up
RealPoint
pos
=
itemPos
(
selection
);
}
else
if
((
int
)
selection
>=
y
+
ch
)
{
x
=
min
(
x
,
(
int
)
selection
);
Scroll
((
int
)
selection
-
ch
-
1
,
-
1
);
// scroll down
y
=
min
(
y
,
(
int
)
selection
);
}
x
=
max
(
x
+
cw
,
(
int
)
selection
)
-
cw
;
}
y
=
max
(
y
+
ch
,
(
int
)
selection
)
-
ch
;
Scroll
(
x
,
y
);
}
}
// redraw
// redraw
Refresh
(
false
);
Refresh
(
false
);
}
}
size_t
GalleryList
::
findItem
(
const
wxMouseEvent
&
ev
)
{
size_t
GalleryList
::
findItem
(
const
wxMouseEvent
&
ev
)
const
{
if
(
direction
==
wxHORIZONTAL
)
{
if
(
direction
==
wxHORIZONTAL
)
{
int
x
,
w
=
item_size
.
GetWidth
()
+
2
*
MARGIN
;
int
x
,
w
=
item_size
.
width
+
MARGIN
+
2
*
BORDER
;
GetViewStart
(
&
x
,
0
);
GetViewStart
(
&
x
,
0
);
return
static_cast
<
size_t
>
(
x
+
ev
.
GetX
()
/
w
);
return
static_cast
<
size_t
>
(
x
+
ev
.
GetX
()
/
w
);
}
else
{
// wxVERTICAL
}
else
{
// wxVERTICAL
int
y
,
h
=
item_size
.
GetHeight
()
+
2
*
MARGIN
;
int
y
,
h
=
item_size
.
height
+
MARGIN
+
2
*
BORDER
;
GetViewStart
(
0
,
&
y
);
GetViewStart
(
0
,
&
y
);
return
static_cast
<
size_t
>
(
y
+
ev
.
GetY
()
/
h
);
return
static_cast
<
size_t
>
(
y
+
ev
.
GetY
()
/
h
);
}
}
}
}
RealPoint
GalleryList
::
itemPos
(
size_t
item
)
const
{
if
(
direction
==
wxHORIZONTAL
)
{
return
RealPoint
(
item
*
(
item_size
.
width
+
MARGIN
+
2
*
BORDER
)
+
MARGIN
+
BORDER
,
MARGIN
+
BORDER
);
}
else
{
return
RealPoint
(
MARGIN
+
BORDER
,
item
*
(
item_size
.
height
+
MARGIN
+
2
*
BORDER
)
+
MARGIN
+
BORDER
);
}
}
// ----------------------------------------------------------------------------- : Events
// ----------------------------------------------------------------------------- : Events
void
GalleryList
::
onLeftDown
(
wxMouseEvent
&
ev
)
{
void
GalleryList
::
onLeftDown
(
wxMouseEvent
&
ev
)
{
...
@@ -85,40 +82,50 @@ void GalleryList::onLeftDown(wxMouseEvent& ev) {
...
@@ -85,40 +82,50 @@ void GalleryList::onLeftDown(wxMouseEvent& ev) {
update
();
update
();
sendEvent
(
EVENT_GALLERY_SELECT
);
sendEvent
(
EVENT_GALLERY_SELECT
);
}
}
ev
.
Skip
();
// focus
}
}
void
GalleryList
::
onLeftDClick
(
wxMouseEvent
&
ev
)
{
void
GalleryList
::
onLeftDClick
(
wxMouseEvent
&
ev
)
{
sendEvent
(
EVENT_GALLERY_ACTIVATE
);
sendEvent
(
EVENT_GALLERY_ACTIVATE
);
}
}
void
GalleryList
::
on
KeyDown
(
wxKeyEvent
&
ev
)
{
void
GalleryList
::
on
Char
(
wxKeyEvent
&
ev
)
{
switch
(
ev
.
GetKeyCode
())
{
switch
(
ev
.
GetKeyCode
())
{
case
WXK_LEFT
:
if
(
direction
==
wxHORIZONTAL
&&
selection
>
0
)
{
case
WXK_LEFT
:
if
(
direction
==
wxHORIZONTAL
&&
selection
>
0
)
{
selection
-=
1
;
selection
-=
1
;
update
();
update
();
sendEvent
(
EVENT_GALLERY_SELECT
);
}
break
;
}
break
;
case
WXK_RIGHT
:
if
(
direction
==
wxHORIZONTAL
&&
selection
+
1
<
itemCount
())
{
case
WXK_RIGHT
:
if
(
direction
==
wxHORIZONTAL
&&
selection
+
1
<
itemCount
())
{
selection
+=
1
;
selection
+=
1
;
update
();
update
();
sendEvent
(
EVENT_GALLERY_SELECT
);
}
break
;
}
break
;
case
WXK_UP
:
if
(
direction
==
wxVERTICAL
&&
selection
>
0
)
{
case
WXK_UP
:
if
(
direction
==
wxVERTICAL
&&
selection
>
0
)
{
selection
-=
1
;
selection
-=
1
;
update
();
update
();
sendEvent
(
EVENT_GALLERY_SELECT
);
}
break
;
}
break
;
case
WXK_DOWN
:
if
(
direction
==
wxVERTICAL
&&
selection
+
1
<
itemCount
())
{
case
WXK_DOWN
:
if
(
direction
==
wxVERTICAL
&&
selection
+
1
<
itemCount
())
{
selection
+=
1
;
selection
+=
1
;
update
();
update
();
sendEvent
(
EVENT_GALLERY_SELECT
);
}
break
;
}
break
;
}
}
}
}
wxSize
GalleryList
::
DoGetBestSize
()
const
{
wxSize
GalleryList
::
DoGetBestSize
()
const
{
wxSize
ws
=
GetSize
(),
cs
=
GetClientSize
();
wxSize
ws
=
GetSize
(),
cs
=
GetClientSize
();
const
int
w
=
item_size
.
GetWidth
()
+
2
*
MARGIN
;
const
int
w
=
item_size
.
width
+
2
*
MARGIN
+
2
*
BORDER
;
const
int
h
=
item_size
.
GetHeight
()
+
2
*
MARGIN
;
const
int
h
=
item_size
.
height
+
2
*
MARGIN
+
2
*
BORDER
;
return
wxSize
(
w
,
h
)
+
ws
-
cs
;
return
wxSize
(
w
,
h
)
+
ws
-
cs
;
}
}
void
GalleryList
::
onPaint
(
wxPaintEvent
&
)
{
wxBufferedPaintDC
dc
(
this
);
DoPrepareDC
(
dc
);
OnDraw
(
dc
);
}
void
GalleryList
::
OnDraw
(
DC
&
dc
)
{
void
GalleryList
::
OnDraw
(
DC
&
dc
)
{
int
x
,
y
;
int
x
,
y
;
int
cw
,
ch
;
int
cw
,
ch
;
...
@@ -128,13 +135,13 @@ void GalleryList::OnDraw(DC& dc) {
...
@@ -128,13 +135,13 @@ void GalleryList::OnDraw(DC& dc) {
GetViewStart
(
&
x
,
&
y
);
GetViewStart
(
&
x
,
&
y
);
GetClientSize
(
&
cw
,
&
ch
);
GetClientSize
(
&
cw
,
&
ch
);
if
(
direction
==
wxHORIZONTAL
)
{
if
(
direction
==
wxHORIZONTAL
)
{
dx
=
item_size
.
GetWidth
()
+
2
*
MARGIN
;
dx
=
item_size
.
width
+
MARGIN
+
2
*
BORDER
;
dy
=
0
;
dy
=
0
;
start
=
(
size_t
)
x
;
start
=
(
size_t
)
x
;
end
=
(
size_t
)
(
start
+
cw
/
dx
+
1
);
end
=
(
size_t
)
(
start
+
cw
/
dx
+
1
);
}
else
{
}
else
{
dx
=
0
;
dx
=
0
;
dy
=
item_size
.
GetHeight
()
+
2
*
MARGIN
;
dy
=
item_size
.
height
+
MARGIN
+
2
*
BORDER
;
start
=
(
size_t
)
y
;
start
=
(
size_t
)
y
;
end
=
(
size_t
)
(
start
+
ch
/
dy
+
1
);
end
=
(
size_t
)
(
start
+
ch
/
dy
+
1
);
}
}
...
@@ -153,9 +160,10 @@ void GalleryList::OnDraw(DC& dc) {
...
@@ -153,9 +160,10 @@ void GalleryList::OnDraw(DC& dc) {
Color
c
=
selected
?
wxSystemSettings
::
GetColour
(
wxSYS_COLOUR_HIGHLIGHT
)
:
unselected
;
Color
c
=
selected
?
wxSystemSettings
::
GetColour
(
wxSYS_COLOUR_HIGHLIGHT
)
:
unselected
;
dc
.
SetPen
(
c
);
dc
.
SetPen
(
c
);
dc
.
SetBrush
(
lerp
(
background
,
c
,
0.3
));
dc
.
SetBrush
(
lerp
(
background
,
c
,
0.3
));
dc
.
DrawRectangle
((
int
)
i
*
dx
+
1
,
(
int
)
i
*
dy
+
1
,
item_size
.
GetWidth
()
+
2
,
item_size
.
GetHeight
()
+
2
);
RealPoint
pos
=
itemPos
(
i
);
dc
.
DrawRectangle
(
pos
.
x
-
BORDER
,
pos
.
y
-
BORDER
,
item_size
.
width
+
2
*
BORDER
,
item_size
.
height
+
2
*
BORDER
);
// draw item
// draw item
drawItem
(
dc
,
(
int
)
i
*
dx
+
MARGIN
,
(
int
)
i
*
dy
+
MARGIN
,
i
,
selected
);
drawItem
(
dc
,
pos
.
x
,
pos
.
y
,
i
,
selected
);
}
}
}
}
...
@@ -169,5 +177,6 @@ void GalleryList::sendEvent(WXTYPE type) {
...
@@ -169,5 +177,6 @@ void GalleryList::sendEvent(WXTYPE type) {
BEGIN_EVENT_TABLE
(
GalleryList
,
wxScrolledWindow
)
BEGIN_EVENT_TABLE
(
GalleryList
,
wxScrolledWindow
)
EVT_LEFT_DOWN
(
GalleryList
::
onLeftDown
)
EVT_LEFT_DOWN
(
GalleryList
::
onLeftDown
)
EVT_LEFT_DCLICK
(
GalleryList
::
onLeftDClick
)
EVT_LEFT_DCLICK
(
GalleryList
::
onLeftDClick
)
EVT_KEY_DOWN
(
GalleryList
::
onKeyDown
)
EVT_CHAR
(
GalleryList
::
onChar
)
EVT_PAINT
(
GalleryList
::
onPaint
)
END_EVENT_TABLE
()
END_EVENT_TABLE
()
src/gui/control/gallery_list.hpp
View file @
f0bcff4e
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
// ----------------------------------------------------------------------------- : Includes
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <util/prec.hpp>
#include <util/real_point.hpp>
// ----------------------------------------------------------------------------- : Events
// ----------------------------------------------------------------------------- : Events
...
@@ -36,7 +37,7 @@ class GalleryList : public wxScrolledWindow {
...
@@ -36,7 +37,7 @@ class GalleryList : public wxScrolledWindow {
protected:
protected:
static
const
size_t
NO_SELECTION
=
(
size_t
)
-
1
;
static
const
size_t
NO_SELECTION
=
(
size_t
)
-
1
;
size_t
selection
;
///< The selected item, or NO_SELECTION if there is no selection
size_t
selection
;
///< The selected item, or NO_SELECTION if there is no selection
wx
Size
item_size
;
///< The size of a single item
Real
Size
item_size
;
///< The size of a single item
int
direction
;
///< Direction of the list, can be wxHORIZONTAL or wxVERTICAL
int
direction
;
///< Direction of the list, can be wxHORIZONTAL or wxVERTICAL
/// Redraw the list after changing the selection or the number of items
/// Redraw the list after changing the selection or the number of items
...
@@ -55,11 +56,14 @@ class GalleryList : public wxScrolledWindow {
...
@@ -55,11 +56,14 @@ class GalleryList : public wxScrolledWindow {
void
onLeftDown
(
wxMouseEvent
&
ev
);
void
onLeftDown
(
wxMouseEvent
&
ev
);
void
onLeftDClick
(
wxMouseEvent
&
ev
);
void
onLeftDClick
(
wxMouseEvent
&
ev
);
void
onKeyDown
(
wxKeyEvent
&
ev
);
void
onChar
(
wxKeyEvent
&
ev
);
void
onPaint
(
wxPaintEvent
&
);
void
OnDraw
(
DC
&
dc
);
void
OnDraw
(
DC
&
dc
);
/// Find the item corresponding to the given location
/// Find the item corresponding to the given location
size_t
findItem
(
const
wxMouseEvent
&
);
size_t
findItem
(
const
wxMouseEvent
&
)
const
;
/// Find the coordinates of an item
RealPoint
itemPos
(
size_t
item
)
const
;
/// Send an event
/// Send an event
void
sendEvent
(
WXTYPE
type
);
void
sendEvent
(
WXTYPE
type
);
};
};
...
...
src/gui/control/package_list.cpp
View file @
f0bcff4e
...
@@ -29,7 +29,7 @@ void PackageList::drawItem(DC& dc, int x, int y, size_t item, bool selected) {
...
@@ -29,7 +29,7 @@ void PackageList::drawItem(DC& dc, int x, int y, size_t item, bool selected) {
int
w
,
h
;
int
w
,
h
;
// draw image
// draw image
if
(
d
.
image
.
Ok
())
{
if
(
d
.
image
.
Ok
())
{
dc
.
DrawBitmap
(
d
.
image
,
x
+
align_delta_x
(
ALIGN_CENTER
,
item_size
.
GetWidth
()
,
d
.
image
.
GetWidth
()),
y
+
3
);
dc
.
DrawBitmap
(
d
.
image
,
x
+
align_delta_x
(
ALIGN_CENTER
,
item_size
.
width
,
d
.
image
.
GetWidth
()),
y
+
3
);
}
}
// draw short name
// draw short name
dc
.
SetFont
(
wxFont
(
12
,
wxSWISS
,
wxNORMAL
,
wxBOLD
,
false
,
_
(
"Arial"
)));
dc
.
SetFont
(
wxFont
(
12
,
wxSWISS
,
wxNORMAL
,
wxBOLD
,
false
,
_
(
"Arial"
)));
...
...
src/gui/set/stats_panel.cpp
View file @
f0bcff4e
...
@@ -10,31 +10,72 @@
...
@@ -10,31 +10,72 @@
#include <gui/control/graph.hpp>
#include <gui/control/graph.hpp>
#include <gui/control/gallery_list.hpp>
#include <gui/control/gallery_list.hpp>
#include <gui/control/filtered_card_list.hpp>
#include <gui/control/filtered_card_list.hpp>
#include <data/game.hpp>
#include <data/statistics.hpp>
#include <util/window_id.hpp>
#include <util/window_id.hpp>
#include <util/alignment.hpp>
#include <gfx/gfx.hpp>
#include <wx/splitter.h>
#include <wx/splitter.h>
// ----------------------------------------------------------------------------- : StatFieldList
DECLARE_TYPEOF_COLLECTION
(
StatsDimensionP
);
DECLARE_TYPEOF_COLLECTION
(
CardP
);
// ----------------------------------------------------------------------------- : StatCategoryList
/// A list of fields of which the statistics can be shown
/// A list of fields of which the statistics can be shown
class
Stat
Field
List
:
public
GalleryList
{
class
Stat
Category
List
:
public
GalleryList
{
public:
public:
Stat
Field
List
(
Window
*
parent
,
int
id
)
Stat
Category
List
(
Window
*
parent
,
int
id
)
:
GalleryList
(
parent
,
id
,
wxVERTICAL
)
:
GalleryList
(
parent
,
id
,
wxVERTICAL
)
{
{
item_size
=
wxSize
(
100
,
30
);
item_size
=
wxSize
(
140
,
23
);
}
void
show
(
const
GameP
&
);
/// The selected category
inline
StatsCategory
&
getSelection
()
{
return
*
game
->
statistics_categories
.
at
(
selection
);
}
}
protected:
protected:
virtual
size_t
itemCount
()
const
;
virtual
size_t
itemCount
()
const
;
virtual
void
drawItem
(
DC
&
dc
,
int
x
,
int
y
,
size_t
item
,
bool
selected
);
virtual
void
drawItem
(
DC
&
dc
,
int
x
,
int
y
,
size_t
item
,
bool
selected
);
private:
GameP
game
;
};
};
size_t
StatFieldList
::
itemCount
()
const
{
void
StatCategoryList
::
show
(
const
GameP
&
game
)
{
return
0
;
// TODO
this
->
game
=
game
;
update
();
}
}
void
StatFieldList
::
drawItem
(
DC
&
dc
,
int
x
,
int
y
,
size_t
item
,
bool
selected
)
{
size_t
StatCategoryList
::
itemCount
()
const
{
// TODO
return
game
?
game
->
statistics_categories
.
size
()
:
0
;
}
void
StatCategoryList
::
drawItem
(
DC
&
dc
,
int
x
,
int
y
,
size_t
item
,
bool
selected
)
{
StatsCategory
&
cat
=
*
game
->
statistics_categories
.
at
(
item
);
// draw icon
if
(
!
cat
.
icon_filename
.
empty
()
&&
!
cat
.
icon
.
Ok
())
{
InputStreamP
file
=
game
->
openIn
(
cat
.
icon_filename
);
Image
img
(
*
file
);
Image
resampled
(
21
,
21
);
resample_preserve_aspect
(
img
,
resampled
);
if
(
img
.
Ok
())
cat
.
icon
=
Bitmap
(
resampled
);
}
if
(
cat
.
icon
.
Ok
())
{
dc
.
DrawBitmap
(
cat
.
icon
,
x
+
1
,
y
+
1
);
}
// draw name
RealRect
rect
(
RealPoint
(
x
+
23
,
y
),
RealSize
(
item_size
.
width
-
30
,
item_size
.
height
));
String
str
=
capitalize
(
cat
.
name
);
dc
.
SetFont
(
wxFont
(
10
,
wxSWISS
,
wxNORMAL
,
wxBOLD
,
false
,
_
(
"Arial"
)));
int
w
,
h
;
dc
.
GetTextExtent
(
str
,
&
w
,
&
h
);
RealPoint
pos
=
align_in_rect
(
ALIGN_MIDDLE_LEFT
,
RealSize
(
w
,
h
),
rect
);
dc
.
DrawText
(
str
,
pos
.
x
,
pos
.
y
);
}
}
// ----------------------------------------------------------------------------- : StatsPanel
// ----------------------------------------------------------------------------- : StatsPanel
...
@@ -44,30 +85,47 @@ StatsPanel::StatsPanel(Window* parent, int id)
...
@@ -44,30 +85,47 @@ StatsPanel::StatsPanel(Window* parent, int id)
{
{
// init controls
// init controls
wxSplitterWindow
*
splitter
;
wxSplitterWindow
*
splitter
;
fields
=
new
StatFieldList
(
this
,
ID_FIELD_LIST
);
categories
=
new
StatCategoryList
(
this
,
ID_FIELD_LIST
);
splitter
=
new
wxSplitterWindow
(
this
,
wxID_ANY
,
wxDefaultPosition
,
wxDefaultSize
,
0
);
splitter
=
new
wxSplitterWindow
(
this
,
wxID_ANY
,
wxDefaultPosition
,
wxDefaultSize
,
0
);
graph
=
new
GraphControl
(
splitter
,
wxID_ANY
);
graph
=
new
GraphControl
(
splitter
,
wxID_ANY
);
card_list
=
new
FilteredCardList
(
splitter
,
wxID_ANY
);
card_list
=
new
FilteredCardList
(
splitter
,
wxID_ANY
);
// init splitter
// init splitter
splitter
->
SetMinimumPaneSize
(
100
);
splitter
->
SetMinimumPaneSize
(
100
);
splitter
->
SetSashGravity
(
1.0
);
splitter
->
SetSashGravity
(
1.0
);
splitter
->
SplitHorizontally
(
graph
,
card_list
,
-
100
);
splitter
->
SplitHorizontally
(
graph
,
card_list
,
-
100
);
// init sizer
// init sizer
wxSizer
*
s
=
new
wxBoxSizer
(
wxHORIZONTAL
);
wxSizer
*
s
=
new
wxBoxSizer
(
wxHORIZONTAL
);
s
->
Add
(
fields
,
0
,
wxEXPAND
|
wxRIGHT
,
2
);
s
->
Add
(
categories
,
0
,
wxEXPAND
|
wxRIGHT
,
2
);
s
->
Add
(
splitter
,
1
,
wxEXPAND
);
s
->
Add
(
splitter
,
1
,
wxEXPAND
);
s
->
SetSizeHints
(
this
);
s
->
SetSizeHints
(
this
);
SetSizer
(
s
);
SetSizer
(
s
);
}
}
void
StatsPanel
::
onChangeSet
()
{
void
StatsPanel
::
onChangeSet
()
{
card_list
->
setSet
(
set
);
card_list
->
setSet
(
set
);
categories
->
show
(
set
->
game
);
}
}
void
StatsPanel
::
onCommand
(
int
id
)
{
void
StatsPanel
::
onCommand
(
int
id
)
{
switch
(
id
)
{
switch
(
id
)
{
case
ID_FIELD_LIST
:
{
case
ID_FIELD_LIST
:
{
// change graph data
// change graph data
if
(
categories
->
hasSelection
())
{
StatsCategory
&
cat
=
categories
->
getSelection
();
GraphDataPre
d
;
FOR_EACH
(
dim
,
cat
.
dimensions
)
{
d
.
axes
.
push_back
(
new_shared1
<
GraphAxis
>
(
dim
->
name
));
}
FOR_EACH
(
card
,
set
->
cards
)
{
Context
&
ctx
=
set
->
getContext
(
card
);
GraphElementP
e
(
new
GraphElement
);
FOR_EACH
(
dim
,
cat
.
dimensions
)
{
e
->
values
.
push_back
(
*
dim
->
script
.
invoke
(
ctx
));
}
d
.
elements
.
push_back
(
e
);
}
graph
->
setData
(
d
);
}
break
;
break
;
}
}
}
}
...
@@ -80,4 +138,5 @@ CardP StatsPanel::selectedCard() const {
...
@@ -80,4 +138,5 @@ CardP StatsPanel::selectedCard() const {
}
}
void
StatsPanel
::
selectCard
(
const
CardP
&
card
)
{
void
StatsPanel
::
selectCard
(
const
CardP
&
card
)
{
card_list
->
setCard
(
card
);
card_list
->
setCard
(
card
);
}
}
src/gui/set/stats_panel.hpp
View file @
f0bcff4e
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
#include <util/prec.hpp>
#include <util/prec.hpp>
#include <gui/set/panel.hpp>
#include <gui/set/panel.hpp>
class
Stat
Field
List
;
class
Stat
Category
List
;
class
GraphControl
;
class
GraphControl
;
class
FilteredCardList
;
class
FilteredCardList
;
...
@@ -33,7 +33,7 @@ class StatsPanel : public SetWindowPanel {
...
@@ -33,7 +33,7 @@ class StatsPanel : public SetWindowPanel {
// --------------------------------------------------- : Data
// --------------------------------------------------- : Data
private:
private:
Stat
FieldList
*
field
s
;
Stat
CategoryList
*
categorie
s
;
GraphControl
*
graph
;
GraphControl
*
graph
;
FilteredCardList
*
card_list
;
FilteredCardList
*
card_list
;
};
};
...
...
src/gui/set/window.cpp
View file @
f0bcff4e
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
#include <gui/set/style_panel.hpp>
#include <gui/set/style_panel.hpp>
#include <gui/set/stats_panel.hpp>
#include <gui/set/stats_panel.hpp>
#include <gui/control/card_list.hpp>
#include <gui/control/card_list.hpp>
#include <gui/control/gallery_list.hpp>
#include <gui/about_window.hpp>
#include <gui/about_window.hpp>
#include <gui/new_window.hpp>
#include <gui/new_window.hpp>
#include <gui/icon_menu.hpp>
#include <gui/icon_menu.hpp>
...
@@ -580,6 +581,7 @@ BEGIN_EVENT_TABLE(SetWindow, wxFrame)
...
@@ -580,6 +581,7 @@ BEGIN_EVENT_TABLE(SetWindow, wxFrame)
EVT_MENU
(
ID_HELP_INDEX
,
SetWindow
::
onHelpIndex
)
EVT_MENU
(
ID_HELP_INDEX
,
SetWindow
::
onHelpIndex
)
EVT_MENU
(
ID_HELP_ABOUT
,
SetWindow
::
onHelpAbout
)
EVT_MENU
(
ID_HELP_ABOUT
,
SetWindow
::
onHelpAbout
)
EVT_TOOL_RANGE
(
ID_CHILD_MIN
,
ID_CHILD_MAX
,
SetWindow
::
onChildMenu
)
EVT_TOOL_RANGE
(
ID_CHILD_MIN
,
ID_CHILD_MAX
,
SetWindow
::
onChildMenu
)
EVT_GALLERY_SELECT
(
ID_FIELD_LIST
,
SetWindow
::
onChildMenu
)
// for StatsPanel, because it is not a EVT_TOOL
EVT_UPDATE_UI
(
wxID_ANY
,
SetWindow
::
onUpdateUI
)
EVT_UPDATE_UI
(
wxID_ANY
,
SetWindow
::
onUpdateUI
)
// EVT_FIND (wxID_ANY, SetWindow::onFind)
// EVT_FIND (wxID_ANY, SetWindow::onFind)
...
...
src/gui/util.cpp
View file @
f0bcff4e
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#include <util/rotation.hpp>
#include <util/rotation.hpp>
#include <wx/mstream.h>
#include <wx/mstream.h>
#if
defined(wxMSW) &&
wxUSE_UXTHEME
#if wxUSE_UXTHEME
#include <wx/msw/uxtheme.h>
#include <wx/msw/uxtheme.h>
#include <tmschema.h>
#include <tmschema.h>
#include <shlobj.h>
#include <shlobj.h>
...
@@ -101,19 +101,19 @@ void draw3DBorder(DC& dc, int x1, int y1, int x2, int y2) {
...
@@ -101,19 +101,19 @@ void draw3DBorder(DC& dc, int x1, int y1, int x2, int y2) {
}
}
void
draw_control_border
(
Window
*
win
,
DC
&
dc
,
const
wxRect
&
rect
)
{
void
draw_control_border
(
Window
*
win
,
DC
&
dc
,
const
wxRect
&
rect
)
{
#if
defined(wxMSW) &&
wxUSE_UXTHEME
#if wxUSE_UXTHEME
RECT
r
;
RECT
r
;
wxUxThemeEngine
*
themeEngine
=
wxUxThemeEngine
::
Get
();
wxUxThemeEngine
*
themeEngine
=
wxUxThemeEngine
::
Get
();
if
(
themeEngine
&&
themeEngine
->
IsAppThemed
())
{
if
(
themeEngine
&&
themeEngine
->
IsAppThemed
())
{
wxUxThemeHandle
hTheme
(
win
,
L
_
(
"EDIT"
));
wxUxThemeHandle
hTheme
(
win
,
_
(
"EDIT"
));
r
.
left
=
rect
.
x
-
1
;
r
.
left
=
rect
.
x
-
1
;
r
.
top
=
rect
.
y
-
1
;
r
.
top
=
rect
.
y
-
1
;
r
.
right
=
rect
.
x
+
rect
.
width
+
1
;
r
.
right
=
rect
.
x
+
rect
.
width
+
1
;
r
.
bottom
=
rect
.
y
+
rect
.
height
+
1
;
r
.
bottom
=
rect
.
y
+
rect
.
height
+
1
;
if
(
hTheme
)
{
if
(
hTheme
)
{
wxUxThemeEngine
::
Get
()
->
DrawThemeBackground
(
wxUxThemeEngine
::
Get
()
->
DrawThemeBackground
(
hTheme
,
(
HTHEME
)
hTheme
,
dc
.
GetHDC
(),
(
HDC
)
dc
.
GetHDC
(),
EP_EDITTEXT
,
EP_EDITTEXT
,
ETS_NORMAL
,
ETS_NORMAL
,
&
r
,
&
r
,
...
...
src/mse.vcproj
View file @
f0bcff4e
...
@@ -849,6 +849,12 @@
...
@@ -849,6 +849,12 @@
<File
<File
RelativePath=
".\data\settings.hpp"
>
RelativePath=
".\data\settings.hpp"
>
</File>
</File>
<File
RelativePath=
".\data\statistics.cpp"
>
</File>
<File
RelativePath=
".\data\statistics.hpp"
>
</File>
<File
<File
RelativePath=
".\data\stylesheet.cpp"
>
RelativePath=
".\data\stylesheet.cpp"
>
</File>
</File>
...
...
src/script/script_manager.hpp
View file @
f0bcff4e
...
@@ -22,10 +22,6 @@ DECLARE_POINTER_TYPE(Game);
...
@@ -22,10 +22,6 @@ DECLARE_POINTER_TYPE(Game);
DECLARE_POINTER_TYPE
(
StyleSheet
);
DECLARE_POINTER_TYPE
(
StyleSheet
);
DECLARE_POINTER_TYPE
(
Card
);
DECLARE_POINTER_TYPE
(
Card
);
// ----------------------------------------------------------------------------- : Dependencies of data type members
// ----------------------------------------------------------------------------- : ScriptManager
// ----------------------------------------------------------------------------- : ScriptManager
/// Manager of the script context for a set, keeps scripts up to date
/// Manager of the script context for a set, keeps scripts up to date
...
...
src/util/string.cpp
View file @
f0bcff4e
...
@@ -6,8 +6,9 @@
...
@@ -6,8 +6,9 @@
// ----------------------------------------------------------------------------- : Includes
// ----------------------------------------------------------------------------- : Includes
#include "string.hpp"
#include <util/prec.hpp>
#include "for_each.hpp"
#include <util/string.hpp>
#include <util/for_each.hpp>
#include <wx/txtstrm.h>
#include <wx/txtstrm.h>
// ----------------------------------------------------------------------------- : Unicode
// ----------------------------------------------------------------------------- : Unicode
...
@@ -145,6 +146,9 @@ String cannocial_name_form(const String& str) {
...
@@ -145,6 +146,9 @@ String cannocial_name_form(const String& str) {
String
singular_form
(
const
String
&
str
)
{
String
singular_form
(
const
String
&
str
)
{
assert
(
str
.
size
()
>
1
);
assert
(
str
.
size
()
>
1
);
assert
(
str
.
GetChar
(
str
.
size
()
-
1
)
==
_
(
's'
));
// ends in 's'
assert
(
str
.
GetChar
(
str
.
size
()
-
1
)
==
_
(
's'
));
// ends in 's'
if
(
str
.
size
()
>
3
&&
is_substr
(
str
,
str
.
size
()
-
3
,
_
(
"ies"
)))
{
return
str
.
substr
(
0
,
str
.
size
()
-
3
)
+
_
(
"y"
);
}
return
str
.
substr
(
0
,
str
.
size
()
-
1
);
return
str
.
substr
(
0
,
str
.
size
()
-
1
);
}
}
...
...
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