コード例 #1
0
ファイル: GUIEditorFont.cs プロジェクト: yangjunhua/ShadowGun
    //
    // Read char description
    //
    bool ReadCharDscr(ref GUIBase_Font.C_FontDscr dscr, StreamReader sr, out bool endOfFile)
    {
        int   charIdx = 0;
        float width   = 0.0f;
        float cx      = 0.0f;
        float cy      = 0.0f;
        float cw      = 0.0f;
        float ch      = 0.0f;

        if (!ReadInt(sr, out charIdx, out endOfFile))
        {
            return(false);
        }

        if (!ReadFloat(sr, out width, out endOfFile))
        {
            return(false);
        }

        if (!ReadFloat(sr, out cx, out endOfFile))
        {
            return(false);
        }

        if (!ReadFloat(sr, out cy, out endOfFile))
        {
            return(false);
        }

        if (!ReadFloat(sr, out cw, out endOfFile))
        {
            return(false);
        }

        if (!ReadFloat(sr, out ch, out endOfFile))
        {
            return(false);
        }

        dscr.AddChar(charIdx, width, cx, cy, cw, ch);

        return(true);
    }
コード例 #2
0
ファイル: GUIEditorFont.cs プロジェクト: yangjunhua/ShadowGun
    bool LoadFontDescription(string fileName, out GUIBase_Font.C_FontDscr fDscr)
    {
        int maxWidth = 0;

        fDscr = new GUIBase_Font.C_FontDscr();

        using (StreamReader sr = File.OpenText(fileName))
        {
            bool endOfFile = false;

            if (!ReadInt(sr, out maxWidth, out endOfFile))
            {
                Debug.Log("Bad font description format " + fileName);
                return(false);
            }

            // Set maximal width of char
            fDscr.SetCharMaxWidth(maxWidth);

            while (!endOfFile)
            {
                if (!ReadCharDscr(ref fDscr, sr, out endOfFile))
                {
                    if (endOfFile)
                    {
                        break;
                    }
                    else
                    {
                        Debug.Log("Bad font description format " + fileName);
                        return(false);
                    }
                }
            }
        }
        return(true);
    }