jrossignol / ContractConfigurator

A config file based solution for creating new contracts for Kerbal Space Program.
https://forum.kerbalspaceprogram.com/index.php?/topic/91625-1
Other
64 stars 67 forks source link

Rich Text Dialogs #291

Closed jrossignol closed 9 years ago

jrossignol commented 9 years ago

Rich text dialogs that allow for:

jrossignol commented 9 years ago

Documentation dump incoming:

Behaviour for creating a dialog box that supports images, rich text and animated Kerbal heads. For details on the tags supported in the text, see the Unity Documentation.

BEHAVIOUR
{
    name = DialogBox
    type = DialogBox
    // The DIALOG_BOX child node represents a single dialog box (the behaviour
    // can create multiple dialog boxes).  If multiple dialog boxes contain the
    // same conditions, they will be displayed sequentially (based on the order
    // they are defined in this file).
    DIALOG_BOX
    {
        // Title of the dialog box.  If not supplied a window without a title
        // is created
        //
        // Type:      string
        // Required:  No
        // 
        title = This is a dialog box
        // The condition under which the dialog box should be displayed.
        //
        // Type:      DialogBox.TriggerCondition
        // Required:  Yes
        // Values:
        //     CONTRACT_ACCEPTED
        //     CONTRACT_SUCCESS
        //     CONTRACT_FAILED
        //     VESSEL_PRELAUNCH
        //     PARAMETER_COMPLETED
        //     PARAMETER_FAILED
        //
        condition = PARAMETER_COMPLETED
        // The *name* of the parameter to which this condition applies.
        // Required if the condition is one of the PARAMETER_ ones.
        //
        // Type:      string
        // Required:  See above
        //
        parameter = MyParameterName
        // The horizontal positioning of the the dialog box on the screen.
        //
        // Type:      DialogBox.Position
        // Required:  No (defaulted)
        // Values:
        //     LEFT (default)
        //     CENTER
        //     RIGHT
        //
        position = LEFT
        // Width as a percentage (between 0.0 and 1.0) of the equivalent 4:3
        // screen width.  This is calculated this way to provide a
        // relatively consistent look across a wide range of display sizes.
        //
        // Type:      float
        // Required:  No (defaulted)
        // Default:   0.8
        //
        width = 1.0
        // Height as a percentage (between 0.0 and 1.0) of the screen height.
        // If the content requires more room, this will automatically grow to
        // accomodated it, so it is recommended to leave this out.
        //
        // Type:      float
        // Required:  No (defaulted)
        // Default:   0.0
        //
        height = 0.3
        // Color of the title text.  This can be specified as an HTML color
        // value.
        //
        // Type:      Color
        // Required:  No (defaulted)
        // Default:   #FFFFFF (white)
        //
        titleColor = #BADA55
        // The following nodes represent sections that can be in a dialog box.
        // These can be combined in any order, and any section repeated any
        // number of times
        // The TEXT section represents a block of text.
        TEXT
        {
            // Text to appear in the dialog box.  It can have embedded newlines
            // using \n, as well as rich text using the HTML tags supported by
            // Unity's rich text.
            //
            // Type:      string
            // Required:  Yes
            // 
            text = This is the text that appears in the dialog box.
            // Size of the text.
            //
            // Type:      int
            // Required:  No (defaulted)
            // Default:   16
            //
            fontSize = 20
            // Color of the text.  This can be specified as an HTML color
            // value.
            //
            // Type:      Color
            // Required:  No (defaulted)
            // Default:   #CCCCCC (grey)
            //
            textColor = #BADA55
        }
        // The IMAGE section allows an external image to be displayed.
        IMAGE
        {
            // The URL of the image (path relative to the GameData directory).
            // This can be any type of image that KSP can load, although DDS is
            // generally recommended.
            //
            // Type:      string
            // Required:  Yes
            // 
            url = ContractPacks/SomeContractPack/SomeImage
            // If the image represents a character, the name of the character
            // to be displayed immediately below the image.  If not specified,
            // nothing is displayed beneath the image.
            //
            // Type:      string
            // Required:  No
            // 
            characterName = My Kerbal Kerman
            // Color of the character text (if being used).  This can be
            // specified as an HTML color value.
            //
            // Type:      Color
            // Required:  No (defaulted)
            // Default:   #BADA55 (badass green)
            //
            textColor = #BADA55
        }
        // The INSTRUCTOR section allows one of the special Kerbal animated
        // avatars to be displayed (such as Gene or Wernher).
        INSTRUCTOR
        {
            // The name of the instructor to display.  Specifically, this is
            // the name of the Unity asset to be loaded.
            //
            // Type:      string
            // Required:  Yes
            // Values:
            //     Instructor_Gene
            //     Instructor_Wernher
            //     Strategy_Mortimer
            //     Strategy_PRGuy (this is Walt)
            //     Strategy_ScienceGuy (this is Linus)
            //     Strategy_MechanicGuy (this is Gus)
            // 
            name = Instructor_Gene
            // Whether to display the character name below the Avatar.
            //
            // Type:      bool
            // Required:  No (defaulted)
            // Default:   true
            //
            showName = true
            // A character name to use instead of the default name of the
            // character.
            //
            // Type:      string
            // Required:  No (defaulted)
            // 
            characterName = Some Other Guy Kerman
            // Color of the character text (if being used).  This can be
            // specified as an HTML color value.
            //
            // Type:      Color
            // Required:  No (defaulted)
            // Default:   #BADA55 (badass green)
            //
            textColor = #BADA55
            // The animation that should be played.  If not supplied, the
            // character's default idle animation is played
            //
            // Type:      DialogBox.InstructorSection.Animation
            // Required:  No
            // Values:
            //     idle
            //     idle_lookAround
            //     idle_sigh
            //     idle_wonder
            //     true_thumbUp
            //     true_thumbsUp
            //     true_nodA
            //     true_nodB
            //     true_smileA
            //     true_smileB
            //     false_disappointed
            //     false_disagreeA
            //     false_disagreeB
            //     false_disagreeC
            //     false_sadA
            // 
            animation = true_thumbsUp
        }
        // The KERBAL section is similar to INSTRUCTOR in that it shows an
        // avatar of a Kerbal.  However, the KERBAL avatars represent vessel
        // crew or astronauts in the astronaut complex.  The following logic
        // is used to determine which Kerbal is selected for the avatar:
        //   1) If characterName is supplied, that is the Kerbal that is used.
        //   2) Otherwise, select a character from the active vessel, based
        //      on the values of crewIndex and excludeName
        //   3) If a selection still cannot be made (the vessel is uncrewed,
        //      or the index out of range for the given crew), then a random
        //      kerbal name and gender are generated (the Kerbal is assumed to 
        //      be in the Astronaut Complex.  This is intended as a fallback to
        //      avoid empty dialog boxes and shouldn't be relied upon.
        KERBAL
        {
            // The character this dialog box should be for.  If the character
            // is a real Kerbal that can be found in the save game, they will
            // be used.  Otherwise, a generic Kerbal portrait will be displayed.
            //
            // Type:      string
            // Required:  No (defaulted)
            // 
            characterName = Valentina Kerman
            // If a characterName is not supplied, then this will be used as an
            // index into the crew list of the current active vessel.  This
            // could be used to set up a conversation between two members of a
            // vessel crew.
            //
            // Type:      int
            // Required:  No (defaulted)
            // Default:   0
            //
            crewIndex = 0
            // A List of names that are to be excluded when searching a vessel
            // crew for a Kerbal to use.  This could be used to set up a
            // conversation between a known crew member and a different crew
            // member.
            //
            // Type:      string
            // Required:  No (Multiples allowed)
            // 
            excludeName = Bob Kerman
            excludeName = Bill Kerman
            // The gender of the character.  Only used if characterName is
            // specified, and the character is not one that can be found in the
            // game.
            //
            // Type:      ProtoCrewMember.Gender
            // Required:  No
            // Values:
            //     Male
            //     Female
            // 
            gender = Female
            // Whether to display the character name below the Avatar.
            //
            // Type:      bool
            // Required:  No (defaulted)
            // Default:   true
            //
            showName = true
            // Color of the character text (if being used).  This can be
            // specified as an HTML color value.
            //
            // Type:      Color
            // Required:  No (defaulted)
            // Default:   #BADA55 (badass green)
            //
            textColor = #BADA55
        }
    }
}
severedsolo commented 9 years ago

