Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit) (+3)

Do you pine for diet colas from the 1970s? Indulge yourself with

The TabBar Contraption:


Configure a set of newline-delimited options, and this contraption allows you to make an exclusive selection among them. In concert with showing/hiding other widgets or manipulating the data stored in other widgets, this can be used to create the appearance of "tabbed" UIs. This contraption supports the standard .show, .font, and .locked attributes. You can obtain the list of options with the .options attribute, and the selected tab (by name) with the .value attribute. When a tab is selected, this contraption provides a click[] event with no arguments.

%%WGT0{"w":[{"name":"tabbar","type":"contraption","size":[168,34],"pos":[184,140],"def":"tabbar","widgets":{"o":{"size":[100,7],"pos":[191,0]},"c":{"size":[168,34]},"i":{"size":[100,8],"pos":[191,11]}}}],"d":{"tabbar":{"name":"tabbar","size":[100,100],"resizable":1,"margin":[1,1,1,1],"description":"a tab bar, allowing the user to make an exclusive selection among several choices.","version":1.1,"script":"on get_options_text do o.text end\non set_options_text x do\n o.text:x\n i.interval:0,(count \"\\n\" split o.text)-1\n view[]\nend\non get_options do \"\\n\" split o.text end\non set_options x do set_options_text[\"\\n\" fuse x] x end\non get_value do get_options[][i.value] end\non set_value x do v:get_options[] i.value:sum (range count v)*v=x x view[] end\n\nbf:image[\"%%IMG2AAsABwADAQUABQEBIAUBAQADAQEgBwEBAAEBASAJAQIgCQECIAkBDA==\"] bb:image[\"%%IMG2AAsABwADAQUABQEBIAUBAQADAQEgAQEFIAEBAQABAQEgAQEHIAEBAiABAQcgAQECIAEBByABAQw=\"]\n\non view do\n c.show:card.show\n c.font:card.font\n c.clear[]\n v:get_options[]\n w:c.size[0]/count v\n each x ix in v\n  sel:ix~i.value\n  b:(ix*w),0,(w+ix<-1+count v),c.size[1]\n  c.segment[(bf,bb)[sel] b 5,4,5,2]\n  c.pattern:(1,32)[sel]\n  c.text[x b+(0,1,0,0) \"center\"]\n end\nend\n\non click pos do\n if !card.locked\n  v:get_options[]\n  w:c.size[0]/count v\n  p:get_value[]\n  set_value[v[floor(first pos)/w]]\n  if !p~get_value[] card.event.click end\n end\nend","template":"on click do\n \nend","attributes":{"name":["options_text"],"label":["Options"],"type":["code"]},"widgets":{"o":{"type":"field","size":[100,20],"pos":[123,1],"show":"none","style":"plain","value":"One\nTwo\nThree"},"c":{"type":"canvas","size":[100,100],"pos":[0,0],"locked":1,"volatile":1,"border":0,"scale":1},"i":{"type":"slider","size":[100,25],"pos":[123,32],"show":"none","interval":[0,2]}}}}}
(+3)

Another variation that might be useful for prototyping and documentation-

The scriptViewer Contraption:

A tabbed text field which allows the user to view (or edit!) the script of several widgets on the current card. The "Sources" should be a newline-delimited list of widget names. If "card" or "deck" are specified, the scriptViewer will access the script of the current card or the deck, respectively.

%%WGT0{"w":[{"name":"scriptViewer","type":"contraption","size":[189,106],"pos":[170,144],"def":"scriptViewer","widgets":{"o":{"size":[100,21],"pos":[212,1],"value":"deck\ncard"},"c":{"size":[189,18]},"i":{"size":[100,26],"pos":[212,34],"interval":[0,1]},"scr":{"size":[185,85]}}}],"d":{"scriptViewer":{"name":"scriptViewer","size":[100,100],"resizable":1,"margin":[3,20,3,3],"description":"a tabbed editor for viewing and editing the scripts of one or more widgets on the current card.","version":1,"script":"on get_options_text do o.text end\non set_options_text x do\n o.text:x\n i.interval:0,(count \"\\n\" split o.text)-1\n view[]\nend\non get_options do \"\\n\" split o.text end\non set_options x do set_options_text[\"\\n\" fuse x] x end\non get_value do get_options[][i.value] end\non set_value x do v:get_options[] i.value:sum (range count v)*v=x x view[] end\n\nbf:image[\"%%IMG2AAsABwADAQUABQEBIAUBAQADAQEgBwEBAAEBASAJAQIgCQECIAkBDA==\"] bb:image[\"%%IMG2AAsABwADAQUABQEBIAUBAQADAQEgAQEFIAEBAQABAQEgAQEHIAEBAiABAQcgAQECIAEBByABAQIgAQEHIAEBAQ==\"]\n\non target do\n val:get_value[]\n if val~\"deck\" deck elseif val~\"card\" deck.card else deck.card.widgets[val] end\nend\non change do\n target[].script:scr.text\nend\n\non view do\n c.font:card.font\n c.clear[]\n v:get_options[]\n w:(.7*c.size[0])/count v\n each x ix in v\n  sel:ix~i.value\n  b:(ix*w),0,(w+ix<-1+count v),c.size[1]\n  c.segment[(bf,bb)[sel] b 5,4,5,2]\n  c.pattern:(1,32)[sel]\n  c.text[x b+(0,1,0,0) \"center\"]\n end\n scr.text:target[].script\n scr.locked:card.locked\nend\n\non click pos do\n v:get_options[]\n w:(.7*c.size[0])/count v\n set_value[v[floor(first pos)/w]]\nend","image":"%%IMG2AGQAZAD/AP8A/wD/AP8A/wCqAWUgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAQIgYgECIGIBAiBiAWU=","attributes":{"name":["options_text"],"label":["Sources"],"type":["code"]},"widgets":{"o":{"type":"field","size":[100,20],"pos":[123,1],"show":"none","style":"plain","value":"card"},"c":{"type":"canvas","size":[100,18],"pos":[0,0],"locked":1,"volatile":1,"show":"transparent","border":0,"pattern":32,"scale":1},"i":{"type":"slider","size":[100,25],"pos":[123,32],"show":"none","interval":[0,2]},"scr":{"type":"field","size":[96,79],"pos":[2,19],"volatile":1,"border":0,"scrollbar":1,"style":"code"}}}}}