Reformat _server & delete map
This commit is contained in:
parent
bff5298c7a
commit
81df4a9b19
@ -13,6 +13,7 @@
|
||||
.CodeMirror-lines {
|
||||
padding: 4px 0; /* Vertical padding around content */
|
||||
}
|
||||
|
||||
.CodeMirror pre {
|
||||
padding: 0 4px; /* Horizontal padding of content */
|
||||
}
|
||||
@ -28,7 +29,10 @@
|
||||
background-color: #f7f7f7;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.CodeMirror-linenumbers {}
|
||||
|
||||
.CodeMirror-linenumbers {
|
||||
}
|
||||
|
||||
.CodeMirror-linenumber {
|
||||
padding: 0 3px 0 5px;
|
||||
min-width: 20px;
|
||||
@ -37,8 +41,13 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.CodeMirror-guttermarker { color: black; }
|
||||
.CodeMirror-guttermarker-subtle { color: #999; }
|
||||
.CodeMirror-guttermarker {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.CodeMirror-guttermarker-subtle {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* CURSOR */
|
||||
|
||||
@ -47,24 +56,29 @@
|
||||
border-right: none;
|
||||
width: 0;
|
||||
}
|
||||
|
||||
/* Shown when moving in bi-directional text */
|
||||
.CodeMirror div.CodeMirror-secondarycursor {
|
||||
border-left: 1px solid silver;
|
||||
}
|
||||
|
||||
.cm-fat-cursor .CodeMirror-cursor {
|
||||
width: auto;
|
||||
border: 0 !important;
|
||||
background: #7e7;
|
||||
}
|
||||
|
||||
.cm-fat-cursor div.CodeMirror-cursors {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.cm-fat-cursor-mark {
|
||||
background-color: rgba(20, 255, 20, 0.5);
|
||||
-webkit-animation: blink 1.06s steps(1) infinite;
|
||||
-moz-animation: blink 1.06s steps(1) infinite;
|
||||
animation: blink 1.06s steps(1) infinite;
|
||||
}
|
||||
|
||||
.cm-animate-fat-cursor {
|
||||
width: auto;
|
||||
border: 0;
|
||||
@ -73,82 +87,199 @@
|
||||
animation: blink 1.06s steps(1) infinite;
|
||||
background-color: #7e7;
|
||||
}
|
||||
|
||||
@-moz-keyframes blink {
|
||||
0% {}
|
||||
50% { background-color: transparent; }
|
||||
100% {}
|
||||
0% {
|
||||
}
|
||||
50% {
|
||||
background-color: transparent;
|
||||
}
|
||||
100% {
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes blink {
|
||||
0% {}
|
||||
50% { background-color: transparent; }
|
||||
100% {}
|
||||
0% {
|
||||
}
|
||||
50% {
|
||||
background-color: transparent;
|
||||
}
|
||||
100% {
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes blink {
|
||||
0% {}
|
||||
50% { background-color: transparent; }
|
||||
100% {}
|
||||
0% {
|
||||
}
|
||||
50% {
|
||||
background-color: transparent;
|
||||
}
|
||||
100% {
|
||||
}
|
||||
}
|
||||
|
||||
/* Can style cursor different in overwrite (non-insert) mode */
|
||||
.CodeMirror-overwrite .CodeMirror-cursor {}
|
||||
.CodeMirror-overwrite .CodeMirror-cursor {
|
||||
}
|
||||
|
||||
.cm-tab { display: inline-block; text-decoration: inherit; }
|
||||
.cm-tab {
|
||||
display: inline-block;
|
||||
text-decoration: inherit;
|
||||
}
|
||||
|
||||
.CodeMirror-rulers {
|
||||
position: absolute;
|
||||
left: 0; right: 0; top: -50px; bottom: -20px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: -50px;
|
||||
bottom: -20px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.CodeMirror-ruler {
|
||||
border-left: 1px solid #ccc;
|
||||
top: 0; bottom: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
/* DEFAULT THEME */
|
||||
|
||||
.cm-s-default .cm-header {color: blue;}
|
||||
.cm-s-default .cm-quote {color: #090;}
|
||||
.cm-negative {color: #d44;}
|
||||
.cm-positive {color: #292;}
|
||||
.cm-header, .cm-strong {font-weight: bold;}
|
||||
.cm-em {font-style: italic;}
|
||||
.cm-link {text-decoration: underline;}
|
||||
.cm-strikethrough {text-decoration: line-through;}
|
||||
.cm-s-default .cm-header {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.cm-s-default .cm-quote {
|
||||
color: #090;
|
||||
}
|
||||
|
||||
.cm-negative {
|
||||
color: #d44;
|
||||
}
|
||||
|
||||
.cm-positive {
|
||||
color: #292;
|
||||
}
|
||||
|
||||
.cm-header, .cm-strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.cm-em {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.cm-link {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.cm-strikethrough {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.cm-s-default .cm-keyword {
|
||||
color: #708;
|
||||
}
|
||||
|
||||
.cm-s-default .cm-atom {
|
||||
color: #219;
|
||||
}
|
||||
|
||||
.cm-s-default .cm-number {
|
||||
color: #164;
|
||||
}
|
||||
|
||||
.cm-s-default .cm-def {
|
||||
color: #00f;
|
||||
}
|
||||
|
||||
.cm-s-default .cm-keyword {color: #708;}
|
||||
.cm-s-default .cm-atom {color: #219;}
|
||||
.cm-s-default .cm-number {color: #164;}
|
||||
.cm-s-default .cm-def {color: #00f;}
|
||||
.cm-s-default .cm-variable,
|
||||
.cm-s-default .cm-punctuation,
|
||||
.cm-s-default .cm-property,
|
||||
.cm-s-default .cm-operator {}
|
||||
.cm-s-default .cm-variable-2 {color: #05a;}
|
||||
.cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;}
|
||||
.cm-s-default .cm-comment {color: #a50;}
|
||||
.cm-s-default .cm-string {color: #a11;}
|
||||
.cm-s-default .cm-string-2 {color: #f50;}
|
||||
.cm-s-default .cm-meta {color: #555;}
|
||||
.cm-s-default .cm-qualifier {color: #555;}
|
||||
.cm-s-default .cm-builtin {color: #30a;}
|
||||
.cm-s-default .cm-bracket {color: #997;}
|
||||
.cm-s-default .cm-tag {color: #170;}
|
||||
.cm-s-default .cm-attribute {color: #00c;}
|
||||
.cm-s-default .cm-hr {color: #999;}
|
||||
.cm-s-default .cm-link {color: #00c;}
|
||||
.cm-s-default .cm-operator {
|
||||
}
|
||||
|
||||
.cm-s-default .cm-error {color: #f00;}
|
||||
.cm-invalidchar {color: #f00;}
|
||||
.cm-s-default .cm-variable-2 {
|
||||
color: #05a;
|
||||
}
|
||||
|
||||
.CodeMirror-composing { border-bottom: 2px solid; }
|
||||
.cm-s-default .cm-variable-3, .cm-s-default .cm-type {
|
||||
color: #085;
|
||||
}
|
||||
|
||||
.cm-s-default .cm-comment {
|
||||
color: #a50;
|
||||
}
|
||||
|
||||
.cm-s-default .cm-string {
|
||||
color: #a11;
|
||||
}
|
||||
|
||||
.cm-s-default .cm-string-2 {
|
||||
color: #f50;
|
||||
}
|
||||
|
||||
.cm-s-default .cm-meta {
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.cm-s-default .cm-qualifier {
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.cm-s-default .cm-builtin {
|
||||
color: #30a;
|
||||
}
|
||||
|
||||
.cm-s-default .cm-bracket {
|
||||
color: #997;
|
||||
}
|
||||
|
||||
.cm-s-default .cm-tag {
|
||||
color: #170;
|
||||
}
|
||||
|
||||
.cm-s-default .cm-attribute {
|
||||
color: #00c;
|
||||
}
|
||||
|
||||
.cm-s-default .cm-hr {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.cm-s-default .cm-link {
|
||||
color: #00c;
|
||||
}
|
||||
|
||||
.cm-s-default .cm-error {
|
||||
color: #f00;
|
||||
}
|
||||
|
||||
.cm-invalidchar {
|
||||
color: #f00;
|
||||
}
|
||||
|
||||
.CodeMirror-composing {
|
||||
border-bottom: 2px solid;
|
||||
}
|
||||
|
||||
/* Default styles for common addons */
|
||||
|
||||
div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}
|
||||
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
||||
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
|
||||
.CodeMirror-activeline-background {background: #e8f2ff;}
|
||||
div.CodeMirror span.CodeMirror-matchingbracket {
|
||||
color: #0b0;
|
||||
}
|
||||
|
||||
div.CodeMirror span.CodeMirror-nonmatchingbracket {
|
||||
color: #a22;
|
||||
}
|
||||
|
||||
.CodeMirror-matchingtag {
|
||||
background: rgba(255, 150, 0, .3);
|
||||
}
|
||||
|
||||
.CodeMirror-activeline-background {
|
||||
background: #e8f2ff;
|
||||
}
|
||||
|
||||
/* STOP */
|
||||
|
||||
@ -165,12 +296,14 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
||||
overflow: scroll !important; /* Things will break if this is overridden */
|
||||
/* 30px is the magic margin used to hide the element's real scrollbars */
|
||||
/* See overflow: hidden in .CodeMirror */
|
||||
margin-bottom: -30px; margin-right: -30px;
|
||||
margin-bottom: -30px;
|
||||
margin-right: -30px;
|
||||
padding-bottom: 30px;
|
||||
height: 100%;
|
||||
outline: none; /* Prevent dragging from highlighting the element */
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.CodeMirror-sizer {
|
||||
position: relative;
|
||||
border-right: 30px solid transparent;
|
||||
@ -184,28 +317,39 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
||||
z-index: 6;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.CodeMirror-vscrollbar {
|
||||
right: 0; top: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
.CodeMirror-hscrollbar {
|
||||
bottom: 0; left: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
overflow-y: hidden;
|
||||
overflow-x: scroll;
|
||||
}
|
||||
|
||||
.CodeMirror-scrollbar-filler {
|
||||
right: 0; bottom: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.CodeMirror-gutter-filler {
|
||||
left: 0; bottom: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.CodeMirror-gutters {
|
||||
position: absolute; left: 0; top: 0;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
min-height: 100%;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.CodeMirror-gutter {
|
||||
white-space: normal;
|
||||
height: 100%;
|
||||
@ -213,32 +357,45 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
||||
vertical-align: top;
|
||||
margin-bottom: -30px;
|
||||
}
|
||||
|
||||
.CodeMirror-gutter-wrapper {
|
||||
position: absolute;
|
||||
z-index: 4;
|
||||
background: none !important;
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
.CodeMirror-gutter-background {
|
||||
position: absolute;
|
||||
top: 0; bottom: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
z-index: 4;
|
||||
}
|
||||
|
||||
.CodeMirror-gutter-elt {
|
||||
position: absolute;
|
||||
cursor: default;
|
||||
z-index: 4;
|
||||
}
|
||||
.CodeMirror-gutter-wrapper ::selection { background-color: transparent }
|
||||
.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }
|
||||
|
||||
.CodeMirror-gutter-wrapper ::selection {
|
||||
background-color: transparent
|
||||
}
|
||||
|
||||
.CodeMirror-gutter-wrapper ::-moz-selection {
|
||||
background-color: transparent
|
||||
}
|
||||
|
||||
.CodeMirror-lines {
|
||||
cursor: text;
|
||||
min-height: 1px; /* prevents collapsing before first draw */
|
||||
}
|
||||
|
||||
.CodeMirror pre {
|
||||
/* Reset some styles that the rest of the page might have set */
|
||||
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
|
||||
-moz-border-radius: 0;
|
||||
-webkit-border-radius: 0;
|
||||
border-radius: 0;
|
||||
border-width: 0;
|
||||
background: transparent;
|
||||
font-family: inherit;
|
||||
@ -255,6 +412,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
||||
-webkit-font-variant-ligatures: contextual;
|
||||
font-variant-ligatures: contextual;
|
||||
}
|
||||
|
||||
.CodeMirror-wrap pre {
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
@ -263,7 +421,10 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
||||
|
||||
.CodeMirror-linebackground {
|
||||
position: absolute;
|
||||
left: 0; right: 0; top: 0; bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
@ -273,9 +434,12 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
||||
padding: 0.1px; /* Force widget margins to stay inside of the container */
|
||||
}
|
||||
|
||||
.CodeMirror-widget {}
|
||||
.CodeMirror-widget {
|
||||
}
|
||||
|
||||
.CodeMirror-rtl pre { direction: rtl; }
|
||||
.CodeMirror-rtl pre {
|
||||
direction: rtl;
|
||||
}
|
||||
|
||||
.CodeMirror-code {
|
||||
outline: none;
|
||||
@ -303,13 +467,17 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
}
|
||||
.CodeMirror-measure pre { position: static; }
|
||||
|
||||
.CodeMirror-measure pre {
|
||||
position: static;
|
||||
}
|
||||
|
||||
div.CodeMirror-cursors {
|
||||
visibility: hidden;
|
||||
position: relative;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
div.CodeMirror-dragcursors {
|
||||
visibility: visible;
|
||||
}
|
||||
@ -318,11 +486,25 @@ div.CodeMirror-dragcursors {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.CodeMirror-selected { background: #d9d9d9; }
|
||||
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
|
||||
.CodeMirror-crosshair { cursor: crosshair; }
|
||||
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
|
||||
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
|
||||
.CodeMirror-selected {
|
||||
background: #d9d9d9;
|
||||
}
|
||||
|
||||
.CodeMirror-focused .CodeMirror-selected {
|
||||
background: #d7d4f0;
|
||||
}
|
||||
|
||||
.CodeMirror-crosshair {
|
||||
cursor: crosshair;
|
||||
}
|
||||
|
||||
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection {
|
||||
background: #d7d4f0;
|
||||
}
|
||||
|
||||
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection {
|
||||
background: #d7d4f0;
|
||||
}
|
||||
|
||||
.cm-searching {
|
||||
background-color: #ffa;
|
||||
@ -330,7 +512,9 @@ div.CodeMirror-dragcursors {
|
||||
}
|
||||
|
||||
/* Used to force a border model for a node */
|
||||
.cm-force-border { padding-right: .1px; }
|
||||
.cm-force-border {
|
||||
padding-right: .1px;
|
||||
}
|
||||
|
||||
@media print {
|
||||
/* Hide the cursor when printing */
|
||||
@ -340,7 +524,11 @@ div.CodeMirror-dragcursors {
|
||||
}
|
||||
|
||||
/* See issue #2901 */
|
||||
.cm-tab-wrap-hack:after { content: ''; }
|
||||
.cm-tab-wrap-hack:after {
|
||||
content: '';
|
||||
}
|
||||
|
||||
/* Help users use markselection to safely style text background */
|
||||
span.CodeMirror-selectedtext { background: none; }
|
||||
span.CodeMirror-selectedtext {
|
||||
background: none;
|
||||
}
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
(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) {
|
||||
})(function (CodeMirror) {
|
||||
var Pos = CodeMirror.Pos;
|
||||
|
||||
function forEach(arr, f) {
|
||||
@ -36,8 +36,10 @@
|
||||
|
||||
// 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};
|
||||
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);
|
||||
@ -52,14 +54,18 @@
|
||||
if (!context) var context = [];
|
||||
context.push(tprop);
|
||||
}
|
||||
return {list: getCompletions(token, context, keywords, options),
|
||||
return {
|
||||
list: getCompletions(token, context, keywords, options),
|
||||
from: Pos(cur.line, token.start),
|
||||
to: Pos(cur.line, token.end)};
|
||||
to: Pos(cur.line, token.end)
|
||||
};
|
||||
}
|
||||
|
||||
function javascriptHint(editor, options) {
|
||||
return scriptHint(editor, javascriptKeywords,
|
||||
function (e, cur) {return e.getTokenAt(cur);},
|
||||
function (e, cur) {
|
||||
return e.getTokenAt(cur);
|
||||
},
|
||||
options);
|
||||
};
|
||||
CodeMirror.registerHelper("hint", "javascript", javascriptHint);
|
||||
@ -85,6 +91,7 @@
|
||||
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 " +
|
||||
@ -108,10 +115,12 @@
|
||||
|
||||
function getCompletions(token, context, keywords, options) {
|
||||
var found = [], start = token.string, global = options && options.globalScope || window;
|
||||
|
||||
function maybeAdd(str) {
|
||||
if (str==null || str==undefined) return;
|
||||
if (str == null || str == undefined) return;
|
||||
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);
|
||||
@ -153,4 +162,4 @@
|
||||
}
|
||||
return found;
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -1,15 +1,16 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
(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) {
|
||||
})(function (CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
// declare global: JSHINT
|
||||
|
||||
function validator(text, options) {
|
||||
@ -30,7 +31,7 @@
|
||||
CodeMirror.registerHelper("lint", "javascript", validator);
|
||||
|
||||
function parseErrors(errors, output) {
|
||||
for ( var i = 0; i < errors.length; i++) {
|
||||
for (var i = 0; i < errors.length; i++) {
|
||||
var error = errors[i];
|
||||
if (error) {
|
||||
if (error.line <= 0) {
|
||||
@ -60,4 +61,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -1,9 +1,9 @@
|
||||
/* The lint marker gutter */
|
||||
.CodeMirror-lint-markers {
|
||||
width: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.CodeMirror-lint-tooltip {
|
||||
.CodeMirror-lint-tooltip {
|
||||
background-color: #ffd;
|
||||
border: 1px solid black;
|
||||
border-radius: 4px 4px 4px 4px;
|
||||
@ -23,24 +23,22 @@
|
||||
-webkit-transition: opacity .4s;
|
||||
-o-transition: opacity .4s;
|
||||
-ms-transition: opacity .4s;
|
||||
}
|
||||
}
|
||||
|
||||
.CodeMirror-lint-mark-error, .CodeMirror-lint-mark-warning {
|
||||
.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-error {
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==");
|
||||
}
|
||||
|
||||
.CodeMirror-lint-mark-warning {
|
||||
.CodeMirror-lint-mark-warning {
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII=");
|
||||
}
|
||||
}
|
||||
|
||||
.CodeMirror-lint-marker-error, .CodeMirror-lint-marker-warning {
|
||||
.CodeMirror-lint-marker-error, .CodeMirror-lint-marker-warning {
|
||||
background-position: center center;
|
||||
background-repeat: no-repeat;
|
||||
cursor: pointer;
|
||||
@ -49,25 +47,26 @@
|
||||
width: 16px;
|
||||
vertical-align: middle;
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
|
||||
.CodeMirror-lint-message-error, .CodeMirror-lint-message-warning {
|
||||
.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 {
|
||||
.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 {
|
||||
.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 {
|
||||
.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%;
|
||||
}
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
@ -1,14 +1,14 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
(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) {
|
||||
})(function (CodeMirror) {
|
||||
"use strict";
|
||||
var GUTTER_ID = "CodeMirror-lint-markers";
|
||||
|
||||
@ -23,32 +23,45 @@
|
||||
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);
|
||||
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; }
|
||||
if (tooltip) {
|
||||
hideTooltip(tooltip);
|
||||
tooltip = null;
|
||||
}
|
||||
var poll = setInterval(function() {
|
||||
if (tooltip) for (var n = node;; n = n.parentNode) {
|
||||
}
|
||||
|
||||
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 (!n) {
|
||||
hide();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!tooltip) return clearInterval(poll);
|
||||
}, 400);
|
||||
@ -60,7 +73,9 @@
|
||||
this.options = options;
|
||||
this.timeout = null;
|
||||
this.hasGutter = hasGutter;
|
||||
this.onMouseOver = function(e) { onMouseOver(cm, e); };
|
||||
this.onMouseOver = function (e) {
|
||||
onMouseOver(cm, e);
|
||||
};
|
||||
this.waitingFor = 0
|
||||
}
|
||||
|
||||
@ -86,7 +101,7 @@
|
||||
inner.className = "CodeMirror-lint-marker-multiple";
|
||||
}
|
||||
|
||||
if (tooltips != false) CodeMirror.on(inner, "mouseover", function(e) {
|
||||
if (tooltips != false) CodeMirror.on(inner, "mouseover", function (e) {
|
||||
showTooltipFor(e, labels, inner);
|
||||
});
|
||||
|
||||
@ -123,16 +138,20 @@
|
||||
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) {
|
||||
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)})
|
||||
cm.operation(function () {
|
||||
updateLinting(cm, annotations)
|
||||
})
|
||||
}, passOptions, cm);
|
||||
}
|
||||
|
||||
@ -150,10 +169,14 @@
|
||||
} else {
|
||||
var annotations = getAnnotations(cm.getValue(), passOptions, cm);
|
||||
if (!annotations) return;
|
||||
if (annotations.then) annotations.then(function(issues) {
|
||||
cm.operation(function() {updateLinting(cm, issues)})
|
||||
if (annotations.then) annotations.then(function (issues) {
|
||||
cm.operation(function () {
|
||||
updateLinting(cm, issues)
|
||||
})
|
||||
});
|
||||
else cm.operation(function() {updateLinting(cm, annotations)})
|
||||
else cm.operation(function () {
|
||||
updateLinting(cm, annotations)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,7 +219,9 @@
|
||||
var state = cm.state.lint;
|
||||
if (!state) return;
|
||||
clearTimeout(state.timeout);
|
||||
state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500);
|
||||
state.timeout = setTimeout(function () {
|
||||
startLinting(cm);
|
||||
}, state.options.delay || 500);
|
||||
}
|
||||
|
||||
function popupTooltips(annotations, e) {
|
||||
@ -223,7 +248,7 @@
|
||||
if (annotations.length) popupTooltips(annotations, e);
|
||||
}
|
||||
|
||||
CodeMirror.defineOption("lint", false, function(cm, val, old) {
|
||||
CodeMirror.defineOption("lint", false, function (cm, val, old) {
|
||||
if (old && old != CodeMirror.Init) {
|
||||
clearMarks(cm);
|
||||
if (cm.state.lint.options.lintOnChange !== false)
|
||||
@ -246,7 +271,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
CodeMirror.defineExtension("performLint", function() {
|
||||
CodeMirror.defineExtension("performLint", function () {
|
||||
if (this.state.lint) startLinting(this);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -7,9 +7,9 @@
|
||||
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);
|
||||
-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;
|
||||
|
||||
@ -19,18 +19,18 @@
|
||||
|
||||
max-height: 20em;
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.CodeMirror-hint {
|
||||
.CodeMirror-hint {
|
||||
margin: 0;
|
||||
padding: 0 4px;
|
||||
border-radius: 2px;
|
||||
white-space: pre;
|
||||
color: black;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
li.CodeMirror-hint-active {
|
||||
li.CodeMirror-hint-active {
|
||||
background: #08f;
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
@ -1,14 +1,14 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
(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) {
|
||||
})(function (CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var HINT_ELEMENT_CLASS = "CodeMirror-hint";
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
// This is the old interface, kept around for now to stay
|
||||
// backwards-compatible.
|
||||
CodeMirror.showHint = function(cm, getHints, options) {
|
||||
CodeMirror.showHint = function (cm, getHints, options) {
|
||||
if (!getHints) return cm.showHint(options);
|
||||
if (options && options.async) getHints.async = true;
|
||||
var newOpts = {hint: getHints};
|
||||
@ -24,7 +24,7 @@
|
||||
return cm.showHint(newOpts);
|
||||
};
|
||||
|
||||
CodeMirror.defineExtension("showHint", function(options) {
|
||||
CodeMirror.defineExtension("showHint", function (options) {
|
||||
options = parseOptions(this, this.getCursor("start"), options);
|
||||
var selections = this.listSelections()
|
||||
if (selections.length > 1) return;
|
||||
@ -56,16 +56,18 @@
|
||||
this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length;
|
||||
|
||||
var self = this;
|
||||
cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); });
|
||||
cm.on("cursorActivity", this.activityFunc = function () {
|
||||
self.cursorActivity();
|
||||
});
|
||||
}
|
||||
|
||||
var requestAnimationFrame = window.requestAnimationFrame || function(fn) {
|
||||
return setTimeout(fn, 1000/60);
|
||||
var requestAnimationFrame = window.requestAnimationFrame || function (fn) {
|
||||
return setTimeout(fn, 1000 / 60);
|
||||
};
|
||||
var cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;
|
||||
|
||||
Completion.prototype = {
|
||||
close: function() {
|
||||
close: function () {
|
||||
if (!this.active()) return;
|
||||
this.cm.state.completionActive = null;
|
||||
this.tick = null;
|
||||
@ -76,11 +78,11 @@
|
||||
CodeMirror.signal(this.cm, "endCompletion", this.cm);
|
||||
},
|
||||
|
||||
active: function() {
|
||||
active: function () {
|
||||
return this.cm.state.completionActive == this;
|
||||
},
|
||||
|
||||
pick: function(data, i) {
|
||||
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,
|
||||
@ -89,7 +91,7 @@
|
||||
this.close();
|
||||
},
|
||||
|
||||
cursorActivity: function() {
|
||||
cursorActivity: function () {
|
||||
if (this.debounce) {
|
||||
cancelAnimationFrame(this.debounce);
|
||||
this.debounce = 0;
|
||||
@ -102,20 +104,22 @@
|
||||
this.close();
|
||||
} else {
|
||||
var self = this;
|
||||
this.debounce = requestAnimationFrame(function() {self.update();});
|
||||
this.debounce = requestAnimationFrame(function () {
|
||||
self.update();
|
||||
});
|
||||
if (this.widget) this.widget.disable();
|
||||
}
|
||||
},
|
||||
|
||||
update: function(first) {
|
||||
update: function (first) {
|
||||
if (this.tick == null) return
|
||||
var self = this, myTick = ++this.tick
|
||||
fetchHints(this.options.hint, this.cm, this.options, function(data) {
|
||||
fetchHints(this.options.hint, this.cm, this.options, function (data) {
|
||||
if (self.tick == myTick) self.finishUpdate(data, first)
|
||||
})
|
||||
},
|
||||
|
||||
finishUpdate: function(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);
|
||||
@ -153,22 +157,37 @@
|
||||
|
||||
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);},
|
||||
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); };
|
||||
bound = function (cm) {
|
||||
return val(cm, handle);
|
||||
};
|
||||
// This mechanism is deprecated
|
||||
else if (baseMap.hasOwnProperty(val))
|
||||
bound = baseMap[val];
|
||||
@ -176,6 +195,7 @@
|
||||
bound = val;
|
||||
ourMap[key] = bound;
|
||||
}
|
||||
|
||||
if (custom)
|
||||
for (var key in custom) if (custom.hasOwnProperty(key))
|
||||
addBinding(key, custom[key]);
|
||||
@ -254,22 +274,38 @@
|
||||
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(); },
|
||||
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(); },
|
||||
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("blur", this.onBlur = function () {
|
||||
closingOnBlur = setTimeout(function () {
|
||||
completion.close();
|
||||
}, 100);
|
||||
});
|
||||
cm.on("focus", this.onFocus = function () {
|
||||
clearTimeout(closingOnBlur);
|
||||
});
|
||||
}
|
||||
|
||||
cm.on("scroll", this.onScroll = function() {
|
||||
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);
|
||||
@ -279,12 +315,15 @@
|
||||
hints.style.left = (left + startScroll.left - curScroll.left) + "px";
|
||||
});
|
||||
|
||||
CodeMirror.on(hints, "dblclick", function(e) {
|
||||
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();}
|
||||
if (t && t.hintId != null) {
|
||||
widget.changeActive(t.hintId);
|
||||
widget.pick();
|
||||
}
|
||||
});
|
||||
|
||||
CodeMirror.on(hints, "click", function(e) {
|
||||
CodeMirror.on(hints, "click", function (e) {
|
||||
var t = getHintElement(hints, e.target || e.srcElement);
|
||||
if (t && t.hintId != null) {
|
||||
widget.changeActive(t.hintId);
|
||||
@ -292,8 +331,10 @@
|
||||
}
|
||||
});
|
||||
|
||||
CodeMirror.on(hints, "mousedown", function() {
|
||||
setTimeout(function(){cm.focus();}, 20);
|
||||
CodeMirror.on(hints, "mousedown", function () {
|
||||
setTimeout(function () {
|
||||
cm.focus();
|
||||
}, 20);
|
||||
});
|
||||
|
||||
CodeMirror.signal(data, "select", completions[this.selectedHint], hints.childNodes[this.selectedHint]);
|
||||
@ -301,7 +342,7 @@
|
||||
}
|
||||
|
||||
Widget.prototype = {
|
||||
close: function() {
|
||||
close: function () {
|
||||
if (this.completion.widget != this) return;
|
||||
this.completion.widget = null;
|
||||
this.hints.parentNode.removeChild(this.hints);
|
||||
@ -315,18 +356,22 @@
|
||||
cm.off("scroll", this.onScroll);
|
||||
},
|
||||
|
||||
disable: function() {
|
||||
disable: function () {
|
||||
this.completion.cm.removeKeyMap(this.keyMap);
|
||||
var widget = this;
|
||||
this.keyMap = {Enter: function() { widget.picked = true; }};
|
||||
this.keyMap = {
|
||||
Enter: function () {
|
||||
widget.picked = true;
|
||||
}
|
||||
};
|
||||
this.completion.cm.addKeyMap(this.keyMap);
|
||||
},
|
||||
|
||||
pick: function() {
|
||||
pick: function () {
|
||||
this.completion.pick(this.data, this.selectedHint);
|
||||
},
|
||||
|
||||
changeActive: function(i, avoidWrap) {
|
||||
changeActive: function (i, avoidWrap) {
|
||||
if (i >= this.data.list.length)
|
||||
i = avoidWrap ? this.data.list.length - 1 : 0;
|
||||
else if (i < 0)
|
||||
@ -343,7 +388,7 @@
|
||||
CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node);
|
||||
},
|
||||
|
||||
screenAmount: function() {
|
||||
screenAmount: function () {
|
||||
return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1;
|
||||
}
|
||||
};
|
||||
@ -369,26 +414,33 @@
|
||||
function resolveAutoHints(cm, pos) {
|
||||
var helpers = cm.getHelpers(pos, "hint"), words
|
||||
if (helpers.length) {
|
||||
var resolved = function(cm, callback, options) {
|
||||
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) {
|
||||
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}) }
|
||||
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) }
|
||||
return function (cm, options) {
|
||||
return CodeMirror.hint.anyword(cm, options)
|
||||
}
|
||||
} else {
|
||||
return function() {}
|
||||
return function () {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -396,7 +448,7 @@
|
||||
resolve: resolveAutoHints
|
||||
});
|
||||
|
||||
CodeMirror.registerHelper("hint", "fromList", function(cm, options) {
|
||||
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])) {
|
||||
@ -429,4 +481,4 @@
|
||||
};
|
||||
|
||||
CodeMirror.defineOption("hintOptions", null);
|
||||
});
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -1,74 +1,74 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="96px" height="124px">
|
||||
<style type="text/css">
|
||||
#background {
|
||||
#background {
|
||||
fill: none;
|
||||
}
|
||||
.arrows {
|
||||
}
|
||||
.arrows {
|
||||
fill: #000;
|
||||
stroke: none;
|
||||
}
|
||||
.selected>.arrows {
|
||||
}
|
||||
.selected>.arrows {
|
||||
fill: #fff;
|
||||
}
|
||||
.checkmark {
|
||||
}
|
||||
.checkmark {
|
||||
fill: #000;
|
||||
font-family: sans-serif;
|
||||
font-size: 10pt;
|
||||
text-anchor: middle;
|
||||
}
|
||||
.trash {
|
||||
}
|
||||
.trash {
|
||||
fill: #888;
|
||||
}
|
||||
.zoom {
|
||||
}
|
||||
.zoom {
|
||||
fill: none;
|
||||
stroke: #888;
|
||||
stroke-width: 2;
|
||||
stroke-linecap: round;
|
||||
}
|
||||
.zoom>.center {
|
||||
}
|
||||
.zoom>.center {
|
||||
fill: #888;
|
||||
stroke-width: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<rect id="background" width="96" height="124" x="0" y="0" />
|
||||
<rect id="background" width="96" height="124" x="0" y="0"/>
|
||||
|
||||
<g>
|
||||
<path class="arrows" d="M 13,1.5 13,14.5 1.74,8 z" />
|
||||
<path class="arrows" d="M 17.5,3 30.5,3 24,14.26 z" />
|
||||
<path class="arrows" d="M 35,1.5 35,14.5 46.26,8 z" />
|
||||
<path class="arrows" d="M 13,1.5 13,14.5 1.74,8 z"/>
|
||||
<path class="arrows" d="M 17.5,3 30.5,3 24,14.26 z"/>
|
||||
<path class="arrows" d="M 35,1.5 35,14.5 46.26,8 z"/>
|
||||
</g>
|
||||
<g class="selected" transform="translate(0, 16)">
|
||||
<path class="arrows" d="M 13,1.5 13,14.5 1.74,8 z" />
|
||||
<path class="arrows" d="M 17.5,3 30.5,3 24,14.26 z" />
|
||||
<path class="arrows" d="M 35,1.5 35,14.5 46.26,8 z" />
|
||||
<path class="arrows" d="M 13,1.5 13,14.5 1.74,8 z"/>
|
||||
<path class="arrows" d="M 17.5,3 30.5,3 24,14.26 z"/>
|
||||
<path class="arrows" d="M 35,1.5 35,14.5 46.26,8 z"/>
|
||||
</g>
|
||||
|
||||
<text class="checkmark" x="55.5" y="28">✓</text>
|
||||
|
||||
<g class="trash">
|
||||
<path d="M 2,41 v 6 h 42 v -6 h -10.5 l -3,-3 h -15 l -3,3 z" />
|
||||
<rect width="36" height="20" x="5" y="50" />
|
||||
<rect width="36" height="42" x="5" y="50" rx="4" ry="4" />
|
||||
<path d="M 2,41 v 6 h 42 v -6 h -10.5 l -3,-3 h -15 l -3,3 z"/>
|
||||
<rect width="36" height="20" x="5" y="50"/>
|
||||
<rect width="36" height="42" x="5" y="50" rx="4" ry="4"/>
|
||||
</g>
|
||||
|
||||
<g class="zoom">
|
||||
<circle r="11.5" cx="16" cy="108" />
|
||||
<circle r="4.3" cx="16" cy="108" class="center" />
|
||||
<path d="m 28,108 h3" />
|
||||
<path d="m 1,108 h3" />
|
||||
<path d="m 16,120 v3" />
|
||||
<path d="m 16,93 v3" />
|
||||
<circle r="11.5" cx="16" cy="108"/>
|
||||
<circle r="4.3" cx="16" cy="108" class="center"/>
|
||||
<path d="m 28,108 h3"/>
|
||||
<path d="m 1,108 h3"/>
|
||||
<path d="m 16,120 v3"/>
|
||||
<path d="m 16,93 v3"/>
|
||||
</g>
|
||||
|
||||
<g class="zoom">
|
||||
<circle r="15" cx="48" cy="108" />
|
||||
<path d="m 48,101.6 v12.8" />
|
||||
<path d="m 41.6,108 h12.8" />
|
||||
<circle r="15" cx="48" cy="108"/>
|
||||
<path d="m 48,101.6 v12.8"/>
|
||||
<path d="m 41.6,108 h12.8"/>
|
||||
</g>
|
||||
|
||||
<g class="zoom">
|
||||
<circle r="15" cx="80" cy="108" />
|
||||
<path d="m 73.6,108 h12.8" />
|
||||
<circle r="15" cx="80" cy="108"/>
|
||||
<path d="m 73.6,108 h12.8"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.0 KiB |
@ -1,9 +1,14 @@
|
||||
|
||||
html,body,div,img{margin:0;padding:0;}
|
||||
body{
|
||||
font-family: Roboto,"Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;;
|
||||
html, body, div, img {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: Roboto, "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;;
|
||||
background-color: #F5F5F5;
|
||||
}
|
||||
|
||||
/* ::-webkit-scrollbar {
|
||||
width: 5px;
|
||||
} */
|
||||
@ -12,12 +17,14 @@ body{
|
||||
min-height: 500px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
#left, #mid, #right{
|
||||
|
||||
#left, #mid, #right {
|
||||
border-radius: 2px;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0 2px 2px 0 rgba(0,0,0,.14), 0 3px 1px -2px rgba(0,0,0,.2), 0 1px 5px 0 rgba(0,0,0,.12);
|
||||
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
|
||||
}
|
||||
#left{
|
||||
|
||||
#left {
|
||||
position: absolute;
|
||||
left: 5px;
|
||||
top: 10px;
|
||||
@ -25,7 +32,7 @@ body{
|
||||
height: 630px;
|
||||
}
|
||||
|
||||
#editArea{
|
||||
#editArea {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 70%;
|
||||
@ -34,7 +41,8 @@ body{
|
||||
/* padding: 10px 5px; */
|
||||
box-sizing: border-box;
|
||||
}
|
||||
#pout{
|
||||
|
||||
#pout {
|
||||
display: block;
|
||||
width: 410px;
|
||||
height: 100%;
|
||||
@ -49,14 +57,16 @@ body{
|
||||
border-radius: 2px;
|
||||
overflow: auto;
|
||||
}
|
||||
#editTip{
|
||||
|
||||
#editTip {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 80px;
|
||||
bottom:10px;
|
||||
margin-bottom: 120px;
|
||||
bottom: 0;
|
||||
left: 10px;
|
||||
}
|
||||
#editArea p{
|
||||
|
||||
#editArea p {
|
||||
margin: 10px;
|
||||
display: block;
|
||||
width: 70%;
|
||||
@ -64,18 +74,21 @@ body{
|
||||
text-align: left;
|
||||
font-size: 14px;
|
||||
}
|
||||
#editTip .btn{
|
||||
|
||||
#editTip .btn {
|
||||
float: right;
|
||||
margin-right: 20px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
#mid{
|
||||
|
||||
#mid {
|
||||
position: absolute;
|
||||
left: 448px;
|
||||
top: 10px;
|
||||
width: 440px;
|
||||
height: 630px;
|
||||
}
|
||||
|
||||
.map {
|
||||
position: absolute;
|
||||
left: 20px;
|
||||
@ -83,7 +96,8 @@ body{
|
||||
width: 416px;
|
||||
height: 416px;
|
||||
}
|
||||
#mid .tools{
|
||||
|
||||
#mid .tools {
|
||||
position: absolute;
|
||||
width: 425px;
|
||||
height: 180px;
|
||||
@ -94,7 +108,8 @@ body{
|
||||
margin-left: 8px;;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
#tip{
|
||||
|
||||
#tip {
|
||||
float: right;
|
||||
width: 50%;
|
||||
height: 95%;
|
||||
@ -106,13 +121,15 @@ body{
|
||||
font-size: 15px;
|
||||
line-height: 14px;
|
||||
}
|
||||
|
||||
.files {
|
||||
width: 50%;
|
||||
height: 120px;
|
||||
/* padding: 10px; */
|
||||
margin-top: 15px;
|
||||
}
|
||||
.input{
|
||||
|
||||
.input {
|
||||
display: block;
|
||||
max-width: 150px;
|
||||
height: 20px;
|
||||
@ -123,23 +140,27 @@ body{
|
||||
background-color: #fff;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 3px;
|
||||
box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
|
||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
|
||||
}
|
||||
#bgSelect{
|
||||
|
||||
#bgSelect {
|
||||
width: 50%;
|
||||
height: 100px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
#bgSelect span{
|
||||
|
||||
#bgSelect span {
|
||||
/* display: block; */
|
||||
font-size: 14px;
|
||||
line-height: 30px;
|
||||
}
|
||||
#printOut{
|
||||
|
||||
#printOut {
|
||||
margin-top: 10px;
|
||||
height: 20px;
|
||||
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 80px;
|
||||
border-radius: 2px;
|
||||
@ -159,16 +180,18 @@ body{
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
border: 0;
|
||||
background: rgba(158,158,158,.2);
|
||||
box-shadow: 0 1px 1px 0 rgba(0,0,0,.14), 0 2px 1px -1px rgba(0,0,0,.2), 0 1px 3px 0 rgba(0,0,0,.12);
|
||||
background: rgba(158, 158, 158, .2);
|
||||
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .14), 0 2px 1px -1px rgba(0, 0, 0, .2), 0 1px 3px 0 rgba(0, 0, 0, .12);
|
||||
color: #fff;
|
||||
background-color: #26A69A;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
background-color: #009688;
|
||||
box-shadow: 0 2px 2px 0 rgba(0,0,0,.14), 0 3px 1px -2px rgba(0,0,0,.2), 0 1px 5px 0 rgba(0,0,0,.12);
|
||||
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
|
||||
}
|
||||
#right{
|
||||
|
||||
#right {
|
||||
position: absolute;
|
||||
left: 900px;
|
||||
top: 10px;
|
||||
@ -176,7 +199,8 @@ body{
|
||||
height: 630px;
|
||||
/* border: 1px solid rgb(238, 13, 13); */
|
||||
}
|
||||
#iconLib{
|
||||
|
||||
#iconLib {
|
||||
position: absolute;
|
||||
width: 435px;
|
||||
height: 620px;
|
||||
@ -184,38 +208,44 @@ body{
|
||||
top: 5px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.egameCanvas {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.gameCanvas {
|
||||
position: absolute;
|
||||
}
|
||||
#dataSelection , .appendSelection{
|
||||
|
||||
#dataSelection, .appendSelection {
|
||||
position: absolute;
|
||||
/* top:0;
|
||||
left:320px; */
|
||||
z-index:75;
|
||||
width:26px;
|
||||
height:26px;
|
||||
z-index: 75;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
margin: 3px 0 0 3px;
|
||||
padding:0;
|
||||
padding: 0;
|
||||
/* display: none; */
|
||||
box-sizing: border-box;
|
||||
background-color:rgba(255, 255, 255, 0.0);
|
||||
background-color: rgba(255, 255, 255, 0.0);
|
||||
border: 1px solid #000;
|
||||
box-shadow: 0 0 0 2px #fff,
|
||||
0 0 0 3px #000;
|
||||
}
|
||||
.warnText{
|
||||
|
||||
.warnText {
|
||||
color: #D50000;
|
||||
font-weight: 700;
|
||||
font-size: 14px;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
.infoText{
|
||||
|
||||
.infoText {
|
||||
color: #2196F3;
|
||||
}
|
||||
.successText{
|
||||
|
||||
.successText {
|
||||
color: #00897B;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
@ -223,20 +253,24 @@ body{
|
||||
table, td {
|
||||
border: 1px solid #fff;
|
||||
color: #fff;
|
||||
cursor:crosshair;
|
||||
cursor: crosshair;
|
||||
}
|
||||
table.col{
|
||||
|
||||
table.col {
|
||||
position: relative;
|
||||
|
||||
text-align: center;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.col td{
|
||||
|
||||
table.col td {
|
||||
background-color: #4DB6AC;
|
||||
}
|
||||
#arrColMark td{
|
||||
|
||||
#arrColMark td {
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
#arrColMark {
|
||||
top: 2px;
|
||||
left: 36px;
|
||||
@ -244,6 +278,7 @@ table.col td{
|
||||
height: 16px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
#mapColMark {
|
||||
top: 2px;
|
||||
left: 19px;
|
||||
@ -251,51 +286,60 @@ table.col td{
|
||||
height: 16px;
|
||||
font-size: 13px;
|
||||
}
|
||||
#mapColMark td{
|
||||
|
||||
#mapColMark td {
|
||||
width: 29px;
|
||||
}
|
||||
#mapColMark td:hover .colBlock{
|
||||
|
||||
#mapColMark td:hover .colBlock {
|
||||
position: absolute;
|
||||
top: 19px;
|
||||
height: 416px;
|
||||
width: 32px;
|
||||
z-index: 100;
|
||||
background-color: rgba(38,166,154,.5);
|
||||
background-color: rgba(38, 166, 154, .5);
|
||||
}
|
||||
table.row{
|
||||
|
||||
table.row {
|
||||
position: relative;
|
||||
text-align: right;
|
||||
vertical-align:middle;
|
||||
vertical-align: middle;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.row td{
|
||||
|
||||
table.row td {
|
||||
background-color: #4C221B;
|
||||
}
|
||||
#arrRowMark{
|
||||
|
||||
#arrRowMark {
|
||||
top: 5px;
|
||||
left: 2px;
|
||||
width: 16px;
|
||||
height: 262px;
|
||||
font-size: 12px;
|
||||
}
|
||||
#mapRowMark{
|
||||
|
||||
#mapRowMark {
|
||||
top: 1px;
|
||||
left: 2px;
|
||||
width: 16px;
|
||||
height: 416px;
|
||||
font-size: 12px;
|
||||
}
|
||||
#mapRowMark td{
|
||||
|
||||
#mapRowMark td {
|
||||
height: 29px;
|
||||
}
|
||||
#mapRowMark td:hover .rowBlock{
|
||||
|
||||
#mapRowMark td:hover .rowBlock {
|
||||
position: absolute;
|
||||
left: 18px;
|
||||
height: 32px;
|
||||
width: 416px;
|
||||
z-index: 100;
|
||||
background-color: rgba(76,34,27,.5);
|
||||
background-color: rgba(76, 34, 27, .5);
|
||||
}
|
||||
|
||||
/* for vue dom */
|
||||
[v-cloak] {
|
||||
display: none !important;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
.leftTab {
|
||||
border-radius: 2px;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0 2px 2px 0 rgba(0,0,0,.14), 0 3px 1px -2px rgba(0,0,0,.2), 0 1px 5px 0 rgba(0,0,0,.12);
|
||||
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
|
||||
}
|
||||
|
||||
.leftTab {
|
||||
@ -9,9 +9,18 @@
|
||||
position: absolute;
|
||||
height: 630px;
|
||||
}
|
||||
.leftTab > *{margin:2.5px 5px;}
|
||||
.leftTab > :first-child{margin-top:5px;}
|
||||
.leftTab > :last-child{margin-bottom:5px;}
|
||||
|
||||
.leftTab > * {
|
||||
margin: 2.5px 5px;
|
||||
}
|
||||
|
||||
.leftTab > :first-child {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.leftTab > :last-child {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.leftTab {
|
||||
left: 5px;
|
||||
@ -31,7 +40,7 @@
|
||||
|
||||
#appendPicSelection span {
|
||||
position: absolute;
|
||||
font-size:11px;
|
||||
font-size: 11px;
|
||||
-webkit-text-stroke: 1px red;
|
||||
text-shadow: black 1px 0, black 0 1px, black -1px 0, black 0 -1px;
|
||||
}
|
||||
@ -63,7 +72,12 @@
|
||||
height: 95%;
|
||||
width: 35%;
|
||||
}
|
||||
#left6 #codeArea {width: 99.5%; height: 15.4em;overflow:y;/* resize:none; */}
|
||||
|
||||
#left6 #codeArea {
|
||||
width: 99.5%;
|
||||
height: 15.4em;
|
||||
overflow: y; /* resize:none; */
|
||||
}
|
||||
|
||||
#left7 {
|
||||
/* height: 440px; width: 375px;float:left; */
|
||||
@ -75,6 +89,7 @@
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#left7 .CodeMirror {
|
||||
/* border-top: 1px solid black;
|
||||
border-bottom: 1px solid black; */
|
||||
@ -95,36 +110,54 @@
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.etable table {
|
||||
margin-top: 0;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.etable table {
|
||||
display: block;
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.etable table th {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.etable table th,
|
||||
.etable table td {
|
||||
padding: 6px 13px;
|
||||
border: 1px solid #dfe2e5;
|
||||
}
|
||||
|
||||
.etable table tr {
|
||||
background-color: #fff;
|
||||
border-top: 1px solid #c6cbd1;
|
||||
}
|
||||
|
||||
.etable table tr:nth-child(2n) {
|
||||
background-color: #f6f8fa;
|
||||
}
|
||||
|
||||
/* copy end --------------------------------------------- */
|
||||
|
||||
.etable tr {width:100%}
|
||||
.etable tr > :nth-child(1) {width:20%}
|
||||
.etable tr > :nth-child(2) {width:20%}
|
||||
.etable tr > :nth-child(3) {width:60%}
|
||||
.etable tr {
|
||||
width: 100%
|
||||
}
|
||||
|
||||
.etable tr > :nth-child(1) {
|
||||
width: 20%
|
||||
}
|
||||
|
||||
.etable tr > :nth-child(2) {
|
||||
width: 20%
|
||||
}
|
||||
|
||||
.etable tr > :nth-child(3) {
|
||||
width: 60%
|
||||
}
|
||||
|
||||
.etable table {
|
||||
overflow: visible;
|
||||
@ -188,6 +221,7 @@ div.etableInputDiv {
|
||||
.etableInputDiv textarea {
|
||||
resize: none;
|
||||
}
|
||||
|
||||
.etableInputDiv textarea:hover {
|
||||
margin: -5px;
|
||||
}
|
||||
|
||||
@ -3,39 +3,55 @@ function editor() {
|
||||
this.material = {};
|
||||
}
|
||||
|
||||
editor.prototype.init = function(callback){
|
||||
var afterCoreReset = function(){
|
||||
editor.prototype.init = function (callback) {
|
||||
var afterCoreReset = function () {
|
||||
|
||||
main.editor.disableGlobalAnimate=false;//允许GlobalAnimate
|
||||
main.editor.disableGlobalAnimate = false;//允许GlobalAnimate
|
||||
/* core.setHeroMoveTriggerInterval(); */
|
||||
|
||||
editor.reset(function(){
|
||||
editor.reset(function () {
|
||||
editor.drawMapBg();
|
||||
var mapArray = core.maps.save(core.status.maps,core.status.floorId);
|
||||
editor.map = mapArray.map(function(v){return v.map(function(v){return editor.ids[[editor.indexs[parseInt(v)][0]]]})});
|
||||
var mapArray = core.maps.save(core.status.maps, core.status.floorId);
|
||||
editor.map = mapArray.map(function (v) {
|
||||
return v.map(function (v) {
|
||||
return editor.ids[[editor.indexs[parseInt(v)][0]]]
|
||||
})
|
||||
});
|
||||
editor.updateMap();
|
||||
editor.currentFloorId=core.status.floorId;
|
||||
editor.currentFloorId = core.status.floorId;
|
||||
editor.currentFloorData = core.floors[core.status.floorId];
|
||||
|
||||
if (Boolean(callback))callback();
|
||||
if (Boolean(callback)) callback();
|
||||
});
|
||||
}
|
||||
|
||||
var afterMainInit = function(){
|
||||
core.floors=JSON.parse(JSON.stringify(core.floors,function(k,v){if(v instanceof Function){return v.toString()}else return v}));
|
||||
core.data=JSON.parse(JSON.stringify(core.data,function(k,v){if(v instanceof Function){return v.toString()}else return v}));
|
||||
data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d=JSON.parse(JSON.stringify(data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d,function(k,v){if(v instanceof Function){return v.toString()}else return v}));
|
||||
editor.main=main;
|
||||
editor.core=core;
|
||||
editor.fs=fs;
|
||||
editor_file = editor_file(editor, function() {
|
||||
editor.file=editor_file;
|
||||
var afterMainInit = function () {
|
||||
core.floors = JSON.parse(JSON.stringify(core.floors, function (k, v) {
|
||||
if (v instanceof Function) {
|
||||
return v.toString()
|
||||
} else return v
|
||||
}));
|
||||
core.data = JSON.parse(JSON.stringify(core.data, function (k, v) {
|
||||
if (v instanceof Function) {
|
||||
return v.toString()
|
||||
} else return v
|
||||
}));
|
||||
data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = JSON.parse(JSON.stringify(data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d, function (k, v) {
|
||||
if (v instanceof Function) {
|
||||
return v.toString()
|
||||
} else return v
|
||||
}));
|
||||
editor.main = main;
|
||||
editor.core = core;
|
||||
editor.fs = fs;
|
||||
editor_file = editor_file(editor, function () {
|
||||
editor.file = editor_file;
|
||||
editor_mode = editor_mode(editor);
|
||||
editor.mode=editor_mode;
|
||||
editor.material.images=core.material.images;
|
||||
editor.mode = editor_mode;
|
||||
editor.material.images = core.material.images;
|
||||
editor.listen(); // 开始监听事件
|
||||
core.resetStatus(core.firstData.hero, null, core.firstData.floorId, null, core.initStatus.maps);
|
||||
core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() {
|
||||
core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function () {
|
||||
afterCoreReset();
|
||||
}, true);
|
||||
core.events.setInitData(null);
|
||||
@ -44,90 +60,90 @@ editor.prototype.init = function(callback){
|
||||
afterMainInit();
|
||||
}
|
||||
|
||||
editor.prototype.reset = function(callback){
|
||||
editor.prototype.reset = function (callback) {
|
||||
editor.idsInit(core.maps, core.icons.icons); // 初始化图片素材信息
|
||||
editor.drawInitData(core.icons.icons); // 初始化绘图
|
||||
if(Boolean(callback))callback();
|
||||
if (Boolean(callback)) callback();
|
||||
}
|
||||
|
||||
editor.prototype.idsInit = function(maps, icons){
|
||||
editor.prototype.idsInit = function (maps, icons) {
|
||||
editor.ids = [0];
|
||||
editor.indexs = [];
|
||||
var MAX_NUM = 1000;
|
||||
var getInfoById = function(id){
|
||||
var getInfoById = function (id) {
|
||||
var block = maps.initBlock(0, 0, id);
|
||||
if(hasOwnProp(block, 'event')){
|
||||
if (hasOwnProp(block, 'event')) {
|
||||
return block;
|
||||
}
|
||||
}
|
||||
var point = 0;
|
||||
for(var i=0; i<MAX_NUM; i++){
|
||||
for (var i = 0; i < MAX_NUM; i++) {
|
||||
var indexBlock = getInfoById(i);
|
||||
editor.indexs[i] = [];
|
||||
if(indexBlock){
|
||||
if (indexBlock) {
|
||||
var id = indexBlock.event.id;
|
||||
var indexId = indexBlock.id;
|
||||
var allCls = Object.keys(icons);
|
||||
for(var j=0; j<allCls.length; j++){
|
||||
if(id in icons[allCls[j]] ){
|
||||
editor.ids.push({'idnum':indexId,'id':id,'images':allCls[j],'y':icons[allCls[j]][id]});
|
||||
for (var j = 0; j < allCls.length; j++) {
|
||||
if (id in icons[allCls[j]]) {
|
||||
editor.ids.push({'idnum': indexId, 'id': id, 'images': allCls[j], 'y': icons[allCls[j]][id]});
|
||||
point++;
|
||||
editor.indexs[i].push(point);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
editor.indexs[0]=[0];
|
||||
editor.indexs[0] = [0];
|
||||
}
|
||||
editor.prototype.drawInitData = function (icons) {
|
||||
var ratio=1;
|
||||
var images=editor.material.images;
|
||||
var maxHeight=700;
|
||||
var sumWidth=0;
|
||||
editor.widthsX={};
|
||||
var ratio = 1;
|
||||
var images = editor.material.images;
|
||||
var maxHeight = 700;
|
||||
var sumWidth = 0;
|
||||
editor.widthsX = {};
|
||||
// var imgNames = Object.keys(images); //还是固定顺序吧;
|
||||
var imgNames = ["terrains", "animates", "enemys", "enemy48", "items", "npcs", "npc48", "autotile"];
|
||||
|
||||
for(var ii=0; ii<imgNames.length; ii++){
|
||||
var img=imgNames[ii], tempy = 0;
|
||||
if(img == 'autotile'){
|
||||
for (var ii = 0; ii < imgNames.length; ii++) {
|
||||
var img = imgNames[ii], tempy = 0;
|
||||
if (img == 'autotile') {
|
||||
var autotiles = images[img];
|
||||
for(var im in autotiles){
|
||||
for (var im in autotiles) {
|
||||
tempy += autotiles[im].height;
|
||||
}
|
||||
editor.widthsX[img]=[img, sumWidth/32, (sumWidth+3*32)/32, tempy];
|
||||
sumWidth += 3*32;
|
||||
editor.widthsX[img] = [img, sumWidth / 32, (sumWidth + 3 * 32) / 32, tempy];
|
||||
sumWidth += 3 * 32;
|
||||
maxHeight = Math.max(maxHeight, tempy);
|
||||
continue;
|
||||
}
|
||||
if(img == 'terrains'){
|
||||
editor.widthsX[img]=[img, sumWidth/32, (sumWidth+images[img].width)/32, images[img].height+32]
|
||||
if (img == 'terrains') {
|
||||
editor.widthsX[img] = [img, sumWidth / 32, (sumWidth + images[img].width) / 32, images[img].height + 32]
|
||||
sumWidth += images[img].width;
|
||||
maxHeight = Math.max(maxHeight, images[img].height+32);
|
||||
maxHeight = Math.max(maxHeight, images[img].height + 32);
|
||||
continue;
|
||||
}
|
||||
editor.widthsX[img]=[img, sumWidth/32, (sumWidth+images[img].width)/32, images[img].height];
|
||||
editor.widthsX[img] = [img, sumWidth / 32, (sumWidth + images[img].width) / 32, images[img].height];
|
||||
sumWidth += images[img].width;
|
||||
maxHeight = Math.max(maxHeight, images[img].height);
|
||||
}
|
||||
var fullWidth=~~(sumWidth*ratio);
|
||||
var fullHeight=~~(maxHeight*ratio);
|
||||
var fullWidth = ~~(sumWidth * ratio);
|
||||
var fullHeight = ~~(maxHeight * ratio);
|
||||
|
||||
if (fullWidth > edata.width) edata.style.width = (edata.width = fullWidth)/ratio + 'px';
|
||||
edata.style.height = (edata.height = fullHeight)/ratio + 'px';
|
||||
if (fullWidth > edata.width) edata.style.width = (edata.width = fullWidth) / ratio + 'px';
|
||||
edata.style.height = (edata.height = fullHeight) / ratio + 'px';
|
||||
var dc = edata.getContext('2d');
|
||||
var nowx = 0;
|
||||
var nowy = 0;
|
||||
for(var ii=0; ii<imgNames.length; ii++){
|
||||
var img=imgNames[ii];
|
||||
if(img == 'terrains'){
|
||||
for (var ii = 0; ii < imgNames.length; ii++) {
|
||||
var img = imgNames[ii];
|
||||
if (img == 'terrains') {
|
||||
dc.drawImage(images[img], nowx, 32);
|
||||
nowx += images[img].width;
|
||||
continue;
|
||||
}
|
||||
if(img == 'autotile'){
|
||||
if (img == 'autotile') {
|
||||
var autotiles = images[img];
|
||||
for(var im in autotiles){
|
||||
for (var im in autotiles) {
|
||||
dc.drawImage(autotiles[im], nowx, nowy);
|
||||
nowy += autotiles[im].height;
|
||||
}
|
||||
@ -140,65 +156,69 @@ editor.prototype.drawInitData = function (icons) {
|
||||
//editor.drawMapBg();
|
||||
//editor.mapInit();
|
||||
}
|
||||
editor.prototype.mapInit = function(){
|
||||
editor.prototype.mapInit = function () {
|
||||
var ec = document.getElementById('event').getContext('2d');
|
||||
ec.clearRect(0, 0, 416, 416);
|
||||
document.getElementById('event2').getContext('2d').clearRect(0,0,416,416);
|
||||
document.getElementById('event2').getContext('2d').clearRect(0, 0, 416, 416);
|
||||
editor.map = [];
|
||||
for(var y=0; y<13; y++){
|
||||
for (var y = 0; y < 13; y++) {
|
||||
editor.map[y] = [];
|
||||
for(var x = 0; x<13; x++){
|
||||
for (var x = 0; x < 13; x++) {
|
||||
editor.map[y][x] = 0;
|
||||
}
|
||||
}
|
||||
editor.currentFloorData.map=editor.map;
|
||||
editor.currentFloorData.firstArrive=[];
|
||||
editor.currentFloorData.events={};
|
||||
editor.currentFloorData.changeFloor={};
|
||||
editor.currentFloorData.afterBattle={};
|
||||
editor.currentFloorData.afterGetItem={};
|
||||
editor.currentFloorData.afterOpenDoor={};
|
||||
editor.currentFloorData.cannotMove={};
|
||||
editor.currentFloorData.map = editor.map;
|
||||
editor.currentFloorData.firstArrive = [];
|
||||
editor.currentFloorData.events = {};
|
||||
editor.currentFloorData.changeFloor = {};
|
||||
editor.currentFloorData.afterBattle = {};
|
||||
editor.currentFloorData.afterGetItem = {};
|
||||
editor.currentFloorData.afterOpenDoor = {};
|
||||
editor.currentFloorData.cannotMove = {};
|
||||
}
|
||||
editor.prototype.drawMapBg = function(img){
|
||||
editor.prototype.drawMapBg = function (img) {
|
||||
var bgc = bg.getContext('2d');
|
||||
if (!core.isset(editor.bgY) || editor.bgY == 0){
|
||||
if (!core.isset(editor.bgY) || editor.bgY == 0) {
|
||||
editor.main.editor.drawMapBg();
|
||||
return;
|
||||
}
|
||||
|
||||
for (var ii = 0; ii < 13; ii++)
|
||||
for (var jj = 0; jj < 13; jj++) {
|
||||
bgc.clearRect(ii*32, jj*32, 32, 32);
|
||||
bgc.drawImage(editor.material.images['terrains'], 0, 32*(editor.bgY||0), 32, 32, ii*32, jj*32, 32, 32);
|
||||
bgc.clearRect(ii * 32, jj * 32, 32, 32);
|
||||
bgc.drawImage(editor.material.images['terrains'], 0, 32 * (editor.bgY || 0), 32, 32, ii * 32, jj * 32, 32, 32);
|
||||
}
|
||||
if(img){
|
||||
if (img) {
|
||||
bgc.drawImage(img, 0, 0, 416, 416);
|
||||
}
|
||||
}
|
||||
|
||||
editor.prototype.updateMap = function(){
|
||||
var blocks = main.editor.mapIntoBlocks(editor.map.map(function(v){return v.map(function(v){return v.idnum||v||0})}),{'events':{},'changeFloor':{}});
|
||||
editor.prototype.updateMap = function () {
|
||||
var blocks = main.editor.mapIntoBlocks(editor.map.map(function (v) {
|
||||
return v.map(function (v) {
|
||||
return v.idnum || v || 0
|
||||
})
|
||||
}), {'events': {}, 'changeFloor': {}});
|
||||
core.status.thisMap.blocks = blocks;
|
||||
main.editor.updateMap();
|
||||
|
||||
var drawTile = function(ctx, x, y, tileInfo){ // 绘制一个普通块
|
||||
var drawTile = function (ctx, x, y, tileInfo) { // 绘制一个普通块
|
||||
|
||||
//ctx.clearRect(x*32, y*32, 32, 32);
|
||||
if(tileInfo == 0) return;
|
||||
if (tileInfo == 0) return;
|
||||
|
||||
if(typeof(tileInfo) == typeof([][0]) || !hasOwnProp(tileInfo, 'idnum')) {//未定义块画红块
|
||||
if(typeof(tileInfo) != typeof([][0]) && hasOwnProp(tileInfo, 'images')){
|
||||
ctx.drawImage(editor.material.images[tileInfo.images], 0, tileInfo.y*32, 32, 32, x*32, y*32, 32, 32);
|
||||
if (typeof(tileInfo) == typeof([][0]) || !hasOwnProp(tileInfo, 'idnum')) {//未定义块画红块
|
||||
if (typeof(tileInfo) != typeof([][0]) && hasOwnProp(tileInfo, 'images')) {
|
||||
ctx.drawImage(editor.material.images[tileInfo.images], 0, tileInfo.y * 32, 32, 32, x * 32, y * 32, 32, 32);
|
||||
}
|
||||
ctx.strokeStyle = 'red';
|
||||
var OFFSET = 2;
|
||||
ctx.lineWidth = OFFSET;
|
||||
ctx.strokeRect(x*32+OFFSET, y*32+OFFSET, 32-OFFSET*2, 32-OFFSET*2);
|
||||
ctx.strokeRect(x * 32 + OFFSET, y * 32 + OFFSET, 32 - OFFSET * 2, 32 - OFFSET * 2);
|
||||
ctx.font = "30px Verdana";
|
||||
ctx.textAlign = 'center'
|
||||
ctx.fillStyle = 'red';
|
||||
ctx.fillText("?", x*32+16, y*32+27);
|
||||
ctx.fillText("?", x * 32 + 16, y * 32 + 27);
|
||||
return;
|
||||
}
|
||||
//ctx.drawImage(editor.material.images[tileInfo.images], 0, tileInfo.y*32, 32, 32, x*32, y*32, 32, 32);
|
||||
@ -291,43 +311,53 @@ editor.prototype.updateMap = function(){
|
||||
*/
|
||||
// 绘制地图 start
|
||||
var eventCtx = document.getElementById('event').getContext("2d");
|
||||
for(var y=0; y<13; y++)
|
||||
for(var x=0; x<13; x++){
|
||||
for (var y = 0; y < 13; y++)
|
||||
for (var x = 0; x < 13; x++) {
|
||||
var tileInfo = editor.map[y][x];
|
||||
if(false && isAutotile(tileInfo)){
|
||||
if (false && isAutotile(tileInfo)) {
|
||||
addIndexToAutotileInfo(x, y);
|
||||
drawAutotile(eventCtx, x, y, tileInfo);
|
||||
}else drawTile(eventCtx, x, y, tileInfo);
|
||||
} else drawTile(eventCtx, x, y, tileInfo);
|
||||
}
|
||||
// 绘制地图 end
|
||||
}
|
||||
|
||||
editor.prototype.changeFloor = function(floorId,callback) {
|
||||
editor.currentFloorData.map = editor.map.map(function(v){return v.map(function(v){return v.idnum||v||0})});
|
||||
core.changeFloor(floorId, null, core.firstData.hero.loc, null, function(){
|
||||
editor.prototype.changeFloor = function (floorId, callback) {
|
||||
editor.currentFloorData.map = editor.map.map(function (v) {
|
||||
return v.map(function (v) {
|
||||
return v.idnum || v || 0
|
||||
})
|
||||
});
|
||||
core.changeFloor(floorId, null, core.firstData.hero.loc, null, function () {
|
||||
editor.drawMapBg();
|
||||
var mapArray = core.maps.save(core.status.maps,core.status.floorId);
|
||||
editor.map = mapArray.map(function(v){return v.map(function(v){return editor.ids[[editor.indexs[parseInt(v)][0]]]})});
|
||||
var mapArray = core.maps.save(core.status.maps, core.status.floorId);
|
||||
editor.map = mapArray.map(function (v) {
|
||||
return v.map(function (v) {
|
||||
return editor.ids[[editor.indexs[parseInt(v)][0]]]
|
||||
})
|
||||
});
|
||||
editor.updateMap();
|
||||
editor.currentFloorId=core.status.floorId;
|
||||
editor.currentFloorId = core.status.floorId;
|
||||
editor.currentFloorData = core.floors[core.status.floorId];
|
||||
editor_mode.floor();
|
||||
if (core.isset(callback))callback();
|
||||
if (core.isset(callback)) callback();
|
||||
});
|
||||
}
|
||||
|
||||
editor.prototype.guid = function() {
|
||||
return 'id_'+'xxxxxxxx_xxxx_4xxx_yxxx_xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
|
||||
editor.prototype.guid = function () {
|
||||
return 'id_' + 'xxxxxxxx_xxxx_4xxx_yxxx_xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
||||
return v.toString(16);
|
||||
});
|
||||
}
|
||||
|
||||
editor.prototype.HTMLescape = function(str_) {
|
||||
return String(str_).split('').map(function(v){return '&#'+v.charCodeAt(0)+';'}).join('');
|
||||
editor.prototype.HTMLescape = function (str_) {
|
||||
return String(str_).split('').map(function (v) {
|
||||
return '&#' + v.charCodeAt(0) + ';'
|
||||
}).join('');
|
||||
}
|
||||
|
||||
editor.prototype.listen = function() {
|
||||
editor.prototype.listen = function () {
|
||||
|
||||
var uc = eui.getContext('2d');
|
||||
|
||||
@ -340,14 +370,15 @@ editor.prototype.listen = function() {
|
||||
var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft
|
||||
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop
|
||||
editor.loc = {
|
||||
'x': scrollLeft+e.clientX - mid.offsetLeft-mapEdit.offsetLeft,
|
||||
'y': scrollTop+e.clientY - mid.offsetTop-mapEdit.offsetTop,
|
||||
'x': scrollLeft + e.clientX - mid.offsetLeft - mapEdit.offsetLeft,
|
||||
'y': scrollTop + e.clientY - mid.offsetTop - mapEdit.offsetTop,
|
||||
'size': 32
|
||||
};
|
||||
return editor.loc; }//返回可用的组件内坐标
|
||||
return editor.loc;
|
||||
}//返回可用的组件内坐标
|
||||
|
||||
function locToPos(loc) {
|
||||
editor.pos = { 'x': ~~(loc.x / loc.size), 'y': ~~(loc.y / loc.size) }
|
||||
editor.pos = {'x': ~~(loc.x / loc.size), 'y': ~~(loc.y / loc.size)}
|
||||
return editor.pos;
|
||||
}
|
||||
|
||||
@ -355,6 +386,7 @@ editor.prototype.listen = function() {
|
||||
var stepPostfix = null;//用于存放寻路检测的第一个点之后的后续移动
|
||||
|
||||
var mouseOutCheck = 2;
|
||||
|
||||
function clear1() {
|
||||
if (mouseOutCheck > 1) {
|
||||
mouseOutCheck--;
|
||||
@ -367,7 +399,7 @@ editor.prototype.listen = function() {
|
||||
}//用于鼠标移出canvas时的自动清除状态
|
||||
|
||||
eui.onmousedown = function (e) {
|
||||
if(!selectBox.isSelected) {
|
||||
if (!selectBox.isSelected) {
|
||||
var loc = eToLoc(e);
|
||||
var pos = locToPos(loc);
|
||||
editor_mode.onmode('nextChange');
|
||||
@ -390,12 +422,14 @@ editor.prototype.listen = function() {
|
||||
}
|
||||
|
||||
eui.onmousemove = function (e) {
|
||||
if(!selectBox.isSelected) {
|
||||
if (!selectBox.isSelected) {
|
||||
// tip.whichShow = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (holdingPath == 0) { return; }
|
||||
if (holdingPath == 0) {
|
||||
return;
|
||||
}
|
||||
mouseOutCheck = 2;
|
||||
e.stopPropagation();
|
||||
var loc = eToLoc(e);
|
||||
@ -409,7 +443,7 @@ editor.prototype.listen = function() {
|
||||
max = directionDistance[i];
|
||||
}
|
||||
}
|
||||
var pos = [{ 'x': 0, 'y': 1 }, { 'x': -1, 'y': 0 }, { 'x': 0, 'y': -1 }, { 'x': 1, 'y': 0 }, false][index]
|
||||
var pos = [{'x': 0, 'y': 1}, {'x': -1, 'y': 0}, {'x': 0, 'y': -1}, {'x': 1, 'y': 0}, false][index]
|
||||
if (pos) {
|
||||
pos.x += pos0.x;
|
||||
pos.y += pos0.y;
|
||||
@ -419,7 +453,7 @@ editor.prototype.listen = function() {
|
||||
}
|
||||
|
||||
eui.onmouseup = function (e) {
|
||||
if(!selectBox.isSelected) {
|
||||
if (!selectBox.isSelected) {
|
||||
tip.whichShow = 1;
|
||||
return;
|
||||
}
|
||||
@ -448,22 +482,22 @@ editor.prototype.listen = function() {
|
||||
info: {}
|
||||
};
|
||||
var reDo = null;
|
||||
document.body.onkeydown = function(e) {
|
||||
document.body.onkeydown = function (e) {
|
||||
// 禁止快捷键的默认行为
|
||||
if( e.ctrlKey && ( e.keyCode == 90 || e.keyCode == 89 ) )
|
||||
if (e.ctrlKey && ( e.keyCode == 90 || e.keyCode == 89 ))
|
||||
e.preventDefault();
|
||||
//Ctrl+z 撤销上一步undo
|
||||
if(e.keyCode == 90 && e.ctrlKey && preMapData && currDrawData.pos.length && selectBox.isSelected){
|
||||
if (e.keyCode == 90 && e.ctrlKey && preMapData && currDrawData.pos.length && selectBox.isSelected) {
|
||||
editor.map = JSON.parse(JSON.stringify(preMapData));
|
||||
editor.updateMap();
|
||||
reDo = JSON.parse(JSON.stringify(currDrawData));
|
||||
currDrawData = {pos: [],info: {}};
|
||||
currDrawData = {pos: [], info: {}};
|
||||
preMapData = null;
|
||||
}
|
||||
//Ctrl+y 重做一步redo
|
||||
if(e.keyCode == 89 && e.ctrlKey && reDo && reDo.pos.length && selectBox.isSelected){
|
||||
if (e.keyCode == 89 && e.ctrlKey && reDo && reDo.pos.length && selectBox.isSelected) {
|
||||
preMapData = JSON.parse(JSON.stringify(editor.map));
|
||||
for(var j=0; j<reDo.pos.length;j++)
|
||||
for (var j = 0; j < reDo.pos.length; j++)
|
||||
editor.map[reDo.pos[j].y][reDo.pos[j].x] = JSON.parse(JSON.stringify(reDo.info));
|
||||
|
||||
editor.updateMap();
|
||||
@ -477,54 +511,54 @@ editor.prototype.listen = function() {
|
||||
var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
|
||||
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
|
||||
var loc = {
|
||||
'x': scrollLeft + e.clientX + iconLib.scrollLeft - right.offsetLeft-iconLib.offsetLeft,
|
||||
'y': scrollTop + e.clientY + iconLib.scrollTop - right.offsetTop-iconLib.offsetTop,
|
||||
'x': scrollLeft + e.clientX + iconLib.scrollLeft - right.offsetLeft - iconLib.offsetLeft,
|
||||
'y': scrollTop + e.clientY + iconLib.scrollTop - right.offsetTop - iconLib.offsetTop,
|
||||
'size': 32
|
||||
};
|
||||
editor.loc = loc;
|
||||
var pos = locToPos(loc);
|
||||
for (var spriter in editor.widthsX){
|
||||
if(pos.x>=editor.widthsX[spriter][1] && pos.x<editor.widthsX[spriter][2]){
|
||||
var ysize = spriter.indexOf('48')===-1?32:48;
|
||||
for (var spriter in editor.widthsX) {
|
||||
if (pos.x >= editor.widthsX[spriter][1] && pos.x < editor.widthsX[spriter][2]) {
|
||||
var ysize = spriter.indexOf('48') === -1 ? 32 : 48;
|
||||
loc.ysize = ysize;
|
||||
pos.y = ~~(loc.y / loc.ysize);
|
||||
pos.x=editor.widthsX[spriter][1];
|
||||
pos.x = editor.widthsX[spriter][1];
|
||||
pos.images = editor.widthsX[spriter][0];
|
||||
var autotiles = editor.material.images['autotile'];
|
||||
if(pos.images=='autotile'){
|
||||
if (pos.images == 'autotile') {
|
||||
var imNames = Object.keys(autotiles);
|
||||
if((pos.y+1)*ysize > editor.widthsX[spriter][3])
|
||||
pos.y = ~~(editor.widthsX[spriter][3]/ysize)-4;
|
||||
else{
|
||||
for(var i=0; i<imNames.length; i++){
|
||||
if(pos.y >= 4*i && pos.y < 4*(i+1)){
|
||||
if ((pos.y + 1) * ysize > editor.widthsX[spriter][3])
|
||||
pos.y = ~~(editor.widthsX[spriter][3] / ysize) - 4;
|
||||
else {
|
||||
for (var i = 0; i < imNames.length; i++) {
|
||||
if (pos.y >= 4 * i && pos.y < 4 * (i + 1)) {
|
||||
pos.images = imNames[i];
|
||||
pos.y = 4*i;
|
||||
pos.y = 4 * i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if((pos.y+1)*ysize > editor.widthsX[spriter][3])
|
||||
pos.y = ~~(editor.widthsX[spriter][3]/ysize)-1;
|
||||
} else if ((pos.y + 1) * ysize > editor.widthsX[spriter][3])
|
||||
pos.y = ~~(editor.widthsX[spriter][3] / ysize) - 1;
|
||||
|
||||
selectBox.isSelected = true;
|
||||
// console.log(pos,editor.material.images[pos.images].height)
|
||||
dataSelection.style.left = pos.x*32 +'px';
|
||||
dataSelection.style.top = pos.y*ysize +'px';
|
||||
dataSelection.style.height = ysize-6+'px';
|
||||
dataSelection.style.left = pos.x * 32 + 'px';
|
||||
dataSelection.style.top = pos.y * ysize + 'px';
|
||||
dataSelection.style.height = ysize - 6 + 'px';
|
||||
|
||||
if(pos.x==0&&pos.y==0){
|
||||
if (pos.x == 0 && pos.y == 0) {
|
||||
// editor.info={idnum:0, id:'empty','images':'清除块', 'y':0};
|
||||
editor.info=0;
|
||||
}else{
|
||||
if(hasOwnProp(autotiles, pos.images)) editor.info={'images':pos.images, 'y':0};
|
||||
else if(pos.images == 'terrains') editor.info={'images':pos.images, 'y':pos.y-1};
|
||||
else editor.info={'images':pos.images, 'y':pos.y};
|
||||
editor.info = 0;
|
||||
} else {
|
||||
if (hasOwnProp(autotiles, pos.images)) editor.info = {'images': pos.images, 'y': 0};
|
||||
else if (pos.images == 'terrains') editor.info = {'images': pos.images, 'y': pos.y - 1};
|
||||
else editor.info = {'images': pos.images, 'y': pos.y};
|
||||
|
||||
for (var ii=0;ii<editor.ids.length;ii++){
|
||||
if( ( editor.info.images==editor.ids[ii].images
|
||||
&& editor.info.y==editor.ids[ii].y )
|
||||
|| (hasOwnProp(autotiles, pos.images) && editor.info.images==editor.ids[ii].id
|
||||
&& editor.info.y==editor.ids[ii].y)){
|
||||
for (var ii = 0; ii < editor.ids.length; ii++) {
|
||||
if (( editor.info.images == editor.ids[ii].images
|
||||
&& editor.info.y == editor.ids[ii].y )
|
||||
|| (hasOwnProp(autotiles, pos.images) && editor.info.images == editor.ids[ii].id
|
||||
&& editor.info.y == editor.ids[ii].y)) {
|
||||
|
||||
editor.info = editor.ids[ii];
|
||||
break;
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
editor_blockly = function(){
|
||||
editor_blockly = function () {
|
||||
|
||||
var editor_blockly = {};
|
||||
var editor_blockly = {};
|
||||
|
||||
initscript=String.raw`
|
||||
initscript = String.raw`
|
||||
(function(){
|
||||
var getCategory = function(name){
|
||||
for(var node of document.getElementById('toolbox').children) {
|
||||
@ -278,8 +278,8 @@ document.getElementById('blocklyDiv').onmousewheel = function(e){
|
||||
})();
|
||||
`;
|
||||
|
||||
var input_='';
|
||||
editor_blockly.runOne = function (){
|
||||
var input_ = '';
|
||||
editor_blockly.runOne = function () {
|
||||
//var printf = console.log;
|
||||
//var printf = function(){};
|
||||
var grammerFile = input_;
|
||||
@ -293,43 +293,42 @@ editor_blockly.runOne = function (){
|
||||
//console.log(converter);
|
||||
|
||||
|
||||
|
||||
var script = document.createElement('script');
|
||||
//var initscript = document.getElementById('initscript').innerText;
|
||||
script.innerHTML = converter.mainFile[5]+initscript;
|
||||
script.innerHTML = converter.mainFile[5] + initscript;
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
var xhr=new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function (){
|
||||
if(xhr.readyState!=4) return;
|
||||
if(xhr.status!=200) {
|
||||
}
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState != 4) return;
|
||||
if (xhr.status != 200) {
|
||||
alert("无法在file://下加载");
|
||||
return;
|
||||
}
|
||||
input_=xhr.responseText;
|
||||
input_ = xhr.responseText;
|
||||
editor_blockly.runOne();
|
||||
}
|
||||
xhr.open('GET','_server/blockly/MotaAction.g4',true);
|
||||
xhr.send(null);
|
||||
}
|
||||
xhr.open('GET', '_server/blockly/MotaAction.g4', true);
|
||||
xhr.send(null);
|
||||
|
||||
codeAreaHL = CodeMirror.fromTextArea(document.getElementById("codeArea"), {
|
||||
codeAreaHL = CodeMirror.fromTextArea(document.getElementById("codeArea"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
lineWrapping: true,
|
||||
continueComments: "Enter",
|
||||
extraKeys: {"Ctrl-Q": "toggleComment"}
|
||||
});
|
||||
});
|
||||
|
||||
editor_blockly.showXML = function () {
|
||||
editor_blockly.showXML = function () {
|
||||
var xml = Blockly.Xml.workspaceToDom(editor_blockly.workspace);
|
||||
var xml_text = Blockly.Xml.domToPrettyText(xml);
|
||||
console.log(xml_text);
|
||||
var xml_text = Blockly.Xml.domToText(xml);
|
||||
console.log(xml_text);
|
||||
console.log(xml);
|
||||
}
|
||||
}
|
||||
|
||||
editor_blockly.runCode = function () {
|
||||
editor_blockly.runCode = function () {
|
||||
// Generate JavaScript code and run it.
|
||||
window.LoopTrap = 1000;
|
||||
Blockly.JavaScript.INFINITE_LOOP_TRAP =
|
||||
@ -342,97 +341,100 @@ editor_blockly.runCode = function () {
|
||||
} catch (e) {
|
||||
alert(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
editor_blockly.parse = function () {
|
||||
editor_blockly.parse = function () {
|
||||
MotaActionFunctions.parse(
|
||||
eval('obj=' + codeAreaHL.getValue().replace(/[<>&]/g,function(c){return {'<':'<','>':'>','&':'&'}[c];})),
|
||||
eval('obj=' + codeAreaHL.getValue().replace(/[<>&]/g, function (c) {
|
||||
return {'<': '<', '>': '>', '&': '&'}[c];
|
||||
})),
|
||||
document.getElementById('entryType').value
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
editor_blockly.id='';
|
||||
editor_blockly.id = '';
|
||||
|
||||
editor_blockly.import = function(id_,args){
|
||||
editor_blockly.import = function (id_, args) {
|
||||
var thisTr = document.getElementById(id_);
|
||||
if(!thisTr)return false;
|
||||
if (!thisTr) return false;
|
||||
var input = thisTr.children[2].children[0].children[0];
|
||||
var field = thisTr.children[0].getAttribute('title');
|
||||
var type = args.type;
|
||||
if(!type)return false;
|
||||
editor_blockly.id=id_;
|
||||
if (!type) return false;
|
||||
editor_blockly.id = id_;
|
||||
codeAreaHL.setValue(input.value);
|
||||
document.getElementById('entryType').value = type;
|
||||
editor_blockly.parse();
|
||||
editor_blockly.show();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
var blocklyWidgetDiv = document.getElementsByClassName('blocklyWidgetDiv');
|
||||
editor_blockly.show = function(){
|
||||
if(typeof(selectBox)!==typeof(undefined))selectBox.isSelected = false;
|
||||
document.getElementById('left6').style='';
|
||||
for(var ii =0,node;node=blocklyWidgetDiv[ii];ii++){
|
||||
var blocklyWidgetDiv = document.getElementsByClassName('blocklyWidgetDiv');
|
||||
editor_blockly.show = function () {
|
||||
if (typeof(selectBox) !== typeof(undefined)) selectBox.isSelected = false;
|
||||
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++){
|
||||
}
|
||||
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='';
|
||||
editor_blockly.cancel = function () {
|
||||
editor_blockly.id = '';
|
||||
editor_blockly.hide();
|
||||
}
|
||||
}
|
||||
|
||||
editor_blockly.confirm = function (){
|
||||
if(!editor_blockly.id){
|
||||
editor_blockly.id='';
|
||||
editor_blockly.confirm = function () {
|
||||
if (!editor_blockly.id) {
|
||||
editor_blockly.id = '';
|
||||
return;
|
||||
}
|
||||
var setvalue = function(value){
|
||||
var setvalue = function (value) {
|
||||
var thisTr = document.getElementById(editor_blockly.id);
|
||||
editor_blockly.id='';
|
||||
editor_blockly.id = '';
|
||||
var input = thisTr.children[2].children[0].children[0];
|
||||
input.value = value;
|
||||
editor_blockly.hide();
|
||||
input.onchange();
|
||||
}
|
||||
if(codeAreaHL.getValue()===''){
|
||||
if (codeAreaHL.getValue() === '') {
|
||||
setvalue('null');
|
||||
return;
|
||||
}
|
||||
var code = Blockly.JavaScript.workspaceToCode(editor_blockly.workspace);
|
||||
eval('var obj=' + code);
|
||||
setvalue(JSON.stringify(obj));
|
||||
}
|
||||
}
|
||||
|
||||
editor_blockly.doubleClickBlock = function (blockId){
|
||||
var b=editor_blockly.workspace.getBlockById(blockId);
|
||||
editor_blockly.doubleClickBlock = function (blockId) {
|
||||
var b = editor_blockly.workspace.getBlockById(blockId);
|
||||
//console.log(b);
|
||||
var textStringDict = {
|
||||
'text_0_s':'EvalString_0',
|
||||
'text_1_s':'EvalString_2',
|
||||
'autoText_s':'EvalString_2',
|
||||
'choices_s':'EvalString_0',
|
||||
'function_s':'RawEvalString_0',
|
||||
'text_0_s': 'EvalString_0',
|
||||
'text_1_s': 'EvalString_2',
|
||||
'autoText_s': 'EvalString_2',
|
||||
'choices_s': 'EvalString_0',
|
||||
'function_s': 'RawEvalString_0',
|
||||
}
|
||||
var f=b?textStringDict[b.type]:null;
|
||||
if(f){
|
||||
var f = b ? textStringDict[b.type] : null;
|
||||
if (f) {
|
||||
var value = b.getFieldValue(f);
|
||||
//多行编辑
|
||||
editor_multi.multiLineEdit(value,b,f,{'lint':f==='RawEvalString_0'},function(newvalue,b,f){
|
||||
if(textStringDict[b.type]!=='RawEvalString_0'){}
|
||||
b.setFieldValue(newvalue.split('\n').join('\\n'),f);
|
||||
editor_multi.multiLineEdit(value, b, f, {'lint': f === 'RawEvalString_0'}, function (newvalue, b, f) {
|
||||
if (textStringDict[b.type] !== 'RawEvalString_0') {
|
||||
}
|
||||
b.setFieldValue(newvalue.split('\n').join('\\n'), f);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return editor_blockly;
|
||||
return editor_blockly;
|
||||
}
|
||||
//editor_blockly=editor_blockly();
|
||||
@ -1,44 +1,54 @@
|
||||
editor_file = function(editor, callback){
|
||||
editor_file = function (editor, callback) {
|
||||
|
||||
var editor_file = {};
|
||||
|
||||
|
||||
var commentjs={
|
||||
'comment':'comment',
|
||||
'data.comment':'dataComment',
|
||||
'functions.comment':'functionsComment',
|
||||
var commentjs = {
|
||||
'comment': 'comment',
|
||||
'data.comment': 'dataComment',
|
||||
'functions.comment': 'functionsComment',
|
||||
}
|
||||
for(var key in commentjs){
|
||||
(function(key){
|
||||
for (var key in commentjs) {
|
||||
(function (key) {
|
||||
var value = commentjs[key];
|
||||
var script = document.createElement('script');
|
||||
if (window.location.href.indexOf('_server')!==-1)
|
||||
script.src = '../project/'+key+'.js';
|
||||
if (window.location.href.indexOf('_server') !== -1)
|
||||
script.src = '../project/' + key + '.js';
|
||||
else
|
||||
script.src = 'project/'+key+'.js';
|
||||
script.src = 'project/' + key + '.js';
|
||||
document.body.appendChild(script);
|
||||
script.onload = function () {
|
||||
editor_file[value]=eval(key.replace('.','_')+'_c456ea59_6018_45ef_8bcc_211a24c627dc');
|
||||
editor_file[value] = eval(key.replace('.', '_') + '_c456ea59_6018_45ef_8bcc_211a24c627dc');
|
||||
var loaded = Boolean(callback);
|
||||
for(var key_ in commentjs){loaded = loaded && editor_file[commentjs[key_]]}
|
||||
if (loaded)callback();
|
||||
for (var key_ in commentjs) {
|
||||
loaded = loaded && editor_file[commentjs[key_]]
|
||||
}
|
||||
if (loaded) callback();
|
||||
}
|
||||
})(key);
|
||||
}
|
||||
|
||||
|
||||
editor_file.getFloorFileList = function(callback){
|
||||
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
|
||||
editor_file.getFloorFileList = function (callback) {
|
||||
if (!isset(callback)) {
|
||||
printe('未设置callback');
|
||||
throw('未设置callback')
|
||||
}
|
||||
;
|
||||
/* var fs = editor.fs;
|
||||
fs.readdir('project/floors',function(err, data){
|
||||
callback([data,err]);
|
||||
}); */
|
||||
callback([editor.core.floorIds,null]);
|
||||
callback([editor.core.floorIds, null]);
|
||||
}
|
||||
//callback([Array<String>,err:String])
|
||||
editor_file.loadFloorFile = function(filename,callback){
|
||||
editor_file.loadFloorFile = function (filename, callback) {
|
||||
//filename不含'/'不含'.js'
|
||||
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
|
||||
if (!isset(callback)) {
|
||||
printe('未设置callback');
|
||||
throw('未设置callback')
|
||||
}
|
||||
;
|
||||
/* var fs = editor.fs;
|
||||
fs.readFile('project/floors/'+filename+'.js','utf-8',function(err, data){
|
||||
if (err!=null){callback(err);return;}
|
||||
@ -58,63 +68,97 @@ editor_file = function(editor, callback){
|
||||
editor.currentFloorData = floorData;
|
||||
callback(null)
|
||||
}); */
|
||||
editor.currentFloorId=editor.core.status.floorId;
|
||||
editor.currentFloorId = editor.core.status.floorId;
|
||||
editor.currentFloorData = editor.core.floors[editor.currentFloorId];
|
||||
}
|
||||
//callback(err:String)
|
||||
editor_file.saveFloorFile = function(callback){
|
||||
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
|
||||
editor_file.saveFloorFile = function (callback) {
|
||||
if (!isset(callback)) {
|
||||
printe('未设置callback');
|
||||
throw('未设置callback')
|
||||
}
|
||||
;
|
||||
/* if (!isset(editor.currentFloorId) || !isset(editor.currentFloorData)) {
|
||||
callback('未选中文件或无数据');
|
||||
} */
|
||||
var filename = 'project/floors/' + editor.currentFloorId + '.js';
|
||||
var datastr = ['main.floors.' , editor.currentFloorId , '=\n{'];
|
||||
var datastr = ['main.floors.', editor.currentFloorId, '=\n{'];
|
||||
if (editor.currentFloorData.map == 'new')
|
||||
editor.currentFloorData.map = editor.map.map(function(v){return v.map(function(){return 0})});
|
||||
editor.currentFloorData.map = editor.map.map(function (v) {
|
||||
return v.map(function () {
|
||||
return 0
|
||||
})
|
||||
});
|
||||
else
|
||||
editor.currentFloorData.map = editor.map.map(function(v){return v.map(function(v){return v.idnum||v||0})});
|
||||
for(var ii in editor.currentFloorData)
|
||||
editor.currentFloorData.map = editor.map.map(function (v) {
|
||||
return v.map(function (v) {
|
||||
return v.idnum || v || 0
|
||||
})
|
||||
});
|
||||
for (var ii in editor.currentFloorData)
|
||||
if (editor.currentFloorData.hasOwnProperty(ii)) {
|
||||
if (ii=='map')
|
||||
datastr=datastr.concat(['\n"',ii,'": [\n',formatMap(editor.currentFloorData[ii]),'\n],']);
|
||||
if (ii == 'map')
|
||||
datastr = datastr.concat(['\n"', ii, '": [\n', formatMap(editor.currentFloorData[ii]), '\n],']);
|
||||
else
|
||||
datastr=datastr.concat(['\n"',ii,'": ',JSON.stringify(editor.currentFloorData[ii],null,4),',']);
|
||||
datastr = datastr.concat(['\n"', ii, '": ', JSON.stringify(editor.currentFloorData[ii], null, 4), ',']);
|
||||
}
|
||||
datastr=datastr.concat(['\n}']);
|
||||
datastr=datastr.join('');
|
||||
fs.writeFile(filename,encode(datastr),'base64',function(err, data){
|
||||
datastr = datastr.concat(['\n}']);
|
||||
datastr = datastr.join('');
|
||||
fs.writeFile(filename, encode(datastr), 'base64', function (err, data) {
|
||||
callback(err);
|
||||
});
|
||||
}
|
||||
//callback(err:String)
|
||||
editor_file.saveNewFile = function(saveFilename,callback){
|
||||
editor_file.saveNewFile = function (saveFilename, callback) {
|
||||
//saveAsFilename不含'/'不含'.js'
|
||||
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
|
||||
if (!isset(callback)) {
|
||||
printe('未设置callback');
|
||||
throw('未设置callback')
|
||||
}
|
||||
;
|
||||
if (!isset(editor.currentFloorData)) {
|
||||
callback('无数据');
|
||||
}
|
||||
editor.currentFloorData={floorId: saveFilename, title: "新建楼层", name: "0", canFlyTo: true, canUseQuickShop: true, images: [], item_ratio: 1,
|
||||
firstArrive: [], events: {}, changeFloor: {}, afterBattle: {}, afterGetItem: {}, afterOpenDoor: {}, cannotMove: {}};
|
||||
editor.currentFloorData = {
|
||||
floorId: saveFilename,
|
||||
title: "新建楼层",
|
||||
name: "0",
|
||||
canFlyTo: true,
|
||||
canUseQuickShop: true,
|
||||
images: [],
|
||||
item_ratio: 1,
|
||||
firstArrive: [],
|
||||
events: {},
|
||||
changeFloor: {},
|
||||
afterBattle: {},
|
||||
afterGetItem: {},
|
||||
afterOpenDoor: {},
|
||||
cannotMove: {}
|
||||
};
|
||||
editor.currentFloorData.map = "new";
|
||||
editor.currentFloorId=saveFilename;
|
||||
editor.currentFloorId = saveFilename;
|
||||
editor_file.saveFloorFile(callback);
|
||||
}
|
||||
//callback(err:String)
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
editor_file.changeIdAndIdnum = function(id,idnum,info,callback){
|
||||
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
|
||||
editor_file.changeIdAndIdnum = function (id, idnum, info, callback) {
|
||||
if (!isset(callback)) {
|
||||
printe('未设置callback');
|
||||
throw('未设置callback')
|
||||
}
|
||||
;
|
||||
//检查maps中是否有重复的idnum或id
|
||||
var change = -1;
|
||||
for(var ii in editor.core.maps.blocksInfo){
|
||||
if (ii==idnum) {
|
||||
for (var ii in editor.core.maps.blocksInfo) {
|
||||
if (ii == idnum) {
|
||||
//暂时只允许创建新的不允许修改已有的
|
||||
//if (info.idnum==idnum){change=ii;break;}//修改id
|
||||
callback('idnum重复了');
|
||||
return;
|
||||
}
|
||||
if (editor.core.maps.blocksInfo[ii].id==id) {
|
||||
if (editor.core.maps.blocksInfo[ii].id == id) {
|
||||
//if (info.id==id){change=ii;break;}//修改idnum
|
||||
callback('id重复了');
|
||||
return;
|
||||
@ -138,30 +182,40 @@ editor_file = function(editor, callback){
|
||||
editor.core.icons.icons[info.images][id]=info.y;
|
||||
}
|
||||
*/
|
||||
var templist=[];
|
||||
var templist = [];
|
||||
var tempcallback = function (err) {
|
||||
templist.push(err);
|
||||
if (templist.length ==2 ) {
|
||||
if (templist[0]!=null || templist[1]!=null)
|
||||
callback((templist[0]||'')+'\n'+(templist[1]||''));
|
||||
if (templist.length == 2) {
|
||||
if (templist[0] != null || templist[1] != null)
|
||||
callback((templist[0] || '') + '\n' + (templist[1] || ''));
|
||||
//这里如果一个成功一个失败会出严重bug
|
||||
else
|
||||
callback(null);
|
||||
}
|
||||
}
|
||||
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',[["add","['items']['"+id+"']",editor_file.comment._data.items_template]],function(err){if(err){printe(err);throw(err)}});
|
||||
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', [["add", "['items']['" + id + "']", editor_file.comment._data.items_template]], function (err) {
|
||||
if (err) {
|
||||
printe(err);
|
||||
throw(err)
|
||||
}
|
||||
if(info.images==='enemys' || info.images==='enemy48'){
|
||||
saveSetting('enemys',[["add","['"+id+"']",editor_file.comment._data.enemys_template]],function(err){if(err){printe(err);throw(err)}});
|
||||
});
|
||||
}
|
||||
if (info.images === 'enemys' || info.images === 'enemy48') {
|
||||
saveSetting('enemys', [["add", "['" + id + "']", editor_file.comment._data.enemys_template]], function (err) {
|
||||
if (err) {
|
||||
printe(err);
|
||||
throw(err)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
callback(null);
|
||||
}
|
||||
//callback(err:String)
|
||||
editor_file.editItem = function(id,actionList,callback){
|
||||
editor_file.editItem = function (id, actionList, callback) {
|
||||
/*actionList:[
|
||||
["change","['items']['name']","红宝石的新名字"],
|
||||
["add","['items']['新的和name同级的属性']",123],
|
||||
@ -169,27 +223,31 @@ editor_file = function(editor, callback){
|
||||
]
|
||||
为[]时只查询不修改
|
||||
*/
|
||||
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
|
||||
if (isset(actionList) && actionList.length > 0){
|
||||
if (!isset(callback)) {
|
||||
printe('未设置callback');
|
||||
throw('未设置callback')
|
||||
}
|
||||
;
|
||||
if (isset(actionList) && actionList.length > 0) {
|
||||
actionList.forEach(function (value) {
|
||||
var tempindex = value[1].indexOf(']')+1;
|
||||
value[1] = [value[1].slice(0,tempindex),"['"+id+"']",value[1].slice(tempindex)].join('');
|
||||
var tempindex = value[1].indexOf(']') + 1;
|
||||
value[1] = [value[1].slice(0, tempindex), "['" + id + "']", value[1].slice(tempindex)].join('');
|
||||
});
|
||||
saveSetting('items',actionList,function (err) {
|
||||
saveSetting('items', actionList, function (err) {
|
||||
callback([
|
||||
(function(){
|
||||
var locObj_ ={};
|
||||
Object.keys(editor_file.comment._data.items._data).forEach(function(v){
|
||||
if (isset(editor.core.items[v][id]) && v!=='items')
|
||||
locObj_[v]=editor.core.items[v][id];
|
||||
(function () {
|
||||
var locObj_ = {};
|
||||
Object.keys(editor_file.comment._data.items._data).forEach(function (v) {
|
||||
if (isset(editor.core.items[v][id]) && v !== 'items')
|
||||
locObj_[v] = editor.core.items[v][id];
|
||||
else
|
||||
locObj_[v]=null;
|
||||
locObj_[v] = null;
|
||||
});
|
||||
locObj_['items']=(function(){
|
||||
var locObj=Object.assign({},editor.core.items.items[id]);
|
||||
Object.keys(editor_file.comment._data.items._data.items._data).forEach(function(v){
|
||||
locObj_['items'] = (function () {
|
||||
var locObj = Object.assign({}, editor.core.items.items[id]);
|
||||
Object.keys(editor_file.comment._data.items._data.items._data).forEach(function (v) {
|
||||
if (!isset(editor.core.items.items[id][v]))
|
||||
locObj[v]=null;
|
||||
locObj[v] = null;
|
||||
});
|
||||
return locObj;
|
||||
})();
|
||||
@ -200,19 +258,19 @@ editor_file = function(editor, callback){
|
||||
});
|
||||
} else {
|
||||
callback([
|
||||
(function(){
|
||||
var locObj_ ={};
|
||||
Object.keys(editor_file.comment._data.items._data).forEach(function(v){
|
||||
if (isset(editor.core.items[v][id]) && v!=='items')
|
||||
locObj_[v]=editor.core.items[v][id];
|
||||
(function () {
|
||||
var locObj_ = {};
|
||||
Object.keys(editor_file.comment._data.items._data).forEach(function (v) {
|
||||
if (isset(editor.core.items[v][id]) && v !== 'items')
|
||||
locObj_[v] = editor.core.items[v][id];
|
||||
else
|
||||
locObj_[v]=null;
|
||||
locObj_[v] = null;
|
||||
});
|
||||
locObj_['items']=(function(){
|
||||
var locObj=Object.assign({},editor.core.items.items[id]);
|
||||
Object.keys(editor_file.comment._data.items._data.items._data).forEach(function(v){
|
||||
locObj_['items'] = (function () {
|
||||
var locObj = Object.assign({}, editor.core.items.items[id]);
|
||||
Object.keys(editor_file.comment._data.items._data.items._data).forEach(function (v) {
|
||||
if (!isset(editor.core.items.items[id][v]))
|
||||
locObj[v]=null;
|
||||
locObj[v] = null;
|
||||
});
|
||||
return locObj;
|
||||
})();
|
||||
@ -224,7 +282,7 @@ editor_file = function(editor, callback){
|
||||
//只有items.cls是items的才有itemEffect和itemEffectTip,keys和constants和tools只有items
|
||||
}
|
||||
//callback([obj,commentObj,err:String])
|
||||
editor_file.editEnemy = function(id,actionList,callback){
|
||||
editor_file.editEnemy = function (id, actionList, callback) {
|
||||
/*actionList:[
|
||||
["change","['name']","初级巫师的新名字"],
|
||||
["add","['新的和name同级的属性']",123],
|
||||
@ -232,20 +290,24 @@ editor_file = function(editor, callback){
|
||||
]
|
||||
为[]时只查询不修改
|
||||
*/
|
||||
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
|
||||
if (isset(actionList) && actionList.length > 0){
|
||||
if (!isset(callback)) {
|
||||
printe('未设置callback');
|
||||
throw('未设置callback')
|
||||
}
|
||||
;
|
||||
if (isset(actionList) && actionList.length > 0) {
|
||||
actionList.forEach(function (value) {
|
||||
value[1] = "['"+id+"']"+value[1];
|
||||
value[1] = "['" + id + "']" + value[1];
|
||||
});
|
||||
saveSetting('enemys',actionList,function (err) {
|
||||
saveSetting('enemys', actionList, function (err) {
|
||||
callback([
|
||||
(function(){
|
||||
var locObj=Object.assign({},editor.core.enemys.enemys[id]);
|
||||
Object.keys(editor_file.comment._data.enemys._data).forEach(function(v){
|
||||
(function () {
|
||||
var locObj = Object.assign({}, editor.core.enemys.enemys[id]);
|
||||
Object.keys(editor_file.comment._data.enemys._data).forEach(function (v) {
|
||||
if (!isset(editor.core.enemys.enemys[id][v]))
|
||||
/* locObj[v]=editor.core.enemys.enemys[id][v];
|
||||
else */
|
||||
locObj[v]=null;
|
||||
locObj[v] = null;
|
||||
});
|
||||
return locObj;
|
||||
})(),
|
||||
@ -254,13 +316,13 @@ editor_file = function(editor, callback){
|
||||
});
|
||||
} else {
|
||||
callback([
|
||||
(function(){
|
||||
var locObj=Object.assign({},editor.core.enemys.enemys[id]);
|
||||
Object.keys(editor_file.comment._data.enemys._data).forEach(function(v){
|
||||
(function () {
|
||||
var locObj = Object.assign({}, editor.core.enemys.enemys[id]);
|
||||
Object.keys(editor_file.comment._data.enemys._data).forEach(function (v) {
|
||||
if (!isset(editor.core.enemys.enemys[id][v]))
|
||||
/* locObj[v]=editor.core.enemys.enemys[id][v];
|
||||
else */
|
||||
locObj[v]=null;
|
||||
locObj[v] = null;
|
||||
});
|
||||
return locObj;
|
||||
})(),
|
||||
@ -270,25 +332,29 @@ editor_file = function(editor, callback){
|
||||
}
|
||||
//callback([obj,commentObj,err:String])
|
||||
|
||||
editor_file.editMapBlocksInfo = function(idnum,actionList,callback){
|
||||
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){
|
||||
if (!isset(callback)) {
|
||||
printe('未设置callback');
|
||||
throw('未设置callback')
|
||||
}
|
||||
;
|
||||
if (isset(actionList) && actionList.length > 0) {
|
||||
actionList.forEach(function (value) {
|
||||
value[1] = "['"+idnum+"']"+value[1];
|
||||
value[1] = "['" + idnum + "']" + value[1];
|
||||
});
|
||||
saveSetting('maps',actionList,function (err) {
|
||||
saveSetting('maps', actionList, function (err) {
|
||||
callback([
|
||||
(function(){
|
||||
var locObj=Object.assign({},editor.core.maps.blocksInfo[idnum]);
|
||||
Object.keys(editor_file.comment._data.maps._data).forEach(function(v){
|
||||
(function () {
|
||||
var locObj = Object.assign({}, editor.core.maps.blocksInfo[idnum]);
|
||||
Object.keys(editor_file.comment._data.maps._data).forEach(function (v) {
|
||||
if (!isset(editor.core.maps.blocksInfo[idnum][v]))
|
||||
locObj[v]=null;
|
||||
locObj[v] = null;
|
||||
});
|
||||
locObj.idnum = idnum;
|
||||
return locObj;
|
||||
@ -298,11 +364,11 @@ editor_file = function(editor, callback){
|
||||
});
|
||||
} else {
|
||||
callback([
|
||||
(function(){
|
||||
var locObj=Object.assign({},editor.core.maps.blocksInfo[idnum]);
|
||||
Object.keys(editor_file.comment._data.maps._data).forEach(function(v){
|
||||
(function () {
|
||||
var locObj = Object.assign({}, editor.core.maps.blocksInfo[idnum]);
|
||||
Object.keys(editor_file.comment._data.maps._data).forEach(function (v) {
|
||||
if (!isset(editor.core.maps.blocksInfo[idnum][v]))
|
||||
locObj[v]=null;
|
||||
locObj[v] = null;
|
||||
});
|
||||
locObj.idnum = idnum;
|
||||
return locObj;
|
||||
@ -315,27 +381,31 @@ editor_file = function(editor, callback){
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
editor_file.editLoc = function(x,y,actionList,callback){
|
||||
editor_file.editLoc = function (x, y, 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){
|
||||
if (!isset(callback)) {
|
||||
printe('未设置callback');
|
||||
throw('未设置callback')
|
||||
}
|
||||
;
|
||||
if (isset(actionList) && actionList.length > 0) {
|
||||
actionList.forEach(function (value) {
|
||||
value[1] = value[1]+"['"+x+","+y+"']";
|
||||
value[1] = value[1] + "['" + x + "," + y + "']";
|
||||
});
|
||||
saveSetting('floors',actionList,function (err) {
|
||||
saveSetting('floors', actionList, function (err) {
|
||||
callback([
|
||||
(function(){
|
||||
var locObj={};
|
||||
Object.keys(editor_file.comment._data.floors._data.loc._data).forEach(function(v){
|
||||
if (isset(editor.currentFloorData[v][x+','+y]))
|
||||
locObj[v]=editor.currentFloorData[v][x+','+y];
|
||||
(function () {
|
||||
var locObj = {};
|
||||
Object.keys(editor_file.comment._data.floors._data.loc._data).forEach(function (v) {
|
||||
if (isset(editor.currentFloorData[v][x + ',' + y]))
|
||||
locObj[v] = editor.currentFloorData[v][x + ',' + y];
|
||||
else
|
||||
locObj[v]=null;
|
||||
locObj[v] = null;
|
||||
});
|
||||
return locObj;
|
||||
})(),
|
||||
@ -344,13 +414,13 @@ editor_file = function(editor, callback){
|
||||
});
|
||||
} else {
|
||||
callback([
|
||||
(function(){
|
||||
var locObj={};
|
||||
Object.keys(editor_file.comment._data.floors._data.loc._data).forEach(function(v){
|
||||
if (isset(editor.currentFloorData[v][x+','+y]))
|
||||
locObj[v]=editor.currentFloorData[v][x+','+y];
|
||||
(function () {
|
||||
var locObj = {};
|
||||
Object.keys(editor_file.comment._data.floors._data.loc._data).forEach(function (v) {
|
||||
if (isset(editor.currentFloorData[v][x + ',' + y]))
|
||||
locObj[v] = editor.currentFloorData[v][x + ',' + y];
|
||||
else
|
||||
locObj[v]=null;
|
||||
locObj[v] = null;
|
||||
});
|
||||
return locObj;
|
||||
})(),
|
||||
@ -363,26 +433,30 @@ editor_file = function(editor, callback){
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
editor_file.editFloor = function(actionList,callback){
|
||||
editor_file.editFloor = function (actionList, callback) {
|
||||
/*actionList:[
|
||||
["change","['title']",'样板 3 层'],
|
||||
["change","['color']",null],
|
||||
]
|
||||
为[]时只查询不修改
|
||||
*/
|
||||
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
|
||||
if (isset(actionList) && actionList.length > 0){
|
||||
saveSetting('floors',actionList,function (err) {
|
||||
if (!isset(callback)) {
|
||||
printe('未设置callback');
|
||||
throw('未设置callback')
|
||||
}
|
||||
;
|
||||
if (isset(actionList) && actionList.length > 0) {
|
||||
saveSetting('floors', actionList, function (err) {
|
||||
callback([
|
||||
(function(){
|
||||
var locObj=Object.assign({},editor.currentFloorData);
|
||||
Object.keys(editor_file.comment._data.floors._data.floor._data).forEach(function(v){
|
||||
(function () {
|
||||
var locObj = Object.assign({}, editor.currentFloorData);
|
||||
Object.keys(editor_file.comment._data.floors._data.floor._data).forEach(function (v) {
|
||||
if (!isset(editor.currentFloorData[v]))
|
||||
/* locObj[v]=editor.currentFloorData[v];
|
||||
else */
|
||||
locObj[v]=null;
|
||||
locObj[v] = null;
|
||||
});
|
||||
Object.keys(editor_file.comment._data.floors._data.loc._data).forEach(function(v){
|
||||
Object.keys(editor_file.comment._data.floors._data.loc._data).forEach(function (v) {
|
||||
delete(locObj[v]);
|
||||
});
|
||||
delete(locObj.map);
|
||||
@ -393,15 +467,15 @@ editor_file = function(editor, callback){
|
||||
});
|
||||
} else {
|
||||
callback([
|
||||
(function(){
|
||||
var locObj=Object.assign({},editor.currentFloorData);
|
||||
Object.keys(editor_file.comment._data.floors._data.floor._data).forEach(function(v){
|
||||
(function () {
|
||||
var locObj = Object.assign({}, editor.currentFloorData);
|
||||
Object.keys(editor_file.comment._data.floors._data.floor._data).forEach(function (v) {
|
||||
if (!isset(editor.currentFloorData[v]))
|
||||
/* locObj[v]=editor.currentFloorData[v];
|
||||
else */
|
||||
locObj[v]=null;
|
||||
locObj[v] = null;
|
||||
});
|
||||
Object.keys(editor_file.comment._data.floors._data.loc._data).forEach(function(v){
|
||||
Object.keys(editor_file.comment._data.floors._data.loc._data).forEach(function (v) {
|
||||
delete(locObj[v]);
|
||||
});
|
||||
delete(locObj.map);
|
||||
@ -415,7 +489,7 @@ editor_file = function(editor, callback){
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
editor_file.editTower = function(actionList,callback){
|
||||
editor_file.editTower = function (actionList, callback) {
|
||||
/*actionList:[
|
||||
["change","['firstData']['version']",'Ver 1.0.1 (Beta)'],
|
||||
["change","['values']['lavaDamage']",200],
|
||||
@ -423,18 +497,22 @@ editor_file = function(editor, callback){
|
||||
为[]时只查询不修改
|
||||
*/
|
||||
var data_obj = data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d;
|
||||
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
|
||||
if (isset(actionList) && actionList.length > 0){
|
||||
saveSetting('data',actionList,function (err) {
|
||||
if (!isset(callback)) {
|
||||
printe('未设置callback');
|
||||
throw('未设置callback')
|
||||
}
|
||||
;
|
||||
if (isset(actionList) && actionList.length > 0) {
|
||||
saveSetting('data', actionList, function (err) {
|
||||
callback([
|
||||
(function(){
|
||||
(function () {
|
||||
//var locObj=Object.assign({'main':{}},editor.core.data);
|
||||
var locObj=Object.assign({},data_obj,{'main':{}});
|
||||
Object.keys(editor_file.dataComment._data.main._data).forEach(function(v){
|
||||
var locObj = Object.assign({}, data_obj, {'main': {}});
|
||||
Object.keys(editor_file.dataComment._data.main._data).forEach(function (v) {
|
||||
if (isset(editor.main[v]))
|
||||
locObj.main[v]=data_obj.main[v];
|
||||
locObj.main[v] = data_obj.main[v];
|
||||
else
|
||||
locObj[v]=null;
|
||||
locObj[v] = null;
|
||||
});
|
||||
return locObj;
|
||||
})(),
|
||||
@ -443,14 +521,14 @@ editor_file = function(editor, callback){
|
||||
});
|
||||
} else {
|
||||
callback([
|
||||
(function(){
|
||||
(function () {
|
||||
//var locObj=Object.assign({'main':{}},editor.core.data);
|
||||
var locObj=Object.assign({},data_obj,{'main':{}});
|
||||
Object.keys(editor_file.dataComment._data.main._data).forEach(function(v){
|
||||
var locObj = Object.assign({}, data_obj, {'main': {}});
|
||||
Object.keys(editor_file.dataComment._data.main._data).forEach(function (v) {
|
||||
if (isset(editor.main[v]))
|
||||
locObj.main[v]=data_obj.main[v];
|
||||
locObj.main[v] = data_obj.main[v];
|
||||
else
|
||||
locObj[v]=null;
|
||||
locObj[v] = null;
|
||||
});
|
||||
return locObj;
|
||||
})(),
|
||||
@ -463,30 +541,40 @@ editor_file = function(editor, callback){
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
var fmap = {};
|
||||
var fjson = JSON.stringify(functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a,function(k,v){if(v instanceof Function){var id_ = editor.guid();fmap[id_]=v.toString();return id_;}else return v},4);
|
||||
var fjson = JSON.stringify(functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a, function (k, v) {
|
||||
if (v instanceof Function) {
|
||||
var id_ = editor.guid();
|
||||
fmap[id_] = v.toString();
|
||||
return id_;
|
||||
} else return v
|
||||
}, 4);
|
||||
var fobj = JSON.parse(fjson);
|
||||
editor_file.functionsMap = fmap;
|
||||
editor_file.functionsJSON = fjson;
|
||||
var buildlocobj = function(locObj){
|
||||
for(var key in locObj){
|
||||
if(typeof(locObj[key])!==typeof(''))buildlocobj(locObj[key]);
|
||||
else locObj[key]=fmap[locObj[key]];
|
||||
var buildlocobj = function (locObj) {
|
||||
for (var key in locObj) {
|
||||
if (typeof(locObj[key]) !== typeof('')) buildlocobj(locObj[key]);
|
||||
else locObj[key] = fmap[locObj[key]];
|
||||
}
|
||||
};
|
||||
|
||||
editor_file.editFunctions = function(actionList,callback){
|
||||
editor_file.editFunctions = function (actionList, callback) {
|
||||
/*actionList:[
|
||||
["change","['events']['afterChangeLight']","function(x,y){console.log(x,y)}"],
|
||||
["change","['ui']['drawAbout']","function(){...}"],
|
||||
]
|
||||
为[]时只查询不修改
|
||||
*/
|
||||
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
|
||||
if (isset(actionList) && actionList.length > 0){
|
||||
saveSetting('functions',actionList,function (err) {
|
||||
if (!isset(callback)) {
|
||||
printe('未设置callback');
|
||||
throw('未设置callback')
|
||||
}
|
||||
;
|
||||
if (isset(actionList) && actionList.length > 0) {
|
||||
saveSetting('functions', actionList, function (err) {
|
||||
callback([
|
||||
(function(){
|
||||
var locObj=JSON.parse(fjson);
|
||||
(function () {
|
||||
var locObj = JSON.parse(fjson);
|
||||
buildlocobj(locObj);
|
||||
return locObj;
|
||||
})(),
|
||||
@ -495,8 +583,8 @@ editor_file = function(editor, callback){
|
||||
});
|
||||
} else {
|
||||
callback([
|
||||
(function(){
|
||||
var locObj=JSON.parse(fjson);
|
||||
(function () {
|
||||
var locObj = JSON.parse(fjson);
|
||||
buildlocobj(locObj);
|
||||
return locObj;
|
||||
})(),
|
||||
@ -515,122 +603,134 @@ editor_file = function(editor, callback){
|
||||
return true
|
||||
}
|
||||
|
||||
var formatMap = function(mapArr){
|
||||
var formatMap = function (mapArr) {
|
||||
//把13*13或者1*169数组格式化
|
||||
var formatArrStr = '';
|
||||
var arr = JSON.stringify(mapArr).replace(/\s+/g, '').split('],[');
|
||||
for(var i =0; i<13; i++){
|
||||
for (var i = 0; i < 13; i++) {
|
||||
var a = [];
|
||||
formatArrStr +=' [';
|
||||
if(i==0||i==12) a = arr[i].split(/\D+/).join(' ').trim().split(' ');
|
||||
formatArrStr += ' [';
|
||||
if (i == 0 || i == 12) a = arr[i].split(/\D+/).join(' ').trim().split(' ');
|
||||
else a = arr[i].split(/\D+/);
|
||||
for(var k=0; k<13; k++){
|
||||
for (var k = 0; k < 13; k++) {
|
||||
var num = parseInt(a[k]);
|
||||
formatArrStr += Array(Math.max(4-String(num).length,0)).join(' ')+num+(k==12?'':',');
|
||||
formatArrStr += Array(Math.max(4 - String(num).length, 0)).join(' ') + num + (k == 12 ? '' : ',');
|
||||
}
|
||||
formatArrStr += ']'+(i==12?'':',\n');
|
||||
formatArrStr += ']' + (i == 12 ? '' : ',\n');
|
||||
}
|
||||
return formatArrStr;
|
||||
}
|
||||
|
||||
var encode = function (str) {
|
||||
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {
|
||||
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) {
|
||||
return String.fromCharCode(parseInt(p1, 16))
|
||||
}))
|
||||
}
|
||||
|
||||
var saveSetting = function(file,actionList,callback) {
|
||||
var saveSetting = function (file, actionList, callback) {
|
||||
//console.log(file);
|
||||
//console.log(actionList);
|
||||
|
||||
if (file=='icons') {
|
||||
if (file == 'icons') {
|
||||
actionList.forEach(function (value) {
|
||||
eval("icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1"+value[1]+'='+JSON.stringify(value[2]));
|
||||
eval("icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1" + value[1] + '=' + JSON.stringify(value[2]));
|
||||
});
|
||||
var datastr='icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 = \n';
|
||||
datastr+=JSON.stringify(icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1,null,'\t');
|
||||
fs.writeFile('project/icons.js',encode(datastr),'base64',function(err, data){
|
||||
var datastr = 'icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 = \n';
|
||||
datastr += JSON.stringify(icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1, null, '\t');
|
||||
fs.writeFile('project/icons.js', encode(datastr), 'base64', function (err, data) {
|
||||
callback(err);
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (file=='maps') {
|
||||
if (file == 'maps') {
|
||||
actionList.forEach(function (value) {
|
||||
eval("maps_90f36752_8815_4be8_b32b_d7fad1d0542e"+value[1]+'='+JSON.stringify(value[2]));
|
||||
eval("maps_90f36752_8815_4be8_b32b_d7fad1d0542e" + value[1] + '=' + JSON.stringify(value[2]));
|
||||
});
|
||||
var datastr='maps_90f36752_8815_4be8_b32b_d7fad1d0542e = \n';
|
||||
var datastr = 'maps_90f36752_8815_4be8_b32b_d7fad1d0542e = \n';
|
||||
//datastr+=JSON.stringify(maps_90f36752_8815_4be8_b32b_d7fad1d0542e,null,4);
|
||||
|
||||
var emap={};
|
||||
var estr = JSON.stringify(maps_90f36752_8815_4be8_b32b_d7fad1d0542e,function(k,v){if(v.id!=null){var id_ = editor.guid();emap[id_]=JSON.stringify(v);return id_;}else return v},'\t');
|
||||
for(var id_ in emap){
|
||||
estr = estr.replace('"'+id_+'"',emap[id_])
|
||||
var emap = {};
|
||||
var estr = JSON.stringify(maps_90f36752_8815_4be8_b32b_d7fad1d0542e, function (k, v) {
|
||||
if (v.id != null) {
|
||||
var id_ = editor.guid();
|
||||
emap[id_] = JSON.stringify(v);
|
||||
return id_;
|
||||
} else return v
|
||||
}, '\t');
|
||||
for (var id_ in emap) {
|
||||
estr = estr.replace('"' + id_ + '"', emap[id_])
|
||||
}
|
||||
datastr+=estr;
|
||||
datastr += estr;
|
||||
|
||||
fs.writeFile('project/maps.js',encode(datastr),'base64',function(err, data){
|
||||
fs.writeFile('project/maps.js', encode(datastr), 'base64', function (err, data) {
|
||||
callback(err);
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (file=='items') {
|
||||
if (file == 'items') {
|
||||
actionList.forEach(function (value) {
|
||||
eval("items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a"+value[1]+'='+JSON.stringify(value[2]));
|
||||
eval("items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a" + value[1] + '=' + JSON.stringify(value[2]));
|
||||
});
|
||||
var datastr='items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = \n';
|
||||
datastr+=JSON.stringify(items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a,null,'\t');
|
||||
fs.writeFile('project/items.js',encode(datastr),'base64',function(err, data){
|
||||
var datastr = 'items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = \n';
|
||||
datastr += JSON.stringify(items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a, null, '\t');
|
||||
fs.writeFile('project/items.js', encode(datastr), 'base64', function (err, data) {
|
||||
callback(err);
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (file=='enemys') {
|
||||
if (file == 'enemys') {
|
||||
actionList.forEach(function (value) {
|
||||
eval("enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80"+value[1]+'='+JSON.stringify(value[2]));
|
||||
eval("enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80" + value[1] + '=' + JSON.stringify(value[2]));
|
||||
});
|
||||
var datastr='enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80 = \n';
|
||||
var emap={};
|
||||
var estr = JSON.stringify(enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80,function(k,v){if(v.hp!=null){var id_ = editor.guid();emap[id_]=JSON.stringify(v);return id_;}else return v},'\t');
|
||||
for(var id_ in emap){
|
||||
estr = estr.replace('"'+id_+'"',emap[id_])
|
||||
var datastr = 'enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80 = \n';
|
||||
var emap = {};
|
||||
var estr = JSON.stringify(enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80, function (k, v) {
|
||||
if (v.hp != null) {
|
||||
var id_ = editor.guid();
|
||||
emap[id_] = JSON.stringify(v);
|
||||
return id_;
|
||||
} else return v
|
||||
}, '\t');
|
||||
for (var id_ in emap) {
|
||||
estr = estr.replace('"' + id_ + '"', emap[id_])
|
||||
}
|
||||
datastr+=estr;
|
||||
fs.writeFile('project/enemys.js',encode(datastr),'base64',function(err, data){
|
||||
datastr += estr;
|
||||
fs.writeFile('project/enemys.js', encode(datastr), 'base64', function (err, data) {
|
||||
callback(err);
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (file=='data') {
|
||||
if (file == 'data') {
|
||||
actionList.forEach(function (value) {
|
||||
eval("data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d"+value[1]+'='+JSON.stringify(value[2]));
|
||||
eval("data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d" + value[1] + '=' + JSON.stringify(value[2]));
|
||||
});
|
||||
if (data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main.floorIds.indexOf(data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.firstData.floorId)<0)
|
||||
if (data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main.floorIds.indexOf(data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.firstData.floorId) < 0)
|
||||
data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.firstData.floorId = data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main.floorIds[0];
|
||||
var datastr='data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = \n';
|
||||
datastr+=JSON.stringify(data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d,null,'\t');
|
||||
fs.writeFile('project/data.js',encode(datastr),'base64',function(err, data){
|
||||
var datastr = 'data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = \n';
|
||||
datastr += JSON.stringify(data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d, null, '\t');
|
||||
fs.writeFile('project/data.js', encode(datastr), 'base64', function (err, data) {
|
||||
callback(err);
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (file=='functions') {
|
||||
if (file == 'functions') {
|
||||
actionList.forEach(function (value) {
|
||||
eval("fmap[fobj"+value[1]+']='+JSON.stringify(value[2]));
|
||||
eval("fmap[fobj" + value[1] + ']=' + JSON.stringify(value[2]));
|
||||
});
|
||||
var fraw = fjson;
|
||||
for(var id_ in fmap){
|
||||
fraw = fraw.replace('"'+id_+'"',fmap[id_])
|
||||
for (var id_ in fmap) {
|
||||
fraw = fraw.replace('"' + id_ + '"', fmap[id_])
|
||||
}
|
||||
var datastr='functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = \n';
|
||||
datastr+=fraw;
|
||||
fs.writeFile('project/functions.js',encode(datastr),'base64',function(err, data){
|
||||
var datastr = 'functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = \n';
|
||||
datastr += fraw;
|
||||
fs.writeFile('project/functions.js', encode(datastr), 'base64', function (err, data) {
|
||||
callback(err);
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (file=='floors') {
|
||||
if (file == 'floors') {
|
||||
actionList.forEach(function (value) {
|
||||
eval("editor.currentFloorData"+value[1]+'='+JSON.stringify(value[2]));
|
||||
eval("editor.currentFloorData" + value[1] + '=' + JSON.stringify(value[2]));
|
||||
});
|
||||
editor_file.saveFloorFile(callback);
|
||||
return;
|
||||
|
||||
@ -1,94 +1,95 @@
|
||||
editor_mode = function(editor){
|
||||
var core = editor.core;
|
||||
editor_mode = function (editor) {
|
||||
var core = editor.core;
|
||||
|
||||
function editor_mode(){
|
||||
this.ids={
|
||||
'loc':'left2',
|
||||
'emenyitem':'left3',
|
||||
'floor':'left4',
|
||||
'tower':'left5',
|
||||
'functions':'left8',
|
||||
function editor_mode() {
|
||||
this.ids = {
|
||||
'loc': 'left2',
|
||||
'emenyitem': 'left3',
|
||||
'floor': 'left4',
|
||||
'tower': 'left5',
|
||||
'functions': 'left8',
|
||||
|
||||
'map':'left',
|
||||
'appendpic':'left1',
|
||||
'map': 'left',
|
||||
'appendpic': 'left1',
|
||||
}
|
||||
this._ids = {}
|
||||
this.dom = {}
|
||||
this.actionList = [];
|
||||
this.mode = '';
|
||||
this.info = {};
|
||||
this.appendPic = {};
|
||||
}
|
||||
this._ids={}
|
||||
this.dom={}
|
||||
this.actionList=[];
|
||||
this.mode='';
|
||||
this.info={};
|
||||
this.appendPic={};
|
||||
}
|
||||
editor_mode.prototype.init = function(callback){
|
||||
if (Boolean(callback))callback();
|
||||
}
|
||||
|
||||
editor_mode.prototype.init_dom_ids = function(callback){
|
||||
editor_mode.prototype.init = function (callback) {
|
||||
if (Boolean(callback)) callback();
|
||||
}
|
||||
|
||||
Object.keys(editor_mode.ids).forEach(function(v){
|
||||
editor_mode.dom[v]=document.getElementById(editor_mode.ids[v]);
|
||||
editor_mode._ids[editor_mode.ids[v]]=v;
|
||||
editor_mode.prototype.init_dom_ids = function (callback) {
|
||||
|
||||
Object.keys(editor_mode.ids).forEach(function (v) {
|
||||
editor_mode.dom[v] = document.getElementById(editor_mode.ids[v]);
|
||||
editor_mode._ids[editor_mode.ids[v]] = v;
|
||||
});
|
||||
|
||||
if (Boolean(callback))callback();
|
||||
}
|
||||
if (Boolean(callback)) callback();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
editor_mode.prototype.objToTable_ = function(obj,commentObj){
|
||||
var outstr=["\n<tr><td>条目</td><td>注释</td><td>值</td></tr>\n"];
|
||||
var guids=[];
|
||||
var defaultcobj={
|
||||
_type:'textarea',
|
||||
_data:'',
|
||||
_string:function(args){//object~[field,cfield,vobj,cobj]
|
||||
editor_mode.prototype.objToTable_ = function (obj, commentObj) {
|
||||
var outstr = ["\n<tr><td>条目</td><td>注释</td><td>值</td></tr>\n"];
|
||||
var guids = [];
|
||||
var defaultcobj = {
|
||||
_type: 'textarea',
|
||||
_data: '',
|
||||
_string: function (args) {//object~[field,cfield,vobj,cobj]
|
||||
var thiseval = args.vobj;
|
||||
return (typeof(thiseval) === typeof('')) && thiseval[0]==='"';
|
||||
return (typeof(thiseval) === typeof('')) && thiseval[0] === '"';
|
||||
},
|
||||
_leaf:function(args){//object~[field,cfield,vobj,cobj]
|
||||
_leaf: function (args) {//object~[field,cfield,vobj,cobj]
|
||||
var thiseval = args.vobj;
|
||||
if (thiseval == null || thiseval == undefined)return true;//null,undefined
|
||||
if (typeof(thiseval) === typeof(''))return true;//字符串
|
||||
if (Object.keys(thiseval).length === 0)return true;//数字,true,false,空数组,空对象
|
||||
if (thiseval == null || thiseval == undefined) return true;//null,undefined
|
||||
if (typeof(thiseval) === typeof('')) return true;//字符串
|
||||
if (Object.keys(thiseval).length === 0) return true;//数字,true,false,空数组,空对象
|
||||
return false;
|
||||
},
|
||||
}
|
||||
var recursionParse = function(pfield,pcfield,pvobj,pcobj) {
|
||||
for(var ii in pvobj){
|
||||
var field = pfield+"['"+ii+"']";
|
||||
var cfield = pcfield+"['_data']['"+ii+"']";
|
||||
var recursionParse = function (pfield, pcfield, pvobj, pcobj) {
|
||||
for (var ii in pvobj) {
|
||||
var field = pfield + "['" + ii + "']";
|
||||
var cfield = pcfield + "['_data']['" + ii + "']";
|
||||
var vobj = pvobj[ii];
|
||||
var cobj = null;
|
||||
if(pcobj && pcobj['_data'] && pcobj['_data'][ii]){
|
||||
cobj = Object.assign({},defaultcobj,pcobj['_data'][ii]);
|
||||
if (pcobj && pcobj['_data'] && pcobj['_data'][ii]) {
|
||||
cobj = Object.assign({}, defaultcobj, pcobj['_data'][ii]);
|
||||
} else {
|
||||
if(pcobj && (pcobj['_data'] instanceof Function))cobj = Object.assign({},defaultcobj,pcobj['_data'](ii));
|
||||
else cobj = Object.assign({},defaultcobj);
|
||||
if (pcobj && (pcobj['_data'] instanceof Function)) cobj = Object.assign({}, defaultcobj, pcobj['_data'](ii));
|
||||
else cobj = Object.assign({}, defaultcobj);
|
||||
}
|
||||
var args = {field:field,cfield:cfield,vobj:vobj,cobj:cobj}
|
||||
if(cobj._leaf instanceof Function)cobj._leaf=cobj._leaf(args);
|
||||
for(var key in cobj){
|
||||
if(key==='_data')continue;
|
||||
if(cobj[key] instanceof Function)cobj[key]=cobj[key](args);
|
||||
var args = {field: field, cfield: cfield, vobj: vobj, cobj: cobj}
|
||||
if (cobj._leaf instanceof Function) cobj._leaf = cobj._leaf(args);
|
||||
for (var key in cobj) {
|
||||
if (key === '_data') continue;
|
||||
if (cobj[key] instanceof Function) cobj[key] = cobj[key](args);
|
||||
}
|
||||
if (cobj._leaf) {
|
||||
var leafnode = editor_mode.objToTr_(obj,commentObj,field,cfield,vobj,cobj);
|
||||
var leafnode = editor_mode.objToTr_(obj, commentObj, field, cfield, vobj, cobj);
|
||||
outstr.push(leafnode[0]);
|
||||
guids.push(leafnode[1]);
|
||||
} else {
|
||||
outstr.push(["<tr><td>----</td><td>----</td><td>",field,"</td></tr>\n"].join(''));
|
||||
recursionParse(field,cfield,vobj,cobj);
|
||||
outstr.push(["<tr><td>----</td><td>----</td><td>", field, "</td></tr>\n"].join(''));
|
||||
recursionParse(field, cfield, vobj, cobj);
|
||||
}
|
||||
}
|
||||
}
|
||||
recursionParse("","",obj,commentObj);
|
||||
var checkRange = function(evalstr,thiseval){
|
||||
if(evalstr){
|
||||
recursionParse("", "", obj, commentObj);
|
||||
var checkRange = function (evalstr, thiseval) {
|
||||
if (evalstr) {
|
||||
return eval(evalstr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
var listen = function(guids) {
|
||||
guids.forEach(function(guid){
|
||||
var listen = function (guids) {
|
||||
guids.forEach(function (guid) {
|
||||
// tr>td[title=field]
|
||||
// >td[title=comment,cobj=cobj:json]
|
||||
// >td>div>input[value=thiseval]
|
||||
@ -96,240 +97,306 @@ editor_mode.prototype.objToTable_ = function(obj,commentObj){
|
||||
var input = thisTr.children[2].children[0].children[0];
|
||||
var field = thisTr.children[0].getAttribute('title');
|
||||
var cobj = JSON.parse(thisTr.children[1].getAttribute('cobj'));
|
||||
input.onchange = function(){
|
||||
input.onchange = function () {
|
||||
var node = thisTr.parentNode;
|
||||
while (!editor_mode._ids.hasOwnProperty(node.getAttribute('id'))) {
|
||||
node = node.parentNode;
|
||||
}
|
||||
editor_mode.onmode(editor_mode._ids[node.getAttribute('id')]);
|
||||
var thiseval=null;
|
||||
if(input.checked!=null)input.value=input.checked;
|
||||
try{
|
||||
var thiseval = null;
|
||||
if (input.checked != null) input.value = input.checked;
|
||||
try {
|
||||
thiseval = JSON.parse(input.value);
|
||||
}catch(ee){
|
||||
printe(field+' : '+ee);
|
||||
} catch (ee) {
|
||||
printe(field + ' : ' + ee);
|
||||
throw ee;
|
||||
}
|
||||
if(checkRange(cobj._range,thiseval)){
|
||||
editor_mode.addAction(['change',field,thiseval]);
|
||||
if (checkRange(cobj._range, thiseval)) {
|
||||
editor_mode.addAction(['change', field, thiseval]);
|
||||
editor_mode.onmode('save');//自动保存
|
||||
} else {
|
||||
printe(field+' : 输入的值不合要求,请鼠标放置在注释上查看说明');
|
||||
printe(field + ' : 输入的值不合要求,请鼠标放置在注释上查看说明');
|
||||
}
|
||||
}
|
||||
input.ondblclick = function(){
|
||||
if(cobj._type==='event')editor_blockly.import(guid,{type:cobj._event});
|
||||
if(cobj._type==='textarea')editor_multi.import(guid,{lint:cobj._lint});
|
||||
input.ondblclick = function () {
|
||||
if (cobj._type === 'event') editor_blockly.import(guid, {type: cobj._event});
|
||||
if (cobj._type === 'textarea') editor_multi.import(guid, {lint: cobj._lint});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
return {"HTML":outstr.join(''),"guids":guids,"listen":listen};
|
||||
}
|
||||
return {"HTML": outstr.join(''), "guids": guids, "listen": listen};
|
||||
}
|
||||
|
||||
editor_mode.prototype.objToTr_ = function(obj,commentObj,field,cfield,vobj,cobj){
|
||||
editor_mode.prototype.objToTr_ = function (obj, commentObj, field, cfield, vobj, cobj) {
|
||||
var guid = editor.guid();
|
||||
var thiseval = vobj;
|
||||
var comment = cobj._data;
|
||||
|
||||
var charlength=10;
|
||||
var charlength = 10;
|
||||
|
||||
var shortField = field.split("']").slice(-2)[0].split("['").slice(-1)[0];
|
||||
shortField = (shortField.length<charlength?shortField:shortField.slice(0,charlength)+'...');
|
||||
shortField = (shortField.length < charlength ? shortField : shortField.slice(0, charlength) + '...');
|
||||
|
||||
var commentHTMLescape=editor.HTMLescape(comment);
|
||||
var shortCommentHTMLescape=(comment.length<charlength?commentHTMLescape:editor.HTMLescape(comment.slice(0,charlength))+'...');
|
||||
var commentHTMLescape = editor.HTMLescape(comment);
|
||||
var shortCommentHTMLescape = (comment.length < charlength ? commentHTMLescape : editor.HTMLescape(comment.slice(0, charlength)) + '...');
|
||||
|
||||
var cobjstr = Object.assign({},cobj);
|
||||
var cobjstr = Object.assign({}, cobj);
|
||||
delete cobjstr._data;
|
||||
cobjstr = editor.HTMLescape(JSON.stringify(cobjstr));
|
||||
|
||||
var outstr=['<tr id="',guid,'"><td title="',field,'">',shortField,'</td>',
|
||||
'<td title="',commentHTMLescape,'" cobj="',cobjstr,'">',shortCommentHTMLescape,'</td>',
|
||||
'<td><div class="etableInputDiv">',editor_mode.objToTd_(obj,commentObj,field,cfield,vobj,cobj),'</div></td></tr>\n',
|
||||
var outstr = ['<tr id="', guid, '"><td title="', field, '">', shortField, '</td>',
|
||||
'<td title="', commentHTMLescape, '" cobj="', cobjstr, '">', shortCommentHTMLescape, '</td>',
|
||||
'<td><div class="etableInputDiv">', editor_mode.objToTd_(obj, commentObj, field, cfield, vobj, cobj), '</div></td></tr>\n',
|
||||
];
|
||||
return [outstr.join(''),guid];
|
||||
}
|
||||
return [outstr.join(''), guid];
|
||||
}
|
||||
|
||||
editor_mode.prototype.objToTd_ = function(obj,commentObj,field,cfield,vobj,cobj){
|
||||
editor_mode.prototype.objToTd_ = function (obj, commentObj, field, cfield, vobj, cobj) {
|
||||
var thiseval = vobj;
|
||||
if(cobj._select){
|
||||
if (cobj._select) {
|
||||
var values = cobj._select.values;
|
||||
var outstr = ['<select>\n',"<option value='",JSON.stringify(thiseval),"'>",JSON.stringify(thiseval),'</option>\n'];
|
||||
values.forEach(function(v){
|
||||
outstr.push(["<option value='",JSON.stringify(v),"'>",JSON.stringify(v),'</option>\n'].join(''))
|
||||
var outstr = ['<select>\n', "<option value='", JSON.stringify(thiseval), "'>", JSON.stringify(thiseval), '</option>\n'];
|
||||
values.forEach(function (v) {
|
||||
outstr.push(["<option value='", JSON.stringify(v), "'>", JSON.stringify(v), '</option>\n'].join(''))
|
||||
});
|
||||
outstr.push('</select>');
|
||||
return outstr.join('');
|
||||
} else if(cobj._input){
|
||||
return ["<input type='text' spellcheck='false' value='",JSON.stringify(thiseval),"'/>\n"].join('');
|
||||
} else if(cobj._bool){
|
||||
return ["<input type='checkbox' ",(thiseval?'checked ':''),"/>\n"].join('');
|
||||
} else if (cobj._input) {
|
||||
return ["<input type='text' spellcheck='false' value='", JSON.stringify(thiseval), "'/>\n"].join('');
|
||||
} else if (cobj._bool) {
|
||||
return ["<input type='checkbox' ", (thiseval ? 'checked ' : ''), "/>\n"].join('');
|
||||
} else {
|
||||
var num = 0;//editor_mode.indent(field);
|
||||
return ["<textarea spellcheck='false' >",JSON.stringify(thiseval,null,num),'</textarea>\n'].join('');
|
||||
return ["<textarea spellcheck='false' >", JSON.stringify(thiseval, null, num), '</textarea>\n'].join('');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
editor_mode.prototype.indent = function(field){
|
||||
editor_mode.prototype.indent = function (field) {
|
||||
var num = '\t';
|
||||
if(field.indexOf("['main']")===0)return 0;
|
||||
if(field.indexOf("['flyRange']")!==-1)return 0;
|
||||
if(field==="['special']")return 0;
|
||||
if (field.indexOf("['main']") === 0) return 0;
|
||||
if (field.indexOf("['flyRange']") !== -1) return 0;
|
||||
if (field === "['special']") return 0;
|
||||
return num;
|
||||
}
|
||||
}
|
||||
|
||||
editor_mode.prototype.addAction = function(action){
|
||||
editor_mode.prototype.addAction = function (action) {
|
||||
editor_mode.actionList.push(action);
|
||||
}
|
||||
}
|
||||
|
||||
editor_mode.prototype.doActionList = function(mode,actionList){
|
||||
if (actionList.length==0)return;
|
||||
editor_mode.prototype.doActionList = function (mode, actionList) {
|
||||
if (actionList.length == 0) return;
|
||||
printf('修改中...');
|
||||
switch (mode) {
|
||||
case 'loc':
|
||||
|
||||
editor.file.editLoc(editor_mode.pos.x,editor_mode.pos.y,actionList,function(objs_){/*console.log(objs_);*/if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
|
||||
editor.file.editLoc(editor_mode.pos.x, editor_mode.pos.y, 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 'emenyitem':
|
||||
|
||||
if (editor_mode.info.images=='enemys'||editor_mode.info.images=='enemy48'){
|
||||
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('修改成功')});
|
||||
if (editor_mode.info.images == 'enemys' || editor_mode.info.images == 'enemy48') {
|
||||
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('修改成功')});
|
||||
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':
|
||||
|
||||
editor.file.editFloor(actionList,function(objs_){/*console.log(objs_);*/if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
|
||||
editor.file.editFloor(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 'tower':
|
||||
|
||||
editor.file.editTower(actionList,function(objs_){/*console.log(objs_);*/if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
|
||||
editor.file.editTower(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 'functions':
|
||||
|
||||
editor.file.editFunctions(actionList,function(objs_){/*console.log(objs_);*/if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
|
||||
editor.file.editFunctions(actionList, function (objs_) {/*console.log(objs_);*/
|
||||
if (objs_.slice(-1)[0] != null) {
|
||||
printe(objs_.slice(-1)[0]);
|
||||
throw(objs_.slice(-1)[0])
|
||||
}
|
||||
;printf('修改成功')
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
editor_mode.prototype.onmode = function (mode) {
|
||||
if (editor_mode.mode!=mode) {
|
||||
if(mode==='save')editor_mode.doActionList(editor_mode.mode,editor_mode.actionList);
|
||||
if(editor_mode.mode==='nextChange' && mode)editor_mode.showMode(mode);
|
||||
editor_mode.mode=mode;
|
||||
editor_mode.actionList=[];
|
||||
}
|
||||
}
|
||||
|
||||
editor_mode.prototype.showMode = function (mode) {
|
||||
for(var name in this.dom){
|
||||
editor_mode.dom[name].style='z-index:-1;opacity: 0;';
|
||||
editor_mode.prototype.onmode = function (mode) {
|
||||
if (editor_mode.mode != mode) {
|
||||
if (mode === 'save') editor_mode.doActionList(editor_mode.mode, editor_mode.actionList);
|
||||
if (editor_mode.mode === 'nextChange' && mode) editor_mode.showMode(mode);
|
||||
editor_mode.mode = mode;
|
||||
editor_mode.actionList = [];
|
||||
}
|
||||
editor_mode.dom[mode].style='';
|
||||
if(editor_mode[mode])editor_mode[mode]();
|
||||
document.getElementById('editModeSelect').value=mode;
|
||||
}
|
||||
|
||||
editor_mode.prototype.showMode = function (mode) {
|
||||
for (var name in this.dom) {
|
||||
editor_mode.dom[name].style = 'z-index:-1;opacity: 0;';
|
||||
}
|
||||
editor_mode.dom[mode].style = '';
|
||||
if (editor_mode[mode]) editor_mode[mode]();
|
||||
document.getElementById('editModeSelect').value = mode;
|
||||
var tips = tip_in_showMode;
|
||||
if(!selectBox.isSelected)printf('tips: '+tips[~~(tips.length*Math.random())]);
|
||||
}
|
||||
if (!selectBox.isSelected) printf('tips: ' + tips[~~(tips.length * Math.random())]);
|
||||
}
|
||||
|
||||
editor_mode.prototype.loc = function(callback){
|
||||
editor_mode.prototype.loc = function (callback) {
|
||||
//editor.pos={x: 0, y: 0};
|
||||
if (!core.isset(editor.pos))return;
|
||||
editor_mode.pos=editor.pos;
|
||||
document.getElementById('pos_a6771a78_a099_417c_828f_0a24851ebfce').innerText=editor_mode.pos.x+','+editor_mode.pos.y;
|
||||
if (!core.isset(editor.pos)) return;
|
||||
editor_mode.pos = editor.pos;
|
||||
document.getElementById('pos_a6771a78_a099_417c_828f_0a24851ebfce').innerText = editor_mode.pos.x + ',' + editor_mode.pos.y;
|
||||
|
||||
var objs=[];
|
||||
editor.file.editLoc(editor_mode.pos.x,editor_mode.pos.y,[],function(objs_){objs=objs_;/*console.log(objs_)*/});
|
||||
var objs = [];
|
||||
editor.file.editLoc(editor_mode.pos.x, editor_mode.pos.y, [], function (objs_) {
|
||||
objs = objs_;
|
||||
/*console.log(objs_)*/
|
||||
});
|
||||
//只查询不修改时,内部实现不是异步的,所以可以这么写
|
||||
var tableinfo=editor_mode.objToTable_(objs[0],objs[1]);
|
||||
document.getElementById('table_3d846fc4_7644_44d1_aa04_433d266a73df').innerHTML=tableinfo.HTML;
|
||||
var tableinfo = editor_mode.objToTable_(objs[0], objs[1]);
|
||||
document.getElementById('table_3d846fc4_7644_44d1_aa04_433d266a73df').innerHTML = tableinfo.HTML;
|
||||
tableinfo.listen(tableinfo.guids);
|
||||
|
||||
if (Boolean(callback))callback();
|
||||
}
|
||||
if (Boolean(callback)) callback();
|
||||
}
|
||||
|
||||
editor_mode.prototype.emenyitem = function(callback){
|
||||
editor_mode.prototype.emenyitem = function (callback) {
|
||||
//editor.info=editor.ids[editor.indexs[201]];
|
||||
if (!core.isset(editor.info))return;
|
||||
if (!core.isset(editor.info)) return;
|
||||
|
||||
if(Object.keys(editor.info).length!==0)editor_mode.info=editor.info;//避免editor.info被清空导致无法获得是物品还是怪物
|
||||
if (Object.keys(editor.info).length !== 0) editor_mode.info = editor.info;//避免editor.info被清空导致无法获得是物品还是怪物
|
||||
|
||||
if (!core.isset(editor_mode.info.id)){
|
||||
document.getElementById('table_a3f03d4c_55b8_4ef6_b362_b345783acd72').innerHTML='';
|
||||
document.getElementById('newIdIdnum').style.display='';
|
||||
if (!core.isset(editor_mode.info.id)) {
|
||||
document.getElementById('table_a3f03d4c_55b8_4ef6_b362_b345783acd72').innerHTML = '';
|
||||
document.getElementById('newIdIdnum').style.display = '';
|
||||
return;
|
||||
}
|
||||
document.getElementById('newIdIdnum').style.display='none';
|
||||
document.getElementById('newIdIdnum').style.display = 'none';
|
||||
|
||||
var objs=[];
|
||||
if (editor_mode.info.images=='enemys' || editor_mode.info.images=='enemy48'){
|
||||
editor.file.editEnemy(editor_mode.info.id,[],function(objs_){objs=objs_;/*console.log(objs_)*/});
|
||||
} else if (editor_mode.info.images=='items'){
|
||||
editor.file.editItem(editor_mode.info.id,[],function(objs_){objs=objs_;/*console.log(objs_)*/});
|
||||
var objs = [];
|
||||
if (editor_mode.info.images == 'enemys' || editor_mode.info.images == 'enemy48') {
|
||||
editor.file.editEnemy(editor_mode.info.id, [], function (objs_) {
|
||||
objs = objs_;
|
||||
/*console.log(objs_)*/
|
||||
});
|
||||
} 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; */
|
||||
editor.file.editMapBlocksInfo(editor_mode.info.idnum,[],function(objs_){objs=objs_;/*console.log(objs_)*/});
|
||||
editor.file.editMapBlocksInfo(editor_mode.info.idnum, [], function (objs_) {
|
||||
objs = objs_;
|
||||
/*console.log(objs_)*/
|
||||
});
|
||||
}
|
||||
//只查询不修改时,内部实现不是异步的,所以可以这么写
|
||||
var tableinfo=editor_mode.objToTable_(objs[0],objs[1]);
|
||||
document.getElementById('table_a3f03d4c_55b8_4ef6_b362_b345783acd72').innerHTML=tableinfo.HTML;
|
||||
var tableinfo = editor_mode.objToTable_(objs[0], objs[1]);
|
||||
document.getElementById('table_a3f03d4c_55b8_4ef6_b362_b345783acd72').innerHTML = tableinfo.HTML;
|
||||
tableinfo.listen(tableinfo.guids);
|
||||
|
||||
if (Boolean(callback))callback();
|
||||
}
|
||||
if (Boolean(callback)) callback();
|
||||
}
|
||||
|
||||
editor_mode.prototype.floor = function(callback){
|
||||
var objs=[];
|
||||
editor.file.editFloor([],function(objs_){objs=objs_;/*console.log(objs_)*/});
|
||||
editor_mode.prototype.floor = function (callback) {
|
||||
var objs = [];
|
||||
editor.file.editFloor([], function (objs_) {
|
||||
objs = objs_;
|
||||
/*console.log(objs_)*/
|
||||
});
|
||||
//只查询不修改时,内部实现不是异步的,所以可以这么写
|
||||
var tableinfo=editor_mode.objToTable_(objs[0],objs[1]);
|
||||
document.getElementById('table_4a3b1b09_b2fb_4bdf_b9ab_9f4cdac14c74').innerHTML=tableinfo.HTML;
|
||||
var tableinfo = editor_mode.objToTable_(objs[0], objs[1]);
|
||||
document.getElementById('table_4a3b1b09_b2fb_4bdf_b9ab_9f4cdac14c74').innerHTML = tableinfo.HTML;
|
||||
tableinfo.listen(tableinfo.guids);
|
||||
if (Boolean(callback))callback();
|
||||
}
|
||||
if (Boolean(callback)) callback();
|
||||
}
|
||||
|
||||
editor_mode.prototype.tower = function(callback){
|
||||
var objs=[];
|
||||
editor.file.editTower([],function(objs_){objs=objs_;/*console.log(objs_)*/});
|
||||
editor_mode.prototype.tower = function (callback) {
|
||||
var objs = [];
|
||||
editor.file.editTower([], function (objs_) {
|
||||
objs = objs_;
|
||||
/*console.log(objs_)*/
|
||||
});
|
||||
//只查询不修改时,内部实现不是异步的,所以可以这么写
|
||||
var tableinfo=editor_mode.objToTable_(objs[0],objs[1]);
|
||||
document.getElementById('table_b6a03e4c_5968_4633_ac40_0dfdd2c9cde5').innerHTML=tableinfo.HTML;
|
||||
var tableinfo = editor_mode.objToTable_(objs[0], objs[1]);
|
||||
document.getElementById('table_b6a03e4c_5968_4633_ac40_0dfdd2c9cde5').innerHTML = tableinfo.HTML;
|
||||
tableinfo.listen(tableinfo.guids);
|
||||
if (Boolean(callback))callback();
|
||||
}
|
||||
if (Boolean(callback)) callback();
|
||||
}
|
||||
|
||||
editor_mode.prototype.functions = function(callback){
|
||||
var objs=[];
|
||||
editor.file.editFunctions([],function(objs_){objs=objs_;/*console.log(objs_)*/});
|
||||
editor_mode.prototype.functions = function (callback) {
|
||||
var objs = [];
|
||||
editor.file.editFunctions([], function (objs_) {
|
||||
objs = objs_;
|
||||
/*console.log(objs_)*/
|
||||
});
|
||||
//只查询不修改时,内部实现不是异步的,所以可以这么写
|
||||
var tableinfo=editor_mode.objToTable_(objs[0],objs[1]);
|
||||
document.getElementById('table_e260a2be_5690_476a_b04e_dacddede78b3').innerHTML=tableinfo.HTML;
|
||||
var tableinfo = editor_mode.objToTable_(objs[0], objs[1]);
|
||||
document.getElementById('table_e260a2be_5690_476a_b04e_dacddede78b3').innerHTML = tableinfo.HTML;
|
||||
tableinfo.listen(tableinfo.guids);
|
||||
if (Boolean(callback))callback();
|
||||
}
|
||||
if (Boolean(callback)) callback();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
editor_mode.prototype.listen = function(callback){
|
||||
editor_mode.prototype.listen = function (callback) {
|
||||
|
||||
var newIdIdnum = document.getElementById('newIdIdnum');
|
||||
newIdIdnum.children[2].onclick = function(){
|
||||
if (newIdIdnum.children[0].value && newIdIdnum.children[1].value){
|
||||
newIdIdnum.children[2].onclick = function () {
|
||||
if (newIdIdnum.children[0].value && newIdIdnum.children[1].value) {
|
||||
var id = newIdIdnum.children[0].value;
|
||||
var idnum = parseInt(newIdIdnum.children[1].value);
|
||||
if (!core.isset(idnum)) {
|
||||
printe('不合法的idnum');
|
||||
return;
|
||||
}
|
||||
editor.file.changeIdAndIdnum(id,idnum,editor_mode.info,function(err){
|
||||
if(err){printe(err);throw(err)}
|
||||
editor.file.changeIdAndIdnum(id, idnum, editor_mode.info, function (err) {
|
||||
if (err) {
|
||||
printe(err);
|
||||
throw(err)
|
||||
}
|
||||
printe('添加id的idnum成功,请F5刷新编辑器');
|
||||
});
|
||||
} else {
|
||||
@ -338,14 +405,14 @@ editor_mode.prototype.listen = function(callback){
|
||||
}
|
||||
|
||||
var selectFloor = document.getElementById('selectFloor');
|
||||
editor.file.getFloorFileList(function(floors){
|
||||
var outstr=[];
|
||||
floors[0].forEach(function(floor){
|
||||
outstr.push(["<option value='",floor,"'>",floor,'</option>\n'].join(''));
|
||||
editor.file.getFloorFileList(function (floors) {
|
||||
var outstr = [];
|
||||
floors[0].forEach(function (floor) {
|
||||
outstr.push(["<option value='", floor, "'>", floor, '</option>\n'].join(''));
|
||||
});
|
||||
selectFloor.innerHTML=outstr.join('');
|
||||
selectFloor.value=core.status.floorId;
|
||||
selectFloor.onchange = function(){
|
||||
selectFloor.innerHTML = outstr.join('');
|
||||
selectFloor.value = core.status.floorId;
|
||||
selectFloor.onchange = function () {
|
||||
editor_mode.onmode('nextChange');
|
||||
editor_mode.onmode('floor');
|
||||
editor.changeFloor(selectFloor.value);
|
||||
@ -353,24 +420,39 @@ editor_mode.prototype.listen = function(callback){
|
||||
});
|
||||
|
||||
var saveFloor = document.getElementById('saveFloor');
|
||||
saveFloor.onclick = function(){
|
||||
saveFloor.onclick = function () {
|
||||
editor_mode.onmode('');
|
||||
editor.file.saveFloorFile(function(err){if(err){printe(err);throw(err)};printf('保存成功');});
|
||||
editor.file.saveFloorFile(function (err) {
|
||||
if (err) {
|
||||
printe(err);
|
||||
throw(err)
|
||||
}
|
||||
|
||||
var saveFloorAs = document.getElementById('saveFloorAs');
|
||||
var saveAsName = document.getElementById('saveAsName');
|
||||
saveFloorAs.onclick = function(){
|
||||
if (!saveAsName.value)return;
|
||||
editor_mode.onmode('');
|
||||
editor.file.saveNewFile(saveAsName.value,function(err){
|
||||
if(err){printe(err);throw(err)}
|
||||
core.floorIds.push(saveAsName.value);
|
||||
editor.file.editTower([['change',"['main']['floorIds']",core.floorIds]],function(objs_){/*console.log(objs_);*/if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printe('新建成功,请F5刷新编辑器生效');});
|
||||
;printf('保存成功');
|
||||
});
|
||||
}
|
||||
|
||||
var ratio=1;
|
||||
var newMap = document.getElementById('newMap');
|
||||
var newFileName = document.getElementById('newFileName');
|
||||
newMap.onclick = function () {
|
||||
if (!newFileName.value) return;
|
||||
editor_mode.onmode('');
|
||||
editor.file.saveNewFile(newFileName.value, function (err) {
|
||||
if (err) {
|
||||
printe(err);
|
||||
throw(err)
|
||||
}
|
||||
core.floorIds.push(newFileName.value);
|
||||
editor.file.editTower([['change', "['main']['floorIds']", core.floorIds]], function (objs_) {/*console.log(objs_);*/
|
||||
if (objs_.slice(-1)[0] != null) {
|
||||
printe(objs_.slice(-1)[0]);
|
||||
throw(objs_.slice(-1)[0])
|
||||
}
|
||||
;printe('新建成功,请F5刷新编辑器生效');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var ratio = 1;
|
||||
var appendPicCanvas = document.getElementById('appendPicCanvas');
|
||||
var bg = appendPicCanvas.children[0];
|
||||
var source = appendPicCanvas.children[1];
|
||||
@ -379,37 +461,37 @@ editor_mode.prototype.listen = function(callback){
|
||||
var appendPicSelection = document.getElementById('appendPicSelection');
|
||||
|
||||
var selectAppend = document.getElementById('selectAppend');
|
||||
var selectAppend_str=[];
|
||||
["terrains", "animates", "enemys", "enemy48", "items", "npcs", "npc48"].forEach(function(image){
|
||||
selectAppend_str.push(["<option value='",image,"'>",image,'</option>\n'].join(''));
|
||||
var selectAppend_str = [];
|
||||
["terrains", "animates", "enemys", "enemy48", "items", "npcs", "npc48"].forEach(function (image) {
|
||||
selectAppend_str.push(["<option value='", image, "'>", image, '</option>\n'].join(''));
|
||||
});
|
||||
selectAppend.innerHTML=selectAppend_str.join('');
|
||||
selectAppend.onchange = function(){
|
||||
selectAppend.innerHTML = selectAppend_str.join('');
|
||||
selectAppend.onchange = function () {
|
||||
var value = selectAppend.value;
|
||||
var ysize = selectAppend.value.indexOf('48')===-1?32:48;
|
||||
var ysize = selectAppend.value.indexOf('48') === -1 ? 32 : 48;
|
||||
editor_mode.appendPic.imageName = value;
|
||||
var img = editor.material.images[value];
|
||||
editor_mode.appendPic.toImg = img;
|
||||
var num = ~~img.width/32;
|
||||
var num = ~~img.width / 32;
|
||||
editor_mode.appendPic.num = num;
|
||||
editor_mode.appendPic.index = 0;
|
||||
var selectStr = '';
|
||||
for(var ii=0;ii<num;ii++){
|
||||
appendPicSelection.children[ii].style='left:0;top:0;height:'+(ysize-6)+'px';
|
||||
selectStr+='{"x":0,"y":0},'
|
||||
for (var ii = 0; ii < num; ii++) {
|
||||
appendPicSelection.children[ii].style = 'left:0;top:0;height:' + (ysize - 6) + 'px';
|
||||
selectStr += '{"x":0,"y":0},'
|
||||
}
|
||||
editor_mode.appendPic.selectPos = eval('['+selectStr+']');
|
||||
for(var jj=num;jj<4;jj++){
|
||||
appendPicSelection.children[jj].style='display:none';
|
||||
editor_mode.appendPic.selectPos = eval('[' + selectStr + ']');
|
||||
for (var jj = num; jj < 4; jj++) {
|
||||
appendPicSelection.children[jj].style = 'display:none';
|
||||
}
|
||||
sprite.style.width = (sprite.width = img.width)/ratio + 'px';
|
||||
sprite.style.height = (sprite.height = img.height+ysize)/ratio + 'px';
|
||||
sprite.style.width = (sprite.width = img.width) / ratio + 'px';
|
||||
sprite.style.height = (sprite.height = img.height + ysize) / ratio + 'px';
|
||||
sprite.getContext('2d').drawImage(img, 0, 0);
|
||||
}
|
||||
selectAppend.onchange();
|
||||
|
||||
var selectFileBtn = document.getElementById('selectFileBtn');
|
||||
selectFileBtn.onclick = function(){
|
||||
selectFileBtn.onclick = function () {
|
||||
var loadImage = function (content, callback) {
|
||||
var image = new Image();
|
||||
try {
|
||||
@ -426,29 +508,29 @@ editor_mode.prototype.listen = function(callback){
|
||||
printe(e);
|
||||
}
|
||||
}
|
||||
core.readFile(function(content){
|
||||
loadImage(content,function(image){
|
||||
core.readFile(function (content) {
|
||||
loadImage(content, function (image) {
|
||||
editor_mode.appendPic.img = image;
|
||||
editor_mode.appendPic.width = image.width;
|
||||
editor_mode.appendPic.height = image.height;
|
||||
var ysize = selectAppend.value.indexOf('48')===-1?32:48;
|
||||
for(var ii=0;ii<3;ii++){
|
||||
var ysize = selectAppend.value.indexOf('48') === -1 ? 32 : 48;
|
||||
for (var ii = 0; ii < 3; ii++) {
|
||||
var newsprite = appendPicCanvas.children[ii];
|
||||
newsprite.style.width = (newsprite.width = Math.floor(image.width/32)*32)/ratio + 'px';
|
||||
newsprite.style.height = (newsprite.height = Math.floor(image.height/ysize)*ysize)/ratio + 'px';
|
||||
newsprite.style.width = (newsprite.width = Math.floor(image.width / 32) * 32) / ratio + 'px';
|
||||
newsprite.style.height = (newsprite.height = Math.floor(image.height / ysize) * ysize) / ratio + 'px';
|
||||
}
|
||||
|
||||
//画灰白相间的格子
|
||||
var bgc = bg.getContext('2d');
|
||||
var colorA = ["#f8f8f8", "#cccccc"];
|
||||
var colorIndex;
|
||||
var sratio=4;
|
||||
for (var ii = 0; ii < image.width/32*sratio; ii++){
|
||||
colorIndex = 1-ii%2;
|
||||
for (var jj = 0; jj < image.height/32*sratio; jj++) {
|
||||
var sratio = 4;
|
||||
for (var ii = 0; ii < image.width / 32 * sratio; ii++) {
|
||||
colorIndex = 1 - ii % 2;
|
||||
for (var jj = 0; jj < image.height / 32 * sratio; jj++) {
|
||||
bgc.fillStyle = colorA[colorIndex];
|
||||
colorIndex = 1 - colorIndex;
|
||||
bgc.fillRect(ii * 32/sratio, jj * 32/sratio, 32/sratio, 32/sratio);
|
||||
bgc.fillRect(ii * 32 / sratio, jj * 32 / sratio, 32 / sratio, 32 / sratio);
|
||||
}
|
||||
}
|
||||
|
||||
@ -458,7 +540,7 @@ editor_mode.prototype.listen = function(callback){
|
||||
//重置临时变量
|
||||
selectAppend.onchange();
|
||||
});
|
||||
},null,'img');
|
||||
}, null, 'img');
|
||||
|
||||
return;
|
||||
}
|
||||
@ -468,65 +550,68 @@ editor_mode.prototype.listen = function(callback){
|
||||
var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft
|
||||
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop
|
||||
var loc = {
|
||||
'x': scrollLeft+e.clientX + appendPicCanvas.scrollLeft - left1.offsetLeft-appendPicCanvas.offsetLeft,
|
||||
'y': scrollTop+e.clientY + appendPicCanvas.scrollTop - left1.offsetTop-appendPicCanvas.offsetTop,
|
||||
'x': scrollLeft + e.clientX + appendPicCanvas.scrollLeft - left1.offsetLeft - appendPicCanvas.offsetLeft,
|
||||
'y': scrollTop + e.clientY + appendPicCanvas.scrollTop - left1.offsetTop - appendPicCanvas.offsetTop,
|
||||
'size': 32,
|
||||
'ysize': selectAppend.value.indexOf('48')===-1?32:48
|
||||
'ysize': selectAppend.value.indexOf('48') === -1 ? 32 : 48
|
||||
};
|
||||
return loc;
|
||||
}//返回可用的组件内坐标
|
||||
|
||||
var locToPos = function (loc) {
|
||||
var pos = { 'x': ~~(loc.x / loc.size), 'y': ~~(loc.y / loc.ysize) ,'ysize': loc.ysize}
|
||||
var pos = {'x': ~~(loc.x / loc.size), 'y': ~~(loc.y / loc.ysize), 'ysize': loc.ysize}
|
||||
return pos;
|
||||
}
|
||||
|
||||
picClick.onclick = function(e){
|
||||
picClick.onclick = function (e) {
|
||||
var loc = eToLoc(e);
|
||||
var pos = locToPos(loc);
|
||||
/*console.log(e,loc,pos);*/
|
||||
var num = editor_mode.appendPic.num;
|
||||
var ii = editor_mode.appendPic.index;
|
||||
if(ii+1>=num)editor_mode.appendPic.index=ii+1-num;
|
||||
if (ii + 1 >= num) editor_mode.appendPic.index = ii + 1 - num;
|
||||
else editor_mode.appendPic.index++;
|
||||
editor_mode.appendPic.selectPos[ii]=pos;
|
||||
appendPicSelection.children[ii].style=[
|
||||
'left:',pos.x*32,'px;',
|
||||
'top:',pos.y*pos.ysize,'px;',
|
||||
'height:',pos.ysize-6,'px;'
|
||||
editor_mode.appendPic.selectPos[ii] = pos;
|
||||
appendPicSelection.children[ii].style = [
|
||||
'left:', pos.x * 32, 'px;',
|
||||
'top:', pos.y * pos.ysize, 'px;',
|
||||
'height:', pos.ysize - 6, 'px;'
|
||||
].join('');
|
||||
}
|
||||
|
||||
var appendConfirm = document.getElementById('appendConfirm');
|
||||
appendConfirm.onclick = function(){
|
||||
var ysize = selectAppend.value.indexOf('48')===-1?32:48;
|
||||
appendConfirm.onclick = function () {
|
||||
var ysize = selectAppend.value.indexOf('48') === -1 ? 32 : 48;
|
||||
var sprited = sprite.getContext('2d');
|
||||
//sprited.drawImage(img, 0, 0);
|
||||
var height = editor_mode.appendPic.toImg.height;
|
||||
var sourced = source.getContext('2d');
|
||||
for(var ii=0,v;v=editor_mode.appendPic.selectPos[ii];ii++){
|
||||
var imgData=sourced.getImageData(v.x*32,v.y*ysize,32,ysize);
|
||||
sprited.putImageData(imgData,ii*32,height);
|
||||
for (var ii = 0, v; v = editor_mode.appendPic.selectPos[ii]; ii++) {
|
||||
var imgData = sourced.getImageData(v.x * 32, v.y * ysize, 32, ysize);
|
||||
sprited.putImageData(imgData, ii * 32, height);
|
||||
}
|
||||
var imgbase64 = sprite.toDataURL().split(',')[1];
|
||||
fs.writeFile('./project/images/'+editor_mode.appendPic.imageName+'.png',imgbase64,'base64',function(err,data){
|
||||
if(err){printe(err);throw(err)}
|
||||
fs.writeFile('./project/images/' + editor_mode.appendPic.imageName + '.png', imgbase64, 'base64', function (err, data) {
|
||||
if (err) {
|
||||
printe(err);
|
||||
throw(err)
|
||||
}
|
||||
printe('追加素材成功,请F5刷新编辑器');
|
||||
});
|
||||
}
|
||||
|
||||
var editModeSelect = document.getElementById('editModeSelect');
|
||||
editModeSelect.onchange = function(){
|
||||
editModeSelect.onchange = function () {
|
||||
editor_mode.onmode('nextChange');
|
||||
editor_mode.onmode(editModeSelect.value);
|
||||
}
|
||||
|
||||
if (Boolean(callback))callback();
|
||||
}
|
||||
if (Boolean(callback)) callback();
|
||||
}
|
||||
|
||||
var editor_mode = new editor_mode();
|
||||
editor_mode.init_dom_ids();
|
||||
var editor_mode = new editor_mode();
|
||||
editor_mode.init_dom_ids();
|
||||
|
||||
return editor_mode;
|
||||
return editor_mode;
|
||||
}
|
||||
//editor_mode = editor_mode(editor);
|
||||
@ -1,8 +1,8 @@
|
||||
editor_multi = function(){
|
||||
editor_multi = function () {
|
||||
|
||||
var editor_multi = {};
|
||||
var editor_multi = {};
|
||||
|
||||
var codeEditor = CodeMirror.fromTextArea(document.getElementById("multiLineCode"), {
|
||||
var codeEditor = CodeMirror.fromTextArea(document.getElementById("multiLineCode"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
indentUnit: 4,
|
||||
@ -16,127 +16,142 @@ var codeEditor = CodeMirror.fromTextArea(document.getElementById("multiLineCode"
|
||||
lint: true,
|
||||
autocomplete: true,
|
||||
extraKeys: {"Ctrl-Q": "toggleComment"},
|
||||
});
|
||||
});
|
||||
|
||||
codeEditor.on("keyup", function (cm, event) {
|
||||
if (codeEditor.getOption("autocomplete") && (event.keyCode >= 65 && event.keyCode<=90) || (event.keyCode>=49 && event.keyCode<=57) || event.keyCode==190) {
|
||||
codeEditor.on("keyup", function (cm, event) {
|
||||
if (codeEditor.getOption("autocomplete") && (event.keyCode >= 65 && event.keyCode <= 90) || (event.keyCode >= 49 && event.keyCode <= 57) || event.keyCode == 190) {
|
||||
try {
|
||||
CodeMirror.commands.autocomplete(cm, null, {completeSingle: false});
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
editor_multi.id='';
|
||||
editor_multi.isString=false;
|
||||
editor_multi.lintAutocomplete=false;
|
||||
editor_multi.id = '';
|
||||
editor_multi.isString = false;
|
||||
editor_multi.lintAutocomplete = false;
|
||||
|
||||
editor_multi.show = function(){
|
||||
if(typeof(selectBox)!==typeof(undefined))selectBox.isSelected = false;
|
||||
editor_multi.show = function () {
|
||||
if (typeof(selectBox) !== typeof(undefined)) selectBox.isSelected = false;
|
||||
var valueNow = codeEditor.getValue();
|
||||
//try{eval('function _asdygakufyg_() { return '+valueNow+'\n}');editor_multi.lintAutocomplete=true;}catch(ee){}
|
||||
if(valueNow.slice(0,8)==='function')editor_multi.lintAutocomplete=true;
|
||||
if (valueNow.slice(0, 8) === 'function') editor_multi.lintAutocomplete = true;
|
||||
editor_multi.setLint();
|
||||
document.getElementById('left7').style='';
|
||||
}
|
||||
editor_multi.hide = function(){document.getElementById('left7').style='z-index:-1;opacity: 0;';}
|
||||
editor_multi.setLint = function() {
|
||||
document.getElementById('left7').style = '';
|
||||
}
|
||||
editor_multi.hide = function () {
|
||||
document.getElementById('left7').style = 'z-index:-1;opacity: 0;';
|
||||
}
|
||||
editor_multi.setLint = function () {
|
||||
codeEditor.setOption("lint", editor_multi.lintAutocomplete);
|
||||
codeEditor.setOption("autocomplete", editor_multi.lintAutocomplete);
|
||||
document.getElementById("lintCheckbox").checked = editor_multi.lintAutocomplete;
|
||||
}
|
||||
editor_multi.toggerLint = function() {
|
||||
}
|
||||
editor_multi.toggerLint = function () {
|
||||
editor_multi.lintAutocomplete = document.getElementById("lintCheckbox").checked;
|
||||
editor_multi.setLint();
|
||||
}
|
||||
}
|
||||
|
||||
editor_multi.indent = function(field){
|
||||
if(typeof(editor)!==typeof(undefined) && editor && editor.mode && editor.mode.indent)return editor.mode.indent(field);
|
||||
editor_multi.indent = function (field) {
|
||||
if (typeof(editor) !== typeof(undefined) && editor && editor.mode && editor.mode.indent) return editor.mode.indent(field);
|
||||
return '\t';
|
||||
}
|
||||
}
|
||||
|
||||
editor_multi.import = function(id_,args){
|
||||
editor_multi.import = function (id_, args) {
|
||||
var thisTr = document.getElementById(id_);
|
||||
if(!thisTr)return false;
|
||||
if (!thisTr) return false;
|
||||
var input = thisTr.children[2].children[0].children[0];
|
||||
var field = thisTr.children[0].getAttribute('title');
|
||||
var comment = thisTr.children[1].getAttribute('title');
|
||||
if(!input.type || input.type!=='textarea')return false;
|
||||
editor_multi.id=id_;
|
||||
editor_multi.isString=false;
|
||||
editor_multi.lintAutocomplete=false;
|
||||
if(args.lint===true)editor_multi.lintAutocomplete=true;
|
||||
if(field.indexOf('Effect') !== -1)editor_multi.lintAutocomplete=true;
|
||||
if(input.value.slice(0,1)==='"'){
|
||||
editor_multi.isString=true;
|
||||
codeEditor.setValue(JSON.parse(input.value)||'');
|
||||
if (!input.type || input.type !== 'textarea') return false;
|
||||
editor_multi.id = id_;
|
||||
editor_multi.isString = false;
|
||||
editor_multi.lintAutocomplete = false;
|
||||
if (args.lint === true) editor_multi.lintAutocomplete = true;
|
||||
if (field.indexOf('Effect') !== -1) editor_multi.lintAutocomplete = true;
|
||||
if (input.value.slice(0, 1) === '"') {
|
||||
editor_multi.isString = true;
|
||||
codeEditor.setValue(JSON.parse(input.value) || '');
|
||||
} else {
|
||||
var num = editor_multi.indent(field);
|
||||
eval('var tobj='+(input.value||'null'));
|
||||
var tmap={};
|
||||
var tstr = JSON.stringify(tobj,function(k,v){if(typeof(v)===typeof('') && v.slice(0,8)==='function'){var id_ = editor.guid();tmap[id_]=v.toString();return id_;}else return v},num);
|
||||
for(var id_ in tmap){
|
||||
tstr = tstr.replace('"'+id_+'"',tmap[id_])
|
||||
eval('var tobj=' + (input.value || 'null'));
|
||||
var tmap = {};
|
||||
var tstr = JSON.stringify(tobj, function (k, v) {
|
||||
if (typeof(v) === typeof('') && v.slice(0, 8) === 'function') {
|
||||
var id_ = editor.guid();
|
||||
tmap[id_] = v.toString();
|
||||
return id_;
|
||||
} else return v
|
||||
}, num);
|
||||
for (var id_ in tmap) {
|
||||
tstr = tstr.replace('"' + id_ + '"', tmap[id_])
|
||||
}
|
||||
codeEditor.setValue(tstr||'');
|
||||
codeEditor.setValue(tstr || '');
|
||||
}
|
||||
editor_multi.show();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
editor_multi.cancel = function(){
|
||||
editor_multi.cancel = function () {
|
||||
editor_multi.hide();
|
||||
editor_multi.id='';
|
||||
multiLineArgs=[null,null,null];
|
||||
}
|
||||
editor_multi.id = '';
|
||||
multiLineArgs = [null, null, null];
|
||||
}
|
||||
|
||||
editor_multi.confirm = function (){
|
||||
if(!editor_multi.id){
|
||||
editor_multi.id='';
|
||||
editor_multi.confirm = function () {
|
||||
if (!editor_multi.id) {
|
||||
editor_multi.id = '';
|
||||
return;
|
||||
}
|
||||
if(editor_multi.id==='callFromBlockly'){
|
||||
editor_multi.id='';
|
||||
if (editor_multi.id === 'callFromBlockly') {
|
||||
editor_multi.id = '';
|
||||
editor_multi.multiLineDone();
|
||||
return;
|
||||
}
|
||||
var setvalue = function(value){
|
||||
var setvalue = function (value) {
|
||||
var thisTr = document.getElementById(editor_multi.id);
|
||||
editor_multi.id='';
|
||||
editor_multi.id = '';
|
||||
var input = thisTr.children[2].children[0].children[0];
|
||||
if(editor_multi.isString){
|
||||
if (editor_multi.isString) {
|
||||
input.value = JSON.stringify(value);
|
||||
} else {
|
||||
eval('var tobj='+(value||'null'));
|
||||
var tmap={};
|
||||
var tstr = JSON.stringify(tobj,function(k,v){if(v instanceof Function){var id_ = editor.guid();tmap[id_]=v.toString();return id_;}else return v},4);
|
||||
for(var id_ in tmap){
|
||||
tstr = tstr.replace('"'+id_+'"',JSON.stringify(tmap[id_]))
|
||||
eval('var tobj=' + (value || 'null'));
|
||||
var tmap = {};
|
||||
var tstr = JSON.stringify(tobj, function (k, v) {
|
||||
if (v instanceof Function) {
|
||||
var id_ = editor.guid();
|
||||
tmap[id_] = v.toString();
|
||||
return id_;
|
||||
} else return v
|
||||
}, 4);
|
||||
for (var id_ in tmap) {
|
||||
tstr = tstr.replace('"' + id_ + '"', JSON.stringify(tmap[id_]))
|
||||
}
|
||||
input.value = tstr;
|
||||
}
|
||||
editor_multi.hide();
|
||||
input.onchange();
|
||||
}
|
||||
setvalue(codeEditor.getValue()||'');
|
||||
}
|
||||
setvalue(codeEditor.getValue() || '');
|
||||
}
|
||||
|
||||
var multiLineArgs=[null,null,null];
|
||||
editor_multi.multiLineEdit = function(value,b,f,args,callback){
|
||||
editor_multi.id='callFromBlockly';
|
||||
codeEditor.setValue(value.split('\\n').join('\n')||'');
|
||||
multiLineArgs[0]=b;
|
||||
multiLineArgs[1]=f;
|
||||
multiLineArgs[2]=callback;
|
||||
editor_multi.lintAutocomplete=Boolean(args.lint);
|
||||
var multiLineArgs = [null, null, null];
|
||||
editor_multi.multiLineEdit = function (value, b, f, args, callback) {
|
||||
editor_multi.id = 'callFromBlockly';
|
||||
codeEditor.setValue(value.split('\\n').join('\n') || '');
|
||||
multiLineArgs[0] = b;
|
||||
multiLineArgs[1] = f;
|
||||
multiLineArgs[2] = callback;
|
||||
editor_multi.lintAutocomplete = Boolean(args.lint);
|
||||
editor_multi.show();
|
||||
}
|
||||
editor_multi.multiLineDone = function(){
|
||||
}
|
||||
editor_multi.multiLineDone = function () {
|
||||
editor_multi.hide();
|
||||
if(!multiLineArgs[0] || !multiLineArgs[1] || !multiLineArgs[2])return;
|
||||
var newvalue = codeEditor.getValue()||'';
|
||||
multiLineArgs[2](newvalue,multiLineArgs[0],multiLineArgs[1])
|
||||
}
|
||||
if (!multiLineArgs[0] || !multiLineArgs[1] || !multiLineArgs[2]) return;
|
||||
var newvalue = codeEditor.getValue() || '';
|
||||
multiLineArgs[2](newvalue, multiLineArgs[0], multiLineArgs[1])
|
||||
}
|
||||
|
||||
return editor_multi;
|
||||
return editor_multi;
|
||||
}
|
||||
//editor_multi=editor_multi();
|
||||
@ -1,87 +1,87 @@
|
||||
(function(){
|
||||
(function () {
|
||||
fs = {};
|
||||
var postsomething = function (data,_ip,callback) {
|
||||
var postsomething = function (data, _ip, callback) {
|
||||
//callback:function(err, data)
|
||||
//data:字符串
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function(){
|
||||
switch(xhr.readyState){
|
||||
xhr.onreadystatechange = function () {
|
||||
switch (xhr.readyState) {
|
||||
case 4 :
|
||||
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304) {
|
||||
if (Boolean(callback)){
|
||||
if (xhr.responseText.slice(0,6)=='error:'){
|
||||
callback(xhr.responseText,null);
|
||||
if (Boolean(callback)) {
|
||||
if (xhr.responseText.slice(0, 6) == 'error:') {
|
||||
callback(xhr.responseText, null);
|
||||
} else {
|
||||
callback(null,xhr.responseText);
|
||||
callback(null, xhr.responseText);
|
||||
}
|
||||
}
|
||||
//printf(xhr.responseText)
|
||||
}else{
|
||||
if (Boolean(callback))callback(xhr.status,null);
|
||||
} else {
|
||||
if (Boolean(callback)) callback(xhr.status, null);
|
||||
//printf('error:' + xhr.status+'<br>'+(xhr.responseText||''));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
xhr.open('post',_ip);
|
||||
xhr.setRequestHeader('Content-Type','text/plain');
|
||||
if(typeof(data)==typeof([][0]) || data==null)data=JSON.stringify({1:2});
|
||||
xhr.open('post', _ip);
|
||||
xhr.setRequestHeader('Content-Type', 'text/plain');
|
||||
if (typeof(data) == typeof([][0]) || data == null) data = JSON.stringify({1: 2});
|
||||
xhr.send(data);
|
||||
}
|
||||
|
||||
fs.readFile = function (filename,encoding,callback) {
|
||||
if (typeof(filename)!=typeof(''))
|
||||
fs.readFile = function (filename, encoding, callback) {
|
||||
if (typeof(filename) != typeof(''))
|
||||
throw 'Type Error in fs.readFile';
|
||||
if (encoding=='utf-8'){
|
||||
if (encoding == 'utf-8') {
|
||||
//读文本文件
|
||||
//filename:支持"/"做分隔符
|
||||
//callback:function(err, data)
|
||||
//data:字符串
|
||||
var data='';
|
||||
data+='type=utf8&';
|
||||
data+='name='+filename;
|
||||
postsomething(data,'/readFile',callback);
|
||||
var data = '';
|
||||
data += 'type=utf8&';
|
||||
data += 'name=' + filename;
|
||||
postsomething(data, '/readFile', callback);
|
||||
return;
|
||||
}
|
||||
if (encoding=='base64'){
|
||||
if (encoding == 'base64') {
|
||||
//读二进制文件
|
||||
//filename:支持"/"做分隔符
|
||||
//callback:function(err, data)
|
||||
//data:base64字符串
|
||||
var data='';
|
||||
data+='type=base64&';
|
||||
data+='name='+filename;
|
||||
postsomething(data,'/readFile',callback);
|
||||
var data = '';
|
||||
data += 'type=base64&';
|
||||
data += 'name=' + filename;
|
||||
postsomething(data, '/readFile', callback);
|
||||
return;
|
||||
}
|
||||
throw 'Type Error in fs.readFile';
|
||||
}
|
||||
|
||||
fs.writeFile = function (filename,datastr,encoding,callback) {
|
||||
if (typeof(filename)!=typeof('') || typeof(datastr)!=typeof(''))
|
||||
fs.writeFile = function (filename, datastr, encoding, callback) {
|
||||
if (typeof(filename) != typeof('') || typeof(datastr) != typeof(''))
|
||||
throw 'Type Error in fs.writeFile';
|
||||
if (encoding=='utf-8'){
|
||||
if (encoding == 'utf-8') {
|
||||
//写文本文件
|
||||
//filename:支持"/"做分隔符
|
||||
//callback:function(err)
|
||||
//datastr:字符串
|
||||
var data='';
|
||||
data+='type=utf8&';
|
||||
data+='name='+filename;
|
||||
data+='&value='+datastr;
|
||||
postsomething(data,'/writeFile',callback);
|
||||
var data = '';
|
||||
data += 'type=utf8&';
|
||||
data += 'name=' + filename;
|
||||
data += '&value=' + datastr;
|
||||
postsomething(data, '/writeFile', callback);
|
||||
return;
|
||||
}
|
||||
if (encoding=='base64'){
|
||||
if (encoding == 'base64') {
|
||||
//写二进制文件
|
||||
//filename:支持"/"做分隔符
|
||||
//callback:function(err)
|
||||
//datastr:base64字符串
|
||||
var data='';
|
||||
data+='type=base64&';
|
||||
data+='name='+filename;
|
||||
data+='&value='+datastr;
|
||||
postsomething(data,'/writeFile',callback);
|
||||
var data = '';
|
||||
data += 'type=base64&';
|
||||
data += 'name=' + filename;
|
||||
data += '&value=' + datastr;
|
||||
postsomething(data, '/writeFile', callback);
|
||||
return;
|
||||
}
|
||||
throw 'Type Error in fs.writeFile';
|
||||
@ -91,11 +91,13 @@
|
||||
//callback:function(err, data)
|
||||
//path:支持"/"做分隔符,不以"/"结尾
|
||||
//data:[filename1,filename2,..] filename是字符串,只包含文件不包含目录
|
||||
if (typeof(path)!=typeof(''))
|
||||
if (typeof(path) != typeof(''))
|
||||
throw 'Type Error in fs.readdir';
|
||||
var data='';
|
||||
data+='name='+path;
|
||||
postsomething(data,'/listFile',function(err, data){callback(err,JSON.parse(data))});
|
||||
var data = '';
|
||||
data += 'name=' + path;
|
||||
postsomething(data, '/listFile', function (err, data) {
|
||||
callback(err, JSON.parse(data))
|
||||
});
|
||||
return;
|
||||
}
|
||||
})();
|
||||
@ -1,24 +1,41 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head><meta charset="utf-8"></head>
|
||||
<body>
|
||||
<script src="./fs.js"></script>
|
||||
<script>
|
||||
fs.writeFile('_test.txt','123中a文bc','utf-8',function(e,d){console.log(e);console.log(d);})
|
||||
setTimeout(function() {
|
||||
fs.writeFile('_test_bin.txt','abc=','base64',function(e,d){console.log(e);console.log(d);})
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<script src="./fs.js"></script>
|
||||
<script>
|
||||
fs.writeFile('_test.txt', '123中a文bc', 'utf-8', function (e, d) {
|
||||
console.log(e);
|
||||
console.log(d);
|
||||
})
|
||||
setTimeout(function () {
|
||||
fs.writeFile('_test_bin.txt', 'abc=', 'base64', function (e, d) {
|
||||
console.log(e);
|
||||
console.log(d);
|
||||
})
|
||||
}, 1000);
|
||||
setTimeout(function() {
|
||||
fs.readFile('_test.txt','utf-8',function(e,d){console.log(e);console.log(d);})
|
||||
setTimeout(function () {
|
||||
fs.readFile('_test.txt', 'utf-8', function (e, d) {
|
||||
console.log(e);
|
||||
console.log(d);
|
||||
})
|
||||
}, 2000);
|
||||
setTimeout(function() {
|
||||
fs.readFile('_test_bin.txt','base64',function(e,d){console.log(e);console.log(d);})
|
||||
setTimeout(function () {
|
||||
fs.readFile('_test_bin.txt', 'base64', function (e, d) {
|
||||
console.log(e);
|
||||
console.log(d);
|
||||
})
|
||||
}, 3000);
|
||||
setTimeout(function() {
|
||||
fs.readdir('.',function(e,d){console.log(e);console.log(d);})
|
||||
setTimeout(function () {
|
||||
fs.readdir('.', function (e, d) {
|
||||
console.log(e);
|
||||
console.log(d);
|
||||
})
|
||||
}, 4000);
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
230
_server/vm.js
230
_server/vm.js
@ -1,22 +1,28 @@
|
||||
// vue 相关处理
|
||||
|
||||
document.body.onmousedown = function(e){
|
||||
document.body.onmousedown = function (e) {
|
||||
//console.log(e);
|
||||
var eid=[];
|
||||
e.path.forEach(function(node){
|
||||
if(!node.getAttribute)return;
|
||||
var eid = [];
|
||||
e.path.forEach(function (node) {
|
||||
if (!node.getAttribute) return;
|
||||
var id_ = node.getAttribute('id');
|
||||
if (id_){
|
||||
if(['left','left1','left2','left3','left4','left5','left8'].indexOf(id_)!==-1)eid.push('edit');
|
||||
if (id_) {
|
||||
if (['left', 'left1', 'left2', 'left3', 'left4', 'left5', 'left8'].indexOf(id_) !== -1) eid.push('edit');
|
||||
eid.push(id_);
|
||||
}
|
||||
});
|
||||
//console.log(eid);
|
||||
if(eid.indexOf('edit')===-1){
|
||||
if(eid.indexOf('tip')===-1) {
|
||||
if (eid.indexOf('edit') === -1) {
|
||||
if (eid.indexOf('tip') === -1) {
|
||||
if (selectBox.isSelected) {
|
||||
editor_mode.onmode('');
|
||||
editor.file.saveFloorFile(function(err){if(err){printe(err);throw(err)};printf('地图保存成功');});
|
||||
editor.file.saveFloorFile(function (err) {
|
||||
if (err) {
|
||||
printe(err);
|
||||
throw(err)
|
||||
}
|
||||
;printf('地图保存成功');
|
||||
});
|
||||
}
|
||||
selectBox.isSelected = false;
|
||||
}
|
||||
@ -24,40 +30,40 @@ document.body.onmousedown = function(e){
|
||||
//editor.mode.onmode('');
|
||||
editor.info = {};
|
||||
}
|
||||
iconLib.onmousedown = function(e){
|
||||
iconLib.onmousedown = function (e) {
|
||||
e.stopPropagation();
|
||||
}
|
||||
var exportM = new Vue({
|
||||
el: '#exportM',
|
||||
var exportMap = new Vue({
|
||||
el: '#exportMap',
|
||||
data: {
|
||||
isExport: false,
|
||||
},
|
||||
methods: {
|
||||
exportMap: function(){
|
||||
exportMap: function () {
|
||||
editor.updateMap();
|
||||
|
||||
var filestr='';
|
||||
for (var yy = 0; yy < 13; yy++){
|
||||
filestr+='['
|
||||
var filestr = '';
|
||||
for (var yy = 0; yy < 13; yy++) {
|
||||
filestr += '['
|
||||
for (var xx = 0; xx < 13; xx++) {
|
||||
var mapxy=editor.map[yy][xx];
|
||||
if(typeof(mapxy)==typeof({})){
|
||||
if ('idnum' in mapxy)mapxy=mapxy.idnum;
|
||||
var mapxy = editor.map[yy][xx];
|
||||
if (typeof(mapxy) == typeof({})) {
|
||||
if ('idnum' in mapxy) mapxy = mapxy.idnum;
|
||||
else {
|
||||
// mapxy='!!?';
|
||||
tip.whichShow = 3;
|
||||
return;
|
||||
}
|
||||
}else if(typeof(mapxy)=='undefined'){
|
||||
} else if (typeof(mapxy) == 'undefined') {
|
||||
tip.whichShow = 3;
|
||||
return;
|
||||
}
|
||||
mapxy=String(mapxy);
|
||||
mapxy=Array(Math.max(4-mapxy.length,0)).join(' ')+mapxy;
|
||||
filestr+=mapxy+(xx==12?'':',')
|
||||
mapxy = String(mapxy);
|
||||
mapxy = Array(Math.max(4 - mapxy.length, 0)).join(' ') + mapxy;
|
||||
filestr += mapxy + (xx == 12 ? '' : ',')
|
||||
}
|
||||
|
||||
filestr += ']'+(yy==12?'':',\n');
|
||||
filestr += ']' + (yy == 12 ? '' : ',\n');
|
||||
}
|
||||
pout.value = filestr;
|
||||
editArea.mapArr = filestr;
|
||||
@ -83,116 +89,124 @@ var editArea = new Vue({
|
||||
watch: {
|
||||
mapArr: function (val, oldval) {
|
||||
var that = this;
|
||||
if(val=='') return;
|
||||
if(exportM.isExport){
|
||||
exportM.isExport = false;
|
||||
if (val == '') return;
|
||||
if (exportMap.isExport) {
|
||||
exportMap.isExport = false;
|
||||
return;
|
||||
}
|
||||
if(that.formatArr()){
|
||||
if (that.formatArr()) {
|
||||
that.error = 0;
|
||||
|
||||
setTimeout(function(){
|
||||
setTimeout(function () {
|
||||
that.mapArr = that.formatArr();
|
||||
that.drawMap();
|
||||
tip.whichShow = 8
|
||||
}, 1000);
|
||||
that.formatTimer = setTimeout(function(){
|
||||
that.formatTimer = setTimeout(function () {
|
||||
pout.value = that.formatArr();
|
||||
}, 5000); //5s后再格式化,不然光标跳到最后很烦
|
||||
}else{
|
||||
} else {
|
||||
that.error = 1;
|
||||
}
|
||||
},
|
||||
error: function(){
|
||||
error: function () {
|
||||
// console.log(editArea.mapArr);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
drawMap: function(){
|
||||
drawMap: function () {
|
||||
var that = this;
|
||||
|
||||
// var mapArray = that.mapArr.split(/\D+/).join(' ').trim().split(' ');
|
||||
var mapArray = JSON.parse('['+that.mapArr+']');
|
||||
for(var y=0; y<13; y++)
|
||||
for(var x=0; x<13; x++){
|
||||
var mapArray = JSON.parse('[' + that.mapArr + ']');
|
||||
for (var y = 0; y < 13; y++)
|
||||
for (var x = 0; x < 13; x++) {
|
||||
var num = mapArray[y][x];
|
||||
if(num == 0 )
|
||||
if (num == 0)
|
||||
editor.map[y][x] = 0;
|
||||
else if(num >= 1000){
|
||||
else if (num >= 1000) {
|
||||
that.error = 3;
|
||||
editor.map[y][x] = undefined;
|
||||
}else if(typeof(editor.indexs[num][0]) == 'undefined'){
|
||||
} else if (typeof(editor.indexs[num][0]) == 'undefined') {
|
||||
that.error = 2;
|
||||
editor.map[y][x] = undefined;
|
||||
}else editor.map[y][x] = editor.ids[[editor.indexs[num][0]]];
|
||||
} else editor.map[y][x] = editor.ids[[editor.indexs[num][0]]];
|
||||
}
|
||||
|
||||
editor.updateMap();
|
||||
|
||||
},
|
||||
formatArr: function(){
|
||||
formatArr: function () {
|
||||
var formatArrStr = '';
|
||||
var that = this;
|
||||
clearTimeout(that.formatTimer);
|
||||
if(this.mapArr.split(/\D+/).join(' ').trim().split(' ').length != 169) return false;
|
||||
if (this.mapArr.split(/\D+/).join(' ').trim().split(' ').length != 169) return false;
|
||||
var arr = this.mapArr.replace(/\s+/g, '').split('],[');
|
||||
|
||||
if(arr.length != 13) return ;
|
||||
for(var i =0; i<13; i++){
|
||||
if (arr.length != 13) return;
|
||||
for (var i = 0; i < 13; i++) {
|
||||
var a = [];
|
||||
formatArrStr +='[';
|
||||
if(i==0||i==12) a = arr[i].split(/\D+/).join(' ').trim().split(' ');
|
||||
formatArrStr += '[';
|
||||
if (i == 0 || i == 12) a = arr[i].split(/\D+/).join(' ').trim().split(' ');
|
||||
else a = arr[i].split(/\D+/);
|
||||
if(a.length != 13){
|
||||
if (a.length != 13) {
|
||||
formatArrStr = '';
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
for(var k=0; k<13; k++){
|
||||
for (var k = 0; k < 13; k++) {
|
||||
var num = parseInt(a[k]);
|
||||
formatArrStr += Array(Math.max(4-String(num).length,0)).join(' ')+num+(k==12?'':',');
|
||||
formatArrStr += Array(Math.max(4 - String(num).length, 0)).join(' ') + num + (k == 12 ? '' : ',');
|
||||
}
|
||||
formatArrStr += ']'+(i==12?'':',\n');
|
||||
formatArrStr += ']' + (i == 12 ? '' : ',\n');
|
||||
}
|
||||
return formatArrStr;
|
||||
}
|
||||
}
|
||||
});
|
||||
var editTip = new Vue({
|
||||
el: '#editTip',
|
||||
var copyMap = new Vue({
|
||||
el: '#copyMap',
|
||||
data: {
|
||||
err: ''
|
||||
},
|
||||
methods: {
|
||||
copyMap: function(){
|
||||
copyMap: function () {
|
||||
|
||||
tip.whichShow = 0;
|
||||
if(pout.value.trim() != ''){
|
||||
if(editArea.error) {
|
||||
this.err = editArea.errors[editArea.error-1];
|
||||
if (pout.value.trim() != '') {
|
||||
if (editArea.error) {
|
||||
this.err = editArea.errors[editArea.error - 1];
|
||||
tip.whichShow = 5
|
||||
return;
|
||||
}
|
||||
try{
|
||||
try {
|
||||
pout.select();
|
||||
document.execCommand("Copy");
|
||||
tip.whichShow = 6;
|
||||
}catch(e){
|
||||
this.err= e;
|
||||
} catch (e) {
|
||||
this.err = e;
|
||||
tip.whichShow = 5;
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
tip.whichShow = 7;
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
var clear = new Vue({
|
||||
el: '#clear',
|
||||
var clearMap = new Vue({
|
||||
el: '#clearMap',
|
||||
|
||||
methods: {
|
||||
clearMap: function(){
|
||||
clearMap: function () {
|
||||
editor.mapInit();
|
||||
editor_mode.onmode('');
|
||||
editor.file.saveFloorFile(function (err) {
|
||||
if (err) {
|
||||
printe(err);
|
||||
throw(err)
|
||||
}
|
||||
;printf('地图清除成功');
|
||||
});
|
||||
editor.updateMap();
|
||||
clearTimeout(editArea.formatTimer);
|
||||
clearTimeout(tip.timer);
|
||||
@ -203,24 +217,46 @@ var clear = new Vue({
|
||||
}
|
||||
}
|
||||
})
|
||||
printf = function(str_,type) {
|
||||
var deleteMap = new Vue({
|
||||
el: '#deleteMap',
|
||||
methods: {
|
||||
deleteMap: function () {
|
||||
editor_mode.onmode('');
|
||||
var index = core.floorIds.indexOf(editor.currentFloorId);
|
||||
if (index>=0) {
|
||||
core.floorIds.splice(index,1);
|
||||
editor.file.editTower([['change', "['main']['floorIds']", core.floorIds]], function (objs_) {/*console.log(objs_);*/
|
||||
if (objs_.slice(-1)[0] != null) {
|
||||
printe(objs_.slice(-1)[0]);
|
||||
throw(objs_.slice(-1)[0])
|
||||
}
|
||||
;printe('删除成功,请F5刷新编辑器生效');
|
||||
});
|
||||
}
|
||||
else printe('删除成功,请F5刷新编辑器生效');
|
||||
}
|
||||
}
|
||||
})
|
||||
printf = function (str_, type) {
|
||||
selectBox.isSelected = false;
|
||||
if(!type){
|
||||
tip.whichShow=11;
|
||||
if (!type) {
|
||||
tip.whichShow = 11;
|
||||
} else {
|
||||
tip.whichShow=12;
|
||||
tip.whichShow = 12;
|
||||
}
|
||||
setTimeout(function(){
|
||||
if(!type){
|
||||
tip.msgs[11]=String(str_);
|
||||
tip.whichShow=12;
|
||||
setTimeout(function () {
|
||||
if (!type) {
|
||||
tip.msgs[11] = String(str_);
|
||||
tip.whichShow = 12;
|
||||
} else {
|
||||
tip.msgs[10]=String(str_);
|
||||
tip.whichShow=11;
|
||||
tip.msgs[10] = String(str_);
|
||||
tip.whichShow = 11;
|
||||
}
|
||||
},1);
|
||||
}, 1);
|
||||
}
|
||||
printe = function (str_) {
|
||||
printf(str_, 'error')
|
||||
}
|
||||
printe = function(str_){printf(str_,'error')}
|
||||
tip_in_showMode = [
|
||||
'涉及图片的更改需要F5刷新浏览器来生效',
|
||||
'文本域可以通过双击,在文本编辑器或事件编辑器中编辑',
|
||||
@ -256,34 +292,34 @@ var tip = new Vue({
|
||||
},
|
||||
watch: {
|
||||
infos: {
|
||||
handler: function(val, oldval){
|
||||
handler: function (val, oldval) {
|
||||
this.isClearBlock = false;
|
||||
if(typeof(val) != 'undefined'){
|
||||
if(val==0) {
|
||||
if (typeof(val) != 'undefined') {
|
||||
if (val == 0) {
|
||||
this.isClearBlock = true;
|
||||
return;
|
||||
}
|
||||
if('id' in val){
|
||||
if ('id' in val) {
|
||||
this.hasId = true;
|
||||
}else{
|
||||
} else {
|
||||
this.hasId = false;
|
||||
}
|
||||
this.isAutotile = false;
|
||||
if(val.images == "autotile" && this.hasId) this.isAutotile = true;
|
||||
if (val.images == "autotile" && this.hasId) this.isAutotile = true;
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
|
||||
whichShow: function(){
|
||||
whichShow: function () {
|
||||
var that = this;
|
||||
that.mapMsg = '';
|
||||
that.msgs[4] = "复制失败!"+editTip.err;
|
||||
that.msgs[4] = "复制失败!" + editTip.err;
|
||||
clearTimeout(that.timer);
|
||||
if(that.whichShow){
|
||||
that.mapMsg = that.msgs[that.whichShow-1];
|
||||
that.timer = setTimeout(function() {
|
||||
if(!(that.whichShow%2))
|
||||
if (that.whichShow) {
|
||||
that.mapMsg = that.msgs[that.whichShow - 1];
|
||||
that.timer = setTimeout(function () {
|
||||
if (!(that.whichShow % 2))
|
||||
that.whichShow = 0;
|
||||
}, 5000); //5秒后自动清除success,warn不清除
|
||||
}
|
||||
@ -297,7 +333,7 @@ var selectBox = new Vue({
|
||||
isSelected: false
|
||||
},
|
||||
watch: {
|
||||
isSelected: function(){
|
||||
isSelected: function () {
|
||||
tip.isSelectedBlock = this.isSelected;
|
||||
tip.whichShow = 0;
|
||||
clearTimeout(tip.timer);
|
||||
@ -312,26 +348,26 @@ var bgSelect = new Vue({
|
||||
selectedBg: 'ground',
|
||||
imgname: ''
|
||||
},
|
||||
watch:{
|
||||
selectedBg: function(){
|
||||
watch: {
|
||||
selectedBg: function () {
|
||||
editor.bgY = this.bgs.indexOf(this.selectedBg);
|
||||
editor.drawMapBg();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
updatebg: function(){
|
||||
updatebg: function () {
|
||||
tip.whichShow = 0;
|
||||
var regx = /\S+\.(png|bmp|jpg|jpeg|gif)$/i;
|
||||
if(regx.test(this.imgname)){
|
||||
var url = 'images/'+this.imgname;
|
||||
editor.loadImg(url).then(function(img){
|
||||
if (regx.test(this.imgname)) {
|
||||
var url = 'images/' + this.imgname;
|
||||
editor.loadImg(url).then(function (img) {
|
||||
editor.drawMapBg(img);
|
||||
tip.whichShow = 10;
|
||||
}).catch(function(err){
|
||||
}).catch(function (err) {
|
||||
console.log(err);
|
||||
tip.whichShow = 9;
|
||||
});
|
||||
}else{
|
||||
} else {
|
||||
tip.whichShow = 9;
|
||||
}
|
||||
}
|
||||
|
||||
170
editor.html
170
editor.html
@ -1,15 +1,15 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<head>
|
||||
<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>
|
||||
</head>
|
||||
<body>
|
||||
<div class="main">
|
||||
<div class="main">
|
||||
<div id="left" style="z-index:-1;opacity: 0;"><!-- map -->
|
||||
<div id="arrEditor">
|
||||
<table class="col" id='arrColMark'></table>
|
||||
@ -18,15 +18,15 @@
|
||||
<textarea cols="10" rows="10" id="pout" v-model="mapArr"></textarea>
|
||||
<p class="warnText" v-if="error">{{ errors[error-1] }}</p>
|
||||
</div>
|
||||
<div id="editTip" v-cloak>
|
||||
<br>
|
||||
<input type="button" value="新建空白地图" id='saveFloorAs'/>
|
||||
<input id='saveAsName' placeholder="输入新楼层id"/>
|
||||
<input class='btn' type="button" value="复制地图" v-on:click="copyMap"/>
|
||||
<div id="editTip">
|
||||
<input type="button" value="新建空白地图" id='newMap'/>
|
||||
<input id='newFileName' placeholder="输入新楼层id"/>
|
||||
</div>
|
||||
<div style="position: absolute;right: 10px;bottom:70px;">
|
||||
<input class='btn' id='clear' type="button" value="清除地图" v-on:click="clearMap"/>
|
||||
<input class='btn' type="button" value="导出地图" id="exportM" v-on:click="exportMap"/>
|
||||
<div style="position: absolute;left: 10px;bottom:0; margin-bottom: 90px">
|
||||
<input type="button" value="导出地图" id="exportMap" v-on:click="exportMap"/>
|
||||
<input type="button" value="复制地图" id="copyMap" v-on:click="copyMap"/>
|
||||
<input type="button" value="清除地图" id='clearMap' v-on:click="clearMap"/>
|
||||
<input type="button" value="删除地图" id="deleteMap" v-on:click="deleteMap"/>
|
||||
</div>
|
||||
</div>
|
||||
<div id="objDataEditor">
|
||||
@ -42,7 +42,8 @@
|
||||
<div class="leftTabContent">
|
||||
<p>
|
||||
<input id="selectFileBtn" type="button" value="导入文件到画板"/>
|
||||
<select id="selectAppend"></select><!-- ["terrains", "animates", "enemys", "enemy48", "items", "npcs", "npc48"] -->
|
||||
<select id="selectAppend"></select>
|
||||
<!-- ["terrains", "animates", "enemys", "enemy48", "items", "npcs", "npc48"] -->
|
||||
<input id="appendConfirm" type="button" value="追加"/>
|
||||
</p>
|
||||
<div id="appendPicCanvas" style="position:relative;overflow: auto;height:470px;">
|
||||
@ -57,21 +58,29 @@
|
||||
<div class="appendSelection"><span style="top: 12px; left: 14px;">4</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="left2" class='leftTab' style="z-index:-1;opacity: 0;"><!-- loc -->
|
||||
<h3 class="leftTabHeader">地图选点 <button onclick="editor.mode.onmode('save')">save</button></h3>
|
||||
<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'>
|
||||
<tr><td>条目</td><td>注释</td><td>值</td></tr>
|
||||
<tr>
|
||||
<td>条目</td>
|
||||
<td>注释</td>
|
||||
<td>值</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="left3" class='leftTab' style="z-index:-1;opacity: 0;"><!-- emenyitem -->
|
||||
<h3 class="leftTabHeader">图块属性 <button onclick="editor.mode.onmode('save')">save</button></h3>
|
||||
<h3 class="leftTabHeader">图块属性 <button onclick="editor.mode.onmode('save')">save</button>
|
||||
</h3>
|
||||
<div class="leftTabContent">
|
||||
<div id='newIdIdnum'><!-- id and idnum -->
|
||||
<input placeholder="输入新id(唯一标识符)"/>
|
||||
@ -82,35 +91,53 @@
|
||||
<div class='etable'>
|
||||
<table>
|
||||
<tbody id='table_a3f03d4c_55b8_4ef6_b362_b345783acd72'>
|
||||
<tr><td>条目</td><td>注释</td><td>值</td></tr>
|
||||
<tr>
|
||||
<td>条目</td>
|
||||
<td>注释</td>
|
||||
<td>值</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="left4" class='leftTab' style="z-index:-1;opacity: 0;"><!-- floor -->
|
||||
<h3 class="leftTabHeader">楼层属性 <button onclick="editor.mode.onmode('save')">save</button></h3>
|
||||
<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'>
|
||||
<tr><td>条目</td><td>注释</td><td>值</td></tr>
|
||||
<tr>
|
||||
<td>条目</td>
|
||||
<td>注释</td>
|
||||
<td>值</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="left5" class='leftTab' style="z-index:-1;opacity: 0;"><!-- tower -->
|
||||
<h3 class="leftTabHeader">全塔属性 <button onclick="editor.mode.onmode('save')">save</button></h3>
|
||||
<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'>
|
||||
<tr><td>条目</td><td>注释</td><td>值</td></tr>
|
||||
<tr>
|
||||
<td>条目</td>
|
||||
<td>注释</td>
|
||||
<td>值</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div></div>
|
||||
<div id="left6" class='leftTab' style="z-index:-1;opacity: 0;"><div style="position: relative; height: 95%"><!-- eventsEditor -->
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
@ -135,28 +162,38 @@
|
||||
</xml>
|
||||
</h3>
|
||||
<div style="position: relative;height: 100%">
|
||||
<div id="blocklyArea"><div id="blocklyDiv"></div></div>
|
||||
<div id="blocklyArea">
|
||||
<div id="blocklyDiv"></div>
|
||||
</div>
|
||||
<textarea id="codeArea" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="left7" style="z-index:-1;opacity: 0;"><!-- 多行文本编辑器 -->
|
||||
<button onclick="editor_multi.confirm()">confirm</button>
|
||||
<button onclick="editor_multi.cancel()">cancel</button>
|
||||
<input type="checkbox" onclick="editor_multi.toggerLint()" id="lintCheckbox" style="vertical-align: bottom;margin-left:6px" />
|
||||
<input type="checkbox" onclick="editor_multi.toggerLint()" id="lintCheckbox"
|
||||
style="vertical-align: bottom;margin-left:6px"/>
|
||||
<span style="vertical-align: bottom; margin-left: -3px">Lint</span>
|
||||
<textarea id="multiLineCode" name="multiLineCode"></textarea>
|
||||
</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>
|
||||
<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'>
|
||||
<tr><td>条目</td><td>注释</td><td>值</td></tr>
|
||||
<tr>
|
||||
<td>条目</td>
|
||||
<td>注释</td>
|
||||
<td>值</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="mid">
|
||||
<table class="col" id='mapColMark'></table>
|
||||
<table class="row" id='mapRowMark'></table>
|
||||
@ -167,14 +204,15 @@
|
||||
<canvas class='egameCanvas' id='eui' width='416' height='416' style='z-index:100'></canvas>
|
||||
</div>
|
||||
<div class="tools">
|
||||
<div id="tip" v-cloak >
|
||||
<div v-if="isSelectedBlock" >
|
||||
<div id="tip" v-cloak>
|
||||
<div v-if="isSelectedBlock">
|
||||
<p v-if="isClearBlock" class="infoText">当前选择为清除块,可擦除地图上块</p>
|
||||
<div v-else>
|
||||
<p v-if="hasId">图块编号:<span class="infoText">{{ infos['idnum'] }}</span></p>
|
||||
<p v-if="hasId">图块ID:<span class="infoText">{{ infos['id'] }}</span></p>
|
||||
<p v-else class="warnText">该图块无对应的数字或ID存在,请先前往icons.js和maps.js中进行定义!</p>
|
||||
<p>图块所在素材:<span class="infoText">{{ infos['images'] + (isAutotile ? '( '+infos['id']+' )' : '') }}</span></p>
|
||||
<p>图块所在素材:<span class="infoText">{{ infos['images'] + (isAutotile ? '( '+infos['id']+' )' : '') }}</span>
|
||||
</p>
|
||||
<p>图块索引:<span class="infoText">{{ infos['y'] }}</span></p>
|
||||
</div>
|
||||
</div>
|
||||
@ -221,9 +259,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <script>/* -->
|
||||
<div id='gameGroup' style='display:none'>
|
||||
</div>
|
||||
<!-- <script>/* -->
|
||||
<div id='gameGroup' style='display:none'>
|
||||
<p id='mainTips'>请稍后...</p>
|
||||
<div id='startPanel'>
|
||||
<div id='startTop'>
|
||||
@ -320,26 +358,26 @@
|
||||
<canvas class='gameCanvas' id='weather' width='416' height='416'></canvas>
|
||||
<canvas class='gameCanvas' id='ui' width='416' height='416'></canvas>
|
||||
<canvas class='gameCanvas' id='data' width='416' height='416'>此浏览器不支持HTML5</canvas>
|
||||
</div>
|
||||
<!-- */</script> -->
|
||||
</div>
|
||||
<!-- */</script> -->
|
||||
<script>
|
||||
// 生成定位编号
|
||||
(function(){
|
||||
// 生成定位编号
|
||||
(function () {
|
||||
var colNum = ' ';
|
||||
for(var i=0; i<13; i++){
|
||||
var tpl = '<td>'+i+'<div class="colBlock" style="left:'+(i*32+1)+'px;"></div></td>';
|
||||
for (var i = 0; i < 13; i++) {
|
||||
var tpl = '<td>' + i + '<div class="colBlock" style="left:' + (i * 32 + 1) + 'px;"></div></td>';
|
||||
colNum += tpl;
|
||||
}
|
||||
arrColMark.innerHTML = '<tr>'+colNum+'</tr>';
|
||||
mapColMark.innerHTML = '<tr>'+colNum+'</tr>';
|
||||
arrColMark.innerHTML = '<tr>' + colNum + '</tr>';
|
||||
mapColMark.innerHTML = '<tr>' + colNum + '</tr>';
|
||||
var rowNum = ' ';
|
||||
for(var i=0; i<13; i++){
|
||||
var tpl = '<tr><td>'+i+'<div class="rowBlock" style="top:'+(i*32+1)+'px;"></div></td></tr>';
|
||||
for (var i = 0; i < 13; i++) {
|
||||
var tpl = '<tr><td>' + i + '<div class="rowBlock" style="top:' + (i * 32 + 1) + 'px;"></div></td></tr>';
|
||||
rowNum += tpl;
|
||||
}
|
||||
arrRowMark.innerHTML = rowNum;
|
||||
mapRowMark.innerHTML = rowNum;
|
||||
})();
|
||||
})();
|
||||
</script>
|
||||
|
||||
<!-- =========================================================== -->
|
||||
@ -353,38 +391,38 @@
|
||||
<script src='_server/vm.js'></script>
|
||||
<script id='mainScript' src='main.js'></script>
|
||||
<script>
|
||||
//所有全局量
|
||||
__all__=['Vue','fs','editor_file','editor_mode','main','core','hasOwnProp','printf','printe','editor','converter','ActionParser','MotaActionFunctions','MotaActionBlocks'];
|
||||
__id__=['editArea','arrRowMark','mapRowMark','data','bg','dataSelection','blocklyDiv','codeAreaHL','entryType'];
|
||||
__Vue__=['exportM','editArea','editTip','clear','tip','selectBox'];
|
||||
//var event = document.getElementById('event');
|
||||
//所有全局量
|
||||
__all__ = ['Vue', 'fs', 'editor_file', 'editor_mode', 'main', 'core', 'hasOwnProp', 'printf', 'printe', 'editor', 'converter', 'ActionParser', 'MotaActionFunctions', 'MotaActionBlocks'];
|
||||
__id__ = ['editArea', 'arrRowMark', 'mapRowMark', 'data', 'bg', 'dataSelection', 'blocklyDiv', 'codeAreaHL', 'entryType'];
|
||||
__Vue__ = ['editArea', 'exportMap', 'copyMap', 'clearMap', 'deleteMap', 'tip', 'selectBox'];
|
||||
//var event = document.getElementById('event');
|
||||
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
function hasOwnProp (obj, key) {
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
function hasOwnProp(obj, key) {
|
||||
return hasOwnProperty.call(obj, key)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script src='_server/editor.js'></script>
|
||||
<script>
|
||||
main.init('editor', function() {
|
||||
editor.init(function(){
|
||||
editor.pos={x: 0, y: 0};
|
||||
main.init('editor', function () {
|
||||
editor.init(function () {
|
||||
editor.pos = {x: 0, y: 0};
|
||||
editor.mode.loc();
|
||||
editor.info=editor.ids[editor.indexs[201]];
|
||||
editor.info = editor.ids[editor.indexs[201]];
|
||||
editor.mode.emenyitem();
|
||||
editor.mode.floor();
|
||||
editor.mode.tower();
|
||||
editor.mode.functions();
|
||||
editor.mode.showMode('floor');
|
||||
editor.mode.listen();
|
||||
editor_multi=editor_multi();
|
||||
editor_blockly=editor_blockly();
|
||||
editor_multi = editor_multi();
|
||||
editor_blockly = editor_blockly();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
//main.listen();
|
||||
//main.listen();
|
||||
</script>
|
||||
|
||||
<!-- hightlight textarea -->
|
||||
|
||||
@ -301,7 +301,7 @@ utils.prototype.readFile = function (success, error, readType) {
|
||||
|
||||
if (core.platform.fileInput==null) {
|
||||
core.platform.fileInput = document.createElement("input");
|
||||
core.platform.fileInput.style.display = 'none';
|
||||
core.platform.fileInput.style.opacity = 0;
|
||||
core.platform.fileInput.type = 'file';
|
||||
core.platform.fileInput.onchange = function () {
|
||||
var files = core.platform.fileInput.files;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user