AddItem() public method

public AddItem ( System c_ItemLabel ) : int
c_ItemLabel System
return int
示例#1
0
    // Use this for initialization
    void Start()
    {
        //LISTBOX TEST
        some_list = new ListBox(new Rect(10, 20, 110, 150), new Rect(0, 0, 90, 150), false, true);
        some_list.AddItem("Text 1");
        some_list.AddItem("Text 2");
        some_list.AddItem("Text 3");
        some_list.AddItem("Text 4");

        some_list.InsertItem(2, icon);
        //-------------
    }
示例#2
0
 private void AddAvailableColor(ColorXML colorXML)
 {
     foreach (ColorXML usedColor in compressedBuilding.availableColoursXMLList)
     {
         if (colorXML.name == usedColor.name)
         {
             return;
         }
     }
     colorGlobalList.AddItem(new ListBoxObject(colorXML.name, colorXML, colorXML.ToColor()));
 }
示例#3
0
        public CollapseItem AddItem(string fileName)
        {
            CollapseItem newItem = mListBox.AddItem(fileName);
            ListBoxIcon  icon    = newItem.AddIcon(mCopyLocallyTexture, "ActionIcon");

            icon.IconClick += new ListBoxFunction(IconClick);
            icon.ScaleX     = icon.ScaleY = 1.1f;

            removeFilesAlreadyMarkedRelative();

            return(newItem);
        }
        //called by messagebox closing when player clicks on spell name
        //currently this just updates selectedItem in the list box
        public void renameSpellPromptHandler(DaggerfallInputMessageBox sender, string input)
        {
            //daggerfall allows empty spell name, seems like a bad idea
            if (string.IsNullOrEmpty(input))
            {
                return;
            }

            //TODO -
            listBox.AddItem(input, listBox.SelectedIndex);
            listBox.RemoveItem(SelectedIndex + 1);
        }
示例#5
0
 private void RestoreItems()
 {
     foreach (var item in CommonLogic.GetInstance().Storage.Members)
     {
         //add member to ui
         MemberItem member = new MemberItem();
         _listBox.AddItem(member);
         member.MemberName.SetText(item.Name);
         member.MemberValue.SetText(item.Value + "%");
         member.IsWinner = item.IsWinner;
         member.Index    = CommonLogic.GetInstance().Storage.Members.Count - 1;
     }
 }
示例#6
0
 private void PrintCategory(int id, int level)
 {
     Category[] cat = categories.ToArray();
     foreach (Category category in cat)
     {
         if (category.ParentCategoryID == id)
         {
             ListBox.AddItem(StringUtil.Clone("|", level) + category.Name, category.CategoryID.ToString());
             categories.Remove(category);
             PrintCategory(category.CategoryID, level + 1);
         }
     }
 }
示例#7
0
        private void LoadScores()
        {
            _ScoresListBox.Clear();

            // Add scores to list box
            foreach (ColonyGameScoreRecord record in ColonyGameScores.GetScores())
            {
                string scoreText = record.MissionDescription + ", " + GetDifficultyString(record.Difficulty) + ", " + record.GameTime.ToString("D7");
                scoreText += ", " + record.PlayerName + ", " + record.WinDate.ToString("M-d-yyyy");

                _ScoresListBox.AddItem(scoreText);
            }
        }
        private void AddPreset(string title, string description, string author, string version, out ListBox.ListItem itemOut)
        {
            var preset = new Preset
            {
                Title = !string.IsNullOrEmpty(title) ? title : "<Unknown>",
                Description = !string.IsNullOrEmpty(description) ? description : "<Missing description>",
                Author = author, //optional
                Version = version,
            };
            presets.Add(preset);

            listBox.AddItem(preset.Title, out itemOut);
            paginator.Total = listBox.Count;
        }
        void AddSelectedProperty(Window callingWindow)
        {
            string selectedString = mAllProperties.GetHighlightedItem().Text;

            if (mPropertiesToSave.Contains(selectedString) == false)
            {
                mPropertiesToSave.AddItem(selectedString);
            }
        }
示例#10
0
    /// <summary>
    /// Add a list of options.
    /// </summary>
    /// <param name="panel">leftPanel, centerPanel or rightPanel.</param>
    /// <param name="Options">List of labels.</param>
    /// <param name="selected">Selected option.</param>
    ListBox AddListbox(
        Panel panel,
        List <string> Options,
        int selected,
        string title,
        string toolTip)
    {
        int displayed = Options.Count;
        int spacing   = 7 * displayed;

        // Title
        TextLabel textLabel = new TextLabel();

        textLabel.Text                = title;
        textLabel.Position            = new Vector2(0, y);
        textLabel.HorizontalAlignment = HorizontalAlignment.Center;
        textLabel.ShadowColor         = Color.clear;
        textLabel.TextColor           = itemColor;
        textLabel.TextScale           = itemTextScale;
        AddToolTipToTextLabel(textLabel, toolTip);
        panel.Components.Add(textLabel);

        y += 8;

        // ListBox
        ListBox listBox = new ListBox();

        listBox.BackgroundColor     = listBoxBackgroundColor;
        listBox.TextColor           = unselectedTextColor;
        listBox.SelectedTextColor   = selectedTextColor;
        listBox.ShadowPosition      = Vector2.zero;
        listBox.TextScale           = itemTextScale;
        listBox.RowsDisplayed       = displayed;
        listBox.RowAlignment        = HorizontalAlignment.Center;
        listBox.HorizontalAlignment = HorizontalAlignment.Center;
        listBox.Position            = new Vector2(0, y);
        listBox.Size = new Vector2(panel.Size.x, spacing);
        listBox.SelectedShadowPosition = DaggerfallUI.DaggerfallDefaultShadowPos;
        listBox.SelectedShadowColor    = Color.black;
        panel.Components.Add(listBox);
        foreach (var option in Options)
        {
            listBox.AddItem(option);
        }
        listBox.SelectedIndex = selected;
        y += (spacing + 5);

        return(listBox);
    }
示例#11
0
        /// <summary>
        /// Add preset to listbox.
        /// </summary>
        private void RegisterPreset(Preset preset)
        {
            string title = preset.Title;

            preset.Title = !string.IsNullOrEmpty(preset.Title) ?
                           mod.TryLocalize("Presets", title, "Title") ?? preset.Title : ModManager.GetText("missingTitle");
            preset.Description = !string.IsNullOrEmpty(preset.Description) ?
                                 mod.TryLocalize("Presets", title, "Description") ?? preset.Description : ModManager.GetText("missingDescription");

            ListBox.ListItem itemOut;
            listBox.AddItem(preset.Title, out itemOut);
            itemOut.textColor         = settings.IsCompatible(preset) ? titleColor : warningColor;
            itemOut.selectedTextColor = selectedTitleColor;
            itemOut.shadowColor       = Color.clear;
        }
示例#12
0
        static void AndACTION(object sender, EventArgs a)
        {
            var cmd = Prompt.Text;

            Prompt.Text = "";
            CommandHistory.AddItem(cmd);
            for (int i = 0; i < cmd.Length; ++i)
            {
                if (cmd[i] < 32 || cmd[i] > 126)
                {
                    QuickGTK.Error($"Non ASCII character found on position: {i} -> {cmd[i]}/{(int)cmd[i]}/{((int)cmd[i]).ToString("X")}");
                    return;
                }
            }
            CommandClass.DoCommand(cmd);
        }
示例#13
0
 static public void UpdateTags()
 {
     TagList.Clear();
     if (CurrentProject == null)
     {
         return;
     }
     CurrentProject.Data.List("Tags").Sort();
     foreach (string tag in CurrentProject.Data.List("Tags"))
     {
         if (tag.Trim() != "")
         {
             TagList.AddItem(tag.Trim());
         }
     }
 }
