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); }
/// <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"); } }
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(); DynamicString.RegisterResolver("RC.UI.UIWorkspace.PixelScaling", delegate() { return("2;2"); }); UIResourceManager.LoadResourceGroup("RC.App.SplashScreen"); UIResourceManager.LoadResourceGroup("RC.App.CommonResources"); UISprite mouseIcon = root.GraphicsPlatform.SpriteManager.LoadSprite("..\\..\\..\\..\\sprites\\pointers\\normal_pointer.png", new RCIntVector(2, 2)); mouseIcon.TransparentColor = new RCColor(255, 0, 255); mouseIcon.Upload(); UIPointer pointer = new UIPointer(mouseIcon, new RCIntVector(0, 0)); display = new TestUIObject(new RCIntVector(2, 2), new RCIntVector(0, 0), new RCIntRectangle(0, 0, 400, 300)); workspace = new MySensitiveAnimObject(new RCIntVector(40, 50), new RCIntRectangle(0, 0, 320, 200), "Workspace", RCColor.Gray, RCColor.Gray); display.Attach(workspace); MyButton button = new MyButton(new RCIntVector(5, 12), new RCIntVector(60, 20), RCColor.Brown, RCColor.Yellow, RCColor.White, "MyButton"); //button.MouseSensor.Enter += delegate(UISensitiveObject sender) { Console.WriteLine("BUTTON ENTER"); }; //button.MouseSensor.Move += delegate(UISensitiveObject sender, UIMouseEventArgs args) { Console.WriteLine("BUTTON MOVE"); }; //button.MouseSensor.Leave += delegate(UISensitiveObject sender) { Console.WriteLine("BUTTON LEAVE"); }; MyCheckbox checkbox = new MyCheckbox(new RCIntVector(70, 12), new RCIntVector(80, 20), RCColor.Red, RCColor.Green, RCColor.LightRed, RCColor.LightGreen, RCColor.White, "MyCheckbox"); MyDropdownSelector selector = new MyDropdownSelector(new RCIntVector(5, 50), new RCIntVector(60, 20), new string[4] { "option0", "option1", "option2", "option3" }, RCColor.WhiteHigh, RCColor.Red, RCColor.Green, RCColor.LightGreen, RCColor.LightBlue, RCColor.Gray); //selector.MouseSensor.Enter += delegate(UISensitiveObject sender) { Console.WriteLine("SELECTOR ENTER"); }; //selector.MouseSensor.Move += delegate(UISensitiveObject sender, UIMouseEventArgs args) { Console.WriteLine("SELECTOR MOVE"); }; //selector.MouseSensor.Leave += delegate(UISensitiveObject sender) { Console.WriteLine("SELECTOR LEAVE"); }; MySlider sliderHorz = new MySlider(new RCIntVector(5, 80), new RCIntVector(80, 10), new UISlider.Settings() { Alignment = UISlider.Alignment.Horizontal, IntervalLength = 10, SliderBottom = 3, SliderLeft = 1, SliderRight = 1, SliderTop = 3, TimeBetweenTrackings = 300, TrackingValueChange = 3, TrackPos = new RCIntVector(10, 5), TrackSize = new RCIntVector(60, 1) }, RCColor.Green, RCColor.LightGreen, RCColor.White); MySlider sliderVert = new MySlider(new RCIntVector(5, 100), new RCIntVector(10, 80), new UISlider.Settings() { Alignment = UISlider.Alignment.Vertical, IntervalLength = 10, SliderBottom = 1, SliderLeft = 3, SliderRight = 3, SliderTop = 1, TimeBetweenTrackings = 300, TrackingValueChange = 3, TrackPos = new RCIntVector(5, 10), TrackSize = new RCIntVector(60, 1) }, RCColor.Green, RCColor.LightGreen, RCColor.White); workspace.Attach(button); workspace.Attach(checkbox); workspace.Attach(selector); workspace.Attach(sliderHorz); workspace.Attach(sliderVert); workspace.AttachSensitive(button); workspace.AttachSensitive(checkbox); workspace.AttachSensitive(selector); workspace.AttachSensitive(sliderHorz); workspace.AttachSensitive(sliderVert); button.Pressed += delegate(UISensitiveObject sender) { TraceManager.WriteAllTrace("BUTTON PRESSED", TraceManager.GetTraceFilterID("RC.UI.Test.Info")); checkbox.IsEnabled = !checkbox.IsEnabled; }; checkbox.CheckedStateChanged += delegate(UISensitiveObject sender) { TraceManager.WriteAllTrace("CHECKBOX STATE CHANGED", TraceManager.GetTraceFilterID("RC.UI.Test.Info")); button.IsEnabled = checkbox.IsChecked; }; selector.SelectedIndexChanged += delegate(UISensitiveObject sender) { TraceManager.WriteAllTrace("SELECTED INDEX CHANGED", TraceManager.GetTraceFilterID("RC.UI.Test.Info")); }; sliderHorz.SelectedValueChanged += delegate(UISensitiveObject sender) { TraceManager.WriteAllTrace(string.Format("SELECTED VALUE CHANGED (horizontal): {0}", sliderHorz.SelectedValue), TraceManager.GetTraceFilterID("RC.UI.Test.Info")); }; sliderVert.SelectedValueChanged += delegate(UISensitiveObject sender) { TraceManager.WriteAllTrace(string.Format("SELECTED VALUE CHANGED (vertical): {0}", sliderVert.SelectedValue), TraceManager.GetTraceFilterID("RC.UI.Test.Info")); }; UIMouseManager mouseMgr = new UIMouseManager(workspace); mouseMgr.SetDefaultMousePointer(pointer); root.GraphicsPlatform.RenderManager.Attach(display); root.GraphicsPlatform.RenderLoop.Start(new RCIntVector(800, 600)); root.Dispose(); }
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(); UISprite mouseIcon = root.GraphicsPlatform.SpriteManager.LoadSprite("..\\..\\..\\..\\sprites\\pointers\\normal_pointer.png", new RCIntVector(2, 2)); mouseIcon.TransparentColor = new RCColor(255, 0, 255); mouseIcon.Upload(); UIPointer pointer = new UIPointer(mouseIcon, new RCIntVector(0, 0)); DynamicString.RegisterResolver("RC.UI.UIWorkspace.PixelScaling", delegate() { return("2;2"); }); UIResourceManager.LoadResourceGroup("RC.App.SplashScreen"); UIResourceManager.LoadResourceGroup("RC.App.CommonResources"); display = new TestUIObject(new RCIntVector(2, 2), new RCIntVector(0, 0), new RCIntRectangle(0, 0, 400, 300)); workspace = new MySensitiveObject(new RCIntVector(40, 50), new RCIntRectangle(0, 0, 320, 200), "Workspace", RCColor.Gray, RCColor.Gray); display.Attach(workspace); MySensitiveObject objA = new MySensitiveObject(new RCIntVector(5, 12), new RCIntRectangle(0, 0, 130, 90), "A", RCColor.Blue, RCColor.LightBlue); MySensitiveObject objB = new MySensitiveObject(new RCIntVector(5, 107), new RCIntRectangle(0, 0, 130, 90), "B", RCColor.Blue, RCColor.LightBlue); MyDraggableObject objC = new MyDraggableObject(new RCIntVector(140, 12), new RCIntRectangle(0, 0, 130, 180), "C", RCColor.Cyan, RCColor.LightCyan); workspace.Attach(objA); workspace.Attach(objB); workspace.Attach(objC); workspace.AttachSensitive(objA); workspace.AttachSensitive(objB); workspace.AttachSensitive(objC); MySensitiveObject objAA = new MySensitiveObject(new RCIntVector(5, 12), new RCIntRectangle(0, 0, 120, 30), "AA", RCColor.Green, RCColor.LightGreen); MySensitiveObject objAB = new MySensitiveObject(new RCIntVector(5, 47), new RCIntRectangle(0, 0, 120, 30), "AB", RCColor.Green, RCColor.LightGreen); MySensitiveObject objBA = new MySensitiveObject(new RCIntVector(5, 12), new RCIntRectangle(0, 0, 120, 30), "BA", RCColor.Green, RCColor.LightGreen); MySensitiveObject objBB = new MySensitiveObject(new RCIntVector(5, 47), new RCIntRectangle(0, 0, 120, 30), "BB", RCColor.Green, RCColor.LightGreen); MyDraggableObject objCA = new MyDraggableObject(new RCIntVector(5, 12), new RCIntRectangle(0, 0, 120, 30), "CA", RCColor.Magenta, RCColor.LightMagenta); MyDraggableObject objCB = new MyDraggableObject(new RCIntVector(5, 47), new RCIntRectangle(0, 0, 120, 30), "CB", RCColor.Gray, RCColor.White); objA.Attach(objAA); objA.Attach(objAB); objB.Attach(objBA); objB.Attach(objBB); objC.Attach(objCA); objC.Attach(objCB); objA.AttachSensitive(objAA); objA.AttachSensitive(objAB); objB.AttachSensitive(objBA); objB.AttachSensitive(objBB); objC.AttachSensitive(objCA); objC.AttachSensitive(objCB); //root.SystemEventQueue.Subscribe<UIKeyboardEventArgs>(OnKeyboardEvent); //root.SystemEventQueue.Subscribe<UIMouseEventArgs>(OnMouseEvent); UIMouseManager mouseMgr = new UIMouseManager(workspace); mouseMgr.SetDefaultMousePointer(pointer); root.GraphicsPlatform.RenderManager.Attach(display); root.GraphicsPlatform.RenderLoop.Start(new RCIntVector(800, 600)); root.Dispose(); }