Пример #1
0
        private void DrawGui(int id)
        {
            GUILayout.BeginVertical(GUILayout.ExpandWidth(true));
            if (_dcpuRunning)
            {
                GUI.enabled = false;
            }
            _keyboard  = GUILayout.Toggle(_keyboard, "Keyboard plugged in");
            _monitor   = GUILayout.Toggle(_monitor, "Monitor plugged in");
            _clock     = GUILayout.Toggle(_clock, "Clock plugged in");
            _bigEndian = GUILayout.Toggle(_bigEndian, "Is big endian binary");
            if (_dcpuRunning)
            {
                GUI.enabled = true;
            }

            if (GUILayout.Button("Load program binary"))
            {
                _fileBrowser = new FileBrowser(new Rect(Screen.width / 2 - 200, Screen.height / 2 - 200, 400, 400), "Select DCPU program", s => FileBrowserSelect(s))
                {
                    BrowserType = FileBrowserType.File, CurrentDirectory = KSP.IO.IOUtils.GetFilePathFor(typeof(KspImpl), ""), disallowDirectoryChange = true
                };
            }

            if (GUILayout.Button("Reset"))
            {
                _keyboardInst = null;
                Dcpu.Reset();
            }

            if (_dcpuRunning ? GUILayout.Button("Stop") : GUILayout.Button("Start"))
            {
                _dcpu.ClearHardware();
                if (_keyboard)
                {
                    _dcpu.AddHardware(_keyboardInst = new GenericKeyboard());
                }
                if (_monitor)
                {
                    _dcpu.AddHardware(new Lem1802(this));
                }
                if (_clock)
                {
                    _dcpu.AddHardware(new GenericClock());
                }
                _dcpuRunning = !_dcpuRunning;
            }

            GUILayout.EndVertical();
            GUI.DragWindow();
        }
Пример #2
0
        private void DrawGui(int id)
        {
            GUILayout.BeginVertical(GUILayout.ExpandWidth(true));
            if (_dcpuRunning)
                GUI.enabled = false;
            _keyboard = GUILayout.Toggle(_keyboard, "Keyboard plugged in");
            _monitor = GUILayout.Toggle(_monitor, "Monitor plugged in");
            _clock = GUILayout.Toggle(_clock, "Clock plugged in");
            _bigEndian = GUILayout.Toggle(_bigEndian, "Is big endian binary");
            if (_dcpuRunning)
                GUI.enabled = true;

            if (GUILayout.Button("Load program binary"))
            {
                _fileBrowser = new FileBrowser(new Rect(Screen.width / 2 - 200, Screen.height / 2 - 200, 400, 400), "Select DCPU program", s => FileBrowserSelect(s))
                                   {BrowserType = FileBrowserType.File, CurrentDirectory = KSP.IO.IOUtils.GetFilePathFor(typeof (KspImpl), ""), disallowDirectoryChange = true};
            }

            if (GUILayout.Button("Reset"))
            {
                _keyboardInst = null;
                Dcpu.Reset();
            }

            if (_dcpuRunning ? GUILayout.Button("Stop") : GUILayout.Button("Start"))
            {
                _dcpu.ClearHardware();
                if (_keyboard)
                    _dcpu.AddHardware(_keyboardInst = new GenericKeyboard());
                if (_monitor)
                    _dcpu.AddHardware(new Lem1802(this));
                if (_clock)
                    _dcpu.AddHardware(new GenericClock());
                _dcpuRunning = !_dcpuRunning;
            }

            GUILayout.EndVertical();
            GUI.DragWindow();
        }