public ListenCommand(IMonitor monitor, ChatCommandsConfig config, NotifyingTextWriter writer) : base(monitor) { this.writer = writer; if (config.ListenToConsoleOnStartup) { this.Handle(null, null); } }
/// <summary>Construct an instance.</summary> /// <remarks>Reassigns the enter handler, replaces <see cref="ChatTextBox" /> and <see cref="EmojiMenu" />.</remarks> public CommandChatBox(IModHelper helper, ICommandHandler handler, ChatCommandsConfig config) { this.handler = handler; this.bCheatHistoryPosition = helper.Reflection.GetField <int>(this, "cheatHistoryPosition"); this.bFormatMessage = helper.Reflection.GetMethod(this, "formatMessage"); this.bMessages = helper.Reflection.GetField <List <ChatMessage> >(this, "messages").GetValue(); this.bEmojiMenuIcon = helper.Reflection.GetField <ClickableTextureComponent>(this, "emojiMenuIcon").GetValue(); this.bChoosingEmoji = helper.Reflection.GetField <bool>(this, "choosingEmoji"); Texture2D chatBoxTexture = Game1.content.Load <Texture2D>("LooseSprites\\chatBox"); this.chatBox.OnEnterPressed -= helper.Reflection.GetField <TextBoxEvent>(this, "e").GetValue(); this.chatBox = this.commandChatTextBox = new CommandChatTextBox(chatBoxTexture, null, Game1.smallFont, Color.White); Game1.keyboardDispatcher.Subscriber = this.chatBox; this.chatBox.Selected = false; this.chatBox.OnEnterPressed += this.EnterPressed; this.multiplayer = helper.Reflection.GetField <Multiplayer>(typeof(Game1), "multiplayer").GetValue(); this.inputState = helper.Reflection.GetField <InputState>(typeof(Game1), "input").GetValue(); ConsoleChatMessage.Init(LocalizedContentManager.CurrentLanguageCode); this.emojiMenu = new CommandEmojiMenu(helper.Reflection, this, emojiTexture, chatBoxTexture); helper.Reflection.GetMethod(this, "updatePosition").Invoke(); this.displayLineIndex = -1; this.config = config; this.config.UseMonospacedFontForCommandOutput = this.config.UseMonospacedFontForCommandOutput && !( LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.ja || LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.zh || LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.th); this.DetermineNumberOfMaxMessages(); }