예제 #1
0
        private void EditModePictureBox_Click(object sender, EventArgs e)
        {
            // 当前ModeComboBox中至少有一项
            if (ModeComboBox.SelectedIndex == -1)
            {
                MessageBoxX.Show(i18N.Translate("Please select a mode first"));
                return;
            }

            var mode = (Models.Mode)ModeComboBox.SelectedItem;

            if (ModifierKeys == Keys.Control)
            {
                Utils.Utils.Open(ModeHelper.GetFullPath(mode.RelativePath));
                return;
            }

            switch (mode.Type)
            {
            case 0:
                Hide();
                new Process(mode).ShowDialog();
                Show();
                break;

            default:
                Utils.Utils.Open(ModeHelper.GetFullPath(mode.RelativePath));
                break;
            }
        }
        /// <summary>
        ///  If the design mode is chosen then the driver will use NeoLoad as Proxy.
        /// </summary>
        /// <param name="capabilities">capabilities to modify</param>
        /// <returns>modified capabilities</returns>
        public static DesiredCapabilities AddProxyCapabilitiesIfNecessary(DesiredCapabilities capabilities)
        {
            if (!Mode.DESIGN.Equals(ModeHelper.getMode()))
            {
                return(capabilities);
            }

            DesignConfiguration conf = ConfigurationHelper.newDesignConfiguration(null, null);
            string host = getDomainName(conf.DesignAPIUrl);
            int    port;

            try
            {
                port = DesignManager.newDesignAPIClientFromConfig(conf).GetRecorderSettings().ProxySettings.Port;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw e;
            }
            string proxyString = host + ":" + port;

            Proxy proxy = new Proxy();

            proxy.HttpProxy = proxyString;
            proxy.SslProxy  = proxyString;

            capabilities.SetCapability(CapabilityType.Proxy, proxy);
            capabilities.SetCapability(CapabilityType.AcceptSslCertificates, true);
            return(capabilities);
        }
예제 #3
0
        /// <summary>
        ///     Updates the text of the metadata with a new map/mods
        ///     Realigns it so it's in the middle.
        /// </summary>
        /// <param name="map"></param>
        public void UpdateAndAlignMetadata(Map map)
        {
            var length = TimeSpan.FromMilliseconds(map.SongLength / ModHelper.GetRateFromMods(ModManager.Mods));

            Mode.UpdateValue(ModeHelper.ToShortHand(map.Mode));
            Bpm.UpdateValue(((int)(map.Bpm * ModHelper.GetRateFromMods(ModManager.Mods))).ToString(CultureInfo.InvariantCulture));
            Length.UpdateValue(length.Hours > 0 ? length.ToString(@"hh\:mm\:ss") : length.ToString(@"mm\:ss"));
            Difficulty.UpdateValue(StringHelper.AccuracyToString((float) map.DifficultyFromMods(ModManager.Mods)).Replace("%", ""));
            LNPercentage.UpdateValue(((int) map.LNPercentage).ToString(CultureInfo.InvariantCulture) + "%");

            for (var i = 0; i < Items.Count; i++)
            {
                var metadata = Items[i];

                if (i == 0)
                {
                    metadata.X = 5;
                    continue;
                }

                var previous = Items[i - 1];
                metadata.X = previous.X + previous.Width + 5 + 5;
            }

            Items.ForEach(x => x.X += (Banner.Width - Items.Last().X) / Items.Count / 2);
        }
