virtual ReadResult readNode(const std::string &file, const Options *options) const
{
    ReadResult result = openArchive(file, osgDB::Archive::READ);

    if (!result.validArchive())
        return result;


    // copy the incoming options if possible so that plugin options can be applied to files
    // inside the archive
    osg::ref_ptr<osgDB::ReaderWriter::Options> local_options =
        options ?
        new osgDB::ReaderWriter::Options(*options) :
        new osgDB::ReaderWriter::Options;

    local_options->setDatabasePath(file);

    ReadResult result_2 = result.getArchive()->readNode(result.getArchive()->getMasterFileName(), local_options.get());


    if (!options || (options->getObjectCacheHint() & osgDB::ReaderWriter::Options::CACHE_ARCHIVES))
    {
        // register the archive so that it is cached for future use.
        osgDB::Registry::instance()->addToArchiveCache(file, result.getArchive());
    }

    return result_2;
}
Exemplo n.º 2
0
/*
 * initialize (this always needs to be done)
 */
int init(char const * archivePath, char  const * archiveName, char const * workpath)
{
#ifdef WIN32
	char *p;
#endif

	if (workpath) {
		f_workpath = (char *)workpath;
#ifdef WIN32
		strcpy(f_temppathraw, f_workpath);
		for ( p = f_temppathraw; *p; p++ )
			if (*p == '/')
				*p = '\\';
#endif
	}

	/* Set up paths */
	if (setPaths(archivePath, archiveName))
		return -1;

	/* Open the archive */
	if (openArchive())
		return -1;

	return 0;
}
Exemplo n.º 3
0
bool KArchive::open(QIODevice::OpenMode mode)
{
    Q_ASSERT(mode != QIODevice::NotOpen);

    if (isOpen()) {
        close();
    }

    if (!d->fileName.isEmpty()) {
        Q_ASSERT(!d->dev);
        if (!createDevice(mode)) {
            return false;
        }
    }

    if (!d->dev) {
        setErrorString(tr("No filename or device was specified"));
        return false;
    }

    if (!d->dev->isOpen() && !d->dev->open(mode)) {
        setErrorString(tr("Could not set device mode to %1").arg(mode));
        return false;
    }

    d->mode = mode;

    Q_ASSERT(!d->rootDir);
    d->rootDir = nullptr;

    return openArchive(mode);
}
Exemplo n.º 4
0
bool PimSettingsBackupRestore::restoreStart(const QString &filename)
{
    if (mStored.isEmpty()) {
        addDate();
        Q_EMIT addInfo(i18n("No data selected."));
        Q_EMIT jobFailed();
        deleteLater();
        return false;
    }
    if (!openArchive(filename, false)) {
        Q_EMIT addError(i18n("Unable to open file \"%1\".", filename));
        Q_EMIT jobFailed();
        deleteLater();
        return false;
    }
    Q_EMIT updateActions(true);
    mAction = Restore;
    mStoreIterator = mStored.constBegin();
    const int version = Utils::archiveVersion(mArchiveStorage->archive());
    if (version > Utils::currentArchiveVersion()) {
        if (!continueToRestore()) {
            return false;
        }
    }
    qCDebug(PIMSETTINGEXPORTERCORE_LOG) << " version " << version;
    AbstractImportExportJob::setArchiveVersion(version);

    addDate();

    Q_EMIT addInfo(i18n("Starting to restore data from \'%1\'", mArchiveStorage->filename()));
    Q_EMIT addEndLine();
    restoreNextStep();
    return true;
}
Exemplo n.º 5
0
bool PimSettingsBackupRestore::backupStart(const QString &filename)
{
    if (mStored.isEmpty()) {
        addDate();
        Q_EMIT addInfo(i18n("No data selected."));
        Q_EMIT jobFailed();
        deleteLater();
        return false;
    }
    if (!openArchive(filename, true)) {
        Q_EMIT addError(i18n("Unable to open file \"%1\".", filename));
        Q_EMIT jobFailed();
        deleteLater();
        return false;
    }
    Q_EMIT updateActions(true);
    mAction = Backup;
    mStoreIterator = mStored.constBegin();
    addDate();
    Q_EMIT addInfo(i18n("Starting to backup data in \'%1\'", mArchiveStorage->filename()));
    Q_EMIT addEndLine();
    //Add version
    Utils::addVersion(mArchiveStorage->archive());
    backupNextStep();
    return true;
}
Exemplo n.º 6
0
bool KArchive::open( QIODevice::OpenMode mode )
{
	Q_ASSERT( mode != QIODevice::NotOpen );

	if ( isOpen() )
		close();

	if ( !d->fileName.isEmpty() )
	{
		Q_ASSERT( !d->dev );
		if ( !createDevice( mode ) )
			return false;
	}

	Q_ASSERT( d->dev );

	if ( !d->dev->isOpen() && !d->dev->open( mode ) )
		return false;

	d->mode = mode;

	Q_ASSERT( !d->rootDir );
	d->rootDir = 0;

	return openArchive( mode );
}
Exemplo n.º 7
0
bool QArchive::open(QIODevice::OpenMode mode)
{
    Q_ASSERT(mode != QIODevice::NotOpen);

    if (isOpen())
        close();


    if (!m_fileName.isEmpty())
    {
       Q_ASSERT(!m_dev);
       if (!createDevice(mode))
        return false;

    }

    if (!m_dev)
        return false;

    if (!m_dev->isOpen() && !m_dev->open(mode))
        return false;

    m_mode = mode;

    Q_ASSERT(!m_rootDir);
    m_rootDir = 0;

    return openArchive(mode);
}
Exemplo n.º 8
0
void LSMainWindow::createActions() {
	m_newArchiveAction = new QAction("&New Archive", this);
	m_openArchiveAction = new QAction("&Open Archive...", this);
	m_saveAction = new QAction("&Save", this);
	m_saveArchiveAsAction = new QAction("Save Archive &As...", this);

	m_newArchiveAction->setShortcuts(QKeySequence::New);
	m_openArchiveAction->setShortcuts(QKeySequence::Open);
	m_saveAction->setShortcuts(QKeySequence::Save);
	m_saveArchiveAsAction->setShortcuts(QKeySequence::SaveAs);

	connect(m_newArchiveAction, SIGNAL(triggered()), SLOT(newArchive()));
	connect(m_openArchiveAction, SIGNAL(triggered()), SLOT(openArchive()));
	connect(m_saveAction, SIGNAL(triggered()), SLOT(save()));
	connect(m_saveArchiveAsAction, SIGNAL(triggered()), SLOT(saveArchiveAs()));

	m_addLayoutAction = new QAction("New &Layout...", this);
	m_addAnimationAction = new QAction("New &Animation...", this);
	m_addTextureAction = new QAction("New &Texture...", this);
	m_importNewAction = new QAction("&New Item...", this);
	m_importAction = new QAction("&Replace This Item...", this);
	m_exportAction = new QAction("&Export to File...", this);
	m_renameAction = new QAction("Re&name Item...", this);
	m_removeAction = new QAction("&Remove Item...", this);

	m_addActionMapper = new QSignalMapper(this);
	m_addActionMapper->setMapping(m_addLayoutAction, (int)LYTPackageBase::Layout);
	m_addActionMapper->setMapping(m_addAnimationAction, (int)LYTPackageBase::Animation);
	m_addActionMapper->setMapping(m_addTextureAction, (int)LYTPackageBase::Texture);

	connect(m_addLayoutAction, SIGNAL(triggered()), m_addActionMapper, SLOT(map()));
	connect(m_addAnimationAction, SIGNAL(triggered()), m_addActionMapper, SLOT(map()));
	connect(m_addTextureAction, SIGNAL(triggered()), m_addActionMapper, SLOT(map()));
	connect(m_addActionMapper, SIGNAL(mapped(int)), SLOT(handleAddSomething(int)));

	connect(m_renameAction, SIGNAL(triggered()), SLOT(handleRenameItem()));
	connect(m_removeAction, SIGNAL(triggered()), SLOT(handleRemoveItem()));

	QMenuBar *bar = menuBar();
	QMenu *m;

	m = bar->addMenu("&File");
	m->addAction(m_newArchiveAction);
	m->addAction(m_openArchiveAction);
	m->addAction(m_saveAction);
	m->addAction(m_saveArchiveAsAction);

	m = bar->addMenu("&Edit");
	m->addAction(m_addLayoutAction);
	m->addAction(m_addAnimationAction);
	m->addAction(m_addTextureAction);
	m->addSeparator();
	QMenu *importMenu = m->addMenu("&Import from File");
	importMenu->addAction(m_importNewAction);
	importMenu->addAction(m_importAction);
	m->addAction(m_exportAction);
	m->addSeparator();
	m->addAction(m_renameAction);
	m->addAction(m_removeAction);
}
//----------------------------------------------------------------------------//
void MinizipResourceProvider::setArchive(const String& archive)
{
    if (d_pimpl->d_zfile)
        closeArchive();

    d_pimpl->d_archive = archive;
    openArchive();
}
Exemplo n.º 10
0
void initLoad(){
	/*ファイルオープン*/
	ARCHIVE archive;
	openArchive(&archive,LOAD_ARCHIVE);
	/*背景取得*/
	SDL_RWops* bgData = getGraphixFile(&archive,LOAD_BG);
	getSpriteFromOPS(&LoadBGSprite,bgData);
	bgData->close(bgData);					//メモリ開放は忘れずに
	closeArchive(&archive);
	
}
Exemplo n.º 11
0
/*
 * initialize (this always needs to be done)
 */
int init(ARCHIVE_STATUS *status, char const * archivePath, char  const * archiveName)
{
	/* Set up paths */
	if (setPaths(status, archivePath, archiveName))
		return -1;

	/* Open the archive */
	if (openArchive(status))
		return -1;

	return 0;
}
Exemplo n.º 12
0
/*
 * Launch an archive with the given fully-qualified path name
 * No command line, no extracting of binaries
 * Designed for embedding situations.
 */
int launchembedded(char const * archivePath, char  const * archiveName)
{
	char pathnm[_MAX_PATH];

	VS("START\n");
	strcpy(pathnm, archivePath);
	strcat(pathnm, archiveName);
	/* Set up paths */
	if (setPaths(archivePath, archiveName))
		return -1;
	VS("Got Paths\n");
	/* Open the archive */
	if (openArchive())
		return -1;
	VS("Opened Archive\n");
	/* Load Python DLL */
	if (loadPython())
		return -1;

	/* Start Python with silly command line */
	if (startPython(1, (char**)&pathnm))
		return -1;
	VS("Started Python\n");

	/* a signal to scripts */
	PyRun_SimpleString("import sys;sys.frozen='dll'\n");
	VS("set sys.frozen\n");
	/* Import modules from archive - this is to bootstrap */
	if (importModules())
		return -1;
	VS("Imported Modules\n");
	/* Install zlibs - now import hooks are in place */
	if (installZlibs())
		return -1;
	VS("Installed Zlibs\n");
	/* Run scripts */
	if (runScripts())
		return -1;
	VS("All scripts run\n");
	if (PyErr_Occurred()) {
		// PyErr_Print();
		//PyErr_Clear();
		VS("Some error occurred\n");
	}
	VS("OK.\n");

	return 0;
}
Exemplo n.º 13
0
        virtual ReadResult readImage(std::istream& fin,const osgDB::ReaderWriter::Options* options) const
        {
            osgDB::ReaderWriter::ReadResult result = openArchive(fin, options);

            if (!result.validArchive()) return result;

            osg::ref_ptr<osgDB::Archive> archive = result.getArchive();

            // copy the incoming options if possible so that plugin options can be applied to files
            // inside the archive
            osg::ref_ptr<osgDB::ReaderWriter::Options> local_options = options?
                options->cloneOptions() :
                new osgDB::ReaderWriter::Options;

            return readImageFromArchive(*archive, local_options.get());
        }
