Beispiel #1
0
Datei: vsh.cpp Projekt: garinh/cs
static void cmd_create (char *args)
{
  csRef<iFile> F (VFS->Open (args, VFS_FILE_WRITE));
  if (!F)
  {
    csPrintfErr ("create: cannot create or open for writing file \"%s\"\n",
      args);
    return;
  }

  csPrintf ("Copying from stdin to file \"%s\", enter EOF to finish\n", args);
  for (;;)
  {
    char buff [160];
    if (!fgets (buff, sizeof (buff), stdin))
      break;
    size_t len = F->Write (buff, strlen (buff));
    if (len < strlen (buff))
    {
      csPrintfErr ("create: error writing to file \"%s\"\n", args);
      break;
    }
  }
  csPrintf ("done, closing file\n");
}
Beispiel #2
0
  THREADED_CALLABLE_IMPL4(TUI, Report, iReporter* reporter, int severity,
    const char* msgId, const char* description)
  {
    csStringArray descrSplit;
    descrSplit.SplitString (description, "\n");

    for (size_t i = descrSplit.GetSize(); i-- > 0;)
    {
      csString& buf = messageBuffer[messageBufferEnd];
      buf.Clear ();

      buf.Append (TUI_SEVERITY_TEXT[severity]);
      csString tmp(descrSplit[i]);
      buf.Append (tmp.Slice (0,74).PadRight (74));

      if (simpleMode)
      {
        if (!prevWasReporter)
          csPrintf ("\n");
        csPrintf ("%s\n", buf.GetDataSafe ());
        prevWasReporter = true;
      }

      messageBufferEnd++;
      if(messageBufferEnd > 3) messageBufferEnd = 0;
    }

    // Print them
    Redraw (TUI::TUI_DRAW_MESSAGES);

    // Also hand it off to the standard listener
    return false;
  }
int main(int argc, char** argv)
{
    iObjectRegistry* object_reg = csInitializer::CreateEnvironment(argc, argv);
    if(!object_reg)
    {
        csPrintf("Object Reg failed to Init!\n");
        return -1;
    }

    if(!csInitializer::SetupConfigManager(object_reg, CONFIGFILE))
    {
        csPrintf("Failed to read config file!\n");
        return -2;
    }

    csInitializer::RequestPlugins (object_reg, CS_REQUEST_VFS,
	CS_REQUEST_PLUGIN("crystalspace.documentsystem.multiplexer", iDocumentSystem),
	CS_REQUEST_END);

    NavGen* navgen = new NavGen(object_reg);
    if(!csInitializer::OpenApplication(object_reg))
    {
        csPrintf("csInitializer::OpenApplication failed!\n"
                 "Is your CRYSTAL environment var set?");
        return -2;
    }
    navgen->Run();

    delete navgen;
    CS_STATIC_VARIABLE_CLEANUP
    csInitializer::DestroyApplication(object_reg);

    return 0;
}
Beispiel #4
0
  void TUI::DrawSimple ()
  {
    bool doFlush = false;
    const char* lt = (const char*)lastTask;
    const char* tn = globalStats.progress.GetTaskName ();
    if ((lt == 0 && tn != 0) || (lt != 0 && lastTask != tn))
    {
      lastTask = globalStats.progress.GetTaskName();

      prevWasReporter = false;
      csPrintf ("\n% 4d %% - %s ", 
        globalStats.progress.GetOverallProgress(),
        lastTask.GetDataSafe());
      doFlush = true;

      // Print new task and global progress
      lastTaskProgress = 0;
    }
    else
    {
      while (lastTaskProgress + 10 < globalStats.progress.GetTaskProgress())
      {
        prevWasReporter = false;
        csPrintf (".");
        lastTaskProgress += 10;
        doFlush = true;
      }
    }
    if (doFlush) fflush (stdout);
  }
