public void LoadFromSettings()
        {
            mostRecentlyUsedFiles.Clear();

            try
            {
                // We load a copy of the profile in case concurrent Game Studio instances are running.
                var profileCopy = LoadLatestProfile();
                var mruList     = settingsKey.GetValue(profileCopy, true);

                // If the version is null, we take all versions, otherwise we take version equal or older to the current version.
                var files = mruList.SelectMany(x =>
                {
                    // Set version information
                    x.Value.ForEach(f => f.Version = x.Key);
                    return(x.Value);
                }).ToList();
                // Sort by descending timestamp
                files.Sort((x, y) => - x.Timestamp.CompareTo(y.Timestamp));
                mostRecentlyUsedFiles.AddRange(files);
            }
            catch (Exception e)
            {
                e.Ignore();
            }
        }
Exemplo n.º 2
0
        private BuildResultCode BuildGetGraphicsPlatform()
        {
            var localLogger   = new LoggerResult();
            var simplePackage = Package.Load(localLogger, builderOptions.PackageFile, new PackageLoadParameters {
                AutoLoadTemporaryAssets = false, LoadAssemblyReferences = false, AutoCompileProjects = false
            });

            if (simplePackage == null ||
                localLogger.HasErrors)
            {
                localLogger.CopyTo(builderOptions.Logger);
                return(BuildResultCode.BuildError);
            }

            var buildProfile = simplePackage.Profiles.FirstOrDefault(pair => pair.Name == builderOptions.BuildProfile);

            if (buildProfile == null)
            {
                builderOptions.Logger.Error("Package {0} did not contain platform {1}", builderOptions.PackageFile, builderOptions.BuildProfile);
                return(BuildResultCode.BuildError);
            }

            // For now, graphics platform is implicit.
            // It will need to be readded to GameSettingsAsset at some point.
            var graphicsPlatformKey = new SettingsKey <GraphicsPlatform>("Xenko.GraphicsPlatform", buildProfile.Properties.Container, builderOptions.Platform.GetDefaultGraphicsPlatform());
            var graphicsPlatform    = graphicsPlatformKey.GetValue(buildProfile.Properties, true);

            Console.WriteLine(graphicsPlatform);
            return(BuildResultCode.Successful);
        }
Exemplo n.º 3
0
        ///***********************************************************************************
        /// <summary>
        /// Load the top, left, width, and height of the window from the registry, use default
        /// application parameters if not present in registry. This should be called from
        /// OnLayout; it takes effect in the first call AFTER EndInit.
        /// </summary>
        ///***********************************************************************************
        public void LoadWindowPosition()
        {
            if (m_fInInit)
            {
                return;
            }
            if (m_fHaveLoadedPosition)
            {
                return;
            }
            m_fHaveLoadedPosition = true;
            CheckDisposed();

            RegistryKey key = SettingsKey;

            int iLeft = (int)key.GetValue(Parent.GetType().Name + "Left", (Parent is Form ?
                                                                           ((Form)Parent).DesktopBounds.Left : Parent.Left));

            int iTop = (int)key.GetValue(Parent.GetType().Name + "Top", (Parent is Form ?
                                                                         ((Form)Parent).DesktopBounds.Top : Parent.Top));

            int iWidth = (int)key.GetValue(Parent.GetType().Name + "Width", (Parent is Form ?
                                                                             ((Form)Parent).DesktopBounds.Width : Parent.Width));

            int iHeight = (int)key.GetValue(Parent.GetType().Name + "Height", (Parent is Form ?
                                                                               ((Form)Parent).DesktopBounds.Height : Parent.Height));

            var rect = new Rectangle(iLeft, iTop, iWidth, iHeight);

            var parentForm = Parent as Form;

            if (parentForm != null)
            {
                ScreenHelper.EnsureVisibleRect(ref rect);
                if (rect != parentForm.DesktopBounds)
                {
                    // this means we loaded values from the registry - or the form is to big
                    parentForm.StartPosition = FormStartPosition.Manual;
                }
                parentForm.DesktopLocation = new Point(rect.X, rect.Y);

                // we can't set the width and height on the form yet - if we do it won't
                // resize our child controls
                m_normalLeft           = rect.X;
                m_normalTop            = rect.Y;
                parentForm.Width       = m_normalWidth = rect.Width;
                parentForm.Height      = m_normalHeight = rect.Height;
                parentForm.WindowState = (FormWindowState)SettingsKey.GetValue(
                    parentForm.GetType().Name + sWindowState, parentForm.WindowState);
            }
            else
            {
                // Set parent dimensions based upon possible adjustments in EnsureVisibleRect
                Parent.Top    = rect.Top;
                Parent.Left   = rect.Left;
                Parent.Width  = rect.Width;
                Parent.Height = rect.Height;
            }
        }
 static LauncherSettings()
 {
     SettingsContainer.LoadSettingsProfile(GetLatestLauncherConfigPath(), true);
     CloseLauncherAutomatically = CloseLauncherAutomaticallyKey.GetValue();
     ActiveVersion     = ActiveVersionKey.GetValue();
     CurrentTab        = CurrentTabKey.GetValue();
     DeveloperVersions = DeveloperVersionsKey.GetValue();
 }
