Skip to content

Commit a70b601

Browse files
committed
Reogranized project structure and added some more documentation
1 parent e7a84c2 commit a70b601

22 files changed

Lines changed: 277 additions & 251 deletions

.idea/workspace.xml

Lines changed: 83 additions & 79 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/debugger.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var tests = {
99
"test-7":"tests/extended.xml",
1010
"test-8":"tests/bilibili.xml",
1111
"test-9":"tests/utsukushiki_mono.xml",
12-
"test-s":"tests/kanpai.xml",
12+
"test-s":"tests/scripting/kanpai.xml",
1313
"test-ac-1":{"f":'tests/ACFun.json',"p":"acfun"},
1414
"test-ac-2":{"f":'tests/ac940133.json',"p":"acfun"},
1515
"test-ts-1":"tests/invalid/no_closing.xml",

demo/index.htm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ <h3>AcFun (Experimental)</h3>
6868
<a id="profiler-start" href="javascript:;">Profiler</a><br>
6969
<a onclick="cm.filter.setRuntimeFilter(null);" href="javascript:;">Clear Runtime Filters</a>
7070
</p>
71+
<p>Scripting: <br>
72+
<a href="scripting">Scripting Sandbox test</a> <br>
73+
<a href="scripting/ccl.htm">CCL /w Scripting Enabled(Beta)</a>
74+
</p>
7175
<p>APIs: <br>
7276
<a id="fs-all" href="javascript:;">Fullscreen</a> <br>
7377
<a id="fs-win" href="javascript:;">Windowed Fullscreen</a>
@@ -76,11 +80,7 @@ <h3>AcFun (Experimental)</h3>
7680
<a id="video-demo" href="javascript:;">Demo with video</a> <br>
7781
<a id="load-cmt-file" href="javascript:;">Load Custom URL</a> <br>
7882
<a href="../experimental/animation">CSS3 Transition Library</a> <br>
79-
<a href="transition-library-test.htm">CCL /w Transition Library (Alpha)</a>
8083
</p>
81-
<p>Scripting: <br>
82-
<a href="../experimental/scripting">Scripting Sandbox test</a> <br>
83-
<a href="../experimental/scripting/ccl.htm">CCL /w Scripting (Alpha)</a> </p>
8484
</div>
8585

8686
<div id="player-unit">
Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,52 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta http-equiv="X-UA-Compatible" value="IE=9">
6-
<title>CCL-Compat BScript Test</title>
6+
<title>CommentCoreLibrary - Bilibili Compatible Scripting Playground</title>
77
<style>
88
#codediv{width:48%; position:absolute; left:10px;}
99
#playerdiv{width:48%; float:right; position:absolute; right:10px;}
10-
#output{font-family:Consolas, 'Courier New', monospace; font-size:12px;padding:10px; background:#000;
11-
position:fixed; bottom:0; left:0; right:0; height:150px; overflow:auto; color:#ccc;border-top:1px dotted #fff;}
10+
#output{
11+
font-family:Consolas, 'Courier New', monospace; font-size:12px;padding:10px; background:#000;
12+
position:fixed; bottom:0; left:0; right:0; height:150px; overflow:auto; color:#ccc;border-top:1px dotted #fff;
13+
}
1214
#player{border:1px solid #f88; width:100%;background-color:#100;position:relative;}
13-
#code-input{width:100%;height:340px;display:block; border:1px solid #f88; padding:10px;background:#000;color:#f88;font-size:20px;}
14-
.s-button, .button{display:block; border:1px solid #f88; padding:8px 6px 8px 6px; background:#000; color:#f88; float:left;-moz-user-select: none; -khtml-user-select: none; -webkit-user-select: none; -o-user-select: none; user-select: none; cursor:default;}
15+
#code-input{
16+
width:100%;height:340px;display:block; border:1px solid #f88;
17+
padding:10px;background:#000;color:#f88;font-size:20px;
18+
}
19+
.s-button, .button{
20+
display:block; border:1px solid #f88; padding:8px 6px 8px 6px;
21+
background:#000; color:#f88; float:left;
22+
-moz-user-select: none;
23+
-khtml-user-select: none;
24+
-webkit-user-select: none;
25+
-o-user-select: none;
26+
user-select: none;
27+
cursor:default;
28+
}
1529
.s-button:hover,.button:hover{background:#f88; color:#000;}
1630
.button{font-size:12px;z-index:99;}
31+
1732
pre{margin:0;}
1833
pre.error{color:#f00;}
1934
pre.warning{color:#FFC500;}
2035
</style>
36+
<link rel="stylesheet" href="../../build/style.css" />
2137
<script type="text/javascript">var $ = function(e){return window.document.getElementById(e);}</script>
2238
<script src="../../src/scripting/build/Host.js" type="text/javascript"></script>
2339
</head>
2440
<body style="background:#000;">
2541
<h2 style="color:#fff">CCL Scripting Demo</h2>
2642
<div id="codediv">
2743
<div style="clear:both;overflow:auto;width:110%;">
28-
<button class="s-button" id="evaluate">Execute (Sandbox)</button><button class="s-button" id="debug-basic">Debug Basic</button><button class="s-button" id="debug-svg">Debug SVGDraw GreenDam</button><button class="s-button" id="debug-svg-madoka">Debug Madoka</button><button class="s-button" id="debug-3dsphere">Debug 3D</button><button class="s-button" id="debug-clear">Clear.Runtime</button>
44+
<button class="s-button" id="evaluate">Execute</button><button class="s-button" id="debug-basic">Debug Basic</button><button class="s-button" id="debug-svg">Debug SVG</button><button class="s-button" id="debug-svg-madoka">Debug Madoka</button><button class="s-button" id="debug-3dsphere">Debug 3D</button><button class="s-button" id="debug-custom">Load Custom</button><button class="s-button" id="debug-clear">Clear</button>
2945
</div>
3046
<textarea id="code-input"></textarea>
3147
</div>
3248
<div id="playerdiv">
3349
<div id="player" style="height:400px;clear:both;overflow:hidden;"></div>
3450
</div>
35-
<div id="output">[Msg] 有关具体API信息请阅读 docs/scripting</div>
51+
<div id="output">[Msg] 有关具体API信息请阅读 docs/scripting<br>[Msg] Supported Custom Tests: 3dterrain.biliscript</div>
3652
<script type="text/javascript">
3753
bscripter = new CCLScripting("../../src/scripting/build/Worker.js");
3854
bscripter.logger = new function(){
@@ -57,24 +73,32 @@ <h2 style="color:#fff">CCL Scripting Demo</h2>
5773
function fetchFile(filename){
5874
var xhr = new XMLHttpRequest();
5975
xhr.onreadystatechange = function(){
60-
if(xhr.readyState == 4 && xhr.status== 200){
76+
if(xhr.readyState === 4 && xhr.status== 200){
6177
$("code-input").value = xhr.responseText;
78+
}else if(xhr.readyState === 4){
79+
bscripter.logger.warn("Load file failed. Server responded with status code " + xhr.status + ".");
6280
}
6381
};
6482
xhr.open("GET", filename, true);
6583
xhr.send();
6684
}
6785
$("debug-basic").addEventListener("click", function(){
68-
fetchFile("manzoku.biliscript");
86+
fetchFile("../../tests/scripting/manzoku.biliscript");
6987
});
7088
$("debug-svg-madoka").addEventListener("click", function(){
71-
fetchFile("madoka.biliscript");
89+
fetchFile("../../tests/scripting/madoka.biliscript");
7290
});
7391
$("debug-svg").addEventListener("click", function(){
74-
fetchFile("greendam.biliscript");
92+
fetchFile("../../tests/scripting/greendam.biliscript");
7593
});
7694
$("debug-3dsphere").addEventListener("click", function(){
77-
fetchFile("3dsphere.biliscript");
95+
fetchFile("../../tests/scripting/3dsphere.biliscript");
96+
});
97+
$("debug-custom").addEventListener("click", function(){
98+
var file = prompt("Please input test file name:");
99+
if(file !== null && file !== ""){
100+
fetchFile("../../tests/scripting/" + file);
101+
}
78102
});
79103
$("debug-clear").addEventListener("click", function(){
80104
//bscripter.clear();

demo/transition-library-test.htm

Lines changed: 0 additions & 119 deletions
This file was deleted.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Errors and Warnings 错误和警告
1+
错误和警告 (Errors and Warnings
22
============================================
33
We try to replicate as much functionality as we can, but sometimes it is just
44
very hard to do. In such cases we will usually silently drop the functionality
@@ -9,7 +9,7 @@ raise an error or fatal error. These cases are very rare.
99
抛弃一个方法实现,并输出一个警告。有时一个函数关乎运行的正确性时,我们才会抛出一个错误或者一个致命性
1010
错误。
1111

12-
Fatal Errors 致命性错误
12+
致命性错误 (Fatal Errors
1313
--------------------------------------------
1414

1515
### Syntax Error 语法错误
@@ -24,7 +24,7 @@ Fatal Errors 致命性错误
2424
### Security Error 安全冲突
2525
试图调用被禁止的函数或者没有提供正确的Key。
2626

27-
Errors 错误
27+
错误 (Errors)
2828
---------------------------------------------
2929
在 CCL 引擎中,有两种引发普通错误的可能性。一种是引发了内部普通错误,另一种是引发了`new Error()`
3030
引发内部普通错误时,你的代码不会获知错误,这种情况的错误主要是由于我们API还原上的互换性问题。在这个
@@ -35,7 +35,7 @@ Errors 错误
3535
一个致命性错误进而阻止之后代码的运行。
3636

3737

38-
Warnings 警告
38+
警告 (Warnings)
3939
----------------------------------------------
4040
警告包括如下三种:
4141

@@ -52,7 +52,7 @@ Unsupported Warning是CCLScripter产生的非关键性的“未实现”警告
5252
非法操作警告多出现于试图写入只读属性,或是试图调用非法函数,调用方法不正确等的警告。一般说明某个操作
5353
无效,但是不会影响执行。
5454

55-
Log 日志
55+
日志 (Log)
5656
----------------------------------------------
5757
日志可以通过 `trace()` 产生。有时内部函数也会 trace 自己,不过这种情况很少。用户可以关闭日志和
5858
警告的产生,但是不能关闭错误。
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Abstractions 抽象化对应关系
2+
===============================
3+
KagerouEngine的虚拟实例大多数都需要有DOM内对应的实际实例,这些实例会根据不同的Host而不同,不过
4+
我们的默认库也包括了一些我们对这些抽象化设计的理解。以下内容仅供脚本作者参考,并非所有未来的CCL脚本
5+
引擎都会采取同样的抽象化。
6+
7+
以下的各个对象根据其在类列表里的地位排序。越是底层的类越靠前
8+
9+
DisplayObject = DOMElement
10+
-------------------------------
11+
DisplayObject是一个基础的显示控件,它是最最基础的控件,拥有可以布局排版,并且实行整块变幻的属性。
12+
它也提供了为所有其它视觉元素支撑的 EventDispatcher 模板。所以说大部分由DisplayObject派生的类
13+
都有一个支撑的 DOM 元素。
14+
15+
Sprite&larr;DisplayObject = DIV + CANVAS
16+
-------------------------------
17+
Sprite是一个比较罕见的控件,它提供了一个基础迅速的绘图空间,同时也是一个其他对象的载体。所以
18+
Sprite本质上是一个 div。但是 div 控件却无法支持绘图,所以在其上我们提供了一套简单的高速绘图空间,
19+
即 canvas。
20+
21+
TextField&larr;DisplayObject = DIV + (SPAN)
22+
-------------------------------
23+
TextField本是文字框,但是在这里常用于显示文字。可以提供基础的格式选择,很是类似一个div元素。当然
24+
了,在对TextFormat进行操作后,div内可能会产生诸多span来保证不同的文字格式。
25+
26+
Shape&larr;DisplayObject = SVG
27+
-------------------------------
28+
Shape是一个图形元件,提供了很多绘图函数和多种复杂的绘图工具,由于Canvas无法满足诸多滤镜等需求,
29+
Shape的后端是一个 SVG 图像。SVG在目前的条件下兼容性相对很好,不过缺点也明显。在绘制时,由于是在
30+
操作DOM元素,所以会执行大量的DOM操作,产生很多DOM元素。在Shape下实现动画效果,性能会打折扣的。
31+
32+
Bitmap&larr;DisplayObject = CANVAS
33+
-------------------------------
34+
Bitmap是一个位点图,允许在其上进行很多像素级别的操作,这非常适合同样支持像素级操作的canvas元素。
35+
36+
潜在意义
37+
===============================
38+
由于 `addChild``removeChild` 方法会由各个影子对象实现,对于许多,如 Bitmap和Shape等
39+
抽象化,我们无法真正的去添加子对象。目前版本会静默放弃,所以建议先创建一个嵌套对象,如 Sprite 等
40+
去包裹两个对象。
41+

0 commit comments

Comments
 (0)