Verified Commit 12cc2aa0 authored by RobLoach's avatar RobLoach
Browse files

console: Disable the console by default

parent ac5a7bae
......@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- `love.system.getOS()` now returns actual operating system name
- `love.console` an in-game console toggled with the tilde key
- Enable the console with `love.console.setEnabled(true)`
- `love.graphics.getColor()` to retrieve the active painting color
## 0.16.1 - 2018-03-12
......
......@@ -32,6 +32,7 @@
*
* - \link love::audio audio \endlink Provides an interface to output sound to the user's speakers.
* - \link love::config config \endlink Global ChaiLove configuration.
* - \link love::console config \endlink The in-game debugging console.
* - \link love::event event \endlink Manages events, like keypresses.
* - \link love::filesystem filesystem \endlink Provides an interface to the user's filesystem.
* - \link love::font font \endlink Allows you to work with fonts.
......
......@@ -14,6 +14,17 @@ namespace love {
/**
* @brief The configuration object for ChaiLove.
*
* This is set through the `conf` callback:
*
* @code
* def conf(t) {
* t.identity = "mygame"
* t.window.width = 1024
* t.window.height = 768
* t.console = false
* }
* @endcode
*/
class config {
public:
......@@ -49,11 +60,11 @@ class config {
std::map<std::string, bool> options;
/**
* @brief Toggles the in-game console.
* @brief Attach the in-game console.
*
* Set t.console = true to allow use of the in-game console.
* When `t.console = true`, will allow use of the in-game console. Use the tilde key to show.
*
* @see `love.console`
* @see love.console
*/
bool console = false;
};
......
......@@ -10,11 +10,11 @@ namespace love {
/**
* @brief In-game console for ChaiLove.
*
* Enable the console by pressing the tilde key on your keyboard. It will
* execute ChaiScript. For example, open the console with \`, and type
* `love.system.getOS()`.
* To enable the console, you must trigger: `love.console.setEnabled(true)` or toggle the console in `love.conf`.
*
* To enable the console, you must trigger: love.console.setEnabled(true)
* Once enabled, display the console by pressing the tilde key on your keyboard. Running commands will execute ChaiScript. For example, try running `love.system.getOS()`.
*
* @see love.config
*/
class console {
public:
......
......@@ -171,6 +171,7 @@ script::script(const std::string& file) {
chai.add(fun(&config::window), "window");
chai.add(fun(&config::modules), "modules");
chai.add(fun(&config::options), "options");
chai.add(fun(&config::console), "console");
// Console
chai.add(fun(&console::isEnabled), "isEnabled");
......
......@@ -31,8 +31,11 @@ class script {
* def conf(t) {
* t.window.width = 1024
* t.window.height = 768
* t.console = false
* }
* @endcode
*
* @see love.config
*/
void conf(config& t);
......
love.console.setEnabled(true)
assert_equal(love.console.isEnabled(), true, "love.console.setEnabled()")
// The console is enabled by default in main.chai -- t.console = true
assert_equal(love.console.isEnabled(), true, "love.console.getEnabled()")
// By default, it's hidden.
assert_equal(love.console.isShown(), false, "love.console.isShown()")
// Disable the console and re-test.
love.console.setEnabled(false)
assert_equal(love.console.isEnabled(), false, "love.console.setEnabled()")
global failure = ""
def conf(t) {
t.console = true;
}
def load() {
print("\n================================\n")
print("ChaiLove: Unit Testing Framework\n")
......
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