enhanced TVBoy widget

This commit is contained in:
thrust26 2020-05-25 08:55:05 +02:00
parent b8f4de9f67
commit 433b3e8980
3 changed files with 73 additions and 21 deletions

View File

@ -16,13 +16,15 @@
//============================================================================
#include "CartTVBoy.hxx"
#include "PopUpWidget.hxx"
#include "CartTVBoyWidget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeTVBoyWidget::CartridgeTVBoyWidget(
GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont,
int x, int y, int w, int h, CartridgeTVBoy& cart)
: CartridgeEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart)
: CartridgeEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart),
myCartTVBoy(cart)
{
initialize();
}
@ -33,9 +35,45 @@ string CartridgeTVBoyWidget::description()
ostringstream info;
info << "TV Boy, " << myCart.romBankCount() << " 4K banks\n"
<< "Hotspots are from $" << Common::Base::HEX2 << 0x1800 << " to $"
<< Common::Base::HEX2 << (0x1800 + myCart.romBankCount() - 1) << "\n";
info << "Startup bank = #" << std::dec << myCart.startBank();
<< "Hotspots are from $" << Common::Base::HEX2 << 0xf800 << " to $"
<< Common::Base::HEX2 << (0xf800 + myCart.romBankCount() - 1) << "\n";
info << CartridgeEnhancedWidget::description();
return info.str();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeTVBoyWidget::bankSelect(int& ypos)
{
CartridgeEnhancedWidget::bankSelect(ypos);
int xpos = myBankWidgets[0]->getRight() + _font.getMaxCharWidth() * 4;
ypos = myBankWidgets[0]->getTop();
myBankLocked = new CheckboxWidget(_boss, _font, xpos, ypos + 1,
"Bankswitching is locked",
kBankLocked);
myBankLocked->setTarget(this);
addFocusWidget(myBankLocked);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeTVBoyWidget::loadConfig()
{
myBankWidgets[0]->setEnabled(!myCartTVBoy.myBankingDisabled);
myBankLocked->setState(myCartTVBoy.myBankingDisabled);
CartridgeEnhancedWidget::loadConfig();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeTVBoyWidget::handleCommand(CommandSender* sender,
int cmd, int data, int id)
{
if(cmd == kBankLocked)
{
myCartTVBoy.myBankingDisabled = myBankLocked->getState();
myBankWidgets[0]->setEnabled(!myCartTVBoy.myBankingDisabled);
}
else
CartridgeEnhancedWidget::handleCommand(sender, cmd, data, id);
}

View File

@ -19,30 +19,44 @@
#define CARTRIDGETVBOY_WIDGET_HXX
class CartridgeTVBoy;
class CheckboxWidget;
#include "CartEnhancedWidget.hxx"
class CartridgeTVBoyWidget : public CartridgeEnhancedWidget
{
public:
CartridgeTVBoyWidget(GuiObject* boss, const GUI::Font& lfont,
const GUI::Font& nfont,
int x, int y, int w, int h,
CartridgeTVBoy& cart);
virtual ~CartridgeTVBoyWidget() = default;
public:
CartridgeTVBoyWidget(GuiObject* boss, const GUI::Font& lfont,
const GUI::Font& nfont,
int x, int y, int w, int h,
CartridgeTVBoy& cart);
virtual ~CartridgeTVBoyWidget() = default;
private:
string manufacturer() override { return "Akor"; }
private:
string manufacturer() override { return "Akor"; }
string description() override;
string description() override;
private:
// Following constructors and assignment operators not supported
CartridgeTVBoyWidget() = delete;
CartridgeTVBoyWidget(const CartridgeTVBoyWidget&) = delete;
CartridgeTVBoyWidget(CartridgeTVBoyWidget&&) = delete;
CartridgeTVBoyWidget& operator=(const CartridgeTVBoyWidget&) = delete;
CartridgeTVBoyWidget& operator=(CartridgeTVBoyWidget&&) = delete;
void bankSelect(int& ypos) override;
CartridgeTVBoy& myCartTVBoy;
CheckboxWidget* myBankLocked{nullptr};
enum {
kBankLocked = 'bkLO'
};
private:
void loadConfig() override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
private:
// Following constructors and assignment operators not supported
CartridgeTVBoyWidget() = delete;
CartridgeTVBoyWidget(const CartridgeTVBoyWidget&) = delete;
CartridgeTVBoyWidget(CartridgeTVBoyWidget&&) = delete;
CartridgeTVBoyWidget& operator=(const CartridgeTVBoyWidget&) = delete;
CartridgeTVBoyWidget& operator=(CartridgeTVBoyWidget&&) = delete;
};
#endif

View File

@ -34,7 +34,7 @@
*/
class CartridgeTVBoy : public CartridgeEnhanced
{
friend class CartridgeMDMWidget;
friend class CartridgeTVBoyWidget;
public:
/**