Skip to content

Commit

Permalink
svn_sync
Browse files Browse the repository at this point in the history
  • Loading branch information
LiXizhi committed Mar 9, 2020
1 parent e010c18 commit 395c9da
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
<pe:if condition ='<%= CommandHelpPage.HasGotCommandName%>'>
<div style="margin-left:7px;margin-top:5px;margin-right:0px;">
<div style='font-weight:bold;'><%=L"命令格式"%><input type='button' value='<%=L"帮助"%>' style='float:left;margin-left:10px;' onclick='OnShowCmdHelp' class='mc_button_blue' /></div>
<textarea ReadOnly="false" UseSystemControl="true" style='<%=format("textcolor:#ffffff;height:%dpx", CommandHelpPage.height-20)%>' value="<%= GetCommandStr()%>"></textarea>
<textarea name="code" ReadOnly="false" UseSystemControl="true" style='<%=format("textcolor:#ffffff;height:%dpx", CommandHelpPage.height-20)%>' value="<%= GetCommandStr()%>" OnRightClick="CommandHelpPage.OnRightClick"></textarea>
</div>
</pe:if>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,4 +381,63 @@ function CommandHelpPage.OnKeyUp_RETURN(callback)
callback();
end
end
end
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
2 changes: 1 addition & 1 deletion script/apps/Aries/Creator/Game/Code/CodeBlockWindow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions script/apps/Aries/Creator/Game/Code/CodeGlobals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions script/apps/Aries/Creator/Game/Code/NplCad/NplCad.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 7 additions & 3 deletions script/apps/Aries/Creator/Game/GUI/OpenAssetFileDialog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions script/apps/Aries/Creator/Game/Login/LocalLoadWorld.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<input type="button" zorder="1" name="godview" tooltip='<%=L"主角"%>' style="margin-left: 1px; margin-top: 1px; width: 32px; height: 32px; background: url(Texture/blocks/items/ts_char_off.png); " onclick="MovieClipController.OnClickGodMode()"/>
</div>
</div>
<pe:gridview name="InventoryItems" style="height:104px;" VerticalScrollBarStep="34" DataSource="<%=DS_Actor_Inventory%>" CellPadding="0" DefaultNodeHeight = "34" ItemsPerLine="5" AllowPaging="false" RememberScrollPos="true" RememberLastPage="true" pagesize="256">
<pe:gridview name="InventoryItems" style="height:104px;" VerticalScrollBarStep="34" DataSource="<%=DS_Actor_Inventory%>" CellPadding="0" DefaultNodeHeight = "34" ItemsPerLine="5" AllowPaging="false" RememberScrollPos="true" RememberLastPage="true" pagesize="512">
<Columns>
<pe:if condition='<%=IsSelectedActor(Eval("slotNumber"))%>'>
<div style="background:url(Texture/Aries/Creator/Theme/GameCommonIcon_32bits.png#236 122 26 26:1 1 1 1)">
Expand Down

0 comments on commit 395c9da

Please sign in to comment.