Skip to content

Commit e1f8164

Browse files
committed
更新:程式碼區塊
1. 增加了可直接編寫程式碼的區塊 2. 增加了兩種程式範本 3. 主標題改名以對應新增功能
1 parent 6cd99f7 commit e1f8164

File tree

4 files changed

+261
-115
lines changed

4 files changed

+261
-115
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ This website allows you to create simple RPG Maker MV/MZ plugins through its int
44

55
目前缺少的功能:
66

7-
1. 在半途插入程式片段、
8-
2. 覆寫既有函數
9-
3. 預設範例插件
7+
1. 預設範例插件
8+
2. 調整區塊順序

index.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,12 @@
275275
gap: 4px;
276276
}
277277

278+
.tips {
279+
font-size: small;
280+
color: #0005;
281+
display: block;
282+
}
283+
278284
@media (max-width: 1400px) {
279285
#build_result_button {
280286
left: calc(85% + 5px);
@@ -371,6 +377,7 @@
371377
</style>
372378
<!-- css -->
373379
<!-- js -->
380+
<script src="./src/editorConfig.js"></script>
374381
<script src="./src/index.js"></script>
375382
<!-- js -->
376383
</head>
@@ -479,12 +486,13 @@
479486
</div>
480487
<div id="root_command" class="root">
481488
<div class="root_title" onclick="onRootTitleClick('comn')">
482-
<span class="title">Event Command</span>
489+
<span class="title">Program</span>
483490
</div>
484491

485492
<div class="command block root_operation">
486-
<button type="button" onclick="CommandControl.onRootAddClick()">Add</button>
487-
<button type="button" onclick="CommandControl.onRootDelClick()">Del All</button>
493+
<button type="button" onclick="CommandControl.onRootAddClick()">Add_Command</button>
494+
<button type="button" onclick="CommandControl.onRootAddCodeClick()">Add_Code</button>
495+
<button type="button" onclick="CommandControl.onRootDelClick()">Del_All</button>
488496
</div>
489497

490498
</div>
@@ -494,7 +502,7 @@
494502
</div>
495503
<!-- plugin display -->
496504
<div id="display_plugin" class="block" style="display: block;">
497-
<span style="font-size: small; color: #0005; display: block;">
505+
<span class="tips">
498506
請注意,如果你在此編輯器內修改了任何內容,再次建立插件時將被覆蓋
499507
</span>
500508
<button type="button" id="copy_result_button" onclick="Builder.setCopyToClipBoard()">複製到剪貼簿</button>

src/editorConfig.js

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
2+
// 定義
3+
4+
// TS 語言驗證
5+
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
6+
noSemanticValidation: true,
7+
noSyntaxValidation: false,
8+
});
9+
10+
// TS 編譯設定
11+
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
12+
target: monaco.languages.typescript.ScriptTarget.ES2015,
13+
allowNonTsExtensions: true,
14+
});
15+
16+
const libSource = `
17+
/** 檔案名稱 */
18+
const FILENAME: ?string
19+
/** 插件參數 */
20+
const PARAMETERS: { [name: string]: ?string }
21+
22+
/** [原始數據]於資料庫定義,來自 Actors.json 的可操控角色資料 */
23+
var $dataActors: DataActors
24+
/** [原始數據]於資料庫定義,來自 Classes.json 的職業資料 */
25+
var $dataClasses: DataClasses
26+
/** [原始數據]於資料庫定義,來自 Skills.json 的技能資料 */
27+
var $dataSkills: DataSkills
28+
/** [原始數據]於資料庫定義,來自 Items.json 的道具資料 */
29+
var $dataItems: DataItems
30+
/** [原始數據]於資料庫定義,來自 Weapons.json 的武器資料 */
31+
var $dataWeapons: DataWeapons
32+
/** [原始數據]於資料庫定義,來自 Armors.json 的裝備資料 */
33+
var $dataArmors: DataArmors
34+
/** [原始數據]於資料庫定義,來自 Enemies.json 的敵人資料 */
35+
var $dataEnemies: DataEnemies
36+
/** [原始數據]於資料庫定義,來自 Troops.json 的敵人隊伍資料 */
37+
var $dataTroops: DataTroops
38+
/** [原始數據]於資料庫定義,來自 States.json 的狀態資料 */
39+
var $dataStates: DataStates
40+
/** [原始數據]於資料庫定義,來自 Animations.json 的動畫資料 */
41+
var $dataAnimations: DataAnimations
42+
/** [原始數據]於資料庫定義,來自 Tilesets.json 的地圖圖塊資料 */
43+
var $dataTilesets: DataTilesets
44+
/** [原始數據]於資料庫定義,來自 CommonEvents.json 的公共事件資料 */
45+
var $dataCommonEvents: DataCommonEvents
46+
/** [原始數據]於資料庫定義,來自 System.json 的系統資料 */
47+
var $dataSystem: DataSystem
48+
/** [原始數據]於資料庫定義,來自 MapInfos.json 的地圖資料 */
49+
var $dataMapInfos: DataMapInfos
50+
51+
/** [運行映射]遊戲運行中權宜放置的暫存資料 */
52+
var $gameTemp: Game_Temp
53+
/** [運行映射]遊戲系統 */
54+
var $gameSystem: Game_System
55+
/** [運行映射]遊戲畫面管理 */
56+
var $gameScreen: Game_Screen
57+
/** [運行映射]計時器 */
58+
var $gameTimer: Game_Timer
59+
/** [運行映射]文本視窗 */
60+
var $gameMessage: Game_Message
61+
/** [運行映射]遊戲開關 */
62+
var $gameSwitches: Game_Switches
63+
/** [運行映射]遊戲變數 */
64+
var $gameVariables: Game_Variables
65+
/** [運行映射]事件自開關 */
66+
var $gameSelfSwitches: Game_SelfSwitches
67+
/** [運行映射] */
68+
var $gameActors: Game_Actors
69+
/** [運行映射]玩家操控隊伍 */
70+
var $gameParty: Game_Party
71+
/** [運行映射]戰鬥中的敵人隊伍 */
72+
var $gameTroop: Game_Troop
73+
/** [運行映射]目前遊戲地圖 */
74+
var $gameMap: Game_Map
75+
/** [運行映射]玩家操控角色 */
76+
var $gamePlayer: Game_Player
77+
78+
/** [原始數據]若為戰鬥或事件測試時執行的測試事件 */
79+
var $testEvent: DataEvent
80+
`
81+
monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource, "ts:lib/rpgmaker_source.d.ts")
82+
monaco.editor.createModel(libSource, "typescript", monaco.Uri.parse("ts:lib/rpgmaker_source.d.ts"))
83+
84+
// 範本
85+
/**
86+
* @param {*} range
87+
* @returns {{label: string, kind: *, documentation: string, insertText: string, insertTextRules: ?*, range: *}[]}
88+
*/
89+
const createDependencyProposals = range => [
90+
{
91+
label: "!overwrite",
92+
kind: monaco.languages.CompletionItemKind.Snippet,
93+
documentation: "覆寫已有函數",
94+
insertText: "const ${1:originMethod} = ${2:Target_Class.prototype.methodName}\n" +
95+
"${2:Target_Class.prototype.methodName} = function (){\n" +
96+
" return ${1:originMethod}.apply(this, arguments)\n" +
97+
"}\n",
98+
insertTextRules:
99+
monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
100+
range,
101+
},
102+
{
103+
label: "!command",
104+
kind: monaco.languages.CompletionItemKind.Snippet,
105+
documentation: "設定插件指令",
106+
insertText: 'PluginManager.registerCommand(FILENAME, "${1:commandName}", function ({ ${2:parameters} }) {\n' +
107+
"\n" +
108+
"})\n",
109+
insertTextRules:
110+
monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
111+
range,
112+
}
113+
]
114+
115+
116+
monaco.languages.registerCompletionItemProvider("javascript", {
117+
triggerCharacters: ["!"],
118+
provideCompletionItems: (model, position) => {
119+
const word = model.getWordUntilPosition(position)
120+
const range = {
121+
startLineNumber: position.lineNumber,
122+
endLineNumber: position.lineNumber,
123+
startColumn: Math.min(0, word.startColumn - 1),
124+
endColumn: word.endColumn,
125+
}
126+
127+
return {
128+
suggestions: createDependencyProposals(range),
129+
}
130+
},
131+
})

0 commit comments

Comments
 (0)