예제 #4
0
 string IRunningInstruction.ToString()
 {
     return(Address.ToString().PadRight(5) +
            Operation.ToString() + "." + Modifier.ToString().PadRight(3) +
            ModeHelper.ToString(ModeA) + ValueA.ToString().PadLeft(6) + ", " +
            ModeHelper.ToString(ModeB) + ValueB.ToString().PadLeft(6) + "     ");
 }
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="item"></param>
        /// <param name="index"></param>
        public override void UpdateContent(MultiplayerGame item, int index)
        {
            Item  = item;
            Index = index;
            Container.AvailableItems[index] = item;

            GameTitle.Text = item.Name;

            DifficultyRating.Text = $"{item.DifficultyRating:0.00}";
            DifficultyRating.Tint = ColorHelper.DifficultyToColor((float)item.DifficultyRating);

            MapTitle.Text = " - " + item.Map;
            MapTitle.X    = DifficultyRating.X + DifficultyRating.Width + 2;

            PlayerCount.Text   = $"{item.Players.Count}/{item.MaxPlayers} Players";
            PasswordLock.Alpha = Item.HasPassword ? 0.75f : 0.30f;

            MapBanner.Alpha = 0;
            FetchMapsetBanner();

            switch (item.Type)
            {
            case MultiplayerGameType.Friendly:
                GameType.Text = $"[{ModeHelper.ToShortHand((GameMode) item.GameMode)}] Friendly - {item.Ruleset.ToString().Replace("_", "-")}";
                break;

            case MultiplayerGameType.Competitive:
                GameType.Text = $"[{ModeHelper.ToShortHand((GameMode) item.GameMode)}] Competitive - {item.Ruleset.ToString().Replace("_", "-")}";
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        /// <summary>
        /// Create a NeoLoad instance to the webDriver.
        /// In Design mode, project in parameter will be opened and the userPath in parameter will be created or updated if it is already present in opened project.
        /// In EndUserExperience mode, the userPath in parameter will be added to the path of entries sent to NeoLoad.
        /// </summary>
        /// <param name="webDriver">an instance of a WebDriver as ChromeDriver or FirefoxDriver.</param>
        /// <param name="userPath">the name of the UserPath.</param>
        /// <param name="projectPath">the path of the project to open in NeoLoad.</param>
        /// <param name="paramBuilderProvider">ParamBuilderProvider class can be overridden in order to update parameters.</param>
        public static NLWebDriver NewNLWebDriver(IWebDriver webDriver, string userPath, string projectPath,
                                                 ParamBuilderProvider paramBuilderProvider)
        {
            Mode mode = ModeHelper.getMode();
            INeoLoadInterceptor interceptor;

            switch (mode)
            {
            case Mode.END_USER_EXPERIENCE:
                ICapabilities capabilitites = null;
                if (webDriver is IHasCapabilities)
                {
                    capabilitites = (webDriver as IHasCapabilities).Capabilities;
                }
                var eueConf = ConfigurationHelper.newEUEConfiguration(webDriver.GetType().Name, userPath, capabilitites);
                interceptor = new WebDriverEUEInterceptor(webDriver, eueConf);
                break;

            case Mode.DESIGN:
                var designConf = ConfigurationHelper.newDesignConfiguration(userPath, projectPath);
                interceptor = new WebDriverDesignInterceptor(designConf, paramBuilderProvider);
                break;

            case Mode.NO_API:
            default:
                interceptor = new NoOpInterceptor();
                break;
            }
            interceptor.DoOnStart();
            return(new NLWebDriver(webDriver, interceptor));
        }
예제 #7
0
        public void ControlButton_Click(object sender, EventArgs e)
        {
            if (RuleListBox.Items.Count == 0)
            {
                MessageBoxX.Show(i18N.Translate("Unable to add empty rule"));
                return;
            }

            if (string.IsNullOrWhiteSpace(RemarkTextBox.Text))
            {
                MessageBoxX.Show(i18N.Translate("Please enter a mode remark"));
                return;
            }

            if (string.IsNullOrWhiteSpace(FilenameTextBox.Text))
            {
                MessageBoxX.Show(i18N.Translate("Please enter a mode filename"));
                return;
            }

            if (_mode != null)
            {
                _mode.Remark = RemarkTextBox.Text;
                _mode.Rule.Clear();
                _mode.Rule.AddRange(RuleListBox.Items.Cast <string>());

                _mode.WriteFile();
                Global.MainForm.LoadModes();
                Edited = false;
                MessageBoxX.Show(i18N.Translate("Mode updated successfully"));
            }
            else
            {
                var relativePath = $"Custom\\{FilenameTextBox.Text}.txt";
                var fullName     = ModeHelper.GetFullPath(relativePath);
                if (File.Exists(fullName))
                {
                    MessageBoxX.Show(i18N.Translate("File already exists.\n Please Change the filename"));
                    return;
                }

                var mode = new Models.Mode(fullName)
                {
                    BypassChina = false,
                    Type        = 0,
                    Remark      = RemarkTextBox.Text
                };

                mode.Rule.AddRange(RuleListBox.Items.Cast <string>());

                mode.WriteFile();
                ModeHelper.Add(mode);
                MessageBoxX.Show(i18N.Translate("Mode added successfully"));
            }

            Close();
        }
예제 #8
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            AddAddServerToolStripMenuItems();

            #region i18N Translations

            _mainFormText.Add(UninstallServiceToolStripMenuItem.Name, new[] { "Uninstall {0}", "NF Service" });
            _mainFormText.Add(UninstallTapDriverToolStripMenuItem.Name, new[] { "Uninstall {0}", "TUN/TAP driver" });

            #endregion

            OnlyInstance.Called += OnCalled;
            // 计算 ComboBox绘制 目标宽度
            _eWidth = ServerComboBox.Width / 10;

            ModeHelper.Load();
            InitMode();
            InitServer();
            _comboBoxInitialized = true;

            // 加载翻译
            InitText();

            // 隐藏 NatTypeStatusLabel
            NatTypeStatusText();

            _configurationGroupBoxHeight = ConfigurationGroupBox.Height;
            _profileConfigurationHeight  = ConfigurationGroupBox.Controls[0].Height / 3; // 因为 AutoSize, 所以得到的是Controls的总高度
            // 加载快速配置
            InitProfile();

            // 打开软件时启动加速,产生开始按钮点击事件
            if (Global.Settings.StartWhenOpened)
            {
                ControlButton.PerformClick();
            }

            Task.Run(() =>
            {
                // 检查更新
                if (Global.Settings.CheckUpdateWhenOpened)
                {
                    CheckUpdate();
                }
            });


            Task.Run(async() =>
            {
                // 检查订阅更新
                if (Global.Settings.UpdateSubscribeatWhenOpened)
                {
                    await UpdateServersFromSubscribe();
                }
            });
        }
예제 #9
0
파일: Process.cs 프로젝트: zu1kbackup/Netch
        public void ControlButton_Click(object sender, EventArgs e)
        {
            if (!RuleRichTextBox.Lines.Any())
            {
                MessageBoxX.Show(i18N.Translate("Unable to add empty rule"));
                return;
            }

            if (string.IsNullOrWhiteSpace(RemarkTextBox.Text))
            {
                MessageBoxX.Show(i18N.Translate("Please enter a mode remark"));
                return;
            }

            if (string.IsNullOrWhiteSpace(FilenameTextBox.Text))
            {
                MessageBoxX.Show(i18N.Translate("Please enter a mode filename"));
                return;
            }

            if (_mode != null)
            {
                _mode.Remark = RemarkTextBox.Text;
                _mode.Rule.Clear();
                _mode.Rule.AddRange(RuleRichTextBox.Lines);

                _mode.WriteFile();
                MessageBoxX.Show(i18N.Translate("Mode updated successfully"));
            }
            else
            {
                var relativePath = FilenameTextBox.Text;
                var fullName     = ModeHelper.GetFullPath(relativePath);
                if (File.Exists(fullName))
                {
                    MessageBoxX.Show(i18N.Translate("File already exists.\n Please Change the filename"));
                    return;
                }

                var mode = new Models.Mode(fullName)
                {
                    BypassChina = false,
                    Type        = 0,
                    Remark      = RemarkTextBox.Text
                };

                mode.Rule.AddRange(RuleRichTextBox.Lines);

                mode.WriteFile();
                MessageBoxX.Show(i18N.Translate("Mode added successfully"));
            }

            Close();
        }
예제 #10
0
        private void DeleteModePictureBox_Click(object sender, EventArgs e)
        {
            // 当前ModeComboBox中至少有一项
            if (ModeComboBox.Items.Count <= 0 || ModeComboBox.SelectedIndex == -1)
            {
                MessageBoxX.Show(i18N.Translate("Please select a mode first"));
                return;
            }

            ModeHelper.Delete((Models.Mode)ModeComboBox.SelectedItem);
            SelectLastMode();
        }
        public static string AllowedModesToString(List <byte> modes)
        {
            var modesList = modes.Select(x => ModeHelper.ToShortHand((GameMode)x)).ToList();

            if (modesList.Count == 0)
            {
                return("None");
            }

            if (modesList.Count == 1)
            {
                return(modesList.First());
            }

            return(string.Join(", ", modesList));
        }
예제 #12
0
        private void UpdateText()
        {
            Username.Text = OnlineManager.Status.Value != ConnectionStatus.Connected
                ? ConfigManager.Username.Value
                : OnlineManager.Self.OnlineUser.Username;

            GameMode.Text = ModeHelper.ToShortHand(ConfigManager.SelectedGameMode.Value);

            switch (OnlineManager.Status.Value)
            {
            case ConnectionStatus.Disconnected:
                Status.Text          = "Offline";
                LoadingWheel.Visible = false;
                break;

            case ConnectionStatus.Connecting:
                Status.Text          = "Connecting. Please Wait!";
                LoadingWheel.Visible = true;
                break;

            case ConnectionStatus.Connected:
                Flag.Image         = Flags.Get(OnlineManager.Self.OnlineUser.CountryFlag);
                Username.Tint      = Colors.GetUserChatColor(OnlineManager.Self.OnlineUser.UserGroups);
                Avatar.Border.Tint = Username.Tint;

                if (OnlineManager.Self.Stats.ContainsKey(ConfigManager.SelectedGameMode.Value))
                {
                    var stats = OnlineManager.Self.Stats[ConfigManager.SelectedGameMode.Value];
                    Status.Text = $"#{stats.Rank:n0} - {stats.OverallPerformanceRating:00.00} ({StringHelper.AccuracyToString((float) stats.OverallAccuracy)})";
                }

                LoadingWheel.Visible = false;
                break;

            case ConnectionStatus.Reconnecting:
                Status.Text          = "Reconnecting. Please Wait!";
                LoadingWheel.Visible = true;
                break;

            default:
                throw new ArgumentOutOfRangeException();
                break;
            }

            GameMode.Visible = OnlineManager.Status.Value == ConnectionStatus.Connected;
            LoadingWheel.X   = Status.Width + 10;
        }
예제 #13
0
        /// <summary>
        ///     Loads an individual skin element.
        /// </summary>
        /// <param name="folder"></param>
        /// <param name="element"></param>
        /// <param name="shared">If the resource is shared between key modes.</param>
        /// <param name="extension"></param>
        /// <returns></returns>
        private Texture2D LoadTexture(SkinKeysFolder folder, string element, bool shared, string extension = ".png")
        {
            string resource;

            if (shared)
            {
                resource = $"Quaver.Resources/Textures/Skins/Shared/{folder.ToString()}/{element}.png";
            }
            else
            {
                resource = $"Quaver.Resources/Textures/Skins/{ConfigManager.DefaultSkin.Value.ToString()}/{Mode.ToString()}/{folder.ToString()}" +
                           $"/{GetResourcePath(element)}.png";
            }

            var folderName = shared ? folder.ToString() : $"/{ModeHelper.ToShortHand(Mode).ToLower()}/{folder.ToString()}";

            return(SkinStore.LoadSingleTexture($"{SkinStore.Dir}/{folderName}/{element}", resource));
        }
예제 #14
0
 private void ReloadModesToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Enabled = false;
     try
     {
         ModeHelper.Load();
         InitMode();
         NotifyTip(i18N.Translate("Modes have been reload"));
     }
     catch (Exception)
     {
         // ignored
     }
     finally
     {
         Enabled = true;
     }
 }
