Пример #1
0
    public MenuIconI NewIcon()
    {
        MenuIcon icon = new MenuIcon();

        Icons.Add(icon);
        return(icon);
    }
Пример #2
0
        /// <summary>
        /// Sets the weight of a fromBuilding by creating a menu and asking the user what weight the fromBuilding should have.
        /// </summary>
        /// <param name="b">The fromBuilding to set a weight for.</param>
        public void SetWeight(Building b)
        {
            Dictionary <MenuIcon, int> doptions = new Dictionary <MenuIcon, int>(8);

            doptions.Add(new MenuIcon(Language.Instance.GetString("NoPriority"), Recellection.textureMap.GetTexture(Globals.TextureTypes.NoPriority)), 0);
            doptions.Add(new MenuIcon(Language.Instance.GetString("LowPriority"), Recellection.textureMap.GetTexture(Globals.TextureTypes.LowPriority)), 50);
            doptions.Add(new MenuIcon(Language.Instance.GetString("HighPriority"), Recellection.textureMap.GetTexture(Globals.TextureTypes.HighPriority)), 100);
            doptions.Add(new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No)), -1);

            Menu menu = new Menu(Globals.MenuLayout.FourMatrix,
                                 new List <MenuIcon>(doptions.Keys),
                                 Language.Instance.GetString("SetImportance"));

            MenuController.LoadMenu(menu);

            Recellection.CurrentState = MenuView.Instance;

            MenuIcon selection = MenuController.GetInput();

            if (doptions[selection] >= 0)
            {
                SetWeight(b, doptions[selection]);
            }

            Recellection.CurrentState = WorldView.Instance;
            MenuController.UnloadMenu();
        }
Пример #3
0
        private void AddMenuItem(ToolStripItemCollection destinationItems, System.Windows.Controls.MenuItem menuItem)
        {
            string MenuHeader = (string)menuItem.Header;

            ToolStripMenuItem NewMenuItem;

            if (menuItem.Icon is Bitmap MenuBitmap)
            {
                NewMenuItem = new ToolStripMenuItem(MenuHeader, MenuBitmap);
            }

            else if (menuItem.Icon is Icon MenuIcon)
            {
                NewMenuItem = new ToolStripMenuItem(MenuHeader, MenuIcon.ToBitmap());
            }

            else
            {
                NewMenuItem = new ToolStripMenuItem(MenuHeader);
            }

            NewMenuItem.Click += OnMenuClicked;
            // See PrepareMenuItem for using the visibility to carry Visible/Enabled flags
            NewMenuItem.Visible = (menuItem.Visibility != System.Windows.Visibility.Collapsed);
            NewMenuItem.Enabled = (menuItem.Visibility == System.Windows.Visibility.Visible);
            NewMenuItem.Checked = menuItem.IsChecked;

            destinationItems.Add(NewMenuItem);
            MenuTable.Add(NewMenuItem, this);
            CommandTable.Add(NewMenuItem, menuItem.Command);
        }
Пример #4
0
		public void Add(MenuIcon icon, string caption) {
			if (count == 5) throw new IndexOutOfRangeException("Izvēlnē drīkst būt tikai pieci elementi");
			if (caption == null) throw new ArgumentNullException("caption");

			if (!indexes.ContainsKey(icon)) indexes.Add(icon, count);
			items[count++]=Tuple.Create(icon, caption);
		}
Пример #5
0
    public MenuIconI NewIcon(int Index)
    {
        MenuIcon Icon = new MenuIcon();

        Icons.Insert(Index, icon);
        return(Icon);
    }
        private void EndGame(Player winner)
        {
            if (backgroundSound.IsPlaying)
            {
                backgroundSound.Pause();
            }

            humanControl.Stop();

            // Build menu

            List <MenuIcon> options = new List <MenuIcon>(1);
            MenuIcon        cancel  = new MenuIcon("");

            cancel.region = new GUIRegion(Recellection.windowHandle,
                                          new System.Windows.Rect(0, Globals.VIEWPORT_HEIGHT - 100, Globals.VIEWPORT_WIDTH, 100));
            options.Add(cancel);
            Menu menu = new Menu(options);

            MenuController.LoadMenu(menu);

            Recellection.CurrentState = new EndGameView(!(winner is AIPlayer));

            MenuController.GetInput();

            MenuController.UnloadMenu();
        }
        private async void Menu_Tapped(object sender, EventArgs e)
        {
            await MenuIcon.TranslateTo(100, 0, 200);

            // await MenuIcon.RotateTo(22, 250);
            await PopupNavigation.Instance.PushAsync(new MenuPopup(MenuIcon));
        }
Пример #8
0
    void CheckCollision()
    {
        ShowCursor(true);
        RaycastHit hitInfo;

        MenuIcon.selectedItem = null;
        if (Physics.Raycast(transform.position, cursor.transform.position - transform.position, out hitInfo))
        {
            if (hitInfo.collider.gameObject.tag == "Screen")
            {
                ShowCursor(false);
            }
            //Test if the collided object is selectable
            SelectableObject so = hitInfo.collider.gameObject.GetComponent <SelectableObject>();
            if (so == null && lastSelectedSo != null && lastSelectedSo.progressBar)
            {
                lastSelectedSo.progressBar.SetActive(false);
            }

            if (so && !UIController.Instance.menu)
            {
                selectionTimer += Time.deltaTime;
                if (so.selectionTime != 0)
                {
                    so.SetProgress(selectionTimer / so.selectionTime);
                }
                if (selectionTimer >= so.selectionTime)
                {
                    so.SelectionEvent();
                    if (so.selectionTime != 0)
                    {
                        so.progressBar.SetActive(false);
                    }
                    //Inform the ui controller that a menu has been selected
                    UIController.Instance.SetMenu(so.menuPrefab.gameObject);
                }
            }
            //If it is not a selectable object, test if it is a menu icon
            else
            {
                selectionTimer = 0;
                MenuIcon mi = hitInfo.collider.gameObject.GetComponent <MenuIcon>();
                if (mi)
                {
                    MenuIcon.selectedItem = mi;
                }
            }
            lastSelectedSo = so;
        }
        else if (lastSelectedSo)
        {
            selectionTimer = 0;
            if (lastSelectedSo.progressBar)
            {
                lastSelectedSo.progressBar.SetActive(false);
            }
        }
    }
Пример #9
0
        private void ChangeVolumeMenu()
        {
            MenuIcon musicVolumeUp   = new MenuIcon(Language.Instance.GetString("MusicVolumeUp"));
            MenuIcon musicVolumeDown = new MenuIcon(Language.Instance.GetString("MusicVolumeDown"));
            MenuIcon sfxVolumeUp     = new MenuIcon(Language.Instance.GetString("EffectsVolumeUp"));
            MenuIcon sfxVolumeDown   = new MenuIcon(Language.Instance.GetString("EffectsVolumeDown"));
            MenuIcon empty           = new MenuIcon("");
            MenuIcon done            = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No));

            List <MenuIcon> iconList = new List <MenuIcon>();;

            iconList.Add(musicVolumeUp);
            iconList.Add(empty);
            iconList.Add(musicVolumeDown);
            iconList.Add(sfxVolumeUp);
            iconList.Add(sfxVolumeDown);
            iconList.Add(done);

            Menu volumeMenu = new Menu(Globals.MenuLayout.NineMatrix, iconList, "");

            MenuController.LoadMenu(volumeMenu);

            bool notFinished = true;

            while (notFinished)
            {
                MenuIcon response = MenuController.GetInput();

                if (response == musicVolumeUp)
                {
                    if (GameOptions.Instance.musicVolume <= 1.0f)
                    {
                        SoundsController.changeMusicVolume(GameOptions.Instance.musicVolume + 0.1f);
                    }
                }
                else if (response == musicVolumeDown)
                {
                    SoundsController.changeMusicVolume(GameOptions.Instance.musicVolume - 0.1f);
                }
                else if (response == sfxVolumeUp)
                {
                    if (GameOptions.Instance.sfxVolume <= 1.0f)
                    {
                        SoundsController.changeEffectsVolume(GameOptions.Instance.sfxVolume + 0.1f);
                    }
                }
                else if (response == sfxVolumeDown)
                {
                    SoundsController.changeEffectsVolume(GameOptions.Instance.sfxVolume - 0.1f);
                }
                else if (response == done)
                {
                    notFinished = false;
                }
            }
            MenuController.UnloadMenu();
        }
