├── .editorconfig ├── .github └── FUNDING.yml ├── .gitignore ├── Commands ├── AdminInstructionsCommand.cs └── BecomeAdmin.cs ├── Extensions.cs ├── HEROsMod.cs ├── HEROsMod.csproj ├── HEROsMod.csproj.user ├── HEROsMod.sln ├── HEROsModModPlayer.cs ├── HEROsModModWorld.cs ├── HEROsModNetwork ├── DatabaseController.cs ├── GeneralMessages.cs ├── Group.cs ├── HEROsModPlayer.cs ├── LoginService.cs ├── Network.cs ├── Region.cs └── TileChangeController.cs ├── HEROsModServerConfig.cs ├── HEROsModServices ├── AchievementManger.cs ├── BuffService.cs ├── CheckTileModificationTool.cs ├── EnemyToggler.cs ├── ExtensionMenuService.cs ├── FlyCam.cs ├── GenericExtensionService.cs ├── GodModeService.cs ├── GroupInspector.cs ├── HEROsModService.cs ├── HardmodeEnemyToggler.cs ├── InfiniteReach.cs ├── InvasionService.cs ├── InventoryManager.cs ├── ItemBanner.cs ├── ItemBrowser.cs ├── ItemClearer.cs ├── KeybindController.cs ├── LightHack.cs ├── Login.cs ├── LoginStorage.cs ├── MapRevealer.cs ├── MiscOptions.cs ├── MobSpawner.cs ├── NPCSpawner.cs ├── PSAService.cs ├── PlayerList.cs ├── PrefixEditor.cs ├── RegionService.cs ├── SelectionTool.cs ├── ServiceController.cs ├── ServiceHotbar.cs ├── SpawnPointSetter.cs ├── StatsService.cs ├── Teleporter.cs ├── TestHotbarSevice.cs ├── TimeChanger.cs ├── TimeWeatherChanger.cs ├── ToggleGravestones.cs ├── Waypoints.cs ├── WeatherChanger.cs ├── WikiService.cs └── ZoomToolsService.cs ├── HerosModSystem.cs ├── Images ├── AllIcons.psd ├── CTF │ ├── blueBanner.png │ ├── blueButtonBG.png │ ├── blueFlag.png │ ├── bluePlatform.png │ ├── blueScore.png │ ├── blueSpawn.png │ ├── blueTeamIcon.png │ ├── platform.png │ ├── redBanner.png │ ├── redButtonBG.png │ ├── redFlag.png │ ├── redPlatform.png │ ├── redScore.png │ ├── redSpawn.png │ └── redTeamIcon.png ├── CollapseBar │ ├── CollapseArrowHorizontal.png │ ├── CollapseButton.png │ ├── CollapseButtonHorizontal.png │ └── collapseArrow.png ├── CollapseIcon.png ├── ExpandIcon.png ├── Old │ ├── CollapseIcon.png │ ├── Demon_Altar.png │ ├── ExpandIcon.png │ ├── LogoNew0.png │ ├── LogoNew1.png │ ├── LogoNew2.png │ ├── backButton.png │ ├── canIcon.png │ ├── closeButton.png │ ├── colorGradient.png │ ├── connectedPlayers.png │ ├── filterMod.png │ ├── forwardButton.png │ ├── login.png │ ├── logout.png │ ├── manageGroups.png │ ├── moonIcon.png │ ├── npcIcon.png │ ├── rainIcon.png │ ├── sortAZ.png │ ├── sortAxe.png │ ├── sortDamage.png │ ├── sortFish.png │ ├── sortHammer.png │ ├── sortItemID.png │ ├── sortPick.png │ ├── sortValue.png │ ├── speed0.png │ ├── speed1.png │ ├── speed2.png │ ├── speed3.png │ ├── speed4.png │ ├── sunIcon.png │ ├── testTubeSpritesheet.png │ └── waypointIcon.png ├── UIKit │ ├── barEdge.png │ ├── buttonEdge.png │ ├── checkBox.png │ ├── checkMark.png │ ├── clearIcon.png │ ├── dropdownCapDown.png │ ├── dropdownCapUp.png │ ├── openIcon.png │ ├── saveIcon.png │ ├── scrollbarEdge.png │ ├── scrollbgEdge.png │ └── textboxEdge.png ├── buddhaMode.png ├── buffs.png ├── canIcon.png ├── closeButton.png ├── connectedPlayers.png ├── contributions.txt ├── event.png ├── explosives.png ├── extensions.png ├── filterMod.png ├── flyCam.png ├── godMode.png ├── gravestone.png ├── infiniteReach.png ├── items.png ├── lighthack.png ├── login.png ├── logout.png ├── manageGroups.png ├── map.png ├── moonIcon.png ├── npcIcon.png ├── npcs.png ├── rainIcon.png ├── rainStop.png ├── reforge.png ├── region.png ├── sandstormStart.png ├── sandstormStop.png ├── settings.png ├── sortAZ.png ├── sortAmmo.png ├── sortAxe.png ├── sortBait.png ├── sortDamage.png ├── sortDefense.png ├── sortFish.png ├── sortHammer.png ├── sortItemID.png ├── sortPick.png ├── sortValue.png ├── spacer.png ├── spawn.png ├── speed0.png ├── speed1.png ├── sunIcon.png ├── tileModification.png ├── timeRain.png └── waypointIcon.png ├── Interfaces ├── Item.cs └── Recipe.cs ├── LICENSE ├── Localization ├── TranslationsNeeded.txt ├── UpdateLocalizationFiles.py ├── de-DE.hjson ├── en-US.hjson ├── es-ES.hjson ├── fr-FR.hjson ├── it-IT.hjson ├── pl-PL.hjson ├── pt-BR.hjson ├── ru-RU.hjson └── zh-Hans.hjson ├── ModExtensions.cs ├── ModUtils.cs ├── Properties └── launchSettings.json ├── README.md ├── UIKit ├── ColorSliders.cs ├── MasterView.cs ├── UIButton.cs ├── UICheckbox.cs ├── UIColorPicker.cs ├── UIColorSlider.cs ├── UIComponents │ ├── DropTableView.cs │ ├── HostPlayWindow.cs │ ├── ItemBrowser.cs │ ├── ItemCollectionView.cs │ ├── ItemTooltip.cs │ ├── ItemView.cs │ ├── KeybindWindow.cs │ ├── MoneyView.cs │ ├── SliderWithTextbox.cs │ ├── Slot.cs │ └── UIHotbar.cs ├── UIDropdown.cs ├── UIImage.cs ├── UILabel.cs ├── UIListView.cs ├── UIMessageBox.cs ├── UIPlayerHead.cs ├── UIRect.cs ├── UIScreen.cs ├── UIScrollBar.cs ├── UIScrollView.cs ├── UISlider.cs ├── UITestController.cs ├── UITextbox.cs ├── UIView.cs ├── UIWindow.cs └── UIWrappingLabel.cs ├── build.txt ├── description.txt ├── description_workshop.txt ├── icon.png └── icon_workshop.png /.editorconfig: -------------------------------------------------------------------------------- 1 | # Rules in this file were initially inferred by Visual Studio IntelliCode from the D:\Documents\My Games\Terraria\ModLoader\Mod Sources\HEROsMod\ codebase based on best match to current usage at 3/1/2019 2 | # You can modify the rules from these initially generated values to suit your own policies 3 | # You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference 4 | [*.cs] 5 | 6 | #Core editorconfig formatting - indentation 7 | 8 | #use hard tabs for indentation 9 | indent_style = tab 10 | 11 | #Formatting - new line options 12 | 13 | #require braces to be on a new line for control_blocks, types, properties, and methods (also known as "Allman" style) 14 | csharp_new_line_before_open_brace = control_blocks, types, properties, methods 15 | 16 | #Formatting - organize using options 17 | 18 | #do not place System.* using directives before other using directives 19 | dotnet_sort_system_directives_first = false 20 | 21 | #Formatting - spacing options 22 | 23 | #require NO space between a cast and the value 24 | csharp_space_after_cast = false 25 | #require a space before the colon for bases or interfaces in a type declaration 26 | csharp_space_after_colon_in_inheritance_clause = true 27 | #require a space after a keyword in a control flow statement such as a for loop 28 | csharp_space_after_keywords_in_control_flow_statements = true 29 | #require a space before the colon for bases or interfaces in a type declaration 30 | csharp_space_before_colon_in_inheritance_clause = true 31 | #remove space within empty argument list parentheses 32 | csharp_space_between_method_call_empty_parameter_list_parentheses = false 33 | #remove space between method call name and opening parenthesis 34 | csharp_space_between_method_call_name_and_opening_parenthesis = false 35 | #do not place space characters after the opening parenthesis and before the closing parenthesis of a method call 36 | csharp_space_between_method_call_parameter_list_parentheses = false 37 | #remove space within empty parameter list parentheses for a method declaration 38 | csharp_space_between_method_declaration_empty_parameter_list_parentheses = false 39 | #place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list. 40 | csharp_space_between_method_declaration_parameter_list_parentheses = false 41 | 42 | #Formatting - wrapping options 43 | 44 | #leave code block on single line 45 | csharp_preserve_single_line_blocks = true 46 | #leave statements and member declarations on the same line 47 | csharp_preserve_single_line_statements = true 48 | 49 | #Style - expression bodied member options 50 | 51 | #prefer block bodies for accessors 52 | csharp_style_expression_bodied_accessors = false:suggestion 53 | #prefer block bodies for methods 54 | csharp_style_expression_bodied_methods = false:suggestion 55 | #prefer block bodies for properties 56 | csharp_style_expression_bodied_properties = false:suggestion 57 | 58 | #Style - expression level options 59 | 60 | #prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them 61 | dotnet_style_predefined_type_for_member_access = true:suggestion 62 | 63 | #Style - implicit and explicit types 64 | 65 | #prefer explicit type over var to declare variables with built-in system types such as int 66 | csharp_style_var_for_built_in_types = false:suggestion 67 | #prefer explicit type over var when the type is already mentioned on the right-hand side of a declaration 68 | csharp_style_var_when_type_is_apparent = false:suggestion 69 | 70 | #Style - language keyword and framework type options 71 | 72 | #prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them 73 | dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion 74 | 75 | #Style - qualification options 76 | 77 | #prefer events not to be prefaced with this. or Me. in Visual Basic 78 | dotnet_style_qualification_for_event = false:suggestion 79 | #prefer fields not to be prefaced with this. or Me. in Visual Basic 80 | dotnet_style_qualification_for_field = false:suggestion 81 | #prefer methods not to be prefaced with this. or Me. in Visual Basic 82 | dotnet_style_qualification_for_method = false:suggestion 83 | #prefer properties not to be prefaced with this. or Me. in Visual Basic 84 | dotnet_style_qualification_for_property = false:suggestion 85 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: JavidPack 4 | patreon: jopojelly 5 | custom: "https://www.paypal.me/JavidPack" 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | obj 3 | .vs 4 | App.config -------------------------------------------------------------------------------- /Commands/AdminInstructionsCommand.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.HEROsModNetwork; 2 | using System; 3 | using Terraria.ModLoader; 4 | 5 | namespace HEROsMod.Commands 6 | { 7 | internal class AdminInstructionsCommand : ModCommand 8 | { 9 | public override CommandType Type => CommandType.Console; 10 | 11 | public override string Command => "HEROsAdmin"; 12 | 13 | public override string Description => HEROsMod.HeroText("AdminInstructionsCommandDescription"); 14 | 15 | public override void Action(CommandCaller caller, string input, string[] args) 16 | { 17 | Console.ForegroundColor = ConsoleColor.Yellow; 18 | Console.WriteLine(string.Format(HEROsMod.HeroText("DedicatedServerAutoMessage"), Network.AuthCode)); 19 | Console.ResetColor(); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Commands/BecomeAdmin.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.HEROsModNetwork; 2 | using System; 3 | using Terraria; 4 | using Terraria.ModLoader; 5 | using Terraria.ID; 6 | 7 | namespace HEROsMod.Commands 8 | { 9 | internal class BecomeAdmin : ModCommand 10 | { 11 | public override CommandType Type => CommandType.World; 12 | 13 | public override string Command => "auth"; 14 | 15 | public override string Description => HEROsMod.HeroText("MakesYouAdminInHEROsMod"); 16 | 17 | public override string Usage => "/auth SecretCode"; 18 | 19 | public override void Action(CommandCaller caller, string input, string[] args) 20 | { 21 | if(Main.netMode == NetmodeID.SinglePlayer) 22 | { 23 | throw new UsageException("Only use this command while on server."); 24 | } 25 | if (args.Length != 1 || args[0].Length != 6) 26 | { 27 | throw new UsageException(); 28 | } 29 | if (args[0] == Network.AuthCode.ToString()) 30 | { 31 | 32 | if (Network.Players[caller.Player.whoAmI].Username.Length > 0) 33 | { 34 | Network.Players[caller.Player.whoAmI].Group = Network.AdminGroup; 35 | DatabaseController.SetPlayerGroup(Network.Players[caller.Player.whoAmI].ID, Network.Players[caller.Player.whoAmI].Group.ID); 36 | LoginService.SendPlayerPermissions(caller.Player.whoAmI); 37 | Network.SendTextToPlayer(HEROsMod.HeroText("YouAreNowAdmin"), caller.Player.whoAmI); 38 | return; 39 | } 40 | else 41 | { 42 | Network.SendTextToPlayer(HEROsMod.HeroText("PleaseLoginFirst"), caller.Player.whoAmI); 43 | return; 44 | } 45 | } 46 | throw new UsageException(HEROsMod.HeroText("AuthCodeIsIncorrect")); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /HEROsMod.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | HEROsMod 6 | latest 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /HEROsMod.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ProjectFiles 5 | 6 | 7 | Program 8 | C:\Program Files %28x86%29\Steam\steamapps\common\Terraria\Terraria.exe 9 | C:\Program Files %28x86%29\Steam\steamapps\common\terraria 10 | -skipselect 11 | 12 | -------------------------------------------------------------------------------- /HEROsMod.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30717.126 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HEROsMod", "HEROsMod.csproj", "{7607A5C9-A439-4157-B0D8-C7F01382FF01}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {7607A5C9-A439-4157-B0D8-C7F01382FF01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {7607A5C9-A439-4157-B0D8-C7F01382FF01}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {7607A5C9-A439-4157-B0D8-C7F01382FF01}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {7607A5C9-A439-4157-B0D8-C7F01382FF01}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {1C2417EE-E4A9-4C75-8F27-97DE58A5F68B} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /HEROsModModPlayer.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.HEROsModNetwork; 2 | using HEROsMod.HEROsModServices; 3 | using HEROsMod.UIKit; 4 | using Microsoft.Xna.Framework; 5 | using Microsoft.Xna.Framework.Graphics; 6 | using Microsoft.Xna.Framework.Input; 7 | using System; 8 | using System.Collections.Generic; 9 | using System.IO; 10 | using Terraria; 11 | using Terraria.DataStructures; 12 | using Terraria.GameInput; 13 | using Terraria.ID; 14 | using Terraria.ModLoader; 15 | using Terraria.ModLoader.IO; 16 | using Terraria.UI; 17 | 18 | namespace HEROsMod 19 | { 20 | public class HEROsModModPlayer : ModPlayer 21 | { 22 | // public override bool Autoload(ref string name) => true; 23 | 24 | private float FreezeNonLoggedInMessageTimer = 7f; 25 | 26 | public override void SetControls() 27 | { 28 | if (FlyCam.Enabled && !FlyCam.LockCamera) 29 | { 30 | Player.controlDown = false; 31 | Player.controlUp = false; 32 | Player.controlLeft = false; 33 | Player.controlRight = false; 34 | 35 | Player.controlMount = false; 36 | Player.controlHook = false; 37 | Player.controlThrow = false; 38 | // player.controlJump = false; 39 | Player.controlSmart = false; 40 | Player.controlTorch = false; 41 | } 42 | if(Main.netMode == NetmodeID.MultiplayerClient && !HEROsModServices.Login.LoggedIn && ModContent.GetInstance().FreezeNonLoggedIn) 43 | { 44 | Player.frozen = true; 45 | FreezeNonLoggedInMessageTimer -= ModUtils.DeltaTime; 46 | if (FreezeNonLoggedInMessageTimer <= 0) 47 | { 48 | FreezeNonLoggedInMessageTimer = 7f; 49 | Main.NewText(HEROsMod.HeroText("LoginInstructions"), Color.Red); 50 | } 51 | } 52 | } 53 | 54 | public override bool ImmuneTo(PlayerDeathReason damageSource, int cooldownCounter, bool dodgeable) 55 | { 56 | if (GodModeService.Enabled && !GodModeService.BuddhaMode) 57 | return true; 58 | return base.ImmuneTo(damageSource, cooldownCounter, dodgeable); 59 | } 60 | 61 | public override bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) 62 | { 63 | if (GodModeService.Enabled && GodModeService.BuddhaMode) 64 | { 65 | Player.statLife = Player.statLifeMax2; 66 | Player.lifeRegen = 999; 67 | return false; 68 | } 69 | return true; 70 | } 71 | 72 | public override void PreUpdate() 73 | { 74 | if (GodModeService.Enabled) 75 | { 76 | if (!GodModeService.BuddhaMode) 77 | Player.statLife = Player.statLifeMax2; 78 | Player.statMana = Player.statManaMax2; 79 | Player.wingTime = Player.wingTimeMax; 80 | } 81 | } 82 | 83 | // TODO - make tmodloader hook, this only gets called while there are players in the world. 84 | private double time; 85 | 86 | public override void PostUpdate() 87 | { 88 | if (Main.dedServ) 89 | { 90 | if (time != Main.time) 91 | { 92 | time = Main.time; 93 | HEROsModNetwork.Network.Update(); 94 | } 95 | } 96 | if (Main.myPlayer == Player.whoAmI && Main.netMode == NetmodeID.MultiplayerClient && !HEROsModServices.Login.LoggedIn && ModContent.GetInstance().FreezeNonLoggedIn) 97 | { 98 | // For visuals. Other players won't see this, but less error prone than Frozen debuff. 99 | Player.frozen = true; 100 | } 101 | } 102 | 103 | public override void ProcessTriggers(TriggersSet triggersSet) 104 | { 105 | } 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /HEROsModModWorld.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.HEROsModNetwork; 2 | using HEROsMod.HEROsModServices; 3 | using HEROsMod.UIKit; 4 | using Microsoft.Xna.Framework; 5 | using Microsoft.Xna.Framework.Graphics; 6 | using Microsoft.Xna.Framework.Input; 7 | using System; 8 | using System.Collections.Generic; 9 | using System.IO; 10 | using Terraria; 11 | using Terraria.DataStructures; 12 | using Terraria.ModLoader; 13 | using Terraria.ModLoader.IO; 14 | using Terraria.UI; 15 | 16 | namespace HEROsMod 17 | { 18 | internal class HEROsModModWorld : ModSystem 19 | { 20 | // public override bool Autoload(ref string name) => true; 21 | 22 | //private const int saveVersion = 0; 23 | 24 | // When a world is loaded on Server or client, we need to load settings. 25 | public override void OnWorldLoad() 26 | { 27 | HEROsModNetwork.DatabaseController.InitializeWorld(); 28 | HEROsModNetwork.Network.InitializeWorld(); 29 | } 30 | 31 | public override void SaveWorldData(TagCompound tag) 32 | { 33 | //if (Main.dedServ) // What about clients? do they save? 34 | { 35 | HEROsModNetwork.DatabaseController.SaveSetting(); 36 | } 37 | } 38 | 39 | public override void LoadWorldData(TagCompound tag) 40 | { 41 | // Just here to not upset ModSystem.ValidateType 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /HEROsModNetwork/HEROsModPlayer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using Terraria; 4 | 5 | namespace HEROsMod.HEROsModNetwork 6 | { 7 | public class HEROsModPlayer 8 | { 9 | private int _playerIndex = -1; 10 | 11 | public int Index 12 | { 13 | get { return _playerIndex; } 14 | } 15 | 16 | //public ServerSock ServerInstance 17 | //{ 18 | // get 19 | // { 20 | // return Netplay.serverSock[_playerIndex]; 21 | // } 22 | //} 23 | 24 | // Changed all the actives to IsActive 25 | // All name to Name 26 | // state to State 27 | // StatusText2 statusText2 28 | //StatusMax statusMax 29 | 30 | public RemoteClient ServerInstance 31 | { 32 | get 33 | { 34 | return Netplay.Clients[_playerIndex]; 35 | } 36 | } 37 | 38 | public Player GameInstance 39 | { 40 | get 41 | { 42 | return Main.player[_playerIndex]; 43 | } 44 | } 45 | 46 | public int ID { get; set; } 47 | 48 | public Group Group { get; set; } 49 | public bool UsingHEROsMod { get; set; } 50 | public string Username { get; set; } 51 | 52 | public bool BackupHostility { get; set; } 53 | public int BackupTeam { get; set; } 54 | 55 | public HEROsModPlayer(int playerIndex) 56 | { 57 | Reset(); 58 | this._playerIndex = playerIndex; 59 | } 60 | 61 | public void Reset() 62 | { 63 | this.Username = String.Empty; 64 | this.ID = -1; 65 | this.UsingHEROsMod = false; 66 | Group = Network.DefaultGroup; 67 | } 68 | } 69 | 70 | public class UserWithID 71 | { 72 | public string Username = string.Empty; 73 | public int ID = -1; 74 | public int groupID = -2; 75 | } 76 | } -------------------------------------------------------------------------------- /HEROsModNetwork/TileChangeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | using Terraria; 5 | 6 | namespace HEROsMod.HEROsModNetwork 7 | { 8 | internal class TileChangeController 9 | { 10 | public static Dictionary TileChanges { get; set; } 11 | 12 | public static void Init() 13 | { 14 | TileChanges = new Dictionary(); 15 | } 16 | 17 | public static void RecordChanges(HEROsModPlayer player, int x, int y) 18 | { 19 | if (player.ID < 0) return; 20 | if (!TileChanges.ContainsKey(player.ID)) 21 | { 22 | TileChanges.Add(player.ID, new TileChange[Main.maxTilesX, Main.maxTilesY]); 23 | } 24 | if (TileChanges[player.ID][x, y] == null) 25 | { 26 | TileChanges[player.ID][x, y] = new TileChange(Main.tile[x, y]); 27 | } 28 | } 29 | 30 | public static void RestoreTileChangesMadeByPlayer(int playerID) 31 | { 32 | if (!TileChanges.ContainsKey(playerID)) return; 33 | TileChange[,] changes = TileChanges[playerID]; 34 | for (int y = 0; y < changes.GetLength(1); y++) 35 | { 36 | for (int x = 0; x < changes.GetLength(0); x++) 37 | { 38 | if (changes[x, y] != null) 39 | { 40 | Tile tile = Main.tile[x, y]; 41 | Tile backupTile = changes[x, y].TilePreviousToChange; 42 | 43 | // TODO: Make my own Tile class to store data, since current Tile instance will always point to current data. 44 | if (backupTile != null /*&& !backupTile.IsTheSameAs(tile)*/) 45 | { 46 | tile.CopyFrom(backupTile); 47 | //NetMessage.SendData(20, -1, -1, "", 1, x, y, 0f, 0); 48 | } 49 | } 50 | } 51 | } 52 | changes = new TileChange[Main.maxTilesX, Main.maxTilesY]; 53 | for (int i = 0; i < Main.player.Length; i++) 54 | { 55 | if (Main.player[i].active) 56 | { 57 | Network.ResendPlayerTileData(Network.Players[i]); 58 | } 59 | } 60 | } 61 | } 62 | 63 | internal class TileChange 64 | { 65 | public DateTime time { get; set; } 66 | 67 | public Tile TilePreviousToChange { get; set; } 68 | 69 | public TileChange(Tile tile) 70 | { 71 | time = DateTime.Now; 72 | TilePreviousToChange = new Tile(); 73 | TilePreviousToChange.CopyFrom(tile); 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /HEROsModServerConfig.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.HEROsModNetwork; 2 | using System.ComponentModel; 3 | using Terraria.Localization; 4 | using Terraria.ModLoader; 5 | using Terraria.ModLoader.Config; 6 | 7 | namespace HEROsMod 8 | { 9 | class HEROsModServerConfig : ModConfig 10 | { 11 | public override ConfigScope Mode => ConfigScope.ServerSide; 12 | 13 | /* 14 | [Label("Disable Achievements")] 15 | [Tooltip("While this is true, vanilla steam achievements will not be obtained.\nUse this if you don't wish to get achievements illegitimately.")] 16 | [DefaultValue(false)] 17 | public bool DisableAchievements { get; set; } 18 | */ 19 | 20 | [DefaultValue(false)] 21 | public bool FreezeNonLoggedIn { get; set; } 22 | 23 | [DefaultValue(true)] 24 | [ReloadRequired] 25 | public bool Telemetry { get; set; } 26 | 27 | public override bool AcceptClientChanges(ModConfig pendingConfig, int whoAmI, ref NetworkText message) 28 | { 29 | if (Network.Players[whoAmI].Group.IsAdmin) 30 | return true; 31 | 32 | message = this.GetLocalization("AcceptClientChangesMessage").ToNetworkText(); 33 | return false; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /HEROsModServices/AchievementManger.cs: -------------------------------------------------------------------------------- 1 | /* 2 | using MonoMod.Cil; 3 | using MonoMod.RuntimeDetour.HookGen; 4 | using System; 5 | using Terraria; 6 | using Terraria.DataStructures; 7 | using Terraria.GameContent.Achievements; 8 | using Terraria.ModLoader; 9 | using Terraria.UI; 10 | 11 | namespace HEROsMod.HEROsModServices 12 | { 13 | static class AchievementManger 14 | { 15 | //public delegate void orig_Value(CustomFloatCondition self, float value); 16 | 17 | internal static void Load() 18 | { 19 | On.Terraria.Achievements.AchievementCondition.Complete += AchievementCondition_Complete; 20 | //On.Terraria.GameContent.Achievements.CustomFloatCondition. 21 | 22 | //Action, T, V> where T is object type and V is property type 23 | 24 | //var set = new orig_Value(CustomIntCondition_Value_set); 25 | //HookEndpointManager.Add(typeof(CustomFloatCondition).GetProperty("ValidateOutput").GetSetMethod(), set); 26 | //HookEndpointManager.Add(typeof(CustomFloatCondition).GetProperty("Value").GetSetMethod(), (CustomFloatCondition self, float val) => { CustomIntCondition_Value_set(self, val); }); 27 | Action, CustomFloatCondition, float> action = (Action a, CustomFloatCondition self, float b) => CustomFloatCondition_Value_set(a, self, b); 28 | HookEndpointManager.Add(typeof(CustomFloatCondition).GetProperty("Value").GetSetMethod(), action); 29 | //HookEndpointManager.Add(typeof(CustomFloatCondition).GetProperty("Value").GetSetMethod(), (Action, CustomFloatCondition, int>)(Action a, CustomFloatCondition self, int b) => CustomIntCondition_Value_set(self, b)); 30 | 31 | } 32 | 33 | private static void AchievementCondition_Complete(On.Terraria.Achievements.AchievementCondition.orig_Complete orig, Terraria.Achievements.AchievementCondition self) 34 | { 35 | var config = ModContent.GetInstance(); 36 | if (config.DisableAchievements) 37 | return; 38 | orig(self); 39 | } 40 | 41 | //private static Action original_CustomIntCondition_Value_Set; 42 | private static void CustomFloatCondition_Value_set(Action orig, CustomFloatCondition self, float val) 43 | { 44 | var config = ModContent.GetInstance(); 45 | if (config.DisableAchievements) 46 | return; 47 | orig(self, val); 48 | //self.Value = val; 49 | } 50 | } 51 | } 52 | 53 | 54 | //using System; 55 | //using System.Reflection; 56 | //using MonoModExt.Utils; 57 | //using MonoModExt.RuntimeDetour; 58 | 59 | //public static class TestClass 60 | //{ 61 | // public static bool allowAchievements; 62 | 63 | // public static void Test() 64 | // { 65 | // var detour = CreateMethodHook( 66 | // typeof(CustomIntCondition).GetProperty(nameof(CustomIntCondition.Value), BindingFlags.Public | BindingFlags.Instance).SetMethod, 67 | // typeof(TestClass).GetMethod(nameof(CustomIntCondition_Value_set), BindingFlags.NonPublic | BindingFlags.Static), 68 | // out original_CustomIntCondition_Value_Set 69 | // ); 70 | 71 | // //Dispose detour on Mod.Unload() 72 | // } 73 | 74 | // private static NativeDetour CreateMethodHook(MethodInfo srcMethod, MethodInfo destMethod, out TDelegate trampolineDelegate) where TDelegate : Delegate 75 | // { 76 | // var delegateType = typeof(TDelegate); 77 | 78 | // detour = new NativeDetour(srcMethod.GetNativeStart(), destMethod); 79 | // detour.Undo(); 80 | 81 | // var trampoline = detour.GenerateTrampoline(delegateType.GetMethod("Invoke")); 82 | // trampolineDelegate = trampoline.CreateDelegate(delegateType); 83 | 84 | // detour.Apply(); 85 | 86 | // return detour; 87 | // } 88 | 89 | // private static Action original_CustomIntCondition_Value_Set; 90 | // private static void CustomIntCondition_Value_set(int val) 91 | // { 92 | // if (allowAchievements) 93 | // { 94 | // original_CustomIntCondition_Value_Set(val); 95 | // } 96 | // } 97 | //} 98 | */ 99 | -------------------------------------------------------------------------------- /HEROsModServices/CheckTileModificationTool.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.UIKit; 2 | using Microsoft.Xna.Framework; 3 | using Microsoft.Xna.Framework.Graphics; 4 | using Microsoft.Xna.Framework.Input; 5 | using ReLogic.Content; 6 | using System; 7 | using Terraria; 8 | using Terraria.ModLoader; 9 | 10 | namespace HEROsMod.HEROsModServices 11 | { 12 | internal class CheckTileModificationTool : HEROsModService 13 | { 14 | private static bool ListeningForInput = false; 15 | 16 | public CheckTileModificationTool() 17 | { 18 | MultiplayerOnly = true; 19 | this._hotbarIcon = new UIImage(HEROsMod.instance.Assets.Request("Images/tileModification", AssetRequestMode.ImmediateLoad)); 20 | this.HotbarIcon.Tooltip = HEROsMod.HeroText("CheckTileForLastModification"); 21 | this.HotbarIcon.onLeftClick += HotbarIcon_onLeftClick; 22 | this.HasPermissionToUse = true; 23 | } 24 | 25 | private void HotbarIcon_onLeftClick(object sender, EventArgs e) 26 | { 27 | ListeningForInput = !ListeningForInput; 28 | } 29 | 30 | public override void Update() 31 | { 32 | if (ListeningForInput && !Main.gameMenu) 33 | { 34 | if (ModUtils.MouseState.LeftButton == ButtonState.Pressed && ModUtils.PreviousMouseState.LeftButton == ButtonState.Released && !UIKit.UIView.GameMouseOverwritten) 35 | { 36 | Terraria.GameInput.PlayerInput.SetZoom_World(); 37 | Vector2 tileCoords = ModUtils.CursorTileCoords; 38 | Terraria.GameInput.PlayerInput.SetZoom_UI(); 39 | HEROsModNetwork.GeneralMessages.RequestTileModificationCheck(tileCoords); 40 | } 41 | if (ModUtils.MouseState.RightButton == ButtonState.Pressed && ModUtils.PreviousMouseState.RightButton == ButtonState.Released && !UIKit.UIView.GameMouseOverwritten) 42 | { 43 | ListeningForInput = false; 44 | } 45 | UIKit.UIView.OverWriteGameMouseInput(); 46 | } 47 | base.Update(); 48 | } 49 | 50 | public static void DrawBoxOnCursor(SpriteBatch spriteBatch) 51 | { 52 | if (ListeningForInput) 53 | { 54 | Vector2 pos = ModUtils.CursorWorldCoords; 55 | pos.X = (int)pos.X / 16 * 16; 56 | pos.Y = (int)pos.Y / 16 * 16; 57 | ModUtils.DrawBorderedRect(spriteBatch, Color.Blue, ModUtils.CursorTileCoords, new Vector2(1, 1), 2); 58 | } 59 | } 60 | 61 | public override void MyGroupUpdated() 62 | { 63 | this.HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.HasPermission("CheckTiles"); 64 | //base.MyGroupUpdated(); 65 | } 66 | 67 | public override void Destroy() 68 | { 69 | ListeningForInput = false; 70 | base.Destroy(); 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /HEROsModServices/EnemyToggler.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.UIKit; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using ReLogic.Content; 4 | using System; 5 | using Terraria; 6 | using Terraria.ModLoader; 7 | using Terraria.ID; 8 | 9 | namespace HEROsMod.HEROsModServices 10 | { 11 | /// 12 | /// A Service that let's you toggle the enemies on the map 13 | /// 14 | internal class EnemyToggler : HEROsModService 15 | { 16 | public static bool EnemiesAllowed = true; 17 | 18 | public EnemyToggler() 19 | { 20 | this._name = "Enemy Toggler"; 21 | this._hotbarIcon = new UIImage(HEROsMod.instance.Assets.Request("Images/npcIcon", AssetRequestMode.ImmediateLoad)); 22 | this._hotbarIcon.onLeftClick += _hotbarIcon_onLeftClick; 23 | this.HotbarIcon.Tooltip = HEROsMod.HeroText("DisableEnemySpawns"); 24 | this._hotbarIcon.Opacity = 1f; 25 | HEROsModNetwork.GeneralMessages.EnemiesToggledByServer += GeneralMessages_EnemiesToggledByServer; 26 | } 27 | 28 | private void GeneralMessages_EnemiesToggledByServer(bool enemiesCanSpawn) 29 | { 30 | if (enemiesCanSpawn) 31 | { 32 | this._hotbarIcon.Opacity = 1f; 33 | this.HotbarIcon.Tooltip = HEROsMod.HeroText("DisableEnemySpawns"); 34 | } 35 | else 36 | { 37 | this._hotbarIcon.Opacity = .5f; 38 | this.HotbarIcon.Tooltip = HEROsMod.HeroText("EnableEnemySpawns"); 39 | } 40 | } 41 | 42 | public static void ToggleNPCs() 43 | { 44 | if (EnemiesAllowed) 45 | { 46 | ClearNPCs(); 47 | } 48 | EnemiesAllowed = !EnemiesAllowed; 49 | } 50 | 51 | public static void ClearNPCs() 52 | { 53 | for (int i = 0; i < Main.maxNPCs; i++) 54 | { 55 | if (Main.npc[i] != null && !Main.npc[i].townNPC) 56 | { 57 | Main.npc[i].life = 0; 58 | if (Main.netMode == NetmodeID.Server) NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, i, 0f, 0f, 0f, 0); 59 | } 60 | } 61 | } 62 | 63 | private void _hotbarIcon_onLeftClick(object sender, EventArgs e) 64 | { 65 | if (ModUtils.NetworkMode != NetworkMode.None) 66 | { 67 | HEROsModNetwork.GeneralMessages.RequestToggleEnemies(); 68 | } 69 | else 70 | { 71 | ToggleNPCs(); 72 | if (EnemiesAllowed) 73 | { 74 | this._hotbarIcon.Opacity = 1f; 75 | this.HotbarIcon.Tooltip = HEROsMod.HeroText("DisableEnemySpawns"); 76 | } 77 | else 78 | { 79 | this._hotbarIcon.Opacity = .5f; 80 | this.HotbarIcon.Tooltip = HEROsMod.HeroText("EnableEnemySpawns"); 81 | } 82 | if(EnemiesAllowed) 83 | Main.NewText(HEROsMod.HeroText("EnemySpawnsEnabled")); 84 | else 85 | Main.NewText(HEROsMod.HeroText("EnemySpawnsDisabled")); 86 | } 87 | } 88 | 89 | public override void MyGroupUpdated() 90 | { 91 | this.HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.HasPermission("ToggleEnemies"); 92 | //base.MyGroupUpdated(); 93 | } 94 | 95 | public override void Destroy() 96 | { 97 | HEROsModNetwork.GeneralMessages.EnemiesToggledByServer -= GeneralMessages_EnemiesToggledByServer; 98 | EnemiesAllowed = true; 99 | base.Destroy(); 100 | } 101 | } 102 | 103 | public class EnemyTogglerGlobalNPC : GlobalNPC 104 | { 105 | // public override bool Autoload(ref string name) => true; 106 | 107 | public override void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns) 108 | { 109 | if (!EnemyToggler.EnemiesAllowed) 110 | { 111 | spawnRate = 0; 112 | maxSpawns = 0; 113 | } 114 | } 115 | } 116 | } -------------------------------------------------------------------------------- /HEROsModServices/ExtensionMenuService.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.UIKit; 2 | using HEROsMod.UIKit.UIComponents; 3 | using Microsoft.Xna.Framework; 4 | using Microsoft.Xna.Framework.Graphics; 5 | using ReLogic.Content; 6 | using System; 7 | using System.Collections.Generic; 8 | using Terraria; 9 | using Terraria.ModLoader; 10 | 11 | namespace HEROsMod.HEROsModServices 12 | { 13 | internal class ExtensionMenuService : HEROsModService 14 | { 15 | private ExtensionMenuWindow _extensionMenuHotbar; 16 | 17 | private List genericServices; 18 | 19 | public ExtensionMenuService() 20 | { 21 | genericServices = new List(); 22 | 23 | IsHotbar = true; 24 | 25 | this._hotbarIcon = new UIImage(HEROsMod.instance.Assets.Request("Images/extensions", AssetRequestMode.ImmediateLoad)); 26 | this.HotbarIcon.Tooltip = HEROsMod.HeroText("ExtensionTools"); 27 | this.HotbarIcon.onLeftClick += HotbarIcon_onLeftClick; 28 | 29 | _extensionMenuHotbar = new ExtensionMenuWindow(); 30 | _extensionMenuHotbar.HotBarParent = HEROsMod.ServiceHotbar; 31 | _extensionMenuHotbar.Hide(); 32 | this.AddUIView(_extensionMenuHotbar); 33 | 34 | Hotbar = _extensionMenuHotbar; 35 | } 36 | 37 | private void HotbarIcon_onLeftClick(object sender, EventArgs e) 38 | { 39 | bool childAvailable = false; 40 | foreach (var item in genericServices) 41 | { 42 | childAvailable |= item.HasPermissionToUse; 43 | } 44 | if (childAvailable) 45 | { 46 | if (_extensionMenuHotbar.selected) 47 | { 48 | _extensionMenuHotbar.selected = false; 49 | _extensionMenuHotbar.Hide(); 50 | } 51 | else 52 | { 53 | _extensionMenuHotbar.selected = true; 54 | _extensionMenuHotbar.Show(); 55 | } 56 | } 57 | else 58 | { 59 | Main.NewText(HEROsMod.HeroText("NoExtensionsLoadedNote")); 60 | } 61 | } 62 | 63 | public override void MyGroupUpdated() 64 | { 65 | bool childAvailable = false; 66 | foreach (var item in genericServices) 67 | { 68 | item.MyGroupUpdated(); 69 | childAvailable |= item.HasPermissionToUse; 70 | } 71 | HasPermissionToUse = childAvailable; 72 | if (!HasPermissionToUse) 73 | { 74 | _extensionMenuHotbar.Hide(); 75 | } 76 | } 77 | 78 | internal void AddGeneric(GenericExtensionService genericService) 79 | { 80 | genericServices.Add(genericService); 81 | } 82 | } 83 | 84 | internal class ExtensionMenuWindow : UIHotbar 85 | { 86 | public ExtensionMenuWindow() 87 | { 88 | buttonView = new UIView(); 89 | Visible = false; 90 | 91 | Height = 55f; 92 | UpdateWhenOutOfBounds = true; 93 | buttonView.Height = Height; 94 | Anchor = AnchorPosition.Top; 95 | AddChild(buttonView); 96 | Position = new Vector2(Position.X, hiddenPosition); 97 | CenterXAxisToParentCenter(); 98 | float num = this.spacing; 99 | for (int i = 0; i < this.buttonView.children.Count; i++) 100 | { 101 | this.buttonView.children[i].Anchor = AnchorPosition.Left; 102 | this.buttonView.children[i].Position = new Vector2(num, 0f); 103 | this.buttonView.children[i].CenterYAxisToParentCenter(); 104 | this.buttonView.children[i].Visible = true; 105 | num += this.buttonView.children[i].Width + this.spacing; 106 | } 107 | this.Resize(); 108 | } 109 | 110 | public override void RefreshHotbar() 111 | { 112 | base.CenterXAxisToParentCenter(); 113 | float num = this.spacing; 114 | for (int i = 0; i < this.buttonView.children.Count; i++) 115 | { 116 | this.buttonView.children[i].Anchor = AnchorPosition.Left; 117 | this.buttonView.children[i].Position = new Vector2(num, 0f); 118 | this.buttonView.children[i].CenterYAxisToParentCenter(); 119 | this.buttonView.children[i].Visible = true; 120 | num += this.buttonView.children[i].Width + this.spacing; 121 | } 122 | this.Resize(); 123 | } 124 | 125 | public void Resize() 126 | { 127 | float num = this.spacing; 128 | for (int i = 0; i < this.buttonView.children.Count; i++) 129 | { 130 | if (this.buttonView.children[i].Visible) 131 | { 132 | this.buttonView.children[i].X = num; 133 | num += this.buttonView.children[i].Width + this.spacing; 134 | } 135 | } 136 | base.Width = num; 137 | this.buttonView.Width = base.Width; 138 | } 139 | } 140 | } -------------------------------------------------------------------------------- /HEROsModServices/GenericExtensionService.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.UIKit; 2 | using HEROsMod.UIKit.UIComponents; 3 | using Microsoft.Xna.Framework.Graphics; 4 | using ReLogic.Content; 5 | using System; 6 | 7 | namespace HEROsMod.HEROsModServices 8 | { 9 | internal class GenericExtensionService : HEROsModService 10 | { 11 | private Asset texture; 12 | private Action buttonClickedAction; // TODO: need left and right click. Use vanilla UIElement MouseEvent maybe? 13 | private Action groupUpdated; 14 | private Func tooltip; 15 | private string permissionName; 16 | 17 | //public GenericExtensionService(UIHotbar hotbar) 18 | //{ 19 | // _name = "Undefined"; 20 | // IsInHotbar = true; 21 | // HotbarParent = hotbar; 22 | // _hotbarIcon = new UIImage(HEROsMod.instance.GetTexture("Images/spawn")/*Main.itemTexture[69]*/); 23 | // _hotbarIcon.Tooltip = "Set Spawn Point"; 24 | // HotbarIcon.onLeftClick += new EventHandler(button_onLeftClick); 25 | // HotbarIcon.onHover += new EventHandler(button_onHover); 26 | //} 27 | 28 | public GenericExtensionService(ExtensionMenuService extensionMenuService, Asset texture, string permissionName, Action buttonClickedAction, Action groupUpdated, Func tooltip) 29 | { 30 | UIHotbar hotbar = extensionMenuService.Hotbar; 31 | 32 | this.texture = texture; 33 | this.buttonClickedAction = buttonClickedAction; 34 | this.groupUpdated = groupUpdated; 35 | this.tooltip = tooltip; 36 | this.permissionName = permissionName; 37 | 38 | _name = "Undefined"; 39 | IsInHotbar = true; 40 | HotbarParent = hotbar; 41 | _hotbarIcon = new UIImage(this.texture); 42 | _hotbarIcon.Tooltip = "Set Spawn Point"; 43 | HotbarIcon.onLeftClick += new EventHandler(button_onLeftClick); 44 | HotbarIcon.onHover += new EventHandler(button_onHover); 45 | } 46 | 47 | public override void MyGroupUpdated() 48 | { 49 | HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.HasPermission(permissionName); 50 | groupUpdated(HasPermissionToUse); 51 | } 52 | 53 | private void button_onLeftClick(object sender, EventArgs e) 54 | { 55 | buttonClickedAction(); 56 | } 57 | 58 | private void button_onHover(object sender, EventArgs e) 59 | { 60 | HotbarIcon.Tooltip = tooltip(); 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /HEROsModServices/GodModeService.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.UIKit; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using ReLogic.Content; 4 | using System; 5 | using Terraria; 6 | using Terraria.ModLoader; 7 | 8 | namespace HEROsMod.HEROsModServices 9 | { 10 | internal class GodModeService : HEROsModService 11 | { 12 | private delegate void GodModeToggledEvent(bool enabled, bool prevEnabled); 13 | 14 | internal static event Action GodModeCallback; 15 | 16 | private static event GodModeToggledEvent GodModeToggled; 17 | 18 | private static bool _enabled = false; 19 | 20 | internal static bool BuddhaMode = false; // changes the behavior of god mode, not a separate permission. 21 | 22 | public static bool Enabled 23 | { 24 | get { return _enabled; } 25 | set 26 | { 27 | if (GodModeToggled != null) 28 | { 29 | GodModeToggled(value, _enabled); 30 | } 31 | _enabled = value; 32 | } 33 | } 34 | internal static void ClearGodModeCallback() 35 | { 36 | GodModeCallback = null; 37 | } 38 | 39 | internal static void InvokeGodModeCallback() 40 | { 41 | GodModeCallback?.Invoke(Enabled); 42 | } 43 | 44 | public GodModeService() 45 | { 46 | this._hotbarIcon = new UIImage(HEROsMod.instance.Assets.Request("Images/godMode", AssetRequestMode.ImmediateLoad)/*Main.itemTexture[1990]*/); 47 | this.HotbarIcon.Tooltip = HEROsMod.HeroText("ToggleGodMode"); 48 | this.HotbarIcon.onLeftClick += HotbarIcon_onLeftClick; 49 | this.HotbarIcon.onRightClick += HotbarIcon_onRightClick; 50 | GodModeToggled += GodModeService_GodModeToggled; 51 | Enabled = false; 52 | } 53 | 54 | private void HotbarIcon_onRightClick(object sender, EventArgs e) 55 | { 56 | BuddhaMode = !BuddhaMode; 57 | if (BuddhaMode) 58 | { 59 | Main.NewText(HEROsMod.HeroText("BuddhaModeEnabled")); 60 | this._hotbarIcon.Texture = HEROsMod.instance.Assets.Request("Images/buddhaMode", AssetRequestMode.ImmediateLoad); 61 | } 62 | else 63 | { 64 | Main.NewText(HEROsMod.HeroText("BuddhaModeDisabled")); 65 | this._hotbarIcon.Texture = HEROsMod.instance.Assets.Request("Images/godMode", AssetRequestMode.ImmediateLoad); 66 | } 67 | } 68 | 69 | 70 | private void GodModeService_GodModeToggled(bool enabled, bool prevEnabled) 71 | { 72 | if (enabled) 73 | { 74 | if (enabled != prevEnabled) 75 | Main.NewText(HEROsMod.HeroText("GodModeEnabled")); 76 | this.HotbarIcon.Opacity = 1f; 77 | } 78 | else 79 | { 80 | if (enabled != prevEnabled) 81 | Main.NewText(HEROsMod.HeroText("GodModeDisabled")); 82 | this.HotbarIcon.Opacity = .5f; 83 | } 84 | } 85 | 86 | public override void MyGroupUpdated() 87 | { 88 | this.HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.HasPermission("GodMode"); 89 | if (!HasPermissionToUse) 90 | { 91 | Enabled = false; 92 | } 93 | //base.MyGroupUpdated(); 94 | } 95 | 96 | private void HotbarIcon_onLeftClick(object sender, EventArgs e) 97 | { 98 | if (ModUtils.NetworkMode == NetworkMode.None) 99 | { 100 | Enabled = !Enabled; 101 | } 102 | else 103 | { 104 | if (!Enabled) 105 | { 106 | HEROsModNetwork.GeneralMessages.RequestGodMode(); 107 | } 108 | else 109 | { 110 | Enabled = false; 111 | } 112 | } 113 | } 114 | 115 | public override void Destroy() 116 | { 117 | Enabled = false; 118 | GodModeToggled -= GodModeService_GodModeToggled; 119 | base.Destroy(); 120 | } 121 | } 122 | } -------------------------------------------------------------------------------- /HEROsModServices/HEROsModService.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.UIKit; 2 | using HEROsMod.UIKit.UIComponents; 3 | using Microsoft.Xna.Framework.Graphics; 4 | using System.Collections.Generic; 5 | 6 | namespace HEROsMod.HEROsModServices 7 | { 8 | internal class HEROsModService 9 | { 10 | private List _UIViews = new List(); 11 | 12 | /// 13 | /// Name of the Service 14 | /// 15 | protected string _name; 16 | 17 | public string Name 18 | { 19 | get { return _name; } 20 | } 21 | 22 | /// 23 | /// Icon that gets used if the service is added to the ServiceHotbar 24 | /// 25 | protected UIImage _hotbarIcon; 26 | 27 | public UIImage HotbarIcon 28 | { 29 | get { return _hotbarIcon; } 30 | } 31 | 32 | public bool IsInHotbar { get; set; } 33 | public UIHotbar HotbarParent { get; set; } 34 | 35 | public bool IsHotbar { get; set; } 36 | public UIHotbar Hotbar { get; set; } 37 | 38 | public bool HasPermissionToUse { get; set; } 39 | public bool MultiplayerOnly { get; set; } 40 | 41 | // Network mode unknown at load time. 42 | public HEROsModService() 43 | { 44 | // if(ModUtils.NetworkMode == NetworkMode.None) 45 | // { 46 | HasPermissionToUse = true; 47 | ModUtils.DebugText("Permission granted: " + Name); 48 | // } 49 | // else 50 | // { 51 | // HasPermissionToUse = false; 52 | //ErrorLogger.Log("Permission not granted"); 53 | // } 54 | } 55 | 56 | /// 57 | /// Services logic is done here. Called once per Update call from the Main thread 58 | /// 59 | public virtual void Update() 60 | { 61 | } 62 | 63 | /// 64 | /// This method must be called before the Service is desposed. 65 | /// 66 | public virtual void Destroy() 67 | { 68 | RemoveAllUIViews(); 69 | } 70 | 71 | /// 72 | /// Add a UIView that belongs to this Service 73 | /// 74 | /// View to be added 75 | public virtual void AddUIView(UIView view) 76 | { 77 | _UIViews.Add(view); 78 | MasterView.gameScreen.AddChild(view); 79 | } 80 | 81 | /// 82 | /// Remove a UIView from this Service 83 | /// 84 | /// View to be removed 85 | public virtual void RemoveUIView(UIView view) 86 | { 87 | _UIViews.Remove(view); 88 | MasterView.gameScreen.RemoveChild(view); 89 | } 90 | 91 | /// 92 | /// Remove all UIViews from this Service 93 | /// 94 | public virtual void RemoveAllUIViews() 95 | { 96 | while (this._UIViews.Count > 0) 97 | { 98 | RemoveUIView(this._UIViews[0]); 99 | } 100 | } 101 | 102 | public virtual void MyGroupUpdated() 103 | { 104 | } 105 | 106 | public virtual void Draw(SpriteBatch spriteBatch) 107 | { 108 | } 109 | 110 | /// 111 | /// Unload during mod unload. 112 | /// 113 | public virtual void Unload() 114 | { 115 | } 116 | 117 | /// 118 | /// SetupContent after all other mod content is loaded. 119 | /// 120 | public virtual void PostSetupContent() 121 | { 122 | } 123 | } 124 | } -------------------------------------------------------------------------------- /HEROsModServices/HardmodeEnemyToggler.cs: -------------------------------------------------------------------------------- 1 | //using System; 2 | //using System.Collections.Generic; 3 | //using System.Linq; 4 | //using System.Text; 5 | //using HEROsModMod.UIKit; 6 | 7 | //using Terraria; 8 | //using HEROsModMod.UIKit.UIComponents; 9 | 10 | //namespace HEROsModMod.HEROsModServices 11 | //{ 12 | // class HardmodeEnemyToggler : HEROsModService 13 | // { 14 | // public HardmodeEnemyToggler(UIHotbar hotbar) 15 | // { 16 | // IsInHotbar = true; 17 | // HotbarParent = hotbar; 18 | // this._name = "Hardmode Enemy Toggler"; 19 | // this._hotbarIcon = new UIImage(Main.itemTexture[1991]); 20 | // this._hotbarIcon.Tooltip = "Toggle Hardmode Enemies"; 21 | // this._hotbarIcon.onLeftClick += _hotbarIcon_onLeftClick; 22 | // } 23 | 24 | // public override void MyGroupUpdated() 25 | // { 26 | // this.HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.HasPermission("ToggleHardmodeEnemies"); 27 | // base.MyGroupUpdated(); 28 | // } 29 | 30 | // void _hotbarIcon_onLeftClick(object sender, EventArgs e) 31 | // { 32 | // if (ModUtils.NetworkMode == NetworkMode.None) 33 | // { 34 | // ToggleHardModeEnemies(); 35 | // } 36 | // else 37 | // { 38 | // HEROsModNetwork.GeneralMessages.RequestToggleHardmodeEnemies(); 39 | // } 40 | // } 41 | 42 | // public static void ToggleHardModeEnemies() 43 | // { 44 | // Main.hardMode = !Main.hardMode; 45 | // EnemyToggler.ClearNPCs(); 46 | // if (ModUtils.NetworkMode == NetworkMode.Server) 47 | // { 48 | // NetMessage.SendData(7); 49 | // } 50 | // } 51 | // } 52 | //} 53 | -------------------------------------------------------------------------------- /HEROsModServices/InfiniteReach.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.UIKit; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using ReLogic.Content; 4 | using System; 5 | using Terraria; 6 | using Terraria.Localization; 7 | using Terraria.ModLoader; 8 | using Terraria.ID; 9 | 10 | namespace HEROsMod.HEROsModServices 11 | { 12 | internal class InfiniteReach : HEROsModService 13 | { 14 | /* =========Hooks============ 15 | * This feature requires Multiple hooks in Player.cs 16 | * Hook 1: 17 | * At the end of the Reset Effects Method and after 18 | * Player.tileRangeX = 5; 19 | * Player.tileRangeY = 4; 20 | * Add 21 | * if (HEROsMod.ModUtils.InfiniteReach) 22 | { 23 | Player.tileRangeX = int.MaxValue / 32 - 20; 24 | Player.tileRangeY = int.MaxValue / 32 - 20; 25 | } 26 | * Hook 2: 27 | * 28 | */ 29 | public static bool Enabled { get; set; } 30 | 31 | public InfiniteReach() 32 | { 33 | Enabled = false; 34 | this._name = "Infinite Reach"; 35 | this._hotbarIcon = new UIImage(HEROsMod.instance.Assets.Request("Images/infiniteReach", AssetRequestMode.ImmediateLoad)/*Main.itemTexture[407]*/); 36 | this._hotbarIcon.onLeftClick += _hotbarIcon_onLeftClick; 37 | this.HotbarIcon.Tooltip = HEROsMod.HeroText("EnableInfiniteReach"); 38 | Disable(); 39 | } 40 | 41 | private void Enable() 42 | { 43 | this._hotbarIcon.Opacity = 1f; 44 | Enabled = true; 45 | this.HotbarIcon.Tooltip = HEROsMod.HeroText("DisableInfiniteReach"); 46 | } 47 | 48 | private void Disable() 49 | { 50 | this._hotbarIcon.Opacity = .5f; 51 | Enabled = false; 52 | this.HotbarIcon.Tooltip = HEROsMod.HeroText("EnableInfiniteReach"); 53 | } 54 | 55 | private void _hotbarIcon_onLeftClick(object sender, EventArgs e) 56 | { 57 | if (Enabled) 58 | { 59 | Disable(); 60 | } 61 | else 62 | { 63 | Enable(); 64 | } 65 | } 66 | 67 | //public static void TileRangeHook() 68 | //{ 69 | // if (Enabled) 70 | // { 71 | // Player.tileRangeX = Main.maxTilesX; 72 | // Player.tileRangeY = Main.maxTilesX; 73 | // } 74 | //} 75 | 76 | public override void Destroy() 77 | { 78 | Disable(); 79 | base.Destroy(); 80 | } 81 | 82 | public override void MyGroupUpdated() 83 | { 84 | this.HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.HasPermission("InfiniteReach"); 85 | if (!HasPermissionToUse) 86 | { 87 | Disable(); 88 | } 89 | //base.MyGroupUpdated(); 90 | } 91 | 92 | public override void Update() 93 | { 94 | base.Update(); 95 | 96 | Player player = Main.player[Main.myPlayer]; 97 | if (Enabled) 98 | { 99 | //if (Main.SmartCursorEnabled) 100 | //{ 101 | // Main.SmartCursorEnabled = false; 102 | // Main.NewText("Smart Cursor automatically disabled in infinte reach mode."); 103 | //} 104 | 105 | // Works with: Place tiles, walls. Axe, Hammer, Pick. 106 | Item selected = player.inventory[player.selectedItem]; 107 | if (selected.createTile >= TileID.Dirt || selected.createWall >= 0 || selected.pick > 0 || selected.axe > 0 || selected.hammer > 0) 108 | { 109 | // TODO, hammering tile destorys walls too?? 110 | player.itemTime = 0; 111 | } 112 | } 113 | } 114 | } 115 | 116 | public class InfiniteReachModPlayer : ModPlayer 117 | { 118 | // public override bool Autoload(ref string name) 119 | // { 120 | // return true; 121 | // } 122 | 123 | public override void ResetEffects() 124 | { 125 | if (Player.whoAmI == Main.myPlayer) 126 | { 127 | if (InfiniteReach.Enabled) 128 | { 129 | Player.tileRangeX = int.MaxValue / 32 - 20; 130 | Player.tileRangeY = int.MaxValue / 32 - 20; 131 | 132 | if (Main.SmartCursorWanted) // Check out SmartCursorIsUsed as well. 133 | { 134 | Main.SmartCursorWanted_Mouse = false; 135 | Main.SmartCursorWanted_GamePad = false; 136 | //Main.SmartCursorWanted = false; 137 | Main.NewText(HEROsMod.HeroText("SmartCursorAutomaticallyDisabledInfinteReachMod")); 138 | } 139 | } 140 | } 141 | } 142 | 143 | //public override void PostUpdate() 144 | //{ 145 | // if (player.whoAmI == Main.myPlayer) 146 | // { 147 | // if (InfiniteReach.Enabled) 148 | // { 149 | // if (player.inventory[player.selectedItem].createTile >= 0 || player.inventory[player.selectedItem].createWall >= 0) 150 | // { 151 | // player.itemTime = 0; 152 | // } 153 | // } 154 | // } 155 | //} 156 | } 157 | } -------------------------------------------------------------------------------- /HEROsModServices/ItemBanner.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.UIKit; 2 | using HEROsMod.UIKit.UIComponents; 3 | using Microsoft.Xna.Framework; 4 | using Microsoft.Xna.Framework.Graphics; 5 | using ReLogic.Content; 6 | using System; 7 | using System.Linq; 8 | using Terraria; 9 | using Terraria.ID; 10 | using Terraria.ModLoader; 11 | 12 | namespace HEROsMod.HEROsModServices 13 | { 14 | internal class ItemBanner : HEROsModService 15 | { 16 | public static bool ItemsBanned { get; set; } 17 | 18 | public static int[] bannedProjectiles = new int[] 19 | { 20 | ProjectileID.RocketII, 21 | ProjectileID.RocketIV, 22 | ProjectileID.Bomb, 23 | ProjectileID.StickyBomb, 24 | ProjectileID.BombFish, 25 | ProjectileID.Dynamite, 26 | ProjectileID.StickyDynamite, 27 | ProjectileID.BouncyDynamite, 28 | }; 29 | 30 | public ItemBanner(UIHotbar hotbar) 31 | { 32 | IsInHotbar = true; 33 | HotbarParent = hotbar; 34 | MultiplayerOnly = true; 35 | this._name = "Item Banner"; 36 | this._hotbarIcon = new UIImage(HEROsMod.instance.Assets.Request("Images/explosives", AssetRequestMode.ImmediateLoad)); 37 | this._hotbarIcon.Tooltip = HEROsMod.HeroText("BanDestructiveExplosives"); 38 | this._hotbarIcon.onLeftClick += _hotbarIcon_onLeftClick; 39 | HEROsModNetwork.GeneralMessages.ItemBannerToggleByServer += GeneralMessages_BannedItemsToggleByServer; 40 | } 41 | 42 | private void _hotbarIcon_onLeftClick(object sender, EventArgs e) 43 | { 44 | if (ModUtils.NetworkMode == NetworkMode.Client) 45 | { 46 | HEROsModNetwork.GeneralMessages.RequestToggleBannedItems(); 47 | } 48 | } 49 | 50 | public override void MyGroupUpdated() 51 | { 52 | this.HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.HasPermission("ToggleBannedItems"); 53 | //base.MyGroupUpdated(); 54 | } 55 | 56 | public void GeneralMessages_BannedItemsToggleByServer(bool itemsbanned) 57 | { 58 | if (itemsbanned) 59 | { 60 | this._hotbarIcon.Opacity = .5f; 61 | this.HotbarIcon.Tooltip = HEROsMod.HeroText("UnbanDestructiveExplosives"); 62 | } 63 | else 64 | { 65 | this._hotbarIcon.Opacity = 1f; 66 | this.HotbarIcon.Tooltip = HEROsMod.HeroText("BanDestructiveExplosives"); 67 | } 68 | ItemsBanned = itemsbanned; 69 | } 70 | } 71 | 72 | internal class ItemBannerGlobalProjectile : GlobalProjectile 73 | { 74 | // public override bool Autoload(ref string name) => true; 75 | 76 | // Is only called on server?? 77 | public override bool PreAI(Projectile projectile) 78 | { 79 | if (ItemBanner.ItemsBanned) 80 | { 81 | if (ItemBanner.bannedProjectiles.Contains(projectile.type)) 82 | { 83 | if (!Main.dedServ) 84 | { 85 | //Projectile newProj = new Projectile(); 86 | //newProj.SetDefaults(type); 87 | Main.NewText(string.Format(HEROsMod.HeroText("ProjectileIsBannerdOnTheServer"), projectile.Name), Color.Red.R, Color.Red.G, Color.Red.B); 88 | } 89 | //ErrorLogger.Log(Main.dedServ + " Item Banned"); 90 | projectile.active = false; 91 | return false; 92 | } 93 | } 94 | return base.PreAI(projectile); 95 | } 96 | } 97 | } -------------------------------------------------------------------------------- /HEROsModServices/ItemBrowser.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.UIKit; 2 | using Microsoft.Xna.Framework; 3 | using Microsoft.Xna.Framework.Graphics; 4 | using ReLogic.Content; 5 | using System; 6 | using Terraria; 7 | using Terraria.ModLoader; 8 | 9 | namespace HEROsMod.HEROsModServices 10 | { 11 | internal class ItemBrowser : HEROsModService 12 | { 13 | private UIKit.UIComponents.ItemBrowser _itemBrowserWindow; 14 | 15 | public ItemBrowser() 16 | { 17 | this._name = "Item Browser"; 18 | this._hotbarIcon = new UIImage(HEROsMod.instance.Assets.Request("Images/items", AssetRequestMode.ImmediateLoad)); 19 | this.HotbarIcon.onLeftClick += _hotbarIcon_onLeftClick; 20 | this.HotbarIcon.Tooltip = HEROsMod.HeroText("ItemBrowser"); 21 | 22 | _itemBrowserWindow = new UIKit.UIComponents.ItemBrowser(); 23 | _itemBrowserWindow.CenterToParent(); 24 | _itemBrowserWindow.Position -= new Vector2(_itemBrowserWindow.Width / 2, (_itemBrowserWindow.Height / 2) + 30); 25 | this.AddUIView(_itemBrowserWindow); 26 | } 27 | 28 | private void _hotbarIcon_onLeftClick(object sender, EventArgs e) 29 | { 30 | // Toggle item browser window 31 | _itemBrowserWindow.Visible = !_itemBrowserWindow.Visible; 32 | // If browser window is visible, open the player inventory 33 | // Mouse items do no work unless the player inventory is open 34 | if (_itemBrowserWindow.Visible) 35 | { 36 | if (!UIKit.UIComponents.ItemBrowser.CategoriesLoaded) 37 | { 38 | ModUtils.DebugText("_hotbarIcon_onLeftClick calling ParseList2"); 39 | 40 | UIKit.UIComponents.ItemBrowser.ParseList2(); 41 | _itemBrowserWindow.SelectedCategory = null; 42 | } 43 | Main.playerInventory = true; 44 | _itemBrowserWindow.SearchBox.Focus(); 45 | } 46 | } 47 | 48 | public override void MyGroupUpdated() 49 | { 50 | this.HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.HasPermission("ItemBrowser"); 51 | if (!HasPermissionToUse) 52 | { 53 | _itemBrowserWindow.Visible = false; 54 | } 55 | //base.MyGroupUpdated(); 56 | } 57 | 58 | public override void Unload() 59 | { 60 | global::HEROsMod.UIKit.UIComponents.ItemBrowser.Unload(); 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /HEROsModServices/ItemClearer.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.UIKit; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using ReLogic.Content; 4 | using System; 5 | using Terraria; 6 | using Terraria.ModLoader; 7 | 8 | namespace HEROsMod.HEROsModServices 9 | { 10 | /// 11 | /// A Service that clears all items on the ground 12 | /// 13 | internal class ItemClearer : HEROsModService 14 | { 15 | public ItemClearer() 16 | { 17 | this._name = "Item Clearer"; 18 | this._hotbarIcon = new UIImage(HEROsMod.instance.Assets.Request("Images/canIcon", AssetRequestMode.ImmediateLoad)); 19 | this._hotbarIcon.onLeftClick += _hotbarIcon_onLeftClick; 20 | this.HotbarIcon.Tooltip = HEROsMod.HeroText("ClearItemsOnGround"); 21 | } 22 | 23 | private void _hotbarIcon_onLeftClick(object sender, EventArgs e) 24 | { 25 | //ClearItems 26 | if (ModUtils.NetworkMode == NetworkMode.None) 27 | { 28 | for (int i = 0; i < Main.maxItems; i++) 29 | { 30 | Main.item[i].active = false; 31 | } 32 | Main.NewText(HEROsMod.HeroText("ItemsOnTheGroundWereCleared")); 33 | } 34 | else 35 | { 36 | HEROsModNetwork.GeneralMessages.RequestClearGroundItems(); 37 | } 38 | } 39 | 40 | public override void MyGroupUpdated() 41 | { 42 | this.HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.HasPermission("ClearItems"); 43 | //base.MyGroupUpdated(); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /HEROsModServices/LightHack.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.UIKit; 2 | using HEROsMod.UIKit.UIComponents; 3 | using Microsoft.Xna.Framework; 4 | using Microsoft.Xna.Framework.Graphics; 5 | using ReLogic.Content; 6 | using System; 7 | using Terraria; 8 | using Terraria.ModLoader; 9 | 10 | namespace HEROsMod.HEROsModServices 11 | { 12 | /// 13 | /// A service that hacks the lighting values for the player 14 | /// 15 | class LightHack : HEROsModService 16 | { 17 | internal static int LightStrength; 18 | internal static float[] LightStrengthValues = new float[] { 0, .25f, .5f, 1f }; 19 | private static string[] LightStrengthStrings = new string[] { HEROsMod.HeroText("LightHackDisabled"), HEROsMod.HeroText("LightHack25%"), HEROsMod.HeroText("LightHack50%"), HEROsMod.HeroText("LightHack100%") }; 20 | 21 | public LightHack(UIHotbar hotbar) 22 | { 23 | IsInHotbar = true; 24 | HotbarParent = hotbar; 25 | this._name = "Light Hack"; 26 | this._hotbarIcon = new UIImage(HEROsMod.instance.Assets.Request("Images/lighthack", AssetRequestMode.ImmediateLoad)); 27 | this._hotbarIcon.onLeftClick += (s, e) => 28 | { 29 | buttonLogic(true); 30 | }; 31 | this._hotbarIcon.onRightClick += (s, e) => 32 | { 33 | buttonLogic(false); 34 | }; 35 | this.HotbarIcon.Tooltip = LightStrengthStrings[LightStrength]; 36 | _hotbarIcon.Opacity = 0.5f; 37 | } 38 | 39 | public override void MyGroupUpdated() 40 | { 41 | this.HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.HasPermission("LightHack"); 42 | } 43 | 44 | public void buttonLogic(bool leftMouse) 45 | { 46 | LightStrength = leftMouse ? (LightStrength + 1) % LightStrengthStrings.Length : (LightStrength + LightStrengthStrings.Length - 1) % LightStrengthStrings.Length; 47 | HotbarIcon.Tooltip = LightStrengthStrings[LightStrength]; 48 | _hotbarIcon.Opacity = (LightStrengthValues[LightStrength] + 1f) / 2; 49 | } 50 | } 51 | 52 | public class LightHackGlobalWall : GlobalWall 53 | { 54 | public override void ModifyLight(int i, int j, int type, ref float r, ref float g, ref float b) 55 | { 56 | if (LightHack.LightStrength > 0) 57 | { 58 | r = MathHelper.Clamp(r + LightHack.LightStrengthValues[LightHack.LightStrength], 0, 1); 59 | g = MathHelper.Clamp(g + LightHack.LightStrengthValues[LightHack.LightStrength], 0, 1); 60 | b = MathHelper.Clamp(b + LightHack.LightStrengthValues[LightHack.LightStrength], 0, 1); 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /HEROsModServices/MapRevealer.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.UIKit; 2 | using HEROsMod.UIKit.UIComponents; 3 | using Microsoft.Xna.Framework; 4 | using Microsoft.Xna.Framework.Graphics; 5 | using ReLogic.Content; 6 | using System; 7 | using Terraria; 8 | using Terraria.ModLoader; 9 | using Terraria.ID; 10 | 11 | namespace HEROsMod.HEROsModServices 12 | { 13 | /// 14 | /// A service that reveals the map for the player 15 | /// 16 | internal class MapRevealer : HEROsModService 17 | { 18 | // TODO, is this how I want to do this? 19 | public static MapRevealer instance; 20 | 21 | public MapRevealer(UIHotbar hotbar) 22 | { 23 | IsInHotbar = true; 24 | HotbarParent = hotbar; 25 | this._name = "Map Revealer"; 26 | this._hotbarIcon = new UIImage(HEROsMod.instance.Assets.Request("Images/map", AssetRequestMode.ImmediateLoad)/*ModUtils.RevealMapTexture*/); 27 | this._hotbarIcon.onLeftClick += _hotbarIcon_onLeftClick; 28 | this.HotbarIcon.Tooltip = HEROsMod.HeroText("RevealMap"); 29 | instance = this; 30 | } 31 | 32 | public override void MyGroupUpdated() 33 | { 34 | this.HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.HasPermission("RevealMap"); 35 | //base.MyGroupUpdated(); 36 | } 37 | 38 | private void _hotbarIcon_onLeftClick(object sender, EventArgs e) 39 | { 40 | if (Main.netMode != NetmodeID.MultiplayerClient) 41 | { 42 | RevealWholeMap(); 43 | } 44 | else 45 | { 46 | Point center = Main.player[Main.myPlayer].Center.ToTileCoordinates(); 47 | 48 | Main.NewText("In multiplayer, this tool will only reveal loaded chunks of the world"); 49 | for (int i = 0; i < Main.maxTilesX; i++) 50 | { 51 | for (int j = 0; j < Main.maxTilesY; j++) 52 | { 53 | if (WorldGen.InWorld(i, j) && Main.sectionManager.TileLoaded(i, j)) 54 | Main.Map.Update(i, j, 255); 55 | } 56 | } 57 | Main.refreshMap = true; 58 | } 59 | } 60 | 61 | public static int MapRevealSize = 300; 62 | 63 | public static void RevealAroundPoint(int x, int y) 64 | { 65 | for (int i = x - MapRevealSize / 2; i < x + MapRevealSize / 2; i++) 66 | { 67 | for (int j = y - MapRevealSize / 2; j < y + MapRevealSize / 2; j++) 68 | { 69 | if (WorldGen.InWorld(i, j) && Main.sectionManager.TileLoaded(i, j)) 70 | Main.Map.Update(i, j, 255); 71 | } 72 | } 73 | Main.refreshMap = true; 74 | } 75 | 76 | public static void RevealWholeMap() 77 | { 78 | for (int i = 0; i < Main.maxTilesX; i++) 79 | { 80 | for (int j = 0; j < Main.maxTilesY; j++) 81 | { 82 | if (WorldGen.InWorld(i, j)) 83 | Main.Map.Update(i, j, 255); 84 | } 85 | } 86 | Main.refreshMap = true; 87 | } 88 | 89 | public void PostDrawFullScreenMap() 90 | { 91 | if (Main.mapFullscreen && HasPermissionToUse) 92 | { 93 | if (Main.mouseRight && Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftControl)) 94 | { 95 | int mapWidth = Main.maxTilesX * 16; 96 | int mapHeight = Main.maxTilesY * 16; 97 | Vector2 cursorPosition = new Vector2(Main.mouseX, Main.mouseY); 98 | 99 | cursorPosition.X -= Main.screenWidth / 2; 100 | cursorPosition.Y -= Main.screenHeight / 2; 101 | 102 | Vector2 mapPosition = Main.mapFullscreenPos; 103 | Vector2 cursorWorldPosition = mapPosition; 104 | 105 | cursorPosition /= 16; 106 | cursorPosition *= 16 / Main.mapFullscreenScale; 107 | cursorWorldPosition += cursorPosition; 108 | //cursorWorldPosition *= 16; 109 | 110 | RevealAroundPoint((int)cursorWorldPosition.X, (int)cursorWorldPosition.Y); 111 | } 112 | } 113 | } 114 | } 115 | } -------------------------------------------------------------------------------- /HEROsModServices/NPCSpawner.cs: -------------------------------------------------------------------------------- 1 | //using System; 2 | //using System.Collections.Generic; 3 | //using System.Linq; 4 | //using System.Text; 5 | //using HEROsModMod.UIKit; 6 | 7 | //using Terraria; 8 | 9 | //namespace HEROsModMod.HEROsModServices 10 | //{ 11 | // class NPCSpawner : HEROsModService 12 | // { 13 | // NPCSpawnerWindow npcSpawnWindow; 14 | // public NPCSpawner() 15 | // { 16 | // this._name = "NPC Spawner"; 17 | // this._hotbarIcon = new UIImage(Main.npcHeadTexture[2]); 18 | // this._hotbarIcon.onLeftClick += _hotbarIcon_onLeftClick; 19 | // this.HotbarIcon.Tooltip = "Spawn NPC"; 20 | 21 | // npcSpawnWindow = new NPCSpawnerWindow(); 22 | // HEROsMod.ServiceHotbar.AddChild(npcSpawnWindow); 23 | // } 24 | 25 | // void _hotbarIcon_onLeftClick(object sender, EventArgs e) 26 | // { 27 | // npcSpawnWindow.Visible = !npcSpawnWindow.Visible; 28 | // if (npcSpawnWindow.Visible) 29 | // { 30 | // npcSpawnWindow.X = HEROsMod.ServiceHotbar.Width / 2 - npcSpawnWindow.Width / 2; 31 | // npcSpawnWindow.Y = -npcSpawnWindow.Height; 32 | // } 33 | // } 34 | 35 | // public override void MyGroupUpdated() 36 | // { 37 | // this.HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.HasPermission("SpawnNPCs"); 38 | // base.MyGroupUpdated(); 39 | // } 40 | 41 | // public override void Destroy() 42 | // { 43 | // HEROsMod.ServiceHotbar.RemoveChild(npcSpawnWindow); 44 | // base.Destroy(); 45 | // } 46 | // } 47 | 48 | // class NPCSpawnerWindow : UIWindow 49 | // { 50 | // static float spacing = 8f; 51 | // static int[] npcIds = new int[] { 22, 17, 18, 38, 20, 19, 54, 124, 107, 108, 142, 160, 178, 207, 208, 209, 227, 228, 229, 353, 368, 369 }; 52 | 53 | // public NPCSpawnerWindow() 54 | // { 55 | // Height = 55; 56 | // UpdateWhenOutOfBounds = true; 57 | 58 | // for (int i = 1; i < Main.npcHeadTexture.Length; i++) 59 | // { 60 | // NPC npc = new NPC(); 61 | // npc.SetDefaults(npcIds[i - 1]); 62 | // UIImage image = new UIImage(Main.npcHeadTexture[i]); 63 | // image.Tooltip = npc.name; 64 | // image.Tag = npcIds[i - 1]; 65 | // image.onLeftClick += image_onLeftClick; 66 | // AddChild(image); 67 | // } 68 | 69 | // float xPos = spacing; 70 | // for (int i = 0; i < children.Count; i++) 71 | // { 72 | // if (children[i].Visible) 73 | // { 74 | // children[i].X = xPos; 75 | // xPos += children[i].Width + spacing; 76 | // children[i].Y = Height / 2 - children[i].Height / 2; 77 | // } 78 | // } 79 | // Width = xPos; 80 | // } 81 | 82 | // void image_onLeftClick(object sender, EventArgs e) 83 | // { 84 | 85 | // UIImage image = (UIImage)sender; 86 | // int npcID = (int)image.Tag; 87 | // bool npcFound = false; 88 | // if (Main.netMode == 1) 89 | // { 90 | // HEROsModNetwork.GeneralMessages.RequestSpawnTownNPC(npcID); 91 | // return; 92 | // } 93 | // Player p = Main.player[Main.myPlayer]; 94 | // for (int i = 0; i < Main.npc.Length; i++) 95 | // { 96 | // NPC n = Main.npc[i]; 97 | // if (n.type == npcID) 98 | // { 99 | // n.position = p.position; 100 | // npcFound = true; 101 | // break; 102 | // } 103 | // } 104 | // if (!npcFound) NPC.NewNPC((int)p.position.X, (int)p.position.Y, npcID); 105 | // } 106 | 107 | // public override void Update() 108 | // { 109 | // if (this.Visible) 110 | // { 111 | // if (!MouseInside) 112 | // { 113 | // int mx = Main.mouseX; 114 | // int my = Main.mouseY; 115 | // float right = DrawPosition.X + Width; 116 | // float left = DrawPosition.X; 117 | // float top = DrawPosition.Y; 118 | // float bottom = DrawPosition.Y + Height; 119 | // float dist = 75f; 120 | // bool outsideBounds = (mx > right && mx - right > dist) || 121 | // (mx < left && left - mx > dist) || 122 | // (my > bottom && my - bottom > dist) || 123 | // (my < top && top - my > dist); 124 | // if ((UIKit.UIView.MouseLeftButton && !MouseInside) || outsideBounds) this.Visible = false; 125 | // } 126 | // } 127 | // base.Update(); 128 | // } 129 | 130 | // } 131 | //} 132 | -------------------------------------------------------------------------------- /HEROsModServices/PSAService.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Net; 5 | 6 | using Terraria; 7 | using Terraria.ModLoader; 8 | 9 | namespace HEROsMod.HEROsModServices 10 | { 11 | // Gets a message everytime log in. 12 | internal class PSAService : HEROsModService 13 | { 14 | private static string psaUrl = "http://javid.ddns.net/tModLoader/herosmod/psa.php"; 15 | private bool psaRequested = false; 16 | 17 | public PSAService() 18 | { 19 | //GetPSA(); 20 | } 21 | 22 | public override void Update() 23 | { 24 | if (!psaRequested) 25 | { 26 | psaRequested = true; 27 | GetPSA(); 28 | } 29 | } 30 | 31 | private static void GetPSA() 32 | { 33 | //WebRequest.DefaultWebProxy = null; 34 | try 35 | { 36 | using (WebClient client = new WebClient()) 37 | { 38 | client.DownloadStringCompleted += ProcessPSA; 39 | client.DownloadStringAsync(new Uri(psaUrl 40 | + "?tmodversion=" + BuildInfo.tMLVersion.ToString() 41 | + "&version=" + HEROsMod.instance.Version.ToString() 42 | + "&platform=" + ModLoader.CompressedPlatformRepresentation 43 | + "&steamid64=" + ModUtils.SteamID 44 | )); 45 | } 46 | } 47 | catch { } 48 | } 49 | 50 | private static void ProcessPSA(Object sender, DownloadStringCompletedEventArgs e) 51 | { 52 | if (e.Error != null) 53 | return; 54 | ModUtils.DebugText("Received from PSA: " + e.Result); 55 | PSAResponse r = JsonConvert.DeserializeObject(e.Result); 56 | if (r.msgbox != null) 57 | { 58 | foreach (var msg in r.msgbox) 59 | { 60 | UIKit.MasterView.AddChildToMaster(new UIKit.UIMessageBox(msg)); 61 | } 62 | } 63 | if (r.psa != null) 64 | { 65 | foreach (var psa in r.psa) 66 | { 67 | Main.NewText(psa, 255, 241, 85); 68 | } 69 | } 70 | } 71 | } 72 | 73 | internal class PSAResponse 74 | { 75 | #pragma warning disable 0649 76 | public List psa; 77 | public List msgbox; 78 | #pragma warning restore 0649 79 | } 80 | } -------------------------------------------------------------------------------- /HEROsModServices/SelectionTool.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using Microsoft.Xna.Framework.Input; 4 | 5 | using Terraria; 6 | 7 | namespace HEROsMod.HEROsModServices 8 | { 9 | internal class SelectionTool 10 | { 11 | private static bool _dragging = false; 12 | private static Vector2 _anchor = Vector2.Zero; 13 | public static bool ListeningForInput { get; set; } 14 | public static bool Visible { get; set; } 15 | public static int X { get; set; } 16 | public static int Y { get; set; } 17 | 18 | public static Vector2 Position 19 | { 20 | get { return new Vector2(X, Y); } 21 | set 22 | { 23 | X = (int)value.X; 24 | Y = (int)value.Y; 25 | } 26 | } 27 | 28 | public static int Width { get; set; } 29 | public static int Height { get; set; } 30 | 31 | public static Vector2 Size 32 | { 33 | get { return new Vector2(Width, Height); } 34 | set 35 | { 36 | Width = (int)value.X; 37 | Height = (int)value.Y; 38 | } 39 | } 40 | 41 | public static void Init() 42 | { 43 | Visible = true; 44 | ListeningForInput = false; 45 | } 46 | 47 | public static void Reset() 48 | { 49 | X = 0; 50 | Y = 0; 51 | Width = 0; 52 | Height = 0; 53 | ListeningForInput = false; 54 | Visible = false; 55 | } 56 | 57 | public static void SetPositionWithCursorPosition() 58 | { 59 | } 60 | 61 | public static void Update() 62 | { 63 | if (ListeningForInput && !Main.gameMenu) 64 | { 65 | Terraria.GameInput.PlayerInput.SetZoom_World(); 66 | Vector2 tileCoords = ModUtils.CursorTileCoords; 67 | Terraria.GameInput.PlayerInput.SetZoom_UI(); 68 | if (ModUtils.MouseState.LeftButton == ButtonState.Pressed && ModUtils.PreviousMouseState.LeftButton == ButtonState.Released && !UIKit.UIView.GameMouseOverwritten) 69 | { 70 | _dragging = true; 71 | Position = tileCoords; 72 | _anchor = Position; 73 | } 74 | else if (_dragging && ModUtils.MouseState.LeftButton == ButtonState.Pressed) 75 | { 76 | Size = tileCoords - _anchor; 77 | if (Width < 0) 78 | { 79 | Width = -Width; 80 | X = (int)_anchor.X - Width; 81 | } 82 | if (Height < 0) 83 | { 84 | Height = -Height; 85 | Y = (int)_anchor.Y - Height; 86 | } 87 | Width++; 88 | Height++; 89 | } 90 | else if (ModUtils.MouseState.LeftButton == ButtonState.Released && ModUtils.PreviousMouseState.LeftButton == ButtonState.Pressed) 91 | { 92 | _dragging = false; 93 | } 94 | UIKit.UIView.OverWriteGameMouseInput(); 95 | } 96 | } 97 | 98 | public static void Draw(SpriteBatch spriteBatch) 99 | { 100 | if (Visible) 101 | { 102 | ModUtils.DrawBorderedRect(spriteBatch, Color.Blue, Position, Size, 3, Width + "x" + Height); 103 | //Vector2 pos = ModUtils.GetWorldCoordsFromTileCoords(Position) - Main.screenPosition; 104 | //spriteBatch.Draw(ModUtils.DummyTexture, new Rectangle((int)pos.X, (int)pos.Y, Width * 16, Height * 16), Color.Blue * .5f); 105 | } 106 | } 107 | } 108 | } -------------------------------------------------------------------------------- /HEROsModServices/ServiceController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace HEROsMod.HEROsModServices 5 | { 6 | internal class ServiceController 7 | { 8 | public delegate void ServiceEventHandler(HEROsModService service); 9 | 10 | public event ServiceEventHandler ServiceAdded; 11 | 12 | public event ServiceEventHandler ServiceRemoved; 13 | 14 | private List _services; 15 | 16 | /// 17 | /// HEROsMod Services laoded into the controller 18 | /// 19 | public List Services 20 | { 21 | get { return _services; } 22 | } 23 | 24 | public ServiceController() 25 | { 26 | _services = new List(); 27 | HEROsModNetwork.LoginService.MyGroupChanged += LoginService_MyGroupChanged; 28 | } 29 | 30 | private void LoginService_MyGroupChanged(object sender, EventArgs e) 31 | { 32 | MyGroupChanged(); 33 | } 34 | 35 | public void MyGroupChanged() 36 | { 37 | if (HEROsModNetwork.LoginService.MyGroup != null) 38 | { 39 | foreach (HEROsModService service in _services) 40 | { 41 | //ErrorLogger.Log("MyGroupChanged for " + service.Name); 42 | service.MyGroupUpdated(); 43 | } 44 | // These not bound to a service because of complicated UI coupling 45 | foreach (var item in HEROsMod.instance.crossModGroupUpdated) 46 | { 47 | item.Value.Invoke(HEROsModNetwork.LoginService.MyGroup.HasPermission(item.Key)); 48 | } 49 | ServiceRemoved(null); 50 | } 51 | } 52 | 53 | /// 54 | /// Add a HEROsModService to the ServiceController 55 | /// 56 | /// Service to add 57 | public void AddService(HEROsModService service) 58 | { 59 | _services.Add(service); 60 | ServiceAdded?.Invoke(service); 61 | } 62 | 63 | /// 64 | /// Remove a HEROsModService from the ServiceController 65 | /// 66 | /// Service to Remove 67 | public void RemoveService(HEROsModService service) 68 | { 69 | service.Destroy(); 70 | _services.Remove(service); 71 | ServiceRemoved?.Invoke(service); 72 | } 73 | 74 | /// 75 | /// Remove all HEROsModServices from the ServiceController 76 | /// 77 | public void RemoveAllServices() 78 | { 79 | while (_services.Count > 0) 80 | { 81 | RemoveService(_services[0]); 82 | } 83 | } 84 | 85 | internal void ServiceRemovedCall() 86 | { 87 | ServiceRemoved(null); 88 | } 89 | } 90 | } -------------------------------------------------------------------------------- /HEROsModServices/SpawnPointSetter.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.UIKit; 2 | using HEROsMod.UIKit.UIComponents; 3 | using Microsoft.Xna.Framework.Graphics; 4 | using ReLogic.Content; 5 | using System; 6 | using Terraria; 7 | using Terraria.ModLoader; 8 | 9 | namespace HEROsMod.HEROsModServices 10 | { 11 | internal class SpawnPointSetter : HEROsModService 12 | { 13 | public SpawnPointSetter(UIHotbar hotbar) 14 | { 15 | IsInHotbar = true; 16 | HotbarParent = hotbar; 17 | this._name = "Spawn Point Setter"; 18 | this._hotbarIcon = new UIImage(HEROsMod.instance.Assets.Request("Images/spawn", AssetRequestMode.ImmediateLoad)/*Main.itemTexture[69]*/); 19 | this._hotbarIcon.Tooltip = HEROsMod.HeroText("SetSpawnPoint"); 20 | this.HotbarIcon.onLeftClick += HotbarIcon_onLeftClick; 21 | } 22 | 23 | public override void MyGroupUpdated() 24 | { 25 | this.HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.IsAdmin; 26 | //base.MyGroupUpdated(); 27 | } 28 | 29 | private void HotbarIcon_onLeftClick(object sender, EventArgs e) 30 | { 31 | if (ModUtils.NetworkMode == NetworkMode.None) 32 | { 33 | //this.position.X = (float)(Main.spawnTileX * 16 + 8 - this.width / 2); 34 | //this.position.Y = (float)(Main.spawnTileY * 16 - this.height); 35 | 36 | Player player = Main.player[Main.myPlayer]; 37 | 38 | Main.spawnTileX = (int)(player.position.X - 8 + player.width / 2) / 16; 39 | Main.spawnTileY = (int)(player.position.Y + player.height) / 16; 40 | 41 | Main.NewText(string.Format(HEROsMod.HeroText("SpawnPointSetToXY"), Main.spawnTileX, Main.spawnTileY)); 42 | } 43 | else 44 | { 45 | HEROsModNetwork.GeneralMessages.RequestSetSpawnPoint(); 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /HEROsModServices/StatsService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using Terraria.ModLoader; 4 | 5 | namespace HEROsMod.HEROsModServices 6 | { 7 | internal class StatsService : HEROsModService 8 | { 9 | private static Uri statUrl = new Uri("http://javid.ddns.net/tModLoader/herosmod/stats.php"); 10 | private static float checkEventPassedTimer = 0; 11 | private static float checkEventPassedTime = 60; // Time between checks for time between in seconds 12 | private static DateTime eventTime; 13 | private static int playHours = -1; 14 | 15 | public StatsService() 16 | { 17 | //eventTime = GetNextSendEvent(); 18 | eventTime = DateTime.Now.AddSeconds(30); 19 | } 20 | 21 | public override void Update() 22 | { 23 | checkEventPassedTimer -= ModUtils.DeltaTime; 24 | if (checkEventPassedTimer <= 0) 25 | { 26 | CheckForEventPassed(); 27 | checkEventPassedTimer = checkEventPassedTime; 28 | } 29 | base.Update(); 30 | } 31 | 32 | private static DateTime GetNextSendEvent() 33 | { 34 | playHours++; 35 | DateTime now = DateTime.Now; 36 | // return new DateTime(now.Year, now.Month, now.Day, now.Hour, 5, 0).AddHours(1); 37 | return now.AddHours(1); 38 | } 39 | 40 | private static void CheckForEventPassed() 41 | { 42 | DateTime now = DateTime.Now; 43 | if (now > eventTime) 44 | { 45 | eventTime = GetNextSendEvent(); 46 | SendData(); 47 | } 48 | } 49 | 50 | private static void SendData() 51 | { 52 | try 53 | { 54 | using (WebClient client = new WebClient()) 55 | { 56 | client.DownloadStringAsync(new Uri(statUrl 57 | + "?tmodversion=" + BuildInfo.tMLVersion.ToString() 58 | + "&version=" + HEROsMod.instance.Version.ToString() 59 | + "&platform=" + ModLoader.CompressedPlatformRepresentation 60 | + "&playhours=" + playHours 61 | + "&steamid64=" + ModUtils.SteamID 62 | )); 63 | } 64 | } 65 | catch 66 | { } 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /HEROsModServices/Teleporter.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using ReLogic.Graphics; 4 | using Terraria; 5 | using Terraria.GameContent; 6 | using Terraria.ID; 7 | using Terraria.Localization; 8 | using Terraria.UI.Chat; 9 | 10 | namespace HEROsMod.HEROsModServices 11 | { 12 | internal class Teleporter : HEROsModService 13 | { 14 | // TODO, is this how I want to do this? 15 | public static Teleporter instance; 16 | private bool rightClickEnabled = true; // TODO: Remember this setting maybe? 17 | private bool rightMouseHadBeenReleased; 18 | 19 | public Teleporter() 20 | { 21 | instance = this; 22 | } 23 | 24 | public override void Update() 25 | { 26 | // This method coincidentally only called when fullscreen is closed. 27 | rightMouseHadBeenReleased = false; 28 | 29 | //if (Main.mapFullscreen) 30 | //{ 31 | // if (this.HasPermissionToUse) 32 | // { 33 | // if (Main.mouseRight && Main.keyState.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.LeftControl)) 34 | // { 35 | // int mapWidth = Main.maxTilesX * 16; 36 | // int mapHeight = Main.maxTilesY * 16; 37 | // Vector2 cursorPosition = new Vector2(Main.mouseX, Main.mouseY); 38 | 39 | // cursorPosition.X -= Main.screenWidth / 2; 40 | // cursorPosition.Y -= Main.screenHeight / 2; 41 | 42 | // Vector2 mapPosition = Main.mapFullscreenPos; 43 | // Vector2 cursorWorldPosition = mapPosition; 44 | 45 | // cursorPosition /= 16; 46 | // cursorPosition *= 16 / Main.mapFullscreenScale; 47 | // cursorWorldPosition += cursorPosition; 48 | // cursorWorldPosition *= 16; 49 | 50 | // Player player = Main.player[Main.myPlayer]; 51 | // cursorWorldPosition.Y -= player.height; 52 | // if (cursorWorldPosition.X < 0) cursorWorldPosition.X = 0; 53 | // else if (cursorWorldPosition.X + player.width > mapWidth) cursorWorldPosition.X = mapWidth - player.width; 54 | // if (cursorWorldPosition.Y < 0) cursorWorldPosition.Y = 0; 55 | // else if (cursorWorldPosition.Y + player.height > mapHeight) cursorWorldPosition.Y = mapHeight - player.height; 56 | // player.position = cursorWorldPosition; 57 | // player.velocity = Vector2.Zero; 58 | // player.fallStart = (int)(player.position.Y / 16f); 59 | // } 60 | // } 61 | //} 62 | base.Update(); 63 | } 64 | 65 | public override void MyGroupUpdated() 66 | { 67 | this.HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.HasPermission("Teleport"); 68 | //base.MyGroupUpdated(); 69 | } 70 | 71 | public void PostDrawFullScreenMap(ref string mouseText) 72 | { 73 | // TODO: Detect MapLayer clicks? 74 | if (HasPermissionToUse) 75 | { 76 | // Toggle Button 77 | Texture2D inventoryTickTexture = TextureAssets.InventoryTickOn.Value; 78 | if (!rightClickEnabled) 79 | inventoryTickTexture = TextureAssets.InventoryTickOff.Value; 80 | Rectangle enableButtonRectangle = new Rectangle(17, Main.screenHeight - 72, inventoryTickTexture.Width, inventoryTickTexture.Height); 81 | 82 | if (enableButtonRectangle.Contains(Main.mouseX, Main.mouseY)) 83 | { 84 | Main.LocalPlayer.mouseInterface = true; 85 | if (Main.mouseLeft && Main.mouseLeftRelease) 86 | { 87 | rightClickEnabled = !rightClickEnabled; 88 | Main.mouseLeftRelease = false; 89 | Terraria.Audio.SoundEngine.PlaySound(SoundID.MenuTick); 90 | } 91 | mouseText = Language.GetTextValue(rightClickEnabled ? "GameUI.Enabled" : "GameUI.Disabled"); 92 | } 93 | var stringSize = ChatManager.GetStringSize(FontAssets.MouseText.Value, HEROsMod.HeroText("RightClickToTeleport"), Vector2.One); 94 | 95 | Utils.DrawInvBG(Main.spriteBatch, new Rectangle(13, Main.screenHeight - 80, (int)stringSize.X + 30, (int)stringSize.Y)/*, new Color(63, 65, 151, 255)*/); 96 | Main.spriteBatch.Draw(inventoryTickTexture, enableButtonRectangle.TopLeft(), Color.White); 97 | 98 | Main.spriteBatch.DrawString(FontAssets.MouseText.Value, HEROsMod.HeroText("RightClickToTeleport"), new Vector2(36, Main.screenHeight - 77), Color.White); 99 | Terraria.GameInput.PlayerInput.SetZoom_Unscaled(); 100 | 101 | rightMouseHadBeenReleased |= !Main.mouseRight; 102 | if (rightMouseHadBeenReleased && rightClickEnabled && Main.mouseRight && Main.keyState.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.LeftControl)) 103 | { 104 | int mapWidth = Main.maxTilesX * 16; 105 | int mapHeight = Main.maxTilesY * 16; 106 | Vector2 cursorPosition = new Vector2(Main.mouseX, Main.mouseY); 107 | 108 | cursorPosition.X -= Main.screenWidth / 2f; 109 | cursorPosition.Y -= Main.screenHeight / 2f; 110 | 111 | Vector2 mapPosition = Main.mapFullscreenPos; 112 | Vector2 cursorWorldPosition = mapPosition; 113 | 114 | cursorPosition /= 16; 115 | cursorPosition *= 16 / Main.mapFullscreenScale; 116 | cursorWorldPosition += cursorPosition; 117 | cursorWorldPosition *= 16; 118 | 119 | Player player = Main.player[Main.myPlayer]; 120 | cursorWorldPosition.Y -= player.height; 121 | if (cursorWorldPosition.X < 0) cursorWorldPosition.X = 0; 122 | else if (cursorWorldPosition.X + player.width > mapWidth) cursorWorldPosition.X = mapWidth - player.width; 123 | if (cursorWorldPosition.Y < 0) cursorWorldPosition.Y = 0; 124 | else if (cursorWorldPosition.Y + player.height > mapHeight) cursorWorldPosition.Y = mapHeight - player.height; 125 | 126 | if (Main.netMode == NetmodeID.SinglePlayer) // single 127 | { 128 | player.Teleport(cursorWorldPosition, 1, 0); 129 | player.position = cursorWorldPosition; 130 | player.velocity = Vector2.Zero; 131 | player.fallStart = (int)(player.position.Y / 16f); 132 | } 133 | else // 1, client 134 | { 135 | //ErrorLogger.Log("Teleport"); 136 | HEROsModNetwork.GeneralMessages.RequestTeleport(cursorWorldPosition); 137 | //NetMessage.SendData(65, -1, -1, "", 0, player.whoAmI, cursorWorldPosition.X, cursorWorldPosition.Y, 1, 0, 0); 138 | } 139 | FlyCam.ForceReset = true; 140 | } 141 | Terraria.GameInput.PlayerInput.SetZoom_UI(); 142 | } 143 | } 144 | } 145 | } -------------------------------------------------------------------------------- /HEROsModServices/TestHotbarSevice.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.UIKit; 2 | using HEROsMod.UIKit.UIComponents; 3 | using Microsoft.Xna.Framework; 4 | using System; 5 | using Terraria; 6 | using Terraria.GameContent; 7 | using Terraria.ID; 8 | 9 | namespace HEROsMod.HEROsModServices 10 | { 11 | internal class TestHotbarService : HEROsModService 12 | { 13 | private TestHotbarWindow _testHotbarWindow; 14 | 15 | public TestHotbarService() 16 | { 17 | this._hotbarIcon = new UIImage(TextureAssets.Buff[3]); 18 | this.HotbarIcon.Tooltip = "Test Hotbar"; 19 | this.HotbarIcon.onLeftClick += HotbarIcon_onLeftClick; 20 | 21 | _testHotbarWindow = new TestHotbarWindow(); 22 | _testHotbarWindow.HotBarParent = HEROsMod.ServiceHotbar; 23 | _testHotbarWindow.Hide(); 24 | this.AddUIView(_testHotbarWindow); 25 | } 26 | 27 | private void HotbarIcon_onLeftClick(object sender, EventArgs e) 28 | { 29 | //Main.NewText("Toggle Hotbar"); 30 | 31 | //_testHotbarWindow.Visible = !_testHotbarWindow.Visible; 32 | if (_testHotbarWindow.selected) 33 | { 34 | _testHotbarWindow.selected = false; 35 | _testHotbarWindow.Hide(); 36 | //Main.NewText("Hide Hotbar"); 37 | 38 | //uIImage.ForegroundColor = buttonUnselectedColor; 39 | } 40 | else 41 | { 42 | //DisableAllWindows(); 43 | _testHotbarWindow.selected = true; 44 | _testHotbarWindow.Show(); 45 | //Main.NewText("Show Hotbar"); 46 | 47 | //uIImage.ForegroundColor = buttonSelectedColor; 48 | } 49 | } 50 | } 51 | 52 | internal class TestHotbarWindow : UIHotbar 53 | { 54 | public UIView buttonView; 55 | public UIImage bStampTiles; 56 | public UIImage bEyeDropper; 57 | public UIImage bFlipHorizontal; 58 | public UIImage bFlipVertical; 59 | public UIImage bToggleTransparentSelection; 60 | 61 | public TestHotbarWindow() 62 | { 63 | this.buttonView = new UIView(); 64 | base.Visible = false; 65 | Main.instance.LoadItem(ItemID.Paintbrush); 66 | Main.instance.LoadItem(ItemID.EmptyDropper); 67 | Main.instance.LoadItem(ItemID.PadThai); 68 | Main.instance.LoadItem(ItemID.Safe); 69 | bStampTiles = new UIImage(TextureAssets.Item[ItemID.Paintbrush]); 70 | bEyeDropper = new UIImage(TextureAssets.Item[ItemID.EmptyDropper]); 71 | bFlipHorizontal = new UIImage(TextureAssets.Item[ItemID.PadThai]); 72 | bFlipVertical = new UIImage(TextureAssets.Item[ItemID.Safe]); 73 | bToggleTransparentSelection = new UIImage(TextureAssets.Buff[BuffID.Invisibility]); 74 | bStampTiles.Tooltip = " Paint Tiles"; 75 | bEyeDropper.Tooltip = " Eye Dropper"; 76 | bFlipHorizontal.Tooltip = " Flip Horizontal"; 77 | bFlipVertical.Tooltip = " Flip Vertical"; 78 | bToggleTransparentSelection.Tooltip = " Toggle Transparent Selection: On"; 79 | buttonView.AddChild(bStampTiles); 80 | buttonView.AddChild(bEyeDropper); 81 | buttonView.AddChild(bFlipHorizontal); 82 | buttonView.AddChild(bFlipVertical); 83 | buttonView.AddChild(bToggleTransparentSelection); 84 | base.Width = 200f; 85 | base.Height = 55f; 86 | this.buttonView.Height = base.Height; 87 | base.Anchor = AnchorPosition.Top; 88 | this.AddChild(this.buttonView); 89 | base.Position = new Vector2(Position.X, this.hiddenPosition); 90 | base.CenterXAxisToParentCenter(); 91 | float num = this.spacing; 92 | for (int i = 0; i < this.buttonView.children.Count; i++) 93 | { 94 | this.buttonView.children[i].Anchor = AnchorPosition.Left; 95 | this.buttonView.children[i].Position = new Vector2(num, 0f); 96 | this.buttonView.children[i].CenterYAxisToParentCenter(); 97 | this.buttonView.children[i].Visible = true; 98 | this.buttonView.children[i].ForegroundColor = buttonUnselectedColor; 99 | num += this.buttonView.children[i].Width + this.spacing; 100 | } 101 | this.Resize(); 102 | } 103 | 104 | public void Resize() 105 | { 106 | float num = this.spacing; 107 | for (int i = 0; i < this.buttonView.children.Count; i++) 108 | { 109 | if (this.buttonView.children[i].Visible) 110 | { 111 | this.buttonView.children[i].X = num; 112 | num += this.buttonView.children[i].Width + this.spacing; 113 | } 114 | } 115 | base.Width = num; 116 | this.buttonView.Width = base.Width; 117 | } 118 | 119 | public void Hide() 120 | { 121 | hidden = true; 122 | arrived = false; 123 | } 124 | 125 | public void Show() 126 | { 127 | arrived = false; 128 | hidden = false; 129 | Visible = true; 130 | } 131 | } 132 | } -------------------------------------------------------------------------------- /HEROsModServices/ToggleGravestones.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.HEROsModNetwork; 2 | using HEROsMod.UIKit; 3 | using HEROsMod.UIKit.UIComponents; 4 | using Microsoft.Xna.Framework.Graphics; 5 | using ReLogic.Content; 6 | using System; 7 | using System.Linq; 8 | using Terraria; 9 | using Terraria.ID; 10 | using Terraria.ModLoader; 11 | 12 | namespace HEROsMod.HEROsModServices 13 | { 14 | internal class ToggleGravestones : HEROsModService 15 | { 16 | public static int[] gravestoneProjectiles = new int[] { 17 | ProjectileID.Tombstone, 18 | ProjectileID.GraveMarker, 19 | ProjectileID.CrossGraveMarker, 20 | ProjectileID.Headstone, 21 | ProjectileID.Gravestone, 22 | ProjectileID.Obelisk, 23 | ProjectileID.RichGravestone1, ProjectileID.RichGravestone2,ProjectileID.RichGravestone3, 24 | ProjectileID.RichGravestone4, ProjectileID.RichGravestone5, 25 | }; 26 | 27 | // public ToggleGravestones() 28 | public ToggleGravestones(UIHotbar hotbar) 29 | { 30 | IsInHotbar = true; 31 | HotbarParent = hotbar; 32 | //MultiplayerOnly = true; 33 | this._name = "Gravestones Toggler"; 34 | this._hotbarIcon = new UIImage(HEROsMod.instance.Assets.Request("Images/gravestone", AssetRequestMode.ImmediateLoad)/*Main.projectileTexture[43]*/); 35 | this._hotbarIcon.onLeftClick += _hotbarIcon_onLeftClick; 36 | this.HotbarIcon.Tooltip = HEROsMod.HeroText("DisableGravestones"); 37 | this._hotbarIcon.Opacity = 1f; 38 | HEROsModNetwork.GeneralMessages.GravestonesToggleByServer += GeneralMessages_GravestonesToggleByServer; 39 | } 40 | 41 | private void GeneralMessages_GravestonesToggleByServer(bool gravestonesCanSpawn) 42 | { 43 | if (gravestonesCanSpawn) 44 | { 45 | this._hotbarIcon.Opacity = 1f; 46 | this.HotbarIcon.Tooltip = HEROsMod.HeroText("DisableGravestones"); 47 | } 48 | else 49 | { 50 | this._hotbarIcon.Opacity = .5f; 51 | this.HotbarIcon.Tooltip = HEROsMod.HeroText("EnableGravestones"); 52 | } 53 | Network.GravestonesAllowed = gravestonesCanSpawn; 54 | } 55 | 56 | private void _hotbarIcon_onLeftClick(object sender, EventArgs e) 57 | { 58 | if (ModUtils.NetworkMode != NetworkMode.None) 59 | { 60 | HEROsModNetwork.GeneralMessages.RequestToggleGravestones(); 61 | } 62 | else 63 | { 64 | if (Network.GravestonesAllowed) 65 | Main.NewText(HEROsMod.HeroText("YouHaveDisabledGravestones")); 66 | else 67 | Main.NewText(HEROsMod.HeroText("YouHaveEnabledGravestones")); 68 | GeneralMessages_GravestonesToggleByServer(!Network.GravestonesAllowed); 69 | } 70 | } 71 | 72 | public override void MyGroupUpdated() 73 | { 74 | this.HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.HasPermission("ToggleGravestones"); 75 | //base.MyGroupUpdated(); 76 | } 77 | } 78 | 79 | internal class GraveStoneGlobalProjectile : GlobalProjectile 80 | { 81 | // public override bool Autoload(ref string name) => true; 82 | 83 | public override bool PreAI(Projectile projectile) 84 | { 85 | if (!Network.GravestonesAllowed) 86 | { 87 | if (ToggleGravestones.gravestoneProjectiles.Contains(projectile.type)) 88 | { 89 | //ErrorLogger.Log("Ded " + Main.dedServ + " projectile.type active false: " + projectile.type); 90 | projectile.active = false; 91 | return false; 92 | } 93 | } 94 | return base.PreAI(projectile); 95 | } 96 | } 97 | } -------------------------------------------------------------------------------- /HEROsModServices/WeatherChanger.cs: -------------------------------------------------------------------------------- 1 | //using System; 2 | //using System.Collections.Generic; 3 | //using System.Linq; 4 | //using System.Text; 5 | //using GameikiMod.UIKit; 6 | //using Microsoft.Xna.Framework; 7 | //using Microsoft.Xna.Framework.Graphics; 8 | 9 | //using Terraria; 10 | 11 | //namespace GameikiMod.GameikiServices 12 | //{ 13 | // class WeatherChanger : GameikiService 14 | // { 15 | // private WeatherControlWindow weatherWindow; 16 | // public WeatherChanger() 17 | // { 18 | // this._name = "Weather Control"; 19 | // this._hotbarIcon = new UIImage(WeatherControlWindow.rainTexture); 20 | // this.HotbarIcon.Tooltip = "Control Rain"; 21 | // this.HotbarIcon.onLeftClick += HotbarIcon_onLeftClick; 22 | 23 | // weatherWindow = new WeatherControlWindow(); 24 | // Gameiki.ServiceHotbar.AddChild(weatherWindow); 25 | // } 26 | 27 | // void HotbarIcon_onLeftClick(object sender, EventArgs e) 28 | // { 29 | // weatherWindow.Visible = !weatherWindow.Visible; 30 | // if (weatherWindow.Visible) 31 | // { 32 | // weatherWindow.X = this._hotbarIcon.X + this._hotbarIcon.Width / 2 - weatherWindow.Width / 2; 33 | // weatherWindow.Y = -weatherWindow.Height; 34 | // } 35 | // } 36 | 37 | // public override void MyGroupUpdated() 38 | // { 39 | // this.HasPermissionToUse = GameikiNetwork.LoginService.MyGroup.HasPermission("ControlWeather"); 40 | // base.MyGroupUpdated(); 41 | // } 42 | 43 | // public override void Destroy() 44 | // { 45 | // Gameiki.ServiceHotbar.RemoveChild(weatherWindow); 46 | // base.Destroy(); 47 | // } 48 | // } 49 | 50 | // class WeatherControlWindow : UIWindow 51 | // { 52 | // static float spacing = 8f; 53 | 54 | // static Texture2D _rainTexture; 55 | // public static Texture2D rainTexture 56 | // { 57 | // get 58 | // { 59 | // if (_rainTexture == null) _rainTexture = GetEmbeddedTexture("Images/rainIcon"); 60 | // return _rainTexture; 61 | // } 62 | // } 63 | 64 | // public WeatherControlWindow() 65 | // { 66 | // Height = 55; 67 | // UpdateWhenOutOfBounds = true; 68 | 69 | // UIImage bStopRain = new UIImage(GetEmbeddedTexture("Images/sunIcon")); 70 | // UIImage bStartRain = new UIImage(rainTexture); 71 | // bStartRain.Tooltip = "Start Rain"; 72 | // bStopRain.Tooltip = "Stop Rain"; 73 | // bStartRain.onLeftClick += bStartRain_onLeftClick; 74 | // bStopRain.onLeftClick += bStopRain_onLeftClick; 75 | // AddChild(bStopRain); 76 | // AddChild(bStartRain); 77 | 78 | // float xPos = spacing; 79 | // for (int i = 0; i < children.Count; i++) 80 | // { 81 | // if (children[i].Visible) 82 | // { 83 | // children[i].X = xPos; 84 | // xPos += children[i].Width + spacing; 85 | // children[i].Y = Height / 2 - children[i].Height / 2; 86 | // } 87 | // } 88 | // Width = xPos; 89 | // } 90 | 91 | // void bStopRain_onLeftClick(object sender, EventArgs e) 92 | // { 93 | // if (Main.netMode == 1) 94 | // { 95 | // GameikiNetwork.GeneralMessages.RequestStopRain(); 96 | // return; 97 | // } 98 | // ModUtils.StopRain(); 99 | // } 100 | 101 | // void bStartRain_onLeftClick(object sender, EventArgs e) 102 | // { 103 | // if (Main.netMode == 1) 104 | // { 105 | // GameikiNetwork.GeneralMessages.RequestStartRain(); 106 | // return; 107 | // } 108 | // ModUtils.StartRain(); 109 | // } 110 | 111 | 112 | 113 | // public override void Update() 114 | // { 115 | // if (this.Visible) 116 | // { 117 | // if (!MouseInside) 118 | // { 119 | // int mx = Main.mouseX; 120 | // int my = Main.mouseY; 121 | // float right = DrawPosition.X + Width; 122 | // float left = DrawPosition.X; 123 | // float top = DrawPosition.Y; 124 | // float bottom = DrawPosition.Y + Height; 125 | // float dist = 75f; 126 | // bool outsideBounds = (mx > right && mx - right > dist) || 127 | // (mx < left && left - mx > dist) || 128 | // (my > bottom && my - bottom > dist) || 129 | // (my < top && top - my > dist); 130 | // if ((UIKit.UIView.MouseLeftButton && !MouseInside) || outsideBounds) this.Visible = false; 131 | // } 132 | // } 133 | // base.Update(); 134 | // } 135 | 136 | // } 137 | //} 138 | -------------------------------------------------------------------------------- /HEROsModServices/ZoomToolsService.cs: -------------------------------------------------------------------------------- 1 | //using System; 2 | //using System.Collections.Generic; 3 | //using System.Linq; 4 | //using System.Text; 5 | //using Microsoft.Xna.Framework; 6 | //using Microsoft.Xna.Framework.Input; 7 | //using Microsoft.Xna.Framework.Graphics; 8 | //using System.IO; 9 | //using System.Text.RegularExpressions; 10 | 11 | //using Terraria; 12 | //using Terraria.ModLoader; 13 | 14 | //namespace HEROsModMod.HEROsModServices 15 | //{ 16 | // class ZoomToolsService : HEROsModService 17 | // { 18 | // public class ZoomToolsServiceModPlayer : ModPlayer 19 | // { 20 | // public override bool Autoload(ref string name) => true; 21 | 22 | // int oldX; 23 | // int oldY; 24 | // public override void PreUpdate() 25 | // { 26 | // oldX = Main.mouseX; 27 | // oldY = Main.mouseY; 28 | // if (player.whoAmI == Main.myPlayer) 29 | // { 30 | // AdjustMousePosition(); 31 | // } 32 | // } 33 | // public override void PostUpdate() 34 | // { 35 | // if (player.whoAmI == Main.myPlayer) 36 | // { 37 | // Main.mouseX = oldX; 38 | // Main.mouseY = oldY; 39 | // } 40 | // } 41 | // } 42 | 43 | // public static Matrix OffsetMatrix 44 | // { 45 | // get 46 | // { 47 | // float transX = Main.screenWidth / 2; 48 | // float transY = Main.screenHeight / 2; 49 | 50 | // return Matrix.Identity 51 | // * Matrix.CreateTranslation(-Main.screenWidth / 2, -Main.screenHeight / 2, 0f) 52 | // * Matrix.CreateScale(Scale, Scale, 1f) 53 | // * Matrix.CreateTranslation(transX, transY, 0f); 54 | // } 55 | // } 56 | 57 | // private static int _mouseXBackup; 58 | // private static int _mouseYBackup; 59 | 60 | // static KeyBinding _zoomInKeyBinding; 61 | // static KeyBinding _zoomOutKeyBinding; 62 | 63 | // static float Scale = 1.5f; 64 | 65 | // public ZoomToolsService() 66 | // { 67 | // //SetKeyBindings(); 68 | // Scale = 1f; 69 | // } 70 | 71 | // public static void SetKeyBindings() 72 | // { 73 | // _zoomInKeyBinding = KeybindController.AddKeyBinding("Zoom Camera In", "OemPlus"); 74 | // _zoomOutKeyBinding = KeybindController.AddKeyBinding("Zoom Camera Out", "OemMinus"); 75 | // } 76 | 77 | // public static Vector2 AdjustMousePosition() 78 | // { 79 | // _mouseXBackup = Main.mouseX; 80 | // _mouseYBackup = Main.mouseY; 81 | 82 | // Vector2 mousePos = new Vector2(ModUtils.MouseState.X, ModUtils.MouseState.Y); 83 | // mousePos = Vector2.Transform(mousePos, Matrix.Invert(OffsetMatrix)); 84 | 85 | 86 | // Main.mouseX = (int)mousePos.X; 87 | // Main.mouseY = (int)mousePos.Y; 88 | 89 | // return mousePos; 90 | // } 91 | 92 | // public static void RestoreMousePosition() 93 | // { 94 | // Main.mouseX = _mouseXBackup; 95 | // Main.mouseY = _mouseYBackup; 96 | // } 97 | 98 | // static float[] scales = new float[] { .25f, .5f, .75f, 1f, 1.25f, 1.5f, 2f, 3f, 5f }; 99 | // public override void Update() 100 | // { 101 | // if (_zoomInKeyBinding.KeyPressed) 102 | // { 103 | // // ErrorLogger.Log("Zoom in prssed"); 104 | // for (int i = 0; i < scales.Length; i++) 105 | // { 106 | // if (Scale < scales[i]) 107 | // { 108 | // Scale = scales[i]; 109 | // Main.NewText("Zoom Level: " + Scale); 110 | // break; 111 | // } 112 | // } 113 | // } 114 | // if (_zoomOutKeyBinding.KeyPressed) 115 | // { 116 | // // ErrorLogger.Log("Zoom out down"); 117 | // for (int i = scales.Length - 1; i >= 0; i--) 118 | // { 119 | // if (Scale > scales[i]) 120 | // { 121 | // Scale = scales[i]; 122 | // Main.NewText("Zoom Level: " + Scale); 123 | // break; 124 | // } 125 | // } 126 | // } 127 | // base.Update(); 128 | // } 129 | 130 | 131 | // } 132 | //} 133 | -------------------------------------------------------------------------------- /HerosModSystem.cs: -------------------------------------------------------------------------------- 1 | using HEROsMod.HEROsModServices; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using Terraria; 7 | using Terraria.ModLoader; 8 | using Terraria.UI; 9 | 10 | namespace HEROsMod 11 | { 12 | public class HerosModSystem : ModSystem 13 | { 14 | public override void PostDrawFullscreenMap(ref string mouseText) 15 | { 16 | Teleporter.instance.PostDrawFullScreenMap(ref mouseText); 17 | MapRevealer.instance.PostDrawFullScreenMap(); 18 | } 19 | 20 | public override void ModifyInterfaceLayers(List layers) 21 | { 22 | int inventoryLayerIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text")); 23 | if (inventoryLayerIndex != -1) 24 | { 25 | layers.Insert(inventoryLayerIndex, new LegacyGameInterfaceLayer( 26 | "HerosMod: UI", 27 | delegate { 28 | try 29 | { 30 | HEROsMod.Update(); 31 | 32 | HEROsMod.ServiceHotbar.Update(); 33 | 34 | HEROsMod.Draw(Main.spriteBatch); 35 | } 36 | catch (Exception e) 37 | { 38 | ModUtils.DebugText("ModifyInterfaceLayers Error: " + e.Message + e.StackTrace); 39 | } 40 | return true; 41 | }, 42 | InterfaceScaleType.UI) 43 | ); 44 | } 45 | 46 | int rulerLayerIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Ruler")); 47 | if (rulerLayerIndex != -1) 48 | { 49 | layers.Insert(rulerLayerIndex, new LegacyGameInterfaceLayer( 50 | "HerosMod: Game Scale UI", 51 | delegate { 52 | HEROsMod.DrawWorldUI(Main.spriteBatch); 53 | return true; 54 | }, 55 | InterfaceScaleType.Game) 56 | ); 57 | } 58 | } 59 | 60 | public override void PreSaveAndQuit() 61 | { 62 | HEROsMod.instance.prefixEditor.PreSaveAndQuit(); 63 | } 64 | 65 | //public override void UpdateMusic(ref int music, ref AVF priority) 66 | //{ 67 | // HEROsMod.CheckIfGameEnteredOrLeft(); 68 | // //Console.WriteLine("?"); 69 | // //KeybindController.DoPreviousKeyState(); 70 | //} 71 | 72 | public override bool HijackGetData(ref byte messageType, ref BinaryReader reader, int playerNumber) 73 | { 74 | if (HEROsModNetwork.Network.CheckIncomingDataForHEROsModMessage(ref messageType, ref reader, playerNumber)) 75 | { 76 | //ErrorLogger.Log("Hijacking: " + messageType); 77 | return true; 78 | } 79 | return false; 80 | } 81 | 82 | public override void PreUpdateEntities() 83 | { 84 | //Handle callbacks here as this is called on all sides 85 | //May need to filter allside vs clientside callbacks 86 | 87 | //Only godmode for now 88 | GodModeService.InvokeGodModeCallback(); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Images/AllIcons.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/AllIcons.psd -------------------------------------------------------------------------------- /Images/CTF/blueBanner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/CTF/blueBanner.png -------------------------------------------------------------------------------- /Images/CTF/blueButtonBG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/CTF/blueButtonBG.png -------------------------------------------------------------------------------- /Images/CTF/blueFlag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/CTF/blueFlag.png -------------------------------------------------------------------------------- /Images/CTF/bluePlatform.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/CTF/bluePlatform.png -------------------------------------------------------------------------------- /Images/CTF/blueScore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/CTF/blueScore.png -------------------------------------------------------------------------------- /Images/CTF/blueSpawn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/CTF/blueSpawn.png -------------------------------------------------------------------------------- /Images/CTF/blueTeamIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/CTF/blueTeamIcon.png -------------------------------------------------------------------------------- /Images/CTF/platform.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/CTF/platform.png -------------------------------------------------------------------------------- /Images/CTF/redBanner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/CTF/redBanner.png -------------------------------------------------------------------------------- /Images/CTF/redButtonBG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/CTF/redButtonBG.png -------------------------------------------------------------------------------- /Images/CTF/redFlag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/CTF/redFlag.png -------------------------------------------------------------------------------- /Images/CTF/redPlatform.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/CTF/redPlatform.png -------------------------------------------------------------------------------- /Images/CTF/redScore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/CTF/redScore.png -------------------------------------------------------------------------------- /Images/CTF/redSpawn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/CTF/redSpawn.png -------------------------------------------------------------------------------- /Images/CTF/redTeamIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/CTF/redTeamIcon.png -------------------------------------------------------------------------------- /Images/CollapseBar/CollapseArrowHorizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/CollapseBar/CollapseArrowHorizontal.png -------------------------------------------------------------------------------- /Images/CollapseBar/CollapseButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/CollapseBar/CollapseButton.png -------------------------------------------------------------------------------- /Images/CollapseBar/CollapseButtonHorizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/CollapseBar/CollapseButtonHorizontal.png -------------------------------------------------------------------------------- /Images/CollapseBar/collapseArrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/CollapseBar/collapseArrow.png -------------------------------------------------------------------------------- /Images/CollapseIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/CollapseIcon.png -------------------------------------------------------------------------------- /Images/ExpandIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/ExpandIcon.png -------------------------------------------------------------------------------- /Images/Old/CollapseIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/CollapseIcon.png -------------------------------------------------------------------------------- /Images/Old/Demon_Altar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/Demon_Altar.png -------------------------------------------------------------------------------- /Images/Old/ExpandIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/ExpandIcon.png -------------------------------------------------------------------------------- /Images/Old/LogoNew0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/LogoNew0.png -------------------------------------------------------------------------------- /Images/Old/LogoNew1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/LogoNew1.png -------------------------------------------------------------------------------- /Images/Old/LogoNew2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/LogoNew2.png -------------------------------------------------------------------------------- /Images/Old/backButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/backButton.png -------------------------------------------------------------------------------- /Images/Old/canIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/canIcon.png -------------------------------------------------------------------------------- /Images/Old/closeButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/closeButton.png -------------------------------------------------------------------------------- /Images/Old/colorGradient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/colorGradient.png -------------------------------------------------------------------------------- /Images/Old/connectedPlayers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/connectedPlayers.png -------------------------------------------------------------------------------- /Images/Old/filterMod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/filterMod.png -------------------------------------------------------------------------------- /Images/Old/forwardButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/forwardButton.png -------------------------------------------------------------------------------- /Images/Old/login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/login.png -------------------------------------------------------------------------------- /Images/Old/logout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/logout.png -------------------------------------------------------------------------------- /Images/Old/manageGroups.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/manageGroups.png -------------------------------------------------------------------------------- /Images/Old/moonIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/moonIcon.png -------------------------------------------------------------------------------- /Images/Old/npcIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/npcIcon.png -------------------------------------------------------------------------------- /Images/Old/rainIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/rainIcon.png -------------------------------------------------------------------------------- /Images/Old/sortAZ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/sortAZ.png -------------------------------------------------------------------------------- /Images/Old/sortAxe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/sortAxe.png -------------------------------------------------------------------------------- /Images/Old/sortDamage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/sortDamage.png -------------------------------------------------------------------------------- /Images/Old/sortFish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/sortFish.png -------------------------------------------------------------------------------- /Images/Old/sortHammer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/sortHammer.png -------------------------------------------------------------------------------- /Images/Old/sortItemID.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/sortItemID.png -------------------------------------------------------------------------------- /Images/Old/sortPick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/sortPick.png -------------------------------------------------------------------------------- /Images/Old/sortValue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/sortValue.png -------------------------------------------------------------------------------- /Images/Old/speed0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/speed0.png -------------------------------------------------------------------------------- /Images/Old/speed1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/speed1.png -------------------------------------------------------------------------------- /Images/Old/speed2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/speed2.png -------------------------------------------------------------------------------- /Images/Old/speed3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/speed3.png -------------------------------------------------------------------------------- /Images/Old/speed4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/speed4.png -------------------------------------------------------------------------------- /Images/Old/sunIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/sunIcon.png -------------------------------------------------------------------------------- /Images/Old/testTubeSpritesheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/testTubeSpritesheet.png -------------------------------------------------------------------------------- /Images/Old/waypointIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/Old/waypointIcon.png -------------------------------------------------------------------------------- /Images/UIKit/barEdge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/UIKit/barEdge.png -------------------------------------------------------------------------------- /Images/UIKit/buttonEdge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/UIKit/buttonEdge.png -------------------------------------------------------------------------------- /Images/UIKit/checkBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/UIKit/checkBox.png -------------------------------------------------------------------------------- /Images/UIKit/checkMark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/UIKit/checkMark.png -------------------------------------------------------------------------------- /Images/UIKit/clearIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/UIKit/clearIcon.png -------------------------------------------------------------------------------- /Images/UIKit/dropdownCapDown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/UIKit/dropdownCapDown.png -------------------------------------------------------------------------------- /Images/UIKit/dropdownCapUp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/UIKit/dropdownCapUp.png -------------------------------------------------------------------------------- /Images/UIKit/openIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/UIKit/openIcon.png -------------------------------------------------------------------------------- /Images/UIKit/saveIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/UIKit/saveIcon.png -------------------------------------------------------------------------------- /Images/UIKit/scrollbarEdge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/UIKit/scrollbarEdge.png -------------------------------------------------------------------------------- /Images/UIKit/scrollbgEdge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/UIKit/scrollbgEdge.png -------------------------------------------------------------------------------- /Images/UIKit/textboxEdge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/UIKit/textboxEdge.png -------------------------------------------------------------------------------- /Images/buddhaMode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/buddhaMode.png -------------------------------------------------------------------------------- /Images/buffs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/buffs.png -------------------------------------------------------------------------------- /Images/canIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/canIcon.png -------------------------------------------------------------------------------- /Images/closeButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/closeButton.png -------------------------------------------------------------------------------- /Images/connectedPlayers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/connectedPlayers.png -------------------------------------------------------------------------------- /Images/contributions.txt: -------------------------------------------------------------------------------- 1 | Thanks to the following for some icon sprites featured in this release: 2 | 3 | Rartrin 4 | GabeHasWon 5 | Eli10293 - -------------------------------------------------------------------------------- /Images/event.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/event.png -------------------------------------------------------------------------------- /Images/explosives.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/explosives.png -------------------------------------------------------------------------------- /Images/extensions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/extensions.png -------------------------------------------------------------------------------- /Images/filterMod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/filterMod.png -------------------------------------------------------------------------------- /Images/flyCam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/flyCam.png -------------------------------------------------------------------------------- /Images/godMode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/godMode.png -------------------------------------------------------------------------------- /Images/gravestone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/gravestone.png -------------------------------------------------------------------------------- /Images/infiniteReach.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/infiniteReach.png -------------------------------------------------------------------------------- /Images/items.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/items.png -------------------------------------------------------------------------------- /Images/lighthack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/lighthack.png -------------------------------------------------------------------------------- /Images/login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/login.png -------------------------------------------------------------------------------- /Images/logout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/logout.png -------------------------------------------------------------------------------- /Images/manageGroups.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/manageGroups.png -------------------------------------------------------------------------------- /Images/map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/map.png -------------------------------------------------------------------------------- /Images/moonIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/moonIcon.png -------------------------------------------------------------------------------- /Images/npcIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/npcIcon.png -------------------------------------------------------------------------------- /Images/npcs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/npcs.png -------------------------------------------------------------------------------- /Images/rainIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/rainIcon.png -------------------------------------------------------------------------------- /Images/rainStop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/rainStop.png -------------------------------------------------------------------------------- /Images/reforge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/reforge.png -------------------------------------------------------------------------------- /Images/region.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/region.png -------------------------------------------------------------------------------- /Images/sandstormStart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/sandstormStart.png -------------------------------------------------------------------------------- /Images/sandstormStop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/sandstormStop.png -------------------------------------------------------------------------------- /Images/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/settings.png -------------------------------------------------------------------------------- /Images/sortAZ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/sortAZ.png -------------------------------------------------------------------------------- /Images/sortAmmo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/sortAmmo.png -------------------------------------------------------------------------------- /Images/sortAxe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/sortAxe.png -------------------------------------------------------------------------------- /Images/sortBait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/sortBait.png -------------------------------------------------------------------------------- /Images/sortDamage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/sortDamage.png -------------------------------------------------------------------------------- /Images/sortDefense.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/sortDefense.png -------------------------------------------------------------------------------- /Images/sortFish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/sortFish.png -------------------------------------------------------------------------------- /Images/sortHammer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/sortHammer.png -------------------------------------------------------------------------------- /Images/sortItemID.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/sortItemID.png -------------------------------------------------------------------------------- /Images/sortPick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/sortPick.png -------------------------------------------------------------------------------- /Images/sortValue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/sortValue.png -------------------------------------------------------------------------------- /Images/spacer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/spacer.png -------------------------------------------------------------------------------- /Images/spawn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/spawn.png -------------------------------------------------------------------------------- /Images/speed0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/speed0.png -------------------------------------------------------------------------------- /Images/speed1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/speed1.png -------------------------------------------------------------------------------- /Images/sunIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/sunIcon.png -------------------------------------------------------------------------------- /Images/tileModification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/tileModification.png -------------------------------------------------------------------------------- /Images/timeRain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/timeRain.png -------------------------------------------------------------------------------- /Images/waypointIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/Images/waypointIcon.png -------------------------------------------------------------------------------- /Interfaces/Item.cs: -------------------------------------------------------------------------------- 1 | //using System; 2 | //using System.Collections.Generic; 3 | //using System.Linq; 4 | //using System.Text; 5 | 6 | //namespace GameikiMod.Interfaces 7 | //{ 8 | // class Item 9 | // { 10 | // public int stack; 11 | // public int maxStack; 12 | 13 | // public int type; 14 | // public string name; 15 | // } 16 | //} 17 | -------------------------------------------------------------------------------- /Interfaces/Recipe.cs: -------------------------------------------------------------------------------- 1 | //using System; 2 | //using System.Collections.Generic; 3 | //using System.Linq; 4 | //using System.Text; 5 | 6 | //namespace GameikiMod.Interfaces 7 | //{ 8 | // class Recipe 9 | // { 10 | // //public string name; 11 | 12 | // public bool needHoney; 13 | // public bool needLava; 14 | // public bool needWood; 15 | // public bool needSand; 16 | // public bool needWater; 17 | 18 | // public Item[] requiredItem; 19 | // public Item createItem; 20 | // } 21 | //} 22 | -------------------------------------------------------------------------------- /Localization/TranslationsNeeded.txt: -------------------------------------------------------------------------------- 1 | en-US, 276/276, 100%, missing 0 2 | de-DE, 152/276, 55%, missing 124 3 | it-IT, 0/276, 0%, missing 276 4 | fr-FR, 0/276, 0%, missing 276 5 | es-ES, 216/276, 78%, missing 60 6 | ru-RU, 275/276, 100%, missing 1 7 | zh-Hans, 276/276, 100%, missing 0 8 | pt-BR, 204/276, 74%, missing 72 9 | pl-PL, 0/276, 0%, missing 276 10 | -------------------------------------------------------------------------------- /Localization/UpdateLocalizationFiles.py: -------------------------------------------------------------------------------- 1 | import os.path 2 | 3 | # tModLoader .lang file updater by jopojelly. (v1.1) 4 | # Run this script after updating en-US.lang with new keys. python 3. 5 | # Also make sure the file encodings are UTF-8 not UTF-8-BOM. 6 | # You can use this script for your own mod if you credit me. 7 | 8 | filename = './{0}.lang' 9 | 10 | languages = ['zh-Hans', 'ru-RU', 'pt-BR', 'pl-PL', 'it-IT', 'fr-FR', 'es-ES', 'de-DE'] 11 | missings = [] 12 | for language in languages: 13 | if not os.path.isfile(filename.format(language)): 14 | with open(filename.format(language), 'w', encoding='utf-8') as output: 15 | output.write("# Translation by: \n\nmissing=missing") 16 | #continue 17 | #language = 'zh-Hans' 18 | otherLanguage = '' 19 | missing = 0 20 | #print("Updating:",language) 21 | with open(filename.format('en-US'), 'r', encoding='utf-8') as english, open(filename.format(language), 'r', encoding='utf-8') as other: 22 | enLines = english.readlines() 23 | 24 | # Preserve Credits (comment lines on first few lines) 25 | otherLinesAll = other.readlines() 26 | 27 | for otherLine in otherLinesAll: 28 | if otherLine.startswith('#'): 29 | otherLanguage += otherLine 30 | else: 31 | break 32 | 33 | # Skip empty whitespace and comment lines to end up with only json lines. 34 | otherLines = [x for x in otherLinesAll if not (x.startswith("#") or len(x.strip()) == 0)] 35 | 36 | if len(otherLines) == 0: 37 | otherLines.append('TrashEntry') # just to prevent Index out of Range 38 | otherIndex = 0 39 | engComments = True 40 | for englishIndex, englishLine in enumerate(enLines): 41 | if englishLine.startswith('#') and engComments: 42 | continue 43 | if len(englishLine.strip()) == 0 and engComments: 44 | engComments = False 45 | 46 | # For lines with key values pairs, copy translation or add commented translation placeholder. 47 | if englishLine.find("=") != -1: 48 | if len(otherLines) > otherIndex and otherLines[otherIndex].startswith(englishLine[:englishLine.find("=")]): 49 | otherLanguage += otherLines[otherIndex] 50 | otherIndex += 1 51 | else: 52 | otherLanguage += "# " + englishLine.strip() + '\n' 53 | missing += 1 54 | # Add English Comments back in 55 | elif englishLine.strip().startswith('#'): 56 | otherLanguage += englishLine 57 | # Add other json lines in. Also add in whitespace lines. 58 | else: 59 | otherLanguage += englishLine 60 | if len(englishLine.strip()) > 0: 61 | otherIndex += 1 62 | #print(otherLanguage) 63 | # Save changes. 64 | if missing > 0: 65 | missings.append( (language, missing) ) 66 | print(language,missing) 67 | with open(filename.format(language), 'w', encoding='utf-8') as output: 68 | output.write(otherLanguage) 69 | 70 | with open('./TranslationsNeeded.txt', 'w', encoding='utf-8') as output: 71 | if len(missings) == 0: 72 | output.write('All Translations up-to-date!') 73 | else: 74 | for entry in missings: 75 | output.write(str(entry[0]) + " " + str(entry[1]) + "\n") 76 | #print("Make sure to run Diff.") 77 | #input("Press Enter to continue...") -------------------------------------------------------------------------------- /ModExtensions.cs: -------------------------------------------------------------------------------- 1 | //using Microsoft.Xna.Framework.Graphics; 2 | //using System; 3 | //using System.Collections.Generic; 4 | //using System.Linq; 5 | //using System.Text; 6 | //using System.Threading.Tasks; 7 | 8 | //namespace HEROsMod 9 | //{ 10 | // class ModExtensions 11 | // { 12 | // internal List ModExtensionList = new List(); 13 | 14 | // public ModExtensions() 15 | // { 16 | // ModExtensionList = new List(); 17 | // } 18 | 19 | // internal void AddButton(Texture2D texture, Action buttonClickedAction, Action groupUpdated, Func tooltip) 20 | // { 21 | // ModExtensionList.Add(new ModExtension(buttonClickedAction, groupUpdated, texture, tooltip)); 22 | // } 23 | // } 24 | 25 | // class ModExtension 26 | // { 27 | // Action ButtonClicked; 28 | // Action GroupUpdated; 29 | // Texture2D ButtonTexture; 30 | // Func ButtonTooltip; 31 | 32 | // public ModExtension(Action buttonClicked, Action groupUpdated, Texture2D buttonTexture, Func buttonTooltip) 33 | // { 34 | // ButtonClicked = buttonClicked; 35 | // GroupUpdated = groupUpdated; 36 | // ButtonTexture = buttonTexture; 37 | // ButtonTooltip = buttonTooltip; 38 | // } 39 | // } 40 | //} 41 | ///* 42 | 43 | // Client Only 44 | //Buttons: Texture, Tooltip, Click Action 45 | 46 | 47 | 48 | //*/ -------------------------------------------------------------------------------- /Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Terraria": { 4 | "commandName": "Executable", 5 | "executablePath": "dotnet", 6 | "commandLineArgs": "$(tMLPath)", 7 | "workingDirectory": "$(tMLSteamPath)" 8 | }, 9 | "TerrariaServer": { 10 | "commandName": "Executable", 11 | "executablePath": "dotnet", 12 | "commandLineArgs": "$(tMLServerPath)", 13 | "workingDirectory": "$(tMLSteamPath)" 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HEROsMod 2 | HERO's Mod is the latest iteration of the Gameiki mod for tModLoader. 3 | 4 | This mod was originally developed by [chatrat12](https://github.com/chatrat12). 5 | 6 | Feel free to suggest new features and submit pull requests. 7 | 8 | ![](http://javid.ddns.net/tModLoader/widget/widgetimage/HEROsMod.png) 9 | -------------------------------------------------------------------------------- /UIKit/ColorSliders.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | 4 | using Terraria; 5 | using Terraria.GameContent; 6 | 7 | namespace HEROsMod.UIKit 8 | { 9 | internal class HueSlider : UISlider 10 | { 11 | public HueSlider() 12 | { 13 | this.Width = ModUtils.HueTexture.Width; 14 | } 15 | 16 | public override void DrawBackground(SpriteBatch spriteBatch) 17 | { 18 | Vector2 pos = DrawPosition; 19 | pos.Y += (sliderTexture.Value.Height - ModUtils.HueTexture.Height) / 2; 20 | Main.spriteBatch.Draw(ModUtils.HueTexture, pos, Color.White); 21 | } 22 | } 23 | 24 | internal class SaturationSlider : UISlider 25 | { 26 | public float Hue { get; set; } 27 | public float Luminosity { get; set; } 28 | 29 | public SaturationSlider() 30 | { 31 | this.Width = ModUtils.HueTexture.Width; 32 | } 33 | 34 | public override void DrawBackground(SpriteBatch spriteBatch) 35 | { 36 | Vector2 pos = DrawPosition; 37 | pos.Y += (sliderTexture.Value.Height - ModUtils.HueTexture.Height) / 2; 38 | Main.spriteBatch.Draw(TextureAssets.ColorBar.Value, pos, Color.White); 39 | int fillWidth = 167; 40 | for (int k = 0; k <= fillWidth; k++) 41 | { 42 | float saturation = (float)k / (float)fillWidth; 43 | Color color4 = Main.hslToRgb(Hue, saturation, Luminosity); 44 | Main.spriteBatch.Draw(TextureAssets.ColorBlip.Value, new Vector2((float)(pos.X + k + 5), (float)(pos.Y + 4)), color4); 45 | } 46 | } 47 | } 48 | 49 | internal class LuminositySlider : UISlider 50 | { 51 | public float Hue { get; set; } 52 | public float Saturation { get; set; } 53 | 54 | public LuminositySlider() 55 | { 56 | this.Width = ModUtils.HueTexture.Width; 57 | } 58 | 59 | public override void DrawBackground(SpriteBatch spriteBatch) 60 | { 61 | Vector2 pos = DrawPosition; 62 | pos.Y += (sliderTexture.Value.Height - ModUtils.HueTexture.Height) / 2; 63 | Main.spriteBatch.Draw(TextureAssets.ColorBar.Value, pos, Color.White); 64 | 65 | int fillWidth = 167; 66 | for (int l = 0; l <= fillWidth; l++) 67 | { 68 | float luminosity = (float)l / (float)fillWidth; 69 | Color color5 = Main.hslToRgb(Hue, Saturation, luminosity); 70 | Main.spriteBatch.Draw(TextureAssets.ColorBlip.Value, new Vector2((float)(pos.X + l + 5), (float)(pos.Y + 4)), color5); 71 | } 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /UIKit/MasterView.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework.Graphics; 2 | using Microsoft.Xna.Framework.Input; 3 | using Terraria; 4 | using Terraria.GameInput; 5 | 6 | namespace HEROsMod.UIKit 7 | { 8 | internal class MasterView : UIView 9 | { 10 | private static MouseState mouseState = Mouse.GetState(); 11 | private static MouseState previousMouseState = Mouse.GetState(); 12 | private static GameScreen _gameScreen = null; 13 | 14 | public static GameScreen gameScreen 15 | { 16 | get 17 | { 18 | if (_gameScreen == null) 19 | { 20 | _gameScreen = new GameScreen(); 21 | AddChildToMaster(_gameScreen); 22 | } 23 | return _gameScreen; 24 | } 25 | } 26 | 27 | private static MenuScreen _menuScreen = null; 28 | 29 | public static MenuScreen menuScreen 30 | { 31 | get 32 | { 33 | if (_menuScreen == null) 34 | { 35 | _menuScreen = new MenuScreen(); 36 | AddChildToMaster(_menuScreen); 37 | } 38 | return _menuScreen; 39 | } 40 | } 41 | 42 | private static MapScreen _mapScreen = null; 43 | 44 | public static MapScreen mapScreen 45 | { 46 | get 47 | { 48 | if (_mapScreen == null) 49 | { 50 | _mapScreen = new MapScreen(); 51 | AddChildToMaster(_mapScreen); 52 | } 53 | return _mapScreen; 54 | } 55 | } 56 | 57 | protected override float GetWidth() 58 | { 59 | return Main.screenWidth; 60 | } 61 | 62 | protected override float GetHeight() 63 | { 64 | return Main.screenHeight; 65 | } 66 | 67 | private static MasterView masterView = new MasterView(); 68 | 69 | public static void ClearMasterView() 70 | { 71 | masterView.children.Clear(); 72 | _mapScreen = null; 73 | _menuScreen = null; 74 | _gameScreen = null; 75 | } 76 | 77 | public static void UpdateMaster() 78 | { 79 | mouseState = Mouse.GetState(); 80 | UIView.MouseLeftButton = mouseState.LeftButton == ButtonState.Pressed; 81 | UIView.MousePrevLeftButton = previousMouseState.LeftButton == ButtonState.Pressed; 82 | UIView.MouseRightButton = mouseState.RightButton == ButtonState.Pressed; 83 | UIView.MousePrevRightButton = previousMouseState.RightButton == ButtonState.Pressed; 84 | UIView.ScrollAmount = PlayerInput.ScrollWheelDeltaForUI; 85 | // UIView.ScrollAmount = (mouseState.ScrollWheelValue - previousMouseState.ScrollWheelValue) / 2; 86 | previousMouseState = mouseState; 87 | //HoverItem = EmptyItem; 88 | HoverText = ""; 89 | GameMouseOverwritten = false; 90 | masterView.Update(); 91 | } 92 | 93 | public static void DrawMaster(SpriteBatch spriteBatch) 94 | { 95 | spriteBatch.End(); 96 | spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.AnisotropicClamp, DepthStencilState.None, null, null, Main.UIScaleMatrix); 97 | masterView.Draw(spriteBatch); 98 | spriteBatch.End(); 99 | spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.AnisotropicClamp, DepthStencilState.None, null, null, Main.UIScaleMatrix); 100 | //Console.WriteLine("update: " + UpdateCalls + "draws: " + DrawCalls); 101 | } 102 | 103 | public static void AddChildToMaster(UIView view) 104 | { 105 | masterView.AddChild(view); 106 | } 107 | 108 | public static void RemoveChildFromMaster(UIView view) 109 | { 110 | masterView.RemoveChild(view); 111 | } 112 | 113 | public class GameScreen : UIView 114 | { 115 | public GameScreen() 116 | { 117 | this.OverridesMouse = false; 118 | } 119 | 120 | public override void Update() 121 | { 122 | if (!Main.gameMenu && !Main.mapFullscreen) 123 | this.Visible = true; 124 | else this.Visible = false; 125 | base.Update(); 126 | } 127 | 128 | protected override float GetWidth() 129 | { 130 | return this.Parent.Width; 131 | } 132 | 133 | protected override float GetHeight() 134 | { 135 | return this.Parent.Height; 136 | } 137 | } 138 | 139 | public class MenuScreen : UIView 140 | { 141 | public MenuScreen() 142 | { 143 | this.OverridesMouse = false; 144 | } 145 | 146 | public override void Update() 147 | { 148 | this.Visible = Main.gameMenu; 149 | base.Update(); 150 | } 151 | 152 | protected override float GetWidth() 153 | { 154 | return this.Parent.Width; 155 | } 156 | 157 | protected override float GetHeight() 158 | { 159 | return this.Parent.Height; 160 | } 161 | } 162 | 163 | public class MapScreen : UIView 164 | { 165 | public MapScreen() 166 | { 167 | this.OverridesMouse = false; 168 | } 169 | 170 | public override void Update() 171 | { 172 | this.Visible = !Main.gameMenu && Main.mapFullscreen; 173 | base.Update(); 174 | } 175 | 176 | protected override float GetWidth() 177 | { 178 | return this.Parent.Width; 179 | } 180 | 181 | protected override float GetHeight() 182 | { 183 | return this.Parent.Height; 184 | } 185 | } 186 | } 187 | } -------------------------------------------------------------------------------- /UIKit/UIButton.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using ReLogic.Content; 4 | using System; 5 | 6 | namespace HEROsMod.UIKit 7 | { 8 | internal class UIButton : UIView 9 | { 10 | public static Asset buttonBackground; 11 | private static Texture2D buttonFill; 12 | 13 | public static Texture2D ButtonFill 14 | { 15 | get 16 | { 17 | if (buttonFill == null) 18 | { 19 | Color[] edgeColors = new Color[buttonBackground.Value.Width * buttonBackground.Value.Height]; 20 | buttonBackground.Value.GetData(edgeColors); 21 | Color[] fillColors = new Color[buttonBackground.Value.Height]; 22 | for (int y = 0; y < fillColors.Length; y++) 23 | { 24 | fillColors[y] = edgeColors[buttonBackground.Value.Width - 1 + y * buttonBackground.Value.Width]; 25 | } 26 | buttonFill = new Texture2D(UIView.graphics, 1, fillColors.Length); 27 | buttonFill.SetData(fillColors); 28 | } 29 | return buttonFill; 30 | } 31 | } 32 | 33 | private Color hoverColor = new Color(38, 42, 120); 34 | private Color drawColor; 35 | 36 | private UILabel label = new UILabel(""); 37 | 38 | public string Text 39 | { 40 | get { return label.Text; } 41 | set 42 | { 43 | label.Text = value; 44 | label.Anchor = AnchorPosition.Center; 45 | ScaleText(); 46 | label.CenterToParent(); 47 | label.Position = new Vector2(label.Position.X, label.Position.Y + 2); 48 | } 49 | } 50 | 51 | public bool AutoSize { get; set; } 52 | 53 | public UIButton(string text) 54 | { 55 | AutoSize = true; 56 | this.AddChild(label); 57 | this.Text = text; 58 | this.BackgroundColor = new Color(28, 32, 119); 59 | drawColor = BackgroundColor; 60 | this.onMouseEnter += new EventHandler(UIButton_onMouseEnter); 61 | this.onMouseLeave += new EventHandler(UIButton_onMouseLeave); 62 | } 63 | 64 | public UIButton(string text, Color backgroundColor, Color hoverColor) 65 | { 66 | AutoSize = true; 67 | this.AddChild(label); 68 | this.Text = text; 69 | this.BackgroundColor = backgroundColor; 70 | drawColor = BackgroundColor; 71 | this.hoverColor = hoverColor; 72 | this.onMouseEnter += new EventHandler(UIButton_onMouseEnter); 73 | this.onMouseLeave += new EventHandler(UIButton_onMouseLeave); 74 | } 75 | public void SetBackgroundColor(Color color) 76 | { 77 | BackgroundColor = color; 78 | drawColor = BackgroundColor; 79 | } 80 | 81 | public void SetTextColor(Color color) 82 | { 83 | label.ForegroundColor = color; 84 | } 85 | 86 | private void UIButton_onMouseLeave(object sender, EventArgs e) 87 | { 88 | drawColor = BackgroundColor; 89 | } 90 | 91 | private void UIButton_onMouseEnter(object sender, EventArgs e) 92 | { 93 | drawColor = hoverColor; 94 | } 95 | 96 | private float width = 0; 97 | 98 | protected override float GetWidth() 99 | { 100 | if (AutoSize) 101 | { 102 | return label.Width + buttonBackground.Value.Width * 2 + 30; 103 | } 104 | else 105 | { 106 | return width; 107 | } 108 | } 109 | 110 | protected override void SetWidth(float width) 111 | { 112 | this.width = width; 113 | 114 | ScaleText(); 115 | label.CenterToParent(); 116 | label.Position = new Vector2(label.Position.X, label.Position.Y + 2); 117 | } 118 | 119 | protected override float GetHeight() 120 | { 121 | return buttonBackground.Value.Height; 122 | } 123 | 124 | private void ScaleText() 125 | { 126 | if (!AutoSize) 127 | { 128 | Vector2 size = label.font.MeasureString(label.Text); 129 | if (size.X > width - (buttonBackground.Value.Width * 2 + 10)) 130 | { 131 | label.Scale = (width - (buttonBackground.Value.Width * 2 + 10)) / size.X; 132 | if (size.Y * label.Scale > this.Height) label.Scale = this.Height / size.Y; 133 | } 134 | else label.Scale = this.Height / size.Y; 135 | } 136 | else label.Scale = this.Height / label.font.MeasureString(label.Text).Y; 137 | } 138 | 139 | public override void Draw(SpriteBatch spriteBatch) 140 | { 141 | spriteBatch.Draw(buttonBackground.Value, DrawPosition, null, drawColor * Opacity, 0f, Origin, 1f, SpriteEffects.None, 0f); 142 | int fillWidth = (int)Width - 2 * buttonBackground.Value.Width; 143 | Vector2 pos = DrawPosition; 144 | pos.X += buttonBackground.Value.Width; 145 | spriteBatch.Draw(ButtonFill, pos - Origin, null, drawColor * Opacity, 0f, Vector2.Zero, new Vector2(fillWidth, 1f), SpriteEffects.None, 0f); 146 | pos.X += fillWidth; 147 | spriteBatch.Draw(buttonBackground.Value, pos, null, drawColor * Opacity, 0f, Origin, 1f, SpriteEffects.FlipHorizontally, 0f); 148 | base.Draw(spriteBatch); 149 | } 150 | } 151 | } -------------------------------------------------------------------------------- /UIKit/UICheckbox.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using ReLogic.Content; 4 | using System; 5 | 6 | namespace HEROsMod.UIKit 7 | { 8 | internal class UICheckbox : UIView 9 | { 10 | internal static Asset checkboxTexture; 11 | internal static Asset checkmarkTexture; 12 | 13 | private bool selected = false; 14 | 15 | public bool Selected 16 | { 17 | get { return selected; } 18 | set 19 | { 20 | if (value != selected) 21 | { 22 | selected = value; 23 | if (SelectedChanged != null) 24 | SelectedChanged(this, EventArgs.Empty); 25 | } 26 | } 27 | } 28 | 29 | public string Text 30 | { 31 | get { return label.Text; } 32 | set { label.Text = value; } 33 | } 34 | 35 | public event EventHandler SelectedChanged; 36 | 37 | private const int spacing = 4; 38 | 39 | private UILabel label; 40 | 41 | public UICheckbox(string text) 42 | { 43 | label = new UILabel(text); 44 | label.Scale = .5f; 45 | label.Position = new Vector2(checkboxTexture.Value.Width + spacing, 0); 46 | this.AddChild(label); 47 | this.onLeftClick += new EventHandler(UICheckbox_onLeftClick); 48 | } 49 | 50 | private void UICheckbox_onLeftClick(object sender, EventArgs e) 51 | { 52 | this.Selected = !Selected; 53 | } 54 | 55 | protected override float GetHeight() 56 | { 57 | return label.Height; 58 | } 59 | 60 | protected override float GetWidth() 61 | { 62 | return checkboxTexture.Value.Width + spacing + label.Width; 63 | } 64 | 65 | public override void Draw(SpriteBatch spriteBatch) 66 | { 67 | Vector2 pos = DrawPosition + new Vector2(0, (float)label.Height / 2 - (float)checkboxTexture.Value.Height / 1.2f); 68 | spriteBatch.Draw(checkboxTexture.Value, pos, null, Color.White, 0f, Origin, 1f, SpriteEffects.None, 0f); 69 | if (Selected) 70 | spriteBatch.Draw(checkmarkTexture.Value, pos, null, Color.White, 0f, Origin, 1f, SpriteEffects.None, 0f); 71 | 72 | base.Draw(spriteBatch); 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /UIKit/UIColorPicker.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using System; 3 | using Terraria; 4 | 5 | namespace HEROsMod.UIKit 6 | { 7 | internal class UIColorPicker : UIView 8 | { 9 | public event EventHandler ColorChanged; 10 | 11 | public Color Color 12 | { 13 | get { return Main.hslToRgb(Hue, Saturation, Luminosity); } 14 | set 15 | { 16 | Vector3 hsl = Main.rgbToHsl(value); 17 | Hue = hsl.X; 18 | Saturation = hsl.Y; 19 | Luminosity = hsl.Z; 20 | } 21 | } 22 | 23 | public float Hue 24 | { 25 | get { return hueSlider.Value; } 26 | set 27 | { 28 | hueSlider.Value = value; 29 | saturationSlider.Hue = value; 30 | luminositySlider.Hue = value; 31 | } 32 | } 33 | 34 | public float Saturation 35 | { 36 | get { return saturationSlider.Value; } 37 | set 38 | { 39 | saturationSlider.Value = value; 40 | luminositySlider.Saturation = value; 41 | } 42 | } 43 | 44 | public float Luminosity 45 | { 46 | get { return luminositySlider.Value; } 47 | set 48 | { 49 | luminositySlider.Value = value; 50 | saturationSlider.Luminosity = value; 51 | } 52 | } 53 | 54 | private HueSlider hueSlider; 55 | private SaturationSlider saturationSlider; 56 | private LuminositySlider luminositySlider; 57 | 58 | public UIColorPicker() 59 | { 60 | hueSlider = new HueSlider(); 61 | saturationSlider = new SaturationSlider(); 62 | luminositySlider = new LuminositySlider(); 63 | 64 | saturationSlider.Y = hueSlider.Height; 65 | luminositySlider.Y = saturationSlider.Y + saturationSlider.Height; 66 | this.Width = hueSlider.Width; 67 | this.Height = luminositySlider.Y + luminositySlider.Height; 68 | 69 | hueSlider.valueChanged += hueSlider_valueChanged; 70 | saturationSlider.valueChanged += saturationSlider_valueChanged; 71 | luminositySlider.valueChanged += luminositySlider_valueChanged; 72 | 73 | this.Color = Color.White; 74 | 75 | AddChild(hueSlider); 76 | AddChild(saturationSlider); 77 | AddChild(luminositySlider); 78 | } 79 | 80 | private void TriggerColorChangedEvent() 81 | { 82 | if (ColorChanged != null) 83 | { 84 | ColorChanged(this, EventArgs.Empty); 85 | } 86 | } 87 | 88 | private void luminositySlider_valueChanged(object sender, float value) 89 | { 90 | Luminosity = luminositySlider.Value; 91 | TriggerColorChangedEvent(); 92 | } 93 | 94 | private void saturationSlider_valueChanged(object sender, float value) 95 | { 96 | Saturation = saturationSlider.Value; 97 | TriggerColorChangedEvent(); 98 | } 99 | 100 | private void hueSlider_valueChanged(object sender, float value) 101 | { 102 | Hue = hueSlider.Value; 103 | TriggerColorChangedEvent(); 104 | } 105 | } 106 | } -------------------------------------------------------------------------------- /UIKit/UIColorSlider.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | 4 | namespace HEROsMod.UIKit 5 | { 6 | internal class UIColorSlider : UISlider 7 | { 8 | protected override float GetWidth() 9 | { 10 | return ModUtils.HueTexture.Width; 11 | } 12 | 13 | public override void Draw(SpriteBatch spriteBatch) 14 | { 15 | Vector2 pos = DrawPosition; 16 | pos.Y += (sliderTexture.Value.Height - ModUtils.HueTexture.Height) / 2; 17 | spriteBatch.Draw(ModUtils.HueTexture, pos, null, BackgroundColor, 0f, Origin, 1f, SpriteEffects.None, 0f); 18 | Vector2 sliderPos = DrawPosition; 19 | sliderPos.X += padding - sliderTexture.Value.Width / 2; 20 | sliderPos.X += (Width - padding * 2) * ((Value - MinValue) / (MaxValue - MinValue)); 21 | spriteBatch.Draw(sliderTexture.Value, sliderPos, null, BackgroundColor, 0f, Origin, 1f, SpriteEffects.None, 0f); 22 | //base.Draw(spriteBatch); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /UIKit/UIComponents/DropTableView.cs: -------------------------------------------------------------------------------- 1 | //using System; 2 | //using System.Collections.Generic; 3 | //using System.Linq; 4 | //using System.Text; 5 | //using HEROsMod.UIKit; 6 | //using HEROsMod.HEROsModVideo.Services.DropRateInfo; 7 | 8 | //using Terraria; 9 | 10 | //namespace HEROsMod.UIKit.UIComponents 11 | //{ 12 | // class DropTableView : UIView 13 | // { 14 | // NPCDropTable dropTable; 15 | // int iconSize = 32; 16 | // public DropTableView(NPCDropTable dropTable, float width) 17 | // { 18 | // this.Width = width; 19 | // this.Height = 0; 20 | // this.dropTable = dropTable; 21 | // PopulateList(); 22 | // } 23 | 24 | // public void PopulateList() 25 | // { 26 | // this.RemoveAllChildren(); 27 | // float yPos = 0f; 28 | 29 | // if (dropTable.MoneyDrops > 0) 30 | // { 31 | // MoneyView minMoney = new MoneyView(dropTable.MinMoney); 32 | // //minMoney.X = Spacing * 2 + 40; 33 | // AddChild(minMoney); 34 | 35 | // UILabel seperator = new UILabel(" - "); 36 | // seperator.Scale = .4f; 37 | // seperator.X = minMoney.X + minMoney.Width; 38 | // AddChild(seperator); 39 | 40 | // MoneyView maxMoney = new MoneyView(dropTable.MaxMoney); 41 | // maxMoney.X = seperator.X + seperator.Width; 42 | // AddChild(maxMoney); 43 | 44 | // yPos = minMoney.Y + minMoney.Height + 2; 45 | // } 46 | 47 | // float amountWidth = 35f; 48 | // foreach(var item in dropTable.Drops) 49 | // { 50 | // string dropAmount = GetDropAmount(item); 51 | 52 | // UIImage itemImage = new UIImage(Main.itemTexture[item.NPCType]); 53 | // itemImage.Anchor = AnchorPosition.Center; 54 | // itemImage.X = amountWidth + iconSize / 2; 55 | // itemImage.Y = yPos + iconSize / 2; 56 | // float itemScale = 1f; 57 | // float pixelWidth = iconSize; 58 | // if (itemImage.Width > pixelWidth || itemImage.Height > pixelWidth) 59 | // { 60 | // if (itemImage.Width > itemImage.Height) 61 | // { 62 | // itemScale = pixelWidth / (float)itemImage.Width; 63 | // } 64 | // else 65 | // { 66 | // itemScale = pixelWidth / (float)itemImage.Height; 67 | // } 68 | // } 69 | // itemImage.Scale = itemScale; 70 | // AddChild(itemImage); 71 | 72 | // if (dropAmount.Length > 0) 73 | // { 74 | // UILabel lDropAmount = new UILabel(dropAmount); 75 | // lDropAmount.Scale = .3f; 76 | // lDropAmount.Anchor = AnchorPosition.Center; 77 | // lDropAmount.X = amountWidth / 2; 78 | // lDropAmount.Y = itemImage.Y; 79 | // AddChild(lDropAmount); 80 | // } 81 | 82 | // UILabel lName = new UILabel(Lang.itemName(item.NPCType, true)); 83 | // lName.Anchor = AnchorPosition.Left; 84 | // lName.Scale = .35f; 85 | // lName.X = itemImage.X + iconSize / 2 + Spacing; 86 | // lName.Y = itemImage.Y; 87 | // AddChild(lName); 88 | 89 | // float percent = item.Percent * 100; 90 | // percent = (float)Math.Round(percent, 2); 91 | // UILabel lPercentage = new UILabel("%" + percent); 92 | // lPercentage.Anchor = AnchorPosition.Left; 93 | // lPercentage.Scale = .35f; 94 | // lPercentage.X = this.Width - lPercentage.Width - Spacing; 95 | // lPercentage.Y = itemImage.Y; 96 | // AddChild(lPercentage); 97 | 98 | // yPos += iconSize + 2; 99 | // } 100 | // this.Height = yPos; 101 | // } 102 | 103 | // private string GetDropAmount(ItemDropInfo item) 104 | // { 105 | // if(item.Min == item.Max) 106 | // { 107 | // if(item.Min == 1) 108 | // { 109 | // return ""; 110 | // } 111 | // else 112 | // { 113 | // return item.Min.ToString(); 114 | // } 115 | // } 116 | // else 117 | // { 118 | // return item.Min + "-" + item.Max; 119 | // } 120 | // } 121 | 122 | // } 123 | //} -------------------------------------------------------------------------------- /UIKit/UIComponents/HostPlayWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using Terraria; 4 | 5 | namespace HEROsMod.UIKit.UIComponents 6 | { 7 | internal class HostPlayWindow : UIWindow 8 | { 9 | public HostPlayWindow() 10 | { 11 | this.Anchor = AnchorPosition.Center; 12 | UIWrappingLabel label = new UIWrappingLabel("Host & Play is not supported in Gamiki Mod. Read our post about it by clicking the button below.", this.Width - 32f); 13 | label.X = 16f; 14 | label.Y = 16f; 15 | UIButton bOk = new UIButton("Ok"); 16 | UIButton bPost = new UIButton("View Post"); 17 | 18 | bOk.Y = label.Y + label.Height + 16f; 19 | bOk.X = Width - bOk.Width - 16f; 20 | bPost.Y = bOk.Y; 21 | bPost.X = bOk.X - bPost.Width - 16f; 22 | Height = bOk.Y + bOk.Height + 16f; 23 | 24 | bOk.onLeftClick += bOk_onLeftClick; 25 | bPost.onLeftClick += bPost_onLeftClick; 26 | 27 | this.AddChild(label); 28 | this.AddChild(bOk); 29 | this.AddChild(bPost); 30 | this.CenterToParent(); 31 | } 32 | 33 | private void bPost_onLeftClick(object sender, EventArgs e) 34 | { 35 | System.Diagnostics.Process.Start("http://HEROsModMod.com/Terraria_Forum/thread/Host__Play-2348"); 36 | } 37 | 38 | private void bOk_onLeftClick(object sender, EventArgs e) 39 | { 40 | Main.menuMode = 12; 41 | this.Parent.RemoveChild(this); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /UIKit/UIComponents/ItemCollectionView.cs: -------------------------------------------------------------------------------- 1 | using Terraria; 2 | using Terraria.GameContent; 3 | 4 | namespace HEROsMod.UIKit.UIComponents 5 | { 6 | internal class ItemCollectionView : UIScrollView 7 | { 8 | private Item[] _items; 9 | 10 | public Item[] Items 11 | { 12 | get { return _items; } 13 | set 14 | { 15 | _items = value; 16 | RepopulateSlots(); 17 | } 18 | } 19 | 20 | private int slotSpace = 4; 21 | private int slotColumns = 8; 22 | private float slotSize = Slot.backgroundTexture.Width * .85f; 23 | private int slotRows = 4; 24 | private Slot[] slots = new Slot[TextureAssets.Item.Length]; 25 | 26 | public ItemCollectionView() 27 | { 28 | Width = (slotSize + slotSpace) * slotColumns + slotSpace + 20; 29 | Height = (slotSize + slotSpace) * slotRows + slotSpace + 20;//300; 30 | 31 | int numOfSlots = slotRows * slotColumns; 32 | 33 | for (int i = 0; i < slots.Length; i++) 34 | { 35 | slots[i] = new Slot(0); 36 | Slot slot = slots[i]; 37 | int x = i % slotColumns; 38 | int y = i / slotColumns; 39 | slot.X = slotSpace + x * (slot.Width + slotSpace); 40 | slot.Y = slotSpace + y * (slot.Height + slotSpace); 41 | } 42 | } 43 | 44 | public void RepopulateSlots() 45 | { 46 | ClearContent(); 47 | for (int i = 0; i < slots.Length; i++) 48 | { 49 | Slot slot = slots[i]; 50 | if (i < Items.Length) 51 | { 52 | slot.Visible = true; 53 | slot.item = Items[i]; 54 | this.ContentHeight = slot.Y + slot.Height + Spacing; 55 | AddChild(slot); 56 | } 57 | else 58 | { 59 | slots[i].Visible = false; 60 | } 61 | } 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /UIKit/UIComponents/ItemView.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using ReLogic.Content; 4 | using ReLogic.Graphics; 5 | using System; 6 | using Terraria; 7 | using Terraria.GameContent; 8 | using Terraria.ModLoader; 9 | 10 | namespace HEROsMod.UIKit.UIComponents 11 | { 12 | internal class ItemView : UIView 13 | { 14 | private Asset _demonAltarTexture = null; 15 | 16 | private Asset DemonAltarTexture 17 | { 18 | get 19 | { 20 | if (_demonAltarTexture == null) 21 | { 22 | _demonAltarTexture = HEROsMod.instance.Assets.Request("Images/Demon_Altar", AssetRequestMode.ImmediateLoad); 23 | } 24 | return _demonAltarTexture; 25 | } 26 | } 27 | 28 | public Item item = new Item(); 29 | public int index = -1; 30 | 31 | public ItemView(Item item) 32 | { 33 | this.Scale = .85f; 34 | this.item = item.Clone(); 35 | this.onHover += Slot2_onHover; 36 | } 37 | 38 | private void Slot2_onHover(object sender, EventArgs e) 39 | { 40 | HoverText = item.Name; 41 | //HoverItem = item.Clone(); 42 | } 43 | 44 | public override void Draw(SpriteBatch spriteBatch) 45 | { 46 | //Demon altar exception 47 | Texture2D texture = null; 48 | if (item.netID == -1000) 49 | { 50 | texture = DemonAltarTexture.Value; 51 | } 52 | else 53 | { 54 | ModUtils.LoadItem(item.type); 55 | texture = TextureAssets.Item[item.type].Value; 56 | } 57 | 58 | float itemScale = 1f; 59 | float pixelWidth = Width * Scale; 60 | if (texture.Width > pixelWidth || texture.Height > pixelWidth) 61 | { 62 | if (texture.Width > texture.Height) 63 | { 64 | itemScale = pixelWidth / (float)texture.Width; 65 | } 66 | else 67 | { 68 | itemScale = pixelWidth / (float)texture.Height; 69 | } 70 | } 71 | //itemScale *= Scale; 72 | 73 | Vector2 pos = DrawPosition; 74 | 75 | //spriteBatch.Draw(ModUtils.DummyTexture, new Rectangle((int)pos.X, (int)pos.Y, (int)Width, (int)Height), Color.Red); 76 | 77 | Vector2 texturePos = new Vector2(this.Width / 2, this.Height / 2); 78 | Vector2 itemOrigin = new Vector2(texture.Width / 2, texture.Height / 2); 79 | 80 | pos += texturePos; 81 | 82 | spriteBatch.Draw(texture, pos, null, item.GetAlpha(Color.White), 0f, itemOrigin, itemScale, SpriteEffects.None, 0f); 83 | if (item.color != default(Color)) 84 | { 85 | spriteBatch.Draw(texture, pos, null, item.GetColor(Color.White), 0f, itemOrigin, itemScale, SpriteEffects.None, 0f); 86 | } 87 | if (item.stack > 1) 88 | { 89 | spriteBatch.DrawString(FontAssets.ItemStack.Value, item.stack.ToString(), new Vector2(DrawPosition.X + 10f * Scale, DrawPosition.Y + 26f * Scale), Color.White, 0f, Vector2.Zero, Scale, SpriteEffects.None, 0f); 90 | } 91 | base.Draw(spriteBatch); 92 | } 93 | } 94 | } -------------------------------------------------------------------------------- /UIKit/UIComponents/MoneyView.cs: -------------------------------------------------------------------------------- 1 | //using System; 2 | //using System.Collections.Generic; 3 | //using System.Linq; 4 | //using System.Text; 5 | //using HEROsMod.HEROsModVideo.Services.DropRateInfo; 6 | 7 | //using Terraria; 8 | 9 | //namespace HEROsMod.UIKit.UIComponents 10 | //{ 11 | // class MoneyView : UIView 12 | // { 13 | // private int _amount; 14 | // public int Amount 15 | // { 16 | // get 17 | // { 18 | // return _amount; 19 | // } 20 | // set 21 | // { 22 | // _amount = value; 23 | // Refresh(); 24 | // } 25 | // } 26 | 27 | // public MoneyView(int amount) 28 | // { 29 | // this.Amount = amount; 30 | // } 31 | 32 | // private void Refresh() 33 | // { 34 | // this.RemoveAllChildren(); 35 | // if(Amount > 0) 36 | // { 37 | // int amount = Amount; 38 | // int platinum = amount / DropCollection.PLATINUM_VALUE; 39 | // amount -= platinum * DropCollection.PLATINUM_VALUE; 40 | // int gold = amount / DropCollection.GOLD_VALUE; 41 | // amount -= gold * DropCollection.GOLD_VALUE; 42 | // int silver = amount / DropCollection.SILVER_VALUE; 43 | // amount -= silver * DropCollection.SILVER_VALUE; 44 | // int copper = amount; 45 | 46 | // float xPos = 0f; 47 | // if (platinum > 0) 48 | // { 49 | // AddCoin(platinum, 74, ref xPos); 50 | // } 51 | // if (gold > 0) 52 | // { 53 | // AddCoin(gold, 73, ref xPos); 54 | // } 55 | // if (silver > 0) 56 | // { 57 | // AddCoin(silver, 72, ref xPos); 58 | // } 59 | // if (copper > 0) 60 | // { 61 | // AddCoin(copper, 71, ref xPos); 62 | // } 63 | // this.Width = xPos; 64 | // } 65 | // } 66 | 67 | // private void AddCoin(int amount, int type, ref float xPos) 68 | // { 69 | // UILabel lAmount = new UILabel(amount.ToString()); 70 | // lAmount.Scale = .4f; 71 | // lAmount.X = xPos + 2; 72 | // this.Height = lAmount.Height; 73 | // AddChild(lAmount); 74 | 75 | // UIImage coin = new UIImage(Main.itemTexture[type]); 76 | // coin.Anchor = AnchorPosition.Left; 77 | // coin.Y = this.Height / 2.5f; 78 | // coin.X = lAmount.X + lAmount.Width; 79 | // AddChild(coin); 80 | 81 | // xPos = coin.X + coin.Width; 82 | // } 83 | // } 84 | //} -------------------------------------------------------------------------------- /UIKit/UIComponents/SliderWithTextbox.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace HEROsMod.UIKit.UIComponents 4 | { 5 | internal class SliderWithTextbox : UIView 6 | { 7 | public float Value 8 | { 9 | get { return slider.Value; } 10 | set 11 | { 12 | slider.Value = value; 13 | } 14 | } 15 | 16 | public float Min 17 | { 18 | get { return slider.MinValue; } 19 | set { slider.MinValue = value; } 20 | } 21 | 22 | public float Max 23 | { 24 | get { return slider.MaxValue; } 25 | set { slider.MaxValue = value; } 26 | } 27 | 28 | public event EventHandler ValueChanged; 29 | 30 | private UITextbox textbox; 31 | private UISlider slider; 32 | 33 | public SliderWithTextbox(float startValue, float minValue, float maxValue) 34 | { 35 | textbox = new UITextbox(); 36 | textbox.Width = 125; 37 | textbox.KeyPressed += textbox_KeyPressed; 38 | textbox.OnLostFocus += textbox_OnLostFocus; 39 | textbox.Numeric = true; 40 | textbox.HasDecimal = true; 41 | slider = new UISlider(); 42 | slider.valueChanged += slider_valueChanged; 43 | 44 | slider.X = textbox.X + textbox.Width + Spacing; 45 | AddChild(textbox); 46 | AddChild(slider); 47 | 48 | slider.MinValue = minValue; 49 | slider.MaxValue = maxValue; 50 | slider.Value = startValue; 51 | 52 | textbox.Text = slider.Value.ToString(); 53 | 54 | this.Height = textbox.Height; 55 | this.Width = slider.X + slider.Width; 56 | } 57 | 58 | private void textbox_OnLostFocus(object sender, EventArgs e) 59 | { 60 | textbox.Text = slider.Value.ToString(); 61 | } 62 | 63 | private void textbox_KeyPressed(object sender, char key) 64 | { 65 | if (textbox.Text.Length == 0 || textbox.Text == "-") 66 | { 67 | slider.Value = slider.MinValue; 68 | return; 69 | } 70 | slider.Value = float.Parse(textbox.Text); 71 | if (ValueChanged != null) 72 | { 73 | ValueChanged(this, EventArgs.Empty); 74 | } 75 | } 76 | 77 | private void slider_valueChanged(object sender, float value) 78 | { 79 | if (!textbox.HadFocus) 80 | { 81 | textbox.Text = slider.Value.ToString(); 82 | } 83 | if (ValueChanged != null) 84 | { 85 | ValueChanged(this, EventArgs.Empty); 86 | } 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /UIKit/UIComponents/UIHotbar.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using Terraria; 4 | 5 | namespace HEROsMod.UIKit.UIComponents 6 | { 7 | internal class UIHotbar : UIWindow 8 | { 9 | internal RasterizerState _rasterizerState = new RasterizerState 10 | { 11 | ScissorTestEnable = true 12 | }; 13 | 14 | internal static float slideMoveSpeed = 8f; 15 | internal float lerpAmount; 16 | 17 | //internal UIHotbar parentHotbar; 18 | internal UIView HotBarParent; 19 | 20 | internal float shownPosition 21 | { 22 | get 23 | { 24 | return (float)Main.screenHeight - base.Height * 2 - 12f + 6; 25 | } 26 | } 27 | 28 | internal float hiddenPosition 29 | { 30 | get 31 | { 32 | if (HotBarParent != null) 33 | { 34 | return (float)Main.screenHeight - base.Height - 12f; 35 | } 36 | //else if (mod.hotbar != null && !mod.hotbar.hidden && hidden) 37 | //{ 38 | // return (float)Main.screenHeight - base.Height - 12f; 39 | //} 40 | else 41 | { 42 | return (float)Main.screenHeight; 43 | } 44 | } 45 | } 46 | 47 | public void Hide() 48 | { 49 | hidden = true; 50 | arrived = false; 51 | } 52 | 53 | public void Show() 54 | { 55 | arrived = false; 56 | hidden = false; 57 | Visible = true; 58 | } 59 | 60 | public virtual void RefreshHotbar() 61 | { 62 | } 63 | 64 | public override void Update() 65 | { 66 | DoSlideMovement(); 67 | base.Update(); 68 | } 69 | 70 | internal float spacing = 8f; 71 | 72 | public bool hidden; 73 | internal bool arrived; 74 | 75 | private bool _selected; 76 | 77 | internal bool selected 78 | { 79 | get { return _selected; } 80 | set 81 | { 82 | if (value == false) 83 | { 84 | hidden = true; 85 | } 86 | else 87 | { 88 | hidden = false; 89 | Visible = true; 90 | //HotBarParent 91 | if (HEROsMod.ServiceHotbar.HotBarChild != null && HEROsMod.ServiceHotbar.HotBarChild != this) 92 | { 93 | HEROsMod.ServiceHotbar.HotBarChild.selected = false; 94 | } 95 | this.CenterXAxisToParentCenter(); 96 | HEROsMod.ServiceHotbar.HotBarChild = this; 97 | } 98 | arrived = false; 99 | _selected = value; 100 | } 101 | } 102 | 103 | public UIView buttonView; 104 | internal static Color buttonUnselectedColor = Color.LightSkyBlue; 105 | internal static Color buttonSelectedColor = Color.White; 106 | internal static Color buttonSelectedHiddenColor = Color.Blue; 107 | 108 | internal void DoSlideMovement() 109 | { 110 | if (!arrived) 111 | { 112 | //Main.NewText("Not Arrived"); 113 | 114 | if (this.hidden) 115 | { 116 | this.lerpAmount -= .01f * slideMoveSpeed; 117 | if (this.lerpAmount < 0f) 118 | { 119 | this.lerpAmount = 0f; 120 | arrived = true; 121 | // Main.NewText("Arrived, Not Visible"); 122 | this.Visible = false; 123 | } 124 | float y = MathHelper.SmoothStep(this.hiddenPosition, this.shownPosition, this.lerpAmount); 125 | base.Position = new Vector2(base.Position.X, y); 126 | } 127 | else 128 | { 129 | this.lerpAmount += .01f * slideMoveSpeed; 130 | if (this.lerpAmount > 1f) 131 | { 132 | this.lerpAmount = 1f; 133 | arrived = true; 134 | // Main.NewText("Arrived, Visible"); 135 | } 136 | float y2 = MathHelper.SmoothStep(this.hiddenPosition, this.shownPosition, this.lerpAmount); 137 | base.Position = new Vector2(base.Position.X, y2); 138 | } 139 | } 140 | else if(!hidden) 141 | { 142 | Position = new Vector2(Position.X, shownPosition); 143 | } 144 | } 145 | 146 | public override void Draw(SpriteBatch spriteBatch) 147 | { 148 | if (Visible) 149 | { 150 | spriteBatch.End(); 151 | //spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, this._rasterizerState); 152 | spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, null, null, this._rasterizerState, null, Main.UIScaleMatrix); 153 | // Rectangle scissorRectangle = new Rectangle((int)base.X- (int)base.Width, (int)base.Y, (int)base.Width, (int)base.Height); 154 | //Parent.Position.Y 155 | // Main.NewText((int)Parent.Position.Y + " " + (int)shownPosition); 156 | // Rectangle scissorRectangle = new Rectangle((int)(base.X - base.Width / 2), (int)(shownPosition), (int)base.Width, (int)base.Height); 157 | Rectangle scissorRectangle = new Rectangle((int)(base.X - base.Width / 2), (int)(shownPosition), (int)base.Width, (int)(HotBarParent.Position.Y - shownPosition)); 158 | /*if (scissorRectangle.X < 0) 159 | { 160 | scissorRectangle.Width += scissorRectangle.X; 161 | scissorRectangle.X = 0; 162 | } 163 | if (scissorRectangle.Y < 0) 164 | { 165 | scissorRectangle.Height += scissorRectangle.Y; 166 | scissorRectangle.Y = 0; 167 | } 168 | if ((float)scissorRectangle.X + base.Width > (float)Main.screenWidth) 169 | { 170 | scissorRectangle.Width = Main.screenWidth - scissorRectangle.X; 171 | } 172 | if ((float)scissorRectangle.Y + base.Height > (float)Main.screenHeight) 173 | { 174 | scissorRectangle.Height = Main.screenHeight - scissorRectangle.Y; 175 | }*/ 176 | scissorRectangle = ModUtils.GetClippingRectangle(spriteBatch, scissorRectangle); 177 | Rectangle scissorRectangle2 = spriteBatch.GraphicsDevice.ScissorRectangle; 178 | spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle; 179 | 180 | base.Draw(spriteBatch); 181 | 182 | spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle2; 183 | spriteBatch.End(); 184 | spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix); 185 | } 186 | // base.Draw(spriteBatch); 187 | } 188 | } 189 | } -------------------------------------------------------------------------------- /UIKit/UIDropdown.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using ReLogic.Content; 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace HEROsMod.UIKit 8 | { 9 | internal class UIDropdown : UIView 10 | { 11 | internal static Asset capUp; 12 | internal static Asset capDown; 13 | private bool itemsShown = false; 14 | private UIWindow itemsWindow = new UIWindow(); 15 | private int selectedItem = 0; 16 | 17 | public int SelectedItem 18 | { 19 | get { return selectedItem; } 20 | set 21 | { 22 | selectedItem = value; 23 | selectedLabel.Text = items[value]; 24 | } 25 | } 26 | 27 | private List items = new List(); 28 | private UILabel selectedLabel = new UILabel(""); 29 | public int ItemCount { get { return items.Count; } } 30 | public string Text { get { return selectedLabel.Text; } } 31 | 32 | public event EventHandler selectedChanged; 33 | 34 | public bool ItemsVisible { get { return itemsWindow.Visible; } } 35 | 36 | public UIDropdown() 37 | { 38 | this.UpdateWhenOutOfBounds = true; 39 | itemsWindow.UpdateWhenOutOfBounds = true; 40 | selectedLabel.ForegroundColor = Color.Black; 41 | selectedLabel.Scale = .5f; 42 | selectedLabel.X = 6; 43 | selectedLabel.TextOutline = false; 44 | itemsWindow.UpdateWhenOutOfBounds = true; 45 | itemsWindow.BackgroundColor = new Color(81, 91, 184); 46 | this.onLeftClick += UIDropdown_onLeftClick; 47 | AddChild(selectedLabel); 48 | AddChild(itemsWindow); 49 | itemsWindow.Visible = false; 50 | selectedChanged += UIDropdown_selectedChanged; 51 | } 52 | 53 | private void UIDropdown_selectedChanged(object sender, EventArgs e) 54 | { 55 | MouseLeftButton = false; 56 | } 57 | 58 | private void UIDropdown_onLeftClick(object sender, EventArgs e) 59 | { 60 | this.MoveToFront(); 61 | ToggleShowingItems(); 62 | } 63 | 64 | private void ToggleShowingItems() 65 | { 66 | if (itemsShown) HideItems(); 67 | else ShowItems(); 68 | } 69 | 70 | private void ShowItems() 71 | { 72 | itemsWindow.Visible = true; 73 | itemsShown = true; 74 | } 75 | 76 | private void HideItems() 77 | { 78 | itemsWindow.Visible = false; 79 | itemsShown = false; 80 | } 81 | 82 | public void AddItem(string item) 83 | { 84 | items.Add(item); 85 | if (itemsWindow.ChildCount == 0) selectedLabel.Text = item; 86 | UILabel label = new UILabel(item); 87 | UIRect bg = new UIRect(); 88 | label.Scale = .4f; 89 | label.X = 8; 90 | bg.X = 3; 91 | bg.Y = Height + ((label.Height) * itemsWindow.ChildCount); 92 | label.Tag = itemsWindow.ChildCount; 93 | bg.Tag = label.Tag; 94 | label.onLeftClick += label_onLeftClick; 95 | bg.onLeftClick += label_onLeftClick; 96 | bg.Width = itemsWindow.Width - 6; 97 | bg.Height = label.Height; 98 | bg.ForegroundColor = Color.White * 0f; 99 | bg.onMouseEnter += bg_onMouseEnter; 100 | bg.onMouseLeave += bg_onMouseLeave; 101 | 102 | itemsWindow.Height = bg.Y + bg.Height + 8; 103 | bg.AddChild(label); 104 | itemsWindow.AddChild(bg); 105 | } 106 | 107 | private void bg_onMouseLeave(object sender, EventArgs e) 108 | { 109 | UIRect rect = (UIRect)sender; 110 | rect.ForegroundColor = Color.White * 0f; 111 | } 112 | 113 | private void bg_onMouseEnter(object sender, EventArgs e) 114 | { 115 | UIRect rect = (UIRect)sender; 116 | rect.ForegroundColor = Color.Black * .1f; 117 | } 118 | 119 | public string GetItem(int index) 120 | { 121 | return items[index]; 122 | } 123 | 124 | public void ClearItems() 125 | { 126 | itemsWindow.RemoveAllChildren(); 127 | selectedItem = 0; 128 | selectedLabel.Text = ""; 129 | items.Clear(); 130 | } 131 | 132 | private void label_onLeftClick(object sender, EventArgs e) 133 | { 134 | this.MoveToFront(); 135 | UIView label = (UIView)sender; 136 | int tag = (int)label.Tag; 137 | selectedLabel.Text = items[tag]; 138 | if (tag != selectedItem) 139 | { 140 | selectedItem = tag; 141 | if (selectedChanged != null) 142 | selectedChanged(this, new EventArgs()); 143 | } 144 | HideItems(); 145 | UIView.MouseLeftButton = false; 146 | } 147 | 148 | private float width = 0; 149 | 150 | protected override float GetWidth() 151 | { 152 | return width; 153 | } 154 | 155 | protected override void SetWidth(float width) 156 | { 157 | this.width = width; 158 | itemsWindow.Width = width; 159 | } 160 | 161 | protected override float GetHeight() 162 | { 163 | if (itemsWindow.Visible) 164 | return itemsWindow.Height; 165 | else return UIButton.buttonBackground.Value.Height; 166 | } 167 | 168 | public override void Update() 169 | { 170 | if (itemsShown && !itemsWindow.MouseInside && MouseLeftButton) 171 | { 172 | HideItems(); 173 | } 174 | base.Update(); 175 | } 176 | 177 | public override void Draw(SpriteBatch spriteBatch) 178 | { 179 | itemsWindow.Draw(spriteBatch); 180 | spriteBatch.Draw(UIButton.buttonBackground.Value, DrawPosition, null, BackgroundColor, 0f, Origin, 1f, SpriteEffects.None, 0f); 181 | int fillWidth = (int)Width - 2 * UIButton.buttonBackground.Value.Width; 182 | Vector2 pos = DrawPosition; 183 | pos.X += UIButton.buttonBackground.Value.Width; 184 | spriteBatch.Draw(UIButton.ButtonFill, pos - Origin, null, BackgroundColor, 0f, Vector2.Zero, new Vector2(fillWidth, 1f), SpriteEffects.None, 0f); 185 | pos.X += fillWidth; 186 | spriteBatch.Draw(UIButton.buttonBackground.Value, pos, null, BackgroundColor, 0f, Origin, 1f, SpriteEffects.FlipHorizontally, 0f); 187 | if (itemsWindow.Visible) 188 | spriteBatch.Draw(capUp.Value, new Vector2(DrawPosition.X + Width - capUp.Value.Width, DrawPosition.Y), Color.White); 189 | else spriteBatch.Draw(capDown.Value, new Vector2(DrawPosition.X + Width - capUp.Value.Width, DrawPosition.Y), Color.White); 190 | selectedLabel.Draw(spriteBatch); 191 | } 192 | } 193 | } -------------------------------------------------------------------------------- /UIKit/UIImage.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using ReLogic.Content; 4 | 5 | namespace HEROsMod.UIKit 6 | { 7 | internal class UIImage : UIView 8 | { 9 | private Asset texture; 10 | 11 | public Asset Texture 12 | { 13 | get { return texture; } 14 | set { this.texture = value; } 15 | } 16 | 17 | private float width 18 | { get { return texture.Value?.Width ?? 0; } } 19 | private float height 20 | { get { return texture.Value?.Height ?? 0; } } 21 | private SpriteEffects _spriteEfftct = SpriteEffects.None; 22 | 23 | public SpriteEffects SpriteEffect 24 | { 25 | get { return _spriteEfftct; } 26 | set { _spriteEfftct = value; } 27 | } 28 | 29 | private Rectangle? sourceRectangle = null; 30 | 31 | public Rectangle SourceRectangle 32 | { 33 | get 34 | { 35 | if (sourceRectangle == null) sourceRectangle = new Rectangle(); 36 | return (Rectangle)sourceRectangle; 37 | } 38 | set { sourceRectangle = value; } 39 | } 40 | 41 | public int SR_X 42 | { 43 | get { return SourceRectangle.X; } 44 | set { SourceRectangle = new Rectangle(value, SourceRectangle.Y, SourceRectangle.Width, SourceRectangle.Height); } 45 | } 46 | 47 | public int SR_Y 48 | { 49 | get { return SourceRectangle.X; } 50 | set { SourceRectangle = new Rectangle(SourceRectangle.X, value, SourceRectangle.Width, SourceRectangle.Height); } 51 | } 52 | 53 | public int SR_Width 54 | { 55 | get { return SourceRectangle.X; } 56 | set { SourceRectangle = new Rectangle(SourceRectangle.X, SourceRectangle.Y, value, SourceRectangle.Height); } 57 | } 58 | 59 | public int SR_Height 60 | { 61 | get { return SourceRectangle.X; } 62 | set { SourceRectangle = new Rectangle(SourceRectangle.X, SourceRectangle.Y, SourceRectangle.Width, value); } 63 | } 64 | 65 | public UIImage(Asset texture) 66 | { 67 | this.Texture = texture; 68 | } 69 | 70 | public UIImage() 71 | { 72 | } 73 | 74 | protected override float GetWidth() 75 | { 76 | if (sourceRectangle != null) return ((Rectangle)sourceRectangle).Width * Scale; 77 | return width * Scale; 78 | } 79 | 80 | protected override float GetHeight() 81 | { 82 | if (sourceRectangle != null) return ((Rectangle)sourceRectangle).Height * Scale; 83 | return height * Scale; 84 | } 85 | 86 | public override void Draw(SpriteBatch spriteBatch) 87 | { 88 | if (Visible) 89 | spriteBatch.Draw(texture.Value, DrawPosition, sourceRectangle, ForegroundColor * Opacity, 0f, Origin / Scale, Scale, SpriteEffect, 0f); 90 | 91 | base.Draw(spriteBatch); 92 | } 93 | } 94 | } -------------------------------------------------------------------------------- /UIKit/UILabel.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using ReLogic.Graphics; 4 | using Terraria; 5 | using Terraria.GameContent; 6 | 7 | namespace HEROsMod.UIKit 8 | { 9 | internal class UILabel : UIView 10 | { 11 | public static DynamicSpriteFont defaultFont { get { return FontAssets.DeathText.Value; } } 12 | public DynamicSpriteFont font; 13 | private string text = ""; 14 | 15 | public string Text 16 | { 17 | get { return text; } 18 | set 19 | { 20 | text = value; 21 | SetWidthHeight(); 22 | } 23 | } 24 | 25 | private bool textOutline = true; 26 | 27 | public bool TextOutline 28 | { 29 | get { return textOutline; } 30 | set { textOutline = value; } 31 | } 32 | 33 | private float width = 0; 34 | private float height = 0; 35 | 36 | public UILabel(string text) 37 | { 38 | font = defaultFont; 39 | this.Text = text; 40 | } 41 | 42 | public UILabel() 43 | { 44 | font = defaultFont; 45 | this.Text = ""; 46 | } 47 | 48 | protected override Vector2 GetOrigin() 49 | { 50 | return base.GetOrigin(); 51 | } 52 | 53 | private void SetWidthHeight() 54 | { 55 | if (Text != null) 56 | { 57 | Vector2 size = font.MeasureString(Text); 58 | width = size.X; 59 | height = size.Y; 60 | } 61 | else 62 | { 63 | width = 0; 64 | height = 0; 65 | } 66 | } 67 | 68 | protected override float GetWidth() 69 | { 70 | return width * Scale; 71 | } 72 | 73 | protected override float GetHeight() 74 | { 75 | if (height == 0) 76 | { 77 | return font.MeasureString("H").Y * Scale; 78 | } 79 | else return height * Scale; 80 | } 81 | 82 | public override void Draw(SpriteBatch spriteBatch) 83 | { 84 | if (Text != null) 85 | { 86 | if (TextOutline) 87 | Utils.DrawBorderStringFourWay(spriteBatch, font, Text, DrawPosition.X, DrawPosition.Y, ForegroundColor, Color.Black * Opacity, Origin / Scale, Scale); 88 | else 89 | spriteBatch.DrawString(font, Text, DrawPosition, ForegroundColor * Opacity, 0f, Origin / Scale, Scale, SpriteEffects.None, 0f); 90 | } 91 | base.Draw(spriteBatch); 92 | } 93 | } 94 | } -------------------------------------------------------------------------------- /UIKit/UIListView.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace HEROsMod.UIKit 7 | { 8 | internal class UIListView : UIView 9 | { 10 | private List labels = new List(); 11 | private List items = new List(); 12 | public bool SelectableItems = true; 13 | private int selectedIndex = -1; 14 | public int SelectedIndex { get { return selectedIndex; } } 15 | 16 | public string[] Items 17 | { 18 | get { return items.ToArray(); } 19 | } 20 | 21 | private float width = 200; 22 | 23 | public UIListView() 24 | { 25 | } 26 | 27 | protected override float GetWidth() 28 | { 29 | return width; 30 | } 31 | 32 | protected override void SetWidth(float width) 33 | { 34 | this.width = width; 35 | } 36 | 37 | protected override float GetHeight() 38 | { 39 | float height = 0; 40 | if (labels.Count > 0) 41 | { 42 | height = labels[labels.Count - 1].Position.Y + labels[labels.Count - 1].Height; 43 | } 44 | return height; 45 | } 46 | 47 | public void AddItem(string text) 48 | { 49 | UILabel label = new UILabel(text); 50 | label.Tag = labels.Count; 51 | label.onLeftClick += label_onLeftClick; 52 | label.Scale = .5f; 53 | label.Position = new Vector2(0, Height); 54 | items.Add(text); 55 | labels.Add(label); 56 | this.AddChild(label); 57 | } 58 | 59 | public void ClearItems() 60 | { 61 | RemoveAllChildren(); 62 | labels.Clear(); 63 | items.Clear(); 64 | } 65 | 66 | private void label_onLeftClick(object sender, EventArgs e) 67 | { 68 | UILabel label = (UILabel)sender; 69 | selectedIndex = (int)label.Tag; 70 | } 71 | 72 | public override void Draw(SpriteBatch spriteBatch) 73 | { 74 | if (SelectableItems) 75 | { 76 | if (selectedIndex > -1) 77 | { 78 | UILabel label = labels[selectedIndex]; 79 | Vector2 pos = label.DrawPosition; 80 | spriteBatch.Draw(ModUtils.DummyTexture, new Rectangle((int)pos.X, (int)pos.Y, (int)this.Width, (int)label.Height), Color.Pink); 81 | } 82 | } 83 | base.Draw(spriteBatch); 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /UIKit/UIMessageBox.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using System; 4 | 5 | namespace HEROsMod.UIKit 6 | { 7 | internal enum UIMessageBoxType 8 | { 9 | Ok, 10 | YesNo 11 | } 12 | 13 | internal class UIMessageBox : UIWindow 14 | { 15 | private UIMessageBoxType MessageType = UIMessageBoxType.Ok; 16 | private UIWrappingLabel label = new UIWrappingLabel(); 17 | private UIButton okButton = null; 18 | private UIButton yesButton = null; 19 | private UIButton noButton = null; 20 | 21 | public event EventHandler yesClicked; 22 | 23 | public event EventHandler noClicked; 24 | 25 | public string Text 26 | { 27 | get { return label.Text; } 28 | set 29 | { 30 | label.Text = value; 31 | this.Height = label.Height + 70; 32 | PositionButtons(); 33 | } 34 | } 35 | 36 | public UIMessageBox() 37 | { 38 | AddButtons(); 39 | this.Text = ""; 40 | } 41 | 42 | public UIMessageBox(string text, bool exclusiveControl = false) 43 | { 44 | AddButtons(); 45 | this.Text = text; 46 | if (exclusiveControl) UIView.exclusiveControl = this; 47 | } 48 | 49 | public UIMessageBox(string text, UIMessageBoxType messageBoxType, bool exclusiveControl = false) 50 | { 51 | this.MessageType = messageBoxType; 52 | AddButtons(); 53 | this.Text = text; 54 | 55 | if (exclusiveControl) UIView.exclusiveControl = this; 56 | } 57 | 58 | private void AddButtons() 59 | { 60 | this.Anchor = AnchorPosition.Center; 61 | label.Anchor = AnchorPosition.Top; 62 | label.Width = Width - 30; 63 | label.Position = new Vector2(Width / 2, 10); 64 | AddChild(label); 65 | if (MessageType == UIMessageBoxType.Ok) 66 | { 67 | okButton = new UIButton("Ok"); 68 | okButton.Anchor = AnchorPosition.BottomRight; 69 | AddChild(okButton); 70 | okButton.onLeftClick += new EventHandler(okButton_onLeftClick); 71 | } 72 | else if (MessageType == UIMessageBoxType.YesNo) 73 | { 74 | noButton = new UIButton("No"); 75 | yesButton = new UIButton("Yes"); 76 | noButton.Anchor = AnchorPosition.BottomRight; 77 | yesButton.Anchor = AnchorPosition.BottomRight; 78 | AddChild(noButton); 79 | AddChild(yesButton); 80 | noButton.onLeftClick += noButton_onLeftClick; 81 | yesButton.onLeftClick += yesButton_onLeftClick; 82 | } 83 | } 84 | 85 | private void yesButton_onLeftClick(object sender, EventArgs e) 86 | { 87 | if (this.yesClicked != null) 88 | yesClicked(this, EventArgs.Empty); 89 | if (this.Parent != null) 90 | { 91 | if (UIView.exclusiveControl == this) UIView.exclusiveControl = null; 92 | this.Parent.RemoveChild(this); 93 | } 94 | } 95 | 96 | private void noButton_onLeftClick(object sender, EventArgs e) 97 | { 98 | if (this.noClicked != null) 99 | noClicked(this, EventArgs.Empty); 100 | if (this.Parent != null) 101 | { 102 | if (UIView.exclusiveControl == this) UIView.exclusiveControl = null; 103 | this.Parent.RemoveChild(this); 104 | } 105 | } 106 | 107 | private void okButton_onLeftClick(object sender, EventArgs e) 108 | { 109 | if (this.Parent != null) 110 | { 111 | if (UIView.exclusiveControl == this) UIView.exclusiveControl = null; 112 | this.Parent.RemoveChild(this); 113 | } 114 | } 115 | 116 | public override void Draw(SpriteBatch spriteBatch) 117 | { 118 | if (Parent != null) 119 | CenterToParent(); 120 | base.Draw(spriteBatch); 121 | } 122 | 123 | private void PositionButtons() 124 | { 125 | if (MessageType == UIMessageBoxType.Ok) 126 | { 127 | okButton.Position = new Vector2(Width - 8, Height - 8); 128 | } 129 | else if (MessageType == UIMessageBoxType.YesNo) 130 | { 131 | noButton.Position = new Vector2(Width - 8, Height - 8); 132 | yesButton.Position = new Vector2(noButton.Position.X - noButton.Width - 8, noButton.Position.Y); 133 | } 134 | } 135 | } 136 | } -------------------------------------------------------------------------------- /UIKit/UIPlayerHead.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | 4 | using Terraria; 5 | 6 | namespace HEROsMod.UIKit 7 | { 8 | internal class UIPlayerHead : UIView 9 | { 10 | private Player _player; 11 | public bool lookRight = true; 12 | 13 | public Player DrawPlayer 14 | { 15 | get { return _player; } 16 | set { _player = value; } 17 | } 18 | 19 | public UIPlayerHead(Player player) 20 | { 21 | DrawPlayer = player; 22 | Width = 40; 23 | Height = 40; 24 | } 25 | 26 | public override void Draw(SpriteBatch spriteBatch) 27 | { 28 | int pd = DrawPlayer.direction; 29 | DrawPlayer.direction = lookRight ? 1 : -1; 30 | Main.MapPlayerRenderer.DrawPlayerHead(Main.Camera, DrawPlayer, new Vector2(DrawPosition.X + Width / 2, DrawPosition.Y + Height / 2), 1f, 0.8f, Color.White); 31 | DrawPlayer.direction = pd; 32 | base.Draw(spriteBatch); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /UIKit/UIRect.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | 4 | namespace HEROsMod.UIKit 5 | { 6 | internal class UIRect : UIView 7 | { 8 | public UIRect() 9 | { 10 | this.Width = 10; 11 | this.Height = 10; 12 | } 13 | 14 | public UIRect(Vector2 position, float width, float height) 15 | { 16 | this.Position = position; 17 | this.Width = width; 18 | this.Height = height; 19 | } 20 | 21 | public override void Draw(SpriteBatch spriteBatch) 22 | { 23 | Texture2D texture = ModUtils.DummyTexture; 24 | spriteBatch.Draw(texture, new Rectangle((int)(DrawPosition.X - Origin.X), (int)(DrawPosition.Y - Origin.Y), (int)Width, (int)Height), ForegroundColor); 25 | base.Draw(spriteBatch); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /UIKit/UIScreen.cs: -------------------------------------------------------------------------------- 1 | using Terraria; 2 | 3 | namespace HEROsMod.UIKit 4 | { 5 | internal class UIScreen : UIView 6 | { 7 | public UIScreen() 8 | { 9 | this.OverridesMouse = false; 10 | } 11 | 12 | protected override float GetWidth() 13 | { 14 | return Main.screenWidth; 15 | } 16 | 17 | protected override float GetHeight() 18 | { 19 | return Main.screenHeight; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /UIKit/UIScrollBar.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using ReLogic.Content; 4 | 5 | namespace HEROsMod.UIKit 6 | { 7 | internal class UIScrollBar : UIView 8 | { 9 | internal static Asset ScrollbarTexture; 10 | private static Texture2D scrollbarFill; 11 | 12 | private static Texture2D ScrollbarFill 13 | { 14 | get 15 | { 16 | if (scrollbarFill == null) 17 | { 18 | Color[] edgeColors = new Color[ScrollbarTexture.Value.Width * ScrollbarTexture.Value.Height]; 19 | ScrollbarTexture.Value.GetData(edgeColors); 20 | Color[] fillColors = new Color[ScrollbarTexture.Value.Width]; 21 | for (int x = 0; x < fillColors.Length; x++) 22 | { 23 | fillColors[x] = edgeColors[x + (ScrollbarTexture.Value.Height - 1) * ScrollbarTexture.Value.Width]; 24 | } 25 | scrollbarFill = new Texture2D(UIView.graphics, fillColors.Length, 1); 26 | scrollbarFill.SetData(fillColors); 27 | } 28 | return scrollbarFill; 29 | } 30 | } 31 | 32 | private float height = 100; 33 | 34 | protected override float GetHeight() 35 | { 36 | return height; 37 | } 38 | 39 | protected override void SetHeight(float height) 40 | { 41 | this.height = height; 42 | } 43 | 44 | protected override float GetWidth() 45 | { 46 | return ScrollbarTexture.Value.Width; 47 | } 48 | 49 | private void DrawScrollBar(SpriteBatch spriteBatch) 50 | { 51 | float fillHeight = Height - ScrollbarTexture.Value.Height * 2; 52 | Vector2 pos = DrawPosition; 53 | spriteBatch.Draw(ScrollbarTexture.Value, pos, null, Color.White * Opacity, 0f, Origin, 1f, SpriteEffects.None, 0f); 54 | pos.Y += ScrollbarTexture.Value.Height; 55 | spriteBatch.Draw(ScrollbarFill, pos - Origin, null, Color.White * Opacity, 0f, Vector2.Zero, new Vector2(1f, fillHeight), SpriteEffects.None, 0f); 56 | pos.Y += fillHeight; 57 | spriteBatch.Draw(ScrollbarTexture.Value, pos, null, Color.White * Opacity, 0f, Origin, 1f, SpriteEffects.FlipVertically, 0f); 58 | } 59 | 60 | public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch) 61 | { 62 | DrawScrollBar(spriteBatch); 63 | base.Draw(spriteBatch); 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /UIKit/UISlider.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using ReLogic.Content; 4 | using Terraria; 5 | using Terraria.GameContent; 6 | 7 | namespace HEROsMod.UIKit 8 | { 9 | internal class UISlider : UIView 10 | { 11 | protected static int padding = 8; 12 | protected static Asset sliderTexture = TextureAssets.ColorSlider; 13 | internal static Asset barTexture; 14 | private static Texture2D barFill; 15 | 16 | private static Texture2D BarFill 17 | { 18 | get 19 | { 20 | if (barFill == null) 21 | { 22 | Color[] edgeColors = new Color[barTexture.Value.Width * barTexture.Value.Height]; 23 | barTexture.Value.GetData(edgeColors); 24 | Color[] fillColors = new Color[barTexture.Value.Height]; 25 | for (int y = 0; y < fillColors.Length; y++) 26 | { 27 | fillColors[y] = edgeColors[barTexture.Value.Width - 1 + y * barTexture.Value.Width]; 28 | } 29 | barFill = new Texture2D(UIView.graphics, 1, fillColors.Length); 30 | barFill.SetData(fillColors); 31 | } 32 | return barFill; 33 | } 34 | } 35 | 36 | public delegate void SliderEventHandler(object sender, float value); 37 | 38 | public event SliderEventHandler valueChanged; 39 | 40 | private float width = 100f; 41 | private float value = 0f; 42 | 43 | public float Value 44 | { 45 | get { return this.value; } 46 | set 47 | { 48 | if (value < MinValue) 49 | { 50 | value = MinValue; 51 | } 52 | if (value > MaxValue) 53 | { 54 | value = MaxValue; 55 | } 56 | this.value = value; 57 | } 58 | } 59 | 60 | private float minValue = 0f; 61 | private float maxValue = 1f; 62 | 63 | public float MinValue 64 | { 65 | get { return minValue; } 66 | set { minValue = value; } 67 | } 68 | 69 | public float MaxValue 70 | { 71 | get { return maxValue; } 72 | set { maxValue = value; } 73 | } 74 | 75 | protected override void SetWidth(float width) 76 | { 77 | this.width = width; 78 | } 79 | 80 | protected override float GetWidth() 81 | { 82 | return this.width; 83 | } 84 | 85 | protected override float GetHeight() 86 | { 87 | return sliderTexture.Value.Height; 88 | } 89 | 90 | public override void Update() 91 | { 92 | base.Update(); 93 | if (ModUtils.MouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Released) 94 | { 95 | leftButtonDown = false; 96 | } 97 | if (leftButtonDown) 98 | { 99 | float sliderPos = UIView.MouseX - DrawPosition.X + Origin.X; 100 | if (sliderPos < padding) sliderPos = padding; 101 | else if (sliderPos > Width - padding) sliderPos = Width - padding; 102 | sliderPos -= padding; 103 | sliderPos /= Width - padding * 2; 104 | this.Value = (MaxValue - minValue) * sliderPos + minValue; 105 | if (valueChanged != null) 106 | { 107 | valueChanged(this, Value); 108 | } 109 | } 110 | } 111 | 112 | public virtual void DrawBackground(SpriteBatch spriteBatch) 113 | { 114 | Vector2 pos = DrawPosition; 115 | pos.Y += (sliderTexture.Value.Height - barTexture.Value.Height) / 2; 116 | spriteBatch.Draw(barTexture.Value, pos, null, BackgroundColor, 0f, Origin, 1f, SpriteEffects.None, 0f); 117 | int fillWidth = (int)Width - 2 * barTexture.Value.Width; 118 | pos.X += barTexture.Value.Width; 119 | spriteBatch.Draw(BarFill, pos - Origin, null, BackgroundColor, 0f, Vector2.Zero, new Vector2(fillWidth, 1f), SpriteEffects.None, 0f); 120 | pos.X += fillWidth; 121 | spriteBatch.Draw(barTexture.Value, pos, null, BackgroundColor, 0f, Origin, 1f, SpriteEffects.FlipHorizontally, 0f); 122 | Vector2 sliderPos = DrawPosition; 123 | sliderPos.X += padding - sliderTexture.Value.Width / 2; 124 | sliderPos.X += (width - padding * 2) * ((value - MinValue) / (MaxValue - MinValue)); 125 | } 126 | 127 | public override void Draw(SpriteBatch spriteBatch) 128 | { 129 | DrawBackground(spriteBatch); 130 | Vector2 sliderPos = DrawPosition; 131 | sliderPos.X += padding - sliderTexture.Value.Width / 2; 132 | sliderPos.X += (width - padding * 2) * ((value - MinValue) / (MaxValue - MinValue)); 133 | spriteBatch.Draw(sliderTexture.Value, sliderPos, null, BackgroundColor, 0f, Origin, 1f, SpriteEffects.None, 0f); 134 | 135 | base.Draw(spriteBatch); 136 | } 137 | } 138 | } -------------------------------------------------------------------------------- /UIKit/UITestController.cs: -------------------------------------------------------------------------------- 1 | //using System; 2 | //using System.Collections.Generic; 3 | //using System.Linq; 4 | //using System.Text; 5 | //using Microsoft.Xna.Framework; 6 | //using Microsoft.Xna.Framework.Graphics; 7 | 8 | //using Terraria; 9 | 10 | //namespace GameikiMod.UIKit 11 | //{ 12 | // class UITestController 13 | // { 14 | // static UIWindow window; 15 | // static UIImage image; 16 | // public static void Init() 17 | // { 18 | // window = new UIWindow(); 19 | // window.CanMove = true; 20 | // window.Position = new Vector2(100, 100); 21 | // window.Height = 500; 22 | 23 | // UILabel label = new UILabel("Test Label"); 24 | // label.Position = new Vector2(100, 50); 25 | // label.Anchor = AnchorPosition.Center; 26 | // label.Scale = .5f; 27 | 28 | // image = new UIImage(UIView.GetEmbeddedTexture("Images/sunIcon")); 29 | // image.Anchor = AnchorPosition.Center; 30 | // image.Position = new Vector2(100, 150); 31 | // image.Scale = 2f; 32 | 33 | // UIButton bCancel = new UIButton("Cancel"); 34 | // UIButton bOk = new UIButton("Ok"); 35 | // bCancel.Anchor = AnchorPosition.BottomRight; 36 | // bCancel.Position = new Vector2(window.Width - 8, window.Height - 8); 37 | // bOk.Anchor = bCancel.Anchor; 38 | // bOk.Position = new Vector2(bCancel.Position.X - bCancel.Width - 8, bCancel.Position.Y); 39 | 40 | 41 | // UISlider slider = new UISlider(); 42 | // slider.Position = new Vector2(100, 100); 43 | // slider.Anchor = AnchorPosition.Center; 44 | // slider.Value = 1f; 45 | // slider.valueChanged += new UISlider.SliderEventHandler(slider_valueChanged); 46 | 47 | // UICheckbox checkbox = new UICheckbox("Check Me"); 48 | // checkbox.Position = new Vector2(100, 200); 49 | // checkbox.Anchor = AnchorPosition.Center; 50 | 51 | 52 | // UIListView listView = new UIListView(); 53 | // listView.Position = new Vector2(8, 8); 54 | // for (int i = 0; i < 20; i++) 55 | // { 56 | // listView.AddItem("Item " + i); 57 | // } 58 | 59 | 60 | // UIScrollView scrollView = new UIScrollView(); 61 | // scrollView.Position = new Vector2(8, 8); 62 | // scrollView.AddChild(listView); 63 | // scrollView.ContentHeight = listView.Height; 64 | // scrollView.ScrollPosition = scrollView.ContentHeight / 2; 65 | 66 | // UITextbox textbox = new UITextbox(); 67 | // textbox.Position = new Vector2(180, 250); 68 | 69 | // UIWrappingLabel wrappingText = new UIWrappingLabel(); 70 | // wrappingText.Text = "This is a test for wrapping text. I sure hope that is does not break... That would really really suck."; 71 | // wrappingText.Position = new Vector2(100, 350); 72 | 73 | // //UIMessageBox messageBox = new UIMessageBox("This is a test Message Box with some test text in it for testing the test Message Box that is only for testing purposes"); 74 | 75 | 76 | // window.AddChild(label); 77 | // window.AddChild(image); 78 | // window.AddChild(bCancel); 79 | // window.AddChild(bOk); 80 | // window.AddChild(slider); 81 | // window.AddChild(checkbox); 82 | // window.AddChild(scrollView); 83 | // window.AddChild(textbox); 84 | // window.AddChild(wrappingText); 85 | // //window.AddChild(messageBox); 86 | // //window.AddChild(listView); 87 | // slider.CenterXAxisToParentCenter(); 88 | // image.CenterXAxisToParentCenter(); 89 | // label.CenterXAxisToParentCenter(); 90 | // checkbox.CenterXAxisToParentCenter(); 91 | 92 | // } 93 | 94 | // static void slider_valueChanged(object sender, float value) 95 | // { 96 | // image.Opacity = value; 97 | // } 98 | 99 | 100 | // public static void Update() 101 | // { 102 | // window.Update(); 103 | // } 104 | 105 | // public static void Draw(SpriteBatch spriteBatch) 106 | // { 107 | // window.Draw(spriteBatch); 108 | // } 109 | // } 110 | //} 111 | -------------------------------------------------------------------------------- /UIKit/UIWindow.cs: -------------------------------------------------------------------------------- 1 | //using System.Windows.Forms; 2 | using Microsoft.Xna.Framework; 3 | using Microsoft.Xna.Framework.Graphics; 4 | 5 | using Terraria; 6 | 7 | namespace HEROsMod.UIKit 8 | { 9 | internal class UIWindow : UIView 10 | { 11 | private bool clickAndDrag = true; 12 | public bool ClickAndDrag { get { return clickAndDrag; } set { clickAndDrag = value; } } 13 | private bool dragging = false; 14 | private Vector2 dragAnchor = Vector2.Zero; 15 | private float width = 500; 16 | private float height = 300; 17 | private bool _constrainInsideParent = true; 18 | public bool CanMove = false; 19 | 20 | public UIWindow() 21 | { 22 | BackgroundColor = new Color(53, 35, 111, 255) * 0.685f; 23 | this.onMouseDown += new ClickEventHandler(UIWindow_onMouseDown); 24 | this.onMouseUp += new ClickEventHandler(UIWindow_onMouseUp); 25 | } 26 | 27 | private void UIWindow_onMouseUp(object sender, byte button) 28 | { 29 | if (dragging) dragging = false; 30 | } 31 | 32 | private void UIWindow_onMouseDown(object sender, byte button) 33 | { 34 | this.MoveToFront(); 35 | if (CanMove) 36 | { 37 | if (button == 0) 38 | { 39 | dragging = true; 40 | dragAnchor = new Vector2(MouseX, MouseY) - DrawPosition; 41 | } 42 | } 43 | } 44 | 45 | protected override void SetWidth(float width) 46 | { 47 | this.width = width; 48 | } 49 | 50 | protected override void SetHeight(float height) 51 | { 52 | this.height = height; 53 | } 54 | 55 | protected override float GetHeight() 56 | { 57 | return height; 58 | } 59 | 60 | protected override float GetWidth() 61 | { 62 | return width; 63 | } 64 | 65 | public override void Update() 66 | { 67 | base.Update(); 68 | if (dragging) 69 | { 70 | Position = new Vector2(MouseX, MouseY) - dragAnchor; 71 | if (_constrainInsideParent) 72 | { 73 | if (Position.X - Origin.X < 0) X = Origin.X; 74 | else if (Position.X + Width - Origin.X > Parent.Width) X = Parent.Width - Width + Origin.X; 75 | if (Y - Origin.Y < 0) Y = Origin.Y; 76 | else if (Y + Height - Origin.Y > Parent.Height) Y = Parent.Height - Height + Origin.Y; 77 | } 78 | } 79 | 80 | if (Visible && (IsMouseInside()/* || button.MouseInside*/)) 81 | { 82 | Main.player[Main.myPlayer].mouseInterface = true; 83 | Main.player[Main.myPlayer].cursorItemIconEnabled = false; 84 | } 85 | } 86 | 87 | public override void Draw(SpriteBatch spriteBatch) 88 | { 89 | if (Visible) 90 | Utils.DrawInvBG(spriteBatch, DrawPosition.X - Origin.X, DrawPosition.Y - Origin.Y, Width, Height, BackgroundColor); 91 | //spriteBatch.Draw(dummyTexture, new Rectangle((int)DrawPosition.X, (int)DrawPosition.Y, (int)Width, (int)Height), Color.Blue); 92 | base.Draw(spriteBatch); 93 | } 94 | } 95 | } -------------------------------------------------------------------------------- /UIKit/UIWrappingLabel.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using ReLogic.Graphics; 3 | using System.Collections.Generic; 4 | 5 | namespace HEROsMod.UIKit 6 | { 7 | internal class UIWrappingLabel : UIView 8 | { 9 | private DynamicSpriteFont font = UILabel.defaultFont; 10 | private float width = 200; 11 | private List labels = new List(); 12 | private string text; 13 | 14 | public string Text 15 | { 16 | get { return text; } 17 | set 18 | { 19 | text = value; 20 | SetLabels(); 21 | } 22 | } 23 | 24 | public UIWrappingLabel() 25 | { 26 | Scale = .5f; 27 | } 28 | 29 | public UIWrappingLabel(string text, float width) 30 | { 31 | this.Width = width; 32 | Scale = .5f; 33 | this.Text = text; 34 | } 35 | 36 | private void SetLabels() 37 | { 38 | for (int i = 0; i < labels.Count; i++) 39 | { 40 | RemoveChild(labels[i]); 41 | } 42 | labels.Clear(); 43 | if (Text.Length > 0) 44 | { 45 | string[] words = Text.Split(' '); 46 | UILabel currentLabel = null; 47 | for (int i = 0; i < words.Length; i++) 48 | { 49 | Vector2 wordSize = font.MeasureString(words[i] + " ") * Scale; 50 | if (currentLabel == null || currentLabel.Width + wordSize.X > Width) 51 | { 52 | currentLabel = new UILabel(); 53 | currentLabel.Scale = Scale; 54 | currentLabel.font = font; 55 | currentLabel.Position = new Vector2(0, labels.Count * currentLabel.Height); 56 | labels.Add(currentLabel); 57 | AddChild(currentLabel); 58 | } 59 | currentLabel.Text += words[i]; 60 | if (i != words.Length - 1) currentLabel.Text += " "; 61 | } 62 | } 63 | } 64 | 65 | protected override float GetWidth() 66 | { 67 | return width; 68 | } 69 | 70 | protected override void SetWidth(float width) 71 | { 72 | this.width = width; 73 | } 74 | 75 | protected override float GetHeight() 76 | { 77 | float result = 0; 78 | for (int i = 0; i < labels.Count; i++) 79 | { 80 | result += labels[i].Height; 81 | } 82 | return result; 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /build.txt: -------------------------------------------------------------------------------- 1 | author = HERO, jopojelly, Matt Thompson, Panini 2 | version = 0.4.16 3 | versionScheme = ?.?.Fix.Quickfix 4 | displayName = HERO's Mod 5 | homepage = http://forums.terraria.org/index.php?threads/heros-mod-creative-mode-server-management-and-over-25-tools-1-3-1-1-compatible.44650/ 6 | buildIgnore = .vs\*, Properties\*, *.csproj, *.user, obj\*, bin\*, *.config, tmod\*, ignore\*, ZVidBuild\*, Images\Old*, Images\AllIcons.psd, .git\*, LICENSE, .gitignore 7 | -------------------------------------------------------------------------------- /description.txt: -------------------------------------------------------------------------------- 1 | HERO's mod is a tools mod. It is a pick and choose server mod that allows you to decide how you want to run your world. You can turn on and off any features and you can allow different groups to use some but not all features. This tool has full group management with a GUI. 2 | 3 | There are over 25 tools and many more in development. These tools aim to allow you to better manage a server without having to use slash commands in Terraria's chat. There is a full interface in game that you can use to preform actions. 4 | 5 | This mod also works for single player. 6 | 7 | Please check out the Forum post for more information. 8 | -------------------------------------------------------------------------------- /description_workshop.txt: -------------------------------------------------------------------------------- 1 | [img]https://i.imgur.com/W2c5CX6.gif[/img] 2 | 3 | HERO's mod is a tools mod. It is a pick and choose server mod that allows you to decide how you want to run your world. You can turn on and off any features and you can allow different groups to use some but not all features. This tool has full group management with a GUI. 4 | 5 | There are over 25 tools and many more in development. These tools aim to allow you to better manage a server without having to use slash commands in Terraria's chat. There is a full interface in game that you can use to preform actions. 6 | 7 | This mod also works for single player. 8 | 9 | Please check out the Forum post for more information. 10 | 11 | [h1]Links[/h1] 12 | Source code hosted on [url=github.com/JavidPack/HEROsMod]GitHub[/url], collaboration welcome 13 | For questions or suggestions, come to my Discord: [url=discord.gg/w8Hcwby][img]https://discordapp.com/api/guilds/276235094622994433/widget.png?style=shield[/img][/url] 14 | Bug reports in the comments here will not be seen, come to Discord or Github to report issues. 15 | If you'd like to support my mods, I have a Patreon [url=www.patreon.com/jopojelly][img]https://i.imgur.com/xII2DwJ.png[/img][/url] 16 | [url=https://steamcommunity.com/profiles/76561198025715866/myworkshopfiles/?appid=1281930]Check out all my mods[/url] -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/icon.png -------------------------------------------------------------------------------- /icon_workshop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JavidPack/HEROsMod/523ac1c70222c37ea4a77a5f903686e05e7013db/icon_workshop.png --------------------------------------------------------------------------------