Пример #1
0
        public MainForm()
        {
            InitializeComponent();

            host = new CRobotHost(this);
            camera = new CWebcam(livePanel, null);
            camera.Initialize();
            camera.SetReady();
        }
Пример #2
0
        public MainForm()
        {
            InitializeComponent();

            host = new CRobotHost(this);
            camera = new CWebcam(livePanel, null, false);
            camera.Initialize();
            camera.SetReady();

            driveBackground = new Bitmap("driveBackground2.png");
            g = Graphics.FromHwnd(drivePanel.Handle);
        }
Пример #3
0
        public MainForm()
        {
            InitializeComponent();

            m_host = new CRobotHost(this);

            m_destImage = Image.FromFile("Images\\destImage.png");

            m_camera = new CWebcam(livePanel, null, false);
            m_camera.Initialize();
            m_camera.SetReady();

            m_center = new Point(floorPlanPanel.Width / 2, floorPlanPanel.Height / 2);

            m_fg = Graphics.FromHwnd(floorPlanPanel.Handle);

            m_pixelsperfoot = 2.0;

            m_callback = new TimerCallback(DrawScale);
            m_fpState = fpState.NONE;

            t_DrawFloorDelegate = new DDrawFloor(DrawFloor);
        }
Пример #4
0
        public override bool HandleInput(KeyEvent KeyEvent)
        {
            if (_EditMode == EEditMode.None)
            {
                base.HandleInput(KeyEvent);
            }

            if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode))
            {
                switch (_EditMode)
                {
                case EEditMode.None:
                    break;

                case EEditMode.PlayerName:
                    SelectSlides[htSelectSlides(SelectSlideProfiles)].RenameValue(
                        CProfiles.AddGetPlayerName(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, KeyEvent.Unicode));
                    break;

                default:
                    break;
                }
            }
            else
            {
                switch (KeyEvent.Key)
                {
                case Keys.Escape:
                    CGraphics.FadeTo(EScreens.ScreenMain);
                    break;

                case Keys.Enter:
                    if (Buttons[htButtons(ButtonExit)].Selected)
                    {
                        CGraphics.FadeTo(EScreens.ScreenMain);
                    }
                    else if (Buttons[htButtons(ButtonSave)].Selected)
                    {
                        SaveProfiles();
                    }
                    else if (Buttons[htButtons(ButtonNew)].Selected)
                    {
                        NewProfile();
                    }
                    else if (Buttons[htButtons(ButtonPlayerName)].Selected)
                    {
                        if (CProfiles.NumProfiles > 0 && _EditMode != EEditMode.PlayerName)
                        {
                            _EditMode = EEditMode.PlayerName;
                        }
                        else
                        {
                            _EditMode = EEditMode.None;
                        }
                    }
                    else if (Buttons[htButtons(ButtonDelete)].Selected)
                    {
                        DeleteProfile();
                    }
                    else if (Buttons[htButtons(ButtonWebcam)].Selected && CWebcam.GetDevices().Length > 0)
                    {
                        OnWebcam();
                    }
                    else if (Buttons[htButtons(ButtonSaveSnapshot)].Selected && CWebcam.GetDevices().Length > 0)
                    {
                        OnSaveSnapshot();
                    }
                    else if (Buttons[htButtons(ButtonDiscardSnapshot)].Selected && CWebcam.GetDevices().Length > 0)
                    {
                        OnDiscardSnapshot();
                    }
                    else if (Buttons[htButtons(ButtonTakeSnapshot)].Selected && CWebcam.GetDevices().Length > 0)
                    {
                        OnTakeSnapshot();
                    }
                    break;

                case Keys.Back:
                    if (_EditMode == EEditMode.PlayerName)
                    {
                        SelectSlides[htSelectSlides(SelectSlideProfiles)].RenameValue(
                            CProfiles.GetDeleteCharInPlayerName(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection));
                    }
                    else
                    {
                        CGraphics.FadeTo(EScreens.ScreenMain);
                    }
                    break;

                case Keys.Delete:
                    DeleteProfile();
                    break;
                }
                if (SelectSlides[htSelectSlides(SelectSlideDifficulty)].Selected)
                {
                    CProfiles.SetDifficulty(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection,
                                            (EGameDifficulty)SelectSlides[htSelectSlides(SelectSlideDifficulty)].Selection);
                }
                else if (SelectSlides[htSelectSlides(SelectSlideAvatars)].Selected)
                {
                    CProfiles.SetAvatar(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection,
                                        SelectSlides[htSelectSlides(SelectSlideAvatars)].Selection);
                }
                else if (SelectSlides[htSelectSlides(SelectSlideGuestProfile)].Selected)
                {
                    CProfiles.SetGuestProfile(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection,
                                              (EOffOn)SelectSlides[htSelectSlides(SelectSlideGuestProfile)].Selection);
                }
                else if (SelectSlides[htSelectSlides(SelectSlideActive)].Selected)
                {
                    CProfiles.SetActive(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection,
                                        (EOffOn)SelectSlides[htSelectSlides(SelectSlideActive)].Selection);
                }
            }

            return(true);
        }