示例#14
0
        public override void Initialize()
        {
            var l1 = new AbsoluteLayout(10, 10, 300, 300, Color.White);
            var l2 = new AbsoluteLayout(10, 10, 100, 100, Color.Green);

            l1.AddComponent(l2);
            var tb     = new TextBlock(50, 20, "STAS", "Arial", 11, StringAlignment.Center, Color.Black);
            var button = new ButtonCircle(10, 20, 25, new Font("Arial", 10), "BUTTON", Color.FromArgb(50, 50, 50));

            l2.AddComponent(button);
            l1.ListenerMouse.AddDown((m) =>
            {
                Console.WriteLine(m.UI);
            });
            AddComponent(l1);

            LayoutGrid grid = new LayoutGrid(400, 100, 400, 400, Color.FromArgb(0, 0, 0));

            grid.InitGrid(2, 2);
            grid.AddComponent(0, 0, new AbsoluteLayout(0, 0, 10, 10, Color.Green));
            grid.AddComponent(1, 0, new AbsoluteLayout(0, 0, 10, 10, Color.Red));
            grid.AddComponent(0, 1, new AbsoluteLayout(0, 0, 10, 10, Color.Blue));
            grid.AddComponent(1, 1, new AbsoluteLayout(0, 0, 10, 10, Color.Gray));
            this.AddComponent(grid);

            Window win    = new Window(400, 400, 500, 500, "My Window");
            var    scroll = new Scroll(10, 150, 100);
            var    lsb    = new ListBox(200, 200, 200, 200);

            scroll.ChangeScroll += (o, e) => { win.Title.Value = scroll.Value.ToString(); };
            win.AddComponent(lsb);
            lsb.AddItem(new ButtonRect(0, 0, 20, 40, new Font("Arial", 12), "Sta", Color.Blue));
            this.AddComponent(win);

            var tabs = new TabLayout <TextBlock>(100, 100, 400, 30, Color.Silver);

            this.AddComponent(tabs);
            for (int i = 0; i < 3; i++)
            {
                tabs.AddTab($"File {i}.cs", new TextBlock(10, 10, "1", "Arial", 14,
                                                          StringAlignment.Center, Color.Red)).Active = (name, ui) => {
                    Console.WriteLine("name: " + name);
                }
            }
            ;
        }
示例#15
0
        public override void Initialize()
        {
            base.Initialize();

            ListBox descriptions = new ListBox((int)Preferences.Width, 200);

            descriptions.AddItem(new ListItem("Electronic Gadget"));
            descriptions.AddItem(new ListItem("Plastic Guy"));
            descriptions.AddItem(new ListItem("I-beleive-have-a-laser"));
            descriptions.AddItem(new ListItem("My-helment-is-a-fishbowl"));
            descriptions.AddItem(new ListItem("I-have-sort-of-wings"));
            descriptions.AddItem(new ListItem("To-the-infinity-and-beyond"));
            descriptions.AddItem(new ListItem("I-am-the-Andy's-second"));

            AddComponent(descriptions, 0, 0);
        }
示例#16
0
        void RefreshSpellsList()
        {
            // Clear existing list
            spellsListBox.ClearItems();

            // Add player spells to list
            EffectBundleSettings[] spellbook = GameManager.Instance.PlayerEntity.GetSpells();
            if (spellbook != null)
            {
                for (int i = 0; i < spellbook.Length; i++)
                {
                    // Show spell name and cost
                    // Costs can change based on player skills and stats so must be calculated each time
                    int goldCost, spellPointCost;
                    FormulaHelper.CalculateTotalEffectCosts(spellbook[i].Effects, spellbook[i].TargetType, out goldCost, out spellPointCost);
                    spellsListBox.AddItem(string.Format("{0} - {1}", spellPointCost, spellbook[i].Name));
                }
            }
        }
示例#17
0
    void TackleDrawLine(Vector3 posCalculated)
    {
        Vector3 pos = posCalculated;

        pos = new Vector3(pos.x, pos.y, -1);

        if (Input.GetMouseButtonDown(0) && GetClickedObjectName().Equals("Terrain2D"))
        {
            line      = Instantiate(linePrefab, lineParent);
            line.name = "line" + count.ToString();

            lndr = line.GetComponent <LineRenderer>();
            //lndr.startWidth = 5f;
            lndr.startWidth = LineWidth.value;


            linePrefabMat = line.GetComponent <LineRenderer>();
            Color UpdatedlineColor = LineColorChange();


            lineListBox.AddItem(new ListBox.ListItem(line.name));

            currentLine = line;
            count++;


            currentLine.GetComponent <LineSpecs>().SetLineStart(pos);
            currentLine.GetComponent <LineSpecs>().SetStart(XYtoLatLong(pos.x, pos.y));
            currentLine.GetComponent <LineSpecs>().SetLineColor(UpdatedlineColor);
        }

        if (Input.GetMouseButton(0) && GetClickedObjectName().Equals("Terrain2D"))
        {
            currentLine.GetComponent <LineSpecs>().SetLineEnd(pos);
            currentLine.GetComponent <LineSpecs>().SetEnd(XYtoLatLong(pos.x, pos.y));
        }

        if (Input.GetMouseButtonUp(0) && GetClickedObjectName().Equals("Terrain2D"))
        {
            currentLine.GetComponent <LineSpecs>().UpdateCollider();
        }
    }
示例#18
0
    public void DrawCircle(List <float> points)
    {
        GameObject Circle = Instantiate(circlePrefab, circleParent);

        float[] p1 = DrawManager.GetComponent <DrawControl>().LatLongToXY(points[0], points[1]);

        Circle.transform.position = new Vector3(p1[0], p1[1], -1);
        Circle.AddComponent <PolygonCollider2D>();
        Circle.transform.localScale = new Vector3(points[2], points[3], 0);

        Circle.name = "Circle" + countC.ToString();               //Added

        CircleListBox.AddItem(new ListBox.ListItem(Circle.name)); //Added

        currentCircle = Circle;
        countC++;

        currentCircle.GetComponent <CircleSpecs>().SetXYRadius(points[2], points[3]);
        currentCircle.GetComponent <CircleSpecs>().SetPointLatLong(new Vector2(points[0], points[1]));
    }
        private void PopulatePlayerList()
        {
            int selectedIndex = m_PlayerListBox.selectedIndex;

            m_PlayerListBox.Clear();

            for (int i = 0; i < UserData.current.selectedVariant.players.Count; ++i)
            {
                ListBoxItem item = ListBoxItem.Create(m_PlayerListPrefab, "Player " + (i + 1));
                item.userData = UserData.current.selectedVariant.players[i];
                m_PlayerListBox.AddItem(item);
            }

            m_PlayerListBox.selectedIndex = selectedIndex;

            // Can't have more than 6 players in the game
            if (UserData.current.selectedVariant.players.Count >= 6)
            {
                m_BtnAddPlayer.interactable = false;
            }
        }
 private void PopulateSpellsList(List <EffectBundleSettings> spells, int?availableSpellPoints = null)
 {
     foreach (EffectBundleSettings spell in spells)
     {
         // Show spell name and cost
         // Costs can change based on player skills and stats so must be calculated each time
         int goldCost, spellPointCost;
         FormulaHelper.CalculateTotalEffectCosts(spell.Effects, spell.TargetType, out goldCost, out spellPointCost, null, spell.MinimumCastingCost);
         ListBox.ListItem listItem;
         spellsListBox.AddItem(string.Format("{0} - {1}", spellPointCost, spell.Name), out listItem);
         if (availableSpellPoints != null && availableSpellPoints < spellPointCost)
         {
             // Desaturate unavailable spells
             float desaturation = 0.75f;
             listItem.textColor                    = Color.Lerp(listItem.textColor, Color.grey, desaturation);
             listItem.selectedTextColor            = Color.Lerp(listItem.selectedTextColor, Color.grey, desaturation);
             listItem.highlightedTextColor         = Color.Lerp(listItem.highlightedTextColor, Color.grey, desaturation);
             listItem.highlightedSelectedTextColor = Color.Lerp(listItem.highlightedSelectedTextColor, Color.grey, desaturation);
         }
     }
 }
