示例#1
0
        public static async Task <bool> WaitForSingleButtonInfoBarAsync(InfoBar infoBar)
        {
            if (infoBar.ActionItems.Count != 1)
            {
                throw new ArgumentException($"{nameof(infoBar)} has more than one button element");
            }

            var completionSource = new TaskCompletionSource <bool>();

            var button = (InfoBarButton)infoBar.ActionItems.GetItem(0);

            button.OnClick += (source, e) =>
            {
                completionSource.SetResult(true);
                e.InfoBarUIElement.Close();
            };

            infoBar.OnClosed += () =>
            {
                completionSource.TrySetResult(false);
            };

            await VsUtilities.ShowInfoBar(infoBar);

            return(await completionSource.Task);
        }
示例#2
0
 // Use this for initialization
 void Start()
 {
     //UserData.ResetUserData();
     m_BG           = GetComponent <BoxGenerator>();
     m_InfoBar      = GameObject.FindGameObjectWithTag("InfoBar").GetComponent <InfoBar>();
     m_ConfirmPanel = GameObject.Find("ConfirmPanel").GetComponentInChildren <ConfirmPanel>();
 }
示例#3
0
        public InfoBarPage CloseClosableBarWithOptions()
        {
            InfoBar closeableBarWithOpts = this.WindowsApp.FindElement(this.closableBarWithOptsQuery);

            closeableBarWithOpts.Close();
            return(this);
        }
示例#4
0
        private bool GetFiles()
        {
            string MediaDirectory = AppSettings.Default.CurrentDirectory;

            index = 0;
            if (Directory.Exists(MediaDirectory))
            {
                DirectoryInfo dirInfo = new DirectoryInfo(MediaDirectory);

                fileList = Helpers.GetFilesByExtensions(dirInfo, ".jpg", ".jpeg", ".png",
                                                        ".bmp", ".mov", ".mpg", ".avi", ".mkv", ".mpeg", ".mp4").ToArray();

                if (AppSettings.Default.Shuffle)
                {
                    Random r = new Random((int)DateTime.Now.Ticks);
                    fileList = Helpers.Shuffle <string>(fileList.ToList(), r).ToArray();
                }
                return(true);
            }
            else
            {
                tb.Text = "No images found! current directory is: " + MediaDirectory;
                Console.WriteLine("Error! No images found!");
                infoBar = InfoBar.Error;
                return(false);
            }
        }
示例#5
0
 void OnMouseOver()
 {
     if ((active) && (character != null))
     {
         if (Info != null)
         {
             Info.delete = false;
         }
         if (controller.infoBar == null)
         {
             controller.infoBar = Instantiate(controller.InfoBarPref, transform.position, transform.rotation);
             Info      = controller.infoBar.GetComponent <InfoBar>();
             Info.text = Information.GetSpellInfo(spell.Name, character.SpellLevel[num], character.power);
             foreach (var x in spell.statusName)
             {
                 Info.text += '\n' + Information.GetEffectInfo(x, character.SpellLevel[num], character.power);
             }
             Info.text += $"\n\n<b>Перезарядка:</b> {spell.reloadtime}";
             //Info.text += $"\n<b> Уровень:</ b > { spell.level + 1}";
         }
         if (Input.GetMouseButtonDown(0) && Time.timeScale != 0 && fightController.lvl == null)
         {
             UseSpell();
         }
     }
 }
示例#6
0
 private void InfoBarLoginHint_OnCloseButtonClick(InfoBar sender, object args)
 {
     if (Common.Logined)
     {
         DialogLogin.Hide();
     }
 }
示例#7
0
 private void Awake()
 {
     _infoBar        = FindObjectOfType <InfoBar>();
     _playerControls = GameObject.Find("GameManager").GetComponent <PlayerControls>();
     _photonView     = GetComponent <PhotonView>();
     _playerGang     = GetComponent <PlayerGang>();
     _fogOfWar       = FindObjectOfType <FogOfWar>();
 }
示例#8
0
        private static async Task ShowInfoBarAsync(ExceptionalConditions conditions)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            InfoBar.CreateInfoBarsForExceptionalConditionsAsync(conditions).FileAndForget(FileAndForgetEventName.InfoBarOpenFailure);

            // After Sarif results loaded to Error List, make sure Viewer package is loaded
            SarifViewerPackage.LoadViewerPackage();
        }