Пример #5
0
        public override bool HandleMouse(MouseEvent MouseEvent)
        {
            if (_EditMode == EEditMode.None)
            {
                base.HandleMouse(MouseEvent);
            }

            if (MouseEvent.LB && IsMouseOver(MouseEvent))
            {
                if (Buttons[htButtons(ButtonExit)].Selected)
                {
                    CGraphics.FadeTo(EScreens.ScreenMain);
                }
                else if (Buttons[htButtons(ButtonSave)].Selected)
                {
                    SaveProfiles();
                }
                else if (Buttons[htButtons(ButtonNew)].Selected)
                {
                    NewProfile();
                }
                else if (Buttons[htButtons(ButtonDelete)].Selected)
                {
                    DeleteProfile();
                }
                else if (Buttons[htButtons(ButtonPlayerName)].Selected)
                {
                    if (CProfiles.NumProfiles > 0 && _EditMode != EEditMode.PlayerName)
                    {
                        _EditMode = EEditMode.PlayerName;
                    }
                    else
                    {
                        _EditMode = EEditMode.None;
                    }
                }
                else if (SelectSlides[htSelectSlides(SelectSlideDifficulty)].Selected)
                {
                    CProfiles.SetDifficulty(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection,
                                            (EGameDifficulty)SelectSlides[htSelectSlides(SelectSlideDifficulty)].Selection);
                }
                else if (SelectSlides[htSelectSlides(SelectSlideAvatars)].Selected)
                {
                    CProfiles.SetAvatar(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection,
                                        SelectSlides[htSelectSlides(SelectSlideAvatars)].Selection);
                    if (CWebcam.GetDevices().Length > 0 && _WebcamTexture.index > 0)
                    {
                        OnDiscardSnapshot();
                    }
                }
                else if (SelectSlides[htSelectSlides(SelectSlideGuestProfile)].Selected)
                {
                    CProfiles.SetGuestProfile(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection,
                                              (EOffOn)SelectSlides[htSelectSlides(SelectSlideGuestProfile)].Selection);
                }
                else if (SelectSlides[htSelectSlides(SelectSlideActive)].Selected)
                {
                    CProfiles.SetActive(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection,
                                        (EOffOn)SelectSlides[htSelectSlides(SelectSlideActive)].Selection);
                }
                else if (Buttons[htButtons(ButtonWebcam)].Selected && CWebcam.GetDevices().Length > 0)
                {
                    OnWebcam();
                }
                else if (Buttons[htButtons(ButtonSaveSnapshot)].Selected && CWebcam.GetDevices().Length > 0)
                {
                    OnSaveSnapshot();
                }
                else if (Buttons[htButtons(ButtonDiscardSnapshot)].Selected && CWebcam.GetDevices().Length > 0)
                {
                    OnDiscardSnapshot();
                }
                else if (Buttons[htButtons(ButtonTakeSnapshot)].Selected && CWebcam.GetDevices().Length > 0)
                {
                    OnTakeSnapshot();
                }
            }

            if (MouseEvent.RB)
            {
                CGraphics.FadeTo(EScreens.ScreenMain);
            }
            return(true);
        }