Пример #10
0
 public Icon(MenuIcon menuIcon)
 {
     type         = menuIcon.type;
     value        = menuIcon.value;
     theme        = menuIcon.theme;
     spin         = menuIcon.spin;
     twoToneColor = menuIcon.twoToneColor;
     iconfont     = menuIcon.iconfont;
 }
Пример #11
0
        public void HandleCommand(MenuIcon icon)
        {
            int index = Items.GetIconIndex(icon);

            if (index != -1)
            {
                HandleCommand(index);
            }
        }
Пример #12
0
        internal int GetIconIndex(MenuIcon icon)
        {
            int index;

            if (indexes.TryGetValue(icon, out index))
            {
                return(index);
            }
            return(-1);
        }
Пример #13
0
        public override IMenuItem AddButton(string text, string key, Bitmap icon, PluginIdentity identity)
        {
            var item = new ToolStripMenuItem {
                Text = text
            };
            var menuItem = AddItem(item, identity, key, false);

            MenuIcon.AssignIcon(menuItem, icon);
            return(menuItem);
        }
Пример #14
0
        protected override IDropDownMenuItem AddDropDown(string text, string key, Bitmap icon, PluginIdentity identity)
        {
            var item = new ParentBarItem(text)
            {
                Padding = new Point(TOOLBAR_ITEM_PADDING_X, TOOLBAR_ITEM_PADDING_Y)
            };;
            var menuItem = AddItem(item, identity, key) as IDropDownMenuItem;

            MenuIcon.AssignIcon(menuItem, icon);
            return(menuItem);
        }
Пример #15
0
        public override IMenuItem AddButton(string text, string key, Bitmap icon, PluginIdentity pluginIdentity)
        {
            var item = new BarItem(text)
            {
                Padding = new Point(TOOLBAR_ITEM_PADDING_X, TOOLBAR_ITEM_PADDING_Y)
            };
            var menuItem = AddItem(item, pluginIdentity, key);

            MenuIcon.AssignIcon(menuItem, icon);
            return(menuItem);
        }
Пример #16
0
        private IDropDownMenuItem AddDropDownCore(ToolStripDropDownItem item, string text, string key,
                                                  Bitmap icon, PluginIdentity identity, bool label)
        {
            item.Text         = text;
            item.Padding      = new Padding(ItemPadding);
            item.ImageScaling = ToolStripItemImageScaling.SizeToFit;

            var menuItem = AddItem(item, identity, key, label) as IDropDownMenuItem;

            MenuIcon.AssignIcon(menuItem, icon);
            return(menuItem);
        }
Пример #17
0
        static Configurator()
        {
            Instance = new Configurator();

            mute       = new MenuIcon(Language.Instance.GetString("Mute"));
            volume     = new MenuIcon(Language.Instance.GetString("Volume"));
            difficulty = new MenuIcon(Language.Instance.GetString("Difficulty"));
            language   = new MenuIcon(Language.Instance.GetString("Language"));
            credits    = new MenuIcon(Language.Instance.GetString("Credits"));
            back       = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No));

            iconList = new List <MenuIcon>();
        }
        static Configurator()
        {
            Instance = new Configurator();

            mute = new MenuIcon(Language.Instance.GetString("Mute"));
            volume = new MenuIcon(Language.Instance.GetString("Volume"));
            difficulty = new MenuIcon(Language.Instance.GetString("Difficulty"));
            language = new MenuIcon(Language.Instance.GetString("Language"));
            credits = new MenuIcon(Language.Instance.GetString("Credits"));
            back = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No));

            iconList = new List<MenuIcon>();
        }
Пример #19
0
        public void ChangeOptions()
        {
            Menu optionsMenu = BuildMenu();

            MenuController.LoadMenu(optionsMenu);

            Recellection.CurrentState = MenuView.Instance;
            bool notFinished = true;

            while (notFinished)
            {
                MenuIcon response = MenuController.GetInput();

                if (response == mute)
                {
                    if (GameOptions.Instance.musicMuted)
                    {
                        GameOptions.Instance.musicMuted = false;
                        SoundsController.changeEffectsVolume(GameOptions.Instance.sfxVolume);
                        SoundsController.changeMusicVolume(GameOptions.Instance.musicVolume);
                    }
                    else
                    {
                        GameOptions.Instance.musicMuted = true;
                        SoundsController.changeEffectsVolume(0.0f);
                        SoundsController.changeMusicVolume(0.0f);
                    }
                }
                else if (response == volume)
                {
                    ChangeVolumeMenu();
                }
                else if (response == language)
                {
                    ChangeLanguageMenu();
                }
                else if (response == difficulty)
                {
                    ChangeDifficultyMenu();
                }
                else if (response == back)
                {
                    notFinished = false;
                }
                else if (response == credits)
                {
                    PlayCredits();
                }
            }
            MenuController.UnloadMenu();
        }
        private void drawMenu()
        {
            MenuIcon one = new MenuIcon("one", null);
            MenuIcon two = new MenuIcon("two", null);
            MenuIcon three = new MenuIcon("three", null);
            MenuIcon four = new MenuIcon("four", null);

            List<MenuIcon> listOfMenuIcons = new List<MenuIcon>();
            listOfMenuIcons.Add(one);
            listOfMenuIcons.Add(two);
            listOfMenuIcons.Add(three);
            listOfMenuIcons.Add(four);
            optionsMenu = new Menu(Globals.MenuLayout.FourMatrix, listOfMenuIcons, "Options Menu");
        }
        void ReleaseDesignerOutlets()
        {
            if (MenuIcon != null)
            {
                MenuIcon.Dispose();
                MenuIcon = null;
            }

            if (TitleLabel != null)
            {
                TitleLabel.Dispose();
                TitleLabel = null;
            }
        }
        private void drawMenu()
        {
            MenuIcon one   = new MenuIcon("one", null);
            MenuIcon two   = new MenuIcon("two", null);
            MenuIcon three = new MenuIcon("three", null);
            MenuIcon four  = new MenuIcon("four", null);

            List <MenuIcon> listOfMenuIcons = new List <MenuIcon>();

            listOfMenuIcons.Add(one);
            listOfMenuIcons.Add(two);
            listOfMenuIcons.Add(three);
            listOfMenuIcons.Add(four);
            optionsMenu = new Menu(Globals.MenuLayout.FourMatrix, listOfMenuIcons, "Options Menu");
        }
Пример #23
0
        void SetupStyling()
        {
            ActivityExplainerLbl.Font   = StyleUtil.Font(StyleUtil.FontType.FontMedium, 18, 22);
            ActivityExplainerLbl.Text   = InfectionStatusViewModel.INFECTION_STATUS_ACTIVITY_STATUS_DESCRIPTION_TEXT;
            MenuIcon.AccessibilityLabel = InfectionStatusViewModel.INFECTION_STATUS_MENU_ACCESSIBILITY_TEXT;
            MenuLabel.Text = InfectionStatusViewModel.INFECTION_STATUS_MENU_TEXT;
            MenuLabel.Font = StyleUtil.Font(StyleUtil.FontType.FontRegular, 18f, 18f);
            MenuIcon.SizeToFit();
            StatusText.Font             = StyleUtil.Font(StyleUtil.FontType.FontBold, 16f, 20f);
            OnOffBtn.Font               = StyleUtil.Font(StyleUtil.FontType.FontBold, 22f, 28f);
            OnOffBtn.ContentEdgeInsets  = new UIEdgeInsets(12, 12, 12, 12);
            OnOffBtn.Layer.CornerRadius = 8;

            SetupEncounterAndInfectedButtons();
        }