예제 #15
0
        /// <summary>
        ///     Loads a spritesheet
        /// </summary>
        /// <param name="folder"></param>
        /// <param name="element"></param>
        /// <param name="shared">If the resource is shared between key modes.</param>
        /// <param name="rows"></param>
        /// <param name="columns"></param>
        /// <param name="extension"></param>
        /// <returns></returns>
        private List <Texture2D> LoadSpritesheet(SkinKeysFolder folder, string element, bool shared, int rows, int columns, string extension = ".png")
        {
            string resource;

            if (shared)
            {
                resource = $"Quaver.Resources/Textures/Skins/Shared/{folder.ToString()}/{element}";
            }
            else
            {
                resource = $"Quaver.Resources/Textures/Skins/{ConfigManager.DefaultSkin.Value.ToString()}/{Mode.ToString()}/{folder.ToString()}" +
                           $"/{GetResourcePath(element)}";
            }

            var folderName = shared ? folder.ToString() : $"/{ModeHelper.ToShortHand(Mode).ToLower()}/{folder.ToString()}/";

            return(SkinStore.LoadSpritesheet(folderName, element, resource, rows, columns, extension));
        }
예제 #16
0
        private NeoloadDesignAPIWrapper()
        {
            string globalMode = null;

            try
            {
                globalMode = TestSuite.Current.Parameters[OPT_RANOREX_NEOLOAD_MODE];
            }
            catch (Exception e)
            {
                // Do nothing
            }

            if (!String.IsNullOrEmpty(globalMode))
            {
                _mode = (Mode)Enum.Parse(typeof(Mode), globalMode.ToUpper());
            }
            else
            {
                _mode = ModeHelper.getPropertyValue(OPT_RANOREX_NEOLOAD_MODE, Mode.NO_API);
            }
        }