示例#9
0
        public async Task MinifyFileAsync(MinifiedFile minifiedFile)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            var root = Path.GetDirectoryName(Solution.GetFullName());

            var destinationFile = minifiedFile.GetFullOutputPath(root);

            if (!File.Exists(destinationFile))
            {
                InfoBar.NewMessage()
                .WithErrorImage()
                .WithText("The path ")
                .WithText(minifiedFile.OutputFile, underline: true)
                .WithText(" is not valid.")
                .Publish();

                return;
            }

            MinifyResult result = null;

            switch (minifiedFile.MinifyType)
            {
            case MinifyType.CSHtml:
                result = await CSHtmlMinifier.MinifyFileAsync(minifiedFile.GetFullSourcePath(root), destinationFile, ((CsHtmlMinifiedFile)minifiedFile).UsePreMailer);

                break;

            case MinifyType.Js:
                if (!await JsMinifier.TryMinifyFileAsync("esbuild.exe", minifiedFile.GetFullSourcePath(root), destinationFile, ((JsMinifiedFile)minifiedFile).Options))
                {
                    InfoBar.NewMessage()
                    .WithErrorImage()
                    .WithText("The file ")
                    .WithText(minifiedFile.SourceFile, underline: true)
                    .WithText(" contains invalid js.")
                    .Publish();
                }
                break;

            default:
                throw new InvalidOperationException("Please create an issue on GitHub, if this throws.");
            }

            if (result is object && !result.Success)
            {
                InfoBar.NewMessage()
                .WithErrorImage()
                .WithText("The file ")
                .WithText(minifiedFile.SourceFile, underline: true)
                .WithText(" produced warnings. ")
                .WithText(result.Message)
                .Publish();
            }
        }
示例#10
0
        public bool TryUpdateConfigFile(string fullName, bool showMessageOnError = true)
        {
            var root = Path.GetDirectoryName(Solution.GetFullName());

            UserSettings settings = null;

            try
            {
                var content = File.ReadAllText(fullName);

                // Updates older config files.
                content = content.Replace("\"Files\"", "\"CSHtmlFiles\"");

                settings = JsonConvert.DeserializeObject <UserSettings>(content);

                settings.CSHtmlFiles = settings.CSHtmlFiles ?? new List <CsHtmlMinifiedFile>();
                settings.JsFiles     = settings.JsFiles ?? new List <JsMinifiedFile>();

                foreach (var file in settings.CSHtmlFiles.Cast <MinifiedFile>().Union(settings.JsFiles))
                {
                    var isSourceValid = File.Exists(file.GetFullSourcePath(root));
                    var isOutputValid = File.Exists(file.GetFullOutputPath(root));

                    if (!isSourceValid || !isOutputValid)
                    {
                        InfoBar.NewMessage()
                        .WithErrorImage()
                        .WithText("The path ")
                        .WithText(isSourceValid ? file.OutputFile : file.SourceFile, underline: true)
                        .WithText(" is not valid.")
                        .Publish();

                        return(false);
                    }
                }
            }
            catch
            {
                if (showMessageOnError)
                {
                    InfoBar.NewMessage()
                    .WithErrorImage()
                    .WithText("The content of your ")
                    .WithText(RazorMinifier.ConfigName, true)
                    .WithText(" contains invalid json.")
                    .Publish();
                }

                return(false);
            }

            Config.UserSettings = settings;

            return(true);
        }
