/// <summary> /// Gets a GUIFont. /// </summary> /// <param name="strFontName">The name of the font</param> /// <returns>A GUIFont instance representing the strFontName or a default GUIFont if the strFontName does not exists.</returns> public static GUIFont GetFont(string strFontName) { lock (Renderlock) { if (strFontName != null) { // Try to interpret the font name as an alias before searching for the font. string fn = null; if (!_dictFontAlias.TryGetValue(strFontName, out fn)) { fn = strFontName; } for (int i = 0; i < _listFonts.Count; ++i) { GUIFont font = _listFonts[i]; if (font.FontName == fn) { return(font); } } } // just return a font return(GetFont("debug")); } }
public override void Dispose() { _previousProperty = ""; _listItems.DisposeAndClearList(); _font = null; base.Dispose(); }
public override void PreAllocResources() { base.PreAllocResources(); float fWidth = 0, fHeight = 0; _font = GUIFontManager.GetFont(_fontName); if (null == _font) { return; } _font.GetTextExtent("afy", ref fWidth, ref fHeight); try { _itemHeight = (int)(fHeight); float fTotalHeight = (float)_height; _itemsPerPage = (int)Math.Floor(fTotalHeight / (fHeight * _lineSpacing)); if (_itemsPerPage == 0) { _itemsPerPage = 1; } } catch (Exception) { _itemHeight = 1; _itemsPerPage = 1; } }
/// <summary> /// This function is called after all of the XmlSkinnable fields have been filled /// with appropriate data. /// Use this to do any construction work other than simple data member assignments, /// for example, initializing new reference types, extra calculations, etc.. /// </summary> public override sealed void FinalizeConstruction() { base.FinalizeConstruction(); if (_fontName == null) { _fontName = string.Empty; } if (_fontName != "" && _fontName != "-") { _font = GUIFontManager.GetFont(_fontName); } GUILocalizeStrings.LocalizeLabel(ref _labelText); if (_labelText == null) { _labelText = string.Empty; } if (_labelText.IndexOf("#") >= 0) { _containsProperty = true; } CachedLabel(); }
/// <summary> /// This function is called after all of the XmlSkinnable fields have been filled /// with appropriate data. /// Use this to do any construction work other than simple data member assignments, /// for example, initializing new reference types, extra calculations, etc.. /// </summary> public override sealed void FinalizeConstruction() { base.FinalizeConstruction(); GUILocalizeStrings.LocalizeLabel(ref _label); // The labelTail is used to fill the backend of a scrolling label for both wrapping and non-wrapping labels // The wrapString is the text that joins the back to the front of a wrapping label (not used if the label should not wrap). if (_userWrapString.Length > 0) { _labelTail = "" + _userWrapString[_userWrapString.Length - 1]; _wrapString = _userWrapString.Substring(0, _userWrapString.Length - 1); } _labelControl = new GUILabelControl(_parentControlId, 0, _positionX, _positionY, _width, _height, _fontName, _label, _textColor, _textAlignment, _textVAlignment, false, _shadowAngle, _shadowDistance, _shadowColor) { CacheFont = false, ParentControl = this }; _labelControl.SetAnimations(Animations); if (_fontName != "" && _fontName != "-") { _font = GUIFontManager.GetFont(_fontName); } if (_label.IndexOf("#", System.StringComparison.Ordinal) >= 0) { _containsProperty = true; } }
/// <summary> /// Frees the control its DirectX resources. /// </summary> public override void Dispose() { base.Dispose(); _previousText = ""; _listLabels.DisposeAndClearList(); _font = null; }
/// <summary> /// Frees the control its DirectX resources. /// </summary> public override void Dispose() { base.Dispose(); _imageCheckMarkFocused.SafeDispose(); _imageCheckMarkNonFocused.SafeDispose(); _font = null; }
/// <summary> /// Allocates the control its DirectX resources. /// </summary> public override void AllocResources() { base.AllocResources(); _imageCheckMarkFocused.AllocResources(); _imageCheckMarkNonFocused.AllocResources(); _font = GUIFontManager.GetFont(_fontName); }
static void Main() { device = IrrlichtDevice.CreateDevice(DriverType.Direct3D9, new Dimension2Di(1280, 768)); // minimum: 1024 (which is 16x64) x 768 (which is 16x48) if (device == null) { return; } device.SetWindowCaption("Pathfinding - Irrlicht Engine"); device.OnEvent += new IrrlichtDevice.EventHandler(device_OnEvent); VideoDriver driver = device.VideoDriver; GUIFont font = device.GUIEnvironment.GetFont("../../media/fontlucida.png"); Color fontNormalColor = Color.SolidWhite; Color fontActionColor = Color.SolidYellow; Texture pathfindingTexture = driver.GetTexture("../../media/pathfinding.png"); int cellSize = pathfindingTexture.Size.Height; pathfinding = new Pathfinding(64, 48, cellSize, 0, 0); pathfinding.SetCell(4, 4, Pathfinding.CellType.Start); pathfinding.SetCell(pathfinding.Width - 5, pathfinding.Height - 5, Pathfinding.CellType.Finish); while (device.Run()) { driver.BeginScene(ClearBufferFlag.Color); pathfinding.FindPath(); pathfinding.Draw(driver, pathfindingTexture); // draw info panel Vector2Di v = new Vector2Di(pathfinding.Width * pathfinding.CellSize + 20, 20); font.Draw("FPS: " + driver.FPS, v, fontNormalColor); v.Y += 32; font.Draw("Map size: " + pathfinding.Width + " x " + pathfinding.Height, v, fontNormalColor); v.Y += 16; font.Draw("Shortest path: " + (pathfinding.PathLength == -1 ? "N/A" : pathfinding.PathLength.ToString()), v, fontNormalColor); v.Y += 16; font.Draw("Calculation time: " + pathfinding.PathCalcTimeMs + " ms", v, fontNormalColor); v.Y += 32; font.Draw(workMode ? "[LMB] Set cell impassable" : "[LMB] Set Start cell", v, fontActionColor); v.Y += 16; font.Draw(workMode ? "[RMB] Set cell passable" : "[RMB] Set Finish cell", v, fontActionColor); v.Y += 16; font.Draw("[Space] Change mode", v, fontActionColor); v.Y += 32; font.Draw("[F1] Clean up the map", v, fontActionColor); v.Y += 16; font.Draw("[F2] Add random blocks", v, fontActionColor); driver.EndScene(); } device.Drop(); }
public override void Dispose() { _previousProperty = ""; _itemList.DisposeAndClearList(); base.Dispose(); _upDownControl.SafeDispose(); _font = null; }
/// <summary> /// Free any direct3d resources /// </summary> public override void Dispose() { //_labelText = string.Empty; _font = null; _reCalculate = true; GUIPropertyManager.OnPropertyChanged -= GUIPropertyManager_OnPropertyChanged; base.Dispose(); }
public override void FinalizeConstruction() { base.FinalizeConstruction(); int x1 = 16; int y1 = 16; GUIGraphicsContext.ScalePosToScreenResolution(ref x1, ref y1); _imageFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height, _textureFocusName); _imageFocused.ParentControl = this; _imageFocused.DimColor = DimColor; _imageNonFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height, _textureNoFocusName); _imageNonFocused.ParentControl = this; _imageNonFocused.DimColor = DimColor; _imageBackground = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height, _backgroundTextureName); _imageBackground.ParentControl = this; _imageBackground.DimColor = DimColor; _imageLeft = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _leftTextureWidth, _leftTextureHeight, _leftTextureName); _imageLeft.DimColor = DimColor; _imageLeft.ParentControl = this; _imageLeftFocus = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _leftTextureFocusWidth, _leftTextureFocusHeight, _leftFocusName); _imageLeftFocus.ParentControl = this; _imageLeftFocus.DimColor = DimColor; _imageRight = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _rightTextureWidth, _rightTextureHeight, _rightTextureName); _imageRight.ParentControl = this; _imageRight.DimColor = DimColor; _imageRightFocus = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _rightTextureFocusWidth, _rightTextureFocusHeight, _rightFocusName); _imageRightFocus.ParentControl = this; _imageRightFocus.DimColor = DimColor; if (_fontName != "" && _fontName != "-") { _font = GUIFontManager.GetFont(_fontName); } GUILocalizeStrings.LocalizeLabel(ref _label); _imageFocused.Filtering = false; _imageNonFocused.Filtering = false; _imageBackground.Filtering = false; _imageLeft.Filtering = false; _imageLeftFocus.Filtering = false; _imageRight.Filtering = false; _imageRightFocus.Filtering = false; _labelControl = new GUILabelControl(_parentControlId); _labelControl.CacheFont = true; _labelControl.ParentControl = this; _labelControl.SetShadow(_shadowAngle, _shadowDistance, _shadowColor); }
void Awake() { guiFont = new GUIFont() { FontColor = Color.magenta, FontSize = 160, Position = new Rect(0, 180, 400, 170) }; }
public override void FinalizeConstruction() { base.FinalizeConstruction(); _font = GUIFontManager.GetFont(_fontName); if (_property.IndexOf("#", StringComparison.Ordinal) >= 0) { _containsProperty = true; } }
void Awake() { guiFont = new GUIFont() { FontColor = Color.white, FontSize = 30, Position = new Rect(100, 100, 100, 20) }; }
/// <summary> /// Set the text of the control. /// </summary> /// <param name="strFontName">The font name.</param> /// <param name="strLabel">The text.</param> /// <param name="dwColor">The font color.</param> public void SetLabel(string strFontName, string strLabel, long dwColor) { if (strFontName == null || strLabel == null) { return; } _label = strLabel; _textColor = dwColor; _fontName = strFontName; _font = GUIFontManager.GetFont(_fontName); }
static void drawPreviewPlateTooltip() { if (hoveredNode == null || !hoveredNode.Visible) { return; } int k = hoveredNode.ID; Texture t = hoveredNode.GetMaterial(0).GetTexture(0); if (t != null && t.Name.Path != "NoPreviewTexture") { k = hoveredNode.ID & (0xFFFFFFF ^ SelectableNodeIdFlag); } string s = previewPlateInfo.ContainsKey(k) ? previewPlateInfo[k] : "???"; if (s != null) { Vector2Di p = irr.Device.CursorControl.Position + new Vector2Di(16); GUIFont f = irr.GUI.Skin.GetFont(GUIDefaultFont.Default); Dimension2Di d = f.GetDimension(s); d.Inflate(16, 12); Recti r = new Recti(p, d); VideoDriver v = irr.Driver; int ax = r.LowerRightCorner.X - v.ScreenSize.Width; int ay = r.LowerRightCorner.Y - v.ScreenSize.Height; if (ax > 0 || ay > 0) { if (ax < 0) { ax = 0; } if (ay < 0) { ay = 0; } r.Offset(-ax, -ay); } v.Draw2DRectangle(r, new Color(0xbb223355)); v.Draw2DRectangleOutline(r, new Color(0xbb445577)); f.Draw(s, r.UpperLeftCorner + new Vector2Di(8, 6), Color.SolidYellow); } }
/// <summary> /// Create a banner image of the specified Size, outputting the input text on it /// </summary> /// <param name="sizeImage">Size of the image to be generated</param> /// <param name="label">Text to be output on the image</param> /// <returns>a bitmap object</returns> private static Bitmap drawSimpleBanner(Size sizeImage, string label) { Bitmap image = new Bitmap(sizeImage.Width, sizeImage.Height); Graphics gph = Graphics.FromImage(image); //gph.FillRectangle(new SolidBrush(Color.FromArgb(50, Color.White)), new Rectangle(0, 0, sizeImage.Width, sizeImage.Height)); GUIFont fontList = GUIFontManager.GetFont(s_sFontName); Font font = new Font(fontList.FontName, 36); gph.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; gph.DrawString(label, font, new SolidBrush(Color.FromArgb(200, Color.White)), 5, (sizeImage.Height - font.GetHeight()) / 2); gph.Dispose(); return(image); }
public Texture2D AddTextureNoOffset(GUIFont font, Texture2D texture, DialoguePosition dp) { if(this.content.image != null) { Texture2D tex = this.content.image as Texture2D; Rect b = new Rect(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height); b.x += dp.boxPadding.x; b.y = texture.height-b.y-b.height; texture = TextureDrawer.AddTexture(texture, b, tex.GetPixels()); } else texture = font.AddTextTexture(texture, this, 0, Vector2.zero, dp.showShadow, dp.shadowOffset); return texture; }
public Texture2D GetTexture(GUIFont font) { Texture2D texture = null; if(this.content.image != null) { texture = this.content.image as Texture2D; } else { texture = font.GetTextTexture(this.content.text, (int)this.bounds.width, (int)this.bounds.height); } return texture; }
public override void AllocResources() { if (null == _font) { return; } base.AllocResources(); _upDownControl.AllocResources(); _font = GUIFontManager.GetFont(_fontName); _upDownControl.WindowId = this._windowId; Calculate(); }
public void AddFont(string n, GUIFont f) { if(name == null) { name = new string[] {n}; font = new GUIFont[] {f}; } else { name = ArrayHelper.Add(n, name); font = ArrayHelper.Add(f, font); } }
static void Main() { device = IrrlichtDevice.CreateDevice(DriverType.OpenGL, new Dimension2Di(800, 600)); device.SetWindowCaption("Sphere Camera - Irrlicht Engine"); driver = device.VideoDriver; scene = device.SceneManager; sphere = scene.AddSphereSceneNode(5, 100); sphere.SetMaterialTexture(0, driver.GetTexture("../../media/earth.jpg")); sphere.TriangleSelector = scene.CreateTriangleSelector(sphere.Mesh, sphere); sphere.TriangleSelector.Drop(); scene.AmbientLight = new Colorf(0.2f, 0.2f, 0.2f); LightSceneNode light = scene.AddLightSceneNode(); light.Position = new Vector3Df(-10, 10, -10); camera = new SphereCamera(device, new Vector3Df(0), 8, 20, 10, 0, 0); camera.Inclination = 200; path = new SpherePath(5.4f); GUIFont font = device.GUIEnvironment.BuiltInFont; device.OnEvent += new IrrlichtDevice.EventHandler(device_OnEvent); device.PostEvent(new Event('r', KeyCode.KeyR, true)); // pretend user pressed [R] while (device.Run()) { driver.BeginScene(); scene.DrawAll(); path.Draw(driver); font.Draw("Press [Arrows], [LMB] and [Mouse Scroll] to change view", 10, 10, Color.SolidYellow); font.Draw("Press [RMB] on Earth to place new path point", 10, 20, Color.SolidYellow); font.Draw("Press [R] to reload path data from file", 10, 30, Color.SolidYellow); font.Draw("Press [C] to clean up", 10, 40, Color.SolidYellow); font.Draw(driver.FPS.ToString() + " fps", 10, driver.ScreenSize.Height - 40, Color.SolidYellow); font.Draw(path.PointCount.ToString() + " point(s)", 10, driver.ScreenSize.Height - 30, Color.SolidYellow); font.Draw(camera.ToString(), 10, driver.ScreenSize.Height - 20, Color.SolidYellow); driver.EndScene(); device.Yield(); } path.Drop(); device.Drop(); }
static void Main() { device = IrrlichtDevice.CreateDevice(DriverType.Direct3D9, new Dimension2Di(1280, 720)); if (device == null) { return; } VideoDriver driver = device.VideoDriver; SceneManager scene = device.SceneManager; device.SetWindowCaption("Abstract Trace - Irrlicht Engine"); device.OnEvent += Device_OnEvent; GUIFont font = device.GUIEnvironment.GetFont("../../media/fontlucida.png"); Color textColor = Color.SolidWhite; CameraSceneNode camera = scene.AddCameraSceneNode(); camera.FarValue = 20000; SceneNodeAnimator a = scene.CreateFlyCircleAnimator(new Vector3Df(), (AbstractTrace.CubeSize * AbstractTrace.GridDim) / 1.25f, 0.000025f, new Vector3Df(0.1f, 1, 0)); camera.AddAnimator(a); a.Drop(); trace = new AbstractTrace(device); trace.Init(); while (device.Run()) { driver.BeginScene(); scene.DrawAll(); if (!isPaused) { trace.Step(); } trace.Draw(drawGenerator); font.Draw("[G]enerator: " + (drawGenerator ? "ON" : "OFF"), new Vector2Di(20, 20), textColor); font.Draw("[P]ause: " + (isPaused ? "ON" : "OFF"), new Vector2Di(20, 35), textColor); font.Draw("Cubes: " + trace.GetTotalCubeCount(), new Vector2Di(20, 50), textColor); font.Draw("FPS: " + driver.FPS, new Vector2Di(20, 65), textColor); driver.EndScene(); } trace.Drop(); device.Drop(); }
void Awake() { guiFont = new GUIFont() { FontColor = Color.cyan, FontSize = 160, Position = new Rect(0, 180, 400, 170) }; mainCamera = GameObject.Find("Main Camera"); mainCamera.AddComponent<AudioSource>(); mainCamera.audio.clip = gameClearClip; mainCamera.audio.Play(); }
void Awake() { guiFont = new GUIFont() { FontColor = Color.cyan, FontSize = 160, Position = new Rect(0, 180, 400, 170) }; mainCamera = GameObject.Find("Main Camera"); mainCamera.AddComponent <AudioSource>(); mainCamera.audio.clip = gameClearClip; mainCamera.audio.Play(); }
/// <summary> /// Allocate any direct3d sources /// </summary> public override void AllocResources() { _propertyHasChanged = true; if (_registeredForEvent == false) { GUIPropertyManager.OnPropertyChanged -= GUIPropertyManager_OnPropertyChanged; GUIPropertyManager.OnPropertyChanged += GUIPropertyManager_OnPropertyChanged; _registeredForEvent = true; } _font = GUIFontManager.GetFont(_fontName); Update(); base.AllocResources(); }
void Awake() { guiFont = new GUIFont() { FontColor = Color.black, FontSize = 30, Position = new Rect(180, 60, 200, 30) }; logo = new GUIFont() { Backgorund = logoTexture, Position = new Rect(220, 280, 400, 240) }; }
/// <summary> /// Converts the font count to its string representation /// </summary> /// <param name="context"></param> /// <param name="culture"></param> /// <param name="value"></param> /// <param name="destinationType"></param> /// <returns></returns> public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) { int fontID = (int)value; GUIFont font = GUIProject.CurrentProject.GetFont(fontID); if (font != null) { return(font.Name); } } return("None"); }
public override void FinalizeConstruction() { base.FinalizeConstruction(); _upDownControl = new GUISpinControl(_controlId, _controlId, _spinControlPositionX, _spinControlPositionY, _spinControlWidth, _spinControlHeight, _upTextureName, _downTextureName, _upTextureNameFocus, _downTextureNameFocus, _fontName, _colorSpinColor, GUISpinControl.SpinType.SPIN_CONTROL_TYPE_INT, Alignment.ALIGN_LEFT); _upDownControl.ParentControl = this; _font = GUIFontManager.GetFont(_fontName); if (_property.IndexOf("#") >= 0) { _containsProperty = true; } SetText(_property); }
static void Main(string[] args) { device = IrrlichtDevice.CreateDevice(DriverType.OpenGL, new Dimension2Di(1024, 600)); device.SetWindowCaption("LightningShots - Irrlicht Engine"); VideoDriver driver = device.VideoDriver; SceneManager smgr = device.SceneManager; device.FileSystem.AddFileArchive("../../media/map-20kdm2.pk3"); AnimatedMesh mesh = smgr.GetMesh("20kdm2.bsp"); MeshSceneNode node = smgr.AddMeshSceneNode(mesh.GetMesh(0)); node.Position = new Vector3Df(-1300, -144, -1249); node.SetMaterialType(MaterialType.LightMapLightingM4); node.SetMaterialFlag(MaterialFlag.Lighting, true); node.TriangleSelector = smgr.CreateTriangleSelector(node.Mesh, node); node.TriangleSelector.Drop(); smgr.AmbientLight = new Colorf(0.15f, 0.14f, 0.13f); CameraSceneNode camera = smgr.AddCameraSceneNodeFPS(); lightningShot = new LightningShot(smgr, node.TriangleSelector); device.OnEvent += new IrrlichtDevice.EventHandler(device_OnEvent); device.CursorControl.Visible = false; while (device.Run()) { driver.BeginScene(true, true, new Color(100, 80, 75)); smgr.DrawAll(); lightningShot.Draw(device.Timer.Time); GUIFont f = device.GUIEnvironment.BuiltInFont; f.Draw("Use [LMB] to shoot", 10, 10, Color.OpaqueYellow); f.Draw("Total lightnings: " + lightningShot.TotalLightnings, 10, 20, Color.OpaqueWhite); f.Draw("Total shots: " + lightningShot.TotalShots, 10, 30, Color.OpaqueWhite); f.Draw(driver.FPS + " fps", 10, 40, Color.OpaqueWhite); driver.EndScene(); } lightningShot.Drop(); device.Drop(); }
public LabelContent(GUIContent c, float x, float y, Color t, Color s, GUIFont font) { this.content = c; this.textColor = t; this.shadowColor = s; Vector2 size; if(this.content.image != null) { size = new Vector2(this.content.image.width, this.content.image.height); } else { size = font.GetTextSize(this.content.text); } this.bounds = new Rect(x, y, size.x, size.y); }
public MyEventReceiver(IrrlichtDevice device, SceneNode room, SceneNode earth) { device.OnEvent += new IrrlichtDevice.EventHandler(device_OnEvent); // store pointer to room so we can change its drawing mode this.driver = device.VideoDriver; this.room = room; this.earth = earth; GUIEnvironment env = device.GUIEnvironment; // set a nicer font GUIFont font = env.GetFont("../../media/fonthaettenschweiler.bmp"); if (font != null) { env.Skin.SetFont(font); } // add window and listbox GUIWindow window = env.AddWindow(new Recti(460, 375, 630, 470), false, "Use 'E' + 'R' to change"); this.listBox = env.AddListBox(new Recti(2, 22, 165, 88), window); this.listBox.AddItem("Diffuse"); this.listBox.AddItem("Bump mapping"); this.listBox.AddItem("Parallax mapping"); this.listBox.SelectedIndex = 1; // create problem text this.problemText = env.AddStaticText( "Your hardware or this renderer is not able to use the needed shaders for this material. Using fall back materials.", new Recti(150, 20, 470, 80)); this.problemText.OverrideColor = new Color(255, 255, 255, 100); // set start material (prefer parallax mapping if available) MaterialRenderer renderer = this.driver.GetMaterialRenderer(MaterialType.ParallaxMapSolid); if (renderer != null && renderer.Capability == 0) { this.listBox.SelectedIndex = 2; } // set the material which is selected in the listbox setMaterial(); }
public override void AllocResources() { base.AllocResources(); _font = GUIFontManager.GetFont(_fontName); _imageTop.AllocResources(); _imageBottom.AllocResources(); _imageMid.AllocResources(); _imageRight.AllocResources(); _imageLeft.AllocResources(); _imageFillBackground.AllocResources(); _imageFill1.AllocResources(); _imageFill2.AllocResources(); _imageFill3.AllocResources(); if (_imageFillMarker != null) { _imageFillMarker.AllocResources(); _imageFillMarker.Height = _height - 6; _imageFillMarker.Filtering = false; } _imageTick.AllocResources(); _imageLogo.AllocResources(); _imageTop.Filtering = false; _imageBottom.Filtering = false; _imageMid.Filtering = false; _imageRight.Filtering = false; _imageLeft.Filtering = false; _imageFill1.Filtering = false; _imageFill2.Filtering = false; _imageFill3.Filtering = false; _imageTick.Filtering = false; if (_height == 0) { _height = _imageRight.TextureHeight; } // _imageTop.Height=_height; _imageRight.Height = _height; _imageLeft.Height = _height; _imageMid.Height = _height; _imageFill1.Height = _height - 6; _imageFill2.Height = _height - 6; _imageFill3.Height = _height - 6; //_imageTick.Height=_height; }
/// <summary> /// Frees the control its DirectX resources. /// </summary> public override void Dispose() { //UnsubscribeEventHandlers(); base.Dispose(); _imageFocused.SafeDispose(); _imageNonFocused.SafeDispose(); _imageBackground.SafeDispose(); _imageLeft.SafeDispose(); _imageLeftFocus.SafeDispose(); _imageRight.SafeDispose(); _imageRightFocus.SafeDispose(); _labelControl.SafeDispose(); _font = null; _showSelect = false; Clear(); }
public Texture2D AddTexture(Texture2D hudTexture, Character c, Vector2 pos, GUIFont font, int hudID) { if(HUDElementType.TEXT.Equals(this.type)) { hudTexture = font.AddTextTexture(hudTexture, this.text[GameHandler.GetLanguage()], this.GetAnchoredRect(pos, font.GetTextSize(this.text[GameHandler.GetLanguage()]), this.bounds), DataHolder.Color(this.textColor), DataHolder.Color(this.shadowColor), 0, Vector2.zero, this.showShadow, this.shadowOffset, false); } else if(HUDElementType.IMAGE.Equals(this.type)) { this.GetImage(); if(this.texture != null) { Vector2 scaledSize = TextureDrawer.GetScaledSize(this.texture, this.bounds, this.scaleMode); hudTexture = TextureDrawer.AddTexture(hudTexture, new Rect(this.bounds.x+pos.x, pos.y-this.bounds.y-scaledSize.y, scaledSize.x, scaledSize.y), TextureDrawer.GetScaledPixels(this.texture, scaledSize, this.bounds, this.scaleMode)); } } else if(HUDElementType.NAME.Equals(this.type)) { GUIContent gc = null; if(HUDContentType.TEXT.Equals(this.contentType)) { if(HUDNameType.CHARACTER.Equals(this.nameType)) gc = new GUIContent(c.GetName()); else if(HUDNameType.CLASS.Equals(this.nameType)) gc = new GUIContent(DataHolder.Classes().GetName(c.currentClass)); else if(HUDNameType.STATUS.Equals(this.nameType)) gc = new GUIContent(DataHolder.StatusValues().GetName(this.statusID)); } else if(HUDContentType.ICON.Equals(this.contentType)) { if(HUDNameType.CHARACTER.Equals(this.nameType)) gc = new GUIContent(c.GetIcon()); else if(HUDNameType.CLASS.Equals(this.nameType)) gc = new GUIContent(DataHolder.Classes().GetIcon(c.currentClass)); else if(HUDNameType.STATUS.Equals(this.nameType)) gc = new GUIContent(DataHolder.StatusValues().GetIcon(this.statusID)); } else if(HUDContentType.BOTH.Equals(this.contentType)) { if(HUDNameType.CHARACTER.Equals(this.nameType)) gc = c.GetContent(); else if(HUDNameType.CLASS.Equals(this.nameType)) gc = DataHolder.Classes().GetContent(c.currentClass); else if(HUDNameType.STATUS.Equals(this.nameType)) gc = DataHolder.StatusValues().GetContent(this.statusID); } if(gc != null) { Vector2 size = Vector2.zero; float gap = 0; if("" != gc.text) { size = font.GetTextSize(gc.text); if(gc.image != null) { gap = font.GetTextSize(" ").x; size.x += gap; } } if(gc.image != null) { size.x += gc.image.width; if(size.y < gc.image.height) size.y = gc.image.height; } Rect rect = this.GetAnchoredRect(pos, size, this.bounds); if(gc.image != null) { Texture2D tex = gc.image as Texture2D; hudTexture = TextureDrawer.AddTexture(hudTexture, new Rect(rect.x, rect.y, gc.image.width, gc.image.height), tex.GetPixels()); rect.x += gc.image.width+gap; rect.width -= gc.image.width+gap; } if("" != gc.text) { hudTexture = font.AddTextTexture(hudTexture, gc.text, rect, DataHolder.Color(this.textColor), DataHolder.Color(this.shadowColor), 0, Vector2.zero, this.showShadow, this.shadowOffset, false); } } } else if(HUDElementType.STATUS.Equals(this.type)) { c.status[this.statusID].lastValueHUD[hudID] = c.status[this.statusID].GetValue(); if(HUDDisplayType.TEXT.Equals(this.displayType)) { string txt = c.status[this.statusID].GetValue().ToString(); if(c.status[this.statusID].IsConsumable() && this.showMax) { txt += this.divider+c.status[c.status[this.statusID].maxStatus].GetValue().ToString(); } hudTexture = font.AddTextTexture(hudTexture, txt, this.GetAnchoredRect(pos, font.GetTextSize(txt), this.bounds), DataHolder.Color(this.textColor), DataHolder.Color(this.shadowColor), 0, Vector2.zero, this.showShadow, this.shadowOffset, false); } else if(HUDDisplayType.BAR.Equals(this.displayType) && c.status[this.statusID].IsConsumable()) { float v1 = c.status[this.statusID].GetValue(); float v2 = c.status[c.status[this.statusID].maxStatus].GetValue(); v2 /= 100; v1 /= v2; this.GetImage(); if(this.texture != null) { Rect b = new Rect(this.bounds.x, this.bounds.y, this.bounds.width*v1/100, this.bounds.height); Vector2 scaledSize = TextureDrawer.GetScaledSize(this.texture, b, this.scaleMode); hudTexture = TextureDrawer.AddTexture(hudTexture, new Rect(b.x+pos.x, pos.y-b.y-scaledSize.y, scaledSize.x, scaledSize.y), TextureDrawer.GetScaledPixels(this.texture, scaledSize, b, this.scaleMode)); } } } else if(HUDElementType.TIMEBAR.Equals(this.type) || HUDElementType.USED_TIMEBAR.Equals(this.type) || HUDElementType.CASTTIME.Equals(this.type)) { float v1 = 0; float v2 = 0; if(HUDElementType.TIMEBAR.Equals(this.type)) { v1 = c.timeBar; v2 = DataHolder.BattleSystem().maxTimebar; c.timeBarHUD[hudID] = v1; } else if(HUDElementType.USED_TIMEBAR.Equals(this.type)) { v1 = c.usedTimeBar; v2 = DataHolder.BattleSystem().maxTimebar; c.usedTimeBarHUD[hudID] = v1; } else if(HUDElementType.CASTTIME.Equals(this.type)) { v1 = c.GetSkillCastTime(); v2 = c.GetSkillCastTimeMax(); c.castTimeHUD[hudID] = v1; } if(HUDDisplayType.TEXT.Equals(this.displayType)) { string txt = ((int)v1).ToString(); hudTexture = font.AddTextTexture(hudTexture, txt, this.GetAnchoredRect(pos, font.GetTextSize(txt), this.bounds), DataHolder.Color(this.textColor), DataHolder.Color(this.shadowColor), 0, Vector2.zero, this.showShadow, this.shadowOffset, false); } else if(HUDDisplayType.BAR.Equals(this.displayType) && v2 > 0) { v2 /= 100; v1 /= v2; this.GetImage(); if(this.texture != null) { Rect b = new Rect(this.bounds.x, this.bounds.y, this.bounds.width*v1/100, this.bounds.height); Vector2 scaledSize = TextureDrawer.GetScaledSize(this.texture, b, this.scaleMode); hudTexture = TextureDrawer.AddTexture(hudTexture, new Rect(b.x+pos.x, pos.y-b.y-scaledSize.y, scaledSize.x, scaledSize.y), TextureDrawer.GetScaledPixels(this.texture, scaledSize, b, this.scaleMode)); } } } else if(HUDElementType.EFFECT.Equals(this.type)) { c.effectHUD = false; int maxView = this.rows*this.columns; float cellWidth = this.bounds.width; float cellHeight = this.bounds.height; cellWidth -= this.spacing*(this.columns-1); cellHeight -= this.spacing*(this.rows-1); cellWidth /= this.columns; cellHeight /= this.rows; int currentColumn = 0; int currentRow = 0; for(int i=0; i<c.effect.Length; i++) { if(i >= maxView) { break; } else { GUIContent gc = null; if(HUDContentType.TEXT.Equals(this.contentType)) { gc = new GUIContent(DataHolder.Effects().GetName(c.effect[i].realID)); } else if(HUDContentType.ICON.Equals(this.contentType)) { gc = new GUIContent(DataHolder.Effects().GetIcon(c.effect[i].realID)); } else if(HUDContentType.BOTH.Equals(this.contentType)) { gc = DataHolder.Effects().GetContent(c.effect[i].realID); } if(gc != null) { Rect rect = new Rect(this.bounds.x+cellWidth*currentColumn+this.spacing*currentColumn, this.bounds.y+cellHeight*currentRow+this.spacing*currentRow, cellWidth, cellHeight); Vector2 size = Vector2.zero; float gap = 0; if("" != gc.text) { size = font.GetTextSize(gc.text); if(gc.image != null) { gap = font.GetTextSize(" ").x; size.x += gap; } } if(gc.image != null) { size.x += gc.image.width; if(size.y < gc.image.height) size.y = gc.image.height; } rect = this.GetAnchoredRect(pos, size, rect); if(gc.image != null) { Texture2D tex = gc.image as Texture2D; hudTexture = TextureDrawer.AddTexture(hudTexture, new Rect(rect.x, rect.y, gc.image.width, gc.image.height), tex.GetPixels()); rect.x += gc.image.width+gap; rect.width -= gc.image.width+gap; } if("" != gc.text) { hudTexture = font.AddTextTexture(hudTexture, gc.text, rect, DataHolder.Color(this.textColor), DataHolder.Color(this.shadowColor), 0, Vector2.zero, this.showShadow, this.shadowOffset, false); } currentColumn++; } if(currentColumn >= this.columns) { currentColumn = 0; currentRow++; } } } } else if(HUDElementType.VARIABLE.Equals(this.type)) { string txt = this.GetVariableText(); if(txt != null && txt != "") { hudTexture = font.AddTextTexture(hudTexture, txt, this.GetAnchoredRect(pos, font.GetTextSize(txt), this.bounds), DataHolder.Color(this.textColor), DataHolder.Color(this.shadowColor), 0, Vector2.zero, this.showShadow, this.shadowOffset, false); } this.lastVarText = txt; } return hudTexture; }
private void AddCharacter(Vector2 pos, Character c, GUIFont font) { this.texture.SetPixels((int)pos.x, (int)pos.y, (int)this.bounds.width, (int)this.bounds.height, this.bgTexture); pos.y += this.bounds.height; for(int j=0; j<this.element.Length; j++) { this.texture = this.element[j].AddTexture(this.texture, c, pos, font, this.realID); } }
public MultiContent(string text, DialoguePosition dp) { this.font = DataHolder.Fonts().GetFont(dp.skin.font); GUIStyle shadowStyle = new GUIStyle(dp.skin.label); shadowStyle.normal.textColor = DataHolder.Color(1); GUIStyle textStyle = new GUIStyle(dp.skin.label); textStyle.wordWrap = false; TextPosition textPosition = new TextPosition(dp.boxBounds, dp.boxPadding, dp.lineSpacing); textPosition.bounds.width -= (dp.boxPadding.x + dp.boxPadding.z); textPosition.bounds.height -= (dp.boxPadding.y + dp.boxPadding.w); this.originalText = text; this.label = new LabelContent[0]; this.currentColor = 0; this.shadowColor = -1; int oldColor = 0; int oldShadowColor = -1; this.textPos = 0; int i = 0; int nl = 0; int fs = 0; int skip = 0; bool lineBreak = false; this.xPos = 0; this.yPos = 0; bool setNextX = false; bool setNextY = false; float nextX = 0; float nextY = 0; string addstring = ""; bool addSpace = false; bool finished = false; Vector2 v = Vector2.zero; Color tCol; Color sCol; Texture2D icon = null; GUIContent part = null; LabelContent nextLabel; while(!finished) { skip = 0; lineBreak = false; oldColor = this.currentColor; oldShadowColor = this.shadowColor; icon = null; part = null; tCol = DataHolder.Color(this.currentColor); if(this.shadowColor == -1 || this.shadowColor >= DataHolder.Colors().GetDataCount()) { sCol = DataHolder.Color(1); } else { sCol = DataHolder.Color(this.shadowColor); } fs = text.IndexOf("#", this.textPos); nl = text.IndexOf("\n", this.textPos); if(fs != -1 && (nl == -1 || fs < nl)) { i = fs; } else { i = nl; } if(i == -1) { i = text.Length - 1; finished = true; } if(setNextX) { this.xPos = nextX; setNextX = false; } if(setNextY) { this.yPos = nextY; setNextY = false; } if(!finished) { if (text[i].ToString() == "#") { if((text.Length - i) >= 1) { string nextChar = text[i+1].ToString(); if(nextChar == "c" || nextChar == "s") { // set text color for the next part int nS = text.IndexOf("#", i+1); if(nS != -1) { string sub = text.Substring(i, nS-i+1); skip = sub.Length+1; try { if(nextChar == "c") { this.currentColor = int.Parse(sub.Substring(2, sub.Length-3)); } else if(nextChar == "s") { this.shadowColor = int.Parse(sub.Substring(2, sub.Length-3)); } } catch(System.Exception e) { Debug.Log(e.Message); if(nextChar == "c") { this.currentColor = 0; } else if(nextChar == "s") { this.shadowColor = -1; } } } } else if(nextChar == "!") { this.currentColor = 0; this.shadowColor = -1; skip = 3; if((text.Length - (i+skip-1)) >= 1 && (text.Substring(i+skip-1, 1) == "\n" || text.Substring(i+skip-1, 1) == "\r")) { lineBreak = true; skip += 1; } } else if(nextChar == "#") { i++; skip = 2; } else if(nextChar == "p") { nextChar = text[i+2].ToString(); // set x or y position for the next text part int nS = text.IndexOf("#", i+2); if(nS != -1) { string sub = text.Substring(i, nS-i+1); skip = sub.Length+1; try { if(nextChar == "x") { nextX = float.Parse(sub.Substring(3, sub.Length-4)); setNextX = true; } else if(nextChar == "y") { nextY = float.Parse(sub.Substring(3, sub.Length-4)); setNextY = true; } } catch(System.Exception e) { Debug.Log(e.Message); } } } else if(nextChar == "i" && text[i+2].ToString() == "q") // icons { int nS = text.IndexOf("#", i+4); if(nS != -1) { string sub = text.Substring(i, nS-i+1); skip = sub.Length+1; sub = text.Substring(i+5, nS-(i+5)); int index = int.Parse(sub); sub = text.Substring(i+3, 2); if(sub == "sv") icon = DataHolder.StatusValues().GetIcon(index); else if(sub == "se") icon = DataHolder.Effects().GetIcon(index); else if(sub == "el") icon = DataHolder.Elements().GetIcon(index); else if(sub == "st") icon = DataHolder.SkillTypes().GetIcon(index); else if(sub == "sk") icon = DataHolder.Skills().GetIcon(index); else if(sub == "it") icon = DataHolder.ItemTypes().GetIcon(index); else if(sub == "im") icon = DataHolder.Items().GetIcon(index); else if(sub == "ir") icon = DataHolder.ItemRecipes().GetIcon(index); else if(sub == "ep") icon = DataHolder.EquipmentParts().GetIcon(index); else if(sub == "wp") icon = DataHolder.Weapons().GetIcon(index); else if(sub == "am") icon = DataHolder.Armors().GetIcon(index); else if(sub == "cl") icon = DataHolder.Classes().GetIcon(index); else if(sub == "ch") icon = DataHolder.Characters().GetIcon(index); else if(sub == "en") icon = DataHolder.Enemies().GetIcon(index); else icon = null; } } else { skip = 2; } } else { skip = 1; } } else if((text.Length - i) >= 1 && (text.Substring(i, 1) == "\n" || text.Substring(i, 1) == "\r")) { lineBreak = true; skip = 2; } i--; } if((i-this.textPos+1) > 0) { if(addSpace) addstring = " "; else addstring = ""; part = new GUIContent(addstring + text.Substring(this.textPos, i - this.textPos + 1)); nextLabel = new LabelContent(part, this.xPos, this.yPos, tCol, sCol, font); v = new Vector2(nextLabel.bounds.width, nextLabel.bounds.height); if ((this.xPos+v.x) > textPosition.bounds.width) { i = this.textPos+font.GetFittingTextLength(part.text, textPosition.bounds.width-this.xPos); lineBreak = true; icon = null; skip = 0; int tmp = i; part = new GUIContent(addstring + text.Substring(this.textPos, i - this.textPos + 1)); v = font.GetTextSize(part.text); while (this.xPos+v.x > textPosition.bounds.width) { i--; if((i-this.textPos+1) > 0) { part = new GUIContent(addstring + text.Substring(this.textPos, i - this.textPos + 1)); } else { part = new GUIContent(""); } v = font.GetTextSize(part.text); tmp = i+1; } while(" " != text[i].ToString() && i>(this.textPos+1)) { i--; } if((i-this.textPos+1) > 0 && " " == text[i].ToString()) { part = new GUIContent(addstring + text.Substring(this.textPos, i - this.textPos + 1)); } else { i = tmp; } nextLabel = new LabelContent(part, this.xPos, this.yPos, tCol, sCol, font); v = new Vector2(nextLabel.bounds.width, nextLabel.bounds.height); this.currentColor = oldColor; this.shadowColor = oldShadowColor; finished = false; } this.label = ArrayHelper.Add(nextLabel, this.label); this.xPos += v.x; if(!lineBreak) { addSpace = part.text[part.text.Length-1].ToString() == " "; } } if(icon != null) { part = new GUIContent(icon); nextLabel = new LabelContent(part, this.xPos, this.yPos, tCol, sCol, font); v = new Vector2(nextLabel.bounds.width, nextLabel.bounds.height); //this.xPos += font.GetTextSize(".").x; if(this.xPos+v.x <= textPosition.bounds.width) { this.label = ArrayHelper.Add(nextLabel, this.label); this.xPos += v.x; addSpace = true; icon = null; } else { lineBreak = true; } } if(lineBreak) { this.xPos = 0; this.yPos += v.y + textPosition.lineSpacing; addSpace = false; if(i+skip < text.Length && " " == text[i+skip].ToString()) { i++; } if((this.yPos+v.y) > (textPosition.bounds.height) && !dp.scrollable) { finished = true; } else if(icon != null) { part = new GUIContent(icon); nextLabel = new LabelContent(part, this.xPos, this.yPos, tCol, sCol, font); v = new Vector2(nextLabel.bounds.width, nextLabel.bounds.height); //this.xPos += font.GetTextSize(".").x; this.label = ArrayHelper.Add(nextLabel, this.label); this.xPos += v.x; addSpace = true; icon = null; } } else if(finished) { this.xPos = 0; this.yPos += v.y + textPosition.lineSpacing; } this.textPos = i + skip; } }
public static GUIFont[] Remove(int index, GUIFont[] list) { ArrayList tmp = new ArrayList(); foreach(GUIFont str in list) tmp.Add(str); tmp.RemoveAt(index); return tmp.ToArray(typeof(GUIFont)) as GUIFont[]; }
public static GUIFont[] Add(GUIFont n, GUIFont[] list) { ArrayList tmp = new ArrayList(); foreach(GUIFont str in list) tmp.Add(str); tmp.Add(n); return tmp.ToArray(typeof(GUIFont)) as GUIFont[]; }