using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace TwoMbit {
    public class EmuSettings {
        bool resolutionUpdated;
        bool audioUpdated;
        bool swFilterUpdated;
        bool hwFilterUpdated;
        bool FpsCounterUpdated;
        bool ScanlineUpdated;
        Config cfg;
        Cart._System ident;

        static List<EmuSettings> list = null;

        public EmuSettings(Config cfg, Cart._System ident) {
            if (list == null) list = new List<EmuSettings>();
            list.Add(this);
            this.ident = ident;
            this.cfg = cfg;
            this.resolutionUpdated = true;
            this.swFilterUpdated = true;
            this.hwFilterUpdated = true;
            this.audioUpdated = true;
            this.FpsCounterUpdated = true;
            this.ScanlineUpdated = true;
        }

        public static EmuSettings getSettingByIdent( Cart._System ident ) {
            foreach (EmuSettings _settings in list) {
                if (_settings.ident == ident) return _settings;
            }
            return null;
        }

        public static void updateResolutions() {
            if (list == null) return;
            foreach (EmuSettings _settings in list) {
                _settings.updateResolution();
            }
        }

        public static void updateScanlines() {
            if (list == null) return;
            foreach (EmuSettings _settings in list) {
                _settings.updateScanline();
            }
        }

        public static void updateFpsCounters() {
            if (list == null) return;
            foreach (EmuSettings _settings in list) {
                _settings.updateFpsCounter();
            }
        }

        public static void updateAudios() {
            if (list == null) return;
            foreach (EmuSettings _settings in list) {
                _settings.updateAudio();
            }
        }

        public static void updateSwFilters() {
            if (list == null) return;
            foreach (EmuSettings _settings in list) {
                _settings.updateSwFilter();
            }
        }

        public static void updateHwFilters() {
            if (list == null) return;
            foreach (EmuSettings _settings in list) {
                _settings.updateHwFilter();
            }
        }

        public void updateScanline() {
            this.ScanlineUpdated = true;
        }

        public void updateAudio() {
            this.audioUpdated = true;
        }

        public void updateResolution() {
            this.resolutionUpdated = true;
        }

        public void updateSwFilter() {
            this.swFilterUpdated = true;
        }

        public void updateHwFilter() {
            this.hwFilterUpdated = true;
        }

        public void updateFpsCounter() {
            this.FpsCounterUpdated = true;
        }

        public bool isScanlineUpdated() {
            bool result = this.ScanlineUpdated;
            this.ScanlineUpdated = false;
            return result;
        }

        public bool isFpsCounterUpdated() {
            bool result = this.FpsCounterUpdated;
            this.FpsCounterUpdated = false;
            return result;
        }

        public bool isAudioUpdated() {
            bool result = this.audioUpdated;
            this.audioUpdated = false;
            return result;
        }

        public bool isResolutionUpdated() {
            bool result = this.resolutionUpdated;
            this.resolutionUpdated = false;
            return result;
        }

        public bool isSwFilterUpdated() {
            bool result = this.swFilterUpdated;
            this.swFilterUpdated = false;
            return result;
        }

        public bool isHwFilterUpdated() {
            bool result = this.hwFilterUpdated;
            this.hwFilterUpdated = false;
            return result;
        }

    }
}