예제 #17
0
 public override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[]?rgbIV) =>
 ModeHelper.CreateDecryptor(ModeValue, PaddingValue, rgbKey, rgbIV, (key, encryption) => new CAST5Transform(key, encryption));
예제 #18
0
 public override string ToString()
 {
     return(Operation.ToString() + "." + Modifier.ToString().PadRight(3) +
            ModeHelper.ToString(ModeA) + ValueA.ToString().PadLeft(6) + ", " +
            ModeHelper.ToString(ModeB) + ValueB.ToString().PadLeft(6) + "     ");
 }
 public override string ToString()
 {
     return(ModeHelper.ToString(Mode) + Expression.ToString());
 }
        public override string GetLine(ParserOptions options, bool start)
        {
            StringBuilder sb = new StringBuilder();

            if (options.Offset)
            {
                sb.Append(Address.ToString("00 "));
            }

            if (options.Labels)
            {
                if (Label != null)
                {
                    sb.Append(Label.PadRight(13));
                }
                else
                {
                    sb.Append("             ");
                }
            }
            else
            {
                if (start)
                {
                    sb.Append("START  ");
                }
                else
                {
                    sb.Append("       ");
                }
            }

            //operation and modifier
            sb.Append(Operation);
            sb.Append(".");
            sb.Append(Modifier.ToString().PadRight(3));

            //A
            sb.Append(ModeHelper.ToString(ModeA));
            if (options.Expressions)
            {
                if (ExpressionA != null)
                {
                    sb.Append(ExpressionA.PadLeft(12));
                }
                else
                {
                    sb.Append(ValueA.ToString().PadLeft(12));
                }
            }
            else
            {
                sb.Append(ValueA.ToString().PadLeft(6));
            }

            //B
            sb.Append(", ");
            sb.Append(ModeHelper.ToString(ModeB));
            if (options.Expressions)
            {
                if (ExpressionB != null)
                {
                    sb.Append(ExpressionB.PadLeft(12));
                }
                else
                {
                    sb.Append(ValueB.ToString().PadLeft(12));
                }
            }
            else
            {
                sb.Append(ValueB.ToString().PadLeft(6));
            }

            //comment
            if (options.Comments && Comment != null && Comment.Length > 0)
            {
                int c = 35;
                if (options.Labels)
                {
                    c += 6;
                }
                if (options.Expressions)
                {
                    c += 19;
                }
                if (sb.Length < c)
                {
                    sb.Append(' ', c);
                }
                sb.Append(";");
                sb.Append(Comment);
            }
            return(sb.ToString());
        }
예제 #21
0
        /// <summary>
        /// </summary>
        public void UpdateContent()
        {
            Map map;

            if (MapManager.Selected.Value?.Md5Checksum == Game.MapMd5)
            {
                map = MapManager.Selected.Value;
            }
            else
            {
                map = MapManager.FindMapFromMd5(Game.MapMd5);

                // In the event that we don't have the correct version, try to find the
                // alternative one. This is commonly used for situations where one has osu!
                // beatmaps auto-loaded and someone downloads and converts the file to .qua format
                if (map == null && Game.MapMd5 != Game.AlternativeMd5)
                {
                    map = MapManager.FindMapFromMd5(Game.AlternativeMd5);
                }

                MapManager.Selected.Value = map;
            }

            HasMap = map != null;

            if (OnlineManager.CurrentGame.HostSelectingMap)
            {
                ArtistTitle.Text      = "Host is currently selecting a map!";
                Mode.Text             = "Please wait...";
                Creator.Text          = "";
                DifficultyName.Text   = "";
                DifficultyRating.Text = "";
            }
            else
            {
                var diffName = GetDifficultyName();

                ArtistTitle.Text = Game.Map.Replace($"[{diffName}]", "");
                Mode.Text        = $"[{ModeHelper.ToShortHand((GameMode) Game.GameMode)}]";
                Creator.Tint     = Color.White;

                DifficultyRating.Text = map != null ? $"{map.DifficultyFromMods(ModManager.Mods):0.00}" : $"{Game.DifficultyRating:0.00}";
                DifficultyRating.Tint = ColorHelper.DifficultyToColor((float)(map?.DifficultyFromMods(ModManager.Mods) ?? Game.DifficultyRating));
                DifficultyRating.X    = Mode.X + Mode.Width + 8;
                DifficultyName.X      = DifficultyRating.X + DifficultyRating.Width + 2;
                DifficultyName.Text   = " - \"" + diffName + "\"";
            }

            var game = (QuaverGame)GameBase.Game;

            if (map != null)
            {
                ArtistTitle.Tint = Color.White;

                var length = TimeSpan.FromMilliseconds(map.SongLength / ModHelper.GetRateFromMods(ModManager.Mods));
                var time   = length.Hours > 0 ? length.ToString(@"hh\:mm\:ss") : length.ToString(@"mm\:ss");

                if (OnlineManager.CurrentGame.HostSelectingMap)
                {
                    Creator.Text = "";
                }
                else
                {
                    Creator.Text = $"By: {map.Creator} | Length: {time} | BPM: {(int) (map.Bpm * ModHelper.GetRateFromMods(ModManager.Mods))} " +
                                   $"| LNs: {(int) map.LNPercentage}%";
                }

                // Inform the server that we now have the map if we didn't before.
                if (OnlineManager.CurrentGame.PlayersWithoutMap.Contains(OnlineManager.Self.OnlineUser.Id))
                {
                    OnlineManager.Client.HasMultiplayerGameMap();
                }

                if (game.CurrentScreen.Type == QuaverScreenType.Lobby || game.CurrentScreen.Type == QuaverScreenType.Multiplayer ||
                    QuaverScreenManager.QueuedScreen.Type == QuaverScreenType.Multiplayer ||
                    AudioEngine.Map != map)
                {
                    if (BackgroundHelper.Map != MapManager.Selected.Value)
                    {
                        Background.Alpha = 0;

                        var view = Screen.View as MultiplayerScreenView;
                        view?.FadeBackgroundOut();
                        BackgroundHelper.Load(map);
                    }

                    ThreadScheduler.Run(() =>
                    {
                        try
                        {
                            if (AudioEngine.Map != map)
                            {
                                if (!HasMap)
                                {
                                    return;
                                }

                                AudioEngine.LoadCurrentTrack();
                                AudioEngine.Track.Play();
                            }
                        }
                        catch (Exception e)
                        {
                            // ignored
                        }
                    });
                }
            }
            // Let the server know that we don't have the selected map
            else
            {
                ArtistTitle.Tint = Color.Red;

                Creator.Text = Game.MapId != -1 ? "You don't have this map. Click to download!" : "You don't have this map. Download not available!";
                Creator.Tint = Colors.SecondaryAccent;

                if (!OnlineManager.CurrentGame.PlayersWithoutMap.Contains(OnlineManager.Self.OnlineUser.Id))
                {
                    OnlineManager.Client.DontHaveMultiplayerGameMap();
                }

                if (!AudioEngine.Track.IsStopped)
                {
                    AudioEngine.Track.Stop();
                }

                MapManager.Selected.Value = MapManager.Mapsets.First().Maps.First();
            }
        }
