Esempio n. 1
0
 public MenuParent(Rect rect, MenuAnchor anchor, string titleName)
 {
     m_MenuName      = titleName;
     m_MaximizedArea = rect;
     m_MenuAnchor    = anchor;
     m_CurShowArea   = rect;
 }
Esempio n. 2
0
 public MenuParent(float x, float y, float width, float height, MenuAnchor anchor, string titleName)
 {
     m_MenuName      = titleName;
     m_MaximizedArea = new Rect(x, y, width, height);
     m_MenuAnchor    = anchor;
     m_CurShowArea   = m_MaximizedArea;
 }
Esempio n. 3
0
        public void RenderEnabledIcon(Sprite sprite, DrawArgs drawArgs, float centerX, float topY,
                                      bool selected, MenuAnchor anchor)
        {
            float width = selected ? SelectedSize : width = NormalSize;

            this.RenderLabel(drawArgs, (int)centerX, (int)topY, (int)width, selected, anchor);

            int color = selected ? white : transparent;

            float centerY = topY + this.curSize * 0.5f;

            this.RenderIcon(sprite, (int)centerX, (int)centerY, (int)this.curSize, (int)this.curSize, color, this.m_iconTexture);

            if (this.curSize == 0)
            {
                this.curSize = width;
            }
            if (width > this.curSize)
            {
                this.curSize = (int)(this.curSize * zoomSpeed);
                if (width < this.curSize)
                {
                    this.curSize = width;
                }
            }
            else if (width < this.curSize)
            {
                this.curSize = (int)(this.curSize / zoomSpeed);
                if (width > this.curSize)
                {
                    this.curSize = width;
                }
            }
        }
        private ViewModelMap <MenuItemVM, MenuItem> CreateViewModelMap(MenuAnchor anchor, Expression <Func <bool> > hasItemsProperty)
        {
            var map = new ViewModelMap <MenuItemVM, MenuItem>(MenuManager.Instance.GetMenuItems(anchor), vm => this.CreateMenuItem(vm, hasItemsProperty));

            map.CollectionChanged += (o, e) => this.RaisePropertyChanged(hasItemsProperty);

            return(map);
        }
Esempio n. 5
0
 public MenuParent(float x, float y, float width, float height, string name, MenuAnchor anchor = MenuAnchor.NONE, MenuAutoSize autoSize = MenuAutoSize.NONE)
 {
     m_anchor          = anchor;
     m_autoSize        = autoSize;
     m_maximizedArea   = new Rect(x, y, width, height);
     m_content         = new GUIContent(GUIContent.none);
     m_content.text    = name;
     m_transformedArea = new Rect();
 }
Esempio n. 6
0
        internal UpdatePage()
            : base()
        {
            MenuAnchor
                aLeft = new MenuAnchor()
                {
                    anchor = new Vector2(0f, 0f),
                    offset = new Vector2(150f),
                    offset_button = new Vector2(0f, 50f)
                },
                aRight = new MenuAnchor()
                {
                    anchor = new Vector2(0.5f, 0f),
                    offset = new Vector2(-200f, 40f),
                    offset_button = new Vector2(0f, 50f)
                };

            anchors.AddRange(new List<MenuAnchor>() { aLeft, aRight });

            // ---

            buttons.Add(new MenuButton(0, "UPDATE", "", "This will close tAPI", () =>
            {
                Process.Start("https://dl.dropboxusercontent.com/u/151130168/MCT/MCT%20Installer.exe");
                API.main.Exit();
            }).SetScale(3f).Where(mb => mb.SetAutomaticPosition(aLeft, 0)));

            buttons.Add(new MenuButton(0, "Don't update", "Main Menu").Where(mb => mb.SetAutomaticPosition(aLeft, 1)));

            // ---

            string text = "";

            XmlNode
                version = UpdateChecker.GetXml().ChildNodes[1],
                current = version.ChildNodes[0];

            text += "Current: " + MctConstants.VERSION_STRING + "\n";
            text += "New: " + current.Attributes["String"].Value + "\n";

            foreach (XmlNode xn in version.ChildNodes[1])
            {
                if (xn.NodeType != XmlNodeType.Element || new Version(xn.Attributes["Version"].Value) < MctConstants.VERSION)
                    continue;

                text += "v" + xn.Attributes["Version"].Value + "\n";

                foreach (XmlNode Xn in xn.ChildNodes)
                    text += "  -" + Xn.InnerText + "\n";
            }

            buttons.Add(new MenuButton(0, text, "", "Changelog", () => { }).Where(mb =>
            {
                mb.SetAutomaticPosition(aRight, 0);
                mb.canMouseOver = false;
            }).SetSize(Main.fontMouseText.MeasureString(text)));
        }
Esempio n. 7
0
        public void Remove(MenuItemVM menuItem, MenuAnchor anchor)
        {
            var menuItems = _menuItems[anchor];

            if (!menuItems.Remove(menuItem))
            {
                this.LogError("failed to remove menu item '{0}' at '{1}'", menuItem.Name, anchor);
            }

            _menuItemPriorities[anchor].Remove(menuItem);
        }
Esempio n. 8
0
 public MenuParent(float x, float y, float width, float height, string name, MenuAnchor anchor = MenuAnchor.NONE, MenuAutoSize autoSize = MenuAutoSize.NONE)
 {
     m_anchor           = anchor;
     m_autoSize         = autoSize;
     m_maximizedArea    = new Rect(x, y, width, height);
     m_content          = new GUIContent(GUIContent.none);
     m_content.text     = name;
     m_transformedArea  = new Rect();
     m_resizeArea       = new Rect();
     m_resizeArea.width = ResizeAreaWidth;
     m_resizeAreaStyle  = GUIStyle.none;
     m_currentScrollPos = Vector2.zero;
 }
        } //Action 节点

        #endregion

        public NodeParametersWindow(float x, float y, float width, float height, MenuAnchor anchor, string titleName) :
            base(x, y, width, height, anchor, titleName)
        {
            var tools = System.Enum.GetValues(typeof(ToolBarEnum));

            m_Tools = new List <string>();
            foreach (var tool in tools)
            {
                ToolBarEnum item = (ToolBarEnum)System.Enum.Parse(typeof(ToolBarEnum), tool.ToString());
                m_Tools.Add(item.ToString());
            }
            SelectedToolIndex = 0; //默认选中第0个工具栏
        }
