Unverified Commit 2c37a363 authored by RobLoach's avatar RobLoach
Browse files

Add conf.chai loading

parent f2aa29c5
......@@ -4,13 +4,14 @@ All notable changes to [ChaiLove](https://github.com/RobLoach/ChaiLove) will be
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## 0.28.1 - Unreleased
## 0.29.0 - Unreleased
### Fixes
- Fixed `/libretro/saves` mounting
### Features
- Added `string::trim()`
- Added `string::split()`
- Adds loading of `conf.chai` for the `conf()` callback
## 0.28.0 - 2018-10-07
### Features
......
......@@ -126,8 +126,6 @@ class Sprite {
};
def loadstate(data) {
print("Load State")
print(data)
var info = from_json(data)
var num = info["number"]
......@@ -147,8 +145,6 @@ def savestate() {
// Construct the JSON data.
var data = ["number": num]
print("Save State")
print(to_json(data))
// Tell the system to save the JSON data.
return to_json(data)
......
......@@ -225,8 +225,8 @@ void retro_set_controller_port_device(unsigned port, unsigned device) {
* libretro callback; Return the amount of bytes required to save a state.
*/
size_t retro_serialize_size(void) {
// Save states will be 5 kilobytes.
return 5000;
// Save states will be 32 kilobytes.
return 32768;
}
/**
......
......@@ -58,7 +58,7 @@ bool script::loadModule(const std::string& moduleName) {
bool script::loadModuleRequire(const std::string& moduleName) {
// Check if the module has already been loaded.
std::string filename = replaceString(moduleName, ".", "/");
std::string filename = replaceString(replaceString(moduleName, ".chai", ""), ".", "/");
if (std::find(m_requiremodules.begin(), m_requiremodules.end(), filename) != m_requiremodules.end()) {
return true;
}
......@@ -438,12 +438,13 @@ script::script(const std::string& file) {
// Load the main.chai file.
::filesystem::path p(file.c_str());
std::string extension(p.extension());
loadModuleRequire("conf");
if (extension == "chailove" || extension == "chaigame") {
mainLoaded = loadModule("main.chai");
mainLoaded = loadModuleRequire("main");
} else {
// Otherwise, load the actual file.
std::string filename(p.filename());
mainLoaded = loadModule(filename);
mainLoaded = loadModuleRequire(filename);
}
}
......
global confTestLoaded = false
def conf(t) {
t.console = true
t.window.width = 640
t.window.height = 500
confTestLoaded = true
}
global failure = ""
def conf(t) {
t.console = true
t.window.width = 640
t.window.height = 500
}
def load() {
print("\n================================\n")
print("ChaiLove: Unit Testing Framework\n")
......
......@@ -42,6 +42,14 @@ assert_equal(trimSubject.trim(), "Hello World!", "string::trim()")
var splitTest = "Hello|How|Are|You"
var splitResult = splitTest.split("|")
assert_equal(splitResult[1], "How", "string::split()")
splitTest = "Rob, John, Loach"
splitTest = "Hello, World, Time"
splitResult = splitTest.split(", ")
assert_equal(splitResult[1], "John", " - commas")
assert_equal(splitResult[1], "World", " - commas")
// conf.chai
var objs = get_objects()
var confTestLoadedExists = objs["confTestLoaded"].get_type_info().bare_equal(bool_type)
assert(confTestLoadedExists, "conf.chai is loaded")
if (confTestLoadedExists) {
assert(confTestLoaded, "conf() called")
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment