voult2 / BetterPawnControl

A RimWorld mod that allows bulk assignment of animals to zones and colonists to outfits (or drugs) in one single action
MIT License
20 stars 21 forks source link

Add Extended priorities support from Work Tab mod. #40

Closed TheLonerD closed 8 months ago

TheLonerD commented 8 months ago

Extended priorities now can be saved/loaded correctly.

Screenshot 2023-10-21 130142
TheLonerD commented 8 months ago

Please compile assemblies by yourself and don't forget to update a documentation.

voult2 commented 8 months ago

Wow! This is great @TheLonerD ! I'll test this, merge it and then release! Thank you very much!

TheLonerD commented 8 months ago

Sure! If you found some bugs just post a message here so I can fix it.

voult2 commented 8 months ago

There is one bug when saving the valuesInner to the save file using Scribe_Collections. The issue is the that scribe is expecting to write (list of) Values but instead it gets a collection (with lists of values).

File: WorkLink.cs

foreach (KeyValuePair<WorkGiverDef, List<int>> entryInner in settingsInner)
{
           keysInner.Add(entryInner.Key);
           valuesInner.Add(priorityPerHour);
 }
Scribe_Collections.Look(ref settingsInner, "settingsInner", LookMode.Def, LookMode.Value, ref keysInner, ref valuesInner);

results in this in the SaveFile (which does not work):

    <settingsInner>
    <keys>
         <li>FightFires</li>
    </keys>
    <values>
         <li>System.Collections.Generic.List`1[System.Int32]</li>
    </values>  

It shoud instead something like:

    <settingsInner>
    <keys>
         <li>FightFires</li>
         <li>WorkGiver#2</li>
    </keys>
    <values>
         <li>
             <prioritiesPerHour>
                <li>3</li>
                <li>3</li>
                ....24 entries...
                <li>3</li>
              </prioritiesPerHour>
          </li>
           <li>
                <prioritiesPerHour>
                  <li>3</li>
                  <li>3</li>
                  ....24 entries...
                  <li>3</li>
              </prioritiesPerHour>
            </li>
    </values>  

I'm trying to find how to best pass the reference to the Scribe_Collections

voult2 commented 8 months ago

I've found a solution based on how Flufly saves the priorities in WorkTab. It requires back and forth translations but it works!

TheLonerD commented 8 months ago

Sounds good! Let me check how Fluffy did that, as I understand we need to create a some kind of translation layer to handle proper serialization<->deserializaton.

voult2 commented 8 months ago

@TheLonerD I just pushed v2.5 with the integration and with the save/load fully working. I'd like to add you as contributer in steam. Can you share your steam_id so I can add you as contributor to the mod in steam?

TheLonerD commented 8 months ago

Yup. My steam id is

On Sun, Oct 22, 2023, at 2:42 AM, Alexandre wrote:

@TheLonerD https://github.com/TheLonerD I just pushed v2.5 with the integration and with the save/load fully working. I'd like to add you as contributer in steam. Can you share your steam_id so I can add you as contributor to the mod in steam?

— Reply to this email directly, view it on GitHub https://github.com/voult2/BetterPawnControl/pull/40#issuecomment-1773938659, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBWN3AR5ACU32BWDWTGFLYARFWBAVCNFSM6AAAAAA6KAIXFOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZTHEZTQNRVHE. You are receiving this because you were mentioned.Message ID: @.***>