Ejemplo n.º 1
0
        public ShanghaiEXE()
        {
            Debug.DebugSet();
            this.InitializeComponent();
            this.Icon = new Icon("icon.ico");

            var oldConfig = Config.FromCFG("option.cfg");

            if (oldConfig != null)
            {
                File.Move("option.cfg", "option.cfg.OLD");
            }

            ShanghaiEXE.Config = Config.FromXML("option.xml") ?? oldConfig ?? new Config();

            SaveData.Pad[1, 0]  = ShanghaiEXE.Config.ControllerMapping.Up;
            SaveData.Pad[1, 1]  = ShanghaiEXE.Config.ControllerMapping.Right;
            SaveData.Pad[1, 2]  = ShanghaiEXE.Config.ControllerMapping.Down;
            SaveData.Pad[1, 3]  = ShanghaiEXE.Config.ControllerMapping.Left;
            SaveData.Pad[1, 4]  = ShanghaiEXE.Config.ControllerMapping.A;
            SaveData.Pad[1, 5]  = ShanghaiEXE.Config.ControllerMapping.B;
            SaveData.Pad[1, 6]  = ShanghaiEXE.Config.ControllerMapping.L;
            SaveData.Pad[1, 7]  = ShanghaiEXE.Config.ControllerMapping.R;
            SaveData.Pad[1, 8]  = ShanghaiEXE.Config.ControllerMapping.Start;
            SaveData.Pad[1, 9]  = ShanghaiEXE.Config.ControllerMapping.Select;
            SaveData.Pad[1, 11] = ShanghaiEXE.Config.ControllerMapping.Turbo ?? 8;

            SaveData.Pad[0, 0]  = ShanghaiEXE.Config.KeyboardMapping.Up;
            SaveData.Pad[0, 1]  = ShanghaiEXE.Config.KeyboardMapping.Right;
            SaveData.Pad[0, 2]  = ShanghaiEXE.Config.KeyboardMapping.Down;
            SaveData.Pad[0, 3]  = ShanghaiEXE.Config.KeyboardMapping.Left;
            SaveData.Pad[0, 4]  = ShanghaiEXE.Config.KeyboardMapping.A;
            SaveData.Pad[0, 5]  = ShanghaiEXE.Config.KeyboardMapping.B;
            SaveData.Pad[0, 6]  = ShanghaiEXE.Config.KeyboardMapping.L;
            SaveData.Pad[0, 7]  = ShanghaiEXE.Config.KeyboardMapping.R;
            SaveData.Pad[0, 8]  = ShanghaiEXE.Config.KeyboardMapping.Start;
            SaveData.Pad[0, 9]  = ShanghaiEXE.Config.KeyboardMapping.Select;
            SaveData.Pad[0, 11] = ShanghaiEXE.Config.KeyboardMapping.Turbo ?? 78;

            this.scaleFactorX = ShanghaiEXE.Config.ScaleFactor;
            this.scaleFactorY = ShanghaiEXE.Config.ScaleFactor;

            var clientWidth  = (int)(240 * Math.Max(1, this.scaleFactorX));
            var clientHeight = (int)(160 * Math.Max(1, this.scaleFactorY));

            this.ClientSize = new Size(clientWidth, clientHeight);

            if (!ShanghaiEXE.Config.Fullscreen)
            {
                this.FormBorderStyle = FormBorderStyle.FixedSingle;
                SaveData.ScreenMode  = false;
            }
            else
            {
                SaveData.ScreenMode  = true;
                this.FormBorderStyle = FormBorderStyle.None;
                this.WindowState     = FormWindowState.Maximized;
                if (ShanghaiEXE.Config.RenderEngine == "OpenGL")
                {
                    var screenSize = Screen.FromControl(this).Bounds;
                    if (ShanghaiEXE.Config.StretchFullscreen == null || ShanghaiEXE.Config.StretchFullscreen.Value)
                    {
                        this.scaleFactorX = (double)screenSize.Width / Constants.ScreenSize.Width;
                        this.scaleFactorY = (double)screenSize.Height / Constants.ScreenSize.Height;
                    }
                    else
                    {
                        var minimumEvenScale = Math.Min((double)screenSize.Width / Constants.ScreenSize.Width, (double)screenSize.Height / Constants.ScreenSize.Height);
                        this.scaleFactorX = minimumEvenScale;
                        this.scaleFactorY = minimumEvenScale;
                    }
                }
                this.ControlBox = false;
                this.Text       = String.Empty;
            }


            this.volBGM = (float)ShanghaiEXE.Config.VolumeBGM;
            this.volSE  = (float)(ShanghaiEXE.Config.VolumeSE / 100);

            Controller.ctl = (ShanghaiEXE.Config.PausedWhenInactive) ? CooperativeLevel.Foreground : CooperativeLevel.Background;

            this.fps30 = ShanghaiEXE.Config.FPS30;

            ShanghaiEXE.languageTranslationService = new LanguageTranslationService(ShanghaiEXE.Config.Language);
            ShanghaiEXE.language = ShanghaiEXE.Config.Language == "en-US" ? 1 : 0;

            if (ShanghaiEXE.Config.ShowDialogueTester)
            {
                var dialogueTester = new DialogueTester(this, () => scene);
                dialogueTester.Show();
            }

            ShanghaiEXE.Config.ToXML("option.xml");

            this.Closing    += new CancelEventHandler(this.Game_Closing);
            this.MaximizeBox = false;
            this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="LanguageTranslationsController" /> class.
 /// </summary>
 /// <param name="languageTranslationService">The language translation service.</param>
 public LanguageTranslationsController(ILanguageTranslationService languageTranslationService)
 {
     _languageTranslationService = languageTranslationService;
 }