Exemple #1
0
        private TreeNodeHeader *CreateNode(int index, Slice key, TreeNodeFlags flags, int len)
        {
            Debug.Assert(index <= NumberOfEntries && index >= 0);
            Debug.Assert(IsBranch == false || index != 0 || key.Size == 0);// branch page's first item must be the implicit ref
            if (HasSpaceFor(key, len) == false)
            {
                throw new InvalidOperationException(string.Format("The page is full and cannot add an entry, this is probably a bug. Key: {0}, data length: {1}, size left: {2}", key, len, SizeLeft));
            }

            // move higher pointers up one slot
            ushort *offsets = KeysOffsets;

            for (int i = NumberOfEntries; i > index; i--)
            {
                offsets[i] = offsets[i - 1];
            }

            var nodeSize = TreeSizeOf.NodeEntry(PageMaxSpace, key, len);
            var node     = AllocateNewNode(index, nodeSize);

            node->Flags = flags;

            Debug.Assert(key.Size <= ushort.MaxValue);
            node->KeySize = (ushort)key.Size;
            if (key.Options == SliceOptions.Key && node->KeySize > 0)
            {
                key.CopyTo((byte *)node + Constants.Tree.NodeHeaderSize);
            }

            return(node);
        }
Exemple #2
0
 public static unsafe bool CollapsingHeader(string label, TreeNodeFlags flags)
 {
     fixed(byte *bytes = System.Text.Encoding.UTF8.GetBytes(label))
     {
         return(ImGuiNative.igCollapsingHeader(bytes, flags));
     }
 }
Exemple #3
0
        public TreePageSplitter(LowLevelTransaction tx,
                                Tree tree,
                                Slice newKey,
                                int len,
                                long pageNumber,
                                TreeNodeFlags nodeType,
                                TreeCursor cursor,
                                bool splittingOnDecompressed = false)
        {
            _tx         = tx;
            _tree       = tree;
            _newKey     = newKey;
            _len        = len;
            _pageNumber = pageNumber;
            _nodeType   = nodeType;
            _cursor     = cursor;
            _splittingOnDecompressed = splittingOnDecompressed;
            TreePage page = _cursor.Pages.Peek();

            if (_splittingOnDecompressed == false)
            {
                _page = _tree.ModifyPage(page);
            }
            else
            {
                Debug.Assert(page is DecompressedLeafPage);
                _page = page;
            }

            _cursor.Pop();
        }
Exemple #4
0
        private bool TryOverwriteDataOrMultiValuePageRefNode(TreeNodeHeader *updatedNode, int len,
                                                             TreeNodeFlags requestedNodeType, out byte *pos)
        {
            switch (requestedNodeType)
            {
            case TreeNodeFlags.Data:
            case TreeNodeFlags.MultiValuePageRef:
            {
                if (updatedNode->DataSize == len &&
                    (updatedNode->Flags == TreeNodeFlags.Data || updatedNode->Flags == TreeNodeFlags.MultiValuePageRef))
                {
                    updatedNode->Flags = requestedNodeType;

                    pos = (byte *)updatedNode + Constants.Tree.NodeHeaderSize + updatedNode->KeySize;
                    return(true);
                }
                break;
            }

            case TreeNodeFlags.PageRef:
                throw new InvalidOperationException("We never add PageRef explicitly");

            default:
                throw new ArgumentOutOfRangeException();
            }
            pos = null;
            return(false);
        }
Exemple #5
0
        public unsafe byte *DirectAdd(string key, int len, TreeNodeFlags nodeType = TreeNodeFlags.Data)
        {
            Slice keySlice;

            using (Slice.From(_llt.Allocator, key, ByteStringType.Immutable, out keySlice))
            {
                return(DirectAdd(keySlice, len, nodeType));
            }
        }
        public DirectAddScope DirectAdd(string key, int len, TreeNodeFlags nodeType, out byte *ptr)
        {
            Slice keySlice;

            using (Slice.From(_llt.Allocator, key, ByteStringType.Immutable, out keySlice))
            {
                return(DirectAdd(keySlice, len, nodeType, out ptr));
            }
        }
        public void WriteBTreePageCreated(PagePosition pos, TreeNodeFlags flags, byte depth)
        {
            if (LogEnable)
            {
                Logger.Add((byte)LogFlags.BPAGE_CREATED);
                Logger.AddRange(BitConverter.GetBytes(pos.FileId));
                Logger.AddRange(BitConverter.GetBytes(pos.PageNumber));
                Logger.Add((byte)flags);
                Logger.Add(depth);

                Modified = true;
                Modifies.Add(pos);
            }
        }
