internal void UpdatePageCoords() { MultilinesFontInfo info = _rendererText.GetInfo(); for (int page = 0, y = 0; page < _pageCoords.GetLength(0); page++) { _pageCoords[page, 0] = y; _pageCoords[page, 1] = 0; for (int i = 0; i < MAX_BOOK_LINES; i++) { if (info == null) { break; } _pageCoords[page, 1] += info.MaxHeight; info = info.Next; } y += _pageCoords[page, 1]; } }
internal void DrawSelection(UltimaBatcher2D batcher, int x, int y, int starty, int endy) { ResetHueVector(); HueVector.Z = 0.5f; int selectStart = Math.Min(Stb.SelectStart, Stb.SelectEnd); int selectEnd = Math.Max(Stb.SelectStart, Stb.SelectEnd); if (selectStart < selectEnd) { MultilinesFontInfo info = _rendererText.GetInfo(); int drawY = 1; int start = 0; while (info != null && selectStart < selectEnd) { // ok we are inside the selection if (selectStart >= start && selectStart < start + info.CharCount) { int startSelectionIndex = selectStart - start; // calculate offset x int drawX = 0; for (int i = 0; i < startSelectionIndex; i++) { drawX += _rendererText.GetCharWidth(info.Data[i].Item); } // selection is gone. Bye bye if (selectEnd >= start && selectEnd < start + info.CharCount) { int count = selectEnd - selectStart; int endX = 0; // calculate width for (int k = 0; k < count; k++) { endX += _rendererText.GetCharWidth(info.Data[startSelectionIndex + k].Item); } if (drawY >= starty && drawY <= endy) { batcher.Draw2D ( SolidColorTextureCache.GetTexture(SELECTION_COLOR), x + drawX, y + drawY - starty, endX, info.MaxHeight + 1, ref HueVector ); } break; } // do the whole line if (drawY >= starty && drawY <= endy) { batcher.Draw2D ( SolidColorTextureCache.GetTexture(SELECTION_COLOR), x + drawX, y + drawY - starty, info.Width - drawX, info.MaxHeight + 1, ref HueVector ); } // first selection is gone. M selectStart = start + info.CharCount; } start += info.CharCount; drawY += info.MaxHeight; info = info.Next; } } }