Engine, adapter and tools without game data
This commit is contained in:
commit
e2ede736f3
3500 changed files with 1640229 additions and 0 deletions
57
engine/ui/casino_ui.h
Normal file
57
engine/ui/casino_ui.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <random>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "ui/ui_runtime.h"
|
||||
|
||||
namespace choco {
|
||||
|
||||
// Source Lua drives the three casino windows; this adapter supplies the two
|
||||
// native game objects and defers inter-dialog transitions until callbacks end.
|
||||
class CasinoUi {
|
||||
public:
|
||||
CasinoUi(const Vfs& assets,const StringTable& strings):runtime_(assets,strings) {}
|
||||
~CasinoUi();
|
||||
bool open(GameSim& sim,const std::filesystem::path& luaRoot,
|
||||
const std::string& building,std::string& error);
|
||||
void close();
|
||||
void mouseMove(float x,float y) {if(active_ && runtime_.attachedToCurrentVm()) runtime_.menu().mouseMove(x,y);}
|
||||
void mouseDown(float x,float y) {if(active_ && runtime_.attachedToCurrentVm()) runtime_.menu().mouseDown(x,y);}
|
||||
void mouseUp(float x,float y);
|
||||
void tick(uint32_t elapsedMs);
|
||||
bool active() const {return active_;}
|
||||
Menu& menu() {return runtime_.menu();}
|
||||
const Menu& menu() const {return runtime_.menu();}
|
||||
std::string takeResult();
|
||||
const std::array<int,4>& reels() const {return reels_;}
|
||||
const std::array<int,21>& crateValues() const {return crates_;}
|
||||
const std::array<bool,21>& crateOpened() const {return opened_;}
|
||||
const std::vector<std::string>& reelOptions() const {return reelOptions_;}
|
||||
bool spinning() const {return spinning_;}
|
||||
private:
|
||||
UiRuntime runtime_;
|
||||
GameSim* sim_=nullptr;
|
||||
lua_State* boundVm_=nullptr;
|
||||
std::string building_;
|
||||
std::string result_;
|
||||
bool active_=false,spinning_=false;
|
||||
uint32_t spinElapsed_=0;
|
||||
double payout_=0;
|
||||
int queued_=0,pending_=0;
|
||||
std::vector<std::pair<std::string,int>> savedGlobals_;
|
||||
std::array<int,4> reels_{};
|
||||
std::array<int,21> crates_{};
|
||||
std::array<bool,21> opened_{};
|
||||
std::vector<std::string> reelOptions_;
|
||||
std::mt19937 rng_{0xCA510u};
|
||||
bool installBindings(std::string& error);
|
||||
bool show(const std::string& path,std::string& error);
|
||||
bool processNext(std::string& error);
|
||||
static int binding(lua_State* L);
|
||||
};
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue