// Recalculate buttons. void ServiceAddedOrRemoved(HEROsModService modifiedService) { // Clear existing icons in the Hotbar _iconView.RemoveAllChildren(); // For each service, add its icon to the hotbar float xPos = Spacing; for (int i = 0; i < HEROsMod.ServiceController.Services.Count; i++) { HEROsModService service = HEROsMod.ServiceController.Services[i]; if (service.HotbarIcon == null || !service.HasPermissionToUse) { continue; } if (service.IsHotbar) { service.Hotbar.buttonView.RemoveAllChildren(); service.Hotbar.test(); } if (service.IsInHotbar /* && service.HotbarParent.buttonView != null*/) { //ErrorLogger.Log("adding " + service.Name); //ErrorLogger.Log("adding 1" + service.HotbarParent.ChildCount); //ErrorLogger.Log("adding 3" + service.HotbarParent.buttonView.ChildCount); UIImage icon = HEROsMod.ServiceController.Services[i].HotbarIcon; //icon.Anchor = AnchorPosition.Left; //icon.X = xPos; //icon.Y = 0; //xPos += icon.Width + Spacing; service.HotbarParent.buttonView.AddChild(icon); //_iconView.AddChild(icon); //icon.CenterYAxisToParentCenter(); service.HotbarParent.test(); //ModUtils.DebugText("added " + service.Name); } else { UIImage icon = HEROsMod.ServiceController.Services[i].HotbarIcon; icon.Anchor = AnchorPosition.Left; icon.X = xPos; icon.Y = 0; xPos += icon.Width + Spacing; _iconView.AddChild(icon); icon.CenterYAxisToParentCenter(); } } if (_iconView.ChildCount > 0) { this.Width = _iconView.GetLastChild().X + _iconView.GetLastChild().Width + Spacing; _iconView.Width = this.Width; } collapseButton.CenterXAxisToParentCenter(); collapseArrow.Position = collapseButton.Position; }
// // private void bButcher_onLeftClick(object sender, EventArgs e) // { // UIImage uIImage = (UIImage)sender; // if (mod.npcButchererHotbar.selected) // { // mod.npcButchererHotbar.selected = false; // mod.npcButchererHotbar.Hide(); // uIImage.ForegroundColor = buttonUnselectedColor; // } // else // { // DisableAllWindows(); // mod.npcButchererHotbar.selected = true; // mod.npcButchererHotbar.Show(); // uIImage.ForegroundColor = buttonSelectedColor; // } // } // private void bToggleQuickTeleport_onLeftClick(object sender, EventArgs e) // { // UIImage uIImage = (UIImage)sender; // if (mod.quickTeleportHotbar.selected) // { // mod.quickTeleportHotbar.selected = false; // mod.quickTeleportHotbar.Hide(); // uIImage.ForegroundColor = buttonUnselectedColor; // } // else // { // DisableAllWindows(); // mod.quickTeleportHotbar.selected = true; // mod.quickTeleportHotbar.Show(); // uIImage.ForegroundColor = buttonSelectedColor; // } // } public override void Update() { try { if (hidden) { lerpAmount -= /*Mod.deltaTime*/ .01f * moveSpeed; if (lerpAmount < 0f) { lerpAmount = 0f; } float y = MathHelper.SmoothStep(hiddenPosition, shownPosition, lerpAmount); Position = new Vector2(xPosition, y); } else { lerpAmount += .01f /*Mod.deltaTime */ * moveSpeed; if (lerpAmount > 1f) { lerpAmount = 1f; } float y2 = MathHelper.SmoothStep(hiddenPosition, shownPosition, lerpAmount); Position = new Vector2(xPosition, y2); } // if (mod.paintToolsHotbar.Visible || mod.quickTeleportHotbar.Visible || mod.quickClearHotbar.Visible || mod.npcButchererHotbar.Visible /* || mod.eventManagerHotbar.Visible*/) // { // int offset = mod.npcButchererHotbar.Visible ? (int)button.Width : 0; // button.Position = new Vector2(0, -button.Height - Math.Max(0, Position.Y - currentHotbar.Position.Y)); // button.CenterXAxisToParentCenter(offset); // arrow.Position = button.Position; // } // else // { button.Position = new Vector2(0, -button.Height); button.CenterXAxisToParentCenter(); arrow.Position = button.Position; // } CenterXAxisToParentCenter(); base.Update(); } catch (Exception e) { CheatSheet.instance.Logger.Error(e.ToString()); } }
private void InitUI() { this.Height = 54; ///55; // 38 + 8 + 8 = 54 this.Width = 0; this.Anchor = AnchorPosition.Top; this.UpdateWhenOutOfBounds = true; MasterView.gameScreen.AddChild(this); _iconView = new UIView(); _iconView.Width = this.Width; _iconView.Height = this.Height; this.AddChild(_iconView); collapseButton = new UIImage(UIView.GetEmbeddedTexture("Images/CollapseBar/CollapseButtonHorizontal")); collapseButton.UpdateWhenOutOfBounds = true; collapseArrow = new UIImage(UIView.GetEmbeddedTexture("Images/CollapseBar/CollapseArrowHorizontal")); collapseArrow.UpdateWhenOutOfBounds = true; collapseButton.Anchor = AnchorPosition.Top; collapseArrow.Anchor = AnchorPosition.Top; collapseArrow.SpriteEffect = SpriteEffects.FlipVertically; AddChild(collapseButton); AddChild(collapseArrow); collapseButton.Position = new Vector2(0, -collapseButton.Height); collapseButton.CenterXAxisToParentCenter(); collapseArrow.Position = collapseButton.Position; collapseArrow.onLeftClick += collapseArrow_onLeftClick; }
public override void Update() { try { if (this.hidden) { this.lerpAmount -= /*Mod.deltaTime*/ .01f * Hotbar.moveSpeed; if (this.lerpAmount < 0f) { this.lerpAmount = 0f; } float y = MathHelper.SmoothStep(this.hiddenPosition, this.shownPosition, this.lerpAmount); base.Position = new Vector2(Hotbar.xPosition, y); } else { this.lerpAmount += .01f /*Mod.deltaTime */ * Hotbar.moveSpeed; if (this.lerpAmount > 1f) { this.lerpAmount = 1f; } float y2 = MathHelper.SmoothStep(this.hiddenPosition, this.shownPosition, this.lerpAmount); base.Position = new Vector2(Hotbar.xPosition, y2); } if (mod.paintToolsHotbar.Visible || mod.quickTeleportHotbar.Visible || mod.quickClearHotbar.Visible || mod.npcButchererHotbar.Visible /* || mod.eventManagerHotbar.Visible*/) { int offset = mod.npcButchererHotbar.Visible ? (int)this.button.Width : 0; this.button.Position = new Vector2(0, -this.button.Height - Math.Max(0, (base.Position.Y - currentHotbar.Position.Y))); button.CenterXAxisToParentCenter(offset); arrow.Position = button.Position; } else { this.button.Position = new Vector2(0, -this.button.Height); button.CenterXAxisToParentCenter(); arrow.Position = button.Position; } base.CenterXAxisToParentCenter(); base.Update(); } catch (Exception e) { ErrorLogger.Log(e.ToString()); } }
public Hotbar(CheatSheet mod) { this.mod = mod; buttonView = new UIView(); // this.timeWindow = new TimeControlWindow(); // this.npcSpawnWindow = new NPCSpawnerWindow(); // this.weatherWindow = new WeatherControlWindow(); // this.timeWindow.Visible = false; // this.npcSpawnWindow.Visible = false; // this.weatherWindow.Visible = false; // this.AddChild(this.timeWindow); // this.AddChild(this.npcSpawnWindow); // this.AddChild(this.weatherWindow); loginTexture = mod.GetTexture("UI/Images.login").Value; // UIView.GetEmbeddedTexture("Images.login.png"); logoutTexture = mod.GetTexture("UI/Images.logout").Value; //UIView.GetEmbeddedTexture("Images.logout.png"); // this.bLogin = new UIImage(Hotbar.loginTexture); // bLogin = new UIImage(mod.GetTexture("UI/Images.login")); Visible = false; UpdateWhenOutOfBounds = true; // Hotbar.groupWindow = new GroupManagementWindow(); button = new UIImage(mod.GetTexture("UI/Images.CollapseBar.CollapseButtonHorizontal").Value); //new UIImage(UIView.GetEmbeddedTexture("Images.CollapseBar.CollapseButtonHorizontal.png")); button.UpdateWhenOutOfBounds = true; arrow = new UIImage(mod.GetTexture("UI/Images.CollapseBar.CollapseArrowHorizontal").Value); //new UIImage(UIView.GetEmbeddedTexture("Images.CollapseBar.CollapseArrowHorizontal.png")); // bToggleEnemies = new UIImage(mod.GetTexture("UI/Images.npcIcon")); // bToggleBlockReach = new UIImage(TextureAssets.Item[407]); // bFlyCamera = new UIImage(TextureAssets.Item[493]); // bRevealMap = new UIImage(mod.GetTexture("UI/Images.canIcon"));// Hotbar.mapTexture); // bWaypoints = new UIImage(mod.GetTexture("UI/Images.waypointIcon")); // bGroupManager = new UIImage(mod.GetTexture("UI/Images.manageGroups")); // bOnlinePlayers = new UIImage(mod.GetTexture("UI/Images.connectedPlayers")); // bTime = new UIImage(mod.GetTexture("UI/Images.sunIcon")); // bWeatherWindow = new UIImage(Main.npcHeadTexture[2]);// WeatherControlWindow.rainTexture); // bBackupWorld = new UIImage(mod.GetTexture("UI/Images.UIKit.saveIcon")); // bCTFSettings = new UIImage(mod.GetTexture("UI/Images.CTF.redFlag")); // Main.instance.LoadNPC(NPCID.KingSlime); Main.instance.LoadItem(ItemID.WorkBench); Main.instance.LoadItem(ItemID.TrashCan); Main.instance.LoadItem(ItemID.DemonHeart); Main.instance.LoadItem(ItemID.Skull); bToggleItemBrowser = new UIImage(TextureAssets.Item[ItemID.WorkBench].Value); bToggleNPCBrowser = new UIImage(mod.GetTexture("UI/Images.npcIcon").Value); bToggleClearMenu = new UIImage(TextureAssets.Item[ItemID.TrashCan].Value); // bToggleRecipeBrowser = new UIImage(TextureAssets.Item[ItemID.CookingPot].Value); // bToggleExtendedCheat = new UIImage(TextureAssets.Item[ItemID.CellPhone].Value); // bTogglePaintTools = new UIImage(TextureAssets.Item[ItemID.Paintbrush].Value); bCycleExtraAccessorySlots = new UIImage(TextureAssets.Item[ItemID.DemonHeart].Value); bVacuum = new UIImage(mod.GetTexture("UI/Images.bVacuum").Value); bToggleNPCButcherer = new UIImage(TextureAssets.Item[ItemID.Skull].Value); // bToggleQuickTeleport = new UIImage(TextureAssets.Item[ItemID.WoodenDoor].Value); //bToggleEventManager = new UIImage(TextureAssets.Item[ItemID.PirateMap]); arrow.UpdateWhenOutOfBounds = true; button.Anchor = AnchorPosition.Top; arrow.Anchor = AnchorPosition.Top; arrow.SpriteEffect = SpriteEffects.FlipVertically; AddChild(button); AddChild(arrow); button.Position = new Vector2(0f, -button.Height); button.CenterXAxisToParentCenter(); //Do i need this? this.button.X -= 40; arrow.Position = button.Position; arrow.onLeftClick += button_onLeftClick; // this.bBackupWorld.onLeftClick += new EventHandler(this.bBackupWorld_onLeftClick); // this.bToggleBlockReach.Tooltip = "Toggle Block Reach"; // this.bToggleEnemies.Tooltip = "Toggle Enemy Spawns"; // this.bFlyCamera.Tooltip = "Toggle Fly Cam"; // this.bRevealMap.Tooltip = "Reveal Map"; // this.bWaypoints.Tooltip = "Open Waypoints Window"; // this.bGroupManager.Tooltip = "Open Group Management"; // this.bOnlinePlayers.Tooltip = "View Connected Players"; // this.bTime.Tooltip = "Set Time"; // this.bWeatherWindow.Tooltip = "Control Rain"; // this.bLogin.Tooltip = "Login"; // this.bCTFSettings.Tooltip = "Capture the Flag Settings"; // this.bBackupWorld.Tooltip = "Backup World"; bToggleItemBrowser.Tooltip = CSText("ShowItemBrowser"); bToggleClearMenu.Tooltip = CSText("ShowClearMenu"); bToggleNPCBrowser.Tooltip = CSText("ShowNPCBrowser"); // bToggleRecipeBrowser.Tooltip = CSText("ShowRecipeBrowser"); // bToggleExtendedCheat.Tooltip = CSText("ShowModExtensionCheats"); // bTogglePaintTools.Tooltip = CSText("ShowPaintTools"); bCycleExtraAccessorySlots.Tooltip = CSText("ExtraAccessorySlots") + ": ?"; bVacuum.Tooltip = CSText("VacuumItems"); bToggleNPCButcherer.Tooltip = CSText("ShowNPCButcherer"); // bToggleQuickTeleport.Tooltip = CSText("ShowQuickWaypoints"); // bToggleEventManager.Tooltip = "Show Event Manager"; // this.bToggleBlockReach.Opacity = Hotbar.disabledOpacity; // this.bFlyCamera.Opacity = Hotbar.disabledOpacity; // this.bToggleEnemies.Opacity = Hotbar.disabledOpacity; // this.bToggleBlockReach.onLeftClick += new EventHandler(this.bToggleBlockReach_onLeftClick); // this.bFlyCamera.onLeftClick += new EventHandler(this.bFlyCamera_onLeftClick); // this.bToggleEnemies.onLeftClick += new EventHandler(this.bToggleEnemies_onLeftClick); // this.bRevealMap.onLeftClick += new EventHandler(this.bRevealMap_onLeftClick); // this.bWaypoints.onLeftClick += new EventHandler(this.bWaypoints_onLeftClick); // this.bGroupManager.onLeftClick += new EventHandler(this.bGroupManager_onLeftClick); // this.bOnlinePlayers.onLeftClick += new EventHandler(this.bOnlinePlayers_onLeftClick); // this.bCTFSettings.onLeftClick += new EventHandler(this.bCTFSettings_onLeftClick); // this.bLogin.onLeftClick += new EventHandler(this.bLogin_onLeftClick); // this.bTime.onLeftClick += new EventHandler(this.bTime_onLeftClick); // this.bWeatherWindow.onLeftClick += new EventHandler(this.bWeatherWindow_onLeftClick); bToggleItemBrowser.onLeftClick += bToggleItemBrowser_onLeftClick; bToggleClearMenu.onLeftClick += bClearItems_onLeftClick; bToggleClearMenu.onRightClick += (s, e) => { QuickClearHotbar.HandleQuickClear(); }; bToggleNPCBrowser.onLeftClick += bToggleNPCBrowser_onLeftClick; // bToggleRecipeBrowser.onLeftClick += bToggleRecipeBrowser_onLeftClick; // bToggleExtendedCheat.onLeftClick += bToggleExtendedCheat_onLeftClick; // bTogglePaintTools.onLeftClick += bTogglePaintTools_onLeftClick; bCycleExtraAccessorySlots.onLeftClick += (s, e) => { CheatSheetPlayer cheatSheetPlayer = Main.LocalPlayer.GetModPlayer <CheatSheetPlayer>(); cheatSheetPlayer.numberExtraAccessoriesEnabled = (cheatSheetPlayer.numberExtraAccessoriesEnabled + 1) % (CheatSheetPlayer.MaxExtraAccessories + 1); bCycleExtraAccessorySlots.Tooltip = CSText("ExtraAccessorySlots") + ": " + cheatSheetPlayer.numberExtraAccessoriesEnabled; }; bCycleExtraAccessorySlots.onRightClick += (s, e) => { CheatSheetPlayer cheatSheetPlayer = Main.LocalPlayer.GetModPlayer <CheatSheetPlayer>(); cheatSheetPlayer.numberExtraAccessoriesEnabled = cheatSheetPlayer.numberExtraAccessoriesEnabled == 0 ? 0 : (cheatSheetPlayer.numberExtraAccessoriesEnabled - 1) % (CheatSheetPlayer.MaxExtraAccessories + 1); bCycleExtraAccessorySlots.Tooltip = CSText("ExtraAccessorySlots") + ": " + cheatSheetPlayer.numberExtraAccessoriesEnabled; }; bVacuum.onLeftClick += bVacuum_onLeftClick; // bToggleNPCButcherer.onLeftClick += bButcher_onLeftClick; // bToggleNPCButcherer.onRightClick += (s, e) => { NPCButchererHotbar.HandleButcher(); }; // bToggleQuickTeleport.onLeftClick += bToggleQuickTeleport_onLeftClick; // bToggleQuickTeleport.onRightClick += (s, e) => // { //QuickTeleportHotbar.TeleportPlayer(Main.LocalPlayer, new Vector2(Main.spawnTileX, Main.spawnTileY), true); // QuickTeleportHotbar.HandleTeleport(); // }; // this.bToggleEventManager.onLeftClick += new EventHandler(this.bToggleEventManager_onLeftClick); // this.buttonView.AddChild(this.bToggleBlockReach); // this.buttonView.AddChild(this.bFlyCamera); // this.buttonView.AddChild(this.bToggleEnemies); // this.buttonView.AddChild(this.bRevealMap); // this.buttonView.AddChild(this.bWaypoints); // this.buttonView.AddChild(this.bTime); // this.buttonView.AddChild(this.bWeatherWindow); // this.buttonView.AddChild(this.bGroupManager); // this.buttonView.AddChild(this.bOnlinePlayers); // this.buttonView.AddChild(this.bCTFSettings); // this.buttonView.AddChild(this.bLogin); // this.buttonView.AddChild(this.bBackupWorld); buttonView.AddChild(bToggleItemBrowser); buttonView.AddChild(bToggleNPCBrowser); // buttonView.AddChild(bToggleRecipeBrowser); // buttonView.AddChild(bToggleExtendedCheat); buttonView.AddChild(bToggleClearMenu); // buttonView.AddChild(bTogglePaintTools); buttonView.AddChild(bCycleExtraAccessorySlots); buttonView.AddChild(bVacuum); buttonView.AddChild(bToggleNPCButcherer); // buttonView.AddChild(bToggleQuickTeleport); // buttonView.AddChild(bToggleEventManager); // buttonView.AddChild(SpawnRateMultiplier.GetButton(mod)); // buttonView.AddChild(MinionSlotBooster.GetButton(mod)); // buttonView.AddChild(LightHack.GetButton(mod)); // buttonView.AddChild(GodMode.GetButton(mod)); // buttonView.AddChild(FullBright.GetButton(mod)); // buttonView.AddChild(BossDowner.GetButton(mod)); // buttonView.AddChild(ConfigurationTool.GetButton(mod)); Width = 200f; Height = 55f; buttonView.Height = Height; Anchor = AnchorPosition.Top; AddChild(buttonView); Position = new Vector2(xPosition, hiddenPosition); CenterXAxisToParentCenter(); float num = spacing; for (int i = 0; i < buttonView.children.Count; i++) { buttonView.children[i].Anchor = AnchorPosition.Left; buttonView.children[i].Position = new Vector2(num, 0f); buttonView.children[i].CenterYAxisToParentCenter(); buttonView.children[i].Visible = true; buttonView.children[i].ForegroundColor = buttonUnselectedColor; num += buttonView.children[i].Width + spacing; } // Hotbar.groupWindow.Visible = false; // MasterView.gameScreen.AddChild(Hotbar.groupWindow); ChangedConfiguration(); //this.Resize(); }