Added support for custom colors for graphs;

Moved 'choice colors' from styel to field, split into 'choice colors' and 'choice colors cardlist';
Added support for pie graphs (no gui to use them, though);
Fixed bugs caused by selecting a card before the set was changed on all panels.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@336 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-05-11 14:10:29 +00:00
parent f9eade95eb
commit 3b6743b110
33 changed files with 634 additions and 186 deletions
+5
View File
@@ -340,3 +340,8 @@ void CardsPanel::selectCard(const CardP& card) {
notes->setValue(card ? &card->notes : nullptr);
Layout();
}
void CardsPanel::selectFirstCard() {
if (!set) return; // we want onChangeSet first
card_list->selectFirst();
}
+1
View File
@@ -68,6 +68,7 @@ class CardsPanel : public SetWindowPanel {
// --------------------------------------------------- : Selection
virtual CardP selectedCard() const;
virtual void selectCard(const CardP& card);
virtual void selectFirstCard();
private:
// --------------------------------------------------- : Controls
+1
View File
@@ -68,6 +68,7 @@ class SetWindowPanel : public wxPanel, public SetView {
// --------------------------------------------------- : Selection
virtual CardP selectedCard() const { return CardP(); } ///< Return the currently selected card, or CardP()
virtual void selectCard(const CardP& card) {} ///< Switch the view to another card
virtual void selectFirstCard() {} ///< Switch the view to the first card
};
// ----------------------------------------------------------------------------- : EOF
+40 -21
View File
@@ -14,6 +14,7 @@
#include <data/statistics.hpp>
#include <util/window_id.hpp>
#include <util/alignment.hpp>
#include <util/tagged_string.hpp>
#include <gfx/gfx.hpp>
#include <wx/splitter.h>
@@ -52,6 +53,8 @@ class StatCategoryList : public GalleryList {
void StatCategoryList::show(const GameP& game) {
this->game = game;
update();
// select first item
selection = itemCount() > 0 ? 0 : NO_SELECTION;
}
size_t StatCategoryList::itemCount() const {
@@ -74,13 +77,11 @@ void StatCategoryList::drawItem(DC& dc, int x, int y, size_t item, bool selected
// draw name
RealRect rect(RealPoint(x + 24, y), RealSize(item_size.x - 30, item_size.y));
String str = capitalize(cat.name);
// dc.SetFont(wxFont(9.5 * text_scaling, wxSWISS, wxNORMAL, wxNORMAL, false,_("Arial")));
dc.SetFont(*wxNORMAL_FONT);
int w, h;
dc.GetTextExtent(str, &w, &h);
RealSize size = RealSize(w,h);
RealPoint pos = align_in_rect(ALIGN_MIDDLE_LEFT, size, rect);
// draw_resampled_text(dc, RealRect(pos, size), 0, 0, 0, str);
dc.DrawText(str, (int)pos.x, (int)pos.y);
}
@@ -110,30 +111,13 @@ StatsPanel::StatsPanel(Window* parent, int id)
void StatsPanel::onChangeSet() {
card_list->setSet(set);
categories->show(set->game);
filterCards();
onCategorySelect();
}
void StatsPanel::onCommand(int id) {
switch (id) {
case ID_FIELD_LIST: {
// change graph data
if (categories->hasSelection()) {
StatsCategory& cat = categories->getSelection();
GraphDataPre d;
FOR_EACH(dim, cat.dimensions) {
d.axes.push_back(new_shared3<GraphAxis>(dim->name, true, dim->numeric));
}
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);
filterCards();
}
onCategorySelect();
break;
}
}
@@ -158,6 +142,41 @@ class StatsFilter : public CardListFilter {
Set& set;
};
void StatsPanel::onCategorySelect() {
// change graph data
if (categories->hasSelection()) {
StatsCategory& cat = categories->getSelection();
GraphDataPre d;
FOR_EACH(dim, cat.dimensions) {
d.axes.push_back(new_shared4<GraphAxis>(
dim->name,
dim->colors.empty() ? AUTO_COLOR_EVEN : AUTO_COLOR_NO,
dim->numeric,
&dim->colors
)
);
}
FOR_EACH(card, set->cards) {
Context& ctx = set->getContext(card);
GraphElementP e(new GraphElement);
bool show = true;
FOR_EACH(dim, cat.dimensions) {
String value = untag(dim->script.invoke(ctx)->toString());
e->values.push_back(value);
if (value.empty() && !dim->show_empty) {
// don't show this element
show = false;
break;
}
}
if (show) {
d.elements.push_back(e);
}
}
graph->setData(d);
filterCards();
}
}
void StatsPanel::onGraphSelect(wxCommandEvent&) {
filterCards();
}
+1
View File
@@ -40,6 +40,7 @@ class StatsPanel : public SetWindowPanel {
GraphControl* graph;
FilteredCardList* card_list;
void onCategorySelect();
void onGraphSelect(wxCommandEvent&);
void filterCards();
};
+1 -1
View File
@@ -77,7 +77,7 @@ void StylePanel::selectCard(const CardP& card) {
// ----------------------------------------------------------------------------- : Events
void StylePanel::onStyleSelect(wxCommandEvent&) {
if (list->hasSelection()) {
if (list->hasSelection() && card) {
StyleSheetP stylesheet = list->getSelection<StyleSheet>();
if (stylesheet == set->stylesheet) {
// select no special style when selecting the same style as the set default
+10 -9
View File
@@ -131,15 +131,12 @@ SetWindow::SetWindow(Window* parent, const SetP& set)
SetSizer(s);
// panels
// NOTE: place the CardsPanel last in the panels list,
// this way the card list is the last to be told of a set change
// this way everyone else already uses the new set when it sends a CardSelectEvent
addPanel(menuWindow, tabBar, new CardsPanel (this, wxID_ANY), 4, _("cards tab"));
addPanel(menuWindow, tabBar, new SetInfoPanel (this, wxID_ANY), 0, _("set info tab"));
addPanel(menuWindow, tabBar, new StylePanel (this, wxID_ANY), 1, _("style tab"));
addPanel(menuWindow, tabBar, new KeywordsPanel(this, wxID_ANY), 2, _("keywords tab"));
addPanel(menuWindow, tabBar, new StatsPanel (this, wxID_ANY), 3, _("stats tab"));
// addPanel(*s, *menuWindow, *tabBar, new DraftPanel (&this, wxID_ANY), 4, _("F10"))
addPanel(menuWindow, tabBar, new CardsPanel (this, wxID_ANY), 0, _("cards tab"));
addPanel(menuWindow, tabBar, new SetInfoPanel (this, wxID_ANY), 1, _("set info tab"));
addPanel(menuWindow, tabBar, new StylePanel (this, wxID_ANY), 2, _("style tab"));
addPanel(menuWindow, tabBar, new KeywordsPanel(this, wxID_ANY), 3, _("keywords tab"));
addPanel(menuWindow, tabBar, new StatsPanel (this, wxID_ANY), 4, _("stats tab"));
// addPanel(*s, *menuWindow, *tabBar, new DraftPanel (&this, wxID_ANY), 5, _("F10"))
selectPanel(ID_WINDOW_CARDS); // select cards panel
// loose ends
@@ -241,6 +238,10 @@ void SetWindow::onChangeSet() {
FOR_EACH(p, panels) {
p->setSet(set);
}
// only after setSet select a card
FOR_EACH(p, panels) {
p->selectFirstCard();
}
fixMinWindowSize();
}