当前位置: 首页>>代码示例>>C++>>正文


C++ CTFileStream类代码示例

本文整理汇总了C++中CTFileStream的典型用法代码示例。如果您正苦于以下问题:C++ CTFileStream类的具体用法?C++ CTFileStream怎么用?C++ CTFileStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CTFileStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DisableRendering

// save anim set file
BOOL CSeriousSkaStudioApp::SaveAnimSetFile(CAnimSet &as, BOOL bConvert)
{
  DisableRendering();
  CTFileName fnAnimSet = as.GetName();
  fnAnimSet = fnAnimSet.NoExt() + ".aal";
  try {
    fnAnimSet.RemoveApplicationPath_t();
  } catch(char *){}

  // back up current skeleton list file
  CTString strBackUp;
  try {
    strBackUp.Load_t(fnAnimSet); 
  } catch(char*){}

  CTFileStream ostrFile;
  try {
    ostrFile.Create_t(fnAnimSet,CTStream::CM_TEXT);
    SaveAnimSet_t(as,ostrFile);
    ostrFile.Close();
  } catch(char *strError) {
    ErrorMessage(strError);
    EnableRendering();
    return FALSE;
  }

  if(bConvert) {
    ConvertAnimSet(fnAnimSet);
  }

  EnableRendering();
  return TRUE;
}
开发者ID:AdamFlores,项目名称:Serious-Engine,代码行数:34,代码来源:SeriousSkaStudio.cpp

示例2: Load_t

void CPlayerCharacter::Load_t( const CTFileName &fnFile) // throw char *
{
  CTFileStream strm;
  strm.Open_t(fnFile);
  Read_t(&strm);
  strm.Close();
}
开发者ID:RocketersAlex,项目名称:LCSource,代码行数:7,代码来源:PlayerCharacter.cpp

示例3: WriteFont_t

extern void WriteFont_t(CFontData &fdFont, const CImageInfo &iiFont, const CImageInfo &iiGrid, const CTFileName &fnFont)
{
  MEX inMex = Max(iiFont.ii_Height,iiFont.ii_Width);
  INDEX ctMipmaps = 0;// GetNoOfMipmaps(iiFont.ii_Width,iiFont.ii_Height);

  CTFileName fnName = fnFont.NoExt();
  try {
    fnName.RemoveApplicationPath_t();
  } catch(char *) {
  }
  // save font tga file
  iiFont.SaveTGA_t(fnName + ".tga");
  iiGrid.SaveTGA_t(fnName + "G.tga");
  // create tex file from saved targa
  CreateTexture_t( fnName+".tga",  fnName+".tex",  inMex, ctMipmaps, TEX_CONSTANT);
  CreateTexture_t( fnName+"G.tga", fnName+"G.tex", inMex, ctMipmaps);
  
  // set texture source to saved font
  fdFont.fd_ptdTextureData = _pTextureStock->Obtain_t(fnName+".tex");
  fdFont.fd_ptdTextureData->Reload();
  fdFont.fd_ptdTextureData->Force(TEX_CONSTANT); // don't mess with created textures
  fdFont.fd_fnTexture = fnName+".tex";

  _ptdGrid = _pTextureStock->Obtain_t(fnName + "G.tex");
  if(_ptdGrid!=NULL) {
    _ptdGrid->Reload();
    _ptdGrid->Force(TEX_CONSTANT); // don't mess with created textures
  }

  // finaly save fnt file
  CTFileStream ostr;
  ostr.Create_t(fnName + ".fnt");
  fdFont.Write_t(&ostr);
}
开发者ID:RocketersAlex,项目名称:LCSource,代码行数:34,代码来源:FontGen.cpp

示例4: GetDocument