예제 #22
0
        /// <summary>
        /// </summary>
        public MultiplayerMap(MultiplayerScreen screen, MultiplayerGame game) : base(new ScalableVector2(682, 86), new ScalableVector2(682, 86))
        {
            Screen = screen;
            Game   = game;
            Size   = new ScalableVector2(650, 86);
            Image  = UserInterface.MapPanel;

            DownloadButton = new ImageButton(UserInterface.BlankBox, OnDownloadButtonClicked)
            {
                Parent    = this,
                Alignment = Alignment.MidCenter,
                Size      = new ScalableVector2(Width - 4, Height - 4),
                Alpha     = 0
            };

            Background = new Sprite
            {
                Parent    = this,
                Size      = new ScalableVector2(Height * 1.70f, Height - 4),
                Alignment = Alignment.MidLeft,
                X         = 2,
                Image     = MapManager.Selected.Value == BackgroundHelper.Map && MapManager.Selected.Value.Md5Checksum == Game.MapMd5 ? BackgroundHelper.RawTexture: UserInterface.MenuBackground,
                Alpha     = MapManager.Selected.Value == BackgroundHelper.Map && MapManager.Selected.Value.Md5Checksum == Game.MapMd5 ? 1 : 0
            };

            AddContainedDrawable(Background);

            var diffName = GetDifficultyName();

            ArtistTitle = new SpriteTextBitmap(FontsBitmap.GothamRegular, game.Map.Replace($"[{diffName}]", ""))
            {
                Parent   = this,
                X        = Background.X + Background.Width + 16,
                Y        = 12,
                FontSize = 16
            };

            AddContainedDrawable(ArtistTitle);

            Mode = new SpriteTextBitmap(FontsBitmap.GothamRegular, "[" + ModeHelper.ToShortHand((GameMode)game.GameMode) + "]")
            {
                Parent   = this,
                X        = ArtistTitle.X,
                Y        = ArtistTitle.Y + ArtistTitle.Height + 8,
                FontSize = 14
            };

            AddContainedDrawable(Mode);

            DifficultyRating = new SpriteTextBitmap(FontsBitmap.GothamRegular, $"{game.DifficultyRating:0.00}")
            {
                Parent   = this,
                X        = Mode.X + Mode.Width + 8,
                Y        = Mode.Y,
                FontSize = 14,
                Tint     = ColorHelper.DifficultyToColor((float)game.DifficultyRating)
            };

            AddContainedDrawable(DifficultyRating);

            DifficultyName = new SpriteTextBitmap(FontsBitmap.GothamRegular, " - \"" + diffName + "\"")
            {
                Parent   = this,
                X        = DifficultyRating.X + DifficultyRating.Width + 2,
                Y        = Mode.Y,
                FontSize = 14,
            };

            AddContainedDrawable(DifficultyName);

            Creator = new SpriteTextBitmap(FontsBitmap.GothamRegular, "Mods: None")
            {
                Parent   = this,
                X        = Mode.X,
                Y        = DifficultyRating.Y + DifficultyRating.Height + 8,
                FontSize = DifficultyRating.FontSize
            };

            AddContainedDrawable(Creator);

            BackgroundHelper.Loaded += OnBackgroundLoaded;
            OnlineManager.Client.OnGameMapChanged       += OnGameMapChanged;
            OnlineManager.Client.OnChangedModifiers     += OnChangedModifiers;
            OnlineManager.Client.OnGameHostSelectingMap += OnGameHostSelectingMap;
            ModManager.ModsChanged += OnModsChanged;

            BackgroundHelper.Load(MapManager.Selected.Value);
            UpdateContent();
        }
