示例#1
0
        public static void Init(IFontFactory fontLoader)
        {
            const string path = "Fonts/Font Awesome 5 Free-Solid-900.otf";

            Font       = fontLoader.LoadFontFromPath(path, 14f, FontStyle.Regular);
            IconConfig = fontLoader.GetTextConfig(font: Font, autoFit: AutoFit.NoFitting, alignment: Alignment.MiddleCenter,
                                                  paddingLeft: 0f, paddingTop: 0f, paddingBottom: 0f, paddingRight: 0f);

            ButtonConfig = fontLoader.GetTextConfig(font: Font, autoFit: AutoFit.TextShouldFitLabel, alignment: Alignment.MiddleCenter,
                                                    paddingLeft: 0f, paddingTop: 0f, paddingBottom: 0f, paddingRight: 0f);

            var tinyFont = fontLoader.LoadFontFromPath(path, 8f, FontStyle.Regular);

            TinyButtonConfig = fontLoader.GetTextConfig(font: tinyFont, autoFit: AutoFit.TextShouldFitLabel, alignment: Alignment.MiddleCenter,
                                                        paddingLeft: -1f, paddingTop: 0f, paddingBottom: 0f, paddingRight: 0f, outlineWidth: 1f);

            TinyButtonConfigHovered = AGSTextConfig.ChangeColor(TinyButtonConfig, Colors.Black, Colors.White, 0f);

            var largeFont = fontLoader.LoadFontFromPath(path, 56f, FontStyle.Regular);

            LargeIconConfig = fontLoader.GetTextConfig(font: largeFont, autoFit: AutoFit.TextShouldFitLabel, alignment: Alignment.MiddleCenter,
                                                       paddingLeft: -1f, paddingTop: 0f, paddingBottom: 0f, paddingRight: 0f, outlineWidth: 1f);

            LargeIconConfigHovered = AGSTextConfig.ChangeColor(LargeIconConfig, GameViewColors.HoveredText, Colors.White, 0f);
        }
示例#2
0
        public GLText(IGraphicsBackend graphics, IRenderMessagePump messagePump, IFontFactory fonts, IFont defaultFont, BitmapPool pool,
                      bool alwaysMeasureOnly, string text = "", int maxWidth = int.MaxValue)
        {
            _messagePump       = messagePump;
            _fonts             = fonts;
            _graphics          = graphics;
            _alwaysMeasureOnly = alwaysMeasureOnly;
            _maxWidth          = maxWidth;
            _text       = text;
            _bitmapPool = pool;
            _config     = fonts.GetTextConfig(font: defaultFont);

            prepareBitmapDraw();
        }
示例#3
0
        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 = _fontLoader.GetTextConfig(autoFit: AutoFit.TextShouldWrapAndLabelShouldFitHeight,
                                                   brush: _brushLoader.LoadSolidBrush(Colors.White), font: _fontLoader.LoadFont(null, 10f));
            }
            if (hoverConfig == null)
            {
                hoverConfig = _fontLoader.GetTextConfig(autoFit: AutoFit.TextShouldWrapAndLabelShouldFitHeight,
                                                        brush: _brushLoader.LoadSolidBrush(Colors.Yellow), font: _fontLoader.LoadFont(null, 10f));
            }
            if (hasBeenChosenConfig == null)
            {
                hasBeenChosenConfig = _fontLoader.GetTextConfig(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);
        }
示例#4
0
        public ILabel GetLabel(string id, [MethodParam(Default = "")] string text,
                               [MethodParam(Default = 80f)] float width, [MethodParam(Default = 30f)] float height,
                               float x, float y,
                               [MethodParam(Browsable = false)] IObject parent = null, ITextConfig config = null,
                               [MethodParam(Browsable = false, Default = false)] bool addToUi = true)
        {
            SizeF          baseSize = new SizeF(width, height);
            TypedParameter idParam  = new TypedParameter(typeof(string), id);
            ILabel         label    = _resolver.Container.Resolve <ILabel>(idParam);

            label.LabelRenderSize = baseSize;
            label.Text            = text;
            label.X          = x;
            label.Y          = y;
            label.Tint       = Colors.Transparent;
            label.TextConfig = config ?? _fonts.GetTextConfig();
            setParent(label, parent);
            if (addToUi)
            {
                _gameState.UI.Add(label);
            }
            return(label);
        }