Exemplo n.º 5
0
        ///***********************************************************************************
        /// <summary>
        ///	Load the Window state from the registry.
        /// </summary>
        ///***********************************************************************************
        public void LoadWindowState()
        {
            CheckDisposed();

            Debug.Assert(Parent is Form);
            Form form = (Form)Parent;

            form.WindowState = (FormWindowState)SettingsKey.GetValue(
                form.GetType().Name + sWindowState, form.WindowState);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Saves the settings into the settings file.
        /// </summary>
        public static void Save()
        {
            // Special case for MRU: we always reload the latest version from the file.
            // Actually modifying and saving MRU is done in a specific class.
            var profileCopy = LoadProfileCopy();
            var mruList     = MostRecentlyUsedSessions.GetValue(profileCopy, true);

            MostRecentlyUsedSessions.SetValue(mruList);
            WriteFile();
        }
Exemplo n.º 7
0
        public void LoadFromSettings()
        {
            mostRecentlyUsedFiles.Clear();

            try
            {
                // We load a copy of the profile in case concurrent Game Studio instances are running.
                var profileCopy = LoadLatestProfile();
                var mruList     = settingsKey.GetValue(profileCopy, true);
                if (includeOlder)
                {
                    // If the version is null, we take all versions, otherwise we take version equal or older to the current version.
                    var files = mruList.Where(x => string.IsNullOrEmpty(version) || string.Compare(x.Key, version, StringComparison.Ordinal) <= 0).SelectMany(x =>
                    {
                        // Set version information
                        x.Value.ForEach(f => f.Version = x.Key);
                        return(x.Value);
                    }).ToList();
                    // Sort by descending timestamp
                    files.Sort((x, y) => - x.Timestamp.CompareTo(y.Timestamp));
                    mostRecentlyUsedFiles.AddRange(files);
                }
                else
                {
                    // We just want the current version
                    var files = mruList.TryGetValue(version);
                    if (files != null)
                    {
                        // Sort by descending timestamp
                        files.Sort((x, y) => - x.Timestamp.CompareTo(y.Timestamp));
                        // Set version information
                        files.ForEach(x => x.Version = version);
                        mostRecentlyUsedFiles.AddRange(files);
                    }
                }
            }
            catch (Exception e)
            {
                e.Ignore();
            }
        }
 private void LoadFromSettings()
 {
     lock (SyncRoot)
     {
         // We load a copy of the profile in case concurrent Game Studio instances are running.
         var profileCopy = loadLatestProfile.Invoke();
         var loadedList  = settingsKey.GetValue(profileCopy, true);
         // Sort by descending timestamp
         loadedList.Sort((x, y) => - x.Timestamp.CompareTo(y.Timestamp));
         mruList.Clear();
         mruList.AddRange(loadedList.Where(IsDataValid));
     }
 }
Exemplo n.º 9
0
 public static T Get <T>(SettingsProfile profile, SettingsKey <T> key)
 {
     return(key.GetValue(profile, true));
 }
Exemplo n.º 10
0
 public T GetValue <T>(SettingsKey <T> key)
 {
     return(key.GetValue(profile, true));
 }
Exemplo n.º 11
0
        public void AddDelayedNotification(SettingsKey <bool> confirmationSettingsKey, string message, string yesCaption, string noCaption, Action yesAction, Action noAction, SettingsKey <bool> yesNoSettingsKey)
        {
            if (confirmationSettingsKey == null)
            {
                throw new ArgumentNullException(nameof(confirmationSettingsKey));
            }
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }
            if (yesCaption == null)
            {
                throw new ArgumentNullException(nameof(yesCaption));
            }
            if (noCaption == null)
            {
                throw new ArgumentNullException(nameof(noCaption));
            }

            // Prevent duplicate
            if (delayedNotifications.Any(t => ReferenceEquals(t.Item1, confirmationSettingsKey)))
            {
                return;
            }

            Action action = async() =>
            {
                var yesNo = yesNoSettingsKey?.GetValue() ?? true;
                var ask   = confirmationSettingsKey.GetValue();
                if (ask)
                {
                    var buttons = DialogHelper.CreateButtons(new[] { yesCaption, noCaption }, 1, 2);
                    var result  = await CheckedMessageBox(message, false, DialogHelper.DontAskAgain, buttons, MessageBoxImage.Question);

                    // Close without clicking on a button
                    if (result.Result == 0)
                    {
                        return;
                    }

                    yesNo = result.Result == 1;
                    if (result.IsChecked == true && (yesNo || yesNoSettingsKey != null))
                    {
                        confirmationSettingsKey.SetValue(false);
                        yesNoSettingsKey?.SetValue(yesNo);
                        Settings.EditorSettings.Save();
                    }
                }
                if (yesNo)
                {
                    yesAction?.Invoke();
                }
                else
                {
                    noAction?.Invoke();
                }
            };

            var windows = Application.Current.Windows;

            if (windows.Count == 0 || windows.OfType <Window>().Any(w => w.IsActive))
            {
                // Execute immediately
                Dispatcher.Invoke(action);
                return;
            }

            // Add a new question
            delayedNotifications.Enqueue(Tuple.Create((SettingsKey)confirmationSettingsKey, action));
        }
Exemplo n.º 12
0
 public T GetValue <T>(SettingsKey <T> key) => key.GetValue(Profile, searchInParentProfile: true);