Beispiel #5
0
Datei: vsh.cpp Projekt: garinh/cs
static void cmd_ls (char *args)
{
  bool fullpath;
  get_option (args, fullpath);

  const char *dir;
  csRef<iDataBuffer> xpath;
  if (args)
  {
    xpath = VFS->ExpandPath (args);
    dir = **xpath;
  }
  else
    dir = VFS->GetCwd ();

  csRef<iStringArray> fl (VFS->FindFiles (dir));
  if (fl->GetSize () > 0)
  {
    bool nl = false;
	
    size_t i;
    for (i = 0; i < fl->GetSize () ; i++)
    {
      const char *fname = fl->Get (i);
      if (fullpath)
      {
        csFileTime ft;
        if (!VFS->GetFileTime (fname, ft))
          memset (&ft, 0, sizeof (ft));
        size_t fs;
        if (!VFS->GetFileSize (fname, fs))
          fs = 0;
        csPrintf ("[%02d:%02d:%02d %02d-%02d-%04d]%9zu %s\n",
	  ft.hour, ft.min, ft.sec,
          ft.day, ft.mon + 1, ft.year, fs, fname);
      }
      else
      {
        size_t dirlen = strlen (fname);
        if (dirlen)
          dirlen--;
        while (dirlen && fname [dirlen - 1] != VFS_PATH_SEPARATOR)
          dirlen--;
        csPrintf ("%-19s", fname + dirlen);
        nl = true;
        if ((i & 3) == 3)
        {
          csPrintf ("\n");
          nl = false;
        }
      }
    }
    if (nl)
      csPrintf ("\n");
  }
  else
    csPrintf ("ls: no files to display\n");
}
Beispiel #6
0
void csGraphics2D::AlertV (int type, const char* title, const char* okMsg,
    const char* msg, va_list arg)
{
  (void)type; (void)title; (void)okMsg;
  csPrintf ("ALERT: ");
  csPrintfV (msg, arg);
  csPrintf ("\n");
  fflush (stdout);
}
Beispiel #7
0
void mcMapParser::ReportError(const char* message, ...)
{
  csPrintf("Error in line %d: ", m_current_line);
  va_list args;
  va_start (args, message);
  csPrintfV (message, args);
  va_end (args);
  csPrintf("\n");
}
Beispiel #8
0
    void BodyChainNode::Print (size_t level) const
    {
        for (size_t i = 0; i < level; i++)
            csPrintf (" ");
        csPrintf ("+ node %zu\n", boneID);

        for (csRefArray<BodyChainNode>::ConstIterator it = children.GetIterator (); it.HasNext (); )
            it.Next ()->Print (level + 1);
    }
Beispiel #9
0
    void BodyChain::Print (BodyChainNode* node, size_t level) const
    {
        for (size_t i = 0; i < level; i++)
            csPrintf (" ");
        csPrintf ("+ node %zu: %s\n", node->boneID, bodySkeleton->skeletonFactory->GetBoneName (node->boneID));

        for (csRefArray<BodyChainNode>::Iterator it = node->children.GetIterator (); it.HasNext (); )
        {
            BodyChainNode*& node = it.Next ();
            Print (node, level + 1);
        }
    }
Beispiel #10
0
  void TUI::DrawSimpleEnd ()
  {
    // Print KD-tree stats
    csPrintf ("\nKD-tree: \n");
    csPrintf ("N: %8zu / %8zu\n", globalStats.kdtree.numNodes, globalStats.kdtree.leafNodes);
    csPrintf ("D: %8zu / %8.03f\n", globalStats.kdtree.maxDepth, 
      (float)globalStats.kdtree.sumDepth / (float)globalStats.kdtree.leafNodes);
    csPrintf ("P: %8zu / %8.03f\n", globalStats.kdtree.numPrimitives, 
      (float)globalStats.kdtree.numPrimitives / (float)globalStats.kdtree.leafNodes);

    kdLastNumNodes = globalStats.kdtree.numNodes;
  }