Exemplo n.º 14
0
bool KArchive::open(int mode)
{
    if(m_dev && !m_dev->open(mode))
        return false;

    if(m_open)
        close();

    m_mode = mode;
    m_open = true;

    Q_ASSERT(d->rootDir == 0L);
    d->rootDir = 0L;

    return openArchive(mode);
}
Exemplo n.º 15
0
/* ArchiveManager::addArchive
 * Adds an archive to the archive list
 *******************************************************************/
bool ArchiveManager::addArchive(Archive* archive)
{
	// Only add if archive is a valid pointer
	if (archive)
	{
		// Add to the list
		archive_t n_archive;
		n_archive.archive = archive;
		n_archive.resource = true;
		open_archives.push_back(n_archive);

		// Listen to the archive
		listenTo(archive);

		// Announce the addition
		announce("archive_added");

		// Add to resource manager
		theResourceManager->addArchive(archive);

		// ZDoom also loads any WADs found in the root of a PK3 or directory
		if ((archive->getType() == ARCHIVE_ZIP || archive->getType() == ARCHIVE_FOLDER) && auto_open_wads_root)
		{
			ArchiveTreeNode* root = archive->getRoot();
			ArchiveEntry* entry;
			EntryType* type;
			for (unsigned a = 0; a < root->numEntries(); a++)
			{
				entry = root->getEntry(a);

				if (entry->getType() == EntryType::unknownType())
					EntryType::detectEntryType(entry);

				type = entry->getType();

				if (type->getId() == "wad")
					// First true: yes, manage this
					// Second true: open silently, don't open a tab for it
					openArchive(entry, true, true);
			}
		}

		return true;
	}
	else
		return false;
}
Exemplo n.º 16
0
int main(int argc, char **argv) {
  struct arguments arguments;

  /* Default values. */
  arguments.silent = 0;
  arguments.verbose = 0;

  /* Parse our arguments; every option seen by parse_opt will be reflected in
   * arguments. */
  argp_parse(&argp, argc, argv, 0, 0, &arguments);

  char *real_path = realpath("./", NULL);

  /* Create output folder */
  char *output_folder = remove_ext(arguments.args[0], '.', '/');
  struct stat st = {0};

  if (stat(output_folder, &st) == -1) {
    mkdir(output_folder, 0700);
  }

  struct DAR_ARCHIVE *archive = openArchive(arguments.args[0]);
  for (uint32_t index = 0; index < archive->count; index++) {
    // Output file name
    const size_t path_size =
        strlen(output_folder) + strlen(archive->entries[index].name) + 2;
    char *path = malloc(path_size);

    // Build output filename
    snprintf(path, path_size, "%s/%s", output_folder,
             archive->entries[index].name);

    // Write file
    FILE *write_ptr = fopen(path, "wb");
    fwrite(archive->entries[index].data, archive->entries[index].size, 1,
           write_ptr);

    // Free resources
    fclose(write_ptr);
    free(path);
  }

  return 0;
  // struct DAR_ARCHIVE *archive =
  // openArchive("/home/dustin/.wine/drive_c/Program Files (x86)/Metal Gear
  // Solid/stage/s19br/stg_tex1.dar");
}
Exemplo n.º 17
0
bool ZipArchive::openArchive(const char *filename, AccessMode mode /* = Read */)
{
   if(mode != Read && mode != Write && mode != ReadWrite)
      return false;

   closeArchive();

   mDiskStream = new FileStream;
   if(mDiskStream->open(filename, (Torque::FS::File::AccessMode)mode))
   {
      setFilename(filename);

      if(openArchive(mDiskStream, mode))
         return true;
   }
   
   // Cleanup just in case openArchive() failed
   closeArchive();

   return false;
}
Exemplo n.º 18
0
/* Look for the archive identified by path into the ARCHIVE_STATUS pool status_list.
 * If the archive is found, a pointer to the associated ARCHIVE_STATUS is returned
 * otherwise the needed archive is opened and added to the pool and then returned.
 * If an error occurs, returns NULL.
 */
