[1.5] HugsLib (11.0.3) Lightweight modding library

Started by UnlimitedHugs, December 15, 2016, 02:20:14 PM

Previous topic - Next topic

nahuen89

Hi, this is the translation for Spanish Latin and Spanish:

<?xml version="1.0" encoding="utf-8" ?>
<LanguageData>

<HugsLib_settings_btn>Ajustes de mod</HugsLib_settings_btn>
<HugsLib_settings_windowTitle>Ajustes de mod</HugsLib_settings_windowTitle>
<HugsLib_settings_resetValue>resetear ajustes por default</HugsLib_settings_resetValue>
<HugsLib_settings_resetAll>Resetear todo</HugsLib_settings_resetAll>
<HugsLib_settings_resetAll_prompt>¿Restablecer todos los ajustes de modificación a sus valores originales?</HugsLib_settings_resetAll_prompt>
<HugsLib_settings_noSettings>No se cargan mods con ajustes configurables.</HugsLib_settings_noSettings>

<HugsLib_ownSettingsName>Otros</HugsLib_ownSettingsName>
<HugsLib_setting_showNews_label>Mostrar noticias de actualizaciones de mods</HugsLib_setting_showNews_label>
<HugsLib_setting_showNews_desc>Permite que los mods recién instalados resalten sus nuevas funciones en una ventana emergente al iniciar el juego.</HugsLib_setting_showNews_desc>
<HugsLib_setting_allNews_label>Todas las noticias de actualización de mod</HugsLib_setting_allNews_label>
<HugsLib_setting_allNews_desc>Muestra todas las noticias de actualización de mod disponibles, incluidas las que ya se han mostrado.</HugsLib_setting_allNews_desc>
<HugsLib_setting_allNews_button>Mostrar ahora</HugsLib_setting_allNews_button>
<HugsLib_setting_allNews_fail>Ninguno de los mods activos tiene noticias de actualización que mostrar.</HugsLib_setting_allNews_fail>

<HugsLib_features_title>Nuevas funciones de modificación</HugsLib_features_title>
<HugsLib_features_description>Se han instalado las siguientes actualizaciones de modificación y éstas son las nuevas características y mejoras incluidas en ellas. \nPuede deshabilitar este diálogo en Opciones &gt; Mod Settings</HugsLib_features_description>
<HugsLib_features_update>{0} v{1}</HugsLib_features_update>
<HugsLib_features_link>Enlace</HugsLib_features_link>
<HugsLib_features_linkDesc>Abre su navegador en una página donde puede obtener más información sobre esta actualización..\nDireccion: {0}</HugsLib_features_linkDesc>

<HugsLib_copiedToClipboard>Copiado al portapapeles.</HugsLib_copiedToClipboard>

<HugsLib_logs_copy>Copiar</HugsLib_logs_copy>
<HugsLib_logs_shareBtn>Compartir registros</HugsLib_logs_shareBtn>
<HugsLib_logs_shareConfirmTitle>Confirmar</HugsLib_logs_shareConfirmTitle>
<HugsLib_logs_shareConfirmMessage>Subir los registros ahora?\n\nEsto publicará los registros de su juego en un servidor público y le dará el enlace para compartir con otros. Esto es útil si necesita ayuda para solucionar un problema o desea informar de un problema a un autor de modificaciones.\n\nNo se compartirá información privada.</HugsLib_logs_shareConfirmMessage>
<HugsLib_logs_publisherTitle>Editor de registro</HugsLib_logs_publisherTitle>
<HugsLib_logs_uploading>Cargando{0}</HugsLib_logs_uploading>
<HugsLib_logs_shortening>Obteniendo URL{0}</HugsLib_logs_shortening>
<HugsLib_logs_uploaded>Carga completa!</HugsLib_logs_uploaded>
<HugsLib_logs_uploadError>Error en carga: {0}</HugsLib_logs_uploadError>
<HugsLib_logs_abortBtn>Abortar</HugsLib_logs_abortBtn>
<HugsLib_logs_retryBtn>Reintentar</HugsLib_logs_retryBtn>
<HugsLib_logs_browseBtn>Abrir en el navegador</HugsLib_logs_browseBtn>

<HugsLib_logs_filesBtn>Archivos</HugsLib_logs_filesBtn>
<HugsLib_logs_openLogFile>Abrir archivo de registro</HugsLib_logs_openLogFile>
<HugsLib_logs_openSaveDir>Abrir carpeta de guardar</HugsLib_logs_openSaveDir>
<HugsLib_logs_openModsDir>Abrir carpeta de Mods</HugsLib_logs_openModsDir>

