Beispiel #1
0
        private void AddButtonToMainMenu([NotNull, ValidatedNotNull] IClientPluginContext context,
                                         [NotNull, ValidatedNotNull] IMutableInterface activeInterface)
        {
            var button = activeInterface.Create <Button>("DiscordButton");

            Debug.Assert(button != null, nameof(button) + " != null");

            var discordInviteUrl = context.GetTypedConfiguration <ExamplePluginConfiguration>()?.DiscordInviteUrl;

            button.Clicked += (sender, args) =>
            {
                if (string.IsNullOrWhiteSpace(discordInviteUrl))
                {
                    context.Logging.Plugin.Error($@"DiscordInviteUrl configuration property is null/empty/whitespace.");
                    return;
                }

                Process.Start(discordInviteUrl);
            };

            button.SetImage(mButtonTexture, mButtonTexture.Name, Button.ControlState.Normal);
            button.SetSize(mButtonTexture.GetWidth(), mButtonTexture.GetHeight());
            button.CurAlignments?.Add(Alignments.Bottom);
            button.CurAlignments?.Add(Alignments.Right);
            button.ProcessAlignments();
        }