@rbxts/centurion-ui 2.0.0-rc.1 → 2.0.0-rc.2
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/package.json +2 -2
- package/src/app/header.luau +105 -38
- package/src/app/history.luau +16 -11
- package/src/app/init.luau +23 -13
- package/src/app/suggestions.luau +11 -12
- package/src/components/corner.luau +1 -1
- package/src/components/divider.luau +2 -1
- package/src/components/stroke.luau +2 -1
- package/src/init.luau +1 -0
- package/src/px.luau +19 -11
- package/src/state.luau +6 -5
- package/src/ts/index.d.ts +1 -0
- package/src/types.luau +2 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rbxts/centurion-ui",
|
|
3
3
|
"description": "Terminal UI for the Centurion command framework",
|
|
4
|
-
"version": "2.0.0-rc.
|
|
4
|
+
"version": "2.0.0-rc.2",
|
|
5
5
|
"author": "paradoxuum",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/ts/init.luau",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@rbxts/centurion": "^2.0.0-rc.
|
|
36
|
+
"@rbxts/centurion": "^2.0.0-rc.2"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {}
|
|
39
39
|
}
|
package/src/app/header.luau
CHANGED
|
@@ -9,12 +9,16 @@ local preferred_input = require("../input")
|
|
|
9
9
|
local px = require("../px")
|
|
10
10
|
local state = require("../state")
|
|
11
11
|
local text = require("../components/text")
|
|
12
|
+
local theme = require("../theme")
|
|
12
13
|
local vide = require("../../vide")
|
|
13
14
|
|
|
15
|
+
local create = vide.create
|
|
14
16
|
local show = vide.show
|
|
17
|
+
local source = vide.source
|
|
15
18
|
|
|
16
19
|
type Header = {
|
|
17
20
|
read order: number?,
|
|
21
|
+
read on_clear: () -> (),
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
-- KeyCode names that aren't what's printed on the key
|
|
@@ -37,21 +41,62 @@ local function key_label(key: Enum.KeyCode): string
|
|
|
37
41
|
return key_labels[key.Name] or key.Name
|
|
38
42
|
end
|
|
39
43
|
|
|
44
|
+
local function clear_button(props: { order: number, on_clear: () -> () })
|
|
45
|
+
local hovered = source(false)
|
|
46
|
+
|
|
47
|
+
return create "TextButton" {
|
|
48
|
+
AutomaticSize = Enum.AutomaticSize.XY,
|
|
49
|
+
AutoButtonColor = false,
|
|
50
|
+
BackgroundTransparency = 1,
|
|
51
|
+
LayoutOrder = props.order,
|
|
52
|
+
Text = "",
|
|
53
|
+
|
|
54
|
+
Activated = props.on_clear,
|
|
55
|
+
MouseEnter = function()
|
|
56
|
+
hovered(true)
|
|
57
|
+
end,
|
|
58
|
+
MouseLeave = function()
|
|
59
|
+
hovered(false)
|
|
60
|
+
end,
|
|
61
|
+
|
|
62
|
+
text {
|
|
63
|
+
auto = "XY",
|
|
64
|
+
text = "Clear",
|
|
65
|
+
text_size = px(state.subtext_size),
|
|
66
|
+
text_style = function()
|
|
67
|
+
return if hovered() then "highlight" else "subtext"
|
|
68
|
+
end,
|
|
69
|
+
weight = Enum.FontWeight.Bold,
|
|
70
|
+
},
|
|
71
|
+
}
|
|
72
|
+
end
|
|
73
|
+
|
|
40
74
|
local function header(props: Header)
|
|
41
75
|
local input = preferred_input()
|
|
42
76
|
|
|
77
|
+
local function show_clear()
|
|
78
|
+
return state.clear_button() and #state.logs() > 0
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
local function show_hint()
|
|
82
|
+
if input() == Enum.PreferredInput.Gamepad then
|
|
83
|
+
return true
|
|
84
|
+
end
|
|
85
|
+
return input() == Enum.PreferredInput.KeyboardAndMouse and #state.activation_keys() > 0
|
|
86
|
+
end
|
|
87
|
+
|
|
43
88
|
return container {
|
|
44
|
-
size = px(UDim2.new(1, 0, 0,
|
|
89
|
+
size = px(UDim2.new(1, 0, 0, 23)),
|
|
45
90
|
order = props.order,
|
|
46
91
|
|
|
47
|
-
padding { x = px(
|
|
92
|
+
padding { x = px(8) },
|
|
48
93
|
flex():column():vertical("center"):between("horizontal"),
|
|
49
94
|
|
|
50
95
|
container {
|
|
51
96
|
auto = "XY",
|
|
52
97
|
order = 1,
|
|
53
98
|
|
|
54
|
-
flex():column():vertical("center"):gap(
|
|
99
|
+
flex():column():vertical("center"):gap(5),
|
|
55
100
|
|
|
56
101
|
image {
|
|
57
102
|
image = state.icon,
|
|
@@ -77,51 +122,73 @@ local function header(props: Header)
|
|
|
77
122
|
},
|
|
78
123
|
},
|
|
79
124
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
end
|
|
84
|
-
return input() == Enum.PreferredInput.KeyboardAndMouse and #state.activation_keys() > 0
|
|
85
|
-
end, function()
|
|
86
|
-
return container {
|
|
87
|
-
auto = "XY",
|
|
88
|
-
order = 2,
|
|
125
|
+
container {
|
|
126
|
+
auto = "XY",
|
|
127
|
+
order = 2,
|
|
89
128
|
|
|
90
|
-
|
|
129
|
+
flex():column():vertical("center"):gap(8),
|
|
91
130
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
131
|
+
-- only shown while there's something to clear
|
|
132
|
+
show(show_clear, function()
|
|
133
|
+
return clear_button { order = 1, on_clear = props.on_clear }
|
|
134
|
+
end),
|
|
135
|
+
|
|
136
|
+
-- vertical rule between the clear button and the close hint
|
|
137
|
+
show(function()
|
|
138
|
+
return show_clear() and show_hint()
|
|
139
|
+
end, function()
|
|
140
|
+
return background {
|
|
141
|
+
order = 2,
|
|
142
|
+
size = px(function()
|
|
143
|
+
return UDim2.fromOffset(1, state.subtext_size())
|
|
144
|
+
end),
|
|
95
145
|
color = function()
|
|
96
|
-
return state.theme()
|
|
146
|
+
return theme.border(state.theme())
|
|
97
147
|
end,
|
|
148
|
+
}
|
|
149
|
+
end),
|
|
98
150
|
|
|
99
|
-
|
|
100
|
-
|
|
151
|
+
show(show_hint, function()
|
|
152
|
+
return container {
|
|
153
|
+
auto = "XY",
|
|
154
|
+
order = 3,
|
|
101
155
|
|
|
102
|
-
|
|
156
|
+
flex():column():vertical("center"):gap(4),
|
|
157
|
+
|
|
158
|
+
background {
|
|
103
159
|
auto = "XY",
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return button_name(Enum.KeyCode.ButtonB)
|
|
108
|
-
end
|
|
109
|
-
return key_label(state.activation_keys()[1])
|
|
160
|
+
order = 1,
|
|
161
|
+
color = function()
|
|
162
|
+
return state.theme().surface
|
|
110
163
|
end,
|
|
111
|
-
|
|
112
|
-
|
|
164
|
+
|
|
165
|
+
corner(px(4)),
|
|
166
|
+
padding { x = px(4), y = px(1) },
|
|
167
|
+
|
|
168
|
+
text {
|
|
169
|
+
auto = "XY",
|
|
170
|
+
text = function()
|
|
171
|
+
-- gamepads close with B rather than an activation key
|
|
172
|
+
if input() == Enum.PreferredInput.Gamepad then
|
|
173
|
+
return button_name(Enum.KeyCode.ButtonB)
|
|
174
|
+
end
|
|
175
|
+
return key_label(state.activation_keys()[1])
|
|
176
|
+
end,
|
|
177
|
+
text_size = px(state.subtext_size),
|
|
178
|
+
weight = Enum.FontWeight.Bold,
|
|
179
|
+
},
|
|
113
180
|
},
|
|
114
|
-
},
|
|
115
181
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
182
|
+
text {
|
|
183
|
+
auto = "XY",
|
|
184
|
+
order = 2,
|
|
185
|
+
text = "to close",
|
|
186
|
+
text_size = px(state.subtext_size),
|
|
187
|
+
text_style = "subtext",
|
|
188
|
+
},
|
|
189
|
+
}
|
|
190
|
+
end),
|
|
191
|
+
},
|
|
125
192
|
}
|
|
126
193
|
end
|
|
127
194
|
|
package/src/app/history.luau
CHANGED
|
@@ -27,9 +27,10 @@ type History = {
|
|
|
27
27
|
read order: number?,
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
local line_height =
|
|
30
|
+
local line_height = 23
|
|
31
|
+
local top_padding = 4
|
|
31
32
|
-- width of the status glyph column, which the message is indented by
|
|
32
|
-
local gutter =
|
|
33
|
+
local gutter = 12
|
|
33
34
|
|
|
34
35
|
local function entry(value: () -> types.Log, i: number, on_select: (command: string) -> ())
|
|
35
36
|
local hovered = source(false)
|
|
@@ -65,15 +66,15 @@ local function entry(value: () -> types.Log, i: number, on_select: (command: str
|
|
|
65
66
|
return if success() then 1 else 0.88 + 0.12 * enter()
|
|
66
67
|
end,
|
|
67
68
|
|
|
68
|
-
corner(px(
|
|
69
|
+
corner(px(4)),
|
|
69
70
|
padding {
|
|
70
71
|
left = px(function()
|
|
71
|
-
return
|
|
72
|
+
return 5 + 12 * enter()
|
|
72
73
|
end),
|
|
73
|
-
right = px(
|
|
74
|
-
y = px(
|
|
74
|
+
right = px(5),
|
|
75
|
+
y = px(4),
|
|
75
76
|
},
|
|
76
|
-
flex():row():fill("horizontal"):gap(
|
|
77
|
+
flex():row():fill("horizontal"):gap(1),
|
|
77
78
|
|
|
78
79
|
-- clicking the header puts the command back into the input
|
|
79
80
|
create "TextButton" {
|
|
@@ -192,10 +193,14 @@ local function history(props: History)
|
|
|
192
193
|
ScrollingDirection = Enum.ScrollingDirection.Y,
|
|
193
194
|
LayoutOrder = props.order,
|
|
194
195
|
Size = spring(function()
|
|
195
|
-
|
|
196
|
+
local height = content_height()
|
|
197
|
+
if height == 0 then
|
|
198
|
+
return UDim2.new()
|
|
199
|
+
end
|
|
200
|
+
return UDim2.fromOffset(0, math.min(height, max_height()) + px.convert(top_padding))
|
|
196
201
|
end, 0.1),
|
|
197
202
|
|
|
198
|
-
ScrollBarThickness = px(
|
|
203
|
+
ScrollBarThickness = px(3),
|
|
199
204
|
ScrollBarImageColor3 = function()
|
|
200
205
|
return state.theme().subtext
|
|
201
206
|
end,
|
|
@@ -211,12 +216,12 @@ local function history(props: History)
|
|
|
211
216
|
hovered(false)
|
|
212
217
|
end,
|
|
213
218
|
|
|
214
|
-
padding { x = px(4) },
|
|
219
|
+
padding { x = px(4), top = px(top_padding) },
|
|
215
220
|
|
|
216
221
|
create "UIListLayout" {
|
|
217
222
|
HorizontalFlex = Enum.UIFlexAlignment.Fill,
|
|
218
223
|
SortOrder = Enum.SortOrder.LayoutOrder,
|
|
219
|
-
Padding = px(UDim.new(0,
|
|
224
|
+
Padding = px(UDim.new(0, top_padding)),
|
|
220
225
|
|
|
221
226
|
changed("AbsoluteContentSize", function(size: Vector2)
|
|
222
227
|
content_height(size.Y)
|
package/src/app/init.luau
CHANGED
|
@@ -452,11 +452,11 @@ local function app()
|
|
|
452
452
|
end,
|
|
453
453
|
transparency = state.transparency,
|
|
454
454
|
|
|
455
|
-
corner(px(
|
|
455
|
+
corner(px(4)),
|
|
456
456
|
padding {
|
|
457
|
-
y = px(
|
|
457
|
+
y = px(5),
|
|
458
458
|
left = px(function()
|
|
459
|
-
return
|
|
459
|
+
return 25 + shake()
|
|
460
460
|
end),
|
|
461
461
|
right = px(function()
|
|
462
462
|
return 10 - shake()
|
|
@@ -486,7 +486,7 @@ local function app()
|
|
|
486
486
|
|
|
487
487
|
{
|
|
488
488
|
AnchorPoint = Vector2.new(0, 0.5),
|
|
489
|
-
Position = px(UDim2.new(0, -
|
|
489
|
+
Position = px(UDim2.new(0, -15, 0.5, 0)),
|
|
490
490
|
},
|
|
491
491
|
},
|
|
492
492
|
|
|
@@ -545,6 +545,10 @@ local function app()
|
|
|
545
545
|
local selected = suggested[selected_suggestion()]
|
|
546
546
|
value = autofill(raw_text(), selected, true)
|
|
547
547
|
end
|
|
548
|
+
|
|
549
|
+
if value ~= raw_text() then
|
|
550
|
+
cmd_history_index = 0
|
|
551
|
+
end
|
|
548
552
|
raw_text(value)
|
|
549
553
|
end,
|
|
550
554
|
|
|
@@ -595,16 +599,16 @@ local function app()
|
|
|
595
599
|
auto = "Y",
|
|
596
600
|
anchor = state.anchor,
|
|
597
601
|
position = function()
|
|
598
|
-
local offset = px.convert((reveal() - 1) *
|
|
602
|
+
local offset = px.convert((reveal() - 1) * 8)
|
|
599
603
|
return px.get(state.position) + UDim2.fromOffset(0, offset)
|
|
600
604
|
end,
|
|
601
605
|
size = px(function()
|
|
602
606
|
local w = state.width()
|
|
603
|
-
return UDim2.new(w.Scale,
|
|
607
|
+
return UDim2.new(w.Scale, 1000, 0, 0)
|
|
604
608
|
end),
|
|
605
609
|
|
|
606
|
-
padding(px(
|
|
607
|
-
flex():row():gap(
|
|
610
|
+
padding(px(8)),
|
|
611
|
+
flex():row():gap(1),
|
|
608
612
|
|
|
609
613
|
{
|
|
610
614
|
Visible = function()
|
|
@@ -622,7 +626,7 @@ local function app()
|
|
|
622
626
|
end,
|
|
623
627
|
transparency = state.transparency,
|
|
624
628
|
|
|
625
|
-
corner(px(
|
|
629
|
+
corner(px(8)),
|
|
626
630
|
stroke {
|
|
627
631
|
color = function()
|
|
628
632
|
return theme.border(state.theme())
|
|
@@ -631,7 +635,13 @@ local function app()
|
|
|
631
635
|
flex():row():fill("horizontal"),
|
|
632
636
|
catch_hover(),
|
|
633
637
|
|
|
634
|
-
header {
|
|
638
|
+
header {
|
|
639
|
+
order = 1,
|
|
640
|
+
on_clear = function()
|
|
641
|
+
state.logs({})
|
|
642
|
+
refocus()
|
|
643
|
+
end,
|
|
644
|
+
},
|
|
635
645
|
divider { order = 2 },
|
|
636
646
|
|
|
637
647
|
history {
|
|
@@ -651,7 +661,7 @@ local function app()
|
|
|
651
661
|
size = UDim2.fromScale(1, 0),
|
|
652
662
|
order = 4,
|
|
653
663
|
|
|
654
|
-
padding(px(
|
|
664
|
+
padding(px(5)),
|
|
655
665
|
|
|
656
666
|
input_field(),
|
|
657
667
|
},
|
|
@@ -666,9 +676,9 @@ local function app()
|
|
|
666
676
|
order = 2,
|
|
667
677
|
|
|
668
678
|
padding {
|
|
669
|
-
left = px(
|
|
679
|
+
left = px(5),
|
|
670
680
|
top = px(function()
|
|
671
|
-
return
|
|
681
|
+
return 4 * pop()
|
|
672
682
|
end),
|
|
673
683
|
},
|
|
674
684
|
|
package/src/app/suggestions.luau
CHANGED
|
@@ -55,7 +55,7 @@ local function pill(props: { text: () -> string, color: () -> Color3, order: num
|
|
|
55
55
|
color = props.color,
|
|
56
56
|
|
|
57
57
|
corner(px(4)),
|
|
58
|
-
padding { x = px(
|
|
58
|
+
padding { x = px(4), y = px(2) },
|
|
59
59
|
|
|
60
60
|
text {
|
|
61
61
|
auto = "XY",
|
|
@@ -101,7 +101,7 @@ local function suggestion_row(value: () -> types.AnalysisSuggestion, i: number,
|
|
|
101
101
|
end,
|
|
102
102
|
|
|
103
103
|
corner(px(4)),
|
|
104
|
-
padding { x = px(
|
|
104
|
+
padding { x = px(5), y = px(3) },
|
|
105
105
|
flex():column():vertical("center"):between("horizontal"),
|
|
106
106
|
|
|
107
107
|
container {
|
|
@@ -112,7 +112,7 @@ local function suggestion_row(value: () -> types.AnalysisSuggestion, i: number,
|
|
|
112
112
|
|
|
113
113
|
-- marks the suggestion Tab will complete
|
|
114
114
|
text {
|
|
115
|
-
size = px(UDim2.fromOffset(
|
|
115
|
+
size = px(UDim2.fromOffset(12, 0)),
|
|
116
116
|
auto = "Y",
|
|
117
117
|
order = 1,
|
|
118
118
|
text = ">",
|
|
@@ -165,8 +165,7 @@ local function suggestion_row(value: () -> types.AnalysisSuggestion, i: number,
|
|
|
165
165
|
text_style = "subtext",
|
|
166
166
|
xalignment = Enum.TextXAlignment.Right,
|
|
167
167
|
|
|
168
|
-
|
|
169
|
-
padding { left = px(32) },
|
|
168
|
+
padding { left = px(28) },
|
|
170
169
|
}
|
|
171
170
|
end),
|
|
172
171
|
}
|
|
@@ -220,7 +219,7 @@ local function suggestions(props: Suggestions)
|
|
|
220
219
|
end,
|
|
221
220
|
transparency = state.transparency,
|
|
222
221
|
|
|
223
|
-
corner(px(
|
|
222
|
+
corner(px(6)),
|
|
224
223
|
stroke {
|
|
225
224
|
color = function()
|
|
226
225
|
return theme.border(state.theme())
|
|
@@ -228,7 +227,7 @@ local function suggestions(props: Suggestions)
|
|
|
228
227
|
},
|
|
229
228
|
create "UISizeConstraint" {
|
|
230
229
|
MinSize = function()
|
|
231
|
-
return Vector2.new(px.convert(
|
|
230
|
+
return Vector2.new(px.convert(213), 0)
|
|
232
231
|
end,
|
|
233
232
|
},
|
|
234
233
|
flex():row():fill("horizontal"),
|
|
@@ -239,7 +238,7 @@ local function suggestions(props: Suggestions)
|
|
|
239
238
|
auto = "XY",
|
|
240
239
|
order = 1,
|
|
241
240
|
|
|
242
|
-
padding { x = px(
|
|
241
|
+
padding { x = px(8), y = px(5) },
|
|
243
242
|
flex():column():vertical("center"):gap(8),
|
|
244
243
|
|
|
245
244
|
pill {
|
|
@@ -271,8 +270,8 @@ local function suggestions(props: Suggestions)
|
|
|
271
270
|
auto = "XY",
|
|
272
271
|
order = 2,
|
|
273
272
|
|
|
274
|
-
padding { x = px(
|
|
275
|
-
flex():row():gap(
|
|
273
|
+
padding { x = px(8), y = px(5) },
|
|
274
|
+
flex():row():gap(4),
|
|
276
275
|
|
|
277
276
|
text {
|
|
278
277
|
auto = "XY",
|
|
@@ -358,7 +357,7 @@ local function suggestions(props: Suggestions)
|
|
|
358
357
|
auto = "XY",
|
|
359
358
|
order = 4,
|
|
360
359
|
|
|
361
|
-
padding(px(
|
|
360
|
+
padding(px(3)),
|
|
362
361
|
flex():row():fill("horizontal"),
|
|
363
362
|
|
|
364
363
|
indexes(function()
|
|
@@ -379,7 +378,7 @@ local function suggestions(props: Suggestions)
|
|
|
379
378
|
auto = "XY",
|
|
380
379
|
order = 6,
|
|
381
380
|
|
|
382
|
-
padding { x = px(
|
|
381
|
+
padding { x = px(8), y = px(4) },
|
|
383
382
|
|
|
384
383
|
text {
|
|
385
384
|
auto = "XY",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
local fade = require("../fade")
|
|
2
|
+
local px = require("../px")
|
|
2
3
|
local state = require("../state")
|
|
3
4
|
local theme = require("../theme")
|
|
4
5
|
local vide = require("../../vide")
|
|
@@ -16,7 +17,7 @@ type Divider = {
|
|
|
16
17
|
-- automatically sized parent grow to fill its own parent
|
|
17
18
|
return function(props: Divider?)
|
|
18
19
|
return create "Frame" {
|
|
19
|
-
Size = UDim2.fromOffset(0, 1),
|
|
20
|
+
Size = px(UDim2.fromOffset(0, 1)),
|
|
20
21
|
BackgroundColor3 = function()
|
|
21
22
|
return theme.border(state.theme())
|
|
22
23
|
end,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
local fade = require("../fade")
|
|
2
|
+
local px = require("../px")
|
|
2
3
|
local vide = require("../../vide")
|
|
3
4
|
|
|
4
5
|
local create = vide.create
|
|
@@ -14,7 +15,7 @@ return function(props: Stroke)
|
|
|
14
15
|
return create "UIStroke" {
|
|
15
16
|
ApplyStrokeMode = Enum.ApplyStrokeMode.Border,
|
|
16
17
|
Color = props.color,
|
|
17
|
-
Thickness = props.thickness or 1,
|
|
18
|
+
Thickness = px(props.thickness or 1),
|
|
18
19
|
Transparency = fade.fade(props.transparency),
|
|
19
20
|
}
|
|
20
21
|
end
|
package/src/init.luau
CHANGED
|
@@ -53,6 +53,7 @@ local function configure(options: types.OptionsPartial)
|
|
|
53
53
|
set_opt(state.width, options.width)
|
|
54
54
|
|
|
55
55
|
set_opt(state.max_suggestions, options.max_suggestions)
|
|
56
|
+
set_opt(state.clear_button, options.clear_button)
|
|
56
57
|
set_opt(state.format_date, options.format_date)
|
|
57
58
|
end
|
|
58
59
|
|
package/src/px.luau
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
local vide = require("../vide")
|
|
2
2
|
|
|
3
|
+
local effect = vide.effect
|
|
3
4
|
local source = vide.source
|
|
4
5
|
local read = vide.read
|
|
5
6
|
local cleanup = vide.cleanup
|
|
6
7
|
|
|
7
8
|
export type Mode = "normal" | "even" | "scale" | "floor" | "ceil"
|
|
8
9
|
|
|
9
|
-
local BASE_RESOLUTION = Vector2.new(
|
|
10
|
-
|
|
10
|
+
local BASE_RESOLUTION = Vector2.new(1280, 720)
|
|
11
|
+
const MIN_SCALE = 0.5
|
|
11
12
|
local DOMINANT_AXIS = 0.5
|
|
12
13
|
|
|
13
14
|
local scale = source(1)
|
|
14
15
|
|
|
16
|
+
local function modify_scale(scale_value: number): number
|
|
17
|
+
return math.max(scale_value, MIN_SCALE)
|
|
18
|
+
end
|
|
19
|
+
|
|
15
20
|
local function convert(value: number, mode: Mode?): number
|
|
16
21
|
return if mode == "even"
|
|
17
22
|
then math.round(value * scale() * 0.5) * 2
|
|
@@ -47,18 +52,21 @@ local function px<T>(value: T | () -> T, mode: Mode? | () -> Mode?): () -> T
|
|
|
47
52
|
end
|
|
48
53
|
|
|
49
54
|
local function mount()
|
|
50
|
-
local
|
|
55
|
+
local viewport_size = source(Vector2.new(0, 0))
|
|
51
56
|
|
|
52
|
-
|
|
53
|
-
local
|
|
54
|
-
local
|
|
55
|
-
local
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
effect(function()
|
|
58
|
+
local viewport = viewport_size()
|
|
59
|
+
local scaleX = math.log(viewport.X / BASE_RESOLUTION.X, 2)
|
|
60
|
+
local scaleY = math.log(viewport.Y / BASE_RESOLUTION.Y, 2)
|
|
61
|
+
|
|
62
|
+
scale(modify_scale(2 ^ math.lerp(scaleX, scaleY, DOMINANT_AXIS)))
|
|
63
|
+
end)
|
|
58
64
|
|
|
59
|
-
|
|
65
|
+
cleanup(workspace.CurrentCamera:GetPropertyChangedSignal("ViewportSize"):Connect(function()
|
|
66
|
+
viewport_size(workspace.CurrentCamera.ViewportSize)
|
|
67
|
+
end))
|
|
60
68
|
|
|
61
|
-
|
|
69
|
+
viewport_size(workspace.CurrentCamera.ViewportSize)
|
|
62
70
|
end
|
|
63
71
|
|
|
64
72
|
return setmetatable({ mount = mount, convert = convert, get = px_raw }, {
|
package/src/state.luau
CHANGED
|
@@ -23,11 +23,12 @@ return {
|
|
|
23
23
|
return `<b>{dateParts[1]}</b> {dateParts[2]}`
|
|
24
24
|
end),
|
|
25
25
|
max_suggestions = source(5),
|
|
26
|
+
clear_button = source(false),
|
|
26
27
|
|
|
27
|
-
text_size = source(
|
|
28
|
-
subtext_size = source(
|
|
28
|
+
text_size = source(19),
|
|
29
|
+
subtext_size = source(16),
|
|
29
30
|
|
|
30
|
-
anchor = source(Vector2.
|
|
31
|
-
position = source(UDim2.new()),
|
|
32
|
-
width = source(UDim.new(
|
|
31
|
+
anchor = source(Vector2.new(0.5, 0)),
|
|
32
|
+
position = source(UDim2.new(0.5, 0, 0, 0)),
|
|
33
|
+
width = source(UDim.new(0, 1200)),
|
|
33
34
|
}
|
package/src/ts/index.d.ts
CHANGED
package/src/types.luau
CHANGED
|
@@ -14,6 +14,7 @@ export type Options = {
|
|
|
14
14
|
transparency: number,
|
|
15
15
|
format_date: (log: Log) -> string,
|
|
16
16
|
max_suggestions: number,
|
|
17
|
+
clear_button: boolean,
|
|
17
18
|
|
|
18
19
|
text_size: number,
|
|
19
20
|
subtext_size: number,
|
|
@@ -32,6 +33,7 @@ export type OptionsPartial = {
|
|
|
32
33
|
transparency: number?,
|
|
33
34
|
format_date: ((log: Log) -> string)?,
|
|
34
35
|
max_suggestions: number?,
|
|
36
|
+
clear_button: boolean?,
|
|
35
37
|
|
|
36
38
|
text_size: number?,
|
|
37
39
|
subtext_size: number?,
|