Kerbal Space Program  1.12.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Static Public Member Functions | List of all members
FinePrint.Utilities.StringUtilities Class Reference

String utilites is soon to be deprecated due to the use of lingoona. More...

Static Public Member Functions

static string AlphaNumericDesignation (int seed)
 Assembles a random designation, used for several name generators. More...
 
static string AppropriatePronoun (PronounCasing casing, GrammaticalGender gender, bool postFix=false)
 Picks an appropriate pronoun given a pronoun case and a gender. More...
 
static float CalculateReadDuration (string s)
 Calculates how long a message of any length should display using average reading speeds. More...
 
static string CardinalDirectionBetween (double originLatitude, double originLongitude, double destinationLatitude, double destinationLongitude)
 Describes the cardinal direction from one point to another. More...
 
static List< string > FormattedCurrencies (float funds, float science, float reputation, bool symbols=false, bool verbose=false, TransactionReasons reason=TransactionReasons.None, CurrencyModifierQuery.TextStyling style=CurrencyModifierQuery.TextStyling.OnGUI)
 Produces a list of formatted strings representing each currency. More...
 
static string GenerateSiteName (int seed, CelestialBody body, bool landLocked, bool allowNamed=true)
 Generates a random site name for a contract. More...
 
static string IntegerToGreek (int x)
 Converts numbers into greek letters. More...
 
static bool IsVowel (char c)
 Determines if a character is a vowel. More...
 
static GrammaticalGender KerbalGrammaticalGender (ProtoCrewMember pcm)
 Returns the grammatical gender for a ProtoCrewMember. More...
 
static void LoadSiteGenerationInfo ()
 This section is mostly site name generation stuff. The lists contents have been moved to an external file, just as the kerbal names. You can find the files at Resources/TextAssets/SiteNameGenerator. This change will allow localization to decide which file is appropiate for the displayed language. The string utlities are loaded in the "Init" method on Localization.cs More...
 
static string NamedSitePrefix (KSPRandom generator=null)
 Generates a waypoint site name prefix. More...
 
static string NamedSiteSuffix (CelestialBody body, bool landLocked, System.Random generator=null)
 Generates a waypoint site name suffix. More...
 
static string PackDelimitedString< T > (List< T > items, char delimiter= '|')
 Packs a list of anything into a delimited string. More...
 
static string PossessiveString (string thing)
 Converts a noun into a possessive noun properly. More...
 
static string ShortKerbalName (string fullKerbalName)
 Strips "Kerman" off of a full kerbal name. More...
 
static string ShortName (string verbose)
 Chooses the final token in a string delimited by periods. More...
 
static string SpecificVesselName (Contract contract)
 Gets the current name of a vessel tracked by a contextual contract. More...
 
static string ThisThisAndThat (List< string > stringList, string connector="#autoLOC_6002373", string conjugation="#autoLOC_6002374")
 Takes a list of strings and turns them into a readable list. More...
 
static string TitleCase (string str)
 Converts a string into "Title Case". More...
 
static bool TryParseGeneric< T > (string input, out T value)
 Tries to parse anything from a string. More...
 
static KeyValuePair< T1, T2 > UnpackDelimitedPair< T1, T2 > (string items, char delimiter= '|')
 Unpacks a delimited pair of strings into a pair of two anythings. More...
 
static List< T > UnpackDelimitedString< T > (string items, char delimiter= '|')
 Unpacks a delimited list of strings into a list of anything. More...
 
static string ValueAndUnits (RecordTrackType trackType, double trackValue)
 Produces a human readable string of a number and unit of measurement for a record track. More...
 

Detailed Description

String utilites is soon to be deprecated due to the use of lingoona.

Member Function Documentation

static string FinePrint.Utilities.StringUtilities.AlphaNumericDesignation ( int  seed)
inlinestatic

Assembles a random designation, used for several name generators.

Parameters
seedThe seed.
Returns
An alphanumeric designation.
static string FinePrint.Utilities.StringUtilities.AppropriatePronoun ( PronounCasing  casing,
GrammaticalGender  gender,
bool  postFix = false 
)
inlinestatic

Picks an appropriate pronoun given a pronoun case and a gender.

Parameters
casingThe pronoun case.
genderThe gender.
postFixIf a possessive pronoun is postfixing the subject.
Returns
An appropriate pronoun given the case and gender.
static float FinePrint.Utilities.StringUtilities.CalculateReadDuration ( string  s)
inlinestatic

Calculates how long a message of any length should display using average reading speeds.

Parameters
sThe string.
Returns
The average time (in seconds) it takes to read the string.
static string FinePrint.Utilities.StringUtilities.CardinalDirectionBetween ( double  originLatitude,
double  originLongitude,
double  destinationLatitude,
double  destinationLongitude 
)
inlinestatic

Describes the cardinal direction from one point to another.

Parameters
originLatitudeLatitude of the origin point.
originLongitudeLongitude of the origin point.
destinationLatitudeLatitude of the destination point.
destinationLongitudeLongitude of the destination point.
Returns
A string describing the cardinal direction between the points.
static List<string> FinePrint.Utilities.StringUtilities.FormattedCurrencies ( float  funds,
float  science,
float  reputation,
bool  symbols = false,
bool  verbose = false,
TransactionReasons  reason = TransactionReasons.None,
CurrencyModifierQuery.TextStyling  style = CurrencyModifierQuery.TextStyling.OnGUI 
)
inlinestatic

Produces a list of formatted strings representing each currency.

Parameters
fundsThe amount of funds before strategies.
scienceThe amount of science before strategies.
reputationThe amount of reputation before strategies.
symbolsWhether to identify the currencies with symbols or words.
verboseIf the strategy deltas should be shown or quietly added in.
reasonAn optional transaction reason if using a strategy.
styleAn optional style to determine coloration.
Returns
A list of formatted strings representing each currency.