Beispiel #11
0
static BOOL GetFileName ( CString & strFileName )
{

	CString sTmp (strFileName);
	_fullpath (strFileName.GetBuffer (258), sTmp, 256);
	strFileName.ReleaseBuffer (-1);

	// get the drive name
	CString sDrive (strFileName);
	int iInd = sDrive.Find ('\\');
	if (iInd >= 0)
		sDrive.ReleaseBuffer ( iInd + 1 );

	// if it's a CD we prompt them to insert the CD
	if (GetDriveType (sDrive) == DRIVE_CDROM)
		{
		CDlgSelCD dlg;
		dlg.m_sFileName = strFileName;
		dlg.m_strMsg.LoadString (IDS_INSERT_CD);
		char sBuf[2];
		sBuf[0] = toupper (strFileName[0]);
		sBuf[1] = 0;
		csPrintf (&dlg.m_strMsg, (char const *) sBuf);
		if (dlg.DoModal () != IDOK)
			{
			TRAP ();
			return (FALSE);
			}

		strFileName = dlg.m_sFileName;
		}
	else

		// not a CD - prompt for the location
		{
		CString sMsg;
		sMsg.LoadString (IDS_BAD_DATA_FILE);
		csPrintf (&sMsg, (char const *) strFileName);
		if (AfxMessageBox (sMsg, MB_YESNO | MB_ICONSTOP) != IDYES)
			return (FALSE);

		CString sFilters;
		sFilters.LoadString (IDS_DATA_FILTERS);
		CFileDialog dlg (TRUE, "dat", strFileName, OFN_FILEMUSTEXIST, sFilters, NULL);	
		if (dlg.DoModal () != IDOK)
			return (FALSE);
		strFileName = dlg.GetPathName ();
		}

	return (TRUE);
}
Beispiel #12
0
void Usage() {
  csPrintf("MD3 to CS XML converter\n");
  csPrintf("by Manjunath Sripadarao\n");
  csPrintf("Usage: md32spr [options] <model-file.zip> [-o=<output-file.zip>]\n");
  csPrintf("Options:\n");
  csPrintf("-wdir=<dir>\tDirectory in which the weapon files are stored.\n");
  csPrintf("\t\texample: -wdir=railgun\n");
  csPrintf("-o=<file.zip>\tOutput zip file name. \n");
  csPrintf("-scale=<float>\tHow much the model should be scaled. Default is 1.\n");
  csPrintf("\t\texample: -scale=4096. Model will be scaled as 1/4096.\n");
}
Beispiel #13
0
bool Shagnetron::PrecacheShaderFile (const char* file, bool doQuick)
{
  if (doVerbose)
    csPrintf ("%s ... ", file);

  csRef<iFile> fileObj = vfs->Open (file, VFS_FILE_READ);
  if (!fileObj.IsValid())
  {
    if (doVerbose) csPrintf ("can't open\n");
    return false;
  }

  csRef<iDocument> doc (docsys->CreateDocument());
  const char* err = doc->Parse (fileObj);
  if (err != 0)
  {
    if (doVerbose) csPrintf ("parse error: %s\n", err);
    return false;
  }
  
  csRef<iDocumentNode> shaderNode = doc->GetRoot()->GetNode ("shader");
  if (!shaderNode.IsValid())
  {
    if (doVerbose) csPrintf ("not a shader\n");
    return false;
  }
  
  if (!doVerbose)
    csPrintf ("%s ... ", file);
  fflush (stdout);
    
  const char* type = shaderNode->GetAttributeValue ("compiler");
  if (type == 0)
    type = shaderNode->GetAttributeValue ("type");
  if (type == 0)
  {
    csPrintf ("'compiler' attribute is missing!\n");
    return false;
  }
  csRef<iShaderCompiler> shcom = shaderMgr->GetCompiler (type);
  if (!shcom.IsValid()) 
  {
    csPrintf ("Could not get shader compiler '%s'", type);
    return false;
  }

  bool result;
  {
    csVfsDirectoryChanger dirChanger (vfs);
    dirChanger.ChangeTo (file);
    
    result = shcom->PrecacheShader (shaderNode,
      shaderMgr->GetShaderCache(), doQuick);
  }

  csPrintf ("%s\n", result ? "ok" : "failed");

  return result;
}
Beispiel #14
0
  void TUI::DrawSwapCacheStats () const
  {
    csPrintf (CS_ANSI_CURSOR(45,19) 
      "                                 ");
    if (globalLighter->swapManager)
    {
      uint64 swappedIn, swappedOut, maxSize;
      globalLighter->swapManager->GetSizes (swappedIn, swappedOut, maxSize);
      csPrintf (CS_ANSI_CURSOR(47,19) "%s/%s in, %s out",
	                FormatByteSize (swappedIn).GetData(),
	                FormatByteSize (maxSize).GetData(),
	                FormatByteSize (swappedOut).GetData());
    }
    csPrintf (CS_ANSI_CURSOR(1,1));
  }
