commit
d5a2c97cec
@ -167,7 +167,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
||||
/* See overflow: hidden in .CodeMirror */
|
||||
margin-bottom: -30px; margin-right: -30px;
|
||||
padding-bottom: 30px;
|
||||
height: 95%;
|
||||
height: 100%;
|
||||
outline: none; /* Prevent dragging from highlighting the element */
|
||||
position: relative;
|
||||
}
|
||||
|
||||
155
_server/CodeMirror/javascript-hint.js
Normal file
155
_server/CodeMirror/javascript-hint.js
Normal file
@ -0,0 +1,155 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
var Pos = CodeMirror.Pos;
|
||||
|
||||
function forEach(arr, f) {
|
||||
for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
|
||||
}
|
||||
|
||||
function arrayContains(arr, item) {
|
||||
if (!Array.prototype.indexOf) {
|
||||
var i = arr.length;
|
||||
while (i--) {
|
||||
if (arr[i] === item) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return arr.indexOf(item) != -1;
|
||||
}
|
||||
|
||||
function scriptHint(editor, keywords, getToken, options) {
|
||||
// Find the token at the cursor
|
||||
var cur = editor.getCursor(), token = getToken(editor, cur);
|
||||
if (/\b(?:string|comment)\b/.test(token.type)) return;
|
||||
token.state = CodeMirror.innerMode(editor.getMode(), token.state).state;
|
||||
|
||||
// If it's not a 'word-style' token, ignore the token.
|
||||
if (!/^[\w$_]*$/.test(token.string)) {
|
||||
token = {start: cur.ch, end: cur.ch, string: "", state: token.state,
|
||||
type: token.string == "." ? "property" : null};
|
||||
} else if (token.end > cur.ch) {
|
||||
token.end = cur.ch;
|
||||
token.string = token.string.slice(0, cur.ch - token.start);
|
||||
}
|
||||
|
||||
var tprop = token;
|
||||
// If it is a property, find out what it is a property of.
|
||||
while (tprop.type == "property") {
|
||||
tprop = getToken(editor, Pos(cur.line, tprop.start));
|
||||
if (tprop.string != ".") return;
|
||||
tprop = getToken(editor, Pos(cur.line, tprop.start));
|
||||
if (!context) var context = [];
|
||||
context.push(tprop);
|
||||
}
|
||||
return {list: getCompletions(token, context, keywords, options),
|
||||
from: Pos(cur.line, token.start),
|
||||
to: Pos(cur.line, token.end)};
|
||||
}
|
||||
|
||||
function javascriptHint(editor, options) {
|
||||
return scriptHint(editor, javascriptKeywords,
|
||||
function (e, cur) {return e.getTokenAt(cur);},
|
||||
options);
|
||||
};
|
||||
CodeMirror.registerHelper("hint", "javascript", javascriptHint);
|
||||
|
||||
function getCoffeeScriptToken(editor, cur) {
|
||||
// This getToken, it is for coffeescript, imitates the behavior of
|
||||
// getTokenAt method in javascript.js, that is, returning "property"
|
||||
// type and treat "." as indepenent token.
|
||||
var token = editor.getTokenAt(cur);
|
||||
if (cur.ch == token.start + 1 && token.string.charAt(0) == '.') {
|
||||
token.end = token.start;
|
||||
token.string = '.';
|
||||
token.type = "property";
|
||||
}
|
||||
else if (/^\.[\w$_]*$/.test(token.string)) {
|
||||
token.type = "property";
|
||||
token.start++;
|
||||
token.string = token.string.replace(/\./, '');
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
function coffeescriptHint(editor, options) {
|
||||
return scriptHint(editor, coffeescriptKeywords, getCoffeeScriptToken, options);
|
||||
}
|
||||
CodeMirror.registerHelper("hint", "coffeescript", coffeescriptHint);
|
||||
|
||||
var stringProps = ("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight " +
|
||||
"toUpperCase toLowerCase split concat match replace search").split(" ");
|
||||
var arrayProps = ("length concat join splice push pop shift unshift slice reverse sort indexOf " +
|
||||
"lastIndexOf every some filter forEach map reduce reduceRight ").split(" ");
|
||||
var funcProps = "prototype apply call bind".split(" ");
|
||||
var javascriptKeywords = ("break case catch class const continue debugger default delete do else export extends false finally for function " +
|
||||
"if in import instanceof new null return super switch this throw true try typeof var void while with yield").split(" ");
|
||||
var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
|
||||
"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");
|
||||
|
||||
function forAllProps(obj, callback) {
|
||||
if (!Object.getOwnPropertyNames || !Object.getPrototypeOf) {
|
||||
for (var name in obj) callback(name)
|
||||
} else {
|
||||
for (var o = obj; o; o = Object.getPrototypeOf(o))
|
||||
Object.getOwnPropertyNames(o).forEach(callback)
|
||||
}
|
||||
}
|
||||
|
||||
function getCompletions(token, context, keywords, options) {
|
||||
var found = [], start = token.string, global = options && options.globalScope || window;
|
||||
function maybeAdd(str) {
|
||||
if (str.lastIndexOf(start, 0) == 0 && !arrayContains(found, str)) found.push(str);
|
||||
}
|
||||
function gatherCompletions(obj) {
|
||||
if (typeof obj == "string") forEach(stringProps, maybeAdd);
|
||||
else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
|
||||
else if (obj instanceof Function) forEach(funcProps, maybeAdd);
|
||||
forAllProps(obj, maybeAdd)
|
||||
}
|
||||
|
||||
if (context && context.length) {
|
||||
// If this is a property, see if it belongs to some object we can
|
||||
// find in the current environment.
|
||||
var obj = context.pop(), base;
|
||||
if (obj.type && obj.type.indexOf("variable") === 0) {
|
||||
if (options && options.additionalContext)
|
||||
base = options.additionalContext[obj.string];
|
||||
if (!options || options.useGlobalScope !== false)
|
||||
base = base || global[obj.string];
|
||||
} else if (obj.type == "string") {
|
||||
base = "";
|
||||
} else if (obj.type == "atom") {
|
||||
base = 1;
|
||||
} else if (obj.type == "function") {
|
||||
if (global.jQuery != null && (obj.string == '$' || obj.string == 'jQuery') &&
|
||||
(typeof global.jQuery == 'function'))
|
||||
base = global.jQuery();
|
||||
else if (global._ != null && (obj.string == '_') && (typeof global._ == 'function'))
|
||||
base = global._();
|
||||
}
|
||||
while (base != null && context.length)
|
||||
base = base[context.pop().string];
|
||||
if (base != null) gatherCompletions(base);
|
||||
} else {
|
||||
// If not, just look in the global object and any local scope
|
||||
// (reading into JS mode internals to get at the local and global variables)
|
||||
for (var v = token.state.localVars; v; v = v.next) maybeAdd(v.name);
|
||||
for (var v = token.state.globalVars; v; v = v.next) maybeAdd(v.name);
|
||||
if (!options || options.useGlobalScope !== false)
|
||||
gatherCompletions(global);
|
||||
forEach(keywords, maybeAdd);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
});
|
||||
63
_server/CodeMirror/javascript-lint.js
Normal file
63
_server/CodeMirror/javascript-lint.js
Normal file
@ -0,0 +1,63 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
// declare global: JSHINT
|
||||
|
||||
function validator(text, options) {
|
||||
if (!window.JSHINT) {
|
||||
if (window.console) {
|
||||
window.console.error("Error: window.JSHINT not defined, CodeMirror JavaScript linting cannot run.");
|
||||
}
|
||||
return [];
|
||||
}
|
||||
if (!options.indent) // JSHint error.character actually is a column index, this fixes underlining on lines using tabs for indentation
|
||||
options.indent = 1; // JSHint default value is 4
|
||||
JSHINT(text, options, options.globals);
|
||||
var errors = JSHINT.data().errors, result = [];
|
||||
if (errors) parseErrors(errors, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeMirror.registerHelper("lint", "javascript", validator);
|
||||
|
||||
function parseErrors(errors, output) {
|
||||
for ( var i = 0; i < errors.length; i++) {
|
||||
var error = errors[i];
|
||||
if (error) {
|
||||
if (error.line <= 0) {
|
||||
if (window.console) {
|
||||
window.console.warn("Cannot display JSHint error (invalid line " + error.line + ")", error);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
var start = error.character - 1, end = start + 1;
|
||||
if (error.evidence) {
|
||||
var index = error.evidence.substring(start).search(/.\b/);
|
||||
if (index > -1) {
|
||||
end += index;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert to format expected by validation service
|
||||
var hint = {
|
||||
message: error.reason,
|
||||
severity: error.code ? (error.code.startsWith('W') ? "warning" : "error") : "error",
|
||||
from: CodeMirror.Pos(error.line - 1, start),
|
||||
to: CodeMirror.Pos(error.line - 1, end)
|
||||
};
|
||||
|
||||
output.push(hint);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
1
_server/CodeMirror/jshint.min.js
vendored
Normal file
1
_server/CodeMirror/jshint.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
73
_server/CodeMirror/lint.css
Normal file
73
_server/CodeMirror/lint.css
Normal file
@ -0,0 +1,73 @@
|
||||
/* The lint marker gutter */
|
||||
.CodeMirror-lint-markers {
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
.CodeMirror-lint-tooltip {
|
||||
background-color: #ffd;
|
||||
border: 1px solid black;
|
||||
border-radius: 4px 4px 4px 4px;
|
||||
color: black;
|
||||
font-family: monospace;
|
||||
font-size: 10pt;
|
||||
overflow: hidden;
|
||||
padding: 2px 5px;
|
||||
position: fixed;
|
||||
white-space: pre;
|
||||
white-space: pre-wrap;
|
||||
z-index: 330;
|
||||
max-width: 600px;
|
||||
opacity: 0;
|
||||
transition: opacity .4s;
|
||||
-moz-transition: opacity .4s;
|
||||
-webkit-transition: opacity .4s;
|
||||
-o-transition: opacity .4s;
|
||||
-ms-transition: opacity .4s;
|
||||
}
|
||||
|
||||
.CodeMirror-lint-mark-error, .CodeMirror-lint-mark-warning {
|
||||
background-position: left bottom;
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
|
||||
.CodeMirror-lint-mark-error {
|
||||
background-image:
|
||||
url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==")
|
||||
;
|
||||
}
|
||||
|
||||
.CodeMirror-lint-mark-warning {
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII=");
|
||||
}
|
||||
|
||||
.CodeMirror-lint-marker-error, .CodeMirror-lint-marker-warning {
|
||||
background-position: center center;
|
||||
background-repeat: no-repeat;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
vertical-align: middle;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.CodeMirror-lint-message-error, .CodeMirror-lint-message-warning {
|
||||
padding-left: 18px;
|
||||
background-position: top left;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.CodeMirror-lint-marker-error, .CodeMirror-lint-message-error {
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII=");
|
||||
}
|
||||
|
||||
.CodeMirror-lint-marker-warning, .CodeMirror-lint-message-warning {
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII=");
|
||||
}
|
||||
|
||||
.CodeMirror-lint-marker-multiple {
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC");
|
||||
background-repeat: no-repeat;
|
||||
background-position: right bottom;
|
||||
width: 100%; height: 100%;
|
||||
}
|
||||
252
_server/CodeMirror/lint.js
Normal file
252
_server/CodeMirror/lint.js
Normal file
@ -0,0 +1,252 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
var GUTTER_ID = "CodeMirror-lint-markers";
|
||||
|
||||
function showTooltip(e, content) {
|
||||
var tt = document.createElement("div");
|
||||
tt.className = "CodeMirror-lint-tooltip";
|
||||
tt.appendChild(content.cloneNode(true));
|
||||
document.body.appendChild(tt);
|
||||
|
||||
function position(e) {
|
||||
if (!tt.parentNode) return CodeMirror.off(document, "mousemove", position);
|
||||
tt.style.top = Math.max(0, e.clientY - tt.offsetHeight - 5) + "px";
|
||||
tt.style.left = (e.clientX + 5) + "px";
|
||||
}
|
||||
CodeMirror.on(document, "mousemove", position);
|
||||
position(e);
|
||||
if (tt.style.opacity != null) tt.style.opacity = 1;
|
||||
return tt;
|
||||
}
|
||||
function rm(elt) {
|
||||
if (elt.parentNode) elt.parentNode.removeChild(elt);
|
||||
}
|
||||
function hideTooltip(tt) {
|
||||
if (!tt.parentNode) return;
|
||||
if (tt.style.opacity == null) rm(tt);
|
||||
tt.style.opacity = 0;
|
||||
setTimeout(function() { rm(tt); }, 600);
|
||||
}
|
||||
|
||||
function showTooltipFor(e, content, node) {
|
||||
var tooltip = showTooltip(e, content);
|
||||
function hide() {
|
||||
CodeMirror.off(node, "mouseout", hide);
|
||||
if (tooltip) { hideTooltip(tooltip); tooltip = null; }
|
||||
}
|
||||
var poll = setInterval(function() {
|
||||
if (tooltip) for (var n = node;; n = n.parentNode) {
|
||||
if (n && n.nodeType == 11) n = n.host;
|
||||
if (n == document.body) return;
|
||||
if (!n) { hide(); break; }
|
||||
}
|
||||
if (!tooltip) return clearInterval(poll);
|
||||
}, 400);
|
||||
CodeMirror.on(node, "mouseout", hide);
|
||||
}
|
||||
|
||||
function LintState(cm, options, hasGutter) {
|
||||
this.marked = [];
|
||||
this.options = options;
|
||||
this.timeout = null;
|
||||
this.hasGutter = hasGutter;
|
||||
this.onMouseOver = function(e) { onMouseOver(cm, e); };
|
||||
this.waitingFor = 0
|
||||
}
|
||||
|
||||
function parseOptions(_cm, options) {
|
||||
if (options instanceof Function) return {getAnnotations: options};
|
||||
if (!options || options === true) options = {};
|
||||
return options;
|
||||
}
|
||||
|
||||
function clearMarks(cm) {
|
||||
var state = cm.state.lint;
|
||||
if (state.hasGutter) cm.clearGutter(GUTTER_ID);
|
||||
for (var i = 0; i < state.marked.length; ++i)
|
||||
state.marked[i].clear();
|
||||
state.marked.length = 0;
|
||||
}
|
||||
|
||||
function makeMarker(labels, severity, multiple, tooltips) {
|
||||
var marker = document.createElement("div"), inner = marker;
|
||||
marker.className = "CodeMirror-lint-marker-" + severity;
|
||||
if (multiple) {
|
||||
inner = marker.appendChild(document.createElement("div"));
|
||||
inner.className = "CodeMirror-lint-marker-multiple";
|
||||
}
|
||||
|
||||
if (tooltips != false) CodeMirror.on(inner, "mouseover", function(e) {
|
||||
showTooltipFor(e, labels, inner);
|
||||
});
|
||||
|
||||
return marker;
|
||||
}
|
||||
|
||||
function getMaxSeverity(a, b) {
|
||||
if (a == "error") return a;
|
||||
else return b;
|
||||
}
|
||||
|
||||
function groupByLine(annotations) {
|
||||
var lines = [];
|
||||
for (var i = 0; i < annotations.length; ++i) {
|
||||
var ann = annotations[i], line = ann.from.line;
|
||||
(lines[line] || (lines[line] = [])).push(ann);
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
function annotationTooltip(ann) {
|
||||
var severity = ann.severity;
|
||||
if (!severity) severity = "error";
|
||||
var tip = document.createElement("div");
|
||||
tip.className = "CodeMirror-lint-message-" + severity;
|
||||
if (typeof ann.messageHTML != 'undefined') {
|
||||
tip.innerHTML = ann.messageHTML;
|
||||
} else {
|
||||
tip.appendChild(document.createTextNode(ann.message));
|
||||
}
|
||||
return tip;
|
||||
}
|
||||
|
||||
function lintAsync(cm, getAnnotations, passOptions) {
|
||||
var state = cm.state.lint
|
||||
var id = ++state.waitingFor
|
||||
function abort() {
|
||||
id = -1
|
||||
cm.off("change", abort)
|
||||
}
|
||||
cm.on("change", abort)
|
||||
getAnnotations(cm.getValue(), function(annotations, arg2) {
|
||||
cm.off("change", abort)
|
||||
if (state.waitingFor != id) return
|
||||
if (arg2 && annotations instanceof CodeMirror) annotations = arg2
|
||||
cm.operation(function() {updateLinting(cm, annotations)})
|
||||
}, passOptions, cm);
|
||||
}
|
||||
|
||||
function startLinting(cm) {
|
||||
var state = cm.state.lint, options = state.options;
|
||||
/*
|
||||
* Passing rules in `options` property prevents JSHint (and other linters) from complaining
|
||||
* about unrecognized rules like `onUpdateLinting`, `delay`, `lintOnChange`, etc.
|
||||
*/
|
||||
var passOptions = options.options || options;
|
||||
var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint");
|
||||
if (!getAnnotations) return;
|
||||
if (options.async || getAnnotations.async) {
|
||||
lintAsync(cm, getAnnotations, passOptions)
|
||||
} else {
|
||||
var annotations = getAnnotations(cm.getValue(), passOptions, cm);
|
||||
if (!annotations) return;
|
||||
if (annotations.then) annotations.then(function(issues) {
|
||||
cm.operation(function() {updateLinting(cm, issues)})
|
||||
});
|
||||
else cm.operation(function() {updateLinting(cm, annotations)})
|
||||
}
|
||||
}
|
||||
|
||||
function updateLinting(cm, annotationsNotSorted) {
|
||||
clearMarks(cm);
|
||||
var state = cm.state.lint, options = state.options;
|
||||
|
||||
var annotations = groupByLine(annotationsNotSorted);
|
||||
|
||||
for (var line = 0; line < annotations.length; ++line) {
|
||||
var anns = annotations[line];
|
||||
if (!anns) continue;
|
||||
|
||||
var maxSeverity = null;
|
||||
var tipLabel = state.hasGutter && document.createDocumentFragment();
|
||||
|
||||
for (var i = 0; i < anns.length; ++i) {
|
||||
var ann = anns[i];
|
||||
var severity = ann.severity;
|
||||
if (!severity) severity = "error";
|
||||
maxSeverity = getMaxSeverity(maxSeverity, severity);
|
||||
|
||||
if (options.formatAnnotation) ann = options.formatAnnotation(ann);
|
||||
if (state.hasGutter) tipLabel.appendChild(annotationTooltip(ann));
|
||||
|
||||
if (ann.to) state.marked.push(cm.markText(ann.from, ann.to, {
|
||||
className: "CodeMirror-lint-mark-" + severity,
|
||||
__annotation: ann
|
||||
}));
|
||||
}
|
||||
|
||||
if (state.hasGutter)
|
||||
cm.setGutterMarker(line, GUTTER_ID, makeMarker(tipLabel, maxSeverity, anns.length > 1,
|
||||
state.options.tooltips));
|
||||
}
|
||||
if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm);
|
||||
}
|
||||
|
||||
function onChange(cm) {
|
||||
var state = cm.state.lint;
|
||||
if (!state) return;
|
||||
clearTimeout(state.timeout);
|
||||
state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500);
|
||||
}
|
||||
|
||||
function popupTooltips(annotations, e) {
|
||||
var target = e.target || e.srcElement;
|
||||
var tooltip = document.createDocumentFragment();
|
||||
for (var i = 0; i < annotations.length; i++) {
|
||||
var ann = annotations[i];
|
||||
tooltip.appendChild(annotationTooltip(ann));
|
||||
}
|
||||
showTooltipFor(e, tooltip, target);
|
||||
}
|
||||
|
||||
function onMouseOver(cm, e) {
|
||||
var target = e.target || e.srcElement;
|
||||
if (!/\bCodeMirror-lint-mark-/.test(target.className)) return;
|
||||
var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2;
|
||||
var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client"));
|
||||
|
||||
var annotations = [];
|
||||
for (var i = 0; i < spans.length; ++i) {
|
||||
var ann = spans[i].__annotation;
|
||||
if (ann) annotations.push(ann);
|
||||
}
|
||||
if (annotations.length) popupTooltips(annotations, e);
|
||||
}
|
||||
|
||||
CodeMirror.defineOption("lint", false, function(cm, val, old) {
|
||||
if (old && old != CodeMirror.Init) {
|
||||
clearMarks(cm);
|
||||
if (cm.state.lint.options.lintOnChange !== false)
|
||||
cm.off("change", onChange);
|
||||
CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver);
|
||||
clearTimeout(cm.state.lint.timeout);
|
||||
delete cm.state.lint;
|
||||
}
|
||||
|
||||
if (val) {
|
||||
var gutters = cm.getOption("gutters"), hasLintGutter = false;
|
||||
for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
|
||||
var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter);
|
||||
if (state.options.lintOnChange !== false)
|
||||
cm.on("change", onChange);
|
||||
if (state.options.tooltips != false && state.options.tooltips != "gutter")
|
||||
CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
|
||||
|
||||
startLinting(cm);
|
||||
}
|
||||
});
|
||||
|
||||
CodeMirror.defineExtension("performLint", function() {
|
||||
if (this.state.lint) startLinting(this);
|
||||
});
|
||||
});
|
||||
36
_server/CodeMirror/show-hint.css
Normal file
36
_server/CodeMirror/show-hint.css
Normal file
@ -0,0 +1,36 @@
|
||||
.CodeMirror-hints {
|
||||
position: absolute;
|
||||
z-index: 301;
|
||||
overflow: hidden;
|
||||
list-style: none;
|
||||
|
||||
margin: 0;
|
||||
padding: 2px;
|
||||
|
||||
-webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
||||
-moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
||||
box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
||||
border-radius: 3px;
|
||||
border: 1px solid silver;
|
||||
|
||||
background: white;
|
||||
font-size: 90%;
|
||||
font-family: monospace;
|
||||
|
||||
max-height: 20em;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.CodeMirror-hint {
|
||||
margin: 0;
|
||||
padding: 0 4px;
|
||||
border-radius: 2px;
|
||||
white-space: pre;
|
||||
color: black;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
li.CodeMirror-hint-active {
|
||||
background: #08f;
|
||||
color: white;
|
||||
}
|
||||
432
_server/CodeMirror/show-hint.js
Normal file
432
_server/CodeMirror/show-hint.js
Normal file
@ -0,0 +1,432 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var HINT_ELEMENT_CLASS = "CodeMirror-hint";
|
||||
var ACTIVE_HINT_ELEMENT_CLASS = "CodeMirror-hint-active";
|
||||
|
||||
// This is the old interface, kept around for now to stay
|
||||
// backwards-compatible.
|
||||
CodeMirror.showHint = function(cm, getHints, options) {
|
||||
if (!getHints) return cm.showHint(options);
|
||||
if (options && options.async) getHints.async = true;
|
||||
var newOpts = {hint: getHints};
|
||||
if (options) for (var prop in options) newOpts[prop] = options[prop];
|
||||
return cm.showHint(newOpts);
|
||||
};
|
||||
|
||||
CodeMirror.defineExtension("showHint", function(options) {
|
||||
options = parseOptions(this, this.getCursor("start"), options);
|
||||
var selections = this.listSelections()
|
||||
if (selections.length > 1) return;
|
||||
// By default, don't allow completion when something is selected.
|
||||
// A hint function can have a `supportsSelection` property to
|
||||
// indicate that it can handle selections.
|
||||
if (this.somethingSelected()) {
|
||||
if (!options.hint.supportsSelection) return;
|
||||
// Don't try with cross-line selections
|
||||
for (var i = 0; i < selections.length; i++)
|
||||
if (selections[i].head.line != selections[i].anchor.line) return;
|
||||
}
|
||||
|
||||
if (this.state.completionActive) this.state.completionActive.close();
|
||||
var completion = this.state.completionActive = new Completion(this, options);
|
||||
if (!completion.options.hint) return;
|
||||
|
||||
CodeMirror.signal(this, "startCompletion", this);
|
||||
completion.update(true);
|
||||
});
|
||||
|
||||
function Completion(cm, options) {
|
||||
this.cm = cm;
|
||||
this.options = options;
|
||||
this.widget = null;
|
||||
this.debounce = 0;
|
||||
this.tick = 0;
|
||||
this.startPos = this.cm.getCursor("start");
|
||||
this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length;
|
||||
|
||||
var self = this;
|
||||
cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); });
|
||||
}
|
||||
|
||||
var requestAnimationFrame = window.requestAnimationFrame || function(fn) {
|
||||
return setTimeout(fn, 1000/60);
|
||||
};
|
||||
var cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;
|
||||
|
||||
Completion.prototype = {
|
||||
close: function() {
|
||||
if (!this.active()) return;
|
||||
this.cm.state.completionActive = null;
|
||||
this.tick = null;
|
||||
this.cm.off("cursorActivity", this.activityFunc);
|
||||
|
||||
if (this.widget && this.data) CodeMirror.signal(this.data, "close");
|
||||
if (this.widget) this.widget.close();
|
||||
CodeMirror.signal(this.cm, "endCompletion", this.cm);
|
||||
},
|
||||
|
||||
active: function() {
|
||||
return this.cm.state.completionActive == this;
|
||||
},
|
||||
|
||||
pick: function(data, i) {
|
||||
var completion = data.list[i];
|
||||
if (completion.hint) completion.hint(this.cm, data, completion);
|
||||
else this.cm.replaceRange(getText(completion), completion.from || data.from,
|
||||
completion.to || data.to, "complete");
|
||||
CodeMirror.signal(data, "pick", completion);
|
||||
this.close();
|
||||
},
|
||||
|
||||
cursorActivity: function() {
|
||||
if (this.debounce) {
|
||||
cancelAnimationFrame(this.debounce);
|
||||
this.debounce = 0;
|
||||
}
|
||||
|
||||
var pos = this.cm.getCursor(), line = this.cm.getLine(pos.line);
|
||||
if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch ||
|
||||
pos.ch < this.startPos.ch || this.cm.somethingSelected() ||
|
||||
(pos.ch && this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) {
|
||||
this.close();
|
||||
} else {
|
||||
var self = this;
|
||||
this.debounce = requestAnimationFrame(function() {self.update();});
|
||||
if (this.widget) this.widget.disable();
|
||||
}
|
||||
},
|
||||
|
||||
update: function(first) {
|
||||
if (this.tick == null) return
|
||||
var self = this, myTick = ++this.tick
|
||||
fetchHints(this.options.hint, this.cm, this.options, function(data) {
|
||||
if (self.tick == myTick) self.finishUpdate(data, first)
|
||||
})
|
||||
},
|
||||
|
||||
finishUpdate: function(data, first) {
|
||||
if (this.data) CodeMirror.signal(this.data, "update");
|
||||
|
||||
var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
|
||||
if (this.widget) this.widget.close();
|
||||
|
||||
this.data = data;
|
||||
|
||||
if (data && data.list.length) {
|
||||
if (picked && data.list.length == 1) {
|
||||
this.pick(data, 0);
|
||||
} else {
|
||||
this.widget = new Widget(this, data);
|
||||
CodeMirror.signal(data, "shown");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function parseOptions(cm, pos, options) {
|
||||
var editor = cm.options.hintOptions;
|
||||
var out = {};
|
||||
for (var prop in defaultOptions) out[prop] = defaultOptions[prop];
|
||||
if (editor) for (var prop in editor)
|
||||
if (editor[prop] !== undefined) out[prop] = editor[prop];
|
||||
if (options) for (var prop in options)
|
||||
if (options[prop] !== undefined) out[prop] = options[prop];
|
||||
if (out.hint.resolve) out.hint = out.hint.resolve(cm, pos)
|
||||
return out;
|
||||
}
|
||||
|
||||
function getText(completion) {
|
||||
if (typeof completion == "string") return completion;
|
||||
else return completion.text;
|
||||
}
|
||||
|
||||
function buildKeyMap(completion, handle) {
|
||||
var baseMap = {
|
||||
Up: function() {handle.moveFocus(-1);},
|
||||
Down: function() {handle.moveFocus(1);},
|
||||
PageUp: function() {handle.moveFocus(-handle.menuSize() + 1, true);},
|
||||
PageDown: function() {handle.moveFocus(handle.menuSize() - 1, true);},
|
||||
Home: function() {handle.setFocus(0);},
|
||||
End: function() {handle.setFocus(handle.length - 1);},
|
||||
Enter: handle.pick,
|
||||
Tab: handle.pick,
|
||||
Esc: handle.close
|
||||
};
|
||||
var custom = completion.options.customKeys;
|
||||
var ourMap = custom ? {} : baseMap;
|
||||
function addBinding(key, val) {
|
||||
var bound;
|
||||
if (typeof val != "string")
|
||||
bound = function(cm) { return val(cm, handle); };
|
||||
// This mechanism is deprecated
|
||||
else if (baseMap.hasOwnProperty(val))
|
||||
bound = baseMap[val];
|
||||
else
|
||||
bound = val;
|
||||
ourMap[key] = bound;
|
||||
}
|
||||
if (custom)
|
||||
for (var key in custom) if (custom.hasOwnProperty(key))
|
||||
addBinding(key, custom[key]);
|
||||
var extra = completion.options.extraKeys;
|
||||
if (extra)
|
||||
for (var key in extra) if (extra.hasOwnProperty(key))
|
||||
addBinding(key, extra[key]);
|
||||
return ourMap;
|
||||
}
|
||||
|
||||
function getHintElement(hintsElement, el) {
|
||||
while (el && el != hintsElement) {
|
||||
if (el.nodeName.toUpperCase() === "LI" && el.parentNode == hintsElement) return el;
|
||||
el = el.parentNode;
|
||||
}
|
||||
}
|
||||
|
||||
function Widget(completion, data) {
|
||||
this.completion = completion;
|
||||
this.data = data;
|
||||
this.picked = false;
|
||||
var widget = this, cm = completion.cm;
|
||||
|
||||
var hints = this.hints = document.createElement("ul");
|
||||
hints.className = "CodeMirror-hints";
|
||||
this.selectedHint = data.selectedHint || 0;
|
||||
|
||||
var completions = data.list;
|
||||
for (var i = 0; i < completions.length; ++i) {
|
||||
var elt = hints.appendChild(document.createElement("li")), cur = completions[i];
|
||||
var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS);
|
||||
if (cur.className != null) className = cur.className + " " + className;
|
||||
elt.className = className;
|
||||
if (cur.render) cur.render(elt, data, cur);
|
||||
else elt.appendChild(document.createTextNode(cur.displayText || getText(cur)));
|
||||
elt.hintId = i;
|
||||
}
|
||||
|
||||
var pos = cm.cursorCoords(completion.options.alignWithWord ? data.from : null);
|
||||
var left = pos.left, top = pos.bottom, below = true;
|
||||
hints.style.left = left + "px";
|
||||
hints.style.top = top + "px";
|
||||
// If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
|
||||
var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
|
||||
var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
|
||||
(completion.options.container || document.body).appendChild(hints);
|
||||
var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
|
||||
var scrolls = hints.scrollHeight > hints.clientHeight + 1
|
||||
var startScroll = cm.getScrollInfo();
|
||||
|
||||
if (overlapY > 0) {
|
||||
var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top);
|
||||
if (curTop - height > 0) { // Fits above cursor
|
||||
hints.style.top = (top = pos.top - height) + "px";
|
||||
below = false;
|
||||
} else if (height > winH) {
|
||||
hints.style.height = (winH - 5) + "px";
|
||||
hints.style.top = (top = pos.bottom - box.top) + "px";
|
||||
var cursor = cm.getCursor();
|
||||
if (data.from.ch != cursor.ch) {
|
||||
pos = cm.cursorCoords(cursor);
|
||||
hints.style.left = (left = pos.left) + "px";
|
||||
box = hints.getBoundingClientRect();
|
||||
}
|
||||
}
|
||||
}
|
||||
var overlapX = box.right - winW;
|
||||
if (overlapX > 0) {
|
||||
if (box.right - box.left > winW) {
|
||||
hints.style.width = (winW - 5) + "px";
|
||||
overlapX -= (box.right - box.left) - winW;
|
||||
}
|
||||
hints.style.left = (left = pos.left - overlapX) + "px";
|
||||
}
|
||||
if (scrolls) for (var node = hints.firstChild; node; node = node.nextSibling)
|
||||
node.style.paddingRight = cm.display.nativeBarWidth + "px"
|
||||
|
||||
cm.addKeyMap(this.keyMap = buildKeyMap(completion, {
|
||||
moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); },
|
||||
setFocus: function(n) { widget.changeActive(n); },
|
||||
menuSize: function() { return widget.screenAmount(); },
|
||||
length: completions.length,
|
||||
close: function() { completion.close(); },
|
||||
pick: function() { widget.pick(); },
|
||||
data: data
|
||||
}));
|
||||
|
||||
if (completion.options.closeOnUnfocus) {
|
||||
var closingOnBlur;
|
||||
cm.on("blur", this.onBlur = function() { closingOnBlur = setTimeout(function() { completion.close(); }, 100); });
|
||||
cm.on("focus", this.onFocus = function() { clearTimeout(closingOnBlur); });
|
||||
}
|
||||
|
||||
cm.on("scroll", this.onScroll = function() {
|
||||
var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
|
||||
var newTop = top + startScroll.top - curScroll.top;
|
||||
var point = newTop - (window.pageYOffset || (document.documentElement || document.body).scrollTop);
|
||||
if (!below) point += hints.offsetHeight;
|
||||
if (point <= editor.top || point >= editor.bottom) return completion.close();
|
||||
hints.style.top = newTop + "px";
|
||||
hints.style.left = (left + startScroll.left - curScroll.left) + "px";
|
||||
});
|
||||
|
||||
CodeMirror.on(hints, "dblclick", function(e) {
|
||||
var t = getHintElement(hints, e.target || e.srcElement);
|
||||
if (t && t.hintId != null) {widget.changeActive(t.hintId); widget.pick();}
|
||||
});
|
||||
|
||||
CodeMirror.on(hints, "click", function(e) {
|
||||
var t = getHintElement(hints, e.target || e.srcElement);
|
||||
if (t && t.hintId != null) {
|
||||
widget.changeActive(t.hintId);
|
||||
if (completion.options.completeOnSingleClick) widget.pick();
|
||||
}
|
||||
});
|
||||
|
||||
CodeMirror.on(hints, "mousedown", function() {
|
||||
setTimeout(function(){cm.focus();}, 20);
|
||||
});
|
||||
|
||||
CodeMirror.signal(data, "select", completions[this.selectedHint], hints.childNodes[this.selectedHint]);
|
||||
return true;
|
||||
}
|
||||
|
||||
Widget.prototype = {
|
||||
close: function() {
|
||||
if (this.completion.widget != this) return;
|
||||
this.completion.widget = null;
|
||||
this.hints.parentNode.removeChild(this.hints);
|
||||
this.completion.cm.removeKeyMap(this.keyMap);
|
||||
|
||||
var cm = this.completion.cm;
|
||||
if (this.completion.options.closeOnUnfocus) {
|
||||
cm.off("blur", this.onBlur);
|
||||
cm.off("focus", this.onFocus);
|
||||
}
|
||||
cm.off("scroll", this.onScroll);
|
||||
},
|
||||
|
||||
disable: function() {
|
||||
this.completion.cm.removeKeyMap(this.keyMap);
|
||||
var widget = this;
|
||||
this.keyMap = {Enter: function() { widget.picked = true; }};
|
||||
this.completion.cm.addKeyMap(this.keyMap);
|
||||
},
|
||||
|
||||
pick: function() {
|
||||
this.completion.pick(this.data, this.selectedHint);
|
||||
},
|
||||
|
||||
changeActive: function(i, avoidWrap) {
|
||||
if (i >= this.data.list.length)
|
||||
i = avoidWrap ? this.data.list.length - 1 : 0;
|
||||
else if (i < 0)
|
||||
i = avoidWrap ? 0 : this.data.list.length - 1;
|
||||
if (this.selectedHint == i) return;
|
||||
var node = this.hints.childNodes[this.selectedHint];
|
||||
node.className = node.className.replace(" " + ACTIVE_HINT_ELEMENT_CLASS, "");
|
||||
node = this.hints.childNodes[this.selectedHint = i];
|
||||
node.className += " " + ACTIVE_HINT_ELEMENT_CLASS;
|
||||
if (node.offsetTop < this.hints.scrollTop)
|
||||
this.hints.scrollTop = node.offsetTop - 3;
|
||||
else if (node.offsetTop + node.offsetHeight > this.hints.scrollTop + this.hints.clientHeight)
|
||||
this.hints.scrollTop = node.offsetTop + node.offsetHeight - this.hints.clientHeight + 3;
|
||||
CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node);
|
||||
},
|
||||
|
||||
screenAmount: function() {
|
||||
return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1;
|
||||
}
|
||||
};
|
||||
|
||||
function applicableHelpers(cm, helpers) {
|
||||
if (!cm.somethingSelected()) return helpers
|
||||
var result = []
|
||||
for (var i = 0; i < helpers.length; i++)
|
||||
if (helpers[i].supportsSelection) result.push(helpers[i])
|
||||
return result
|
||||
}
|
||||
|
||||
function fetchHints(hint, cm, options, callback) {
|
||||
if (hint.async) {
|
||||
hint(cm, callback, options)
|
||||
} else {
|
||||
var result = hint(cm, options)
|
||||
if (result && result.then) result.then(callback)
|
||||
else callback(result)
|
||||
}
|
||||
}
|
||||
|
||||
function resolveAutoHints(cm, pos) {
|
||||
var helpers = cm.getHelpers(pos, "hint"), words
|
||||
if (helpers.length) {
|
||||
var resolved = function(cm, callback, options) {
|
||||
var app = applicableHelpers(cm, helpers);
|
||||
function run(i) {
|
||||
if (i == app.length) return callback(null)
|
||||
fetchHints(app[i], cm, options, function(result) {
|
||||
if (result && result.list.length > 0) callback(result)
|
||||
else run(i + 1)
|
||||
})
|
||||
}
|
||||
run(0)
|
||||
}
|
||||
resolved.async = true
|
||||
resolved.supportsSelection = true
|
||||
return resolved
|
||||
} else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
|
||||
return function(cm) { return CodeMirror.hint.fromList(cm, {words: words}) }
|
||||
} else if (CodeMirror.hint.anyword) {
|
||||
return function(cm, options) { return CodeMirror.hint.anyword(cm, options) }
|
||||
} else {
|
||||
return function() {}
|
||||
}
|
||||
}
|
||||
|
||||
CodeMirror.registerHelper("hint", "auto", {
|
||||
resolve: resolveAutoHints
|
||||
});
|
||||
|
||||
CodeMirror.registerHelper("hint", "fromList", function(cm, options) {
|
||||
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
|
||||
var to = CodeMirror.Pos(cur.line, token.end);
|
||||
if (token.string && /\w/.test(token.string[token.string.length - 1])) {
|
||||
var term = token.string, from = CodeMirror.Pos(cur.line, token.start);
|
||||
} else {
|
||||
var term = "", from = to;
|
||||
}
|
||||
var found = [];
|
||||
for (var i = 0; i < options.words.length; i++) {
|
||||
var word = options.words[i];
|
||||
if (word.slice(0, term.length) == term)
|
||||
found.push(word);
|
||||
}
|
||||
|
||||
if (found.length) return {list: found, from: from, to: to};
|
||||
});
|
||||
|
||||
CodeMirror.commands.autocomplete = CodeMirror.showHint;
|
||||
|
||||
var defaultOptions = {
|
||||
hint: CodeMirror.hint.auto,
|
||||
completeSingle: true,
|
||||
alignWithWord: true,
|
||||
closeCharacters: /[\s()\[\]{};:>,]/,
|
||||
closeOnUnfocus: true,
|
||||
completeOnSingleClick: true,
|
||||
container: null,
|
||||
customKeys: null,
|
||||
extraKeys: null
|
||||
};
|
||||
|
||||
CodeMirror.defineOption("hintOptions", null);
|
||||
});
|
||||
@ -181,4 +181,5 @@ fs.readdir(path, callback)
|
||||
|
||||
目前主体部分使用了 0-15,75,100
|
||||
|
||||
blockly使用 200 ,多行文本编辑器使用 300
|
||||
blockly使用 200,201
|
||||
多行文本编辑器使用 300
|
||||
@ -764,13 +764,13 @@ return code;
|
||||
*/
|
||||
|
||||
choices_s
|
||||
: '选项' ':' EvalString BGNL? '标题' EvalString? '图像' IdString? BGNL? Newline choicesContext+ BEND Newline
|
||||
: '选项' ':' EvalString? BGNL? '标题' EvalString? '图像' IdString? BGNL? Newline choicesContext+ BEND Newline
|
||||
;
|
||||
|
||||
/* choices_s
|
||||
tooltip : choices: 给用户提供选项
|
||||
helpUrl : https://ckcz123.github.io/mota-js/#/event?id=choices-%e7%bb%99%e7%94%a8%e6%88%b7%e6%8f%90%e4%be%9b%e9%80%89%e9%a1%b9
|
||||
default : ["提示文字:选择一种钥匙","流浪者","woman"]
|
||||
default : ["","流浪者","woman"]
|
||||
var title='';
|
||||
if (EvalString_1==''){
|
||||
if (IdString_0=='')title='';
|
||||
@ -779,7 +779,9 @@ if (EvalString_1==''){
|
||||
if (IdString_0=='')title='\\t['+EvalString_1+']';
|
||||
else title='\\t['+EvalString_1+','+IdString_0+']';
|
||||
}
|
||||
var code = ['{"type": "choices", "text": "',title+EvalString_0,'", "choices": [\n',
|
||||
EvalString_0 = title+EvalString_0;
|
||||
EvalString_0 = EvalString_0 ?(', "text": "'+EvalString_0+'"'):'';
|
||||
var code = ['{"type": "choices"',EvalString_0,', "choices": [\n',
|
||||
choicesContext_0,
|
||||
']},\n'].join('');
|
||||
return code;
|
||||
@ -1315,7 +1317,7 @@ ActionParser.prototype.parseAction = function() {
|
||||
choice.text,this.insertActionList(choice.action),text_choices]);
|
||||
}
|
||||
this.next = MotaActionBlocks['choices_s'].xmlText([
|
||||
this.EvalString(data.text),'','',text_choices,this.next]);
|
||||
this.isset(data.text)?this.EvalString(data.text):null,'','',text_choices,this.next]);
|
||||
break;
|
||||
case "win":
|
||||
this.next = MotaActionBlocks['win_s'].xmlText([
|
||||
|
||||
@ -19,6 +19,16 @@
|
||||
width: 435px;
|
||||
}
|
||||
|
||||
.leftTab .leftTabHeader {
|
||||
position: fixed;
|
||||
top: 15px;
|
||||
left: 15px;
|
||||
}
|
||||
|
||||
.leftTab .leftTabContent {
|
||||
padding-top: 50px;
|
||||
}
|
||||
|
||||
#appendPicSelection span {
|
||||
position: absolute;
|
||||
font-size:11px;
|
||||
@ -28,24 +38,30 @@
|
||||
|
||||
#left6 {
|
||||
left: 5px;
|
||||
/* top: 1930px; */
|
||||
top: 5px;
|
||||
z-index: 200;
|
||||
position: fixed;
|
||||
background-color: rgb(245, 245, 245);
|
||||
width: 1335px;
|
||||
height: 780px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#left6 #blocklyArea {
|
||||
float: left;
|
||||
width: 60%;
|
||||
height: 95%;
|
||||
}
|
||||
|
||||
#left6 #blocklyDiv {
|
||||
height: 480px;
|
||||
width: 940px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#left6 .CodeMirror {
|
||||
border: 1px solid #eee;
|
||||
height: 200px;
|
||||
width: 1300px;
|
||||
float: left;
|
||||
height: 95%;
|
||||
width: 35%;
|
||||
}
|
||||
#left6 #codeArea {width: 99.5%; height: 15.4em;overflow:y;/* resize:none; */}
|
||||
|
||||
@ -56,15 +72,16 @@
|
||||
z-index: 200;
|
||||
position: fixed;
|
||||
background-color: rgb(245, 245, 245);
|
||||
width: 1335px;
|
||||
height: 780px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
#left7 .CodeMirror {
|
||||
/* border-top: 1px solid black;
|
||||
border-bottom: 1px solid black; */
|
||||
border: 1px solid #eee;
|
||||
height: 700px;
|
||||
width: 940px;
|
||||
font-size: 14px;
|
||||
height: 95%;
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
.etable table,
|
||||
|
||||
@ -368,7 +368,7 @@ editor.prototype.listen = function() {
|
||||
var pos = locToPos(loc);
|
||||
editor_mode.onmode('nextChange');
|
||||
editor_mode.onmode('loc');
|
||||
editor_mode.loc();
|
||||
//editor_mode.loc();
|
||||
tip.whichShow = 1;
|
||||
return;
|
||||
}
|
||||
@ -530,7 +530,7 @@ editor.prototype.listen = function() {
|
||||
tip.infos = JSON.parse(JSON.stringify(editor.info));
|
||||
editor_mode.onmode('nextChange');
|
||||
editor_mode.onmode('emenyitem');
|
||||
editor_mode.emenyitem();
|
||||
//editor_mode.emenyitem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,6 +126,32 @@ initscript=String.raw`
|
||||
],
|
||||
"false": []
|
||||
}),
|
||||
'<label text="商店购买属性/钥匙"></label>',
|
||||
MotaActionFunctions.actionParser.parse([
|
||||
{"type": "choices", "text": "\t[老人,man]少年,你需要钥匙吗?\n我这里有大把的!",
|
||||
"choices": [
|
||||
{"text": "黄钥匙(\${9+flag:shop_times}金币)", "action": [
|
||||
{"type": "if", "condition": "status:money>=9+flag:shop_times",
|
||||
"true": [
|
||||
{"type": "setValue", "name": "status:money", "value": "status:money-(9+flag:shop_times)"},
|
||||
{"type": "setValue", "name": "item:yellowKey", "value": "item:yellowKey+1"},
|
||||
],
|
||||
"false": [
|
||||
"\t[老人,man]你的金钱不足!",
|
||||
{"type": "revisit"}
|
||||
]
|
||||
}
|
||||
]},
|
||||
{"text": "蓝钥匙(\${18+2*flag:shop_times}金币)", "action": [
|
||||
]},
|
||||
{"text": "离开", "action": [
|
||||
{"type": "exit"}
|
||||
]}
|
||||
]
|
||||
},
|
||||
{"type": "setValue", "name": "flag:shop_times", "value": "flag:shop_times+1"},
|
||||
{"type": "revisit"}
|
||||
], 'event'),
|
||||
'<label text="战前剧情"></label>',
|
||||
MotaActionFunctions.actionParser.parse({
|
||||
"trigger": "action",
|
||||
@ -180,7 +206,9 @@ initscript=String.raw`
|
||||
getCategory(name).innerHTML = toolboxObj[name].join(toolboxgap);
|
||||
}
|
||||
|
||||
var workspace = Blockly.inject('blocklyDiv',{
|
||||
var blocklyArea = document.getElementById('blocklyArea');
|
||||
var blocklyDiv = document.getElementById('blocklyDiv');
|
||||
var workspace = Blockly.inject(blocklyDiv,{
|
||||
media: '_server/blockly/media/',
|
||||
toolbox: document.getElementById('toolbox'),
|
||||
zoom:{
|
||||
@ -192,7 +220,16 @@ initscript=String.raw`
|
||||
scaleSpeed: 1.08
|
||||
},
|
||||
trashcan: false,
|
||||
});
|
||||
});
|
||||
|
||||
var onresize = function(e) {
|
||||
blocklyDiv.style.width = blocklyArea.offsetWidth + 'px';
|
||||
blocklyDiv.style.height = blocklyArea.offsetHeight + 'px';
|
||||
};
|
||||
window.addEventListener('resize', onresize, false);
|
||||
onresize();
|
||||
Blockly.svgResize(workspace);
|
||||
|
||||
|
||||
var doubleClickCheck=[[0,'abc']];
|
||||
function omitedcheckUpdateFunction(event) {
|
||||
@ -336,8 +373,21 @@ editor_blockly.import = function(id_){
|
||||
return true;
|
||||
}
|
||||
|
||||
editor_blockly.show = function(){document.getElementById('left6').style='';}
|
||||
editor_blockly.hide = function(){document.getElementById('left6').style='z-index:-1;opacity: 0;';}
|
||||
var blocklyWidgetDiv = document.getElementsByClassName('blocklyWidgetDiv');
|
||||
editor_blockly.show = function(){
|
||||
document.getElementById('left6').style='';
|
||||
for(var ii =0,node;node=blocklyWidgetDiv[ii];ii++){
|
||||
node.style.zIndex = 201;
|
||||
node.style.opacity = '';
|
||||
}
|
||||
}
|
||||
editor_blockly.hide = function(){
|
||||
document.getElementById('left6').style='z-index:-1;opacity: 0;';
|
||||
for(var ii =0,node;node=blocklyWidgetDiv[ii];ii++){
|
||||
node.style.zIndex = -1;
|
||||
node.style.opacity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
editor_blockly.cancel = function(){
|
||||
editor_blockly.id='';
|
||||
|
||||
@ -149,10 +149,10 @@ editor_file = function(editor, callback){
|
||||
saveSetting('maps',[["add","['"+idnum+"']",{'cls': info.images, 'id':id}]],tempcallback);
|
||||
saveSetting('icons',[["add","['"+info.images+"']['"+id+"']",info.y]],tempcallback);
|
||||
if(info.images==='items'){
|
||||
saveSetting('items',[["change"/*其实应该是add*/,"['items']['"+id+"']",editor_file.comment.items_template]],function(err){if(err){printe(err);throw(err)}});
|
||||
saveSetting('items',[["add","['items']['"+id+"']",editor_file.comment.items_template]],function(err){if(err){printe(err);throw(err)}});
|
||||
}
|
||||
if(info.images==='enemys' || info.images==='enemy48'){
|
||||
saveSetting('enemys',[["change"/*其实应该是add*/,"['"+id+"']",editor_file.comment.enemys_template]],function(err){if(err){printe(err);throw(err)}});
|
||||
saveSetting('enemys',[["add","['"+id+"']",editor_file.comment.enemys_template]],function(err){if(err){printe(err);throw(err)}});
|
||||
}
|
||||
|
||||
callback(null);
|
||||
@ -174,33 +174,47 @@ editor_file = function(editor, callback){
|
||||
});
|
||||
saveSetting('items',actionList,function (err) {
|
||||
callback([
|
||||
{'items':(function(){
|
||||
var locObj=Object.assign({},editor.core.items.items[id]);
|
||||
Object.keys(editor_file.comment.items.items).forEach(function(v){
|
||||
if (!isset(editor.core.items.items[id][v]))
|
||||
/* locObj[v]=editor.core.items.items[id][v];
|
||||
else */
|
||||
locObj[v]=null;
|
||||
(function(){
|
||||
var locObj_ ={};
|
||||
Object.keys(editor_file.comment.items).forEach(function(v){
|
||||
if (isset(editor.core.items[v][id]) && v!=='items')
|
||||
locObj_[v]=editor.core.items[v][id];
|
||||
else
|
||||
locObj_[v]=null;
|
||||
});
|
||||
return locObj;
|
||||
locObj_['items']=(function(){
|
||||
var locObj=Object.assign({},editor.core.items.items[id]);
|
||||
Object.keys(editor_file.comment.items.items).forEach(function(v){
|
||||
if (!isset(editor.core.items.items[id][v]))
|
||||
locObj[v]=null;
|
||||
});
|
||||
return locObj;
|
||||
})();
|
||||
return locObj_;
|
||||
})(),
|
||||
'itemEffect':editor.core.items.itemEffect[id],'itemEffectTip':editor.core.items.itemEffectTip[id]},
|
||||
editor_file.comment.items,
|
||||
err]);
|
||||
});
|
||||
} else {
|
||||
callback([
|
||||
{'items':(function(){
|
||||
var locObj=Object.assign({},editor.core.items.items[id]);
|
||||
Object.keys(editor_file.comment.items.items).forEach(function(v){
|
||||
if (!isset(editor.core.items.items[id][v]))
|
||||
/* locObj[v]=editor.core.items.items[id][v];
|
||||
else */
|
||||
locObj[v]=null;
|
||||
(function(){
|
||||
var locObj_ ={};
|
||||
Object.keys(editor_file.comment.items).forEach(function(v){
|
||||
if (isset(editor.core.items[v][id]) && v!=='items')
|
||||
locObj_[v]=editor.core.items[v][id];
|
||||
else
|
||||
locObj_[v]=null;
|
||||
});
|
||||
return locObj;
|
||||
locObj_['items']=(function(){
|
||||
var locObj=Object.assign({},editor.core.items.items[id]);
|
||||
Object.keys(editor_file.comment.items.items).forEach(function(v){
|
||||
if (!isset(editor.core.items.items[id][v]))
|
||||
locObj[v]=null;
|
||||
});
|
||||
return locObj;
|
||||
})();
|
||||
return locObj_;
|
||||
})(),
|
||||
'itemEffect':editor.core.items.itemEffect[id],'itemEffectTip':editor.core.items.itemEffectTip[id]},
|
||||
editor_file.comment.items,
|
||||
null]);
|
||||
}
|
||||
@ -253,6 +267,49 @@ editor_file = function(editor, callback){
|
||||
}
|
||||
//callback([obj,commentObj,err:String])
|
||||
|
||||
editor_file.editMapBlocksInfo = function(idnum,actionList,callback){
|
||||
/*actionList:[
|
||||
["change","['events']",["\t[老人,magician]领域、夹击。\n请注意领域怪需要设置value为伤害数值,可参见样板中初级巫师的写法。"]],
|
||||
["change","['afterBattle']",null],
|
||||
]
|
||||
为[]时只查询不修改
|
||||
*/
|
||||
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
|
||||
if (isset(actionList) && actionList.length > 0){
|
||||
actionList.forEach(function (value) {
|
||||
value[1] = "['"+idnum+"']"+value[1];
|
||||
});
|
||||
saveSetting('maps',actionList,function (err) {
|
||||
callback([
|
||||
(function(){
|
||||
var locObj=Object.assign({},editor.core.maps.blocksInfo[idnum]);
|
||||
Object.keys(editor_file.comment.maps).forEach(function(v){
|
||||
if (!isset(editor.core.maps.blocksInfo[idnum][v]))
|
||||
locObj[v]=null;
|
||||
});
|
||||
locObj.idnum = idnum;
|
||||
return locObj;
|
||||
})(),
|
||||
editor_file.comment.maps,
|
||||
null]);
|
||||
});
|
||||
} else {
|
||||
callback([
|
||||
(function(){
|
||||
var locObj=Object.assign({},editor.core.maps.blocksInfo[idnum]);
|
||||
Object.keys(editor_file.comment.maps).forEach(function(v){
|
||||
if (!isset(editor.core.maps.blocksInfo[idnum][v]))
|
||||
locObj[v]=null;
|
||||
});
|
||||
locObj.idnum = idnum;
|
||||
return locObj;
|
||||
})(),
|
||||
editor_file.comment.maps,
|
||||
null]);
|
||||
}
|
||||
}
|
||||
//callback([obj,commentObj,err:String])
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
editor_file.editLoc = function(x,y,actionList,callback){
|
||||
@ -479,13 +536,9 @@ editor_file = function(editor, callback){
|
||||
var saveSetting = function(file,actionList,callback) {
|
||||
//console.log(file);
|
||||
//console.log(actionList);
|
||||
actionList.forEach(function (value) {
|
||||
if (value[0]!='change' && file!='icons' && file!='maps') {printe('目前只支持change');throw('目前只支持change')};
|
||||
});
|
||||
|
||||
if (file=='icons') {
|
||||
actionList.forEach(function (value) {
|
||||
if (value[0]!='add')return;
|
||||
eval("icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1"+value[1]+'='+JSON.stringify(value[2]));
|
||||
});
|
||||
var datastr='icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 = \n';
|
||||
@ -497,7 +550,6 @@ editor_file = function(editor, callback){
|
||||
}
|
||||
if (file=='maps') {
|
||||
actionList.forEach(function (value) {
|
||||
if (value[0]!='add')return;
|
||||
eval("maps_90f36752_8815_4be8_b32b_d7fad1d0542e"+value[1]+'='+JSON.stringify(value[2]));
|
||||
});
|
||||
var datastr='maps_90f36752_8815_4be8_b32b_d7fad1d0542e = \n';
|
||||
@ -517,7 +569,6 @@ editor_file = function(editor, callback){
|
||||
}
|
||||
if (file=='items') {
|
||||
actionList.forEach(function (value) {
|
||||
if (value[0]!='change')return;
|
||||
eval("items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a"+value[1]+'='+JSON.stringify(value[2]));
|
||||
});
|
||||
var datastr='items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = \n';
|
||||
@ -529,7 +580,6 @@ editor_file = function(editor, callback){
|
||||
}
|
||||
if (file=='enemys') {
|
||||
actionList.forEach(function (value) {
|
||||
if (value[0]!='change')return;
|
||||
eval("enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80"+value[1]+'='+JSON.stringify(value[2]));
|
||||
});
|
||||
var datastr='enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80 = \n';
|
||||
@ -546,7 +596,6 @@ editor_file = function(editor, callback){
|
||||
}
|
||||
if (file=='data') {
|
||||
actionList.forEach(function (value) {
|
||||
if (value[0]!='change')return;
|
||||
eval("data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d"+value[1]+'='+JSON.stringify(value[2]));
|
||||
});
|
||||
var datastr='data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = \n';
|
||||
@ -558,7 +607,6 @@ editor_file = function(editor, callback){
|
||||
}
|
||||
if (file=='functions') {
|
||||
actionList.forEach(function (value) {
|
||||
if (value[0]!='change')return;
|
||||
eval("fmap[fobj"+value[1]+']='+JSON.stringify(value[2]));
|
||||
});
|
||||
var fraw = fjson;
|
||||
@ -574,7 +622,6 @@ editor_file = function(editor, callback){
|
||||
}
|
||||
if (file=='floors') {
|
||||
actionList.forEach(function (value) {
|
||||
if (value[0]!='change')return;
|
||||
eval("editor.currentFloorData"+value[1]+'='+JSON.stringify(value[2]));
|
||||
});
|
||||
editor_file.saveFloorFile(callback);
|
||||
|
||||
@ -182,6 +182,8 @@ editor_mode.prototype.doActionList = function(mode,actionList){
|
||||
editor.file.editEnemy(editor_mode.info.id,actionList,function(objs_){/*console.log(objs_);*/if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
|
||||
} else if (editor_mode.info.images=='items'){
|
||||
editor.file.editItem(editor_mode.info.id,actionList,function(objs_){/*console.log(objs_);*/if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
|
||||
} else {
|
||||
editor.file.editMapBlocksInfo(editor_mode.info.idnum,actionList,function(objs_){/*console.log(objs_);*/if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
|
||||
}
|
||||
break;
|
||||
case 'floor':
|
||||
@ -256,8 +258,9 @@ editor_mode.prototype.emenyitem = function(callback){
|
||||
} else if (editor_mode.info.images=='items'){
|
||||
editor.file.editItem(editor_mode.info.id,[],function(objs_){objs=objs_;/*console.log(objs_)*/});
|
||||
} else {
|
||||
document.getElementById('table_a3f03d4c_55b8_4ef6_b362_b345783acd72').innerHTML='';
|
||||
return;
|
||||
/* document.getElementById('table_a3f03d4c_55b8_4ef6_b362_b345783acd72').innerHTML='';
|
||||
return; */
|
||||
editor.file.editMapBlocksInfo(editor_mode.info.idnum,[],function(objs_){objs=objs_;/*console.log(objs_)*/});
|
||||
}
|
||||
//只查询不修改时,内部实现不是异步的,所以可以这么写
|
||||
var tableinfo=editor_mode.objToTable(objs[0],objs[1]);
|
||||
|
||||
@ -5,9 +5,22 @@ var editor_multi = {};
|
||||
var codeEditor = CodeMirror.fromTextArea(document.getElementById("multiLineCode"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
indentUnit: 4,
|
||||
tabSize: 4,
|
||||
indentWithTabs: true,
|
||||
smartIndent: true,
|
||||
mode: {name: "javascript", json: true, globalVars: true},
|
||||
lineWrapping: true,
|
||||
continueComments: "Enter",
|
||||
extraKeys: {"Ctrl-Q": "toggleComment"}
|
||||
gutters: ["CodeMirror-lint-markers"],
|
||||
lint: true,
|
||||
extraKeys: {"Ctrl-Q": "toggleComment"},
|
||||
});
|
||||
|
||||
codeEditor.on("keyup", function (cm, event) {
|
||||
if ((event.keyCode >= 65 && event.keyCode<=90) || (event.keyCode>=49 && event.keyCode<=57) || event.keyCode==190) {
|
||||
CodeMirror.commands.autocomplete(cm, null, {completeSingle: false});
|
||||
}
|
||||
});
|
||||
|
||||
editor_multi.id='';
|
||||
|
||||
49
editor.html
49
editor.html
@ -4,6 +4,8 @@
|
||||
<meta charset="utf-8">
|
||||
<link href="_server/css/editor.css" rel="stylesheet">
|
||||
<link href="_server/CodeMirror/codemirror.css" rel="stylesheet">
|
||||
<link href="_server/CodeMirror/show-hint.css" rel="stylesheet">
|
||||
<link href="_server/CodeMirror/lint.css" rel="stylesheet">
|
||||
<link href="_server/css/editor_mode.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
@ -35,8 +37,9 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="left1" class='leftTab' style="z-index:-1;opacity: 0;"><div ><!-- appendpic -->
|
||||
<h3>追加素材</h3>
|
||||
<div id="left1" class='leftTab' style="z-index:-1;opacity: 0;"><!-- appendpic -->
|
||||
<h3 class="leftTabHeader">追加素材</h3>
|
||||
<div class="leftTabContent">
|
||||
<p>
|
||||
<input id="selectFileBtn" type="button" value="导入文件到画板"/>
|
||||
<select id="selectAppend"></select><!-- ["terrains", "animates", "enemys", "enemy48", "items", "npcs", "npc48"] -->
|
||||
@ -55,9 +58,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</div></div>
|
||||
<div id="left2" class='leftTab' style="z-index:-1;opacity: 0;"><div><!-- loc -->
|
||||
<h3>地图选点 <button onclick="editor.mode.onmode('save')">save</button></h3>
|
||||
<p id='pos_a6771a78_a099_417c_828f_0a24851ebfce'>0,0</p>
|
||||
<div id="left2" class='leftTab' style="z-index:-1;opacity: 0;"><!-- loc -->
|
||||
<h3 class="leftTabHeader">地图选点 <button onclick="editor.mode.onmode('save')">save</button></h3>
|
||||
<div class="leftTabContent">
|
||||
<p id='pos_a6771a78_a099_417c_828f_0a24851ebfce' style="margin-left: 15px">0,0</p>
|
||||
<div class='etable'>
|
||||
<table>
|
||||
<tbody id='table_3d846fc4_7644_44d1_aa04_433d266a73df'>
|
||||
@ -66,8 +70,9 @@
|
||||
</table>
|
||||
</div>
|
||||
</div></div>
|
||||
<div id="left3" class='leftTab' style="z-index:-1;opacity: 0;"><div><!-- emenyitem -->
|
||||
<h3>图块属性 <button onclick="editor.mode.onmode('save')">save</button></h3>
|
||||
<div id="left3" class='leftTab' style="z-index:-1;opacity: 0;"><!-- emenyitem -->
|
||||
<h3 class="leftTabHeader">图块属性 <button onclick="editor.mode.onmode('save')">save</button></h3>
|
||||
<div class="leftTabContent">
|
||||
<div id='newIdIdnum'><!-- id and idnum -->
|
||||
<input placeholder="输入新id"/>
|
||||
<input placeholder="输入新idnum"/>
|
||||
@ -83,8 +88,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div></div>
|
||||
<div id="left4" class='leftTab' style="z-index:-1;opacity: 0;"><div><!-- floor -->
|
||||
<h3>楼层属性 <button onclick="editor.mode.onmode('save')">save</button></h3>
|
||||
<div id="left4" class='leftTab' style="z-index:-1;opacity: 0;"><!-- floor -->
|
||||
<h3 class="leftTabHeader">楼层属性 <button onclick="editor.mode.onmode('save')">save</button></h3>
|
||||
<div class="leftTabContent">
|
||||
<div class='etable'>
|
||||
<table>
|
||||
<tbody id='table_4a3b1b09_b2fb_4bdf_b9ab_9f4cdac14c74'>
|
||||
@ -93,8 +99,9 @@
|
||||
</table>
|
||||
</div>
|
||||
</div></div>
|
||||
<div id="left5" class='leftTab' style="z-index:-1;opacity: 0;"><div><!-- tower -->
|
||||
<h3>全塔属性 <button onclick="editor.mode.onmode('save')">save</button></h3>
|
||||
<div id="left5" class='leftTab' style="z-index:-1;opacity: 0;"><!-- tower -->
|
||||
<h3 class="leftTabHeader">全塔属性 <button onclick="editor.mode.onmode('save')">save</button></h3>
|
||||
<div class="leftTabContent">
|
||||
<div class='etable'>
|
||||
<table>
|
||||
<tbody id='table_b6a03e4c_5968_4633_ac40_0dfdd2c9cde5'>
|
||||
@ -103,7 +110,7 @@
|
||||
</table>
|
||||
</div>
|
||||
</div></div>
|
||||
<div id="left6" class='leftTab' style="z-index:-1;opacity: 0;"><div><!-- eventsEditor -->
|
||||
<div id="left6" class='leftTab' style="z-index:-1;opacity: 0;"><div style="position: relative; height: 95%"><!-- eventsEditor -->
|
||||
<h3>事件编辑器
|
||||
<button onclick="editor_blockly.showXML()">Show XML</button>
|
||||
<button onclick="editor_blockly.runCode()">console.log(obj=code)</button>
|
||||
@ -127,18 +134,19 @@
|
||||
<category name="template"></category>
|
||||
</xml>
|
||||
</h3>
|
||||
<div style="position: relative;">
|
||||
<div id="blocklyDiv"></div>
|
||||
<div style="position: relative;height: 100%">
|
||||
<div id="blocklyArea"><div id="blocklyDiv"></div></div>
|
||||
<textarea id="codeArea" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div></div>
|
||||
<div id="left7" style="z-index:-1;opacity: 0;"><div><!-- 多行文本编辑器 -->
|
||||
<div id="left7" style="z-index:-1;opacity: 0;"><!-- 多行文本编辑器 -->
|
||||
<button onclick="editor_multi.confirm()">confirm</button>
|
||||
<button onclick="editor_multi.cancel()">cancel</button>
|
||||
<textarea id="multiLineCode" name="multiLineCode"></textarea>
|
||||
</div></div>
|
||||
<div id="left8" class='leftTab' style="z-index:-1;opacity: 0;"><div><!-- functions -->
|
||||
<h3>脚本编辑 <button onclick="editor.mode.onmode('save')">save</button></h3>
|
||||
</div>
|
||||
<div id="left8" class='leftTab' style="z-index:-1;opacity: 0;"><!-- functions -->
|
||||
<h3 class="leftTabHeader">脚本编辑 <button onclick="editor.mode.onmode('save')">save</button></h3>
|
||||
<div class="leftTabContent">
|
||||
<div class='etable'>
|
||||
<table>
|
||||
<tbody id='table_e260a2be_5690_476a_b04e_dacddede78b3'>
|
||||
@ -387,6 +395,11 @@ main.init('editor', function() {
|
||||
<script src="_server/blockly/zh-hans.js"></script>
|
||||
<script src='_server/editor_blockly.js'></script>
|
||||
<script src="_server/CodeMirror/codeMirror.bundle.min.js"></script>
|
||||
<script src="_server/CodeMirror/show-hint.js"></script>
|
||||
<script src="_server/CodeMirror/javascript-hint.js"></script>
|
||||
<script src="_server/CodeMirror/jshint.min.js"></script>
|
||||
<script src="_server/CodeMirror/lint.js"></script>
|
||||
<script src="_server/CodeMirror/javascript-lint.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -1382,7 +1382,7 @@ control.prototype.resumeReplay = function () {
|
||||
control.prototype.forwardReplay = function () {
|
||||
if (!core.status.replay.replaying) return;
|
||||
core.status.replay.speed = parseInt(10*core.status.replay.speed + 1)/10;
|
||||
if (core.status.replay.speed>2.5) core.status.replay.speed=2.5;
|
||||
if (core.status.replay.speed>3.0) core.status.replay.speed=3.0;
|
||||
core.drawTip("x"+core.status.replay.speed+"倍");
|
||||
}
|
||||
|
||||
@ -1440,7 +1440,7 @@ control.prototype.replay = function () {
|
||||
core.useItem(itemId, function () {
|
||||
core.replay();
|
||||
});
|
||||
}, 750);
|
||||
}, 750 / Math.sqrt(core.status.replay.speed));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1458,7 +1458,7 @@ control.prototype.replay = function () {
|
||||
core.changeFloor(floorId, stair, null, null, function () {
|
||||
core.replay();
|
||||
});
|
||||
}, 750);
|
||||
}, 750 / Math.sqrt(core.status.replay.speed));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1491,7 +1491,7 @@ control.prototype.replay = function () {
|
||||
core.status.event.selection = parseInt(selections.shift());
|
||||
core.events.openShop(shopId, false);
|
||||
|
||||
}, 750);
|
||||
}, 750 / Math.sqrt(core.status.replay.speed));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,6 +281,8 @@ core.prototype.init = function (coreData, callback) {
|
||||
core.setRequestAnimationFrame();
|
||||
core.showStartAnimate();
|
||||
|
||||
|
||||
|
||||
if (core.isset(functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.plugins))
|
||||
core.plugin = new functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.plugins.plugin();
|
||||
|
||||
|
||||
@ -71,6 +71,10 @@ events.prototype.getEvents = function (eventName) {
|
||||
return this.events[eventName];
|
||||
}
|
||||
|
||||
events.prototype.initGame = function () {
|
||||
return this.eventdata.initGame();
|
||||
}
|
||||
|
||||
////// 游戏开始事件 //////
|
||||
events.prototype.startGame = function (hard) {
|
||||
|
||||
@ -555,7 +559,7 @@ events.prototype.doAction = function() {
|
||||
core.status.route.push("choices:"+index);
|
||||
core.events.insertAction(data.choices[index].action);
|
||||
core.events.doAction();
|
||||
}, 750)
|
||||
}, 750 / Math.sqrt(core.status.replay.speed))
|
||||
}
|
||||
else {
|
||||
core.stopReplay();
|
||||
|
||||
253
libs/items.js
253
libs/items.js
@ -7,32 +7,13 @@ items.prototype.init = function () {
|
||||
this.items = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.items;
|
||||
this.itemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.itemEffect;
|
||||
this.itemEffectTip = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.itemEffectTip;
|
||||
this.useItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.useItemEffect;
|
||||
this.canUseItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.canUseItemEffect;
|
||||
//delete(items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a);
|
||||
}
|
||||
|
||||
////// 获得所有道具 //////
|
||||
items.prototype.getItems = function () {
|
||||
// 大黄门钥匙?钥匙盒?
|
||||
if (core.flags.bigKeyIsBox)
|
||||
this.items['bigKey'] = {'cls': 'items', 'name': '钥匙盒'};
|
||||
// 面前的墙?四周的墙?
|
||||
if (core.flags.pickaxeFourDirections)
|
||||
this.items.pickaxe.text = "可以破坏勇士四周的墙";
|
||||
if (core.flags.bombFourDirections)
|
||||
this.items.bomb.text = "可以炸掉勇士四周的怪物";
|
||||
if (core.flags.equipment) {
|
||||
this.items.sword1 = {'cls': 'constants', 'name': '铁剑', 'text': '一把很普通的铁剑,攻击+'+core.values.sword1};
|
||||
this.items.sword2 = {'cls': 'constants', 'name': '银剑', 'text': '一把很普通的银剑,攻击+'+core.values.sword2};
|
||||
this.items.sword3 = {'cls': 'constants', 'name': '骑士剑', 'text': '一把很普通的骑士剑,攻击+'+core.values.sword3};
|
||||
this.items.sword4 = {'cls': 'constants', 'name': '圣剑', 'text': '一把很普通的圣剑,攻击+'+core.values.sword4};
|
||||
this.items.sword5 = {'cls': 'constants', 'name': '神圣剑', 'text': '一把很普通的神圣剑,攻击+'+core.values.sword5};
|
||||
this.items.shield1 = {'cls': 'constants', 'name': '铁盾', 'text': '一个很普通的铁盾,防御+'+core.values.shield1};
|
||||
this.items.shield2 = {'cls': 'constants', 'name': '银盾', 'text': '一个很普通的银盾,防御+'+core.values.shield2};
|
||||
this.items.shield3 = {'cls': 'constants', 'name': '骑士盾', 'text': '一个很普通的骑士盾,防御+'+core.values.shield3};
|
||||
this.items.shield4 = {'cls': 'constants', 'name': '圣盾', 'text': '一个很普通的圣盾,防御+'+core.values.shield4};
|
||||
this.items.shield5 = {'cls': 'constants', 'name': '神圣盾', 'text': '一个很普通的神圣盾,防御+'+core.values.shield5};
|
||||
}
|
||||
|
||||
return this.items;
|
||||
}
|
||||
|
||||
@ -66,72 +47,8 @@ items.prototype.useItem = function (itemId, callback) {
|
||||
}
|
||||
var itemCls = core.material.items[itemId].cls;
|
||||
|
||||
if (itemId=='book') core.ui.drawBook(0);
|
||||
if (itemId=='fly') core.ui.drawFly(core.status.hero.flyRange.indexOf(core.status.floorId));
|
||||
if (itemId == 'earthquake' || itemId == 'bomb' || itemId == 'pickaxe' || itemId=='icePickaxe'
|
||||
|| itemId == 'snow' || itemId == 'hammer' || itemId=='bigKey') {
|
||||
// 消除当前层的某些块
|
||||
core.removeBlockByIds(core.status.floorId, core.status.event.data);
|
||||
core.drawMap(core.status.floorId, function () {
|
||||
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
|
||||
core.updateFg();
|
||||
core.drawTip(core.material.items[itemId].name + "使用成功");
|
||||
|
||||
if (itemId == 'bomb' || itemId == 'hammer')
|
||||
core.events.afterUseBomb();
|
||||
});
|
||||
}
|
||||
if (itemId == 'centerFly') {
|
||||
// 对称飞
|
||||
core.clearMap('hero', 0, 0, 416, 416);
|
||||
core.setHeroLoc('x', core.status.event.data.x);
|
||||
core.setHeroLoc('y', core.status.event.data.y);
|
||||
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
|
||||
core.drawTip(core.material.items[itemId].name + "使用成功");
|
||||
}
|
||||
if (itemId == 'upFly' || itemId == 'downFly') {
|
||||
// 上楼器/下楼器
|
||||
core.changeFloor(core.status.event.data.id, null, {'direction': core.status.hero.loc.direction, 'x': core.status.event.data.x, 'y': core.status.event.data.y}, null, function (){
|
||||
core.drawTip(core.material.items[itemId].name + "使用成功");
|
||||
core.replay();
|
||||
});
|
||||
}
|
||||
if (itemId == 'poisonWine') core.setFlag('poison', false);
|
||||
if (itemId == 'weakWine') {
|
||||
core.setFlag('weak', false);
|
||||
core.status.hero.atk += core.values.weakValue;
|
||||
core.status.hero.def += core.values.weakValue;
|
||||
}
|
||||
if (itemId == 'curseWine') core.setFlag('curse', false);
|
||||
if (itemId == 'superWine') {
|
||||
core.setFlag('poison', false);
|
||||
if (core.hasFlag('weak')) {
|
||||
core.setFlag('weak', false);
|
||||
core.status.hero.atk += core.values.weakValue;
|
||||
core.status.hero.def += core.values.weakValue;
|
||||
}
|
||||
core.setFlag('curse', false);
|
||||
}
|
||||
|
||||
// 剑
|
||||
if (itemId.indexOf("sword")==0) {
|
||||
var now=core.getFlag('sword', 'sword0'); // 当前装备剑的ID
|
||||
core.status.hero.atk -= core.values[now];
|
||||
core.setItem(now, 1);
|
||||
core.status.hero.atk += core.values[itemId];
|
||||
core.setItem(itemId, 0);
|
||||
core.setFlag('sword', itemId);
|
||||
core.drawTip("已装备"+core.material.items[itemId].name);
|
||||
}
|
||||
// 盾
|
||||
if (itemId.indexOf("shield")==0) {
|
||||
var now=core.getFlag('shield', 'shield0');
|
||||
core.status.hero.def -= core.values[now];
|
||||
core.setItem(now, 1);
|
||||
core.status.hero.def += core.values[itemId];
|
||||
core.setItem(itemId, 0);
|
||||
core.setFlag('shield', itemId);
|
||||
core.drawTip("已装备"+core.material.items[itemId].name);
|
||||
if (itemId in this.useItemEffect) {
|
||||
eval(this.useItemEffect[itemId]);
|
||||
}
|
||||
|
||||
core.updateStatusBar();
|
||||
@ -155,167 +72,9 @@ items.prototype.canUseItem = function (itemId) {
|
||||
// 没有道具
|
||||
if (!core.hasItem(itemId)) return false;
|
||||
|
||||
if (itemId == 'book') return true;
|
||||
if (itemId == 'fly') return core.status.hero.flyRange.indexOf(core.status.floorId)>=0;
|
||||
if (itemId == 'pickaxe') {
|
||||
// 破墙镐
|
||||
var ids = [];
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) &&
|
||||
(block.event.id == 'yellowWall' || block.event.id=='whiteWall' || block.event.id=='blueWall')) // 能破哪些墙
|
||||
{
|
||||
// 四个方向
|
||||
if (core.flags.pickaxeFourDirections) {
|
||||
if (Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {
|
||||
ids.push(i);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (block.x == core.nextX() && block.y == core.nextY()) {
|
||||
ids.push(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ids.length>0) {
|
||||
core.status.event.data = ids;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (itemId in this.canUseItemEffect) {
|
||||
return eval(this.canUseItemEffect[itemId]);
|
||||
}
|
||||
if (itemId == 'icePickaxe') {
|
||||
// 破冰镐
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.x==core.nextX() && block.y==core.nextY() && block.event.id=='ice') {
|
||||
core.status.event.data = [i];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (itemId == 'bomb') {
|
||||
// 炸弹
|
||||
var ids = [];
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.cls.indexOf('enemy')==0 && Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {
|
||||
var enemy = core.material.enemys[block.event.id];
|
||||
if (core.isset(enemy.bomb) && !enemy.bomb) continue;
|
||||
if (core.flags.bombFourDirections || (block.x==core.nextX() && block.y==core.nextY()))
|
||||
ids.push(i);
|
||||
}
|
||||
}
|
||||
if (ids.length>0) {
|
||||
core.status.event.data = ids;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (itemId == 'hammer') {
|
||||
// 圣锤
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.cls.indexOf('enemy')==0 && block.x==core.nextX() && block.y==core.nextY()) {
|
||||
var enemy = core.material.enemys[block.event.id];
|
||||
if (core.isset(enemy.bomb) && !enemy.bomb) continue;
|
||||
core.status.event.data = [i];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (itemId == 'earthquake') {
|
||||
var ids = []
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && (block.event.id == 'yellowWall' || block.event.id == 'blueWall' || block.event.id == 'whiteWall'))
|
||||
ids.push(i);
|
||||
}
|
||||
if (ids.length>0) {
|
||||
core.status.event.data = ids;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (itemId == 'centerFly') {
|
||||
// 中心对称
|
||||
var toX = 12 - core.getHeroLoc('x'), toY = 12-core.getHeroLoc('y');
|
||||
var block = core.getBlock(toX, toY);
|
||||
if (block==null) {
|
||||
core.status.event.data = {'x': toX, 'y': toY};
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (itemId == 'upFly') {
|
||||
// 上楼器
|
||||
var floorId = core.status.floorId;
|
||||
var index = core.floorIds.indexOf(floorId);
|
||||
if (index==core.floorIds.length-1) return false;
|
||||
var toId = core.floorIds[index+1];
|
||||
var toX = core.getHeroLoc('x'), toY = core.getHeroLoc('y');
|
||||
|
||||
var block = core.getBlock(toX, toY, toId);
|
||||
if (block==null) {
|
||||
core.status.event.data = {'id': toId, 'x': toX, 'y': toY};
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (itemId == 'downFly') {
|
||||
// 下楼器
|
||||
var floorId = core.status.floorId;
|
||||
var index = core.floorIds.indexOf(floorId);
|
||||
if (index==0) return false;
|
||||
var toId = core.floorIds[index-1];
|
||||
var toX = core.getHeroLoc('x'), toY = core.getHeroLoc('y');
|
||||
|
||||
var block = core.getBlock(toX, toY, toId);
|
||||
if (block==null) {
|
||||
core.status.event.data = {'id': toId, 'x': toX, 'y': toY};
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (itemId=='snow') {
|
||||
// 冰冻徽章
|
||||
var ids = [];
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.id == 'lava' && Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {
|
||||
ids.push(i);
|
||||
}
|
||||
}
|
||||
if (ids.length>0) {
|
||||
core.status.event.data = ids;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (itemId=='bigKey') {
|
||||
// 大黄门钥匙
|
||||
var ids = [];
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.id == 'yellowDoor') {
|
||||
ids.push(i);
|
||||
}
|
||||
}
|
||||
if (ids.length>0) {
|
||||
core.status.event.data = ids;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (itemId=='poisonWine') return core.hasFlag('poison');
|
||||
if (itemId=='weakWine') return core.hasFlag('weak');
|
||||
if (itemId=='curseWine') return core.hasFlag('curse');
|
||||
if (itemId=='superWine') return core.hasFlag('poison') || core.hasFlag('weak') || core.hasFlag('curse');
|
||||
|
||||
// 剑盾
|
||||
if (itemId.indexOf("sword")==0 || itemId.indexOf("shield")==0) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -8,7 +8,9 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
'isEquipment': '物品是否属于装备(仅在core.flags.equipment时有效)\n$select({\"values\":[true,false]})$end'
|
||||
},
|
||||
'itemEffect':'cls为items的即捡即用类物品的效果,执行时会对这里的字符串执行eval()',
|
||||
'itemEffectTip':'cls为items的即捡即用类物品,在获得时左上角额外显示的文字,执行时会对这里的字符串执行eval()得到字符串'
|
||||
'itemEffectTip':'cls为items的即捡即用类物品,在获得时左上角额外显示的文字,执行时会对这里的字符串执行eval()得到字符串',
|
||||
'useItemEffect':'cls为tools或contants时的使用物品效果,执行时会对这里的字符串执行eval()',
|
||||
'canUseItemEffect':'cls为tools或contants时能否使用物品的判断,执行时会return这里的字符串执行eval()后的结果',
|
||||
},
|
||||
"items_template" : {'cls': 'items', 'name': '新物品'},
|
||||
"enemys" : {
|
||||
@ -31,6 +33,13 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
'damage':'战前扣血的点数\n$range(thiseval==~~thiseval||thiseval==null)$end'
|
||||
},
|
||||
"enemys_template" : {'name': '新敌人', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'point': 0, 'special': 0},
|
||||
"maps" : {
|
||||
"id" : "图块ID \n$range(false)$end",
|
||||
"idnum" : "图块数字 \n$range(false)$end",
|
||||
"cls" : "图块类别 \n$range(false)$end",
|
||||
"trigger" : "图块的默认触发器 \n$select({\"values\":[null,\"openDoor\",\"passNet\",\"changeLight\",\"ski\",\"pushBox\"]})$end",
|
||||
"noPass" : "图块默认可通行状态 \n$select({\"values\":[null,true,false]})$end"
|
||||
},
|
||||
"floors" : {
|
||||
'floor' : {
|
||||
"floorId": "文件名和floorId需要保持完全一致 \n楼层唯一标识符仅能由字母、数字、下划线组成,且不能由数字开头 \n推荐用法:第20层就用MT20,第38层就用MT38,地下6层就用MT_6(用下划线代替负号),隐藏3层用MT3h(h表示隐藏),等等 \n楼层唯一标识符,需要和名字完全一致 \n这里不能更改floorId,请通过另存为来实现\n$range(false)$end",
|
||||
|
||||
@ -126,18 +126,18 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
"bluePotion": " 蓝血瓶加血数值 ",
|
||||
"yellowPotion": " 黄血瓶加血数值 ",
|
||||
"greenPotion": " 绿血瓶加血数值 ",
|
||||
"sword0": " 默认装备折断的剑的攻击力 ",
|
||||
"shield0": " 默认装备残破的盾的防御力 ",
|
||||
"sword1": " 铁剑加攻数值 ",
|
||||
"shield1": " 铁盾加防数值 ",
|
||||
"sword2": " 银剑加攻数值 ",
|
||||
"shield2": " 银盾加防数值 ",
|
||||
"sword3": " 骑士剑加攻数值 ",
|
||||
"shield3": " 骑士盾加防数值 ",
|
||||
"sword4": " 圣剑加攻数值 ",
|
||||
"shield4": " 圣盾加防数值 ",
|
||||
"sword5": " 神圣剑加攻数值 ",
|
||||
"shield5": " 神圣盾加防数值 ",
|
||||
"sword0": " 默认装备折断的剑的攻击力 \n$leaf(true)$end",
|
||||
"shield0": " 默认装备残破的盾的防御力 \n$leaf(true)$end",
|
||||
"sword1": " 铁剑加攻数值 \n$leaf(true)$end",
|
||||
"shield1": " 铁盾加防数值 \n$leaf(true)$end",
|
||||
"sword2": " 银剑加攻数值 \n$leaf(true)$end",
|
||||
"shield2": " 银盾加防数值 \n$leaf(true)$end",
|
||||
"sword3": " 骑士剑加攻数值 \n$leaf(true)$end",
|
||||
"shield3": " 骑士盾加防数值 \n$leaf(true)$end",
|
||||
"sword4": " 圣剑加攻数值 \n$leaf(true)$end",
|
||||
"shield4": " 圣盾加防数值 \n$leaf(true)$end",
|
||||
"sword5": " 神圣剑加攻数值 \n$leaf(true)$end",
|
||||
"shield5": " 神圣盾加防数值 \n$leaf(true)$end",
|
||||
"moneyPocket": " 金钱袋加金币的数值 ",
|
||||
"breakArmor": " /****** 怪物相关 ******/ \n 破甲的比例(战斗前,怪物附加角色防御的x%作为伤害) ",
|
||||
"counterAttack": " 反击的比例(战斗时,怪物每回合附加角色攻击的x%作为伤害,无视角色防御) ",
|
||||
|
||||
@ -147,7 +147,7 @@ data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
||||
"pickaxeFourDirections": true,
|
||||
"bombFourDirections": true,
|
||||
"bigKeyIsBox": false,
|
||||
"equipment": false,
|
||||
"equipment": true,
|
||||
"enableDeleteItem": true,
|
||||
"enableAddPoint": false,
|
||||
"enableNegativeDamage": true,
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
{
|
||||
"events" : {
|
||||
"initGame": "游戏开始前的一些初始化操作",
|
||||
"setInitData" : "不同难度分别设置初始属性",
|
||||
"win" : "游戏获胜事件",
|
||||
"lose" : "游戏失败事件",
|
||||
|
||||
@ -1,268 +1,295 @@
|
||||
functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
{
|
||||
"events":{
|
||||
////// 游戏开始前的一些初始化操作 //////
|
||||
"initGame": function() {
|
||||
// 游戏开始前的一些初始化操作
|
||||
|
||||
// 根据flag来对道具进行修改
|
||||
if (core.flags.bigKeyIsBox)
|
||||
core.material.items.bigKey = {'cls': 'items', 'name': '钥匙盒'};
|
||||
// 面前的墙?四周的墙?
|
||||
if (core.flags.pickaxeFourDirections)
|
||||
core.material.items.pickaxe.text = "可以破坏勇士四周的墙";
|
||||
if (core.flags.bombFourDirections)
|
||||
core.material.items.bomb.text = "可以炸掉勇士四周的怪物";
|
||||
if (core.flags.equipment) {
|
||||
core.material.items.sword1 = {'cls': 'constants', 'name': '铁剑', 'text': '一把很普通的铁剑'};
|
||||
core.material.items.sword2 = {'cls': 'constants', 'name': '银剑', 'text': '一把很普通的银剑'};
|
||||
core.material.items.sword3 = {'cls': 'constants', 'name': '骑士剑', 'text': '一把很普通的骑士剑'};
|
||||
core.material.items.sword4 = {'cls': 'constants', 'name': '圣剑', 'text': '一把很普通的圣剑'};
|
||||
core.material.items.sword5 = {'cls': 'constants', 'name': '神圣剑', 'text': '一把很普通的神圣剑'};
|
||||
core.material.items.shield1 = {'cls': 'constants', 'name': '铁盾', 'text': '一个很普通的铁盾'};
|
||||
core.material.items.shield2 = {'cls': 'constants', 'name': '银盾', 'text': '一个很普通的银盾'};
|
||||
core.material.items.shield3 = {'cls': 'constants', 'name': '骑士盾', 'text': '一个很普通的骑士盾'};
|
||||
core.material.items.shield4 = {'cls': 'constants', 'name': '圣盾', 'text': '一个很普通的圣盾'};
|
||||
core.material.items.shield5 = {'cls': 'constants', 'name': '神圣盾', 'text': '一个很普通的神圣盾'};
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
////// 不同难度分别设置初始属性 //////
|
||||
"setInitData":function (hard) {
|
||||
// 不同难度分别设置初始属性
|
||||
if (hard=='Easy') { // 简单难度
|
||||
core.setFlag('hard', 1); // 可以用flag:hard来获得当前难度
|
||||
// 可以在此设置一些初始福利,比如设置初始生命值可以调用:
|
||||
// core.setStatus("hp", 10000);
|
||||
// 赠送一把黄钥匙可以调用
|
||||
// core.setItem("yellowKey", 1);
|
||||
}
|
||||
if (hard=='Normal') { // 普通难度
|
||||
core.setFlag('hard', 2); // 可以用flag:hard来获得当前难度
|
||||
}
|
||||
if (hard=='Hard') { // 困难难度
|
||||
core.setFlag('hard', 3); // 可以用flag:hard来获得当前难度
|
||||
}
|
||||
if (hard=='Hell') { // 噩梦难度
|
||||
core.setFlag('hard', 4); // 可以用flag:hard来获得当前难度
|
||||
}
|
||||
core.events.afterLoadData();
|
||||
// 不同难度分别设置初始属性
|
||||
if (hard=='Easy') { // 简单难度
|
||||
core.setFlag('hard', 1); // 可以用flag:hard来获得当前难度
|
||||
// 可以在此设置一些初始福利,比如设置初始生命值可以调用:
|
||||
// core.setStatus("hp", 10000);
|
||||
// 赠送一把黄钥匙可以调用
|
||||
// core.setItem("yellowKey", 1);
|
||||
}
|
||||
if (hard=='Normal') { // 普通难度
|
||||
core.setFlag('hard', 2); // 可以用flag:hard来获得当前难度
|
||||
}
|
||||
if (hard=='Hard') { // 困难难度
|
||||
core.setFlag('hard', 3); // 可以用flag:hard来获得当前难度
|
||||
}
|
||||
if (hard=='Hell') { // 噩梦难度
|
||||
core.setFlag('hard', 4); // 可以用flag:hard来获得当前难度
|
||||
}
|
||||
core.events.afterLoadData();
|
||||
},
|
||||
////// 游戏获胜事件 //////
|
||||
"win" : function(reason) {
|
||||
// 游戏获胜事件
|
||||
core.ui.closePanel();
|
||||
var replaying = core.status.replay.replaying;
|
||||
core.stopReplay();
|
||||
core.waitHeroToStop(function() {
|
||||
core.removeGlobalAnimate(0,0,true);
|
||||
core.clearMap('all'); // 清空全地图
|
||||
core.drawText([
|
||||
"\t[恭喜通关]你的分数是${status:hp}。"
|
||||
], function () {
|
||||
core.events.gameOver(reason||'', replaying);
|
||||
})
|
||||
});
|
||||
// 游戏获胜事件
|
||||
core.ui.closePanel();
|
||||
var replaying = core.status.replay.replaying;
|
||||
core.stopReplay();
|
||||
core.waitHeroToStop(function() {
|
||||
core.removeGlobalAnimate(0,0,true);
|
||||
core.clearMap('all'); // 清空全地图
|
||||
core.drawText([
|
||||
"\t[恭喜通关]你的分数是${status:hp}。"
|
||||
], function () {
|
||||
core.events.gameOver(reason||'', replaying);
|
||||
})
|
||||
});
|
||||
},
|
||||
////// 游戏失败事件 //////
|
||||
"lose" : function(reason) {
|
||||
// 游戏失败事件
|
||||
core.ui.closePanel();
|
||||
var replaying = core.status.replay.replaying;
|
||||
core.stopReplay();
|
||||
core.waitHeroToStop(function() {
|
||||
core.drawText([
|
||||
"\t[结局1]你死了。\n如题。"
|
||||
], function () {
|
||||
core.events.gameOver(null, replaying);
|
||||
});
|
||||
})
|
||||
// 游戏失败事件
|
||||
core.ui.closePanel();
|
||||
var replaying = core.status.replay.replaying;
|
||||
core.stopReplay();
|
||||
core.waitHeroToStop(function() {
|
||||
core.drawText([
|
||||
"\t[结局1]你死了。\n如题。"
|
||||
], function () {
|
||||
core.events.gameOver(null, replaying);
|
||||
});
|
||||
})
|
||||
},
|
||||
////// 转换楼层结束的事件 //////
|
||||
"afterChangeFloor" : function (floorId) {
|
||||
// 转换楼层结束的事件
|
||||
if (!core.hasFlag("visited_"+floorId)) {
|
||||
core.insertAction(core.floors[floorId].firstArrive);
|
||||
core.setFlag("visited_"+floorId, true);
|
||||
}
|
||||
// 转换楼层结束的事件
|
||||
if (!core.hasFlag("visited_"+floorId)) {
|
||||
core.insertAction(core.floors[floorId].firstArrive);
|
||||
core.setFlag("visited_"+floorId, true);
|
||||
}
|
||||
},
|
||||
////// 加点事件 //////
|
||||
"addPoint" : function (enemy) {
|
||||
// 加点事件
|
||||
var point = enemy.point;
|
||||
if (!core.flags.enableAddPoint || !core.isset(point) || point<=0) return [];
|
||||
// 加点事件
|
||||
var point = enemy.point;
|
||||
if (!core.flags.enableAddPoint || !core.isset(point) || point<=0) return [];
|
||||
|
||||
// 加点,返回一个choices事件
|
||||
return [
|
||||
{"type": "choices",
|
||||
"choices": [
|
||||
{"text": "攻击+"+(1*point), "action": [
|
||||
{"type": "setValue", "name": "status:atk", "value": "status:atk+"+(1*point)}
|
||||
]},
|
||||
{"text": "防御+"+(2*point), "action": [
|
||||
{"type": "setValue", "name": "status:def", "value": "status:def+"+(2*point)}
|
||||
]},
|
||||
{"text": "生命+"+(200*point), "action": [
|
||||
{"type": "setValue", "name": "status:hp", "value": "status:hp+"+(200*point)}
|
||||
]},
|
||||
]
|
||||
}
|
||||
];
|
||||
// 加点,返回一个choices事件
|
||||
return [
|
||||
{"type": "choices",
|
||||
"choices": [
|
||||
{"text": "攻击+"+(1*point), "action": [
|
||||
{"type": "setValue", "name": "status:atk", "value": "status:atk+"+(1*point)}
|
||||
]},
|
||||
{"text": "防御+"+(2*point), "action": [
|
||||
{"type": "setValue", "name": "status:def", "value": "status:def+"+(2*point)}
|
||||
]},
|
||||
{"text": "生命+"+(200*point), "action": [
|
||||
{"type": "setValue", "name": "status:hp", "value": "status:hp+"+(200*point)}
|
||||
]},
|
||||
]
|
||||
}
|
||||
];
|
||||
},
|
||||
////// 战斗结束后触发的事件 //////
|
||||
"afterBattle" : function(enemyId,x,y,callback) {
|
||||
// 战斗结束后触发的事件
|
||||
// 战斗结束后触发的事件
|
||||
|
||||
var enemy = core.material.enemys[enemyId];
|
||||
var enemy = core.material.enemys[enemyId];
|
||||
|
||||
// 扣减体力值
|
||||
core.status.hero.hp -= core.enemys.getDamage(enemyId);
|
||||
if (core.status.hero.hp<=0) {
|
||||
core.status.hero.hp=0;
|
||||
core.updateStatusBar();
|
||||
core.events.lose('battle');
|
||||
return;
|
||||
}
|
||||
// 获得金币和经验
|
||||
var money = enemy.money;
|
||||
if (core.hasItem('coin')) money *= 2;
|
||||
if (core.hasFlag('curse')) money=0;
|
||||
core.status.hero.money += money;
|
||||
var experience =enemy.experience;
|
||||
if (core.hasFlag('curse')) experience=0;
|
||||
core.status.hero.experience += experience;
|
||||
var hint = "打败 " + enemy.name;
|
||||
if (core.flags.enableMoney)
|
||||
hint += ",金币+" + money;
|
||||
if (core.flags.enableExperience)
|
||||
hint += ",经验+" + experience;
|
||||
core.drawTip(hint);
|
||||
// 扣减体力值
|
||||
core.status.hero.hp -= core.enemys.getDamage(enemyId);
|
||||
if (core.status.hero.hp<=0) {
|
||||
core.status.hero.hp=0;
|
||||
core.updateStatusBar();
|
||||
core.events.lose('battle');
|
||||
return;
|
||||
}
|
||||
// 获得金币和经验
|
||||
var money = enemy.money;
|
||||
if (core.hasItem('coin')) money *= 2;
|
||||
if (core.hasFlag('curse')) money=0;
|
||||
core.status.hero.money += money;
|
||||
var experience =enemy.experience;
|
||||
if (core.hasFlag('curse')) experience=0;
|
||||
core.status.hero.experience += experience;
|
||||
var hint = "打败 " + enemy.name;
|
||||
if (core.flags.enableMoney)
|
||||
hint += ",金币+" + money;
|
||||
if (core.flags.enableExperience)
|
||||
hint += ",经验+" + experience;
|
||||
core.drawTip(hint);
|
||||
|
||||
// 删除该块
|
||||
if (core.isset(x) && core.isset(y)) {
|
||||
core.removeBlock(x, y);
|
||||
core.canvas.event.clearRect(32 * x, 32 * y, 32, 32);
|
||||
}
|
||||
// 删除该块
|
||||
if (core.isset(x) && core.isset(y)) {
|
||||
core.removeBlock(x, y);
|
||||
core.canvas.event.clearRect(32 * x, 32 * y, 32, 32);
|
||||
}
|
||||
|
||||
// 毒衰咒的处理
|
||||
var special = enemy.special;
|
||||
// 中毒
|
||||
if (core.enemys.hasSpecial(special, 12) && !core.hasFlag('poison')) {
|
||||
core.setFlag('poison', true);
|
||||
}
|
||||
// 衰弱
|
||||
if (core.enemys.hasSpecial(special, 13) && !core.hasFlag('weak')) {
|
||||
core.setFlag('weak', true);
|
||||
core.status.hero.atk-=core.values.weakValue;
|
||||
core.status.hero.def-=core.values.weakValue;
|
||||
}
|
||||
// 诅咒
|
||||
if (core.enemys.hasSpecial(special, 14) && !core.hasFlag('curse')) {
|
||||
core.setFlag('curse', true);
|
||||
}
|
||||
// 仇恨属性:减半
|
||||
if (core.flags.hatredDecrease && core.enemys.hasSpecial(special, 17)) {
|
||||
core.setFlag('hatred', parseInt(core.getFlag('hatred', 0)/2));
|
||||
}
|
||||
// 自爆
|
||||
if (core.enemys.hasSpecial(special, 19)) {
|
||||
core.status.hero.hp = 1;
|
||||
}
|
||||
// 退化
|
||||
if (core.enemys.hasSpecial(special, 21)) {
|
||||
core.status.hero.atk -= (enemy.atkValue||0);
|
||||
core.status.hero.def -= (enemy.defValue||0);
|
||||
if (core.status.hero.atk<0) core.status.hero.atk=0;
|
||||
if (core.status.hero.def<0) core.status.hero.def=0;
|
||||
}
|
||||
// 增加仇恨值
|
||||
core.setFlag('hatred', core.getFlag('hatred',0)+core.values.hatred);
|
||||
core.updateStatusBar();
|
||||
// 毒衰咒的处理
|
||||
var special = enemy.special;
|
||||
// 中毒
|
||||
if (core.enemys.hasSpecial(special, 12) && !core.hasFlag('poison')) {
|
||||
core.setFlag('poison', true);
|
||||
}
|
||||
// 衰弱
|
||||
if (core.enemys.hasSpecial(special, 13) && !core.hasFlag('weak')) {
|
||||
core.setFlag('weak', true);
|
||||
core.status.hero.atk-=core.values.weakValue;
|
||||
core.status.hero.def-=core.values.weakValue;
|
||||
}
|
||||
// 诅咒
|
||||
if (core.enemys.hasSpecial(special, 14) && !core.hasFlag('curse')) {
|
||||
core.setFlag('curse', true);
|
||||
}
|
||||
// 仇恨属性:减半
|
||||
if (core.flags.hatredDecrease && core.enemys.hasSpecial(special, 17)) {
|
||||
core.setFlag('hatred', parseInt(core.getFlag('hatred', 0)/2));
|
||||
}
|
||||
// 自爆
|
||||
if (core.enemys.hasSpecial(special, 19)) {
|
||||
core.status.hero.hp = 1;
|
||||
}
|
||||
// 退化
|
||||
if (core.enemys.hasSpecial(special, 21)) {
|
||||
core.status.hero.atk -= (enemy.atkValue||0);
|
||||
core.status.hero.def -= (enemy.defValue||0);
|
||||
if (core.status.hero.atk<0) core.status.hero.atk=0;
|
||||
if (core.status.hero.def<0) core.status.hero.def=0;
|
||||
}
|
||||
// 增加仇恨值
|
||||
core.setFlag('hatred', core.getFlag('hatred',0)+core.values.hatred);
|
||||
core.updateStatusBar();
|
||||
|
||||
|
||||
// 事件的处理
|
||||
var todo = [];
|
||||
// 如果不为阻击,且该点存在,且有事件
|
||||
if (!core.enemys.hasSpecial(special, 18) && core.isset(x) && core.isset(y)) {
|
||||
var event = core.floors[core.status.floorId].afterBattle[x+","+y];
|
||||
if (core.isset(event)) {
|
||||
// 插入事件
|
||||
core.unshift(todo, event);
|
||||
}
|
||||
}
|
||||
// 如果有加点
|
||||
var point = core.material.enemys[enemyId].point;
|
||||
if (core.isset(point) && point>0) {
|
||||
core.unshift(todo, core.events.addPoint(core.material.enemys[enemyId]));
|
||||
}
|
||||
// 事件的处理
|
||||
var todo = [];
|
||||
// 如果不为阻击,且该点存在,且有事件
|
||||
if (!core.enemys.hasSpecial(special, 18) && core.isset(x) && core.isset(y)) {
|
||||
var event = core.floors[core.status.floorId].afterBattle[x+","+y];
|
||||
if (core.isset(event)) {
|
||||
// 插入事件
|
||||
core.unshift(todo, event);
|
||||
}
|
||||
}
|
||||
// 如果有加点
|
||||
var point = core.material.enemys[enemyId].point;
|
||||
if (core.isset(point) && point>0) {
|
||||
core.unshift(todo, core.events.addPoint(core.material.enemys[enemyId]));
|
||||
}
|
||||
|
||||
// 如果事件不为空,将其插入
|
||||
if (todo.length>0) {
|
||||
core.events.insertAction(todo,x,y);
|
||||
}
|
||||
// 如果事件不为空,将其插入
|
||||
if (todo.length>0) {
|
||||
core.events.insertAction(todo,x,y);
|
||||
}
|
||||
|
||||
// 如果已有事件正在处理中
|
||||
if (core.status.event.id == null) {
|
||||
core.continueAutomaticRoute();
|
||||
}
|
||||
else {
|
||||
core.clearContinueAutomaticRoute();
|
||||
}
|
||||
if (core.isset(callback)) callback();
|
||||
// 如果已有事件正在处理中
|
||||
if (core.status.event.id == null) {
|
||||
core.continueAutomaticRoute();
|
||||
}
|
||||
else {
|
||||
core.clearContinueAutomaticRoute();
|
||||
}
|
||||
if (core.isset(callback)) callback();
|
||||
|
||||
},
|
||||
////// 开一个门后触发的事件 //////
|
||||
"afterOpenDoor" : function(doorId,x,y,callback) {
|
||||
// 开一个门后触发的事件
|
||||
|
||||
var todo = [];
|
||||
if (core.isset(x) && core.isset(y)) {
|
||||
var event = core.floors[core.status.floorId].afterOpenDoor[x+","+y];
|
||||
if (core.isset(event)) {
|
||||
core.unshift(todo, event);
|
||||
}
|
||||
}
|
||||
// 开一个门后触发的事件
|
||||
|
||||
var todo = [];
|
||||
if (core.isset(x) && core.isset(y)) {
|
||||
var event = core.floors[core.status.floorId].afterOpenDoor[x+","+y];
|
||||
if (core.isset(event)) {
|
||||
core.unshift(todo, event);
|
||||
}
|
||||
}
|
||||
|
||||
if (todo.length>0) {
|
||||
core.events.insertAction(todo,x,y);
|
||||
}
|
||||
if (todo.length>0) {
|
||||
core.events.insertAction(todo,x,y);
|
||||
}
|
||||
|
||||
if (core.status.event.id == null) {
|
||||
core.continueAutomaticRoute();
|
||||
}
|
||||
else {
|
||||
core.clearContinueAutomaticRoute();
|
||||
}
|
||||
if (core.isset(callback)) callback();
|
||||
if (core.status.event.id == null) {
|
||||
core.continueAutomaticRoute();
|
||||
}
|
||||
else {
|
||||
core.clearContinueAutomaticRoute();
|
||||
}
|
||||
if (core.isset(callback)) callback();
|
||||
},
|
||||
////// 改变亮灯之后,可以触发的事件 //////
|
||||
"afterChangeLight" : function(x,y) {
|
||||
// 改变亮灯之后,可以触发的事件
|
||||
// 改变亮灯之后,可以触发的事件
|
||||
|
||||
},
|
||||
////// 推箱子后的事件 //////
|
||||
"afterPushBox" : function () {
|
||||
// 推箱子后的事件
|
||||
// 推箱子后的事件
|
||||
|
||||
var noBoxLeft = function () {
|
||||
// 地图上是否还存在未推到的箱子,如果不存在则返回true,存在则返回false
|
||||
for (var i=0;i<core.status.thisMap.blocks.length;i++) {
|
||||
var block=core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && block.event.id=='box') return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
var noBoxLeft = function () {
|
||||
// 地图上是否还存在未推到的箱子,如果不存在则返回true,存在则返回false
|
||||
for (var i=0;i<core.status.thisMap.blocks.length;i++) {
|
||||
var block=core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && block.event.id=='box') return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (noBoxLeft()) {
|
||||
// 可以通过if语句来进行开门操作
|
||||
/*
|
||||
if (core.status.floorId=='xxx') { // 在某个楼层
|
||||
core.insertAction([ // 插入一条事件
|
||||
{"type": "openDoor", "loc": [x,y]} // 开门
|
||||
])
|
||||
}
|
||||
*/
|
||||
}
|
||||
if (noBoxLeft()) {
|
||||
// 可以通过if语句来进行开门操作
|
||||
/*
|
||||
if (core.status.floorId=='xxx') { // 在某个楼层
|
||||
core.insertAction([ // 插入一条事件
|
||||
{"type": "openDoor", "loc": [x,y]} // 开门
|
||||
])
|
||||
}
|
||||
*/
|
||||
}
|
||||
},
|
||||
////// 使用炸弹/圣锤后的事件 //////
|
||||
"afterUseBomb" : function () {
|
||||
// 使用炸弹/圣锤后的事件
|
||||
// 使用炸弹/圣锤后的事件
|
||||
|
||||
// 这是一个使用炸弹也能开门的例子
|
||||
/*
|
||||
if (core.status.floorId=='xxx' && core.terrainExists(x0,y0,'specialDoor') // 某个楼层,该机关门存在
|
||||
&& !core.enemyExists(x1,y1) && !core.enemyExists(x2,y2)) // 且守门的怪物都不存在
|
||||
{
|
||||
core.insertAction([ // 插入事件
|
||||
{"type": "openDoor", "loc": [x0,y0]} // 开门
|
||||
])
|
||||
}
|
||||
*/
|
||||
// 这是一个使用炸弹也能开门的例子
|
||||
/*
|
||||
if (core.status.floorId=='xxx' && core.terrainExists(x0,y0,'specialDoor') // 某个楼层,该机关门存在
|
||||
&& !core.enemyExists(x1,y1) && !core.enemyExists(x2,y2)) // 且守门的怪物都不存在
|
||||
{
|
||||
core.insertAction([ // 插入事件
|
||||
{"type": "openDoor", "loc": [x0,y0]} // 开门
|
||||
])
|
||||
}
|
||||
*/
|
||||
|
||||
},
|
||||
////// 即将存档前可以执行的操作 //////
|
||||
"beforeSaveData" : function(data) {
|
||||
// 即将存档前可以执行的操作
|
||||
// 即将存档前可以执行的操作
|
||||
|
||||
},
|
||||
////// 读档事件后,载入事件前,可以执行的操作 //////
|
||||
"afterLoadData" : function(data) {
|
||||
// 读档事件后,载入事件前,可以执行的操作
|
||||
// 可以在这里对怪物数据进行动态修改,详见文档——事件——怪物数据的动态修改
|
||||
// 读档事件后,载入事件前,可以执行的操作
|
||||
// 可以在这里对怪物数据进行动态修改,详见文档——事件——怪物数据的动态修改
|
||||
|
||||
|
||||
}
|
||||
@ -270,48 +297,71 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
"ui":{
|
||||
////// 绘制“关于”界面 //////
|
||||
"drawAbout" : function() {
|
||||
// 绘制“关于”界面
|
||||
if (!core.isPlaying()) {
|
||||
core.status.event = {'id': null, 'data': null};
|
||||
core.dom.startPanel.style.display = 'none';
|
||||
}
|
||||
core.lockControl();
|
||||
core.status.event.id = 'about';
|
||||
// 绘制“关于”界面
|
||||
if (!core.isPlaying()) {
|
||||
core.status.event = {'id': null, 'data': null};
|
||||
core.dom.startPanel.style.display = 'none';
|
||||
}
|
||||
core.lockControl();
|
||||
core.status.event.id = 'about';
|
||||
|
||||
core.clearMap('ui', 0, 0, 416, 416);
|
||||
var left = 48, top = 36, right = 416 - 2 * left, bottom = 416 - 2 * top;
|
||||
core.clearMap('ui', 0, 0, 416, 416);
|
||||
var left = 48, top = 36, right = 416 - 2 * left, bottom = 416 - 2 * top;
|
||||
|
||||
core.setAlpha('ui', 0.85);
|
||||
core.fillRect('ui', left, top, right, bottom, '#000000');
|
||||
core.setAlpha('ui', 1);
|
||||
core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2);
|
||||
core.setAlpha('ui', 0.85);
|
||||
core.fillRect('ui', left, top, right, bottom, '#000000');
|
||||
core.setAlpha('ui', 1);
|
||||
core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2);
|
||||
|
||||
var text_start = left + 24;
|
||||
var text_start = left + 24;
|
||||
|
||||
// 名称
|
||||
core.canvas.ui.textAlign = "left";
|
||||
core.fillText('ui', "HTML5 魔塔样板", text_start, top+35, "#FFD700", "bold 22px Verdana");
|
||||
core.fillText('ui', "版本: "+core.firstData.version, text_start, top + 80, "#FFFFFF", "bold 17px Verdana");
|
||||
core.fillText('ui', "作者: 艾之葵", text_start, top + 112);
|
||||
core.fillText('ui', 'HTML5魔塔交流群:539113091', text_start, top+112+32);
|
||||
// TODO: 写自己的“关于”页面,每次增加32像素即可
|
||||
// 名称
|
||||
core.canvas.ui.textAlign = "left";
|
||||
core.fillText('ui', "HTML5 魔塔样板", text_start, top+35, "#FFD700", "bold 22px Verdana");
|
||||
core.fillText('ui', "版本: "+core.firstData.version, text_start, top + 80, "#FFFFFF", "bold 17px Verdana");
|
||||
core.fillText('ui', "作者: 艾之葵", text_start, top + 112);
|
||||
core.fillText('ui', 'HTML5魔塔交流群:539113091', text_start, top+112+32);
|
||||
// TODO: 写自己的“关于”页面,每次增加32像素即可
|
||||
}
|
||||
},
|
||||
"plugins": {
|
||||
"plugin": function () {
|
||||
////// 插件编写,可以在这里写自己额外需要执行的脚本 //////
|
||||
////// 插件编写,可以在这里写自己额外需要执行的脚本 //////
|
||||
|
||||
// 在这里写的代码,在所有模块加载完毕后,游戏开始前会被执行
|
||||
console.log("插件编写测试");
|
||||
// 可以写一些其他的被直接执行的代码
|
||||
// 在这里写的代码,在所有模块加载完毕后,游戏开始前会被执行
|
||||
console.log("插件编写测试");
|
||||
// 可以写一些其他的被直接执行的代码
|
||||
|
||||
// 在这里写所有需要自定义的函数
|
||||
// 写法必须是 this.xxx = function (args) { ...
|
||||
// 如果不写this的话,函数将无法被外部所访问
|
||||
this.test = function () {
|
||||
console.log("插件函数执行测试");
|
||||
}
|
||||
// 可以在任何地方(如afterXXX或自定义脚本事件)调用函数,方法为 core.plugin.xxx();
|
||||
|
||||
// 在这里写所有需要自定义的函数
|
||||
// 写法必须是 this.xxx = function (args) { ...
|
||||
// 如果不写this的话,函数将无法被外部所访问
|
||||
this.test = function () {
|
||||
console.log("插件函数执行测试");
|
||||
}
|
||||
|
||||
this.useEquipment = function (itemId) { // 使用装备
|
||||
if (itemId.indexOf("sword")==0) {
|
||||
var now=core.getFlag('sword', 'sword0'); // 当前装备剑的ID
|
||||
core.status.hero.atk -= core.values[now];
|
||||
core.setItem(now, 1);
|
||||
core.status.hero.atk += core.values[itemId];
|
||||
core.setItem(itemId, 0);
|
||||
core.setFlag('sword', itemId);
|
||||
core.drawTip("已装备"+core.material.items[itemId].name);
|
||||
}
|
||||
if (itemId.indexOf("shield")==0) {
|
||||
var now=core.getFlag('shield', 'shield0');
|
||||
core.status.hero.def -= core.values[now];
|
||||
core.setItem(now, 1);
|
||||
core.status.hero.def += core.values[itemId];
|
||||
core.setItem(itemId, 0);
|
||||
core.setFlag('shield', itemId);
|
||||
core.drawTip("已装备"+core.material.items[itemId].name);
|
||||
}
|
||||
}
|
||||
|
||||
// 可以在任何地方(如afterXXX或自定义脚本事件)调用函数,方法为 core.plugin.xxx();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,6 +112,69 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"bigKey":"',全钥匙+1'",
|
||||
"superPotion":"',生命值翻倍'",
|
||||
"moneyPocket":"',金币+'+core.values.moneyPocket",
|
||||
},
|
||||
|
||||
"useItemEffect": {
|
||||
"book": "core.ui.drawBook(0);",
|
||||
"fly": "core.ui.drawFly(core.status.hero.flyRange.indexOf(core.status.floorId));",
|
||||
"earthquake": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n});",
|
||||
"pickaxe": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n});",
|
||||
"icePickaxe": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n});",
|
||||
"snow": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n});",
|
||||
"bigKey": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n});",
|
||||
"bomb": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n core.events.afterUseBomb();\n});",
|
||||
"hammer": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n core.events.afterUseBomb();\n});",
|
||||
"centerFly": "core.clearMap('hero', 0, 0, 416, 416);\ncore.setHeroLoc('x', core.status.event.data.x);\ncore.setHeroLoc('y', core.status.event.data.y);\ncore.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');\ncore.drawTip(core.material.items[itemId].name + '使用成功');",
|
||||
"upFly": "var loc = {'direction': core.status.hero.loc.direction, 'x': core.status.event.data.x, 'y': core.status.event.data.y};\ncore.changeFloor(core.status.event.data.id, null, loc, null, function (){\n core.drawTip(core.material.items[itemId].name + '使用成功');\n core.replay();\n});",
|
||||
"downFly": "var loc = {'direction': core.status.hero.loc.direction, 'x': core.status.event.data.x, 'y': core.status.event.data.y};\ncore.changeFloor(core.status.event.data.id, null, loc, null, function (){\n core.drawTip(core.material.items[itemId].name + '使用成功');\n core.replay();\n});",
|
||||
"poisonWine": "core.setFlag('poison', false);",
|
||||
"weakWine": "core.setFlag('weak', false);\ncore.status.hero.atk += core.values.weakValue;\ncore.status.hero.def += core.values.weakValue;",
|
||||
"curseWine": "core.setFlag('curse', false);",
|
||||
"superWine": "core.setFlag('poison', false);\nif (core.hasFlag('weak')) {\n core.setFlag('weak', false);\n core.status.hero.atk += core.values.weakValue;\n core.status.hero.def += core.values.weakValue;\n}\ncore.setFlag('curse', false);",
|
||||
"sword0": "core.plugin.useEquipment(itemId)",
|
||||
"sword1": "core.plugin.useEquipment(itemId)",
|
||||
"sword2": "core.plugin.useEquipment(itemId)",
|
||||
"sword3": "core.plugin.useEquipment(itemId)",
|
||||
"sword4": "core.plugin.useEquipment(itemId)",
|
||||
"sword5": "core.plugin.useEquipment(itemId)",
|
||||
"shield0": "core.plugin.useEquipment(itemId)",
|
||||
"shield1": "core.plugin.useEquipment(itemId)",
|
||||
"shield2": "core.plugin.useEquipment(itemId)",
|
||||
"shield3": "core.plugin.useEquipment(itemId)",
|
||||
"shield4": "core.plugin.useEquipment(itemId)",
|
||||
"shield5": "core.plugin.useEquipment(itemId)",
|
||||
},
|
||||
|
||||
"canUseItemEffect": {
|
||||
"book": "true",
|
||||
"fly": "core.status.hero.flyRange.indexOf(core.status.floorId)>=0",
|
||||
"pickaxe": "var able=false;\nvar ids = [];\nfor (var i in core.status.thisMap.blocks) {\n var block = core.status.thisMap.blocks[i];\n if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) &&\n (block.event.id == 'yellowWall' || block.event.id=='whiteWall' || block.event.id=='blueWall')) // 能破哪些墙\n {\n // 四个方向\n if (core.flags.pickaxeFourDirections) {\n if (Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {\n ids.push(i);\n }\n }\n else {\n if (block.x == core.nextX() && block.y == core.nextY()) {\n ids.push(i);\n }\n }\n }\n}\nif (ids.length>0) {\n core.status.event.data = ids;\n able=true;\n}\nable",
|
||||
"icePickaxe": "var able=false;\nfor (var i in core.status.thisMap.blocks) {\n var block = core.status.thisMap.blocks[i];\n if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.x==core.nextX() && block.y==core.nextY() && block.event.id=='ice') {\n core.status.event.data = [i];\n able=true;\n }\n}\nable",
|
||||
"bomb": "var able=false;\nvar ids = [];\nfor (var i in core.status.thisMap.blocks) {\n var block = core.status.thisMap.blocks[i];\n if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.cls.indexOf('enemy')==0 && Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {\n var enemy = core.material.enemys[block.event.id];\n if (core.isset(enemy.bomb) && !enemy.bomb) continue;\n if (core.flags.bombFourDirections || (block.x==core.nextX() && block.y==core.nextY()))\n ids.push(i);\n }\n}\nif (ids.length>0) {\n core.status.event.data = ids;\n able=true;\n}\nable",
|
||||
"hammer": "var able=false;\nfor (var i in core.status.thisMap.blocks) {\n var block = core.status.thisMap.blocks[i];\n if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.cls.indexOf('enemy')==0 && block.x==core.nextX() && block.y==core.nextY()) {\n var enemy = core.material.enemys[block.event.id];\n if (core.isset(enemy.bomb) && !enemy.bomb) continue;\n core.status.event.data = [i];\n able=true;\n }\n}\nable",
|
||||
"earthquake": "var able=false;\nvar ids = [];\nfor (var i in core.status.thisMap.blocks) {\n var block = core.status.thisMap.blocks[i];\n if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && (block.event.id == 'yellowWall' || block.event.id == 'blueWall' || block.event.id == 'whiteWall')) // 能炸的墙壁\n ids.push(i);\n}\nif (ids.length>0) {\n core.status.event.data = ids;\n able=true;\n}\nable",
|
||||
"centerFly": "var able=false;\nvar toX = 12 - core.getHeroLoc('x'), toY = 12-core.getHeroLoc('y');\nvar block = core.getBlock(toX, toY);\nif (block==null) {\n core.status.event.data = {'x': toX, 'y': toY};\n able = true;\n}\nable",
|
||||
"upFly": "var able=false;\nvar floorId = core.status.floorId, index = core.floorIds.indexOf(floorId);\nif (index<core.floorIds.length-1) {\n\tvar toId = core.floorIds[index+1], toX = core.getHeroLoc('x'), toY = core.getHeroLoc('y');\n\tif (core.getBlock(toX, toY, toId)==null) {\n\t\tcore.status.event.data = {'id': toId, 'x': toX, 'y': toY};\n\t\table=true;\n\t}\n}\nable",
|
||||
"downFly": "var able=false;\nvar floorId = core.status.floorId, index = core.floorIds.indexOf(floorId);\nif (index>0) {\n\tvar toId = core.floorIds[index-1], toX = core.getHeroLoc('x'), toY = core.getHeroLoc('y');\n\tif (core.getBlock(toX, toY, toId)==null) {\n\t\tcore.status.event.data = {'id': toId, 'x': toX, 'y': toY};\n\t\table=true;\n\t}\n}\nable",
|
||||
"snow": "var able=false;\nvar ids = [];\nfor (var i in core.status.thisMap.blocks) {\n var block = core.status.thisMap.blocks[i];\n if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.id == 'lava' && Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {\n ids.push(i);\n }\n}\nif (ids.length>0) {\n core.status.event.data = ids;\n able=true;\n}\nable",
|
||||
"bigKey": "var able=false;\nvar ids = [];\nfor (var i in core.status.thisMap.blocks) {\n var block = core.status.thisMap.blocks[i];\n if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.id == 'yellowDoor') {\n ids.push(i);\n }\n}\nif (ids.length>0) {\n core.status.event.data = ids;\n able=true;\n}\nable",
|
||||
"poisonWine": "core.hasFlag('poison')",
|
||||
"weakWine": "core.hasFlag('weak')",
|
||||
"curseWine": "core.hasFlag('curse')",
|
||||
"superWine": "core.hasFlag('poison') || core.hasFlag('weak') || core.hasFlag('curse')",
|
||||
"sword0": "true",
|
||||
"sword1": "true",
|
||||
"sword2": "true",
|
||||
"sword3": "true",
|
||||
"sword4": "true",
|
||||
"sword5": "true",
|
||||
"shield0": "true",
|
||||
"shield1": "true",
|
||||
"shield2": "true",
|
||||
"shield3": "true",
|
||||
"shield4": "true",
|
||||
"shiled5": "true",
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user