示例#1
0
        public void init()
        {
            if (!LangINI.LangLoadOK)
            {
                return;
            }

            Ok_btn.Text            = LangINI.lang_table[AprNesUI.GetInstance().AppConfigure["Lang"]]["ok"];
            this.Text              = LangINI.lang_table[AprNesUI.GetInstance().AppConfigure["Lang"]]["setting"];
            choose_dir.Text        = LangINI.lang_table[AprNesUI.GetInstance().AppConfigure["Lang"]]["selectfolder"];
            groupBox1.Text         = LangINI.lang_table[AprNesUI.GetInstance().AppConfigure["Lang"]]["keypad"];
            groupBox2.Text         = LangINI.lang_table[AprNesUI.GetInstance().AppConfigure["Lang"]]["joypad"];
            groupBox4.Text         = LangINI.lang_table[AprNesUI.GetInstance().AppConfigure["Lang"]]["screen"];
            LimitFPS_checkBox.Text = LangINI.lang_table[AprNesUI.GetInstance().AppConfigure["Lang"]]["limitfps"];
            label18.Text           = LangINI.lang_table[AprNesUI.GetInstance().AppConfigure["Lang"]]["langchoose"];
            label9.Text            = "Shift + p " + LangINI.lang_table[AprNesUI.GetInstance().AppConfigure["Lang"]]["capture_path"];
            groupBox3.Text         = LangINI.lang_table[AprNesUI.GetInstance().AppConfigure["Lang"]]["scanline"];


            comboBox1.Items.Clear();

            int ch = 0;

            foreach (string i in LangINI.lang_map.Keys)
            {
                comboBox1.Items.Add(i + " " + LangINI.lang_map[i]);
                if (i == AprNesUI.GetInstance().AppConfigure["Lang"])
                {
                    comboBox1.SelectedIndex = ch;
                }
                ch++;
            }
        }
示例#2
0
文件: AprNesUI.cs 项目: jizang/AprNes
 public static AprNesUI GetInstance()
 {
     if (instance == null || instance.IsDisposed)
     {
         instance = new AprNesUI();
     }
     return(instance);
 }
示例#3
0
 public void init()
 {
     inf = AprNesUI.GetInstance().GetRomInfo();
     richTextBox1.Text = inf;
 }