Beispiel #15
0
void BaseMapGen::OnCommandLineHelp()
{
  csPrintf ("\n");
  csPrintf ("Usage: basemapgen <path> <world> [OPTIONS]\n");
  csPrintf (" Example: basemapgen /this/data/terrain world\n");
  csPrintf ("\n");
  csPrintf ("<path>                    The path to the worldfile           (default /this)\n");
  csPrintf ("<world>                   Name of the world file              (default 'world')\n");
  csPrintf ("-terrainname=<regexp>     Regexp for the terrain mesh objects (default '.*')\n");
  csPrintf ("-terraformername=<regexp> Regexp for the terraformer          (default '.*')\n");
  csPrintf ("-resolution=<pixels>      The resolution for the basemap      (default basemap resolution)\n");
}
Beispiel #16
0
/// report something
void Report (iObjectRegistry *object_reg, int severity, const char* msg, ...)
{
  va_list arg;
  va_start (arg, msg);
  csRef<iReporter> rep = csQueryRegistry<iReporter> (object_reg);
  if (rep)
    rep->ReportV (severity, "crystalspace.graphic.image.io.jng", 
      msg, arg);
  else
  {
    csPrintf ("crystalspace.graphic.image.io.jng: ");
    csPrintfV (msg, arg);
    csPrintf ("\n");
  }
  va_end (arg);
}
Beispiel #17
0
Datei: vsh.cpp Projekt: garinh/cs
static void cmd_help (char *)
{
  csPrintf (
"----========************* Virtual Shell commands: *************========----\n"
"cat {-} file           Display file contents to console; with '-' in one pass\n"
"cd {path}              Change directory to path; or to root if path not given\n"
"config {-} file        Parse a VFS config file; with '-' file is on real FS\n"
"cp {-} src dst         Copy file src to file dst; with '-' in one pass\n"
"create file            Create a file and copy from stdin to file until EOF\n"
"exists file            Test if file exists on VFS\n"
"exit                   Exit Virtual Shell\n"
"ls {-} {path}          List files; with '-' shows full pathname\n"
"mount vpath rpath      Add a virtual path mapped to given real path\n"
"mounts                 Display all virtual mounts\n"
"pwd                    Print working directory\n"
"rm file                Delete file on VFS\n"
"rmounts vpath          Display real paths mounted at virtual path\n"
"rpath file             Convert the virtual path into real path\n"
"save                   Save current virtual file system state to " VFS_CONFIG_FILE "\n"
"sync                   Synchronize virtual file system (flush pending writes)\n"
"time file              Display file's modification time\n"
"unmount vpath {rpath}  Remove a virtual path; completely if no rpath is given\n"
"------------------------\n"
"The following aliases are also recognized:\n"
"chdir --> cd        copy --> cp         del  --> rm\n"
"dir   --> ls        quit --> exit       type --> cat\n"
"------------------------\n"
"Wildcards are okay in these commands: ls, cp, rm\n"
  );
}
Beispiel #18
0
void Win32Assistant::DisableConsole ()
{
  if (!console_window) return;
  console_window = false;

  DWORD lasterr;
  csString outName;
  {
    char apppath[MAX_PATH];
    GetModuleFileName (0, apppath, sizeof(apppath));
    lasterr = GetLastError ();
    if (lasterr != ERROR_INSUFFICIENT_BUFFER)
      outName = apppath;
  }
  if (lasterr == ERROR_INSUFFICIENT_BUFFER)
  {
    DWORD bufSize = 2*MAX_PATH;
    char* buf = 0;
    while (lasterr == ERROR_INSUFFICIENT_BUFFER)
    {
      buf = (char*)cs_realloc (buf, bufSize);
      GetModuleFileName (0, buf, bufSize);
      bufSize += MAX_PATH;
      lasterr = GetLastError ();
    }
    outName = buf;
    cs_free (buf);
  }

  {
    size_t basePos = outName.FindLast ('\\');
    if (basePos != (size_t)-1) outName.DeleteAt (0, basePos+1);
  }
  {
    size_t dot = outName.FindLast ('.');
    if (dot != (size_t)-1)
      outName.Overwrite (dot, ".txt");
    else
      outName.Append (".txt");
  }
  {
    char tmp[MAX_PATH];
    if (GetTempPath (sizeof (tmp), tmp) != 0)
      outName.Insert (0, tmp);
  }

  /* Redirect only those handles that were not initially redirected by
   * the user */
  if (!IsStdHandleRedirected (STD_ERROR_HANDLE)) 
    freopen (outName, "w", stderr);
  if (!IsStdHandleRedirected (STD_OUTPUT_HANDLE)) 
    freopen (outName, "w", stdout);
  FreeConsole();

  struct tm *now;
  time_t aclock;
  time( &aclock );
  now = localtime( &aclock );
  csPrintf("====== %s", asctime(now));
}
Beispiel #19
0
void Win32Assistant::Shutdown()
{
  csRef<iEventQueue> q (csQueryRegistry<iEventQueue> (registry));
  if (q != 0)
    q->RemoveListener(this);
  if (!is_console_app && (cmdline_help_wanted || console_window))
  {
    HANDLE hConsole = CreateFile ("CONIN$", GENERIC_READ, FILE_SHARE_READ, 0, 
      OPEN_EXISTING, 0, 0);
    if (hConsole != 0)
    {
      INPUT_RECORD ir;
      DWORD events_read;
      /* Empty console events, to remove earlier key presses */
      while (PeekConsoleInput (hConsole, &ir, 1, &events_read)
	&& (events_read != 0))
      {
	ReadConsoleInput (hConsole, &ir, 1, &events_read);
      }
      
      csPrintf ("\nPress a key to close this window...");
      fflush (stdout);
      /* Wait for keyboard event */
      do 
      {
	ReadConsoleInput (hConsole, &ir, 1, &events_read);
      } while ((events_read == 0) || (ir.EventType != KEY_EVENT));
      CloseHandle (hConsole);
    }
  }
}
void HeightMapGen::CreateHeightmap (int heightmap_res, iCollideSystem* cdsys, 
                                     iSector* sector, csRGBpixel* hmap_dst, 
                                     float* height_dst, 
                                     const csBox3& box)
{
  csPrintf ("Creating heightmap...\n"); fflush (stdout);

  float dx = (box.MaxX () - box.MinX () - 0.2) / float (heightmap_res-1);
  float dz = (box.MaxZ () - box.MinZ () - 0.2) / float (heightmap_res-1);
  for (int z = 0 ; z < heightmap_res ; z++)
  {
    for (int x = 0 ; x < heightmap_res ; x++)
    {
      csVector3 start, end;
      start.x = box.MinX () + (float)x * dx + 0.1;
      start.y = box.MaxY () + 10.0;
      start.z = box.MinZ () + (heightmap_res-z-1) * dz + 0.1;
      end = start;
      end.y = box.MinY () - 10.0;
      csVector3 isect;
      //mesh->HitBeamObject (start, end, isect, 0, 0);
      csIntersectingTriangle closest_tri;
      csColliderHelper::TraceBeam (cdsys, sector, start, end,
      	false, closest_tri, isect);
      float y = (isect.y - box.MinY ()) / (box.MaxY () - box.MinY ());
      if (y < 0) y = 0;
      else if (y > 0.9999f) y = 0.9999f;
      *height_dst++ = y;
      y *= 256.0;
      hmap_dst->Set (int (y), int (y), int (y));
      hmap_dst++;
    }
  }
}
Beispiel #21
0
Datei: vsh.cpp Projekt: garinh/cs
static void cmd_time (char *args)
{
  if (!args)
  {
    csPrintfErr ("time: expected filename\n");
    return;
  }

  csFileTime flmt;
  if (!VFS->GetFileTime (args, flmt))
  {
    csPrintfErr ("time: can not query file time (no such file maybe)\n");
    return;
  }

  struct tm time;
  memset (&time, 0, sizeof (time));
  time.tm_sec = flmt.sec;
  time.tm_min = flmt.min;
  time.tm_hour = flmt.hour;
  time.tm_mday = flmt.day;
  time.tm_mon = flmt.mon;
  time.tm_year = flmt.year - 1900;

  // No newline needed; asctime() adds it for us.
  csPrintf ("Last file modification time: %s", asctime (&time));
}
Beispiel #22
0
void csReporter::ActualReport (const csRefArray<iReporterListener>& listeners,
                               int severity, const char* msgId, 
                               const char* buf)
{
  bool add_msg = true;
  size_t i;
  for (i = 0 ; i < listeners.GetSize () ; i++)
  {
    iReporterListener* listener = listeners[i];
    if (listener->Report (this, severity, msgId, buf))
    {
      add_msg = false;
      break;
    }
  }

  if (add_msg)
  {
    csReporterMessage* msg = new csReporterMessage ();
    msg->severity = severity;
    msg->id = csStrNew (msgId);
    msg->description = csStrNew (buf);
    CS::Threading::RecursiveMutexScopedLock lock (mutex);
    messages.Push (msg);
    if (listeners.GetSize () == 0 && (severity == CS_REPORTER_SEVERITY_ERROR
    	|| severity == CS_REPORTER_SEVERITY_BUG))
    {
      csPrintf ("%s\n", buf);
    }
  }
}
void HeightMapGen::CreateBasemap (int heightmap_res, csRGBpixel* basemap_dst, 
                                   uint8* matmap_dst, const float* height_dst,
                                   const csArray<TextureLayer>& txt_layers)
{
  csPrintf ("Creating base texturemap...\n"); fflush (stdout);
  for (int z = 0 ; z < heightmap_res ; z++)
  {
    csRGBpixel* bm_dst = basemap_dst + (heightmap_res-z-1) * heightmap_res;
    uint8* mm_dst = matmap_dst + (heightmap_res-z-1) * heightmap_res;
    for (int x = 0 ; x < heightmap_res ; x++)
    {
      float y = *height_dst++;
      (void)y;

      int layer;
      //for (layer = 0 ; layer < num_texture_layers ; layer++)
      //{
        //if (y >= txt_layers[layer].min_height
		//&& y <= txt_layers[layer].max_height)
	  //break;
      //}
      //*mm_dst++ = layer;
      layer = *mm_dst++;
      bm_dst->Set (
      	int (txt_layers[layer].average.red * 255.0),
      	int (txt_layers[layer].average.green * 255.0),
      	int (txt_layers[layer].average.blue * 255.0)
      	);
      bm_dst++;
    }
  }
}
Beispiel #24
0
bool Win32Assistant::HandleEvent (iEvent& e)
{
  if (e.Name == Frame)
  {
    if(use_own_message_loop)
    {
      MSG msg;
      /*
        [res] *W versions of the message queue functions exist,
        but they don't seem to make a difference.
      */
      while (PeekMessage (&msg, 0, 0, 0, PM_NOREMOVE))
      {
        if (!GetMessage (&msg, 0, 0, 0))
        {
          iEventOutlet* outlet = GetEventOutlet();
          outlet->Broadcast (Quit);
          return true;
        }
        TranslateMessage (&msg);
        DispatchMessage (&msg);
      }
    }
    return true;
  }
  else if (e.Name == SystemOpen)
  {
    return true;
  }
  else if (e.Name == SystemClose)
  {
  } 
  else if (e.Name == CommandLineHelp)
  {

   #ifdef CS_DEBUG 
    const char *defcon = "yes";
   #else
    const char *defcon = "no";
   #endif

    csPrintf ("Win32-specific options:\n");
    csPrintf ("  -[no]console       Create a debug console (default = %s)\n",     
      defcon);
  }
  return false;
}
Beispiel #25
0
bool BaseMapGen::LoadMap ()
{
  csRef<iVFS> vfs = csQueryRegistry<iVFS> (object_reg);
  csRef<iConfigManager> cfgmgr = csQueryRegistry<iConfigManager> (object_reg);

  csRef<iConfigFile> cfgfile = cfgmgr->GetDynamicDomain ();
  csPrintf ("Loading custom VFS mounts from:\n%s\n", cfgfile->GetFileName ());
  vfs->LoadMountsFromFile(cfgfile);
  
  csString path = cmdline->GetName(0);
  csString world = cmdline->GetName(1);

  if (path.IsEmpty()) path = "/this";
  if (world.IsEmpty()) world = "world";

  csStringArray paths;
  paths.Push ("/lev/");
  if (!vfs->ChDirAuto(path.GetData(), &paths, 0, "world"))
  {
    Report("Error setting directory '%s'!", path.GetData ());
    return false;
  }

  csRef<iFile> buf = vfs->Open(world.GetData(), VFS_FILE_READ);
  if (!buf)
  {
    Report("Failed to open file '%s'!", world.GetData());
    return false;
  }

  csRef<iDocument> doc;
  csRef<iDocumentSystem> docsys;

  if (!docsys) docsys = csPtr<iDocumentSystem> (new csTinyDocumentSystem ());
  doc = docsys->CreateDocument ();
  const char* error = doc->Parse (buf, true);
  if (error != 0)
  {
    Report("Failed to parse file '%s': %s", world.GetData(),
      error);
    return false;
  }

  if (doc)
  {
    rootnode = doc->GetRoot()->GetNode("world");
    if (!rootnode)
      return false;
  }
  
  ScanPluginNodes ();
  
  ScanTextures();
  ScanMaterials();
  
  return true;
}
//-----------------------------------------------------------------------------
// csPlatformStartup
//	Platform-specific startup.
//-----------------------------------------------------------------------------
bool csPlatformStartup(iObjectRegistry* r)
{
  csPrintf("Crystal Space for " CS_PLATFORM_NAME " " CS_VERSION "\nPorted to "
    CS_PLATFORM_NAME " by Eric Sunshine <*****@*****.**>\n\n");
  csRef<iOSXAssistant> a = csPtr<iOSXAssistant>(new OSXAssistant (r));
  r->Register(a, "iOSXAssistant");

  return true;
}
Beispiel #27
0
void BaseMapGen::DrawProgress (int percent)
{
  const uint progTotal = 65;
  uint numDone = (progTotal*percent) / 100;

  csPrintf (CS_ANSI_CURSOR_BWD(72) CS_ANSI_CLEAR_LINE "[");

  uint x;
  for (x = 0 ; x < numDone ; x++)
    csPrintf ("=");

  for (; x < progTotal; x++)
    csPrintf (" ");

  csPrintf("] %d%%", percent);

  fflush (stdout);

}
Beispiel #28
0
csRef<iImage> BaseMapGen::LoadImage (const csString& filename, int format)
{
  csPrintf ("Trying to load '%s'... \t", filename.GetData());
  fflush (stdout);
  csRef<iImage> image;
  csRef<iImageIO> imageio = csQueryRegistry<iImageIO> (object_reg);
  csRef<iVFS> VFS = csQueryRegistry<iVFS> (object_reg);

  csRef<iDataBuffer> buf = VFS->ReadFile (filename.GetData(), false);
  if (!buf)
  {
    Report ("Failed to load image file '%s'!", filename.GetData());
    return GenerateErrorTexture (32, 32);
  }
  image = imageio->Load (buf, format);
  image.IsValid() ? csPrintf ("success.\n") : csPrintf ("failed.\n");

  return image;
}
Beispiel #29
0
  void TUI::DrawMessage () const
  {
    csPrintf (CS_ANSI_CURSOR(3, 21));

    // Draw the four buffers, starting with messageBufferEnd
    int row = messageBufferEnd-1;
    if(row <  0) row = 3;

    for(uint i = 0; i < 4; i++)
    {
      csPrintf ("%s", messageBuffer[row].GetDataSafe ());
      
      row--;
      if(row < 0) row = 3;
      csPrintf (CS_ANSI_CURSOR_DOWN(1));
      csPrintf (CS_ANSI_CURSOR_BWD(100) CS_ANSI_CURSOR_FWD(2));
    }
    csPrintf (CS_ANSI_CURSOR(1,1));
  }
Beispiel #30
0
Datei: vsh.cpp Projekt: garinh/cs
static void cmd_rmounts (char *args)
{
  if (!args)
  {
    csPrintfErr ("rmounts: expected virtual mount path\n");
    return;
  }

  csRef<iStringArray> rpaths = VFS->GetRealMountPaths (args);
  if (rpaths->GetSize ())
  {
    for (size_t i=0; i<rpaths->GetSize () ; i++)
    {
      csPrintf ("%s\n", rpaths->Get (i));
    }
  }
  else
    csPrintf ("rmounts: no virtual mount at path `%s'\n", args);
}