Esempio n. 1
0
pfConsoleCmdGroup::pfConsoleCmdGroup(const char *name, const char *parent )
{
    fNext = nil;
    fPrevPtr = nil;
    fCommands = nil;
    fSubGroups = nil;
    
    if( name == nil )
    {
        /// Create base
        hsStrncpy( fName, "base", sizeof( fName ) );
        fParentGroup = nil;
    }
    else
    {
        pfConsoleCmdGroup   *group = GetBaseGroup();

        if( parent != nil && parent[ 0 ] != 0 )
        {
            group = group->FindSubGroupRecurse( parent );
            hsAssert( group != nil, "Trying to register group under nonexistant group!" );
        }

        hsStrncpy( fName, name, sizeof( fName ) );
        group->AddSubGroup( this );
        fParentGroup = group;
    }

}
Esempio n. 2
0
bool plStatusLog::IAddLine( const char *line, int32_t count, uint32_t color )
{
    int     i;

    if(fLoggingOff && !fForceLog)
        return true;

    /// Scroll pointers up
    fSema->Wait();

    bool ret = true;

    if (fMaxNumLines > 0)
    {
        delete [] fLines[ 0 ];
        for( i = 0; i < fMaxNumLines - 1; i++ )
        {
            fLines[ i ] = fLines[ i + 1 ];
            fColors[ i ] = fColors[ i + 1 ];
        }
    }

    /// Add new
    if( line == nil || strlen( line ) == 0 )
    {
        if (fMaxNumLines > 0)
        {
            fColors[ i ] = 0;
            fLines[ i ] = nil;
        }
        ret = IPrintLineToFile( "", 0 );
    }
    else
    {
        if( count < 0 )
            count = strlen( line );

        if (fMaxNumLines > 0)
        {
            fLines[ i ] = new char[ count + 1 ];
            hsStrncpy( fLines[ i ], line, count + 1 );
            fLines[ i ][ count ] = 0;

            char *c = strchr( fLines[ i ], '\n' );
            if( c != nil )
            {
                *c = 0;
                count--;
            }

            fColors[ i ] = color;
        }

        ret = IPrintLineToFile( line, count );
    }

    fSema->Signal();

    return ret;
}
Esempio n. 3
0
pfConsoleCmd::pfConsoleCmd(const char *group, const char *name,
                            const char *paramList, const char *help, 
                            pfConsoleCmdPtr func, bool localOnly )
{
    fNext = nil;
    fPrevPtr = nil;

    fFunction = func;
    fLocalOnly = localOnly;
    
    hsStrncpy( fName, name, sizeof( fName ) );
    fHelpString = help;

    ICreateSignature( paramList );
    Register( group, name );
}
Esempio n. 4
0
//-----------------------------------------------------------------------------
// Name: SetEnumeErrorStr()
// Desc:
//-----------------------------------------------------------------------------
void hsGDirect3DTnLEnumerate::SetEnumeErrorStr(const char* s)
{
    hsStrncpy(fEnumeErrorStr, s, 128);
}
Esempio n. 5
0
int HSExport2::DoExport(const TCHAR *name,ExpInterface *ei,Interface *gi, BOOL suppressPrompts, DWORD options)
{
    BOOL backupEnabled = gi->AutoBackupEnabled();
    gi->EnableAutoBackup(FALSE);

    BOOL bmmSilentMode = TheManager->SilentMode();
    TheManager->SetSilentMode(TRUE);

    bool mbSuppressPrompts = hsMessageBox_SuppressPrompts;
    hsMessageBox_SuppressPrompts = (suppressPrompts)?true:false;

    // Disable save so we don't crash in export or
    // otherwise screw database.
    SimpleExportExitCallback exitCB;
    gi->RegisterExitMAXCallback(&exitCB);

    gUserPropMgr.OpenQuickTable();
    hsConverterUtils::Instance().CreateNodeSearchCache();

    BroadcastNotification(NOTIFY_PRE_EXPORT);

    // get just the path (not the file) of where we are going to export to
    char out_path[256];
    IGetPath(name, out_path);
    // Apparently this was implied by the open dialog, but not if you call Max's ExportToFile() func
    SetCurrentDirectory(out_path);

    // 
    // Setup ErrorMsg
    //
    // Needs to be outside try/catch so it doesn't stack unwind...
    plExportErrorMsg hituser_errorMessage;  // This is the errorMessage that slaps user

    TSTR filename = gi->GetCurFileName();
    hsStrncpy(fName, filename, 128);
    char *dot = strrchr(fName, '.');
    if (dot)
        *dot = 0;
    char ErrorLogName[512];
    sprintf(ErrorLogName, "%s%s.err", out_path, fName);
    plExportLogErrorMsg logonly_errorMessage(ErrorLogName);     // This errorMessage just writes it all to a file

    // now decide which errorMessage object to use
    plErrorMsg* errorMessage;
    if (suppressPrompts)
        errorMessage = &logonly_errorMessage;
    else
        errorMessage = &hituser_errorMessage;

    // For export time stats
    DWORD exportTime = timeGetTime();
    _SYSTEMTIME tm;
    GetSystemTime(&tm);

    //
    // Let's get cracking!  Convert the scene...
    //
    plConvertSettings settings;
    
    if (plExportDlg::Instance().IsExporting())
    {
        settings.fDoPreshade = plExportDlg::Instance().GetDoPreshade();
        settings.fPhysicalsOnly = plExportDlg::Instance().GetPhysicalsOnly();
        settings.fDoLightMap = plExportDlg::Instance().GetDoLightMap();
        settings.fExportPage = plExportDlg::Instance().GetExportPage();
    }

    plConvert::Instance().Init(gi, errorMessage, &settings);

    // We want to incorporate any SDL changes since the last export, so we DeInit()
    // and re-initialize.
    char buf[MAX_PATH];
    strcpy(buf, plMaxConfig::GetClientPath());
    strcat(buf, "sdl");
    plSDLMgr::GetInstance()->SetSDLDir(buf);
    plSDLMgr::GetInstance()->DeInit();
    plSDLMgr::GetInstance()->Init();

    // Add disk source for writing
    char datPath[MAX_PATH];
    strcpy(datPath, out_path);
    plFileUtils::AddSlash(datPath);
    strcat(datPath, "dat\\");
    CreateDirectory(datPath, NULL);
    plPluginResManager::ResMgr()->SetDataPath(datPath);

    if (hsgResMgr::Reset())
    {
        plSimulationMgr::Init();
        plAvatarMgr::GetInstance();

        // Verify the pages here manually, since it's a separate step now
        plPluginResManager::ResMgr()->VerifyPages();

        plPythonFileMod::SetAtConvertTime();

        // Convert!!!
        bool convertOK = plConvert::Instance().Convert();

        // Free the material cache.  This will delete unused materials.
        hsMaterialConverter::Instance().FreeMaterialCache(out_path);

        if (convertOK)
        {
            // Optimize the drawables
            plOptimizeIterator  optIterator;
            plPluginResManager::ResMgr()->IterateKeys( &optIterator );

            // And save.
            plPluginResManager::ResMgr()->WriteAllPages();

            // Write out a texture log file
            char textureLog[MAX_PATH];
            sprintf(textureLog, "log\\exportedTextures_%s.log", fName);
            plTextureExportLog      textureExportLog( textureLog );
            plTextureLoggerCBack    loggerCallback( &textureExportLog );
            
            plPluginResManager::ResMgr()->IterateKeys( &loggerCallback );
            
            textureExportLog.Write();

            // Moving this to the end of writing the files out. Yes, this means that any unused mipmaps still get
            // written to disk, including ones loaded on preload, but it's the only way to get shared texture pages
            // to work without loading in the entire age worth of reffing objects. - 5.30.2002 mcn
            plBitmapCreator::Instance().DeInit();
        }

        // Have the resMgr clean up after export. This includes paging out any converted pages
        plPluginResManager::ResMgr()->EndExport();

        plSimulationMgr::Shutdown();
        plAvatarMgr::ShutDown();

        // Reset the resmgr so we free all the memory it allocated
        hsgResMgr::Reset();
    }


    //----------------------------------------------
    // Write a log entry to the Db file name for now
    //----------------------------------------------
    hsUNIXStream dbLog;
    dbLog.Open(name,"at");
    char str[256];
    exportTime = (timeGetTime() - exportTime) / 1000;
    sprintf(str,"Export from Max File \"%s\" on %02d/%02d/%4d took %d:%02d\n",filename,tm.wMonth,tm.wDay,tm.wYear, exportTime/60, exportTime%60);
    dbLog.WriteString(str);
    dbLog.Close();

    // Allow plugins to clean up after export
    BroadcastNotification(NOTIFY_POST_EXPORT);

    hsConverterUtils::Instance().DestroyNodeSearchCache();
    gUserPropMgr.CloseQuickTable();
    gi->UnRegisterExitMAXCallback(&exitCB);
    hsMessageBox_SuppressPrompts = mbSuppressPrompts;
    TheManager->SetSilentMode(bmmSilentMode);
    gi->EnableAutoBackup(backupEnabled);

    MessageBeep(MB_ICONASTERISK);

    return 1;
}