Differences From
Artifact [16bf595c8c]:
131 131 return climg('', 'starlit-ui-button-sw.png') ..
132 132 climg(':hovered', 'starlit-ui-button-sw-hover.png') ..
133 133 climg(':pressed', 'starlit-ui-button-sw-press.png')
134 134 end
135 135 local function widget(...)
136 136 table.insert(lines, string.format(...))
137 137 end
138 + local specializedTooltip = false
138 139 if def.kind == 'vert' then
139 140 for _, w in ipairs(def) do
140 141 local src, st = starlit.ui.build(w, state)
141 142 widget('container[%s,%s]%scontainer_end[]', state.x, state.y, src)
142 143 state.y=state.y + state.spacing + st.h
143 144 state.w = math.max(state.w, st.w)
144 145 end
146 + state.y = state.y - state.spacing
145 147 state.w = state.w + state.padding
146 148 state.h = state.y + state.padding/2
147 149 elseif def.kind == 'hztl' then
148 150 for _, w in ipairs(def) do
149 151 local src, st = starlit.ui.build(w, state)
150 152 widget('container[%s,%s]%scontainer_end[]', state.x, state.y, src)
151 153 -- TODO alignments
................................................................................
195 197 def.id)
196 198 end
197 199 state.w = state.w + state.padding
198 200 state.h = state.h + state.padding/2
199 201 elseif def.kind == 'list' then
200 202 local slotTypes = {
201 203 plain = {hue = 200, sat = -.1, lum = 0};
202 - element = {hue = 20, sat = -.3, lum = 0};
204 +-- element = {hue = 20, sat = -.3, lum = 0};
203 205 chip = {hue = 0, sat = -1, lum = 0};
204 - psi = {hue = 300, sat = 0, lum = 0};
206 +-- psi = {hue = 300, sat = 0, lum = 0};
205 207 power = {hue = 50, sat = 0, lum = .2};
206 208 }
207 209 local img
208 210 if state.mode == 'hw' then
209 211 img = lib.image('starlit-ui-slot-physical.png');
210 212 else
211 213 img = lib.image('starlit-ui-slot.png'):shift(slotTypes[def.listContent or 'plain']);
212 214 end
213 215 local spac = state.spacing
216 + local target = def.target
217 + if not target and def.node then
218 + target=string.format('nodemeta:%s,%s,%s', def.node.x,def.node.y,def.node.z)
219 + end
214 220 widget('style_type[list;spacing=%s,%s]',spac,spac)
215 221 assert(def.w and def.h, 'ui-lists require a fixed size')
216 222 for lx = 0, def.w-1 do
217 223 for ly = 0, def.h-1 do
218 224 local ox, oy = state.x + lx*(1+spac), state.y + ly*(1+spac)
219 225 table.insert(lines, string.format('image[%s,%s;1.1,1.1;%s]', ox-0.05,oy-0.05, img:render()))
220 226 end end
221 227 table.insert(lines, string.format('listcolors[#00000000;#ffffff10]')) -- FIXME
222 228 table.insert(lines, string.format('list[%s;%s;%s,%s;%s,%s;%s]',
223 - E(def.target), E(def.inv),
229 + E(target), E(def.inv),
224 230 state.x, state.y,
225 231 def.w, def.h,
226 232 def.idx))
227 233 local sm = 1
228 234 state.w = def.w * sm + (spac * (def.w - 1))
229 235 state.h = def.h * sm + (spac * (def.h - 1))
230 236 elseif def.kind == 'contact' then
................................................................................
231 237 if def.color then table.insert(lines, btnColorDef(def.id)) end
232 238 local img = def.img
233 239 local desc
234 240 if def.item then
235 241 img = ItemStack(def.item):get_name()
236 242 desc = ItemStack(def.item):get_description()
237 243 end
244 + desc = def.desc or desc
238 245 widget('%simage_button%s[%s,%s;%s,%s;%s;%s;%s]',
239 246 def.item and 'item_' or '',
240 247 def.close and '_exit' or '',
241 248 state.x, state.y, def.w, def.h,
242 249 E(img), E(def.id), E(def.label or ''))
243 - if desc and not def.desc then
250 + if desc then
244 251 widget('tooltip[%s;%s]', E(def.id), E(desc))
252 + specializedTooltip = true
245 253 end
246 254 elseif def.kind == 'button' then
247 255 if def.color then table.insert(lines, btnColorDef(def.id)) end
248 256 local label = E(def.label or '')
249 257 if state.fg then label = lib.color(state.fg):fmt(label) end
250 258 widget('button%s[%s,%s;%s,%s;%s;%s]',
251 259 def.close and '_exit' or '',
252 260 state.x, state.y, def.w, def.h,
253 261 E(def.id), label)
262 + if def.desc then
263 + widget('tooltip[%s;%s]', E(def.id), E(def.desc))
264 + specializedTooltip = true
265 + end
254 266 elseif def.kind == 'img' then
255 267 widget('%s[%s,%s;%s,%s;%s]',
256 268 def.item and 'item_image' or 'image',
257 269 state.x, state.y, def.w, def.h, E(def.item or def.img))
258 270 elseif def.kind == 'label' then
259 271 local txt = E(def.text)
260 272 if state.fg then txt = lib.color(state.fg):fmt(txt) end
................................................................................
283 295 if def.text then
284 296 widget('hypertext[%s,%s;%s,%s;;%s]',
285 297 state.x, state.y, def.w, def.h,
286 298 string.format('<global halign=center valign=middle color=%s>%s', fg:hex(), E(def.text)))
287 299 end
288 300 end
289 301
290 - if def.desc then
302 + if def.desc and not specializedTooltip then
291 303 local coord
292 304 if def.id then
293 305 coord = E(def.id)
294 306 else
295 307 coord = string.format("%s,%s;%s,%s", state.x, state.y, def.w, def.h)
296 308 end
297 309 widget('tooltip[%s;%s;#000000;#ffffff]', coord, E(def.desc))