示例#21
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init"></see> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"></see> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (DesignMode)
            {
                return;
            }

            categories = KbContext.CurrentKb.ManagerCategory.GetAll();
            Category[] cat = categories.ToArray();
            foreach (Category category in cat)
            {
                if (category.ParentCategoryID == null)
                {
                    ListBox.AddItem(category.Name, category.CategoryID.ToString());
                    categories.Remove(category);
                    PrintCategory(category.CategoryID, 1);
                }
            }
        }
示例#22
0
        public void AddConfigPage(IGameEffectConfigPage page)
        {
            // Create panel to home config page
            Panel panel = new Panel();

            panel.Position        = effectPanelRect.position;
            panel.Size            = effectPanelRect.size;
            panel.BackgroundColor = effectPanelBackgroundColor;
            panel.Enabled         = false;
            panel.Tag             = page.Key;
            mainPanel.Components.Add(panel);

            // Setup config page
            page.Setup(panel);

            // Add page to select from list
            effectPagesDict.Add(page.Key, new ConfigPageEntry()
            {
                panel = panel, page = page
            });
            effectList.AddItem(page.Title, -1, page.Key);
        }
示例#23
0
    void GetLoadedMods()
    {
        var mods = ModManager.Instance.GetAllMods(true);

        modList.ClearItems();

        if (modSettings == null || modSettings.Length != mods.Length)
        {
            modSettings = new ModSettings[mods.Length];
        }

        for (int i = 0; i < mods.Length; i++)
        {
            ModSettings modsett = new ModSettings();
            modsett.modInfo = mods[i].ModInfo;
            modsett.enabled = mods[i].Enabled;
            modSettings[i]  = modsett;
            modList.AddItem(modsett.modInfo.ModFileName);
        }

        mods = null;
    }
示例#24
0
    void TackleDrawCircle(Vector3 posCalculated)
    {
        Vector3 pos = posCalculated;

        pos = new Vector3(pos.x, pos.y, -1);

        //Check if mouse button is pressed on terrain
        if (Input.GetMouseButtonDown(0) && GetClickedObjectName().Equals("Terrain2D"))
        {
            circleObject = Instantiate(circlePrefab, circleParent);

            circleObject.name = "Circle" + countC.ToString(); //Added
            circleObject.transform.position = pos;
            initialPosition = pos;

            initialScale  = circleObject.transform.localScale;
            startDraw     = true;
            registerMouse = true;
            CircleListBox.AddItem(new ListBox.ListItem(circleObject.name)); //Added
            countC++;
        }
        if (registerMouse)
        {
            if (Input.GetMouseButtonUp(0))
            {
                startDraw     = false;
                registerMouse = false;

                circleObject.GetComponent <CircleSpecs>().SetPointLatLong(XYtoLatLong(initialPosition.x, initialPosition.y));
                circleObject.AddComponent <PolygonCollider2D>();
            }
            if (startDraw)
            {
                Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - initialPosition;
                circleObject.transform.localScale = new Vector3(initialScale.x + difference.x, initialScale.y + difference.y);
                circleObject.GetComponent <CircleSpecs>().SetXYRadius(initialScale.x + difference.x, initialScale.y + difference.y);
            }
        }
    }
示例#25
0
        void Refresh()
        {
            ItemCollection playerItems = GameManager.Instance.PlayerEntity.Items;

            for (int i = 0; i < playerItems.Count; i++)
            {
                DaggerfallUnityItem item = playerItems.GetItem(i);
                if (item.IsEnchanted)
                {
                    foreach (DaggerfallEnchantment enchantment in item.Enchantments)
                    {
                        if (enchantment.type == EnchantmentTypes.CastWhenUsed)
                        {
                            magicUseItems.Add(item);
                            break;
                        }
                    }
                }
                else if (item.IsPotion)
                {
                    magicUseItems.Add(item);
                }
            }

            if (magicUseItems.Count > 0)
            {
                ListBox.ClearItems();
                foreach (DaggerfallUnityItem magicUseItem in magicUseItems)
                {
                    ListBox.AddItem(magicUseItem.LongName);
                }
            }
            else
            {
                CloseWindow();
            }
        }
