|
23 | 23 |
|
24 | 24 | namespace Sims2Tools.DBPF.CPF
|
25 | 25 | {
|
26 |
| - public abstract class Cpf : DBPFResource, IDisposable |
| 26 | + public abstract class Cpf : DBPFResource, IDbpfScriptable, IDisposable |
27 | 27 | {
|
28 | 28 | private static readonly byte[] SIGNATURE = { 0xE0, 0x50, 0xE7, 0xCB, 0x02, 0x00 };
|
29 | 29 |
|
@@ -274,6 +274,70 @@ public CpfItem GetOrAddItem(string name, MetaData.DataTypes datatype)
|
274 | 274 | return AddItem(new CpfItem(name, datatype));
|
275 | 275 | }
|
276 | 276 |
|
| 277 | + #region IDBPFScriptable |
| 278 | + public bool Assert(string item, string value) |
| 279 | + { |
| 280 | + // TODO - IDBPFScriptable - Assert |
| 281 | + throw new NotImplementedException(); |
| 282 | + } |
| 283 | + |
| 284 | + public bool Assignment(string item, string value) |
| 285 | + { |
| 286 | + CpfItem cpfItem = GetItem(item); |
| 287 | + |
| 288 | + if (cpfItem != null) |
| 289 | + { |
| 290 | + switch (cpfItem.DataType) |
| 291 | + { |
| 292 | + case MetaData.DataTypes.dtString: |
| 293 | + { |
| 294 | + cpfItem.StringValue = value; |
| 295 | + return true; |
| 296 | + } |
| 297 | + case MetaData.DataTypes.dtUInteger: |
| 298 | + { |
| 299 | + uint val; |
| 300 | + |
| 301 | + if (value.StartsWith("0x")) |
| 302 | + { |
| 303 | + val = UInt32.Parse(value.Substring(2), System.Globalization.NumberStyles.HexNumber); |
| 304 | + } |
| 305 | + else |
| 306 | + { |
| 307 | + val = UInt32.Parse(value); |
| 308 | + } |
| 309 | + |
| 310 | + cpfItem.UIntegerValue = val; |
| 311 | + return true; |
| 312 | + } |
| 313 | + case MetaData.DataTypes.dtInteger: |
| 314 | + { |
| 315 | + cpfItem.IntegerValue = Int32.Parse(value); |
| 316 | + return true; |
| 317 | + } |
| 318 | + case MetaData.DataTypes.dtBoolean: |
| 319 | + { |
| 320 | + // TODO - IDBPFScriptable - Assignment |
| 321 | + throw new NotImplementedException(); |
| 322 | + } |
| 323 | + case MetaData.DataTypes.dtSingle: |
| 324 | + { |
| 325 | + // TODO - IDBPFScriptable - Assignment |
| 326 | + throw new NotImplementedException(); |
| 327 | + } |
| 328 | + } |
| 329 | + } |
| 330 | + |
| 331 | + return false; |
| 332 | + } |
| 333 | + |
| 334 | + public IDbpfScriptable Indexed(int index) |
| 335 | + { |
| 336 | + // TODO - IDBPFScriptable - Indexed |
| 337 | + throw new NotImplementedException(); |
| 338 | + } |
| 339 | + #endregion |
| 340 | + |
277 | 341 | protected XmlElement AddXml(XmlElement parent, string name)
|
278 | 342 | {
|
279 | 343 | XmlElement element = XmlHelper.CreateResElement(parent, name, this);
|
|
0 commit comments