示例#11
0
        /// <summary>
        /// Secondary 'clock' loop. Mainly controls the secondary UI for now.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Clock_Elapsed(object sender, ElapsedEventArgs e)
        {
            Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(() =>
            {
                switch (infoBar)
                {
                case (InfoBar.Clock):
                    {
                        tb.Text = DateTime.Now.ToString(AppSettings.Default.TimeFormat);
                        break;
                    }

                case (InfoBar.Error):
                    {
                        tb.Text       = "Error! Please check your appsettings.json!";
                        tb.FontSize   = 75;
                        tb.Foreground = Brushes.Red;
                        break;
                    }

                case (InfoBar.FileInfo):
                    {
                        tb.Text = AppSettings.Default.Shuffle.ToString();
                        break;
                    }

                case (InfoBar.IP):
                    {
                        numberOfTimes++;

                        tb.Text = Helpers.GetIPString();
                        if (numberOfTimes > NumberOfSecondsToShowIP)
                        {
                            infoBar = InfoBar.Clock;
                        }
                        break;
                    }

                default:
                    {
                        tb.Text = "";
                        break;
                    }
                }
            });

            // NOTE: We update this here in case a bad value gets put into the app settings
            // We only try to update it if it's changed. Setting that to a bad value can be catastrophic.
            // May consider limiting the values in the future.
            if (slideTimer.Interval != AppSettings.Default.SlideshowTransitionTime)
            {
                slideTimer.Interval = AppSettings.Default.SlideshowTransitionTime;
                Timer_Tick(null, null);
            }
        }
示例#12
0
    void Start()
    {
        fireAmmunition = GameObject.Find(NameContainer.PLAYER).gameObject.GetComponentInChildren <FireAmmunition>();

        GameObject _fireForceBar = GameObject.Find(NameContainer.FIRE_FORCE_BAR);

        if (null != _fireForceBar)
        {
            fireForceBar = _fireForceBar.GetComponent <InfoBar>();
        }
    }
示例#13
0
    // Use this for initialization
    public void Start()
    {
        playerMovement = GameObject.Find(NameContainer.PLAYER).GetComponentInChildren <PlayerMovement>();

        GameObject _breakBar = GameObject.Find(NameContainer.BREAK_BAR);

        // TODO this is to avoid null reference errors. Probably scene objects should be retrieved by one separate object that would provide some proxies in case elements are not on stage?
        if (null != _breakBar)
        {
            breakBar = _breakBar.GetComponent <InfoBar>();
        }
    }
        private static void ErrorListService_LogProcessed(object sender, LogProcessedEventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (!SarifViewerPackage.IsUnitTesting)
            {
                InfoBar.CreateInfoBarsForExceptionalConditionsAsync(e.ExceptionalConditions).FileAndForget(FileAndForgetEventName.InfoBarOpenFailure);

                // After Sarif results loaded to Error List, make sure Viewer package is loaded
                SarifViewerPackage.LoadViewerPackage();
            }
        }
 void OnMouseOver()
 {
     if (info != null)
     {
         info.delete = false;
     }
     if (controller.infoBar == null)
     {
         controller.infoBar = Instantiate(controller.InfoBarPref, transform.position, transform.rotation);
         info      = controller.infoBar.GetComponent <InfoBar>();
         info.text = text;
     }
 }
示例#16
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            UI.Init(new Vector2(width, height), new TextFont(Content, "Font/"));
            UI.AddInterface("Interface1");
            tbInfo     = new Label(null, "Item Name", 14, TextOrientation.Left, new Vector2(100, 75), new Vector2(250, 25), Color.Black, Color.Transparent);
            tb         = new TextBox(null, "", 14, 30, new Vector2(100, 100), new Vector2(250, 25), null, null, null, null);
            addButton  = new Button(null, "Add Item", 14, TextOrientation.Left, new Vector2(100, 150), new Vector2(100, 25));
            remButton  = new Button(null, "Remove Item", 14, TextOrientation.Left, new Vector2(225, 150), new Vector2(125, 25));
            lb         = new ListBox(null, 14, TextOrientation.Left, new Vector2(100, 200), new Vector2(250, 500), null, null, null, null);
            pbProgress = new ProgressBar(null, new Vector2(400, 200), new Vector2(100, 25), 0, 100, 75, 14, false, null, null, null, null);
            sSlider    = new Slider(null, new Vector2(400, 250), new Vector2(100, 25), 50, 1, 0, 100, 14, TextOrientation.Center, null, null, true, true, true);
            ibMenu     = new InfoBar(null);

            ibMenu.AddElement("File");
            ibMenu.AddElement("Edit");
            Window window = new Window(null, null, "Stuff", TextOrientation.Left, Vector2.Zero, new Vector2(200), true, true, true, true);

            window.Open(new Vector2(100, 100));

            addButton.Disable();
            remButton.Disable();
            lb.SelectedItemCountChanged += (sender) => { if (lb.Count > 0 && lb.SelectedItems.Count > 0)
                                                         {
                                                             remButton.Enable();
                                                         }
                                                         else
                                                         {
                                                             remButton.Disable();
                                                         } };
            tb.TextChanged += (sender) => { if (tb.Text != "")
                                            {
                                                addButton.Enable();
                                            }
                                            else
                                            {
                                                addButton.Disable();
                                            } };
            tb.EnterPressed += (sender) => { if (tb.Text != "")
                                             {
                                                 lb.AddItem(tb.Text); tb.Clear();
                                             }
            };

            lb.TransferToFront();

            addButton.Clicked += (sender) => { lb.AddItem(tb.Text); tb.Clear(); };
            remButton.Clicked += (sender) => { lb.RemoveSelectedItems(); };
        }