Пример #24
0
        public void Add(MenuIcon icon, string caption)
        {
            if (count == 5)
            {
                throw new IndexOutOfRangeException("Izvēlnē drīkst būt tikai pieci elementi");
            }
            if (caption == null)
            {
                throw new ArgumentNullException("caption");
            }

            if (!indexes.ContainsKey(icon))
            {
                indexes.Add(icon, count);
            }
            items[count++] = Tuple.Create(icon, caption);
        }
Пример #25
0
    GameObject CreateIcon(Icon icon, Vector2 pos, Vector3 scale)
    {
        GameObject quad = GameObject.CreatePrimitive(PrimitiveType.Quad);

        quad.renderer.material       = icon.mat;
        quad.transform.parent        = transform;
        quad.transform.localPosition = menuOffset;
        quad.name = icon.name;
        if (menuLayout == MenuLayout.Spherical)
        {
            float rotX = pos.x * iconRotation;
            float rotY = pos.y * iconRotation;
            quad.transform.rotation = Quaternion.Euler(new Vector3(rotY, rotX, 0));
            quad.transform.Translate(new Vector3(0, 0, 1), Space.Self);
            quad.transform.LookAt(transform.position + menuOffset);
            quad.transform.Rotate(new Vector3(0, 180, 0));
        }
        else if (menuLayout == MenuLayout.Cylindrical)
        {
            float rotX = pos.x * iconRotation;
            quad.transform.rotation = Quaternion.Euler(new Vector3(0, rotX, 0));
            quad.transform.Translate(new Vector3(0, -pos.y * (iconSize + iconMargin), 1), Space.Self);
            //quad.transform.LookAt (transform.position + menuOffset);
            //quad.transform.Rotate (new Vector3 (0, 180, 0));
        }
        quad.transform.localScale = scale;
        MenuIcon mi = quad.AddComponent <MenuIcon>();

        mi.tooltip       = icon.tooltip;
        mi.subMenuPrefab = icon.subMenuPrefab;
        mi.isBackButton  = icon.isBackButton;
        mi.isCloseButton = icon.isCloseButton;
        mi.callback      = icon.callback;
        mi.condition     = icon.condition;
        mi.zOffset       = icon.zOffset;
        mi.parentMenu    = this;

        if (icon.useSecondState)
        {
            GameObject subIcon = CreateIcon(icon.secondState, pos, scale);
            mi.secondState = subIcon;
            subIcon.GetComponent <MenuIcon>().secondState = quad;
            mi.secondState.SetActive(false);
        }
        return(quad);
    }
Пример #26
0
    public void Menu(int n)
    {
        switch (n)
        {
        case 0:
            PlayerInfo.SetActive(true);
            FrontMenu.SetActive(true);
            HelpMenu.SetActive(false);
            LogOffMenu.SetActive(false);
            break;

        case 1:
            PlayerInfo.SetActive(false);
            FrontMenu.SetActive(false);
            HelpMenu.SetActive(true);
            break;

        case 2:
            PlayerInfo.SetActive(false);
            FrontMenu.SetActive(false);
            LogOffMenu.SetActive(true);
            break;

        case 3:
            PlayerMenu.SetActive(true);
            PlayerInfo.SetActive(true);
            FrontMenu.SetActive(true);
            HelpMenu.SetActive(false);
            LogOffMenu.SetActive(false);
            MenuIcon.SetActive(false);
            GameObject.Find("Me").GetComponent <Movement> ().Position(true);

            break;

        case 4:
            GameObject.Find("Me").GetComponent <Movement> ().Position(false);
            PlayerMenu.SetActive(false);
            MenuIcon.SetActive(true);
            break;

        case 5:
            StartCoroutine(Disconnect());
            break;
        }
    }
Пример #27
0
        void SetupStyling()
        {
            NewIndicatorView.Layer.CornerRadius = NewIndicatorView.Layer.Frame.Height / 2;
            ActivityExplainerLbl.Font           = StyleUtil.Font(StyleUtil.FontType.FontMedium, 18, 22);
            ActivityExplainerLbl.Text           = InfectionStatusViewModel.INFECTION_STATUS_ACTIVITY_STATUS_DESCRIPTION_TEXT;
            MenuIcon.AccessibilityLabel         = InfectionStatusViewModel.INFECTION_STATUS_MENU_ACCESSIBILITY_TEXT;
            MenuIcon.TitleEdgeInsets            = new UIEdgeInsets(0, -8, 0, 0);
            MenuIcon.SetTitle(InfectionStatusViewModel.INFECTION_STATUS_MENU_TEXT, UIControlState.Normal);
            MenuIcon.Font = StyleUtil.Font(StyleUtil.FontType.FontRegular, 18f, 18f);
            MenuIcon.SizeToFit();
            StyleUtil.InitLabel(StatusHeader, StyleUtil.FontType.FontBold, InfectionStatusViewModel.INFECTION_STATUS_PAGE_TITLE, 22f, 26f);
            StatusText.Font             = StyleUtil.Font(StyleUtil.FontType.FontRegular, 16f, 20f);
            OnOffBtn.Font               = StyleUtil.Font(StyleUtil.FontType.FontBold, 22f, 28f);
            OnOffBtn.ContentEdgeInsets  = new UIEdgeInsets(12, 12, 12, 12);
            OnOffBtn.Layer.CornerRadius = 8;

            SetupEncounterAndInfectedButtons();
        }
        private void upgradeMenu()
        {
            Building building = selectedTile.GetBuilding();

            MenuIcon speed  = new MenuIcon(Language.Instance.GetString("UpgradeSpeed"), null, Color.Black);
            MenuIcon power  = new MenuIcon(Language.Instance.GetString("UpgradePower"), null, Color.Black);
            MenuIcon cancel = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No), Color.Black);

            List <MenuIcon> menuIcons = new List <MenuIcon>();

            menuIcons.Add(speed);
            menuIcons.Add(power);
            menuIcons.Add(cancel);

            Menu upgradeMenu = new Menu(Globals.MenuLayout.FourMatrix, menuIcons, Language.Instance.GetString("UpgradeMenu"), Color.Black);

            MenuController.LoadMenu(upgradeMenu);
            Recellection.CurrentState = MenuView.Instance;
            MenuIcon chosenMenu = MenuController.GetInput();

            Recellection.CurrentState = WorldView.Instance;
            MenuController.UnloadMenu();

            if (chosenMenu == speed)
            {
                if (!playerInControll.unitAcc.PayAndUpgradeSpeed(building))
                {
                    //SoundsController.playSound("Denied");
                }
            }
            else if (chosenMenu == power)
            {
                if (!playerInControll.unitAcc.PayAndUpgradePower(building))
                {
                    //SoundsController.playSound("Denied");
                }
            }
        }
