コード例 #1
0
        private float measureSpace()
        {
            //hack to measure the size of spaces. For some reason MeasureString returns bad results when string ends with a space.
            IFont font = _fonts.LoadFont(_config.Font.FontFamily, _config.Font.SizeInPoints * _scaleUp.X, _config.Font.Style);

            return(font.MeasureString(" a").Width - font.MeasureString("a").Width);
        }
コード例 #2
0
        private async Task LoadFontFace(FontId font)
        {
            var fontFace = await loader.LoadFont(font);

            fontMap[font.Id] = new FontFace {
                Font = fontFace, IsLoaded = true
            };
        }
コード例 #3
0
 public IFont Resize(float sizeInPoints)
 {
     return(_fontLoader.LoadFont(FontFamily, sizeInPoints, Style));
 }
コード例 #4
0
ファイル: AGSDialogFactory.cs プロジェクト: saizant/MonoAGS
        public IDialogOption GetDialogOption(string text, ITextConfig config = null, ITextConfig hoverConfig = null,
                                             ITextConfig hasBeenChosenConfig = null, bool speakOption        = true, bool showOnce = false)
        {
            var game = _resolver.Container.Resolve <IGame>();

            if (config == null)
            {
                config = new AGSTextConfig(autoFit: AutoFit.TextShouldWrapAndLabelShouldFitHeight,
                                           brush: _brushLoader.LoadSolidBrush(Colors.White), font: _fontLoader.LoadFont(null, 10f));
            }
            if (hoverConfig == null)
            {
                hoverConfig = new AGSTextConfig(autoFit: AutoFit.TextShouldWrapAndLabelShouldFitHeight,
                                                brush: _brushLoader.LoadSolidBrush(Colors.Yellow), font: _fontLoader.LoadFont(null, 10f));
            }
            if (hasBeenChosenConfig == null)
            {
                hasBeenChosenConfig = new AGSTextConfig(autoFit: AutoFit.TextShouldWrapAndLabelShouldFitHeight,
                                                        brush: _brushLoader.LoadSolidBrush(Colors.Gray), font: _fontLoader.LoadFont(null, 10f));
            }
            ILabel label = _ui.GetLabel($"Dialog option: {text}", text, game.Settings.VirtualResolution.Width, 20f, 0f, 0f,
                                        config: config, addToUi: false);

            label.Enabled = true;
            TypedParameter labelParam         = new TypedParameter(typeof(ILabel), label);
            NamedParameter speakParam         = new NamedParameter("speakOption", speakOption);
            NamedParameter showOnceParam      = new NamedParameter("showOnce", showOnce);
            NamedParameter hoverParam         = new NamedParameter("hoverConfig", hoverConfig);
            NamedParameter wasChosenParam     = new NamedParameter("hasBeenChosenConfig", hasBeenChosenConfig);
            TypedParameter playerParam        = new TypedParameter(typeof(ICharacter), _gameState.Player);
            IDialogActions dialogActions      = _resolver.Container.Resolve <IDialogActions>(playerParam);
            TypedParameter dialogActionsParam = new TypedParameter(typeof(IDialogActions), dialogActions);
            IDialogOption  option             = _resolver.Container.Resolve <IDialogOption>(labelParam, speakParam, showOnceParam, hoverParam,
                                                                                            wasChosenParam, playerParam, dialogActionsParam);

            return(option);
        }