Exemple #8
0
        public TreePageSplitter(LowLevelTransaction tx,
                                Tree tree,
                                Slice newKey,
                                int len,
                                long pageNumber,
                                TreeNodeFlags nodeType,
                                TreeCursor cursor)
        {
            _tx         = tx;
            _tree       = tree;
            _newKey     = newKey;
            _len        = len;
            _pageNumber = pageNumber;
            _nodeType   = nodeType;
            _cursor     = cursor;
            TreePage page = _cursor.Pages.Peek();

            _page = _tree.ModifyPage(page);
            _cursor.Pop();
        }
        private bool TryOverwriteDataOrMultiValuePageRefNode(TreeNodeHeader *updatedNode, Slice key, int len,
                                                             TreeNodeFlags requestedNodeType, ushort?version, out byte *pos)
        {
            switch (requestedNodeType)
            {
            case TreeNodeFlags.Data:
            case TreeNodeFlags.MultiValuePageRef:
            {
                if (updatedNode->DataSize == len &&
                    (updatedNode->Flags == TreeNodeFlags.Data || updatedNode->Flags == TreeNodeFlags.MultiValuePageRef))
                {
                    CheckConcurrency(key, version, updatedNode->Version, TreeActionType.Add);

                    if (updatedNode->Version == ushort.MaxValue)
                    {
                        updatedNode->Version = 0;
                    }
                    updatedNode->Version++;

                    updatedNode->Flags = requestedNodeType;

                    {
                        pos = (byte *)updatedNode + Constants.NodeHeaderSize + updatedNode->KeySize;
                        return(true);
                    }
                }
                break;
            }

            case TreeNodeFlags.PageRef:
                throw new InvalidOperationException("We never add PageRef explicitly");

            default:
                throw new ArgumentOutOfRangeException();
            }
            pos = null;
            return(false);
        }
Exemple #10
0
        public byte *DirectAdd(Slice key, int len, TreeNodeFlags nodeType = TreeNodeFlags.Data, ushort?version = null)
        {
            Debug.Assert(nodeType == TreeNodeFlags.Data || nodeType == TreeNodeFlags.MultiValuePageRef);

            if (State.InWriteTransaction)
            {
                State.IsModified = true;
            }

            if (_llt.Flags == (TransactionFlags.ReadWrite) == false)
            {
                throw new ArgumentException("Cannot add a value in a read only transaction");
            }

            if (AbstractPager.IsKeySizeValid(key.Size) == false)
            {
                throw new ArgumentException($"Key size is too big, must be at most {AbstractPager.MaxKeySize} bytes, but was {(key.Size + AbstractPager.RequiredSpaceForNewNode)}", nameof(key));
            }

            Func <TreeCursor> cursorConstructor;
            TreeNodeHeader *  node;
            var foundPage = FindPageFor(key, out node, out cursorConstructor);

            var page = ModifyPage(foundPage);

            ushort nodeVersion            = 0;
            bool?  shouldGoToOverflowPage = null;

            if (page.LastMatch == 0) // this is an update operation
            {
                node = page.GetNode(page.LastSearchPosition);

                Debug.Assert(SliceComparer.EqualsInline(TreeNodeHeader.ToSlicePtr(_llt.Allocator, node), key));

                shouldGoToOverflowPage = ShouldGoToOverflowPage(len);

                byte *pos;
                if (shouldGoToOverflowPage == false)
                {
                    // optimization for Data and MultiValuePageRef - try to overwrite existing node space
                    if (TryOverwriteDataOrMultiValuePageRefNode(node, key, len, nodeType, version, out pos))
                    {
                        return(pos);
                    }
                }
                else
                {
                    // optimization for PageRef - try to overwrite existing overflows
                    if (TryOverwriteOverflowPages(node, key, len, version, out pos))
                    {
                        return(pos);
                    }
                }

                RemoveLeafNode(page, out nodeVersion);
            }
            else // new item should be recorded
            {
                State.NumberOfEntries++;
            }

            CheckConcurrency(key, version, nodeVersion, TreeActionType.Add);

            var   lastSearchPosition = page.LastSearchPosition; // searching for overflow pages might change this
            byte *overFlowPos        = null;
            var   pageNumber         = -1L;

            if (shouldGoToOverflowPage ?? ShouldGoToOverflowPage(len))
            {
                pageNumber = WriteToOverflowPages(len, out overFlowPos);
                len        = -1;
                nodeType   = TreeNodeFlags.PageRef;
            }

            byte *dataPos;

            if (page.HasSpaceFor(_llt, key, len) == false)
            {
                using (var cursor = cursorConstructor())
                {
                    cursor.Update(cursor.Pages.First, page);

                    var pageSplitter = new TreePageSplitter(_llt, this, key, len, pageNumber, nodeType, nodeVersion, cursor);
                    dataPos = pageSplitter.Execute();
                }

                DebugValidateTree(State.RootPageNumber);
            }
            else
            {
                switch (nodeType)
                {
                case TreeNodeFlags.PageRef:
                    dataPos = page.AddPageRefNode(lastSearchPosition, key, pageNumber);
                    break;

                case TreeNodeFlags.Data:
                    dataPos = page.AddDataNode(lastSearchPosition, key, len, nodeVersion);
                    break;

                case TreeNodeFlags.MultiValuePageRef:
                    dataPos = page.AddMultiValueNode(lastSearchPosition, key, len, nodeVersion);
                    break;

                default:
                    throw new NotSupportedException("Unknown node type for direct add operation: " + nodeType);
                }
                page.DebugValidate(_llt, State.RootPageNumber);
            }
            if (overFlowPos != null)
            {
                return(overFlowPos);
            }
            return(dataPos);
        }
