/// <summary> /// 从缓存区构造多边形填充到字型轮廓(一个字型轮廓包含多个多边形,每个多边形由若干个直线或曲线组成) /// </summary> /// <param name="outline">轮廓</param> /// <param name="buffer">缓存区指针</param> /// <param name="bufferSize">缓存区大小</param> /// <returns></returns> private static void FillPolygons(DOutline outline, IntPtr buffer, int bufferSize) { //多边形头大小 int polygonHeaderSize = Marshal.SizeOf(typeof(TTPOLYGONHEADER)); //线大小 int lineSize = Marshal.SizeOf(typeof(TTPOLYCURVEHEAD)); //点大小 int pointFxSize = Marshal.SizeOf(typeof(POINTFX)); //缓存区首地址值 int ptr = buffer.ToInt32(); //偏移量 int offset = 0; //轮廓的多边形列表 IList <DPolygon> polygons = outline.Polygons; while (offset < bufferSize) { //多边形头信息 TTPOLYGONHEADER header = (TTPOLYGONHEADER)Marshal.PtrToStructure(new IntPtr(ptr + offset), typeof(TTPOLYGONHEADER)); //构建多边形 DPolygon polygon = new DPolygon(header.dwType); //起始点 polygon.Start = header.pfxStart; //获取尾索引 int endCurvesIndex = offset + header.cb; //向后偏移一个项 offset += polygonHeaderSize; while (offset < endCurvesIndex) { //线段信息 TTPOLYCURVEHEAD lineHeader = (TTPOLYCURVEHEAD)Marshal.PtrToStructure(new IntPtr(ptr + offset), typeof(TTPOLYCURVEHEAD)); //偏移到点序列首地址 offset += lineSize; //构建线段 DLine line = new DLine(lineHeader.wType); //读取点序列,加入线段中 for (int i = 0; i < lineHeader.cpfx; i++) { POINTFX point = (POINTFX)Marshal.PtrToStructure(new IntPtr(ptr + offset), typeof(POINTFX)); //将点加入线段 line.Points.Add(point); //偏移 offset += pointFxSize; } //将线加入多边形 polygon.Lines.Add(line); } //将多边形加入轮廓 polygons.Add(polygon); } }
public void DLine_FromYarnLine_TitleCaseFace() { line.text = "Nora (Happy): Test."; DLine dLine = DLine.FromYarnLine(line); Assert.AreEqual("Nora", dLine.name); Assert.AreEqual("Happy", dLine.face); Assert.AreEqual("Test.", dLine.text); }
public void DLine_FromYarnLine_Default() { line.text = "Henry: Test"; DLine dLine = DLine.FromYarnLine(line); Assert.AreEqual("Henry", dLine.name); Assert.AreEqual("Default", dLine.face); Assert.AreEqual("Test", dLine.text); }
public void DLine_FromYarnLine_WordsWithColonsAndParens() { line.text = "Nora (Sad): Test Test (Test): More test."; DLine dLine = DLine.FromYarnLine(line); Assert.AreEqual("Nora", dLine.name); Assert.AreEqual("Sad", dLine.face); Assert.AreEqual("Test Test (Test): More test.", dLine.text); }
public void DLine_FromYarnLine_Pause() { line.text = "Nora (Happy) <nopause>: Test."; DLine dLine = DLine.FromYarnLine(line); Assert.AreEqual("Nora", dLine.name); Assert.AreEqual("Happy", dLine.face); Assert.AreEqual("Test.", dLine.text); Assert.AreEqual(false, dLine.pause); }
public void DLine_FromYarnLine_Jitter() { line.text = "Nora (Happy) <jitter=1.5>: Test."; DLine dLine = DLine.FromYarnLine(line); Assert.AreEqual("Nora", dLine.name); Assert.AreEqual("Happy", dLine.face); Assert.AreEqual("Test.", dLine.text); Assert.AreEqual(1.5f, dLine.jitter); }
public void DLine_FromYarnLine_Speed() { line.text = "Nora (Happy) <speed=1.5>: Test."; DLine dLine = DLine.FromYarnLine(line); Assert.AreEqual("Nora", dLine.name); Assert.AreEqual("Happy", dLine.face); Assert.AreEqual("Test.", dLine.text); Assert.AreEqual(1.5f, dLine.speed); }
public void DLine_FromYarnLine_ClearText() { line.text = "Nora (Happy) <nocleartext>: Test."; DLine dLine = DLine.FromYarnLine(line); Assert.AreEqual("Nora", dLine.name); Assert.AreEqual("Happy", dLine.face); Assert.AreEqual("Test.", dLine.text); Assert.AreEqual(false, dLine.clear_text); }
public void DLine_FromYarnLine_WaitAndClear() { line.text = "Nora (Happy) <nocleartext; wait=1.5>: Test."; DLine dLine = DLine.FromYarnLine(line); Assert.AreEqual("Nora", dLine.name); Assert.AreEqual("Happy", dLine.face); Assert.AreEqual("Test.", dLine.text); Assert.AreEqual(false, dLine.clear_text); Assert.AreEqual(1.5f, dLine.wait); }
public void TestObjectSet() { HashSet <GraphItem> set1 = new HashSet <GraphItem>(); GraphItem item1 = new DLine(); GraphItem item2 = new DLine(); set1.Add(item2); set1.Add(item1); if (set1.Contains(item2)) { Console.WriteLine("Contains"); } }
private void bt_line_Click(object sender, EventArgs e) { DLine line = new DLine { MyBrush = new SolidBrush(Color.FromArgb(128, Color.DarkOrchid)), Selectable = true //X = e.Location.X, //Y = e.Location.Y, }; CommandAdd add = new CommandAdd(); add.item = line; paintPanel1.SetCommand(add); }
// PlControl pl; // private void Start() { // pl=GameObject.FindObjectOfType<PlControl>(); // } // private void Update() { // // if((pl.transform.position-transform.position).magnitude>5){ // // Debug.Log("unconnect"); // // } // } public override void interact(int val = 0) { DLine ln = di.getNextLine(val); if (ln == null) { activeI = false; } else { Debug.Log(aname + ":" + ln.str); txt.text = ln.str; if (!ln.str.Equals("")) { player.playS("talk"); } } }
private void GDLine() { Graphics DLine; DLine = this.CreateGraphics(); Pen PL = new Pen(Color.FromArgb(255, RedL, GreenL, BlueL), 6); DLine.Clear(this.BackColor); DLine.DrawLine(PL, 100, 100, 400, 400); DLine.DrawLine(PL, 400, 100, 100, 400); DLine.DrawLine(PL, 250, 100, 250, 400); DLine.DrawLine(PL, 400, 250, 100, 250); DLine.DrawLine(PL, 100, 100, 100, 400); DLine.DrawLine(PL, 400, 100, 400, 400); DLine.DrawLine(PL, 100, 100, 400, 100); DLine.DrawLine(PL, 100, 400, 400, 400); DLine.Dispose(); }
/// <summary> /// 有的1、3路本来Goup应该是相等的,但是AM却把他们的Goup切成不一样的了,这时候需要递归判断,如果成功后取出最后的行号,以便外部不用再判断中间判断过的了 /// </summary> /// <param name="detailRoot"></param> /// <param name="firstLineIdx"></param> /// <param name="groupIdx"></param> /// <param name="toRow"></param> /// <param name="toGroup"></param> /// <returns></returns> bool CrossJuge(DReport detailRoot, int startLineIdx, int startGroupIdx, int startRowIdx, int opGroupIdx, int opStartRowIdx, ref HashSet <DRow> crossJugeRowList) { bool result = false; int opLineIdx = 1; if (startLineIdx == 1) { opLineIdx = 3; } //取出交叉判断的第一个Goup的第一Row的行索引 var startGroup = detailRoot.rowData.rowGroups[startGroupIdx]; DLine opOneLine = null; //尝试10次,因为对面的路不一定在下一个Goup里,下一个Goup里可能只有中间路的而不一定是两边路的, //(XXX)这时候就从下一个Group找,这样最多找10次直到找到为止(XXX) //上面的判断会有bug,2019-4-20 更新,因为只是该Goup的这一行只有中间路两边路没有而已,该Goup的下面几行还有会可能有两边路的,所以先循环该Goup的所有行没有再到下一个Goup for (int i = 0; i < 10; ++i) { opGroupIdx += i; if (opGroupIdx < detailRoot.rowData.rowGroups.Length) { var opGroup = detailRoot.rowData.rowGroups[opGroupIdx]; for (; opStartRowIdx < opGroup.rows.Length; ++opStartRowIdx) { var opOneRow = opGroup.rows[opStartRowIdx]; opOneLine = opOneRow.GetLine(opLineIdx); if (opOneLine != null) { break; } } } if (opOneLine != null) { break; } opStartRowIdx = 0; } if (opOneLine == null) { return(result); } var opOneNum = opOneLine.number; var opRowIdx = 0; for (int rowIdx = startRowIdx; rowIdx < startGroup.rows.Length; ++rowIdx) { //该Goup从Row为0开始往下判断 var drow = startGroup.rows[rowIdx]; var line = drow.GetLine(startLineIdx); //这里line有可能为空,因为这一Goup有可能中间路多很多Row,多出的那些Row两边都可能没有,这些Row都是新增Line操作的,所以直接crossJugeRowList.Add(drow);就可以了 if (line != null) { var opText = GetTextByLineNumber(detailRoot, opGroupIdx, opLineIdx, opOneNum, out opGroupIdx, out opRowIdx); if (opText == null) { return(result); } if (line.GetText() != opText) { return(result); } opOneNum++; } crossJugeRowList.Add(drow); crossJugeRowList.Add(detailRoot.rowData.rowGroups[opGroupIdx].rows[opRowIdx]); } //先直接往下做判断,只有往下没有当前路的行或当前路的行没有改变的才做CrossJuge,否则就NextJuge bool isNextJuge = false; var nextGroup = startGroupIdx + 1; if (detailRoot.rowData.rowGroups.Length > nextGroup) { var group = detailRoot.rowData.rowGroups[nextGroup]; if (group != null) { var line = group.rows[0].GetLine(startLineIdx); if (line != null) { //如果3路里有其中一路有变化才做对比 bool needHandl = false; foreach (var dline in group.rows[0].lines) { if (dline.modifyClass != "U" && dline.modifyClass != "UU") { needHandl = true; break; } } if (needHandl) { isNextJuge = true; //如果已经满了,就开始从下一Goup的0开始 if (opRowIdx == detailRoot.rowData.rowGroups[opGroupIdx].rows.Length - 1) { opGroupIdx++; opRowIdx = 0; } //否则就在当前的Goup的下一个Row开始 else { opRowIdx++; } return(CrossJuge(detailRoot, startLineIdx, nextGroup, 0, opGroupIdx, opRowIdx, ref crossJugeRowList)); } } } } if (isNextJuge == false) { if (opRowIdx == detailRoot.rowData.rowGroups[opGroupIdx].rows.Length - 1) { result = true; } else { return(CrossJuge(detailRoot, opLineIdx, opGroupIdx, opRowIdx + 1, startGroupIdx + 1, 0, ref crossJugeRowList)); } } return(result); }
/// Show a line of dialogue, gradually public override IEnumerator RunLine(Yarn.Line line) { // Convert line text to DLine DLine dLine = DLine.FromYarnLine(line); if (cinematic_mode) { dLine.pause = false; // Set default wait time if not defined if (dLine.wait <= 0) { dLine.wait = 1; } } nameText.text = dLine.name; portraitImage.sprite = dLine.GetFace(); // Show the text if (dLine.clear_text) { lineText.text = ""; } else { last_text = lineText.text; } lineText.gameObject.SetActive(true); talkButtonPressed = false; ShowCanvas(); if (dLine.speed > 0.0f) { // Display the line one character at a time var stringBuilder = new StringBuilder(); foreach (char c in dLine.text) { // Detect keypress to skip text animation if (talkButtonPressed) { break; } stringBuilder.Append(c); lineText.text = stringBuilder.ToString(); yield return(new WaitForSeconds(dLine.speed)); } } // Display the line immediately if textSpeed == 0 if (dLine.clear_text) { lineText.text = dLine.text; } else { lineText.text = last_text + dLine.text; } if (dLine.pause) { talkButtonPressed = false; // Delay before showing continue prompt for (int i = 0; i < 10; i++) { if (talkButtonPressed == true) { break; } yield return(new WaitForSeconds(0.1f)); } // Show the 'press any key' prompt when done, if we have one if (!talkButtonPressed && continuePrompt != null) { continuePrompt.SetActive(true); } // Wait for any user input while (!talkButtonPressed) { yield return(null); } if (continuePrompt != null) { continuePrompt.SetActive(false); } } else { if (dLine.wait > 0) { yield return(new WaitForSeconds(dLine.wait)); } } // Hide the text and prompt lineText.gameObject.SetActive(false); }