Esempio n. 10
0
 public Menu(string title, string subTitle = "", int x = 0, int y = 0, MenuAnchor anchor = MenuAnchor.MiddleRight, string identifier = "")
 {
     Title              = title;
     SubTitle           = subTitle;
     X                  = x;
     Y                  = y;
     Anchor             = (int)anchor;
     Items              = new List <MenuItem>();
     Identifier         = identifier;
     OnIndexChangeEvent = false;
     OnMenuCloseEvent   = false;
     ExtraInt           = 0;
 }
Esempio n. 11
0
		public MenuParent( AmplifyShaderEditorWindow parentWindow, float x, float y, float width, float height, string name, MenuAnchor anchor = MenuAnchor.NONE, MenuAutoSize autoSize = MenuAutoSize.NONE )
		{
			m_parentWindow = parentWindow:
			m_anchor = anchor:
			m_autoSize = autoSize:
			m_maximizedArea = new Rect( x, y, width, height ):
			m_content = new GUIContent( GUIContent.none ):
			m_content.text = name:
			m_transformedArea = new Rect():
			m_resizeArea = new Rect():
			m_resizeArea.width = ResizeAreaWidth:
			m_resizeAreaStyle = GUIStyle.none:
			m_currentScrollPos = Vector2.zero:
		}
Esempio n. 12
0
        public Menu(string id, string title, string subTitle, int posX, int posY, MenuAnchor anchor, bool noExit = false, bool enableBanner = true, bool backCloseMenu = false)
        {
            _selectedIndex = -1;
            _selectedItem  = null;

            if (id == null && id.Trim().Length == 0)
            {
                Id = null;
            }
            else
            {
                Id = id;
            }

            BannerSprite  = null;
            BannerColor   = null;
            BannerTexture = null;

            if (title != null && title.Trim().Length == 0)
            {
                Title = null;
            }
            else
            {
                Title = title;
            }

            if (subTitle != null && subTitle.Trim().Length > 0)
            {
                SubTitle = subTitle;
            }

            PosX             = posX;
            PosY             = posY;
            Anchor           = anchor;
            NoExit           = noExit;
            EnableBanner     = enableBanner;
            BackCloseMenu    = backCloseMenu;
            _data            = new Dictionary <string, object>();
            _items           = new List <MenuItem>();
            OnCheckboxChange = null;
            OnIndexChange    = null;
            OnItemSelect     = null;
            OnListChange     = null;
            OnMenuClose      = null;
            OnMenuOpen       = null;
            Callback         = null;
            Finalizer        = null;
        }
Esempio n. 13
0
        private static void Enable()
        {
            MenuAnchor anchor = menuPlacement.GetCurrentMenuAnchor();

            if (!anchor)
            {
                Debug.LogError("Error: could not enable color picker. Could not find current menu anchor from the MenuPlacement script.");

                return;
            }

            if (anchor.kind == MenuAnchor.Kind.SCREEN)
            {
                _isInVR = false;

                return;
            }

            _isInVR = true;
        }
Esempio n. 14
0
        public void Register(MenuItemVM menuItem, MenuAnchor anchor, int priority = 0)
        {
            var prioritiyLookup = _menuItemPriorities[anchor];
            var menuItems       = _menuItems[anchor];

            var inserted = false;

            for (var i = 0; i < menuItems.Count; ++i)
            {
                if (prioritiyLookup[menuItems[i]] > priority)
                {
                    menuItems.Insert(i, menuItem);
                    inserted = true;
                    break;
                }
            }

            if (!inserted)
            {
                menuItems.Add(menuItem);
            }

            prioritiyLookup[menuItem] = priority;
        }
Esempio n. 15
0
 public PaletteParent(AmplifyShaderEditorWindow parentWindow, float x, float y, float width, float height, string name, MenuAnchor anchor = MenuAnchor.NONE, MenuAutoSize autoSize = MenuAutoSize.NONE) : base(parentWindow, x, y, width, height, name, anchor, autoSize)
 {
     m_searchFilter      = string.Empty;
     m_currentCategories = new Dictionary <string, PaletteFilterData>();
     //m_allItems = items;
     m_currentItems = new List <ContextMenuItem>();
 }
Esempio n. 16
0
 public UIMenu SetAnchor(MenuAnchor anchor)
 {
     this.anchor = anchor;
     return(this);
 }
Esempio n. 17
0
        protected static HashSet <NodeParent.LinConnectInfor> m_AllConnectedLinePoints = new HashSet <NodeParent.LinConnectInfor>();  //所有的连线

        #region 构造函数
        public BehaviorTreeEditorMenu(float x, float y, float width, float height, MenuAnchor anchor, string titleName) :
            base(x, y, width, height, anchor, titleName)
        {
        }
Esempio n. 18
0
        public override void OnAllModsLoaded()
        {
            base.OnAllModsLoaded();

            try
            {
                if (ModDebugger.ShouldDebug)
                    ModDebugger.DebugMods();

                if (Main.dedServ)
                    return;

                // insert settings menu button in the Options menu
                Menu.menuPages.Add("MCT:Settings", new SettingsPage());

                MenuAnchor aOptions = new MenuAnchor()
                {
                    anchor = new Vector2(0.5f, 0f),
                    offset = new Vector2(315f, 200f),
                    offset_button = new Vector2(0f, 50f)
                };

                Menu.menuPages["Options"].anchors.Add(aOptions);
                Menu.menuPages["Options"].buttons.Add(new MenuButton(0, "MCT Settings", "MCT:Settings").Where(mb => mb.SetAutomaticPosition(aOptions, 0)));

#if !USE_APIMODBASE
                Menu.menuPages["Mods Menu"].OnEntry += () =>
                {
                    Mods.mods    .Insert(0, mod);
                    Mods.modsCopy.Insert(0, mod);
                };
#endif

                if (UpdateChecker.GetIsUpdateAvailable())
                    UpdateBoxInjector.Inject();
            }
            catch (Exception e)
            {
                MessageBox.Show("An unexpected exception occured in the MCT internally, please show this to PoroCYon:" + Environment.NewLine + e, "MCT internal error");
            }
        }
Esempio n. 19
0
 public PaletteParent(List <ContextMenuItem> items, float x, float y, float width, float height, string name, MenuAnchor anchor = MenuAnchor.NONE, MenuAutoSize autoSize = MenuAutoSize.NONE) : base(x, y, width, height, name, anchor, autoSize)
 {
     m_searchFilter      = string.Empty;
     m_currentCategories = new Dictionary <string, PaletteFilterData>();
     m_allItems          = new List <ContextMenuItem>();
     m_currentItems      = new List <ContextMenuItem>();
     for (int i = 0; i < items.Count; i++)
     {
         m_allItems.Add(items[i]);
     }
 }
Esempio n. 20
0
        /// <summary>
        /// Initializes the Page
        /// </summary>
        protected override void Init()
        {
            base.Init();

            MenuAnchor
                aLeft = new MenuAnchor()
                {
                    anchor = new Vector2(0.5f, 0),
                    offset = new Vector2(-105, 200),
                    offset_button = new Vector2(0, 50)
                },
                aRight = new MenuAnchor()
                {
                    anchor = new Vector2(0.5f, 0),
                    offset = new Vector2(105, 200),
                    offset_button = new Vector2(0, 50)
                },
                aCentre = new MenuAnchor()
                {
                    anchor = new Vector2(0.5f, 0f),
                    offset = new Vector2(0f, 200f),
                    offset_button = new Vector2(0f, 50f)
                };

            anchors.AddRange(new List<MenuAnchor>() { aLeft, aRight, aCentre });

            int index = 0;

            buttons.Add(checkUpdates = new CheckBox(UpdateChecker.CheckForUpdates, "Automatically check\nfor updates")
            {
                anchor = new Vector2(0f),
                offset = new Vector2(300f, 200f),

                OnChecked = (cb) =>
                {
                    UpdateChecker.CheckForUpdates = true;
                },
                OnUnchecked = (cb) =>
                {
                    UpdateChecker.CheckForUpdates = false;
                }
            }
            .Where(cb =>
            {
                cb.SetAutomaticPosition(aCentre, index++);

                cb.SetSize(cb.size.Where(delegate(ref Vector2 v) { v.Y *= 2; }));

                index++;
            }));

            buttons.Add(new MenuButton(0, "Check for updates", "").Where(mb =>
            {
                mb.SetAutomaticPosition(aCentre, index++);

                mb.Click = () =>
                {
                    if (UpdateChecker.GetIsUpdateAvailable())
                        UpdateBoxInjector.Inject();
                    else
                        mb.description = "No update availables";
                };
            }));

            buttons.Add(new MenuButton(0, "Back", "Options").Where(mb =>
            {
                mb.SetAutomaticPosition(aCentre, ++index);
                index++;

                mb.Click += () =>
                {
                    FileStream fs = new FileStream(MctMod.MCTDataFile, FileMode.Create);
					MctMod.WriteSettings(fs);
                    fs.Close();
                };
            }));
        }
Esempio n. 21
0
 internal ObservableCollection <MenuItemVM> GetMenuItems(MenuAnchor anchor)
 {
     return(_menuItems[anchor]);
 }
Esempio n. 22
0
 public BehaviorTreeEditorMenu(Rect rect, MenuAnchor anchor, string titleName) :
     base(rect, anchor, titleName)
 {
 }
Esempio n. 23
0
 /// <summary>
 /// 初始化一个MenuBar实例
 /// </summary>
 /// <param name="anchor">菜单停靠位置</param>
 /// <param name="iconSize">按钮图标尺寸</param>
 public MenuBar(MenuAnchor anchor, int iconSize)
 {
     m_anchor = anchor;
     MenuButton.SelectedSize = iconSize;
 }
