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
16b99249
Commit
16b99249
authored
Aug 03, 2008
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented seed controls on random pack panel;
seed settings and pack amounts are stored in settings
parent
03b72c52
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
113 additions
and
16 deletions
+113
-16
src/data/settings.cpp
src/data/settings.cpp
+5
-0
src/data/settings.hpp
src/data/settings.hpp
+3
-0
src/gui/set/random_pack_panel.cpp
src/gui/set/random_pack_panel.cpp
+86
-16
src/gui/set/random_pack_panel.hpp
src/gui/set/random_pack_panel.hpp
+11
-0
src/gui/set/window.cpp
src/gui/set/window.cpp
+2
-0
src/util/window_id.hpp
src/util/window_id.hpp
+6
-0
No files found.
src/data/settings.cpp
View file @
16b99249
...
@@ -76,6 +76,8 @@ GameSettings::GameSettings()
...
@@ -76,6 +76,8 @@ GameSettings::GameSettings()
,
images_export_conflicts
(
CONFLICT_NUMBER_OVERWRITE
)
,
images_export_conflicts
(
CONFLICT_NUMBER_OVERWRITE
)
,
use_auto_replace
(
true
)
,
use_auto_replace
(
true
)
,
initialized
(
false
)
,
initialized
(
false
)
,
pack_seed_random
(
true
)
,
pack_seed
(
123456
)
{}
{}
void
GameSettings
::
initDefaults
(
const
Game
&
game
)
{
void
GameSettings
::
initDefaults
(
const
Game
&
game
)
{
...
@@ -110,6 +112,9 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(GameSettings) {
...
@@ -110,6 +112,9 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(GameSettings) {
REFLECT
(
images_export_conflicts
);
REFLECT
(
images_export_conflicts
);
REFLECT
(
use_auto_replace
);
REFLECT
(
use_auto_replace
);
REFLECT
(
auto_replaces
);
REFLECT
(
auto_replaces
);
REFLECT
(
pack_amounts
);
REFLECT
(
pack_seed_random
);
REFLECT
(
pack_seed
);
}
}
...
...
src/data/settings.hpp
View file @
16b99249
...
@@ -82,6 +82,9 @@ class GameSettings : public IntrusivePtrBase<GameSettings> {
...
@@ -82,6 +82,9 @@ class GameSettings : public IntrusivePtrBase<GameSettings> {
FilenameConflicts
images_export_conflicts
;
FilenameConflicts
images_export_conflicts
;
bool
use_auto_replace
;
bool
use_auto_replace
;
vector
<
AutoReplaceP
>
auto_replaces
;
///< Things to autoreplace in textboxes
vector
<
AutoReplaceP
>
auto_replaces
;
///< Things to autoreplace in textboxes
map
<
String
,
int
>
pack_amounts
;
bool
pack_seed_random
;
int
pack_seed
;
DECLARE_REFLECTION
();
DECLARE_REFLECTION
();
private:
private:
...
...
src/gui/set/random_pack_panel.cpp
View file @
16b99249
...
@@ -13,7 +13,10 @@
...
@@ -13,7 +13,10 @@
#include <gui/control/filtered_card_list.hpp>
#include <gui/control/filtered_card_list.hpp>
#include <data/game.hpp>
#include <data/game.hpp>
#include <data/pack.hpp>
#include <data/pack.hpp>
#include <data/settings.hpp>
#include <util/window_id.hpp>
#include <wx/spinctrl.h>
#include <wx/spinctrl.h>
#include <boost/random/mersenne_twister.hpp>
DECLARE_TYPEOF_COLLECTION
(
PackTypeP
);
DECLARE_TYPEOF_COLLECTION
(
PackTypeP
);
DECLARE_TYPEOF_COLLECTION
(
CardP
);
DECLARE_TYPEOF_COLLECTION
(
CardP
);
...
@@ -71,9 +74,9 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id)
...
@@ -71,9 +74,9 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id)
// init controls
// init controls
preview
=
new
CardViewer
(
this
,
wxID_ANY
);
preview
=
new
CardViewer
(
this
,
wxID_ANY
);
card_list
=
new
FilteredCardList
(
this
,
wxID_ANY
);
card_list
=
new
FilteredCardList
(
this
,
wxID_ANY
);
wxButton
*
generate
=
new
wxButton
(
this
,
wxID_ANY
,
_BUTTON_
(
"generate pack"
));
generate_button
=
new
wxButton
(
this
,
ID_GENERATE_PACK
,
_BUTTON_
(
"generate pack"
));
wxRadioButton
*
seed_random
=
new
wxRadioButton
(
this
,
wxID_ANY
,
_BUTTON_
(
"random seed"
));
seed_random
=
new
wxRadioButton
(
this
,
ID_SEED_RANDOM
,
_BUTTON_
(
"random seed"
));
wxRadioButton
*
seed_fixed
=
new
wxRadioButton
(
this
,
wxID_ANY
,
_BUTTON_
(
"fixed seed"
));
seed_fixed
=
new
wxRadioButton
(
this
,
ID_SEED_FIXED
,
_BUTTON_
(
"fixed seed"
));
seed
=
new
wxTextCtrl
(
this
,
wxID_ANY
);
seed
=
new
wxTextCtrl
(
this
,
wxID_ANY
);
static_cast
<
SetWindow
*>
(
parent
)
->
setControlStatusText
(
seed_random
,
_HELP_
(
"random seed"
));
static_cast
<
SetWindow
*>
(
parent
)
->
setControlStatusText
(
seed_random
,
_HELP_
(
"random seed"
));
static_cast
<
SetWindow
*>
(
parent
)
->
setControlStatusText
(
seed_fixed
,
_HELP_
(
"fixed seed"
));
static_cast
<
SetWindow
*>
(
parent
)
->
setControlStatusText
(
seed_fixed
,
_HELP_
(
"fixed seed"
));
...
@@ -100,8 +103,8 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id)
...
@@ -100,8 +103,8 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id)
s7
->
Add
(
s8
,
0
,
wxALL
&
~
wxTOP
,
4
);
s7
->
Add
(
s8
,
0
,
wxALL
&
~
wxTOP
,
4
);
s6
->
Add
(
s7
,
0
,
0
,
8
);
s6
->
Add
(
s7
,
0
,
0
,
8
);
//s6->AddStretchSpacer();
//s6->AddStretchSpacer();
//s6->Add(generate, 0, wxTOP | wxALIGN_RIGHT, 8);
//s6->Add(generate
_button
, 0, wxTOP | wxALIGN_RIGHT, 8);
s6
->
Add
(
generate
,
1
,
wxTOP
|
wxEXPAND
,
8
);
s6
->
Add
(
generate
_button
,
1
,
wxTOP
|
wxEXPAND
,
8
);
s3
->
Add
(
s6
,
0
,
wxEXPAND
|
wxLEFT
,
8
);
s3
->
Add
(
s6
,
0
,
wxEXPAND
|
wxLEFT
,
8
);
s2
->
Add
(
s3
,
0
,
wxEXPAND
|
wxALL
&
~
wxTOP
,
4
);
s2
->
Add
(
s3
,
0
,
wxEXPAND
|
wxALL
&
~
wxTOP
,
4
);
s2
->
Add
(
card_list
,
1
,
wxEXPAND
);
s2
->
Add
(
card_list
,
1
,
wxEXPAND
);
...
@@ -110,7 +113,12 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id)
...
@@ -110,7 +113,12 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id)
SetSizer
(
s
);
SetSizer
(
s
);
}
}
RandomPackPanel
::~
RandomPackPanel
()
{
storeSettings
();
}
void
RandomPackPanel
::
onChangeSet
()
{
void
RandomPackPanel
::
onChangeSet
()
{
storeSettings
();
preview
->
setSet
(
set
);
preview
->
setSet
(
set
);
card_list
->
setSet
(
set
);
card_list
->
setSet
(
set
);
...
@@ -128,36 +136,98 @@ void RandomPackPanel::onChangeSet() {
...
@@ -128,36 +136,98 @@ void RandomPackPanel::onChangeSet() {
PackItem
i
;
PackItem
i
;
i
.
pack
=
pack
;
i
.
pack
=
pack
;
i
.
label
=
new
wxStaticText
(
this
,
wxID_ANY
,
pack
->
name
);
i
.
label
=
new
wxStaticText
(
this
,
wxID_ANY
,
pack
->
name
);
i
.
value
=
new
wxSpinCtrl
(
this
,
wxID_ANY
,
_
(
"0"
),
wxDefaultPosition
,
wxSize
(
50
,
-
1
));
i
.
value
=
new
wxSpinCtrl
(
this
,
ID_PACK_AMOUNT
,
_
(
"0"
),
wxDefaultPosition
,
wxSize
(
50
,
-
1
));
packsSizer
->
Add
(
i
.
label
,
0
,
wxALIGN_CENTER_VERTICAL
);
packsSizer
->
Add
(
i
.
label
,
0
,
wxALIGN_CENTER_VERTICAL
);
packsSizer
->
Add
(
i
.
value
,
0
,
wxEXPAND
|
wxALIGN_CENTER
);
packsSizer
->
Add
(
i
.
value
,
0
,
wxEXPAND
|
wxALIGN_CENTER
);
packs
.
push_back
(
i
);
packs
.
push_back
(
i
);
}
}
Layout
();
Layout
();
// settings
GameSettings
&
gs
=
settings
.
gameSettingsFor
(
*
set
->
game
);
seed_random
->
SetValue
(
gs
.
pack_seed_random
);
seed_fixed
->
SetValue
(
!
gs
.
pack_seed_random
);
seed
->
Enable
(
!
gs
.
pack_seed_random
);
setSeed
(
gs
.
pack_seed
);
FOR_EACH
(
i
,
packs
)
{
i
.
value
->
SetValue
(
gs
.
pack_amounts
[
i
.
pack
->
name
]);
}
updateTotals
();
}
void
RandomPackPanel
::
storeSettings
()
{
GameSettings
&
gs
=
settings
.
gameSettingsFor
(
*
set
->
game
);
gs
.
pack_seed_random
=
seed_random
->
GetValue
();
FOR_EACH
(
i
,
packs
)
{
gs
.
pack_amounts
[
i
.
pack
->
name
]
=
i
.
value
->
GetValue
();
}
}
}
// ----------------------------------------------------------------------------- : UI
// ----------------------------------------------------------------------------- : UI
void
RandomPackPanel
::
initUI
(
wxToolBar
*
tb
,
wxMenuBar
*
mb
)
{
void
RandomPackPanel
::
initUI
(
wxToolBar
*
tb
,
wxMenuBar
*
mb
)
{}
// ?
}
void
RandomPackPanel
::
destroyUI
(
wxToolBar
*
tb
,
wxMenuBar
*
mb
)
{
void
RandomPackPanel
::
destroyUI
(
wxToolBar
*
tb
,
wxMenuBar
*
mb
)
{}
// ?
}
void
RandomPackPanel
::
onUpdateUI
(
wxUpdateUIEvent
&
ev
)
{
void
RandomPackPanel
::
onUpdateUI
(
wxUpdateUIEvent
&
ev
)
{}
// ?
}
void
RandomPackPanel
::
onCommand
(
int
id
)
{
void
RandomPackPanel
::
onCommand
(
int
id
)
{
// ?
switch
(
id
)
{
case
ID_PACK_AMOUNT
:
{
updateTotals
();
break
;
}
case
ID_GENERATE_PACK
:
{
generate
();
break
;
}
case
ID_SEED_RANDOM
:
case
ID_SEED_FIXED
:
{
seed
->
Enable
(
seed_fixed
->
GetValue
());
break
;
}
}
}
}
// ----------------------------------------------------------------------------- : Generating
// ----------------------------------------------------------------------------- : Generating
void
RandomPackPanel
::
updateTotals
()
{
total_packs
=
0
;
FOR_EACH
(
i
,
packs
)
{
total_packs
+=
i
.
value
->
GetValue
();
}
// update UI
generate_button
->
Enable
(
total_packs
>
0
);
}
int
RandomPackPanel
::
getSeed
()
{
// determine seed value
int
seed
=
0
;
if
(
seed_random
->
GetValue
())
{
// use the C rand() function to get a seed
seed
=
rand
()
%
1000
*
1000
+
clock
()
%
1000
;
}
else
{
// convert *any* string to a number
String
s
=
this
->
seed
->
GetValue
();
FOR_EACH_CONST
(
c
,
s
)
{
seed
*=
10
;
seed
+=
abs
(
c
-
'0'
)
+
123456789
*
(
abs
(
c
-
'0'
)
/
10
);
}
}
setSeed
(
seed
);
return
seed
;
}
void
RandomPackPanel
::
setSeed
(
int
seed
)
{
seed
%=
1000000
;
this
->
seed
->
SetValue
(
wxString
::
Format
(
_
(
"%06d"
),
seed
));
GameSettings
&
gs
=
settings
.
gameSettingsFor
(
*
set
->
game
);
gs
.
pack_seed
=
seed
;
}
void
RandomPackPanel
::
generate
()
{
void
RandomPackPanel
::
generate
()
{
boost
::
mt19937
random
((
unsigned
)
getSeed
());
//set->game->pack_types[0].generate()
//set->game->pack_types[0].generate()
}
}
...
...
src/gui/set/random_pack_panel.hpp
View file @
16b99249
...
@@ -23,6 +23,7 @@ DECLARE_POINTER_TYPE(PackType);
...
@@ -23,6 +23,7 @@ DECLARE_POINTER_TYPE(PackType);
class
RandomPackPanel
:
public
SetWindowPanel
{
class
RandomPackPanel
:
public
SetWindowPanel
{
public:
public:
RandomPackPanel
(
Window
*
parent
,
int
id
);
RandomPackPanel
(
Window
*
parent
,
int
id
);
~
RandomPackPanel
();
// --------------------------------------------------- : UI
// --------------------------------------------------- : UI
...
@@ -44,6 +45,8 @@ class RandomPackPanel : public SetWindowPanel {
...
@@ -44,6 +45,8 @@ class RandomPackPanel : public SetWindowPanel {
wxTextCtrl
*
seed
;
///< Seed value
wxTextCtrl
*
seed
;
///< Seed value
wxFlexGridSizer
*
packsSizer
;
wxFlexGridSizer
*
packsSizer
;
wxFlexGridSizer
*
totalsSizer
;
wxFlexGridSizer
*
totalsSizer
;
wxButton
*
generate_button
;
wxRadioButton
*
seed_random
,
*
seed_fixed
;
struct
PackItem
{
struct
PackItem
{
PackTypeP
pack
;
PackTypeP
pack
;
...
@@ -55,9 +58,17 @@ class RandomPackPanel : public SetWindowPanel {
...
@@ -55,9 +58,17 @@ class RandomPackPanel : public SetWindowPanel {
struct
TotalItem
{
struct
TotalItem
{
};
};
vector
<
TotalItem
>
totals
;
vector
<
TotalItem
>
totals
;
int
total_packs
;
/// Update the total count of each card type
void
updateTotals
();
/// Get a seed value
int
getSeed
();
void
setSeed
(
int
seed
);
/// Generate the cards
/// Generate the cards
void
generate
();
void
generate
();
/// Store the settings
void
storeSettings
();
public:
public:
typedef
PackItem
PackItem_for_typeof
;
typedef
PackItem
PackItem_for_typeof
;
};
};
...
...
src/gui/set/window.cpp
View file @
16b99249
...
@@ -771,6 +771,8 @@ BEGIN_EVENT_TABLE(SetWindow, wxFrame)
...
@@ -771,6 +771,8 @@ BEGIN_EVENT_TABLE(SetWindow, wxFrame)
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_COMMAND_RANGE
(
ID_CHILD_MIN
,
ID_CHILD_MAX
,
wxEVT_COMMAND_BUTTON_CLICKED
,
SetWindow
::
onChildMenu
)
EVT_COMMAND_RANGE
(
ID_CHILD_MIN
,
ID_CHILD_MAX
,
wxEVT_COMMAND_BUTTON_CLICKED
,
SetWindow
::
onChildMenu
)
EVT_COMMAND_RANGE
(
ID_CHILD_MIN
,
ID_CHILD_MAX
,
wxEVT_COMMAND_SPINCTRL_UPDATED
,
SetWindow
::
onChildMenu
)
EVT_COMMAND_RANGE
(
ID_CHILD_MIN
,
ID_CHILD_MAX
,
wxEVT_COMMAND_RADIOBUTTON_SELECTED
,
SetWindow
::
onChildMenu
)
EVT_GALLERY_SELECT
(
ID_FIELD_LIST
,
SetWindow
::
onChildMenu
)
// for StatsPanel, because it is not a EVT_TOOL
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
)
...
...
src/util/window_id.hpp
View file @
16b99249
...
@@ -190,6 +190,12 @@ enum ChildMenuID {
...
@@ -190,6 +190,12 @@ enum ChildMenuID {
// Statistics panel
// Statistics panel
,
ID_FIELD_LIST
=
3031
,
ID_FIELD_LIST
=
3031
// Random pack panel
,
ID_PACK_AMOUNT
=
3041
,
ID_SEED_RANDOM
,
ID_SEED_FIXED
,
ID_GENERATE_PACK
// SymbolFont (Format menu)
// SymbolFont (Format menu)
,
ID_INSERT_SYMBOL_MENU_MIN
=
3301
,
ID_INSERT_SYMBOL_MENU_MIN
=
3301
,
ID_INSERT_SYMBOL_MENU_MAX
=
3999
,
ID_INSERT_SYMBOL_MENU_MAX
=
3999
...
...
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