Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bundles/bundle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console = Console
3 changes: 1 addition & 2 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"name": "dev-mode",
"displayName": "Developer Mode",
"author": "deltanedas",
"description": "Lets you type into the console.\nPress [stat]F8[] to open.",
"description": "Lets you type into the console.\nPress [stat]F8[] to open on PC.\n[stat]Requires [#00aaff]DeltaNedas/ui-lib[] on mobile.",
"version": "3.3.2",
"hidden": true,
"minGameVersion": "136",
Expand Down
66 changes: 66 additions & 0 deletions scripts/button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
Copyright (c) DeltaNedas 2020

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

const ui = require("ui-lib/library");

// Android also doesn't load the logger automatically in 6.0
Vars.loadLogger();

var shown = false;

const toggle = () => {
shown = !shown;
};

/* button for poor mobile users */
ui.addButton("console", "terminal", toggle);

/* or if you don't want to start a game */
ui.addMenuButton("$console", "terminal", toggle);

// Always show console - even outside of a game
ui.addArea("console", {
init(console) {
Core.scene.add(console.bottom().left());
console.visibility = () => shown;
},
post() {},

group: null
});

ui.addTable("console", "console", console => {
console.bottom().left();
console.background(Tex.buttonTrans);
console.defaults().margin(8);

// Clear the console
console.button(Icon.refresh, Styles.cleari, 40, () => {
Vars.ui.consolefrag.clearMessages();
});

// Prompt for a line of JS
console.button(Icon.terminal, Styles.cleari, 40, () => {
Vars.ui.consolefrag.toggle();
}).marginRight(8);

console.add("$console").marginLeft(8);
});

ui.onLoad(() => {
Vars.ui.consolefrag.visibility = () => shown;
});
8 changes: 5 additions & 3 deletions scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

Vars.enableConsole = true;
if (Vars.mobile) {
require("button");
}