It all seemed to be working well, once I got it going and used the setup and update methods in the inventory window. However, when I equip weapons, It equips two items, one after the other. It appears I have two inventory windows open, so when I click to equip an item, it seems to think I am clicking the inventory twice. Where am I going wrong with this code?
Code: Select all
using UnityEngine;
using System;
using DaggerfallWorkshop.Game.UserInterface;
using System.Linq;
using OutfitManager;
namespace DaggerfallWorkshop.Game.UserInterfaceWindows
{
public class OutfitManagerInventoryWindow : DaggerfallInventoryWindow
{
public TextLabel currentoutfitLabel;
public TextLabel BundleLabel;
private TextLabel RebundleLabel;
public TextLabel DismantleLabel;
private Button NextoutfitButton;
private object PrevoufitButton;
private Button PrevoutfitButton;
private TextLabel selectedoutfitLabel;
private TextLabel NextoutfitLabel;
private TextLabel PrevoutfitLabel;
private Button BundleButton;
private Button DismantleButton;
DaggerfallFont outfitFont = new DaggerfallFont(DaggerfallFont.FontName.FONT0000);
DaggerfallFont buttonFont = new DaggerfallFont(DaggerfallFont.FontName.FONT0002);
public OutfitManagerInventoryWindow(IUserInterfaceManager uiManager, DaggerfallBaseWindow previous = null)
: base(uiManager, previous)
{
}
protected override void Setup()
{
base.Setup();
currentoutfitLabel = DaggerfallUI.AddTextLabel(outfitFont, new Vector2(DaggerfallUI.Instance.InventoryWindow.NativePanel.InteriorWidth * OutfitManager.OutfitManager.instance.panelSlider, 12f), "", DaggerfallUI.Instance.InventoryWindow.NativePanel);
//BundleLabel = DaggerfallUI.AddTextLabel(buttonFont, new Vector2(50, 193), "Bundle", DaggerfallUI.Instance.InventoryWindow.NativePanel);
//RebundleLabel = DaggerfallUI.AddTextLabel(buttonFont, new Vector2(50, 18), "Rebundle", DaggerfallUI.Instance.InventoryWindow.NativePanel);
//DismantleLabel = DaggerfallUI.AddTextLabel(buttonFont, new Vector2(129, 193), "Dismantle", DaggerfallUI.Instance.InventoryWindow.NativePanel);
selectedoutfitLabel = DaggerfallUI.AddTextLabel(buttonFont, new Vector2(89, 190), OutfitManager.OutfitManager.instance.currentOutfit, DaggerfallUI.Instance.InventoryWindow.NativePanel);
NextoutfitLabel = DaggerfallUI.AddTextLabel(buttonFont, new Vector2(120, 191), ">", DaggerfallUI.Instance.InventoryWindow.NativePanel);
PrevoutfitLabel = DaggerfallUI.AddTextLabel(buttonFont, new Vector2(80, 191), "<", DaggerfallUI.Instance.InventoryWindow.NativePanel);
BundleButton = DaggerfallUI.AddButton(new Rect(89, 191, 30, 10), DaggerfallUI.Instance.InventoryWindow.NativePanel);
DismantleButton = DaggerfallUI.AddButton(new Rect(89, 191, 30, 10), DaggerfallUI.Instance.InventoryWindow.NativePanel);
NextoutfitButton = DaggerfallUI.AddButton(new Rect(120, 191, 10, 10), DaggerfallUI.Instance.InventoryWindow.NativePanel);
PrevoutfitButton = DaggerfallUI.AddButton(new Rect(80, 191, 10, 10), DaggerfallUI.Instance.InventoryWindow.NativePanel);
BundleButton.OnMouseClick += OutfitManager.OutfitManager.instance.SaveOutfitBundle;
DismantleButton.OnMouseClick += OutfitManager.OutfitManager.instance.DeleteOutfit;
NextoutfitButton.OnMouseClick += OutfitManager.OutfitManager.instance.NextOutfit;
PrevoutfitButton.OnMouseClick += OutfitManager.OutfitManager.instance.PreviousOutfit;
}
public override void Update()
{
base.Update();
//CODE INJECTION: updates inventory UI when outfit name is changed by player using outfit manager ui controls. This works fine to update the UI propertly, despite the equip bug. Still have equip bug with this code removed, so this does not cause it.
if(currentoutfitLabel.Text != OutfitManager.OutfitManager.instance.currentOutfit)
{
currentoutfitLabel.Position = new Vector2(((DaggerfallUI.Instance.InventoryWindow.NativePanel.InteriorWidth - currentoutfitLabel.TextWidth) * OutfitManager.OutfitManager.instance.panelSlider), 12f);
currentoutfitLabel.Text = OutfitManager.OutfitManager.instance.currentOutfit;
}
else if(currentoutfitLabel.Text == OutfitManager.OutfitManager.instance.currentOutfit && currentoutfitLabel.Text == "Bundle" && selectedoutfitLabel.Text != "Bundle")
{
currentoutfitLabel.Enabled = false;
BundleButton.Enabled = true;
DismantleButton.Enabled = false;
selectedoutfitLabel.Text = "Bundle";
}
else if (currentoutfitLabel.Text == OutfitManager.OutfitManager.instance.currentOutfit && currentoutfitLabel.Text != "Bundle" && selectedoutfitLabel.Text != "Unbundle")
{
currentoutfitLabel.Enabled = true;
BundleButton.Enabled = false;
DismantleButton.Enabled = true;
selectedoutfitLabel.Text = "Unbundle";
}
}
}
}