Beispiel #1
0
        public bool ApplyMod(EqpManipulation m, IMod mod)
        {
#if USE_EQP
            Manipulations[m] = mod;
            File ??= new ExpandedEqpFile();
            return(m.Apply(File));
#else
            return(false);
#endif
        }
Beispiel #2
0
        public bool RevertMod(EqpManipulation m)
        {
#if USE_EQP
            if (Manipulations.Remove(m))
            {
                var def   = ExpandedEqpFile.GetDefault(m.SetId);
                var manip = new EqpManipulation(def, m.Slot, m.SetId);
                return(manip.Apply(File !));
            }
#endif
            return(false);
        }
Beispiel #3
0
    // Deserialize and check Eqp Entries and add them to the list if they are non-default.
    private void DeserializeEqpEntry(MetaFileInfo metaFileInfo, byte[]?data)
    {
        // Eqp can only be valid for equipment.
        if (data == null || !metaFileInfo.EquipSlot.IsEquipment())
        {
            return;
        }

        var value = Eqp.FromSlotAndBytes(metaFileInfo.EquipSlot, data);
        var def   = new EqpManipulation(ExpandedEqpFile.GetDefault(metaFileInfo.PrimaryId), metaFileInfo.EquipSlot, metaFileInfo.PrimaryId);
        var manip = new EqpManipulation(value, metaFileInfo.EquipSlot, metaFileInfo.PrimaryId);

        if (def.Entry != manip.Entry)
        {
            MetaManipulations.Add(manip);
        }
    }
Beispiel #4
0
        public static void Draw(EqpManipulation meta, Mod.Editor editor, Vector2 iconSize)
        {
            DrawMetaButtons(meta, editor, iconSize);

            // Identifier
            ImGui.TableNextColumn();
            ImGui.SetCursorPosX(ImGui.GetCursorPosX() + ImGui.GetStyle().FramePadding.X);
            ImGui.TextUnformatted(meta.SetId.ToString());
            ImGuiUtil.HoverTooltip("Model Set ID");
            var defaultEntry = ExpandedEqpFile.GetDefault(meta.SetId);

            ImGui.TableNextColumn();
            ImGui.SetCursorPosX(ImGui.GetCursorPosX() + ImGui.GetStyle().FramePadding.X);
            ImGui.TextUnformatted(meta.Slot.ToName());
            ImGuiUtil.HoverTooltip("Equip Slot");

            // Values
            ImGui.TableNextColumn();
            using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing,
                                               new Vector2(3 * ImGuiHelpers.GlobalScale, ImGui.GetStyle().ItemSpacing.Y));
            var idx = 0;

            foreach (var flag in Eqp.EqpAttributes[meta.Slot])
            {
                using var id = ImRaii.PushId(idx++);
                var defaultValue = defaultEntry.HasFlag(flag);
                var currentValue = meta.Entry.HasFlag(flag);
                if (Checkmark("##eqp", flag.ToLocalName(), currentValue, defaultValue, out var value))
                {
                    editor.Meta.Change(meta with {
                        Entry = value ? meta.Entry | flag : meta.Entry & ~flag
                    });
                }

                ImGui.SameLine();
            }

            ImGui.NewLine();
        }