示例#17
0
        public ScintillaControlHandler()
        {
            nativecontrol = new ScintillaView();

            SetStyle();

            var infobar = new InfoBar();

            infobar.Bounds = new CoreGraphics.CGRect(0, 0, 400, 0);
            infobar.SetDisplay(IBDisplay.All);

            nativecontrol.SetInfoBar(infobar, false);

            this.Control = nativecontrol;
        }
示例#18
0
        public void GetData(CrmServiceClient client, InfoBar infoBar)
        {
            if (CrmMetadata.Metadata != null)
            {
                infoBar.HideInfoBar();
                return;
            }

            var bgw = new BackgroundWorker();

            bgw.DoWork += (_, __) => CrmMetadata.GetMetadata(client);

            bgw.RunWorkerCompleted += (_, __) => infoBar.HideInfoBar();

            bgw.RunWorkerAsync();
        }
示例#19
0
 public void OnMouseOver()
 {
     if (Info != null)
     {
         Info.delete = false;
     }
     if (controller.infoBar == null)
     {
         controller.infoBar = Instantiate(controller.InfoBarPref, transform.position, transform.rotation);
         Info      = controller.infoBar.GetComponent <InfoBar>();
         Info.text = Information.GetEffectInfo(Name, level, power);
         if (Time.timeScale == 0f)
         {
             Info.text += $"\n\n<color=\"green\"><b>Осталось:</b> {Mathf.Ceil(lifetime*10)/10} сек.<color=\"white\">";
         }
     }
 }
        /// <summary>
        /// Handles the UserDialog event of the learnlogic control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MLifter.BusinessLayer.UserDialogEventArgs"/> instance containing the event data.</param>
        /// <remarks>Documented by Dev02, 2008-05-21</remarks>
        void learnlogic_UserDialog(object sender, UserDialogEventArgs e)
        {
            if (e is UserNotifyDialogEventArgs)
            {
                UserNotifyDialogEventArgs args = (UserNotifyDialogEventArgs)e;
                string message = string.Empty;
                bool   dontShowAgainMessage = false;
                switch (args.dialogkind)
                {
                case UserNotifyDialogEventArgs.NotifyDialogKind.PoolEmpty:
                    message = Properties.Resources.POOL_EMPTY_TEXT;
                    break;

                case UserNotifyDialogEventArgs.NotifyDialogKind.NotEnoughMultipleChoices:
                    message = string.Format(Properties.Resources.MULTIPLE_CHOICE_TEXT, e.dictionary.Settings.MultipleChoiceOptions.NumberOfChoices.Value);
                    break;

                case UserNotifyDialogEventArgs.NotifyDialogKind.SelectedLearnModeNotAllowed:
                    if (Settings.Default.DontShowSelectedLearnModeNotAllowedMessage)
                    {
                        break;
                    }

                    dontShowAgainMessage = true;
                    //[ML-2115] LearnModes for Infobar not localized
                    message = string.Format(Properties.Resources.SELECTED_LEARNMODE_NOT_ALLOWED,
                                            (e.OptionalParamter is MLifter.BusinessLayer.LearnModes) ? Resources.ResourceManager.GetString("LEARNING_MODE_" + e.OptionalParamter.ToString().ToUpper()) : e.OptionalParamter);
                    break;

                case UserNotifyDialogEventArgs.NotifyDialogKind.NoWords:
                    //gets displayed in UserDialogComponent
                    break;

                default:
                    break;
                }

                if (!string.IsNullOrEmpty(message))
                {
                    InfoBar infobar;
                    infobar = new InfoBar(message, answerPanel.InfoBarControl, DockStyle.Top, true, dontShowAgainMessage, answerPanel.AdditionalInfoBarSuspendControl);
                    infobar.DontShowAgainChanged += new EventHandler(infobar_DontShowAgainChanged);
                }
            }
        }
    // Use this for initialization
    void Start()
    {
        m_State   = BoxState.FALL;
        m_CurTime = 0;
        GameObject gc = GameObject.FindGameObjectWithTag("GameController");

        m_BG = gc.GetComponent <BoxGenerator>();

        m_SkillBt = GetSkillButton(m_Type);

        //init coordinate
        Vector2 pos   = new Vector2(transform.localPosition.x, transform.localPosition.y);
        Coord2D coord = m_BG.PosToCoord(pos);

        SetCoord(coord);

        m_InfoBar = GameObject.FindGameObjectWithTag("InfoBar").GetComponent <InfoBar>();
    }
