Differences From
Artifact [ddaa1e9478]:
93 93 kind = i.img and 'contact' or 'button', close = i.close;
94 94 color = i.color;
95 95 fg = i.fg;
96 96 label = i.label;
97 97 img = i.img;
98 98 id = i.id;
99 99 w = bw, h = rh;
100 + desc = i.desc;
100 101 })
101 102 if i.cfg then
102 103 table.insert(bar, {
103 104 kind = 'button';
104 105 color = i.color;
105 106 fg = i.fg;
106 107 label = "CFG";
................................................................................
306 307 if e.key == 'disable' and e.value == 'yes' then
307 308 color.lum = -.2
308 309 fg = lib.color {hue=color.hue,sat=0.7,lum=0.7}
309 310 break
310 311 end
311 312 end
312 313 end
313 - if tbl then table.insert(tbl, {
314 - color = color, fg = fg;
315 - label = r.sw.label or r.sw.name;
316 - id = string.format('suit_pgm_%s_', id);
317 - cfg = cfg, close = close;
318 - }) end
314 + if tbl then
315 + local props = {
316 + {title = "Size", desc=lib.math.siUI('B', r.sw.size), affinity='info'};
317 + }
318 + if r.sw.cost and r.sw.cost.ram then
319 + table.insert(props, {title = "Memory Usage", desc=lib.math.siUI('B', r.sw.cost.ram), affinity='info'})
320 + end
321 + if r.sw.cost and r.sw.cost.cycles then
322 + table.insert(props, {title = "Compute Usage", desc=lib.math.siUI('cycles',r.sw.cost.cycles,true), affinity='info'})
323 + end
324 + if r.powerCost then
325 + table.insert(props, {title = "Power Draw", desc=lib.math.siUI('W', r.powerCost), affinity='info'})
326 + end
327 + if r.speed then
328 + table.insert(props, {title = "Minimum Runtime", desc=lib.math.timespec(r.speed), affinity='info'})
329 + end
330 + table.insert(tbl, {
331 + color = color, fg = fg;
332 + label = r.sw.label or r.sw.name;
333 + id = string.format('suit_pgm_%s_', id);
334 + desc = starlit.ui.tooltip {
335 + title = r.sw.name;
336 + desc = r.sw.desc;
337 + color = lib.color(1,0,.8);
338 + props = props;
339 + };
340 + cfg = cfg, close = close;
341 + })
342 + end
319 343 end
320 344 end
321 345 local menu = { kind = 'vert', mode = 'sw', padding = 0.5 }
322 346 if swm then table.insert(menu, abilityMenu(swm)) end
323 347
324 348 local inv = user.entity:get_inventory()
325 349 --[[
................................................................................
515 539 user:suitPowerStateSet(suitMode)
516 540 return true
517 541 end
518 542 end;
519 543 };
520 544 };
521 545 })
546 +
547 +starlit.interface.install(starlit.type.ui {
548 + id = 'starlit:box';
549 + pages = {
550 + index = {
551 + setupState = function(state, user, ctx)
552 + state.ctx = ctx
553 + end;
554 + handle = function(state, user, q)
555 + if q.quit then
556 + user:suitSound 'starlit-quit' -- TODO better sound
557 + end
558 + end;
559 + render = function(state, user)
560 + local body = {kind='vert', w=6; mode='hw', spacing=.5, padding=1 }
561 + for i, l in ipairs(state.ctx.inv) do
562 + local inv = minetest.get_meta(l.pos):get_inventory()
563 + local w = l.w or 6
564 + if l.label then
565 + table.insert(body, {kind = 'hbar'; text = l.label, w=w+.5, h = .5})
566 + end
567 + table.insert(body, {kind = 'list';
568 + w = w, h = inv:get_size(l.id)/w;
569 + node = l.pos, inv = l.id;
570 + spacing = .1;
571 + })
572 + end
573 + table.insert(body, {kind = 'list';
574 + target = 'current_player', inv = 'main';
575 + w = 6, h = 1, spacing = 0.1;
576 + })
577 + return starlit.ui.build(body)
578 + end;
579 + }
580 + }
581 +})