public async Task <IActionResult> PairDelete(int id) { TagPair TagPair = await _context.TagPair.FindAsync(id); _context.TagPair.Remove(TagPair); await _context.SaveChangesAsync(); return(Ok("{}")); }
public async Task <IActionResult> PairPost(int tag1, int tag2, [FromQuery] int type) { Tag Tag1 = await _context.Tag.FindAsync(tag1); Tag Tag2 = await _context.Tag.FindAsync(tag2); PairType pairType = (PairType)type; //This is a hack. 99 means "child" from the tag manager, so we're swapping them. //It's a dumb hack, but I'm tired. if (type == 99) { Tag1 = await _context.Tag.FindAsync(tag2); Tag2 = await _context.Tag.FindAsync(tag1); pairType = PairType.Parent; } if (Tag1 == null | Tag2 == null) { return(NotFound()); } TagPair newPair = new TagPair() { Tag1 = Tag1, Tag2 = Tag2, Type = pairType }; if (await _context.TagPair.AnyAsync(tp => (tp.Tag1 == Tag1 && tp.Tag2 == Tag2))) { return(NotFound()); } await _context.TagPair.AddAsync(newPair); await _context.SaveChangesAsync(); return(Ok("{}")); }
private static List <TagPair> ArrangeTag(List <TagElement> tag_list) { List <TagPair> tags = new List <TagPair>(); List <TagPair> tag_lock = new List <TagPair>(); List <TagPair> tag_normal = new List <TagPair>(); List <TagPair> tag_large = new List <TagPair>(); // 長いタグ List <TagPair> tag_including_link = new List <TagPair>(); // 「リンク」を含んだタグ LoadTagFont(); for (int i = 0; i < tag_list.Count; ++i) { TagPair pair = new TagPair(tag_list[i].Get(), GetStringWidth(tag_list[i].Get())); if (tag_list[i].IsLock()) { tag_lock.Add(pair); } else if (pair.length >= 180.0) { tag_large.Add(pair); } else if (pair.tag.IndexOf("リンク") >= 0) { tag_including_link.Add(pair); } else { tag_normal.Add(pair); } } tags.AddRange(tag_lock); tags.AddRange(tag_normal); tags.AddRange(tag_large); tags.AddRange(tag_including_link); return(tags); }
public override void VisitTagPair(TagPair tagPair) { VisitChildren(tagPair); }
("[", TagSectionOnly(TagPair(BracketOpen)),
IEnumerator ShowDialog(string dialogString) { int charsToShow = 0; int stringOffset; float elapsedTime = 0f; string untaggedString; List <TagPair> tagPairs = new List <TagPair>(); talking = true; taggedDialogString = dialogString; untaggedString = dialogString; // remove tag pairs while (true) { TagPair newTagPair = TryGetTagPair(untaggedString); if (newTagPair == null) { break; } tagPairs.Add(newTagPair); untaggedString = untaggedDialogString; } string firstHalf, secondHalf; while (charsToShow < untaggedString.Length) { firstHalf = untaggedString.Substring(0, charsToShow); secondHalf = untaggedString.Substring(charsToShow, untaggedString.Length - charsToShow); stringOffset = 0; for (int i = tagPairs.Count - 1; i >= 0; i--) { stringOffset = 0; if (charsToShow > tagPairs[i].openTagPos) { firstHalf = PutSubstringInIndex(firstHalf, tagPairs[i].openTagPos, tagPairs[i].openTag); stringOffset += tagPairs[i].openTag.Length; if (charsToShow > tagPairs[i].closeTagPos) { firstHalf = PutSubstringInIndex(firstHalf, tagPairs[i].closeTagPos + stringOffset, tagPairs[i].closeTag); } else { firstHalf += tagPairs[i].closeTag; } stringOffset += tagPairs[i].closeTag.Length; } } dialogText.text = firstHalf + "<color=#00000000>" + secondHalf + "</color>"; yield return(null); // charsToShow += 5; elapsedTime += Time.deltaTime; charsToShow = (int)(elapsedTime * charsToShowPerSecond); } dialogText.text = dialogString; // while(charsToShow <= initialDialog.Length) { // currentDialogText = initialDialog.Substring(0, charsToShow); // dialogText.text = currentDialogText; // if(charsToShow % sfxInterval == 0 && dialogText.text.Length > 0) // PlayDialogSfx(); // // yield return new WaitForSeconds(textWaitTime + pauseTime); // charsToShow++; // } yield return(null); EndDialog(); }
TagPair TryGetTagPair(string fullString) { int openTagIndex, closeTagIndex; /// GET OPEN TAG openTagIndex = fullString.IndexOf('<'); closeTagIndex = fullString.IndexOf('>'); //return if no chars encountered if (openTagIndex == -1 || closeTagIndex == -1) { return(null); } string currentString = ""; if (openTagIndex > 0) { currentString += fullString.Substring(0, openTagIndex); } if (closeTagIndex < fullString.Length - 1) { currentString += fullString.Substring(closeTagIndex + 1, fullString.Length - closeTagIndex - 1); } Debug.Log("current string: " + currentString); TagPair tp = new TagPair(); tp.openTag = fullString.Substring(openTagIndex, closeTagIndex - openTagIndex + 1); tp.openTagPos = openTagIndex; /// GET CLOSE TAG openTagIndex = currentString.LastIndexOf('<'); closeTagIndex = currentString.LastIndexOf('>'); //return if no chars encountered if (openTagIndex == -1 || closeTagIndex == -1) { return(null); } untaggedDialogString = ""; if (openTagIndex > 0) { untaggedDialogString += currentString.Substring(0, openTagIndex); } if (closeTagIndex < fullString.Length - 1) { untaggedDialogString += currentString.Substring(closeTagIndex + 1, currentString.Length - closeTagIndex - 1); } Debug.Log("untagged string: " + untaggedDialogString); tp.closeTag = currentString.Substring(openTagIndex, closeTagIndex - openTagIndex + 1); tp.closeTagPos = openTagIndex; return(tp); }