Пример #29
0
        /// <summary>
        /// Builds a Menu for changing languages and processes the result.
        /// </summary>
        private void ChangeLanguageMenu()
        {
            String[] availableLanguages = Language.Instance.GetAvailableLanguages();

            #if DEBUG
            LoggerFactory.GetLogger().Info("Available Languages:");
            #endif

            Dictionary <MenuIcon, String> languageDic = new Dictionary <MenuIcon, String>();

            foreach (String lang in availableLanguages)
            {
                #if DEBUG
                LoggerFactory.GetLogger().Info(lang);
                #endif

                MenuIcon aLanguage = new MenuIcon(lang);
                languageDic.Add(aLanguage, lang);
            }

            List <MenuIcon> iconList = new List <MenuIcon>(languageDic.Keys);

            MenuIcon cancel = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No));
            iconList.Add(cancel);

            Menu langMenu = new Menu(Globals.MenuLayout.NineMatrix, iconList, Language.Instance.GetString("ChooseLanguage"));

            MenuController.LoadMenu(langMenu);
            Recellection.CurrentState = MenuView.Instance;

            MenuIcon choosenLang = MenuController.GetInput();
            if (choosenLang != cancel)
            {
                Language.Instance.SetLanguage(languageDic[choosenLang]);
                LoggerFactory.GetLogger().Info("Language set to " + languageDic[choosenLang]);
            }
            MenuController.UnloadMenu();
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="previousSelection"></param>
        private void TileMenu()
        {
            MenuIcon moveUnits = new MenuIcon(Language.Instance.GetString("MoveUnits"), null, Color.Black);
            MenuIcon cancel    = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No), Color.Black);

            List <MenuIcon> menuIcons = new List <MenuIcon>();

            if (theWorld.GetMap().GetTile(previousSelection.absPoint).GetUnits(playerInControll).Count > 0)
            {
                // Only show this options if there are units.
                menuIcons.Add(moveUnits);
            }
            menuIcons.Add(cancel);

            Menu buildingMenu = new Menu(Globals.MenuLayout.FourMatrix, menuIcons, Language.Instance.GetString("TileMenu"), Color.Black);

            MenuController.LoadMenu(buildingMenu);
            Recellection.CurrentState = MenuView.Instance;
            MenuIcon choosenMenu = MenuController.GetInput();

            Recellection.CurrentState = WorldView.Instance;
            MenuController.UnloadMenu();

            if (choosenMenu == moveUnits)
            {
                Selection currSel = retrieveSelection();
                if (!(currSel.state == State.TILE || currSel.state == State.BUILDING))
                {
                    return;
                }


                Tile from = theWorld.GetMap().GetTile(previousSelection.absPoint);
                SelectTile(theWorld.GetMap().GetTile(currSel.absPoint));

                UnitController.MoveUnits(playerInControll, from, selectedTile, from.GetUnits().Count);
            }
        }
Пример #31
0
 protected override IDropDownMenuItem AddDropDown(string text, string key, Bitmap icon, PluginIdentity identity, bool isFirst = false)
 {
     if (!isFirst)
     {
         var item = new ParentBarItem(text)
         {
             Padding = new Point(TOOLBAR_ITEM_PADDING_X, TOOLBAR_ITEM_PADDING_Y)
         };
         var menuItem = AddItem(item, identity, key) as IDropDownMenuItem;
         MenuIcon.AssignIcon(menuItem, icon);
         return(menuItem);
     }
     else
     {
         var item = new ToolStripTabItem()
         {
             Text = text, Name = key, Image = icon,
         };
         var menuItem = AddItem(item, identity, key) as IDropDownMenuItem;
         MenuIcon.AssignIcon(menuItem, icon);
         return(menuItem);
     }
 }
Пример #32
0
        private void ChangeDifficultyMenu()
        {
            Dictionary <MenuIcon, String> difficultyDic = new Dictionary <MenuIcon, String>();

            #if DEBUG
            LoggerFactory.GetLogger().Info("Available difficulties:");
            #endif

            foreach (String diff in System.Enum.GetNames(typeof(Globals.Difficulty)))
            {
                #if DEBUG
                LoggerFactory.GetLogger().Info(diff);
                #endif

                MenuIcon aDifficulty = new MenuIcon(diff);
                difficultyDic.Add(aDifficulty, diff);
            }

            List <MenuIcon> iconList = new List <MenuIcon>(difficultyDic.Keys);

            MenuIcon cancel = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No));
            iconList.Add(cancel);

            Menu diffMenu = new Menu(Globals.MenuLayout.FourMatrix, iconList, Language.Instance.GetString("ChooseADifficulty"));

            MenuController.LoadMenu(diffMenu);
            Recellection.CurrentState = MenuView.Instance;

            MenuIcon choosenDiff = MenuController.GetInput();

            if (choosenDiff != cancel)
            {
                GameOptions.Instance.difficulty = (Globals.Difficulty)Enum.Parse(typeof(Globals.Difficulty), difficultyDic[choosenDiff]);
                LoggerFactory.GetLogger().Info("Difficulty set to " + difficultyDic[choosenDiff]);
            }
            MenuController.UnloadMenu();
        }
        /// <summary>
        /// Builds a Menu for changing languages and processes the result.
        /// </summary>
        private void ChangeLanguageMenu()
        {
            String[] availableLanguages = Language.Instance.GetAvailableLanguages();

            #if DEBUG
            LoggerFactory.GetLogger().Info("Available Languages:");
            #endif

            Dictionary<MenuIcon, String> languageDic = new Dictionary<MenuIcon, String>();

            foreach (String lang in availableLanguages)
            {
                #if DEBUG
                LoggerFactory.GetLogger().Info(lang);
                #endif

                MenuIcon aLanguage = new MenuIcon(lang);
                languageDic.Add(aLanguage, lang);
            }

            List<MenuIcon> iconList = new List<MenuIcon>(languageDic.Keys);

            MenuIcon cancel = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No));
            iconList.Add(cancel);

            Menu langMenu = new Menu(Globals.MenuLayout.NineMatrix, iconList, Language.Instance.GetString("ChooseLanguage"));

            MenuController.LoadMenu(langMenu);
            Recellection.CurrentState = MenuView.Instance;

            MenuIcon choosenLang = MenuController.GetInput();
            if (choosenLang != cancel)
            {
                Language.Instance.SetLanguage(languageDic[choosenLang]);
                LoggerFactory.GetLogger().Info("Language set to " + languageDic[choosenLang]);
            }
            MenuController.UnloadMenu();
        }
