예제 #1
0
BOOL
CGameSettingsDialog::OnInitDialog()
{
    SetDlgItemText(IDC_GAMEPATH, m_Project->GetDirectory());
    // set game title
    GetDlgItem(IDC_GAMETITLE)->SetFocus();
    SetDlgItemText(IDC_GAMETITLE, m_Project->GetGameTitle());
    SendDlgItemMessage(IDC_GAMETITLE, EM_SETSEL, 0, -1);
    // set game author and description
    SetDlgItemText(IDC_AUTHOR, m_Project->GetAuthor());
    SetDlgItemText(IDC_DESCRIPTION, m_Project->GetDescription());
    m_FoundScript = 0;
    // fill script list
    if (m_Project->GetItemCount(GT_SCRIPTS) > 0)
    {
        // add the scripts from the project
        for (int i = 0; i < m_Project->GetItemCount(GT_SCRIPTS); i++)
        {
            const char* script = m_Project->GetItem(GT_SCRIPTS, i);
            if (script != NULL && strlen(script) > 0)
            {
                // don't show thumbs.db files
                if (strlen(script) >= strlen("thumbs.db") && strcmp_ci(script, "thumbs.db") == 0) {
                    continue;
                }
                // don't show desktop.ini files
                if (strlen(script) >= strlen("desktop.ini") && strcmp_ci(script, "desktop.ini") == 0) {
                    continue;
                }
                // don't show folder.htt files
                if (strlen(script) >= strlen("folder.htt") && strcmp_ci(script, "folder.htt") == 0) {
                    continue;
                }
                // don't show java files
                if (extension_compare(script, ".java")) {
                    continue;
                }
                SendDlgItemMessage(IDC_SCRIPT, CB_ADDSTRING, 0, (LPARAM)script);
                m_FoundScript = 1;
            }
        }
        const char* game_script = m_Project->GetGameScript();
        SendDlgItemMessage(IDC_SCRIPT, CB_SELECTSTRING, -1, (LPARAM)game_script);
    }
    if (!m_FoundScript)
    {
        SendDlgItemMessage(IDC_SCRIPT, CB_ADDSTRING, 0, (LPARAM)"(none)");
        SendDlgItemMessage(IDC_SCRIPT, CB_SETCURSEL, 0, 0);
    }
    // set screen resolution
    SetDlgItemInt(IDC_SCREENWIDTH,  m_Project->GetScreenWidth());
    SetDlgItemInt(IDC_SCREENHEIGHT, m_Project->GetScreenHeight());
    return FALSE;
}
예제 #2
0
static int
corpus_read_next_transcription_line(char **trans)
{
    char utt_id[512];
    char *s;

    /* look for a close paren in the line */
    s = strrchr(transcription_line, ')');

    if (s != NULL) {
	int nspace;
	/* found a close paren */

	nspace = strspn(s + 1, " \t\r\n");
	if (s[nspace + 1] == '\0') {
	    /* it is at the end of the line */
	    *s = '\0';		/* terminate the string at the paren */

	    /* search for a matching open paren */
	    for (s--; (s >= transcription_line) && (*s != '('); s--);

	    if (*s == '(') {
		/* found a matching open paren */

		assert(strlen(s+1) < 512);

		strcpy(utt_id, s+1);

		if (strcmp_ci(utt_id, corpus_utt()) != 0) {
		    char *uttfullname = corpus_utt_full_name();
		    int suffpos = strlen(uttfullname) - strlen(utt_id);

		    if (suffpos >= 0 && strlen(utt_id) > 0 && strcmp_ci(&uttfullname[suffpos], utt_id) != 0) {
		        E_WARN("Utterance id in transcription file, '%s', does not match filename in control path '%s'.\n",
			       utt_id, uttfullname);
		    }
		}

		/* look for the first non-whitespace character before
		   the open paren */
		for (--s; (s >= transcription_line) && isspace((unsigned char)*s); s--);
		if (s < transcription_line) {
		    E_FATAL("Utterance transcription is empty: %s\n", transcription_line);
		}
		++s;
		*s = '\0';	/* terminate the string at the first whitespace character
				   following the first non-whitespace character found above */
	    }
	    else {
		E_ERROR("Expected open paren after ending close paren in line: '%s'\n", transcription_line);
		return S3_ERROR;
	    }
	}
	else {
	    /* close paren not at end of line so assume it is not
	       the close paren associated with the utt id */
	}
    }
    else {
	/* No close paren, so no utt id */
	
	/* This is fine, but the user gets no explicit sanity check
	   for the ordering of the LSN file */
    }

    *trans = strdup(transcription_line);
    
    return S3_SUCCESS;
}
예제 #3
0
static bool IsBMP(const char* filename)
{
  return (strlen(filename) > 4 && strcmp_ci(filename + strlen(filename) - 4, ".bmp") == 0);
}
예제 #4
0
static bool IsGIF(const char* filename)
{
  return (strlen(filename) > 4 && strcmp_ci(filename + strlen(filename) - 4, ".gif") == 0);
}
예제 #5
0
static bool IsPCX(const char* filename)
{
  return (strlen(filename) > 4 && strcmp_ci(filename + strlen(filename) - 4, ".pcx") == 0);
}
예제 #6
0
static bool IsJPEG(const char* filename)
{
  return ((strlen(filename) > 5 && strcmp_ci(filename + strlen(filename) - 5, ".jpeg") == 0) ||
          (strlen(filename) > 4 && strcmp_ci(filename + strlen(filename) - 4, ".jpg") == 0));
}
예제 #7
0
 bool operator<(const Game& rhs) const
 {
     return (strcmp_ci(name.c_str(), rhs.name.c_str()) < 0);
 }
