168
169
170
171
172
173
174
175
176
177
178
179
180
181
...
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
...
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
...
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
...
458
459
460
461
462
463
464
465
466
467
468
469
470
471
...
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
...
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
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
...
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
|
end
end
if not pgm then return false end -- HAX
-- kind=active programs must be assigned to a command slot
-- kind=direct programs must open their UI
-- kind=passive programs must toggle on and off
if pgm.sw.powerKind == 'active' then
if cfg then
user:openUI(pgm.sw.ui, 'index', {
context = 'suit';
program = pgm;
})
return false
................................................................................
elseif pptrMatch(ptr, pnan.secondary) then
pnan.secondary = nil
else
pnan.secondary = ptr
end
user:suitSound 'starlit-configure'
elseif pgm.sw.powerKind == 'direct' then
local ctx = {
context = 'suit';
program = pgm;
}
if pgm.sw.ui then
user:openUI(pgm.sw.ui, 'index', ctx)
return false
else
pgm.sw.run(user, ctx)
end
elseif pgm.sw.powerKind == 'passive' then
if cfg then
user:openUI(pgm.sw.ui, 'index', {
context = 'suit';
program = pgm;
})
return false
end
local addDisableRec = true
for i, e in ipairs(pgm.file.body.conf) do
if e.key == 'disable' and e.value == 'yes' then
addDisableRec = false
................................................................................
w=2, h=2;
})
menu.padding = 1;
end
return starlit.ui.build(menu)
end;
};
compilerListRecipes = {
};
psi = {
render = function(state, user)
return starlit.ui.build {
kind = 'vert', mode = 'sw';
padding = 0.5;
}
end;
................................................................................
local tb = {
kind = 'vert', mode = 'sw';
padding = 0.5,
{kind = 'hztl', padding = 0.25;
{kind = 'label', text = 'Name', w = 2, h = barh};
{kind = 'label', text = user.persona.name, w = 4, h = barh}};
}
local statBars = {'nutrition', 'hydration', 'fatigue', 'morale', 'irradiation', 'illness'}
for idx, id in ipairs(statBars) do
local s = starlit.world.stats[id]
local amt, sv = user:effectiveStat(id)
local min, max = starlit.world.species.statRange(user.persona.species, user.persona.speciesVariant, id)
local st = string.format('%s / %s', s.desc(amt, true), s.desc(max))
table.insert(tb, {kind = 'hztl', padding = 0.25;
{kind = 'label', w=2, h=barh, text = lib.str.capitalize(s.name)};
{kind = 'hbar', w=4, h=barh, fac = sv, text = st, color=s.color};
})
end
local abilities = {
maneuver = {};
direct = {};
passive = {};
}
state.abilityMap = {}
for i, a in pairs(user:species().abilities) do
................................................................................
user:suitPowerStateSet(suitMode)
return true
end
end;
};
};
})
-- TODO destroy suit interfaces when power runs out or suit/chip is otherwise disabled
starlit.interface.install(starlit.type.ui {
id = 'starlit:compile-matter-component';
sub = {
suit = function(state, user, evt)
if evt.kind == 'disrobe' then state:close()
................................................................................
setupState = function(state, user, ctx)
state.pgm = ctx.program
state.select = {}
local E = starlit.mod.electronics
if ctx.context == 'suit' then
state.fetch = function()
local cst = user.entity:get_inventory():get_list 'starlit_suit_chips'
local cl = {order={}, map={}}
for i, c in ipairs(cst) do
if not c:is_empty() then
local d = E.chip.read(c)
local co = {
stack = c;
data = d;
}
table.insert(cl.order, co)
cl.map[d.uuid] = co
end
end
if state.select.chip and not cl.map[state.select.chip.data.uuid] then
-- chip no longer available
user:suitSound 'starlit-error'
state.select = {}
end
state.select.chips = cl
state.select.scms = {}
if state.select.chip then
state.select.scms = E.chip.usableSoftware({state.select.chip.stack},nil,
function(s) return s.sw.kind == 'schematic' end)
end
end
end
end;
onClose = function(state, user)
user:suitSound 'starlit-quit'
end;
................................................................................
handle = function(state, user, q)
local sel = state.select
state.fetch()
local chips = state.select.chips
local function chirp()
user:suitSound 'starlit-nav'
end
local function onPickChip(chip)
chirp()
sel.chip = chip
return true
end
local function onPickScm(scm)
chirp()
sel.scm = scm
return true
end
if sel.chip == nil then
for k in next, q do
local id = k:match "^chip_(%d+)$"
if id then
local cm = chips.map[tonumber(id)]
if cm then return onPickChip(cm) end
end
end
elseif sel.scm == nil then
if q.back then chirp() sel.chip = nil return true end
for k in next, q do
local id = k:match "^scm_(%d+)$"
if id then
local cm = state.select.scms[tonumber(id)]
if cm then return onPickScm(cm) end
end
end
else
if q.back then chirp() sel.scm = nil return true end
end
end;
render = function(state, user)
local sel, pgmSelector = state.select, {}
state.fetch()
local function pushSelector(id, item, label, desc, req)
local rh = .5
local label = {kind = 'text', w = 10-1.5, h=1.5;
text = '<global valign=middle>'..label }
if req then
label.h = label.h - rh - .2
local imgs = {}
for ci,c in ipairs(req) do
for ei, e in ipairs(c.list) do
table.insert(imgs, {kind = 'img', w=rh, h=rh, img=e.img})
................................................................................
if sel.chips == nil then
table.insert(pgmSelector, {kind = 'img', img = 'starlit-ui-alert.png', w=2, h=2})
elseif sel.chip == nil then
for i, c in ipairs(sel.chips.order) do
-- TODO filter out chips without schematics?
pushSelector('chip_' .. c.data.uuid, c.stack, c.data.label)
end
else
if sel.scm == nil then
for idx, ent in ipairs(sel.scms) do
local fab = ItemStack(ent.sw.output):get_definition()._starlit.fab
if fab.flag.print then
local req = fab:visualize()
pushSelector('scm_' .. idx, ent.sw.output, ent.sw.name, nil, req)
end
end
table.insert(pgmSelector, back)
else
local output = ItemStack(sel.scm.sw.output):get_definition()
local fab = output._starlit.fab
local sw = sel.scm.sw
table.insert(pgmSelector, {kind = 'hztl', w=10, h=1.2;
{kind = 'img', item = sw.output, w=1.2, h=1.2, desc=output.description};
{kind = 'text', text = string.format('<global valign=middle><b>%s</b>', sw.name), w=10-1.2,h=1.2};
})
local inputTbl = {kind = 'vert', w=5,h=0;
{kind = 'hbar', w=5, h=.5, text='Input'}};
local costTbl = {kind = 'vert', w=5,h=0; spacing=.25;
{kind = 'hbar', w=5, h=.5, text='Process'}};
local reqPane = {kind = 'pane', id='reqPane', w=10, h=7;
{kind = 'hztl', w=10,h=0; inputTbl, costTbl}
}
local req = fab:visualize()
for ci,c in ipairs(req) do
table.insert(inputTbl, {kind = 'label', w=4.5, h=1, x=.5;
text=lib.str.capitalize(c.header)});
for ei,e in ipairs(c.list) do
table.insert(inputTbl, {kind = 'hztl', w=4, h=.5, x=1;
{kind='img', w=.5,h=.5, img=e.img};
{kind='label', w=3.3,h=.5,x=.2, text=e.label};
});
end
end
if sw.cost then
local function pushCost(t, val)
table.insert(costTbl, {kind='text', w=4.5,h=.5,x=.5;
text=string.format('<b>%s</b>: %s',t,val);
})
end
if sw.cost.cycles then
pushCost('Energy', lib.math.siUI('J', sel.scm.powerCost))
pushCost('Compute', lib.math.siUI({'cycle','cycles'}, sw.cost.cycles, true))
end
end
table.insert(pgmSelector, reqPane)
table.insert(pgmSelector, {kind = 'hztl', w=10,h=1.2;
{kind = 'button', id='back', label = '<- Back', w=5,h=1.2};
{kind = 'button', id='print', label = 'Print ->', w=5,h=1.2, color={hue=120,sat=0,lum=0}};
})
end
end
return starlit.ui.build {
kind = 'hztl', padding = 0.5; w = 20, h = 10, mode = 'sw';
{kind = 'vert', w = 5, h = 5;
|
>
>
>
>
>
>
>
>
>
|
<
<
<
|
<
<
<
<
<
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
|
>
>
>
|
|
>
>
>
>
>
|
|
>
>
>
|
>
>
>
>
>
>
>
|
<
>
|
|
<
<
<
<
|
>
>
>
<
<
>
>
>
>
|
<
<
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
|
>
>
|
<
<
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
<
>
>
>
|
|
<
<
|
>
>
|
>
>
>
>
>
>
>
|
|
>
>
>
|
|
|
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
|
<
<
<
>
>
>
>
|
|
>
>
>
>
>
>
|
<
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
...
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
...
329
330
331
332
333
334
335
336
337
338
339
340
341
342
...
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
...
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
...
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
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
...
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
...
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
|
end
end
if not pgm then return false end -- HAX
-- kind=active programs must be assigned to a command slot
-- kind=direct programs must open their UI
-- kind=passive programs must toggle on and off
local function suitCtx(pgm)
local chips = user.entity:get_inventory():get_list 'starlit_suit_chips'
local pgmctx = starlit.mod.electronics.chip.usableSoftware(chips, {pgm})[1]
return {
context = 'suit';
program = pgmctx;
}
end
if pgm.sw.powerKind == 'active' then
if cfg then
user:openUI(pgm.sw.ui, 'index', {
context = 'suit';
program = pgm;
})
return false
................................................................................
elseif pptrMatch(ptr, pnan.secondary) then
pnan.secondary = nil
else
pnan.secondary = ptr
end
user:suitSound 'starlit-configure'
elseif pgm.sw.powerKind == 'direct' then
local ctx = suitCtx(pgm)
if pgm.sw.ui then
user:openUI(pgm.sw.ui, 'index', ctx)
return false
else
pgm.sw.run(user, ctx)
end
elseif pgm.sw.powerKind == 'passive' then
if cfg then
user:openUI(pgm.sw.ui, 'index', suitCtx(pgm))
return false
end
local addDisableRec = true
for i, e in ipairs(pgm.file.body.conf) do
if e.key == 'disable' and e.value == 'yes' then
addDisableRec = false
................................................................................
w=2, h=2;
})
menu.padding = 1;
end
return starlit.ui.build(menu)
end;
};
psi = {
render = function(state, user)
return starlit.ui.build {
kind = 'vert', mode = 'sw';
padding = 0.5;
}
end;
................................................................................
local tb = {
kind = 'vert', mode = 'sw';
padding = 0.5,
{kind = 'hztl', padding = 0.25;
{kind = 'label', text = 'Name', w = 2, h = barh};
{kind = 'label', text = user.persona.name, w = 4, h = barh}};
}
local statBars = {'stamina', 'numina', 'nutrition', 'hydration', 'fatigue', 'morale', 'irradiation', 'illness'}
local function wrapElts(n, l)
local all = {kind='vert'}
local ct, row
local function flush()
if row then
table.insert(all, row)
end
row = {kind='hztl', spacing = 0.2}
ct = 0
end
flush()
for i, e in ipairs(l) do
ct = ct + 1
table.insert(row, e)
if ct >= n then flush() end
end
flush()
return all
end
local bars = {}
local function pushBar(s, amt, sv, min, max)
local st = string.format('%s / %s', s.desc(amt, true), s.desc(max))
table.insert(bars, {kind = 'hztl', padding = 0.25;
{kind = 'label', w=2, h=barh, text = lib.str.capitalize(s.name)};
{kind = 'hbar', w=4, h=barh, fac = sv, text = st, color=s.color};
})
end
do local hp, hpf = user:effectiveStat 'health'
local desc = {
name='health';
desc = function(hp) return tostring(hp) end;
color = {hue=10,sat=1,lum=.5};
}
pushBar(desc, hp, hpf, starlit.world.species.statRange(user.persona.species, user.persona.speciesVariant, 'health'))
end
do local ep, ex = user:suitCharge(), user:suitPowerCapacity()
local desc = {
name = 'power';
desc = function(j) return lib.math.siUI('J', j) end;
color = {hue=190,sat=1,lum=.5};
}
pushBar(desc, ep, ep/ex, 0, ex)
end
for idx, id in ipairs(statBars) do
local s = starlit.world.stats[id]
local amt, sv = user:effectiveStat(id)
local min, max = starlit.world.species.statRange(user.persona.species, user.persona.speciesVariant, id)
pushBar(s, amt, sv, min, max)
end
table.insert(tb, wrapElts(2, bars))
local abilities = {
maneuver = {};
direct = {};
passive = {};
}
state.abilityMap = {}
for i, a in pairs(user:species().abilities) do
................................................................................
user:suitPowerStateSet(suitMode)
return true
end
end;
};
};
})
local function compilerCanPrint(user, cpl, scm)
local output = ItemStack(scm.sw.output):get_definition()
local fab = output._starlit.fab
local sw = scm.sw
local ok, consume, unsat, leftover, itemSpec = fab:seek {
user.entity:get_inventory():get_list 'main';
}
local cost = {
consume = consume, unsat = unsat, leftover = leftover, itemSpec = itemSpec;
runtimeEstimate = scm.speed + cpl.speed + (fab.time and fab.time.print or 0);
power = cpl.powerCost + scm.powerCost;
ram = (cpl.cost and cpl.cost.ram or 0)
+ (scm.cost and scm.cost.ram or 0);
cycles = (cpl.cost and cpl.cost.cycles or 0)
+ (scm.cost and scm.cost.cycles or 0);
}
local userComp = starlit.mod.electronics.chip.sumCompute(
user.entity:get_inventory():get_list 'starlit_suit_chips'
)
if ok and cost.power <= user:suitCharge() and cost.ram <= userComp.ram then
return true, cost
else return false, cost end
end
-- TODO destroy suit interfaces when power runs out or suit/chip is otherwise disabled
starlit.interface.install(starlit.type.ui {
id = 'starlit:compile-matter-component';
sub = {
suit = function(state, user, evt)
if evt.kind == 'disrobe' then state:close()
................................................................................
setupState = function(state, user, ctx)
state.pgm = ctx.program
state.select = {}
local E = starlit.mod.electronics
if ctx.context == 'suit' then
state.fetch = function()
local cst = user.entity:get_inventory():get_list 'starlit_suit_chips'
local cl = {order={}, map={}, slot={}}
for i, c in ipairs(cst) do
if not c:is_empty() then
local d = E.chip.read(c)
local co = {
stack = c;
data = d;
}
table.insert(cl.order, co)
cl.map[d.uuid] = co
cl.slot[i] = co
end
end
-- kill me fam
if ( state.select.chip
and state.select.chip ~= true
and not cl.map[state.select.chip])
or (state.select.scm
and not state.select.scms[state.select.scm])
then
-- chip or pgm no longer available
user:suitSound 'starlit-error'
state.select = {}
end
state.select.chips = cl
state.select.scms = {}
if state.select.chip then
state.select.scms = E.chip.usableSoftware(cst,nil, function(s)
if state.select.chip ~= true then
if cl.slot[s.chipSlot].data.uuid ~= state.select.chip then
return false
end
end
return s.sw.kind == 'schematic'
end)
end
end
end
end;
onClose = function(state, user)
user:suitSound 'starlit-quit'
end;
................................................................................
handle = function(state, user, q)
local sel = state.select
state.fetch()
local chips = state.select.chips
local function chirp()
user:suitSound 'starlit-nav'
end
local function trySelection(id)
if sel[id] == nil then
for k in next, q do
local pat = "^"..id.."_(%d+)$" -- ew
local idx = k:match(pat)
if idx then
local cm = tonumber(idx)
if cm then
chirp()
sel[id] = cm
return true
end
end
end
end
end
if sel.chip == nil then
if q.showAll then
chirp()
sel.chip = true
return true
elseif q.find then
chirp()
-- TODO
return true
end
end
if trySelection('chip') then
return true
elseif trySelection('scm') then
return true
else
if q.back then
chirp()
if sel.input then
sel.input = nil
elseif sel.scm then
sel.scm = nil
elseif sel.chip then
sel.chip = nil
end
return true
elseif q.commit then
if not sel.input then
chirp()
sel.input = true
return true
else
local scm = sel.scms[sel.scm]
local ok, cost = compilerCanPrint(user, state.pgm, scm)
if ok then
user:suitSound 'starlit-configure'
-- consume consumables
-- add print job
state.select = {}
return true
else
user:suitSound 'starlit-error'
end
end
end
end
end;
render = function(state, user)
local sel, pgmSelector = state.select, {}
state.fetch()
local function pushSelector(id, item, label, desc, req)
local rh = .5
local label = {kind = 'text', w = 10-1.5, h=1.5;
text = '<global valign=middle>'..lib.str.htsan(label) }
if req then
label.h = label.h - rh - .2
local imgs = {}
for ci,c in ipairs(req) do
for ei, e in ipairs(c.list) do
table.insert(imgs, {kind = 'img', w=rh, h=rh, img=e.img})
................................................................................
if sel.chips == nil then
table.insert(pgmSelector, {kind = 'img', img = 'starlit-ui-alert.png', w=2, h=2})
elseif sel.chip == nil then
for i, c in ipairs(sel.chips.order) do
-- TODO filter out chips without schematics?
pushSelector('chip_' .. c.data.uuid, c.stack, c.data.label)
end
if next(sel.chips.order) then
table.insert(pgmSelector, {kind = 'hztl', w=10,h=1.5;
{kind = 'button', w=5,h=1.5; id='showAll', label='Show All'};
{kind = 'button', w=5,h=1.5; id='find', label='Find'};
})
end
else
if sel.scm == nil then
for idx, ent in ipairs(sel.scms) do
local fab = ItemStack(ent.sw.output):get_definition()._starlit.fab
if fab.flag.print then
local req = fab:visualize()
pushSelector('scm_' .. idx, ent.sw.output, ent.sw.name, nil, req)
end
end
table.insert(pgmSelector, back)
else
local scm = sel.scms[sel.scm]
local output = ItemStack(scm.sw.output):get_definition()
local fab = output._starlit.fab
local sw = scm.sw
local function unmet(str)
return lib.color(1,.3,.3):fmt(str)
end
table.insert(pgmSelector, {kind = 'hztl', w=10, h=1.2;
{kind = 'img', item = sw.output, w=1.2, h=1.2, desc=output.description};
{kind = 'text', text = string.format('<global valign=middle><b>%s</b>', lib.str.htsan(sw.name)), w=10-1.2,h=1.2};
})
local inputTbl = {kind = 'vert', w=5,h=0;
{kind = 'hbar', w=5, h=.5, text=sel.input and 'Input Plan' or 'Input'}};
local costTbl = {kind = 'vert', w=5,h=0;
{kind = 'hbar', w=5, h=.5, text=sel.input and 'Process Plan' or 'Process'}};
local reqPane = {kind = 'pane', id='reqPane', w=10, h=7;
{kind = 'hztl', w=10,h=0; inputTbl, costTbl}
}
local function pushCost(x, t, val)
table.insert(costTbl, {kind='label', w=4.5,h=.5,x=x;
text=string.format('%s: %s',t,val);
})
end
local function pushComputeCosts(header, p)
if p then
table.insert(costTbl, {kind = 'label', w=5, h=.5, x=0; text=header});
if p.cycles then
pushCost(.5, 'Compute', lib.math.siUI({'cycle','cycles'}, p.cycles, true))
end
if p.power then
local str = lib.math.siUI('J', p.power)
if p.power > user:suitCharge() then str = unmet(str) end
pushCost(.5, 'Power', str)
end
if p.ram then
local str = string.format("%s / %s",
lib.math.siUI('B', p.ram),
lib.math.siUI('B', state.pgm.comp.ram))
if p.ram > state.pgm.comp.ram then str = unmet(str) end
pushCost(.5, 'Memory', str)
end
end
end
local function fabToUI(x, inputTbl, req)
for ci,c in ipairs(req) do
table.insert(inputTbl, {kind = 'label', w=5-x, h=.5, x=x;
text=lib.str.capitalize(c.header)});
for ei,e in ipairs(c.list) do
table.insert(inputTbl, {kind = 'hztl', w=4.5-x, h=.5, x=x+.5;
{kind='img', w=.5,h=.5, img=e.img};
{kind='label', w=3.3,h=.5,x=.2, text=lib.str.capitalize(e.label)};
});
end
end
end
local commitHue=120, commitLabel
if not sel.input then
commitLabel = 'Plan'
fabToUI(0, inputTbl, fab:visualize())
local function pushComputeCostsSw(header, p)
if p.sw.cost then
pushComputeCosts(header, {
cycles = p.sw.cost.cycles;
power = p.powerCost;
ram = p.sw.cost.ram;
})
end
end
pushComputeCostsSw('Schematic', scm)
pushComputeCostsSw('Compiler', state.pgm)
else
commitLabel = 'Commit'
pushComputeCosts('Total', {
cycles = (scm.sw.cost and scm.sw.cost.cycles or 0)
+ (state.pgm.sw.cost and state.pgm.sw.cost.cycles or 0);
power = (scm.powerCost or 0)
+ (state.pgm.powerCost or 0)
+ (fab.cost and fab.cost.power or 0);
ram = (scm.sw.cost and scm.sw.cost.ram or 0)
+ (state.pgm.sw.cost and state.pgm.sw.cost.ram or 0);
})
if fab.time and fab.time.print then
pushCost(0, 'Job Runtime', lib.math.timespec(fab.time.print + scm.speed))
pushCost(.5, 'Print Time', lib.math.timespec(fab.time.print))
pushCost(.5, 'CPU Time', lib.math.timespec(scm.speed + state.pgm.speed))
end
local ok, compileCost = compilerCanPrint(user, state.pgm, scm)
fabToUI(0, inputTbl, compileCost.itemSpec:visualize())
if next(compileCost.unsat) then
local vis = compileCost.unsat:visualize()
for si, s in ipairs(vis) do
s.header = 'Missing ' .. s.header
for ei, e in ipairs(s.list) do
e.label = lib.color(1,.2,.2):fmt(e.label)
end
end
fabToUI(0, inputTbl, vis)
end
if not ok then commitHue = 0 end
end
table.insert(pgmSelector, reqPane)
table.insert(pgmSelector, {kind = 'hztl', w=10,h=1.2;
{kind = 'button', id='back', label = '← Back', w=5,h=1.2};
{kind = 'button', id='commit', label = commitLabel .. ' →', w=5,h=1.2, color={hue=commitHue,sat=0,lum=0}};
})
end
end
return starlit.ui.build {
kind = 'hztl', padding = 0.5; w = 20, h = 10, mode = 'sw';
{kind = 'vert', w = 5, h = 5;
|