// Save smc file
void CSeriousSkaStudioApp::SaveSmcFile(CModelInstance &mi,BOOL bSaveChildren)
{
	CSeriousSkaStudioDoc *pDoc = GetDocument();

  // first get first model instance that has its file
  CModelInstance *pmiParent=NULL;
  CModelInstance *pmiFirst=&mi;
  CTFileName fnSmc = mi.mi_fnSourceFile;
  CModelInstance *pfmi = mi.GetFirstNonReferencedParent(GetDocument()->m_ModelInstance);
  if(pfmi!=NULL) {
    pmiParent = pfmi->GetParent(pDoc->m_ModelInstance);
    pmiFirst = pfmi;
    fnSmc = pfmi->mi_fnSourceFile;
  }

  DisableRendering();
  try
  {
    fnSmc.RemoveApplicationPath_t();
  }
  catch(char *){}

  CTFileStream ostrFile;
  // try to save model instance
  try {
    ostrFile.Create_t(fnSmc,CTStream::CM_TEXT);
    SaveModelInstance_t(pmiFirst,pmiParent,ostrFile,bSaveChildren);
    ostrFile.Close();
    NotificationMessage("Smc '%s' saved.",pmiFirst->mi_fnSourceFile); 
  } catch(char *strError) {
    ErrorMessage(strError);
  }
  EnableRendering();
}
开发者ID:AdamFlores,项目名称:Serious-Engine,代码行数:35,代码来源:SeriousSkaStudio.cpp

示例5: Save_t

void CPlayerCharacter::Save_t( const CTFileName &fnFile) // throw char *
{
  CTFileStream strm;
  strm.Create_t(fnFile);
  Write_t(&strm);
  strm.Close();
}
开发者ID:RocketersAlex,项目名称:LCSource,代码行数:7,代码来源:PlayerCharacter.cpp

示例6: Load_t

/*
 * Load entire world (both brushes and current state).
 */
void CWorld::Load_t(const CTFileName &fnmWorld) // throw char *
{
  // remember the file
  wo_fnmFileName = fnmWorld;
  // open the file
  CTFileStream strmFile;
  strmFile.Open_t(fnmWorld);

  // check engine build allowing reinit
  BOOL bNeedsReinit;
  _pNetwork->CheckVersion_t(strmFile, TRUE, bNeedsReinit);

  // read the world from the file
  Read_t(&strmFile);

  // close the file
  strmFile.Close();

  // if reinit is needed
  if (bNeedsReinit) {
    // reinitialize
    SetProgressDescription(TRANS("converting from old version"));
    CallProgressHook_t(0.0f);
    ReinitializeEntities();
    CallProgressHook_t(1.0f);
    // reinitialize
    SetProgressDescription(TRANS("saving converted file"));
    CallProgressHook_t(0.0f);
    Save_t(fnmWorld);
    CallProgressHook_t(1.0f);
  }
}
开发者ID:ArcticPheenix,项目名称:Serious-Engine,代码行数:35,代码来源:WorldIO.cpp

示例7: ASSERT

// enable dictionary in writable file from this point
void CTStream::DictionaryWriteBegin_t(const CTFileName &fnmImportFrom, SLONG slImportOffset)
{
  ASSERT(strm_slDictionaryPos==0);
  ASSERT(strm_dmDictionaryMode == DM_NONE);
  strm_ntDictionary.SetAllocationParameters(100, 5, 5);
  strm_ctDictionaryImported = 0;

  // if importing an existing dictionary to start with
  if (fnmImportFrom!="") {
    // open that file
    CTFileStream strmOther;
    strmOther.Open_t(fnmImportFrom);
    // read the dictionary in that stream
    strmOther.ReadDictionary_intenal_t(slImportOffset);
    // copy the dictionary here
    CopyDictionary(strmOther);
    // write dictionary importing data
    WriteID_t("DIMP");  // dictionary import
    *this<<fnmImportFrom<<slImportOffset;
    // remember how many filenames were imported
    strm_ctDictionaryImported = strm_afnmDictionary.Count();
  }

  // write dictionary position chunk id
  WriteID_t("DPOS");  // dictionary position
  // remember where position will be placed
  strm_slDictionaryPos = GetPos_t();
  // leave space for position
  *this<<SLONG(0);

  // start dictionary
  strm_dmDictionaryMode = DM_ENABLED;
}
开发者ID:bsmr-games,项目名称:Serious-Engine,代码行数:34,代码来源:Stream.cpp

