//---------------------------------------------------------------------------
void TConfiguration::Load()
{
  TGuard Guard(FCriticalSection);
  std::unique_ptr<THierarchicalStorage> Storage(CreateStorage(false));
  Storage->SetAccessMode(smRead);
  LoadFrom(Storage.get());
}
Exemple #2
0
//---------------------------------------------------------------------------
void __fastcall TConfiguration::Import(const UnicodeString & FileName)
{
  THierarchicalStorage * Storage = NULL;
  THierarchicalStorage * ImportStorage = NULL;
  try
  {
    ImportStorage = new TIniFileStorage(FileName);
    ImportStorage->AccessMode = smRead;

    Storage = CreateScpStorage(false);
    Storage->AccessMode = smReadWrite;
    Storage->Explicit = true;

    CopyData(ImportStorage, Storage);

    Default();
    LoadFrom(ImportStorage);

    if (ImportStorage->OpenSubKey(Configuration->StoredSessionsSubKey, false))
    {
      StoredSessions->Clear();
      StoredSessions->DefaultSettings->Default();
      StoredSessions->Load(ImportStorage);
    }
  }
  __finally
  {
    delete ImportStorage;
    delete Storage;
  }

  // save all and explicit
  DoSave(true, true);
}
Exemple #3
0
bool SirenAssembly::LoadFromData(const FileIdRef& fileId, const MemoryData& data, uint format /*= (uint)-1*/)
{
	FileType fileType = (FileType)format;
	RETURN_FALSE_IF_NOT_EQUAL(fileType, FileType::mpb);

	MemoryStream stream(data);
	return LoadFrom(stream);
}
bool
CIniParser::LoadFrom( const CString& iniText )
{GUCEF_TRACE;

    CDynamicBuffer stringBuffer;
    stringBuffer.LinkTo( iniText.C_String(), iniText.Length() );
    CDynamicBufferAccess stringBufferAccess( &stringBuffer, false );
    return LoadFrom( stringBufferAccess );
}
void TConfiguration::Load(THierarchicalStorage * Storage)
{
  TGuard Guard(FCriticalSection);
  TStorageAccessMode StorageAccessMode = Storage->GetAccessMode();
  SCOPE_EXIT
  {
    Storage->SetAccessMode(StorageAccessMode);
  };
  Storage->SetAccessMode(smRead);
  LoadFrom(Storage);
}
Exemple #6
0
int Object::Load(const char *fn) {
  num2obj[0] = NULL;
  obj2num[NULL] = 0;

  FILE *fl = fopen(fn, "r");
  if(!fl) return -1;

  fscanf(fl, "%X\n", &ver);

  todo.clear();
  if(LoadFrom(fl)) { fclose(fl); return -1; }

  vector<Object*>::iterator ind;
  for(ind = todo.begin(); ind != todo.end(); ++ind) {
    list<act_t> killacts;
    map<act_t,Object*>::iterator aind = (*ind)->act.begin();
    for(; aind != (*ind)->act.end(); ++aind) {
      /* Decode the Object Number from a pointer, Encoded in LoadFrom() */
      int num = int(aind->second - ((Object *)(NULL)));
      aind->second = num2obj[num];
      if(aind->second) {
	aind->second->touching_me.insert(*ind);
	}
      else if(aind->first <= ACT_REST){		//Targetless Actions
	aind->second = NULL;
	}
      else {	//Act Targ No Longer Exists ("junkrestart", I hope)!
	killacts.push_back(aind->first);
	}
      if(aind->first == ACT_FIGHT) {
	(*ind)->BusyFor(500, (*ind)->Tactics().c_str());
	}
      }
    list<act_t>::iterator kill = killacts.begin();
    for(; kill != killacts.end(); ++kill) {	//Kill Actions on Non-Existent
      act.erase(*kill);
      }
    if((*ind)->IsUsing("Lumberjack")) {		//FIXME: All long-term skills?
      (*ind)->BusyFor(500, "use Lumberjack");
      }
    }
  todo.clear();

  if(ver < 0x0016) {
    fscanf(fl, "%*d\n");	//Used to be start room, which is an action now
    }

  fclose(fl);
  return 0;
  }
