mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
d2196eea09
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
86 lines
3.6 KiB
C++
86 lines
3.6 KiB
C++
//+----------------------------------------------------------------------------+
|
|
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
|
//| Copyright: (C) 2001 - 2007 Twan van Laarhoven |
|
|
//| License: GNU General Public License 2 or later (see file COPYING) |
|
|
//+----------------------------------------------------------------------------+
|
|
|
|
// ----------------------------------------------------------------------------- : Includes
|
|
|
|
#include <util/prec.hpp>
|
|
#include <render/value/multiple_choice.hpp>
|
|
#include <render/value/choice.hpp>
|
|
#include <render/card/viewer.hpp>
|
|
#include <data/stylesheet.hpp>
|
|
#include <gui/util.hpp>
|
|
|
|
DECLARE_TYPEOF_COLLECTION(String);
|
|
|
|
// ----------------------------------------------------------------------------- : MultipleChoiceValueViewer
|
|
|
|
IMPLEMENT_VALUE_VIEWER(MultipleChoice);
|
|
|
|
bool MultipleChoiceValueViewer::prepare(RotatedDC& dc) {
|
|
if (style().render_style & (RENDER_CHECKLIST | RENDER_LIST)) return false;
|
|
return prepare_choice_viewer(dc, viewer, style(), value().value());
|
|
}
|
|
|
|
void MultipleChoiceValueViewer::draw(RotatedDC& dc) {
|
|
drawFieldBorder(dc);
|
|
if (style().render_style & RENDER_HIDDEN) return;
|
|
RealPoint pos = align_in_rect(style().alignment, RealSize(0,0), style().getInternalRect());
|
|
// selected choices
|
|
vector<String> selected;
|
|
value().get(selected);
|
|
if (style().render_style & RENDER_CHECKLIST) {
|
|
// render all choices
|
|
int end = field().choices->lastId();
|
|
vector<String>::iterator select_it = selected.begin();
|
|
for (int i = 0 ; i < end ; ++i) {
|
|
String choice = field().choices->choiceName(i);
|
|
bool active = select_it != selected.end() && *select_it == choice;
|
|
if (active) select_it++;
|
|
drawChoice(dc, pos, choice, active);
|
|
}
|
|
} else if (style().render_style & RENDER_LIST) {
|
|
// render only selected choices
|
|
FOR_EACH(choice, selected) {
|
|
drawChoice(dc, pos, choice);
|
|
}
|
|
} else {
|
|
draw_choice_viewer(dc, viewer, style(), value().value());
|
|
}
|
|
}
|
|
|
|
void MultipleChoiceValueViewer::drawChoice(RotatedDC& dc, RealPoint& pos, const String& choice, bool active) {
|
|
RealSize size; size.height = item_height;
|
|
if (nativeLook() && (style().render_style & RENDER_CHECKLIST)) {
|
|
wxRect rect = dc.trRectStraight(RealRect(pos + RealSize(1,1), RealSize(12,12)));
|
|
draw_checkbox(nullptr, dc.getDC(), rect, active); // TODO
|
|
size = add_horizontal(size, RealSize(14,16));
|
|
}
|
|
if (style().render_style & RENDER_IMAGE) {
|
|
map<String,ScriptableImage>::iterator it = style().choice_images.find(cannocial_name_form(choice));
|
|
if (it != style().choice_images.end() && it->second.isReady()) {
|
|
// TODO: caching
|
|
GeneratedImage::Options options(0,0, viewer.stylesheet.get(),&getSet());
|
|
options.zoom = dc.getZoom();
|
|
options.angle = dc.trAngle(style().angle);
|
|
Image image = it->second.generate(options);
|
|
ImageCombine combine = it->second.combine();
|
|
// TODO : alignment?
|
|
dc.DrawPreRotatedImage(image, RealRect(pos.x + size.width, pos.y, options.width, options.height), combine == COMBINE_DEFAULT ? style().combine : combine);
|
|
size.width += options.width;
|
|
}
|
|
}
|
|
if (style().render_style & RENDER_TEXT) {
|
|
// draw text
|
|
String text = tr(*viewer.stylesheet, choice, capitalize_sentence(choice));
|
|
RealSize text_size = dc.GetTextExtent(text);
|
|
dc.DrawText(text, align_in_rect(ALIGN_MIDDLE_LEFT, text_size,
|
|
RealRect(pos + RealSize(size.width + 1, 0), RealSize(0,size.height))));
|
|
size = add_horizontal(size, text_size);
|
|
}
|
|
// next position
|
|
pos = move_in_direction(style().direction, pos, size, style().spacing);
|
|
}
|