Esempio n. 24
0
        /// <summary>
        /// Initializes the Page
        /// </summary>
        protected override void Init()
        {
            buttons.Clear();
            anchors.Clear();

            base.Init();

            MenuAnchor
                aLeft = new MenuAnchor()
                {
                    anchor = new Vector2(0.5f, 0f),
                    offset = new Vector2(-210f, 200f),
                    offset_button = new Vector2(0f, 50f)
                },
                aRight = new MenuAnchor()
                {
                    anchor = new Vector2(0.5f, 0f),
                    offset = new Vector2(210f, 200f),
                    offset_button = new Vector2(0f, 50f)
                },
                aCentre = new MenuAnchor()
                {
                    anchor = new Vector2(0.5f, 0f),
                    offset = new Vector2(0f, 200f),
                    offset_button = new Vector2(0f, 50f)
                };

            int lid = 0, cid = 0, rid = 0;

            anchors.AddRange(new List<MenuAnchor>() { aLeft, aRight, aCentre });

            Main.newWorldName = (string)worldJson["name"];

            buttons.Add(name = new MenuButtonStringValue(new Vector2(0.5f, 0), new Vector2(-150, 200), "World Name", "").SetSize(300, 60)
                .Where(mbsv =>
                {
                    mbsv.displayTextValueEmpty = selectedWorld;

                    mbsv.Update = () =>
                    {
                        mbsv.displayTextValueEmpty = selectedWorld;

                        if (mbsv.whoAmi == Menu.setButton)
                        {
                            string old = Main.newWorldName;
                            Main.newWorldName = Main.GetInputText(Main.newWorldName);

                            if (Main.newWorldName.Length > 20)
                                Main.newWorldName = Main.newWorldName.Substring(0, 20);

                            if (old != Main.newWorldName)
                                Main.PlaySound(12, -1, -1, 1);

                            if (Main.inputTextEnter)
                                Menu.setButton = -1;
                        }

                        mbsv.scaleValue = Math.Min(1f, (mbsv.size.X - 20) / Main.fontMouseText.MeasureString(mbsv.displayTextValue = Main.newWorldName).X);
                    };

                    mbsv.SetAutomaticPosition(aCentre, cid++);
                }));

            cid++;
            lid++; lid++;
            rid++; rid++;

            buttons.Add(new CheckBox((bool)worldJson["progress"]["bosses"]["Eye of Cthulhu"], "Defeated Eye of Cthulhu")
                .Where(cb =>
                {
                    cb.OnChecked += delegate
                    {
                        worldJson["progress"]["bosses"]["Eye of Cthulhu"] = true;
                    };
                    cb.OnUnchecked += delegate
                    {
                        worldJson["progress"]["bosses"]["Eye of Cthulhu"] = false;
                    };

                    cb.SetAutomaticPosition(aLeft, lid++);
                }));
            buttons.Add(new CheckBox((bool)worldJson["progress"]["bosses"]["Corrupt Boss"], "Defeated Eater of Worlds/Brain of Cthulhu")
                .Where(cb =>
                {
                    cb.OnChecked += delegate
                    {
                        worldJson["progress"]["bosses"]["Eater of Worlds"] = true;
                    };
                    cb.OnUnchecked += delegate
                    {
                        worldJson["progress"]["bosses"]["Eater of Worlds"] = false;
                    };

                    cb.SetAutomaticPosition(aLeft, lid++);
                }));
            buttons.Add(new CheckBox((bool)worldJson["progress"]["bosses"]["Skeletron"], "Defeated Skeletron")
                .Where(cb =>
                {
                    cb.OnChecked += delegate
                    {
                        worldJson["progress"]["bosses"]["Skeletron"] = true;
                    };
                    cb.OnUnchecked += delegate
                    {
                        worldJson["progress"]["bosses"]["Skeletron"] = false;
                    };

                    cb.SetAutomaticPosition(aLeft, lid++);
                }));

            buttons.Add(new CheckBox((bool)worldJson["progress"]["bosses"]["Queen Bee"], "Defeated Queen Bee")
                .Where(cb =>
                {
                    cb.OnChecked += delegate
                    {
                        worldJson["progress"]["bosses"]["Queen Bee"] = true;
                    };
                    cb.OnUnchecked += delegate
                    {
                        worldJson["progress"]["bosses"]["Queen Bee"] = false;
                    };

                    cb.SetAutomaticPosition(aCentre, cid++);
                }));
            buttons.Add(new CheckBox((bool)worldJson["progress"]["bosses"]["The Destroyer"], "Defeated The Destroyer")
                .Where(cb =>
                {
                    cb.OnChecked += delegate
                    {
                        worldJson["progress"]["bosses"]["The Destroyer"] = true;
                    };
                    cb.OnUnchecked += delegate
                    {
                        worldJson["progress"]["bosses"]["The Destroyer"] = false;
                    };

                    cb.SetAutomaticPosition(aCentre, cid++);
                }));
            buttons.Add(new CheckBox((bool)worldJson["progress"]["bosses"]["Skeletron"], "Defeated The Twins")
                .Where(cb =>
                {
                    cb.OnChecked += delegate
                    {
                        worldJson["progress"]["bosses"]["The Twins"] = true;
                    };
                    cb.OnUnchecked += delegate
                    {
                        worldJson["progress"]["bosses"]["The Twins"] = false;
                    };

                    cb.SetAutomaticPosition(aCentre, cid++);
                }));

            buttons.Add(new CheckBox((bool)worldJson["progress"]["bosses"]["Skeletron Prime"], "Defeated Skeletron Prime")
                .Where(cb =>
                {
                    cb.OnChecked += delegate
                    {
                        worldJson["progress"]["bosses"]["Skeletron Prime"] = true;
                    };
                    cb.OnUnchecked += delegate
                    {
                        worldJson["progress"]["bosses"]["Skeletron Prime"] = false;
                    };

                    cb.SetAutomaticPosition(aRight, rid++);
                }));
            buttons.Add(new CheckBox((bool)worldJson["progress"]["bosses"]["Plantera"], "Defeated Plantera")
                .Where(cb =>
                {
                    cb.OnChecked += delegate
                    {
                        worldJson["progress"]["bosses"]["Plantera"] = true;
                    };
                    cb.OnUnchecked += delegate
                    {
                        worldJson["progress"]["bosses"]["Plantera"] = false;
                    };

                    cb.SetAutomaticPosition(aRight, rid++);
                }));
            buttons.Add(new CheckBox((bool)worldJson["progress"]["bosses"]["Golem"], "Defeated Golem")
                .Where(cb =>
                {
                    cb.OnChecked += delegate
                    {
                        worldJson["progress"]["bosses"]["Golem"] = true;
                    };
                    cb.OnUnchecked += delegate
                    {
                        worldJson["progress"]["bosses"]["Golem"] = false;
                    };

                    cb.SetAutomaticPosition(aRight, rid++);
                }));

            buttons.Add(new CheckBox((bool)worldJson["crimson"], "Crimson")
                .Where(cb =>
                {
                    cb.OnChecked += delegate
                    {
                        worldJson["crimson"] = true;
                    };
                    cb.OnUnchecked += delegate
                    {
                        worldJson["crimson"] = false;
                    };

                    cb.SetAutomaticPosition(aLeft, lid++);
                }));
            buttons.Add(new CheckBox((bool)worldJson["corruption"], "Corruption")
                .Where(cb =>
                {
                    cb.OnChecked += delegate
                    {
                        worldJson["corruption"] = true;
                    };
                    cb.OnUnchecked += delegate
                    {
                        worldJson["corruption"] = false;
                    };

                    cb.SetAutomaticPosition(aRight, rid++);
                }));

            buttons.Add(new CheckBox((bool)worldJson["progress"]["npcs"]["Goblin Tinkerer"], "Saved Goblin Tinkerer")
                .Where(cb =>
                {
                    cb.OnChecked += delegate
                    {
                        worldJson["progress"]["npcs"]["Goblin Tinkerer"] = true;
                    };
                    cb.OnUnchecked += delegate
                    {
                        worldJson["progress"]["npcs"]["Goblin Tinkerer"] = false;
                    };

                    cb.SetAutomaticPosition(aCentre, cid++);
                }));
            buttons.Add(new CheckBox((bool)worldJson["progress"]["npcs"]["Wizard"], "Saved Wizard")
                .Where(cb =>
                {
                    cb.OnChecked += delegate
                    {
                        worldJson["progress"]["npcs"]["Wizard"] = true;
                    };
                    cb.OnUnchecked += delegate
                    {
                        worldJson["progress"]["npcs"]["Wizard"] = false;
                    };

                    cb.SetAutomaticPosition(aCentre, cid++);
                }));
            buttons.Add(new CheckBox((bool)worldJson["progress"]["npcs"]["Mechanic"], "Saved Mechanic")
                .Where(cb =>
                {
                    cb.OnChecked += delegate
                    {
                        worldJson["progress"]["npcs"]["Mechanic"] = true;
                    };
                    cb.OnUnchecked += delegate
                    {
                        worldJson["progress"]["npcs"]["Mechanic"] = false;
                    };

                    cb.SetAutomaticPosition(aCentre, cid++);
                }));

            buttons.Add(new MenuButtonPlusMinus(0, "Altars smashed", "", "", () => { })
                .Where(mbpm =>
                {
                    mbpm.displayText = "Altars smashed: " + (int)worldJson["progress"]["altarCount"];

                    mbpm.Click = () =>
                    {
                        if (mbpm.currentSelected == 1)
                            worldJson["progress"]["altarCount"] = (int)worldJson["progress"]["altarCount"] - 1;
                        else if (mbpm.currentSelected >= 1)
                            worldJson["progress"]["altarCount"] = (int)worldJson["progress"]["altarCount"] + 1;

                        if ((int)worldJson["progress"]["altarCount"] < 0)
                            worldJson["progress"]["altarCount"] = 0;

                        mbpm.displayText = "Altars smashed: " + (int)worldJson["progress"]["altarCount"];

                        Main.PlaySound(12);
                    };

                    mbpm.ClickHold = () =>
                    {
                        if (mbpm.currentSelected < 1)
                            mbpm.framesHeld = 0;
                        else if (mbpm.framesHeld >= 20 && mbpm.framesHeld % 2 == 0)
                            mbpm.Click();
                    };

                    mbpm.Update = () =>
                    {
                        if (mbpm.currentSelected < 0)
                            return;

                        int
                            scroll = (Main.mouseState.ScrollWheelValue - Main.oldMouseState.ScrollWheelValue) / 120,
                            original = mbpm.currentSelected;

                        while (scroll != 0)
                        {
                            if (scroll < 0)
                                mbpm.currentSelected = 1;
                            else
                                mbpm.currentSelected = 2;

                            scroll -= Math.Sign(scroll);

                            mbpm.Click();
                        }

                        mbpm.currentSelected = original;
                    };

                    mbpm.SetAutomaticPosition(aLeft, lid++);
                    mbpm.SetSize(new Vector2(250f, 50f));
                    mbpm.customPos = mbpm.position - new Vector2(50f, 5f);
                }));
            buttons.Add(new MenuButtonPlusMinus(0, "Shadow orbs smashed", "", "", () => { })
                .Where(mbpm =>
                {
                    mbpm.displayText = "Shadow orbs smashed: " + (int)worldJson["progress"]["shadowOrb"]["counter"];

                    mbpm.Click = () =>
                    {
                        if (mbpm.currentSelected == 1)
                            worldJson["progress"]["shadowOrb"]["counter"] = (int)worldJson["progress"]["shadowOrb"]["counter"] - 1;
                        else if (mbpm.currentSelected >= 1)
                            worldJson["progress"]["shadowOrb"]["counter"] = (int)worldJson["progress"]["shadowOrb"]["counter"] + 1;

                        if ((int)worldJson["progress"]["shadowOrb"]["counter"] < 0)
                            worldJson["progress"]["shadowOrb"]["counter"] = 0;

                        mbpm.displayText = "Shadow orbs smashed: " + (int)worldJson["progress"]["shadowOrb"]["counter"];

                        Main.PlaySound(12);
                    };

                    mbpm.ClickHold = () =>
                    {
                        if (mbpm.currentSelected < 1)
                            mbpm.framesHeld = 0;
                        else if (mbpm.framesHeld >= 20 && mbpm.framesHeld % 2 == 0)
                            mbpm.Click();
                    };

                    mbpm.Update = () =>
                    {
                        if (mbpm.currentSelected < 0)
                            return;

                        int
                            scroll = (Main.mouseState.ScrollWheelValue - Main.oldMouseState.ScrollWheelValue) / 120,
                            original = mbpm.currentSelected;

                        while (scroll != 0)
                        {
                            if (scroll < 0)
                                mbpm.currentSelected = 1;
                            else
                                mbpm.currentSelected = 2;

                            scroll -= Math.Sign(scroll);

                            mbpm.Click();
                        }

                        mbpm.currentSelected = original;
                    };

                    mbpm.SetAutomaticPosition(aRight, rid++);
                    mbpm.SetSize(new Vector2(300f, 50f));
                    mbpm.customPos = mbpm.position - new Vector2(0f, 5f);
                }));

            if ((int)worldJson["hardmodeOres"][0] == -1)
                worldJson["hardmodeOres"][0] = 107;
            if ((int)worldJson["hardmodeOres"][1] == -1)
                worldJson["hardmodeOres"][1] = 187;
            if ((int)worldJson["hardmodeOres"][2] == -1)
                worldJson["hardmodeOres"][2] = 111;

            buttons.Add(oreButtons[0] = new MenuButton(0, "Cobalt", "", "", () =>
            {
                if ((int)worldJson["hardmodeOres"][0] == 107)
                {
                    worldJson["hardmodeOres"][0] = 221;
                    oreButtons[0].displayText = "Palladium";
                }
                else
                {
                    worldJson["hardmodeOres"][0] = 107;
                    oreButtons[0].displayText = "Cobalt";
                }

                Main.PlaySound(12);
            }).Where(mb =>
            {
                if ((int)worldJson["hardmodeOres"][0] == 221)
                    mb.displayText = "Palladium";

                mb.SetAutomaticPosition(aLeft, lid++);
            }));
            buttons.Add(oreButtons[1] = new MenuButton(0, "Mithril", "", "", () =>
            {
                if ((int)worldJson["hardmodeOres"][1] == 108)
                {
                    worldJson["hardmodeOres"][1] = 222;
                    oreButtons[1].displayText = "Orchialcum";
                }
                else
                {
                    worldJson["hardmodeOres"][1] = 108;
                    oreButtons[1].displayText = "Mithril";
                }

                Main.PlaySound(12);
            }).Where(mb =>
            {
                if ((int)worldJson["hardmodeOres"][1] == 222)
                    mb.displayText = "Orchialcum";

                mb.SetAutomaticPosition(aCentre, cid++);
            }));
            buttons.Add(oreButtons[2] = new MenuButton(0, "Adamantite", "", "", () =>
            {
                if ((int)worldJson["hardmodeOres"][2] == 111)
                {
                    worldJson["hardmodeOres"][2] = 223;
                    oreButtons[2].displayText = "Titanium";
                }
                else
                {
                    worldJson["hardmodeOres"][2] = 111;
                    oreButtons[2].displayText = "Adamantite";
                }

                Main.PlaySound(12);
            }).Where(mb =>
            {
                if ((int)worldJson["hardmodeOres"][2] == 223)
                    mb.displayText = "Titanium";

                mb.SetAutomaticPosition(aRight, rid++);
            }));

            lid++;
            cid++;
            rid++;

            buttons.Add(new MenuButton(0, "Save & go back", "World Select").Where(mb =>
            {
                mb.Click += () =>
                {
                    using (ZipFile zf = new ZipFile(selectedWorldPath))
                    {
                        zf.RemoveEntry("Info.json");
                        zf.AddEntry("Info.json", JsonMapper.ToJson(worldJson));

                        zf.Save();

                        Main.LoadWorlds();
                    }
                };

                mb.SetAutomaticPosition(new MenuAnchor()
                {
                    anchor = new Vector2(0.5f, 0f),
                    offset = new Vector2(-105f, 200f),
                    offset_button = new Vector2(0f, 50f)
                }, lid++);
            }));
            buttons.Add(new MenuButton(0, "Go back without saving", "World Select").Where(mb => mb.SetAutomaticPosition(new MenuAnchor()
            {
                anchor = new Vector2(0.5f, 0f),
                offset = new Vector2(105f, 200f),
                offset_button = new Vector2(0f, 50f)
            }, rid++)));
        }
Esempio n. 25
0
 public NodeActionMenu(Rect rect, MenuAnchor anchor, string titleName) :
     base(rect, anchor, titleName)
 {
 }
Esempio n. 26
0
 public BehaviorTreeEditorMenu_TopTool(Rect rect, MenuAnchor anchor, string titleName) :
     base(rect, anchor, titleName)
 {
     InitialToolBatItem();
 }
Esempio n. 27
0
 void Awake()
 {
     instance = this;
 }
Esempio n. 28
0
        public void RenderLabel(DrawArgs drawArgs, int x, int y, int buttonHeight, bool selected, MenuAnchor anchor)
        {
            if (selected)
            {
                if (buttonHeight == this.curSize)
                {
                    this.alpha += alphaStep;
                    if (this.alpha > 255)
                    {
                        this.alpha = 255;
                    }
                }
            }
            else
            {
                this.alpha -= alphaStep;
                if (this.alpha < 0)
                {
                    this.alpha = 0;
                    return;
                }
            }

            int halfWidth = (int)(SelectedSize * 0.75);
            int label_x   = x - halfWidth + 1;
            int label_y   = (int)(y + SelectedSize) + 1;

            FontDrawFlags format = FontDrawFlags.NoClip | FontDrawFlags.Center | FontDrawFlags.WordBreak;

            if (anchor == MenuAnchor.Bottom)
            {
                format |= FontDrawFlags.Bottom;
                label_y = y - 202;
            }

            Rectangle rect = new Rectangle(
                label_x,
                label_y,
                (int)halfWidth * 2,
                200);

            if (rect.Right > drawArgs.screenWidth)
            {
                rect = Rectangle.FromLTRB(rect.Left, rect.Top, drawArgs.screenWidth, rect.Bottom);
            }

            drawArgs.toolbarFont.DrawText(
                null, this.Description,
                rect,
                format,
                black & 0xffffff + (this.alpha << 24));

            rect.Offset(2, 0);

            drawArgs.toolbarFont.DrawText(
                null, this.Description,
                rect,
                format,
                black & 0xffffff + (this.alpha << 24));

            rect.Offset(0, 2);

            drawArgs.toolbarFont.DrawText(
                null, this.Description,
                rect,
                format,
                black & 0xffffff + (this.alpha << 24));

            rect.Offset(-2, 0);

            drawArgs.toolbarFont.DrawText(
                null, this.Description,
                rect,
                format,
                black & 0xffffff + (this.alpha << 24));

            rect.Offset(1, -1);

            drawArgs.toolbarFont.DrawText(
                null, this.Description,
                rect,
                format,
                white & 0xffffff + (this.alpha << 24));
        }
        }                                             //是否处于激活状态

        #region 构造函数
        public ContexMenuParent(float x, float y, float width, float height, MenuAnchor anchor, string titleName) :
            base(x, y, width, height, anchor, titleName)
        {
            IsActive = false;
        }
