Example #1
0
        public MainWindow(bool bLoadWks) {
            Utilities.LoadOperations();

            _instance = this;

            Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Tencent\\Tag\\Behaviac");

            if (regKey != null) {
                regKey.Close();
            }

            SetDefaultSettings();

            // Add the designers resource manager to the list of all available resource managers
            Plugin.AddResourceManager(Resources.ResourceManager);

            // Load the config file
            loadConfig();

            // Restore layout
            loadLayout(Plugin.EditMode, __layoutFile, bLoadWks);

            this.Shown += new System.EventHandler(MainWindow_Shown);
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(MainWindow_FormClosing);

            this.dumpMenuItem.Visible = false;
        }
Example #2
0
        public MainWindow(bool bLoadWks)
        {
            _instance = this;

            Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Tencent\\Tag\\Behaviac");
            if (regKey != null)
            {
                regKey.Close();
            }

            //TODO: add a setting in base to hold all these settings
            Node.ColorTheme = (Node.ColorThemes)Settings.Default.ColorTheme;
            Behaviac.Design.Nodes.Action.NoResultTreatAsError = Settings.Default.NoResultTreatAsError;
            NodeViewData.ShowNodeId = Settings.Default.ShowVersionInfo;
            NodeViewData.IsDisplayLengthLimited = Settings.Default.IsDisplayLengthLimited;
            NodeViewData.LimitedDisplayLength = Settings.Default.LimitedDisplayLength;
            Plugin.UseBasicDisplayName = Settings.Default.UseBasicDisplayName;
            MessageQueue.LimitMessageCount = Settings.Default.LimitLogCount;
            MessageQueue.MaxMessageCount = Settings.Default.MaxLogCount;

            //if not chinese, to use as english
            switch ((Language)Settings.Default.Language)
            {
                case Language.Chinese:
                    Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN");
                    break;

                default:
                   Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
                   break;
            }

            // Add the designers resource manager to the list of all available resource managers
            Plugin.AddResourceManager(Resources.ResourceManager);

            // Load the config file
            loadConfig();

            // Restore layout
            loadLayout(Plugin.EditMode, __layoutFile, bLoadWks);

            this.Shown += new System.EventHandler(MainWindow_Shown);
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(MainWindow_FormClosing);

            this.dumpToolStripMenuItem.Visible = false;
        }
Example #3
0
        static void Main(string[] args)
        {
            try
            {
                if (Settings.Default.UpdateRequired)
                {
                    Settings.Default.Upgrade();
                    Settings.Default.UpdateRequired = false;
                }

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Plugin.LoadPlugins();

                //only do it when there are args
                if (args.Length > 0)
                {
                    NativeMethods.InitConsoleHandles();
                }

                CommandOptions options = new CommandOptions();

                bool bOk = options.Parse(args);

                if (!bOk || options.help)
                {
                    string allFormats = string.Empty;
                    foreach (ExporterInfo info in Plugin.Exporters)
                    {
                        if (!string.IsNullOrEmpty(allFormats))
                            allFormats += "|";

                        allFormats += info.ID;
                    }

                    string usage = string.Format
                        (@"
                            Usage:
                                BehaviacDesigner.exe <workspaceFile> <options>
                                    options:
                                        /bt=btFile
                                        /export=<{0}>
                                        /help", allFormats);

                    System.Console.WriteLine(usage);
                }

                if (options.export)
                {
                    if (bOk)
                    {
                        string msg = string.Format("Exporting: format '{0}' workspace '{1}' ...", options.format, options.workspace);
                        System.Console.WriteLine(msg);

                        if (!System.IO.File.Exists(options.workspace))
                        {
                            msg = string.Format("Workspace '{0}' does not exist! check the workspace path and name.", options.workspace);
                            System.Console.WriteLine(msg);

                            return;
                        }

                        new MainWindow(false);

                        if (MainWindow.Instance.SetWorkspace(options.workspace, false))
                        {
                            MainWindow.Instance.ExportBehavior(true, options.format);
                        }
                        else
                        {
                            //msg = string.Format("Workspace '{0}' is not a valid workspace file!", options.workspace);
                            //System.Console.WriteLine(msg);
                        }
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(options.workspace))
                        {
                            System.Console.WriteLine("No workspace is specified!");
                        }
                        if (string.IsNullOrEmpty(options.format))
                        {
                            System.Console.WriteLine("No format is specified!");
                        }
                    }

                    return;
                }

                MainWindow mainWindow = new MainWindow(true);
                if (!string.IsNullOrEmpty(options.workspace))
                {
                    mainWindow.SetWorkspace(options.workspace, false);

                    if (!string.IsNullOrEmpty(options.bt))
                    {
                        UIUtilities.ShowBehaviorTree(options.bt);
                    }
                }

                Application.Run(mainWindow);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception is {0}", e);
            }
        }