mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
Use LocalFileName class for file names inside a package.
This commit is contained in:
@@ -50,10 +50,10 @@ ImageFieldP ImageCardList::findImageField() {
|
||||
/// A request for a thumbnail of a card image
|
||||
class CardThumbnailRequest : public ThumbnailRequest {
|
||||
public:
|
||||
CardThumbnailRequest(ImageCardList* parent, const String& filename)
|
||||
CardThumbnailRequest(ImageCardList* parent, const LocalFileName& filename)
|
||||
: ThumbnailRequest(
|
||||
parent,
|
||||
_("card") + parent->set->absoluteFilename() + _("-") + filename,
|
||||
_("card") + parent->set->absoluteFilename() + _("-") + filename.toStringForKey(),
|
||||
wxDateTime::Now()) // TODO: Find mofication time of card image
|
||||
, filename(filename)
|
||||
{}
|
||||
@@ -78,23 +78,23 @@ class CardThumbnailRequest : public ThumbnailRequest {
|
||||
if (img.Ok()) {
|
||||
wxImageList* il = parent->GetImageList(wxIMAGE_LIST_SMALL);
|
||||
int id = il->Add(wxBitmap(img));
|
||||
parent->thumbnails.insert(make_pair(filename, id));
|
||||
parent->thumbnails.insert(make_pair(filename.toStringForKey(), id));
|
||||
parent->Refresh(false);
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool threadSafe() const {return true;}
|
||||
private:
|
||||
String filename;
|
||||
private:
|
||||
LocalFileName filename;
|
||||
};
|
||||
|
||||
int ImageCardList::OnGetItemImage(long pos) const {
|
||||
if (image_field) {
|
||||
// Image = thumbnail of first image field of card
|
||||
ImageValue& val = static_cast<ImageValue&>(*getCard(pos)->data[image_field]);
|
||||
if (!val.filename) return -1; // no image
|
||||
if (val.filename.empty()) return -1; // no image
|
||||
// is there already a thumbnail?
|
||||
map<String,int>::const_iterator it = thumbnails.find(val.filename);
|
||||
map<String,int>::const_iterator it = thumbnails.find(val.filename.toStringForKey());
|
||||
if (it != thumbnails.end()) {
|
||||
return it->second;
|
||||
} else {
|
||||
|
||||
@@ -252,7 +252,7 @@ void SymbolWindow::onFileStore(wxCommandEvent& ev) {
|
||||
if (performer) {
|
||||
SymbolValueP value = static_pointer_cast<SymbolValue>(performer->value);
|
||||
Package& package = performer->getLocalPackage();
|
||||
FileName new_filename = package.newFileName(value->field().name,_(".mse-symbol")); // a new unique name in the package
|
||||
LocalFileName new_filename = package.newFileName(value->field().name,_(".mse-symbol")); // a new unique name in the package
|
||||
auto stream = package.openOut(new_filename);
|
||||
Writer writer(*stream, file_version_symbol);
|
||||
writer.handle(control->getSymbol());
|
||||
|
||||
@@ -45,7 +45,7 @@ void ImageValueEditor::sliceImage(const Image& image) {
|
||||
// clicked ok?
|
||||
if (s.ShowModal() == wxID_OK) {
|
||||
// store the image into the set
|
||||
FileName new_image_file = getLocalPackage().newFileName(field().name,_("")); // a new unique name in the package
|
||||
LocalFileName new_image_file = getLocalPackage().newFileName(field().name,_("")); // a new unique name in the package
|
||||
Image img = s.getImage();
|
||||
img.SaveFile(getLocalPackage().nameOut(new_image_file), wxBITMAP_TYPE_PNG); // always use PNG images, see #69. Disk space is cheap anyway.
|
||||
addAction(value_action(valueP(), new_image_file));
|
||||
@@ -88,7 +88,7 @@ bool ImageValueEditor::doPaste() {
|
||||
}
|
||||
|
||||
bool ImageValueEditor::doDelete() {
|
||||
addAction(value_action(valueP(), FileName()));
|
||||
addAction(value_action(valueP(), LocalFileName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user