remove dynamic casting

This commit is contained in:
thrust26 2020-04-21 15:14:52 +02:00
parent 8e3e0479b1
commit 98d42cfd94
4 changed files with 17 additions and 12 deletions

View File

@ -22,7 +22,8 @@
CartridgeFA2Widget::CartridgeFA2Widget(
GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont,
int x, int y, int w, int h, CartridgeFA2& cart)
: CartridgeEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart)
: CartridgeEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart),
myCartFA2(cart)
{
int xpos = 2,
ypos = initialize();
@ -74,20 +75,18 @@ string CartridgeFA2Widget::description()
void CartridgeFA2Widget::handleCommand(CommandSender* sender,
int cmd, int data, int id)
{
CartridgeFA2& cart = dynamic_cast<CartridgeFA2&>(myCart);
switch(cmd)
{
case kFlashErase:
cart.flash(0);
myCartFA2.flash(0);
break;
case kFlashLoad:
cart.flash(1);
myCartFA2.flash(1);
break;
case kFlashSave:
cart.flash(2);
myCartFA2.flash(2);
break;
default:

View File

@ -33,9 +33,7 @@ class CartridgeFA2Widget : public CartridgeEnhancedWidget
virtual ~CartridgeFA2Widget() = default;
private:
string manufacturer() override { return "Chris D. Walton (Star Castle 2600 Arcade)"; }
string description() override;
CartridgeFA2& myCartFA2;
ButtonWidget *myFlashErase{nullptr}, *myFlashLoad{nullptr}, *myFlashSave{nullptr};
@ -45,6 +43,11 @@ class CartridgeFA2Widget : public CartridgeEnhancedWidget
kFlashSave = 'flSV'
};
private:
string manufacturer() override { return "Chris D. Walton (Star Castle 2600 Arcade)"; }
string description() override;
private:
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;

View File

@ -22,7 +22,8 @@
CartridgeWDWidget::CartridgeWDWidget(
GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont,
int x, int y, int w, int h, CartridgeWD& cart)
: CartridgeEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart)
: CartridgeEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart),
myCartWD(cart)
{
initialize();
}
@ -45,8 +46,7 @@ string CartridgeWDWidget::description()
string CartridgeWDWidget::hotspotStr(int bank, int segment, bool prefix)
{
ostringstream info;
CartridgeWD& cart = dynamic_cast<CartridgeWD&>(myCart);
CartridgeWD::BankOrg banks = cart.ourBankOrg[bank];
CartridgeWD::BankOrg banks = myCartWD.ourBankOrg[bank];
info << "(" << (prefix ? "hotspot " : "")
<< "$" << Common::Base::HEX1 << (myCart.hotspot() + bank) << ") ["

View File

@ -31,6 +31,9 @@ class CartridgeWDWidget : public CartridgeEnhancedWidget
CartridgeWD& cart);
virtual ~CartridgeWDWidget() = default;
private:
CartridgeWD& myCartWD;
private:
string manufacturer() override { return "Wickstead Design"; }