Add memory to state
This commit is contained in:
parent
690df0321f
commit
3b9085545b
6 changed files with 19 additions and 11 deletions
|
@ -88,9 +88,11 @@ bool OBoy::loaded() const
|
|||
return _loaded;
|
||||
}
|
||||
|
||||
QImage OBoy::backgroundMap() const
|
||||
QImage OBoy::backgroundMap(int index) const
|
||||
{
|
||||
CAMLparam0();
|
||||
CAMLlocal1(ocaml_index);
|
||||
ocaml_index = index;
|
||||
|
||||
static value * closure_f = fetch_caml_callback("oboy_bg_map");
|
||||
if (closure_f == nullptr) {
|
||||
|
@ -98,7 +100,7 @@ QImage OBoy::backgroundMap() const
|
|||
return QImage(0, 0, QImage::Format_Indexed8);
|
||||
}
|
||||
|
||||
const auto bg_array = Caml_ba_array_val(caml_callback(*closure_f, Val_unit));
|
||||
const auto bg_array = Caml_ba_array_val(caml_callback(*closure_f, Val_int(ocaml_index)));
|
||||
const auto bg_raw_data = static_cast<caml_ba_uint8 *>(bg_array->data);
|
||||
|
||||
Q_ASSERT(bg_array->num_dims == 2);
|
||||
|
|
|
@ -10,7 +10,6 @@ class OBoy : public QObject
|
|||
Q_PROPERTY(QString name READ name CONSTANT)
|
||||
Q_PROPERTY(QString version READ version CONSTANT)
|
||||
Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
|
||||
Q_PROPERTY(QImage backgroundMap READ backgroundMap CONSTANT)
|
||||
public:
|
||||
explicit OBoy(QObject *parent = nullptr);
|
||||
|
||||
|
@ -18,7 +17,7 @@ public:
|
|||
QString version() const;
|
||||
bool loaded() const;
|
||||
Q_INVOKABLE bool load(const QString &path);
|
||||
QImage backgroundMap() const;
|
||||
QImage backgroundMap(int index) const;
|
||||
|
||||
signals:
|
||||
void loadedChanged(bool loaded);
|
||||
|
|
|
@ -17,6 +17,6 @@ QImage OImageProvider::requestImage(const QString &id, QSize *size, const QSize
|
|||
}
|
||||
Q_ASSERT(oboy->loaded());
|
||||
|
||||
QImage img = oboy->backgroundMap();
|
||||
QImage img = oboy->backgroundMap(0);
|
||||
return img;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue