public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers) { int inventoryLayerIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text")); if (inventoryLayerIndex != -1) { layers.Insert(inventoryLayerIndex, new LegacyGameInterfaceLayer( "HerosMod: UI", delegate { try { HEROsMod.Update(); HEROsMod.ServiceHotbar.Update(); HEROsMod.DrawBehindUI(Main.spriteBatch); HEROsMod.Draw(Main.spriteBatch); KeybindController.DoPreviousKeyState(); } catch (Exception e) { ModUtils.DebugText("PostDrawInInventory Error: " + e.Message + e.StackTrace); } return(true); }, InterfaceScaleType.UI) ); } }
public override void SetControls() { if (FlyCam.Enabled && !FlyCam.LockCamera) { player.controlDown = false; player.controlUp = false; player.controlLeft = false; player.controlRight = false; player.controlMount = false; player.controlHook = false; player.controlThrow = false; // player.controlJump = false; player.controlSmart = false; player.controlTorch = false; } if (Main.netMode == NetmodeID.MultiplayerClient && !HEROsModServices.Login.LoggedIn && ModContent.GetInstance <HEROsModServerConfig>().FreezeNonLoggedIn) { player.frozen = true; FreezeNonLoggedInMessageTimer -= ModUtils.DeltaTime; if (FreezeNonLoggedInMessageTimer <= 0) { FreezeNonLoggedInMessageTimer = 7f; Main.NewText(HEROsMod.HeroText("LoginInstructions"), Color.Red); } } }
public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers) { int inventoryLayerIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text")); if (inventoryLayerIndex != -1) { layers.Insert(inventoryLayerIndex, new LegacyGameInterfaceLayer( "HerosMod: UI", delegate { try { HEROsMod.Update(); HEROsMod.ServiceHotbar.Update(); HEROsMod.DrawBehindUI(Main.spriteBatch); HEROsMod.Draw(Main.spriteBatch); KeybindController.DoPreviousKeyState(); } catch (Exception e) { ModUtils.DebugText("HerosMod: UI Error: " + e.Message + e.StackTrace); } return(true); }, InterfaceScaleType.UI) ); // Technically before the above GameInterfaceLayer layers.Insert(inventoryLayerIndex, new LegacyGameInterfaceLayer( "HerosMod: UI (Game Scale)", delegate { try { if (ModUtils.NetworkMode != NetworkMode.Server) { foreach (var service in ServiceController.Services) { service.UpdateGameScale(); } } SelectionTool.Update(); } catch (Exception e) { ModUtils.DebugText("HerosMod: UI (Game Scale) Error: " + e.Message + e.StackTrace); } return(true); }, InterfaceScaleType.Game) ); } }
// Clear EVERYthing, mod is unloaded. public override void Unload() { UIKit.UIComponents.ItemBrowser.Filters = null; UIKit.UIComponents.ItemBrowser.DefaultSorts = null; UIKit.UIComponents.ItemBrowser.Categories = null; UIKit.UIComponents.ItemBrowser.CategoriesLoaded = false; UIKit.UIButton.buttonBackground = null; UIKit.UIView.closeTexture = null; UIKit.UITextbox.textboxBackground = null; UIKit.UISlider.barTexture = null; UIKit.UIScrollView.ScrollbgTexture = null; UIKit.UIScrollBar.ScrollbarTexture = null; UIKit.UIDropdown.capUp = null; UIKit.UIDropdown.capDown = null; UIKit.UICheckbox.checkboxTexture = null; UIKit.UICheckbox.checkmarkTexture = null; HEROsModServices.Login._loginTexture = null; HEROsModServices.Login._logoutTexture = null; try { KeybindController.bindings.Clear(); if (ServiceController != null) { if (ServiceController.Services != null) { foreach (var service in ServiceController.Services) { service.Unload(); } } ServiceController.RemoveAllServices(); } HEROsModNetwork.Network.ResetAllPlayers(); HEROsModNetwork.Network.ServerUsingHEROsMod = false; HEROsModNetwork.Network.Regions.Clear(); MasterView.ClearMasterView(); } catch (Exception e) { ModUtils.DebugText("Unload:\n" + e.Message + "\n" + e.StackTrace + "\n"); } extensionMenuService = null; miscOptions = null; prefixEditor = null; _hotbar = null; ServiceController = null; TimeWeatherControlHotbar.Unload(); ModUtils.previousInventoryItems = null; translations = null; instance = null; }
public override void PostDrawInterface(SpriteBatch spriteBatch) { try { HEROsMod.Update(); HEROsMod.ServiceHotbar.Update(); HEROsMod.DrawBehindUI(spriteBatch); HEROsMod.Draw(spriteBatch); KeybindController.DoPreviousKeyState(); } catch (Exception e) { ModUtils.DebugText("PostDrawInInventory Error: " + e.Message + e.StackTrace); } }
internal static Dictionary <string, ModTranslation> translations; // reference to private field. public override void Load() { // Since we are using hooks not in older versions, and since ItemID.Count changed, we need to do this. if (ModLoader.version < new Version(0, 10, 1, 3)) { throw new Exception(HEROsMod.HeroText("UpdateTModLoaderToUse")); } try { instance = this; FieldInfo translationsField = typeof(Mod).GetField("translations", BindingFlags.Instance | BindingFlags.NonPublic); translations = (Dictionary <string, ModTranslation>)translationsField.GetValue(this); //LoadTranslations(); // AddGlobalItem("HEROsModGlobalItem", new HEROsModGlobalItem()); // AddPlayer("HEROsModModPlayer", new HEROsModModPlayer()); //if (ModUtils.NetworkMode != NetworkMode.Server) if (!Main.dedServ) { UIKit.UIButton.buttonBackground = HEROsMod.instance.GetTexture("Images/UIKit/buttonEdge"); UIKit.UIView.closeTexture = HEROsMod.instance.GetTexture("Images/closeButton"); UIKit.UITextbox.textboxBackground = HEROsMod.instance.GetTexture("Images/UIKit/textboxEdge"); UIKit.UISlider.barTexture = HEROsMod.instance.GetTexture("Images/UIKit/barEdge"); UIKit.UIScrollView.ScrollbgTexture = GetTexture("Images/UIKit/scrollbgEdge"); UIKit.UIScrollBar.ScrollbarTexture = HEROsMod.instance.GetTexture("Images/UIKit/scrollbarEdge"); UIKit.UIDropdown.capUp = HEROsMod.instance.GetTexture("Images/UIKit/dropdownCapUp"); UIKit.UIDropdown.capDown = HEROsMod.instance.GetTexture("Images/UIKit/dropdownCapDown"); UIKit.UICheckbox.checkboxTexture = HEROsMod.instance.GetTexture("Images/UIKit/checkBox"); UIKit.UICheckbox.checkmarkTexture = HEROsMod.instance.GetTexture("Images/UIKit/checkMark"); } Init(); } catch (Exception e) { ModUtils.DebugText("Load:\n" + e.Message + "\n" + e.StackTrace + "\n"); } }
public override void Load() { // Since we are using hooks not in older versions, and since ItemID.Count changed, we need to do this. if (ModLoader.version < new Version(0, 9, 2)) { throw new Exception("\nThis mod uses functionality only present in the latest tModLoader. Please update tModLoader to use this mod\n\n"); } try { instance = this; // AddGlobalItem("HEROsModGlobalItem", new HEROsModGlobalItem()); AddPlayer("HEROsModModPlayer", new HEROsModModPlayer()); //if (ModUtils.NetworkMode != NetworkMode.Server) Init(); } catch (Exception e) { ModUtils.DebugText("Load:\n" + e.Message + "\n" + e.StackTrace + "\n"); } }