示例#22
0
        public static async System.Threading.Tasks.Task ShowInfoBar(InfoBar infoBar)
        {
            IVsInfoBarUIFactory infoBarUIFactory = await ServiceProvider.GetGlobalServiceAsync(typeof(SVsInfoBarUIFactory)) as IVsInfoBarUIFactory;

            var uiElement = infoBarUIFactory.CreateInfoBar(infoBar);

            IVsShell shell = await ServiceProvider.GetGlobalServiceAsync(typeof(SVsShell)) as IVsShell;

            shell.GetProperty((int)__VSSPROPID7.VSSPROPID_MainWindowInfoBarHost, out var host);
            if (host is IVsInfoBarHost infoBarHost)
            {
                var eventSink = new InfoBarEvents(infoBar, uiElement);
                uiElement.Advise(eventSink, out var cookie);
                eventSink.Cookie = cookie;

                infoBarHost.AddInfoBar(uiElement);
            }
        }
示例#23
0
        public static InfoBar CreateInfoBar(string title, string message, StackPanel panel, Severity severity)
        {
            if (Settings.IsShowNotifications)
            {
                var bar = new InfoBar();
                bar.Severity = severity;
                bar.Title    = title;
                bar.Message  = message;
                bar.Margin   = new Thickness(0, 5, 0, 0);

                panel.Children.Insert(0, bar);
                return(bar);
            }
            else
            {
                return(null);
            }
        }
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            //This gets executed 1st as each code file is loaded
            if (!(Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider.GetService(typeof(DTE)) is DTE dte))
            {
                return;
            }

            if (!(SharedGlobals.GetGlobal("CrmService", dte) is CrmServiceClient client))
            {
                return;
            }

            if (!IsIntellisenseEnabled(dte))
            {
                return;
            }

            ITextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView == null)
            {
                return;
            }

            CrmJsCompletionCommandHandler CreateCommandHandler() => new CrmJsCompletionCommandHandler(textViewAdapter, textView, this);

            textView.Properties.GetOrCreateSingletonProperty(CreateCommandHandler);

            var metadata = SharedGlobals.GetGlobal("CrmMetadata", dte);

            if (metadata != null)
            {
                return;
            }

            var infoBar      = new InfoBar(false);
            var infoBarModel = CreateMetadataInfoBar();

            infoBar.ShowInfoBar(infoBarModel);

            GetData(client, infoBar);
        }
示例#25
0
 void OnMouseOver()
 {
     if (Info != null)
     {
         Info.delete = false;
     }
     if (controller.infoBar == null)
     {
         controller.infoBar = Instantiate(controller.InfoBarPref, transform.position, transform.rotation);
         Info      = controller.infoBar.GetComponent <InfoBar>();
         Info.text = Information.GetSpellInfo(spell.Name, level, controller.friends[num].power);
         foreach (var x in spell.statusName)
         {
             Info.text += '\n' + Information.GetEffectInfo(x, level, controller.friends[num].power);
         }
         Info.text += $"\n\n<b>Перезарядка:</b> {spell.reloadtime}";
         Info.text += $"\n<b>Уровень:</b> { level + 1}";
     }
 }