示例#26
0
        private void LoadMissions()
        {
            _MissionListBox.Clear();

            // Read missions in "ColonyGames" directory
            if (!Directory.Exists("ColonyGames"))
            {
                return;
            }

            // Add missions to list box
            foreach (string file in Directory.EnumerateFiles("ColonyGames", "*.opm", SearchOption.AllDirectories))
            {
                try
                {
                    MissionRoot mission = MissionReader.GetMissionData(file);
                    _MissionListBox.AddItem(mission.levelDetails.description, new ListBoxItemContents(file, mission));
                }
                catch (System.Exception ex)
                {
                    Debug.LogException(ex);
                }
            }
        }
        protected override void Setup()
        {
            base.Setup();

            ParentPanel.BackgroundColor = ScreenDimColor;

            nativeTexture = DaggerfallUI.GetTextureFromImg(SPELLBOOKIMAGENAME);
            if (!nativeTexture)
            {
                throw new Exception("DaggerfallTravelMap: Could not load native texture.");
            }

            mainPanel = new Panel();
            mainPanel.BackgroundTexture = nativeTexture;
            mainPanel.Size = new Vector2(nativeTexture.width, nativeTexture.height);
            mainPanel.HorizontalAlignment = HorizontalAlignment.Center;
            mainPanel.VerticalAlignment   = VerticalAlignment.Middle;
            mainPanel.Name = "main_panel";
            NativePanel.Components.Add(mainPanel);

            listBox                     = new ListBox();
            listBox.Position            = new Vector2(5, 12);
            listBox.Size                = new Vector2(111, 132);
            listBox.RowsDisplayed       = 16;
            listBox.MaxCharacters       = 22;
            listBox.Name                = "spell_list";
            listBox.OnMouseClick       += listBox_OnMouseClickHandler;
            listBox.OnMouseDoubleClick += listBox_OnMouseDoubleClickHandler;
            listBox.OnMouseScrollDown  += listBox_OnMouseScroll;
            listBox.OnMouseScrollUp    += listBox_OnMouseScroll;
            mainPanel.Components.Add(listBox);

            buyButton               = DaggerfallUI.AddButton(new Rect(3, 152, 36, 9), mainPanel);
            buyButton.Name          = "buy_button";
            buyButton.OnMouseClick += buyButton_OnMouseClick;

            upArrowButton               = DaggerfallUI.AddButton(new Rect(121, 11, 9, 16), mainPanel);
            upArrowButton.Name          = "upArroow_button";
            upArrowButton.OnMouseClick += arrowButton_OnMouseClick;

            downArrowButton               = DaggerfallUI.AddButton(new Rect(121, 132, 9, 16), mainPanel);
            downArrowButton.Name          = "downArroow_button";
            downArrowButton.OnMouseClick += arrowButton_OnMouseClick;

            exitButton               = DaggerfallUI.AddButton(new Rect(216, 149, 42, 14.5f), mainPanel);
            exitButton.Name          = "downArroow_button";
            exitButton.OnMouseClick += exitButton_OnMouseClick;

            scrollBar = new VerticalScrollBar();
            scrollBar.HorizontalAlignment = HorizontalAlignment.None;
            scrollBar.VerticalAlignment   = VerticalAlignment.None;
            scrollBar.Position            = new Vector2(121, 27);
            scrollBar.Size         = new Vector2(9, 104);
            scrollBar.TotalUnits   = listBox.Count;
            scrollBar.DisplayUnits = listBox.RowsDisplayed;
            scrollBar.ScrollIndex  = 0;
            scrollBar.Name         = "scrollbar";
            scrollBar.OnScroll    += ScrollBar_OnScroll;
            mainPanel.Components.Add(scrollBar);

            spellIcon      = DaggerfallUI.AddPanel(new Rect(149.25f, 14, 16, 16), mainPanel);
            spellIcon.Name = "spell_icon";
            spellIcon.BackgroundTextureLayout = BackgroundLayout.StretchToFill;

            spellRangeIcon      = DaggerfallUI.AddPanel(new Rect(182, 14, 25, 16), mainPanel);
            spellRangeIcon.Name = "spellRange_icon";
            spellRangeIcon.BackgroundTextureLayout = BackgroundLayout.StretchToFill;

            spellElementIcon      = DaggerfallUI.AddPanel(new Rect(223, 14, 16, 16), mainPanel);
            spellElementIcon.Name = "spellEffect_icon";
            spellElementIcon.BackgroundTextureLayout = BackgroundLayout.StretchToFill;

            spellName               = new TextLabel();
            spellName.Position      = new Vector2(123, 1);
            spellName.Size          = new Vector2(122, 7);
            spellName.MaxCharacters = 24;
            spellName.Name          = "spellName_label";
            mainPanel.Components.Add(spellName);

            spellPrice               = new TextLabel();
            spellPrice.Position      = new Vector2(76, 153);
            spellPrice.Size          = new Vector2(50, 7);
            spellPrice.MaxCharacters = 19;
            spellPrice.Name          = "spellPrice_label";
            mainPanel.Components.Add(spellPrice);

            spellEffectPanels = new Panel[3];

            spellEffectPanels[0]               = new Panel();
            spellEffectPanels[0].Position      = new Vector2(138, 40);
            spellEffectPanels[0].Size          = new Vector2(118, 28);
            spellEffectPanels[0].Name          = "effect_top";
            spellEffectPanels[0].OnMouseClick += SpellEffectPanelClick;
            mainPanel.Components.Add(spellEffectPanels[0]);

            spellEffectPanels[1]               = new Panel();
            spellEffectPanels[1].Position      = new Vector2(138, 78);
            spellEffectPanels[1].Size          = new Vector2(118, 28);
            spellEffectPanels[1].Name          = "effect_middle";
            spellEffectPanels[1].OnMouseClick += SpellEffectPanelClick;
            mainPanel.Components.Add(spellEffectPanels[1]);

            spellEffectPanels[2]               = new Panel();
            spellEffectPanels[2].Position      = new Vector2(138, 116);
            spellEffectPanels[2].Size          = new Vector2(118, 28);
            spellEffectPanels[2].Name          = "effect_bottom";
            spellEffectPanels[2].OnMouseClick += SpellEffectPanelClick;
            mainPanel.Components.Add(spellEffectPanels[2]);

            //configure effect labels
            spellEffectLabels = new TextLabel[spellEffectPanels.Length * 2];

            for (int i = 0; i < spellEffectLabels.Length; i++)
            {
                spellEffectLabels[i] = new TextLabel();
                spellEffectLabels[i].MaxCharacters       = 24;
                spellEffectLabels[i].Text                = string.Format("index: {0} panel: {1}", i, i / 2);
                spellEffectLabels[i].Name                = "effect_label_" + i;
                spellEffectLabels[i].HorizontalAlignment = HorizontalAlignment.Center;

                if (i % 2 == 0)
                {
                    spellEffectLabels[i].Position = new Vector2(spellEffectLabels[i].Position.x, spellEffectPanels[i / 2].Size.y * .125f);
                }
                else
                {
                    spellEffectLabels[i].Position = new Vector2(spellEffectLabels[i].Position.x, spellEffectPanels[i / 2].Size.y * .5f);
                }
                spellEffectPanels[i / 2].Components.Add(spellEffectLabels[i]);
            }

            Refresh = true;

            //##below just fills in examples for testing until spells are implemented

            spellIcon.BackgroundTexture        = GetSpellIcon(34);
            spellRangeIcon.BackgroundTexture   = GetSpellRangeIcon(0);
            spellElementIcon.BackgroundTexture = GetElementTypeIcon(0);
            spellPrice.Text = "01234567890123456789012345678901234567890";

            for (int i = 0; i < spellEffectPanels.Length; i++)
            {
                var labels = GetEffectLabels(i);
                SetEffectLabel(labels, new string[] { labels[0].Name, labels[1].Name });
            }

            for (int i = 0; i < 50; i++)
            {
                listBox.AddItem(i + "- spell name");
            }

#if LAYOUT
            SetBackgroundColors();
#endif
        }
