/// <summary> /// Note: consider making a struct that packages all these settings, or one or two structs /// At this rate, the number of variables for this function is growing to the point that it /// deteroriates readability /// </summary> /// <param name="scene"></param> /// <param name="consoleHeight"></param> /// <param name="initEnabled"></param> /// <param name="verbosity"></param> /// <param name="useGlobalVerbosity"></param> /// <param name="useTimeStamps"></param> /// <param name="consoleFont"></param> /// <param name="initOpen"></param> /// <param name="consolePrefix"></param> /// <param name="consoleTextRenderDepth"></param> /// <param name="consoleBackgroundRenderDepth"></param> /// <param name="logBufferSize"></param> public void Initialize(gxtSceneGraph scene, float consoleHeight, bool initEnabled = true, gxtVerbosityLevel verbosity = gxtVerbosityLevel.INFORMATIONAL, bool useGlobalVerbosity = true, bool useTimeStamps = false, SpriteFont consoleFont = null, bool initOpen = true, string consolePrefix = "console: ", float consoleTextRenderDepth = 0.0f, float consoleBackgroundRenderDepth = 1.0f, int logBufferSize = 6) { gxtDebug.Assert(logBufferSize >= 0); gxtDebug.Assert(gxtDisplayManager.SingletonIsInitialized); this.enabled = initEnabled; this.useGlobalVerbosity = useGlobalVerbosity; this.verbosityLevel = verbosity; this.useTimeStamps = useTimeStamps; this.isOpen = initOpen; this.text = string.Empty; // all these colors and depths should be taken as parameters this.consoleSpriteFont = consoleFont; this.informationalMaterial = new gxtMaterial(isOpen, Color.White, consoleTextRenderDepth); this.successMaterial = new gxtMaterial(isOpen, Color.Green, consoleTextRenderDepth); this.warningMaterial = new gxtMaterial(isOpen, Color.Yellow, consoleTextRenderDepth); this.criticalMaterial = new gxtMaterial(isOpen, Color.Red, consoleTextRenderDepth); this.inputMaterial = new gxtMaterial(isOpen, Color.Black, consoleTextRenderDepth); this.backgroundMaterial = new gxtMaterial(isOpen, new Color(255, 255, 255, 65), consoleBackgroundRenderDepth); this.resolutionWidth = gxtDisplayManager.Singleton.ResolutionWidth; this.resolutionHeight = gxtDisplayManager.Singleton.ResolutionHeight; this.consoleWidth = resolutionWidth; this.consoleHeight = gxtMath.Clamp(consoleHeight, 0.0f, resolutionHeight); gxtDisplayManager.Singleton.resolutionChanged += OnResolutionChange; // these should be taken as parameters this.horizontalPadding = 15.0f; this.verticalPadding = 0.0f; this.verticalTextSpacing = 5.0f; // background rectangle and container node backgroundRectangle = new gxtRectangle(consoleWidth, consoleHeight, backgroundMaterial); consoleNode = new gxtSceneNode(); consoleNode.Position = new Vector2(0.0f, (-resolutionHeight * 0.5f) + (consoleHeight * 0.5f)); consoleNode.AttachDrawable(backgroundRectangle); // textnode this.consolePrefix = consolePrefix; consoleTextField = new gxtTextField(consoleFont, consolePrefix + "_", inputMaterial); consoleTextNode = new gxtSceneNode(); consoleTextNode.AttachDrawable(consoleTextField); consoleNode.AddChild(consoleTextNode); this.logBufferSize = logBufferSize; this.logWriteIndex = 0; logBufferNodes = new gxtSceneNode[logBufferSize]; logBufferEntries = new gxtTextField[logBufferSize]; // consider using a fixed size queue instead gxtISceneNode topAnchor = new gxtSceneNode(); topAnchor.Position = new Vector2((consoleWidth * 0.5f) - horizontalPadding, (-consoleHeight * 0.5f) + verticalPadding); logBufferNodes[0] = topAnchor; logBufferEntries[0] = new gxtTextField(consoleFont); logBufferEntries[0].Material = new gxtMaterial(); logBufferNodes[0].AttachDrawable(logBufferEntries[0]); gxtISceneNode current = topAnchor; for (int i = 1; i < logBufferSize; ++i) { gxtISceneNode node = new gxtSceneNode(); logBufferNodes[i] = node; current.AddChild(node); node.Position = new Vector2(0.0f, verticalTextSpacing); current = node; gxtTextField tf = new gxtTextField(consoleFont); logBufferEntries[i] = tf; tf.Material = new gxtMaterial(); current.AttachDrawable(tf); } consoleNode.AddChild(topAnchor); scene.AddNode(consoleNode); AdjustConsoleTextPos(); }
private void InitializeRectangles() { float spacing = 100.0f; //float sign = 1.0f; int verticalVariation = 35; gxtRandom rng = new gxtRandom(); gxtISceneNode node; gxtRectangle rect = new gxtRectangle(65, 35); for (int i = 0; i < NUM_RECTANGLES; i++) { //gxtIDrawable drawable = new gxtDrawable(Color.Blue); //drawable.Entity = rect; float x = (float)(spacing * i); float y = rng.Next(-verticalVariation, verticalVariation); float rot = (float)rng.NextFloat() * gxtMath.TWO_PI; node = new gxtSceneNode(); node.Position = new Vector2(x, y); node.Rotation = rot; //node.ColorOverlay = Color.Blue; //node.AttachDrawable(drawable); sceneGraph.AddNode(node); gxtAABB aabb = node.GetAABB(); nodes.Add(node); drawableCollider.AddObject(node, ref aabb); //gxtRectangle rect = new gxtRectangle(new Vector2(x, y), new Vector2(65, 35), Color.Blue, 0.5f); //rect.Rotation = rot; //drawables.Add(rect); //drawManager.Add(rect); //gxtAABB rectAABB = rect.GetAABB(); //drawableCollider.AddObject(rect, ref rectAABB); } }