<commit_before>﻿using System;
using System.Drawing;
using OpenTK.Input;
using OpenTK.Graphics;

namespace SpaceTradingGame.Engine.UI.Controls
{
    public class Slider : Control
    {
        public Slider(Control parent, int x, int y, int width)
            : base(parent)
        {
            this.position = new Point(x, y);
            this.size = new Point(width, 1);
            this.scrollSize = width;

            this.sliderMode = SliderModes.Horizontal;
            this.setBarPosition();
        }
        public Slider(Control parent, int x, int y, SliderModes mode, int size)
            : base(parent)
        {
            this.position = new Point(x, y);

            if (mode == SliderModes.Horizontal)
            {
                this.size = new Point(size, 1);
                this.railToken = '═';
            }
            else
            {
                this.size = new Point(1, size);
                this.railToken = '║';
            }

            this.scrollSize = size;
            this.sliderMode = mode;
            this.setBarPosition();
        }

        public override void DrawStep()
        {
            this.drawRail();

            GraphicConsole.SetColor(this.barColor, this.fillColor);
            GraphicConsole.Put(this.barToken, this.barPosition.X, this.barPosition.Y);
            
            base.DrawStep();
        }
        public override void UpdateFrame(GameTime gameTime)
        {
            base.UpdateFrame(gameTime);
        }
        public override void MouseWheel(MouseWheelEventArgs e)
        {
            int difference = e.Delta / this.scrollSize;

            if (difference != 0)
            {
                this.currentValue += difference;

                if (this.currentValue < 0f)
                    this.currentValue = 0f;
                else if (this.currentValue > 100f)
                    this.currentValue = 100f;

                this.onValueChange();
                InterfaceManager.DrawStep();
            }<commit_msg>Fixed scrolling bug in the Slider control, still need to add mouse control.<commit_after>﻿using System;
using System.Drawing;
using OpenTK.Input;
using OpenTK.Graphics;

namespace SpaceTradingGame.Engine.UI.Controls
{
    public class Slider : Control
    {
        public Slider(Control parent, int x, int y, int width)
            : base(parent)
        {
            this.position = new Point(x, y);
            this.size = new Point(width, 1);
            this.scrollSize = width;

            this.sliderMode = SliderModes.Horizontal;
            this.setBarPosition();
        }
        public Slider(Control parent, int x, int y, SliderModes mode, int size)
            : base(parent)
        {
            this.position = new Point(x, y);

            if (mode == SliderModes.Horizontal)
            {
                this.size = new Point(size, 1);
                this.railToken = '═';
            }
            else
            {
                this.size = new Point(1, size);
                this.railToken = '║';
            }

            this.scrollSize = size;
            this.sliderMode = mode;
            this.setBarPosition();
        }

        public override void DrawStep()
        {
            this.drawRail();

            GraphicConsole.SetColor(this.barColor, this.fillColor);
            GraphicConsole.Put(this.barToken, this.barPosition.X, this.barPosition.Y);
            
            base.DrawStep();
        }
        public override void UpdateFrame(GameTime gameTime)
        {
            base.UpdateFrame(gameTime);
        }
        public override void MouseWheel(MouseWheelEventArgs e)
        {
            int difference = e.Delta;

            if (difference != 0)
            {
                this.currentValue += difference;

                if (this.currentValue < 0f)
                    this.currentValue = 0f;
                else if (this.currentValue > 100f)
                    this.currentValue = 100f;

                this.onValueChange();
                InterfaceManager.DrawStep();
            }
{'fraction_non_alphanumeric': 0.09233791748526522, 'fraction_numerical': 0.005893909626719057, 'mean_word_length': 1.4157769869513641, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4814193', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1044, 'n_words': 247}