Exemple #1
0
        private static void internalLoadGlux(string filename)
        {
            if (!string.IsNullOrEmpty(filename))
            {
                //int numberOfTries = 0;
                //const int maxNumberOfTries = 5;
                //bool succeeded = false;

                //Exception lastException = null;
                //ObjectFinder.GlueProject = null;
                //while (numberOfTries < maxNumberOfTries)
                //{
                //    try
                //    {
                //        GlueProjectSave = FileManager.XmlDeserialize<GlueProjectSave>(filename);
                //        succeeded = true;
                //        break;
                //    }
                //    catch (Exception e)
                //    {
                //        System.Threading.Thread.Sleep(25);
                //        numberOfTries++;
                //        lastException = e;
                //    }
                //}

                //if (!succeeded)
                //{
                //    MessageBox.Show("Error loading GLUX:\n\n" + lastException.ToString());
                //}


                ObjectFinder.GlueProject = GlueProjectSave;



                foreach (var screenSave in GlueProjectSave.Screens)
                {
                    screenSave.UpdateCustomProperties();
                }

                foreach (var entitySave in GlueProjectSave.Entities)
                {
                    entitySave.UpdateCustomProperties();
                }


                LocalizationManager.ClearDatabase();
                GlueProjectSave.UpdateIfTranslationIsUsed();



                // Need to find directory before doing the translation loading
                FileManager.RelativeDirectory = FileManager.GetDirectory(filename);



                mCurrentGlueFile = filename;

                Microsoft.Build.BuildEngine.Project vsProj = new Microsoft.Build.BuildEngine.Project();
                string csProjFileName = FileManager.RemoveExtension(mCurrentGlueFile) + ".csproj";
                vsProj.Load(csProjFileName, Microsoft.Build.BuildEngine.ProjectLoadSettings.IgnoreMissingImports);


                FindContentDirectory(vsProj);


                var vsProjectState = new VsProjectState();
                vsProjectState.DefaultNamespace = null;
                EditorObjects.IoC.Container.Set <IVsProjectState>(vsProjectState);

                foreach (BuildPropertyGroup bpg in vsProj.PropertyGroups)
                {
                    foreach (BuildProperty bp in bpg)
                    {
                        if (bp.Name == "RootNamespace")
                        {
                            vsProjectState.DefaultNamespace = bp.Value;
                            break;
                        }
                    }
                }

                LoadLocalization();

                FlatRedBallServices.Game.Window.Title = filename;

                if (GluxLoaded != null)
                {
                    GluxLoaded();
                }
            }
        }