Пример #34
0
		internal int GetIconIndex(MenuIcon icon) {
			int index;
			if (indexes.TryGetValue(icon, out index)) return index;
			return -1;
		}
        private void ChangeVolumeMenu()
        {
            MenuIcon musicVolumeUp = new MenuIcon(Language.Instance.GetString("MusicVolumeUp"));
            MenuIcon musicVolumeDown = new MenuIcon(Language.Instance.GetString("MusicVolumeDown"));
            MenuIcon sfxVolumeUp = new MenuIcon(Language.Instance.GetString("EffectsVolumeUp"));
            MenuIcon sfxVolumeDown = new MenuIcon(Language.Instance.GetString("EffectsVolumeDown"));
            MenuIcon empty = new MenuIcon("");
            MenuIcon done = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No));

            List<MenuIcon> iconList = new List<MenuIcon>(); ;
            iconList.Add(musicVolumeUp);
            iconList.Add(empty);
            iconList.Add(musicVolumeDown);
            iconList.Add(sfxVolumeUp);
            iconList.Add(sfxVolumeDown);
            iconList.Add(done);

            Menu volumeMenu = new Menu(Globals.MenuLayout.NineMatrix, iconList, "");

            MenuController.LoadMenu(volumeMenu);

            bool notFinished = true;

            while (notFinished)
            {
                MenuIcon response = MenuController.GetInput();

                if (response == musicVolumeUp)
                {
                    if (GameOptions.Instance.musicVolume <= 1.0f)
                    {
                        SoundsController.changeMusicVolume(GameOptions.Instance.musicVolume + 0.1f);
                    }
                }
                else if (response == musicVolumeDown)
                {
                    SoundsController.changeMusicVolume(GameOptions.Instance.musicVolume - 0.1f);
                }
                else if (response == sfxVolumeUp)
                {
                    if (GameOptions.Instance.sfxVolume <= 1.0f)
                    {
                        SoundsController.changeEffectsVolume(GameOptions.Instance.sfxVolume + 0.1f);
                    }
                }
                else if (response == sfxVolumeDown)
                {
                    SoundsController.changeEffectsVolume(GameOptions.Instance.sfxVolume - 0.1f);
                }
                else if (response == done)
                {
                    notFinished = false;
                }
            }
            MenuController.UnloadMenu();
        }
        /// <summary>
        /// Loads the Building menu from a selection.
        /// Must have building on tile.
        /// </summary>
        /// <param name="theSelection"></param>
        private void BuildingMenu()
        {
            World.Map map = theWorld.GetMap();
            Building building = selectedTile.GetBuilding();
            if (building == null || building.owner != playerInControll)
            {
                return;
            }
            int toHeal = Math.Min(building.maxHealth - building.currentHealth, building.units.Count());

            MenuIcon setWeight = new MenuIcon(Language.Instance.GetString("SetWeight"));
            MenuIcon buildCell = new MenuIcon(Language.Instance.GetString("BuildCell"));
            MenuIcon removeCell = new MenuIcon(Language.Instance.GetString("RemoveCell"));
            MenuIcon upgradeUnits = new MenuIcon(Language.Instance.GetString("UpgradeUnits") + " (" + playerInControll.unitAcc.GetUpgradeCost() + ")");
            MenuIcon moveUnits = new MenuIcon(Language.Instance.GetString("MoveUnits"));
            MenuIcon repairCell = new MenuIcon(Language.Instance.GetString("RepairCell") + " (" + toHeal + ")");
            MenuIcon setAggro = new MenuIcon(Language.Instance.GetString("SetAggro"));
            MenuIcon Cancel = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No));

            List<MenuIcon> menuIcons = new List<MenuIcon>();
            menuIcons.Add(setWeight);
            menuIcons.Add(buildCell);
            menuIcons.Add(removeCell);
            menuIcons.Add(upgradeUnits);
            menuIcons.Add(moveUnits);
            menuIcons.Add(repairCell);
            menuIcons.Add(setAggro);
            menuIcons.Add(Cancel);

            Menu buildingMenu = new Menu(Globals.MenuLayout.NineMatrix, menuIcons, Language.Instance.GetString("BuildingMenu"), Color.Black);
            MenuController.LoadMenu(buildingMenu);
            Recellection.CurrentState = MenuView.Instance;
            MenuIcon choosenMenu = MenuController.GetInput();
            Recellection.CurrentState = WorldView.Instance;
            MenuController.UnloadMenu();

            if (choosenMenu.Equals(setWeight))
            {
                GraphController.Instance.SetWeight(building);
            }
            else if (choosenMenu.Equals(buildCell))
            {
                tobii.SetFeedbackColor(Color.DarkGreen);
                Selection destsel;
                do
                {
                    SetConstructionLines(BuildingController.GetValidBuildingInterval(selectedTile.position, theWorld));
                    destsel = retrieveSelection();
                    RemoveconstructionTileLines(BuildingController.GetValidBuildingInterval(selectedTile.position, theWorld));
                }
                while (destsel.state != State.TILE);

                tobii.SetFeedbackColor(Color.White);

                SelectTile(map.GetTile(destsel.absPoint));

                //TODO Add a check to see if the tile is a correct one. The diffrence between the selected tiles coordinates and the source building shall not exceed 3.
                if (selectedTile.GetBuilding() == null)
                {
                    try
                    {
                        BuildingController.ConstructBuilding(playerInControll, selectedTile, building, theWorld);
                        tobii.SetFeedbackColor(Color.White);
                    }
                    catch (BuildingController.BuildingOutOfRangeException)
                    {
                        logger.Debug("Caught BuildingOutOfRangeExcpetion");
                    }
                }
                else
                {
                    //SoundsController.playSound("Denied");
                    tobii.SetFeedbackColor(Color.White);
                    return;
                }
            }
            else if (choosenMenu.Equals(removeCell))
            {
                BuildingController.RemoveBuilding(building);
            }
            else if (choosenMenu.Equals(upgradeUnits))
            {
                upgradeMenu();
            }
            else if (choosenMenu.Equals(moveUnits))
            {
                tobii.SetFeedbackColor(Color.Red);

                Selection destsel = retrieveSelection();
                if (destsel.state == State.BUILDING || destsel.state == State.TILE)
                {
                    Tile selTile = map.GetTile(destsel.absPoint);
                    UnitController.MoveUnits(playerInControll, selectedTile, selTile, building.GetUnits().Count);
                }

                tobii.SetFeedbackColor(Color.White);
            }
            else if (choosenMenu.Equals(repairCell))
            {
                playerInControll.unitAcc.DestroyUnits(building.units, toHeal);
                building.Repair(toHeal);
            }
            else if (choosenMenu.Equals(setAggro))
            {
                building.IsAggressive = !building.IsAggressive;
                building.UpdateAggressiveness(null, new Event<IEnumerable<Unit>>(building.GetUnits(), EventType.ADD));
            }
            else if (choosenMenu.Equals(Cancel))
            {
                return;
            }
            else
            {
                return;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="player"></param>
        public static void ConstructBuilding(Player player, Tile constructTile, Building sourceBuilding, World theWorld)
        {
            logger.Trace("Constructing a building for a player");
            //TODO Somehow present a menu to the player, and then
            //use the information to ADD (not the document) the fromBuilding.

            MenuIcon baseCell = new MenuIcon(Language.Instance.GetString("BaseCell") +
                    " (" + player.unitAcc.CalculateBuildingCostInflation(Globals.BuildingTypes.Base)+")",
                    Recellection.textureMap.GetTexture(Globals.TextureTypes.BaseBuilding), Color.Black);

            MenuIcon resourceCell = new MenuIcon(Language.Instance.GetString("ResourceCell") +
                    " (" + player.unitAcc.CalculateBuildingCostInflation(Globals.BuildingTypes.Resource) + ")",
                    Recellection.textureMap.GetTexture(Globals.TextureTypes.ResourceBuilding), Color.Black);

            MenuIcon defensiveCell = new MenuIcon(Language.Instance.GetString("DefensiveCell") +
                    " (" + player.unitAcc.CalculateBuildingCostInflation(Globals.BuildingTypes.Barrier) + ")",
                    Recellection.textureMap.GetTexture(Globals.TextureTypes.BarrierBuilding), Color.Black);

            MenuIcon aggressiveCell = new MenuIcon(Language.Instance.GetString("AggressiveCell") +
                    " (" + player.unitAcc.CalculateBuildingCostInflation(Globals.BuildingTypes.Aggressive) + ")",
                    Recellection.textureMap.GetTexture(Globals.TextureTypes.AggressiveBuilding), Color.Black);
            MenuIcon cancel = new MenuIcon(Language.Instance.GetString("Cancel"),
                    Recellection.textureMap.GetTexture(Globals.TextureTypes.No));
            List<MenuIcon> menuIcons = new List<MenuIcon>();
            menuIcons.Add(baseCell);
            menuIcons.Add(resourceCell);
            menuIcons.Add(defensiveCell);
            menuIcons.Add(aggressiveCell);
            menuIcons.Add(cancel);
            Menu ConstructBuildingMenu = new Menu(Globals.MenuLayout.NineMatrix, menuIcons, Language.Instance.GetString("ChooseBuilding"), Color.Black);
            MenuController.LoadMenu(ConstructBuildingMenu);
            Recellection.CurrentState = MenuView.Instance;
            Globals.BuildingTypes building;

            MenuIcon choosenMenu = MenuController.GetInput();
            Recellection.CurrentState = WorldView.Instance;
            MenuController.UnloadMenu();
            if (choosenMenu.Equals(baseCell))
            {
                building = Globals.BuildingTypes.Base;
            }
            else if (choosenMenu.Equals(resourceCell))
            {
                building = Globals.BuildingTypes.Resource;
            }
            else if (choosenMenu.Equals(defensiveCell))
            {
                building = Globals.BuildingTypes.Barrier;
            }
            else if (choosenMenu.Equals(aggressiveCell))
            {
                building = Globals.BuildingTypes.Aggressive;
            }
            else
            {
                return;
            }

            // If we have selected a tile, and we can place a building at the selected tile...
            try
            {
                if (!AddBuilding(building, sourceBuilding,
                        constructTile.position, theWorld, player))
                {
                    //SoundsController.playSound("Denied");
                }
            }
            catch (BuildingOutOfRangeException bore)
            {
                throw bore;
            }
        }
Пример #38
0
        private void BuildSubjects()
        {
            for (var cnt = 0; cnt < 16; cnt++)
                _subjects[cnt] = null;

            for (var cnt = 0; cnt < Logic.ScriptVars[(int)ScriptVariableNames.IN_SUBJECT]; cnt++)
            {
                uint res = (uint)_subjectList[(_subjectBar[cnt] & 65535) - BASE_SUBJECT, 0];
                uint frame = (uint)_subjectList[(_subjectBar[cnt] & 65535) - BASE_SUBJECT, 1];
                _subjects[cnt] = new MenuIcon(MENU_BOT, (byte)cnt, res, frame, _screen);
                if (Logic.ScriptVars[(int)ScriptVariableNames.OBJECT_HELD] != 0)
                    _subjects[cnt].SetSelect(_subjectBar[cnt] == Logic.ScriptVars[(int)ScriptVariableNames.OBJECT_HELD]);
                else
                    _subjects[cnt].SetSelect(true);
            }
        }
Пример #39
0
	public MenuIconI NewIcon(int Index)
	{
		MenuIcon Icon = new MenuIcon();
		Icons.Insert(Index, icon);
		return Icon;
	}
        private void upgradeMenu()
        {
            Building building = selectedTile.GetBuilding();

            MenuIcon speed = new MenuIcon(Language.Instance.GetString("UpgradeSpeed"), null, Color.Black);
            MenuIcon power = new MenuIcon(Language.Instance.GetString("UpgradePower"), null, Color.Black);
            MenuIcon cancel = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No), Color.Black);

            List<MenuIcon> menuIcons = new List<MenuIcon>();
            menuIcons.Add(speed);
            menuIcons.Add(power);
            menuIcons.Add(cancel);

            Menu upgradeMenu = new Menu(Globals.MenuLayout.FourMatrix, menuIcons, Language.Instance.GetString("UpgradeMenu"), Color.Black);
            MenuController.LoadMenu(upgradeMenu);
            Recellection.CurrentState = MenuView.Instance;
            MenuIcon chosenMenu = MenuController.GetInput();
            Recellection.CurrentState = WorldView.Instance;
            MenuController.UnloadMenu();

            if (chosenMenu == speed)
            {
                if (!playerInControll.unitAcc.PayAndUpgradeSpeed(building))
                {
                    //SoundsController.playSound("Denied");
                }
            }
            else if (chosenMenu == power)
            {
                if (!playerInControll.unitAcc.PayAndUpgradePower(building))
                {
                    //SoundsController.playSound("Denied");
                }
            }
        }
        private void ChangeDifficultyMenu()
        {
            Dictionary<MenuIcon, String> difficultyDic = new Dictionary<MenuIcon, String>();

            #if DEBUG
            LoggerFactory.GetLogger().Info("Available difficulties:");
            #endif

            foreach(String diff in System.Enum.GetNames(typeof(Globals.Difficulty)))
            {
                #if DEBUG
                LoggerFactory.GetLogger().Info(diff);
                #endif

                MenuIcon aDifficulty = new MenuIcon(diff);
                difficultyDic.Add(aDifficulty, diff);
            }

            List<MenuIcon> iconList = new List<MenuIcon>(difficultyDic.Keys);

            MenuIcon cancel = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No));
            iconList.Add(cancel);

            Menu diffMenu = new Menu(Globals.MenuLayout.FourMatrix, iconList, Language.Instance.GetString("ChooseADifficulty"));

            MenuController.LoadMenu(diffMenu);
            Recellection.CurrentState = MenuView.Instance;

            MenuIcon choosenDiff = MenuController.GetInput();

            if (choosenDiff != cancel)
            {
                GameOptions.Instance.difficulty = (Globals.Difficulty) Enum.Parse(typeof(Globals.Difficulty), difficultyDic[choosenDiff]);
                LoggerFactory.GetLogger().Info("Difficulty set to " + difficultyDic[choosenDiff]);
            }
            MenuController.UnloadMenu();
        }
        public void Run()
        {
            logger.Debug("Initializer is running.");

            #region Build main menu
            MenuIcon newgame = new MenuIcon(Language.Instance.GetString("NewGame"), null, Color.Black);
            MenuIcon options = new MenuIcon(Language.Instance.GetString("Options"), null, Color.Black);
            MenuIcon help = new MenuIcon(Language.Instance.GetString("Help"), null, Color.Black);
            MenuIcon quit = new MenuIcon(Language.Instance.GetString("Quit"), null, Color.Black);

            List<MenuIcon> menuOptions = new List<MenuIcon>();
            menuOptions.Add(newgame);
            menuOptions.Add(options);
            menuOptions.Add(help);
            menuOptions.Add(quit);

            Menu mainMenu = new Menu(Globals.MenuLayout.FourMatrix, menuOptions, "", Color.Black);

            MenuView view = MenuView.Instance;

            // Just to make sure everything is in there...
            new MenuController(TobiiController.GetInstance(this.windowHandle), mainMenu);
            #endregion

            ShowSplashScreen();

            Cue backgroundSound = Sounds.Instance.LoadSound("Menu");
            backgroundSound.Play();

            while(true)
            {
                backgroundSound.Resume();
                Recellection.CurrentState = view;
                logger.Info("Waiting for Tobii input...");
                MenuIcon response = MenuController.GetInput();

                logger.Info("Got input!");

                if (response == newgame)
                {
                    // START THE GAME ALREADY!

                    GameInitializer gameInit = new GameInitializer();
                    backgroundSound.Pause();
                    WorldView.Initiate(gameInit.theWorld);
                    Recellection.CurrentState = WorldView.Instance;// new WorldView(gameInit.theWorld);
                    VictorTurner vt = new VictorTurner(gameInit);
                    vt.Run();
                }
                else if (response == quit)
                {
                    List<MenuIcon> promptOptions = new List<MenuIcon>(2);
                    MenuIcon yes = new MenuIcon(Language.Instance.GetString("Yes"), Recellection.textureMap.GetTexture(Globals.TextureTypes.Yes));
                    MenuIcon no = new MenuIcon(Language.Instance.GetString("No"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No));
                    promptOptions.Add(yes);
                    promptOptions.Add(no);
                    MenuController.LoadMenu(new Menu(Globals.MenuLayout.Prompt, promptOptions, Language.Instance.GetString("AreYouSureYouWantToQuit")));
                    Recellection.CurrentState = MenuView.Instance;

                    if (MenuController.GetInput() == yes)
                    {
                        Environment.Exit(0);
                    }

                    MenuController.UnloadMenu();
                }
                else if (response == options)
                {
                    Configurator.Instance.ChangeOptions();
                }
                else if (response == help)
                {
                    List<MenuIcon> opt = new List<MenuIcon>(1);
                    MenuIcon cancel = new MenuIcon("");
                    cancel.region = new GUIRegion(Recellection.windowHandle,
                        new System.Windows.Rect(0, Globals.VIEWPORT_HEIGHT - 100, Globals.VIEWPORT_WIDTH, 100));
                    opt.Add(cancel);
                    Menu menu = new Menu(opt);
                    MenuController.LoadMenu(menu);

                    Recellection.CurrentState = new HelpView();

                    MenuController.GetInput();

                    MenuController.UnloadMenu();
                }
                else
                {
                    Recellection.playBeethoven();
                }
            }
        }
