Agreed, but there is so litte room by the feet and so much by the shoulders.
Have a "change" button to indicate swapping outfits.
Speaking of swapping outfits, man why doesn't that have equiptime while weapons have?
Agreed, but there is so litte room by the feet and so much by the shoulders.
Have a "change" button to indicate swapping outfits.
Please use the UI window factory to override the standard inventory window. You may need to make changes to permissions or mark methods as overridable, that's fine just submit a core PR with any changes you need.l3lessed wrote: ↑Fri Dec 06, 2019 1:29 am
I have gone over UI, inventory stuff for the last few days for my combat overhaul. This feature hits my work well, so I have started the base for the script today and got it imported in using the modding system. Now comes the fun stuff, coding in the rect objects for the UI and setting up the coding for managing the outfit system.
This will be both a fun mod to develop, but it also will help me understand the modding system better before I try to move my combat overhaul to it.
Code: Select all
using UnityEngine;
using UnityEngine.UI;
using System;
using System.Collections;
using System.Linq;
using DaggerfallConnect;
using DaggerfallWorkshop.Game.Entity;
using DaggerfallWorkshop.Game.Items;
using System.Collections.Generic;
using DaggerfallWorkshop.Game.UserInterface;
using DaggerfallWorkshop.Game.UserInterfaceWindows;
using DaggerfallWorkshop.Game.Formulas;
using DaggerfallWorkshop.Game.MagicAndEffects;
using DaggerfallWorkshop.Game.MagicAndEffects.MagicEffects;
using DaggerfallWorkshop.Game.Utility;
using DaggerfallWorkshop.Utility;
using DaggerfallWorkshop.Game.Utility.ModSupport; //required for modding features
namespace DaggerfallWorkshop.Game
{
public class OutfitManager : MonoBehaviour
{
PlayerEntity playerEntity;
#region UI Rects
Rect nextrect = new Rect(0, 10, 120, 30);
Rect previousButton = new Rect(0, 40, 120, 30);
Rect count = new Rect(0, 70, 120, 60);
Rect load = new Rect(0, 130, 130, 30);
public DaggerfallUnityItem rightHeld;
public DaggerfallUnityItem leftHeld;
public DaggerfallUnityItem leftArmEquipped;
public DaggerfallUnityItem legsEquipped;
public DaggerfallUnityItem rightArmEquipped;
public DaggerfallUnityItem chestEquipped;
public static List<DaggerfallUnityItem> outfitList = new List<DaggerfallUnityItem>();
public static List<DaggerfallUnityItem> currentEquip = new List<DaggerfallUnityItem>();
#endregion
#region Properties
public PlayerEntity PlayerEntity
{
get { return (playerEntity != null) ? playerEntity : playerEntity = GameManager.Instance.PlayerEntity; }
}
#endregion
//KeyCode toggleClosedBinding;
IEnumerator Start()
{
yield return new WaitForSeconds(2);
//delay for a few seconds` then display the Hello World message
DaggerfallUI.Instance.PopupMessage("Outfits Initiated");
//toggleClosedBinding = InputManager.Instance.GetBinding(InputManager.Actions.Inventory);
}
// Update is called once per frame
void Update()
{
}
[Invoke(StateManager.StateTypes.Game, 0)]
public static void Init(InitParams initParams)
{
Debug.Log("main init");
//just an example of how to add a mono-behavior to a scene.
GameObject outfitGo = new GameObject("outfit");
OutfitManager outfit = outfitGo.AddComponent<OutfitManager>();
//after finishing, set the mod's IsReady flag to true.
ModManager.Instance.GetMod(initParams.ModTitle).IsReady = true;
}
//You can have as many of these methods as you want to call by the ModManager
//If you pass an integer to the Invoke constructor, you can control the order in which they load
//lower loads sooner. Note that this is per MOD not per-class.
[Invoke(StateManager.StateTypes.Game, 1)]
public static void Init2(InitParams initParams)
{
Debug.Log("init 2");
}
//the 2nd paramater allows you to control which state the ModManager will invoke this method - the Start state
//-that's when the scene is first loaded, or the game state - when a game is started (either a new game, or a save is loaded)
[Invoke(StateManager.StateTypes.Start)]
public static void InitStart(InitParams initParams)
{
Debug.Log("init at Start");
DaggerfallUI.Instance.PopupMessage("Outfits Initiated 2");
}
//pulls players currently equipped outfit by grabbing every equipment slot.
//it doesn't matter if the player has something equipped or not. It will add
//a null, which then gets removed from the list later.
void currentEquipped ()
{
rightHeld = PlayerEntity.ItemEquipTable.GetItem(EquipSlots.RightHand);
leftHeld = PlayerEntity.ItemEquipTable.GetItem(EquipSlots.LeftHand);
legsEquipped = PlayerEntity.ItemEquipTable.GetItem(EquipSlots.LegsArmor);
leftArmEquipped = PlayerEntity.ItemEquipTable.GetItem(EquipSlots.LeftArm);
rightArmEquipped = PlayerEntity.ItemEquipTable.GetItem(EquipSlots.RightArm);
chestEquipped = PlayerEntity.ItemEquipTable.GetItem(EquipSlots.ChestArmor);
}
//saves the currently selected outfit. It grabs the stored equipped items through the stored
//vars retrieved from above. Then runs through list and removes slots that had no items/null.
//prints out items in debug.log for debugging. Null items in list will cause object reference
//error.
void saveCurrentOutfit()
{
outfitList.Add(rightHeld);
outfitList.Add(leftHeld);
outfitList.Add(legsEquipped);
outfitList.Add(leftArmEquipped);
outfitList.Add(rightArmEquipped);
outfitList.Add(chestEquipped);
outfitList = outfitList.Where(item => item != null).ToList();
DaggerfallUI.Instance.PopupMessage("List Size:" + outfitList.Count);
foreach (DaggerfallUnityItem outfitItem in outfitList)
{
Debug.Log(outfitItem.LongName);
}
}
//beginning of outfit load routine. Will use saved outfit lists to equipped outfits to player.
void loadCurrentOutfit()
{
if (outfitList != null)
{
foreach (DaggerfallUnityItem outfitItem in outfitList)
{
DaggerfallUI.Instance.PopupMessage("Equipped:" + outfitItem.ItemName);
}
}
}
//GUI overlay.
void OnGUI()
{
//sets background color for GUI items.
GUI.backgroundColor = Color.red;
//counts the total windows. Use this to hide added gui items when
//not in menu.
int totalwindows = DaggerfallUI.UIManager.WindowCount;
//if a menu is not open, hide gui buttons below.
if(totalwindows != -1)
{
//sets up buttons and then if true trigger. Uses stored rects from above.
if (GUI.Button(nextrect, "Next Outfit"))
{
DaggerfallUI.Instance.PopupMessage("Next Outfit Equipped");
}
else if (GUI.Button(previousButton, "Previous Outfit"))
{
DaggerfallUI.Instance.PopupMessage("Previous Outfit Equipped");
}
else if (GUI.Button(count, totalwindows.ToString()))
{
DaggerfallUI.Instance.PopupMessage("Are you sure you want to save this outfit into slot" + totalwindows.ToString());
currentEquipped();
saveCurrentOutfit();
}
else if (GUI.Button(load, "Load Outfit"))
{
DaggerfallUI.Instance.PopupMessage("Are you sure you want to load outfit " + totalwindows.ToString());
loadCurrentOutfit();
}
}
}
}
}
By the way there's a pending PR that will add hotkeys for many things: https://github.com/Interkarma/daggerfal ... /pull/1510