Exemple #1
0
        static void Main(string[] args)
        {
            /// Initialize the UI-core and install the XNA-plugin (TODO: make it configurable)
            UIRoot   root      = new UIRoot();
            Assembly xnaPlugin = Assembly.Load("RC.UI.XnaPlugin, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");

            root.LoadPlugins(xnaPlugin);
            root.InstallPlugins();

            /// Create the UIWorkspace and set the mouse pointer
            UIWorkspace workspace = new UIWorkspace(new RCIntVector(1024, 768), new RCIntVector(1024, 768));

            UISprite mouseIcon = root.GraphicsPlatform.SpriteManager.LoadSprite("..\\..\\..\\..\\sprites\\pointers\\normal_pointer.png");

            mouseIcon.TransparentColor = new RCColor(255, 0, 255);
            mouseIcon.Upload();
            UIPointer pointer = new UIPointer(mouseIcon, new RCIntVector(0, 0));

            UIWorkspace.Instance.SetDefaultMousePointer(pointer);

            /// Create and activate the test page
            RCMotionControlTestPage motionControlTestPage = new RCMotionControlTestPage();

            UIWorkspace.Instance.RegisterPage(motionControlTestPage);
            motionControlTestPage.Activate();

            /// Start and run the render loop
            root.GraphicsPlatform.RenderLoop.Start(workspace.DisplaySize);

            /// After the render loop has been stopped, release all resources of the UIRoot.
            root.GraphicsPlatform.SpriteManager.DestroySprite(mouseIcon);
            root.Dispose();
        }
        public static void ClassInitialize(TestContext context)
        {
            UIRoot   root      = new UIRoot();
            Assembly xnaPlugin = Assembly.Load("RC.UI.XnaPlugin, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");

            root.LoadPlugins(xnaPlugin);
            root.InstallPlugins();
            UIWorkspace workspace = new UIWorkspace(new RCIntVector(1024, 768), new RCIntVector(1024, 768));

            Directory.CreateDirectory(OUTPUT_DIR);
        }
        public static void Test()
        {
            ConfigurationManager.Initialize("../../../../config/RC.UI.Test/RC.UI.Test.root");
            UIRoot   root      = new UIRoot();
            Assembly xnaPlugin = Assembly.Load("RC.UI.XnaPlugin, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");

            root.LoadPlugins(xnaPlugin);
            root.InstallPlugins();

            UIWorkspace workspace = new UIWorkspace(new RCIntVector(740, 500), new RCIntVector(320, 200));

            pageA = new UIPage();
            pageB = new UIPage();

            panelAA = new MyPanel(new RCIntRectangle(5, 5, 100, 90), new RCIntRectangle(5, 5, 90, 80), UIPanel.ShowMode.DriftFromTop, UIPanel.HideMode.DriftToLeft);
            panelAB = new MyPanel(new RCIntRectangle(5, 100, 100, 90), new RCIntRectangle(5, 5, 90, 80), UIPanel.ShowMode.DriftFromBottom, UIPanel.HideMode.DriftToLeft);
            panelAC = new MyPanel(new RCIntRectangle(110, 5, 200, 90), new RCIntRectangle(5, 5, 190, 80), UIPanel.ShowMode.DriftFromTop, UIPanel.HideMode.DriftToRight);
            panelAD = new MyPanel(new RCIntRectangle(110, 100, 200, 90), new RCIntRectangle(5, 5, 190, 80), UIPanel.ShowMode.DriftFromBottom, UIPanel.HideMode.DriftToRight);

            panelBA = new MyPanel(new RCIntRectangle(5, 5, 100, 90), new RCIntRectangle(5, 5, 90, 80), UIPanel.ShowMode.DriftFromLeft, UIPanel.HideMode.DriftToTop);
            panelBB = new MyPanel(new RCIntRectangle(5, 100, 100, 90), new RCIntRectangle(5, 5, 90, 80), UIPanel.ShowMode.DriftFromLeft, UIPanel.HideMode.DriftToBottom);
            panelBC = new MyPanel(new RCIntRectangle(110, 5, 200, 90), new RCIntRectangle(5, 5, 190, 80), UIPanel.ShowMode.DriftFromRight, UIPanel.HideMode.DriftToTop);
            panelBD = new MyPanel(new RCIntRectangle(110, 100, 200, 90), new RCIntRectangle(5, 5, 190, 80), UIPanel.ShowMode.DriftFromRight, UIPanel.HideMode.DriftToBottom);

            workspace.RegisterPage(pageA);
            workspace.RegisterPage(pageB);
            pageA.RegisterPanel(panelAA);
            pageA.RegisterPanel(panelAB);
            pageA.RegisterPanel(panelAC);
            pageA.RegisterPanel(panelAD);
            pageB.RegisterPanel(panelBA);
            pageB.RegisterPanel(panelBB);
            pageB.RegisterPanel(panelBC);
            pageB.RegisterPanel(panelBD);

            pageB.Activate();
            panelBA.Show();
            panelBB.Show();
            panelBC.Show();
            panelBD.Show();

            pageA.StatusChanged += OnPageStatusChanged;
            pageB.StatusChanged += OnPageStatusChanged;
            pageB.Deactivate();

            root.GraphicsPlatform.RenderLoop.Start(workspace.DisplaySize);
            root.Dispose();
        }