<HugsLib_restart_title>Reiniciar juego</HugsLib_restart_title>
<HugsLib_restart_text>Los cambios han sido guardados.\n\nPara activar la nueva configuración de modificación, se recomienda reiniciar el juego.</HugsLib_restart_text>
<HugsLib_restart_restartNowBtn>Reiniciar ahora</HugsLib_restart_restartNowBtn>
<HugsLib_restart_autoToggle>Reiniciar automáticamente</HugsLib_restart_autoToggle>
<HugsLib_restart_restarting>Reiniciando</HugsLib_restart_restarting>
<HugsLib_setting_autoRestart_label>Reiniciar después de cambiar el menú Mods</HugsLib_setting_autoRestart_label>
<HugsLib_setting_autoRestart_desc>Reinicia automáticamente el juego después de haber realizado cambios en el menú Mods.</HugsLib_setting_autoRestart_desc>

<test_enumSetting_DefaultValue>Valor por defecto</test_enumSetting_DefaultValue>
<test_enumSetting_ValueOne>Valor Uno</test_enumSetting_ValueOne>
<test_enumSetting_ValueTwo>Valor Dos</test_enumSetting_ValueTwo>

</LanguageData>

UnlimitedHugs

Quote from: nahuen89 on February 12, 2017, 04:37:14 PM
Hi, this is the translation for Spanish Latin and Spanish

Thank you, I'll include this in the next release.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

UnlimitedHugs

Updated to 2.4.2

This should fix the automatic restart failing for some players, or so I hope, since I couldn't reproduce it myself.
Also, a special case of detour warning should be fixed.
@nahuen89, your translation is also included in this release.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam


Sspec7aR

Hey guys ... I installed the mod and the game told me (when I loaded my save) that now it is running with Core and HugsLib mods /// my question is reallllllly stupid but like a newbie in this game ... how I can start this mod ... I mean ... to see the library ? o_O pls help me ... I will appreciate it ... and sry for this stupid question but I really dont know :(

UnlimitedHugs

Quote from: Wishmaster on February 19, 2017, 08:03:30 AM
Can I use HugsLib to show a custom dialog window ?
I've used Dialog_MessageBox but I can't figure out how to actually show up

The dialog must be added to the window stack to be displayed. Try this:

Find.WindowStack.Add(new Dialog_MessageBox("Heyo"))


Quote from: Sspec7aR on February 19, 2017, 11:20:16 AM
-snip-

I think you are looking for a feature that HugsLib doesn't have.
The library is a set of tools that other mods can use to make development easier- it's not something players can use.
If you are looking for mods to install, you could check out the Rimworld workshop on Steam.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

UnlimitedHugs

Updated to 2.4.3

The log uploader should now work properly on the Linux build of the game.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

Wishmaster

#157
Is destructive detouring implementation with Harmony planned ?

Also is there a way to use a custom setting like an enum with creating a customdrawer ? I want to make a dynamical options list.

UnlimitedHugs

Quote from: Wishmaster on February 27, 2017, 07:51:04 PM
Will non destructive detouring implementation with Harmony is planned ?
Also is there a way to use a custom setting like an enum with creating a customdrawer ? I want to make a dynamical options list.

I plan to include Harmony in the A17 release of HugsLib. There will be a migration guide on how to refit existing detours to make use of Harmony instead.

If you're using customdrawer, you have a lot more flexibility- you don't have to use an enum. For a dynamic drop-down list you would probably use a string-typed setting handle to store the currently selected option. Here's the method that draws the control for enum handles- feel free to adapt it to your own case. 
If you require more pointers, let me know.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

Wishmaster

So I've done what you said. But I've found no way to save the setting value.
I've read on your documentation.
QuoteMake sure to assign SettingHandle.Value when the setting changes so that it may be properly saved.

But I guess I have to do it with SettingHandle<T>.OnValueChanged = ... right ?
Well I can't trigger it with my custom drawer.

I've assigned this function of mine bellow to SettingHandle.  CustomDrawer and it works fine but for some reasons it never returns true when I change the setting (I guess this is what triggers OnValueChanged and or makes HugsLib save the setting).
I assign a local variable "bool settingChanged" that is used as a return value, and a member "activePolicy" that is the value I want to be set (this works perfectly).
But settingChanged is always false !