示例#28
0
        public override void InitWindow()
        {
            //window init
            SetParameters(nameof(MainWindow), nameof(MainWindow), 1300, 840, false);
            SetMinSize(500, 300);
            SetBackground(32, 34, 37);

            //title
            title = new TitleBar("Mimic");
            title.SetStyle(Styles.GetTitleBarStyle());

            HorizontalStack h_stack = new HorizontalStack();

            h_stack.SetMargin(0, 22, 0, 0);
            h_stack.SetSpacing(0, 0);

            //left block
            VerticalStack left = new VerticalStack();//70

            left.SetWidth(70);
            left.SetWidthPolicy(SizePolicy.Fixed);
            left.SetPadding(2, 0, 2, 2);
            left.SetSpacing(0, 10);

            SpaceVIL.Rectangle line = new SpaceVIL.Rectangle();
            line.SetBackground(32, 34, 37);
            line.SetSizePolicy(SizePolicy.Expand, SizePolicy.Fixed);
            line.SetHeight(1);
            line.SetShadow(2, 0, 2, Color.FromArgb(150, 0, 0, 0));
            line.SetMargin(8, 0, 8, 0);

            ButtonCore mimic_icon = new ButtonCore("M");

            mimic_icon.SetFont(new Font(DefaultsService.GetDefaultFont().FontFamily, 30, FontStyle.Bold));
            mimic_icon.SetSize(50, 50);
            mimic_icon.SetBackground(114, 137, 208);
            mimic_icon.SetAlignment(ItemAlignment.Top | ItemAlignment.HCenter);
            mimic_icon.SetBorderRadius(new CornerRadius(15));

            SpaceVIL.Rectangle divider = new SpaceVIL.Rectangle();
            divider.SetBackground(47, 49, 54);
            divider.SetSizePolicy(SizePolicy.Expand, SizePolicy.Fixed);
            divider.SetHeight(2);
            divider.SetMargin(15, 0, 15, 0);

            ButtonToggle notes_area_btn = new ButtonToggle("N");

            notes_area_btn.SetFont(new Font(DefaultsService.GetDefaultFont().FontFamily, 30, FontStyle.Bold));
            notes_area_btn.SetSize(50, 50);
            notes_area_btn.SetBackground(Color.Transparent);
            notes_area_btn.SetForeground(100, 101, 105);
            notes_area_btn.SetAlignment(ItemAlignment.Top | ItemAlignment.HCenter);
            notes_area_btn.SetBorderRadius(new CornerRadius(15));
            notes_area_btn.SetBorderFill(100, 101, 105);
            notes_area_btn.SetBorderThickness(1);
            notes_area_btn.EventMouseClick += (sender, args) =>
            {
                if (notes_area_btn.IsToggled())
                {
                    freeNotes.SetVisible(true);
                    conversation.SetVisible(false);
                    freeNotes.GetParent().Update(GeometryEventType.ResizeHeight);
                }
                else
                {
                    freeNotes.SetVisible(false);
                    conversation.SetVisible(true);
                    freeNotes.GetParent().Update(GeometryEventType.ResizeHeight);
                }
            };

            ButtonCore add_btn = new ButtonCore();

            add_btn.SetSize(50, 50);
            add_btn.SetBackground(Color.Transparent);
            add_btn.SetAlignment(ItemAlignment.Top | ItemAlignment.HCenter);
            add_btn.SetBorderRadius(new CornerRadius(25));
            add_btn.SetBorderFill(100, 101, 105);
            add_btn.SetBorderThickness(1);
            add_btn.SetToolTip("Add a new friend.");
            add_btn.EventMouseClick += (sender, args) =>
            {
                AddMenuDialog dialog = new AddMenuDialog();
                dialog.OnCloseDialog += () =>
                {
                    string result = dialog.InputResult;
                    if (!result.Equals(String.Empty))
                    {
                        contacts_bar.AddItem(InfinityItemsBox.GetVisualContact(result, input_message));
                    }
                };
                dialog.Show(this);
            };

            CustomShape plus = new CustomShape();

            plus.SetBackground(100, 101, 105);
            plus.SetSize(20, 20);
            plus.SetAlignment(ItemAlignment.VCenter | ItemAlignment.HCenter);
            plus.SetTriangles(GraphicsMathService.GetCross(20, 20, 2, 0));

            //middleblock
            VerticalStack middle = new VerticalStack();//240

            middle.SetStyle(Styles.GetCommonContainerStyle());
            middle.SetWidth(240);
            middle.SetWidthPolicy(SizePolicy.Fixed);
            middle.SetBackground(47, 49, 54);
            middle.SetBorderRadius(new CornerRadius(6, 0, 6, 0));

            Frame search_bar = new Frame();

            search_bar.SetBorderRadius(new CornerRadius(6, 0, 0, 0));
            search_bar.SetBackground(47, 49, 54);
            search_bar.SetHeight(48);
            search_bar.SetPadding(15, 0, 15, 0);
            search_bar.SetHeightPolicy(SizePolicy.Fixed);
            search_bar.SetShadow(2, 0, 2, Color.FromArgb(150, 0, 0, 0));

            contacts_bar = new ListBox();
            contacts_bar.SetPadding(8, 8, 8, 8);
            contacts_bar.SetBackground(Color.Transparent);
            contacts_bar.SetHScrollBarVisible(ScrollBarVisibility.Never);
            contacts_bar.SetVScrollBarVisible(ScrollBarVisibility.Never);
            contacts_bar.SetSelectionVisible(false);

            Frame user_bar = new Frame();

            user_bar.SetBorderRadius(new CornerRadius(0, 0, 6, 0));
            user_bar.SetBackground(42, 44, 49);
            user_bar.SetHeight(48);
            user_bar.SetPadding(15, 0, 15, 0);
            user_bar.SetHeightPolicy(SizePolicy.Fixed);
            user_bar.SetAlignment(ItemAlignment.Bottom);

            TextEdit search = new TextEdit();

            search.SetPadding(10, 0, 10, 0);
            search.SetFont(DefaultsService.GetDefaultFont(12));
            search.SetForeground(150, 150, 150);
            search.SetSubstrateText("Find or start conversation");
            search.SetSubstrateFontSize(12);
            search.SetSubstrateFontStyle(FontStyle.Regular);
            search.SetSubstrateForeground(100, 100, 100);
            search.SetHeight(32);
            search.SetBackground(37, 39, 43);
            search.SetAlignment(ItemAlignment.HCenter, ItemAlignment.VCenter);
            search.SetBorderRadius(4);
            search.SetBorderThickness(1);
            search.SetBorderFill(32, 34, 37);

            //right block
            VerticalStack right = new VerticalStack();//expand

            right.SetStyle(Styles.GetCommonContainerStyle());
            right.SetSpacing(0, 2);

            HorizontalStack conversation_bar = new HorizontalStack();

            conversation_bar.SetBackground(54, 57, 63);
            conversation_bar.SetHeight(48);
            conversation_bar.SetHeightPolicy(SizePolicy.Fixed);
            conversation_bar.SetPadding(10, 0, 0, 0);
            conversation_bar.SetSpacing(5, 0);
            conversation_bar.SetShadow(2, 0, 2, Color.FromArgb(150, 0, 0, 0));

            freeNotes = new FreeArea();
            freeNotes.SetVisible(false);
            freeNotes.SetBackground(Color.FromArgb(5, 255, 255, 255));

            conversation = new ListBox();
            conversation.SetPadding(4, 4, 4, 4);
            conversation.SetBackground(Color.Transparent);
            conversation.SetHScrollBarVisible(ScrollBarVisibility.Never);
            conversation.GetArea().SetPadding(16, 10, 2, 2);
            conversation.SetSelectionVisible(false);

            VerticalScrollBar vs = conversation.VScrollBar;

            vs.SetWidth(16);
            vs.SetBorderThickness(4);
            vs.SetBorderFill(54, 57, 63);
            vs.SetBorderRadius(new CornerRadius(9));
            vs.SetArrowsVisible(false);
            vs.SetBackground(47, 49, 54);
            vs.SetPadding(0, 0, 0, 0);
            vs.Slider.Track.SetBackground(Color.Transparent);
            vs.Slider.SetBorderThickness(4);
            vs.Slider.SetBorderFill(54, 57, 63);
            vs.Slider.SetBorderRadius(new CornerRadius(9));
            vs.Slider.SetBackground(32, 34, 37, 255);
            vs.Slider.SetMargin(new Indents(0, 0, 0, 0));
            vs.Slider.RemoveAllItemStates();

            HorizontalStack input_bar = new HorizontalStack();

            input_bar.SetHeight(44);
            input_bar.SetHeightPolicy(SizePolicy.Fixed);
            input_bar.SetMargin(20, 10, 20, 30);
            input_bar.SetPadding(15, 0, 8, 0);
            input_bar.SetSpacing(10, 0);
            input_bar.SetBackground(72, 75, 81);
            input_bar.SetBorderRadius(new CornerRadius(6, 6, 6, 6));

            ButtonCore emoji = new ButtonCore("+");

            emoji.SetSize(24, 24);
            emoji.SetBackground(126, 128, 132);
            emoji.SetAlignment(ItemAlignment.VCenter | ItemAlignment.Left);
            emoji.SetBorderRadius(new CornerRadius(12));

            SpaceVIL.Rectangle divider_v = new SpaceVIL.Rectangle();
            divider_v.SetBackground(126, 128, 132);
            divider_v.SetWidth(2);
            divider_v.SetSizePolicy(SizePolicy.Fixed, SizePolicy.Expand);
            divider_v.SetMargin(0, 10, 0, 10);

            input_message = new TextEdit();
            input_message.SetBackground(Color.Transparent);
            input_message.SetForeground(Color.White);
            input_message.SetAlignment(ItemAlignment.VCenter);
            input_message.SetBorderRadius(new CornerRadius(0, 3, 0, 3));
            input_message.SetSubstrateText("Message @Jackson");
            input_message.EventKeyPress += (sender, args) =>
            {
                if (args.Key == KeyCode.Enter)
                {
                    conversation.AddItem(InfinityItemsBox.GetMessage(input_message.GetText()));
                    input_message.Clear();
                }
            };

            ButtonCore add_note = InfinityItemsBox.GetOrdinaryButton();

            add_note.SetForeground(166, 167, 168);
            add_note.SetFont(new Font(DefaultsService.GetDefaultFont().FontFamily, 12, FontStyle.Bold));
            add_note.SetText("Add new note");
            add_note.SetWidth(100);
            add_note.SetShadow(4, 0, 2, Color.FromArgb(150, 0, 0, 0));
            add_note.EventMouseClick += (sender, args) =>
            {
                NoteBlock block = InfinityItemsBox.GetNoteBlock();
                block.SetPosition(100, 100);
                freeNotes.AddItem(block);
            };

            //adding items
            AddItems(
                title,
                h_stack
                );
            h_stack.AddItems(
                left,
                middle,
                right
                );
            left.AddItems(
                line,
                mimic_icon,
                divider,
                notes_area_btn,
                add_btn
                );
            add_btn.AddItem(
                plus
                );
            middle.AddItems(
                search_bar,
                contacts_bar,
                user_bar
                );
            search_bar.AddItems(
                search
                );
            user_bar.AddItems(
                new UserBar("Daniel")
                );
            right.AddItems(
                conversation_bar,
                conversation,
                freeNotes,
                input_bar
                );
            conversation_bar.AddItems(
                add_note,
                InfinityItemsBox.GetOrdinaryButton(),
                InfinityItemsBox.GetOrdinaryButton(),
                InfinityItemsBox.GetOrdinaryButton(),
                InfinityItemsBox.GetOrdinaryButton()
                );
            input_bar.AddItems(
                emoji,
                divider_v,
                input_message
                );
            contacts_bar.AddItems(
                InfinityItemsBox.GetVisualContact("Jackson", input_message),
                InfinityItemsBox.GetVisualContact("Evelyn", input_message),
                InfinityItemsBox.GetVisualContact("Alexander", input_message),
                InfinityItemsBox.GetVisualContact("Matthew", input_message)
                );
        }
        void RefreshSpellsList(bool preservePosition)
        {
            // Preserve indices before ClearItems()
            int oldScrollIndex   = spellsListBox.ScrollIndex;
            int oldSelectedIndex = spellsListBox.SelectedIndex;

            // Clear existing list
            spellsListBox.ClearItems();

            // Add spells based on mode
            if (buyMode)
            {
                // Load spells for sale
                offeredSpells.Clear();
                List <SpellRecord.SpellRecordData> standardSpells = DaggerfallSpellReader.ReadSpellsFile(Path.Combine(DaggerfallUnity.Arena2Path, spellsFilename));
                if (standardSpells == null || standardSpells.Count == 0)
                {
                    Debug.LogError("Failed to load SPELLS.STD for spellbook in buy mode.");
                    return;
                }

                for (int i = 0; i < standardSpells.Count; i++)
                {
                    // Filter internal spells starting with exclamation point '!'
                    if (standardSpells[i].spellName.StartsWith("!"))
                    {
                        continue;
                    }

                    // NOTE: Classic allows purchase of duplicate spells
                    // If ever changing this, must ensure spell is an *exact* duplicate (i.e. not a custom spell with same name)
                    // Just allowing duplicates for now as per classic and let user manage preference

                    // Get effect bundle settings from classic spell
                    EffectBundleSettings bundle;
                    if (!GameManager.Instance.EntityEffectBroker.ClassicSpellRecordDataToEffectBundleSettings(standardSpells[i], BundleTypes.Spell, out bundle))
                    {
                        continue;
                    }

                    // Store offered spell and add to list box
                    offeredSpells.Add(bundle);
                    spellsListBox.AddItem(standardSpells[i].spellName);
                }
            }
            else
            {
                // Add player spells to list
                EffectBundleSettings[] spellbook = GameManager.Instance.PlayerEntity.GetSpells();
                if (spellbook != null)
                {
                    for (int i = 0; i < spellbook.Length; i++)
                    {
                        // Show spell name and cost
                        // Costs can change based on player skills and stats so must be calculated each time
                        int goldCost, spellPointCost;
                        FormulaHelper.CalculateTotalEffectCosts(spellbook[i].Effects, spellbook[i].TargetType, out goldCost, out spellPointCost, null, spellbook[i].MinimumCastingCost);
                        spellsListBox.AddItem(string.Format("{0} - {1}", spellPointCost, spellbook[i].Name));
                    }
                }
            }

            if (preservePosition)
            {
                spellsListBox.ScrollIndex = oldScrollIndex;
                if (oldSelectedIndex >= spellsListBox.Count)
                {
                    if (spellsListBox.Count > 0)
                    {
                        spellsListBox.SelectedIndex = spellsListBox.Count - 1;
                    }
                    else
                    {
                        spellsListBox.SelectNone();
                    }
                }
                else
                {
                    spellsListBox.SelectedIndex = oldSelectedIndex;
                }
            }
        }
