PageRenderTime 39ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/NekoKun.Editor/RPGMaker/EventCommand/EventCommand.cs

https://bitbucket.org/nekokun/nekokun
C# | 49 lines | 43 code | 6 blank | 0 comment | 8 complexity | 20dd67882fb99297300d53ede113952d MD5 | raw file
Possible License(s): MIT, CC-BY-SA-3.0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using NekoKun.Serialization.RubyMarshal;
  5. namespace NekoKun.RPGMaker
  6. {
  7. public class EventCommand
  8. {
  9. public string ID;
  10. public string Name;
  11. public string Format;
  12. public EventCommandGroup Group;
  13. public bool IsGenerated;
  14. public string GeneratedBy;
  15. public EventCommand(System.Xml.XmlNode node, EventCommandGroup group)
  16. {
  17. ID = node.Attributes["ID"].Value;
  18. Name = node.Attributes["Name"].Value;
  19. Group = group;
  20. if (node.Attributes["Format"] != null)
  21. {
  22. Format = group.Provider.Format.PrepareFormat(node.Attributes["Format"].Value);
  23. }
  24. else
  25. Format = Name;
  26. if (node.Attributes["GeneratedBy"] != null)
  27. {
  28. IsGenerated = true;
  29. GeneratedBy = node.Attributes["GeneratedBy"].Value;
  30. }
  31. }
  32. public string FormatParams(RubyObject ev)
  33. {
  34. object o = ev.InstanceVariable["@parameters"];
  35. if (o == null)
  36. return this.Group.Provider.Format.ParseFormat(this.Format, null);
  37. List<object> param = o as List<object>;
  38. if (param.Count == 0)
  39. return this.Group.Provider.Format.ParseFormat(this.Format, null);
  40. return this.Group.Provider.Format.ParseFormat(this.Format, param);
  41. }
  42. }
  43. }