Esempio n. 30
0
        private string m_BgImagePath = "Assets/Editor/EditorResources/ActionNodeItembg.png"; //背景图


        #region 构造函数

        public BehaviorTreeEditorMenu_TopTool(float x, float y, float width, float height, MenuAnchor anchor, string titleName) :
            base(x, y, width, height, anchor, titleName)
        {
            InitialToolBatItem();
        }
 public ContexMenuParent(Rect rect, MenuAnchor anchor, string titleName) :
     base(rect, anchor, titleName)
 {
     IsActive = false;
 }
Esempio n. 32
0
        private int m_DefaultSelectItem = 0; //默认选中的对象

        #region 构造函数

        public NodeActionMenu(float x, float y, float width, float height, MenuAnchor anchor, string titleName) :
            base(x, y, width, height, anchor, titleName)
        {
        }
Esempio n. 33
0
		/// <summary>
		/// Initializes a new instance of the <see cref= "T:WorldWind.Menu.MenuBar"/> class.
		/// </summary>
		/// <param name="anchor"></param>
		/// <param name="iconSize"></param>
		public MenuBar(MenuAnchor anchor, int iconSize)
		{
			m_anchor = anchor;
			MenuButton.SelectedSize = iconSize;
		}
Esempio n. 34
0
        /// <summary>
        /// Initializes the Page
        /// </summary>
        protected override void Init()
        {
            base.Init();

            MenuAnchor
                aLeft = new MenuAnchor()
                {
                    anchor = new Vector2(0.5f, 0),
                    offset = new Vector2(-105, 200),
                    offset_button = new Vector2(0, 50)
                },
                aRight = new MenuAnchor()
                {
                    anchor = new Vector2(0.5f, 0),
                    offset = new Vector2(105, 200),
                    offset_button = new Vector2(0, 50)
                },
                aCentre = new MenuAnchor()
                {
                    anchor = new Vector2(0.5f, 0f),
                    offset = new Vector2(0f, 200f),
                    offset_button = new Vector2(0f, 50f)
                };

            anchors.AddRange(new List<MenuAnchor>() { aLeft, aRight, aCentre });

            buttons.Add(new MenuButton(0, "Accent colour:", "", "", () => { }).With(mb =>
            {
                mb.canMouseOver = false;

                mb.SetAutomaticPosition(aLeft, 0);

                mb.Update += () => mb.colorText = ColourAccent;
            }));

            buttons.Add(new Image(MctUI.WhitePixel)
            {
                Scale = new Vector2(24f),
                IsButton = true,
                size = new Vector2(40f) / 24f,
                colorText = FromAccentEnum(AccentColour.Cobalt),
                description = "Cobalt"
            }
            .With(mb =>
            {
                mb.SetAutomaticPosition(aLeft, 1);

                mb.Click += () => AccentColour = AccentColour.Cobalt;
            }));
            buttons.Add(new Image(MctUI.WhitePixel)
            {
                Scale = new Vector2(24f),
                IsButton = true,
                size = new Vector2(40f) / 24f,
                colorText = FromAccentEnum(AccentColour.Lime),
                description = "Lime"
            }
            .With(mb =>
            {
                mb.SetAutomaticPosition(aLeft, 2);

                mb.Click += () => AccentColour = AccentColour.Lime;
            }));
            buttons.Add(new Image(MctUI.WhitePixel)
            {
                Scale = new Vector2(24f),
                IsButton = true,
                size = new Vector2(40f) / 24f,
                colorText = FromAccentEnum(AccentColour.OrangeRed),
                description = "Orange-red"
            }
            .With(mb =>
            {
                mb.SetAutomaticPosition(aLeft, 3);

                mb.Click += () => AccentColour = AccentColour.OrangeRed;
            }));

            // ---

            buttons.Add(new MenuButton(0, "Theme colour:", "", "", () => { }).With(mb =>
            {
                mb.canMouseOver = false;

                mb.SetAutomaticPosition(aRight, 0);

                mb.Update += () => mb.colorText = ColourAccent;
            }));

            buttons.Add(new Image(MctUI.WhitePixel)
            {
                Scale = new Vector2(24f),
                IsButton = true,
                size = new Vector2(40f) / 24f,
                colorText = FromThemeEnum(ThemeColour.Black),
                description = "Black"
            }
            .With((mb) =>
            {
                mb.SetAutomaticPosition(aRight, 1);

                mb.Click += () => ThemeColour = ThemeColour.Black;
            }));
            buttons.Add(new Image(MctUI.WhitePixel)
            {
                Scale = new Vector2(24f),
                IsButton = true,
                size = new Vector2(40f) / 24f,
                colorText = FromThemeEnum(ThemeColour.White),
                description = "White"
            }
            .With((mb) =>
            {
                mb.SetAutomaticPosition(aRight, 2);

                mb.Click += () => ThemeColour = ThemeColour.White;
            }));

            // ---

            buttons.Add(new MenuButton(0, "Back", "Options").Where(mb => mb.SetAutomaticPosition(aCentre, 4)));
        }