示例#30
0
    public void Drawline(List <float> points, string LineColorHexCode)
    {
        //format long1, long2, lat1, lat2

        GameObject line = Instantiate(lineprefab, lineParent);

        line.name = "line" + count.ToString();


        float[] p1 = DrawManager.GetComponent <DrawControl>().LatLongToXY(points[4], points[2]);
        float[] p2 = DrawManager.GetComponent <DrawControl>().LatLongToXY(points[5], points[3]);

        #region ColorConverts


        //Reading Color in HEX Format From Excercise Area XML File*************

        //float r, g, b;
        //string rs, gs, bs;

        //rs = LineColorHexCode.Substring(0, 2);
        //gs = LineColorHexCode.Substring(2, 2);
        //bs = LineColorHexCode.Substring(4, 2);

        //UnityEngine.Debug.Log("LINE : Before conversion values of RS = {0} , GS = {1} && Bs = {2}" + rs + gs + bs);
        ////r = Convert.ToInt32(rs, 16);
        ////b = Convert.ToInt32(gs, 16);
        ////g = Convert.ToInt32(bs, 16);

        //r = int.Parse(rs, System.Globalization.NumberStyles.HexNumber);
        //g = int.Parse(gs, System.Globalization.NumberStyles.HexNumber);
        //b = int.Parse(bs, System.Globalization.NumberStyles.HexNumber);
        //UnityEngine.Debug.Log("LINE : After conversion values of R = {0} , G = {1} && B = {2}" + r + g + b);

        //Reading Color in HEX Format From Excercise Area XML File*************

        //Reading Color in RGBA Format From Excercise Area XML File*************

        //string als, rs, gs, bs;
        //rs = LineColorHexCode.Split(';')[0];
        //gs = LineColorHexCode.Split(';')[1];
        //bs = LineColorHexCode.Split(';')[2];
        //als = LineColorHexCode.Split(';')[3];

        //Color clr = new Color();
        //clr.r = float.Parse(rs);
        //clr.g = float.Parse(gs);
        //clr.b = float.Parse(bs);
        //clr.a = float.Parse(als);

        //Reading Color in RGBA Format From Excercise Area XML File**************

        #endregion
        LineRenderer lnRend         = line.GetComponent <LineRenderer>();
        string       intToHexColour = ColorIntToHex(Convert.ToInt32(LineColorHexCode));
        lnRend.material.color = HexToColor(intToHexColour);

        currentline = line;
        count++;
        lineListBox.AddItem(new ListBox.ListItem(line.name));

        currentline.GetComponent <LineSpecs>().SetLineStart(new Vector3(p1[0], p1[1], -1));
        currentline.GetComponent <LineSpecs>().SetLineEnd(new Vector3(p2[0], p2[1], -1));

        currentline.GetComponent <LineSpecs>().SetStart(new Vector2(points[4], points[2]));
        currentline.GetComponent <LineSpecs>().SetEnd(new Vector2(points[5], points[3]));
    }
示例#31
0
    public void DrawBull(List <float> points, string BullEyeColorHexCode)
    {
        GameObject point = Instantiate(PointPrefab, BullEyeParent);

        float[] p1 = DrawManager.GetComponent <DrawControl>().LatLongToXY(points[0], points[1]);
        point.transform.position = new Vector3(p1[0], p1[1], -1);
        point.name = "BullEye" + countB.ToString();

        SpriteRenderer spriteRend = point.GetComponent <SpriteRenderer>();

        #region Color Converters


        //Reading Color in HEX Format From Excercise Area XML File*************

        //float r, g, b;
        //string rs, gs, bs;

        //rs = BullEyeColorHexCode.Substring(0, 2);
        //gs = BullEyeColorHexCode.Substring(2, 2);
        //bs = BullEyeColorHexCode.Substring(4, 2);

        //UnityEngine.Debug.Log("BullEye : Before conversion values of RS = {0} , GS = {1} && Bs = {2}" + rs + gs + bs);

        ////r = Convert.ToInt32(rs, 16);
        ////b = Convert.ToInt32(gs, 16);
        ////g = Convert.ToInt32(bs, 16);

        //r = int.Parse(rs, System.Globalization.NumberStyles.HexNumber);
        //g = int.Parse(gs, System.Globalization.NumberStyles.HexNumber);
        //b = int.Parse(bs, System.Globalization.NumberStyles.HexNumber);

        //UnityEngine.Debug.Log("BullEye : After conversion values of R = {0} , G = {1} && B = {2}" + r + g + b);

        //Reading Color in HEX Format From Excercise Area XML File*************

        //Reading Color in RGBA Format From Excercise Area XML File***********

        //string als, rs, gs, bs;

        //rs = BullEyeColorHexCode.Split(';')[0];
        //gs = BullEyeColorHexCode.Split(';')[1];
        //bs = BullEyeColorHexCode.Split(';')[2];
        //als = BullEyeColorHexCode.Split(';')[3];

        //Color clr = new Color();
        //clr.r = float.Parse(rs);
        //clr.g = float.Parse(gs);
        //clr.b = float.Parse(bs);
        //clr.a = float.Parse(als);

        //Reading Color in RGBA Format From Excercise Area XML File************

        #endregion

        string intToHexColour = ColorIntToHex(Convert.ToInt32(BullEyeColorHexCode));
        spriteRend.material.color = HexToColor(intToHexColour);


        BullListBox.AddItem(new ListBox.ListItem(point.name));

        currentpoint = point;
        countB++;
        currentpoint.GetComponent <BullSpecs>().SetPointLatLong(new Vector2(points[0], points[1]));
    }
