/// <summary> /// Localizes the PLib strings. /// </summary> /// <param name="locale">The locale to use.</param> internal static void LocalizeItself(Localization.Locale locale) { if (locale == null) { throw new ArgumentNullException(nameof(locale)); } Localization.RegisterForTranslation(typeof(PLibStrings)); var assembly = Assembly.GetExecutingAssembly(); string locCode = locale.Code; if (string.IsNullOrEmpty(locCode)) { locCode = Localization.GetCurrentLanguageCode(); } try { using (var stream = assembly.GetManifestResourceStream( TRANSLATIONS_RES_PATH + locCode + TRANSLATIONS_EXT)) { if (stream != null) { // File.ReadAllLines does not work on streams unfortunately var lines = new List <string>(128); using (var reader = new StreamReader(stream, Encoding.UTF8)) { string line; while ((line = reader.ReadLine()) != null) { lines.Add(line); } } Localization.OverloadStrings(Localization.ExtractTranslatedStrings( lines.ToArray())); #if DEBUG PUtil.LogDebug("Localizing PLib Core to locale {0}".F(locCode)); #endif } } } catch (Exception e) { PUtil.LogWarning("Failed to load {0} localization for PLib Core:".F(locCode)); PUtil.LogExcWarn(e); } }
/// <summary> /// Copies the sounds from one animation to another animation. /// </summary> /// <param name="dstAnim">The destination anim file name.</param> /// <param name="srcAnim">The source anim file name.</param> public static void CopySoundsToAnim(string dstAnim, string srcAnim) { if (string.IsNullOrEmpty(dstAnim)) { throw new ArgumentNullException(nameof(dstAnim)); } if (string.IsNullOrEmpty(srcAnim)) { throw new ArgumentNullException(nameof(srcAnim)); } var anim = Assets.GetAnim(dstAnim); if (anim != null) { var audioSheet = GameAudioSheets.Get(); var animData = anim.GetData(); // For each anim in the kanim, look for existing sound events under the old // anim's file name for (int i = 0; i < animData.animCount; i++) { string animName = animData.GetAnim(i)?.name ?? ""; var events = audioSheet.GetEvents(srcAnim + "." + animName); if (events != null) { #if DEBUG PUtil.LogDebug("Adding {0:D} audio event(s) to anim {1}.{2}".F(events. Count, dstAnim, animName)); #endif audioSheet.events[dstAnim + "." + animName] = events; } } } else { PUtil.LogWarning("Destination animation \"{0}\" not found!".F(dstAnim)); } }