/* MapEntryPanel::createImage * Creates a PNG file of the map preview * TODO: Preference panel for background and line colors, * as well as for image size *******************************************************************/ bool MapEntryPanel::createImage() { if (entry == NULL) return false; ArchiveEntry temp; // Stupid OpenGL grumble grumble grumble if (GLEW_ARB_framebuffer_object) map_canvas->createImage(temp, map_image_width, map_image_height); else map_canvas->createImage(temp, min<int>(map_image_width, map_canvas->GetSize().x), min<int>(map_image_height, map_canvas->GetSize().y)); string name = S_FMT("%s_%s", CHR(entry->getParent()->getFilename(false)), CHR(entry->getName())); wxFileName fn(name); // Create save file dialog wxFileDialog dialog_save(this, S_FMT("Save Map Preview \"%s\"", name.c_str()), dir_last, fn.GetFullName(), "PNG (*.PNG)|*.png", wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition); // Run the dialog & check that the user didn't cancel if (dialog_save.ShowModal() == wxID_OK) { // If a filename was selected, export it bool ret = temp.exportFile(dialog_save.GetPath()); // Save 'dir_last' dir_last = dialog_save.GetDirectory(); return ret; } return true; }
/* SplashWindow::init * Sets up the splash window *******************************************************************/ void SplashWindow::init() { // Load logo image string tempfile = appPath("temp.png", DIR_TEMP); ArchiveEntry* logo = theArchiveManager->programResourceArchive()->getEntry("logo.png"); if (logo) { logo->exportFile(tempfile); bm_logo.LoadFile(tempfile, wxBITMAP_TYPE_PNG); } // Clean up wxRemoveFile(tempfile); }
/* loadIcons * Loads all icons from slade.pk3 (in the icons/ dir) *******************************************************************/ bool loadIcons() { string tempfile = appPath("sladetemp", DIR_TEMP); // Get slade.pk3 Archive* res_archive = theArchiveManager->programResourceArchive(); // Do nothing if it doesn't exist if (!res_archive) return false; // Get the icons directory of the archive ArchiveTreeNode* dir_icons = res_archive->getDir("icons/"); // Go through each entry in the directory for (size_t a = 0; a < dir_icons->numEntries(false); a++) { ArchiveEntry* entry = dir_icons->getEntry(a); // Export entry data to a temporary file entry->exportFile(tempfile); // Create / setup icon icon_t n_icon; n_icon.image.LoadFile(tempfile); // Load image from temp file n_icon.name = entry->getName(true); // Set icon name // Add the icon icons.push_back(n_icon); // Delete the temporary file wxRemoveFile(tempfile); } return true; }
bool loadIconsDir(int type, ArchiveTreeNode* dir) { if (!dir) return false; // Check for icon set dirs for (unsigned a = 0; a < dir->nChildren(); a++) { if (dir->getChild(a)->getName() != "large") { if (type == GENERAL) iconsets_general.push_back(dir->getChild(a)->getName()); else if (type == ENTRY) iconsets_entry.push_back(dir->getChild(a)->getName()); } } // Get icon set dir string icon_set_dir = "Default"; if (type == ENTRY) icon_set_dir = iconset_entry_list; if (type == GENERAL) icon_set_dir = iconset_general; if (icon_set_dir != "Default" && dir->getChild(icon_set_dir)) dir = (ArchiveTreeNode*)dir->getChild(icon_set_dir); vector<icon_t>& icons = iconList(type); string tempfile = appPath("sladetemp", DIR_TEMP); // Go through each entry in the directory for (size_t a = 0; a < dir->numEntries(false); a++) { ArchiveEntry* entry = dir->getEntry(a); // Ignore anything not png format if (!entry->getName().EndsWith("png")) continue; // Export entry data to a temporary file entry->exportFile(tempfile); // Create / setup icon icon_t n_icon; n_icon.image.LoadFile(tempfile); // Load image from temp file n_icon.name = entry->getName(true); // Set icon name n_icon.resource_entry = entry; // Add the icon icons.push_back(n_icon); // Delete the temporary file wxRemoveFile(tempfile); } // Go through large icons ArchiveTreeNode* dir_large = (ArchiveTreeNode*)dir->getChild("large"); if (dir_large) { for (size_t a = 0; a < dir_large->numEntries(false); a++) { ArchiveEntry* entry = dir_large->getEntry(a); // Ignore anything not png format if (!entry->getName().EndsWith("png")) continue; // Export entry data to a temporary file entry->exportFile(tempfile); // Create / setup icon bool found = false; string name = entry->getName(true); for (unsigned i = 0; i < icons.size(); i++) { if (icons[i].name == name) { icons[i].image_large.LoadFile(tempfile); found = true; break; } } if (!found) { icon_t n_icon; n_icon.image_large.LoadFile(tempfile); // Load image from temp file n_icon.name = entry->getName(true); // Set icon name n_icon.resource_entry = entry; // Add the icon icons.push_back(n_icon); } // Delete the temporary file wxRemoveFile(tempfile); } } return true; }