private ulong HashParse(string word) { if (word.StartsWith("0x")) { return(ulong.Parse(word.Substring(2), NumberStyles.HexNumber)); } return(Hash40Util.StringToHash40(word)); }
private void SetNodeParamValue(ParamStruct root, ulong hex40, object value) { var paramValue = ((ParamValue)root.Nodes[hex40]); if (paramValue.TypeKey == ParamType.hash40) { paramValue.Value = Hash40Util.StringToHash40(value.ToString()); } else { paramValue.Value = value; } }
public PrcHexMapping(string strValue) { Value = Hash40Util.StringToHash40(strValue); }
public bool GenerateBgmPrcFile(List <BgmDbNewEntry> bgmEntries, string outputFilePath) { var saveNoIndex = (short)(_coreBgmDb.OrderByDescending(p => p.SaveNo).First().SaveNo + 1); var testDispOrderIndex = (short)(_coreBgmDb.OrderByDescending(p => p.TestDispOrder).First().TestDispOrder + 1); var menuValueIndex = _coreBgmDb.OrderByDescending(p => p.MenuValue).First().MenuValue + 1; var t = new ParamFile(); t.Open(_resourceService.GetBgmDbResource()); //DBROOT var dbRoot = t.Root.Nodes[HEX_CAT_DBROOT] as ParamList; foreach (var bgmEntry in bgmEntries) { var newEntry = dbRoot.Nodes[1].Clone() as ParamStruct; SetNodeParamValue(newEntry, HEX_UI_BGM_ID, bgmEntry.UiBgmId); SetNodeParamValue(newEntry, HEX_STREAM_SET_ID, bgmEntry.StreamSetId); SetNodeParamValue(newEntry, HEX_RARITY, bgmEntry.Rarity); SetNodeParamValue(newEntry, HEX_RECORD_TYPE, bgmEntry.RecordType); SetNodeParamValue(newEntry, HEX_UI_GAMETITLE_ID, bgmEntry.UiGameTitleId); SetNodeParamValue(newEntry, HEX_NAME_ID, bgmEntry.NameId); //SetNodeParamValue(newEntry, HEX_SAVE_NO, saveNoIndex); SetNodeParamValue(newEntry, HEX_TEST_DISP_ORDER, testDispOrderIndex); SetNodeParamValue(newEntry, HEX_MENU_VALUE, menuValueIndex); SetNodeParamValue(newEntry, HEX_SHOP_PRICE, (uint)0); dbRoot.Nodes.Add(newEntry); saveNoIndex++; testDispOrderIndex++; menuValueIndex++; } //STREAM_SET var streamSet = t.Root.Nodes[HEX_CAT_STREAM_SET] as ParamList; foreach (var bgmEntry in bgmEntries) { var newEntry = streamSet.Nodes[0].Clone() as ParamStruct; SetNodeParamValue(newEntry, HEX_STREAM_SET_ID, bgmEntry.StreamSetId); SetNodeParamValue(newEntry, HEX_INFO0, bgmEntry.Info0); streamSet.Nodes.Add(newEntry); } //ASSIGNED_INFO var assignedInfo = t.Root.Nodes[HEX_CAT_ASSIGNED_INFO] as ParamList; foreach (var bgmEntry in bgmEntries) { var newEntry = assignedInfo.Nodes[0].Clone() as ParamStruct; SetNodeParamValue(newEntry, HEX_INFO_ID, bgmEntry.InfoId); SetNodeParamValue(newEntry, HEX_STREAM_ID, bgmEntry.StreamId); assignedInfo.Nodes.Add(newEntry); } //STREAM_PROPERTY var streamProperty = t.Root.Nodes[HEX_CAT_STREAM_PROPERTY] as ParamList; foreach (var bgmEntry in bgmEntries) { var newEntry = streamProperty.Nodes[0].Clone() as ParamStruct; SetNodeParamValue(newEntry, HEX_STREAM_ID, bgmEntry.StreamId); SetNodeParamValue(newEntry, HEX_DATA_NAME0, bgmEntry.DataName0); streamProperty.Nodes.Add(newEntry); } //BGM PLAYLIST (QUICK & DIRTY) foreach (var bgmEntry in bgmEntries) { if (bgmEntry.Playlists == null) { continue; } foreach (var playlist in bgmEntry.Playlists) { var playlistId = playlist.Id; if (!playlistId.StartsWith("bgm")) { _logger.LogWarning("The playlist_id for song '{Song}' must start with 'bgm', skipping...", bgmEntry.ToneName); continue; } var hexValue = Hash40Util.StringToHash40(playlistId); ParamList bgmPlaylist = null; ParamStruct newEntry = null; //If the playlist doesn't exist... if (!t.Root.Nodes.ContainsKey(hexValue)) { var playlistToClone = t.Root.Nodes[HEX_PLAYLIST_EXAMPLE] as ParamList; bgmPlaylist = playlistToClone.Clone() as ParamList; t.Root.Nodes.Add(hexValue, bgmPlaylist); if (bgmPlaylist.Nodes.Count > 1) { bgmPlaylist.Nodes.RemoveRange(1, bgmPlaylist.Nodes.Count - 1); newEntry = bgmPlaylist.Nodes[0] as ParamStruct; } } else { bgmPlaylist = t.Root.Nodes[hexValue] as ParamList; newEntry = bgmPlaylist.Nodes[0].Clone() as ParamStruct; bgmPlaylist.Nodes.Add(newEntry); } //Add song SetNodeParamValue(newEntry, HEX_UI_BGM_ID, bgmEntry.UiBgmId); for (int i = 0; i <= 15; i++) { SetNodeParamValue(newEntry, string.Format(HEX_ORDERNBR, i), (short)(bgmPlaylist.Nodes.Count)); SetNodeParamValue(newEntry, string.Format(HEX_INCIDENCENBR, i), (ushort)500); } } } t.Save(outputFilePath); return(true); }