本文整理汇总了C++中MemChunk::exportFile方法的典型用法代码示例。如果您正苦于以下问题:C++ MemChunk::exportFile方法的具体用法?C++ MemChunk::exportFile怎么用?C++ MemChunk::exportFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemChunk
的用法示例。
在下文中一共展示了MemChunk::exportFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exportAsPNG
/* EntryOperations::exportAsPNG
* Converts [entry] to a PNG image (if possible) and saves the PNG
* data to a file [filename]. Does not alter the entry data itself
*******************************************************************/
bool EntryOperations::exportAsPNG(ArchiveEntry* entry, string filename)
{
// Check entry was given
if (!entry)
return false;
// Create image from entry
SImage image;
if (!Misc::loadImageFromEntry(&image, entry))
{
wxLogMessage("Error converting %s: %s", entry->getName(), Global::error);
return false;
}
// Write png data
MemChunk png;
SIFormat* fmt_png = SIFormat::getFormat("png");
if (!fmt_png->saveImage(image, png, theMainWindow->getPaletteChooser()->getSelectedPalette(entry)))
{
wxLogMessage("Error converting %s", entry->getName());
return false;
}
// Export file
return png.exportFile(filename);
}
示例2: write
/* ADatArchive::write
* Writes the dat archive to a file
* Returns true if successful, false otherwise
*******************************************************************/
bool ADatArchive::write(string filename, bool update) {
// Write to a MemChunk, then export it to a file
MemChunk mc;
if (write(mc, true))
return mc.exportFile(filename);
else
return false;
}
示例3: exit
// -----------------------------------------------------------------------------
// Application exit, shuts down and cleans everything up.
// If [save_config] is true, saves all configuration related files
// -----------------------------------------------------------------------------
void App::exit(bool save_config)
{
exiting = true;
if (save_config)
{
// Save configuration
saveConfigFile();
// Save text style configuration
StyleSet::saveCurrent();
// Save colour configuration
MemChunk ccfg;
ColourConfiguration::writeConfiguration(ccfg);
ccfg.exportFile(App::path("colours.cfg", App::Dir::User));
// Save game exes
wxFile f;
f.Open(App::path("executables.cfg", App::Dir::User), wxFile::write);
f.Write(Executables::writeExecutables());
f.Close();
// Save custom special presets
Game::saveCustomSpecialPresets();
// Save custom scripts
ScriptManager::saveUserScripts();
}
// Close all open archives
archive_manager.closeAll();
// Clean up
EntryType::cleanupEntryTypes();
Drawing::cleanupFonts();
OpenGL::Texture::clearAll();
// Clear temp folder
std::error_code error;
for (auto& item : std::filesystem::directory_iterator{ App::path("", App::Dir::Temp) })
{
if (!item.is_regular_file())
continue;
if (!std::filesystem::remove(item, error))
Log::warning("Could not clean up temporary file \"{}\": {}", item.path().string(), error.message());
}
// Close lua
Lua::close();
// Close DUMB
dumb_exit();
// Exit wx Application
wxGetApp().Exit();
}
示例4: exportEntry
bool exportEntry()
{
wxFileName fn(appPath(entry->getName(), DIR_TEMP));
fn.SetExt("mid");
// Convert to WAV data
MemChunk convdata;
// Doom Sound
if (entry->getType()->getFormat() == "snd_doom" ||
entry->getType()->getFormat() == "snd_doom_mac")
Conversions::doomSndToWav(entry->getMCData(), convdata);
// Doom PC Speaker Sound
else if (entry->getType()->getFormat() == "snd_speaker")
Conversions::spkSndToWav(entry->getMCData(), convdata);
// AudioT PC Speaker Sound
else if (entry->getType()->getFormat() == "snd_audiot")
Conversions::spkSndToWav(entry->getMCData(), convdata, true);
// Wolfenstein 3D Sound
else if (entry->getType()->getFormat() == "snd_wolf")
Conversions::wolfSndToWav(entry->getMCData(), convdata);
// Creative Voice File
else if (entry->getType()->getFormat() == "snd_voc")
Conversions::vocToWav(entry->getMCData(), convdata);
// Jaguar Doom Sound
else if (entry->getType()->getFormat() == "snd_jaguar")
Conversions::jagSndToWav(entry->getMCData(), convdata);
// Blood Sound
else if (entry->getType()->getFormat() == "snd_bloodsfx")
Conversions::bloodToWav(entry, convdata);
else
{
Global::error = S_FMT("Type %s can not be converted to WAV", CHR(entry->getType()->getName()));
return false;
}
// Export file and start monitoring if successful
filename = fn.GetFullPath();
if (convdata.exportFile(filename))
{
file_modified = wxFileModificationTime(filename);
Start(1000);
return true;
}
return false;
}
示例5: OnExit
/* MainApp::OnExit
* Application shutdown, run when program is closed
*******************************************************************/
int MainApp::OnExit()
{
exiting = true;
// Save configuration
saveConfigFile();
// Save text style configuration
StyleSet::saveCurrent();
// Save colour configuration
MemChunk ccfg;
ColourConfiguration::writeConfiguration(ccfg);
ccfg.exportFile(appPath("colours.cfg", DIR_USER));
// Save game exes
wxFile f;
f.Open(appPath("executables.cfg", DIR_USER), wxFile::write);
f.Write(Executables::writeExecutables());
f.Close();
// Close the map editor if it's open
MapEditorWindow::deleteInstance();
// Close all open archives
theArchiveManager->closeAll();
// Clean up
EntryType::cleanupEntryTypes();
ArchiveManager::deleteInstance();
Console::deleteInstance();
SplashWindow::deleteInstance();
// Clear temp folder
wxDir temp;
temp.Open(appPath("", DIR_TEMP));
string filename = wxEmptyString;
bool files = temp.GetFirst(&filename, wxEmptyString, wxDIR_FILES);
while (files)
{
if (!wxRemoveFile(appPath(filename, DIR_TEMP)))
wxLogMessage("Warning: Could not clean up temporary file \"%s\"", filename);
files = temp.GetNext(&filename);
}
// Close lua
Lua::close();
return 0;
}
示例6: openAudio
/* AudioEntryPanel::openAudio
* Opens an audio file for playback (SFML 2.x+)
*******************************************************************/
bool AudioEntryPanel::openAudio(MemChunk& audio, string filename)
{
// Stop if sound currently playing
resetStream();
// (Re)create sound buffer
if (sound_buffer)
delete sound_buffer;
sound_buffer = new sf::SoundBuffer();
audio_type = AUTYPE_INVALID;
// Load into buffer
if (sound_buffer->loadFromMemory((const char*)audio.getData(), audio.getSize()))
{
LOG_MESSAGE(3, "opened as sound");
// Bind to sound
sound->setBuffer(*sound_buffer);
audio_type = AUTYPE_SOUND;
// Enable play controls
#if (SFML_VERSION_MAJOR == 2 && SFML_VERSION_MINOR < 2)
// SFML before 2.2 has a bug where it reports an incorrect value for long sounds, so compute it ourselves then
setAudioDuration((sound_buffer->getSampleCount() / sound_buffer->getSampleRate())*(1000/sound_buffer->getChannelCount()));
#else
setAudioDuration(sound_buffer->getDuration().asMilliseconds());
#endif
btn_play->Enable();
btn_pause->Enable();
btn_stop->Enable();
return true;
}
else if (music->openFromMemory((const char*)audio.getData(), audio.getSize()))
{
LOG_MESSAGE(3, "opened as music");
// Couldn't open the audio as a sf::SoundBuffer, try sf::Music instead
audio_type = AUTYPE_MUSIC;
// Enable play controls
setAudioDuration(music->getDuration().asMilliseconds());
btn_play->Enable();
btn_stop->Enable();
return true;
}
else
{
// Couldn't open as sound or music, try the wxMediaCtrl
LOG_MESSAGE(3, "opened as media");
// Dump audio to temp file
audio.exportFile(filename);
if (openMedia(filename))
return true;
}
// Unable to open audio, disable play controls
setAudioDuration(0);
btn_play->Enable(false);
btn_pause->Enable(false);
btn_stop->Enable(false);
return false;
}