Bit of feedback for your documentation. 0.3 is way too small for the default width. I used 1.0 personally, and it looks great.

severedsolo commented 9 years ago

aaand I think I found a bug.

The "Kerbal" bit - it's supposed to show a portrait am I right? Because if the kerbal type is set to "Unknown" (in this case, I spawned an unknown passenger, and then used him in the dialog box) - the box is blank.

jrossignol commented 9 years ago

The default is actually 0.8, but 0.3 doesn't make sense so I've changed the example in the doc.

Toss up your config for that contract and I'll take a look.

severedsolo commented 9 years ago

Relevant bit is: BEHAVIOUR { name = DialogBox type = DialogBox DIALOG_BOX { title = Meet Scully condition = CONTRACT_ACCEPTED position = LEFT width = 1.0 titleColor = #BADA55 TEXT { text = I believe you've already met my colleague Mulder. Listen, that... weather balloon you found is emitting a signal, but we can't trace where it's going. The lab boys are picking up a similar signal from Mun, so I'm ordering you to take me to check it out. I'll meet you on the Launch Pad. fontSize = 20 textColor = #BADA55 } KERBAL { characterName = Scully Kerman gender = Female showName = true textColor = #BADA55 } }

severedsolo commented 9 years ago

Also - "PARAMETER_COMPLETED" boxes seem to be coming up twice.

Relevant config: DIALOG_BOX { title = Metorological Study. condition = PARAMETER_COMPLETED parameter = MunLanding position = LEFT width = 1.0 titleColor = #BADA55 TEXT { text = Fascinating, another... weather balloon. Wait here while I try and upload the... meteorological data. fontSize = 20 textColor = #BADA55 } KERBAL { characterName = Scully Kerman gender = Female showName = true textColor = #BADA55 } }

jrossignol commented 9 years ago

Can you post the SpawnKerbal too so I don't have to reproduce that part? Actually, if you post up the whole thing I can just edit it as needed to reproduce, easier for me.

jrossignol commented 9 years ago

Duh, your first issue should've been obvious if I was thinking. You're missing the stuff under ContractConfigurator/ui. Grab everything in there and you should see the fallback image for your Scully. Sadly, KSP makes it difficult for me to show a Kerbal head for anything but an active vessel, so I have static images as a fallback. In your case you may want to consider using IMAGE instead. In fact, if you play around with Texture Replacer, you may be able to get good Scully/Mulders. :+1:

Anyway, the parameter one does sound buggy though - I'll let you know what I find.

severedsolo commented 9 years ago

I'll probably end up using image anyway (I was just trying to get it working) but I don't understand what you mean by ContractConfigurator/ui stuff? Can't see it in the docs anywhere.

Anyway, the full configs are all here: https://github.com/severedsolo/ContractPackKFiles

jrossignol commented 9 years ago

Not in the documentation - I mean the files in GameData/ContractConfigurator/ui. They'll be there in the 1.7.0 release package, but you'll need to grab them if you're playing around with the dev version.

jrossignol commented 9 years ago

Alright, duplicate dialog box issue is fixed, thanks for bringing it to my attention.

severedsolo commented 9 years ago

Sorry to be a pain! downloaded latest version, and now my (previously working) contracts are refusing to load, as they are saying that "the requested value 'CONTRACT_COMPLETED' was not found".

All 4 contracts in the link above have this issue.

jrossignol commented 9 years ago

Sorry about that - I was doing some cleanup a few days ago to make things more consistent between behaviours and renamed that to CONTRACT_SUCCESS - I forgot to go and update the documentation in this post!