Exemple #11
0
 public static bool TreeNodeEx(string label, TreeNodeFlags flags = 0)
 {
     return(ImGuiNative.igTreeNodeEx(label, flags));
 }
Exemple #12
0
        private unsafe TreePageEntry AllocateEntry(ILowLevelTransaction tx, TreeNodeFlags nodeFlags, TreePageEntry parent, int index)
        {
            var page = tx.AllocateTrees(Id, 1)[0];

            ref var header = ref page.Header;
 private void SetFlag(TreeNodeFlags bit, bool value)
 {
     if (value)
     {
         myFlags |= bit;
     }
     else
     {
         myFlags &= ~bit;
     }
 }
Exemple #14
0
        public override void DrawSettingsMenu()
        {
            TreeNodeFlags collapsingHeaderFlags = TreeNodeFlags.CollapsingHeader;

            if (ImGui.TreeNodeEx("Plugin Options", collapsingHeaderFlags))
            {
                Settings.EnableInHideout.Value = ImGuiExtension.Checkbox("Enable in Hideout", Settings.EnableInHideout);
                ImGui.Separator();
                Settings.TicksPerSecond.Value = ImGuiExtension.IntSlider("Ticks Per Second", Settings.TicksPerSecond); ImGuiExtension.ToolTipWithText("(?)", "Determines how many times the plugin checks flasks every second.\nLower for less resources, raise for faster response (but higher chance to chug potions).");
                ImGui.Separator();
                Settings.Debug.Value = ImGuiExtension.Checkbox("Debug Mode", Settings.Debug);
                ImGui.TreePop();
            }


            if (ImGui.TreeNodeEx("Flask Options", collapsingHeaderFlags))
            {
                if (ImGui.TreeNode("Individual Flask Settings"))
                {
                    for (int i = 0; i < 5; i++)
                    {
                        FlaskSetting currentFlask = Settings.FlaskSettings[i];
                        if (ImGui.TreeNode("Flask " + (i + 1) + " Settings"))
                        {
                            currentFlask.Enabled.Value      = ImGuiExtension.Checkbox("Enable", currentFlask.Enabled);
                            currentFlask.Hotkey.Value       = ImGuiExtension.HotkeySelector("Hotkey", currentFlask.Hotkey);
                            currentFlask.ReservedUses.Value = ImGuiExtension.IntSlider("Reserved Uses", currentFlask.ReservedUses); ImGuiExtension.ToolTipWithText("(?)", "The absolute number of uses reserved on a flask.\nSet to 1 to always have 1 use of the flask available for manual use.");
                            ImGui.TreePop();
                        }
                    }

                    ImGui.TreePop();
                }

                if (ImGui.TreeNode("Health and Mana"))
                {
                    Settings.AutoFlask.Value = ImGuiExtension.Checkbox("Enable", Settings.AutoFlask);

                    ImGuiExtension.SpacedTextHeader("Settings");
                    Settings.ForceBubblingAsInstantOnly = ImGuiExtension.Checkbox("Force Bubbling as Instant only", Settings.ForceBubblingAsInstantOnly);
                    ImGuiExtension.ToolTipWithText("(?)", "When enabled, flasks with the Bubbling mod will only be used as an instant flask.");
                    Settings.ForcePanickedAsInstantOnly = ImGuiExtension.Checkbox("Force Panicked as Instant only", Settings.ForcePanickedAsInstantOnly);
                    ImGuiExtension.ToolTipWithText("(?)", "When enabled, flasks with the Panicked mod will only be used as an instant flask. \nNote, Panicked will not be used until under 35%% with this enabled."); //
                    ImGuiExtension.SpacedTextHeader("Health Flask");
                    Settings.HPPotion.Value          = ImGuiExtension.IntSlider("Min Life % Auto HP Flask", Settings.HPPotion);
                    Settings.InstantHPPotion.Value   = ImGuiExtension.IntSlider("Min Life % Auto Instant HP Flask", Settings.InstantHPPotion);
                    Settings.DisableLifeSecUse.Value = ImGuiExtension.Checkbox("Disable Life/Hybrid Flask Offensive/Defensive Usage", Settings.DisableLifeSecUse);

                    ImGuiExtension.SpacedTextHeader("Mana Flask");
                    ImGui.Spacing(); Settings.ManaPotion.Value = ImGuiExtension.IntSlider("Min Mana % Auto Mana Flask", Settings.ManaPotion);
                    Settings.InstantManaPotion.Value           = ImGuiExtension.IntSlider("Min Mana % Auto Instant MP Flask", Settings.InstantManaPotion);
                    Settings.MinManaFlask.Value = ImGuiExtension.IntSlider("Min Mana Auto Mana Flask", Settings.MinManaFlask);
                    ImGui.TreePop();
                }

                if (ImGui.TreeNode("Remove Ailments"))
                {
                    Settings.RemAilment.Value = ImGuiExtension.Checkbox("Enable", Settings.RemAilment);

                    ImGuiExtension.SpacedTextHeader("Ailments");
                    Settings.RemFrozen.Value = ImGuiExtension.Checkbox("Frozen", Settings.RemFrozen);
                    ImGui.SameLine();
                    Settings.RemBurning.Value = ImGuiExtension.Checkbox("Burning", Settings.RemBurning);
                    Settings.RemShocked.Value = ImGuiExtension.Checkbox("Shocked", Settings.RemShocked);
                    ImGui.SameLine();
                    Settings.RemCurse.Value  = ImGuiExtension.Checkbox("Cursed", Settings.RemCurse);
                    Settings.RemPoison.Value = ImGuiExtension.Checkbox("Poison", Settings.RemPoison);
                    ImGui.SameLine();
                    Settings.RemBleed.Value     = ImGuiExtension.Checkbox("Bleed", Settings.RemBleed);
                    Settings.CorruptCount.Value = ImGuiExtension.IntSlider("Corrupting Blood Stacks", Settings.CorruptCount);
                    ImGui.TreePop();
                }

                if (ImGui.TreeNode("Speed Flasks"))
                {
                    Settings.SpeedFlaskEnable.Value = ImGuiExtension.Checkbox("Enable", Settings.SpeedFlaskEnable);

                    ImGuiExtension.SpacedTextHeader("Flasks");
                    Settings.QuicksilverFlaskEnable.Value = ImGuiExtension.Checkbox("Quicksilver Flask", Settings.QuicksilverFlaskEnable);
                    Settings.SilverFlaskEnable.Value      = ImGuiExtension.Checkbox("Silver Flask", Settings.SilverFlaskEnable);

                    ImGuiExtension.SpacedTextHeader("Settings");
                    Settings.MinMsPlayerMoving.Value = ImGuiExtension.IntSlider("Milliseconds Spent Moving", Settings.MinMsPlayerMoving); ImGuiExtension.ToolTipWithText("(?)", "Milliseconds spent moving before flask will be used.\n1000 milliseconds = 1 second");
                    ImGui.TreePop();
                }

                if (ImGui.TreeNode("Defensive Flasks"))
                {
                    Settings.DefensiveFlaskEnable.Value = ImGuiExtension.Checkbox("Enable", Settings.DefensiveFlaskEnable);
                    ImGui.Spacing();
                    ImGui.Separator();
                    Settings.HPPercentDefensive.Value         = ImGuiExtension.IntSlider("Min Life %", Settings.HPPercentDefensive);
                    Settings.ESPercentDefensive.Value         = ImGuiExtension.IntSlider("Min ES %", Settings.ESPercentDefensive);
                    Settings.OffensiveAsDefensiveEnable.Value = ImGuiExtension.Checkbox("Use offensive flasks for defense", Settings.OffensiveAsDefensiveEnable);
                    ImGui.Separator();

                    Settings.DefensiveMonsterCount.Value    = ImGuiExtension.IntSlider("Monster Count", Settings.DefensiveMonsterCount);
                    Settings.DefensiveMonsterDistance.Value = ImGuiExtension.IntSlider("Monster Distance", Settings.DefensiveMonsterDistance);
                    Settings.DefensiveCountNormalMonsters   = ImGuiExtension.Checkbox("Normal Monsters", Settings.DefensiveCountNormalMonsters);
                    Settings.DefensiveCountRareMonsters     = ImGuiExtension.Checkbox("Rare Monsters", Settings.DefensiveCountRareMonsters);
                    Settings.DefensiveCountMagicMonsters    = ImGuiExtension.Checkbox("Magic Monsters", Settings.DefensiveCountMagicMonsters);
                    Settings.DefensiveCountUniqueMonsters   = ImGuiExtension.Checkbox("Unique Monsters", Settings.DefensiveCountUniqueMonsters);
                    ImGui.TreePop();
                }

                if (ImGui.TreeNode("Offensive Flasks"))
                {
                    Settings.OffensiveFlaskEnable.Value = ImGuiExtension.Checkbox("Enable", Settings.OffensiveFlaskEnable);
                    ImGui.Spacing();
                    ImGui.Separator();
                    Settings.HPPercentOffensive.Value = ImGuiExtension.IntSlider("Min Life %", Settings.HPPercentOffensive);
                    Settings.ESPercentOffensive.Value = ImGuiExtension.IntSlider("Min ES %", Settings.ESPercentOffensive);
                    ImGui.Separator();
                    Settings.OffensiveMonsterCount.Value    = ImGuiExtension.IntSlider("Monster Count", Settings.OffensiveMonsterCount);
                    Settings.OffensiveMonsterDistance.Value = ImGuiExtension.IntSlider("Monster Distance", Settings.OffensiveMonsterDistance);
                    Settings.OffensiveCountNormalMonsters   = ImGuiExtension.Checkbox("Normal Monsters", Settings.OffensiveCountNormalMonsters);
                    Settings.OffensiveCountRareMonsters     = ImGuiExtension.Checkbox("Rare Monsters", Settings.OffensiveCountRareMonsters);
                    Settings.OffensiveCountMagicMonsters    = ImGuiExtension.Checkbox("Magic Monsters", Settings.OffensiveCountMagicMonsters);
                    Settings.OffensiveCountUniqueMonsters   = ImGuiExtension.Checkbox("Unique Monsters", Settings.OffensiveCountUniqueMonsters);

                    ImGui.TreePop();
                }
                ImGui.TreePop();
            }

            if (ImGui.TreeNodeEx("UI Settings", collapsingHeaderFlags))
            {
                if (ImGui.TreeNodeEx("Flask UI", TreeNodeFlags.Framed))
                {
                    Settings.FlaskUiEnable.Value  = ImGuiExtension.Checkbox("Enable", Settings.FlaskUiEnable);
                    Settings.FlaskPositionX.Value = ImGuiExtension.FloatSlider("X Position", Settings.FlaskPositionX);
                    Settings.FlaskPositionY.Value = ImGuiExtension.FloatSlider("Y Position", Settings.FlaskPositionY);
                    Settings.FlaskTextSize.Value  = ImGuiExtension.IntSlider("Text Size", Settings.FlaskTextSize);
                    ImGui.TreePop();
                }

                if (ImGui.TreeNodeEx("Buff UI", TreeNodeFlags.Framed))
                {
                    Settings.BuffUiEnable.Value        = ImGuiExtension.Checkbox("Enable", Settings.BuffUiEnable);
                    Settings.BuffPositionX.Value       = ImGuiExtension.FloatSlider("X Position", Settings.BuffPositionX);
                    Settings.BuffPositionY.Value       = ImGuiExtension.FloatSlider("Y Position", Settings.BuffPositionY);
                    Settings.BuffTextSize.Value        = ImGuiExtension.IntSlider("Text Size", Settings.BuffTextSize);
                    Settings.EnableFlaskAuraBuff.Value = ImGuiExtension.Checkbox("Enable Flask Or Aura Debuff/Buff", Settings.EnableFlaskAuraBuff);
                    ImGui.TreePop();
                }

                ImGui.TreePop();
            }
        }
 private bool GetAnyFlag(TreeNodeFlags bits)
 {
     return (myFlags & bits) != 0;
 }
Exemple #16
0
 private static void ThrowUnknownNodeTypeAddOperation(TreeNodeFlags nodeType)
 {
     throw new NotSupportedException("Unknown node type for direct add operation: " + nodeType);
 }
Exemple #17
0
        public void InfoDumpMenu(int idIn, out int idPop)
        {
            TreeNodeFlags collapsingHeaderFlags = TreeNodeFlags.CollapsingHeader;

            idPop = idIn;
            if (ImGui.TreeNodeEx("Basic Options", collapsingHeaderFlags))
            {
                ImGui.PushID(idPop);
                Settings.LegionThings.Value = ImGuiExtension.Checkbox(Settings.LegionThings.Value ? "Enable Features" : "Enable Features", Settings.LegionThings);
                idPop++;
                ImGui.PopID();
                Settings.DrawChests.Value = ImGuiExtension.Checkbox(Settings.DrawChests.Value ? "Draw chests" : "Draw Chests", Settings.DrawChests);
                idPop++;
                ImGui.PopID();
                Settings.DrawMobs.Value = ImGuiExtension.Checkbox(Settings.DrawMobs.Value ? "Draw Reward Mobs" : "Draw Reward Mobs", Settings.DrawMobs);
                idPop++;
                ImGui.TreePop();
            }

            if (ImGui.TreeNodeEx("Icons", collapsingHeaderFlags))
            {
                ImGui.PushID(idPop);
                Settings.DrawFancyIcons.Value = ImGuiExtension.Checkbox(Settings.DrawFancyIcons.Value ? "Detailed Loot Icons & Labels" : "Detailed Loot Icons & Labels", Settings.DrawFancyIcons);
                idPop++;
                ImGui.PopID();
                Settings.DrawMonolithIcon.Value = ImGuiExtension.Checkbox(Settings.DrawMobLines.Value ? "Draw Monolith Icon" : "Draw Monolith Icon", Settings.DrawMonolithIcon);
                idPop++;
                ImGui.PopID();
                Settings.IconSizeGeneral.Value = ImGuiExtension.IntSlider("Generals Icon Size", Settings.IconSizeGeneral);
                idPop++;
                ImGui.PopID();
                Settings.IconSizeLoot.Value = ImGuiExtension.IntSlider("Loot Icon Size", Settings.IconSizeLoot);
                idPop++;
                ImGui.PopID();
                Settings.IconSizeChest.Value = ImGuiExtension.IntSlider("Chest Icon Size", Settings.IconSizeChest);
                idPop++;
                ImGui.PopID();
                Settings.IconSizeHoard.Value = ImGuiExtension.IntSlider("War Hoard Icon Size", Settings.IconSizeHoard);
                idPop++;
                ImGui.PopID();
                ImGui.TreePop();
            }
            if (ImGui.TreeNodeEx("Text Labels", collapsingHeaderFlags))
            {
                ImGui.PushID(idPop);
                Settings.TextLabels.Value = ImGuiExtension.Checkbox(Settings.TextLabels.Value ? "Icon Text Labels" : "Icon Text Labels", Settings.TextLabels);
                idPop++;
                ImGui.PopID();
                Settings.LootTextLabels.Value = ImGuiExtension.Checkbox(Settings.LootTextLabels.Value ? "Loot Type as Text Label" : "Loot Type as Text Label", Settings.LootTextLabels);
                idPop++;
                ImGui.PopID();
                Settings.TextLabelsOnly.Value = ImGuiExtension.Checkbox(Settings.TextLabelsOnly.Value ? "Text Labels Only" : "Text Labels Only", Settings.TextLabelsOnly);
                idPop++;
                ImGui.PopID();
                Settings.TextSize.Value = ImGuiExtension.IntSlider("Text Label Font Size", Settings.TextSize);
                idPop++;
                ImGui.PopID();
                ImGui.TreePop();
            }
            if (ImGui.TreeNodeEx("World Icons", collapsingHeaderFlags))
            {
                ImGui.PushID(idPop);
                Settings.DrawWorldIcons.Value = ImGuiExtension.Checkbox(Settings.DrawWorldIcons.Value ? "Draw Icons in World" : "Draw Icons in World", Settings.DrawWorldIcons);
                idPop++;
                ImGui.PopID();
                Settings.IconSizeWorld.Value = ImGuiExtension.IntSlider("World Icon Size", Settings.IconSizeWorld);
                idPop++;
                ImGui.TreePop();
            }
            if (ImGui.TreeNodeEx("Lines to Things", collapsingHeaderFlags))
            {
                ImGui.PushID(idPop);
                Settings.DrawChestsLines.Value = ImGuiExtension.Checkbox(Settings.DrawChestsLines.Value ? "Draw Lines to Chests" : "Draw Lines to Chests", Settings.DrawChestsLines);
                idPop++;
                ImGui.PopID();
                Settings.DrawMobLines.Value = ImGuiExtension.Checkbox(Settings.DrawMobLines.Value ? "Draw Lines to Reward Mobs" : "Draw Lines to Reward Mobs", Settings.DrawMobLines);
                idPop++;
                ImGui.PopID();
                Settings.DrawMonolithLine.Value = ImGuiExtension.Checkbox(Settings.DrawMobLines.Value ? "Draw Line to Monolith" : "Draw Line to Monolith", Settings.DrawMonolithLine);
                idPop++;
                ImGui.PopID();
                Settings.LineThickness.Value = ImGuiExtension.IntSlider("Line Thickness", Settings.LineThickness);
                idPop++;
                ImGui.PopID();
                Settings.LineAlpha.Value = ImGuiExtension.IntSlider("Line Alpha", Settings.LineAlpha);
                idPop++;
                ImGui.TreePop();
            }
            if (ImGui.TreeNodeEx("Color Pickers", collapsingHeaderFlags))
            {
                ImGui.Text("Color Selection:");
                Settings.KaruiColor = ImGuiExtension.ColorPicker("Karui Color", Settings.KaruiColor);
                idPop++;
                ImGui.PopID();
                Settings.EternalColor = ImGuiExtension.ColorPicker("Eternal Empire Color", Settings.EternalColor);
                idPop++;
                ImGui.PopID();
                Settings.TemplarColor = ImGuiExtension.ColorPicker("Templar Color", Settings.TemplarColor);
                idPop++;
                ImGui.PopID();
                Settings.VaalColor = ImGuiExtension.ColorPicker("Vaal Color", Settings.VaalColor);
                idPop++;
                ImGui.PopID();
                Settings.MarakethColor = ImGuiExtension.ColorPicker("Maraketh Color", Settings.MarakethColor);
                idPop++;
                ImGui.TreePop();
            }
        }
Exemple #18
0
        //obsolete!
        public static bool CollapsingHeader(string label, string id, bool displayFrame, bool defaultOpen)
        {
            TreeNodeFlags default_open_flags = TreeNodeFlags.DefaultOpen;

            return(ImGuiNative.igCollapsingHeader(label, (defaultOpen ? default_open_flags : 0)));
        }
Exemple #19
0
 public static extern bool igCollapsingHeader(string label, ref bool p_open, TreeNodeFlags flags = 0);
Exemple #20
0
 public static bool CollapsingHeader(string label, TreeNodeFlags flags)
 {
     return(ImGuiNative.igCollapsingHeader(label, flags));
 }
        public unsafe byte *DirectAdd(string key, int len, TreeNodeFlags nodeType = TreeNodeFlags.Data, ushort?version = null)
        {
            var keySlice = Slice.From(_llt.Allocator, key, Sparrow.ByteStringType.Immutable);

            return(DirectAdd(keySlice, len, nodeType, version));
        }
 private bool GetFlag(TreeNodeFlags bit)
 {
     return (myFlags & bit) == bit;
 }
Exemple #23
0
        public DirectAddScope DirectAdd(Slice key, int len, TreeNodeFlags nodeType, out byte *ptr)
        {
            if (_llt.Flags == TransactionFlags.ReadWrite)
            {
                State.IsModified = true;
            }
            else
            {
                ThreadCannotAddInReadTx();
            }

            if (AbstractPager.IsKeySizeValid(key.Size) == false)
            {
                ThrowInvalidKeySize(key);
            }

            var foundPage = FindPageFor(key, node: out TreeNodeHeader * node, cursor: out TreeCursorConstructor cursorConstructor, allowCompressed: true);
            var page      = ModifyPage(foundPage);

            bool?shouldGoToOverflowPage = null;

            if (page.LastMatch == 0) // this is an update operation
            {
                if ((nodeType & TreeNodeFlags.NewOnly) == TreeNodeFlags.NewOnly)
                {
                    ThrowConcurrencyException();
                }

                node = page.GetNode(page.LastSearchPosition);

#if DEBUG
                using (TreeNodeHeader.ToSlicePtr(_llt.Allocator, node, out Slice nodeCheck))
                {
                    Debug.Assert(SliceComparer.EqualsInline(nodeCheck, key));
                }
#endif
                shouldGoToOverflowPage = ShouldGoToOverflowPage(len);

                byte *pos;
                if (shouldGoToOverflowPage == false)
                {
                    // optimization for Data and MultiValuePageRef - try to overwrite existing node space
                    if (TryOverwriteDataOrMultiValuePageRefNode(node, len, nodeType, out pos))
                    {
                        ptr = pos;
                        return(new DirectAddScope(this));
                    }
                }
                else
                {
                    // optimization for PageRef - try to overwrite existing overflows
                    if (TryOverwriteOverflowPages(node, len, out pos))
                    {
                        ptr = pos;
                        return(new DirectAddScope(this));
                    }
                }

                RemoveLeafNode(page);
            }
            else // new item should be recorded
            {
                State.NumberOfEntries++;
            }

            nodeType &= ~TreeNodeFlags.NewOnly;
            Debug.Assert(nodeType == TreeNodeFlags.Data || nodeType == TreeNodeFlags.MultiValuePageRef);

            var   lastSearchPosition = page.LastSearchPosition; // searching for overflow pages might change this
            byte *overFlowPos        = null;
            var   pageNumber         = -1L;
            if (shouldGoToOverflowPage ?? ShouldGoToOverflowPage(len))
            {
                pageNumber = WriteToOverflowPages(len, out overFlowPos);
                len        = -1;
                nodeType   = TreeNodeFlags.PageRef;
            }

            byte *dataPos;
            if (page.HasSpaceFor(_llt, key, len) == false)
            {
                if (IsLeafCompressionSupported == false || TryCompressPageNodes(key, len, page) == false)
                {
                    using (var cursor = cursorConstructor.Build(key))
                    {
                        cursor.Update(cursor.Pages, page);

                        var pageSplitter = new TreePageSplitter(_llt, this, key, len, pageNumber, nodeType, cursor);
                        dataPos = pageSplitter.Execute();
                    }

                    DebugValidateTree(State.RootPageNumber);

                    ptr = overFlowPos == null ? dataPos : overFlowPos;
                    return(new DirectAddScope(this));
                }

                // existing values compressed and put at the end of the page, let's insert from Upper position
                lastSearchPosition = 0;
            }

            switch (nodeType)
            {
            case TreeNodeFlags.PageRef:
                dataPos = page.AddPageRefNode(lastSearchPosition, key, pageNumber);
                break;

            case TreeNodeFlags.Data:
                dataPos = page.AddDataNode(lastSearchPosition, key, len);
                break;

            case TreeNodeFlags.MultiValuePageRef:
                dataPos = page.AddMultiValueNode(lastSearchPosition, key, len);
                break;

            default:
                ThrowUnknownNodeTypeAddOperation(nodeType);
                dataPos = null;     // never executed
                break;
            }

            page.DebugValidate(this, State.RootPageNumber);

            ptr = overFlowPos == null ? dataPos : overFlowPos;
            return(new DirectAddScope(this));
        }