WINCLOSE.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. namespace OpenVIII.Fields.Scripts.Instructions
  2. {
  3. /// <summary>
  4. /// Close the last window created by AMES.
  5. /// I haven't tried this for other types of windows...
  6. /// </summary>
  7. internal sealed class WINCLOSE : JsmInstruction
  8. {
  9. #region Fields
  10. private readonly int _channel;
  11. #endregion Fields
  12. #region Constructors
  13. public WINCLOSE(int channel) => _channel = channel;
  14. public WINCLOSE(int parameter, IStack<IJsmExpression> stack)
  15. : this(
  16. channel: ((Jsm.Expression.PSHN_L)stack.Pop()).Int32())
  17. {
  18. }
  19. #endregion Constructors
  20. #region Methods
  21. public override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services) => sw.Format(formatterContext, services)
  22. .StaticType(nameof(IMessageService))
  23. .Method(nameof(IMessageService.Close))
  24. .Argument("channel", _channel)
  25. .Comment(nameof(WINCLOSE));
  26. public override IAwaitable TestExecute(IServices services)
  27. {
  28. ServiceId.Message[services].Close(_channel);
  29. return DummyAwaitable.Instance;
  30. }
  31. public override string ToString() => $"{nameof(WINCLOSE)}({nameof(_channel)}: {_channel})";
  32. #endregion Methods
  33. }
  34. }