Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            if (args.Length >= 1)
            {
                if (args[0].Equals("/gct", StringComparison.InvariantCultureIgnoreCase))
                {
                    GCTEditor editor = new GCTEditor();
                    if (args.Length >= 2)
                    {
                        editor.TargetNode = editor.LoadGCT(args[1]);
                    }
                    Application.Run(editor);
                    return;
                }
                else if (args[0].EndsWith(".gct", StringComparison.InvariantCultureIgnoreCase))
                {
                    GCTEditor editor = new GCTEditor();
                    editor.TargetNode = editor.LoadGCT(args[0]);
                    Application.Run(editor);
                    return;
                }
            }

            try
            {
                if (args.Length >= 1)
                {
                    Open(args[0]);
                }

                if (args.Length >= 2)
                {
                    ResourceNode target = ResourceNode.FindNode(RootNode, args[1], true);
                    if (target != null)
                    {
                        MainForm.Instance.TargetResource(target);
                    }
                    else
                    {
                        Say(String.Format("Error: Unable to find node or path '{0}'!", args[1]));
                    }
                }

                Application.Run(MainForm.Instance);
            }
            catch (FileNotFoundException x)
            {
                if (x.Message.Contains("Could not load file or assembly"))
                {
                    MessageBox.Show(x.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    throw x;
                }
            }
            finally { Close(true); }
        }
