public ScriptGraphNode(ScriptsConfiguration config, Script script, List <Script> availableScripts) { this.config = config; this.availableScripts = availableScripts; title = script.Name; expanded = true; m_CollapseButton.Clear(); m_CollapseButton.SetEnabled(false); capabilities = Capabilities.Ascendable | Capabilities.Selectable | Capabilities.Movable; Script = script; RegisterCallback <MouseDownEvent>(OnNodeMouseDown); InputPorts[string.Empty] = AddPort(Direction.Input, startLabel); foreach (var line in script.Lines) { if (line is LabelScriptLine labelLine) { InputPorts[labelLine.LabelText] = AddPort(Direction.Input, $"{LabelScriptLine.IdentifierLiteral}{labelLine.LabelText}"); continue; } if (line is CommandScriptLine commandLine) { if (commandLine.Command is Goto gotoCommand) { AddOutPort(gotoCommand, gotoCommand.Path.Name ?? line.ScriptName, gotoCommand.Path.NamedValue, $"goto {gotoCommand.Path}".Replace(".null", string.Empty).Replace("null", string.Empty)); } if (commandLine.Command is Gosub gosubCommand) { AddOutPort(gosubCommand, gosubCommand.Path.Name ?? line.ScriptName, gosubCommand.Path.NamedValue, $"gosub {gosubCommand.Path}".Replace(".null", string.Empty).Replace("null", string.Empty)); } continue; } } void AddOutPort(Command command, string gotoScript, string gotoLabel, string portLabel) { portLabel = $"{CommandScriptLine.IdentifierLiteral}{portLabel}"; var portData = new OutputPortData { ScriptName = gotoScript, Label = string.IsNullOrEmpty(gotoLabel) ? string.Empty : gotoLabel, Port = AddPort(Direction.Output, portLabel, command.ConditionalExpression) }; OutputPorts.Add(portData); } }
// ================================================== // コンストラクタ // ================================================== public DrumMap(string targetPath) { // ---------------------------------------- // ノート、出力ポートの個数を数える // ---------------------------------------- NoteCount = 0; OutputPortCount = 0; foreach (string line in File.ReadLines(targetPath)) { if (line[0] == '#') { OutputPortCount++; } else { NoteCount++; } } // ---------------------------------------- // ノート、出力ポートの情報を読み込む // ---------------------------------------- NoteDatas = new NoteData[NoteCount]; OutputPortDatas = new OutputPortData[OutputPortCount]; int noteCount = 0; int outputPortCount = 0; foreach (string line in File.ReadLines(targetPath)) { // 読み込んだ行をタブで分解 string[] splitedDatas = line.Split('\t'); // 行頭に # がついている場合、出力ポート情報の読み込み if (line[0] == '#') { string tmpOutputPortName; uint tmpDefaultFlag; uint tmpDefaultPacking; uint tmpBankNumber; uint tmpPatchNumber; // 出力ポート名がデフォルトの場合 if (InputData.Instance().OutputPortNames[InputData.Instance().SelectedOutputPortNameIndex] == "デフォルト") { tmpOutputPortName = null; tmpDefaultFlag = DefaultPortTrue; tmpDefaultPacking = Packing_F; } else { tmpOutputPortName = InputData.Instance().OutputPortNames[InputData.Instance().SelectedOutputPortNameIndex]; tmpDefaultFlag = DefaultPortFalse; tmpDefaultPacking = Packing_0; } // バンク番号がデフォルトの場合 if (splitedDatas[3] == "-") { tmpBankNumber = Packing_F; } else { tmpBankNumber = uint.Parse(splitedDatas[3]); } // パッチ番号がデフォルトの場合 if (splitedDatas[4] == "-") { tmpPatchNumber = Packing_F; } else { tmpPatchNumber = uint.Parse(splitedDatas[4]); } // 出力ポート情報をまとめる OutputPortDatas[outputPortCount] = new OutputPortData( channelNumber: uint.Parse(splitedDatas[1]), outputPortNumber: uint.Parse(splitedDatas[2]), outputPortName: tmpOutputPortName, defaultFlag: tmpDefaultFlag, defaultPacking: tmpDefaultPacking, bankNumber: tmpBankNumber, patchNumber: tmpPatchNumber ); outputPortCount++; } // 行頭に # がついていない場合、ノート情報の読み込み else { uint tmpNoteEndFlag; // 最後のノートの場合 if (noteCount == NoteCount - 1) { tmpNoteEndFlag = NoteEndTrue; } else { tmpNoteEndFlag = NoteEndFalse; } // ノート情報をまとめる NoteDatas[noteCount] = new NoteData( inputNoteNumber: uint.Parse(splitedDatas[0]), outputNoteNumber: uint.Parse(splitedDatas[1]), noteName: splitedDatas[2], channelNumber: uint.Parse(splitedDatas[3]), outputPortNumber: uint.Parse(splitedDatas[4]), velocityOffset: int.Parse(splitedDatas[5]), velocityScale: float.Parse(splitedDatas[6]) / 100, tmpNoteEndFlag ); noteCount++; } } //読み込んだ情報からファイルサイズと各セクションのサイズを算出 NoteDataSize = 16 + 116 * NoteCount; OutputPortDataSize = 16 + 20 * OutputPortCount; OutputPortDataSize2 = 16 + 24 * OutputPortCount; OthrerDataSize = 16 + 40 * NoteCount; BankPatchDataSize = 16 + 36 * OutputPortCount; FileSize = 16 + NoteDataSize + 174 + OutputPortDataSize + OutputPortDataSize2 + OthrerDataSize; }