Beispiel #1
0
// parse command line parameters and set results to static variables
void ParseCommandLine(CTString strCmd)
{
  cmd_strOutput = "";
  cmd_strOutput+=CTString(0, TRANS("Command line: '%s'\n"), strCmd);
  // if no command line
  if (strlen(strCmd) == 0) {
    // do nothing
    return;
  }
  _strCmd = strCmd;

  FOREVER {
    CTString strWord = GetNextParam();
    if (strWord=="") {
      cmd_strOutput+="\n";
      return;
    } else if (strWord=="+level") {
      cmd_strWorld = GetNextParam();
    } else if (strWord=="+server") {
      cmd_bServer = TRUE;
    } else if (strWord=="+quickjoin") {
      cmd_bQuickJoin = TRUE;
    } else if (strWord=="+game") {
      CTString strMod = GetNextParam();
      if (strMod!="SeriousSam") { // (we ignore default mod - always use base dir in that case)
        _fnmMod = "Mods\\"+strMod+"\\";
      }
    } else if (strWord=="+cdpath") {
      _fnmCDPath = GetNextParam();
    } else if (strWord=="+password") {
      cmd_strPassword = GetNextParam();
    } else if (strWord=="+connect") {
      cmd_strServer = GetNextParam();
      const char *pcColon = strchr(cmd_strServer, ':');
      if (pcColon!=NULL) {
        CTString strServer;
        CTString strPort;
        cmd_strServer.Split(pcColon-cmd_strServer, strServer, strPort);
        cmd_strServer = strServer;
        strPort.ScanF(":%d", &cmd_iPort);
      }
    } else if (strWord=="+script") {
      cmd_strScript = GetNextParam();
    } else if (strWord=="+goto") {
      GetNextParam().ScanF("%d", &cmd_iGoToMarker);
    } else if (strWord=="+logfile") {
      _strLogFile = GetNextParam();
    } else {
      cmd_strOutput+=CTString(0, TRANS("  Unknown option: '%s'\n"), strWord);
    }
  }
}
Beispiel #2
0
void ReadPos(CCameraPos &cp)
{
  try {
    CTString strLine;
    _strScript.GetLine_t(strLine);
    strLine.ScanF("%g: %g: %g %g %g:%g %g %g:%g", 
      &cp.cp_tmTick,
      &cp.cp_fSpeed,
      &cp.cp_vPos(1), &cp.cp_vPos(2), &cp.cp_vPos(3),
      &cp.cp_aRot(1), &cp.cp_aRot(2), &cp.cp_aRot(3),
      &cp.cp_aFOV);

  } catch (char *strError) {
    CPrintF("Camera: %s\n", strError);
  }
}
Beispiel #3
0
CTString IFeel_GetProjectFileName()
{
  CTString strIFeelTable;
  CTFileName fnIFeelTable = (CTString)"Data\\IFeel.txt";
  CTString strDefaultProjectFile = "Data\\Default.ifr";
  // get product name
  CTString strProduct = IFeel_GetProductName();
  try
  {
    strIFeelTable.Load_t(fnIFeelTable);
  }
  catch(char *strErr)
  {
    CPrintF("%s\n",strErr);
    return "";
  }

  CTString strLine;
  // read up to 1000 devices
  for(INDEX idev=0;idev<1000;idev++)
  {
    char strDeviceName[256];
    char strProjectFile[256];
    strLine = strIFeelTable;
    // read first line
    strLine.OnlyFirstLine();
    if(strLine==strIFeelTable)
    {
      break;
    }
    // remove that line 
    strIFeelTable.RemovePrefix(strLine);
    strIFeelTable.DeleteChar(0);
    // read device name and project file name
    strIFeelTable.ScanF("\"%256[^\"]\" \"%256[^\"]\"",&strDeviceName,&strProjectFile);
    // check if this is default 
    if(strcmp(strDeviceName,"Default")==0) strDefaultProjectFile = strProjectFile;
    // check if this is current device 
    if(strProduct == strDeviceName) return strProjectFile;
  }
  // device was not found, return default project file
  CPrintF("No project file specified for device '%s'.\nUsing default project file\n",strProduct);
  return strDefaultProjectFile;
}
Beispiel #4
0
void CVirtualTreeCtrl::OnDropFiles(HDROP hDropInfo) 
{
	CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd());
  INDEX ctFiles = DragQueryFile( hDropInfo, 0xFFFFFFFF, NULL, 0);

  // get dropped coordinates
  CPoint point;
  DragQueryPoint( hDropInfo, &point);
  
  CVirtualTreeNode *pVTNDst = ItemForCoordinate(point);
  if( pVTNDst!=NULL)
  {
    for( INDEX i=0; i<ctFiles; i++)
    {
	    char chrFile[ 256];
      DragQueryFile( hDropInfo, i, chrFile, 256);
      CTString strAddr = CTString(chrFile);
      if( strAddr != "")
      {
        CVirtualTreeNode *pVTNSrc;
        strAddr.ScanF("VTN%d", &pVTNSrc);
        if(pVTNSrc==pVTNDst) return;
        pVTNSrc->MoveToDirectory( pVTNDst);
        // delete all items
        DeleteAllItems();
        m_pBrowser->AddDirectoryRecursiv( &m_pBrowser->m_VirtualTree, TVI_ROOT);   // Fill CTreeCtrl using recursion
        SortChildren( NULL);
        SelectItem( (HTREEITEM) pVTNSrc->vtn_Handle);
        m_pBrowser->m_bVirtualTreeChanged = TRUE;
        m_pBrowser->OpenSelectedDirectory();
      }
    }
  }

	CTreeCtrl::OnDropFiles(hDropInfo);
}
Beispiel #5
0
// parse command line parameters and set results to static variables
void ParseCommandLine(CTString strCmd)
{
    cmd_strOutput = "";
    cmd_strOutput+=CTString(0, TRANS("Command line: '%s'\n"), strCmd);
    // if no command line
    if (strlen(strCmd) == 0) {
        // do nothing
        return;
    }
    _strCmd = strCmd;

    FOREVER {
        CTString strWord = GetNextParam();
        if (strWord=="") {
            cmd_strOutput+="\n";
            return;
        } else if (strWord=="+level") {
            cmd_strWorld = GetNextParam();
        } else if (strWord=="+server") {
            cmd_bServer = TRUE;
        } else if (strWord=="+player") {
            cmd_strPlayer = GetNextParam();
        } else if (strWord=="+quickjoin") {
            cmd_bQuickJoin = TRUE;
        } else if (strWord=="+game") {
            CTString strMod = GetNextParam();
#if _SE_DEMO
            if (strMod!="SeriousSam" && strMod!="Warped") {
                FatalError(TRANS("This MOD is not allowed in demo version!"));
                return;
            }
#endif
            if (strMod!="SeriousSam") { // (we ignore default mod - always use base dir in that case)
                _fnmMod = "Mods\\"+strMod+"\\";
            }
        } else if (strWord=="+cdpath") {
            _fnmCDPath = GetNextParam();
        } else if (strWord=="+password") {
            cmd_strPassword = GetNextParam();
        } else if (strWord=="+connect") {
            cmd_strServer = GetNextParam();
            const char *pcColon = strchr(cmd_strServer, ':');
            if (pcColon!=NULL) {
                CTString strServer;
                CTString strPort;
                cmd_strServer.Split(pcColon-cmd_strServer, strServer, strPort);
                cmd_strServer = strServer;
                strPort.ScanF(":%d", &cmd_iPort);
            }
        } else if (strWord=="+windowpos") {
            CTString strWinPos = GetNextParam();
            const char *pcColon = strchr(strWinPos, ':');
            if (pcColon!=NULL) {
                CTString strLeft;
                CTString strTop;
                strWinPos.Split(pcColon-strWinPos, strLeft, strTop);
                strLeft.ScanF("%d", &cmd_iWindowLeft);
                strTop.ScanF(":%d", &cmd_iWindowTop);
            }
        } else if (strWord=="+script") {
            cmd_strScript = GetNextParam();
        } else if (strWord=="+goto") {
            GetNextParam().ScanF("%d", &cmd_iGoToMarker);
        } else if (strWord=="+logfile") {
            _strLogFile = GetNextParam();
        } else {
            cmd_strOutput+=CTString(0, TRANS("  Unknown option: '%s'\n"), strWord);
        }
    }
}
Beispiel #6
0
static void LoadingHook_t(CProgressHookInfo *pphi)
{
  // if user presses escape
  ULONG ulCheckFlags = 0x8000;
  if (pphi->phi_fCompleted>0) {
    ulCheckFlags |= 0x0001;
  }
  if (_bUserBreakEnabled && (GetAsyncKeyState(VK_ESCAPE)&ulCheckFlags)) {
    // break loading
    throw TRANS("User break!");
  }

#if USECUSTOMTEXT
  // if no custom loading text
  if (_strCustomText=="") {
    // load it
    try {
      _strCustomText.Load_t(CTFILENAME("Data\\LoadingText.txt"));
    } catch (char *strError) {
      _strCustomText = strError;
    }
  }
#endif

  // measure time since last call
  static CTimerValue tvLast(0I64);
  CTimerValue tvNow = _pTimer->GetHighPrecisionTimer();

  // if not first or final update, and not enough time passed
  if (pphi->phi_fCompleted!=0 && pphi->phi_fCompleted!=1 &&
     (tvNow-tvLast).GetSeconds() < REFRESHTIME) {
    // do nothing
    return;
  }
  tvLast = tvNow;

  // skip if cannot lock drawport
  CDrawPort *pdp = _pdpLoadingHook;                           
  ASSERT(pdp!=NULL);
  CDrawPort dpHook(pdp, TRUE);
  if( !dpHook.Lock()) return;

  // clear screen
  dpHook.Fill(C_BLACK|255);

  // get session properties currently loading
  CSessionProperties *psp = (CSessionProperties *)_pNetwork->GetSessionProperties();
  ULONG ulLevelMask = psp->sp_ulLevelsMask;
  if (psp->sp_bCooperative) {
    INDEX iLevel = -1;
    INDEX iLevelNext = -1;
    CTString strLevelName = _pNetwork->ga_fnmWorld.FileName();
    CTString strNextLevelName = _pNetwork->ga_fnmNextLevel.FileName();
    
    // second encounter
    INDEX u, v;
    u = v = -1;
    strLevelName.ScanF("%01d_%01d_", &u, &v);
    iLevel = u*10+v;
    RemapLevelNames(iLevel);
    u = v = -1;
    strNextLevelName.ScanF("%01d_%01d_", &u, &v);
    iLevelNext = u*10+v;
    RemapLevelNames(iLevelNext);

    // first encounter
    if(iLevel == -1) {
      strLevelName.ScanF("%02d_", &iLevel);
      strNextLevelName.ScanF("%02d_", &iLevelNext);

      if(iLevel != -1) {
        map_bIsFirstEncounter = TRUE;
      }
    } else {
      map_bIsFirstEncounter = FALSE;
    }
   
    if (iLevel>0) {
      ulLevelMask|=1<<(iLevel-1);
    }
    if (iLevelNext>0) {
      ulLevelMask|=1<<(iLevelNext-1);
    }
  }

  if (ulLevelMask!=0 && !_pNetwork->IsPlayingDemo()) {
    // map hook
    extern void RenderMap( CDrawPort *pdp, ULONG ulLevelMask, CProgressHookInfo *pphi);
    RenderMap(&dpHook, ulLevelMask, pphi);

    // finish rendering
    dpHook.Unlock();
    dpHook.dp_Raster->ra_pvpViewPort->SwapBuffers();

    // keep current time
    tvLast = _pTimer->GetHighPrecisionTimer();
    return;
  }

  // get sizes
  PIX pixSizeI = dpHook.GetWidth();
  PIX pixSizeJ = dpHook.GetHeight();
  CFontData *pfd = _pfdConsoleFont;
  PIX pixCharSizeI = pfd->fd_pixCharWidth  + pfd->fd_pixCharSpacing;
  PIX pixCharSizeJ = pfd->fd_pixCharHeight + pfd->fd_pixLineSpacing;

  PIX pixBarSizeJ = 17;//*pixSizeJ/480;

  COLOR colBcg = LerpColor(C_BLACK, SE_COL_BLUE_LIGHT, 0.30f)|0xff;
  COLOR colBar = LerpColor(C_BLACK, SE_COL_BLUE_LIGHT, 0.45f)|0xff;
  COLOR colLines = colBar; //C_vdGREEN|0xff;
  COLOR colText = LerpColor(C_BLACK, SE_COL_BLUE_LIGHT, 0.95f)|0xff;
  COLOR colEsc = C_WHITE|0xFF;

  dpHook.Fill(0, pixSizeJ-pixBarSizeJ, pixSizeI, pixBarSizeJ, colBcg);
  dpHook.Fill(0, pixSizeJ-pixBarSizeJ, pixSizeI*pphi->phi_fCompleted, pixBarSizeJ, colBar);
  dpHook.DrawBorder(0, pixSizeJ-pixBarSizeJ, pixSizeI, pixBarSizeJ, colLines);

  dpHook.SetFont( _pfdConsoleFont);
  dpHook.SetTextScaling( 1.0f);
  dpHook.SetTextAspect( 1.0f);
  // print status text
  setlocale(LC_ALL, "");
  CTString strDesc(0, "%s", pphi->phi_strDescription);  strupr((char*)(const char*)strDesc);
  setlocale(LC_ALL, "C");
  CTString strPerc(0, "%3.0f%%", pphi->phi_fCompleted*100);
  //dpHook.PutText(strDesc, pixCharSizeI/2, pixSizeJ-pixBarSizeJ-2-pixCharSizeJ, C_GREEN|255);
  //dpHook.PutTextCXY(strPerc, pixSizeI/2, pixSizeJ-pixBarSizeJ/2+1, C_GREEN|255);
  dpHook.PutText(strDesc, pixCharSizeI/2, pixSizeJ-pixBarSizeJ+pixCharSizeJ/2, colText);
  dpHook.PutTextR(strPerc, pixSizeI-pixCharSizeI/2, pixSizeJ-pixBarSizeJ+pixCharSizeJ/2, colText);
  if (_bUserBreakEnabled && !_pGame->gm_bFirstLoading) {
    dpHook.PutTextC( TRANS( "PRESS ESC TO ABORT"), pixSizeI/2, pixSizeJ-pixBarSizeJ-2-pixCharSizeJ, colEsc);
  }

/*  
  //LCDPrepare(1.0f);
  //LCDSetDrawport(&dpHook);
  
  // fill the box with background dirt and grid
  //LCDRenderClouds1();
  //LCDRenderGrid();

  // draw progress bar
  PIX pixBarCentI = pixBoxSizeI*1/2;
  PIX pixBarCentJ = pixBoxSizeJ*3/4;
  PIX pixBarSizeI = pixBoxSizeI*7/8;
  PIX pixBarSizeJ = pixBoxSizeJ*3/8;
  PIX pixBarMinI = pixBarCentI-pixBarSizeI/2;
  PIX pixBarMaxI = pixBarCentI+pixBarSizeI/2;
  PIX pixBarMinJ = pixBarCentJ-pixBarSizeJ/2;
  PIX pixBarMaxJ = pixBarCentJ+pixBarSizeJ/2;

  dpBox.Fill(pixBarMinI, pixBarMinJ, 
    pixBarMaxI-pixBarMinI, pixBarMaxJ-pixBarMinJ, C_BLACK|255);
  dpBox.Fill(pixBarMinI, pixBarMinJ, 
    (pixBarMaxI-pixBarMinI)*pphi->phi_fCompleted, pixBarMaxJ-pixBarMinJ, C_GREEN|255);

  // put more dirt
  LCDRenderClouds2Light();

  // draw borders
  COLOR colBorders = LerpColor(C_GREEN, C_BLACK, 200);
  LCDDrawBox(0,-1, PIXaabbox2D(
    PIX2D(pixBarMinI, pixBarMinJ), 
    PIX2D(pixBarMaxI, pixBarMaxJ)), 
    colBorders|255);
  LCDDrawBox(0,-1, PIXaabbox2D(
    PIX2D(0,0), PIX2D(dpBox.GetWidth(), dpBox.GetHeight())), 
    colBorders|255);

  // print status text
  dpBox.SetFont( _pfdDisplayFont);
  dpBox.SetTextScaling( 1.0f);
  dpBox.SetTextAspect( 1.0f);
  // print status text
  CTString strRes;
  strRes.PrintF( "%s", pphi->phi_strDescription);
  //strupr((char*)(const char*)strRes);
  dpBox.PutTextC( strRes, 160, 17, C_GREEN|255);
  strRes.PrintF( "%3.0f%%", pphi->phi_fCompleted*100);
  dpBox.PutTextCXY( strRes, pixBarCentI, pixBarCentJ, C_GREEN|255);
  dpBox.Unlock();

  if( Flesh.gm_bFirstLoading) {
#if USECUSTOMTEXT
    FLOAT fScaling = (FLOAT)slSizeI/640.0f;
    dpHook.Lock();
    dpHook.SetFont( _pfdDisplayFont);
    dpHook.SetTextScaling( fScaling);
    dpHook.SetTextAspect( 1.0f);
    //dpHook.Fill( 0, 0, slSizeI, pixCenterJ, C_vdGREEN|255, C_vdGREEN|255, C_vdGREEN|0, C_vdGREEN|0);
    dpHook.PutTextC( TRANS( "SERIOUS SAM - TEST VERSION"), pixCenterI, 5*fScaling, C_WHITE|255);
    dpHook.PutTextC( TRANS( "THIS IS NOT A DEMO VERSION, THIS IS A COMPATIBILITY TEST!"), pixCenterI, 25*fScaling, C_WHITE|255);
    dpHook.PutTextC( TRANS( "Serious Sam (c) 2000 Croteam LLC, All Rights Reserved.\n"), pixCenterI, 45*fScaling, C_WHITE|255);
    dpHook.PutText( _strCustomText, 1*fScaling, 85*fScaling, C_GREEN|255);
    dpHook.Unlock();
#endif
  } else if (_bUserBreakEnabled) {
    FLOAT fScaling = (FLOAT)slSizeI/640.0f;
    dpHook.Lock();
    dpHook.SetFont( _pfdDisplayFont);
    dpHook.SetTextScaling( fScaling);
    dpHook.SetTextAspect( 1.0f);
    //dpHook.Fill( 0, 0, slSizeI, pixCenterJ, C_vdGREEN|255, C_vdGREEN|255, C_vdGREEN|0, C_vdGREEN|0);
    dpHook.PutTextC( TRANS( "PRESS ESC TO ABORT"), pixCenterI, pixCenterJ+pixBoxSizeJ+5*fScaling, C_WHITE|255);
  }
  */

  dpHook.Unlock();
  // finish rendering
  dpHook.dp_Raster->ra_pvpViewPort->SwapBuffers();

  // keep current time
  tvLast = _pTimer->GetHighPrecisionTimer();
}