Пример #43
0
        void ReleaseDesignerOutlets()
        {
            if (BottomConstraint != null)
            {
                BottomConstraint.Dispose();
                BottomConstraint = null;
            }

            if (ChatEditMessage != null)
            {
                ChatEditMessage.Dispose();
                ChatEditMessage = null;
            }

            if (ChatEditMessageContainer != null)
            {
                ChatEditMessageContainer.Dispose();
                ChatEditMessageContainer = null;
            }

            if (ChatMessageWindow != null)
            {
                ChatMessageWindow.Dispose();
                ChatMessageWindow = null;
            }

            if (ChatOneBack != null)
            {
                ChatOneBack.Dispose();
                ChatOneBack = null;
            }

            if (ChatOneLeftConstraint != null)
            {
                ChatOneLeftConstraint.Dispose();
                ChatOneLeftConstraint = null;
            }

            if (ChatOneRightConstraint != null)
            {
                ChatOneRightConstraint.Dispose();
                ChatOneRightConstraint = null;
            }

            if (ChatSendMessage != null)
            {
                ChatSendMessage.Dispose();
                ChatSendMessage = null;
            }

            if (ChatTargetImage != null)
            {
                ChatTargetImage.Dispose();
                ChatTargetImage = null;
            }

            if (ChatViewProfile != null)
            {
                ChatViewProfile.Dispose();
                ChatViewProfile = null;
            }

            if (MatchDate != null)
            {
                MatchDate.Dispose();
                MatchDate = null;
            }

            if (MenuBlock != null)
            {
                MenuBlock.Dispose();
                MenuBlock = null;
            }

            if (MenuContainer != null)
            {
                MenuContainer.Dispose();
                MenuContainer = null;
            }

            if (MenuFriend != null)
            {
                MenuFriend.Dispose();
                MenuFriend = null;
            }

            if (MenuIcon != null)
            {
                MenuIcon.Dispose();
                MenuIcon = null;
            }

            if (MenuLayer != null)
            {
                MenuLayer.Dispose();
                MenuLayer = null;
            }

            if (MenuLocationUpdates != null)
            {
                MenuLocationUpdates.Dispose();
                MenuLocationUpdates = null;
            }

            if (MenuReport != null)
            {
                MenuReport.Dispose();
                MenuReport = null;
            }

            if (MenuUnmatch != null)
            {
                MenuUnmatch.Dispose();
                MenuUnmatch = null;
            }

            if (NoMessages != null)
            {
                NoMessages.Dispose();
                NoMessages = null;
            }

            if (RoundBottom != null)
            {
                RoundBottom.Dispose();
                RoundBottom = null;
            }

            if (Snackbar != null)
            {
                Snackbar.Dispose();
                Snackbar = null;
            }

            if (SnackBottomConstraint != null)
            {
                SnackBottomConstraint.Dispose();
                SnackBottomConstraint = null;
            }

            if (SnackTopConstraint != null)
            {
                SnackTopConstraint.Dispose();
                SnackTopConstraint = null;
            }

            if (TargetName != null)
            {
                TargetName.Dispose();
                TargetName = null;
            }

            if (UnmatchDate != null)
            {
                UnmatchDate.Dispose();
                UnmatchDate = null;
            }
        }