Exemple #4
0
        public static void ClassInitialize(TestContext context)
        {
            ConfigurationManager.Initialize("..\\..\\..\\..\\config\\RC.UI.Test\\RC.UI.Test.root");
            //ConstantsTable.Add("RC.App.Version", "1.0.0.0", "STRING");

            UIRoot   root      = new UIRoot();
            Assembly xnaPlugin = Assembly.Load("RC.UI.XnaPlugin, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");

            root.LoadPlugins(xnaPlugin);
            root.InstallPlugins();
            UIWorkspace workspace = new UIWorkspace(new RCIntVector(1024, 768), new RCIntVector(1024, 768));

            UIResourceManager.LoadResourceGroup("RC.App.SplashScreen");
            UIResourceManager.LoadResourceGroup("RC.App.CommonResources");
            Directory.CreateDirectory(OUTPUT_DIR);
        }
Exemple #5
0
        /// <summary>
        /// This is the starting point of the RC application. Command line switches for RC.exe:
        /// /cfg filename --> Name of the root configuration file to initialize with (RC.root by default).
        /// /c --> Run RC.exe with console window (console is hidden by default). You can also toggle the console
        ///        window by pressing the CTRL + ALT + SHIFT + C combination during runtime.
        /// </summary>
        static void Main(string[] args)
        {
            try
            {
                /// Read and execute the command line switches
                ConsoleHelper.HideConsole();
                CmdLineSwitch.ParseCommandLine(args);
                CmdLineSwitch.ExecuteSwitches();

                /// Initialize the configuration sub-system
                if (!ConfigurationManager.IsInitialized)
                {
                    ConfigurationManager.Initialize(RCAppSetup.Mode == RCAppMode.Normal ? "RC.App.root" : "RC.MapEditor.root");
                }

                /// Start the components of the system
                StartComponents();

                /// Initialize the UI-core and install the XNA-plugin (TODO: make it configurable)
                UIRoot   root      = new UIRoot(RCAppSetup.ScreenIndex);
                Assembly xnaPlugin = Assembly.Load("RC.UI.XnaPlugin, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
                root.LoadPlugins(xnaPlugin);
                root.InstallPlugins();

                /// Create the UIWorkspace (TODO: make it configurable)
                UIWorkspace workspace = new UIWorkspace(new RCIntVector(1024, 768), RCAppSetup.Mode == RCAppMode.Normal ? new RCIntVector(320, 200) : new RCIntVector(1024, 768));

                if (RCAppSetup.Mode == RCAppMode.Normal)
                {
                    TraceManager.WriteAllTrace("NORMAL STARTUP...", TraceManager.GetTraceFilterID("RC.App.Info"));

                    /// Load the common resource group (TODO: make it configurable?)
                    UIResourceManager.LoadResourceGroup("RC.App.SplashScreen");

                    /// Initialize the pages of the RC application.
                    root.GraphicsPlatform.RenderLoop.FrameUpdate += InitPages;

                    /// Start and run the render loop
                    root.GraphicsPlatform.RenderLoop.Start(workspace.DisplaySize);
                }
                else
                {
                    ConsoleHelper.ShowConsole();
                    TraceManager.WriteAllTrace("STARTING MAP EDITOR...", TraceManager.GetTraceFilterID("RC.MapEditor.Info"));

                    /// Read the parameters from the command line
                    if (RCAppSetup.Mode == RCAppMode.NewMap)
                    {
                        Console.Write("Name of the new map file: ");
                        RCAppSetup.MapFile = Console.ReadLine();
                        if (File.Exists(RCAppSetup.MapFile))
                        {
                            throw new IOException(string.Format("The file '{0}' already exists!", RCAppSetup.MapFile));
                        }
                        Console.Write("Name of the new map: ");
                        RCAppSetup.MapName = Console.ReadLine();
                        Console.Write("Name of the tileset of the new map: ");
                        RCAppSetup.TilesetName = Console.ReadLine();
                        Console.Write("Name of the default terrain of the new map: ");
                        RCAppSetup.DefaultTerrain = Console.ReadLine();
                        Console.Write("Size of the new map: ");
                        RCAppSetup.MapSize = XmlHelper.LoadIntVector(Console.ReadLine());
                    }
                    else if (RCAppSetup.Mode == RCAppMode.LoadMap)
                    {
                        Console.Write("Name of the map file to load: ");
                        RCAppSetup.MapFile = Console.ReadLine();
                    }

                    TraceManager.WriteAllTrace(RCAppSetup.ToString(), TraceManager.GetTraceFilterID("RC.MapEditor.Info"));

                    /// Load the resources for the map editor.
                    UIResourceManager.LoadResourceGroup("RC.MapEditor.Resources");

                    /// Set the default mouse pointer.
                    workspace.SetDefaultMousePointer(UIResourceManager.GetResource <UIPointer>("RC.App.Pointers.NormalPointer"));

                    /// Initialize the page of the map editor.
                    root.GraphicsPlatform.RenderLoop.FrameUpdate += InitMapEditorPage;

                    /// Start and run the render loop
                    root.GraphicsPlatform.RenderLoop.Start(workspace.DisplaySize);
                }

                /// After the render loop has been stopped, release all resources of the UIRoot.
                root.Dispose();

                ComponentManager.StopComponents();
                ComponentManager.UnregisterComponentsAndPlugins();

                /// End of RC application
                if (ConsoleHelper.IsConsoleHidden)
                {
                    Console.Clear();
                    ConsoleHelper.ShowConsole();
                }
            }
            catch (Exception ex)
            {
                /// Catch any exception from the UI-thread, write it to the console and show a "sorry" message-box
                Exception currException = ex;
                Console.WriteLine(currException.ToString());
                while (currException.InnerException != null)
                {
                    currException = currException.InnerException;
                    Console.WriteLine(currException.ToString());
                }

                MessageBox.Show("An internal error happened and the application will be closed.\nSee the contents of installed traces for more information!", "Sorry");
            }
        }