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 66 forks source link

Final Frontier Integration #351

Open inigmatus opened 8 years ago

inigmatus commented 8 years ago

Would be interesting if we could post custom ribbons for completion of contracts, which could be awarded when using Final Frontier mod: http://forum.kerbalspaceprogram.com/threads/67246-1-0-5-Final-Frontier-kerbal-individual-merits-0-8-9-1414

See code example below.

inigmatus commented 8 years ago

Enhancement request pseudo-code:

Recommend developing a Final Frontier Tree specifying the a custom tree of ribbons for use when specified by the FFRibbonGroup attribute in CONTRACT_TYPE. The FF_TREE is used by FF to determine what level of ribbon to award for completing the contract (assumption is to award the next ribbon specified in the tree), else no ribbon if not specified.

So something like this:

FF_RANK_TREE { name = FFTree1 0 = SSI-Aerospace/Assets/ribbon1 //Name defines ribbon name used by FF. See http://nereid42.de/screenshots/finalfrontier1.jpg Not required. If not specified then defaults to contract name with "Ribbon" appended to the end of it. 0.name = Helicopter Certification //appears as "Helicopter Certification Ribbon:" 0.text = Description of award used by FF for this specific ribbon. Required. 1 = SSI-Aerospace/Assets/ribbon2 1.text = KSC Coast Guard Certification 2 = SSI-Aerospace/Assets/ribbon3 2.text = Earned for landing on the VAB three times! 3 = SSI-Aerospace/Assets/ribbon4 3.text = Earned for landing on the VAB four times!

//If pilot award this ribbon instead when completing this rank (rank 3 above is awarded to all regardless in this example) 0.pilot = SSI-Aerospace/Assets/pilotribbon1 0.pilot.description = Required description. 1.pilot = SSI-Aerospace/Assets/pilotribbon2 1.pilot.description = Earned for landing on the VAB without spilling a drink.

//If engineer award this ribbon instead when completing this rank (rank 3 above is awarded to all regardless in this example) 0.engineer = SSI-Aerospace/Assets/engineerribbon1 0.engineer.description = Required description. 4.engineer = SSI-Aerospace/Assets/engineerribbon2 4.engineer.description = Landed on Admin building and cleaned the rotors.

//If all applicable ribbons already earned by Kerbal, no more ribbon awards. not required, default is no. If set to yes, then FF continues Awarding duplicate ribbons beginning again with rank 0. continueAwarding = no }

FF_RANK_TREE { name = FFTree2 0 = SSI-Aerospace/Assets/specialribbon1 0.name = STS Booster Retrieval 0.text = Awarded for retrieving prototype STS boosters for STS-1 continueAwarding = no }

CONTRACT_TYPE { ... //Specific ribbon image for FF to award for 1st time completion, else use the FF_Rank_Tree to award a ribbon based on earned FF rank. If not specified, then no ribbon awarded FFRibbon = FFTree1

//Not required if Tree specified, else required. FFRibbonText = Gold Leaf Cluster for Rescuing the S.S. Minnow ... }

Thoughts?

The above represents the final version of the concept when applied. To start with, you could just test adding the FFRibbon attribute to CONTRACT_TYPE and have it specify the image for the ribbon for FF to award on 1st time completion.

jrossignol commented 8 years ago

From my post on the forums:

I worked with Nereid on this for a little bit a long while back (maybe 8 months or so), but both real life stuff came up for him, as well as more important issues with Final Frontier around persistence. We never really got past the discussion stage. It kind of fell off my radar since then.

Anyway, there's nothing I can do in Contract Configurator without changes from Nereid. I could be completely wrong as these are from memory, but the major changes required were:

  • Better support for externally loading ribbons. If I remember correctly, the problem with the custom ribbons was you had to assign them to a "slot". So there would be the potential for two people doing different contract packs picking the same slot and conflicting.
  • API for allowing a custom ribbon to be assigned or the level upgraded. Right now it's all event based I think that was it (although those two items would require a fair bit of rework in the Final Frontier code base, if I remember correctly).

If Nereid wants to and is able to make those changes, then I may look into support in Contract Configurator again.

jrossignol commented 8 years ago

Support will be in next version of Final Frontier, example code from Nereid:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

namespace MyPlugin
{
   // KSPAddon.Startup.MainMenu makes sure we already have loaded all ingame textures
   // make sure once is set to true
   [KSPAddon(KSPAddon.Startup.MainMenu, true)]
   class Example : MonoBehaviour
   {
      // place your ribbon png files (size 120x32 pixel) here...
      private const String RIBBON_BASE = "MyPluginInGameData/Ribbons/";

      // UNIQUE (!) ribbon code
      private const String RIBBON_CODE = "KSP";

      FinalFrontierAdapter adapter;

      public void Start()
      {
         Debug.Log("starting example");

         // create the adapter
         this.adapter = new FinalFrontierAdapter();
         // plugin to Final Frontier
         this.adapter.Plugin();

         if (this.adapter.IsInstalled()) // optional test
         {
            // register the ribbon with a unique code, a path to the png file and a name for a ribbon
            // prestige and boolean attribute for a ribbon that has to be a first awarded ribbon are optional
            // IMPORTANT: do not register ribbons twice and not before all textures are loaded (not until GameScene LOADING is done)!
            this.adapter.RegisterRibbon(RIBBON_CODE, RIBBON_BASE + "SpaceProgram", "Space Program Ribbon");
         }

         // ok, we want to award this ribbon to every applicant that enters the space program
         GameEvents.OnCrewmemberHired.Add(this.OnCrewmemberHired);
      }

      // callback for new Crew Member hired
      private void OnCrewmemberHired(ProtoCrewMember kerbal, int value)
      {
         Debug.Log("crew member hired: " + kerbal.name + " (" + value + ")");
         //
         // now we want to award the KSP ribbon
         this.adapter.AwardRibbonToKerbal(RIBBON_CODE, kerbal);
      }
   }
}
inigmatus commented 8 years ago

absolutely totally 100% bona fide awesome!

inigmatus commented 8 years ago

he did it he did it he did it! http://forum.kerbalspaceprogram.com/index.php?/topic/61065-105-final-frontier-kerbal-individual-merits-0813-1728/&page=75#comment-2346956

Araym-KSP commented 8 years ago

... and also Nereid did this: http://forum.kerbalspaceprogram.com/index.php?/topic/61065-105-final-frontier-kerbal-individual-merits-0813-1728/&do=findComment&comment=2346956 a "free from mods" ability to add ribbons... As I probably going to release a "pack" of military ranks and as I TOTALLY DO NOT knowing C# coding, could it be possible that "customized ribbons" in a free mode could also be used by customized contract? I'm asking it because I remembered Inigma looking at some of my creations and NOW (if anyone of Contract configurator modders is interested) I could release a WHOLE LOT of new ribbons :D

jrossignol commented 8 years ago

If I implement it, it will likely use those same custom definitions. I have serious reservations about the notion of having a 4-digit ribbon ID and nicely asking people not to use the same ID. Because about half the time problems caused by contract packs end up coming my way for support....

inigmatus commented 8 years ago

Checking status on this AWESOME enhancement to CC.

jrossignol commented 8 years ago

To be honest, somewhere between a long time from now and never. This one has a pretty long history (I requested the Final Frontier changes from Neireid originally back in Feb/Mar 2015. Both that time and this one I made my requirements fairly clear.

However, the implementation leaves a lot to be desired. The 4-digit unique ribbon IDs is either something I can auto-generate in Contract Configurator (then I risk clashing with ribbons that use that ID that can be added through "ribbon packs"). Or I can force it on the contract pack developer. Either way, I've got a support nightmare on my hands, and I have enough that I don't want to increase my support workload.

So my thinking at this point is unless there's a re-architecting of those unique 4-digit IDs (and there is no reason to limit it to a 4 digit numeric ID when a string identifier would work just fine), then I am not likely to implement Contract Configurator integration here.

jrossignol commented 8 years ago

Improved support has now been added in final frontier: http://forum.kerbalspaceprogram.com/index.php?/topic/61065-112-final-frontier-kerbal-individual-merits-109-2459/&do=findComment&comment=2589236