mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-13 05:57:00 -04:00
perliminaries for filtered card list
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@152 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
DECLARE_TYPEOF_COLLECTION(GraphAxisP);
|
DECLARE_TYPEOF_COLLECTION(GraphAxisP);
|
||||||
DECLARE_TYPEOF_COLLECTION(GraphElementP);
|
DECLARE_TYPEOF_COLLECTION(GraphElementP);
|
||||||
DECLARE_TYPEOF_COLLECTION(GraphGroup);
|
DECLARE_TYPEOF_COLLECTION(GraphGroup);
|
||||||
|
DECLARE_TYPEOF_COLLECTION(int);
|
||||||
typedef map<String,UInt> map_String_UInt;
|
typedef map<String,UInt> map_String_UInt;
|
||||||
DECLARE_TYPEOF(map_String_UInt);
|
DECLARE_TYPEOF(map_String_UInt);
|
||||||
|
|
||||||
@@ -257,6 +258,19 @@ void GraphControl::onMouseDown(wxMouseEvent& ev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GraphControl::hasSelection(size_t axis) const {
|
||||||
|
return current_item.size() >= axis && current_item[axis] >= 0;
|
||||||
|
}
|
||||||
|
void GraphControl::getSelection(vector<String>& out) const {
|
||||||
|
out.clear();
|
||||||
|
if (!graph) return;
|
||||||
|
FOR_EACH_2_CONST(i, current_item, a, graph->getData().axes) {
|
||||||
|
if (i >= 0) {
|
||||||
|
out.push_back((size_t)i < a->groups.size() ? a->groups[i].name : wxEmptyString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(GraphControl, wxControl)
|
BEGIN_EVENT_TABLE(GraphControl, wxControl)
|
||||||
EVT_PAINT (GraphControl::onPaint)
|
EVT_PAINT (GraphControl::onPaint)
|
||||||
EVT_SIZE (GraphControl::onSize)
|
EVT_SIZE (GraphControl::onSize)
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ class Graph {
|
|||||||
virtual bool findItem(const RealPoint& pos, const RealRect& rect, vector<int>& out) const { return false; }
|
virtual bool findItem(const RealPoint& pos, const RealRect& rect, vector<int>& out) const { return false; }
|
||||||
/// Change the data
|
/// Change the data
|
||||||
virtual void setData(const GraphDataP& d) { data = d; }
|
virtual void setData(const GraphDataP& d) { data = d; }
|
||||||
|
/// Get the data
|
||||||
|
inline const GraphData& getData() const { return *data; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Data of the graph
|
/// Data of the graph
|
||||||
@@ -162,6 +164,11 @@ class GraphControl : public wxControl {
|
|||||||
/// Update the data in the graph
|
/// Update the data in the graph
|
||||||
void setData(const GraphDataP& data);
|
void setData(const GraphDataP& data);
|
||||||
|
|
||||||
|
/// Is there a selection on the given axis?
|
||||||
|
bool hasSelection(size_t axis) const;
|
||||||
|
/// Get the current item, returns the selected value on each axis in out
|
||||||
|
void getSelection(vector<String>& out) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Graph object
|
/// Graph object
|
||||||
GraphP graph;
|
GraphP graph;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include <wx/splitter.h>
|
#include <wx/splitter.h>
|
||||||
|
|
||||||
DECLARE_TYPEOF_COLLECTION(StatsDimensionP);
|
DECLARE_TYPEOF_COLLECTION(StatsDimensionP);
|
||||||
|
DECLARE_TYPEOF_COLLECTION(String);
|
||||||
DECLARE_TYPEOF_COLLECTION(CardP);
|
DECLARE_TYPEOF_COLLECTION(CardP);
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : StatCategoryList
|
// ----------------------------------------------------------------------------- : StatCategoryList
|
||||||
@@ -131,6 +132,24 @@ void StatsPanel::onCommand(int id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class StatsFilter : public CardListFilter {
|
||||||
|
public:
|
||||||
|
StatsFilter(Set& set, const vector<StatsDimensionP>& dims, const vector<String>& values)
|
||||||
|
: set(set), dims(dims), values(values)
|
||||||
|
{}
|
||||||
|
virtual bool keep(const CardP& card) {
|
||||||
|
Context& ctx = set.getContext(card);
|
||||||
|
FOR_EACH_2(d, dims, v, values) {
|
||||||
|
if (*d->script.invoke(ctx) != v) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
Set& set;
|
||||||
|
vector<StatsDimensionP> dims;
|
||||||
|
vector<String> values;
|
||||||
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Selection
|
// ----------------------------------------------------------------------------- : Selection
|
||||||
|
|
||||||
CardP StatsPanel::selectedCard() const {
|
CardP StatsPanel::selectedCard() const {
|
||||||
|
|||||||
Reference in New Issue
Block a user