public void SetScriptComment(int line_no, ScriptMessageType type, string message) { var change = false; var msg_data = (ScriptMessageData)null; lock (comment_list_sync_) { if (line_no < comment_list_.Length) { if (message != null) { /* データ有りの場合はデータベースに上書き登録 */ comment_list_[line_no] = new ScriptMessageData(DateTime.UtcNow, type, message); change = true; } else { /* データ無しの場合はデータベースから削除 */ comment_list_[line_no] = null; change = true; } } } if (change) { CommentUpdated?.Invoke(this, line_no, msg_data); } }
/// <summary> /// Called when the script parsing has errors/warnings /// </summary> /// <param name="message"></param> /// <param name="messageType"></param> protected void RaiseScriptError(string message, ScriptMessageType messageType) { if (scriptErrorDelegate != null) { scriptErrorDelegate(message, messageType); } }
private void AddMessage(ScriptMessageType type, string message) { var msg_info = new ScriptMessageData(DateTime.UtcNow, type, message); lock (message_list_sync_) { message_list_.Add(msg_info); } MessageAppended?.Invoke(this, msg_info); }
/// <summary> /// Called when the script parsing has errors/warnings /// </summary> /// <param name="message"></param> /// <param name="messageType"></param> private void RaiseScriptError(string message, ScriptMessageType messageType) { switch (messageType) { case (ScriptMessageType.FatalError): RaiseBatchParserExecutionError(SR.EE_ScriptError_FatalError, message, messageType); break; case (ScriptMessageType.Error): RaiseBatchParserExecutionError(SR.EE_ScriptError_Error, message, messageType); break; default: Debug.Assert(messageType == ScriptMessageType.Warning); RaiseBatchParserExecutionError(SR.EE_ScriptError_Warning, message, messageType); break; } }
/// <summary> /// Constructor method for BatchParserExecutionErrorEventArgs class /// </summary> public BatchParserExecutionErrorEventArgs(string errorLine, string message, ScriptMessageType messageType) : base(errorLine, message, null) { this.messageType = messageType; }
/// <summary> /// Called when batch parser found an error /// </summary> /// <param name="msg"></param> private void RaiseBatchParserExecutionError(string errorLine, string message, ScriptMessageType messageType) { EventHandler <BatchParserExecutionErrorEventArgs> cache = BatchParserExecutionError; if (cache != null) { BatchParserExecutionErrorEventArgs args = new BatchParserExecutionErrorEventArgs(errorLine, message, messageType); cache(this, args); } }
public ScriptMessageData(DateTime dt, ScriptMessageType type, string message) { CreateTime = dt; Type = type; Message = message; }
// Recv Opcodes public void handleOutboundPackets(OutboundOpcodes opcode, Packet packet) { switch (opcode) { case USER_PORTAL_SCRIPT_REQUEST: packet.ReadByte(); String portalName = packet.ReadString(); String script = Util.getPortalScriptName(Parser.MAP_ID, portalName); if (!script.Equals("Unknown") && !isWaitForScriptAnswer()) { bool initedLifes = initedLifeObjects; Parser.dispose(); Parser.getActiveScript().setPortal(Parser.MAP_ID, script, initedLifes); } break; case OutboundOpcodes.DIRECTION_NODE_COLLISION: int key = packet.ReadInt(); if (!Util.getDirectionScriptName(Parser.MAP_ID, key).Equals("Unknown")) { bool initedLifes = initedLifeObjects; Parser.dispose(); Parser.getActiveScript().setDirection(Parser.MAP_ID, key, initedLifes); } break; case USER_QUEST_REQUEST: int requestType = packet.ReadByte(); int questID = packet.ReadInt(); if (questID == 7707) { return; } if (!isWaitForScriptAnswer()) { bool inited = initedLifeObjects; // should I check the type and then dispose ? Parser.dispose(); Handler.handleUserQuestRequest(requestType, questID, inited); read = true; } break; case USER_SELECT_NPC: //if (isDisposed()) //{ int objectID = packet.ReadInt(); Npc npc = LifeStorage.getNpcByObjectID(objectID); if (npc != null) { if (Util.hasNpcScript(npc.TemplateID)) { bool initedLifes = initedLifeObjects; Parser.dispose(); Parser.getActiveScript().setNpcID(npc.TemplateID, initedLifes); } } //} break; case USER_SCRIPT_MESSAGE_ANSWER: ScriptMessageType scriptMessageType = Util.GetEnumObjectByValue <ScriptMessageType>(packet.ReadByte()); Console.WriteLine("Script MEssage Type {0}", scriptMessageType); if (scriptMessageType == ScriptMessageType.AskYesNo || scriptMessageType == ScriptMessageType.AskAccept) { addComment("Response is " + (packet.ReadBool() ? "Yes" : "No")); } if (scriptMessageType == ScriptMessageType.AskMenu) { packet.ReadByte(); if (packet.Length >= 4) { addComment(String.Format("if selection == {0}:", packet.ReadInt())); } } setWaitForAnswer(false); break; } }
public static void handleScriptMessage(Packet packet) { int speakerType = packet.ReadByte(); int speakerID = packet.ReadInt(); if (packet.ReadBool()) { int overrideNpc = packet.ReadInt(); if (overrideNpc != 0) { speakerID = overrideNpc; } } ScriptMessageType type = Util.GetEnumObjectByValue <ScriptMessageType>(packet.ReadByte()); int param = packet.ReadShort(); int color = packet.ReadByte(); switch (type) { case Say: case AskMenu: case AskAccept: case AskYesNo: case AskText: case AskBoxText: case SayIllustration: if (hasParam(param, ParamType.OverrideSpeakerID)) { int overrideNpc = packet.ReadInt(); if (overrideNpc != 0) { speakerID = overrideNpc; } } break; } switch (param) { case 0x24: Parser.getActiveScript().addLine(String.Format("sm.setNpcOverrideBoxChat({0})", speakerID)); break; case 0x25: Parser.getActiveScript().addLine(String.Format("sm.setIntroBoxChat({0})", speakerID)); break; default: Parser.getActiveScript().addLine(String.Format("sm.setSpeakerID({0})", speakerID)); handleScriptMessageParam(param); if (color != 0) { Parser.getActiveScript().addLine(String.Format("sm.setColor({0})", color)); } break; } if (speakerType != 4) { Parser.getActiveScript().addLine(String.Format("sm.setSpeakerType({0})", speakerType)); } String text; bool isPrev, isNext; switch (type) { case Say: text = packet.ReadString(); isPrev = packet.ReadBool(); isNext = packet.ReadBool(); if (text.Contains(Environment.NewLine)) { text.Replace(Environment.NewLine, "\r\n"); } if (isPrev && isNext) { Parser.getActiveScript().addLine(String.Format("sm.sendSay({0})", Util.quotes(text))); } else if (isPrev && !isNext) { Parser.getActiveScript().addLine(String.Format("sm.sendPrev({0})", Util.quotes(text))); } else if (!isPrev && isNext) { Parser.getActiveScript().addLine(String.Format("sm.sendNext({0})", Util.quotes(text))); } else { Parser.getActiveScript().addLine(String.Format("sm.sendSayOkay({0})", Util.quotes(text))); } break; case AskYesNo: text = packet.ReadString(); if (text.Contains(Environment.NewLine)) { text.Replace(Environment.NewLine, "\r\n"); } Parser.getActiveScript().addLine(String.Format("if sm.sendAskYesNo({0}):", Util.quotes(text))); break; case AskAccept: text = packet.ReadString(); if (text.Contains(Environment.NewLine)) { text.Replace(Environment.NewLine, "\r\n"); } Parser.getActiveScript().addLine(String.Format("if sm.sendAskAccept({0}):", Util.quotes(text))); break; case AskMenu: text = packet.ReadString(); if (text.Contains(Environment.NewLine)) { text.Replace(Environment.NewLine, "\r\n"); } Parser.getActiveScript().addLine(String.Format("selection = sm.sendNext({0})", Util.quotes(text))); break; case SayIllustration: text = packet.ReadString(); isPrev = packet.ReadBool(); isNext = packet.ReadBool(); int faceIndex = packet.ReadInt(); String isLeft = packet.ReadBoolPy(); if (isPrev && isNext) { Parser.getActiveScript().addLine(String.Format("sm.sendSayIllustration({0}, {1}, {2})", Util.quotes(text), faceIndex, isLeft)); } else if (isPrev && !isNext) { Parser.getActiveScript().addLine(String.Format("sm.sendSayPrevIllustration({0}, {1}, {2})", Util.quotes(text), faceIndex, isLeft)); } else if (!isPrev && isNext) { Parser.getActiveScript().addLine(String.Format("sm.sendSayNextIllustration({0}, {1}, {2})", Util.quotes(text), faceIndex, isLeft)); } else { Parser.getActiveScript().addLine(String.Format("sm.sendSayOkayIllustration({0}, {1}, {2})", Util.quotes(text), faceIndex, isLeft)); } break; default: Parser.getActiveScript().addComment(String.Format("Unhandled Script Message [{0}] Packet: {1}", type, packet.ToString())); break; } Parser.getActiveScript().setWaitForAnswer(true); }