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
263c2ca9
Commit
263c2ca9
authored
Nov 25, 2006
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dependency following now works
parent
b51d7fae
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
108 additions
and
12 deletions
+108
-12
src/data/card.cpp
src/data/card.cpp
+8
-0
src/data/card.hpp
src/data/card.hpp
+4
-0
src/data/set.cpp
src/data/set.cpp
+7
-0
src/data/set.hpp
src/data/set.hpp
+4
-0
src/gui/preferences_window.cpp
src/gui/preferences_window.cpp
+1
-1
src/gui/set/window.cpp
src/gui/set/window.cpp
+3
-1
src/mse.vcproj
src/mse.vcproj
+6
-0
src/render/value/choice.cpp
src/render/value/choice.cpp
+1
-1
src/script/image.cpp
src/script/image.cpp
+19
-0
src/script/script_manager.cpp
src/script/script_manager.cpp
+25
-8
src/script/script_manager.hpp
src/script/script_manager.hpp
+1
-0
src/script/value.cpp
src/script/value.cpp
+1
-1
src/script/value.hpp
src/script/value.hpp
+8
-0
src/util/index_map.hpp
src/util/index_map.hpp
+1
-0
src/util/io/reader.hpp
src/util/io/reader.hpp
+5
-0
src/util/window_id.hpp
src/util/window_id.hpp
+14
-0
No files found.
src/data/card.cpp
View file @
263c2ca9
...
...
@@ -31,6 +31,14 @@ String Card::identification() const {
return
_
(
"TODO"
);
}
void
mark_dependency_member
(
const
CardP
&
card
,
const
String
&
name
,
const
Dependency
&
dep
)
{
// Find field with that name
IndexMap
<
FieldP
,
ValueP
>::
const_iterator
it
=
card
->
data
.
find
(
name
);
if
(
it
!=
card
->
data
.
end
())
{
(
*
it
)
->
fieldP
->
dependent_scripts
.
push_back
(
dep
);
}
}
IMPLEMENT_REFLECTION
(
Card
)
{
REFLECT
(
stylesheet
);
REFLECT
(
notes
);
...
...
src/data/card.hpp
View file @
263c2ca9
...
...
@@ -13,6 +13,8 @@
#include <util/reflect.hpp>
class
Game
;
class
Dependency
;
DECLARE_POINTER_TYPE
(
Card
);
DECLARE_POINTER_TYPE
(
Field
);
DECLARE_POINTER_TYPE
(
Value
);
DECLARE_POINTER_TYPE
(
StyleSheet
);
...
...
@@ -43,5 +45,7 @@ class Card {
DECLARE_REFLECTION
();
};
void
mark_dependency_member
(
const
CardP
&
value
,
const
String
&
name
,
const
Dependency
&
dep
);
// ----------------------------------------------------------------------------- : EOF
#endif
src/data/set.cpp
View file @
263c2ca9
...
...
@@ -95,6 +95,13 @@ void Set::validate(Version file_app_version) {
*/
}
}
void
mark_dependency_member
(
Set
*
value
,
const
String
&
name
,
const
Dependency
&
dep
)
{
// TODO
}
void
mark_dependency_member
(
const
SetP
&
value
,
const
String
&
name
,
const
Dependency
&
dep
)
{
mark_dependency_member
(
value
.
get
(),
name
,
dep
);
}
// in scripts, set.something is read from the set_info
template
<
typename
Tag
>
void
reflect_set_info_get_member
(
Tag
&
tag
,
const
IndexMap
<
FieldP
,
ValueP
>&
data
)
{}
...
...
src/data/set.hpp
View file @
263c2ca9
...
...
@@ -25,6 +25,7 @@ DECLARE_POINTER_TYPE(Value);
DECLARE_POINTER_TYPE
(
Keyword
);
class
ScriptManager
;
class
Context
;
class
Dependency
;
// ----------------------------------------------------------------------------- : Set
...
...
@@ -82,6 +83,9 @@ inline int item_count(const Set& set) {
return
(
int
)
set
.
cards
.
size
();
}
void
mark_dependency_member
(
const
SetP
&
value
,
const
String
&
name
,
const
Dependency
&
dep
);
void
mark_dependency_member
(
Set
*
value
,
const
String
&
name
,
const
Dependency
&
dep
);
// ----------------------------------------------------------------------------- : SetView
/// A 'view' of a Set, is notified when the Set is updated
...
...
src/gui/preferences_window.cpp
View file @
263c2ca9
...
...
@@ -145,7 +145,7 @@ DisplayPreferencesPage::DisplayPreferencesPage(Window* parent)
s5
->
Add
(
new
wxStaticText
(
this
,
wxID_ANY
,
_
(
"Columns: "
)),
0
,
wxALL
&
~
wxLEFT
|
wxEXPAND
,
4
);
s5
->
Add
(
columns
);
s4
->
Add
(
s5
,
0
,
wxEXPAND
|
wxALL
,
4
);
s
->
Add
(
s
,
0
,
wxEXPAND
|
wxALL
&
~
wxTOP
,
8
);
s
->
Add
(
s
4
,
0
,
wxEXPAND
|
wxALL
&
~
wxTOP
,
8
);
s
->
SetSizeHints
(
this
);
SetSizer
(
s
);
}
...
...
src/gui/set/window.cpp
View file @
263c2ca9
...
...
@@ -18,6 +18,7 @@
#include <gui/about_window.hpp>
#include <gui/update_checker.hpp>
#include <gui/new_window.hpp>
#include <gui/preferences_window.hpp>
#include <gui/icon_menu.hpp>
#include <util/window_id.hpp>
#include <data/game.hpp>
...
...
@@ -487,7 +488,8 @@ void SetWindow::onReplaceAll(wxFindDialogEvent&) {
}
void
SetWindow
::
onEditPreferences
(
wxCommandEvent
&
)
{
// SettingsWindow wnd(this);
PreferencesWindow
wnd
(
this
);
wnd
.
ShowModal
();
// if (wnd.ShowModal() == wxID_OK) {
// // render settings may have changed, notify all windows
// FOR_EACH(m, setWindows) {
...
...
src/mse.vcproj
View file @
263c2ca9
...
...
@@ -580,6 +580,12 @@
<File
RelativePath=
".\gui\drop_down_list.hpp"
>
</File>
<File
RelativePath=
".\gui\image_slice_window.cpp"
>
</File>
<File
RelativePath=
".\gui\image_slice_window.hpp"
>
</File>
<File
RelativePath=
".\gui\new_window.cpp"
>
</File>
...
...
src/render/value/choice.cpp
View file @
263c2ca9
...
...
@@ -18,7 +18,7 @@ void ChoiceValueViewer::draw(RotatedDC& dc) {
double
margin
=
0
;
if
(
style
().
render_style
&
RENDER_IMAGE
)
{
// draw image
map
<
String
,
ScriptableImage
>::
iterator
it
=
style
().
choice_images
.
find
(
value
().
value
(
));
map
<
String
,
ScriptableImage
>::
iterator
it
=
style
().
choice_images
.
find
(
cannocial_name_form
(
value
().
value
()
));
if
(
it
!=
style
().
choice_images
.
end
())
{
ScriptableImage
&
img
=
it
->
second
;
ScriptImageP
i
;
...
...
src/script/image.cpp
View file @
263c2ca9
...
...
@@ -208,6 +208,24 @@ SCRIPT_FUNCTION(set_mask) {
}
}
bool
parse_enum
(
const
String
&
,
ImageCombine
&
out
);
SCRIPT_FUNCTION
(
set_combine
)
{
if
(
last_update_age
()
==
0
)
{
SCRIPT_PARAM
(
String
,
combine
);
ScriptImageP
image
=
to_script_image
(
ctx
.
getVariable
(
_
(
"input"
)));
// parse and set combine
if
(
!
parse_enum
(
combine
,
image
->
combine
))
{
throw
ScriptError
(
_
(
"Not a valid combine mode: '"
)
+
combine
+
_
(
"'"
));
}
return
image
;
}
else
{
SCRIPT_RETURN
(
script_image_up_to_date
(
ctx
.
getVariable
(
_
(
"input"
)))
);
}
}
SCRIPT_FUNCTION
(
buildin_image
)
{
if
(
last_update_age
()
==
0
)
{
SCRIPT_PARAM
(
String
,
input
);
...
...
@@ -223,5 +241,6 @@ void init_script_image_functions(Context& ctx) {
ctx
.
setVariable
(
_
(
"linear blend"
),
script_linear_blend
);
ctx
.
setVariable
(
_
(
"masked blend"
),
script_masked_blend
);
ctx
.
setVariable
(
_
(
"set mask"
),
script_set_mask
);
ctx
.
setVariable
(
_
(
"set combine"
),
script_set_combine
);
ctx
.
setVariable
(
_
(
"buildin image"
),
script_buildin_image
);
}
src/script/script_manager.cpp
View file @
263c2ca9
...
...
@@ -12,6 +12,8 @@
#include <data/game.hpp>
#include <data/card.hpp>
#include <data/field.hpp>
#include <data/action/set.hpp>
#include <data/action/value.hpp>
#include <util/error.hpp>
typedef
map
<
const
StyleSheet
*
,
Context
*>
Contexts
;
...
...
@@ -32,7 +34,10 @@ void init_script_image_functions(Context& ctx);
ScriptManager
::
ScriptManager
(
Set
&
set
)
:
set
(
set
)
{}
{
// add as an action listener for the set, so we receive actions
set
.
actions
.
addListener
(
this
);
}
ScriptManager
::~
ScriptManager
()
{
set
.
actions
.
removeListener
(
this
);
...
...
@@ -40,8 +45,6 @@ ScriptManager::~ScriptManager() {
FOR_EACH
(
sc
,
contexts
)
{
delete
sc
.
second
;
}
// add as an action listener for the set, so we receive actions
set
.
actions
.
addListener
(
this
);
}
Context
&
ScriptManager
::
getContext
(
const
StyleSheetP
&
stylesheet
)
{
...
...
@@ -116,11 +119,19 @@ void ScriptManager::initDependencies(Context& ctx, StyleSheet& stylesheet) {
// ----------------------------------------------------------------------------- : ScriptManager : updating
void
ScriptManager
::
onAction
(
const
Action
&
action
,
bool
undone
)
{
// TODO
// TYPE_CASE(action, ValueAction) {
// }
// TYPE_CASE(action, CardListAction) {
// }
TYPE_CASE
(
action
,
ValueAction
)
{
// find the affected card
FOR_EACH
(
card
,
set
.
cards
)
{
if
(
card
->
data
.
contains
(
action
.
valueP
))
{
updateValue
(
*
action
.
valueP
,
card
);
return
;
}
}
updateValue
(
*
action
.
valueP
,
CardP
());
}
TYPE_CASE_
(
action
,
CardListAction
)
{
updateAllDependend
(
set
.
game
->
dependent_scripts_cards
);
}
}
void
ScriptManager
::
updateStyles
(
const
CardP
&
card
)
{
...
...
@@ -196,8 +207,14 @@ void ScriptManager::alsoUpdate(deque<ToUpdate>& to_update, const vector<Dependen
FOR_EACH_CONST
(
d
,
deps
)
{
switch
(
d
.
type
)
{
case
DEP_SET_FIELD
:
{
ValueP
value
=
set
.
data
.
at
(
d
.
index
);
to_update
.
push_back
(
ToUpdate
(
value
.
get
(),
CardP
()));
break
;
}
case
DEP_CARD_FIELD
:
{
if
(
card
)
{
ValueP
value
=
card
->
data
.
at
(
d
.
index
);
to_update
.
push_back
(
ToUpdate
(
value
.
get
(),
card
));
}
break
;
}
case
DEP_CARDS_FIELD
:
{
break
;
...
...
src/script/script_manager.hpp
View file @
263c2ca9
...
...
@@ -64,6 +64,7 @@ class ScriptManager : public ActionListener {
// Something that needs to be updated
struct
ToUpdate
{
ToUpdate
(
Value
*
value
,
CardP
card
)
:
value
(
value
),
card
(
card
)
{}
Value
*
value
;
///< value to update
CardP
card
;
///< card the value is in, or CadP() if it is not a card field
};
...
...
src/script/value.cpp
View file @
263c2ca9
...
...
@@ -164,7 +164,7 @@ class ScriptString : public ScriptValue {
return
l
;
}
else
if
(
value
==
_
(
"yes"
)
||
value
==
_
(
"true"
))
{
return
true
;
}
else
if
(
value
==
_
(
"no"
)
||
value
==
_
(
"false"
))
{
}
else
if
(
value
==
_
(
"no"
)
||
value
==
_
(
"false"
)
||
value
.
empty
()
)
{
return
false
;
}
else
{
throw
ScriptError
(
_
(
"Not a number: '"
)
+
value
+
_
(
"'"
));
...
...
src/script/value.hpp
View file @
263c2ca9
...
...
@@ -220,6 +220,10 @@ int item_count(const T& v) {
return
-
1
;
}
/// Mark a dependency on a member of value, can be overloaded
template
<
typename
T
>
void
mark_dependency_member
(
const
T
&
value
,
const
String
&
name
,
const
Dependency
&
dep
)
{}
/// Script value containing an object (pointer)
template
<
typename
T
>
class
ScriptObject
:
public
ScriptValue
{
...
...
@@ -245,6 +249,10 @@ class ScriptObject : public ScriptValue {
}
}
}
virtual
ScriptValueP
dependencyMember
(
const
String
&
name
,
const
Dependency
&
dep
)
const
{
mark_dependency_member
(
value
,
name
,
dep
);
return
getMember
(
name
);
}
virtual
int
itemCount
()
const
{
int
i
=
item_count
(
*
value
);
return
i
>=
0
?
i
:
ScriptValue
::
itemCount
();
...
...
src/util/index_map.hpp
View file @
263c2ca9
...
...
@@ -39,6 +39,7 @@ class IndexMap : private vector<Value> {
using
vector
<
Value
>::
const_reference
;
using
vector
<
Value
>::
begin
;
using
vector
<
Value
>::
end
;
using
vector
<
Value
>::
at
;
// for using numeric indices directly
/// Initialize this map with default values given a list of keys
/** has no effect if already initialized with the given keys */
...
...
src/util/io/reader.hpp
View file @
263c2ca9
...
...
@@ -227,6 +227,11 @@ void Reader::handle(IndexMap<K,V>& m) {
/* warning: unknown value */
\
warning
(
_
(
"Unrecognized value: "
)
+
value
);
\
}
\
}
\
bool
parse_enum
(
const
String
&
value
,
Enum
&
out
)
{
\
EnumReader
reader
(
value
);
\
reflect_
##
Enum
(
out
,
reader
);
\
return
reader
.
isDone
();
\
}
/// 'Tag' to be used when reflecting enumerations for Reader
...
...
src/util/window_id.hpp
View file @
263c2ca9
...
...
@@ -178,6 +178,20 @@ enum ControlID {
,
ID_NOTEBOOK
,
ID_APPRENTICE_BROWSE
,
ID_CHECK_UPDATES_NOW
// Image slicer
,
ID_PREVIEW
,
ID_SELECTOR
,
ID_SIZE
,
ID_LEFT
,
ID_TOP
,
ID_WIDTH
,
ID_HEIGHT
,
ID_FIX_ASPECT
,
ID_ZOOM
,
ID_ZOOM_X
,
ID_ZOOM_Y
,
ID_SHARPEN
,
ID_SHARPEN_AMOUNT
};
// ----------------------------------------------------------------------------- : EOF
...
...
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