We can now load lua scripts properly

This commit is contained in:
wheremyfoodat 2023-12-16 16:36:03 +02:00
parent c57f2db6c0
commit 6386605b97
6 changed files with 73 additions and 2 deletions

View file

@ -119,6 +119,8 @@ class Emulator {
EmulatorConfig& getConfig() { return config; }
Cheats& getCheats() { return cheats; }
ServiceManager& getServiceManager() { return kernel.getServiceManager(); }
LuaManager& getLua() { return lua; }
RendererType getRendererType() const { return config.rendererType; }
Renderer* getRenderer() { return gpu.getRenderer(); }
u64 getTicks() { return cpu.getTicks(); }

View file

@ -1,4 +1,6 @@
#pragma once
#include <string>
#include "helpers.hpp"
#include "memory.hpp"
@ -36,6 +38,8 @@ class LuaManager {
void initialize();
void initializeThunks();
void loadFile(const char* path);
void loadString(const std::string& code);
void reset();
void signalEvent(LuaEvent e) {
if (haveScript) [[unlikely]] {
@ -52,6 +56,7 @@ class LuaManager {
void close() {}
void initialize() {}
void loadFile(const char* path) {}
void loadString(const std::string& code) {}
void reset() {}
void signalEvent(LuaEvent e) {}
};

View file

@ -21,7 +21,7 @@ class MainWindow : public QMainWindow {
private:
// Types of messages we might send from the GUI thread to the emulator thread
enum class MessageType { LoadROM, Reset, Pause, Resume, TogglePause, DumpRomFS, PressKey, ReleaseKey };
enum class MessageType { LoadROM, Reset, Pause, Resume, TogglePause, DumpRomFS, PressKey, ReleaseKey, LoadLuaScript };
// Tagged union representing our message queue messages
struct EmulatorMessage {
@ -35,6 +35,10 @@ class MainWindow : public QMainWindow {
struct {
u32 key;
} key;
struct {
std::string* str;
} string;
};
};
@ -72,4 +76,5 @@ class MainWindow : public QMainWindow {
void keyPressEvent(QKeyEvent* event) override;
void keyReleaseEvent(QKeyEvent* event) override;
void loadLuaScript(const std::string& code);
};