< These strings can be arranged many ways, so rather than try to accommodate every possibility, we'll return a list to be used however is needed.

< We are comparing strings to avoid confusing situations where the amount is not technically zero, but it's so small that it is being displayed as zero anyway.

static string FinePrint.Utilities.StringUtilities.GenerateSiteName ( int  seed,
CelestialBody  body,
bool  landLocked,
bool  allowNamed = true 
)
inlinestatic

Generates a random site name for a contract.

Parameters
seedThe random seed.
bodyThe celestial body.
landLockedExclude oceanic names.
Returns
A random site name.
static string FinePrint.Utilities.StringUtilities.IntegerToGreek ( int  x)
inlinestatic

Converts numbers into greek letters.

Parameters
xThe number.
Returns
A greek letter represented by the number
static bool FinePrint.Utilities.StringUtilities.IsVowel ( char  c)
inlinestatic

Determines if a character is a vowel.

Parameters
cThe character.
Returns
If it is a vowel.
static GrammaticalGender FinePrint.Utilities.StringUtilities.KerbalGrammaticalGender ( ProtoCrewMember  pcm)
inlinestatic

Returns the grammatical gender for a ProtoCrewMember.

Parameters
pcmThe ProtoCrewMember.
Returns
The grammatical gender for them.
static void FinePrint.Utilities.StringUtilities.LoadSiteGenerationInfo ( )
inlinestatic

This section is mostly site name generation stuff. The lists contents have been moved to an external file, just as the kerbal names. You can find the files at Resources/TextAssets/SiteNameGenerator. This change will allow localization to decide which file is appropiate for the displayed language. The string utlities are loaded in the "Init" method on Localization.cs

Used to load the site generator language info into the game.

static string FinePrint.Utilities.StringUtilities.NamedSitePrefix ( KSPRandom  generator = null)
inlinestatic

Generates a waypoint site name prefix.

Parameters
generatorAn optional random generator to use.
Returns
A waypoint site name prefix.

< About half the time, just return a random kerbal name, for variety.

static string FinePrint.Utilities.StringUtilities.NamedSiteSuffix ( CelestialBody  body,
bool  landLocked,
System.Random  generator = null 
)
inlinestatic

Generates a waypoint site name suffix.

Parameters
generatorAn optional random generator to use.
Returns
A waypoint site name suffix.
static string FinePrint.Utilities.StringUtilities.PackDelimitedString< T > ( List< T >  items,
char  delimiter = '|' 
)
inlinestatic

Packs a list of anything into a delimited string.

Template Parameters
TThe type to convert from.
Parameters
itemsThe list of items to convert.
delimiterOptional custom delimiter.
Returns
A string delimited by the delimiter.
static string FinePrint.Utilities.StringUtilities.PossessiveString ( string  thing)
inlinestatic

Converts a noun into a possessive noun properly.

Parameters
thingThe noun.
Returns
The possessive noun.
static string FinePrint.Utilities.StringUtilities.ShortKerbalName ( string  fullKerbalName)
inlinestatic

Strips "Kerman" off of a full kerbal name.

Parameters
fullKerbalNameFull name of the kerbal.
Returns
The first name of the kerbal.
static string FinePrint.Utilities.StringUtilities.ShortName ( string  verbose)
inlinestatic

Chooses the final token in a string delimited by periods.

Parameters
verboseThe long string.
Returns
The last token of the string.
static string FinePrint.Utilities.StringUtilities.SpecificVesselName ( Contract  contract)
inlinestatic

Gets the current name of a vessel tracked by a contextual contract.

Parameters
contractThe contextual contract.
Returns
The tracked vessel's name.
static string FinePrint.Utilities.StringUtilities.ThisThisAndThat ( List< string >  stringList,
string  connector = "#autoLOC_6002373",
string  conjugation = "#autoLOC_6002374" 
)
inlinestatic

Takes a list of strings and turns them into a readable list.

Parameters
stringListThe list of strings.
Returns
"String1, String2, and String3"
static string FinePrint.Utilities.StringUtilities.TitleCase ( string  str)
inlinestatic

Converts a string into "Title Case".

Parameters
strThe string.
Returns
The capitalized string.
static bool FinePrint.Utilities.StringUtilities.TryParseGeneric< T > ( string  input,
out T  value 
)
inlinestatic

Tries to parse anything from a string.

Template Parameters
TThe resultant type.
Parameters
inputThe string to parse.
valueThe thing to parse to.
Returns
If the parse was successful.
static KeyValuePair<T1, T2> FinePrint.Utilities.StringUtilities.UnpackDelimitedPair< T1, T2 > ( string  items,
char  delimiter = '|' 
)
inlinestatic

Unpacks a delimited pair of strings into a pair of two anythings.

Template Parameters
T1The type to convert the first key to.
T2The type to convert the second value to.
Parameters
itemsThe delimited string.
delimiterOptional custom delimiter.
Returns
A pair of things unpacked from the string.
static List<T> FinePrint.Utilities.StringUtilities.UnpackDelimitedString< T > ( string  items,
char  delimiter = '|' 
)
inlinestatic

Unpacks a delimited list of strings into a list of anything.

Template Parameters
TThe type to convert the strings to.
Parameters
itemsThe delimited string.
delimiterOptional custom delimiter.
Returns
A list of things unpacked from the string.
static string FinePrint.Utilities.StringUtilities.ValueAndUnits ( RecordTrackType  trackType,
double  trackValue 
)
inlinestatic

Produces a human readable string of a number and unit of measurement for a record track.

Parameters
trackTypeType of the record track.
trackValueThe track value.
Returns
A human readable measurement

The documentation for this class was generated from the following file: