private static void CopyJson(string[] args) { GameLocation loc = Game1.currentLocation; Farmer who = Game1.player; if (loc is null || who is null) { print("\nPlayer not loaded!\n"); return; } StringBuilder builder = new StringBuilder(13); builder.AppendLine("\"warpid\": {"); builder.Append("\t\"Location\": \"").Append(loc.Name).AppendLine("\","); builder.Append("\t\"X\": ").Append(who.getTileX()).AppendLine(","); builder.Append("\t\"Y\": ").Append(who.getTileY()).AppendLine(","); builder.AppendLine("\t\"Enabled\": true,"); builder.AppendLine("\t\"Label\": \"label\""); builder.Append("}"); if (DesktopClipboard.IsAvailable) { DesktopClipboard.SetText(builder.ToString()); print("\nJSON copied to clipboard!\n"); } else { print("\nClipboard not available, printing to console!\n"); print(builder.ToString()); } }
protected void copyCode(Farmer who) { if (DesktopClipboard.SetText(code)) { Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\UI:Server_InviteCode_Copied"))); } else { Game1.showRedMessageUsingLoadString("Strings\\UI:Server_InviteCode_CopyFailed"); } }
public override void receiveLeftClick(int x, int y, bool playSound = true) { if (pasteButton != null && pasteButton.containsPoint(x, y)) { string pasted_text = ""; if (DesktopClipboard.GetText(ref pasted_text)) { Game1.playSound("drumkit6"); textBox.Text = pasted_text; } else { Game1.playSound("cancel"); } } base.receiveLeftClick(x, y, playSound); }
private void GetLogFile(string arg1, string[] arg2) { string logPath = Path.Combine(Constants.DataPath, "ErrorLogs", "SMAPI-latest.txt"); if (!File.Exists(logPath)) { Monitor.Log($"SMAPI log not found at {logPath}.", LogLevel.Error); return; } if (arg2.Length == 0) { File.Copy(logPath, Environment.CurrentDirectory); Monitor.Log($"Copied SMAPI log to game folder {Environment.CurrentDirectory}.", LogLevel.Alert); } else { string cmd = arg2[0].ToLower(); switch (cmd) { case "desktop": case "dt": File.Copy(logPath, Environment.GetFolderPath(Environment.SpecialFolder.Desktop)); Monitor.Log($"Copied SMAPI log to Desktop {Environment.GetFolderPath(Environment.SpecialFolder.Desktop)}.", LogLevel.Alert); break; case "copy": case "cp": string log = File.ReadAllText(logPath); if (DesktopClipboard.SetText(log)) { Monitor.Log($"Copied SMAPI log to Clipboard.", LogLevel.Alert); } else { Monitor.Log($"Coulding copy SMAPI log to Clipboard!", LogLevel.Error); } break; } } }
private void GameEvents_OneSecondTick(object sender, EventArgs e) { if (IsEnabled == false) // server toggle { Game1.paused = false; return; } NoClientsPause(); //Turn back on when done testing!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! if (this.Config.clientsCanPause == true) { clientControlledPause(); } //Invite Code Copier if (this.Config.copyInviteCodeToClipboard == true) { if (!String.Equals(inviteCode, Game1.server.getInviteCode())) { DesktopClipboard.SetText("Invite Code: " + Game1.server.getInviteCode()); inviteCode = Game1.server.getInviteCode(); } } //write code to a InviteCode.txt in the Always On Server mod folder if (!String.Equals(inviteCodeTXT, Game1.server.getInviteCode())) { inviteCodeTXT = Game1.server.getInviteCode(); if (eggHuntAvailable == true) { inviteCodeTXT = "Festival In Progress Try Again Later"; } else if (luauSoupAvailable == true) { inviteCodeTXT = "Festival In Progress Try Again Later"; } else if (jellyDanceAvailable == true) { inviteCodeTXT = "Festival In Progress Try Again Later"; } else if (grangeDisplayAvailable == true) { inviteCodeTXT = "Festival In Progress Try Again Later"; } else if (goldenPumpkinAvailable == true) { inviteCodeTXT = "Festival In Progress Try Again Later"; } else if (iceFishingAvailable == true) { inviteCodeTXT = "Festival In Progress Try Again Later"; } else if (winterFeastAvailable == true) { inviteCodeTXT = "Festival In Progress Try Again Later"; } else { try { //Pass the filepath and filename to the StreamWriter Constructor StreamWriter sw = new StreamWriter("Mods/Always On Server/InviteCode.txt"); //Write a line of text sw.WriteLine(inviteCodeTXT); //Close the file sw.Close(); } catch (Exception b) { Console.WriteLine("Exception: " + b.Message); } finally { Console.WriteLine("Executing finally block."); } } } //left click menu spammer to get through random events happening if (IsEnabled == true) // server toggle { if (Game1.activeClickableMenu != null) { this.Helper.Reflection.GetMethod(Game1.activeClickableMenu, "receiveLeftClick").Invoke(0, 0, true); } } //disable friendship decay if (IsEnabled == true) // server toggle { if (this.PreviousFriendships.Any()) { foreach (string key in Game1.player.friendshipData.Keys) { Friendship friendship = Game1.player.friendshipData[key]; if (this.PreviousFriendships.TryGetValue(key, out int oldPoints) && oldPoints > friendship.Points) { friendship.Points = oldPoints; } } } this.PreviousFriendships.Clear(); foreach (var pair in Game1.player.friendshipData.FieldDict) { this.PreviousFriendships[pair.Key] = pair.Value.Value.Points; } } //eggHunt event if (eggHuntAvailable == true && Game1.CurrentEvent != null && Game1.CurrentEvent.isFestival) { eggHuntCountDown += 1; float chatEgg = this.Config.eggHuntCountDownConfig / 60f; if (eggHuntCountDown == 1) { Game1.chatBox.activate(); Game1.chatBox.setText($"The Egg Hunt will begin in {chatEgg:0.#} minutes."); Game1.chatBox.chatBox.RecieveCommandInput('\r'); } if (eggHuntCountDown == this.Config.eggHuntCountDownConfig + 1) { this.Helper.Reflection.GetMethod(Game1.CurrentEvent, "answerDialogueQuestion", true).Invoke(Game1.getCharacterFromName("Lewis"), "yes"); } if (eggHuntCountDown >= this.Config.eggHuntCountDownConfig + 5) { if (Game1.activeClickableMenu != null) { this.Helper.Reflection.GetMethod(Game1.activeClickableMenu, "receiveLeftClick").Invoke(10, 10, true); } } } //flower dance turned off, causes server crashes /* //flowerDance event * if (flowerDanceAvailable == true && Game1.CurrentEvent != null && Game1.CurrentEvent.isFestival) * { * flowerDanceCountDown += 1; * * float chatFlower = this.Config.flowerDanceCountDownConfig / 60f; * if (flowerDanceCountDown == 1) * { * Game1.chatBox.activate(); * Game1.chatBox.setText($"The Flower Dance will begin in {chatFlower:0.#} minutes."); * Game1.chatBox.chatBox.RecieveCommandInput('\r'); * } * * if (flowerDanceCountDown == this.Config.flowerDanceCountDownConfig + 1) * { * this.Helper.Reflection.GetMethod(Game1.CurrentEvent, "answerDialogueQuestion", true).Invoke(Game1.getCharacterFromName("Lewis"), "yes"); * } * if (flowerDanceCountDown >= this.Config.flowerDanceCountDownConfig + 5) * { * if (Game1.activeClickableMenu != null) * { * this.Helper.Reflection.GetMethod(Game1.activeClickableMenu, "receiveLeftClick").Invoke(10, 10, true); * } * } * }*/ //luauSoup event if (luauSoupAvailable == true && Game1.CurrentEvent != null && Game1.CurrentEvent.isFestival) { luauSoupCountDown += 1; float chatSoup = this.Config.luauSoupCountDownConfig / 60f; if (luauSoupCountDown == 1) { Game1.chatBox.activate(); Game1.chatBox.setText($"The Soup Tasting will begin in {chatSoup:0.#} minutes."); Game1.chatBox.chatBox.RecieveCommandInput('\r'); } if (luauSoupCountDown == this.Config.luauSoupCountDownConfig + 1) { this.Helper.Reflection.GetMethod(Game1.CurrentEvent, "answerDialogueQuestion", true).Invoke(Game1.getCharacterFromName("Lewis"), "yes"); } if (luauSoupCountDown >= this.Config.luauSoupCountDownConfig + 5) { if (Game1.activeClickableMenu != null) { this.Helper.Reflection.GetMethod(Game1.activeClickableMenu, "receiveLeftClick").Invoke(10, 10, true); } } } //Dance of the Moonlight Jellies event if (jellyDanceAvailable == true && Game1.CurrentEvent != null && Game1.CurrentEvent.isFestival) { jellyDanceCountDown += 1; float chatJelly = this.Config.jellyDanceCountDownConfig / 60f; if (jellyDanceCountDown == 1) { Game1.chatBox.activate(); Game1.chatBox.setText($"The Dance of the Moonlight Jellies will begin in {chatJelly:0.#} minutes."); Game1.chatBox.chatBox.RecieveCommandInput('\r'); } if (jellyDanceCountDown == this.Config.jellyDanceCountDownConfig + 1) { this.Helper.Reflection.GetMethod(Game1.CurrentEvent, "answerDialogueQuestion", true).Invoke(Game1.getCharacterFromName("Lewis"), "yes"); } if (jellyDanceCountDown >= this.Config.jellyDanceCountDownConfig + 5) { if (Game1.activeClickableMenu != null) { this.Helper.Reflection.GetMethod(Game1.activeClickableMenu, "receiveLeftClick").Invoke(10, 10, true); } } } //Grange Display event if (grangeDisplayAvailable == true && Game1.CurrentEvent != null && Game1.CurrentEvent.isFestival) { grangeDisplayCountDown += 1; float chatGrange = this.Config.grangeDisplayCountDownConfig / 60f; if (grangeDisplayCountDown == 1) { Game1.chatBox.activate(); Game1.chatBox.setText($"The Grange Judging will begin in {chatGrange:0.#} minutes."); Game1.chatBox.chatBox.RecieveCommandInput('\r'); } if (grangeDisplayCountDown == this.Config.grangeDisplayCountDownConfig + 1) { this.Helper.Reflection.GetMethod(Game1.CurrentEvent, "answerDialogueQuestion", true).Invoke(Game1.getCharacterFromName("Lewis"), "yes"); } if (grangeDisplayCountDown == this.Config.grangeDisplayCountDownConfig + 5) { Game1.player.team.SetLocalReady("festivalEnd", true); Game1.activeClickableMenu = (IClickableMenu) new ReadyCheckDialog("festivalEnd", true, (ConfirmationDialog.behavior)(who => { getBedCoordinates(); Game1.exitActiveMenu(); Game1.warpFarmer("Farmhouse", bedX, bedY, false); Game1.timeOfDay = 2200; Game1.shouldTimePass(); }), (ConfirmationDialog.behavior)null); } } //golden pumpkin maze event if (goldenPumpkinAvailable == true && Game1.CurrentEvent != null && Game1.CurrentEvent.isFestival) { goldenPumpkinCountDown += 1; if (goldenPumpkinCountDown == 10) { Game1.player.team.SetLocalReady("festivalEnd", true); Game1.activeClickableMenu = (IClickableMenu) new ReadyCheckDialog("festivalEnd", true, (ConfirmationDialog.behavior)(who => { getBedCoordinates(); Game1.exitActiveMenu(); Game1.warpFarmer("Farmhouse", bedX, bedY, false); Game1.timeOfDay = 2400; Game1.shouldTimePass(); }), (ConfirmationDialog.behavior)null); } } //ice fishing event if (iceFishingAvailable == true && Game1.CurrentEvent != null && Game1.CurrentEvent.isFestival) { iceFishingCountDown += 1; float chatIceFish = this.Config.iceFishingCountDownConfig / 60f; if (iceFishingCountDown == 1) { Game1.chatBox.activate(); Game1.chatBox.setText($"The Ice Fishing Contest will begin in {chatIceFish:0.#} minutes."); Game1.chatBox.chatBox.RecieveCommandInput('\r'); } if (iceFishingCountDown == this.Config.iceFishingCountDownConfig + 1) { this.Helper.Reflection.GetMethod(Game1.CurrentEvent, "answerDialogueQuestion", true).Invoke(Game1.getCharacterFromName("Lewis"), "yes"); } if (iceFishingCountDown >= this.Config.iceFishingCountDownConfig + 5) { if (Game1.activeClickableMenu != null) { this.Helper.Reflection.GetMethod(Game1.activeClickableMenu, "receiveLeftClick").Invoke(10, 10, true); } } } //Feast of the Winter event if (winterFeastAvailable == true && Game1.CurrentEvent != null && Game1.CurrentEvent.isFestival) { winterFeastCountDown += 1; if (winterFeastCountDown == 10) { Game1.player.team.SetLocalReady("festivalEnd", true); Game1.activeClickableMenu = (IClickableMenu) new ReadyCheckDialog("festivalEnd", true, (ConfirmationDialog.behavior)(who => { getBedCoordinates(); Game1.exitActiveMenu(); Game1.warpFarmer("Farmhouse", bedX, bedY, false); Game1.timeOfDay = 2200; Game1.shouldTimePass(); }), (ConfirmationDialog.behavior)null); } } }