예제 #23
0
        /// <summary>
        ///     Reads config file for skin.ini elements.
        ///
        ///     REMEMBER TO SET YOUR DEFAULTS FOR BOTH 4K AND 7K
        ///     AND ALL DEFAULT SKINS (BARS/ARROWS)
        /// </summary>
        private void ReadConfig(bool loadFromResources)
        {
            IniData config;

            if (loadFromResources)
            {
                using (var stream = new StreamReader(GameBase.Game.Resources.GetStream($"Quaver.Resources/Textures/Skins/{ConfigManager.DefaultSkin.Value}/skin.ini")))
                    config = new IniFileParser.IniFileParser(new ConcatenateDuplicatedKeysIniDataParser()).ReadData(stream);
            }
            else
            {
                if (Store.Config == null)
                {
                    return;
                }

                config = Store.Config;
            }

            var ini = config[ModeHelper.ToShortHand(Mode).ToUpper()];

            StageReceptorPadding         = ConfigHelper.ReadInt32(StageReceptorPadding, ini["StageReceptorPadding"]);
            HitPosOffsetY                = ConfigHelper.ReadInt32(HitPosOffsetY, ini["HitPosOffsetY"]);
            NotePadding                  = ConfigHelper.ReadInt32(NotePadding, ini["NotePadding"]);
            ColumnLightingScale          = ConfigHelper.ReadFloat(ColumnLightingScale, ini["ColumnLightingScale"]);
            ColumnLightingOffsetY        = ConfigHelper.ReadInt32(ColumnLightingOffsetY, ini["ColumnLightingOffsetY"]);
            ColumnSize                   = ConfigHelper.ReadInt32(ColumnSize, ini["ColumnSize"]);
            ReceptorPosOffsetY           = ConfigHelper.ReadInt32(ReceptorPosOffsetY, ini["ReceptorPosOffsetY"]);
            ColumnAlignment              = ConfigHelper.ReadInt32(ColumnAlignment, ini["ColumnAlignment"]);
            ColorObjectsBySnapDistance   = ConfigHelper.ReadBool(ColorObjectsBySnapDistance, ini["ColorObjectsBySnapDistance"]);
            JudgementHitBurstScale       = ConfigHelper.ReadByte(JudgementHitBurstScale, ini["JudgementHitBurstScale"]);
            ReceptorsOverHitObjects      = ConfigHelper.ReadBool(ReceptorsOverHitObjects, ini["ReceptorsOverHitObjects"]);
            JudgeColors[Judgement.Marv]  = ConfigHelper.ReadColor(JudgeColors[Judgement.Marv], ini["JudgeColorMarv"]);
            JudgeColors[Judgement.Perf]  = ConfigHelper.ReadColor(JudgeColors[Judgement.Perf], ini["JudgeColorPerf"]);
            JudgeColors[Judgement.Great] = ConfigHelper.ReadColor(JudgeColors[Judgement.Great], ini["JudgeColorGreat"]);
            JudgeColors[Judgement.Good]  = ConfigHelper.ReadColor(JudgeColors[Judgement.Good], ini["JudgeColorGood"]);
            JudgeColors[Judgement.Okay]  = ConfigHelper.ReadColor(JudgeColors[Judgement.Okay], ini["JudgeColorOkay"]);
            JudgeColors[Judgement.Miss]  = ConfigHelper.ReadColor(JudgeColors[Judgement.Miss], ini["JudgeColorMiss"]);
            BgMaskAlpha                  = ConfigHelper.ReadFloat(BgMaskAlpha, ini["BgMaskAlpha"]);
            FlipNoteImagesOnUpscroll     = ConfigHelper.ReadBool(FlipNoteImagesOnUpscroll, ini["FlipNoteImagesOnUpscroll"]);
            FlipNoteEndImagesOnUpscroll  = ConfigHelper.ReadBool(FlipNoteEndImagesOnUpscroll, ini["FlipNoteEndImagesOnUpscroll"]);
            HitLightingY                 = ConfigHelper.ReadInt32(HitLightingY, ini["HitLightingY"]);
            HitLightingX                 = ConfigHelper.ReadInt32(HitLightingX, ini["HitLightingX"]);
            HitLightingFps               = ConfigHelper.ReadInt32(HitLightingFps, ini["HitLightingFps"]);
            HoldLightingFps              = ConfigHelper.ReadInt32(HoldLightingFps, ini["HoldLightingFps"]);
            HitLightingWidth             = ConfigHelper.ReadInt32(HitLightingWidth, ini["HitLightingWidth"]);
            HitLightingHeight            = ConfigHelper.ReadInt32(HitLightingHeight, ini["HitLightingHeight"]);
            ScoreDisplayPosX             = ConfigHelper.ReadInt32(ScoreDisplayPosX, ini["ScoreDisplayPosX"]);
            ScoreDisplayPosY             = ConfigHelper.ReadInt32(ScoreDisplayPosY, ini["ScoreDisplayPosY"]);
            RatingDisplayPosX            = ConfigHelper.ReadInt32(RatingDisplayPosX, ini["RatingDisplayPosX"]);
            RatingDisplayPosY            = ConfigHelper.ReadInt32(RatingDisplayPosY, ini["RatingDisplayPosY"]);
            AccuracyDisplayPosX          = ConfigHelper.ReadInt32(AccuracyDisplayPosX, ini["AccuracyDisplayPosX"]);
            AccuracyDisplayPosY          = ConfigHelper.ReadInt32(AccuracyDisplayPosY, ini["AccuracyDisplayPosY"]);
            KpsDisplayPosX               = ConfigHelper.ReadInt32(KpsDisplayPosX, ini["KpsDisplayPosX"]);
            KpsDisplayPosY               = ConfigHelper.ReadInt32(KpsDisplayPosY, ini["KpsDisplayPosY"]);
            ComboPosX                     = ConfigHelper.ReadInt32(ComboPosX, ini["ComboPosX"]);
            ComboPosY                     = ConfigHelper.ReadInt32(ComboPosY, ini["ComboPosY"]);
            JudgementBurstPosY            = ConfigHelper.ReadInt32(JudgementBurstPosY, ini["JudgementBurstPosY"]);
            HealthBarType                 = ConfigHelper.ReadEnum(HealthBarType, ini["HealthBarType"]);
            HealthBarKeysAlignment        = ConfigHelper.ReadEnum(HealthBarKeysAlignment, ini["HealthBarKeysAlignment"]);
            HitErrorPosX                  = ConfigHelper.ReadInt32(HitErrorPosX, ini["HitErrorPosX"]);
            HitErrorPosY                  = ConfigHelper.ReadInt32(HitErrorPosY, ini["HitErrorPosY"]);
            HitErrorHeight                = ConfigHelper.ReadInt32(HitErrorHeight, ini["HitErrorHeight"]);
            HitErrorChevronSize           = ConfigHelper.ReadInt32(HitErrorChevronSize, ini["HitErrorChevronSize"]);
            TimingLineColor               = ConfigHelper.ReadColor(TimingLineColor, ini["TimingLineColor"]);
            SongTimeProgressInactiveColor = ConfigHelper.ReadColor(SongTimeProgressInactiveColor, ini["SongTimeProgressInactiveColor"]);
            SongTimeProgressActiveColor   = ConfigHelper.ReadColor(SongTimeProgressActiveColor, ini["SongTimeProgressActiveColor"]);
            JudgementCounterAlpha         = ConfigHelper.ReadFloat(JudgementCounterAlpha, ini["JudgementCounterAlpha"]);
            JudgementCounterFontColor     = ConfigHelper.ReadColor(JudgementCounterFontColor, ini["JudgementCounterFontColor"]);
            JudgementCounterSize          = ConfigHelper.ReadInt32(JudgementCounterSize, ini["JudgementCounterSize"]);
            DrawLongNoteEnd               = ConfigHelper.ReadBool(DrawLongNoteEnd, ini["DrawLongNoteEnd"]);
            ScoreDisplayScale             = ConfigHelper.ReadInt32(ScoreDisplayScale, ini["ScoreDisplayScale"]);
            RatingDisplayScale            = ConfigHelper.ReadInt32(RatingDisplayScale, ini["RatingDisplayScale"]);
            AccuracyDisplayScale          = ConfigHelper.ReadInt32(AccuracyDisplayScale, ini["AccuracyDisplayScale"]);
            ComboDisplayScale             = ConfigHelper.ReadInt32(ComboDisplayScale, ini["ComboDisplayScale"]);
            KpsDisplayScale               = ConfigHelper.ReadInt32(KpsDisplayScale, ini["KpsDisplayScale"]);
            SongTimeProgressScale         = ConfigHelper.ReadInt32(SongTimeProgressScale, ini["SongTimeProgressScale"]);
            DeadNoteColor                 = ConfigHelper.ReadColor(DeadNoteColor, ini["DeadNoteColor"]);
            BattleRoyaleAlertPosX         = ConfigHelper.ReadInt32(BattleRoyaleAlertPosX, ini["BattleRoyaleAlertPosX"]);
            BattleRoyaleAlertPosY         = ConfigHelper.ReadInt32(BattleRoyaleAlertPosY, ini["BattleRoyaleAlertPosY"]);
            BattleRoyaleAlertScale        = ConfigHelper.ReadInt32(BattleRoyaleAlertScale, ini["BattleRoyaleAlertScale"]);
            BattleRoyaleEliminatedPosX    = ConfigHelper.ReadInt32(BattleRoyaleEliminatedPosX, ini["BattleRoyaleEliminatedPosX"]);
            BattleRoyaleEliminatedPosY    = ConfigHelper.ReadInt32(BattleRoyaleEliminatedPosY, ini["BattleRoyaleEliminatedPosY"]);
        }
