mirror of https://github.com/stella-emu/stella.git
Add UI for saving ARM image.
This commit is contained in:
parent
2421292c83
commit
c66cf897ec
|
@ -22,33 +22,68 @@
|
||||||
#include "StringParser.hxx"
|
#include "StringParser.hxx"
|
||||||
#include "ScrollBarWidget.hxx"
|
#include "ScrollBarWidget.hxx"
|
||||||
#include "StringListWidget.hxx"
|
#include "StringListWidget.hxx"
|
||||||
|
#include "EditTextWidget.hxx"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
constexpr int SAVE_ARM_IMAGE_CMD = 'sarm';
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
CartridgeELFWidget::CartridgeELFWidget(GuiObject* boss, const GUI::Font& lfont,
|
CartridgeELFWidget::CartridgeELFWidget(GuiObject* boss, const GUI::Font& lfont,
|
||||||
const GUI::Font& nfont,
|
const GUI::Font& nfont,
|
||||||
int x, int y, int w, int h,
|
int x, int y, int w, int h,
|
||||||
CartridgeELF& cart)
|
CartridgeELF& cart)
|
||||||
: CartDebugWidget(boss, lfont, nfont, x, y, w, h)
|
: CartDebugWidget(boss, lfont, nfont, x, y, w, h), myCart(cart)
|
||||||
{
|
{
|
||||||
addBaseInformation(cart.myImageSize, "AtariAge", "see log below", 1);
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
const auto lineHeight = lfont.getLineHeight();
|
void CartridgeELFWidget::initialize()
|
||||||
const auto logWidth = _w - 12;
|
{
|
||||||
constexpr uInt32 visibleLogLines = 20;
|
addBaseInformation(myCart.myImageSize, "AtariAge", "see log below", 1);
|
||||||
|
|
||||||
|
const auto lineHeight = _font.getLineHeight();
|
||||||
|
const auto width = _w - 12;
|
||||||
|
constexpr uInt32 visibleLogLines = 19;
|
||||||
|
constexpr int x = 2;
|
||||||
|
|
||||||
|
int y = (9 * lineHeight) / 2;
|
||||||
|
|
||||||
const StringParser parser(
|
const StringParser parser(
|
||||||
cart.getDebugLog(),
|
myCart.getDebugLog(),
|
||||||
(logWidth - ScrollBarWidget::scrollBarWidth(lfont)) / lfont.getMaxCharWidth()
|
(width - ScrollBarWidget::scrollBarWidth(_font)) / _font.getMaxCharWidth()
|
||||||
);
|
);
|
||||||
|
|
||||||
const auto& logLines = parser.stringList();
|
const auto& logLines = parser.stringList();
|
||||||
const bool useScrollbar = logLines.size() > visibleLogLines;
|
const bool useScrollbar = logLines.size() > visibleLogLines;
|
||||||
|
|
||||||
auto logWidget = new StringListWidget(
|
auto logWidget = new StringListWidget(
|
||||||
boss, lfont, 2, (9 * lineHeight) / 2, logWidth, visibleLogLines * lineHeight, false, useScrollbar
|
_boss, _font, x, y, width, visibleLogLines * lineHeight, false, useScrollbar
|
||||||
);
|
);
|
||||||
|
|
||||||
logWidget->setEditable(false);
|
logWidget->setEditable(false);
|
||||||
logWidget->setEnabled(true);
|
logWidget->setEnabled(true);
|
||||||
logWidget->setList(logLines);
|
logWidget->setList(logLines);
|
||||||
|
|
||||||
|
y += visibleLogLines * lineHeight + lineHeight / 2;
|
||||||
|
const auto saveImageButtonWidth = 17 * _font.getMaxCharWidth();
|
||||||
|
|
||||||
|
WidgetArray wid;
|
||||||
|
|
||||||
|
const auto saveImageButton = new ButtonWidget(_boss, _font, x, y, "Save ARM image", SAVE_ARM_IMAGE_CMD);
|
||||||
|
saveImageButton->setTarget(this);
|
||||||
|
|
||||||
|
const auto imageNameEdit = new EditTextWidget(
|
||||||
|
_boss, _font, x + saveImageButtonWidth, y, width - saveImageButtonWidth, lineHeight + 2, "arm_image.bin"
|
||||||
|
);
|
||||||
|
|
||||||
|
wid.push_back(saveImageButton);
|
||||||
|
wid.push_back(imageNameEdit);
|
||||||
|
|
||||||
|
addToFocusList(wid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CartridgeELFWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
||||||
|
{
|
||||||
|
if (cmd == SAVE_ARM_IMAGE_CMD) cout << "save image" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
class CartridgeELF;
|
class CartridgeELF;
|
||||||
|
|
||||||
class CartridgeELFWidget: public CartDebugWidget
|
class CartridgeELFWidget: public CartDebugWidget, public CommandSender
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CartridgeELFWidget(GuiObject* boss, const GUI::Font& lfont,
|
CartridgeELFWidget(GuiObject* boss, const GUI::Font& lfont,
|
||||||
|
@ -32,7 +32,13 @@ class CartridgeELFWidget: public CartDebugWidget
|
||||||
|
|
||||||
~CartridgeELFWidget() override = default;
|
~CartridgeELFWidget() override = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initialize();
|
||||||
|
|
||||||
|
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
CartridgeELF& myCart;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CartridgeELFWidget() = delete;
|
CartridgeELFWidget() = delete;
|
||||||
|
|
Loading…
Reference in New Issue