From 395c9da4294e7ac28766d62cf9c8069e33a9ffd8 Mon Sep 17 00:00:00 2001 From: LXZ_svn_sync Date: Mon, 9 Mar 2020 10:07:00 +0800 Subject: [PATCH] svn_sync --- .../Areas/ChatSystem/CommandHelpPage.html | 2 +- .../Game/Areas/ChatSystem/CommandHelpPage.lua | 61 ++++++++++++++++++- .../Creator/Game/Code/CodeBlockWindow.lua | 2 +- .../CodeBlocklyDef/CodeBlocklyDef_Motion.lua | 1 + .../CodeBlocklyDef/ParacraftCodeBlockly.lua | 6 +- .../Aries/Creator/Game/Code/CodeGlobals.lua | 7 ++- .../Aries/Creator/Game/Code/NplCad/NplCad.lua | 8 ++- .../Game/Code/NplMicrobit/NplMicrobit.lua | 6 +- .../Creator/Game/GUI/OpenAssetFileDialog.lua | 10 ++- .../Creator/Game/Login/LocalLoadWorld.lua | 3 +- .../Game/Movie/MovieClipController.html | 2 +- 11 files changed, 93 insertions(+), 15 deletions(-) diff --git a/script/apps/Aries/Creator/Game/Areas/ChatSystem/CommandHelpPage.html b/script/apps/Aries/Creator/Game/Areas/ChatSystem/CommandHelpPage.html index 72ddd981..2c151e38 100644 --- a/script/apps/Aries/Creator/Game/Areas/ChatSystem/CommandHelpPage.html +++ b/script/apps/Aries/Creator/Game/Areas/ChatSystem/CommandHelpPage.html @@ -146,7 +146,7 @@
<%=L"命令格式"%>
- +
diff --git a/script/apps/Aries/Creator/Game/Areas/ChatSystem/CommandHelpPage.lua b/script/apps/Aries/Creator/Game/Areas/ChatSystem/CommandHelpPage.lua index c3effe0f..31aadab9 100644 --- a/script/apps/Aries/Creator/Game/Areas/ChatSystem/CommandHelpPage.lua +++ b/script/apps/Aries/Creator/Game/Areas/ChatSystem/CommandHelpPage.lua @@ -381,4 +381,63 @@ function CommandHelpPage.OnKeyUp_RETURN(callback) callback(); end end -end \ No newline at end of file +end + +-- @return textcontrol, multilineEditBox control. +function CommandHelpPage.GetTextControl() + if(page) then + local textAreaCtrl = page:FindControl("code"); + local textCtrl = textAreaCtrl and textAreaCtrl.ctrlEditbox; + if(textCtrl) then + return textCtrl:ViewPort(), textCtrl; + end + end +end + +function CommandHelpPage.OnRightClick() + local ctrl = CommandHelpPage.GetTextControl() + if(ctrl) then + local info = ctrl:getMouseOverWordInfo() + if(info and info.word) then + CommandHelpPage.ShowContextMenuForWord(info.word, info.lineText, info.fromPos, info.toPos) + end + end +end + +function CommandHelpPage.ShowContextMenuForWord(word, line, from, to) + if(not word) then + return + end + local ctl = CommandHelpPage.contextMenuCtrl; + if(not ctl)then + ctl = CommonCtrl.ContextMenu:new{ + name = "CodeIntelliSense.contextMenuCtrl", + width = 230, + height = 60, -- add menuitemHeight(30) with each new item + DefaultNodeHeight = 26, + onclick = CommandHelpPage.OnClickContextMenuItem, + }; + CommandHelpPage.contextMenuCtrl = ctl; + ctl.RootNode:AddChild(CommonCtrl.TreeNode:new{Text = "", Name = "root_node", Type = "Group", NodeHeight = 0 }); + end + + local node = ctl.RootNode:GetChild(1); + if(node) then + node:ClearAllChildren(); + node:AddChild(CommonCtrl.TreeNode:new({Text = format(L"朗读: %s", word), tag = word, Name = "PronounceIt", Type = "Menuitem", onclick = nil, })) + if(word:match("^%w+$")) then + node:AddChild(CommonCtrl.TreeNode:new({Text = format(L"翻译: %s ...", word), tag = word, Name = "Dictionary", Type = "Menuitem", onclick = nil, })) + end + ctl.height = (#node) * 26 + 4; + end + ctl:Show(mouse_x, mouse_y); +end + +function CommandHelpPage.OnClickContextMenuItem(node) + local name = node.Name + if(name == "PronounceIt") then + GameLogic.RunCommand("/voice ".. node.tag); + elseif(name == "Dictionary") then + GameLogic.RunCommand("open", format("https://fanyi.baidu.com/#en/zh/"..node.tag)); + end +end diff --git a/script/apps/Aries/Creator/Game/Code/CodeBlockWindow.lua b/script/apps/Aries/Creator/Game/Code/CodeBlockWindow.lua index 443a8a8a..ea37638e 100644 --- a/script/apps/Aries/Creator/Game/Code/CodeBlockWindow.lua +++ b/script/apps/Aries/Creator/Game/Code/CodeBlockWindow.lua @@ -290,7 +290,7 @@ function CodeBlockWindow.SetCodeEntity(entity, bNoCodeUpdate) if(codeBlock) then local text = codeBlock:GetLastMessage() or ""; if(text == "" and not CodeBlockWindow.GetMovieEntity()) then - if(self.entity and self.entity:IsCodeEmpty()) then + if(self.entity and self.entity:IsCodeEmpty() and self.entity.AutoCreateMovieEntity) then if(self.entity:AutoCreateMovieEntity()) then text = L"我们在代码方块旁边自动创建了一个电影方块! 你现在可以用代码控制电影方块中的演员了!"; else diff --git a/script/apps/Aries/Creator/Game/Code/CodeBlocklyDef/CodeBlocklyDef_Motion.lua b/script/apps/Aries/Creator/Game/Code/CodeBlocklyDef/CodeBlocklyDef_Motion.lua index 67315fa1..8becf314 100644 --- a/script/apps/Aries/Creator/Game/Code/CodeBlocklyDef/CodeBlocklyDef_Motion.lua +++ b/script/apps/Aries/Creator/Game/Code/CodeBlocklyDef/CodeBlocklyDef_Motion.lua @@ -435,6 +435,7 @@ walkForward(0) helpUrl = "", canRun = true, previousStatement = true, + hide_in_toolbox = true, -- deprecated, use SetActorValue("velocity") instead nextStatement = true, funcName = "velocity", func_description = 'velocity(%s)', diff --git a/script/apps/Aries/Creator/Game/Code/CodeBlocklyDef/ParacraftCodeBlockly.lua b/script/apps/Aries/Creator/Game/Code/CodeBlocklyDef/ParacraftCodeBlockly.lua index 818eaeee..8c556aaa 100644 --- a/script/apps/Aries/Creator/Game/Code/CodeBlocklyDef/ParacraftCodeBlockly.lua +++ b/script/apps/Aries/Creator/Game/Code/CodeBlocklyDef/ParacraftCodeBlockly.lua @@ -146,7 +146,11 @@ function ParacraftCodeBlockly.CompileCode(code, filename, codeblock) if(codeLanguageType == "python")then local pyruntime = NPL.load("Mod/PyRuntime/Transpiler.lua") - local py_env, env_error_msg = NPL.load("Mod/PyRuntime/py2lua/polyfill.lua") + if(not ParacraftCodeBlockly.isPythonRuntimeLoaded) then + ParacraftCodeBlockly.isPythonRuntimeLoaded = true; + pyruntime:start() + end + local py_env, env_error_msg = NPL.load("Mod/PyRuntime/py2npl/polyfill.lua") local code_env = codeblock:GetCodeEnv() py_env['_set_codeblock_env'](code_env) pyruntime:installMethods(code_env, py_env); diff --git a/script/apps/Aries/Creator/Game/Code/CodeGlobals.lua b/script/apps/Aries/Creator/Game/Code/CodeGlobals.lua index 124d89d6..6b341ed7 100644 --- a/script/apps/Aries/Creator/Game/Code/CodeGlobals.lua +++ b/script/apps/Aries/Creator/Game/Code/CodeGlobals.lua @@ -216,11 +216,14 @@ end function CodeGlobals:log(obj, ...) commonlib.echo(obj, ...); + local text; if(type(obj) == "string") then - self:logAdded(string.format(obj, ...)); + text = string.format(obj, ...); else - self:logAdded(commonlib.serialize_in_length(obj, 100)); + text = commonlib.serialize_in_length(obj, 100); end + self:logAdded(text); + GameLogic.AppendChat(text); end -- @return x,y: x in [-500, 500] range diff --git a/script/apps/Aries/Creator/Game/Code/NplCad/NplCad.lua b/script/apps/Aries/Creator/Game/Code/NplCad/NplCad.lua index 09ac7ca6..7862a678 100644 --- a/script/apps/Aries/Creator/Game/Code/NplCad/NplCad.lua +++ b/script/apps/Aries/Creator/Game/Code/NplCad/NplCad.lua @@ -116,8 +116,12 @@ function NplCad.CompileCode(code, filename, codeblock) local block_name = codeblock:GetBlockName(); if(not block_name or block_name == "")then block_name = "default" - end + GameLogic.AddBBS("error", L"请给CAD方块指定角色名称", 15000, "255 0 0") + end local relativePath = format("blocktemplates/nplcad/%s.x",commonlib.Encoding.Utf8ToDefault(block_name)); + + GameLogic.AddBBS("NPLCAD", format(L"CAD模型将保存到%s", relativePath), 5000, "255 0 0") + local filepath = GameLogic.GetWorldDirectory()..relativePath; code = NplCad.GetCode(code, filepath, relativePath); @@ -132,7 +136,7 @@ end -- set code block's nearby movie block's first actor's model to filepath if it is not. function NplCad.SetCodeBlockActorAsset(codeBlock, filepath) - if(CodeBlockWindow.GetCodeBlock() == codeBlock and CodeBlockWindow.IsVisible()) then + if(CodeBlockWindow.GetCodeBlock and CodeBlockWindow.GetCodeBlock() == codeBlock and CodeBlockWindow.IsVisible()) then local actor; local movieEntity = codeBlock:GetMovieEntity(); if(movieEntity and not movieEntity:GetFirstActorStack()) then diff --git a/script/apps/Aries/Creator/Game/Code/NplMicrobit/NplMicrobit.lua b/script/apps/Aries/Creator/Game/Code/NplMicrobit/NplMicrobit.lua index 21a5cb13..1f951df9 100644 --- a/script/apps/Aries/Creator/Game/Code/NplMicrobit/NplMicrobit.lua +++ b/script/apps/Aries/Creator/Game/Code/NplMicrobit/NplMicrobit.lua @@ -174,7 +174,11 @@ function NplMicrobit.CompileCode(code, filename, codeblock) end if(codeLanguageType == "python")then local pyruntime = NPL.load("Mod/PyRuntime/Transpiler.lua") - local py_env, env_error_msg = NPL.load("Mod/PyRuntime/py2lua/polyfill.lua") + if(not ParacraftCodeBlockly.isPythonRuntimeLoaded) then + ParacraftCodeBlockly.isPythonRuntimeLoaded = true; + pyruntime:start() + end + local py_env, env_error_msg = NPL.load("Mod/PyRuntime/py2npl/polyfill.lua") pyruntime:installMethods(codeblock:GetCodeEnv(),py_env); -- this callback is synchronous pyruntime:transpile(code, function(res) diff --git a/script/apps/Aries/Creator/Game/GUI/OpenAssetFileDialog.lua b/script/apps/Aries/Creator/Game/GUI/OpenAssetFileDialog.lua index d0d49567..965b1d05 100644 --- a/script/apps/Aries/Creator/Game/GUI/OpenAssetFileDialog.lua +++ b/script/apps/Aries/Creator/Game/GUI/OpenAssetFileDialog.lua @@ -320,9 +320,13 @@ function OpenAssetFileDialog.OnOpenAssetFileDialog() if(filename and page) then local fileItem = Files.ResolveFilePath(filename); - if(fileItem and fileItem.relativeToWorldPath) then - local filename = fileItem.relativeToWorldPath; - OpenAssetFileDialog.SetText(filename); + if(fileItem) then + if(fileItem.relativeToWorldPath) then + local filename = fileItem.relativeToWorldPath; + OpenAssetFileDialog.SetText(filename); + elseif(fileItem.relativeToRootPath) then + OpenAssetFileDialog.SetText(fileItem.relativeToRootPath); + end end end end diff --git a/script/apps/Aries/Creator/Game/Login/LocalLoadWorld.lua b/script/apps/Aries/Creator/Game/Login/LocalLoadWorld.lua index ccb00938..378aef61 100644 --- a/script/apps/Aries/Creator/Game/Login/LocalLoadWorld.lua +++ b/script/apps/Aries/Creator/Game/Login/LocalLoadWorld.lua @@ -83,9 +83,8 @@ function LocalLoadWorld.GetWorldFolder() end function LocalLoadWorld.GetWorldFolderFullPath() - local myWorldFolder = GameLogic.GetFilters():apply_filters("LocalLoadWorld.GetWorldFolderFullPath", LocalLoadWorld.GetWorldFolder()); - if (not LocalLoadWorld.OpenWorldFolderFullPath) then + local myWorldFolder = GameLogic.GetFilters():apply_filters("LocalLoadWorld.GetWorldFolderFullPath", LocalLoadWorld.GetWorldFolder()); LocalLoadWorld.OpenWorldFolderFullPath = myWorldFolder; if (not commonlib.Files.IsAbsolutePath(LocalLoadWorld.OpenWorldFolderFullPath)) then diff --git a/script/apps/Aries/Creator/Game/Movie/MovieClipController.html b/script/apps/Aries/Creator/Game/Movie/MovieClipController.html index f37fd2c4..6b3a95b3 100644 --- a/script/apps/Aries/Creator/Game/Movie/MovieClipController.html +++ b/script/apps/Aries/Creator/Game/Movie/MovieClipController.html @@ -67,7 +67,7 @@ - +