Esempio n. 1
0
        private void AdjustAssetTypeInfo()
        {
            var atis = AvailableAssetTypes.Self.AllAssetTypes
                       .Where(item => item.QualifiedRuntimeTypeName.QualifiedType ==
                              "Microsoft.Xna.Framework.Media.Song");

            foreach (var ati in atis)
            {
                ati.CustomLoadFunc = (element, nos, rfs, contentManager) =>
                {
                    bool shouldAssignField = ReferencedFileSaveCodeGenerator.NeedsFullProperty(rfs, element);

                    string variableName;

                    if (shouldAssignField)
                    {
                        variableName = "m" + rfs.GetInstanceName();
                    }
                    else
                    {
                        variableName = rfs.GetInstanceName();
                    }

                    var fileName = ReferencedFileSaveCodeGenerator.GetFileToLoadForRfs(rfs, ati); // FlatRedBall.IO.FileManager.RemoveExtension(rfs.Name).ToLowerInvariant().Replace("\\", "/");
                    if (rfs.DestroyOnUnload == false)
                    {
                        contentManager = "FlatRedBall.FlatRedBallServices.GlobalContentManager";
                    }
                    //return $"{propertyName} = FlatRedBall.FlatRedBallServices.Load<Microsoft.Xna.Framework.Media.Song>(@"content/screens/gamescreen/baronsong", contentManagerName);";
                    return($"{variableName} = FlatRedBall.FlatRedBallServices.Load<Microsoft.Xna.Framework.Media.Song>(@\"{fileName}\", {contentManager});");
                };
            }
        }
        string GetGumxLoadCode(IElement element, NamedObjectSave nos, ReferencedFileSave rfs, string contentManagerName)
        {
            string fileNameToLoad = ReferencedFileSaveCodeGenerator.GetFileToLoadForRfs(rfs, mGumxAti);

            string toReturn = $"FlatRedBall.Gum.GumIdb.StaticInitialize(\"{fileNameToLoad}\"); " +
                              "FlatRedBall.Gum.GumIdbExtensions.RegisterTypes();  " +
                              "FlatRedBall.Gui.GuiManager.BringsClickedWindowsToFront = false;";

            var displaySettings = GlueState.Self.CurrentGlueProject?.DisplaySettings;

            if (displaySettings != null)
            {
                if (displaySettings.FixedAspectRatio == false || displaySettings.AspectRatioHeight == 0)
                {
                    toReturn += "FlatRedBall.Gum.GumIdb.FixedCanvasAspectRatio = null;";
                }
                else
                {
                    var aspectRatio = displaySettings.AspectRatioWidth / displaySettings.AspectRatioHeight;
                    toReturn += $"FlatRedBall.Gum.GumIdb.FixedCanvasAspectRatio = {displaySettings.AspectRatioWidth}/{displaySettings.AspectRatioHeight}m;";
                }
            }

            // As of August 19, 2019 Glue handles this in the camera code, so this isn't needed anymore
            //toReturn +=
            //            "FlatRedBall.FlatRedBallServices.GraphicsOptions.SizeOrOrientationChanged += (not, used) => { FlatRedBall.Gum.GumIdb.UpdateDisplayToMainFrbCamera(); };"
            //            ;

            var gumxRfs = GumProjectManager.Self.GetRfsForGumProject();

            bool shouldShowOutlines = false;

            if (gumxRfs != null)
            {
                shouldShowOutlines = gumxRfs.Properties.GetValue <bool>("ShowDottedOutlines");
            }

            string valueAsString = shouldShowOutlines.ToString().ToLowerInvariant();

            toReturn +=
                $"Gum.Wireframe.GraphicalUiElement.ShowLineRectangles = {valueAsString};";

            return(toReturn);
        }
        private string GetRawDialogTreeLoadCode(IElement element, NamedObjectSave namedObject, ReferencedFileSave referencedFile, string contentManager)
        {
            var fileName = ReferencedFileSaveCodeGenerator.GetFileToLoadForRfs(referencedFile, referencedFile.GetAssetTypeInfo());

            return($"{referencedFile.GetInstanceName()} = DialogTreePlugin.SaveClasses.DialogTreeRaw.RootObject.FromJson(\"{fileName}\");");
        }