mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-23 10:59:45 +00:00
Merge branch 'main' into dev
This commit is contained in:
commit
be59202e17
6 changed files with 65 additions and 6 deletions
40
dev/tests/client/creating_new_world.lua
Normal file
40
dev/tests/client/creating_new_world.lua
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
app.tick()
|
||||||
|
app.set_setting("ui.language", "en_US")
|
||||||
|
|
||||||
|
local main_page = Document.new("core:pages/main")
|
||||||
|
test.click(main_page.worlds_btn)
|
||||||
|
|
||||||
|
local worlds_page = Document.new("core:pages/worlds")
|
||||||
|
test.click(worlds_page.new_world_btn)
|
||||||
|
|
||||||
|
local page = Document.new("core:pages/new_world")
|
||||||
|
local world_name = "test-"..random.uuid()
|
||||||
|
test.fill(page.name_box, world_name)
|
||||||
|
test.fill(page.seed_box, "randomseed")
|
||||||
|
test.click(page.generator_btn)
|
||||||
|
|
||||||
|
local generators_page = Document.new("core:pages/generators")
|
||||||
|
test.click(test.find_by_text(generators_page.root, "Flat_grass"))
|
||||||
|
|
||||||
|
local new_world_page = Document.new("core:pages/new_world")
|
||||||
|
test.click(new_world_page.create_world_btn)
|
||||||
|
|
||||||
|
app.sleep_until(function() return gui.root["hud.hotbar"].exists end)
|
||||||
|
|
||||||
|
test.press("escape")
|
||||||
|
local pause_page = Document.new("core:pages/pause")
|
||||||
|
test.click(pause_page.quit_btn)
|
||||||
|
|
||||||
|
test.click(main_page.worlds_btn)
|
||||||
|
|
||||||
|
local world_button = test.find_by_text(worlds_page.root, world_name).parent
|
||||||
|
local delete_button = test.find_by_attr(world_button, "src", "gui/delete_icon")
|
||||||
|
test.click(delete_button)
|
||||||
|
|
||||||
|
assert(test.find_by_text(
|
||||||
|
gui.root.root, string.format("Do you want to delete world forever? (user:worlds/%s)", world_name)
|
||||||
|
), "World deletion confirm dialog not shown")
|
||||||
|
|
||||||
|
test.press("enter")
|
||||||
|
|
||||||
|
assert(not world_button.exists, "World still shown in worlds list after deletion")
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<panel size='400' color='0' interval='1' context='menu'>
|
<panel size='400' color='0' interval='1' context='menu'>
|
||||||
<button onclick='menu.page="worlds"'>@Worlds</button>
|
<button id='worlds_btn' onclick='menu.page="worlds"'>@Worlds</button>
|
||||||
<button onclick='menu.page="scripts"'>@Scripts</button>
|
<button onclick='menu.page="scripts"'>@Scripts</button>
|
||||||
<button onclick='menu.page="settings"'>@Settings</button>
|
<button onclick='menu.page="settings"'>@Settings</button>
|
||||||
<button onclick='menu.page="content_menu"'>@Content</button>
|
<button onclick='menu.page="content_menu"'>@Content</button>
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,11 @@
|
||||||
</textbox>
|
</textbox>
|
||||||
<label>@Seed</label>
|
<label>@Seed</label>
|
||||||
<textbox id='seed_box' placeholder='-' padding='4'></textbox>
|
<textbox id='seed_box' placeholder='-' padding='4'></textbox>
|
||||||
<button onclick='save_state() menu.page="generators"' id='generator_btn'>
|
<button id='generator_btn' onclick='save_state() menu.page="generators"'>
|
||||||
@World generator
|
@World generator
|
||||||
</button>
|
</button>
|
||||||
<button id='content_btn' onclick='save_state() menu.page="content"'/>
|
<button id='content_btn' onclick='save_state() menu.page="content"'/>
|
||||||
<button onclick='create_world()' margin='0,20,0,1'>
|
<button id='create_world_btn' onclick='create_world()' margin='0,20,0,1'>
|
||||||
@Create World
|
@Create World
|
||||||
</button>
|
</button>
|
||||||
<button onclick='menu:back()'>@Back</button>
|
<button onclick='menu:back()'>@Back</button>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<button onclick='gui.close_menu()'>@Continue</button>
|
<button onclick='gui.close_menu()'>@Continue</button>
|
||||||
<button onclick='menu.page="content?mode=world"'>@Content</button>
|
<button onclick='menu.page="content?mode=world"'>@Content</button>
|
||||||
<button onclick='menu.page="settings"'>@Settings</button>
|
<button onclick='menu.page="settings"'>@Settings</button>
|
||||||
<button onclick='app.close_world(true)'>
|
<button id='quit_btn' onclick='app.close_world(true)'>
|
||||||
@Save and Quit to Menu
|
@Save and Quit to Menu
|
||||||
</button>
|
</button>
|
||||||
</panel>
|
</panel>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<panel size='400' color='0' interval='1' context='menu'>
|
<panel size='400' color='0' interval='1' context='menu'>
|
||||||
<button onclick='menu.page="new_world"'>@New World</button>
|
<button id="new_world_btn" onclick='menu.page="new_world"'>@New World</button>
|
||||||
|
|
||||||
<panel id='worlds' size='390,1' padding='5' color='#FFFFFF11' max-length='400'>
|
<panel id='worlds' size='390,1' padding='5' color='#FFFFFF11' max-length='400'>
|
||||||
</panel>
|
</panel>
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,25 @@ function next_waypoint()
|
||||||
return route[#route]
|
return route[#route]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function is_passed(waypoint, next_point, pos)
|
||||||
|
local wx, wz = waypoint[1] + 0.5, waypoint[3] + 0.5
|
||||||
|
local dx, dz = pos[1] - wx, pos[3] - wz
|
||||||
|
if dx * dx + dz * dz > 2.25 then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return dx * (next_point[1] + 0.5 - wx) + dz * (next_point[3] + 0.5 - wz) > 0
|
||||||
|
end
|
||||||
|
|
||||||
|
local function drop_passed_waypoints(new_route)
|
||||||
|
table.remove(new_route, #new_route)
|
||||||
|
local pos = tsf:get_pos()
|
||||||
|
while #new_route >= 2 and
|
||||||
|
is_passed(new_route[#new_route], new_route[#new_route - 1], pos) do
|
||||||
|
table.remove(new_route, #new_route)
|
||||||
|
end
|
||||||
|
return new_route
|
||||||
|
end
|
||||||
|
|
||||||
local refresh_internal = 100
|
local refresh_internal = 100
|
||||||
local frameid = math.random(0, refresh_internal)
|
local frameid = math.random(0, refresh_internal)
|
||||||
|
|
||||||
|
|
@ -64,7 +83,7 @@ function on_update()
|
||||||
else
|
else
|
||||||
local new_route = pathfinding.pull_route(agent)
|
local new_route = pathfinding.pull_route(agent)
|
||||||
if new_route then
|
if new_route then
|
||||||
route = new_route
|
route = drop_passed_waypoints(new_route)
|
||||||
started = false
|
started = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue