Exemple #1
0
        private void ReadTitle(WarResource res)
        {
            int index  = 0x22;
            int offset = ReadInt(index, res.data);

            while (offset < res.data.Length)
            {
                ushort firstVal = ReadUShort(offset, res.data);
                if (firstVal == 0xFFFF)
                {
                    // Means => end of title section
                    return;
                }

                UIEntry Label = new UIEntry();
                Label.Type      = UIEntryType.Label;
                Label.Alignment = (UIEntryTextAlignment)firstVal;
                Label.X         = ReadUShort(offset + 2, res.data);
                Label.Y         = ReadUShort(offset + 4, res.data);
                Label.Text      = ReadString(offset + 6, res);
                Labels.Add(Label);

                offset += 0x0A;
            }
        }
Exemple #2
0
        private static void DrawLabel(Rect rect, string label, UIEntry item)
        {
            if (!ScrollPositions.ContainsKey(item))
            {
                ScrollPositions.Add(item, new Vector2());
            }

            var itemScrollPosition = ScrollPositions[item];

            Text.Font = GameFont.Small;

            WidgetExtensions.LabelScrollable(rect, label, ref itemScrollPosition, false, true, false);

            Text.Font = GameFont.Small;

            ScrollPositions[item] = _scrollPosition;
        }
Exemple #3
0
        private void ReadUIElements(WarResource res)
        {
            int index  = 0x26;
            int offset = ReadInt(index, res.data);

            // Length of one button => 0x1C
            while (offset < res.data.Length)
            {
                ushort firstVal = ReadUShort(offset, res.data);
                if (firstVal == 0xFFFF)
                {
                    break;
                }

                UIEntry me = new UIEntry();
                me.Type      = (UIEntryType)ReadUShort(offset, res.data);
                me.Alignment = (UIEntryTextAlignment)ReadUShort(offset + 2, res.data);  // This is just a guess based on the label section
                me.X         = ReadUShort(offset + 4, res.data);
                me.Y         = ReadUShort(offset + 6, res.data);
                ushort unk = ReadUShort(offset + 8, res.data);
                me.ButtonReleasedResourceIndex = ReadResourceIndex(offset + 10, res);
                me.ButtonPressedResourceIndex  = ReadResourceIndex(offset + 14, res);
                me.Text = string.Empty;
                if (me.Type == UIEntryType.Button || me.Type == UIEntryType.TextFieldSelectable ||
                    me.Type == UIEntryType.ListBoxSelectButton || me.Type == UIEntryType.TextFieldButton ||
                    me.Type == UIEntryType.TextFieldHidden)
                {
                    me.Text = ReadString(offset + 18, res);
                }
                else if (me.Type == UIEntryType.ValueList || me.Type == UIEntryType.ListBox)
                {
                    // Read values
                    int valuesOffset = ReadInt(offset + 18, res.data);
                    while (valuesOffset < res.data.Length)
                    {
                        int valueOff = ReadInt(valuesOffset, res.data);
                        if (valueOff == unchecked ((int)0xFFFFFFFF) ||
                            valueOff == 0)
                        {
                            break;
                        }

                        string val = ReadStringDirect(valueOff, res);
                        me.Values.Add(val);

                        valuesOffset += 4;
                    }
                }
                else
                {
                    me.ValueCount = ReadInt(offset + 18, res.data);
                }

                me.ButtonIndex = ReadInt(offset + 22, res.data);
                me.HotKey      = ReadUShort(offset + 26, res.data);
                Elements.Add(me);

                if (me.Type == UIEntryType.ListBoxSelectButton)
                {
                    // Fill values which will be pasted into the listbox
                    me.Values = new List <string>(ReadMultiselectValues(me.ButtonIndex, res));
                }

                offset += 0x1C;
            }
        }
Exemple #4
0
        public static void Main(string[] args)
        {
            uiInitOptions o = new uiInitOptions();

            uiInit(ref o);

            List <UIMenu> menus = new List <UIMenu>();
            var           menu  = new UIMenu("File");

            menus.Add(menu);
            var item = menu.AppendItem("Open");

            item.OnClicked += (mi, w) =>
            {
                string filename = window.OpenFile();
                if (String.IsNullOrEmpty(filename))
                {
                    window.MessageBox("No file selected", "Don't be alarmed!", true);
                    return;
                }
                window.MessageBox("File selected", filename);
            };
            item            = menu.AppendItem("Save");
            item.OnClicked += (mi, w) =>
            {
                string filename = window.OpenFile();
                if (String.IsNullOrEmpty(filename))
                {
                    window.MessageBox("No file selected", "Don't be alarmed!", true);
                    return;
                }
                window.MessageBox("File selected (don't worry, it's still there)", filename);
            };
            item = menu.AppendQuitItem();
            //uiOnShouldQuit()

            menu = new UIMenu("Edit");
            menus.Add(menu);
            item = menu.AppendCheckItem("Checkable Item");
            menu.AppendSeparator();
            item         = menu.AppendItem("Disabled Item");
            item.Enabled = false;
            item         = menu.AppendPreferencesItem();

            menu = new UIMenu("Help");
            menus.Add(menu);
            item = menu.AppendItem("Help");
            menu.AppendAboutItem();

            window = new UIWindow("libui Control Gallery", 640, 480, true);

            window.Margined   = true;
            window.OnClosing += (w) =>
            {
                window.Dispose();
                uiQuit();
                return(0);
            };

            var box = new UIBox(true);

            box.Padded = true;
            window.SetChild(box);

            var hbox = new UIBox();

            box.Padded = true;
            box.Append(hbox, true);

            var group = new UIGroup("Basic Controls");

            group.Margined = true;
            hbox.Append(group, false);

            var inner = new UIBox(true);

            inner.Padded = true;
            group.SetChild(inner);

            inner.Append(new UIButton("Button"), false);

            var entry = new UIEntry();

            entry.Text = "Entry";
            inner.Append(entry, false);

            inner.Append(new UILabel("Label"), false);

            inner.Append(new UISeparator(), false);

            inner.Append(new UIDateTimePicker(UIDateTimePickerType.Date), false);

            inner.Append(new UIDateTimePicker(UIDateTimePickerType.Time), false);

            inner.Append(new UIDateTimePicker(UIDateTimePickerType.DateTime), false);

            //inner.Append(new UIFontButton(), false);

            var inner2 = new UIBox(true);

            inner2.Padded = true;
            hbox.Append(inner2, true);

            group          = new UIGroup("Numbers");
            group.Margined = true;
            inner2.Append(group, false);

            inner        = new UIBox(true);
            inner.Padded = true;
            group.SetChild(inner);

            var spinbox = new UISpinbox(0, 100);

            inner.Append(spinbox, false);

            var slider = new UISlider(0, 100);

            inner.Append(slider, false);

            var progressbar = new UIProgressBar();

            inner.Append(progressbar, false);

            group          = new UIGroup("Lists");
            group.Margined = true;
            inner2.Append(group, false);

            inner        = new UIBox(true);
            inner.Padded = true;
            group.SetChild(inner);

            spinbox.OnChanged += (s) =>
            {
                slider.Value      = spinbox.Value;
                progressbar.Value = (int)spinbox.Value;
            };

            slider.OnChanged += (s) =>
            {
                spinbox.Value     = slider.Value;
                progressbar.Value = (int)slider.Value;
            };

            var cbox = new UICombobox();

            cbox.Append("Combobox Item 1");
            cbox.Append("Combobox Item 2");
            cbox.Append("Combobox Item 3");
            inner.Append(cbox, false);

            cbox = new UICombobox(true);
            cbox.Append("Editable Item 1");
            cbox.Append("Editable Item 2");
            cbox.Append("Editable Item 3");
            inner.Append(cbox, false);

            var rb = new UIRadioButtons();

            rb.Append("Radio Button 1");
            rb.Append("Radio Button 2");
            rb.Append("Radio Button 3");
            inner.Append(rb, true);

            var tab = new UITab();

            tab.Append("Page 1", new UIBox());
            tab.Append("Page 2", new UIBox());
            tab.Append("Page 3", new UIBox());
            inner2.Append(tab, true);

            GC.Collect();

            window.Shown = true;
            uiMain();
            uiUninit();
            GC.KeepAlive(menus);
            GC.KeepAlive(window);
        }
Exemple #5
0
        private void ReadUIElements(WarResource res)
        {
            int index = 0x26;
             int offset = ReadInt(index, res.data);

             // Length of one button => 0x1C
             while (offset < res.data.Length)
             {
            ushort firstVal = ReadUShort(offset, res.data);
            if (firstVal == 0xFFFF)
               break;

            UIEntry me = new UIEntry();
            me.Type = (UIEntryType)ReadUShort(offset, res.data);
            me.Alignment = (UIEntryTextAlignment)ReadUShort(offset + 2, res.data);      // This is just a guess based on the label section
            me.X = ReadUShort(offset + 4, res.data);
            me.Y = ReadUShort(offset + 6, res.data);
            ushort unk = ReadUShort(offset + 8, res.data);
            me.ButtonReleasedResourceIndex = ReadResourceIndex(offset + 10, res);
            me.ButtonPressedResourceIndex = ReadResourceIndex(offset + 14, res);
            me.Text = string.Empty;
            if (me.Type == UIEntryType.Button || me.Type == UIEntryType.TextFieldSelectable ||
               me.Type == UIEntryType.ListBoxSelectButton || me.Type == UIEntryType.TextFieldButton ||
               me.Type == UIEntryType.TextFieldHidden)
            {
               me.Text = ReadString(offset + 18, res);
            }
            else if (me.Type == UIEntryType.ValueList || me.Type == UIEntryType.ListBox)
            {
               // Read values
               int valuesOffset = ReadInt(offset + 18, res.data);
               while (valuesOffset < res.data.Length)
               {
                  int valueOff = ReadInt(valuesOffset, res.data);
                  if (valueOff == unchecked((int)0xFFFFFFFF) ||
                     valueOff == 0)
                     break;

                  string val = ReadStringDirect(valueOff, res);
                  me.Values.Add(val);

                  valuesOffset += 4;
               }
            }
            else
            {
               me.ValueCount = ReadInt(offset + 18, res.data);
            }

            me.ButtonIndex = ReadInt(offset + 22, res.data);
            me.HotKey = ReadUShort(offset + 26, res.data);
            Elements.Add(me);

            if (me.Type == UIEntryType.ListBoxSelectButton)
            {
               // Fill values which will be pasted into the listbox
               me.Values = new List<string>(ReadMultiselectValues(me.ButtonIndex, res));
            }

            offset += 0x1C;
             }
        }
Exemple #6
0
        private void ReadTitle(WarResource res)
        {
            int index = 0x22;
             int offset = ReadInt(index, res.data);

             while (offset < res.data.Length)
             {
            ushort firstVal = ReadUShort(offset, res.data);
            if (firstVal == 0xFFFF)
               // Means => end of title section
               return;

            UIEntry Label = new UIEntry();
            Label.Type = UIEntryType.Label;
            Label.Alignment = (UIEntryTextAlignment)firstVal;
            Label.X = ReadUShort(offset + 2, res.data);
            Label.Y = ReadUShort(offset + 4, res.data);
            Label.Text = ReadString(offset + 6, res);
            Labels.Add(Label);

            offset += 0x0A;
             }
        }