Пример #44
0
	public MenuIconI NewIcon()
	{
		MenuIcon icon = new MenuIcon();
		Icons.Add(icon);
		return icon;
	}
        /// <summary>
        /// 
        /// </summary>
        /// <param name="previousSelection"></param>
        private void TileMenu()
        {
            MenuIcon moveUnits = new MenuIcon(Language.Instance.GetString("MoveUnits"), null, Color.Black);
            MenuIcon cancel = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No), Color.Black);

            List<MenuIcon> menuIcons = new List<MenuIcon>();
            if (theWorld.GetMap().GetTile(previousSelection.absPoint).GetUnits(playerInControll).Count > 0)
            {
                // Only show this options if there are units.
                menuIcons.Add(moveUnits);
            }
            menuIcons.Add(cancel);

            Menu buildingMenu = new Menu(Globals.MenuLayout.FourMatrix, menuIcons, Language.Instance.GetString("TileMenu"), Color.Black);
            MenuController.LoadMenu(buildingMenu);
            Recellection.CurrentState = MenuView.Instance;
            MenuIcon choosenMenu = MenuController.GetInput();
            Recellection.CurrentState = WorldView.Instance;
            MenuController.UnloadMenu();

            if (choosenMenu == moveUnits)
            {
                Selection currSel = retrieveSelection();
                if (! (currSel.state == State.TILE || currSel.state == State.BUILDING))
                {
                    return;
                }

                Tile from = theWorld.GetMap().GetTile(previousSelection.absPoint);
                SelectTile(theWorld.GetMap().GetTile(currSel.absPoint));

                UnitController.MoveUnits(playerInControll, from, selectedTile, from.GetUnits().Count);
            }
        }
