Ejemplo n.º 1
0
        public MainWindow()
        {
            OFilteredServerList = new TrulyObservableCollection <ServerInfo>();

            SourceInitialized += (s, a) =>
            {
                StartCheckingVersions();

                if (ServerRefreshRate > 0)
                {
                    _refreshTimer          = new DispatcherTimer();
                    _refreshTimer.Interval = new TimeSpan(0, 0, ServerRefreshRate);
                    _refreshTimer.Tick    += (object sender, EventArgs e) => StartRefreshingServers();
                    _refreshTimer.Start();
                }
                StartRefreshingServers();

                if (VersionCheck.GetGameVersionName() == "Unknown")
                {
                    Properties.Settings.Default.Installed = false;
                    Properties.Settings.Default.Save();

                    #region PrimaryStartupInstallation
                    //Show the dialog that asks to install the game
                    this.InitFirstInstall();
                    #endregion PrimaryStartupInstallation
                }
                else
                {
                    Properties.Settings.Default.Installed = true;
                    Properties.Settings.Default.Save();
                    if (Properties.Settings.Default.Username != "")
                    {
                        SD_Username.Content = Properties.Settings.Default.Username;
                    }
                    else
                    {
                        ShowUsernameBox();
                    }
                }
            };
            InitializeComponent();

            //SetMessageboxText(MESSAGE_IDLE); // This must be set before any asynchronous code runs, as it might otherwise be overridden.
            ServerInfoGrid.Items.SortDescriptions.Add(new SortDescription(PlayerCountColumn.SortMemberPath, ListSortDirection.Ascending));

            SD_GameVersion.Content = VersionCheck.GetGameVersionName();

            BannerTools.Setup();
            SD_ClanHeader.Cursor = BannerTools.GetBannerLink(null) != "" ? Cursors.Hand : null;

            //due to the mediaelement being set to manual control, we need to start the previewvid in the constructor
            this.sv_MapPreviewVid.Play();
        }
Ejemplo n.º 2
0
        private void ServerInfoGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ServerInfoGrid.SelectedIndex >= OFilteredServerList.Count || ServerInfoGrid.SelectedIndex <= -1)
            {
                return;
            }

            ServerInfo selected = GetSelectedServer();

            //Original mappreview code
            //sv_MapPreview.Source = BitmapToImageSourceConverter.Convert(MapPreviewSettings.GetMapBitmap(selected.MapName));

            //Movie mappreview code
            if (File.Exists(GameInstallation.GetRootPath() + "\\PreviewVids\\" + selected.MapName + ".mp4"))
            {
                this.DefaultMoviePlays  = false;
                sv_MapPreviewVid.Source = new Uri(GameInstallation.GetRootPath() + "\\PreviewVids\\" + selected.MapName + ".mp4");
                sv_MapPreviewVid.Play();
            }
            else if (!this.DefaultMoviePlays)
            {
                sv_MapPreviewVid.Source = new Uri(GameInstallation.GetRootPath() + "\\PreviewVids\\Default.mp4");
                this.DefaultMoviePlays  = true;
                sv_MapPreviewVid.Play();
            }

            SD_ClanHeader.Source = BannerTools.GetBanner(selected.IPWithPort);
            SD_ClanHeader.Cursor = BannerTools.GetBannerLink(selected.IPWithPort) != "" ? Cursors.Hand : null;

            SD_Name.Content          = selected.ServerName;
            SD_GameLength.Content    = selected.TimeLimit.ToString();
            SD_MineLimit.Content     = selected.MineLimit.ToString();
            SD_GameMode.Content      = selected.MapMode.ToString();
            SD_PlayerLimit.Content   = selected.MaxPlayers.ToString();
            SD_ServerVersion.Content = selected.GameVersion;
            SD_VehicleLimit.Content  = selected.VehicleLimit;
            SD_CN.Content            = selected.CountryName;

            Rect r;

            ServerInfo.FlagCodes.TryGetValue(selected.CountryCode, out r);
            this.SD_CFI.Viewbox = r;

            Autobalance_Checkbx.Source  = GetChkBxImg(selected.AutoBalance);
            Steam_Checkbx.Source        = GetChkBxImg(selected.SteamRequired);
            Crates_Checkbx.Source       = GetChkBxImg(selected.SpawnCrates);
            InfantryOnly_Checkbx.Source = GetChkBxImg(selected.VehicleLimit <= 0);
            Ranked_Checkbx.Source       = GetChkBxImg(selected.Ranked);

            // Set version mismatch message visibility and join button opacity
            if (VersionCheck.GetGameVersionName() == selected.GameVersion)
            {
                version_mismatch = false;
                SD_VersionMismatch.Visibility           = Visibility.Hidden;
                this.Join_Server_Btn.Background.Opacity = 1.0;
                this.Join_Server_Btn.Content            = "Join Server";
            }
            else
            {
                version_mismatch = true;
                SD_VersionMismatch.Visibility           = Visibility.Visible;
                this.Join_Server_Btn.Background.Opacity = 0.5;
                this.Join_Server_Btn.Content            = "Server Version Mismatch";
            }

            System.Windows.Media.Animation.Storyboard sb = this.FindResource("JoinButtonGlow") as System.Windows.Media.Animation.Storyboard;
            System.Windows.Media.Animation.Storyboard.SetTarget(sb, this.Join_Server_Btn);
            sb.Begin();

            ServerInfoGrid.UpdateLayout();
        }