Esempio n. 35
0
        /// <summary>
        /// Called when all mods are loaded
        /// </summary>
        public override void OnAllModsLoaded()
        {
            if (Main.dedServ)
                return;

            // easy as 4 * Math.Atan(1)

            MctUI.AddCustomUI(MainUI.Interface = new MainUI());

            MctUI.AddCustomUI(ItemUI  .Instance = new ItemUI  ());
            MctUI.AddCustomUI(BuffUI  .Instance = new BuffUI  ());
            MctUI.AddCustomUI(PrefixUI.Instance = new PrefixUI());
            MctUI.AddCustomUI(NpcUI   .Instance = new NpcUI   ());
            MctUI.AddCustomUI(PlayerUI.Instance = new PlayerUI());
            MctUI.AddCustomUI(WorldUI .Instance = new WorldUI ());

            //MctUI.AddCustomUI(EditGlobalNPCUI.Interface = new EditGlobalNPCUI());
            //MctUI.AddCustomUI(EditItemUI.Interface = new EditItemUI());

            // a bit less easy...
            Menu.menuPages.Add("ICM:Edit World", new EditWorldPage());

            MenuAnchor aCustom = new MenuAnchor()
            {
                anchor = new Vector2(0.5f, 0f),
                offset = new Vector2(315f, 200f),
                offset_button = new Vector2(0f, 50f)
            };

            //Menu.menuPages.Add("ICM:Settings", new SettingsPage());

            //Menu.menuPages["Options"].anchors.Add(aOptions);
            //Menu.menuPages["Options"].buttons.Add(new MenuButton(1, "ICM Settings", "ICM:Settings").With(mb => mb.SetAutomaticPosition(aCustom, 0)));

            #region edit player code
            editPlayerOffset = Menu.menuPages["Player Select"].buttons.Count;

            for (int i = 0; i < 5; i++)
            {
                int index = i;
                Menu.menuPages["Player Select"].buttons.Add(new MenuButton(new Vector2(0.5f, 0), new Vector2(100, 200 + i * 50), "Edit Player", "")
                .Where(w =>
                {
                    w.Update = () =>
                    {
                        if (index + Menu.skip < Main.numLoadPlayers)
                        {
                            w.displayText = "Edit " + Main.loadPlayer[index + Menu.skip].name;

                            w.scale = Math.Min(1f, (w.size.X - 20) / Main.fontMouseText.MeasureString(w.displayText).X);
                        }
                        //else
                        //{
                        //    // disabling done in PostGameDraw
                        //}
                    };
                    w.Click = () =>
                    {
                        int pid = index + Menu.skip;

                        if (pid >= Main.numLoadPlayers)
                        {
                            Main.loadPlayer[Main.numLoadPlayers] = new Player();
                            Main.loadPlayer[Main.numLoadPlayers].inventory[0].SetDefaults("Copper Shortsword");
                            Main.loadPlayer[Main.numLoadPlayers].inventory[0].Prefix(-1);
                            Main.loadPlayer[Main.numLoadPlayers].inventory[1].SetDefaults("Copper Pickaxe");
                            Main.loadPlayer[Main.numLoadPlayers].inventory[1].Prefix(-1);
                            Main.loadPlayer[Main.numLoadPlayers].inventory[2].SetDefaults("Copper Axe");
                            Main.loadPlayer[Main.numLoadPlayers].inventory[2].Prefix(-1);
                            Menu.MoveTo("Create Player");
                            return;
                        }

                        string name = (string)Main.loadPlayer[pid].name.Clone(); // backup name because it's reset in {Create Player}.OnEntry

                        int oldLoadPlayers = Main.numLoadPlayers;
                        Main.numLoadPlayers = pid;

                        string path = Main.PlayerPath + "\\" + Main.loadPlayer[pid].name + ".plr";

                        MenuPage create = Menu.menuPages["Create Player"];

                        // sometimes, hacking is NOT easy

                        if (File.Exists(path))
                        {
                            File.WriteAllBytes(path + ".ipb", File.ReadAllBytes(path)); // ICM Player Backup
                            File.Delete(path);
                        }
                        if (File.Exists(path + ".bak"))
                        {
                            File.WriteAllBytes(path + ".bak.ipb", File.ReadAllBytes(path + ".bak"));
                            File.Delete(path + ".bak");
                        }

                        Action
                            entry        = null,
                            entryCleanup = null;

                        entryCleanup = () =>
                        {
                            Main.numLoadPlayers = oldLoadPlayers;
                            Menu.menuPages["Player Select"].OnEntry -= entryCleanup;

                            if (!File.Exists(path) && File.Exists(path + ".ipb"))
                            {
                                File.WriteAllBytes(path, File.ReadAllBytes(path + ".ipb"));
                                File.Delete(path + ".ipb");
                            }

                            if (!File.Exists(path + ".bak") && File.Exists(path + ".bak.ipb"))
                            {
                                File.WriteAllBytes(path, File.ReadAllBytes(path + ".bak.ipb"));
                                File.Delete(path + ".bak.ipb");
                            }
                        };
                        entry        = () =>
                        {
                            if (create.buttons[17].displayText == "Save Player")
                                create.buttons[17].displayText = "Create Player";
                            else
                                create.buttons[17].displayText = "Save Player";

                            create.OnEntry -= entry;
                            Menu.menuPages["Player Select"].OnEntry += entryCleanup;
                        };
                        create.OnEntry += entry;

                        Menu.MoveTo("Create Player");

                        Main.loadPlayer[pid].name = name;
                    };
                }));
            }
            #endregion

            #region edit world code
            editWorldOffset = Menu.menuPages["World Select"].buttons.Count;

            for (int i = 0; i < 5; i++)
            {
                int index = i;
                Menu.menuPages["World Select"].buttons.Add(new MenuButton(new Vector2(0.5f, 0), new Vector2(100, 200 + i * 50), "Edit World", "")
                .Where(w =>
                {
                    w.Update = () =>
                    {
                        if (index + Menu.skip < Main.numLoadPlayers)
                        {
                            w.displayText = "Edit " + Main.loadWorld[index + Menu.skip];

                            w.scale = Math.Min(1f, (w.size.X - 20) / Main.fontMouseText.MeasureString(w.displayText).X);
                        }
                    };
                    w.Click = () =>
                    {
                        int wid = index + Menu.skip;

                        EditWorldPage.selectedWorld     = Main.loadWorld    [wid];
                        EditWorldPage.selectedWorldPath = Main.loadWorldPath[wid];

                        ((EditWorldPage)Menu.menuPages["ICM:Edit World"]).LoadData();

                        Menu.MoveTo("ICM:Edit World"); // editing is done there
                    };
                }));
            }
            #endregion

            base.OnAllModsLoaded();
        }