Skip to content

Commit

Permalink
update Yuescript with new optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
pigpigyyy committed Mar 18, 2024
1 parent 07e6adc commit 28fd9e3
Show file tree
Hide file tree
Showing 50 changed files with 1,577 additions and 1,092 deletions.
76 changes: 41 additions & 35 deletions Assets/Script/Dev/Entry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,28 @@ stop = function() -- 476
return true -- 481
end -- 476
_module_0["stop"] = stop -- 481
local _anon_func_0 = function(Path, file, Content, require, type) -- 502
do -- 495
local scriptPath = Path:getPath(file) -- 495
Content:insertSearchPath(1, scriptPath) -- 496
scriptPath = Path(scriptPath, "Script") -- 497
if Content:exist(scriptPath) then -- 498
Content:insertSearchPath(1, scriptPath) -- 499
end -- 498
local result = require(file) -- 500
if "function" == type(result) then -- 501
result() -- 501
end -- 501
return nil -- 502
end -- 502
end -- 495
local _anon_func_1 = function(scroll, Label, fontSize, width, err) -- 532
local label = Label("sarasa-mono-sc-regular", fontSize) -- 529
label.alignment = "Left" -- 530
label.textWidth = width - fontSize -- 531
label.text = err -- 532
return label -- 529
end -- 529
local enterEntryAsync -- 483
enterEntryAsync = function(entry) -- 483
isInEntry = false -- 484
Expand All @@ -841,19 +863,7 @@ enterEntryAsync = function(entry) -- 483
end -- 489
end -- 488
sleep() -- 493
return xpcall(function() -- 494
local scriptPath = Path:getPath(file) -- 495
Content:insertSearchPath(1, scriptPath) -- 496
scriptPath = Path(scriptPath, "Script") -- 497
if Content:exist(scriptPath) then -- 498
Content:insertSearchPath(1, scriptPath) -- 499
end -- 498
local result = require(file) -- 500
if "function" == type(result) then -- 501
result() -- 501
end -- 501
return nil -- 502
end, function(msg) -- 502
return xpcall(_anon_func_0, function(msg) -- 502
local err = debug.traceback(msg) -- 504
allClear() -- 505
print(err) -- 506
Expand Down Expand Up @@ -893,21 +903,15 @@ enterEntryAsync = function(entry) -- 483
scroll.view.children.first.textWidth = w - fontSize -- 527
return scroll:adjustSizeWithAlign("Auto", 10, Size(w, h)) -- 528
end) -- 523
scroll.view:addChild((function() -- 529
local label = Label("sarasa-mono-sc-regular", fontSize) -- 529
label.alignment = "Left" -- 530
label.textWidth = width - fontSize -- 531
label.text = err -- 532
return label -- 529
end)()) -- 529
scroll.view:addChild(_anon_func_1(scroll, Label, fontSize, width, err)) -- 529
return scroll -- 515
end)()) -- 515
return root -- 514
end)()) -- 514
_with_0:alignLayout() -- 533
end -- 513
return err -- 534
end) -- 534
end, Path, file, Content, require, type) -- 534
end -- 483
_module_0["enterEntryAsync"] = enterEntryAsync -- 534
local enterDemoEntry -- 536
Expand Down Expand Up @@ -1048,6 +1052,20 @@ local windowFlags = { -- 612
"NoBringToFrontOnFocus" -- 617
} -- 611
local initFooter = true -- 618
local _anon_func_2 = function(currentIndex, allEntries) -- 652
if currentIndex > 1 then -- 652
return allEntries[currentIndex - 1] -- 653
else -- 655
return allEntries[#allEntries] -- 655
end -- 652
end -- 652
local _anon_func_3 = function(currentIndex, allEntries) -- 659
if currentIndex < #allEntries then -- 659
return allEntries[currentIndex + 1] -- 660
else -- 662
return allEntries[1] -- 662
end -- 659
end -- 659
footerWindow = threadLoop(function() -- 619
local zh = useChinese and isChineseSupported -- 620
if HttpServer.wsConnectionCount > 0 then -- 621
Expand Down Expand Up @@ -1101,26 +1119,14 @@ footerWindow = threadLoop(function() -- 619
if currentIndex == nil then -- 651
currentIndex = #allEntries + 1 -- 651
end -- 651
enterDemoEntry((function() -- 652
if currentIndex > 1 then -- 652
return allEntries[currentIndex - 1] -- 653
else -- 655
return allEntries[#allEntries] -- 655
end -- 652
end)()) -- 652
enterDemoEntry(_anon_func_2(currentIndex, allEntries)) -- 652
end -- 649
if right then -- 656
allClear() -- 657
if currentIndex == nil then -- 658
currentIndex = 0 -- 658
end -- 658
enterDemoEntry((function() -- 659
if currentIndex < #allEntries then -- 659
return allEntries[currentIndex + 1] -- 660
else -- 662
return allEntries[1] -- 662
end -- 659
end)()) -- 659
enterDemoEntry(_anon_func_3(currentIndex, allEntries)) -- 659
end -- 656
end -- 662
if not showEntry then -- 663
Expand Down
35 changes: 18 additions & 17 deletions Assets/Script/Example/DragonBones.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,34 @@ local DragonBone = dora.DragonBone -- 1
local p = _G.p -- 1
local print = _G.print -- 1
local tostring = _G.tostring -- 1
local Vec2 = dora.Vec2 -- 1
local Label = dora.Label -- 1
local Ease = dora.Ease -- 1
local Spawn = dora.Spawn -- 1
local Opacity = dora.Opacity -- 1
local Delay = dora.Delay -- 1
local App = dora.App -- 1
local Sequence = dora.Sequence -- 1
local Spawn = dora.Spawn -- 1
local Scale = dora.Scale -- 1
local Ease = dora.Ease -- 1
local Delay = dora.Delay -- 1
local Opacity = dora.Opacity -- 1
local Event = dora.Event -- 1
local Vec2 = dora.Vec2 -- 1
local threadLoop = dora.threadLoop -- 1
local ImGui = dora.ImGui -- 1
local boneStr = "DragonBones/NewDragon" -- 3
local animations = DragonBone:getAnimations(boneStr) -- 5
local looks = DragonBone:getLooks(boneStr) -- 6
p(animations, looks) -- 8
local _anon_func_0 = function(_with_0, Label, name, App, Sequence, Spawn, Scale, Ease, Delay, Opacity, Event, Vec2, x, y) -- 31
local _with_1 = Label("sarasa-mono-sc-regular", 30) -- 19
_with_1.text = name -- 20
_with_1.color = App.themeColor -- 21
_with_1:perform(Sequence(Spawn(Scale(1, 0, 2, Ease.OutQuad), Sequence(Delay(0.5), Opacity(0.5, 1, 0))), Event("Stop"))) -- 22
_with_1.position = Vec2(x, y) -- 29
_with_1.order = 100 -- 30
_with_1:slot("Stop", function() -- 31
return _with_1:removeFromParent() -- 31
end) -- 31
return _with_1 -- 19
end -- 19
local bone -- 10
do -- 10
local _with_0 = DragonBone(boneStr) -- 10
Expand All @@ -38,18 +50,7 @@ do -- 10
do -- 18
local name = _with_0:containsPoint(x, y) -- 18
if name then -- 18
return _with_0:addChild((function() -- 19
local _with_1 = Label("sarasa-mono-sc-regular", 30) -- 19
_with_1.text = name -- 20
_with_1.color = App.themeColor -- 21
_with_1:perform(Sequence(Spawn(Scale(1, 0, 2, Ease.OutQuad), Sequence(Delay(0.5), Opacity(0.5, 1, 0))), Event("Stop"))) -- 22
_with_1.position = Vec2(x, y) -- 29
_with_1.order = 100 -- 30
_with_1:slot("Stop", function() -- 31
return _with_1:removeFromParent() -- 31
end) -- 31
return _with_1 -- 19
end)()) -- 31
return _with_0:addChild(_anon_func_0(_with_0, Label, name, App, Sequence, Spawn, Scale, Ease, Delay, Opacity, Event, Vec2, x, y)) -- 31
end -- 18
end -- 18
end) -- 16
Expand Down
11 changes: 7 additions & 4 deletions Assets/Script/Example/Entity Move.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,24 @@ do -- 6
entity.target = location -- 12
end) -- 12
end) -- 9
return scene -- 7
return false -- 12
end) -- 7
end -- 6
do -- 14
local _with_0 = Observer("Add", { -- 14
"image" -- 14
}) -- 14
_with_0:watch(function(self, image) -- 15
return sceneGroup:each(function(e) -- 15
sceneGroup:each(function(e) -- 15
do -- 16
local _with_1 = Sprite(image) -- 16
self.sprite = _with_1 -- 16
_with_1:addTo(e.scene) -- 17
_with_1:runAction(Scale(0.5, 0, 0.5, Ease.OutBack)) -- 18
end -- 16
return true -- 19
end) -- 19
end) -- 15
return false -- 19
end) -- 15
end -- 14
do -- 21
Expand Down Expand Up @@ -90,6 +91,7 @@ do -- 27
if newPos == target then -- 37
self.target = nil -- 37
end -- 37
return false -- 37
end) -- 28
end -- 27
do -- 39
Expand All @@ -102,8 +104,9 @@ do -- 39
sprite.position = position -- 41
local lastDirection = self.oldValues.direction or sprite.angle -- 42
if math.abs(direction - lastDirection) > 1 then -- 43
return sprite:runAction(Roll(0.3, lastDirection, direction)) -- 44
sprite:runAction(Roll(0.3, lastDirection, direction)) -- 44
end -- 43
return false -- 44
end) -- 40
end -- 39
Entity({ -- 47
Expand Down
8 changes: 4 additions & 4 deletions Assets/Script/Example/Entity Move.yue
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ sceneGroup = Group ["scene",]
positionGroup = Group ["position",]

with Observer "Add", ["scene",]
\watch (scene) => with scene
\watch (scene): false => with scene
.touchEnabled = true
\slot "TapEnded", (touch) ->
:location = touch
positionGroup\each (entity) ->
entity.target = location

with Observer "Add", ["image",]
\watch (image) => sceneGroup\each (e) ->
\watch (image): false => sceneGroup\each (e) ->
with @sprite = Sprite image
\addTo e.scene
\runAction Scale 0.5, 0, 0.5, Ease.OutBack
Expand All @@ -25,7 +25,7 @@ with Observer "Remove", ["target",]
\watch => print "remove target from entity #{@index}"

with Group ["position", "direction", "speed", "target"]
\watch (position, direction, speed, target) =>
\watch (position, direction, speed, target): false =>
return if target == position
dir = target - position
dir = dir\normalize!
Expand All @@ -37,7 +37,7 @@ with Group ["position", "direction", "speed", "target"]
@target = nil if newPos == target

with Observer "AddOrChange", ["position", "direction", "sprite"]
\watch (position, direction, sprite) =>
\watch (position, direction, sprite): false =>
sprite.position = position
lastDirection = @oldValues.direction or sprite.angle
if math.abs(direction - lastDirection) > 1
Expand Down
Loading

0 comments on commit 28fd9e3

Please sign in to comment.