예제 #8
0
파일: Map.cpp 프로젝트: FlyingJester/sphere
bool
sMap::Import_VergeMAP(const char* filename, const char* tilesetFilename, IFileSystem& fs)
{
  m_MusicFile   = "";
  m_EntryScript = "";
  m_ExitScript  = "";
  m_Layers.clear();
  m_Entities.clear();

  IFile* file = fs.Open(filename, IFileSystem::read);
  if (file == NULL) 
    return false;

  // check for v1 maps (ver 4) and v2 maps (ver 5)
  char signature[6];
  file->Read(signature, 6);
  file->Seek(0);

  bool success = false;

  if (signature[0] == 4)
  {
    V1MAP_HEADER header;
    file->Read(&header, sizeof(header));

    word* layer_background = new word[header.layer_size_x * header.layer_size_y];
    word* layer_foreground = new word[header.layer_size_x * header.layer_size_y];
    file->Read(layer_background, header.layer_size_x * header.layer_size_y * sizeof(word));
    file->Read(layer_foreground, header.layer_size_x * header.layer_size_y * sizeof(word));

    sTileset tileset;
    if (strcmp_ci(tilesetFilename + strlen(tilesetFilename) - 4, ".vsp") == 0)
      success = tileset.Import_VSP(tilesetFilename, fs);
    else
      success = tileset.Load(tilesetFilename, fs);

    sLayer layer[2];

    if (success)
    {
      // process map and see if the map has tiles that are out of range
      int highestTileIndex = 0;
      for (int j=0; j<header.layer_size_y; j++)
        for (int i=0; i<header.layer_size_x; i++)
          if (layer_background[j * header.layer_size_x + i] >= highestTileIndex)
            highestTileIndex = layer_background[j * header.layer_size_x + i];
          else if (layer_foreground[j * header.layer_size_x + i] >= highestTileIndex)
            highestTileIndex = layer_foreground[j * header.layer_size_x + i];

      if (highestTileIndex >= tileset.GetNumTiles())
        success = false;

      // transfer data across into the sMap now...
      if (success)
      {
        layer[0].SetName("Background");
        layer[1].SetName("Foreground");
        layer[0].Resize(header.layer_size_x, header.layer_size_y);
        layer[1].Resize(header.layer_size_x, header.layer_size_y);

        for (int j=0; j<header.layer_size_y; j++)
          for (int i=0; i<header.layer_size_x; i++)
          {
            layer[0].SetTile(i,j, layer_background[j * header.layer_size_x + i]);

            if (layer_foreground[j * header.layer_size_x + i])
            layer[1].SetTile(i,j, layer_foreground[j * header.layer_size_x + i]);
            else
              layer[1].SetTile(i,j, tileset.GetNumTiles());
          }

        tileset.AppendTiles(1);
        memset(tileset.GetTile(tileset.GetNumTiles() - 1).GetPixels(), 0, 256 * sizeof(RGBA));
        m_Tileset = tileset;
        AppendLayer(layer[0]);
        AppendLayer(layer[1]);
        SetMusicFile((char*)header.music_fname);
        SetStartX(header.x_start);
        SetStartX(header.y_start);
        SetStartDirection(4);

        // calculate the parallax mode
        for (int i=0; i<2; i++)
        {
          // FIXME (set parallax properly)
//          GetLayer(i).SetParallaxX(1, 1);
//          GetLayer(i).SetParallaxY(1, 1);
//          GetLayer(i).SetScrollingX(1, 1);
//          GetLayer(i).SetScrollingX(1, 1);
        }

        switch(header.parallax_mode)
        {
          case 0:
            SetStartLayer(0);
            break;

          case 1:
            SetStartLayer(1);
            break;

          case 2:
            // FIXME (set parallax properly)
            SetStartLayer(1);
//            GetLayer(0).SetParallaxX(header.parallax_multiplier, header.parallax_divisor);
//            GetLayer(0).SetParallaxY(header.parallax_multiplier, header.parallax_divisor);
            break;

          case 3:
            // FIXME (set parallax properly)
            SetStartLayer(0);
//            GetLayer(1).SetParallaxX(header.parallax_multiplier, header.parallax_divisor);
//            GetLayer(1).SetParallaxY(header.parallax_multiplier, header.parallax_divisor);
            break;
        }
      }
    }

    // cleanup
    delete[] layer_background;
    delete[] layer_foreground;
  }
  else if (strcmp(signature, "MAPù5") == 0)
  {
    V2MAP_HEADER header;
    V2MAP_LAYERINFO LayerInfo[7];
    sTileset tileset;
    word *mapLayer[7];
    int i,j,k;
    int highestTileIndex = 0;

    file->Read(&header, sizeof(header));
    for (i=0; i<header.num_layers; i++)
    {
      file->Read(LayerInfo + i, sizeof(V2MAP_LAYERINFO));
      //bug for v2's map: two bytes are added for no reason
      word w;
      file->Read(&w, 2);
    }

    // get info about map and uncompress it
    for (i=0; i<header.num_layers; i++)
      mapLayer[i] = new word[LayerInfo[i].size_x * LayerInfo[i].size_y];

    for (i=0; i<header.num_layers; i++)
    {
      // god, this is so dumb. It's supposed to be the buffersize, but do I look like I need it?
      file->Read(&j, 4);
      for (j=0; j<LayerInfo[i].size_x*LayerInfo[i].size_y; j++)
      {
        word value;
        byte run;
        
        file->Read(&value, sizeof(word));

        if ((value & 0xFF00) == 0xFF00)
        {
          run = (byte)value & 0x00FF;
          file->Read(&value, sizeof(word));
          
          mapLayer[i][j] = value;
          for (k=1; k<run; k++)
          {
            j++;
            mapLayer[i][j] = value;
          }
        }
        else
        {
          mapLayer[i][j]  = value;
        }
      }
    }

    if (strcmp_ci(tilesetFilename + strlen(tilesetFilename) - 4, ".vsp") == 0)
      success = tileset.Import_VSP(tilesetFilename);
    else
      success = tileset.Load(tilesetFilename);


    // transfer map array into the class
    if (success)
    {
      highestTileIndex = 0;
      // check for any tile index larger than the tilset's index
      for (i=0; i<header.num_layers; i++)
        for (j=0; j<LayerInfo[i].size_x*LayerInfo[i].size_y; j++)
          if (mapLayer[i][j] >= highestTileIndex)
            highestTileIndex = mapLayer[i][j];

      if (highestTileIndex >= tileset.GetNumTiles())
        success = false;

    if (success)
      {
        sLayer *layer;
        layer = new sLayer[header.num_layers];

        for (i=0; i<header.num_layers; i++)
        {
          char Name[7];
          memcpy(Name, "Layer A", 8);
          Name[6] += i;

          layer[i].SetName(Name);
          layer[i].Resize(LayerInfo[i].size_x, LayerInfo[i].size_y);
        }

        for (i=0; i<header.num_layers; i++)
        {
          for (j=0; j<LayerInfo[i].size_y; j++)
            for (k=0; k<LayerInfo[i].size_x; k++)
              layer[i].SetTile(k, j, mapLayer[i][(j * LayerInfo[i].size_x) + k]);

          // FIXME: set parallax properly
//          layer[i].SetParallaxX(LayerInfo[i].multx, LayerInfo[i].pdivx);
//          layer[i].SetParallaxY(LayerInfo[i].multy, LayerInfo[i].pdivy);
//          layer[i].SetScrollingX(1,1);
//          layer[i].SetScrollingY(1,1);
        }

        for (i=0; i<(int)strlen((char*)header.renderstring); i++)
          switch(header.renderstring[i])
          {
          case '1': AppendLayer(layer[0]); j = 0; break;
          case '2': AppendLayer(layer[1]); j = 1; break;
          case '3': AppendLayer(layer[2]); j = 2; break;
          case '4': AppendLayer(layer[3]); j = 3; break;
          case '5': AppendLayer(layer[4]); j = 4; break;
          case '6': AppendLayer(layer[5]); j = 5; break;
          case 'E': SetStartLayer(j); break;
          }

        SetMusicFile((char*)header.music_name);
        SetStartX(header.x_start);
        SetStartY(header.y_start);
        m_Tileset = tileset;

        delete[] layer;
      } 
    }

    for (i=0; i<header.num_layers; i++)
      delete mapLayer[i];
  }

  file->Close();
  return success;
} 
예제 #9
0
static void UpdateTreeStructure(CTreeCtrl& m_TreeControl, HTREEITEM root) {
  const int FOLDER_CLOSED = 1;
  const int FOLDER_OPENED = 2;

  std::vector<std::string> folderlist = GetFolderList("*");
  for (unsigned int i = 0; i < folderlist.size(); i++) {
    if (!strcmp(folderlist[i].c_str(), ".")
        || !strcmp(folderlist[i].c_str(), "..")) {
      continue;
    }

    // insert folder
    HTREEITEM item = m_TreeControl.InsertItem(
      TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE,
      folderlist[i].c_str(),
      FOLDER_CLOSED, // image,
      FOLDER_OPENED, // selected_image,
      0,
      0,
      0, // item,
      root == NULL ? TVI_ROOT : root,
      TVI_SORT
    );

    // insert files into that folder
    char directory[MAX_PATH] = {0};
    GetCurrentDirectory(MAX_PATH, directory);
    SetCurrentDirectory(folderlist[i].c_str());
    std::vector<std::string> filelist = GetFileList("*");

    for (unsigned int j = 0; j < filelist.size(); j++)
    {
      // don't show thumbs.db files
      if (filelist[j].size() >= strlen("thumbs.db") && strcmp_ci(filelist[j].c_str(), "thumbs.db") == 0)
        continue;

      // don't show folder.htt files
      if (filelist[j].size() >= strlen("folder.htt") && strcmp_ci(filelist[j].c_str(), "folder.htt") == 0)
        continue;

      // don't show desktop.ini files
      if (filelist[j].size() >= strlen("desktop.ini") && strcmp_ci(filelist[j].c_str(), "desktop.ini") == 0)
        continue;

      // don't show .pyc files
      if (filelist[j].size() >= 4 && filelist[j].rfind(".pyc") == filelist[j].size() - 4) {
        continue;
      }

      // don't show .class files
      if (filelist[j].size() >= 6 && filelist[j].rfind(".class") == filelist[j].size() - 6) {
        continue;
      }

      int image_index = IDI_FILETYPE_BASE - 1; // Unknown icon type
      std::string filename = filelist[j];
      for (int file_type = 0; file_type < FTL.GetNumFileTypes(); file_type++) {
        std::vector<std::string> extensions;
        FTL.GetFileTypeExtensions(file_type, false, extensions);

        for (unsigned int i = 0; i < extensions.size(); i++) {
          if (filename.rfind(extensions[i]) == filename.size() - extensions[i].size()) {
            image_index = IDI_FILETYPE_BASE + file_type;
            file_type = FTL.GetNumFileTypes();
            break;
          }
        }
      }

      m_TreeControl.InsertItem(
        TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE,
        filelist[j].c_str(),
        image_index, image_index, //image, image,
        0, 0, 0, item, TVI_SORT
      );
    }

    filelist.clear();
    if (GetFolderList("*").size() > 0)
      UpdateTreeStructure(m_TreeControl, item);

    SetCurrentDirectory(directory);
  }
}