From 6d8ab0c256457b8114b21a4178ec899b5873094d Mon Sep 17 00:00:00 2001 From: skidau Date: Sat, 17 Jan 2015 11:16:15 +1100 Subject: Draw buttons in rows of eight in the Controller config. --- Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp | 45 +++++++++++++++--------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp') diff --git a/Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp b/Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp index 4b838a8ab6..812e4320a4 100644 --- a/Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp +++ b/Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp @@ -48,6 +48,25 @@ static void DrawCoordinate(wxDC &dc, ControlState x, ControlState y) DrawCenteredRectangle(dc, xc, yc, COORD_VIS_SIZE, COORD_VIS_SIZE); } +void DrawButton(unsigned int* const bitmasks, unsigned int buttons, unsigned int n, wxDC& dc, ControlGroupBox* g, unsigned int row) +{ + if (buttons & bitmasks[(row * 8) + n]) + { + dc.SetBrush(*wxRED_BRUSH); + } + else + { + unsigned char amt = 255 - g->control_group->controls[(row * 8) + n]->control_ref->State() * 128; + dc.SetBrush(wxBrush(wxColour(amt, amt, amt))); + } + dc.DrawRectangle(n * 12, (row == 0) ? 0 : (row * 12 - 1), 14, 12); + + // text + const std::string name = g->control_group->controls[(row * 8) + n]->name; + // bit of hax so ZL, ZR show up as L, R + dc.DrawText(StrToWxStr(std::string(1, (name[1] && name[1] < 'a') ? name[1] : name[0])), n * 12 + 2, 1 + ((row == 0) ? 0 : (row * 12 - 1))); +} + static void DrawControlGroupBox(wxDC &dc, ControlGroupBox *g) { switch (g->control_group->type) @@ -242,35 +261,29 @@ static void DrawControlGroupBox(wxDC &dc, ControlGroupBox *g) break; case GROUP_TYPE_BUTTONS : { - const unsigned int button_count = ((unsigned int)g->control_group->controls.size()); + unsigned int button_count = ((unsigned int)g->control_group->controls.size()); // draw the shit dc.SetPen(*wxGREY_PEN); - unsigned int * const bitmasks = new unsigned int[ button_count ]; + unsigned int* const bitmasks = new unsigned int[button_count]; for (unsigned int n = 0; ncontrol_group)->GetState(&buttons, bitmasks); - for (unsigned int n = 0; ncontrol_group->controls[n]->control_ref->State() * 128; - dc.SetBrush(wxBrush(wxColour(amt, amt, amt))); + DrawButton(bitmasks, buttons, n, dc, g, row); } - dc.DrawRectangle(n * 12, 0, 14, 12); - - // text - const std::string name = g->control_group->controls[n]->name; - // bit of hax so ZL, ZR show up as L, R - dc.DrawText(StrToWxStr(std::string(1, (name[1] && name[1] < 'a') ? name[1] : name[0])), n*12 + 2, 1); } delete[] bitmasks; -- cgit v1.2.3