sci2-ts 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/lib/996.sc +46 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ All notable changes to this project. Versions follow [Semantic Versioning](https
|
|
|
4
4
|
and the entries are generated from commit messages
|
|
5
5
|
([Conventional Commits](https://www.conventionalcommits.org/)) when a release is made.
|
|
6
6
|
|
|
7
|
+
## [0.11.0](https://github.com/rlueder/sci-ts/compare/v0.10.0...v0.11.0) (2026-10-02)
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
* **lib:** menus as one framed box, and text boxes that sit on the bottom of the screen ([#13](https://github.com/rlueder/sci-ts/issues/13)) ([83cf03d](https://github.com/rlueder/sci-ts/commit/83cf03d0bb4e044d24cbff769a102294e3a66a03))
|
|
12
|
+
|
|
7
13
|
## [0.10.0](https://github.com/rlueder/sci-ts/compare/v0.9.0...v0.10.0) (2026-10-02)
|
|
8
14
|
|
|
9
15
|
### Added
|
package/lib/996.sc
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
;; A box of text over the room: drawn by the interpreter into a bitmap, shown as a screen
|
|
23
23
|
;; item in the UI plane. Set text (and width, x, y), then init; it's as tall as the text
|
|
24
24
|
;; unless height is set. Font, colours and frame come from the textStyle unless set here.
|
|
25
|
+
;; With bottom set, y is worked out so the box ends there: it grows upwards with the text.
|
|
25
26
|
(class TextItem of Obj
|
|
26
27
|
(properties
|
|
27
28
|
x 0 y 0 z 0
|
|
@@ -40,7 +41,8 @@
|
|
|
40
41
|
frame -2 ; -1: none
|
|
41
42
|
textLeft 0 textTop 0 textRight -1 textBottom -1
|
|
42
43
|
width 200
|
|
43
|
-
height 0
|
|
44
|
+
height 0
|
|
45
|
+
bottom -1) ; -1: placed at y
|
|
44
46
|
|
|
45
47
|
(method (init &tmp r m padL padT padR padB)
|
|
46
48
|
(if (== font -1) (= font (textStyle font?)))
|
|
@@ -65,6 +67,7 @@
|
|
|
65
67
|
(= textTop padT)
|
|
66
68
|
(= textRight (- width (+ padR 1)))
|
|
67
69
|
(= textBottom (- height (+ padB 1)))
|
|
70
|
+
(if (!= bottom -1) (= y (- bottom height)))
|
|
68
71
|
(= plane uiPlane)
|
|
69
72
|
(= bitmap (CreateTextBitmap 0 width height self))
|
|
70
73
|
(if (!= frame -1) (self drawFrame:))
|
|
@@ -111,7 +114,7 @@
|
|
|
111
114
|
noun 0 verb 0 cond 0 seq 0
|
|
112
115
|
font -1 ; -1: the textStyle's
|
|
113
116
|
x -1 ; -1: centred
|
|
114
|
-
y 16
|
|
117
|
+
y 16 ; below 0: that far above the bottom of the screen, growing upwards
|
|
115
118
|
width 220)
|
|
116
119
|
|
|
117
120
|
(method (say txt whoCares)
|
|
@@ -128,7 +131,8 @@
|
|
|
128
131
|
font: font
|
|
129
132
|
width: width
|
|
130
133
|
x: (if (== x -1) (/ (- SCREEN_WIDTH width) 2) else x)
|
|
131
|
-
y: y
|
|
134
|
+
y: (if (< y 0) 0 else y)
|
|
135
|
+
bottom: (if (< y 0) (+ SCREEN_HEIGHT y) else -1)
|
|
132
136
|
yourself:))
|
|
133
137
|
(box init:))
|
|
134
138
|
(= talking self)
|
|
@@ -294,25 +298,53 @@
|
|
|
294
298
|
(String ARRAY_FREE text)
|
|
295
299
|
(super dispose:)))
|
|
296
300
|
|
|
297
|
-
;; Choices
|
|
298
|
-
;; gets every click (it's the `dialog`). The caller
|
|
301
|
+
;; Choices one under another in a box (the textStyle's frame around them all); the first
|
|
302
|
+
;; click on one ends it. While it's open it gets every click (it's the `dialog`). The caller
|
|
303
|
+
;; hears the choice by `choose: value`.
|
|
299
304
|
(class Menu of Obj
|
|
300
305
|
(properties
|
|
301
306
|
items 0
|
|
302
307
|
caller 0
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
308
|
+
panel 0
|
|
309
|
+
y 20 ; the top of the box
|
|
310
|
+
width 240
|
|
311
|
+
next 0) ; where the next choice goes
|
|
312
|
+
|
|
313
|
+
(method (add v txt &tmp item f)
|
|
314
|
+
(= f (textStyle frame?))
|
|
315
|
+
(if (not items)
|
|
316
|
+
(= items (List new:))
|
|
317
|
+
(= next (+ y (if (!= f -1) (CelHigh f 0 4) else 1))))
|
|
318
|
+
(= item
|
|
319
|
+
((MenuItem new:)
|
|
320
|
+
value: v
|
|
321
|
+
text: txt
|
|
322
|
+
frame: -1
|
|
323
|
+
borderColor: -1
|
|
324
|
+
width: (- width (if (!= f -1) (+ (CelWide f 0 6) (CelWide f 0 7)) else 2))
|
|
325
|
+
x: (+ (/ (- SCREEN_WIDTH width) 2) (if (!= f -1) (CelWide f 0 6) else 1))
|
|
326
|
+
y: next
|
|
327
|
+
yourself:))
|
|
309
328
|
(item init:)
|
|
310
|
-
(+=
|
|
329
|
+
(+= next (item height?))
|
|
311
330
|
(items add: item)
|
|
312
331
|
(return self))
|
|
313
332
|
|
|
314
|
-
|
|
333
|
+
;; The box behind the choices, then it waits for one.
|
|
334
|
+
(method (show whoCares &tmp f)
|
|
335
|
+
(= f (textStyle frame?))
|
|
315
336
|
(= caller whoCares)
|
|
337
|
+
(if items
|
|
338
|
+
(= panel
|
|
339
|
+
((TextItem new:)
|
|
340
|
+
text: ""
|
|
341
|
+
x: (/ (- SCREEN_WIDTH width) 2)
|
|
342
|
+
y: y
|
|
343
|
+
width: width
|
|
344
|
+
height: (+ (- next y) (if (!= f -1) (CelHigh f 0 5) else 1))
|
|
345
|
+
priority: 99
|
|
346
|
+
yourself:))
|
|
347
|
+
(panel init:))
|
|
316
348
|
(= dialog self))
|
|
317
349
|
|
|
318
350
|
(method (handleEvent event &tmp item v c)
|
|
@@ -336,6 +368,7 @@
|
|
|
336
368
|
(items eachElementDo: #dispose)
|
|
337
369
|
(items dispose:)
|
|
338
370
|
(= items 0))
|
|
371
|
+
(if panel (panel dispose:) (= panel 0))
|
|
339
372
|
(super dispose:)))
|
|
340
373
|
|
|
341
374
|
;; A conversation with something: talking to it opens a menu of topics, choosing one says
|