Пример #1
0
        /// <summary>
        /// 評価値を数字として描画リストに加えます。
        /// </summary>
        private void AddRenderValue(GLUtil.RenderBuffer renderBuffer, Score score)
        {
            var textTexture = GLUtil.TextureCache.GetTextTexture(
                score.Value.ToString(), ValueFont);
            var texture = textTexture.Texture;

            var textTexture2 = GLUtil.TextureCache.GetTextTexture(
                score.Name ?? string.Empty, NameFont);
            var texture2 = textTexture2.Texture;

            if (texture != null && texture.IsAvailable)
            {
                var Margin = 0.02f;

                // 描画領域はテクスチャサイズの割合から決定します。
                // 評価値は画像の下部or上部の
                // 横幅が全体の 3/4 以上になるか、
                // 縦幅が全体の 1/5 以上になるまで
                // 拡大します。拡大は縦横比を保存した状態で行います。

                // フォントの描画サイズを全体の高さからの割合で指定。
                var eh = this.valueHeight;
                var ew = eh * texture.OriginalWidth / texture.OriginalHeight; 

                // 文字幅がエレメントサイズを超えていたら、
                // 文字列サイズの調整を行います。
                if (ew > 0.9f)
                {
                    ew = 0.9f;
                    eh = ew * texture.OriginalHeight / texture.OriginalWidth;
                }

                // 評価値の背景描画
                var bounds = new RectangleF(
                    -0.5f, this.valueTop, 1.0f, this.valueHeight);
                renderBuffer.AddRender(
                    BlendType.Diffuse, Color.FromArgb(128, Color.Black),
                    bounds, Transform, 1.0);

                // 先手後手の描画 (左側のマージンはつけません)
                bounds = new RectangleF(
                    -0.5f, this.valueTop, eh * texture2.OriginalWidth / texture2.OriginalHeight, eh);
                renderBuffer.AddRender(
                    texture2, BlendType.Diffuse,
                    bounds, Transform, 1.0);

                // 評価値の描画
                bounds = new RectangleF(
                    0.5f - Margin - ew, this.valueTop, ew, eh);
                renderBuffer.AddRender(
                    texture, BlendType.Diffuse,
                    bounds, Transform, 1.0);
            }
        }