示例8: Save_t

/*
 * Save entire world (both brushes  current state).
 */
void CWorld::Save_t(const CTFileName &fnmWorld) // throw char *
{
  // create the file
  CTFileStream strmFile;
  strmFile.Create_t(fnmWorld);

  // save engine build
  _pNetwork->WriteVersion_t(strmFile);

  // write the world to the file
  Write_t(&strmFile);
}
开发者ID:ArcticPheenix,项目名称:Serious-Engine,代码行数:15,代码来源:WorldIO.cpp

示例9: LoadOneFile

static void LoadOneFile(const CTFileName &fnm)
{
  try {
    // open the file
    CTFileStream strm;
    strm.Open_t(fnm);

    // count number of lines
    INDEX ctLines = 0;
    while(!strm.AtEOF()) {
      CTString strLine;
      strm.GetLine_t(strLine);
      ctLines++;
    }
    strm.SetPos_t(0);

    // allocate that much
    CTString *astr = _astrCredits.Push(ctLines);
    // load all lines
    for(INDEX iLine = 0; iLine<ctLines && !strm.AtEOF(); iLine++) {
      strm.GetLine_t(astr[iLine]);
    }

    strm.Close();

    _bCreditsOn = TRUE;
  } catch (char *strError) {
    CPrintF("%s\n", strError);
  }
}
开发者ID:AdamFlores,项目名称:Serious-Engine,代码行数:30,代码来源:Credits.cpp

示例10: SaveSettings

static void SaveSettings(const CTFileName &fnConfgin)
{
  if(!_bInitialized) return;
  try {
    CTFileStream ostr;
    ostr.Create_t(fnConfgin);

    INDEX iVersion=CONFIG_VERSION;
    ULONG ulFlags = GetFontFlags();
    INDEX iFontSize = GetIntFromControl(IEC_FONT_SIZE);
    INDEX iFirstChar = GetIntFromControl(IEC_FIRST_CHAR);
    INDEX iLastChar = GetIntFromControl(IEC_LAST_CHAR);
    INDEX iAlignH  = GetComboIndex(IDC_ALIGN_H);
    INDEX iAlignV  = GetComboIndex(IDC_ALIGN_V);
    INDEX iPaddingX = GetIntFromControl(IEC_PADDINGX);
    INDEX iPaddingY = GetIntFromControl(IEC_PADDINGY);
    INDEX iWidthAdd = GetIntFromControl(IEC_WIDTH_ADD);
    INDEX iHeightAdd = GetIntFromControl(IEC_HEIGHT_ADD);
    INDEX ctShadows = GetIntFromControl(IEC_SHADOW_PASSES);
    INDEX iTexWidth = GetIntFromControl(ICB_TEX_WIDTH);
    INDEX iTexHeight = GetIntFromControl(ICB_TEX_HEIGHT);
    const CTString strFontName = GetStringFromControl(ICB_FONT_NAMES);
    const CTString strSampleText = GetStringFromControl(IEC_SAMPLE_TEXT);

  
    ostr<<iVersion;
    ostr<<ulFlags;
    ostr<<iFontSize;
    ostr<<iFirstChar;
    ostr<<iLastChar;
    ostr<<iAlignH;
    ostr<<iAlignV;
    ostr<<iPaddingX;
    ostr<<iPaddingY;
    ostr<<iWidthAdd;
    ostr<<iHeightAdd;
    ostr<<ctShadows;
    ostr<<iTexWidth;
    ostr<<iTexHeight;
    ostr<<strFontName;
    ostr<<strSampleText;
    ostr<<_bShowTexture;
    ostr<<_bShowGrid;
    ostr<<_fnCharacterTable;
  } catch(char *strErr) {
    MessageBox(_hWnd,strErr,0,0);
  }
}
开发者ID:RocketersAlex,项目名称:LCSource,代码行数:48,代码来源:FontGen.cpp

示例11: SaveTGA_t

