public DMASTDefinitionParameter(DMASTPath path, DMASTExpression value, DMValueType type, DMASTExpression possibleValues) { Path = path; Value = value; Type = type; PossibleValues = possibleValues; }
private void SetVariableValue(DMVariable variable, DMASTExpression value, DMValueType valType = DMValueType.Anything) { DMVisitorExpression._scopeMode = variable.IsGlobal ? "static" : "normal"; DMExpression expression = DMExpression.Create(_currentObject, variable.IsGlobal ? DMObjectTree.GlobalInitProc : null, value, variable.Type); DMVisitorExpression._scopeMode = "normal"; expression.ValType = valType; if (expression.TryAsConstant(out var constant)) { variable.Value = constant; return; } if (variable.IsConst) { throw new CompileErrorException(value.Location, "Value of const var must be a constant"); } //Whether this should be initialized at runtime bool isValid = expression switch { //TODO: A better way of handling procs evaluated at compile time Expressions.ProcCall procCall => procCall.GetTargetProc(_currentObject).Proc?.Name switch { "rgb" => true, "generator" => true, "matrix" => true, "icon" => true, "file" => true, "sound" => true, _ => variable.IsGlobal },
public override void ReadFromBuffer(NetIncomingMessage buffer) { PromptId = buffer.ReadVariableInt32(); Types = (DMValueType)buffer.ReadUInt16(); Title = buffer.ReadString(); Message = buffer.ReadString(); DefaultValue = buffer.ReadString(); }
protected void FinishPrompt(DMValueType responseType, object value) { if (_responseSent) { return; } _responseSent = true; Program.OpenDream.Connection.SendPacket(new PacketPromptResponse(PromptId, responseType, value)); Close(); }
private void SetVariableValue(DMVariable variable, DMASTExpression value, DMValueType valType = DMValueType.Anything) { DMVisitorExpression._scopeMode = variable.IsGlobal ? "static" : "normal"; DMExpression expression = DMExpression.Create(_currentObject, variable.IsGlobal ? DMObjectTree.GlobalInitProc : null, value, variable.Type); DMVisitorExpression._scopeMode = "normal"; expression.ValType = valType; if (expression.TryAsConstant(out var constant)) { variable.Value = constant; return; } if (variable.IsConst) { throw new CompileErrorException(value.Location, "Value of const var must be a constant"); } switch (expression) { case Expressions.List: case Expressions.NewList: case Expressions.NewPath: //TODO: A better way of handling procs evaluated at compile time case Expressions.ProcCall procCall when procCall.GetTargetProc(_currentObject).Proc?.Name == "rgb": variable.Value = new Expressions.Null(Location.Unknown); EmitInitializationAssign(variable, expression); break; case Expressions.ProcCall procCall when procCall.GetTargetProc(_currentObject).Proc?.Name == "generator": variable.Value = new Expressions.Null(Location.Unknown); EmitInitializationAssign(variable, expression); break; case Expressions.StringFormat: case Expressions.ProcCall: if (!variable.IsGlobal) { throw new CompileErrorException(value.Location, $"Invalid initial value for \"{variable.Name}\""); } variable.Value = new Expressions.Null(Location.Unknown); EmitInitializationAssign(variable, expression); break; default: throw new CompileErrorException(value.Location, $"Invalid initial value for \"{variable.Name}\""); } }
public override void ReadFromBuffer(NetIncomingMessage buffer) { PromptId = buffer.ReadVariableInt32(); Type = (DMValueType)buffer.ReadUInt16(); Value = Type switch { DMValueType.Null => null, DMValueType.Text or DMValueType.Message => buffer.ReadString(), DMValueType.Num => buffer.ReadSingle(), _ => throw new ArgumentOutOfRangeException() }; }
protected void FinishPrompt(DMValueType responseType, object value) { if (_responseSent) { return; } _responseSent = true; var msg = _netManager.CreateNetMessage <MsgPromptResponse>(); msg.PromptId = _promptId; msg.Type = responseType; msg.Value = value; _netManager.ClientSendMessage(msg); }
protected void FinishPrompt(DMValueType responseType, object value) { if (_responseSent) { return; } _responseSent = true; var msg = new MsgPromptResponse() { PromptId = _promptId, Type = responseType, Value = value }; _netManager.ClientSendMessage(msg); }
public void ReadFromStream(PacketStream stream) { PromptId = stream.ReadUInt16(); Type = (DMValueType)stream.ReadUInt16(); switch (Type) { case DMValueType.Null: Value = null; break; case DMValueType.Text: Value = stream.ReadString(); break; case DMValueType.Num: Value = stream.ReadInt32(); break; case DMValueType.Message: Value = stream.ReadString(); break; default: throw new Exception("Invalid prompt response type '" + Type + "'"); } }
public DMASTInput(DMASTCallParameter[] parameters, DMValueType types, DMASTExpression list) { Parameters = parameters; Types = types; List = list; }
public void ReadFromStream(PacketStream stream) { PromptId = stream.ReadUInt16(); Types = (DMValueType)stream.ReadUInt16(); Message = stream.ReadString(); }
public PacketPrompt(int promptId, DMValueType types, string message) { PromptId = promptId; Types = types; Message = message; }
public PacketPromptResponse(int promptId, DMValueType type, object value) { PromptId = promptId; Type = type; Value = value; }