Пример #6
0
        public override bool HandleMouse(SMouseEvent mouseEvent)
        {
            if (_EditMode == EEditMode.None)
            {
                base.HandleMouse(mouseEvent);
            }

            if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent))
            {
                if (_Buttons[_ButtonExit].Selected)
                {
                    CGraphics.FadeTo(EScreen.Main);
                }
                else if (_Buttons[_ButtonSave].Selected)
                {
                    _SaveProfiles();
                }
                else if (_Buttons[_ButtonNew].Selected)
                {
                    _NewProfile();
                }
                else if (_Buttons[_ButtonDelete].Selected)
                {
                    _DeleteProfile();
                }
                else if (_Buttons[_ButtonPlayerName].Selected)
                {
                    if (CProfiles.NumProfiles > 0 && _EditMode != EEditMode.PlayerName)
                    {
                        _EditMode = EEditMode.PlayerName;
                    }
                    else
                    {
                        _EditMode = EEditMode.None;
                    }
                }
                else if (_SelectSlides[_SelectSlideDifficulty].Selected)
                {
                    CProfiles.SetDifficulty(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag),
                                            (EGameDifficulty)_SelectSlides[_SelectSlideDifficulty].Selection);
                }
                else if (_SelectSlides[_SelectSlideAvatars].Selected)
                {
                    CProfiles.SetAvatar(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag),
                                        _SelectSlides[_SelectSlideAvatars].SelectedTag);
                    if (CWebcam.IsDeviceAvailable() && _WebcamTexture != null)
                    {
                        _OnDiscardSnapshot();
                    }
                }
                else if (_SelectSlides[_SelectSlideUserRole].Selected)
                {
                    CProfiles.SetUserRoleProfile(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag),
                                                 (EUserRole)_SelectSlides[_SelectSlideUserRole].Selection);
                }
                else if (_SelectSlides[_SelectSlideActive].Selected)
                {
                    CProfiles.SetActive(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag),
                                        (EOffOn)_SelectSlides[_SelectSlideActive].Selection);
                }
                else if (_Buttons[_ButtonWebcam].Selected)
                {
                    _OnWebcam();
                }
                else if (_Buttons[_ButtonSaveSnapshot].Selected)
                {
                    _OnSaveSnapshot();
                }
                else if (_Buttons[_ButtonDiscardSnapshot].Selected)
                {
                    _OnDiscardSnapshot();
                }
                else if (_Buttons[_ButtonTakeSnapshot].Selected)
                {
                    _OnTakeSnapshot();
                }
            }

            if (mouseEvent.RB)
            {
                CGraphics.FadeTo(EScreen.Main);
            }
            return(true);
        }