Exemplo n.º 2
0
        public static bool Open(string path)
        {
            if (String.IsNullOrEmpty(path))
            {
                return(false);
            }

            if (!File.Exists(path))
            {
                Say("File does not exist.");
                return(false);
            }

            if (path.EndsWith(".gct", StringComparison.InvariantCultureIgnoreCase))
            {
                GCTEditor editor = new GCTEditor();
                editor.TargetNode = GCTEditor.LoadGCT(path);
                editor.Show();
                return(true);
            }

            if (!Close())
            {
                return(false);
            }

#if !DEBUG
            try
            {
#endif
            if ((_rootNode = NodeFactory.FromFile(null, _rootPath = path)) != null)
            {
                MainForm.Instance.Reset();
                return(true);
            }
            else
            {
                _rootPath = null;
                Say("Unable to recognize input file.");
                MainForm.Instance.Reset();
            }
#if !DEBUG
        }

        catch (Exception x) { Say(x.ToString()); }
#endif

            Close();

            return(false);
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            if (args.Length >= 1)
            {
                if (args[0].Equals("/gct", StringComparison.InvariantCultureIgnoreCase))
                {
                    GCTEditor editor = new GCTEditor();
                    if (args.Length >= 2)
                    {
                        editor.TargetNode = GCTEditor.LoadGCT(args[1]);
                    }
                    Application.Run(editor);
                    return;
                }
                else if (args[0].EndsWith(".gct", StringComparison.InvariantCultureIgnoreCase))
                {
                    GCTEditor editor = new GCTEditor();
                    editor.TargetNode = GCTEditor.LoadGCT(args[0]);
                    Application.Run(editor);
                    return;
                }
            }

            List <string> remainingArgs = new List <string>();

            foreach (string a in args)
            {
                if (a.Equals("/audio:directsound", StringComparison.InvariantCultureIgnoreCase))
                {
                    System.Audio.AudioProvider.AvailableTypes = System.Audio.AudioProvider.AudioProviderType.DirectSound;
                }
                else if (a.Equals("/audio:openal", StringComparison.InvariantCultureIgnoreCase))
                {
                    System.Audio.AudioProvider.AvailableTypes = System.Audio.AudioProvider.AudioProviderType.OpenAL;
                }
                else if (a.Equals("/audio:none", StringComparison.InvariantCultureIgnoreCase))
                {
                    System.Audio.AudioProvider.AvailableTypes = System.Audio.AudioProvider.AudioProviderType.None;
                }
                else
                {
                    remainingArgs.Add(a);
                }
            }
            args = remainingArgs.ToArray();

            try
            {
                if (args.Length >= 1)
                {
                    Open(args[0]);
                }

                if (args.Length >= 2)
                {
                    ResourceNode target = ResourceNode.FindNode(RootNode, args[1], true);
                    if (target != null)
                    {
                        MainForm.Instance.TargetResource(target);
                    }
                    else
                    {
                        Say(String.Format("Error: Unable to find node or path '{0}'!", args[1]));
                    }
                }

                Application.Run(MainForm.Instance);
            }
            catch (FileNotFoundException x)
            {
                if (x.Message.Contains("Could not load file or assembly"))
                {
                    MessageBox.Show(x.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    throw x;
                }
            }
            finally { Close(true); }
        }
Exemplo n.º 4
0
        public static void Update()
        {
            if (!_enabled)
            {
                DiscordRpc.ClearPresence();
                DiscordRpc.Shutdown();
                return;
            }

            if (!DiscordControllerSet)
            {
                DiscordController.Initialize();
                _controllerSet = true;
            }

            DiscordController.presence = new DiscordRpc.RichPresence
            {
                smallImageKey  = UserPickedImageKey,
                smallImageText = "",
                largeImageKey  = "brawlcrate",
                largeImageText = Program.AssemblyTitleFull
            };
            ResourceNode root         = MainForm.Instance?.RootNode?.Resource;
            string       rootName     = root?.Name;
            bool         hasGct       = (rootName?.EndsWith(".gct") ?? false) || (rootName?.EndsWith(".txt") ?? false);
            bool         usingManager = false;
            GCTEditor    gctEditor    = null;

            if (!hasGct)
            {
                FormCollection fc = Application.OpenForms;
                foreach (Form frm in fc)
                {
                    if (frm is CostumeManager.MainForm)
                    {
                        DiscordController.presence.details = "Managing Costumes";
                        usingManager = true;
                        break;
                    }
                    if (frm is SongManager.MainForm)
                    {
                        DiscordController.presence.details = "Managing Songs";
                        usingManager = true;
                        break;
                    }
                    if (frm is StageManager.MainForm)
                    {
                        DiscordController.presence.details = "Managing Stages";
                        usingManager = true;
                        break;
                    }
                    if (!(frm is GCTEditor editor))
                    {
                        continue;
                    }

                    hasGct    = true;
                    gctEditor = editor;
                    break;
                }
            }

            if (!usingManager)
            {
                if (hasGct)
                {
                    DiscordController.presence.details = WorkString + " codes";
                }
                else if (root == null)
                {
                    DiscordController.presence.details = "Idling";
                }
                else if (Program.RootPath == null)
                {
                    if (root is ARCNode && ((ARCNode)root).IsStage)
                    {
                        if (rootName.StartsWith("STGRESULT", StringComparison.OrdinalIgnoreCase))
                        {
                            DiscordController.presence.details = WorkString + " the results screen";
                        }
                        else
                        {
                            DiscordController.presence.details = WorkString + " a stage";
                        }
                    }
                    else
                    {
                        DiscordController.presence.details = WorkString + " a new mod";
                    }
                }
                else if (root is ARCNode)
                {
                    if (((ARCNode)root).IsStage)
                    {
                        if (rootName.StartsWith("STGRESULT", StringComparison.OrdinalIgnoreCase))
                        {
                            DiscordController.presence.details = WorkString + " the results screen";
                        }
                        else
                        {
                            DiscordController.presence.details = WorkString + " a stage";
                        }
                    }
                    else if (((ARCNode)root).IsFighter)
                    {
                        if (rootName.EndsWith("0") ||
                            rootName.EndsWith("1") ||
                            rootName.EndsWith("2") ||
                            rootName.EndsWith("3") ||
                            rootName.EndsWith("4") ||
                            rootName.EndsWith("5") ||
                            rootName.EndsWith("6") ||
                            rootName.EndsWith("7") ||
                            rootName.EndsWith("8") ||
                            rootName.EndsWith("9"))
                        {
                            DiscordController.presence.details = WorkString + " a costume";
                        }
                        else if (rootName.Contains("motion", StringComparison.OrdinalIgnoreCase))
                        {
                            DiscordController.presence.details = WorkString + " animations";
                        }
                        else
                        {
                            DiscordController.presence.details = WorkString + " a fighter";
                        }
                    }
                    else if (rootName.StartsWith("sc_", StringComparison.OrdinalIgnoreCase) ||
                             rootName.StartsWith("common5", StringComparison.OrdinalIgnoreCase) ||
                             rootName.StartsWith("mu_", StringComparison.OrdinalIgnoreCase))
                    {
                        DiscordController.presence.details = WorkString + " menus";
                    }
                    else if (rootName.StartsWith("info", StringComparison.OrdinalIgnoreCase))
                    {
                        DiscordController.presence.details = WorkString + " UI";
                    }
                    else if (Program.RootPath.Substring(0, Program.RootPath.LastIndexOf('\\'))
                             .EndsWith("\\stage\\adventure"))
                    {
                        DiscordController.presence.details = WorkString + " a subspace stage";
                    }
                    else if (rootName.StartsWith("common2", StringComparison.OrdinalIgnoreCase))
                    {
                        DiscordController.presence.details = WorkString + " single player";
                    }
                    else if (rootName.StartsWith("common3", StringComparison.OrdinalIgnoreCase))
                    {
                        DiscordController.presence.details = WorkString + " items";
                    }
                    else if (rootName.StartsWith("common", StringComparison.OrdinalIgnoreCase))
                    {
                        DiscordController.presence.details = WorkString + " animations";
                    }
                    else if (rootName.StartsWith("home_", StringComparison.OrdinalIgnoreCase) &&
                             Program.RootPath.Substring(0, Program.RootPath.LastIndexOf('\\'))
                             .EndsWith("\\system\\homebutton"))
                    {
                        DiscordController.presence.details = WorkString + " the home menu";
                    }
                    else if (rootName.Equals("cs_pack", StringComparison.OrdinalIgnoreCase))
                    {
                        DiscordController.presence.details = WorkString + " coin launcher";
                    }
                    else if ((MainForm.Instance.RootNode.Name.StartsWith("Itm") ||
                              Program.RootPath.Substring(0, Program.RootPath.LastIndexOf('\\')).EndsWith("\\item") ||
                              Program.RootPath.Substring(0, Program.RootPath.LastIndexOf('\\'))
                              .Substring(0, Program.RootPath.LastIndexOf('\\')).EndsWith("\\item")) &&
                             (rootName.EndsWith("Brres") || rootName.EndsWith("Param")))
                    {
                        DiscordController.presence.details = WorkString + " an item";
                    }
                    else
                    {
                        DiscordController.presence.details = WorkString + " a mod";
                    }
                }
                else if (root is RELNode)
                {
                    DiscordController.presence.details = WorkString + " a module";
                }
                else if (root is RSTMNode)
                {
                    DiscordController.presence.details = WorkString + " a BRSTM";
                }
                else
                {
                    DiscordController.presence.details = WorkString + " a mod";
                }

                if (hasGct || MainForm.Instance.RootNode != null)
                {
                    switch (_modNameType)
                    {
                    case ModNameType.UserDefined:
                        DiscordController.presence.state = _userNamedMod;
                        break;

                    case ModNameType.AutoInternal:
                        if (gctEditor != null)
                        {
                            DiscordController.presence.state = gctEditor.TargetNode?.Name ?? "";
                        }
                        else if (hasGct)
                        {
                            DiscordController.presence.state = string.IsNullOrEmpty(Program.RootPath)
                                    ? ""
                                    : Program.RootPath.Substring(Program.RootPath.LastIndexOf('\\') + 1,
                                                                 Program.RootPath.LastIndexOf('\\') - Program.RootPath.LastIndexOf('.'));
                        }
                        else
                        {
                            DiscordController.presence.state =
                                MainForm.Instance.RootNode == null || MainForm.Instance.RootNode.Name == null ||
                                rootName.Equals("<null>", StringComparison.OrdinalIgnoreCase)
                                        ? ""
                                        : rootName;
                        }

                        break;

                    case ModNameType.AutoExternal:
                        if (gctEditor != null)
                        {
                            try
                            {
                                DiscordController.presence.state =
                                    gctEditor.TargetNode._origPath.Substring(
                                        gctEditor.TargetNode._origPath.LastIndexOf('\\') + 1);
                            }
                            catch
                            {
                                DiscordController.presence.state = "";
                            }
                        }
                        else
                        {
                            DiscordController.presence.state = string.IsNullOrEmpty(Program.RootPath)
                                    ? ""
                                    : Program.RootPath.Substring(Program.RootPath.LastIndexOf('\\') + 1);
                        }

                        break;

                    default:
                        DiscordController.presence.state = "";
                        break;
                    }
                }
            }

            if (ShowTimeElapsed)
            {
                DiscordController.presence.startTimestamp = startTime;
            }

            DiscordRpc.UpdatePresence(DiscordController.presence);
        }
Exemplo n.º 5
0
        private void gCTEditorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GCTEditor c = new GCTEditor();

            c.Show();
        }