static ARCHIVE_STATUS *get_archive(ARCHIVE_STATUS *status_list[], const char *path)
{
    ARCHIVE_STATUS *status = NULL;
    int i = 0;

    VS("Getting file from archive.\n");
    if (createTempPath(status_list[SELF]) == -1){
        return NULL;
    }

    for (i = 1; status_list[i] != NULL; i++){
        if (strcmp(status_list[i]->archivename, path) == 0) {
            VS("Archive found: %s\n", path);
            return status_list[i];
        }
        VS("Checking next archive in the list...\n");
    }

    if ((status = (ARCHIVE_STATUS *) calloc(1, sizeof(ARCHIVE_STATUS))) == NULL) {
        FATALERROR("Error allocating memory for status\n");
        return NULL;
    }

    strcpy(status->archivename, path);
    strcpy(status->homepath, status_list[SELF]->homepath);
    strcpy(status->temppath, status_list[SELF]->temppath);
#ifdef WIN32
    strcpy(status->homepathraw, status_list[SELF]->homepathraw);
    strcpy(status->temppathraw, status_list[SELF]->temppathraw);
#endif

    if (openArchive(status)) {
        FATALERROR("Error openning archive %s\n", path);
        free(status);
        return NULL;
    }

    status_list[i] = status;
    return status;
}
Exemplo n.º 19
0
// -----------------------------------------------------------------------------
// Adds an archive to the archive list
// -----------------------------------------------------------------------------
bool ArchiveManager::addArchive(Archive* archive)
{
	// Only add if archive is a valid pointer
	if (archive)
	{
		// Add to the list
		OpenArchive n_archive;
		n_archive.archive  = archive;
		n_archive.resource = true;
		open_archives_.push_back(n_archive);

		// Listen to the archive
		listenTo(archive);

		// Announce the addition
		announce("archive_added");

		// Add to resource manager
		theResourceManager->addArchive(archive);

		// ZDoom also loads any WADs found in the root of a PK3 or directory
		if ((archive->formatId() == "zip" || archive->formatId() == "folder") && auto_open_wads_root)
		{
			for (const auto& entry : archive->rootDir()->allEntries())
			{
				if (entry->type() == EntryType::unknownType())
					EntryType::detectEntryType(entry.get());

				if (entry->type()->id() == "wad")
					// First true: yes, manage this
					// Second true: open silently, don't open a tab for it
					openArchive(entry.get(), true, true);
			}
		}

		return true;
	}
	else
		return false;
}
Exemplo n.º 20
0
void MainWindow::setupActions()
{
    m_newAction = actionCollection()->addAction(KStandardAction::New, QStringLiteral("ark_file_new"), this, SLOT(newArchive()));
    m_openAction = actionCollection()->addAction(KStandardAction::Open, QStringLiteral("ark_file_open"), this, SLOT(openArchive()));
    actionCollection()->addAction(KStandardAction::Quit, QStringLiteral("ark_quit"), this, SLOT(quit()));

    m_recentFilesAction = KStandardAction::openRecent(this, SLOT(openUrl(QUrl)), Q_NULLPTR);
    actionCollection()->addAction(QStringLiteral("ark_file_open_recent"), m_recentFilesAction);

    m_recentFilesAction->setToolBarMode(KRecentFilesAction::MenuMode);
    m_recentFilesAction->setToolButtonPopupMode(QToolButton::DelayedPopup);
    m_recentFilesAction->setIconText(i18nc("action, to open an archive", "Open"));
    m_recentFilesAction->setToolTip(i18n("Open an archive"));
    m_recentFilesAction->loadEntries(KSharedConfig::openConfig()->group("Recent Files"));

    KStandardAction::preferences(this, SLOT(showSettings()), actionCollection());
}
Exemplo n.º 21
0
int launch(char const * archivePath, char  const * archiveName)
{
	PyObject *obHandle;
	int loadedNew = 0;
	char pathnm[_MAX_PATH];

    VS("START");
	strcpy(pathnm, archivePath);
	strcat(pathnm, archiveName);
    /* Set up paths */
    if (setPaths(archivePath, archiveName))
        return -1;
	VS("Got Paths");
    /* Open the archive */
    if (openArchive())
        return -1;
	VS("Opened Archive");
    /* Load Python DLL */
    if (attachPython(&loadedNew))
        return -1;

	if (loadedNew) {
		/* Start Python with silly command line */
		PyEval_InitThreads();
		if (startPython(1, (char**)&pathnm))
			return -1;
		VS("Started new Python");
		thisthread = PyThreadState_Swap(NULL);
		PyThreadState_Swap(thisthread);
	}
	else {
		VS("Attached to existing Python");

		/* start a mew interp */
		thisthread = PyThreadState_Swap(NULL);
		PyThreadState_Swap(thisthread);
		if (thisthread == NULL) {
			thisthread = Py_NewInterpreter();
			VS("created thisthread");
		}
		else
			VS("grabbed thisthread");
		PyRun_SimpleString("import sys;sys.argv=[]");
	}

	/* a signal to scripts */
	PyRun_SimpleString("import sys;sys.frozen='dll'\n");
	VS("set sys.frozen");
	/* Create a 'frozendllhandle' as a counterpart to
	   sys.dllhandle (which is the Pythonxx.dll handle)
	*/
	obHandle = Py_BuildValue("i", gInstance);
	PySys_SetObject("frozendllhandle", obHandle);
	Py_XDECREF(obHandle);
    /* Import modules from archive - this is to bootstrap */
    if (importModules())
        return -1;
	VS("Imported Modules");
    /* Install zlibs - now import hooks are in place */
    if (installZlibs())
        return -1;
	VS("Installed Zlibs");
    /* Run scripts */
    if (runScripts())
        return -1;
	VS("All scripts run");
    if (PyErr_Occurred()) {
		// PyErr_Print();
		//PyErr_Clear();
		VS("Some error occurred");
    }
	VS("PGL released");
	// Abandon our thread state.
	PyEval_ReleaseThread(thisthread);
    VS("OK.");
    return 0;
}
Exemplo n.º 22
0
void ZoneViewerWindow::initMenus()
{
    QMenu *fileMenu = new QMenu(this);
    fileMenu->setTitle("&File");

    QAction *openAction = new QAction("&Open S3D archive...", this);
    openAction->setShortcut(QKeySequence::Open);
    QAction *clearAction = new QAction("&Clear", this);
    QAction *selectDirAction = new QAction("Select Asset Directory...", this);

    QAction *quitAction = new QAction("&Quit", this);
    quitAction->setShortcut(QKeySequence::Quit);

    fileMenu->addAction(openAction);
    fileMenu->addAction(clearAction);
    fileMenu->addAction(selectDirAction);
    fileMenu->addSeparator();
    fileMenu->addAction(quitAction);

    QMenu *renderMenu = new QMenu(this);
    renderMenu->setTitle("&Render");

    m_noLightingAction = new QAction("No Lighting", this);
    m_bakedLightingAction = new QAction("Baked Lighting", this);
    m_debugVertexColorAction = new QAction("Show Vertex Color", this);
    m_debugTextureFactorAction = new QAction("Show Texture Blend Factor", this);
    m_debugDiffuseAction = new QAction("Show Diffuse Factor", this);
    m_noLightingAction->setCheckable(true);
    m_bakedLightingAction->setCheckable(true);
    m_debugVertexColorAction->setCheckable(true);
    m_debugTextureFactorAction->setCheckable(true);
    m_debugDiffuseAction->setCheckable(true);
    m_bakedLightingAction->setEnabled(false);
    m_debugDiffuseAction->setEnabled(false);
    QActionGroup *lightingActions = new QActionGroup(this);
    lightingActions->addAction(m_noLightingAction);
    lightingActions->addAction(m_bakedLightingAction);
    lightingActions->addAction(m_debugVertexColorAction);
    lightingActions->addAction(m_debugTextureFactorAction);
    lightingActions->addAction(m_debugDiffuseAction);

    m_showFpsAction = new QAction("Show Stats", this);
    m_showFpsAction->setCheckable(true);
    m_showZoneAction = new QAction("Show Zone", this);
    m_showZoneAction->setCheckable(true);
    m_showZoneAction->setChecked(m_scene->game()->showZone());
    m_showZoneObjectsAction = new QAction("Show Zone Objects", this);
    m_showZoneObjectsAction->setCheckable(true);
    m_showFogAction = new QAction("Show Fog", this);
    m_showFogAction->setCheckable(true);
    m_showFogAction->setChecked(m_scene->game()->showFog());
    m_showZoneObjectsAction->setChecked(m_scene->game()->showObjects());
    m_cullZoneObjectsAction = new QAction("Frustum Culling of Zone Objects", this);
    m_cullZoneObjectsAction->setCheckable(true);
    m_cullZoneObjectsAction->setChecked(m_scene->game()->cullObjects());
    m_showSoundTriggersAction = new QAction("Show Sound Triggers", this);
    m_showSoundTriggersAction->setCheckable(true);

    renderMenu->addAction(m_noLightingAction);
    renderMenu->addAction(m_bakedLightingAction);
    renderMenu->addAction(m_debugVertexColorAction);
    renderMenu->addAction(m_debugTextureFactorAction);
    renderMenu->addAction(m_debugDiffuseAction);
    renderMenu->addSeparator();
    renderMenu->addAction(m_showFpsAction);
    renderMenu->addAction(m_showZoneAction);
    renderMenu->addAction(m_showZoneObjectsAction);
    renderMenu->addAction(m_cullZoneObjectsAction);
    renderMenu->addAction(m_showFogAction);
    renderMenu->addAction(m_showSoundTriggersAction);

    menuBar()->addMenu(fileMenu);
    menuBar()->addMenu(renderMenu);

    updateMenus();

    connect(openAction, SIGNAL(triggered()), this, SLOT(openArchive()));
    connect(clearAction, SIGNAL(triggered()), this, SLOT(clearZone()));
    connect(selectDirAction, SIGNAL(triggered()), this, SLOT(selectAssetDir()));
    connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));

    connect(m_noLightingAction, SIGNAL(triggered()), this, SLOT(setNoLighting()));
    connect(m_bakedLightingAction, SIGNAL(triggered()), this, SLOT(setBakedLighting()));
    connect(m_debugVertexColorAction, SIGNAL(triggered()), this, SLOT(setDebugVertexColor()));
    connect(m_debugTextureFactorAction, SIGNAL(triggered()), this, SLOT(setDebugTextureFactor()));
    connect(m_debugDiffuseAction, SIGNAL(triggered()), this, SLOT(setDebugDiffuse()));
    connect(m_showFpsAction, SIGNAL(toggled(bool)), m_viewport, SLOT(setShowStats(bool)));
    connect(m_showZoneAction, SIGNAL(toggled(bool)), m_scene, SLOT(showZone(bool)));
    connect(m_showZoneObjectsAction, SIGNAL(toggled(bool)), m_scene, SLOT(showZoneObjects(bool)));
    connect(m_showFogAction, SIGNAL(toggled(bool)), m_scene, SLOT(showFog(bool)));
    connect(m_cullZoneObjectsAction, SIGNAL(toggled(bool)), m_scene, SLOT(setFrustumCulling(bool)));
    connect(m_showSoundTriggersAction, SIGNAL(toggled(bool)), m_scene, SLOT(showSoundTriggers(bool)));
}
Exemplo n.º 23
0
Common::Error BladeRunnerEngine::run() {
	Graphics::PixelFormat format = createRGB555();
	initGraphics(640, 480, &format);

	_system->showMouse(true);

	bool hasSavegames = !SaveFileManager::list(_targetName).empty();

	if (!startup(hasSavegames)) {
		shutdown();
		return Common::Error(Common::kUnknownError, "Failed to initialize resources");
	}



#if BLADERUNNER_DEBUG_GAME
	{
#else
	if (warnUserAboutUnsupportedGame()) {
#endif
		if (hasSavegames) {
			_kia->_forceOpen = true;
			_kia->open(kKIASectionLoad);
		}
		// TODO: why is game starting new game here when everything is done in startup?
		//  else {
		// 	newGame(1);
		// }

		gameLoop();

		_mouse->disable();

		if (_gameOver) {
			// autoSaveGame(4, 1); // TODO
			_endCredits->show();
		}
	}

	shutdown();

	return Common::kNoError;
}

bool BladeRunnerEngine::startup(bool hasSavegames) {
	// These are static objects in original game

	_screenEffects = new ScreenEffects(this, 0x8000);

	_endCredits = new EndCredits(this);

	_actorDialogueQueue = new ActorDialogueQueue(this);

	_settings = new Settings(this);

	_itemPickup = new ItemPickup(this);

	_lights = new Lights(this);

	// TODO: outtake player - but this is done bit differently

	_policeMaze = new PoliceMaze(this);

	_obstacles = new Obstacles(this);

	_sceneScript = new SceneScript(this);

	_debugger = new Debugger(this);

	// This is the original startup in the game

	bool r;

	_surfaceFront.create(640, 480, createRGB555());
	_surfaceBack.create(640, 480, createRGB555());
	_surface4.create(640, 480, createRGB555());

	_gameTime = new Time(this);

	r = openArchive("STARTUP.MIX");
	if (!r)
		return false;

	_gameInfo = new GameInfo(this);
	if (!_gameInfo)
		return false;

	r = _gameInfo->open("GAMEINFO.DAT");
	if (!r) {
		return false;
	}


	// TODO: Create datetime - not used

	// TODO: Create graphics surfaces 1-4

	// TODO: Allocate audio cache

	if (hasSavegames) {
		if (!loadSplash()) {
			return false;
		}
	}

	_waypoints = new Waypoints(this, _gameInfo->getWaypointCount());

	_combat = new Combat(this);

	_gameVars = new int[_gameInfo->getGlobalVarCount()]();

	// TODO: Init Actor AI Update counter

	// Seed rand

	// TODO: Sine and cosine lookup tables for intervals of 1.0, 4.0, and 12.0
	_cosTable1024 = new Common::CosineTable(1024); // 10-bits = 1024 points for 2*PI;
	_sinTable1024 = new Common::SineTable(1024);

	_view = new View();

	_sceneObjects = new SceneObjects(this, _view);

	_gameFlags = new GameFlags();
	_gameFlags->setFlagCount(_gameInfo->getFlagCount());

	_items = new Items(this);

	_audioMixer = new AudioMixer(this);

	_audioPlayer = new AudioPlayer(this);

	_music = new Music(this);

	_audioSpeech = new AudioSpeech(this);

	_ambientSounds = new AmbientSounds(this);

	// TODO: Read BLADE.INI

	_chapters = new Chapters(this);
	if (!_chapters)
		return false;

	if (!openArchive("MUSIC.MIX"))
		return false;

	if (!openArchive("SFX.MIX"))
		return false;

	if (!openArchive("SPCHSFX.TLK"))
		return false;

	_overlays = new Overlays(this);
	_overlays->init();

	_zbuffer = new ZBuffer();
	_zbuffer->init(640, 480);

	int actorCount = (int)_gameInfo->getActorCount();
	assert(actorCount < kActorCount);
	for (int i = 0; i != actorCount; ++i) {
		_actors[i] = new Actor(this, i);
		_actors[i]->setup(i);
	}
	_actors[kActorVoiceOver] = new Actor(this, kActorVoiceOver);
	_playerActor = _actors[_gameInfo->getPlayerId()];

	_playerActor->setFPS(15);
	_playerActor->timerStart(6, 200);

	// TODO: Set actor ids (redundant?)

	_policeMaze = new PoliceMaze(this);

	_textActorNames = new TextResource(this);
	if (!_textActorNames->open("ACTORS"))
		return false;

	_textCrimes = new TextResource(this);
	if (!_textCrimes->open("CRIMES"))
		return false;

	_textClueTypes = new TextResource(this);
	if (!_textClueTypes->open("CLUETYPE"))
		return false;

	_textKIA = new TextResource(this);
	if (!_textKIA->open("KIA"))
		return false;

	_textSpinnerDestinations = new TextResource(this);
	if (!_textSpinnerDestinations->open("SPINDEST"))
		return false;

	_textVK = new TextResource(this);
	if (!_textVK->open("VK"))
		return false;

	_textOptions = new TextResource(this);
	if (!_textOptions->open("OPTIONS"))
		return false;

	_dialogueMenu = new DialogueMenu(this);
	if (!_dialogueMenu->loadText("DLGMENU"))
		return false;

	_suspectsDatabase = new SuspectsDatabase(this, _gameInfo->getSuspectCount());

	_kia = new KIA(this);

	_spinner = new Spinner(this);

	_elevator = new Elevator(this);

	_scores = new Scores(this);

	_mainFont = new Font(this);
	_mainFont->open("KIA6PT.FON", 640, 480, -1, 0, 0x252D);
	_mainFont->setSpacing(1, 0);

	for (int i = 0; i != 43; ++i) {
		Shape *shape = new Shape(this);
		shape->open("SHAPES.SHP", i);
		_shapes.push_back(shape);
	}

	_esper = new ESPER(this);

	_vk = new VK(this);

	_mouse = new Mouse(this);
	// _mouse->setCursorPosition(320, 240);
	_mouse->setCursor(0);

	_sliceAnimations = new SliceAnimations(this);
	r = _sliceAnimations->open("INDEX.DAT");
	if (!r)
		return false;

	r = _sliceAnimations->openCoreAnim();
	if (!r) {
		return false;
	}

	_sliceRenderer = new SliceRenderer(this);
	_sliceRenderer->setScreenEffects(_screenEffects);

	_crimesDatabase = new CrimesDatabase(this, "CLUES", _gameInfo->getClueCount());

	// TODO: Scene
	_scene = new Scene(this);

	// Load INIT.DLL
	InitScript initScript(this);
	initScript.SCRIPT_Initialize_Game();

	// TODO: Load AI-ACT1.DLL
	_aiScripts = new AIScripts(this, actorCount);

	initChapterAndScene();

	return true;
}
Exemplo n.º 24
0
void
do_ar(int argc, const char ** argv)
{
	const char *	options;
	const char *	archiveName;
	BOOL		doExtract;
	BOOL		doTable;
	BOOL		doPrint;
	BOOL		verbose;
	Archive		arch;

	verbose = FALSE;
	doExtract = FALSE;
	doTable = FALSE;
	doPrint = FALSE;

	if (argc < 3)
	{
		fprintf(stderr, "Too few arguments for ar\n");

		return;
	}

	/*
	 * Get the option string and archive file name.
	 */
	options = argv[1];
	archiveName = argv[2];

	/*
	 * Advance the arguments to the list of file names (if any).
	 */
	argc -= 3;
	argv += 3;

	/*
	 * Parse the option characters.
	 */
	for (; *options; options++)
	{
		switch (*options)
		{
		case 't':
			doTable = TRUE;
			break;

		case 'x':
			doExtract = TRUE;
			break;

		case 'p':
			doPrint = TRUE;
			break;

		case 'v':
			verbose = TRUE;
			break;

		case 'd': case 'm': case 'q': case 'r':
			fprintf(stderr, "Writing ar files is not supported\n");

			return;

		default:
			fprintf(stderr, "Unknown ar flag: %c\n", *options);

			return;
		}
	}

	if (doExtract + doTable + doPrint != 1)
	{
		fprintf(stderr,
			"Exactly one of 'x', 'p' or 't' must be specified\n");

		return;
	}

	/*
	 * Open the archive file.
	 */
	initArchive(&arch);

	if (!openArchive(archiveName, &arch))
		return;

	/*
	 * Read the first special member of the archive.
	 */
	if (!readSpecialMember(&arch))
		return;

	/*
	 * Read all of the normal members of the archive.
	 */
	while (readNormalMember(&arch))
	{
		/*
		 * If this file is not wanted then skip it.
		 */
		if (!wantMember(&arch, argc, argv))
		{
			if (!skipMember(&arch))
				break;

			continue;
		}

		/*
		 * This file is wanted.
		 */
		if (doTable)
		{
			if (verbose)
				listMember(&arch);
			else
				puts(arch.name);

			if (!skipMember(&arch))
				break;
		}
		else if (doPrint)
		{
			if (verbose)
			{
				/*
				 * The verbose format makes me gag,
				 * but 4.4BSD, GNU and even V7 all
				 * have the same lossage.
				 */
				printf("\n<%s>\n\n", arch.name);
				fflush(stdout);
			}

			if (!writeFile(&arch, STDOUT))
				break;
		}
		else if (doExtract)
		{
			int	outfd;
			BOOL	success;

			if (verbose)
				printf("x - %s\n", arch.name);

			outfd = createFile(&arch);

			if (outfd == -1)
				break;

			success = writeFile(&arch, outfd);

			if (close(outfd) == -1)
			{
				fprintf(stderr, "Can't close %s: %s\n",
					arch.name, strerror(errno));

				break;
			}

			if (!success)
				break;
		}
		else
		{
			fprintf(stderr, "Oops -- I don't know what to do\n");
			break;
		}
	}

	closeArchive(&arch);
}