// save TGA routine
void CImageInfo::SaveTGA_t( const CTFileName &strFileName) const // throw char *
{
  TGAHeader *pTGAHdr;
  UBYTE *pTGABuffer, *pTGAImage;
  SLONG slFileSize;
  PIX pixBitmapSize = ii_Width*ii_Height;
  CTFileStream TGAFile;

  // determine and check image info format
  SLONG slBytesPerPixel = ii_BitsPerPixel/8;
  ASSERT( slBytesPerPixel==3 || slBytesPerPixel==4);
  if( slBytesPerPixel!=3 && slBytesPerPixel!=4) throw( TRANS( "Unsupported BitsPerPixel in ImageInfo header."));

  // determine TGA file size and allocate memory
  slFileSize = sizeof(struct TGAHeader) + pixBitmapSize *slBytesPerPixel;
  pTGABuffer = (UBYTE*)AllocMemory( slFileSize);
  pTGAHdr    = (struct TGAHeader*)pTGABuffer;
  pTGAImage  = pTGABuffer + sizeof(struct TGAHeader);

  // set TGA picture size dimensions
  memset( pTGABuffer, 0x0, sizeof(struct TGAHeader));
  pTGAHdr->Width        = (UWORD)ii_Width;
  pTGAHdr->Height       = (UWORD)ii_Height;
  pTGAHdr->BitsPerPixel = (UBYTE)ii_BitsPerPixel;
  pTGAHdr->ImageType    = 2;

  // flip image vertically
  BOOL bAlphaChannel = (slBytesPerPixel==4);
  FlipBitmap( ii_Picture, pTGAImage, ii_Width, ii_Height, 1, bAlphaChannel);

  // convert CroTeam's pixel format to TGA format
  UBYTE *pubTmp = pTGAImage;  // need 'walking' pointer
  for( INDEX iPix=0; iPix<pixBitmapSize; iPix++)
  { // flip bytes
    Swap( pubTmp[0], pubTmp[2]);  // R & B channels
    pubTmp += slBytesPerPixel; 
  }

  // save entire TGA memory to file and close it
  TGAFile.Create_t( strFileName);
  TGAFile.Write_t( pTGABuffer, slFileSize);
  TGAFile.Close();

  // free temorary allocated memory for TGA image format
  FreeMemory( pTGABuffer);
}
开发者ID:0-T-0,项目名称:Serious-Engine,代码行数:47,代码来源:ImageInfo.cpp

示例12: LoadBrushes_t

/*
 * Load just world brushes from a file with entire world information.
 */
void CWorld::LoadBrushes_t(const CTFileName &fnmWorld) // throw char *
{
  // remember the file
  wo_fnmFileName = fnmWorld;
  // open the file
  CTFileStream strmFile;
  strmFile.Open_t(fnmWorld);

  // check engine build disallowing reinit
  BOOL bNeedsReinit;
  _pNetwork->CheckVersion_t(strmFile, FALSE, bNeedsReinit);
  ASSERT(!bNeedsReinit);

  strmFile.ExpectID_t("WRLD"); // 'world'
  // read the world brushes from the file
  ReadBrushes_t(&strmFile);
}
开发者ID:ArcticPheenix,项目名称:Serious-Engine,代码行数:20,代码来源:WorldIO.cpp

示例13: CreateTexture

