コード例 #1
0
ファイル: TerminalEntryRenderArea.cs プロジェクト: gmich/Gem
        public void UpdateCursor(Behavior <IEffect> behavior, Row currentRow, int row, int position)
        {
            int rowIndex = row;

            appendLocation = new Vector2(0, (rowIndex) * (rowSize + AreaSettings.RowSpacing) - 1);
            int pos = position - 1;

            if (cellEffects.ContainsKey(rowIndex) && pos > -1)
            {
                foreach (var entry in currentRow.Entries.Take(pos))
                {
                    var entryWidth = font.MeasureString(entry.Content.ToString()).X;
                    appendLocation.X += (entryWidth + AreaSettings.CellSpacing);
                }
                if (pos != -1)
                {
                    var lastEntry = currentRow.Entries.Skip(pos).FirstOrDefault();
                    if (lastEntry != null)
                    {
                        var entryWidth = font.MeasureString(lastEntry.Content.ToString()).X;
                        appendLocation.X += entryWidth + 1;
                    }
                }
            }
            float x = screenPosition.X + appendLocation.X - camera.Position.X;
            float y = screenPosition.Y + appendLocation.Y - camera.Position.Y;

            cursorEffect = (behavior.At(Behavior.Create(ctx => x),
                                        Behavior.Create(ctx => y)));
        }