Can you help me again ?
Did I miss something regarding how to save settings ?


              public bool DrawHandleInputEnum(Rect controlRect)
             {
                 bool settingChanged = false;
                 //if (info.enumNames == null) return false;
                 var readableValue = ToString();
                 if (Widgets.ButtonText(controlRect, readableValue))
                 {
                     var floatOptions = new List<FloatMenuOption>();

                     floatOptions.Add(new FloatMenuOption(Policies.Unrestricted.label, () =>
                     {
                         activePolicy = null;
                     }));
                     foreach (var policyOption in this.pawnMask.RelatedPolicies)
                     {
                         floatOptions.Add(new FloatMenuOption(policyOption.label, () =>
                         {
                             // this is confirmed to attribute the variable as I want...
                             activePolicy = policyOption;
                             // ... but this will never make the function return true.
                             settingChanged = true;
                         }));
                     }
                     Find.WindowStack.Add(new FloatMenu(floatOptions));
                 }
                 //if (info.validationScheduled)
                 //{
                 //    info.validationScheduled = false;
                 //    return true;
                 //}
                 return settingChanged;
             }


UnlimitedHugs

#160
Quote from: Wishmaster on March 05, 2017, 04:29:08 PM
- snip -

I made the same mistake here! :D
Basically, when your float menu option is selected, the drawer method has already returned- which means it always returns false, and thus your setting is never saved. This is why I set validationScheduled to true- that way the change can be detected the next time the control is drawn.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

Wishmaster

I did not even think about using my validationScheduled member...
Now the drawer returns true but that doesn't trigger OnValueChanged.
I'm not sure how to save the setting.

First I do this to create the handle Settings.GetHandle<MyCustomSetting>(settingId, settingLabel, settingDesc, new MyCustomSettingHandle());

Should the latest parameter be that or a MyCustomSetting object ? Should I create an implicit conversion then ?

Please forgive my amateurishness in coding.

UnlimitedHugs

#162
Quote from: Wishmaster on March 05, 2017, 07:19:55 PM
Now the drawer returns true but that doesn't trigger OnValueChanged.

OnValueChanged is called when SettingHandle.Value is assigned a different value. Setting saving happens when the settings window is closed and at least one setting reported to have been changed.
So, to have the setting saved when the window closes, you would have to assign SettingHandle.Value when the user picks a new option and have the custom drawer return true.
I'm not sure what MyCustomSetting and MyCustomSettingHandle are in your example are- but if you are trying to use a custom data type to store your value, I would use null as the default value (the 4th parameter). If you link me to your full code, I could give you more specific pointers.
Also, no worries- we are here to help each other.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

Wishmaster

#163
Yes, it is a custom type.
Now I realize that 4th parameter's type is a unique value for all possible settings, right ?
When I set it to null as a default value, obviously I get a NullReferenceException when opening mod settings because the reference for ToString() does not exist.

At first I wanted to use a single instance of MyCustomSettingHandle to deal with all combinations of the related setting.
Then to update the SettingHandle.Value from inside the CustomDrawer, I've found no other way but to add a SettingHandle<MyCustomSetting> member to my MyCustomSettingHandle, and assign the value created by Settings.GetHandle in DefsLoaded().
Then I can assign SettingHandle.Value. But what value should I assign ? SettingHandle.Value = this does not assign a different value

Note: I'm making a dynamic list of settings. I have one or more MyCustomSetting*** depending on the user.

I don't show up all my code but try to make a summary of it instead. I hope it makes easier to understand the related issues i have.

edit I've found a dirty way to somehow fix it:
now the Value is saved and OnValueChanged is triggered.

in my MyCustomSettingHandle class

         public override bool Equals(object obj)
         {
             return false;
         }

UnlimitedHugs

Quote from: Wishmaster on March 06, 2017, 06:56:52 AM
- snip -

The problem is probably due to to the fact that handle values that equal its default value are not saved.
The 4th parameter (the default value) should be null for custom setting types- otherwise you would end up with the same object in both the Value and DefaultValue fields when the player resets the setting. Of course, that implies the need to check for null in the Value field, and assign it a new object. And no, the default value is specific only to the handle it is passed to.
Overriding Equals() should not be necessary neither in the handle, nor in the data type- unless I missed something in my implementation.
OnValueChanged would not be called in this case, but it doesn't need to- since you are using a custom drawer and are notified of the change anyway. All that should be necessary for a successful save is returning true in the drawer, and the Value of the handle not being equal to the default value.
Hope this helps.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam