Esempio n. 1
0
void plGenericType::CopyFrom(const plGenericType& c)
{
    IDeallocString();
    fType = c.fType;
    if (fType==kString || fType==kAny)
    {
        fS=hsStrcpy(c.fS);
    }
    else
    {
        HSMemory::BlockMove((void*)&c.fI, (void*)&fI, 4);
    }
}
Esempio n. 2
0
void plVarDescriptor::CopyFrom(const plVarDescriptor* other)
{
    SetName(other->GetName());
    SetDefault(other->GetDefault());
    SetCount(other->GetCount());
    SetDisplayOptions(other->GetDisplayOptions());

    delete [] fTypeString;
    fTypeString=hsStrcpy(other->GetTypeString());
    
    fType = other->GetType();
    fFlags = other->fFlags;
}
Esempio n. 3
0
void plAutoUIBase::AddFloatSpinner(int16_t id, const char *scriptName, const char *name, int vid, std::vector<std::string>* vstates, float def, float min, float max)
{
    char *scriptNameNew = scriptName ? hsStrcpy(scriptName) : IMakeScriptName(name);

    fDesc->AddParam(id, scriptNameNew, TYPE_FLOAT, 0, 0,
        p_default, def,
        p_range, min, max,
        end,
        end);
    plAutoUIParam* param = new plSpinnerParam(id, name, true);
    param->SetVisInfo(vid, vstates);
    fParams.push_back(param);
}
Esempio n. 4
0
bool ICallStrFunc(PyObject *dict, char *funcName, char*& val)
{
    PyObject *obj;
    if (ICallVoidFunc(dict, funcName, obj))
    {
        if (PyString_Check(obj))
        {
            val = hsStrcpy(PyString_AsString(obj));
            Py_DECREF(obj);
            return true;
        }
    }

    return false;
}
void    plSoundBuffer::SetFileName( const char *name )
{
    if(fLoading)
    {
        hsAssert(false, "Unable to set SoundBuffer filename");
        return;
    }

    delete [] fFileName;
    if( name != nil )
        fFileName = hsStrcpy( name );
    else
        fFileName = nil;

    // Data is no longer valid
    UnLoad();
}
Esempio n. 6
0
plRegistryPageNode::plRegistryPageNode(const char* path)
    : fValid(kPageCorrupt)
    , fPath(nil)
    , fDynLoadedTypes(0)
    , fStaticLoadedTypes(0)
    , fOpenRequests(0)
    , fIsNewPage(false)
{
    fPath = hsStrcpy(path);

    hsStream* stream = OpenStream();
    if (stream)
    {
        fPageInfo.Read(&fStream);
        fValid = IVerify();
        CloseStream();
    }
}
Esempio n. 7
0
bool    pfConsoleContext::SetVar( uint32_t idx, const pfConsoleCmdParam &value )
{
    hsAssert( fVarValues.GetCount() == fVarNames.GetCount(), "Mismatch in console var context arrays" );
    if( idx >= fVarValues.GetCount() )
    {
        hsAssert( false, "SetVar() index out of range for console context" );
        return false;
    }

    if( fVarValues[ idx ].GetType() == pfConsoleCmdParam::kString )
    {
        // Remember, params won't know any better, since by default they don't own a copy of their string
        delete [] ( (char *)fVarValues[ idx ] );
    }

    fVarValues[ idx ] = value;
    if( fVarValues[ idx ].GetType() == pfConsoleCmdParam::kString )
        fVarValues[ idx ].SetString( hsStrcpy( fVarValues[ idx ] ) );

    return true;
}
Esempio n. 8
0
HFONT   plWinFontCache::IMakeFont( const char *face, int height, int weight, bool italic, uint32_t quality )
{
    plFontRecord    myRec;
    int             i;


    // Find a cached name for us
    for( i = 0; i < fFontNameCache.GetCount(); i++ )
    {
        if( strcmp( face, fFontNameCache[ i ] ) == 0 )
            break;
    }

    if( i == fFontNameCache.GetCount() )
        fFontNameCache.Append( hsStrcpy( face ) );

    myRec.fFace = fFontNameCache[ i ];
    myRec.fHeight = height;
    myRec.fWeight = weight;
    myRec.fItalic = italic;
    myRec.fQuality = quality;

    myRec.fFont = CreateFont( height, 0, 0, 0, weight, italic ? TRUE : FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS,
                            CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, VARIABLE_PITCH, face );

    if( myRec.fFont != nil )
    {
//#ifdef HS_DEBUGGING
#if 1
        LOGFONT fontInfo;

        if( GetObject( myRec.fFont, sizeof( fontInfo ), &fontInfo ) )
        {
            const char *err = nil;

            if( fontInfo.lfQuality != quality )         
                err = "Quality of created font does not match";
            if( fontInfo.lfHeight != height )
                err = "Height of created font does not match";
            if( fontInfo.lfWeight != weight )
                err = "Weight of created font does not match";
            if( static_cast<bool>(fontInfo.lfItalic) != italic )
                err = "Italic-ness of created font does not match";
            if( stricmp( fontInfo.lfFaceName, face ) != 0 )
                err = "Face of created font does not match";

            if( err != nil )
            {
                static bool triedClearing = false;

                if( fontInfo.lfQuality != quality )         
                {
                    plStatusLog::AddLineS( "pipeline.log", "ERROR: CreateFont() failed to return proper font (%s). Using what was given...", err );
                }
                else
                {
                    plStatusLog::AddLineS( "pipeline.log", "ERROR: CreateFont() failed to return proper font (%s). %s", err, triedClearing ? "" : "Clearing cache and retrying..." );
                    if( !triedClearing )
                    {
                        triedClearing = true;

                        // Didn't work, so get rid of it
                        DeleteObject( myRec.fFont );

                        // Clear all fonts and try again
                        Clear();
                        
                        // Make sure we reload our custom fonts tho
                        ILoadCustomFonts();
                        
                        // Try again
                        HFONT font = IMakeFont( face, height, weight, italic, quality );
                        
                        triedClearing = false;

                        return font;
                    }
                }
            }
        }
#endif

        fFontCache.Append( myRec );
    }
    else
    {
        plStatusLog::AddLineS( "pipeline.log", "ERROR: CreateFont() call FAILED (face: %s, size: %d %s %s)", face, -height, weight == FW_BOLD ? "bold" : "", italic ? "italic" : "" );
    }

    return myRec.fFont;
}
Esempio n. 9
0
hsFile::hsFile(const char pathAndName[]) : fPathAndName(nil), fFILE(nil)
{
    if (pathAndName)
        fPathAndName = hsStrcpy(pathAndName);
}
plTextureExportLog::plTextureExportLog( const char *fileName )
{
    fFileName = hsStrcpy( fileName );
    fNodeList = nil;
}
void    plDynSurfaceWriter::plWinSurface::SetFont( const char *face, uint16_t size, uint8_t flags, hsBool aaRGB )
{
    delete [] fFontFace;
    fFontFace = ( face != nil ) ? hsStrcpy( face ) : nil;
    fFontSize = size;
    fFontFlags = flags;
    fFontAntiAliasRGB = aaRGB;

    bool hadAFont = false;
    if( fFont != nil )
    {
        hadAFont = true;
        plWinFontCache::GetInstance().FreeFont( fFont );    
        fFont = nil;
    }

    if( face == nil )
        return;

    bool    bold = ( fFontFlags & plDynSurfaceWriter::kFontBold ) ? true : false;
    bool    italic = ( fFontFlags & plDynSurfaceWriter::kFontItalic ) ? true : false;

    int nHeight = -MulDiv( size, GetDeviceCaps( fDC, LOGPIXELSY ), 72 );
    fFont = plWinFontCache::GetInstance().GetMeAFont( face, nHeight, bold ? FW_BOLD : FW_NORMAL, italic, 
                                                        fFontAntiAliasRGB ? ANTIALIASED_QUALITY : DEFAULT_QUALITY );
    if( fFont == nil && fFontAntiAliasRGB )
    {
        static bool warnedCantAntiAlias = false;

        // Creation of font failed; could be that we can't do anti-aliasing? Try not doing it...
        if( !warnedCantAntiAlias )
        {
            plStatusLog::AddLineS( "pipeline.log", "WARNING: Cannot allocate anti-aliased font. Falling back to non-anti-aliased. This will be the only warning" );
            warnedCantAntiAlias = true;
        }

        fFont = plWinFontCache::GetInstance().GetMeAFont( face, nHeight, bold ? FW_BOLD : FW_NORMAL, italic, 
                                                            fFontAntiAliasRGB ? ANTIALIASED_QUALITY : DEFAULT_QUALITY );
    }

    if( fFont == nil )
    {
        hsAssert( false, "Cannot create Windows font for plDynSurfaceWriter" );
        plStatusLog::AddLineS( "pipeline.log", "ERROR: Cannot allocate font for RGB surface! (face: %s, size: %d %s %s)", face, nHeight, bold ? "bold" : "", italic ? "italic" : "" );

        delete [] fFontFace;
        fFontFace = nil;
        fFontSize = 0;
        return;
    }

    if( SelectObject( fDC, fFont ) == nil && hadAFont )
    {
        char msg[ 256 ];
        FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nil, GetLastError(), MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), msg, sizeof( msg ), nil );
        char *ret = strrchr( msg, '\n' );
        if( ret != nil )
            *ret = 0;

        plStatusLog::AddLineS( "pipeline.log", 0xffff0000, "SelectObject() FAILED (%s)", msg );
    }

}
Esempio n. 12
0
void plClothingTileset::SetName(char *name)
{
    delete fName; fName = hsStrcpy(name);
}
Esempio n. 13
0
pfConsoleContext::pfConsoleContext( const char *name )
{
    fName = ( name != nil ) ? hsStrcpy( name ) : nil;
    fAddWhenNotFound = true;
}
Esempio n. 14
0
//
// Set type from a string.  Return false on err.
//
bool plVarDescriptor::SetType(const char* type)
{
    if (!type)
        return false;

    if (!stricmp(type, "vector3"))
        fType=kVector3;
    else
    if (!stricmp(type, "point3"))
        fType=kPoint3;
    else
    if (!stricmp(type, "rgb"))
        fType=kRGB;
    else
    if (!stricmp(type, "rgba"))
        fType=kRGBA;
    else
    if (!stricmp(type, "rgb8"))
        fType=kRGB8;
    else
    if (!stricmp(type, "rgba8"))
        fType=kRGBA8;
    else
    if (!strnicmp(type, "quat",4))
        fType=kQuaternion;
    else
    if (!stricmp(type, "rgba"))
        fType=kRGBA;
    else
    if (!stricmp(type, "int"))
        fType=kInt;
    else
    if (!stricmp(type, "byte"))
        fType=kByte;
    else
    if (!stricmp(type, "short"))
        fType=kShort;
    else
    if (!stricmp(type, "float"))
        fType=kFloat;
    else
    if (!stricmp(type, "double"))
        fType=kDouble;
    else
    if (!stricmp(type, "time"))
        fType=kTime;
    else
    if (!stricmp(type, "ageTimeOfDay"))
        fType=kAgeTimeOfDay;
    else
    if (!stricmp(type, "bool"))
        fType=kBool;
    else
    if (!stricmp(type, "string32"))
        fType=kString32;
    else
    if (!stricmp(type, "plKey"))
        fType=kKey;
    else
    if (!stricmp(type, "message") || !stricmp(type, "creatable") )
        fType=kCreatable;
    else
    if (*type=='$')
        fType=kStateDescriptor;
    else
        return false;   // err
    
    delete [] fTypeString;
    fTypeString = hsStrcpy(type);

    return true;    // ok
}
Esempio n. 15
0
void    pfConsoleCmd::ICreateSignature(const char *paramList )
{
    static char seps[] = " :-";

    char    params[ 256 ];
    char    *ptr, *nextPtr, *tok, *tok2;
    int     i;


    /// Simple check
    if( paramList == nil )
    {
        fSignature.Push( kAny );
        fSigLabels.Push( (char *)nil );
        return;
    }

    /// So we can do stuff to it
    hsAssert( strlen( paramList ) < sizeof( params ), "Make the (#*$& params string larger!" );
    hsStrcpy( params, paramList );

    fSignature.Empty();
    fSigLabels.Empty();

    /// Loop through all the types given in the list
    ptr = params;
    do
    {
        /// Find break
        nextPtr = strchr( ptr, ',' );
        if( nextPtr != nil )
        {
            *nextPtr = 0;
            nextPtr++;
        }

        /// Do this param
        tok = strtok( ptr, seps );
        if( tok == nil && ptr == params )
            break;

        hsAssert( tok != nil, "Bad parameter list for console command!" );
        tok2 = strtok( nil, seps );

        if( tok2 != nil )
        {
            // Type and label: assume label second
            fSigLabels.Push( hsStrcpy( tok2 ) );            
        }
        else
            fSigLabels.Push( (char *)nil );

        // Find type
        for( i = 0; i < kNumTypes; i++ )
        {
            if( strcmp( fSigTypes[ i ], tok ) == 0 )
            {
                fSignature.Push( (uint8_t)i );
                break;
            }
        }

        hsAssert( i < kNumTypes, "Bad parameter type in console command parameter list!" );

    } while( ( ptr = nextPtr ) != nil );
}
Esempio n. 16
0
void plAgeGlobalAnim::SetGlobalVarName(char *name) 
{ 
    delete [] fGlobalVarName; 
    fGlobalVarName = hsStrcpy(name); 
}
Esempio n. 17
0
void plLayerMovie::SetMovieName(const char* n)
{
    delete [] fMovieName;
    fMovieName = hsStrcpy(n);
}
Esempio n. 18
0
 hsBool Open(const char* filename, const char* mode)
 {
     fFilename = hsStrcpy(filename);
     return plZlibStream::Open(filename, mode);
 }
Esempio n. 19
0
void plLayerSDLAnimation::SetVarName(char *name) 
{ 
    delete [] fVarName; 
    fVarName = hsStrcpy(name); 
}