Exemple #7
0
Sprite::Sprite(const std::string& path) :
	m_sdl_texture{nullptr},
	m_width{0},
	m_height{0},
	m_path{path}
{
	LoadFrom(m_path);

	SetBlendMode(SDL_BLENDMODE_BLEND);
	SetAlpha(255);

	ASSERT(m_width >= 0 , "Must be >= 0");
	ASSERT(m_height >= 0, "Must be >= 0");
}
Exemple #8
0
//---------------------------------------------------------------------------
void __fastcall TConfiguration::Load()
{
  TGuard Guard(FCriticalSection);

  THierarchicalStorage * Storage = CreateScpStorage(false);
  try
  {
    Storage->AccessMode = smRead;
    LoadFrom(Storage);
  }
  __finally
  {
    delete Storage;
  }
}
// constructor
Gradient::Gradient(BMessage* archive)
#ifdef ICON_O_MATIC
	: BArchivable(archive),
	  Observable(),
	  Transformable(),
#else
	: Transformable(),
#endif

	  fColors(4),
	  fType(GRADIENT_LINEAR),
	  fInterpolation(INTERPOLATION_SMOOTH),
	  fInheritTransformation(true)
{
	if (!archive)
		return;

	// read transformation
	int32 size = Transformable::matrix_size;
	const void* matrix;
	ssize_t dataSize = size * sizeof(double);
	if (archive->FindData("transformation", B_DOUBLE_TYPE,
						  &matrix, &dataSize) == B_OK
		&& dataSize == (ssize_t)(size * sizeof(double)))
		LoadFrom((const double*)matrix);

	// color steps
	BGradient::ColorStop step;
	for (int32 i = 0; archive->FindFloat("offset", i, &step.offset) >= B_OK; i++) {
		if (archive->FindInt32("color", i, (int32*)&step.color) >= B_OK)
			AddColor(step, i);
		else
			break;
	}
	if (archive->FindInt32("type", (int32*)&fType) < B_OK)
		fType = GRADIENT_LINEAR;

	if (archive->FindInt32("interpolation", (int32*)&fInterpolation) < B_OK)
		fInterpolation = INTERPOLATION_SMOOTH;

	if (archive->FindBool("inherit transformation",
						  &fInheritTransformation) < B_OK)
		fInheritTransformation = true;
}
bool
CIniParser::LoadFrom( const CDataNode& node       ,
                      TIniSection* currentSection )
{GUCEF_TRACE;

    TIniSection* iniSection = currentSection;

    // A node is a section node if it has no value set and no attributes
    const CString& value = node.GetValue();
    if ( node.GetAttCount() == 0 && value.IsNULLOrEmpty() )
    {
        // Check if this is just an link node which or the end delimiter of a section identifier
        // We do this by checking if the node has 1 or more children with a value or attributes.

        if ( HasChildWithValueOrAttribs( node ) )
        {
            // Base the new section path off of the path to the root node
            CString sectionName = node.GetPathToRoot( '\\', true );

            // Add each attribute as a key value pair is this section
            TIniSection dummySection;
            m_iniData.push_back( dummySection );
            iniSection = &(*m_iniData.rbegin());
            iniSection->sectionName = sectionName;
        }
    }
    else
    {
        if ( NULL != iniSection )
        {
            if ( !value.IsNULLOrEmpty() )
            {
                iniSection->sectionData.Set( node.GetName(), node.GetValue() );
            }

            // Add this section if there are attributes for this section
            if ( node.GetAttCount() > 0 )
            {
                // Add all attributes as key/value pairs in the ini
                // Note that the ini has no uniqueness constraint so that constraint on the data
                // stored as attributes is lost when representing the data via the ini format
                CDataNode::TAttributeMap::const_iterator i = node.AttributeBegin();
                while ( i != node.AttributeEnd() )
                {
                    iniSection->sectionData.Set( (*i).first, (*i).second );
                    ++i;
                }
            }
        }
    }

    // Repeat recursively for all the children
    CDataNode::const_iterator n = node.Begin();
    while ( n != node.End() )
    {
        if ( !LoadFrom( *(*n), iniSection ) )
        {
            return false;
        }
        ++n;
    }
    return true;
}
bool
CIniParser::LoadFrom( const CDataNode& rootNode )
{GUCEF_TRACE;

    return LoadFrom( rootNode, NULL );
}
Exemple #12
0
System::System(FILE *f) : SObject() {
  LoadFrom(f);
  }
CDataToolGeneratedSrc::CDataToolGeneratedSrc(const string& source_file_path)
{
    LoadFrom(source_file_path, this);
}
Exemple #14
0
Player::Player(FILE *f) {
  LoadFrom(f);
  }