protected int _startVisibleCharIdx = 0; //idx included #endregion Fields #region Constructors public FLabelAnimate(string fontName, string text, bool startVisible=false, FTextParams textParams=null) : base(fontName, text, textParams==null?new FTextParams():textParams) { if (startVisible) { _endVisibleCharIdx=text.Length; } }
public void LoadFont(string name, string elementName, string configPath, FTextParams fontTextParams) { FAtlasElement element = GetElementWithName(elementName); FFont font = new FFont(name, element, configPath, fontTextParams); _fonts.Add(font); _fontsByName.Add(name, font); }
public FFont(string name, FAtlasElement element, string configPath, FTextParams fontTextParams) { _name = name; _element = element; _configPath = configPath; _fontTextParams = fontTextParams; LoadAndParseConfigFile(); }
public FFont(string name, FAtlasElement element, string configPath, float offsetX, float offsetY, FTextParams textParams) { _name = name; _element = element; _configPath = configPath; _textParams = textParams; _offsetX = offsetX; _offsetY = offsetY; LoadAndParseConfigFile(); }
public FFont(string name, FAtlasElement element, string configPath, float offsetX, float offsetY, FTextParams textParams) { _name = name; _element = element; _configPath = configPath; _textParams = textParams; _offsetX = offsetX * Futile.displayScale / Futile.resourceScale; _offsetY = offsetY * Futile.displayScale / Futile.resourceScale; LoadAndParseConfigFile(); }
public FLabel (string fontName, string text, FTextParams textParams) : base() { _fontName = fontName; _text = text; _font = Futile.atlasManager.GetFontWithName(_fontName); _textParams = textParams; Init(FFacetType.Quad, _font.element, 0); CreateTextQuads(); }
public FLabel(string fontName, string text, FTextParams textParams) : base() { _fontName = fontName; _text = text; _font = Futile.atlasManager.GetFontWithName(_fontName); _textParams = textParams; Init(FFacetType.Quad, _font.element, 0); CreateTextQuads(); }
private static void LoadFont(string fontName, float offsetX, float offsetY,float lineHeightOffset, float kerningOffset) { //offsetY -= 1f; //they're all off by 1 offsetY -= 2f; lineHeightOffset -= 6; FTextParams textParams; textParams = new FTextParams(); textParams.kerningOffset = kerningOffset; textParams.lineHeightOffset = lineHeightOffset; Futile.atlasManager.LoadFont(fontName,"Fonts/"+fontName, "Fonts/"+fontName, offsetX,offsetY,textParams); }
private static void LoadFont(string fontName, float offsetX, float offsetY, float lineHeightOffset, float kerningOffset) { //offsetY -= 1f; //they're all off by 1 offsetY -= 2f; lineHeightOffset -= 6; FTextParams textParams; textParams = new FTextParams(); textParams.kerningOffset = kerningOffset; textParams.lineHeightOffset = lineHeightOffset; Futile.atlasManager.LoadFont(fontName, "Fonts/" + fontName, "Fonts/" + fontName, offsetX, offsetY, textParams); }
virtual public FLabel AddLabel(string fontName, string text, FTextParams textParams, Color color) { if (_label != null) { RemoveChild(_label); } _label = new FLabel(fontName, text, textParams); AddChild(_label); _label.color = color; _label.anchorX = _label.anchorY = 0.5f; _label.x = -_anchorX * _sprite.width + _sprite.width / 2; _label.y = -_anchorY * _sprite.height + _sprite.height / 2; return(_label); }
// Use this for initialization void Start() { //instance = this; Go.defaultEaseType = EaseType.Linear; Go.duplicatePropertyRule = DuplicatePropertyRuleType.RemoveRunningProperty; bool landscape = true; bool portrait = false; bool isIPad = SystemInfo.deviceModel.Contains("iPad"); bool shouldSupportPortraitUpsideDown = isIPad && portrait; //only support portrait upside-down on iPad FutileParams fparams = new FutileParams(landscape, landscape, portrait, shouldSupportPortraitUpsideDown); fparams.backgroundColor = new Color(0.1f, 0.1f, 0.1f); fparams.AddResolutionLevel(480.0f, 1.0f, 1.0f, "_Scale1"); //iPhone fparams.AddResolutionLevel(960.0f, 2.0f, 2.0f, "_Scale2"); //iPhone retina fparams.AddResolutionLevel(1024.0f, 2.0f, 2.0f, "_Scale2"); //iPad fparams.AddResolutionLevel(1280.0f, 2.0f, 2.0f, "_Scale2"); //Nexus 7 fparams.AddResolutionLevel(2048.0f, 4.0f, 4.0f, "_Scale4"); //iPad Retina fparams.origin = new Vector2(0.0f, 0.0f); Futile.instance.Init(fparams); Futile.atlasManager.LoadAtlas("Atlases/UIFonts"); Futile.atlasManager.LoadAtlas("Atlases/GameAtlas"); FPWorld.Create(64.0f); FTextParams textParams; textParams = new FTextParams(); textParams.lineHeightOffset = -8.0f; Futile.atlasManager.LoadFont("Franchise", "FranchiseFont" + Futile.resourceSuffix, "Atlases/FranchiseFont" + Futile.resourceSuffix, -2.0f, -5.0f, textParams); textParams = new FTextParams(); textParams.kerningOffset = -0.5f; textParams.lineHeightOffset = -8.0f; Futile.atlasManager.LoadFont("CubanoInnerShadow", "Cubano_InnerShadow" + Futile.resourceSuffix, "Atlases/CubanoInnerShadow" + Futile.resourceSuffix, 0.0f, 2.0f, textParams); GoToPage(PageType.BitmaskPuzzleShapesGame); }
public FPseudoHtmlText(string fontName, string text, FTextParams textParams, float maxWidth, PseudoHtmlTextAlign align, float lineOffset,object actionsDelegate) { _fontName = fontName; _text = text.Replace("\n"," "); _textParams = textParams; _maxWidth = maxWidth; _align=align; _lineOffset=lineOffset; _actionsDelegate=actionsDelegate; _stylesStack=new List<Dictionary<string, string>>(); PushDefaultStyles(); _buttonActions=new Dictionary<FButton, string>(); _contentContainer = new FContainer (); AddChild (_contentContainer); Update (); }
virtual public FLabel AddLabel (string fontName, string text, FTextParams textParams, Color color) { if(_label != null) { RemoveChild(_label); } _label = new FLabel(fontName, text, textParams); AddChild(_label); _label.color = color; _label.anchorX = _label.anchorY = 0.5f; _label.x = -_anchorX*_sprite.width+_sprite.width/2; _label.y = -_anchorY*_sprite.height+_sprite.height/2; return _label; }
public FLetterQuadLine[] GetQuadInfoForText(string text, FTextParams textParams) { int lineCount = 0; int letterCount = 0; char[] letters = text.ToCharArray(); //at some point these should probably be pooled and reused so we're not allocing new ones all the time FLetterQuadLine[] lines = new FLetterQuadLine[10]; int lettersLength = letters.Length; for(int c = 0; c<lettersLength; ++c) { char letter = letters[c]; if(letter == ASCII_NEWLINE) { lines[lineCount] = new FLetterQuadLine(); lines[lineCount].letterCount = letterCount; lines[lineCount].quads = new FLetterQuad[letterCount]; lineCount++; letterCount = 0; } else { letterCount++; } } lines[lineCount] = new FLetterQuadLine(); lines[lineCount].letterCount = letterCount; lines[lineCount].quads = new FLetterQuad[letterCount]; FLetterQuadLine[] oldLines = lines; lines = new FLetterQuadLine[lineCount+1]; for(int c = 0; c<lineCount+1; ++c) { lines[c] = oldLines[c]; } lineCount = 0; letterCount = 0; float nextX = 0; float nextY = 0; FCharInfo charInfo; char previousLetter = '\0'; float minX = 100000; float maxX = -100000; float minY = 100000; float maxY = -100000; float usableLineHeight = _lineHeight + textParams.scaledLineHeightOffset + _textParams.scaledLineHeightOffset; for(int c = 0; c<lettersLength; ++c) { char letter = letters[c]; if(letter == ASCII_NEWLINE) { lines[lineCount].bounds = new Rect(minX,minY,maxX-minX,maxY-minY); minX = 100000; maxX = -100000; minY = 100000; maxY = -100000; nextX = 0; nextY -= usableLineHeight; lineCount++; letterCount = 0; } else { FKerningInfo foundKerning = _nullKerning; for(int k = 0; k<_kerningCount; k++) { FKerningInfo kerningInfo = _kerningInfos[k]; if(kerningInfo.first == previousLetter && kerningInfo.second == letter) { foundKerning = kerningInfo; } } //TODO: Reuse letterquads with pooling! FLetterQuad letterQuad = new FLetterQuad(); if(_charInfosByID.ContainsKey(letter)) { charInfo = _charInfosByID[letter]; } else //we don't have that character in the font { //blank, character (could consider using the "char not found square") charInfo = _charInfosByID[0]; } float totalKern = foundKerning.amount + textParams.scaledKerningOffset + _textParams.scaledKerningOffset; nextX += totalKern; letterQuad.charInfo = charInfo; Rect quadRect = new Rect(nextX + charInfo.offsetX, nextY - charInfo.offsetY - charInfo.height, charInfo.width, charInfo.height); letterQuad.rect = quadRect; lines[lineCount].quads[letterCount] = letterQuad; minX = Math.Min (minX, quadRect.xMin); maxX = Math.Max (maxX, quadRect.xMax); maxY = Math.Max (maxY, nextY); minY = Math.Min (minY, nextY - usableLineHeight); // minY = Math.Min (minY, quadRect.yMin); // maxY = Math.Max (maxY, quadRect.yMax); nextX += charInfo.xadvance; letterCount++; } previousLetter = letter; } lines[lineCount].bounds = new Rect(minX,minY,maxX-minX,maxY-minY); return lines; }
public void LoadFont(string name, string elementName, string configPath, float offsetX, float offsetY, FTextParams textParams) { FAtlasElement element = GetElementWithName(elementName); FFont font = new FFont(name,element,configPath, offsetX, offsetY, textParams); _fonts.Add(font); _fontsByName.Add (name, font); }
private void Start() { instance = this; Go.defaultEaseType = EaseType.Linear; Go.duplicatePropertyRule = DuplicatePropertyRuleType.RemoveRunningProperty; //Screen.showCursor = false; //Time.timeScale = 0.1f; bool landscape = true; bool portrait = false; bool isIPad = SystemInfo.deviceModel.Contains("iPad"); bool shouldSupportPortraitUpsideDown = isIPad && portrait; //only support portrait upside-down on iPad FutileParams fparams = new FutileParams(landscape, landscape, portrait, shouldSupportPortraitUpsideDown); fparams.backgroundColor = RXUtils.GetColorFromHex(0x000000); //light blue 0x94D7FF or 0x74CBFF //fparams.AddResolutionLevel(2560.0f, 2.0f, 2.0f, ""); //1280x720 //fparams.AddResolutionLevel(1280.0f, 1.0f, 2.0f, ""); //1280x720 fparams.AddResolutionLevel(1920.0f, 1.5f, 2.0f, ""); //1920x1080 fparams.AddResolutionLevel(960.0f, 0.75f, 2.0f, ""); //960x540 fparams.origin = new Vector2(0.5f,0.5f); Futile.instance.Init (fparams); Futile.atlasManager.LoadAtlas("Atlases/UIAtlas"); Futile.atlasManager.LoadAtlas("Atlases/UIFonts"); Futile.atlasManager.LoadAtlas("Atlases/BackgroundAtlas"); Futile.atlasManager.LoadAtlas("Atlases/GameAtlas"); FTextParams textParams; textParams = new FTextParams(); textParams.lineHeightOffset = -8.0f; Futile.atlasManager.LoadFont("Franchise","FranchiseFont", "Atlases/FranchiseFont", -2.0f,-5.0f,textParams); textParams = new FTextParams(); textParams.kerningOffset = -0.5f; textParams.lineHeightOffset = -8.0f; Futile.atlasManager.LoadFont("CubanoInnerShadow","Cubano_InnerShadow", "Atlases/CubanoInnerShadow", 0.0f,2.0f,textParams); textParams = new FTextParams(); textParams.lineHeightOffset = -8.0f; textParams.kerningOffset = -0.5f; Futile.atlasManager.LoadFont("CubanoBig","Cubano136", "Atlases/Cubano136", 0.0f,2.0f,textParams); GamepadManager.Init(); GameManager.Init(); _stage = Futile.stage; _stage.AddChild(background = new Background()); GoToPage(TPageType.PagePlayerSelect); _stage.ListenForUpdate (HandleUpdate); FSoundManager.isMuted = !GameConfig.IS_SOUND_ON; _stage.ListenForResize(HandleResize); }
private void Start() { Go.defaultEaseType = EaseType.Linear; Go.duplicatePropertyRule = DuplicatePropertyRuleType.RemoveRunningProperty; // Uncomment if you need to delete bad save data on startup // PlayerPrefs.DeleteAll(); //Time.timeScale = 0.1f; //use for checking timings of things in slow motion //only support portrait FutileParams fparams = new FutileParams(true, true, false, true); fparams.backgroundColor = RXUtils.GetColorFromHex(0x050122); fparams.shouldLerpToNearestResolutionLevel = false; fparams.resolutionLevelPickMode = FResolutionLevelPickMode.Closest; bool shouldHaveScale1 = true; bool shouldHaveScale2 = true; bool shouldHaveScale4 = true; #if UNITY_WEBPLAYER //webplayer has everything but scale2 stripped out shouldHaveScale1 = false; shouldHaveScale4 = false; #endif if(shouldHaveScale1) fparams.AddResolutionLevel(480.0f, 1.0f, 1.0f, "_Scale1"); //iPhone if(shouldHaveScale2) fparams.AddResolutionLevel(960.0f, 2.0f, 2.0f, "_Scale2"); //iPhone retina if(shouldHaveScale2) fparams.AddResolutionLevel(1024.0f, 2.0f, 2.0f, "_Scale2"); //iPad if(shouldHaveScale2) fparams.AddResolutionLevel(1136.0f, 2.0f, 2.0f, "_Scale2"); //iPhone 5 retina if(shouldHaveScale2) fparams.AddResolutionLevel(1280.0f, 2.0f, 2.0f, "_Scale2"); //Nexus 7 if(shouldHaveScale4) fparams.AddResolutionLevel(2048.0f, 4.0f, 4.0f, "_Scale4"); //iPad Retina //FOR SCREENSHOTS // if(shouldHaveScale1) fparams.AddResolutionLevel(480.0f, 1.0f, 2.0f, "_Scale2"); //iPhone // if(shouldHaveScale2) fparams.AddResolutionLevel(960.0f, 2.0f, 2.0f, "_Scale2"); //iPhone retina // if(shouldHaveScale2) fparams.AddResolutionLevel(1024.0f, 2.0f, 4.0f, "_Scale4"); //iPad // if(shouldHaveScale2) fparams.AddResolutionLevel(1136.0f, 2.0f, 4.0f, "_Scale4"); //iPhone 5 retina // if(shouldHaveScale2) fparams.AddResolutionLevel(1280.0f, 2.0f, 4.0f, "_Scale4"); //Nexus 7 // if(shouldHaveScale4) fparams.AddResolutionLevel(2048.0f, 4.0f, 4.0f, "_Scale4"); //iPad Retina fparams.origin = new Vector2(0.5f,0.5f); Futile.instance.Init (fparams); Futile.atlasManager.LoadAtlas("Atlases/MainAtlas"); //Futile.atlasManager.LoadImage("Atlases/Fonts/Raleway"); //Futile.atlasManager.LoadImage("Atlases/Fonts/Ostrich"); FTextParams textParams; textParams = new FTextParams(); textParams.kerningOffset = -0.0f; textParams.lineHeightOffset = -15.0f; Futile.atlasManager.LoadFont("Raleway","Fonts/Raleway"+Futile.resourceSuffix, "Atlases/Fonts/Raleway"+Futile.resourceSuffix, -1.0f,-1.0f,textParams); // // textParams = new FTextParams(); // textParams.kerningOffset = -0.0f; // textParams.lineHeightOffset = -15.0f; // Futile.atlasManager.LoadFont("Ostrich","Atlases/Fonts/Ostrich", "Atlases/Fonts/Ostrich"+Futile.resourceSuffix, 0.0f,-2.0f,textParams); // for(int s = 0; s<10; s++) { FSoundManager.PreloadSound("Musical/Note"+s+"_bass"); FSoundManager.PreloadSound("Musical/Note"+s+"_normal"); } Futile.stage.AddChild(new Keeper()); //keeper statically retains itself and never gets removed }
public FLetterQuadLine[] GetQuadInfoForText(string text, FTextParams textParams) { int lineCount = 0; int letterCount = 0; char[] letters = text.ToCharArray(); FLetterQuadLine[] lines = new FLetterQuadLine[10]; for(int c = 0; c<letters.Length; ++c) { char letter = letters[c]; if(letter == ASCII_NEWLINE) { lines[lineCount] = new FLetterQuadLine(); lines[lineCount].letterCount = letterCount; lines[lineCount].quads = new FLetterQuad[letterCount]; lineCount++; letterCount = 0; } else { letterCount++; } } lines[lineCount] = new FLetterQuadLine(); lines[lineCount].letterCount = letterCount; lines[lineCount].quads = new FLetterQuad[letterCount]; FLetterQuadLine[] oldLines = lines; lines = new FLetterQuadLine[lineCount+1]; for(int c = 0; c<lineCount+1; ++c) { lines[c] = oldLines[c]; } lineCount = 0; letterCount = 0; float nextX = 0; float nextY = 0; FCharInfo charInfo; char previousLetter = '\0'; float minX = 100000; float maxX = -100000; float minY = 100000; float maxY = -100000; for(int c = 0; c<letters.Length; ++c) { char letter = letters[c]; if(letter == ASCII_NEWLINE) { lines[lineCount].bounds = new Rect(minX,minY,maxX-minX,maxY-minY); minX = 100000; maxX = -100000; minY = 100000; maxY = -100000; nextX = 0; nextY -= _lineHeight + textParams.scaledLineHeightOffset + _fontTextParams.scaledLineHeightOffset; lineCount++; letterCount = 0; } else { FKerningInfo foundKerning = _nullKerning; foreach(FKerningInfo kerningInfo in _kerningInfos) { if(kerningInfo.first == previousLetter && kerningInfo.second == letter) { foundKerning = kerningInfo; } } //TODO: Reuse letterquads with pooling! FLetterQuad letterQuad = new FLetterQuad(); charInfo = _charInfosByID[letter]; float totalKern = foundKerning.amount + textParams.scaledKerningOffset + _fontTextParams.scaledKerningOffset; nextX += totalKern; letterQuad.charInfo = charInfo; // Rect quadRect = new Rect(nextX + charInfo.offsetX, nextY - charInfo.offsetY - charInfo.height, charInfo.width, charInfo.height); letterQuad.rect = quadRect; lines[lineCount].quads[letterCount] = letterQuad; minX = Math.Min (minX, quadRect.xMin); maxX = Math.Max (maxX, quadRect.xMax); minY = Math.Min (minY, quadRect.yMin); maxY = Math.Max (maxY, quadRect.yMax); nextX += charInfo.xadvance; letterCount++; } previousLetter = letter; } lines[lineCount].bounds = new Rect(minX,minY,maxX-minX,maxY-minY); return lines; }
// Use this for initialization void Start() { //instance = this; Go.defaultEaseType = EaseType.Linear; Go.duplicatePropertyRule = DuplicatePropertyRuleType.RemoveRunningProperty; bool landscape = true; bool portrait = false; bool isIPad = SystemInfo.deviceModel.Contains("iPad"); bool shouldSupportPortraitUpsideDown = isIPad && portrait; //only support portrait upside-down on iPad FutileParams fparams = new FutileParams(landscape, landscape, portrait, shouldSupportPortraitUpsideDown); fparams.backgroundColor = new Color(0.1f, 0.1f, 0.1f); fparams.AddResolutionLevel(480.0f, 1.0f, 1.0f, "_Scale1"); //iPhone fparams.AddResolutionLevel(960.0f, 2.0f, 2.0f, "_Scale2"); //iPhone retina fparams.AddResolutionLevel(1024.0f, 2.0f, 2.0f, "_Scale2"); //iPad fparams.AddResolutionLevel(1280.0f, 2.0f, 2.0f, "_Scale2"); //Nexus 7 fparams.AddResolutionLevel(2048.0f, 4.0f, 4.0f, "_Scale4"); //iPad Retina fparams.origin = new Vector2(0.0f,0.0f); Futile.instance.Init (fparams); Futile.atlasManager.LoadAtlas("Atlases/UIFonts"); Futile.atlasManager.LoadAtlas("Atlases/GameAtlas"); FPWorld.Create(64.0f); FTextParams textParams; textParams = new FTextParams(); textParams.lineHeightOffset = -8.0f; Futile.atlasManager.LoadFont("Franchise","FranchiseFont"+Futile.resourceSuffix, "Atlases/FranchiseFont"+Futile.resourceSuffix, -2.0f,-5.0f,textParams); textParams = new FTextParams(); textParams.kerningOffset = -0.5f; textParams.lineHeightOffset = -8.0f; Futile.atlasManager.LoadFont("CubanoInnerShadow","Cubano_InnerShadow"+Futile.resourceSuffix, "Atlases/CubanoInnerShadow"+Futile.resourceSuffix, 0.0f,2.0f,textParams); GoToPage(PageType.BitmaskPuzzleShapesGame); }
public FLetterQuadLine[] GetQuadInfoForText(string text, FTextParams labelTextParams) { int lineCount = 0; int letterCount = 0; char[] letters = text.ToCharArray(); //at some point these should probably be pooled and reused so we're not allocing new ones all the time //now they're structs though, so it might not be an issue FLetterQuadLine[] lines = new FLetterQuadLine[15]; int lettersLength = letters.Length; for (int c = 0; c < lettersLength; ++c) { char letter = letters[c]; if (letter == ASCII_NEWLINE) { lines[lineCount] = new FLetterQuadLine(); lines[lineCount].letterCount = letterCount; lines[lineCount].quads = new FLetterQuad[letterCount]; lineCount++; letterCount = 0; } else { letterCount++; } } lines[lineCount] = new FLetterQuadLine(); lines[lineCount].letterCount = letterCount; lines[lineCount].quads = new FLetterQuad[letterCount]; FLetterQuadLine[] oldLines = lines; lines = new FLetterQuadLine[lineCount + 1]; for (int c = 0; c < lineCount + 1; ++c) { lines[c] = oldLines[c]; } lineCount = 0; letterCount = 0; float nextX = 0; float nextY = 0; FCharInfo charInfo; char previousLetter = '\0'; float minX = float.MaxValue; float maxX = float.MinValue; float minY = float.MaxValue; float maxY = float.MinValue; float usableLineHeight = _lineHeight + labelTextParams.scaledLineHeightOffset + _textParams.scaledLineHeightOffset; for (int c = 0; c < lettersLength; ++c) { char letter = letters[c]; if (letter == ASCII_NEWLINE) { if (letterCount == 0) { lines[lineCount].bounds = new Rect(0, 0, nextY, nextY - usableLineHeight); } else { lines[lineCount].bounds = new Rect(minX, minY, maxX - minX, maxY - minY); } minX = float.MaxValue; maxX = float.MinValue; minY = float.MaxValue; maxY = float.MinValue; nextX = 0; nextY -= usableLineHeight; lineCount++; letterCount = 0; } else { FKerningInfo foundKerning = _nullKerning; for (int k = 0; k < _kerningCount; k++) { FKerningInfo kerningInfo = _kerningInfos[k]; if (kerningInfo.first == previousLetter && kerningInfo.second == letter) { foundKerning = kerningInfo; } } //TODO: Reuse letterquads with pooling! FLetterQuad letterQuad = new FLetterQuad(); if (_charInfosByID.ContainsKey(letter)) { charInfo = _charInfosByID[letter]; } else //we don't have that character in the font { //blank, character (could consider using the "char not found square") charInfo = _charInfosByID[0]; } float totalKern = foundKerning.amount + labelTextParams.scaledKerningOffset + _textParams.scaledKerningOffset; if (letterCount == 0) { nextX = -charInfo.offsetX; //don't offset the first character } else { nextX += totalKern; } letterQuad.charInfo = charInfo; Rect quadRect = new Rect(nextX + charInfo.offsetX, nextY - charInfo.offsetY - charInfo.height, charInfo.width, charInfo.height); letterQuad.rect = quadRect; lines[lineCount].quads[letterCount] = letterQuad; minX = Math.Min(minX, quadRect.xMin); maxX = Math.Max(maxX, quadRect.xMax); minY = Math.Min(minY, nextY - usableLineHeight); maxY = Math.Max(maxY, nextY); nextX += charInfo.xadvance; letterCount++; } previousLetter = letter; } if (letterCount == 0) //there were no letters, so minX and minY would be crazy if we used them { lines[lineCount].bounds = new Rect(0, 0, nextY, nextY - usableLineHeight); } else { lines[lineCount].bounds = new Rect(minX, minY, maxX - minX, maxY - minY); } return(lines); }
public FLetterQuadLine[] GetQuadInfoForText(string text, FTextParams labelTextParams) { int lineCount = 0; int letterCount = 0; char[] letters = text.ToCharArray(); //at some point these should probably be pooled and reused so we're not allocing new ones all the time //now they're structs though, so it might not be an issue FLetterQuadLine[] lines = new FLetterQuadLine[10]; int lettersLength = letters.Length; for(int c = 0; c<lettersLength; ++c) { char letter = letters[c]; if(letter == ASCII_NEWLINE) { lines[lineCount] = new FLetterQuadLine(); lines[lineCount].letterCount = letterCount; lines[lineCount].quads = new FLetterQuad[letterCount]; lineCount++; letterCount = 0; } else { letterCount++; } } lines[lineCount] = new FLetterQuadLine(); lines[lineCount].letterCount = letterCount; lines[lineCount].quads = new FLetterQuad[letterCount]; FLetterQuadLine[] oldLines = lines; lines = new FLetterQuadLine[lineCount+1]; for(int c = 0; c<lineCount+1; ++c) { lines[c] = oldLines[c]; } lineCount = 0; letterCount = 0; float nextX = 0; float nextY = 0; FCharInfo charInfo; char previousLetter = '\0'; float minX = float.MaxValue; float maxX = float.MinValue; float minY = float.MaxValue; float maxY = float.MinValue; float usableLineHeight = _lineHeight + labelTextParams.scaledLineHeightOffset + _textParams.scaledLineHeightOffset; for(int c = 0; c<lettersLength; ++c) { char letter = letters[c]; if(letter == ASCII_NEWLINE) { if(letterCount == 0) { lines[lineCount].bounds = new Rect(0,0,nextY,nextY - usableLineHeight); } else { lines[lineCount].bounds = new Rect(minX,minY,maxX-minX,maxY-minY); } minX = float.MaxValue; maxX = float.MinValue; minY = float.MaxValue; maxY = float.MinValue; nextX = 0; nextY -= usableLineHeight; lineCount++; letterCount = 0; } else { FKerningInfo foundKerning = _nullKerning; for(int k = 0; k<_kerningCount; k++) { FKerningInfo kerningInfo = _kerningInfos[k]; if(kerningInfo.first == previousLetter && kerningInfo.second == letter) { foundKerning = kerningInfo; } } FLetterQuad letterQuad = new FLetterQuad(); if(!_charInfosByID.TryGetValue(letter,out charInfo)) { charInfo = _charInfosByID[0]; } float totalKern = foundKerning.amount + labelTextParams.scaledKerningOffset + _textParams.scaledKerningOffset; if(letterCount == 0) { nextX = -charInfo.offsetX; //don't offset the first character } else { nextX += totalKern; } letterQuad.charInfo = charInfo; Rect quadRect = new Rect(nextX + charInfo.offsetX, nextY - charInfo.offsetY - charInfo.height, charInfo.width, charInfo.height); letterQuad.rect = quadRect; lines[lineCount].quads[letterCount] = letterQuad; minX = Math.Min (minX, quadRect.xMin); maxX = Math.Max (maxX, quadRect.xMax); minY = Math.Min (minY, nextY - usableLineHeight); maxY = Math.Max (maxY, nextY); nextX += charInfo.xadvance; letterCount++; } previousLetter = letter; } if(letterCount == 0) //there were no letters, so minX and minY would be crazy if we used them { lines[lineCount].bounds = new Rect(0,0,nextY,nextY - usableLineHeight); } else { lines[lineCount].bounds = new Rect(minX,minY,maxX-minX,maxY-minY); } for(int n = 0; n<lineCount+1; n++) { lines[n].bounds.height += labelTextParams.scaledLineHeightOffset + _textParams.scaledLineHeightOffset; } return lines; }
public void LoadFont(string name, string elementName, string configPath, FTextParams fontTextParams) { FAtlasElement element = _allElementsByName[elementName]; FFont font = new FFont(name,element,configPath, fontTextParams); _fonts.Add(font); _fontsByName.Add (name, font); }
private void Start() { Go.defaultEaseType = EaseType.Linear; Go.duplicatePropertyRule = DuplicatePropertyRuleType.RemoveRunningProperty; // Uncomment if you need to delete bad save data on startup // PlayerPrefs.DeleteAll(); //Time.timeScale = 0.1f; //use for checking timings of things in slow motion FutileParams fparams = new FutileParams(true, true, false, false); fparams.backgroundColor = RXUtils.GetColorFromHex(0x050122); fparams.shouldLerpToNearestResolutionLevel = false; fparams.resolutionLevelPickMode = FResolutionLevelPickMode.Closest; bool shouldHaveScale1 = true; bool shouldHaveScale2 = true; bool shouldHaveScale4 = true; #if UNITY_WEBPLAYER //webplayer has everything but scale2 stripped out shouldHaveScale1 = false; shouldHaveScale4 = false; #endif if (shouldHaveScale1) { fparams.AddResolutionLevel(480.0f, 1.0f, 1.0f, "_Scale1"); //iPhone } if (shouldHaveScale2) { fparams.AddResolutionLevel(960.0f, 2.0f, 2.0f, "_Scale2"); //iPhone retina } if (shouldHaveScale2) { fparams.AddResolutionLevel(1024.0f, 2.0f, 2.0f, "_Scale2"); //iPad } if (shouldHaveScale2) { fparams.AddResolutionLevel(1136.0f, 2.0f, 2.0f, "_Scale2"); //iPhone 5 retina } if (shouldHaveScale2) { fparams.AddResolutionLevel(1280.0f, 2.0f, 2.0f, "_Scale2"); //Nexus 7 } if (shouldHaveScale4) { fparams.AddResolutionLevel(2048.0f, 4.0f, 4.0f, "_Scale4"); //iPad Retina } //FOR SCREENSHOTS // if(shouldHaveScale1) fparams.AddResolutionLevel(480.0f, 1.0f, 2.0f, "_Scale2"); //iPhone // if(shouldHaveScale2) fparams.AddResolutionLevel(960.0f, 2.0f, 2.0f, "_Scale2"); //iPhone retina // if(shouldHaveScale2) fparams.AddResolutionLevel(1024.0f, 2.0f, 4.0f, "_Scale4"); //iPad // if(shouldHaveScale2) fparams.AddResolutionLevel(1136.0f, 2.0f, 4.0f, "_Scale4"); //iPhone 5 retina // if(shouldHaveScale2) fparams.AddResolutionLevel(1280.0f, 2.0f, 4.0f, "_Scale4"); //Nexus 7 // if(shouldHaveScale4) fparams.AddResolutionLevel(2048.0f, 4.0f, 4.0f, "_Scale4"); //iPad Retina fparams.origin = new Vector2(0.5f, 0.5f); Futile.instance.Init(fparams); Futile.atlasManager.LoadAtlas("Atlases/MainAtlas"); //Futile.atlasManager.LoadImage("Atlases/Fonts/Raleway"); //Futile.atlasManager.LoadImage("Atlases/Fonts/Ostrich"); FTextParams textParams; textParams = new FTextParams(); textParams.kerningOffset = -0.0f; textParams.lineHeightOffset = -15.0f; Futile.atlasManager.LoadFont("Raleway", "Fonts/Raleway" + Futile.resourceSuffix, "Atlases/Fonts/Raleway" + Futile.resourceSuffix, -1.0f, -1.0f, textParams); // // textParams = new FTextParams(); // textParams.kerningOffset = -0.0f; // textParams.lineHeightOffset = -15.0f; // Futile.atlasManager.LoadFont("Ostrich","Atlases/Fonts/Ostrich", "Atlases/Fonts/Ostrich"+Futile.resourceSuffix, 0.0f,-2.0f,textParams); // for (int s = 0; s < 10; s++) { FSoundManager.PreloadSound("Musical/Note" + s + "_bass"); FSoundManager.PreloadSound("Musical/Note" + s + "_normal"); } Futile.stage.AddChild(new Keeper()); //keeper statically retains itself and never gets removed }
public FLetterQuadLine[] GetQuadInfoForText(string text, FTextParams textParams) { int lineCount = 0; int letterCount = 0; char[] letters = text.ToCharArray(); FLetterQuadLine[] lines = new FLetterQuadLine[10]; for (int c = 0; c < letters.Length; ++c) { char letter = letters[c]; if (letter == ASCII_NEWLINE) { lines[lineCount] = new FLetterQuadLine(); lines[lineCount].letterCount = letterCount; lines[lineCount].quads = new FLetterQuad[letterCount]; lineCount++; letterCount = 0; } else { letterCount++; } } lines[lineCount] = new FLetterQuadLine(); lines[lineCount].letterCount = letterCount; lines[lineCount].quads = new FLetterQuad[letterCount]; FLetterQuadLine[] oldLines = lines; lines = new FLetterQuadLine[lineCount + 1]; for (int c = 0; c < lineCount + 1; ++c) { lines[c] = oldLines[c]; } lineCount = 0; letterCount = 0; float nextX = 0; float nextY = 0; FCharInfo charInfo; char previousLetter = '\0'; float minX = 100000; float maxX = -100000; float minY = 100000; float maxY = -100000; for (int c = 0; c < letters.Length; ++c) { char letter = letters[c]; if (letter == ASCII_NEWLINE) { lines[lineCount].bounds = new Rect(minX, minY, maxX - minX, maxY - minY); minX = 100000; maxX = -100000; minY = 100000; maxY = -100000; nextX = 0; nextY -= _lineHeight + textParams.scaledLineHeightOffset + _fontTextParams.scaledLineHeightOffset; lineCount++; letterCount = 0; } else { FKerningInfo foundKerning = _nullKerning; foreach (FKerningInfo kerningInfo in _kerningInfos) { if (kerningInfo.first == previousLetter && kerningInfo.second == letter) { foundKerning = kerningInfo; } } //TODO: Reuse letterquads with pooling! FLetterQuad letterQuad = new FLetterQuad(); charInfo = _charInfosByID[letter]; float totalKern = foundKerning.amount + textParams.scaledKerningOffset + _fontTextParams.scaledKerningOffset; nextX += totalKern; letterQuad.charInfo = charInfo; // Rect quadRect = new Rect(nextX + charInfo.offsetX, nextY - charInfo.offsetY - charInfo.height, charInfo.width, charInfo.height); letterQuad.rect = quadRect; lines[lineCount].quads[letterCount] = letterQuad; minX = Math.Min(minX, quadRect.xMin); maxX = Math.Max(maxX, quadRect.xMax); minY = Math.Min(minY, quadRect.yMin); maxY = Math.Max(maxY, quadRect.yMax); nextX += charInfo.xadvance; letterCount++; } previousLetter = letter; } lines[lineCount].bounds = new Rect(minX, minY, maxX - minX, maxY - minY); return(lines); }
static Config() { textParams = new FTextParams(); textParams.kerningOffset=-3f; textParams.lineHeightOffset=-6f; }