Add Lua scripting support to desktop emulator
- Created emulator-specific lua_game_emulator.cpp using filesystem instead of FatFS - Created lua_game_loader_emulator.cpp to scan games/lua_examples directory - Updated CMakeLists.txt to include Lua 5.4 engine and bindings - Updated to SFML 3.0 API compatibility (event handling, sprite initialization) - Updated Game class to use public members for Lua bindings - Updated GameLauncher to use std::function for lambda captures - Added continuous 60 FPS rendering for smooth display - Emulator now loads and runs all three example Lua games
This commit is contained in:
@@ -1,25 +1,33 @@
|
||||
// Copy of game_launcher.h for emulator build
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include "input_event.h"
|
||||
#include "game.h"
|
||||
|
||||
class LowLevelRenderer;
|
||||
class LowLevelGUI;
|
||||
class InputManager;
|
||||
|
||||
struct GameEntry {
|
||||
const char* name;
|
||||
const char* description;
|
||||
Game* (*factory)(uint16_t width, uint16_t height, LowLevelRenderer* renderer, LowLevelGUI* gui, InputManager* input_manager);
|
||||
std::function<Game*(uint16_t, uint16_t, LowLevelRenderer*, LowLevelGUI*, InputManager*)> factory;
|
||||
};
|
||||
|
||||
class GameLauncher {
|
||||
public:
|
||||
GameLauncher(uint16_t width, uint16_t height, LowLevelRenderer* renderer, LowLevelGUI* gui, InputManager* input_manager);
|
||||
void register_game(const char* name, const char* description, Game* (*factory)(uint16_t, uint16_t, LowLevelRenderer*, LowLevelGUI*, InputManager*));
|
||||
|
||||
void register_game(const char* name, const char* description,
|
||||
std::function<Game*(uint16_t, uint16_t, LowLevelRenderer*, LowLevelGUI*, InputManager*)> factory);
|
||||
|
||||
void draw();
|
||||
bool update(const InputEvent& event);
|
||||
Game* get_selected_game();
|
||||
void reset();
|
||||
bool is_game_selected() const { return selected_game != nullptr; }
|
||||
|
||||
private:
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
@@ -29,6 +37,7 @@ private:
|
||||
std::vector<GameEntry> games;
|
||||
int selected_index;
|
||||
Game* selected_game;
|
||||
|
||||
static const int MENU_Y_START = 60;
|
||||
static const int MENU_ITEM_HEIGHT = 40;
|
||||
static const int MENU_PADDING = 10;
|
||||
|
||||
Reference in New Issue
Block a user