Exemple #1
0
/**
 * Load animDataTable from save
 * @param fHandle Savefile open for reading
 * @param saveGameFormat The used savegame format
 * @todo Add Operation Stealth savefile support
 *
 * Unlike the old code, this one actually rebuilds the table one frame
 * at a time.
 */
void loadResourcesFromSave(Common::SeekableReadStream &fHandle, enum CineSaveGameFormat saveGameFormat) {
    int16 foundFileIdx;
    char *animName, part[256], name[10];

    strcpy(part, currentPartName);

    // We only support these variations of the savegame format at the moment.
    assert(saveGameFormat == ANIMSIZE_23 || saveGameFormat == ANIMSIZE_30_PTRS_INTACT);

    const int entrySize = ((saveGameFormat == ANIMSIZE_23) ? 23 : 30);
    const int fileStartPos = fHandle.pos();

    for(int resourceIndex=0; resourceIndex<NUM_MAX_ANIMDATA; resourceIndex++) {
        // Seek to the start of the current animation's entry
        fHandle.seek(fileStartPos + resourceIndex * entrySize);
        // Read in the current animation entry
        fHandle.readUint16BE(); // width
        fHandle.readUint16BE();
        fHandle.readUint16BE(); // bpp
        fHandle.readUint16BE(); // height

        bool validPtr = false;
        // Handle variables only present in animation entries of size 30
        if (entrySize == 30) {
            validPtr = (fHandle.readUint32BE() != 0); // Read data pointer
            fHandle.readUint32BE(); // Discard mask pointer
        }

        foundFileIdx = fHandle.readSint16BE();
        int16 frameIndex = fHandle.readSint16BE(); // frame
        fHandle.read(name, 10);

        // Handle variables only present in animation entries of size 23
        if (entrySize == 23) {
            validPtr = (fHandle.readByte() != 0);
        }

        // Don't try to load invalid entries.
        if (foundFileIdx < 0 || !validPtr) {
            //resourceIndex++; // Jump over the invalid entry
            continue;
        }

        // Alright, the animation entry looks to be valid so let's start handling it...
        if (strcmp(currentPartName, name) != 0) {
            closePart();
            loadPart(name);
        }

        animName = g_cine->_partBuffer[foundFileIdx].partName;
        loadRelatedPalette(animName); // Is this for Future Wars only?
        loadResource(animName, resourceIndex, frameIndex);
    }

    loadPart(part);

    // Make sure we jump over all the animation entries
    fHandle.seek(fileStartPos + NUM_MAX_ANIMDATA * entrySize);
}
void LIB_EDIT_FRAME::OnImportPart( wxCommandEvent& event )
{
    wxString msg;
    m_lastDrawItem = NULL;
    wxString libName = getTargetLib();

    if( !m_libMgr->LibraryExists( libName ) )
    {
        libName = SelectLibraryFromList();

        if( !m_libMgr->LibraryExists( libName ) )
            return;
    }

    wxFileDialog dlg( this, _( "Import Symbol" ), m_mruPath,
                      wxEmptyString, SchematicLibraryFileWildcard(),
                      wxFD_OPEN | wxFD_FILE_MUST_EXIST );

    if( dlg.ShowModal() == wxID_CANCEL )
        return;

    wxFileName fn = dlg.GetPath();
    m_mruPath = fn.GetPath();

    wxArrayString symbols;
    SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );

    // TODO dialog to select the part to be imported if there is more than one
    try
    {
        pi->EnumerateSymbolLib( symbols, fn.GetFullPath() );
    }
    catch( const IO_ERROR& ioe )
    {
        msg.Printf( _( "Cannot import symbol library \"%s\"." ), fn.GetFullPath() );
        DisplayErrorMessage( this, msg, ioe.What() );
        return;
    }

    if( symbols.empty() )
    {
        msg.Printf( _( "Symbol library file \"%s\" is empty." ), fn.GetFullPath() );
        DisplayError( this,  msg );
        return;
    }

    wxString symbolName = symbols[0];
    LIB_ALIAS* entry = pi->LoadSymbol( fn.GetFullPath(), symbolName );

    if( m_libMgr->PartExists( symbols[0], libName ) )
    {
        msg.Printf( _( "Symbol \"%s\" already exists in library \"%s\"." ), symbolName, libName );
        DisplayError( this,  msg );
        return;
    }

    m_libMgr->UpdatePart( entry->GetPart(), libName );
    SyncLibraries( false );
    loadPart( symbolName, libName, 1 );
}
Exemple #3
0
KParts::ReadOnlyPart *BasketPlugin::createPart()
{
  KParts::ReadOnlyPart *part = loadPart();

  connect( part, SIGNAL(showPart()), this, SLOT(showPart()) );

  return part;
}
Exemple #4
0
KParts::ReadOnlyPart *KarmPlugin::createPart()
{
    KParts::ReadOnlyPart *part = loadPart();
    if(!part) return 0;

    // this calls a DCOP interface from karm via the lib KarmDCOPIface_stub that is generated automatically
    mStub = new KarmDCOPIface_stub(dcopClient(), "KArm",
                                   "KarmDCOPIface");

    return part;
}
Exemple #5
0
int CADCv3DPlugin::loadCad(const char *filename, osg::Group *)
{

    this->renderWhileLoading = coConfig::getInstance()->isOn("COVER.Plugin.CADCv3D.RenderWhileLoading", true);

    while (loadPart(filename) == coVRIOReader::Loading)
    {
    }

    return 1;
}
Exemple #6
0
void LIB_EDIT_FRAME::OnRevert( wxCommandEvent& aEvent )
{
    LIB_ID libId = getTargetLibId();
    const wxString& libName = libId.GetLibNickname();
    const wxString& partName = libId.GetLibItemName();  // Empty if this is the library itself that is selected

    wxString msg = wxString::Format( _( "Revert \"%s\" to last version saved?" ),
                                     partName.IsEmpty() ? libName : partName );

    if( !ConfirmRevertDialog( this, msg ) )
        return;

    bool reload_currentPart = false;
    wxString curr_partName = partName;

    if( GetCurPart() )
    {
        // the library itself is reverted: the current part will be reloaded only if it is
        // owned by this library
        if( partName.IsEmpty() )
        {
            LIB_ID curr_libId = GetCurPart()->GetLibId();
            reload_currentPart = libName == curr_libId.GetLibNickname();

            if( reload_currentPart )
                curr_partName = curr_libId.GetLibItemName();
        }
        else
            reload_currentPart = isCurrentPart( libId );
    }

    int unit = m_unit;

    if( reload_currentPart )
        emptyScreen();

    if( partName.IsEmpty() )
    {
        m_libMgr->RevertLibrary( libName );
    }
    else
    {
        libId = m_libMgr->RevertPart( libId.GetLibItemName(), libId.GetLibNickname() );

        m_treePane->GetLibTree()->SelectLibId( libId );
        m_libMgr->ClearPartModified( libId.GetLibItemName(), libId.GetLibNickname() );
    }

    if( reload_currentPart && m_libMgr->PartExists( curr_partName, libName ) )
        loadPart( curr_partName, libName, unit );

    m_treePane->Refresh();
    refreshSchematic();
}
Exemple #7
0
KParts::ReadOnlyPart *KOrganizerPlugin::createPart()
{
  KParts::ReadOnlyPart *part = loadPart();

  if ( !part )
    return 0;

  mIface = new KCalendarIface_stub( dcopClient(), "kontact", "CalendarIface" );

  return part;
}
KParts::ReadOnlyPart *KJotsPlugin::createPart()
{
  KParts::ReadOnlyPart *part = loadPart();
  if ( !part ) {
    return 0;
  }

  m_interface = new OrgKdeKJotsComponentInterface(
    "org.kde.kjots", "/KJotsComponent", QDBusConnection::sessionBus() );

  return part;
}
Exemple #9
0
KParts::ReadOnlyPart *JournalPlugin::createPart()
{
  KParts::ReadOnlyPart *part = loadPart();

  if ( !part )
    return 0;

  dcopClient(); // ensure that we register to DCOP as "korganizer"
  mIface = new KCalendarIface_stub( dcopClient(), "kontact", "CalendarIface" );

  return part;
}
KParts::ReadOnlyPart *CoisceimPlugin::createPart()
{
  KParts::ReadOnlyPart *part = loadPart();
  if ( !part ) {
    return 0;
  }

  m_interface = new org::kde::coisceim::CoisceimWidget(
    "org.kde.coisceim", "/CoisceimWidget", QDBusConnection::sessionBus() );

  return part;
}
KParts::ReadOnlyPart *TodoPlugin::createPart()
{
  KParts::ReadOnlyPart *part = loadPart();

  if ( !part ) {
    return 0;
  }

  mIface = new OrgKdeKorganizerCalendarInterface(
    "org.kde.korganizer", "/Calendar", QDBusConnection::sessionBus(), this );

  return part;
}
Exemple #12
0
KParts::ReadOnlyPart *JournalPlugin::createPart()
{
    KParts::ReadOnlyPart *part = loadPart();

    if (!part) {
        return Q_NULLPTR;
    }

    mIface = new OrgKdeKorganizerCalendarInterface(
        QStringLiteral("org.kde.korganizer"), QStringLiteral("/Calendar"), QDBusConnection::sessionBus(), this);

    return part;
}
Exemple #13
0
void DECFile::loadParts(Common::SeekableSubReadStreamEndian &dec) {
	dec.skip(13); // Name
	if (_hasPadding)
		dec.skip(1);

	dec.skip(13); // File?
	if (_hasPadding)
		dec.skip(1);

	uint16 partCount = dec.readUint16();

	_parts.resize(partCount);
	for (PartArray::iterator p = _parts.begin(); p != _parts.end(); ++p)
		loadPart(*p, dec);
}
Exemple #14
0
void LIB_EDIT_FRAME::OnCreateNewPart( wxCommandEvent& event )
{
    m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() );
    SetDrawItem( NULL );
    wxString lib = getTargetLib();

    if( !m_libMgr->LibraryExists( lib ) )
    {
        lib = SelectLibraryFromList();

        if( !m_libMgr->LibraryExists( lib ) )
            return;
    }

    DIALOG_LIB_NEW_COMPONENT dlg( this );
    dlg.SetMinSize( dlg.GetSize() );

    if( dlg.ShowModal() == wxID_CANCEL )
        return;

    if( dlg.GetName().IsEmpty() )
    {
        wxMessageBox( _( "This new symbol has no name and cannot be created." ) );
        return;
    }

    wxString name = dlg.GetName();
    // Currently, symbol names cannot include a space, that breaks libraries:
    name.Replace( " ", "_" );

    // Test if there is a component with this name already.
    if( !lib.empty() && m_libMgr->PartExists( name, lib ) )
    {
        wxString msg = wxString::Format( _( "Symbol \"%s\" already exists in library \"%s\"" ),
                                         name, lib );
        DisplayError( this, msg );
        return;
    }

    LIB_PART new_part( name );      // do not create part on the heap, it will be buffered soon
    new_part.GetReferenceField().SetText( dlg.GetReference() );
    new_part.SetUnitCount( dlg.GetUnitCount() );

    // Initialize new_part.m_TextInside member:
    // if 0, pin text is outside the body (on the pin)
    // if > 0, pin text is inside the body

    if( dlg.GetPinNameInside() )
    {
        new_part.SetPinNameOffset( dlg.GetPinTextPosition() );

        if( new_part.GetPinNameOffset() == 0 )
            new_part.SetPinNameOffset( 1 );
    }
    else
    {
        new_part.SetPinNameOffset( 0 );
    }

    ( dlg.GetPowerSymbol() ) ? new_part.SetPower() : new_part.SetNormal();
    new_part.SetShowPinNumbers( dlg.GetShowPinNumber() );
    new_part.SetShowPinNames( dlg.GetShowPinName() );
    new_part.LockUnits( dlg.GetLockItems() );

    if( dlg.GetUnitCount() < 2 )
        new_part.LockUnits( false );

    m_libMgr->UpdatePart( &new_part, lib );
    SyncLibraries( false );
    loadPart( name, lib, 1 );

    new_part.SetConversion( dlg.GetAlternateBodyStyle() );
    // must be called after loadPart, that calls SetShowDeMorgan, but
    // because the symbol is empty,it looks like it has no alternate body
    SetShowDeMorgan( dlg.GetAlternateBodyStyle() );

}
Exemple #15
0
void LIB_EDIT_FRAME::savePartAs()
{
    LIB_ID old_lib_id = getTargetLibId();
    wxString old_name = old_lib_id.GetLibItemName();
    wxString old_lib = old_lib_id.GetLibNickname();
    LIB_PART* part = m_libMgr->GetBufferedPart( old_name, old_lib );

    if( part )
    {
        SYMBOL_LIB_TABLE* tbl = Prj().SchSymbolLibTable();
        wxArrayString headers;
        std::vector< wxArrayString > itemsToDisplay;
        std::vector< wxString > libNicknames = tbl->GetLogicalLibs();

        headers.Add( _( "Nickname" ) );
        headers.Add( _( "Description" ) );

        for( const auto& name : libNicknames )
        {
            wxArrayString item;
            item.Add( name );
            item.Add( tbl->GetDescription( name ) );
            itemsToDisplay.push_back( item );
        }

        EDA_LIST_DIALOG dlg( this, _( "Save Copy of Symbol" ), headers, itemsToDisplay, old_lib,
                             nullptr, nullptr, /* sort */ false, /* show headers */ false );
        dlg.SetListLabel( _( "Save in library:" ) );
        dlg.SetOKLabel( _( "Save" ) );

        wxBoxSizer* bNameSizer = new wxBoxSizer( wxHORIZONTAL );

        wxStaticText* label = new wxStaticText( &dlg, wxID_ANY, _( "Name:" ),
                                                wxDefaultPosition, wxDefaultSize, 0 );
        bNameSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );

        wxTextCtrl* nameTextCtrl = new wxTextCtrl( &dlg, wxID_ANY, old_name,
                                                   wxDefaultPosition, wxDefaultSize, 0 );
        bNameSizer->Add( nameTextCtrl, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );

        wxSizer* mainSizer = dlg.GetSizer();
        mainSizer->Prepend( bNameSizer, 0, wxEXPAND|wxTOP|wxLEFT|wxRIGHT, 5 );

        // Move nameTextCtrl to the head of the tab-order
        if( dlg.GetChildren().DeleteObject( nameTextCtrl ) )
            dlg.GetChildren().Insert( nameTextCtrl );

        dlg.SetInitialFocus( nameTextCtrl );

        dlg.Layout();
        mainSizer->Fit( &dlg );

        if( dlg.ShowModal() != wxID_OK )
            return;                   // canceled by user

        wxString new_lib = dlg.GetTextSelection();

        if( new_lib.IsEmpty() )
        {
            DisplayError( NULL, _( "No library specified.  Symbol could not be saved." ) );
            return;
        }

        wxString new_name = nameTextCtrl->GetValue();
        new_name.Trim( true );
        new_name.Trim( false );
        new_name.Replace( " ", "_" );

        if( new_name.IsEmpty() )
        {
            DisplayError( NULL, _( "No symbol name specified.  Symbol could not be saved." ) );
            return;
        }

        // Test if there is a component with this name already.
        if( m_libMgr->PartExists( new_name, new_lib ) )
        {
            wxString msg = wxString::Format( _( "Symbol \"%s\" already exists in library \"%s\"" ),
                                             new_name, new_lib );
            DisplayError( this, msg );
            return;
        }

        LIB_PART new_part( *part );
        new_part.SetName( new_name );

        fixDuplicateAliases( &new_part, new_lib );
        m_libMgr->UpdatePart( &new_part, new_lib );
        SyncLibraries( false );
        m_treePane->GetLibTree()->SelectLibId( LIB_ID( new_lib, new_part.GetName() ) );

        if( isCurrentPart( old_lib_id ) )
            loadPart( new_name, new_lib, m_unit );
    }
}
Exemple #16
0
void mtpFileLoader::started(bool loadFirst, bool prior) {
	if ((queue->queries >= MaxFileQueries && (!loadFirst || !prior)) || complete) return;
	loadPart();
}
Exemple #17
0
void LIB_EDIT_FRAME::OnEditPart( wxCommandEvent& aEvent )
{
    int unit = 0;
    LIB_ID partId = m_treePane->GetLibTree()->GetSelectedLibId( &unit );
    loadPart( partId.GetLibItemName(), partId.GetLibNickname(), unit );
}
Exemple #18
0
bool CineEngine::loadPlainSaveFW(Common::SeekableReadStream &in, CineSaveGameFormat saveGameFormat) {
    char bgName[13];

    // At savefile position 0x0000:
    currentDisk = in.readUint16BE();

    // At 0x0002:
    in.read(currentPartName, 13);
    // At 0x000F:
    in.read(currentDatName, 13);

    // At 0x001C:
    musicIsPlaying = in.readSint16BE();

    // At 0x001E:
    in.read(currentPrcName, 13);
    // At 0x002B:
    in.read(currentRelName, 13);
    // At 0x0038:
    in.read(currentMsgName, 13);
    // At 0x0045:
    in.read(bgName, 13);
    // At 0x0052:
    in.read(currentCtName, 13);

    checkDataDisk(currentDisk);

    if (strlen(currentPartName)) {
        loadPart(currentPartName);
    }

    if (strlen(currentPrcName)) {
        loadPrc(currentPrcName);
    }

    if (strlen(currentRelName)) {
        loadRel(currentRelName);
    }

    if (strlen(bgName)) {
        loadBg(bgName);
    }

    if (strlen(currentCtName)) {
        loadCtFW(currentCtName);
    }

    // At 0x005F:
    loadObjectTable(in);

    // At 0x2043 (i.e. 0x005F + 2 * 2 + 255 * 32):
    renderer->restorePalette(in, 0);

    // At 0x2083 (i.e. 0x2043 + 16 * 2 * 2):
    g_cine->_globalVars.load(in, NUM_MAX_VAR);

    // At 0x2281 (i.e. 0x2083 + 255 * 2):
    loadZoneData(in);

    // At 0x22A1 (i.e. 0x2281 + 16 * 2):
    loadCommandVariables(in);

    // At 0x22A9 (i.e. 0x22A1 + 4 * 2):
    char tempCommandBuffer[kMaxCommandBufferSize];
    in.read(tempCommandBuffer, kMaxCommandBufferSize);
    g_cine->_commandBuffer = tempCommandBuffer;
    renderer->setCommand(g_cine->_commandBuffer);

    // At 0x22F9 (i.e. 0x22A9 + 0x50):
    renderer->_cmdY = in.readUint16BE();

    // At 0x22FB:
    bgVar0 = in.readUint16BE();
    // At 0x22FD:
    allowPlayerInput = in.readUint16BE();
    // At 0x22FF:
    playerCommand = in.readSint16BE();
    // At 0x2301:
    commandVar1 = in.readSint16BE();
    // At 0x2303:
    isDrawCommandEnabled = in.readUint16BE();
    // At 0x2305:
    var5 = in.readUint16BE();
    // At 0x2307:
    var4 = in.readUint16BE();
    // At 0x2309:
    var3 = in.readUint16BE();
    // At 0x230B:
    var2 = in.readUint16BE();
    // At 0x230D:
    commandVar2 = in.readSint16BE();

    // At 0x230F:
    renderer->_messageBg = in.readUint16BE();

    // At 0x2311:
    in.readUint16BE();
    // At 0x2313:
    in.readUint16BE();

    // At 0x2315:
    loadResourcesFromSave(in, saveGameFormat);

    loadScreenParams(in);
    loadGlobalScripts(in);
    loadObjectScripts(in);
    loadOverlayList(in);
    loadBgIncrustFromSave(in);

    if (strlen(currentMsgName)) {
        loadMsg(currentMsgName);
    }

    if (strlen(currentDatName)) {
        g_sound->loadMusic(currentDatName);
        if (musicIsPlaying) {
            g_sound->playMusic();
        }
    }

    return !(in.eos() || in.err());
}
Exemple #19
0
void FileLoader::startLoading(bool loadFirst, bool prior) {
	if ((_queue->queries >= _queue->limit && (!loadFirst || !prior)) || _complete) return;
	loadPart();
}