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
ce99e785
Commit
ce99e785
authored
Aug 04, 2008
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pack totals on random pack panel
parent
c9eecc04
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
5 deletions
+79
-5
data/magic.mse-game/game
data/magic.mse-game/game
+3
-0
src/gui/set/random_pack_panel.cpp
src/gui/set/random_pack_panel.cpp
+74
-2
src/gui/set/random_pack_panel.hpp
src/gui/set/random_pack_panel.hpp
+2
-3
No files found.
data/magic.mse-game/game
View file @
ce99e785
...
...
@@ -1844,6 +1844,9 @@ pack item:
pack item:
name: rare
filter: card.rarity == "rare"
pack item:
name: special
filter: card.rarity == "special"
pack item:
name: basic land
filter: card.type == "Plains"
...
...
src/gui/set/random_pack_panel.cpp
View file @
ce99e785
...
...
@@ -15,10 +15,13 @@
#include <data/pack.hpp>
#include <data/settings.hpp>
#include <util/window_id.hpp>
#include <wx/spinctrl.h>
#include <boost/random/mersenne_twister.hpp>
#include <wx/spinctrl.h>
#include <wx/dcbuffer.h>
DECLARE_TYPEOF_COLLECTION
(
PackTypeP
);
DECLARE_TYPEOF_COLLECTION
(
PackItemP
);
DECLARE_TYPEOF_COLLECTION
(
PackItemRefP
);
DECLARE_TYPEOF_COLLECTION
(
CardP
);
DECLARE_TYPEOF_COLLECTION
(
RandomPackPanel
::
PackItem_for_typeof
);
...
...
@@ -68,6 +71,68 @@ void RandomCardList::getItems(vector<VoidP>& out) const {
}
// ----------------------------------------------------------------------------- : PackTotalsPanel
class
PackTotalsPanel
:
public
wxPanel
{
public:
PackTotalsPanel
(
Window
*
parent
,
int
id
)
:
wxPanel
(
parent
,
id
)
{}
void
setGame
(
const
GameP
&
game
);
void
clear
();
void
addPack
(
PackType
&
pack
,
int
copies
);
void
addItemRef
(
PackItemRef
&
item
,
int
copies
);
private:
DECLARE_EVENT_TABLE
();
GameP
game
;
void
onPaint
(
wxPaintEvent
&
);
void
draw
(
DC
&
dc
);
map
<
String
,
int
>
amounts
;
};
void
PackTotalsPanel
::
onPaint
(
wxPaintEvent
&
)
{
wxBufferedPaintDC
dc
(
this
);
draw
(
dc
);
}
void
PackTotalsPanel
::
draw
(
DC
&
dc
)
{
// clear background
dc
.
SetPen
(
*
wxTRANSPARENT_PEN
);
dc
.
SetBrush
(
wxSystemSettings
::
GetColour
(
wxSYS_COLOUR_3DFACE
));
wxSize
size
=
dc
.
GetSize
();
dc
.
DrawRectangle
(
0
,
0
,
size
.
x
,
size
.
y
);
// draw table
dc
.
SetTextForeground
(
wxSystemSettings
::
GetColour
(
wxSYS_COLOUR_BTNTEXT
));
dc
.
SetFont
(
*
wxNORMAL_FONT
);
int
y
=
0
;
FOR_EACH
(
item
,
game
->
pack_items
)
{
int
w
,
h
;
String
name
=
capitalize
(
item
->
name
);
String
amount
;
amount
<<
amounts
[
item
->
name
];
dc
.
GetTextExtent
(
amount
,
&
w
,
&
h
);
dc
.
DrawText
(
name
,
0
,
y
);
dc
.
DrawText
(
amount
,
size
.
x
-
w
,
y
);
//align right
y
+=
h
+
10
;
}
}
void
PackTotalsPanel
::
setGame
(
const
GameP
&
game
)
{
this
->
game
=
game
;
clear
();
}
void
PackTotalsPanel
::
clear
()
{
amounts
.
clear
();
}
void
PackTotalsPanel
::
addPack
(
PackType
&
pack
,
int
copies
)
{
FOR_EACH
(
item
,
pack
.
items
)
{
addItemRef
(
*
item
,
copies
*
item
->
amount
);
}
}
void
PackTotalsPanel
::
addItemRef
(
PackItemRef
&
item
,
int
copies
)
{
amounts
[
item
.
name
]
+=
copies
;
}
BEGIN_EVENT_TABLE
(
PackTotalsPanel
,
wxPanel
)
EVT_PAINT
(
PackTotalsPanel
::
onPaint
)
END_EVENT_TABLE
()
// ----------------------------------------------------------------------------- : RandomPackPanel
RandomPackPanel
::
RandomPackPanel
(
Window
*
parent
,
int
id
)
...
...
@@ -80,6 +145,7 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id)
seed_random
=
new
wxRadioButton
(
this
,
ID_SEED_RANDOM
,
_BUTTON_
(
"random seed"
));
seed_fixed
=
new
wxRadioButton
(
this
,
ID_SEED_FIXED
,
_BUTTON_
(
"fixed seed"
));
seed
=
new
wxTextCtrl
(
this
,
wxID_ANY
);
totals
=
new
PackTotalsPanel
(
this
,
wxID_ANY
);
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
,
_HELP_
(
"seed"
));
...
...
@@ -95,6 +161,7 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id)
s4
->
Add
(
packsSizer
,
1
,
wxEXPAND
|
wxALL
&
~
wxTOP
,
4
);
s3
->
Add
(
s4
,
1
,
wxEXPAND
,
8
);
wxSizer
*
s5
=
new
wxStaticBoxSizer
(
wxHORIZONTAL
,
this
,
_LABEL_
(
"pack totals"
));
s5
->
Add
(
totals
,
1
,
wxEXPAND
|
wxALL
,
4
);
s3
->
Add
(
s5
,
1
,
wxEXPAND
|
wxLEFT
,
8
);
wxSizer
*
s6
=
new
wxBoxSizer
(
wxVERTICAL
);
wxSizer
*
s7
=
new
wxStaticBoxSizer
(
wxVERTICAL
,
this
,
_LABEL_
(
"seed"
));
...
...
@@ -123,6 +190,7 @@ void RandomPackPanel::onChangeSet() {
storeSettings
();
preview
->
setSet
(
set
);
card_list
->
setSet
(
set
);
totals
->
setGame
(
set
->
game
);
// remove old pack controls
FOR_EACH
(
i
,
packs
)
{
...
...
@@ -195,11 +263,15 @@ void RandomPackPanel::onCommand(int id) {
// ----------------------------------------------------------------------------- : Generating
void
RandomPackPanel
::
updateTotals
()
{
totals
->
clear
();
total_packs
=
0
;
FOR_EACH
(
i
,
packs
)
{
total_packs
+=
i
.
value
->
GetValue
();
int
copies
=
i
.
value
->
GetValue
();
total_packs
+=
copies
;
totals
->
addPack
(
*
i
.
pack
,
copies
);
}
// update UI
totals
->
Refresh
(
false
);
generate_button
->
Enable
(
total_packs
>
0
);
}
...
...
src/gui/set/random_pack_panel.hpp
View file @
ce99e785
...
...
@@ -15,6 +15,7 @@
class
CardViewer
;
class
RandomCardList
;
class
PackTotalsPanel
;
DECLARE_POINTER_TYPE
(
PackType
);
// ----------------------------------------------------------------------------- : RandomPackPanel
...
...
@@ -50,6 +51,7 @@ class RandomPackPanel : public SetWindowPanel {
wxFlexGridSizer
*
totalsSizer
;
wxButton
*
generate_button
;
wxRadioButton
*
seed_random
,
*
seed_fixed
;
PackTotalsPanel
*
totals
;
struct
PackItem
{
PackTypeP
pack
;
...
...
@@ -58,9 +60,6 @@ class RandomPackPanel : public SetWindowPanel {
};
vector
<
PackItem
>
packs
;
struct
TotalItem
{
};
vector
<
TotalItem
>
totals
;
int
total_packs
;
/// Update the total count of each card type
...
...
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