- [FIX] al recrear una finestra de vegades es perdia la textura de les fonts de la UI.
82 lines
2.7 KiB
C++
82 lines
2.7 KiB
C++
#include "zx_dialog_joystick.h"
|
|
#include "ui.h"
|
|
#include "z80debug.h"
|
|
#include "gamepad.h"
|
|
|
|
namespace dialogs
|
|
{
|
|
namespace joysticks
|
|
{
|
|
int32_t selected = 0;
|
|
|
|
void init(int32_t index)
|
|
{
|
|
if (index != -1) selected = index;
|
|
ui::setDialog(dialogs::joysticks::show);
|
|
z80debug::pause();
|
|
}
|
|
|
|
void show()
|
|
{
|
|
uint8_t back_color = COLOR_DARK;
|
|
uint8_t front_color = COLOR_WHITE;
|
|
|
|
ui::setoffset(0,0);
|
|
ui::printrect(36, 15, 46, 12, COLOR_DARK);
|
|
ui::panel(36,15,46,12,"CONFIGURE JOYSTICKS:");
|
|
|
|
if (ui::mouseInside(34,9,7,1)) {
|
|
back_color = COLOR_WHITE;
|
|
front_color = COLOR_BLACK;
|
|
if (ui::getClicked()) { ui::setDialog(nullptr); z80debug::cont(); }
|
|
}
|
|
ui::printrect(34, 9, 7, 1, back_color);
|
|
ui::printtxt(35,9,"CLOSE", front_color);
|
|
|
|
ui::panel(38,17,20,8,"JOYSTICKS:");
|
|
const int num_gamepads = gamepad::getNumGamepads();
|
|
if (selected>=num_gamepads) selected = 0;
|
|
for (int i=0; i<num_gamepads; ++i)
|
|
{
|
|
char name[] = "JOYSTICK 0";
|
|
name[9] = 48+i;
|
|
back_color = COLOR_DARK;
|
|
front_color = COLOR_WHITE;
|
|
if (ui::mouseInside(0,i,18,1)) {
|
|
back_color = COLOR_BLACK;
|
|
if (ui::getClicked()) {
|
|
selected = i;
|
|
}
|
|
}
|
|
if (selected==i) {
|
|
back_color = COLOR_WHITE;
|
|
front_color = COLOR_BLACK;
|
|
}
|
|
ui::printrect(0,i,18,1, back_color);
|
|
ui::printtxt(0,i,name, front_color);
|
|
}
|
|
ui::panel(60,17,20,8,"TYPE:");
|
|
const int selected_type = gamepad::getGamepadType(selected);
|
|
const char* types[5] = {"SINCLAIR 1", "SINCLAIR 2", "KEMPSTON", "FULLER", "CUSTOM"};
|
|
for (int i=0;i<5;++i)
|
|
{
|
|
back_color = COLOR_DARK;
|
|
front_color = COLOR_WHITE;
|
|
if (ui::mouseInside(0,i,18,1)) {
|
|
back_color = COLOR_BLACK;
|
|
if (ui::getClicked()) {
|
|
gamepad::setGamepadType(selected, i+1);
|
|
}
|
|
}
|
|
if (i==selected_type-1) {
|
|
back_color = COLOR_WHITE;
|
|
front_color = COLOR_BLACK;
|
|
}
|
|
ui::printrect(0,i,18,1, back_color);
|
|
ui::printtxt(0,i,types[i],front_color);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|