Welcome to mirror list, hosted at ThFree Co, Russian Federation.

SelectSnesButtonsForm.cs - github.com/ClusterM/hakchi2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 19ecfc44690516c5b3a524359f5ffea0ecf59e1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using com.clusterrr.hakchi_gui.Properties;
using System;
using System.Windows.Forms;

namespace com.clusterrr.hakchi_gui
{
    public partial class SelectSnesButtonsForm : Form
    {
        [Flags]
        public enum SnesButtons
        {
            A = 0x01,
            B = 0x02,
            Select = 0x04,
            Start = 0x08,
            Up = 0x10,
            Down = 0x20,
            Left = 0x40,
            Right = 0x080,
            X = 0x100,
            Y = 0x200,
            L = 0x400,
            R = 0x800
        }

        public SnesButtons SelectedButtons;

        public SelectSnesButtonsForm(SnesButtons buttons)
        {
            InitializeComponent();
            checkBoxA.Checked = (buttons & SnesButtons.A) != 0;
            checkBoxB.Checked = (buttons & SnesButtons.B) != 0;
            checkBoxSelect.Checked = (buttons & SnesButtons.Select) != 0;
            checkBoxStart.Checked = (buttons & SnesButtons.Start) != 0;
            checkBoxUp.Checked = (buttons & SnesButtons.Up) != 0;
            checkBoxDown.Checked = (buttons & SnesButtons.Down) != 0;
            checkBoxLeft.Checked = (buttons & SnesButtons.Left) != 0;
            checkBoxRight.Checked = (buttons & SnesButtons.Right) != 0;
            checkBoxX.Checked = (buttons & SnesButtons.X) != 0;
            checkBoxY.Checked = (buttons & SnesButtons.Y) != 0;
            checkBoxL.Checked = (buttons & SnesButtons.L) != 0;
            checkBoxR.Checked = (buttons & SnesButtons.R) != 0;
            SelectedButtons = buttons;
        }

        private void checkBox_CheckedChanged(object sender, EventArgs e)
        {
            SelectedButtons =
                (checkBoxA.Checked ? SnesButtons.A : 0) |
                (checkBoxB.Checked ? SnesButtons.B : 0) |
                (checkBoxSelect.Checked ? SnesButtons.Select : 0) |
                (checkBoxStart.Checked ? SnesButtons.Start : 0) |
                (checkBoxUp.Checked ? SnesButtons.Up : 0) |
                (checkBoxDown.Checked ? SnesButtons.Down : 0) |
                (checkBoxLeft.Checked ? SnesButtons.Left : 0) |
                (checkBoxRight.Checked ? SnesButtons.Right : 0) |
                (checkBoxX.Checked ? SnesButtons.X : 0) |
                (checkBoxY.Checked ? SnesButtons.Y : 0) |
                (checkBoxL.Checked ? SnesButtons.L : 0) |
                (checkBoxR.Checked ? SnesButtons.R : 0);
        }

        private void buttonOk_Click(object sender, EventArgs e)
        {
            int buttonCount = 0;
            for (int i = 0; i < 12; i++)
                if (((int)SelectedButtons & (1 << i)) != 0)
                    buttonCount++;
            if (buttonCount < 2)
            {
                MessageBox.Show(this, Resources.SelectAtLeastTwo, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            DialogResult = DialogResult.OK;
            Close();
        }
    }
}