示例#4
0
文件: AprNesUI.cs 项目: jizang/AprNes
        void polling_listener()
        {
            while (app_running)
            {
                Thread.Sleep(_joystick.PeriodMin);
                List <joystickEvent> event_list = _joystick.joy_event_captur();
                foreach (joystickEvent joy_event in event_list)
                {
                    //for configure
                    if (configure)
                    {
                        AprNesUI.GetInstance().Invoke(new MethodInvoker(() =>
                        {
                            if (joy_event.event_type == 0)  //方向鍵觸發
                            {
                                if (joy_event.way_type == 0)
                                {
                                    AprNes_ConfigureUI.GetInstance().Setup_JoyPad_define(joy_event.joystick_id.ToString(), "X", 0, joy_event.way_value);
                                }
                                else
                                {
                                    AprNes_ConfigureUI.GetInstance().Setup_JoyPad_define(joy_event.joystick_id.ToString(), "Y", 0, joy_event.way_value);
                                }
                            }
                            else  //一般按鈕觸發
                            {
                                AprNes_ConfigureUI.GetInstance().Setup_JoyPad_define(joy_event.joystick_id.ToString(), "Button " + joy_event.button_id.ToString(), joy_event.button_id, 128);
                            }
                        }));
                        break;
                    }

                    //for gaming..
                    if (running)
                    {
                        KeyMap joy = KeyMap.NES_btn_A;
                        if (joy_event.event_type == 1)
                        {
                            string key = joy_event.joystick_id.ToString() + "," + "Button " + joy_event.button_id.ToString() + "," + joy_event.button_id.ToString();
                            if (AprNesUI.GetInstance().NES_KeyMAP_joypad.ContainsKey(key))
                            {
                                joy = AprNesUI.GetInstance().NES_KeyMAP_joypad[key];
                            }
                            else
                            {
                                continue;
                            }
                        }
                        else
                        {
                            string XY  = (joy_event.way_type == 0) ? "X" : "Y";
                            string key = joy_event.joystick_id.ToString() + "," + JoyPadWayName(XY, joy_event.way_value) + "," + "0" + "," + joy_event.way_value;

                            if (AprNesUI.GetInstance().NES_KeyMAP_joypad.ContainsKey(key))
                            {
                                joy = AprNesUI.GetInstance().NES_KeyMAP_joypad[key];
                            }
                            else
                            {
                                string key_a = joy_event.joystick_id.ToString() + "," + JoyPadWayName(XY, 0) + "," + "0" + "," + "0";
                                string key_b = joy_event.joystick_id.ToString() + "," + JoyPadWayName(XY, 65535) + "," + "0" + "," + "65535";

                                if (NES_KeyMAP_joypad.ContainsKey(key_a) || (AprNesUI.GetInstance().NES_KeyMAP_joypad.ContainsKey(key_b)))
                                {
                                    if (XY == "X")
                                    {
                                        NesCore.P1_ButtonUnPress((byte)KeyMap.NES_btn_LEFT);
                                        NesCore.P1_ButtonUnPress((byte)KeyMap.NES_btn_RIGHT);
                                    }

                                    if (XY == "Y")
                                    {
                                        NesCore.P1_ButtonUnPress((byte)KeyMap.NES_btn_UP);
                                        NesCore.P1_ButtonUnPress((byte)KeyMap.NES_btn_DOWN);
                                    }
                                }
                                continue;
                            }
                        }

                        switch (joy)
                        {
                        case KeyMap.NES_btn_A:
                        {
                            if (joy_event.button_event == 1)
                            {
                                NesCore.P1_ButtonPress((byte)KeyMap.NES_btn_A);
                            }
                            else
                            {
                                NesCore.P1_ButtonUnPress((byte)KeyMap.NES_btn_A);
                            }
                        }
                        break;

                        case KeyMap.NES_btn_B:
                        {
                            if (joy_event.button_event == 1)
                            {
                                NesCore.P1_ButtonPress((byte)KeyMap.NES_btn_B);
                            }
                            else
                            {
                                NesCore.P1_ButtonUnPress((byte)KeyMap.NES_btn_B);
                            }
                        }
                        break;

                        case KeyMap.NES_btn_SELECT:
                        {
                            if (joy_event.button_event == 1)
                            {
                                NesCore.P1_ButtonPress((byte)KeyMap.NES_btn_SELECT);
                            }
                            else
                            {
                                NesCore.P1_ButtonUnPress((byte)KeyMap.NES_btn_SELECT);
                            }
                        }
                        break;

                        case KeyMap.NES_btn_START:
                        {
                            if (joy_event.button_event == 1)
                            {
                                NesCore.P1_ButtonPress((byte)KeyMap.NES_btn_START);
                            }
                            else
                            {
                                NesCore.P1_ButtonUnPress((byte)KeyMap.NES_btn_START);
                            }
                        }
                        break;

                        case KeyMap.NES_btn_UP:
                            NesCore.P1_ButtonPress((byte)KeyMap.NES_btn_UP);
                            break;

                        case KeyMap.NES_btn_DOWN:
                            NesCore.P1_ButtonPress((byte)KeyMap.NES_btn_DOWN);
                            break;

                        case KeyMap.NES_btn_LEFT:
                            NesCore.P1_ButtonPress((byte)KeyMap.NES_btn_LEFT);
                            break;

                        case KeyMap.NES_btn_RIGHT:
                            NesCore.P1_ButtonPress((byte)KeyMap.NES_btn_RIGHT);
                            break;
                        }
                    }
                }
            }
        }
示例#5
0
文件: Program.cs 项目: jizang/AprNes
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(AprNesUI.GetInstance());
 }
