Esempio n. 1
0
QTextBlock* CProjectFile::scan( QTextBlock* b ){
    QTextBlock* block = b;

    QProgressDialog pdia( QWidget::tr( "Processing " ) + m_document->fileInfo().fileName() ,
                          "" , 0 , m_document->editor()->blockCount() );
    pdia.setCancelButton( 0 );
    pdia.show();

    //while( &block->next() != (QTextBlock*)&block->end() ){
    while( block->next().isValid() ){
        m_blockNumber++;
        block = &block->next();

        m_blockList.append( block );

        CProjectItem* pjitem = CProjectItemFactory::buildItem( m_document, block, m_parent );
        if( pjitem!=NULL ){
            m_childList.append( pjitem );
            for( int __i = 0; __i < pjitem->blockNumber()-1; __i++ ){
                m_blockNumber++;
                block = &block->next();
                m_blockList.append( block );
            }
        }

        if( m_blockNumber % 20 == 0 )
            pdia.setValue( m_blockNumber );

        //qDebug() << block->text() << block->isValid();

        if( !block->isValid() )break;
    }
    qDebug() << "end item: " << m_label;
    return block;
}
Esempio n. 2
0
CGameObject *CInputHandler::dragEnd(const Point &pt, CTreeItem *dragItem) {
	CViewItem *view = _gameManager->getView();
	if (!view)
		return nullptr;

	// Scan through the view items to find the item being dropped on
	CGameObject *target = nullptr;
	for (CTreeItem *treeItem = view->scan(view); treeItem; treeItem = treeItem->scan(view)) {
		CGameObject *gameObject = dynamic_cast<CGameObject *>(treeItem);
		if (gameObject && gameObject != dragItem) {
			if (gameObject->checkPoint(pt))
				target = gameObject;
		}
	}

	if (target) {
		// Check if the cursor is on the PET. If so, pass to the PET
		// to see what specific element the drag ended on
		CProjectItem *project = view->getRoot();
		if (project) {
			CPetControl *petControl = project->getPetControl();
			if (petControl && petControl->contains(pt)) {
				target = petControl->dragEnd(pt);
				if (!target)
					target = petControl;
			}
		}
	}

	return target;
}
Esempio n. 3
0
void CPetControl::postLoad() {
	CProjectItem *root = getRoot();

	if (!_activeNPCName.empty() && root)
		_activeNPC = root->findByName(_activeNPCName);
	if (!_remoteTargetName.empty() && root)
		_remoteTarget = dynamic_cast<CGameObject *>(root->findByName(_remoteTargetName));

	setArea(_currentArea, true);
	loaded();
}
Esempio n. 4
0
bool TitanicEngine::canLoadGameStateCurrently() {
	if (!_window->_inputAllowed)
		return false;
	CProjectItem *project = _window->_gameManager->_project;
	if (project) {
		CPetControl *pet = project->getPetControl();
		if (pet && !pet->isAreaUnlocked())
			return false;
	}

	return true;
}
Esempio n. 5
0
void CPetSave::execute() {
	CPetControl *pet = getPetControl();
	if (_savegameSlotNum >= 0) {
		highlightSlot(-1);
		CProjectItem *project = pet ? pet->getRoot() : nullptr;

		if (project) {
			project->saveGame(_savegameSlotNum, _slotNames[_savegameSlotNum].getText());
			pet->displayMessage(BLANK);
		}
	} else if (pet) {
		pet->displayMessage(SELECT_GAME_TO_SAVE);
	}
}
Esempio n. 6
0
void PProjectWindow::SelectionChanged(void)
{
	int32 sel = fList->CurrentSelection(0);
	BListItem* viewItem = (sel<0) ? NULL : fList->FullListItemAt(sel);
	PProjectItem* prjViewItem = dynamic_cast<PProjectItem*>(viewItem);
	CProjectItem* prjItem
		= prjViewItem
			? dynamic_cast<CProjectItem*>(prjViewItem->ModelItem())
			: NULL;
	bool addOk = prjItem ? prjItem->CanBeAddedTo() : false;
	fButtonBar->SetEnabled(msg_PAdd, addOk);
	bool removeOk = prjItem ? prjItem->CanBeRemoved() : false;
	fButtonBar->SetEnabled(msg_PRemove, removeOk);
}
Esempio n. 7
0
void CProjectItem::loadGame(int slotId) {
    CompressedFile file;

    // Clear any existing project contents and call preload code
    preLoad();
    clear();

    // Open either an existing savegame slot or the new game template
    if (slotId >= 0) {
        Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(
                                           g_vm->generateSaveName(slotId));
        file.open(saveFile);
    } else {
        Common::File *newFile = new Common::File();
        if (!newFile->open("newgame.st"))
            error("Could not open newgame.st");
        file.open(newFile);
    }

    // Load the savegame header in
    TitanicSavegameHeader header;
    readSavegameHeader(&file, header);
    delete header._thumbnail;

    // Load the contents in
    CProjectItem *newProject = loadData(&file);
    file.IsClassStart();
    getGameManager()->load(&file);

    file.close();

    // Clear existing project
    clear();

    // Detach each item under the loaded project, and re-attach them
    // to the existing project instance (this)
    CTreeItem *item;
    while ((item = newProject->getFirstChild()) != nullptr) {
        item->detach();
        item->addUnder(this);
    }

    // Loaded project instance is no longer needed
    newProject->destroyAll();

    // Post-load processing
    postLoad();
}