mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
Change tabs to two spaces.
This commit is contained in:
@@ -18,53 +18,53 @@ DECLARE_TYPEOF_COLLECTION(PackageChoiceValueViewer::Item);
|
||||
IMPLEMENT_VALUE_VIEWER(PackageChoice);
|
||||
|
||||
struct PackageChoiceValueViewer::ComparePackagePosHint {
|
||||
bool operator () (const PackagedP& a, const PackagedP& b) {
|
||||
// use position_hints to determine order
|
||||
if (a->position_hint < b->position_hint) return true;
|
||||
if (a->position_hint > b->position_hint) return false;
|
||||
// ensure a deterministic order: use the names
|
||||
return a->name() < b->name();
|
||||
}
|
||||
bool operator () (const PackagedP& a, const PackagedP& b) {
|
||||
// use position_hints to determine order
|
||||
if (a->position_hint < b->position_hint) return true;
|
||||
if (a->position_hint > b->position_hint) return false;
|
||||
// ensure a deterministic order: use the names
|
||||
return a->name() < b->name();
|
||||
}
|
||||
};
|
||||
|
||||
void PackageChoiceValueViewer::initItems() {
|
||||
vector<PackagedP> choices;
|
||||
package_manager.findMatching(field().match, choices);
|
||||
sort(choices.begin(), choices.end(), ComparePackagePosHint());
|
||||
FOR_EACH(p, choices) {
|
||||
Item i;
|
||||
i.package_name = p->relativeFilename();
|
||||
i.name = capitalize_sentence(p->short_name);
|
||||
Image image;
|
||||
InputStreamP stream = p->openIconFile();
|
||||
if (stream && image.LoadFile(*stream)) {
|
||||
i.image = Bitmap(resample(image, 16,16));
|
||||
}
|
||||
items.push_back(i);
|
||||
}
|
||||
vector<PackagedP> choices;
|
||||
package_manager.findMatching(field().match, choices);
|
||||
sort(choices.begin(), choices.end(), ComparePackagePosHint());
|
||||
FOR_EACH(p, choices) {
|
||||
Item i;
|
||||
i.package_name = p->relativeFilename();
|
||||
i.name = capitalize_sentence(p->short_name);
|
||||
Image image;
|
||||
InputStreamP stream = p->openIconFile();
|
||||
if (stream && image.LoadFile(*stream)) {
|
||||
i.image = Bitmap(resample(image, 16,16));
|
||||
}
|
||||
items.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
void PackageChoiceValueViewer::draw(RotatedDC& dc) {
|
||||
drawFieldBorder(dc);
|
||||
// find item
|
||||
String text = value().package_name;
|
||||
Bitmap image;
|
||||
if (value().package_name.empty()) {
|
||||
text = field().empty_name;
|
||||
} else {
|
||||
FOR_EACH(i, items) {
|
||||
if (i.package_name == value().package_name) {
|
||||
text = i.name;
|
||||
image = i.image;
|
||||
}
|
||||
}
|
||||
}
|
||||
// draw image
|
||||
if (image.Ok()) {
|
||||
dc.DrawBitmap(image, RealPoint(0,0));
|
||||
}
|
||||
// draw text
|
||||
dc.SetFont(style().font, 1.0);
|
||||
RealPoint pos = align_in_rect(ALIGN_MIDDLE_LEFT, RealSize(0, dc.GetCharHeight()), dc.getInternalRect()) + RealSize(17., 0);
|
||||
dc.DrawTextWithShadow(text, style().font, pos);
|
||||
drawFieldBorder(dc);
|
||||
// find item
|
||||
String text = value().package_name;
|
||||
Bitmap image;
|
||||
if (value().package_name.empty()) {
|
||||
text = field().empty_name;
|
||||
} else {
|
||||
FOR_EACH(i, items) {
|
||||
if (i.package_name == value().package_name) {
|
||||
text = i.name;
|
||||
image = i.image;
|
||||
}
|
||||
}
|
||||
}
|
||||
// draw image
|
||||
if (image.Ok()) {
|
||||
dc.DrawBitmap(image, RealPoint(0,0));
|
||||
}
|
||||
// draw text
|
||||
dc.SetFont(style().font, 1.0);
|
||||
RealPoint pos = align_in_rect(ALIGN_MIDDLE_LEFT, RealSize(0, dc.GetCharHeight()), dc.getInternalRect()) + RealSize(17., 0);
|
||||
dc.DrawTextWithShadow(text, style().font, pos);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user