예제 #24
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            log.LogInformation("Up and Running!");
            ParameterChecker parameterChecker = new ParameterChecker(req.Query);

            if (!parameterChecker.IsValidConfig)
            {
                return(new BadRequestResult());
            }
            ModeHelper modeHelper = new ModeHelper(req.Query, req.Headers);
            IMode      mode       = modeHelper.Mode;

            log.LogInformation("Initialize Credential Helper");
            CredentialHelper credentialHelper = new CredentialHelper();
            var serviceClientCredentials      = await credentialHelper.GetAzureCredentials();

            string SubscriptionID = Environment.GetEnvironmentVariable("SubscriptionID", EnvironmentVariableTarget.Process);

            string    resourceGroupName = req.Query["ResourceGroupName"];
            DnsHelper dnsHelper         = null;

            try
            {
                dnsHelper = new DnsHelper(serviceClientCredentials, SubscriptionID, resourceGroupName, mode.Zone);
            }
            catch (Exception e)
            {
                log.LogError(e.Message, e.StackTrace);
            }

            bool recordExists = await dnsHelper.RecordExists(mode);

            RecordSet newRecordSet = null;

            if ((!recordExists) && mode.AutoCreateZone)
            {
                try
                {
                    newRecordSet = await dnsHelper.CreateZone(mode);
                }
                catch (Exception e)
                {
                    return((ActionResult) new BadRequestObjectResult(e.Message));
                }
            }

            string answer         = string.Empty;
            bool   zoneIsUpToDate = await dnsHelper.ZoneIsUpToDate(mode.Hostname, mode.Type, mode.Address);

            if (!zoneIsUpToDate)
            {
                try
                {
                    newRecordSet = await dnsHelper.UpdateZone(mode);
                }
                catch (Exception e)
                {
                    return((ActionResult) new BadRequestObjectResult(e.Message));
                }
            }

            if (newRecordSet != null)
            {
                answer = JsonConvert.SerializeObject(newRecordSet);
                return((ActionResult) new OkObjectResult($"{answer}"));
            }
            else
            {
                return((ActionResult) new OkResult());
            }
        }
