public static int GetLineCount(string text, PointF position, CitizenFX.Core.UI.Font font, float scale, float wrap) { // Tell the game that we are going to request the number of lines SetTextGxtEntry("CELL_EMAIL_BCON"); // _BEGIN_TEXT_COMMAND_LINE_COUNT // Add the text that has been sent to us UIResText.AddLongStringForUtf8(text); // ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME // Get the resolution with the correct aspect ratio SizeF res = ResolutionMaintainRatio; // Calculate the x and y positions float x = position.X / res.Width; float y = position.Y / res.Height; // Set the properties for the text SetTextFont((int)font); SetTextScale(1f, scale); // If there is some text wrap to add if (wrap > 0) { // Calculate the wrap size float start = position.X / res.Width; float end = start + (wrap / res.Width); // And apply it SetTextWrap(x, end); } // Finally, return the number of lines being made by the string return(GetTextScreenLineCount(x, y)); // _GET_TEXT_SCREEN_LINE_COUNT }
/// <summary> /// Gets the line count for the text. /// </summary> /// <param name="text">The text to measure.</param> /// <param name="position">The position of the text.</param> /// <param name="font">The font to use.</param> /// <returns>The number of lines used.</returns> public static int GetLineCount(string text, Point position, GTA.Font font, float scale, int wrap) { // Tell the game that we are going to request the number of lines Function.Call(Hash._SET_TEXT_GXT_ENTRY, "CELL_EMAIL_BCON"); // _BEGIN_TEXT_COMMAND_LINE_COUNT // Add the text that has been sent to us UIResText.AddLongStringForUtf8(text); // ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME // Get the resolution with the correct aspect ratio SizeF res = ResolutionMaintainRatio; // Calculate the x and y positions float x = position.X / res.Width; float y = position.Y / res.Height; // Set the properties for the text Function.Call(Hash.SET_TEXT_FONT, (int)font); Function.Call(Hash.SET_TEXT_SCALE, 1f, scale); // If there is some text wrap to add if (wrap > 0) { // Calculate the wrap size float start = position.X / res.Width; float end = start + (wrap / res.Width); // And apply it Function.Call(Hash.SET_TEXT_WRAP, x, end); } // Finally, return the number of lines being made by the string return(Function.Call <int>(Hash._0x9040DFB09BE75706, x, y)); // _GET_TEXT_SCREEN_LINE_COUNT }