Beispiel #1
0
  void saveData()
  {
    kgmString path;
    kgmString delim;

    kgmSystem::getPathDelim(delim);

#ifdef ANDROID
    path = kgmString(kgm_android_datapath()) + "/cdata";
#else

    kgmSystem::getHomeDirectory(path);

    path += delim;
    path += ".Komble";

    if(!kgmSystem::isDirectory(path))
      kgmFile::make_directory(path);

    path += delim;
    path += "data";
#endif;

    kgmFile f;

    f.open(path, kgmFile::Write | kgmFile::Create);

    if(f.m_file)
      f.write(&data, sizeof(data));

    f.close();
  }
Beispiel #2
0
  void readData()
  {
    kgmString path;
    kgmString delim;

    kgmSystem::getPathDelim(delim);

#ifdef ANDROID
    path = kgmString(kgm_android_datapath()) + "/cdata";
#else

    kgmSystem::getHomeDirectory(path);

    path += delim;
    path += ".Komble";

    if(!kgmSystem::isDirectory(path))
      return;

    path += delim;
    path += "data";
#endif;

    kgmFile f;

    f.open(path, kgmFile::Read);

    if(f.m_file)
      f.read(&data, sizeof(data));

    f.close();
  }
Beispiel #3
0
void kgmGameSettings::set(char* key, char* val)
{
  if(m_xml && m_xml->m_node)
  {
    kgmXml::Node* node = m_xml->m_node->node(key);

    if(node)
    {
      for(int i = 0; i < node->attributes(); i++)
      {
        kgmXml::Attribute* attr = node->m_attributes[i];

        if(attr->m_name == kgmString("value"))
        {
          attr->m_data = val;
        }
      }
    }
  }

}
Beispiel #4
0
bool kgmGameResources::getFile(const char* id, kgmMemory<u8>& m)
{
  kgmString path;
  int   i = 0;

  if(!id)
    return false;

#ifdef WIN32
  const kgmString delim((const char*)"\\", 1);
#else
  const kgmString delim((const char*)"/", 1);
#endif

#ifdef ANDROID

#ifdef DEBUG
  kgm_log() << "\nkgmEngine android loading file " << id << "\n";
#endif

  AAsset* asset = AAssetManager_open(kgm_android_getAssetManager(), (const char *) id, AASSET_MODE_UNKNOWN);

  if (NULL == asset)
  {
#ifdef DEBUG
    kgmLog::log("_ASSET_NOT_FOUND_");
#endif

    return false;
  }

  long size = AAsset_getLength(asset);
  m.alloc(size);
  AAsset_read (asset, m.data(), size);
#ifdef DEBUG
  kgm_log() << "\nkgmEngine android file size: " << (s32)size << "\n";
#endif
  AAsset_close(asset);

  return true;

#else

  for(i = 0; i < m_paths.size(); i++)
  {
    kgmFile file;

    if(m_paths[i]->type == 2)
    {
      path = m_paths[i]->path + delim + kgmString(id, strlen(id));

      if(kgmIGame::getGame()->getSystem()->isFile(path) && file.open(path, kgmFile::Read))
      {
        m.alloc(file.length());
        file.read(m.data(), file.length());
        file.close();

        return true;
      }
    }
    else if(m_paths[i]->type == 1)
    {
      if(m_paths[i]->archive.copy(id, m))
      {
        return true;
      }
    }
  }

#endif

#ifdef DEBUG
  kgm_log() << "kgmGameResources::getFile Cannot load file: " << id << "\n";
#endif

  return false;
}