/// <summary> /// Calculates the Y coordinates of the texts to be displayed. /// </summary> /// <param name="textsToDisplay">The list of texts to be displayed.</param> /// <returns>The calculated Y coordinates.</returns> private List <int> CalculateTextCoordsY(List <UIString> textsToDisplay) { if (textsToDisplay.Count == 0) { return(new List <int>()); } int totalHeightOfTexts = textsToDisplay.Count - 1; foreach (UIString text in textsToDisplay) { totalHeightOfTexts += text.Font.MinimumLineHeight; } List <int> coordsY = new List <int> { this.middle.Y - totalHeightOfTexts / 2 + textsToDisplay[0].Font.CharTopMaximum }; for (int i = 1; i < textsToDisplay.Count; i++) { int previousCoordY = coordsY[i - 1]; UIString previousText = textsToDisplay[i - 1]; UIString currentText = textsToDisplay[i]; coordsY.Add(previousCoordY + previousText.Font.CharBottomMaximum + currentText.Font.CharTopMaximum + 1); } return(coordsY); }
private void FormatText(bool newText) { if (uiFont != null) { float wrapDimension = (internalSize.x / textScale); if (Mathf.Abs(wrapDimension - lastWrapDimension) > 1 || newText) { // if(! newText){ // Debug.Log(wrapDimension + " : " + lastWrapDimension); // } if (textLayout == UITextLayout.Dynamic) { formattedText = text; } else if (textLayout == UITextLayout.StaticWrap || textLayout == UITextLayout.DynamicWrap) { formattedText = UIString.WrapString(text, uiFont, wrapDimension, (int)PixelScaleConstant * fontSize); // Debug.Log(formattedText[formattedText.Length-1]); } lastWrapDimension = wrapDimension; textMesh.text = formattedText; CalculateHitArea(); } } }
public UIQuote(string sp, params string [] t) { Speaker = sp; Quote = new UIString[t.Length]; for (int i = 0; i < t.Length; i++) { Quote[i] = new UIString(t[i]); } }
/// <see cref="IUIRenderContext.RenderString"/> public void RenderString(UIString str, RCIntVector position, RCIntVector textboxSize, UIStringAlignment alignment) { if (this.isClosed) { throw new UIException("Render context unavailable!"); } throw new NotImplementedException(); // TODO: implement this method }
/// <summary> /// Function to get the string in the correct language /// </summary> /// <param name="key">The type of string to get</param> /// <returns>The string in the correct current language set</returns> public static string GetString(UIString key) { // Error Check if (!dictionary[(int)Language].ContainsKey(key) || dictionary[(int)Language][key] == "") { return("NO STRING"); } return(dictionary[(int)Language][key]); }
/// <summary> /// A operational game object entity, that can move, jump and be pronounced dead or alive. /// </summary> /// <param name="game">Current game instance.</param> public Entity(Game game) : base(game) { //Initial values IsStatic = false; Width = 64; Height = 64; IsInteractive = true; SpriteTitle = new UIString(game, game.Content.Load <SpriteFont>("UI/Fonts/DebugFont")); SpriteTitle.Text = string.Empty; }
/// <see cref="UIObject.Render_i"/> protected sealed override void Render_i(IUIRenderContext renderContext) { List <UIString> textsToDisplay = this.GetDisplayedTexts(); List <int> textCoordsY = this.CalculateTextCoordsY(textsToDisplay); for (int i = 0; i < textsToDisplay.Count; i++) { UIString textToDisplay = textsToDisplay[i]; renderContext.RenderString(textToDisplay, new RCIntVector(this.middle.X - textToDisplay.Width / 2, textCoordsY[i])); } }
/// <see cref="RCTextInformationDisplay.GetDisplayedTexts"/> protected override List <UIString> GetDisplayedTexts() { /// Check if there is 1 object is selected. if (this.selectionDetailsView.SelectionCount != 1) { return(new List <UIString>()); } int mapObjectID = this.selectionDetailsView.GetObjectID(0); this.displayedTexts.Clear(); /// Fill the list of displayed text with the armor informations of the selected object. Tuple <int, int> armorInfo = this.mapObjectDetailsView.GetArmorInfo(mapObjectID); if (armorInfo != null) { int originalArmor = armorInfo.Item1; int armorUpgrade = armorInfo.Item2; string armorInfoStr = armorUpgrade != 0 ? string.Format("{0}+{1}", originalArmor, armorUpgrade) : string.Format("{0}", originalArmor); this.armorText[0] = armorInfoStr; this.displayedTexts.Add(this.armorText); } /// Fill the list of displayed text with the weapon informations of the selected object. List <Tuple <string, int, int> > weaponInfoList = this.mapObjectDetailsView.GetWeaponInfo(mapObjectID); foreach (Tuple <string, int, int> weaponInfo in weaponInfoList) { string weaponName = weaponInfo.Item1; int originalDamage = weaponInfo.Item2; int damageUpgrade = weaponInfo.Item3; string weaponInfoStr = damageUpgrade != 0 ? string.Format("{0}+{1}", originalDamage, damageUpgrade) : string.Format("{0}", originalDamage); UIString weaponText = this.weaponTexts[weaponName]; weaponText[0] = weaponInfoStr; this.displayedTexts.Add(weaponText); } return(this.displayedTexts); }
/// <see cref="UIObject.Render_i"/> protected override void Render_i(IUIRenderContext renderContext) { base.Render_i(renderContext); if (this.ConnectionStatus != ConnectionStatusEnum.Online) { return; } renderContext.RenderString(this.mineralsText, MINERAL_TEXT_POS, MINERAL_VESPENE_TEXT_MAXWIDTH); renderContext.RenderString(this.vespeneGasText, VESPENE_TEXT_POS, MINERAL_VESPENE_TEXT_MAXWIDTH); UIString usedSupplyToRender = this.playerView.UsedSupply > this.playerView.TotalSupply ? this.criticalUsedSupplyText : this.normalUsedSupplyText; renderContext.RenderString(usedSupplyToRender, SUPPLY_TEXT_POS, SUPPLY_TEXT_MAXWIDTH); renderContext.RenderString(this.totalSupplyText, SUPPLY_TEXT_POS + new RCIntVector(usedSupplyToRender.Width + 1, 0), SUPPLY_TEXT_MAXWIDTH - usedSupplyToRender.Width - 1); }
public void EntityTypeNameTextWidthTest() { string entityTypeNamesPath = System.IO.Path.Combine(INPUT_DIR, ENTITY_TYPE_NAMES_FILE); string[] entityTypeNames = File.ReadAllLines(entityTypeNamesPath); string[] entityTypeNameWidths = new string[entityTypeNames.Length]; for (int i = 0; i < entityTypeNames.Length; i++) { UIString typeNameString = new UIString(entityTypeNames[i], UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font5"), new RCIntVector(1, 1), RCColor.White); //UISprite typeNameSprite = UIRoot.Instance.GraphicsPlatform.SpriteManager.CreateSprite(RCColor.Black, new RCIntVector(typeNameString.Width, typeNameString.Font.MinimumLineHeight)); //IUIRenderContext typeNameSpriteContext = UIRoot.Instance.GraphicsPlatform.SpriteManager.CreateRenderContext(typeNameSprite); //typeNameSpriteContext.RenderString(typeNameString); entityTypeNameWidths[i] = string.Format("{0} - Width: {1}, Height: {2}", entityTypeNames[i], typeNameString.Width, typeNameString.Font.MinimumLineHeight); typeNameString.Dispose(); } string outputPath = System.IO.Path.Combine(OUTPUT_DIR, ENTITY_TYPE_NAME_WIDTHS_OUT_FILE); File.WriteAllLines(outputPath, entityTypeNameWidths); }
/// <summary> /// Function to add a key-string value to the dictionary /// </summary> /// <param name="key">The key to add this at</param> /// <param name="englishString">The English version of the string</param> /// <param name="japaneseString">The Japanese version of the string</param> private static void addToDictionary(UIString key, string englishString, string japaneseString = "") { dictionary[(int)Language.English].Add(key, englishString); dictionary[(int)Language.日本語].Add(key, japaneseString); }
/// <see cref="UIObject.Render_i"/> protected sealed override void Render_i(IUIRenderContext renderContext) { base.Render_i(renderContext); /// Check if we are online and in single selection mode. if (this.ConnectionStatus != ConnectionStatusEnum.Online) { return; } if (this.selectionDetailsView.SelectionCount != 1) { return; } /// Retrieve the ID and the HP condition of the object. int mapObjectID = this.selectionDetailsView.GetObjectID(0); MapObjectConditionEnum hpCondition = this.mapObjectDetailsView.GetHPCondition(mapObjectID); if (!this.hpIndicatorSprites.ContainsKey(hpCondition)) { return; } /// Render the big icon of the selected object. SpriteRenderInfo hpSprite = this.mapObjectDetailsView.GetBigHPIcon(mapObjectID); renderContext.RenderSprite(this.hpIndicatorSprites[hpCondition][hpSprite.Index], RCDetailsPanel.ICON_POS + hpSprite.DisplayCoords, hpSprite.Section); /// Render the typename of the selected object. UIString typeTextToRender = this.objectTypeTexts[this.mapObjectDetailsView.GetObjectTypeID(mapObjectID)]; RCIntVector typeNameStringPos = TYPENAME_STRING_MIDDLE_POS - new RCIntVector(typeTextToRender.Width / 2, 0); renderContext.RenderString(typeTextToRender, typeNameStringPos); /// Render the HP of the selected object. int currentHP = this.mapObjectDetailsView.GetCurrentHP(mapObjectID); if (currentHP != -1) { int maxHP = this.mapObjectDetailsView.GetMaxHP(mapObjectID); UIString hpTextToRender = this.hpTexts[hpCondition]; hpTextToRender[0] = currentHP; hpTextToRender[1] = maxHP; RCIntVector hpStringPos = HP_STRING_MIDDLE_POS - new RCIntVector(hpTextToRender.Width / 2, 0); renderContext.RenderString(hpTextToRender, hpStringPos); } /// Render the energy of the selected object. int currentEnergy = this.mapObjectDetailsView.GetCurrentEnergy(mapObjectID); if (currentEnergy != -1) { int maxEnergy = this.mapObjectDetailsView.GetMaxEnergy(mapObjectID); this.energyText[0] = currentEnergy; this.energyText[1] = maxEnergy; RCIntVector energyStringPos = ENERGY_STRING_MIDDLE_POS - new RCIntVector(this.energyText.Width / 2, 0); renderContext.RenderString(this.energyText, energyStringPos); } }
public IEnumerator QuoteRoutine(UIQuote q) { int quote_num = 0; float rate = 1.5F; float rate_inc = 0.03F; GameManager.IgnoreInput = true; QuoteObjects.Img[0].DOColor(new Color(1, 1, 1, 0.8F), 0.35F); QuoteObjects.Img[0].raycastTarget = true; yield return(new WaitForSeconds(0.1F)); UIObj qobj = Quote("", q.Speaker); while (quote_num < q.Quote.Length) { while (Input.GetMouseButton(0)) { yield return(null); } rate = 1.0F; UIString target = q.Quote[quote_num]; /*for (float i = 0; i < (target.Value.Length+1); i = i + rate) * { * if(Input.GetMouseButtonDown(0)) * { * break; * } * qobj["textbox"].Txt[0].text = target.Value.Substring(0, (int)i); * //qobj["textbox"].Txt[0].color = target.Colour; * qobj["textbox"].Txt[0].fontSize = target.Size; * * rate += rate_inc; * yield return null; * }*/ qobj["textbox"].Txt[0].text = target.Value; qobj["textbox"].Txt[0].color = Color.white; qobj["textbox"].Txt[0].fontSize = 60; while (Input.GetMouseButton(0)) { yield return(null); } while (!Input.GetMouseButtonDown(0)) { yield return(null); } quote_num++; yield return(null); } qobj.PoolDestroy(); QuoteObjects.Img[0].DOColor(new Color(1, 1, 1, 0), 0.35F); //QuoteMat.DOFloat(0, "_Size", 0.25F); QuoteObjects.Img[0].raycastTarget = false; GameManager.IgnoreInput = false; yield return(null); }
/// <see cref="UIRenderLoopBase.RenderString_i"/> protected override void RenderString_i(UIString str, RCIntVector position, RCIntVector textboxSize, UIStringAlignment alignment) { throw new NotImplementedException(); }
/// <see cref="UIRenderLoopBase.RenderString_i"/> protected override void RenderString_i(UIString str, RCIntVector position, int width) { throw new NotImplementedException(); }
public override int GetHashCode() { return(UIString != null ? UIString.GetHashCode() : 0); }