Пример #46
0
        private void BuildMenu()
        {
            for (var cnt = 0; cnt < _inMenu; cnt++)
                _objects[cnt] = null;

            _inMenu = 0;
            for (var pocketNo = 0; pocketNo < TOTAL_pockets; pocketNo++)
            {
                if (Logic.ScriptVars[(int)(ScriptVariableNames.POCKET_1 + pocketNo)] != 0)
                {
                    _menuList[_inMenu] = (uint)(pocketNo + 1);
                    _inMenu++;
                }
            }

            for (var menuSlot = 0; menuSlot < _inMenu; menuSlot++)
            {
                _objects[menuSlot] = new MenuIcon(MENU_TOP, (byte)menuSlot, (uint) _objectDefs[_menuList[menuSlot],MenuObject.bigIconRes], (uint) _objectDefs[_menuList[menuSlot], MenuObject.bigIconFrame], _screen);
                uint objHeld = Logic.ScriptVars[(int)ScriptVariableNames.OBJECT_HELD];

                // check highlighting
                if (Logic.ScriptVars[(int)ScriptVariableNames.MENU_LOOKING] != 0 || _subjectBarStatus == MenuState.MENU_OPEN)
                { // either we're in the chooser or we're doing a 'LOOK AT'
                    if ((objHeld == 0) || (objHeld == _menuList[menuSlot]))
                        _objects[menuSlot].SetSelect(true);
                }
                else if (Logic.ScriptVars[(int)ScriptVariableNames.SECOND_ITEM] != 0)
                { // clicked luggage onto 2nd icon - we need to color-highlight the 2 relevant icons & grey out the rest
                    if ((_menuList[menuSlot] == objHeld) || (_menuList[menuSlot] == Logic.ScriptVars[(int)ScriptVariableNames.SECOND_ITEM]))
                        _objects[menuSlot].SetSelect(true);
                }
                else
                { // this object is selected - ie. GREYED OUT
                    if (objHeld != _menuList[menuSlot])
                        _objects[menuSlot].SetSelect(true);
                }
            }
        }
        private void GameMenu()
        {
            MenuIcon endTurn = new MenuIcon(Language.Instance.GetString("EndTurn"));
            MenuIcon endGame = new MenuIcon(Language.Instance.GetString("EndGame"));
            MenuIcon cancel = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No));

            List<MenuIcon> options = new List<MenuIcon>(4);
            options.Add(endTurn);
            options.Add(endGame);
            options.Add(cancel);

            Menu menu = new Menu(Globals.MenuLayout.FourMatrix, options, "");
            MenuController.LoadMenu(menu);

            bool done = false;
            while(! done)
            {
                Recellection.CurrentState = MenuView.Instance;
                MenuIcon input = MenuController.GetInput();
                if (input == endTurn)
                {
                    finished = true;
                    break;
                }
                else if (input == endGame)
                {
                    List<MenuIcon> promptOptions = new List<MenuIcon>(2);
                    MenuIcon yes = new MenuIcon(Language.Instance.GetString("Yes"), Recellection.textureMap.GetTexture(Globals.TextureTypes.Yes));
                    MenuIcon no = new MenuIcon(Language.Instance.GetString("No"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No));
                    promptOptions.Add(yes);
                    promptOptions.Add(no);
                    MenuController.LoadMenu(new Menu(Globals.MenuLayout.Prompt, promptOptions, Language.Instance.GetString("AreYouSureYouWantToEndTheGame")));
                    MenuIcon inp = MenuController.GetInput();
                    MenuController.UnloadMenu();

                    if (inp == yes)
                    {
                        // This should make the player lose :D
                        List<Building> buildingsToRemove = new List<Building>();
                        foreach(Graph g in playerInControll.GetGraphs())
                        {
                            foreach(Building b in g.GetBuildings())
                            {
                                buildingsToRemove.Add(b);
                            }
                        }
                        foreach(Building b in buildingsToRemove)
                        {
                            BuildingController.RemoveBuilding(b);
                        }
                        finished = true;
                        break;
                    }
                }
                else if (input == cancel)
                {
                    break;
                }
            }
            Recellection.CurrentState = WorldView.Instance;
            MenuController.UnloadMenu();
        }
        private void createGUIRegionGridAndScrollZone()
        {
            int numOfRows = (int)(Recellection.viewPort.Height / Globals.TILE_SIZE) - 2;
            int numOfCols = (int)(Recellection.viewPort.Width / Globals.TILE_SIZE) - 2;

            menuMatrix = new MenuIcon[numOfCols, numOfRows];

            scrollZone = new List<MenuIcon>();

            //This will create a matrix with menuIcons, ignoring the ones
            //closest to the edge.
            for (int x = 0; x < numOfCols; x++)
            {
                for (int y = 0; y < numOfRows; y++)
                {
                    menuMatrix[x, y] = new MenuIcon("" + (x + 1) + "_" + (y + 1), null, Color.NavajoWhite);

                    //Should not need a targetRectangle.
                    /*menuMatrix[x, y].targetRectangle = new Microsoft.Xna.Framework.Rectangle(
                        x * Globals.TILE_SIZE, y * Globals.TILE_SIZE, Globals.TILE_SIZE, Globals.TILE_SIZE);
                    */
                    //x + 1 and y + 1 should make them not be placed at the edge.
                    menuMatrix[x, y].region = new GUIRegion(Recellection.windowHandle,
                        new System.Windows.Rect((x + 1) * Globals.TILE_SIZE, (y + 1) * Globals.TILE_SIZE, Globals.TILE_SIZE, Globals.TILE_SIZE));
                }

            }
            /*
             * The following code creates the scroll zones with this pattern:
             * 1 2 2 2 2 3
             * 4         5
             * 4         5
             * 4         5
             * 6 7 7 7 7 8
             *
             * A number indicates wich index it has in the list, the label describes its position
             */

            #region UglyCode
            int windowWidth = Recellection.viewPort.Width;
            int windowHeight = Recellection.viewPort.Height;
            //Will code the scroll zones in one line.

            //First is a tile sized square top left on the screen.
            scrollZone.Add(new MenuIcon("-1_-1", null, Color.Chocolate));

            scrollZone[0].region = new GUIRegion(Recellection.windowHandle, new System.Windows.Rect(0, 0, Globals.TILE_SIZE, Globals.TILE_SIZE));
            scrollZone[0].region.DwellTime = new TimeSpan(SCROLL_ZONE_DWELL_TIME);
            scrollZone[0].region.HideFeedbackIndicator = true;

            //Second is a laying rectangle spanning the screen width minus two tile widths.
            scrollZone.Add(new MenuIcon("0_-1", null, Color.Chocolate));

            scrollZone[1].region = new GUIRegion(Recellection.windowHandle, new System.Windows.Rect(Globals.TILE_SIZE, 0, windowWidth - Globals.TILE_SIZE * 2, Globals.TILE_SIZE));
            scrollZone[1].region.DwellTime = new TimeSpan(SCROLL_ZONE_DWELL_TIME);
            scrollZone[1].region.HideFeedbackIndicator = true;

            //Third is like the first but placed to the far right.
            scrollZone.Add(new MenuIcon("1_-1", null, Color.Chocolate));

            scrollZone[2].region = new GUIRegion(Recellection.windowHandle, new System.Windows.Rect(windowWidth - Globals.TILE_SIZE, 0, Globals.TILE_SIZE, Globals.TILE_SIZE));
            scrollZone[2].region.DwellTime = new TimeSpan(SCROLL_ZONE_DWELL_TIME);
            scrollZone[2].region.HideFeedbackIndicator = true;

            //Fourth is a standing rectangle at the left side of the screen, its height is screen height minus two tile heights.
            scrollZone.Add(new MenuIcon("-1_0", null, Color.Chocolate));

            scrollZone[3].region = new GUIRegion(Recellection.windowHandle, new System.Windows.Rect(0, Globals.TILE_SIZE, Globals.TILE_SIZE, windowHeight - Globals.TILE_SIZE * 2));
            scrollZone[3].region.DwellTime = new TimeSpan(SCROLL_ZONE_DWELL_TIME);
            scrollZone[3].region.HideFeedbackIndicator = true;

            //Fift is the same as the right but placed at the right side of the screen.
            scrollZone.Add(new MenuIcon("1_0", null, Color.Chocolate));

            scrollZone[4].region = new GUIRegion(Recellection.windowHandle, new System.Windows.Rect(windowWidth - Globals.TILE_SIZE, Globals.TILE_SIZE, Globals.TILE_SIZE, windowHeight - Globals.TILE_SIZE * 2));
            scrollZone[4].region.DwellTime = new TimeSpan(SCROLL_ZONE_DWELL_TIME);
            scrollZone[4].region.HideFeedbackIndicator = true;

            //Like the first but at the bottom
            scrollZone.Add(new MenuIcon("-1_1", null, Color.Chocolate));

            scrollZone[5].region = new GUIRegion(Recellection.windowHandle, new System.Windows.Rect(0, windowHeight - Globals.TILE_SIZE, Globals.TILE_SIZE, Globals.TILE_SIZE));
            scrollZone[5].region.DwellTime = new TimeSpan(SCROLL_ZONE_DWELL_TIME);
            scrollZone[5].region.HideFeedbackIndicator = true;
            //Like the second but at the bottom
            scrollZone.Add(new MenuIcon("0_1", null, Color.Chocolate));

            scrollZone[6].region = new GUIRegion(Recellection.windowHandle, new System.Windows.Rect(Globals.TILE_SIZE, windowHeight - Globals.TILE_SIZE, windowWidth - Globals.TILE_SIZE * 2, Globals.TILE_SIZE));
            scrollZone[6].region.DwellTime = new TimeSpan(SCROLL_ZONE_DWELL_TIME);
            scrollZone[6].region.HideFeedbackIndicator = true;

            //Like the third but at the bottom
            scrollZone.Add(new MenuIcon("1_1", null, Color.Chocolate));

            scrollZone[7].region = new GUIRegion(Recellection.windowHandle, new System.Windows.Rect(windowWidth - Globals.TILE_SIZE, windowHeight - Globals.TILE_SIZE, Globals.TILE_SIZE, Globals.TILE_SIZE));
            scrollZone[7].region.DwellTime = new TimeSpan(SCROLL_ZONE_DWELL_TIME);
            scrollZone[7].region.HideFeedbackIndicator = true;

            #endregion

            List<MenuIcon> allMenuIcons = new List<MenuIcon>();

            foreach (MenuIcon mi in menuMatrix)
            {
                allMenuIcons.Add(mi);
            }
            foreach (MenuIcon mi in scrollZone)
            {
                allMenuIcons.Add(mi);
            }
            //here be offscreen regions!
            leftOff = new MenuIcon(new GUIRegion(IntPtr.Zero, new System.Windows.Rect(-700, 0, 700, Globals.VIEWPORT_HEIGHT)));
            rightOff = new MenuIcon(new GUIRegion(IntPtr.Zero, new System.Windows.Rect(Globals.VIEWPORT_WIDTH, 0, 700, Globals.VIEWPORT_HEIGHT)));
            topOff = new MenuIcon(new GUIRegion(IntPtr.Zero, new System.Windows.Rect(0, Globals.VIEWPORT_HEIGHT, Globals.VIEWPORT_WIDTH, 700)));
            botOff = new MenuIcon(new GUIRegion(IntPtr.Zero, new System.Windows.Rect(0, -700, Globals.VIEWPORT_WIDTH, 700)));
            MenuController.LoadMenu(new Menu(allMenuIcons, leftOff, rightOff, topOff, botOff));
            MenuController.DisableMenuInput();
        }
        private void EndGame(Player winner)
        {
            if (backgroundSound.IsPlaying)
            {
                backgroundSound.Pause();
            }

            humanControl.Stop();

            // Build menu

            List<MenuIcon> options = new List<MenuIcon>(1);
            MenuIcon cancel = new MenuIcon("");
            cancel.region = new GUIRegion(Recellection.windowHandle,
                new System.Windows.Rect(0, Globals.VIEWPORT_HEIGHT - 100, Globals.VIEWPORT_WIDTH, 100));
            options.Add(cancel);
            Menu menu = new Menu(options);
            MenuController.LoadMenu(menu);

            Recellection.CurrentState = new EndGameView(! (winner is AIPlayer));

            MenuController.GetInput();

            MenuController.UnloadMenu();
        }