示例#32
0
        public static void Initialize()
        {
            #region menu setup
            menuLabel = new Text(P._Canvas);
            menuLabel.SetPos(128, 28);
            menuLabel.Font = P.GuiFontLarge;
            menuLabel.String = "Books";

            menu = new ListBox(P._Canvas);
            foreach (Book b in activeBooks)
            {
                activeBookItems.Add(menu.AddItem(b.title));
            }
            menu.EnableScroll(true, true);
            menu.SetSize(160, 2*P.ScreenSize.Y/3 - 36);
            menu.SetPos(128,48);

            menu.MouseInputEnabled = true;
            for (int i = 0; i < activeBookItems.Count; i++)
            {
                activeBookItems[i].OnRowSelected += new Base.ControlCallback(Book_OnRowSelected);
                activeBookItems[i].SetTextColor(System.Drawing.Color.Gray);
            }
            #endregion

            bookTitle = new Text(P._Canvas);
            bookTitle.String = "";
            bookTitle.SetPos(300, 40);
            bookTitle.Font = P.GuiFontLarge;

            authorText = new Text(P._Canvas);
            authorText.String = "";
            authorText.SetPos(300, 64);

            statusText = new Text(P._Canvas);
            statusText.SetPos(300, 80);
            statusText.String = "";

            publishingProgress = new ProgressBar(P._Canvas);
            publishingProgress.Value = 0;
            publishingProgress.SetBounds(300, P.ScreenSize.Y/3-16, 200, 16);
            publishingProgress.Hide();

            GameManager.BookPageItems.Add(menuLabel);
            GameManager.BookPageItems.Add(menu);
            GameManager.BookPageItems.Add(bookTitle);
            GameManager.BookPageItems.Add(authorText);
            GameManager.BookPageItems.Add(publishingProgress);
            GameManager.BookPageItems.Add(statusText);
        }
        protected override void Load(EntityGUI.GUIFactory factory)
        {
            var font = this.Resourses.LoadAsset<Font>("Fonts\\Metro.fnt");
            var bigfont = this.Resourses.LoadAsset<Font>("Fonts\\BigMetro.fnt");
            this.Panel.BackgroundColor = Color.Black;

            //Creates a textbox with maxlength 20
            TextBox textBox0 = new TextBox(font, "", 20);
            textBox0.Position = new OpenTK.Vector2(50, 50);

            //It should be noted that a textbox height is always font.size + padding.y + padding.h since it would
            //i did it this way since a textbox of any other height would look bad.
            textBox0.Size = new OpenTK.Vector2(200, 20);

            //A hint is displayed if the textbox is empty.
            textBox0.Hint = "20 char text field!";

            this.Panel.AddControl(textBox0);

            //Creates a textbox with unlimited length.
            TextBox textBox1 = new TextBox(font, "");
            textBox1.BackgroundColor = Color.White;
            textBox1.TextColor = Color.Red;
            textBox1.Position = new OpenTK.Vector2(50, textBox0.Bounds.Bottom + 10);
            textBox1.Size = new OpenTK.Vector2(200, 20);
            textBox1.Hint = "Unlimited textbox.";

            this.Panel.AddControl(textBox1);

            //Creates a textbox with custom colors.
            TextBox textBox2 = new TextBox(font, "");
            textBox2.BackgroundColor = Color.Green;
            textBox2.TextColor = Color.Gold;
            textBox2.SelectedColor = Color.Red;
            textBox2.HintColor = Color.RosyBrown;
            textBox2.Position = new OpenTK.Vector2(50, textBox1.Bounds.Bottom + 10);
            textBox2.Size = new OpenTK.Vector2(200, 20);
            textBox2.Hint = "Unlimited textbox 2.";

            this.Panel.AddControl(textBox2);

            TextBox textBox3 = new TextBox(bigfont, "", 20);
            textBox3.Position = new OpenTK.Vector2(50, textBox2.Bounds.Bottom + 10);
            textBox3.Size = new OpenTK.Vector2(300, 20);
            textBox3.Hint = "Unlimited textbox 2.";

            this.Panel.AddControl(textBox3);

            //Create a numberbox startvalue 100 min 0 max 255
            NumberBox numberBox0 = new NumberBox(font, 100, byte.MinValue, byte.MaxValue);
            numberBox0.Position = new OpenTK.Vector2(50, textBox3.Bounds.Bottom + 10);
            numberBox0.Size = new OpenTK.Vector2(200, 20);

            this.Panel.AddControl(numberBox0);

            TextArea area = new TextArea(font);
            area.Position = new OpenTK.Vector2(textBox3.Bounds.Right + 20, 50);
            area.Size = new OpenTK.Vector2(400, 300);
            area.Text = "This is a text area! This is not fully implemented! Yes true it is.";
            this.Panel.AddControl(area);

            ListBox<int> numbers = new ListBox<int>(font);
            numbers.Position = new OpenTK.Vector2(area.Bounds.Right + 20, 50);
            numbers.Size = new OpenTK.Vector2(400, 300);

            for (int i = 0; i < 20; i++)
            {
                numbers.AddItem(i);
            }

            this.Panel.AddControl(numbers);
        }