示例#6
0
        public void BeforClose()
        {
            if (radioButtonX2s.Checked)
            {
                AprNesUI.GetInstance().AppConfigure["ScreenSize"] = "2";
                AprNesUI.GetInstance().AppConfigure["filter"]     = "scanline";
            }
            else if (radioButtonX4s.Checked)
            {
                AprNesUI.GetInstance().AppConfigure["ScreenSize"] = "4";
                AprNesUI.GetInstance().AppConfigure["filter"]     = "scanline";
            }
            else if (radioButtonX6s.Checked)
            {
                AprNesUI.GetInstance().AppConfigure["ScreenSize"] = "6";
                AprNesUI.GetInstance().AppConfigure["filter"]     = "scanline";
            }

            if (radioButtonX1.Checked)
            {
                AprNesUI.GetInstance().AppConfigure["ScreenSize"] = "1";
                AprNesUI.GetInstance().AppConfigure["filter"]     = "xbrz";
            }
            else if (radioButtonX2.Checked)
            {
                AprNesUI.GetInstance().AppConfigure["ScreenSize"] = "2";
                AprNesUI.GetInstance().AppConfigure["filter"]     = "xbrz";
            }
            else if (radioButtonX3.Checked)
            {
                AprNesUI.GetInstance().AppConfigure["ScreenSize"] = "3";
                AprNesUI.GetInstance().AppConfigure["filter"]     = "xbrz";
            }
            else if (radioButtonX4.Checked)
            {
                AprNesUI.GetInstance().AppConfigure["ScreenSize"] = "4";
                AprNesUI.GetInstance().AppConfigure["filter"]     = "xbrz";
            }
            else if (radioButtonX5.Checked)
            {
                AprNesUI.GetInstance().AppConfigure["ScreenSize"] = "5";
                AprNesUI.GetInstance().AppConfigure["filter"]     = "xbrz";
            }
            else if (radioButtonX6.Checked)
            {
                AprNesUI.GetInstance().AppConfigure["ScreenSize"] = "6";
                AprNesUI.GetInstance().AppConfigure["filter"]     = "xbrz";
            }
            else if (radioButtonX8.Checked)
            {
                AprNesUI.GetInstance().AppConfigure["ScreenSize"] = "8";
                AprNesUI.GetInstance().AppConfigure["filter"]     = "xbrz";
            }
            else if (radioButtonX9.Checked)
            {
                AprNesUI.GetInstance().AppConfigure["ScreenSize"] = "9";
                AprNesUI.GetInstance().AppConfigure["filter"]     = "xbrz";
            }
            AprNesUI.GetInstance().NES_KeyMAP_joypad.Clear();

            foreach (string key in NES_KeyMAP_joypad_config.Keys)
            {
                AprNesUI.GetInstance().NES_KeyMAP_joypad[key] = NES_KeyMAP_joypad_config[key];
            }

            AprNesUI.GetInstance().AppConfigure["LimitFPS"] = "0";
            if (LimitFPS_checkBox.Checked)
            {
                AprNesUI.GetInstance().AppConfigure["LimitFPS"] = "1";
            }

            AprNesUI.GetInstance().AppConfigure["CaptureScreenPath"] = screen_path.Text;
            AprNesUI.GetInstance().key_A                = key_A;
            AprNesUI.GetInstance().key_B                = key_B;
            AprNesUI.GetInstance().key_SELECT           = key_SELECT;
            AprNesUI.GetInstance().key_START            = key_START;
            AprNesUI.GetInstance().key_RIGHT            = key_RIGHT;
            AprNesUI.GetInstance().key_LEFT             = key_LEFT;
            AprNesUI.GetInstance().key_UP               = key_UP;
            AprNesUI.GetInstance().key_DOWN             = key_DOWN;
            AprNesUI.GetInstance().AppConfigure["Lang"] = (comboBox1.SelectedItem as string).Split(new char[] { ' ' })[0];
            AprNesUI.GetInstance().Configure_Write();

            AprNesUI.GetInstance().LoadConfig();
            AprNesUI.GetInstance().initUILang();
            AprNesUI.GetInstance().initUIsize();

            AprNesUI.GetInstance().Reset();
        }
