Loading image, spade, gui, look in description

- scene.image supports image scaling
- scale loading images properly (might need more work later)
- spade now shows what block will be spaded using the cube marker
- removed run.sh
This commit is contained in:
Dany0 2015-02-09 20:56:16 +01:00
parent 34a79de33c
commit d45f8971d5
5 changed files with 31 additions and 48 deletions

View File

@ -26,6 +26,11 @@ return function (plr)
this.gui_pick_scale = 1.3
this.mspeed_mul = MODE_PSPEED_SPADE
if not this.mdl_cube_marker and mdl_cube then
this.mdl_cube_marker = mdl_cube({filt=function(br,bg,bb)
return 233,16,16
end})
end
function this.get_damage(styp, tplr)
if tplr.team == plr.team then return 0, "ERROR" end
@ -190,14 +195,17 @@ return function (plr)
function this.render(px,py,pz,ya,xa,ya2)
ya = ya - math.pi/2
if plr.blx1 and (plr.alive or plr.respawning) and map_block_get(plr.blx2, plr.bly2, plr.blz2) then
mdl_test_inst.render_global(
plr.blx1+0.5, plr.bly1+0.5, plr.blz1+0.5,
rotpos*0.01, rotpos*0.004, 0.0, 0.1+0.01*math.sin(rotpos*0.071))
mdl_test_inst.render_global(
(plr.blx1*2+plr.blx2)/3+0.5,
(plr.bly1*2+plr.bly2)/3+0.5,
(plr.blz1*2+plr.blz2)/3+0.5,
-rotpos*0.01, -rotpos*0.004, 0.0, 0.1+0.01*math.sin(-rotpos*0.071))
this.mdl_cube_marker.render_global(
plr.blx2+0.55, plr.bly2+0.55, plr.blz2+0.55,
0.0, 0.0, 0.0, 24.0+math.abs(2*math.sin(rotpos*0.071)))
-- mdl_test_inst.render_global(
-- plr.blx1+0.5, plr.bly1+0.5, plr.blz1+0.5,
-- rotpos*0.01, rotpos*0.004, 0.0, 0.1+0.01*math.sin(rotpos*0.071))
-- mdl_test_inst.render_global(
-- (plr.blx1*2+plr.blx2)/3+0.5,
-- (plr.bly1*2+plr.bly2)/3+0.5,
-- (plr.blz1*2+plr.blz2)/3+0.5,
-- -rotpos*0.01, -rotpos*0.004, 0.0, 0.1+0.01*math.sin(-rotpos*0.071))
end
this.mdl.render_global(
px, py, pz, ya, xa, ya2, 1)

View File

@ -573,7 +573,7 @@ function gui_create_scene(width, height, shared_rate)
local samples = sample_packet[1]
local col_1 = sample_packet[2]
local col_2 = sample_packet[3]
local scaleX = (#samples-1) / w;
local scalex = (#samples-1) / w;
local amin = sample_packet[4]
local amax = sample_packet[5]
@ -602,7 +602,7 @@ function gui_create_scene(width, height, shared_rate)
local last = bmin + (samples[1] - amin) * ratio
for n=1, w do
local cur = bmin + (samples[math.floor(n*scaleX)+1] - amin) * ratio
local cur = bmin + (samples[math.floor(n*scalex)+1] - amin) * ratio
local top = math.floor(math.max(cur, last));
local bot = math.floor(math.min(cur, last));
for z=bot, top do
@ -961,6 +961,9 @@ function gui_create_scene(width, height, shared_rate)
local this = scene.display_object(options)
this._img = options.img
this.width, this.height = common.img_get_dims(this._img)
this.width, this.height = options.width or this.width, options.height or this.height
this.scalex, this.scaley = options.scalex or 1.0, options.scaley or 1.0
this.use_img = false
function this.getter_keys.width()
@ -972,7 +975,7 @@ function gui_create_scene(width, height, shared_rate)
function this._recalc_size()
local pw, ph
pw, ph = common.img_get_dims(this.img)
pw, ph = this.width or pw, this.height or ph
rawset(this, 'width', pw)
rawset(this, 'height', ph)
this.dirty = true
@ -985,7 +988,7 @@ function gui_create_scene(width, height, shared_rate)
this._recalc_size()
end
function this.draw_update()
client.img_blit(this._img, this.l, this.t)
client.img_blit(this._img, this.l, this.t, this.width, this.height, 0, 0, 0xFFFFFFFF, this.scalex, this.scaley)
end
this._recalc_size()

View File

@ -161,10 +161,14 @@ do
if string.sub(fname, 1,6) == "clsave" then return client.fetch_block(ftype, fname) end
if widgets ~= nil then
scene = gui_create_scene(w, h)
loading_img = scene.image{img=img_loading, x=screen_width/2, y=screen_height/2}
img_loading_width, img_loading_height = client.img_get_dims(img_loading)
img_loading_scale = math.min(screen_width/img_loading_width, screen_height/img_loading_height)
loading_img = scene.image{img=img_loading, x=screen_width/2, y=screen_height/2, width = screen_width, height = screen_height, scalex = img_loading_scale, scaley = img_loading_scale}
scene.root.add_child(loading_img)
if img_map then
map_img = scene.image{img=img_map, x=-screen_width/2, y=screen_height/2}
img_map_width, img_map_height = client.img_get_dims(img_map)
img_map_scale = math.min(screen_width/img_map_width, screen_height/img_map_height)
map_img = scene.image{img=img_map, x=-screen_width/2, y=screen_height/2, width = screen_width, height = screen_height, scalex = img_map_scale, scaley = img_map_scale}
scene.root.add_child(map_img)
end
end

32
run.sh
View File

@ -1,32 +0,0 @@
#!/bin/bash
PS3='Please enter your choice: '
options=("Single-player" "rakiru's server" "Lighting test" "Map editor" "PMF editor" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Single-player")
echo "Starting local server..."
./iceball -s 0 pkg/base pkg/maps/mesa.vxl
;;
"rakiru's server")
echo "Joining rakiru's server..."
./iceball -c play.iceballga.me 20737
;;
"Lighting test")
echo "Starting local server with lighting test..."
./iceball -s 0 pkg/iceball/radtest
;;
"Map editor")
echo "Starting map editor..."
./iceball -s 0 pkg/iceball/mapedit
;;
"PMF editor")
echo "Starting PMF editor..."
./iceball -s 0 pkg/iceball/pmfedit
;;
"Quit")
break
;;
*) echo invalid option;;
esac
done

BIN
tools/lastsav.vxl Normal file

Binary file not shown.