mirror of https://github.com/stella-emu/stella.git
working on more controllers and debugger widgets
This commit is contained in:
parent
48cea696d8
commit
d590938156
|
@ -20,37 +20,52 @@
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
DrivingWidget::DrivingWidget(GuiObject* boss, const GUI::Font& font,
|
||||
int x, int y, Controller& controller)
|
||||
int x, int y, Controller& controller, bool embedded)
|
||||
: ControllerWidget(boss, font, x, y, controller)
|
||||
{
|
||||
const string& label = getHeader();
|
||||
|
||||
const int fontHeight = font.getFontHeight(),
|
||||
bwidth = font.getStringWidth("Gray code +") + 10,
|
||||
fontWidth = font.getMaxCharWidth(),
|
||||
bheight = font.getLineHeight() + 4;
|
||||
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Driving)");
|
||||
StaticTextWidget* t;
|
||||
|
||||
t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth,
|
||||
fontHeight, label, TextAlign::Left);
|
||||
if(embedded)
|
||||
{
|
||||
const int bwidth = font.getStringWidth("GC+ ");
|
||||
|
||||
ypos += t->getHeight() + 20;
|
||||
myGrayUp = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
|
||||
"Gray code +", kGrayUpCmd);
|
||||
myGrayUp = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
|
||||
"GC+", kGrayUpCmd);
|
||||
|
||||
ypos += myGrayUp->getHeight() + 5;
|
||||
myGrayDown = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
|
||||
"GC-", kGrayDownCmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int bwidth = font.getStringWidth("Gray code +") + 10;
|
||||
t = new StaticTextWidget(boss, font, xpos, ypos + 2, lwidth,
|
||||
fontHeight, label, TextAlign::Left);
|
||||
|
||||
ypos += t->getHeight() + 20;
|
||||
myGrayUp = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
|
||||
"Gray code +", kGrayUpCmd);
|
||||
|
||||
ypos += myGrayUp->getHeight() + 5;
|
||||
myGrayDown = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
|
||||
"Gray code -", kGrayDownCmd);
|
||||
}
|
||||
myGrayUp->setTarget(this);
|
||||
|
||||
ypos += myGrayUp->getHeight() + 5;
|
||||
myGrayDown = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
|
||||
"Gray code -", kGrayDownCmd);
|
||||
myGrayDown->setTarget(this);
|
||||
|
||||
xpos += myGrayDown->getWidth() + 10; ypos -= 10;
|
||||
xpos += myGrayDown->getWidth() + fontWidth; ypos -= 10;
|
||||
myGrayValue = new DataGridWidget(boss, font, xpos, ypos,
|
||||
1, 1, 2, 8, Common::Base::Fmt::_16);
|
||||
myGrayValue->setTarget(this);
|
||||
myGrayValue->setEditable(false);
|
||||
|
||||
xpos = x + 30; ypos += myGrayDown->getHeight() + 20;
|
||||
xpos = x + fontWidth*3; ypos += myGrayDown->getHeight() + 20;
|
||||
myFire = new CheckboxWidget(boss, font, xpos, ypos, "Fire", kFireCmd);
|
||||
myFire->setTarget(this);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class DrivingWidget : public ControllerWidget
|
|||
{
|
||||
public:
|
||||
DrivingWidget(GuiObject* boss, const GUI::Font& font, int x, int y,
|
||||
Controller& controller);
|
||||
Controller& controller, bool embedded = false);
|
||||
~DrivingWidget() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -34,7 +34,7 @@ JoystickWidget::JoystickWidget(GuiObject* boss, const GUI::Font& font,
|
|||
|
||||
t = new StaticTextWidget(boss, font, xpos, ypos + 2, lwidth,
|
||||
fontHeight, label, TextAlign::Left);
|
||||
xpos += t->getWidth() / 2 - 5; ypos += t->getHeight() + 20;
|
||||
xpos += t->getWidth() / 2 - 5; ypos = t->getBottom() + fontHeight;
|
||||
}
|
||||
myPins[kJUp] = new CheckboxWidget(boss, font, xpos, ypos, "",
|
||||
CheckboxWidget::kCheckActionCmd);
|
||||
|
|
|
@ -26,22 +26,38 @@ class NullControlWidget : public ControllerWidget
|
|||
{
|
||||
public:
|
||||
NullControlWidget(GuiObject* boss, const GUI::Font& font, int x, int y,
|
||||
Controller& controller)
|
||||
Controller& controller, bool embedded = false)
|
||||
: ControllerWidget(boss, font, x, y, controller)
|
||||
{
|
||||
ostringstream buf;
|
||||
buf << getHeader();
|
||||
const int fontHeight = font.getFontHeight(),
|
||||
lineHeight = font.getLineHeight(),
|
||||
lwidth = std::max(font.getStringWidth(buf.str()),
|
||||
font.getStringWidth("Controller input"));
|
||||
new StaticTextWidget(boss, font, x, y+2, lwidth,
|
||||
fontHeight, buf.str(), TextAlign::Left);
|
||||
new StaticTextWidget(boss, font, x, y+2+2*lineHeight, lwidth,
|
||||
fontHeight, "Controller input", TextAlign::Center);
|
||||
new StaticTextWidget(boss, font, x, y+2+3*lineHeight, lwidth,
|
||||
fontHeight, "not available",
|
||||
TextAlign::Center);
|
||||
lineHeight = font.getLineHeight();
|
||||
|
||||
if(embedded)
|
||||
{
|
||||
const int lwidth = font.getStringWidth("avail.");
|
||||
|
||||
y += fontHeight;
|
||||
new StaticTextWidget(boss, font, x, y, lwidth, fontHeight,
|
||||
"not", TextAlign::Center);
|
||||
y += lineHeight;
|
||||
new StaticTextWidget(boss, font, x, y, lwidth, fontHeight,
|
||||
"avail.", TextAlign::Center);
|
||||
}
|
||||
else
|
||||
{
|
||||
ostringstream buf;
|
||||
buf << getHeader();
|
||||
const int lwidth = std::max(font.getStringWidth(buf.str()),
|
||||
font.getStringWidth("Controller input"));
|
||||
|
||||
new StaticTextWidget(boss, font, x, y + 2, lwidth, fontHeight, buf.str());
|
||||
y += 2 + lineHeight * 2;
|
||||
new StaticTextWidget(boss, font, x, y, lwidth,
|
||||
fontHeight, "Controller input", TextAlign::Center);
|
||||
new StaticTextWidget(boss, font, x, y+lineHeight, lwidth,
|
||||
fontHeight, "not available",
|
||||
TextAlign::Center);
|
||||
}
|
||||
}
|
||||
|
||||
~NullControlWidget() override = default;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "Console.hxx"
|
||||
#include "TIA.hxx"
|
||||
#include "QuadTari.hxx"
|
||||
#include "DrivingWidget.hxx"
|
||||
#include "JoystickWidget.hxx"
|
||||
#include "NullControlWidget.hxx"
|
||||
#include "QuadTariWidget.hxx"
|
||||
|
@ -28,40 +29,54 @@ QuadTariWidget::QuadTariWidget(GuiObject* boss, const GUI::Font& font,
|
|||
int x, int y, Controller& controller)
|
||||
: ControllerWidget(boss, font, x, y, controller)
|
||||
{
|
||||
const int fontWidth = font.getMaxCharWidth(),
|
||||
fontHeight = font.getFontHeight();
|
||||
string label = (isLeftPort() ? "Left" : "Right") + string(" (QuadTari)");
|
||||
StaticTextWidget* t = new StaticTextWidget(boss, font, x, y + 2, label);
|
||||
QuadTari& qt = static_cast<QuadTari&>(controller);
|
||||
|
||||
x += font.getMaxCharWidth() * 2;
|
||||
y = t->getBottom() + font.getFontHeight() * 1.25;
|
||||
|
||||
// TODO: support multiple controller types
|
||||
switch(qt.myFirstController->type())
|
||||
{
|
||||
case Controller::Type::Joystick:
|
||||
x += fontWidth * 2;
|
||||
y = t->getBottom() + fontHeight;
|
||||
myFirstControl = new JoystickWidget(boss, font, x, y, *qt.myFirstController, true);
|
||||
x = myFirstControl->getRight() - font.getMaxCharWidth() * 8;
|
||||
break;
|
||||
|
||||
case Controller::Type::Driving:
|
||||
y = t->getBottom() + font.getFontHeight() * 1;
|
||||
myFirstControl = new DrivingWidget(boss, font, x, y, *qt.myFirstController, true);
|
||||
break;
|
||||
|
||||
default:
|
||||
myFirstControl = new NullControlWidget(boss, font, x, y, *qt.myFirstController);
|
||||
x += font.getMaxCharWidth() * 8;
|
||||
y = t->getBottom() + font.getFontHeight() * 1.25;
|
||||
myFirstControl = new NullControlWidget(boss, font, x, y, *qt.myFirstController, true);
|
||||
break;
|
||||
}
|
||||
|
||||
x = t->getLeft() + fontWidth * 10;
|
||||
switch(qt.mySecondController->type())
|
||||
{
|
||||
case Controller::Type::Joystick:
|
||||
x += fontWidth * 2;
|
||||
y = t->getBottom() + fontHeight;
|
||||
mySecondControl = new JoystickWidget(boss, font, x, y, *qt.mySecondController, true);
|
||||
break;
|
||||
|
||||
case Controller::Type::Driving:
|
||||
y = t->getBottom() + font.getFontHeight();
|
||||
myFirstControl = new DrivingWidget(boss, font, x, y, *qt.mySecondController, true);
|
||||
break;
|
||||
|
||||
default:
|
||||
mySecondControl = new NullControlWidget(boss, font, x, y, *qt.mySecondController);
|
||||
y = t->getBottom() + font.getFontHeight() * 1.25;
|
||||
mySecondControl = new NullControlWidget(boss, font, x, y, *qt.mySecondController, true);
|
||||
break;
|
||||
}
|
||||
|
||||
myPointer = new StaticTextWidget(boss, font,
|
||||
x - font.getMaxCharWidth() * 5, y, " ");
|
||||
t->getLeft() + font.getMaxCharWidth() * 7, y, " ");
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -25,18 +25,20 @@
|
|||
#include "AtariVox.hxx"
|
||||
#include "Driving.hxx"
|
||||
#include "Joystick.hxx"
|
||||
#include "Paddles.hxx"
|
||||
#include "SaveKey.hxx"
|
||||
#include "QuadTari.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
QuadTari::QuadTari(Jack jack, OSystem& osystem, const System& system, const Properties& properties)
|
||||
QuadTari::QuadTari(Jack jack, const OSystem& osystem, const System& system, const Properties& properties)
|
||||
: Controller(jack, osystem.eventHandler().event(), system,
|
||||
Controller::Type::QuadTari),
|
||||
myOSystem(osystem)
|
||||
myOSystem(osystem),
|
||||
myProperties(properties)
|
||||
{
|
||||
string first, second;
|
||||
Controller::Type firstType = Controller::Type::Joystick,
|
||||
secondType = Controller::Type::Joystick;
|
||||
string first, second;
|
||||
|
||||
if(jack == Controller::Jack::Left)
|
||||
{
|
||||
|
@ -74,6 +76,16 @@ unique_ptr<Controller> QuadTari::addController(const Controller::Type type, bool
|
|||
|
||||
switch(type)
|
||||
{
|
||||
case Controller::Type::Paddles:
|
||||
{
|
||||
// Check if we should swap the paddles plugged into a jack
|
||||
bool swapPaddles = myProperties.get(PropType::Controller_SwapPaddles) == "YES";
|
||||
|
||||
return make_unique<Paddles>(myJack, myEvent, mySystem, swapPaddles, false, false);
|
||||
}
|
||||
case Controller::Type::Driving:
|
||||
return make_unique<Driving>(myJack, myEvent, mySystem, second);
|
||||
|
||||
case Controller::Type::AtariVox:
|
||||
{
|
||||
nvramfile /= "atarivox_eeprom.dat";
|
||||
|
@ -81,9 +93,6 @@ unique_ptr<Controller> QuadTari::addController(const Controller::Type type, bool
|
|||
myOSystem.settings().getString("avoxport"),
|
||||
nvramfile, callback); // no alternative mapping here
|
||||
}
|
||||
case Controller::Type::Driving:
|
||||
return make_unique<Driving>(myJack, myEvent, mySystem, second);
|
||||
|
||||
case Controller::Type::SaveKey:
|
||||
{
|
||||
nvramfile /= "savekey_eeprom.dat";
|
||||
|
|
|
@ -38,7 +38,7 @@ class QuadTari : public Controller
|
|||
@param system The system using this controller
|
||||
@param properties The properties to use for the current ROM
|
||||
*/
|
||||
QuadTari(Jack jack, OSystem& osystem, const System& system, const Properties& properties);
|
||||
QuadTari(Jack jack, const OSystem& osystem, const System& system, const Properties& properties);
|
||||
~QuadTari() override = default;
|
||||
|
||||
public:
|
||||
|
@ -91,7 +91,8 @@ class QuadTari : public Controller
|
|||
private:
|
||||
unique_ptr<Controller> addController(const Controller::Type type, bool second);
|
||||
|
||||
OSystem& myOSystem;
|
||||
const OSystem& myOSystem;
|
||||
const Properties& myProperties;
|
||||
unique_ptr<Controller> myFirstController;
|
||||
unique_ptr<Controller> mySecondController;
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ QuadTariDialog::QuadTariDialog(GuiObject* boss, const GUI::Font& font, int max_w
|
|||
ctrls.clear();
|
||||
//VarList::push_back(ctrls, "Auto-detect", "AUTO");
|
||||
VarList::push_back(ctrls, "Joystick", "JOYSTICK");
|
||||
//VarList::push_back(ctrls, "Paddles", "PADDLES");
|
||||
VarList::push_back(ctrls, "Paddles", "PADDLES");
|
||||
//VarList::push_back(ctrls, "Paddles_IAxis", "PADDLES_IAXIS");
|
||||
//VarList::push_back(ctrls, "Paddles_IAxDr", "PADDLES_IAXDR");
|
||||
//VarList::push_back(ctrls, "BoosterGrip", "BOOSTERGRIP");
|
||||
|
@ -64,7 +64,7 @@ QuadTariDialog::QuadTariDialog(GuiObject* boss, const GUI::Font& font, int max_w
|
|||
//VarList::push_back(ctrls, "MindLink", "MINDLINK");
|
||||
//VarList::push_back(ctrls, "QuadTari", "QUADTARI");
|
||||
|
||||
int pwidth = font.getStringWidth("Joystick12"); // looks better overall
|
||||
int pwidth = font.getStringWidth("Joystick12"); // a bit wider looks better overall
|
||||
|
||||
myLeftPortLabel = new StaticTextWidget(this, font, xpos, ypos + 1, "Left port");
|
||||
|
||||
|
|
Loading…
Reference in New Issue