示例#7
0
        private void GBEMU_ConfigureUI_Shown(object sender, EventArgs e)
        {
            NES_KeyMAP_joypad_config.Clear();
            foreach (string key in AprNesUI.GetInstance().NES_KeyMAP_joypad.Keys)
            {
                NES_KeyMAP_joypad_config[key] = AprNesUI.GetInstance().NES_KeyMAP_joypad[key];
            }

            joypad_A.Text = joypad_B.Text = joypad_SELECT.Text = joypad_START.Text = joypad_UP.Text = joypad_DOWN.Text = joypad_LEFT.Text = joypad_RIGHT.Text = "";

            foreach (string key in NES_KeyMAP_joypad_config.Keys)
            {
                if (key == "")
                {
                    continue;
                }

                if (NES_KeyMAP_joypad_config[key] == AprNesUI.KeyMap.NES_btn_A)
                {
                    List <string> tmp = key.Split(new char[] { ',' }).ToList();
                    joypad_A.Text = tmp[1];
                }
                else if (NES_KeyMAP_joypad_config[key] == AprNesUI.KeyMap.NES_btn_B)
                {
                    List <string> tmp = key.Split(new char[] { ',' }).ToList();
                    joypad_B.Text = tmp[1];
                }
                else if (NES_KeyMAP_joypad_config[key] == AprNesUI.KeyMap.NES_btn_SELECT)
                {
                    List <string> tmp = key.Split(new char[] { ',' }).ToList();
                    joypad_SELECT.Text = tmp[1];
                }
                else if (NES_KeyMAP_joypad_config[key] == AprNesUI.KeyMap.NES_btn_START)
                {
                    List <string> tmp = key.Split(new char[] { ',' }).ToList();
                    joypad_START.Text = tmp[1];
                }
                else if (NES_KeyMAP_joypad_config[key] == AprNesUI.KeyMap.NES_btn_UP)
                {
                    List <string> tmp = key.Split(new char[] { ',' }).ToList();
                    joypad_UP.Text = tmp[1];
                }
                else if (NES_KeyMAP_joypad_config[key] == AprNesUI.KeyMap.NES_btn_DOWN)
                {
                    List <string> tmp = key.Split(new char[] { ',' }).ToList();
                    joypad_DOWN.Text = tmp[1];
                }
                else if (NES_KeyMAP_joypad_config[key] == AprNesUI.KeyMap.NES_btn_LEFT)
                {
                    List <string> tmp = key.Split(new char[] { ',' }).ToList();
                    joypad_LEFT.Text = tmp[1];
                }
                else if (NES_KeyMAP_joypad_config[key] == AprNesUI.KeyMap.NES_btn_RIGHT)
                {
                    List <string> tmp = key.Split(new char[] { ',' }).ToList();
                    joypad_RIGHT.Text = tmp[1];
                }
            }


            switch (AprNesUI.GetInstance().AppConfigure["filter"])
            {
            case "xbrz":
                (groupBox4.Controls.Find("radioButtonX" + AprNesUI.GetInstance().AppConfigure["ScreenSize"], true)[0] as RadioButton).Checked = true;
                break;

            case "scanline":
                (groupBox3.Controls.Find("radioButtonX" + AprNesUI.GetInstance().AppConfigure["ScreenSize"] + "s", true)[0] as RadioButton).Checked = true;
                break;
            }



            if (AprNesUI.GetInstance().AppConfigure["LimitFPS"] == "1")
            {
                LimitFPS_checkBox.Checked = true;
            }
            else
            {
                LimitFPS_checkBox.Checked = false;
            }

            screen_path.Text = AprNesUI.GetInstance().AppConfigure["CaptureScreenPath"];

            textBox_A.Text      = ((Keys)int.Parse(AprNesUI.GetInstance().AppConfigure["key_A"])).ToString();
            textBox_B.Text      = ((Keys)int.Parse(AprNesUI.GetInstance().AppConfigure["key_B"])).ToString();
            textBox_SELECT.Text = ((Keys)int.Parse(AprNesUI.GetInstance().AppConfigure["key_SELECT"])).ToString();
            textBox_START.Text  = ((Keys)int.Parse(AprNesUI.GetInstance().AppConfigure["key_START"])).ToString();
            textBox_UP.Text     = ((Keys)int.Parse(AprNesUI.GetInstance().AppConfigure["key_UP"])).ToString();
            textBox_DOWN.Text   = ((Keys)int.Parse(AprNesUI.GetInstance().AppConfigure["key_DOWN"])).ToString();
            textBox_LEFT.Text   = ((Keys)int.Parse(AprNesUI.GetInstance().AppConfigure["key_LEFT"])).ToString();
            textBox_RIGHT.Text  = ((Keys)int.Parse(AprNesUI.GetInstance().AppConfigure["key_RIGHT"])).ToString();

            key_A      = int.Parse(AprNesUI.GetInstance().AppConfigure["key_A"]);
            key_B      = int.Parse(AprNesUI.GetInstance().AppConfigure["key_B"]);
            key_SELECT = int.Parse(AprNesUI.GetInstance().AppConfigure["key_SELECT"]);
            key_START  = int.Parse(AprNesUI.GetInstance().AppConfigure["key_START"]);
            key_UP     = int.Parse(AprNesUI.GetInstance().AppConfigure["key_UP"]);
            key_DOWN   = int.Parse(AprNesUI.GetInstance().AppConfigure["key_DOWN"]);
            key_LEFT   = int.Parse(AprNesUI.GetInstance().AppConfigure["key_LEFT"]);
            key_RIGHT  = int.Parse(AprNesUI.GetInstance().AppConfigure["key_RIGHT"]);

            LimitFPS_checkBox.Focus();
        }