示例#26
0
        public void CreateConfig()
        {
            var(project, _) = Solution.GetStartupProjects().FirstOrDefault();

            if (project is null)
            {
                project = Solution.GetAllProjects().FirstOrDefault();

                if (project is null)
                {
                    InfoBar.NewMessage()
                    .WithErrorImage()
                    .WithText("There is no project present, in which the config file should be generated in.")
                    .WithButton("Ok")
                    .Publish();

                    return;
                }
            }

            _ignoreAddedFile = true;

            var success = project.CreateDocument(RazorMinifier.ConfigName);

            _ignoreAddedFile = false;

            if (success != VSADDRESULT.ADDRESULT_Success)
            {
                return;
            }

            var document = GetConfigFile(project);

            var fullName = document.GetFullName();

            SetConfigFile(fullName);

            TryLoadLocalConfigFile(project);
        }
示例#27
0
        /// <summary>
        /// Displays an <see cref="InfoBar"/> in VS.
        /// </summary>
        /// <param name="infoBar">The InfoBar object to display.</param>
        /// <param name="serviceProvider">VS async service provider.</param>
        /// <returns>A task that completes once the infobar is displayed.</returns>
        public static async Task ShowInfoBarAsync(InfoBar infoBar, IAsyncServiceProvider serviceProvider)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            IVsInfoBarUIFactory infoBarUIFactory = await serviceProvider.GetServiceAsync(typeof(SVsInfoBarUIFactory)) as IVsInfoBarUIFactory;

            Assumes.Present(infoBarUIFactory);

            var uiElement = infoBarUIFactory.CreateInfoBar(infoBar);

            IVsShell shell = await ServiceProvider.GetGlobalServiceAsync(typeof(SVsShell)) as IVsShell;

            shell.GetProperty((int)__VSSPROPID7.VSSPROPID_MainWindowInfoBarHost, out var host);
            if (host is IVsInfoBarHost infoBarHost)
            {
                var eventSink = new InfoBarEvents(infoBar, uiElement);
                uiElement.Advise(eventSink, out var cookie);
                eventSink.Cookie = cookie;

                infoBarHost.AddInfoBar(uiElement);
            }
        }
示例#28
0
        public static InfoBar CreateInfoBarWithAction(string title, string message, StackPanel panel, Severity severity, string buttonContent, Action action)
        {
            if (Settings.IsShowNotifications)
            {
                var bar = new InfoBar();
                bar.Severity = severity;
                bar.Title    = title;
                bar.Message  = message;
                bar.Margin   = new Thickness(0, 5, 0, 0);

                var btnAction = new Button();
                btnAction.Content = buttonContent;
                btnAction.Click  += (e, s) => { action(); };

                bar.ActionButton = btnAction;
                panel.Children.Insert(0, bar);
                return(bar);
            }
            else
            {
                return(null);
            }
        }
示例#29
0
 void OnMouseOver()
 {
     if (Info != null)
     {
         Info.delete = false;
     }
     if (controller.infoBar == null)
     {
         var hero = lvl.Hero.Peek();
         controller.infoBar = Instantiate(controller.InfoBarPref, transform.position, transform.rotation);
         Info      = controller.infoBar.GetComponent <InfoBar>();
         Info.text = Information.GetSpellUpgrade(spell.Name, hero.SpellLevel[spell.num], hero.power);
         foreach (var x in spell.statusName)
         {
             Info.text += '\n' + Information.GetEffectUpgrade(x, hero.SpellLevel[spell.num], hero.power);
         }
         Info.text += $"\n\n<b>Перезарядка:</b> {spell.reloadtime}";
         //Info.text += $"\n<b> Уровень:</ b > { spell.level + 1}";
     }
     if (Input.GetMouseButton(0))
     {
         rend.color = MouseClick;
     }
     else
     {
         rend.color = MouseIn;
     }
     if (Input.GetMouseButtonUp(0))
     {
         if (Info != null)
         {
             Destroy(Info.gameObject);
         }
         ApplyUpgrade();
     }
 }