示例#34
0
        void ShowResolutionPanel()
        {
            // Disable previous stage
            browserPanel.Enabled = false;

            // Get resolutions
            initialResolution    = Screen.currentResolution;
            availableResolutions = Screen.resolutions;

            // Create backdrop
            if (!backdropCreated)
            {
                CreateBackdrop();
            }

            // Add resolution panel
            resolutionPanel.Outline.Enabled     = true;
            resolutionPanel.BackgroundColor     = backgroundColor;
            resolutionPanel.HorizontalAlignment = HorizontalAlignment.Left;
            resolutionPanel.VerticalAlignment   = VerticalAlignment.Middle;
            resolutionPanel.Size = new Vector2(120, 175);
            NativePanel.Components.Add(resolutionPanel);

            // Add resolution title text
            TextLabel resolutionTitleLabel = new TextLabel();

            resolutionTitleLabel.Text     = GetText("resolution");
            resolutionTitleLabel.Position = new Vector2(0, 2);
            //resolutionTitleLabel.ShadowPosition = Vector2.zero;
            resolutionTitleLabel.HorizontalAlignment = HorizontalAlignment.Center;
            resolutionPanel.Components.Add(resolutionTitleLabel);

            // Add resolution picker
            resolutionList.BackgroundColor     = new Color(0.1f, 0.1f, 0.1f, 0.5f);
            resolutionList.TextColor           = unselectedTextColor;
            resolutionList.SelectedTextColor   = selectedTextColor;
            resolutionList.ShadowPosition      = Vector2.zero;
            resolutionList.HorizontalAlignment = HorizontalAlignment.Center;
            resolutionList.RowsDisplayed       = 8;
            resolutionList.RowAlignment        = HorizontalAlignment.Center;
            resolutionList.Position            = new Vector2(0, 12);
            resolutionList.Size = new Vector2(80, 62);
            resolutionList.SelectedShadowPosition = DaggerfallUI.DaggerfallDefaultShadowPos;
            resolutionList.SelectedShadowColor    = Color.black;
            resolutionList.OnMouseClick          += ResolutionList_OnMouseClick;
            resolutionList.OnScroll += ResolutionList_OnScroll;
            resolutionPanel.Components.Add(resolutionList);

            // Add resolution scrollbar
            resolutionScroller.Position  = new Vector2(100, 12);
            resolutionScroller.Size      = new Vector2(5, 62);
            resolutionScroller.OnScroll += ResolutionScroller_OnScroll;
            resolutionPanel.Components.Add(resolutionScroller);

            // Add resolutions
            for (int i = 0; i < availableResolutions.Length; i++)
            {
                string item = string.Format("{0}x{1}", availableResolutions[i].width, availableResolutions[i].height);
                resolutionList.AddItem(item);

                if (availableResolutions[i].width == initialResolution.width &&
                    availableResolutions[i].height == initialResolution.height)
                {
                    resolutionList.SelectedIndex = i;
                }
            }
            resolutionList.ScrollToSelected();

            // Setup scroller
            resolutionScroller.DisplayUnits    = 8;
            resolutionScroller.TotalUnits      = resolutionList.Count;
            resolutionScroller.BackgroundColor = resolutionList.BackgroundColor;

            // Add fullscreen checkbox
            fullscreenCheckbox.Label.Text           = GetText("fullscreen");
            fullscreenCheckbox.Label.ShadowPosition = DaggerfallUI.DaggerfallDefaultShadowPos;
            fullscreenCheckbox.Label.ShadowColor    = Color.black;
            fullscreenCheckbox.Position             = new Vector2(0, 76);
            fullscreenCheckbox.HorizontalAlignment  = HorizontalAlignment.Center;
            fullscreenCheckbox.IsChecked            = Screen.fullScreen;
            fullscreenCheckbox.CheckBoxColor        = selectedTextColor;
            fullscreenCheckbox.Label.TextColor      = selectedTextColor;
            fullscreenCheckbox.OnToggleState       += FullscreenCheckbox_OnToggleState;
            resolutionPanel.Components.Add(fullscreenCheckbox);

            // Add quality title text
            TextLabel qualityTitleLabel = new TextLabel();

            qualityTitleLabel.Text     = GetText("quality");
            qualityTitleLabel.Position = new Vector2(0, 92);
            //qualityTitleLabel.ShadowPosition = Vector2.zero;
            qualityTitleLabel.HorizontalAlignment = HorizontalAlignment.Center;
            resolutionPanel.Components.Add(qualityTitleLabel);

            // Add quality picker
            qualityList.BackgroundColor     = new Color(0.1f, 0.1f, 0.1f, 0.5f);
            qualityList.TextColor           = unselectedTextColor;
            qualityList.SelectedTextColor   = selectedTextColor;
            qualityList.ShadowPosition      = Vector2.zero;
            qualityList.HorizontalAlignment = HorizontalAlignment.Center;
            qualityList.RowsDisplayed       = 6;
            qualityList.RowAlignment        = HorizontalAlignment.Center;
            qualityList.Position            = new Vector2(0, 102);
            qualityList.Size = new Vector2(85, 46);
            qualityList.SelectedShadowPosition = DaggerfallUI.DaggerfallDefaultShadowPos;
            qualityList.SelectedShadowColor    = Color.black;
            qualityList.OnMouseClick          += QualityList_OnMouseClick;
            resolutionPanel.Components.Add(qualityList);
            foreach (var name in QualitySettings.names)
            {
                qualityList.AddItem(name);
            }
            qualityList.SelectedIndex = DaggerfallUnity.Settings.QualityLevel;

            // Test/confirm button
            testText = GetText("testText");
            okText   = GetText("okText");
            testOrConfirmButton.Position            = new Vector2(0, 160);
            testOrConfirmButton.Size                = new Vector2(40, 12);
            testOrConfirmButton.Outline.Enabled     = true;
            testOrConfirmButton.Label.Text          = testText;
            testOrConfirmButton.BackgroundColor     = new Color(0.0f, 0.5f, 0.0f, 0.4f);
            testOrConfirmButton.HorizontalAlignment = HorizontalAlignment.Center;
            testOrConfirmButton.OnMouseClick       += ResolutionTestOrConfirmButton_OnMouseClick;
            resolutionPanel.Components.Add(testOrConfirmButton);
        }
        protected void InitLayerSettingsWindow()
        {
            LayerSettingsWindow = new Window(UI.GetInterface(Name), null, "Settings", TextOrientation.Center, Vector2.Zero, new Vector2(712, 500), true, false, false, false);

            LayerSettingsWindow.AddElement(new Label(UI.GetInterface(Name), "Layer Name", 14, TextOrientation.Left, new Vector2(10, 10), new Vector2(200, 25), Color.Black, Color.Transparent));
            LayerSettingsWindow.AddElement(new TextBox(UI.GetInterface(Name), layerName, 14, 20, new Vector2(10, 40), new Vector2(200, 25), Color.Black, Color.White, origin, Color.Black));

            LayerSettingsWindow.AddElement(new Label(UI.GetInterface(Name), "Available Traits", 14, TextOrientation.Left, new Vector2(10, 80), new Vector2(200, 50), Color.Black, Color.Transparent));
            LayerSettingsWindow.AddElement(new Label(UI.GetInterface(Name), "Contained Traits", 14, TextOrientation.Left, new Vector2(400, 80), new Vector2(200, 50), Color.Black, Color.Transparent));
            LayerSettingsWindow.AddElement(new Button(UI.GetInterface(Name), ">", 24, TextOrientation.Center, new Vector2(330, 230), new Vector2(50, 50), origin, hover, pressed));
            LayerSettingsWindow.AddElement(new Button(UI.GetInterface(Name), "<", 24, TextOrientation.Center, new Vector2(330, 290), new Vector2(50, 50), origin, hover, pressed));

            ListBox a = new ListBox(UI.GetInterface(Name), 14, TextOrientation.Left, new Vector2(10, 110), new Vector2(300, 350), Color.Black, Color.White, origin, hover);
            ListBox b = new ListBox(UI.GetInterface(Name), 14, TextOrientation.Left, new Vector2(400, 110), new Vector2(300, 350), Color.Black, Color.White, origin, hover);
            LayerSettingsWindow.AddElement(a);
            LayerSettingsWindow.AddElement(b);

            availableTraits.Add("Affects Movement Speed");
            availableTraits.Add("Cast Shadow");
            availableTraits.Add("Collision");
            availableTraits.Add("Function Layer");
            availableTraits.Add("Transparent");
            availableTraits.Add("Stainable");
            availableTraits.Add("Projectile Collision");
            availableTraits.Add("NPC Collision");
            availableTraits.Add("Item Collision");

            a.AddItem(availableTraits[0]);
            a.AddItem(availableTraits[1]);
            a.AddItem(availableTraits[2]);
            a.AddItem(availableTraits[3]);
            a.AddItem(availableTraits[4]);
            a.AddItem(availableTraits[5]);
            a.AddItem(availableTraits[6]);
            a.AddItem(availableTraits[7]);
            a.AddItem(availableTraits[8]);

            (LayerSettingsWindow[1] as TextBox).TextChanged += (sender) =>
            {
                TextBox tb = sender as TextBox;
                if (tb.Text != "")
                    layerName = tb.Text;
            };

            LayerSettingsWindow[4].Clicked += (sender) =>
            {
                if (a.SelectedItems.Count > 0)
                {
                    for (int i = 0; i < a.SelectedItems.Count; i++)
                    {
                        b.AddItem(a.SelectedItems[i]);
                    }
                    a.RemoveSelectedItems();
                }
            };

            LayerSettingsWindow[5].Clicked += (sender) =>
            {
                if (b.SelectedItems.Count > 0)
                {
                    for (int i = 0; i < b.SelectedItems.Count; i++)
                    {
                        a.AddItem(b.SelectedItems[i]);
                    }
                    b.RemoveSelectedItems();
                }
            };

            LayerSettingsWindow.Open(new Vector2(Game1.ScreenWidth / 2.0f - LayerSettingsWindow.Size.X / 2.0f, Game1.ScreenHeight / 2.0f - LayerSettingsWindow.Size.Y / 2.0f));
        }