void CDlgCreateSpecularTexture::CreateTexture( CTFileName fnTexture, FLOAT fExp)
{
  CImageInfo II;
  CTFileStream fsFile;
  CTextureData TD;

  INDEX iSelectedSize = m_comboSizeInPixels.GetCurSel();
  ASSERT( iSelectedSize != CB_ERR);
  PIX pixSize = 1UL<<iSelectedSize;
  PIX pixSizeI = pixSize;
  PIX pixSizeJ = pixSize;
  UBYTE *pubImage = (UBYTE *)AllocMemory(pixSize*pixSize*3);
  II.Attach(pubImage, pixSize, pixSize, 24);
  for (PIX pixI=0; pixI<pixSizeI; pixI++) {
    for (PIX pixJ=0; pixJ<pixSizeJ; pixJ++) {
      FLOAT fS = pixI*2.0f/pixSizeI-1;
      FLOAT fT = pixJ*2.0f/pixSizeJ-1;
      FLOAT fZ = Sqrt(1-2*fS*fS-2*fT*fT);
      fZ = Clamp(fZ, 0.0f, 1.0f);
      FLOAT fZN = FLOAT(pow(fZ, fExp));
      ASSERT(fZN>=0 && fZN<=1);
      UBYTE ub = UBYTE(fZN*255);
      pubImage[(pixJ*pixSize+pixI)*3+0] = ub;
      pubImage[(pixJ*pixSize+pixI)*3+1] = ub;
      pubImage[(pixJ*pixSize+pixI)*3+2] = ub;
    }
  }

  try
  {
    TD.Create_t( &II, pixSize, 1, FALSE);
    fsFile.Create_t( fnTexture);
    TD.Write_t( &fsFile);
    fsFile.Close();
  }
  // if failed
  catch (char *strError)
  {
    // report error
    AfxMessageBox(CString(strError));
  }
  II.Detach();
  FreeMemory(pubImage);
}
开发者ID:0-T-0,项目名称:Serious-Engine,代码行数:44,代码来源:DlgCreateSpecularTexture.cpp

示例14: LoadFileList

// load a filelist
static BOOL LoadFileList(CDynamicStackArray<CTFileName> &afnm, const CTFileName &fnmList)
{
  afnm.PopAll();
  try {
    CTFileStream strm;
    strm.Open_t(fnmList);
    while(!strm.AtEOF()) {
      CTString strLine;
      strm.GetLine_t(strLine);
      strLine.TrimSpacesLeft();
      strLine.TrimSpacesRight();
      if (strLine!="") {
        afnm.Push() = strLine;
      }
    }
    return TRUE;
  } catch(char *strError) {
    CPrintF("%s\n", strError);
    return FALSE;
  }
}
开发者ID:bsmr-games,项目名称:Serious-Engine,代码行数:22,代码来源:Stream.cpp

示例15: GetGfxFileInfo_t

// sets image info structure members with info form file of any supported graphic format
//  (CT RAW, PCX8, PCX24, TGA32 uncompressed), but does not load picture content nor palette
INDEX CImageInfo::GetGfxFileInfo_t( const CTFileName &strFileName) // throw char *
{
  CTFileStream GfxFile;
  TGAHeader TGAhdr;
  PCXHeader PCXhdr;

  // lets assume it's a TGA file
  GfxFile.Open_t( strFileName, CTStream::OM_READ);
  GfxFile.Read_t( &TGAhdr, sizeof( struct TGAHeader));
  GfxFile.Close();

  // check for supported targa format
  if( (TGAhdr.ImageType==2 || TGAhdr.ImageType==10) && TGAhdr.BitsPerPixel>=24) {
    // targa it is, so clear image info and set new values
    Clear();
    ii_Width  = TGAhdr.Width;
    ii_Height = TGAhdr.Height;
    ii_BitsPerPixel = TGAhdr.BitsPerPixel;
    // we done here, no need to check further
    return TGA_FILE;
  }

  // we miss Targa, so lets check for supported PCX format
  GfxFile.Open_t( strFileName, CTStream::OM_READ);
  GfxFile.Read_t( &PCXhdr, sizeof( struct PCXHeader));
  GfxFile.Close();

  // check for supported PCX format
  if( (PCXhdr.MagicID == 10) && (PCXhdr.PixelBits == 8)) {
    // PCX it is, so clear image info and set new values
    Clear();
    ii_Width = PCXhdr.Xmax - PCXhdr.Xmin + 1;
    ii_Height = PCXhdr.Ymax - PCXhdr.Ymin + 1;
    ii_BitsPerPixel = PCXhdr.PixelBits * PCXhdr.Planes;
    // we done here, no need to check further
    return PCX_FILE;
  }

  // we didn't found a supported gfx format, sorry ...
  return UNSUPPORTED_FILE;
}
开发者ID:0-T-0,项目名称:Serious-Engine,代码行数:43,代码来源:ImageInfo.cpp


注:本文中的CTFileStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。