示例#30
0
 public InfoPanel(InfoBar info_bar)
 {
     this.info_bar = info_bar;
 }
示例#31
0
 /// <summary>
 /// Initializes a new instance of the InfoBarAutomationPeer class.
 /// </summary>
 /// <param name="owner">The InfoBar control instance to create the peer for.</param>
 public InfoBarAutomationPeer(InfoBar owner) : base(owner)
 {
 }
        protected void InitEditorBar()
        {
            EditorBar = new InfoBar(UI.GetInterface(Name));

            EditorBar.Size = new Vector2(6000, EditorBar.Size.Y);
            EditorBar.AddElement("File", SupportedInfoBarElement.Button);
            EditorBar[0].HoverButtonList.Add("New Map");
            EditorBar[0].HoverButtonList.Add("Load Map");
            EditorBar[0].HoverButtonList.Add("Save Map");

            EditorBar.AddElement("Edit", SupportedInfoBarElement.Button);
            EditorBar[1].HoverButtonList.Add("Undo");
            EditorBar[1].HoverButtonList.Add("Redo");

            EditorBar.AddElement("Window", SupportedInfoBarElement.Button);
            EditorBar[2].HoverButtonList.Add("Tile Selector");
            EditorBar[2].HoverButtonList.Add("Toolbar");

            EditorBar.AddElement("Start Game", SupportedInfoBarElement.Button);

            //EditorBar function
            EditorBar[0].HoverButtonList[0].Clicked += (sender) =>
            {
                GameStateManager.TransitionState(GameStateManager.NewMapPrefs);
            };

            EditorBar[0].HoverButtonList[1].Clicked += (sender) =>
            {
                Map.Clear();
                Map.Load();
            };

            EditorBar[0].HoverButtonList[2].Clicked += (sender) =>
            {
                MultiThreading.StartThread("Thread_Saver");
            };

            EditorBar[1].HoverButtonList[0].Clicked += (sender) =>
            {
                EventHandler.Undo();
            };

            EditorBar[1].HoverButtonList[1].Clicked += (sender) =>
            {
                EventHandler.Redo();
            };

            EditorBar[2].HoverButtonList[0].Clicked += (sender) =>
            {
                CurrentTileBar.Open(new Vector2(200, Game1.ScreenHeight - 125));
                TileSelect.Open(new Vector2(0, 21));
            };

            EditorBar[2].HoverButtonList[1].Clicked += (sender) =>
            {
                ToolBar.Open(new Vector2(Game1.ScreenWidth - ToolBar.Size.X, 21));
            };

            EditorBar[3].Clicked += (sender) =>
            {
                Map.SaveAndReLoad();
                Map.CurrentBrush.SetBrush(new BrushTool(Map.Settings.AccessibleTiles.PlaceholderTile, 1));
                Game1.Cam.Zoom = 1;
                GameStateManager.TransitionState(GameStateManager.Playing);
            };
        }
    //Prepare player to run\\
    void Start()
    {
        //If debugMode is on at start, tell us (incase we're looking at performance, and forgot about debugMode
        if(debugMode == true)
            UnityEngine.Debug.Log ("Debug Mode is on");

        //Check if the first part of the OS name is "Unix" (Mac OS is a Unix-based system)
        if(Environment.OSVersion.ToString().Substring (0, 4) == "Unix")
        {

            //Set path to the predefined location for UMP music files on Macintosh-based OS
            path = mac;

            onMac = true;

            //If debugMode is on, tell us that the user is running a Macintosh-based Operating System
            if(debugMode == true)
                UnityEngine.Debug.Log ("Player Running on Macintosh OS");
        } else {

            //Set path to the predefined location for UMP music files on a Windows-based OS
            path = windows;

            onMac = false;

            //If debugMode is on, tell us that the user is running a Windows-based Operating System
            if(debugMode == true)
                UnityEngine.Debug.Log ("Player Running on Windows OS");
        }

        publicPath = path;

        //Find & assign infoBar and audioVisualizer
        infoBar = GameObject.FindGameObjectWithTag("InfoBar").GetComponent<InfoBar>();

        //Assign mediaPath to the correct directory
        mediaPath = path + Path.DirectorySeparatorChar + "Media";

        //Assign prefsLocation to the correct directory
        prefsLocation = path + Path.DirectorySeparatorChar + "Preferences.ump";

        //Get the current directory (so we know where to save the new version if an update is avaliable)
        appLocation = Environment.CurrentDirectory;

        //Check if the directories exist
        //NOTE: We only need to check mediaPath because if mediaPath exists, so does path
        if(!Directory.Exists (mediaPath))
        {

            //If debugMode is on, tell us that the directories do not exist
            if(debugMode == true)
                UnityEngine.Debug.Log ("Directories Do Not Exist");

            //Show the X image to alert the user that something is wrong
            filesExistImage.texture = x;

            //Tell the user that they need to create the directories for UMP to work
            filesExistText.text = "The requried directories do not exist!\nTo create them, click 'Create Directories'";

            //Set the boolean filesExist to false and the array clipList to null
            filesExist = false;
            clipList = null;
        } else {

        //Set the boolean filesExist to true
        filesExist = true;

        //Get the all the files ending in .WAV in path & assign them to the array clipList
        clipList = Directory.GetFiles(mediaPath, "*.wav");

        //Get the number of songs currently playiable and send that to infoBar
        infoBar.songCount = clipList.Length;

        //If debugMode is on, display how many songs are playable
        if(debugMode == true)
            UnityEngine.Debug.Log (clipList.Length + " songs are playable");
        }

        //If the Preferences file exists set the preferences accordingly
        if(File.Exists (prefsLocation))
        {

            //Bring all the text from our file into memory
            string[] prefs = File.ReadAllLines(prefsLocation);

            //Set loop, shuffle, and the volume to what it was last
            loop = Convert.ToBoolean(prefs[0]);
            shuffle = Convert.ToBoolean(prefs[1]);
            continuous = Convert.ToBoolean(prefs[2]);
            volumeBarValue = Convert.ToSingle(prefs[3]);
            previousSongs[0] = Convert.ToInt32(prefs[4]);
            if(previousSongs[0] > clipList.Length)
                previousSongs[0] = clipList.Length;

            previousSongs[1] = Convert.ToInt32(prefs[5]);
            if(previousSongs[1] > clipList.Length)
                previousSongs[1] = clipList.Length;

            previousSongs[2] = Convert.ToInt32(prefs[6]);
            if(previousSongs[2] > clipList.Length)
                previousSongs[2] = clipList.Length;

            previousSongs[3] = Convert.ToInt32(prefs[7]);
            if(previousSongs[3] > clipList.Length)
                previousSongs[3] = clipList.Length;

            previousSongs[4] = Convert.ToInt32(prefs[8]);
            if(previousSongs[4] > clipList.Length)
                previousSongs[4] = clipList.Length;

            previousSongs[5] = Convert.ToInt32(prefs[9]);
            if(previousSongs[5] > clipList.Length)
                previousSongs[5] = clipList.Length;

            previousSongs[6] = Convert.ToInt32(prefs[10]);
            if(previousSongs[6] > clipList.Length)
                previousSongs[6] = clipList.Length;

            TextWriter savePrefs = new StreamWriter(prefsLocation);
            savePrefs.WriteLine(loop + "\n" + shuffle + "\n" + continuous + "\n" + volumeBarValue + "\n" + previousSongs[0] + "\n" + previousSongs[1] + "\n" + previousSongs[2] + "\n" + previousSongs[3] + "\n" + previousSongs[4] + "\n" + previousSongs[5] + "\n" + previousSongs[6]);
            savePrefs.Close();

        //If the Preferences file does not exist, create it
        } else if(filesExist == true){

            //Create the file
            using (FileStream createPrefs = File.Create(prefsLocation))
            {

                //Make a byte array and fill it with the values for loop, shuffle, volume, and empty values for the previous sogns.
                Byte[] preferences = new UTF8Encoding(true).GetBytes(loop + "\n" + shuffle + "\n" + continuous + "\n" + volumeBarValue + "\n 0 \n 0 \n 0 \n 0 \n 0 \n 0 \n 0");

                //Write to our new file
                createPrefs.Write(preferences, 0, preferences.Length);

                createPrefs.Close();
            }
        }
        InvokeRepeating("CheckMediaPath", 0, 2);
    }