Пример #7
0
        private static void _Run(string[] args)
        {
            Application.DoEvents();

            try
            {
                // Create data folder
                Directory.CreateDirectory(CSettings.DataFolder);

                // Init Log
                CLog.Init();

                if (!CProgrammHelper.CheckRequirements())
                {
                    return;
                }
                CProgrammHelper.Init();

                CLog.StartBenchmark("Init Program");
                CMain.Init();
                Application.DoEvents();

                // Init Language
                CLog.StartBenchmark("Init Language");
                if (!CLanguage.Init())
                {
                    throw new CLoadingException("Language");
                }
                CLog.StopBenchmark("Init Language");

                Application.DoEvents();

                // load config
                CLog.StartBenchmark("Init Config");
                CConfig.LoadCommandLineParams(args);
                CConfig.UseCommandLineParamsBefore();
                CConfig.Init();
                CConfig.UseCommandLineParamsAfter();
                CLog.StopBenchmark("Init Config");

                // Create folders
                CSettings.CreateFolders();

                _SplashScreen = new CSplashScreen();
                Application.DoEvents();

                // Init Draw
                CLog.StartBenchmark("Init Draw");
                if (!CDraw.Init())
                {
                    throw new CLoadingException("drawing");
                }
                CLog.StopBenchmark("Init Draw");

                Application.DoEvents();

                // Init Playback
                CLog.StartBenchmark("Init Playback");
                if (!CSound.Init())
                {
                    throw new CLoadingException("playback");
                }
                CLog.StopBenchmark("Init Playback");

                Application.DoEvents();

                // Init Record
                CLog.StartBenchmark("Init Record");
                if (!CRecord.Init())
                {
                    throw new CLoadingException("record");
                }
                CLog.StopBenchmark("Init Record");

                Application.DoEvents();

                // Init VideoDecoder
                CLog.StartBenchmark("Init Videodecoder");
                if (!CVideo.Init())
                {
                    throw new CLoadingException("video");
                }
                CLog.StopBenchmark("Init Videodecoder");

                Application.DoEvents();

                // Init Database
                CLog.StartBenchmark("Init Database");
                if (!CDataBase.Init())
                {
                    throw new CLoadingException("database");
                }
                CLog.StopBenchmark("Init Database");

                Application.DoEvents();

                //Init Webcam
                CLog.StartBenchmark("Init Webcam");
                if (!CWebcam.Init())
                {
                    throw new CLoadingException("webcam");
                }
                CLog.StopBenchmark("Init Webcam");

                Application.DoEvents();

                // Init Background Music
                CLog.StartBenchmark("Init Background Music");
                CBackgroundMusic.Init();
                CLog.StopBenchmark("Init Background Music");

                Application.DoEvents();

                // Init Profiles
                CLog.StartBenchmark("Init Profiles");
                CProfiles.Init();
                CLog.StopBenchmark("Init Profiles");

                Application.DoEvents();

                // Init Fonts
                CLog.StartBenchmark("Init Fonts");
                if (!CFonts.Init())
                {
                    throw new CLoadingException("fonts");
                }
                CLog.StopBenchmark("Init Fonts");

                Application.DoEvents();

                // Theme System
                CLog.StartBenchmark("Init Theme");
                if (!CThemes.Init())
                {
                    throw new CLoadingException("theme");
                }
                CLog.StopBenchmark("Init Theme");

                CLog.StartBenchmark("Load Theme");
                CThemes.Load();
                CLog.StopBenchmark("Load Theme");

                Application.DoEvents();

                // Load Cover
                CLog.StartBenchmark("Init Cover");
                if (!CCover.Init())
                {
                    throw new CLoadingException("covertheme");
                }
                CLog.StopBenchmark("Init Cover");

                Application.DoEvents();

                // Init Screens
                CLog.StartBenchmark("Init Screens");
                CGraphics.Init();
                CLog.StopBenchmark("Init Screens");

                Application.DoEvents();

                // Init Server
                CLog.StartBenchmark("Init Server");
                CVocaluxeServer.Init();
                CLog.StopBenchmark("Init Server");

                Application.DoEvents();

                // Init Input
                CLog.StartBenchmark("Init Input");
                CController.Init();
                CController.Connect();
                CLog.StopBenchmark("Init Input");

                Application.DoEvents();

                // Init Game;
                CLog.StartBenchmark("Init Game");
                CGame.Init();
                CProfiles.Update();
                CConfig.UsePlayers();
                CLog.StopBenchmark("Init Game");

                Application.DoEvents();

                // Init Party Modes;
                CLog.StartBenchmark("Init Party Modes");
                if (!CParty.Init())
                {
                    throw new CLoadingException("Party Modes");
                }
                CLog.StopBenchmark("Init Party Modes");

                Application.DoEvents();
                //Only reasonable point to call GC.Collect() because initialization may cause lots of garbage
                //Rely on GC doing its job afterwards and call Dispose methods where appropriate
                GC.Collect();
                CLog.StopBenchmark("Init Program");
            }
            catch (Exception e)
            {
                MessageBox.Show("Error on start up: " + e.Message);
                CLog.LogError("Error on start up: " + e);
                if (_SplashScreen != null)
                {
                    _SplashScreen.Close();
                }
                _CloseProgram();
                return;
            }
            Application.DoEvents();

            // Start Main Loop
            if (_SplashScreen != null)
            {
                _SplashScreen.Close();
            }

            CDraw.MainLoop();
        }