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(); }
/// <inheritdoc /> public override void OnStop([NotNull, ValidatedNotNull] IClientPluginContext context) { context.Logging.Application.Info( $@"{nameof(ExampleClientPluginEntry)}.{nameof(OnStop)} writing to the application log!"); context.Logging.Plugin.Info( $@"{nameof(ExampleClientPluginEntry)}.{nameof(OnStop)} writing to the plugin log!"); }
/// <inheritdoc /> public override void OnStart([NotNull, ValidatedNotNull] IClientPluginContext context) { context.Logging.Application.Info( $@"{nameof(ExampleClientPluginEntry)}.{nameof(OnStart)} writing to the application log!"); context.Logging.Plugin.Info( $@"{nameof(ExampleClientPluginEntry)}.{nameof(OnStart)} writing to the plugin log!"); mButtonTexture = context.ContentManager.LoadEmbedded <GameTexture>( context, ContentTypes.Interface, "Assets/join-our-discord.png"); context.Lifecycle.LifecycleChangeState += HandleLifecycleChangeState; }
private void HandleLifecycleChangeState([NotNull, ValidatedNotNull] IClientPluginContext context, [NotNull, ValidatedNotNull] LifecycleChangeStateArgs lifecycleChangeStateArgs) { Debug.Assert(mButtonTexture != null, nameof(mButtonTexture) + " != null"); var activeInterface = context.Lifecycle.Interface; if (activeInterface == null) { return; } switch (lifecycleChangeStateArgs.State) { case GameStates.Menu: AddButtonToMainMenu(context, activeInterface); break; } }