starlit  Diff

Differences From Artifact [ddaa1e9478]:

To Artifact [39c7d68ac6]:


93
94
95
96
97
98
99

100
101
102
103
104
105
106
...
306
307
308
309
310
311
312
















313
314
315
316






317

318
319
320
321
322
323
324
325
...
515
516
517
518
519
520
521




































			kind = i.img and 'contact' or 'button', close = i.close;
			color = i.color;
			fg = i.fg;
			label = i.label;
			img = i.img;
			id = i.id;
			w = bw, h = rh;

		})
		if i.cfg then 
			table.insert(bar, {
				kind = 'button';
				color = i.color;
				fg = i.fg;
				label = "CFG";
................................................................................
								if e.key == 'disable' and e.value == 'yes' then
									color.lum = -.2
									fg = lib.color {hue=color.hue,sat=0.7,lum=0.7}
									break
								end
							end
						end
















						if tbl then table.insert(tbl, {
							color = color, fg = fg;
							label = r.sw.label or r.sw.name;
							id = string.format('suit_pgm_%s_', id);






							cfg = cfg, close = close;

						}) end
					end
				end
				local menu = { kind = 'vert', mode = 'sw', padding = 0.5 }
				if swm then table.insert(menu, abilityMenu(swm)) end

				local inv = user.entity:get_inventory()
				--[[
................................................................................
					user:suitPowerStateSet(suitMode)
					return true
				end
			end;
		};
	};
})











































>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
>
>
>
>
>
>
|
>
|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
...
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
...
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
			kind = i.img and 'contact' or 'button', close = i.close;
			color = i.color;
			fg = i.fg;
			label = i.label;
			img = i.img;
			id = i.id;
			w = bw, h = rh;
			desc = i.desc;
		})
		if i.cfg then 
			table.insert(bar, {
				kind = 'button';
				color = i.color;
				fg = i.fg;
				label = "CFG";
................................................................................
								if e.key == 'disable' and e.value == 'yes' then
									color.lum = -.2
									fg = lib.color {hue=color.hue,sat=0.7,lum=0.7}
									break
								end
							end
						end
						if tbl then
							local props = {
								{title = "Size", desc=lib.math.siUI('B', r.sw.size), affinity='info'};
							}
							if r.sw.cost and r.sw.cost.ram then
								table.insert(props, {title = "Memory Usage", desc=lib.math.siUI('B', r.sw.cost.ram), affinity='info'})
							end
							if r.sw.cost and r.sw.cost.cycles then
								table.insert(props, {title = "Compute Usage", desc=lib.math.siUI('cycles',r.sw.cost.cycles,true), affinity='info'})
							end
							if r.powerCost then
								table.insert(props, {title = "Power Draw", desc=lib.math.siUI('W', r.powerCost), affinity='info'})
							end
							if r.speed then
								table.insert(props, {title = "Minimum Runtime", desc=lib.math.timespec(r.speed), affinity='info'})
							end
							table.insert(tbl, {
								color = color, fg = fg;
								label = r.sw.label or r.sw.name;
								id = string.format('suit_pgm_%s_', id);
								desc = starlit.ui.tooltip {
									title = r.sw.name;
									desc = r.sw.desc;
									color = lib.color(1,0,.8);
									props = props;
								};
								cfg = cfg, close = close;
							})
						end
					end
				end
				local menu = { kind = 'vert', mode = 'sw', padding = 0.5 }
				if swm then table.insert(menu, abilityMenu(swm)) end

				local inv = user.entity:get_inventory()
				--[[
................................................................................
					user:suitPowerStateSet(suitMode)
					return true
				end
			end;
		};
	};
})

starlit.interface.install(starlit.type.ui {
	id = 'starlit:box';
	pages = {
		index = {
			setupState = function(state, user, ctx)
				state.ctx = ctx
			end;
			handle = function(state, user, q)
				if q.quit then
					user:suitSound 'starlit-quit' -- TODO better sound
				end
			end;
			render = function(state, user)
				local body = {kind='vert', w=6; mode='hw', spacing=.5, padding=1 }
				for i, l in ipairs(state.ctx.inv) do
					local inv = minetest.get_meta(l.pos):get_inventory()
					local w = l.w or 6
					if l.label then
						table.insert(body, {kind = 'hbar'; text = l.label, w=w+.5, h = .5})
					end
					table.insert(body, {kind = 'list';
						w = w, h = inv:get_size(l.id)/w;
						node = l.pos, inv = l.id;
						spacing = .1;
					})
				end
				table.insert(body, {kind = 'list';
					target = 'current_player', inv = 'main';
					w = 6, h = 1, spacing = 0.1;
				})
				return starlit.ui.build(body)
			end;
		}
	}
})