mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
Finally got precompiled headers to work.
Now all C++ files need to #include <util/prec.hpp>
That is why all .cpp files are touched by this commit
Many changes to installers and update checking:
- the window is now called PackagesWindow, in a new source file
- update checking is now independent from the PackagesWindow. For update checking only a list of package versions are needed (vector<PackageDependency>). This is much less information to download at each startup.
- the list of available packages is now a list of available Installers, since an installer can contain multiple packages.
- moved the logic of dependency checking etc. to data/installer
- moved the actual installation to util/io/package_manager
- moved directory iteration/creation logic to util/file_utils
- added PackageDirectory: the local and global package directory now have their own object (was part of PackageManager)
- added PackageVersion: for detecting if a package has been modified after it was installed.
- added PackageDescription: description/header of a package. Basicly the same as what Packaged provides.
- added DownloadableInstaller: where to find an insaller, what does it contain?
- added InstallablePackage: brining it all together: installer, package, status, action.
Current status: the insaller is currently broken in a few places, more on that soon.
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@792 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/card_editor.hpp>
|
||||
#include <gui/value/editor.hpp>
|
||||
#include <gui/icon_menu.hpp>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/card_list.hpp>
|
||||
#include <gui/control/card_list_column_select.hpp>
|
||||
#include <gui/icon_menu.hpp>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/card_list_column_select.hpp>
|
||||
#include <data/game.hpp>
|
||||
#include <data/field.hpp>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/card_viewer.hpp>
|
||||
#include <data/stylesheet.hpp>
|
||||
#include <data/settings.hpp>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/filtered_card_list.hpp>
|
||||
|
||||
DECLARE_TYPEOF_COLLECTION(CardP);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/gallery_list.hpp>
|
||||
#include <gfx/gfx.hpp>
|
||||
#include <wx/dcbuffer.h>
|
||||
@@ -91,7 +92,6 @@ void GalleryList::scrollTo(int top, bool update_scrollbar) {
|
||||
top = max(0, top);
|
||||
// scroll
|
||||
if (top == visible_start) return;
|
||||
//%int old_top = visible_start;
|
||||
visible_start = top;
|
||||
if (update_scrollbar) {
|
||||
// scroll bar
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/graph.hpp>
|
||||
#include <util/alignment.hpp>
|
||||
#include <gfx/gfx.hpp>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/image_card_list.hpp>
|
||||
#include <gui/thumbnail_thread.hpp>
|
||||
#include <data/field/image.hpp>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/item_list.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <wx/imaglist.h>
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <wx/listctrl.h>
|
||||
|
||||
typedef intrusive_ptr<IntrusivePtrVirtualBase> VoidP;
|
||||
|
||||
// ----------------------------------------------------------------------------- : ItemList
|
||||
|
||||
/// A generic list of items
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/keyword_list.hpp>
|
||||
#include <gui/icon_menu.hpp>
|
||||
#include <data/set.hpp>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/native_look_editor.hpp>
|
||||
#include <gui/value/editor.hpp>
|
||||
#include <gui/util.hpp>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/package_list.hpp>
|
||||
#include <util/io/package_manager.hpp>
|
||||
#include <util/alignment.hpp>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/select_card_list.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <data/card.hpp>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/text_ctrl.hpp>
|
||||
#include <gui/value/editor.hpp>
|
||||
#include <gui/util.hpp>
|
||||
|
||||
@@ -6,12 +6,13 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/tree_list.hpp>
|
||||
#include <gfx/gfx.hpp>
|
||||
#include <wx/renderer.h>
|
||||
#include <wx/dcbuffer.h>
|
||||
|
||||
DECLARE_TYPEOF_COLLECTION(TreeList::Item);
|
||||
DECLARE_TYPEOF_COLLECTION(TreeList::ItemP);
|
||||
|
||||
// ----------------------------------------------------------------------------- : TreeList : item managment
|
||||
|
||||
@@ -23,21 +24,28 @@ void TreeList::rebuild(bool full) {
|
||||
}
|
||||
|
||||
bool TreeList::hasChildren(size_t item) const {
|
||||
return item < items.size() && items[item].level < items[item+1].level;
|
||||
return item + 1 < items.size() && items[item]->level < items[item+1]->level;
|
||||
}
|
||||
|
||||
void TreeList::expand(size_t item, bool expand) {
|
||||
if (hasChildren(item) && items[item].expanded != expand) {
|
||||
items[item].expanded = expand;
|
||||
if (hasChildren(item) && items[item]->expanded != expand) {
|
||||
items[item]->expanded = expand;
|
||||
rebuild(false);
|
||||
}
|
||||
}
|
||||
|
||||
void TreeList::select(size_t item) {
|
||||
void TreeList::select(size_t item, bool event) {
|
||||
if (item >= items.size() || selection == item) return;
|
||||
size_t oldpos = selection < items.size() ? items[selection].position : 0;
|
||||
// select
|
||||
size_t oldpos = selection < items.size() ? items[selection]->position : 0;
|
||||
selection = item;
|
||||
size_t pos = items[selection].position;
|
||||
size_t pos = items[selection]->position;
|
||||
// event
|
||||
if (event) {
|
||||
wxCommandEvent ev(wxEVT_COMMAND_LISTBOX_SELECTED, GetId());
|
||||
ProcessEvent(ev);
|
||||
}
|
||||
// redraw
|
||||
if (pos < first_line) {
|
||||
ScrollToLine(pos);
|
||||
} else if (pos >= first_line + visible_lines_t) {
|
||||
@@ -53,28 +61,28 @@ void TreeList::calcItemCount() {
|
||||
total_lines = 0;
|
||||
int visible_level = 0;
|
||||
FOR_EACH(i,items) {
|
||||
if (i.level <= visible_level) {
|
||||
i.position = total_lines;
|
||||
if (i->level <= visible_level) {
|
||||
i->position = total_lines;
|
||||
++total_lines;
|
||||
if (i.expanded) visible_level = i.level + 1;
|
||||
else visible_level = i.level;
|
||||
if (i->expanded) visible_level = i->level + 1;
|
||||
else visible_level = i->level;
|
||||
} else {
|
||||
i.position = NOTHING;
|
||||
i->position = NOTHING;
|
||||
}
|
||||
}
|
||||
// update lines
|
||||
UInt lines = 0;
|
||||
FOR_EACH_REVERSE(i,items) {
|
||||
if (i.visible()) {
|
||||
i.lines = lines;
|
||||
lines &= (1 << i.level) - 1;
|
||||
lines |= 1 << i.level;
|
||||
if (i->visible()) {
|
||||
i->lines = lines;
|
||||
lines &= (1 << i->level) - 1;
|
||||
lines |= 1 << i->level;
|
||||
}
|
||||
}
|
||||
// selection hidden? move to first visible item before it
|
||||
if (selection < items.size()) {
|
||||
for ( ; selection + 1 > 0 ; --selection) {
|
||||
if (items[selection].visible()) break; // visible
|
||||
if (items[selection]->visible()) break; // visible
|
||||
}
|
||||
if (selection >= items.size()) selection = 0;
|
||||
}
|
||||
@@ -86,20 +94,20 @@ size_t TreeList::findItemByPos(int y) const {
|
||||
}
|
||||
size_t TreeList::findItem(size_t line, size_t start) const {
|
||||
for (size_t i = start ; i < items.size() ; ++i) {
|
||||
if (items[i].visible() && items[i].position >= line) return i;
|
||||
if (items[i]->visible() && items[i]->position >= line) return i;
|
||||
}
|
||||
return items.size();
|
||||
}
|
||||
size_t TreeList::findLastItem(size_t start) const {
|
||||
for (size_t i = min(items.size(), start) - 1 ; i + 1 > 0 ; --i) {
|
||||
if (items[i].visible()) return i;
|
||||
if (items[i]->visible()) return i;
|
||||
}
|
||||
return items.size();
|
||||
}
|
||||
size_t TreeList::findParent(size_t start) const {
|
||||
int level = items[start].level;
|
||||
int level = items[start]->level;
|
||||
for (size_t i = start - 1 ; i + 1 > 0 ; --i) {
|
||||
if (items[i].visible() && items[i].level < level) return i;
|
||||
if (items[i]->visible() && items[i]->level < level) return i;
|
||||
}
|
||||
return items.size();
|
||||
}
|
||||
@@ -147,9 +155,13 @@ void TreeList::onPaint(wxPaintEvent& ev) {
|
||||
size_t start = findItem(first_line);
|
||||
size_t end = findItem(first_line + visible_lines);
|
||||
for (size_t i = start ; i < end ; ++i) {
|
||||
const Item& item = items[i];
|
||||
const Item& item = *items[i];
|
||||
if (!item.visible()) continue; // invisible
|
||||
x = level_width * (item.level + 1);
|
||||
// line below
|
||||
dc.SetPen(lerp(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW),
|
||||
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT),0.2));
|
||||
dc.DrawLine(x,y+item_height-1,cs.x,y+item_height-1);
|
||||
// draw lines
|
||||
dc.SetPen(lerp(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW),
|
||||
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT),0.4));
|
||||
@@ -171,15 +183,12 @@ void TreeList::onPaint(wxPaintEvent& ev) {
|
||||
if (selection == i) {
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
|
||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
|
||||
dc.DrawRectangle(x, y, cs.x-x, item_height);
|
||||
dc.DrawRectangle(x, y, cs.x-x, item_height-1);
|
||||
}
|
||||
// draw text(s)
|
||||
for (size_t j = 0 ; j < cols ; ++j) {
|
||||
int w = columnWidth(j);
|
||||
if (selection != i)
|
||||
dc.SetTextForeground(itemColor(i,j));
|
||||
dc.DrawText(itemText(i,j),x+1,y+1);
|
||||
drawItem(dc, i, j, x+1, y, selection == i);
|
||||
if (j == 0) x = 0;
|
||||
x += w;
|
||||
}
|
||||
@@ -197,7 +206,7 @@ void TreeList::onChar(wxKeyEvent& ev) {
|
||||
break;
|
||||
} case WXK_LEFT: {
|
||||
if (selection < items.size()) {
|
||||
if (hasChildren(selection) && items[selection].expanded) {
|
||||
if (hasChildren(selection) && items[selection]->expanded) {
|
||||
expand(selection, false);
|
||||
} else {
|
||||
// select parent
|
||||
@@ -207,7 +216,7 @@ void TreeList::onChar(wxKeyEvent& ev) {
|
||||
break;
|
||||
} case WXK_RIGHT: {
|
||||
if (selection < items.size() && hasChildren(selection)) {
|
||||
if (items[selection].expanded) {
|
||||
if (items[selection]->expanded) {
|
||||
// select first child
|
||||
select(selection+1);
|
||||
Refresh(false);
|
||||
@@ -216,10 +225,10 @@ void TreeList::onChar(wxKeyEvent& ev) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
} case WXK_PAGEUP: {
|
||||
} case WXK_PAGEUP: case WXK_PRIOR: {
|
||||
ScrollToLine(first_line > visible_lines_t ? first_line - visible_lines_t : 0);
|
||||
break;
|
||||
} case WXK_PAGEDOWN: {
|
||||
} case WXK_PAGEDOWN: case WXK_NEXT: {
|
||||
ScrollToLine(first_line + visible_lines_t);
|
||||
break;
|
||||
} case WXK_HOME: {
|
||||
@@ -242,9 +251,9 @@ void TreeList::onChar(wxKeyEvent& ev) {
|
||||
void TreeList::onLeftDown(wxMouseEvent& ev) {
|
||||
size_t i = findItemByPos(ev.GetY());
|
||||
if (i >= items.size()) return;
|
||||
int left = items[i].level * level_width;
|
||||
int left = items[i]->level * level_width;
|
||||
if (hasChildren(i) && ev.GetX() >= left && ev.GetX() < left + level_width) {
|
||||
expand(i, !items[i].expanded);
|
||||
expand(i, !items[i]->expanded);
|
||||
} else {
|
||||
select(i);
|
||||
}
|
||||
@@ -255,7 +264,7 @@ void TreeList::onLeftDClick(wxMouseEvent& ev) {
|
||||
size_t i = findItemByPos(ev.GetY());
|
||||
if (i >= items.size()) return;
|
||||
if (hasChildren(i)) {
|
||||
expand(i, !items[i].expanded);
|
||||
expand(i, !items[i]->expanded);
|
||||
}
|
||||
ev.Skip();
|
||||
}
|
||||
@@ -264,7 +273,8 @@ void TreeList::onLeftDClick(wxMouseEvent& ev) {
|
||||
|
||||
void TreeList::ScrollToLine(size_t line) {
|
||||
// determine the real first line to scroll to: we shouldn't scroll beyond the end
|
||||
line = (size_t)min((int)line, (int)(total_lines - visible_lines_t));
|
||||
line = (size_t)max((int)line, 0);
|
||||
line = (size_t)min((int)line, max(0, (int)(total_lines - visible_lines_t)));
|
||||
// nothing to do?
|
||||
if (line == first_line) return;
|
||||
first_line = line;
|
||||
@@ -314,12 +324,13 @@ void TreeList::onScroll(wxScrollWinEvent& ev) {
|
||||
|
||||
void TreeList::onSize(wxSizeEvent& ev) {
|
||||
UpdateScrollbar();
|
||||
Refresh(false);
|
||||
ev.Skip();
|
||||
}
|
||||
|
||||
void TreeList::onMouseWheel(wxMouseEvent& ev) {
|
||||
ScrollLines(-ev.GetWheelRotation() * ev.GetLinesPerAction() / ev.GetWheelDelta());
|
||||
Refresh(false);
|
||||
int delta = -ev.GetWheelRotation() * ev.GetLinesPerAction() / ev.GetWheelDelta();
|
||||
ScrollToLine(first_line + delta);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <wx/vscroll.h>
|
||||
|
||||
typedef intrusive_ptr<IntrusivePtrVirtualBase> VoidP;
|
||||
|
||||
// ----------------------------------------------------------------------------- : TreeList
|
||||
|
||||
/// A combination of a TreeCtrl and a ListCtrl. A tree with multiple columns.
|
||||
@@ -24,7 +22,7 @@ class TreeList : public wxPanel {
|
||||
/// Expand/collapse an item
|
||||
void expand(size_t item, bool expand = true);
|
||||
/// Select an item
|
||||
void select(size_t item);
|
||||
void select(size_t item, bool event = true);
|
||||
|
||||
/// (re)build the list
|
||||
void rebuild(bool full = true);
|
||||
@@ -32,24 +30,26 @@ class TreeList : public wxPanel {
|
||||
public:
|
||||
|
||||
/// An item in the tree list
|
||||
struct Item {
|
||||
Item() {}
|
||||
Item(int level, bool expanded = false, VoidP data = VoidP())
|
||||
: level(level), expanded(expanded), data(data)
|
||||
{}
|
||||
class Item : public IntrusivePtrBase<Item> {
|
||||
public:
|
||||
Item() : level(0), expanded(false) {}
|
||||
virtual ~Item() {}
|
||||
|
||||
int level;
|
||||
bool expanded;
|
||||
VoidP data;
|
||||
inline bool visible() const { return position != NOTHING; }
|
||||
|
||||
private:
|
||||
friend class TreeList;
|
||||
size_t position; // NOTHING if invisible, otherwise the line the item is on
|
||||
UInt lines; // lines in front of this item (bit set)
|
||||
inline bool visible() const { return position != NOTHING; }
|
||||
};
|
||||
typedef intrusive_ptr<Item> ItemP;
|
||||
|
||||
protected:
|
||||
|
||||
/// The items in the tree list
|
||||
vector<Item> items;
|
||||
vector<ItemP> items;
|
||||
|
||||
static const size_t NOTHING = (size_t)-1;
|
||||
size_t selection;
|
||||
@@ -57,10 +57,8 @@ class TreeList : public wxPanel {
|
||||
/// Initialize the items
|
||||
virtual void initItems() = 0;
|
||||
|
||||
/// Get the text of an item
|
||||
virtual String itemText(size_t item, size_t column) const = 0;
|
||||
/// Get the color of an item
|
||||
virtual Color itemColor(size_t item, size_t column) const = 0;
|
||||
/// Draw the text of an item
|
||||
virtual void drawItem(DC& dc, size_t index, size_t column, int x, int y, bool selected) const = 0;
|
||||
|
||||
/// The number of columns
|
||||
virtual size_t columnCount() const = 0;
|
||||
@@ -69,11 +67,11 @@ class TreeList : public wxPanel {
|
||||
/// The width of a column in pixels
|
||||
virtual int columnWidth(size_t column) const = 0;
|
||||
|
||||
private:
|
||||
int item_height;
|
||||
static const int header_height = 17;
|
||||
static const int level_width = 17;
|
||||
|
||||
private:
|
||||
size_t total_lines; // number of shown items
|
||||
size_t first_line; // first visible line
|
||||
size_t visible_lines; // number of (partially) visible lines
|
||||
|
||||
Reference in New Issue
Block a user