public bool SerializeDS2EventLocations(PARAM locs) { HashSet <long> ids = new HashSet <long>(); foreach (var o in Objects) { if (o is MapEntity m && m.Type == MapEntity.MapEntityType.DS2EventLocation && m.WrappedObject is PARAM.Row mp) { if (!ids.Contains(mp.ID)) { ids.Add(mp.ID); } else { MessageBox.Show($@"{mp.Name} has an ID that's already used. Please change it to something unique and save again.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } // Adjust the location to be relative to the mapoffset var newloc = new PARAM.Row(mp); newloc["PositionX"].Value = (float)mp["PositionX"].Value - MapOffset.Position.X; newloc["PositionY"].Value = (float)mp["PositionY"].Value - MapOffset.Position.Y; newloc["PositionZ"].Value = (float)mp["PositionZ"].Value - MapOffset.Position.Z; locs.Rows.Add(newloc); } } return(true); }
public void ShortcutPopups() { if (ImGui.BeginPopup("ctrlVPopup")) { ImGui.InputText("Offset", ref _currentCtrlVInput, 20); long offset = 0; try { offset = int.Parse(_currentCtrlVInput); } catch { ImGui.EndPopup(); return; } if (ImGui.Selectable("Submit")) { List <PARAM.Row> rowsToInsert = new List <PARAM.Row>(); if (!_selection.rowSelectionExists()) { foreach (PARAM.Row r in _clipboardRows) { PARAM.Row newrow = new PARAM.Row(r);// more cloning newrow.ID = r.ID + offset; rowsToInsert.Add(newrow); } } EditorActionManager.ExecuteAction(new AddParamsAction(ParamBank.Params[_clipboardParam], "legacystring", rowsToInsert, false)); } ImGui.EndPopup(); } }
public void removeRowFromSelection(PARAM.Row row) { if (_activeParam != null) { _paramStates[_activeParam].selectionRows.Remove(row); } }
// Param util: copy all values from one row to another public static void CopyRow(PARAM.Row from, PARAM.Row to) { for (int i = 0; i < from.Cells.Count; i++) { to.Cells[i].Value = from.Cells[i].Value; } }
public override ActionEvent Execute() { foreach (var row in Clonables) { var newrow = new PARAM.Row(row); if (Param[(int)row.ID] == null) { newrow.Name = row.Name != null ? row.Name : ""; int index = 0; foreach (PARAM.Row r in Param.Rows) { if (r.ID > newrow.ID) { break; } index++; } Param.Rows.Insert(index, newrow); } else { newrow.Name = row.Name != null ? row.Name + "_1" : ""; Param.Rows.Insert(Param.Rows.IndexOf(Param[(int)row.ID]) + 1, newrow); } Clones.Add(newrow); } if (SetSelection) { // EditorCommandQueue.AddCommand($@"param/select/{ParamString}/{Clones[0].ID}"); } return(ActionEvent.NoEvent); }
private void PropertyRowValueContextMenu(string visualName, string VirtualRef, dynamic oldval) { if (ImGui.BeginPopupContextItem("quickMEdit")) { if (ImGui.Selectable("Edit all selected...")) { EditorCommandQueue.AddCommand($@"param/menu/massEditRegex/selection: {visualName}: "); } if (VirtualRef != null) { PropertyRowVirtualRefContextItems(VirtualRef, oldval); } if (ParamEditorScreen.EditorMode && ImGui.BeginMenu("Find rows with this value...")) { foreach (KeyValuePair <string, PARAM> p in ParamBank.Params) { int v = (int)oldval; PARAM.Row r = p.Value[v]; if (r != null && ImGui.Selectable($@"{p.Key}: {(r.Name != null ? r.Name : "null")}")) { EditorCommandQueue.AddCommand($@"param/select/-1/{p.Key}/{v}"); } } ImGui.EndMenu(); } ImGui.EndPopup(); } }
private T AddRow(PARAM.Row row) { // Add Row instance to this Param AND add its RowWrapper to this ParamDict. Param.Rows.Add(row); base[row.ID] = (T)Activator.CreateInstance(typeof(T), row, AllParams, Text); return(this[row.ID]); }
private static void WriteMemoryPARAM(PARAM param, int paramOffset, SoulsMemoryHandler memoryHandler) { var BasePtr = memoryHandler.GetParamPtrDS3(paramOffset); var BaseDataPtr = memoryHandler.GetToRowPtrDS3(paramOffset); var RowCount = memoryHandler.GetRowCountDS3(paramOffset); IntPtr DataSectionPtr; int RowId = 0; int rowPtr = 0; for (int i = 0; i < RowCount; i++) { memoryHandler.ReadProcessMemory(BaseDataPtr, ref RowId); memoryHandler.ReadProcessMemory(BaseDataPtr + 0x8, ref rowPtr); DataSectionPtr = IntPtr.Add(BasePtr, rowPtr); BaseDataPtr += 0x18; PARAM.Row row = param[RowId]; if (row != null) { WriteMemoryRow(row, DataSectionPtr, memoryHandler); } } }
private void refreshToolStripMenuItem_Click(object sender, EventArgs e) { ParamFile selectedParam = (ParamFile)dgvRows.DataSource; PARAM.Row selectedRow = (PARAM.Row)dgvCells.DataSource; LoadRegulation(regulationPath); dgvParams.ClearSelection(); foreach (DataGridViewRow row in dgvParams.Rows) { if (((ParamFile)row.DataBoundItem).Name == selectedParam.Name) { row.Cells[0].Selected = true; } } dgvRows.ClearSelection(); foreach (DataGridViewRow row in dgvRows.Rows) { if (((PARAM.Row)row.DataBoundItem).ID == selectedRow.ID) { row.Cells[0].Selected = true; } } }
public override ActionEvent Execute() { foreach (var row in Clonables) { var newrow = new PARAM.Row(row); if (useIDAsIndex) { Param.Rows.Insert(newrow.ID, newrow); } else { if (Param[(int)row.ID] != null) { if (replParams) { PARAM.Row existing = Param[(int)row.ID]; RemovedIndex.Add(Param.Rows.IndexOf(existing)); Removed.Add(existing); Param.Rows.Remove(existing); } else { newrow.Name = row.Name != null ? row.Name + "_1" : ""; int newID = row.ID + 1; while (Param[newID] != null) { newID++; } newrow.ID = newID; Param.Rows.Insert(Param.Rows.IndexOf(Param[(int)newID - 1]) + 1, newrow); } } if (Param[(int)row.ID] == null) { newrow.Name = row.Name != null ? row.Name : ""; if (appOnly) { Param.Rows.Add(newrow); } else { int index = 0; foreach (PARAM.Row r in Param.Rows) { if (r.ID > newrow.ID) { break; } index++; } Param.Rows.Insert(index, newrow); } } } Clones.Add(newrow); } return(ActionEvent.NoEvent); }
private void dgvRows_SelectionChanged(object sender, EventArgs e) { if (dgvRows.SelectedCells.Count > 0) { PARAM.Row row = (PARAM.Row)dgvRows.SelectedCells[0].OwningRow.DataBoundItem; dgvCells.DataSource = row; dgvCells.DataMember = "Cells"; } }
public void AddRow(string key, PARAM.Row row) { if (Rows.Count > 0 && row.ID != Rows[0].ID) { throw new ArgumentException("All IDs must match for param rows to be merged"); } RowMap.Add(key, row); Rows.Add(row); }
public void Serialize(PARAM.Row regist, GameObject parent) { regist["EnemyParam"].Value = EnemyParam; regist["Unk04"].Value = Unk04; regist["Unk08"].Value = Unk08; regist["Unk0C"].Value = Unk0C; regist["Unk0E"].Value = Unk0E; regist["Unk0F"].Value = Unk0F; }
public MergedParamRow(MergedParamRow clone) { foreach (var entry in clone.RowMap) { var n = new PARAM.Row(entry.Value); RowMap.Add(entry.Key, n); Rows.Add(n); } }
public void SetFromGeneratorParam(long id, PARAM.Row regist) { ID = id; EnemyParam = (uint)regist["EnemyParam"].Value; Unk04 = (uint)regist["Unk04"].Value; Unk08 = (uint)regist["Unk08"].Value; Unk0C = (ushort)regist["Unk0C"].Value; Unk0E = (byte)regist["Unk0E"].Value; Unk0F = (byte)regist["Unk0F"].Value; }
public void SetActiveRow(PARAM.Row row) { if (_activeParam != null) { ParamEditorParamSelectionState s = _paramStates[_activeParam]; s.activeRow = row; s.selectionRows.Clear(); s.selectionRows.Add(row); } }
public void SetFromGeneratorParam(long id, PARAM.Row generator, PARAM.Row location) { ID = id; LocationUnk0C = (uint)location["Unk0C"].Value; LocationUnk14 = (uint)location["Unk14"].Value; LocationUnk18 = (uint)location["Unk18"].Value; LocationUnk1C = (uint)location["Unk1C"].Value; Unk00 = (byte)generator["Unk00"].Value; Unk01 = (byte)generator["Unk01"].Value; Unk02 = (byte)generator["Unk02"].Value; Unk03 = (byte)generator["Unk03"].Value; Unk04 = (uint)generator["Unk04"].Value; GeneratorRegistrationParam = (uint)generator["GeneratorRegistParam"].Value; Unk0C = (byte)generator["Unk0C"].Value; Unk0D = (byte)generator["Unk0D"].Value; Unk0E = (byte)generator["Unk0E"].Value; Unk0F = (byte)generator["Unk0F"].Value; Unk10 = (uint)generator["Unk10"].Value; Unk14 = (uint)generator["Unk14"].Value; Unk18 = (uint)generator["Unk18"].Value; Unk1C = (uint)generator["Unk1C"].Value; Unk20 = (uint)generator["Unk20"].Value; Unk24 = (uint)generator["Unk24"].Value; Unk28 = (uint)generator["Unk28"].Value; Unk2C = (uint)generator["Unk2C"].Value; Unk30 = (uint)generator["Unk30"].Value; Unk34 = (uint)generator["Unk34"].Value; Unk38 = (uint)generator["Unk38"].Value; Unk3C = (uint)generator["Unk3C"].Value; Unk40 = (uint)generator["Unk40"].Value; Unk44 = (uint)generator["Unk44"].Value; Unk48 = (uint)generator["Unk48"].Value; Unk4C = (uint)generator["Unk4C"].Value; Unk50 = (uint)generator["Unk50"].Value; Unk54 = (uint)generator["Unk54"].Value; Unk58 = (uint)generator["Unk58"].Value; Unk5C = (uint)generator["Unk5C"].Value; Unk60 = (uint)generator["Unk60"].Value; Unk64 = (uint)generator["Unk64"].Value; Unk68 = (uint)generator["Unk68"].Value; Unk6C = (uint)generator["Unk6C"].Value; Unk70 = (uint)generator["Unk70"].Value; Unk74 = (uint)generator["Unk74"].Value; Unk78 = (uint)generator["Unk78"].Value; Unk7C = (uint)generator["Unk7C"].Value; Unk80 = (float)generator["Unk80"].Value; Unk84 = (uint)generator["Unk84"].Value; Unk88 = (uint)generator["Unk88"].Value; Unk8C = (uint)generator["Unk8C"].Value; Unk90 = (uint)generator["Unk90"].Value; Unk94 = (uint)generator["Unk94"].Value; Unk98 = (uint)generator["Unk98"].Value; Unk9C = (uint)generator["Unk9C"].Value; }
public void Serialize(PARAM.Row generator, PARAM.Row location, GameObject parent) { location["Unk0C"].Value = LocationUnk0C; location["Unk14"].Value = LocationUnk14; location["Unk18"].Value = LocationUnk18; location["Unk1C"].Value = LocationUnk1C; generator["Unk00"].Value = Unk00; generator["Unk01"].Value = Unk01; generator["Unk02"].Value = Unk02; generator["Unk03"].Value = Unk03; generator["Unk04"].Value = Unk04; generator["GeneratorRegistParam"].Value = GeneratorRegistrationParam; generator["Unk0C"].Value = Unk0C; generator["Unk0D"].Value = Unk0D; generator["Unk0E"].Value = Unk0E; generator["Unk0F"].Value = Unk0F; generator["Unk10"].Value = Unk10; generator["Unk14"].Value = Unk14; generator["Unk18"].Value = Unk18; generator["Unk1C"].Value = Unk1C; generator["Unk20"].Value = Unk10; generator["Unk24"].Value = Unk14; generator["Unk28"].Value = Unk18; generator["Unk2C"].Value = Unk1C; generator["Unk30"].Value = Unk10; generator["Unk34"].Value = Unk14; generator["Unk38"].Value = Unk18; generator["Unk3C"].Value = Unk1C; generator["Unk40"].Value = Unk10; generator["Unk44"].Value = Unk14; generator["Unk48"].Value = Unk18; generator["Unk4C"].Value = Unk1C; generator["Unk50"].Value = Unk10; generator["Unk54"].Value = Unk14; generator["Unk58"].Value = Unk18; generator["Unk5C"].Value = Unk1C; generator["Unk60"].Value = Unk10; generator["Unk64"].Value = Unk14; generator["Unk68"].Value = Unk18; generator["Unk6C"].Value = Unk1C; generator["Unk70"].Value = Unk10; generator["Unk74"].Value = Unk14; generator["Unk78"].Value = Unk18; generator["Unk7C"].Value = Unk1C; generator["Unk80"].Value = Unk10; generator["Unk84"].Value = Unk14; generator["Unk88"].Value = Unk18; generator["Unk8C"].Value = Unk1C; generator["Unk90"].Value = Unk10; generator["Unk94"].Value = Unk14; generator["Unk98"].Value = Unk18; generator["Unk9C"].Value = Unk1C; }
private static void WriteMemoryRow(PARAM.Row row, IntPtr RowDataSectionPtr, SoulsMemoryHandler memoryHandler) { int offset = 0; int bitFieldPos = 0; BitArray bits = null; foreach (var cell in row.Cells) { offset += WriteMemoryCell(cell, RowDataSectionPtr + offset, ref bitFieldPos, ref bits, memoryHandler); } }
public void addRowToSelection(PARAM.Row row) { if (_activeParam != null) { ParamEditorParamSelectionState s = _paramStates[_activeParam]; if (!s.selectionRows.Contains(row)) { s.selectionRows.Add(row); } } }
public void OnGui(PARAM.Row selection, string id, float w, float h) { ImGui.PushStyleColor(ImGuiCol.ChildBg, new Vector4(0.145f, 0.145f, 0.149f, 1.0f)); ImGui.SetNextWindowSize(new Vector2(350, h - 80), ImGuiCond.FirstUseEver); ImGui.SetNextWindowPos(new Vector2(w - 370, 20), ImGuiCond.FirstUseEver); ImGui.Begin($@"Properties##{id}"); ImGui.BeginChild("propedit"); PropEditorParamRow(selection); ImGui.EndChild(); ImGui.End(); ImGui.PopStyleColor(); }
private void PropertyRowRefs(List <string> reftypes, dynamic oldval) { // Add named row and context menu // Lists located params ImGui.NewLine(); bool entryFound = false; foreach (string rt in reftypes) { string hint = ""; if (ParamBank.Params.ContainsKey(rt)) { PARAM param = ParamBank.Params[rt]; ParamMetaData meta = ParamMetaData.Get(ParamBank.Params[rt].AppliedParamdef); if (meta != null && meta.Row0Dummy && (int)oldval == 0) { continue; } PARAM.Row r = param[(int)oldval]; ImGui.SameLine(); if (r == null && (int)oldval > 0) { if (meta != null && meta.OffsetSize > 0) { // Test if previous row exists. In future, add param meta to determine size of offset int altval = (int)oldval - (int)oldval % meta.OffsetSize; r = ParamBank.Params[rt][altval]; hint = $@"(+{(int) oldval % meta.OffsetSize})"; } } if (r == null) { continue; } entryFound = true; if (r.Name == null || r.Name.Equals("")) { ImGui.TextColored(new Vector4(1.0f, 0.5f, 0.5f, 1.0f), "Unnamed Row"); } else { ImGui.TextColored(new Vector4(1.0f, 0.5f, 0.5f, 1.0f), r.Name + hint); } ImGui.NewLine(); } } ImGui.SameLine(); if (!entryFound) { ImGui.TextColored(new Vector4(0.0f, 0.0f, 0.0f, 1.0f), "___"); } }
public void PropEditorParamRow(PARAM.Row row) { IReadOnlyList <PARAM.Cell> cells = new List <PARAM.Cell>(); cells = row.Cells; ImGui.Columns(2); ImGui.Separator(); int id = 0; // This should be rewritten somehow it's super ugly ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0.8f, 0.8f, 0.8f, 1.0f)); var nameProp = row.GetType().GetProperty("Name"); var idProp = row.GetType().GetProperty("ID"); PropEditorPropInfoRow(row, nameProp, "Name", ref id); PropEditorPropInfoRow(row, idProp, "ID", ref id); ImGui.PopStyleColor(); ParamMetaData meta = ParamMetaData.Get(row.Def); if (meta != null && meta.AlternateOrder != null && ParamEditorScreen.AllowFieldReorderPreference) { foreach (var field in meta.AlternateOrder) { if (field.Equals("-")) { ImGui.Separator(); continue; } if (row[field] == null) { continue; } PropEditorPropCellRow(row[field], ref id); } foreach (var cell in cells) { if (!meta.AlternateOrder.Contains(cell.Def.InternalName)) { PropEditorPropCellRow(cell, ref id); } } } else { foreach (var cell in cells) { PropEditorPropCellRow(cell, ref id); } } ImGui.Columns(1); }
public static List <PARAM.Cell> GetMatchingCells(PARAM.Row row, Regex fieldrx) { List <PARAM.Cell> clist = new List <PARAM.Cell>(); foreach (PARAM.Cell c in row.Cells) { if (fieldrx.Match(c.Def.InternalName).Success) { clist.Add(c); } } return(clist); }
public PARAM.Row AddRow(string name, int id) { PARAM param = Params[name]; if (param[id] != null) { // This can get quadratic? But eh good to check throw new Exception($"Trying to add id {id} in {name} but already exists"); } PARAM.Row row = new PARAM.Row(id, "", param.AppliedParamdef); param.Rows.Add(row); return(row); }
public T CopyRow(long sourceId, long newId, params dynamic[] args) { T newRow = AddRow(newId); PARAM.Row sourceRow = Param.Rows.First(row => row.ID == sourceId); // Copy all values from source row (except name). foreach (var cell in newRow.Row.Cells) { cell.Value = sourceRow[cell.Def.InternalName].Value; } // Override with any arguments passed in. ApplyArgsToRow(newRow, args); return(newRow); }
public ShopLot(PARAM.Row itemShop, NPCShopkeeper owner) { ID = itemShop.ID; ShopLotItem = new ShopLotItem(this, (ItemShopCategoryID)Convert.ToInt64(itemShop["equipType"].Value), Convert.ToInt64(itemShop["equipId"].Value)); ShopType = (ShopTypeID)Convert.ToInt32(itemShop["shopType"].Value); Value = Convert.ToInt32(itemShop["value"].Value); MaterialID = Convert.ToInt32(itemShop["mtrlId"].Value); EventFlag = Convert.ToInt32(itemShop["eventFlag"].Value); SellQuantity = Convert.ToInt32(itemShop["sellQuantity"].Value); QwcID = Convert.ToInt64(itemShop["qwcId"].Value); Description = itemShop.Name; ownerShopKeeper = owner; originalRow = itemShop; }
public void DecorateParam(PARAM.Row row) { if (!_entryCache.ContainsKey((int)row.ID)) { _entryCache.Add((int)row.ID, FMGBank.LookupItemID((int)row.ID, _category)); } var entry = _entryCache[(int)row.ID]; if (entry != null) { ImGui.SameLine(); ImGui.TextColored(new Vector4(1.0f, 1.0f, 0.0f, 1.0f), $@" <{entry.Text}>"); } }
/// <summary> /// Initialize from DS3 item lot param /// </summary> /// <param name="lot"></param> public ItemLotParam(PARAM.Row lot) { for (int i = 0; i < 8; i++) { ItemID[i] = (int)lot[$@"ItemLotId{i + 1}"].Value; } for (int i = 0; i < 8; i++) { ItemCategory[i] = (uint)lot[$@"LotItemCategory0{i + 1}"].Value; } for (int i = 0; i < 8; i++) { ItemBasePoint[i] = (short)lot[$@"LotItemBasePoint0{i + 1}"].Value; } for (int i = 0; i < 8; i++) { ItemCumulatePoint[i] = (short)lot[$@"cumulateLotPoint0{i + 1}"].Value; } for (int i = 0; i < 8; i++) { GetItemFlagID[i] = (int)lot[$@"GetItemFlagId0{i + 1}"].Value; } GetItemFlagIDG = (int)lot["getItemFlagId"].Value; CumulateNumFlagID = (int)lot["cumulateNumFlagId"].Value; CumulateMaxNum = (byte)lot["cumulateNumMax"].Value; ItemRarity = (byte)lot["LotItemRarity"].Value; for (int i = 0; i < 8; i++) { ItemNum[i] = (byte)lot[$@"LotItemNum{i + 1}"].Value; } for (int i = 0; i < 8; i++) { EnableLuck[i] = (bool)lot[$@"EnableLuck0{i + 1}"].Value; } for (int i = 0; i < 8; i++) { CumulateReset[i] = (bool)lot[$@"cumulateReset0{i + 1}"].Value; } ClearCount = (sbyte)lot["ClearCount"].Value; }
public void DecorateContextMenu(PARAM.Row row) { if (!_entryCache.ContainsKey((int)row.ID)) { return; } if (ImGui.BeginPopupContextItem(row.ID.ToString())) { if (ImGui.Selectable($@"Goto {_category.ToString()} Text")) { EditorCommandQueue.AddCommand($@"text/select/{_category.ToString()}/{row.ID}"); } ImGui.EndPopup(); } }