mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 21:47:00 -04:00
Merge pull request #1 from haganbmj/style_filtering
feat: game/stylesheet filtering
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.cpp]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
trim_trailing_whitespace = true
|
||||||
+12
-1
@@ -1,6 +1,17 @@
|
|||||||
Magic Set Editor changelog, for the details see `git log`
|
Magic Set Editor changelog, for the details see `git log`
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
|
FORK: Changes isolated to this fork
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Features:
|
||||||
|
* Independently control Export Zoom setting in Preferences Window.
|
||||||
|
* Center the loaded image by default in the Image Slice Window.
|
||||||
|
* Add Button to Center the loaded image in the Image Slice Window.
|
||||||
|
* Add "Created At", "Last Modified At", "Has Notes" columns to card list.
|
||||||
|
* Add filter box to Game and Stylesheet selection.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
HEAD: new items added as changes are made
|
HEAD: new items added as changes are made
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
project(magicseteditor VERSION 2.1.3)
|
project(magicseteditor VERSION 2.2.0)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||||
|
|||||||
@@ -212,6 +212,10 @@ help:
|
|||||||
website:
|
website:
|
||||||
about:
|
about:
|
||||||
|
|
||||||
|
# New Set Window
|
||||||
|
search game list control: Filter the game list. Use - to exclude games. Use field: to search in a specific field. Use quotes for literal search. Separate multiple queries with a space.
|
||||||
|
search stylesheet list control: Filter the stylesheet list. Use - to exclude styles. Use field: to search in a specific field. Use quotes for literal search. Separate multiple queries with a space.
|
||||||
|
|
||||||
# Cards panel
|
# Cards panel
|
||||||
collapse notes: Hide the card notes box
|
collapse notes: Hide the card notes box
|
||||||
expand notes: Show the card notes box
|
expand notes: Show the card notes box
|
||||||
@@ -461,6 +465,8 @@ label:
|
|||||||
# New set window
|
# New set window
|
||||||
game type: &Game type:
|
game type: &Game type:
|
||||||
style type: &Card style:
|
style type: &Card style:
|
||||||
|
search game list : Filter Games
|
||||||
|
search stylesheet list: Filter Stylesheets
|
||||||
|
|
||||||
stylesheet not found :
|
stylesheet not found :
|
||||||
The set you are trying to open uses the stylesheet "%s".
|
The set you are trying to open uses the stylesheet "%s".
|
||||||
|
|||||||
@@ -13,6 +13,12 @@
|
|||||||
#include <script/profiler.hpp>
|
#include <script/profiler.hpp>
|
||||||
#include <gui/util.hpp>
|
#include <gui/util.hpp>
|
||||||
|
|
||||||
|
bool PackageData::contains(QuickFilterPart const& query) const {
|
||||||
|
if (query.match(_("full_name"), package->full_name)) return true;
|
||||||
|
if (query.match(_("short_name"), package->short_name)) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : PackageList
|
// ----------------------------------------------------------------------------- : PackageList
|
||||||
|
|
||||||
PackageList::PackageList(Window* parent, int id, int direction, bool always_focused)
|
PackageList::PackageList(Window* parent, int id, int direction, bool always_focused)
|
||||||
@@ -23,29 +29,29 @@ PackageList::PackageList(Window* parent, int id, int direction, bool always_focu
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t PackageList::itemCount() const {
|
size_t PackageList::itemCount() const {
|
||||||
return packages.size();
|
return filtered_packages.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackageList::drawItem(DC& dc, int x, int y, size_t item) {
|
void PackageList::drawItem(DC& dc, int x, int y, size_t item) {
|
||||||
dc.SetClippingRegion(x+1, y+2, item_size.x-2, item_size.y-2);
|
dc.SetClippingRegion(x+1, y+2, item_size.x-2, item_size.y-2);
|
||||||
PackageData& d = packages.at(item);
|
PackageDataP& d = filtered_packages.at(item);
|
||||||
RealRect rect(RealPoint(x,y),item_size);
|
RealRect rect(RealPoint(x,y),item_size);
|
||||||
RealPoint pos;
|
RealPoint pos;
|
||||||
int w, h;
|
int w, h;
|
||||||
// draw image
|
// draw image
|
||||||
if (d.image.Ok()) {
|
if (d->image.Ok()) {
|
||||||
dc.DrawBitmap(d.image, x + int(align_delta_x(ALIGN_CENTER, item_size.x, d.image.GetWidth())), y + 3, true);
|
dc.DrawBitmap(d->image, x + int(align_delta_x(ALIGN_CENTER, item_size.x, d->image.GetWidth())), y + 3, true);
|
||||||
}
|
}
|
||||||
// draw short name
|
// draw short name
|
||||||
dc.SetFont(wxFont(12,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,_("Arial")));
|
dc.SetFont(wxFont(12,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,_("Arial")));
|
||||||
dc.GetTextExtent(capitalize(d.package->short_name), &w, &h);
|
dc.GetTextExtent(capitalize(d->package->short_name), &w, &h);
|
||||||
pos = align_in_rect(ALIGN_CENTER, RealSize(w,h), rect);
|
pos = align_in_rect(ALIGN_CENTER, RealSize(w,h), rect);
|
||||||
dc.DrawText(capitalize(d.package->short_name), max(x+1,(int)pos.x), (int)pos.y + 110);
|
dc.DrawText(capitalize(d->package->short_name), max(x+1,(int)pos.x), (int)pos.y + 110);
|
||||||
// draw name
|
// draw name
|
||||||
dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
|
dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
|
||||||
dc.GetTextExtent(d.package->full_name, &w, &h);
|
dc.GetTextExtent(d->package->full_name, &w, &h);
|
||||||
RealPoint text_pos = align_in_rect(ALIGN_CENTER, RealSize(w,h), rect);
|
RealPoint text_pos = align_in_rect(ALIGN_CENTER, RealSize(w,h), rect);
|
||||||
dc.DrawText(d.package->full_name, max(x+1,(int)text_pos.x), (int)text_pos.y + 130);
|
dc.DrawText(d->package->full_name, max(x+1,(int)text_pos.x), (int)text_pos.y + 130);
|
||||||
dc.DestroyClippingRegion();
|
dc.DestroyClippingRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,6 +68,9 @@ struct PackageList::ComparePackagePosHint {
|
|||||||
void PackageList::showData(const String& pattern) {
|
void PackageList::showData(const String& pattern) {
|
||||||
// clear
|
// clear
|
||||||
packages.clear();
|
packages.clear();
|
||||||
|
filtered_packages.clear();
|
||||||
|
filter.reset();
|
||||||
|
|
||||||
// find matching packages
|
// find matching packages
|
||||||
vector<PackagedP> matching;
|
vector<PackagedP> matching;
|
||||||
{
|
{
|
||||||
@@ -82,19 +91,23 @@ void PackageList::showData(const String& pattern) {
|
|||||||
}
|
}
|
||||||
// sort list
|
// sort list
|
||||||
sort(packages.begin(), packages.end(), ComparePackagePosHint());
|
sort(packages.begin(), packages.end(), ComparePackagePosHint());
|
||||||
|
|
||||||
// update list
|
// update list
|
||||||
|
applyFilter();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackageList::clear() {
|
void PackageList::clear() {
|
||||||
packages.clear();
|
packages.clear();
|
||||||
|
filtered_packages.clear();
|
||||||
|
filter.reset();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackageList::select(const String& name, bool send_event) {
|
void PackageList::select(const String& name, bool send_event) {
|
||||||
for (vector<PackageData>::const_iterator it = packages.begin() ; it != packages.end() ; ++it) {
|
for (vector<PackageDataP>::const_iterator it = filtered_packages.begin() ; it != filtered_packages.end() ; ++it) {
|
||||||
if (it->package->name() == name) {
|
if (it->get()->package->name() == name) {
|
||||||
subcolumns[0].selection = it - packages.begin();
|
subcolumns[0].selection = it - filtered_packages.begin();
|
||||||
update();
|
update();
|
||||||
if (send_event) {
|
if (send_event) {
|
||||||
sendEvent(EVENT_GALLERY_SELECT);
|
sendEvent(EVENT_GALLERY_SELECT);
|
||||||
@@ -110,3 +123,19 @@ void PackageList::select(const String& name, bool send_event) {
|
|||||||
int PackageList::requiredWidth() const {
|
int PackageList::requiredWidth() const {
|
||||||
return (item_size.x + SPACING) * (int)itemCount();
|
return (item_size.x + SPACING) * (int)itemCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PackageList::setFilter(const PackageDataFilterP& filter) {
|
||||||
|
this->filter = filter;
|
||||||
|
applyFilter();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PackageList::applyFilter() {
|
||||||
|
this->filtered_packages.clear();
|
||||||
|
|
||||||
|
FOR_EACH(p, packages) {
|
||||||
|
if (!filter || filter->keep(p)) {
|
||||||
|
filtered_packages.push_back(make_intrusive<PackageData>(p));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,8 +11,25 @@
|
|||||||
#include <util/prec.hpp>
|
#include <util/prec.hpp>
|
||||||
#include <util/error.hpp>
|
#include <util/error.hpp>
|
||||||
#include <gui/control/gallery_list.hpp>
|
#include <gui/control/gallery_list.hpp>
|
||||||
|
#include <data/filter.hpp>
|
||||||
|
|
||||||
DECLARE_POINTER_TYPE(Packaged);
|
DECLARE_POINTER_TYPE(Packaged);
|
||||||
|
DECLARE_POINTER_TYPE(PackageData);
|
||||||
|
|
||||||
|
// Information about a package
|
||||||
|
class PackageData : public IntrusivePtrVirtualBase, public IntrusiveFromThis<PackageData> {
|
||||||
|
public:
|
||||||
|
PackageData() {};
|
||||||
|
PackageData(const PackagedP& package, const Bitmap& image) : package(package), image(image) {};
|
||||||
|
PackagedP package;
|
||||||
|
Bitmap image;
|
||||||
|
|
||||||
|
bool contains(QuickFilterPart const& query) const;
|
||||||
|
|
||||||
|
DECLARE_REFLECTION();
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef intrusive_ptr<Filter<PackageData>> PackageDataFilterP;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : PackageList
|
// ----------------------------------------------------------------------------- : PackageList
|
||||||
|
|
||||||
@@ -38,7 +55,7 @@ public:
|
|||||||
* Throws if the selection is not of type T */
|
* Throws if the selection is not of type T */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
intrusive_ptr<T> getSelection(bool load_fully = true) const {
|
intrusive_ptr<T> getSelection(bool load_fully = true) const {
|
||||||
intrusive_ptr<T> ret = dynamic_pointer_cast<T>(packages.at(getSelectionId()).package);
|
intrusive_ptr<T> ret = dynamic_pointer_cast<T>(filtered_packages.at(getSelectionId())->package);
|
||||||
if (!ret) throw InternalError(_("PackageList: Selected package has the wrong type"));
|
if (!ret) throw InternalError(_("PackageList: Selected package has the wrong type"));
|
||||||
if (load_fully) ret->loadFully();
|
if (load_fully) ret->loadFully();
|
||||||
return ret;
|
return ret;
|
||||||
@@ -50,6 +67,8 @@ public:
|
|||||||
/// Required width to show all items
|
/// Required width to show all items
|
||||||
int requiredWidth() const;
|
int requiredWidth() const;
|
||||||
using GalleryList::column_count;
|
using GalleryList::column_count;
|
||||||
|
|
||||||
|
void setFilter(const PackageDataFilterP& filter);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Draw an item
|
/// Draw an item
|
||||||
@@ -58,18 +77,11 @@ protected:
|
|||||||
size_t itemCount() const override;
|
size_t itemCount() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The default icon to use
|
void applyFilter();
|
||||||
// wxIcon default_icon;
|
|
||||||
|
|
||||||
// Information about a package
|
|
||||||
struct PackageData {
|
|
||||||
PackageData() {}
|
|
||||||
PackageData(const PackagedP& package, const Bitmap& image) : package(package), image(image) {}
|
|
||||||
PackagedP package;
|
|
||||||
Bitmap image;
|
|
||||||
};
|
|
||||||
struct ComparePackagePosHint;
|
struct ComparePackagePosHint;
|
||||||
/// The displayed packages
|
/// The displayed packages
|
||||||
vector<PackageData> packages;
|
vector<PackageData> packages;
|
||||||
|
vector<PackageDataP> filtered_packages;
|
||||||
|
PackageDataFilterP filter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+73
-13
@@ -26,7 +26,7 @@ SetP new_set_window(Window* parent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NewSetWindow::NewSetWindow(Window* parent)
|
NewSetWindow::NewSetWindow(Window* parent)
|
||||||
: wxDialog(parent, wxID_ANY, _TITLE_("new set"), wxDefaultPosition, wxSize(530,320), wxDEFAULT_DIALOG_STYLE)
|
: wxDialog(parent, wxID_ANY, _TITLE_("new set"), wxDefaultPosition, wxSize(830,360), wxDEFAULT_DIALOG_STYLE)
|
||||||
{
|
{
|
||||||
wxBusyCursor wait;
|
wxBusyCursor wait;
|
||||||
// init controls
|
// init controls
|
||||||
@@ -34,11 +34,26 @@ NewSetWindow::NewSetWindow(Window* parent)
|
|||||||
stylesheet_list = new PackageList (this, ID_STYLESHEET_LIST, wxHORIZONTAL, false);
|
stylesheet_list = new PackageList (this, ID_STYLESHEET_LIST, wxHORIZONTAL, false);
|
||||||
wxStaticText* game_text = new wxStaticText(this, ID_GAME_LIST, _LABEL_("game type"));
|
wxStaticText* game_text = new wxStaticText(this, ID_GAME_LIST, _LABEL_("game type"));
|
||||||
wxStaticText* stylesheet_text = new wxStaticText(this, ID_STYLESHEET_LIST, _LABEL_("style type"));
|
wxStaticText* stylesheet_text = new wxStaticText(this, ID_STYLESHEET_LIST, _LABEL_("style type"));
|
||||||
|
|
||||||
|
game_filter = new FilterCtrl(this, ID_GAME_FILTER, _LABEL_("search game list"), _HELP_("search game list control"));
|
||||||
|
game_filter->setFilter(game_filter_value);
|
||||||
|
|
||||||
|
stylesheet_filter = new FilterCtrl(this, ID_STYLESHEET_FILTER, _LABEL_("search stylesheet list"), _HELP_("search stylesheet list control"));
|
||||||
|
stylesheet_filter->setFilter(stylesheet_filter_value);
|
||||||
|
|
||||||
// init sizer
|
// init sizer
|
||||||
wxSizer* s = new wxBoxSizer(wxVERTICAL);
|
wxSizer* s = new wxBoxSizer(wxVERTICAL);
|
||||||
s->Add(game_text, 0, wxALL, 4);
|
wxSizer* s2 = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
s2->Add(game_text, 0, wxALL & ~wxLEFT, 4);
|
||||||
|
s2->AddStretchSpacer();
|
||||||
|
s2->Add(game_filter, 1, wxALIGN_RIGHT, 4);
|
||||||
|
s->Add(s2, wxSizerFlags().Expand().Border(wxALL, 6));
|
||||||
s->Add(game_list, 0, wxEXPAND | (wxALL & ~wxTOP), 4);
|
s->Add(game_list, 0, wxEXPAND | (wxALL & ~wxTOP), 4);
|
||||||
s->Add(stylesheet_text, 0, wxALL, 4);
|
wxSizer* s3 = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
s3->Add(stylesheet_text, 0, wxALL & ~wxLEFT, 4);
|
||||||
|
s3->AddStretchSpacer();
|
||||||
|
s3->Add(stylesheet_filter, 1, wxALIGN_RIGHT, 4);
|
||||||
|
s->Add(s3, wxSizerFlags().Expand().Border(wxALL, 6));
|
||||||
s->Add(stylesheet_list, 0, wxEXPAND | (wxALL & ~wxTOP), 4);
|
s->Add(stylesheet_list, 0, wxEXPAND | (wxALL & ~wxTOP), 4);
|
||||||
s->Add(CreateButtonSizer(wxOK | wxCANCEL) , 0, wxEXPAND | wxALL, 8);
|
s->Add(CreateButtonSizer(wxOK | wxCANCEL) , 0, wxEXPAND | wxALL, 8);
|
||||||
s->SetSizeHints(this);
|
s->SetSizeHints(this);
|
||||||
@@ -46,7 +61,7 @@ NewSetWindow::NewSetWindow(Window* parent)
|
|||||||
// Resize
|
// Resize
|
||||||
Layout();
|
Layout();
|
||||||
wxSize min_size = GetSizer()->GetMinSize() + GetSize() - GetClientSize();
|
wxSize min_size = GetSizer()->GetMinSize() + GetSize() - GetClientSize();
|
||||||
SetSize(630,min_size.y);
|
SetSize(830, min_size.y);
|
||||||
// init lists
|
// init lists
|
||||||
game_list->showData<Game>();
|
game_list->showData<Game>();
|
||||||
try {
|
try {
|
||||||
@@ -69,7 +84,7 @@ void NewSetWindow::onGameSelect(wxCommandEvent&) {
|
|||||||
// resize (yuck)
|
// resize (yuck)
|
||||||
Layout();
|
Layout();
|
||||||
wxSize min_size = GetSizer()->GetMinSize() + GetSize() - GetClientSize();
|
wxSize min_size = GetSizer()->GetMinSize() + GetSize() - GetClientSize();
|
||||||
SetSize(630,min_size.y);
|
SetSize(830,min_size.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewSetWindow::onStyleSheetSelect(wxCommandEvent&) {
|
void NewSetWindow::onStyleSheetSelect(wxCommandEvent&) {
|
||||||
@@ -80,10 +95,33 @@ void NewSetWindow::onStyleSheetSelect(wxCommandEvent&) {
|
|||||||
settings.gameSettingsFor(*game).default_stylesheet = stylesheet->name();
|
settings.gameSettingsFor(*game).default_stylesheet = stylesheet->name();
|
||||||
UpdateWindowUI(wxUPDATE_UI_RECURSE);
|
UpdateWindowUI(wxUPDATE_UI_RECURSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewSetWindow::onStyleSheetActivate(wxCommandEvent&) {
|
void NewSetWindow::onStyleSheetActivate(wxCommandEvent&) {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NewSetWindow::onGameFilterUpdate(wxCommandEvent&) {
|
||||||
|
if (game_list->hasSelection()) {
|
||||||
|
GameP existingGameSelection = game_list->getSelection<Game>(false);
|
||||||
|
game_list->setFilter(game_filter->getFilter<PackageData>());
|
||||||
|
game_list->select(existingGameSelection->name());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
game_list->setFilter(game_filter->getFilter<PackageData>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewSetWindow::onStylesheetFilterUpdate(wxCommandEvent&) {
|
||||||
|
if (stylesheet_list->hasSelection()) {
|
||||||
|
StyleSheetP existingStylesheetSelection = stylesheet_list->getSelection<StyleSheet>(false);
|
||||||
|
stylesheet_list->setFilter(stylesheet_filter->getFilter<PackageData>());
|
||||||
|
stylesheet_list->select(existingStylesheetSelection->name());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stylesheet_list->setFilter(stylesheet_filter->getFilter<PackageData>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NewSetWindow::OnOK(wxCommandEvent&) {
|
void NewSetWindow::OnOK(wxCommandEvent&) {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
@@ -117,9 +155,11 @@ void NewSetWindow::onIdle(wxIdleEvent& ev) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(NewSetWindow, wxDialog)
|
BEGIN_EVENT_TABLE(NewSetWindow, wxDialog)
|
||||||
EVT_GALLERY_SELECT (ID_GAME_LIST, NewSetWindow::onGameSelect)
|
EVT_GALLERY_SELECT(ID_GAME_LIST, NewSetWindow::onGameSelect)
|
||||||
EVT_GALLERY_SELECT (ID_STYLESHEET_LIST, NewSetWindow::onStyleSheetSelect)
|
EVT_GALLERY_SELECT(ID_STYLESHEET_LIST, NewSetWindow::onStyleSheetSelect)
|
||||||
EVT_GALLERY_ACTIVATE(ID_STYLESHEET_LIST, NewSetWindow::onStyleSheetActivate)
|
EVT_GALLERY_ACTIVATE(ID_STYLESHEET_LIST, NewSetWindow::onStyleSheetActivate)
|
||||||
|
EVT_COMMAND_RANGE(ID_STYLESHEET_FILTER, ID_STYLESHEET_FILTER, wxEVT_COMMAND_TEXT_UPDATED, NewSetWindow::onStylesheetFilterUpdate)
|
||||||
|
EVT_COMMAND_RANGE(ID_GAME_FILTER, ID_GAME_FILTER, wxEVT_COMMAND_TEXT_UPDATED, NewSetWindow::onGameFilterUpdate)
|
||||||
EVT_BUTTON (wxID_OK, NewSetWindow::OnOK)
|
EVT_BUTTON (wxID_OK, NewSetWindow::OnOK)
|
||||||
EVT_UPDATE_UI (wxID_ANY, NewSetWindow::onUpdateUI)
|
EVT_UPDATE_UI (wxID_ANY, NewSetWindow::onUpdateUI)
|
||||||
EVT_IDLE ( NewSetWindow::onIdle)
|
EVT_IDLE ( NewSetWindow::onIdle)
|
||||||
@@ -135,18 +175,26 @@ StyleSheetP select_stylesheet(const Game& game, const String& failed_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SelectStyleSheetWindow::SelectStyleSheetWindow(Window* parent, const Game& game, const String& failed_name)
|
SelectStyleSheetWindow::SelectStyleSheetWindow(Window* parent, const Game& game, const String& failed_name)
|
||||||
: wxDialog(parent, wxID_ANY, _TITLE_("select stylesheet"), wxDefaultPosition, wxSize(530,320), wxDEFAULT_DIALOG_STYLE)
|
: wxDialog(parent, wxID_ANY, _TITLE_("select stylesheet"), wxDefaultPosition, wxSize(830,320), wxDEFAULT_DIALOG_STYLE)
|
||||||
, game(game)
|
, game(game)
|
||||||
{
|
{
|
||||||
wxBusyCursor wait;
|
wxBusyCursor wait;
|
||||||
// init controls
|
// init controls
|
||||||
stylesheet_list = new PackageList (this, ID_STYLESHEET_LIST);
|
stylesheet_list = new PackageList (this, ID_STYLESHEET_LIST);
|
||||||
wxStaticText* description = new wxStaticText(this, ID_GAME_LIST, _LABEL_1_("stylesheet not found", failed_name));
|
wxStaticText* description = new wxStaticText(this, ID_GAME_LIST, _LABEL_1_("stylesheet not found", failed_name));
|
||||||
wxStaticText* stylesheet_text = new wxStaticText(this, ID_STYLESHEET_LIST, _LABEL_("style type"));
|
wxStaticText* stylesheet_text = new wxStaticText(this, ID_STYLESHEET_LIST, _LABEL_("style type"));
|
||||||
|
|
||||||
|
stylesheet_filter = new FilterCtrl(this, ID_STYLESHEET_FILTER, _LABEL_("search stylesheet list"), _HELP_("search stylesheet list control"));
|
||||||
|
stylesheet_filter->setFilter(stylesheet_filter_value);
|
||||||
|
|
||||||
// init sizer
|
// init sizer
|
||||||
wxSizer* s = new wxBoxSizer(wxVERTICAL);
|
wxSizer* s = new wxBoxSizer(wxVERTICAL);
|
||||||
s->Add(description, 0, wxALL, 4);
|
s->Add(description, 0, wxALL, 4);
|
||||||
s->Add(stylesheet_text, 0, wxALL, 4);
|
wxSizer* s2 = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
s2->Add(stylesheet_text, 0, wxALL & ~wxLEFT, 4);
|
||||||
|
s2->AddStretchSpacer();
|
||||||
|
s2->Add(stylesheet_filter, 1, wxALIGN_RIGHT, 4);
|
||||||
|
s->Add(s2, wxSizerFlags().Expand().Border(wxALL, 6));
|
||||||
s->Add(stylesheet_list, 0, wxEXPAND | (wxALL & ~wxTOP), 4);
|
s->Add(stylesheet_list, 0, wxEXPAND | (wxALL & ~wxTOP), 4);
|
||||||
s->Add(CreateButtonSizer(wxOK | wxCANCEL) , 0, wxEXPAND | wxALL, 8);
|
s->Add(CreateButtonSizer(wxOK | wxCANCEL) , 0, wxEXPAND | wxALL, 8);
|
||||||
s->SetSizeHints(this);
|
s->SetSizeHints(this);
|
||||||
@@ -157,7 +205,7 @@ SelectStyleSheetWindow::SelectStyleSheetWindow(Window* parent, const Game& game,
|
|||||||
// Resize
|
// Resize
|
||||||
Layout();
|
Layout();
|
||||||
wxSize min_size = GetSizer()->GetMinSize() + GetSize() - GetClientSize();
|
wxSize min_size = GetSizer()->GetMinSize() + GetSize() - GetClientSize();
|
||||||
SetSize(630,min_size.y);
|
SetSize(830,min_size.y);
|
||||||
UpdateWindowUI(wxUPDATE_UI_RECURSE);
|
UpdateWindowUI(wxUPDATE_UI_RECURSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,6 +215,17 @@ void SelectStyleSheetWindow::onStyleSheetSelect(wxCommandEvent&) {
|
|||||||
}
|
}
|
||||||
void SelectStyleSheetWindow::onStyleSheetActivate(wxCommandEvent&) {
|
void SelectStyleSheetWindow::onStyleSheetActivate(wxCommandEvent&) {
|
||||||
done();
|
done();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SelectStyleSheetWindow::onStylesheetFilterUpdate(wxCommandEvent&) {
|
||||||
|
if (stylesheet_list->hasSelection()) {
|
||||||
|
StyleSheetP existingStylesheetSelection = stylesheet_list->getSelection<StyleSheet>(false);
|
||||||
|
stylesheet_list->setFilter(stylesheet_filter->getFilter<PackageData>());
|
||||||
|
stylesheet_list->select(existingStylesheetSelection->name());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stylesheet_list->setFilter(stylesheet_filter->getFilter<PackageData>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectStyleSheetWindow::OnOK(wxCommandEvent&) {
|
void SelectStyleSheetWindow::OnOK(wxCommandEvent&) {
|
||||||
@@ -198,7 +257,8 @@ void SelectStyleSheetWindow::onIdle(wxIdleEvent& ev) {
|
|||||||
|
|
||||||
BEGIN_EVENT_TABLE(SelectStyleSheetWindow, wxDialog)
|
BEGIN_EVENT_TABLE(SelectStyleSheetWindow, wxDialog)
|
||||||
EVT_GALLERY_SELECT (ID_STYLESHEET_LIST, SelectStyleSheetWindow::onStyleSheetSelect)
|
EVT_GALLERY_SELECT (ID_STYLESHEET_LIST, SelectStyleSheetWindow::onStyleSheetSelect)
|
||||||
EVT_GALLERY_ACTIVATE(ID_STYLESHEET_LIST, SelectStyleSheetWindow::onStyleSheetActivate)
|
EVT_GALLERY_ACTIVATE(ID_STYLESHEET_LIST, SelectStyleSheetWindow::onStyleSheetActivate)
|
||||||
|
EVT_COMMAND_RANGE(ID_STYLESHEET_FILTER, ID_STYLESHEET_FILTER, wxEVT_COMMAND_TEXT_UPDATED, SelectStyleSheetWindow::onStylesheetFilterUpdate)
|
||||||
EVT_BUTTON (wxID_OK, SelectStyleSheetWindow::OnOK)
|
EVT_BUTTON (wxID_OK, SelectStyleSheetWindow::OnOK)
|
||||||
EVT_UPDATE_UI (wxID_ANY, SelectStyleSheetWindow::onUpdateUI)
|
EVT_UPDATE_UI (wxID_ANY, SelectStyleSheetWindow::onUpdateUI)
|
||||||
EVT_IDLE ( SelectStyleSheetWindow::onIdle)
|
EVT_IDLE ( SelectStyleSheetWindow::onIdle)
|
||||||
|
|||||||
+15
-2
@@ -9,6 +9,7 @@
|
|||||||
// ----------------------------------------------------------------------------- : Includes
|
// ----------------------------------------------------------------------------- : Includes
|
||||||
|
|
||||||
#include <util/prec.hpp>
|
#include <util/prec.hpp>
|
||||||
|
#include <gui/control/filter_ctrl.hpp>
|
||||||
|
|
||||||
class PackageList;
|
class PackageList;
|
||||||
class Game;
|
class Game;
|
||||||
@@ -34,6 +35,12 @@ private:
|
|||||||
|
|
||||||
// gui items
|
// gui items
|
||||||
PackageList* game_list, *stylesheet_list;
|
PackageList* game_list, *stylesheet_list;
|
||||||
|
|
||||||
|
FilterCtrl* game_filter;
|
||||||
|
String game_filter_value;
|
||||||
|
|
||||||
|
FilterCtrl* stylesheet_filter;
|
||||||
|
String stylesheet_filter_value;
|
||||||
|
|
||||||
// --------------------------------------------------- : events
|
// --------------------------------------------------- : events
|
||||||
|
|
||||||
@@ -41,6 +48,8 @@ private:
|
|||||||
|
|
||||||
void onStyleSheetSelect (wxCommandEvent&);
|
void onStyleSheetSelect (wxCommandEvent&);
|
||||||
void onStyleSheetActivate(wxCommandEvent&);
|
void onStyleSheetActivate(wxCommandEvent&);
|
||||||
|
void onStylesheetFilterUpdate(wxCommandEvent&);
|
||||||
|
void onGameFilterUpdate(wxCommandEvent&);
|
||||||
|
|
||||||
virtual void OnOK(wxCommandEvent&);
|
virtual void OnOK(wxCommandEvent&);
|
||||||
|
|
||||||
@@ -72,12 +81,16 @@ private:
|
|||||||
const Game& game;
|
const Game& game;
|
||||||
|
|
||||||
// gui items
|
// gui items
|
||||||
PackageList* stylesheet_list;
|
PackageList* stylesheet_list;
|
||||||
|
|
||||||
|
FilterCtrl* stylesheet_filter;
|
||||||
|
String stylesheet_filter_value;
|
||||||
|
|
||||||
// --------------------------------------------------- : events
|
// --------------------------------------------------- : events
|
||||||
|
|
||||||
void onStyleSheetSelect (wxCommandEvent&);
|
void onStyleSheetSelect (wxCommandEvent&);
|
||||||
void onStyleSheetActivate(wxCommandEvent&);
|
void onStyleSheetActivate(wxCommandEvent&);
|
||||||
|
void onStylesheetFilterUpdate(wxCommandEvent&);
|
||||||
|
|
||||||
virtual void OnOK(wxCommandEvent&);
|
virtual void OnOK(wxCommandEvent&);
|
||||||
|
|
||||||
|
|||||||
+34
-11
@@ -35,17 +35,25 @@ void StylePanel::initControls() {
|
|||||||
list = new PackageList (this, wxID_ANY);
|
list = new PackageList (this, wxID_ANY);
|
||||||
use_for_all = new wxButton (this, ID_STYLE_USE_FOR_ALL, _BUTTON_("use for all cards"));
|
use_for_all = new wxButton (this, ID_STYLE_USE_FOR_ALL, _BUTTON_("use for all cards"));
|
||||||
use_custom_options = new wxCheckBox(this, ID_STYLE_USE_CUSTOM, _BUTTON_("use custom styling options"));
|
use_custom_options = new wxCheckBox(this, ID_STYLE_USE_CUSTOM, _BUTTON_("use custom styling options"));
|
||||||
editor = new StylingEditor(this, ID_EDITOR, wxNO_BORDER);
|
editor = new StylingEditor(this, ID_EDITOR, wxNO_BORDER);
|
||||||
|
|
||||||
|
stylesheet_filter = new FilterCtrl(this, ID_STYLESHEET_FILTER, _LABEL_("search stylesheet list"), _HELP_("search stylesheet list control"));
|
||||||
|
stylesheet_filter->setFilter(stylesheet_filter_value);
|
||||||
|
|
||||||
// init sizer
|
// init sizer
|
||||||
wxSizer* s = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer* s = new wxBoxSizer(wxHORIZONTAL);
|
||||||
s->Add(preview, 0, wxRIGHT, 2);
|
s->Add(preview, 0, wxRIGHT, 2);
|
||||||
wxSizer* s2 = new wxBoxSizer(wxVERTICAL);
|
wxSizer* s2 = new wxBoxSizer(wxVERTICAL);
|
||||||
s2->Add(list, 0, wxEXPAND | wxBOTTOM, 4);
|
s2->Add(list, 0, wxEXPAND | wxBOTTOM, 4);
|
||||||
s2->Add(use_for_all, 0, wxRIGHT | wxBOTTOM | wxALIGN_RIGHT, 4);
|
wxSizer* s3 = new wxBoxSizer(wxHORIZONTAL);
|
||||||
wxSizer* s3 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("styling options"));
|
s3->Add(stylesheet_filter, 0, wxBOTTOM | wxALIGN_LEFT, 4);
|
||||||
s3->Add(use_custom_options, 0, wxEXPAND | wxALL, 4);
|
s3->AddStretchSpacer();
|
||||||
s3->Add(editor, 2, wxEXPAND, 0);
|
s3->Add(use_for_all, 0, wxBOTTOM | wxALIGN_RIGHT, 4);
|
||||||
s2->Add(s3, 1, wxEXPAND | wxALL, 2);
|
s2->Add(s3, wxSizerFlags().Expand().Border(wxALL, 6));
|
||||||
|
wxSizer* s4 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("styling options"));
|
||||||
|
s4->Add(use_custom_options, 0, wxEXPAND | wxALL, 4);
|
||||||
|
s4->Add(editor, 2, wxEXPAND, 0);
|
||||||
|
s2->Add(s4, 1, wxEXPAND | wxALL, 2);
|
||||||
s->Add(s2, 1, wxEXPAND, 8);
|
s->Add(s2, 1, wxEXPAND, 8);
|
||||||
s->SetSizeHints(this);
|
s->SetSizeHints(this);
|
||||||
SetSizer(s);
|
SetSizer(s);
|
||||||
@@ -62,7 +70,7 @@ void StylePanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StylePanel::updateListSize() {
|
void StylePanel::updateListSize() {
|
||||||
if (!isInitialized()) return;
|
if (!isInitialized() || list_size_already_initialized) return;
|
||||||
// how many columns fit?
|
// how many columns fit?
|
||||||
size_t fit_columns = (size_t)((GetSize().y - 400) / 152);
|
size_t fit_columns = (size_t)((GetSize().y - 400) / 152);
|
||||||
// we only need enough columns to show all items
|
// we only need enough columns to show all items
|
||||||
@@ -73,8 +81,11 @@ void StylePanel::updateListSize() {
|
|||||||
if (column_count != list->column_count) {
|
if (column_count != list->column_count) {
|
||||||
list->column_count = column_count;
|
list->column_count = column_count;
|
||||||
static_cast<SetWindow*>(GetParent())->fixMinWindowSize();
|
static_cast<SetWindow*>(GetParent())->fixMinWindowSize();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
list_size_already_initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
bool StylePanel::Layout() {
|
bool StylePanel::Layout() {
|
||||||
updateListSize();
|
updateListSize();
|
||||||
return SetWindowPanel::Layout();
|
return SetWindowPanel::Layout();
|
||||||
@@ -125,6 +136,17 @@ void StylePanel::onAction(const Action& action, bool undone) {
|
|||||||
use_for_all->Enable(card && card->stylesheet);
|
use_for_all->Enable(card && card->stylesheet);
|
||||||
use_custom_options->Enable((bool)card);
|
use_custom_options->Enable((bool)card);
|
||||||
use_custom_options->SetValue(card ? card->has_styling : false);
|
use_custom_options->SetValue(card ? card->has_styling : false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StylePanel::onStylesheetFilterUpdate(wxCommandEvent&) {
|
||||||
|
if (list->hasSelection()) {
|
||||||
|
StyleSheetP existingStylesheetSelection = list->getSelection<StyleSheet>(false);
|
||||||
|
list->setFilter(stylesheet_filter->getFilter<PackageData>());
|
||||||
|
list->select(existingStylesheetSelection->name());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
list->setFilter(stylesheet_filter->getFilter<PackageData>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Selection
|
// ----------------------------------------------------------------------------- : Selection
|
||||||
@@ -186,7 +208,8 @@ void StylePanel::onUseCustom(wxCommandEvent&) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(StylePanel, wxPanel)
|
BEGIN_EVENT_TABLE(StylePanel, wxPanel)
|
||||||
EVT_GALLERY_SELECT(wxID_ANY, StylePanel::onStyleSelect)
|
EVT_GALLERY_SELECT(wxID_ANY, StylePanel::onStyleSelect)
|
||||||
|
EVT_COMMAND_RANGE(ID_STYLESHEET_FILTER, ID_STYLESHEET_FILTER, wxEVT_COMMAND_TEXT_UPDATED, StylePanel::onStylesheetFilterUpdate)
|
||||||
EVT_BUTTON (ID_STYLE_USE_FOR_ALL, StylePanel::onUseForAll)
|
EVT_BUTTON (ID_STYLE_USE_FOR_ALL, StylePanel::onUseForAll)
|
||||||
EVT_CHECKBOX (ID_STYLE_USE_CUSTOM, StylePanel::onUseCustom)
|
EVT_CHECKBOX (ID_STYLE_USE_CUSTOM, StylePanel::onUseCustom)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|||||||
+72
-66
@@ -1,66 +1,72 @@
|
|||||||
//+----------------------------------------------------------------------------+
|
//+----------------------------------------------------------------------------+
|
||||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||||
//| Copyright: (C) Twan van Laarhoven and the other MSE developers |
|
//| Copyright: (C) Twan van Laarhoven and the other MSE developers |
|
||||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||||
//+----------------------------------------------------------------------------+
|
//+----------------------------------------------------------------------------+
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Includes
|
// ----------------------------------------------------------------------------- : Includes
|
||||||
|
|
||||||
#include <util/prec.hpp>
|
#include <util/prec.hpp>
|
||||||
#include <gui/set/panel.hpp>
|
#include <gui/set/panel.hpp>
|
||||||
|
#include <gui/control/filter_ctrl.hpp>
|
||||||
class CardViewer;
|
|
||||||
class PackageList;
|
class CardViewer;
|
||||||
class StylingEditor;
|
class PackageList;
|
||||||
|
class StylingEditor;
|
||||||
// ----------------------------------------------------------------------------- : StylePanel
|
|
||||||
|
// ----------------------------------------------------------------------------- : StylePanel
|
||||||
/// A panel showing a list of stylesheets, and an editor for styling
|
|
||||||
class StylePanel : public SetWindowPanel {
|
/// A panel showing a list of stylesheets, and an editor for styling
|
||||||
public:
|
class StylePanel : public SetWindowPanel {
|
||||||
StylePanel(Window* parent, int id);
|
public:
|
||||||
|
StylePanel(Window* parent, int id);
|
||||||
void onChangeSet() override;
|
|
||||||
void onAction(const Action&, bool undone) override;
|
void onChangeSet() override;
|
||||||
|
void onAction(const Action&, bool undone) override;
|
||||||
// --------------------------------------------------- : UI
|
|
||||||
|
// --------------------------------------------------- : UI
|
||||||
void initUI(wxToolBar*, wxMenuBar*) override;
|
|
||||||
|
void initUI(wxToolBar*, wxMenuBar*) override;
|
||||||
// --------------------------------------------------- : Clipboard
|
|
||||||
bool canCut() const override;
|
// --------------------------------------------------- : Clipboard
|
||||||
bool canCopy() const override;
|
bool canCut() const override;
|
||||||
bool canPaste() const override;
|
bool canCopy() const override;
|
||||||
bool canSelectAll() const override;
|
bool canPaste() const override;
|
||||||
void doCut() override;
|
bool canSelectAll() const override;
|
||||||
void doCopy() override;
|
void doCut() override;
|
||||||
void doPaste() override;
|
void doCopy() override;
|
||||||
void doSelectAll() override;
|
void doPaste() override;
|
||||||
|
void doSelectAll() override;
|
||||||
// --------------------------------------------------- : Selection
|
|
||||||
void selectCard(const CardP& card) override;
|
// --------------------------------------------------- : Selection
|
||||||
|
void selectCard(const CardP& card) override;
|
||||||
private:
|
|
||||||
DECLARE_EVENT_TABLE();
|
private:
|
||||||
|
DECLARE_EVENT_TABLE();
|
||||||
CardViewer* preview; ///< Card preview
|
|
||||||
PackageList* list; ///< List of stylesheets
|
CardViewer* preview; ///< Card preview
|
||||||
StylingEditor* editor; ///< Editor for styling information
|
PackageList* list; ///< List of stylesheets
|
||||||
wxButton* use_for_all;
|
StylingEditor* editor; ///< Editor for styling information
|
||||||
wxCheckBox* use_custom_options;
|
wxButton* use_for_all;
|
||||||
CardP card; ///< Card we are working on
|
wxCheckBox* use_custom_options;
|
||||||
|
FilterCtrl* stylesheet_filter;
|
||||||
void onStyleSelect(wxCommandEvent&);
|
String stylesheet_filter_value;
|
||||||
void onUseForAll(wxCommandEvent&);
|
CardP card; ///< Card we are working on
|
||||||
void onUseCustom(wxCommandEvent&);
|
bool list_size_already_initialized = false;
|
||||||
|
|
||||||
/// Determine the best size for the list of stylesheets based on available space
|
void onStyleSelect(wxCommandEvent&);
|
||||||
void updateListSize();
|
void onUseForAll(wxCommandEvent&);
|
||||||
bool Layout() override;
|
void onUseCustom(wxCommandEvent&);
|
||||||
|
|
||||||
/// Actual intialization of the controls
|
void onStylesheetFilterUpdate(wxCommandEvent&);
|
||||||
void initControls();
|
|
||||||
};
|
/// Determine the best size for the list of stylesheets based on available space
|
||||||
|
void updateListSize();
|
||||||
|
bool Layout() override;
|
||||||
|
|
||||||
|
/// Actual intialization of the controls
|
||||||
|
void initControls();
|
||||||
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -227,6 +227,10 @@ enum ControlID {
|
|||||||
ID_CONTROL_MIN = 1000,
|
ID_CONTROL_MIN = 1000,
|
||||||
ID_CONTROL_MAX = 1999,
|
ID_CONTROL_MAX = 1999,
|
||||||
|
|
||||||
|
// New Set Window
|
||||||
|
ID_STYLESHEET_FILTER,
|
||||||
|
ID_GAME_FILTER,
|
||||||
|
|
||||||
// Controls
|
// Controls
|
||||||
ID_VIEWER = 1001,
|
ID_VIEWER = 1001,
|
||||||
ID_EDITOR,
|
ID_EDITOR,
|
||||||
|
|||||||
Reference in New Issue
Block a user