예제 #25
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            AddAddServerToolStripMenuItems();

            OnlyInstance.Called += OnCalled;
            // 计算 ComboBox绘制 目标宽度
            _eWidth = ServerComboBox.Width / 10;

            ModeHelper.Load();
            InitMode();
            InitServer();
            _comboBoxInitialized = true;

            // 加载翻译
            InitText();

            // 隐藏 NatTypeStatusLabel
            NatTypeStatusText();

            _sizeHeight = Size.Height;
            _configurationGroupBoxHeight = ConfigurationGroupBox.Height;
            _profileConfigurationHeight  = ConfigurationGroupBox.Controls[0].Height / 3; // 因为 AutoSize, 所以得到的是Controls的总高度
            _profileGroupboxHeight       = ProfileGroupBox.Height;
            // 加载快速配置
            InitProfile();

            // 打开软件时启动加速,产生开始按钮点击事件
            if (Global.Settings.StartWhenOpened)
            {
                ControlButton.PerformClick();
            }

            // 自动检测延迟
            Task.Run(() =>
            {
                while (true)
                {
                    if (State == State.Waiting || State == State.Stopped)
                    {
                        TestServer();

                        Thread.Sleep(10000);
                    }
                    else
                    {
                        Thread.Sleep(200);
                    }
                }
            });

            Task.Run(() =>
            {
                // 检查更新
                if (Global.Settings.CheckUpdateWhenOpened)
                {
                    CheckUpdate();
                }
            });


            Task.Run(async() =>
            {
                // 检查订阅更新
                if (Global.Settings.UpdateSubscribeatWhenOpened)
                {
                    await UpdateServersFromSubscribe();
                }
            });
        }
예제 #26
0
        /// <summary>
        ///     Loads elements that rely on the lane.
        /// </summary>
        private void LoadLaneSpecificElements()
        {
            for (var i = 0; i < 7; i++)
            {
                if (i == 4 && Mode == GameMode.Keys4)
                {
                    break;
                }

                // Column Colors
                if (Store.Config != null)
                {
                    ColumnColors[i] = ConfigHelper.ReadColor(ColumnColors[i], Store.Config[ModeHelper.ToShortHand(Mode).ToUpper()][$"ColumnColor{i + 1}"]);
                }

                // HitObjects
                LoadHitObjects(NoteHitObjects, $"note-hitobject-{i + 1}", i);
                LoadHitObjects(NoteHoldHitObjects, $"note-holdhitobject-{i + 1}", i);

                // LNS
                NoteHoldBodies.Add(LoadSpritesheet(SkinKeysFolder.HitObjects, $"note-holdbody-{i + 1}", false, 0, 0));
                NoteHoldEnds.Add(LoadTexture(SkinKeysFolder.HitObjects, $"note-holdend-{i + 1}", false));

                // Receptors
                NoteReceptorsUp.Add(LoadTexture(SkinKeysFolder.Receptors, $"receptor-up-{i + 1}", false));
                NoteReceptorsDown.Add(LoadTexture(SkinKeysFolder.Receptors, $"receptor-down-{i + 1}", false));

                // Editor
                EditorLayerNoteHitObjects.Add(LoadTexture(SkinKeysFolder.Editor, $"note-hitobject-{i + 1}", false));
                EditorLayerNoteHoldBodies.Add(LoadTexture(SkinKeysFolder.Editor, $"note-holdbody-{i + 1}", false));
                EditorLayerNoteHoldEnds.Add(LoadTexture(SkinKeysFolder.Editor, $"note-holdend-{i + 1}", false));
            }
        }
예제 #27
0
        /// <summary>
        /// </summary>
        public OnlinePlayercard()
        {
            Size  = new ScalableVector2(520, 66);
            Image = UserInterface.PlayercardBackground;

            Background = new Sprite()
            {
                Parent    = this,
                Alignment = Alignment.MidCenter,
                Size      = new ScalableVector2(Width - 4, Height - 4),
                Image     = UserInterface.PlayercardCoverDefault,
                Alpha     = 0.65f
            };

            Button = new ImageButton(UserInterface.BlankBox)
            {
                Parent    = this,
                Alignment = Alignment.MidCenter,
                Size      = new ScalableVector2(Width - 4, Height - 4),
                Alpha     = 0
            };

            Button.Clicked += OnButtonClicked;
            Avatar          = new Sprite()
            {
                Parent    = this,
                Alignment = Alignment.MidLeft,
                Size      = new ScalableVector2(Height * 0.75f, Height * 0.75f),
                X         = 12,
                Image     = SteamManager.UserAvatars[SteamUser.GetSteamID().m_SteamID]
            };

            Avatar.AddBorder(Color.White, 2);

            Flag = new Sprite()
            {
                Parent    = this,
                Alignment = Alignment.MidLeft,
                Y         = -12,
                Size      = new ScalableVector2(24, 24),
                X         = Avatar.X + Avatar.Width + 10,
                Image     = Flags.Get("XX")
            };

            Username = new SpriteTextBitmap(FontsBitmap.GothamRegular, ConfigManager.Username.Value)
            {
                Parent    = Flag,
                Alignment = Alignment.MidLeft,
                X         = Flag.Width + 8,
                FontSize  = 20
            };

            GameMode = new SpriteTextBitmap(FontsBitmap.GothamRegular, ModeHelper.ToShortHand(ConfigManager.SelectedGameMode.Value))
            {
                Parent    = this,
                Alignment = Alignment.BotRight,
                Position  = new ScalableVector2(-10, -8),
                FontSize  = 16,
                Tint      = Colors.SecondaryAccent,
            };

            Status = new SpriteTextBitmap(FontsBitmap.GothamRegular, "Offline")
            {
                Parent    = this,
                Alignment = Alignment.MidLeft,
                X         = Flag.X,
                Y         = Flag.Y + Flag.Height,
                FontSize  = 16
            };

            LoadingWheel = new Sprite()
            {
                Parent    = Status,
                Size      = new ScalableVector2(16, 16),
                Image     = UserInterface.LoadingWheel,
                Alignment = Alignment.MidLeft,
                X         = Status.Width + 10
            };

            UpdateText();

            OnlineManager.Status.ValueChanged           += OnOnlineStatusChanged;
            ConfigManager.SelectedGameMode.ValueChanged += OnSelectedGameModeChanged;
        }
        public AutoModIssueMultiModeDiffName(Qua map) : base(AutoModIssueLevel.Ranking)
        {
            Map = map;

            Text = $"The difficulty '{Map.DifficultyName}' should contain '{ModeHelper.ToShortHand(Map.Mode)}'";
        }