· 5 years ago · Mar 01, 2020, 10:22 AM
1--Veranium XI.0.5 | Rewritten by Ivy#1000 Edited by Uniqua
2--[[Keywords:
3 VIn: Veranium Instance.
4 VEn: Veranium Enumerator.
5 VCv: Veranium Color Variant.
6 VCt: Veranium Custom TweenService .
7 VCn: Veranium Constructor.
8 VCf: Veranium Core Function.
9 VLb: Veranium Library.
10
11 Veranium: Class Library | Works Similar To RLua's Instance.new()
12 Vera: Automated UIL | Works Similar To Most UILs Out There
13
14 Note: This Veranium Version is a modified version with improvements to support Himarici.
15]]
16
17local Veranium;
18--Getting Services
19local UserInputService = game:GetService("UserInputService");
20local TweenService = game:GetService("TweenService");
21local TextService = game:GetService("TextService");
22local RunService = game:GetService("RunService");
23local CoreGui = game:GetService("CoreGui");
24local Players = game:GetService("Players");
25local Debris = game:GetService("Debris");
26local Player = Players.LocalPlayer;
27local PlayerGui = Player.PlayerGui;
28local Mouse = Player:GetMouse();
29
30local _PREFIX = "\226\128\139\226\128\139\226\128\139";
31local VeraniumSpace = Instance.new("ScreenGui");
32
33VeraniumSpace.ResetOnSpawn = false
34VeraniumSpace.Name = "VeraniumSpace"
35VeraniumSpace.DisplayOrder = 9e5;
36VeraniumSpace.ZIndexBehavior = Enum.ZIndexBehavior.Sibling;
37pcall(function()
38 VeraniumSpace.Parent = CoreGui;
39end);
40if VeraniumSpace.Parent == nil then
41 VeraniumSpace.Parent = PlayerGui;
42end;
43
44local VLb_CVMath;
45VLb_CVMath = {
46 Map = function(Num, Start1, Stop1, Start2, Stop2)
47 return ((Num-Start1)/(Stop1-Start1))*(Stop2-Start2)+Start2
48 end,
49 MapColor = function(StartColor, EndColor, StartFrame, EndFrame, Frame)
50 local Map = VLb_CVMath.Map
51 return Color3.new(
52 Map(Frame, StartFrame, EndFrame, StartColor.r, EndColor.r),
53 Map(Frame, StartFrame, EndFrame, StartColor.g, EndColor.g),
54 Map(Frame, StartFrame, EndFrame, StartColor.b, EndColor.b)
55 )
56 end,
57 Round = function(Num)
58 local Low = math.floor(Num)
59 local High = math.floor(Num) + 1
60 local LV = -(Low - Num)
61 local HV = High - Num
62 if (HV > LV) then
63 return Low
64 else
65 return High
66 end
67 end
68};
69
70local VCf_IsA;
71local VCf_Destructor;
72local function VCf_SRO_NDX(Value)
73 error("This Object is read-only.");
74end;
75
76local function VCf_SetReadOnly(Value)
77 if type(Value) == "table" then
78 local Meta = getmetatable(Value);
79 if type(Meta) == "table" then
80 Meta.__newindex = VCf_SRO_NDX;
81 elseif Meta == nil then
82 setmetatable(Value, {
83 __newindex = VCf_SRO_NDX,
84 __index = rawget
85 });
86 else
87 error("This table is Protected.");
88 end;
89 elseif type(Value) == "userdata" then
90 local Meta = getmetatable(Value);
91 if type(Meta) == "table" then
92 Meta.__newindex = VCf_SRO_NDX;
93 else
94 error("This userdata is Protected.");
95 end;
96 else
97 error("Value given must be a table/userdata.");
98 end;
99end;
100
101--Enum Library.
102local VEn_Data = {
103 CornerType = {
104 Sharp = "rbxassetid://3457842171",
105 Smooth = "rbxassetid://3457843087",
106 Edged = "rbxassetid://3457843868",
107 None = "",
108 [0] = "rbxassetid://3457842171",
109 [1] = "rbxassetid://3457843087",
110 [2] = "rbxassetid://3457843868",
111 [3] = ""
112 },
113 CheckBoxType = {
114 Sharp = 0,
115 Smooth = 1,
116 Circular = 2,
117 Diamond = 3,
118 None = 4,
119 [0] = 0,
120 [1] = 1,
121 [2] = 2,
122 [3] = 3,
123 [4] = 4
124 },
125 FillBoxType = {
126 Sharp = "rbxassetid://4049002850",
127 Smooth = "rbxassetid://4049766910",
128 Circular = "rbxassetid://4049877539",
129 [0] = "rbxassetid://4049002850",
130 [1] = "rbxassetid://4049766910",
131 [2] = "rbxassetid://4049877539"
132 },
133 NotificationType = {
134 Info = "rbxassetid://4057220511",
135 Error = "rbxassetid://4057319805",
136 None = "",
137 [0] = "rbxassetid://4057220511",
138 [1] = "rbxassetid://4057319805",
139 [2] = ""
140 },
141 MetroLocation = {
142 TopLeft = {
143 AnchorPoint = Vector2.new(0, 0),
144 Position = UDim2.new(0, 0, 0, 0),
145 SizeConstraint = "X",
146 ThicknessConstraint = "Y",
147 BOffsetX = 1,
148 BOffsetY = 1
149 },
150 TopCenter = {
151 AnchorPoint = Vector2.new(0.5, 0),
152 Position = UDim2.new(0.5, 0, 0, 0),
153 SizeConstraint = "X",
154 ThicknessConstraint = "Y",
155 BOffsetX = 0,
156 BOffsetY = 1
157 },
158 TopRight = {
159 AnchorPoint = Vector2.new(1, 0),
160 Position = UDim2.new(1, 0, 0, 0),
161 SizeConstraint = "X",
162 ThicknessConstraint = "Y",
163 BOffsetX = -1,
164 BOffsetY = 1
165 },
166 LeftTop = {
167 AnchorPoint = Vector2.new(0, 0),
168 Position = UDim2.new(0, 0, 0, 0),
169 SizeConstraint = "Y",
170 ThicknessConstraint = "X",
171 BOffsetX = 1,
172 BOffsetY = 1
173 },
174 LeftCenter = {
175 AnchorPoint = Vector2.new(0, 0.5),
176 Position = UDim2.new(0, 0, 0.5, 0),
177 SizeConstraint = "Y",
178 ThicknessConstraint = "X",
179 BOffsetX = 1,
180 BOffsetY = 0
181 },
182 LeftBottom = {
183 AnchorPoint = Vector2.new(0, 1),
184 Position = UDim2.new(0, 0, 1, 0),
185 SizeConstraint = "Y",
186 ThicknessConstraint = "X",
187 BOffsetX = 1,
188 BOffsetY = -1
189 },
190 RightTop = {
191 AnchorPoint = Vector2.new(1, 0),
192 Position = UDim2.new(1, 0, 0, 0),
193 SizeConstraint = "Y",
194 ThicknessConstraint = "X",
195 BOffsetX = -1,
196 BOffsetY = 1
197 },
198 RightCenter = {
199 AnchorPoint = Vector2.new(1, 0.5),
200 Position = UDim2.new(1, 0, 0.5, 0),
201 SizeConstraint = "Y",
202 ThicknessConstraint = "X",
203 BOffsetX = -1,
204 BOffsetY = 0
205 },
206 RightBottom = {
207 AnchorPoint = Vector2.new(1, 1),
208 Position = UDim2.new(1, 0, 1, 0),
209 SizeConstraint = "Y",
210 ThicknessConstraint = "X",
211 BOffsetX = -1,
212 BOffsetY = -1
213 },
214 BottomLeft = {
215 AnchorPoint = Vector2.new(0, 1),
216 Position = UDim2.new(0, 0, 1, 0),
217 SizeConstraint = "X",
218 ThicknessConstraint = "Y",
219 BOffsetX = 1,
220 BOffsetY = -1
221 },
222 BottomCenter = {
223 AnchorPoint = Vector2.new(0.5, 1),
224 Position = UDim2.new(0.5, 0, 1, 0),
225 SizeConstraint = "X",
226 ThicknessConstraint = "Y",
227 BOffsetX = 0,
228 BOffsetY = -1
229 },
230 BottomRight = {
231 AnchorPoint = Vector2.new(1, 1),
232 Position = UDim2.new(1, 0, 1, 0),
233 SizeConstraint = "X",
234 ThicknessConstraint = "Y",
235 BOffsetX = -1,
236 BOffsetY = -1
237 };
238 };
239};
240
241local VEn_References = {};
242local VEn_Meta = {
243 __tostring = function(Proxy)
244 local Meta = VEn_References[Proxy];
245 if typeof(Meta) == "table" then
246 return Meta.___Path;
247 else
248 error("Unable to get the meta of VEnum.");
249 end;
250 end,
251 __index = function(Proxy, Field)
252 local Meta = VEn_References[Proxy];
253 if typeof(Field) ~= "string" then
254 error("Attempt to index VEnum with "..typeof(Field).." (string expected).");
255 end;
256 if typeof(Meta) == "table" then
257 if Meta.___IsLib then
258 return Meta.___Value[Field];
259 else
260 error("This is a VEnum. Not an EnumLibrary.");
261 end;
262 else
263 error("Unable to get the meta of VEnum.");
264 end;
265 end,
266 __newindex = function(Proxy, Field, Value)
267 error("VEnums are read-only ;w;");
268 end,
269 __metatable = "S-Stay from my Metatable! P-Prevert!";--No context uwu
270}
271local function VEn_Create(VEn_Value, VEn_Path, VEn_IsLib, VEn_SubLib)
272 local Proxy = newproxy(true);
273 local Meta = getmetatable(Proxy);
274 --Metadata Setup
275 Meta.___Value = VEn_Value;
276 Meta.___Path = VEn_Path;
277 Meta.___IsLib = VEn_IsLib;
278 Meta.___SubLib = VEn_SubLib;
279 --Metamethod Setup
280 Meta.__tostring = VEn_Meta.__tostring;
281 Meta.__index = VEn_Meta.__index;
282 Meta.__newindex = VEn_Meta.__newindex;
283 Meta.__metatable = VEn_Meta.__metatable;
284 --Linking Proxy To Meta
285 VEn_References[Proxy] = Meta;
286 return Proxy;
287end
288
289--Initial Library
290local function VCf_GetEnumValue(Proxy)
291 return VEn_References[Proxy].___Value;
292end
293local function VCf_IsEnum(Proxy)
294 return (VEn_References[Proxy] ~= nil);
295end
296local function VCf_GetEnumMeta(Proxy)
297 return VEn_References[Proxy];
298end
299local function VCf_GetEnumLValue(L, V)
300 if VCf_IsEnum(V) then
301 return VCf_GetEnumValue(V);
302 end;
303 return VEn_Data[L][V];
304end
305--This may look complicated but it's not.
306--This is just calling VEn_Create() to make the Proxy versions of VEnums.
307
308--Setup
309--SliderType
310VEn_Data.SliderType = VEn_Data.CornerType;
311
312local VLb_Enums = VEn_Create({
313 CornerType = VEn_Create({
314 Sharp = VEn_Create(VEn_Data.CornerType.Sharp, "VLb_Enums.CornerType.Sharp", false, "CornerType"),
315 Smooth = VEn_Create(VEn_Data.CornerType.Smooth, "VLb_Enums.CornerType.Smooth", false, "CornerType"),
316 Edged = VEn_Create(VEn_Data.CornerType.Edged, "VLb_Enums.CornerType.Edged", false, "CornerType")
317 }, "VLb_Enums.CornerType", true, "VLb_Enums"),
318 SliderType = VEn_Create({
319 Box = VEn_Create(VEn_Data.SliderType.Sharp, "VLb_Enums.SliderType.Box", false, "SliderType"),
320 Round = VEn_Create(VEn_Data.SliderType.Smooth, "VLb_Enums.SliderType.Round", false, "SliderType"),
321 Diamond = VEn_Create(VEn_Data.SliderType.Edged, "VLb_Enums.SliderType.Diamond", false, "SliderType"),
322 Custom = VEn_Create(VEn_Data.SliderType.None, "VLb_Enums.SliderType.Custom", false, "SliderType")
323 }, "VLb_Enums.SliderType", true, "VLb_Enums"),
324 MetroLocation = VEn_Create({
325 TopLeft = VEn_Create(VEn_Data.MetroLocation.TopLeft, "VLb_Enums.MetroLocation.TopLeft", false, "MetroLocation"),
326 TopCenter = VEn_Create(VEn_Data.MetroLocation.TopCenter, "VLb_Enums.MetroLocation.TopCenter", false, "MetroLocation"),
327 TopRight = VEn_Create(VEn_Data.MetroLocation.TopRight, "VLb_Enums.MetroLocation.TopRight", false, "MetroLocation"),
328 LeftTop = VEn_Create(VEn_Data.MetroLocation.LeftTop, "VLb_Enums.MetroLocation.LeftTop", false, "MetroLocation"),
329 LeftCenter = VEn_Create(VEn_Data.MetroLocation.LeftCenter, "VLb_Enums.MetroLocation.LeftCenter", false, "MetroLocation"),
330 LeftBottom = VEn_Create(VEn_Data.MetroLocation.LeftBottom, "VLb_Enums.MetroLocation.LeftBottom", false, "MetroLocation"),
331 RightTop = VEn_Create(VEn_Data.MetroLocation.RightTop, "VLb_Enums.MetroLocation.RightTop", false, "MetroLocation"),
332 RightCenter = VEn_Create(VEn_Data.MetroLocation.RightCenter, "VLb_Enums.MetroLocation.RightCenter", false, "MetroLocation"),
333 RightBottom = VEn_Create(VEn_Data.MetroLocation.RightBottom, "VLb_Enums.MetroLocation.RightBottom", false, "MetroLocation"),
334 BottomLeft = VEn_Create(VEn_Data.MetroLocation.BottomLeft, "VLb_Enums.MetroLocation.BottomLeft", false, "MetroLocation"),
335 BottomCenter = VEn_Create(VEn_Data.MetroLocation.BottomCenter, "VLb_Enums.MetroLocation.BottomCenter", false, "MetroLocation"),
336 BottomRight = VEn_Create(VEn_Data.MetroLocation.BottomRight, "VLb_Enums.MetroLocation.BottomRight", false, "MetroLocation")
337 }, "VLb_Enums.MetroLocation", true, "VLb_Enums"),
338 CheckBoxType = VEn_Create({
339 Sharp = VEn_Create(VEn_Data.CheckBoxType.Sharp, "VLb_Enums.CheckBoxType.Sharp", false, "CheckBoxType"),
340 Smooth = VEn_Create(VEn_Data.CheckBoxType.Smooth, "VLb_Enums.CheckBoxType.Smooth", false, "CheckBoxType"),
341 Circular = VEn_Create(VEn_Data.CheckBoxType.Circular, "VLb_Enums.CheckBoxType.Circular", false, "CheckBoxType"),
342 Diamond = VEn_Create(VEn_Data.CheckBoxType.Diamond, "VLb_Enums.CheckBoxType.Diamond", false, "CheckBoxType"),
343 Custom = VEn_Create(VEn_Data.CheckBoxType.None, "VLb_Enums.CheckBoxType.Custom", false, "CheckBoxType")
344 }, "VLb_Enums.CheckBoxType", true, "VLb_Enums"),
345 FillBoxType = VEn_Create({
346 Sharp = VEn_Create(VEn_Data.FillBoxType.Sharp, "VLb_Enums.FillBoxType.Sharp", false, "FillBoxType"),
347 Smooth = VEn_Create(VEn_Data.FillBoxType.Smooth, "VLb_Enums.FillBoxType.Smooth", false, "FillBoxType"),
348 Circular = VEn_Create(VEn_Data.FillBoxType.Circular, "VLb_Enums.FillBoxType.Circular", false, "FillBoxType")
349 }, "VLb_Enums.FillBoxType", true, "VLb_Enums"),
350 NotificationType = VEn_Create({
351 Info = VEn_Create(VEn_Data.NotificationType.Info, "VLb_Enums.NotificationType.Info", false, "NotificationType"),
352 Error = VEn_Create(VEn_Data.NotificationType.Error, "VLb_Enums.NotificationType.Error", false, "NotificationType"),
353 None = VEn_Create(VEn_Data.NotificationType.None, "VLb_Enums.NotificationType.None", false, "NotificationType")
354 }, "VLb_Enums.NotificationType", true, "VLb_Enums")
355}, "VLb_Enums", true);
356
357
358local VCv_Data = {};
359local VLb_ColorVariants = {
360 LinkFunction = function(Proxy, Object, Field)
361 if type(Object) ~= "userdata" and type(Object) ~= "table" then
362 error("Arg#2 must be a userdata/table (Usually VeraniumInstances.)");
363 end;
364 if type(Field) ~= "string" then
365 error("Arg#3 must be a string. (Resembles the varying field.)");
366 end;
367 local Meta = VCv_Data[Proxy];
368 if type(Meta) == "table" and type(Meta.___Linked) == "table" then
369 local Linked = Meta.___Linked;
370 if type(Linked[Object]) == "table" then
371 Object[Field] = Meta.___Value.Value;
372 Linked[Object][Field] = true;
373 else
374 Object[Field] = Meta.___Value.Value;
375 Linked[Object] = {
376 [Field] = true
377 };
378 end;
379 else
380 error("Arg#1 is not a VCv. (This could be because you're using '.' instead of ':'.)");
381 end;
382 end,
383 UnlinkFunction = function(Proxy, Object, Field, NoErrors)
384 if type(Object) ~= "userdata" and type(Object) ~= "table" then
385 error("Arg#2 must be a userdata/table (Usually VeraniumInstances.)");
386 end;
387 if type(Field) ~= "string" then
388 error("Arg#3 must be a string. (Resembles the varying field.)");
389 end;
390 local Meta = VCv_Data[Proxy];
391 if type(Meta) == "table" and type(Meta.___Linked) == "table" then
392 local Linked = Meta.___Linked;
393 if type(Linked[Object]) == "table" then
394 Linked[Object][Field] = nil;
395 elseif not NoErrors then
396 error("This Object wasn't linked.");
397 else return;
398 end;
399 else
400 error("Arg#1 is not a VCv. (This could be because you're using '.' instead of ':'.)");
401 end;
402 end,
403 RemoveVariant = function(Proxy)
404 local Meta = VCv_Data[Proxy];
405 if type(Meta) == "table" then
406 VCv_Data[Proxy] = nil;
407 Meta.___Connection:Disconnect();
408 Meta.___Value:Remove();
409 Meta.___Value:Destroy();
410 Meta.___Tweens = nil;
411 Meta.___Linked = nil;
412 Meta.___On = false;
413 Meta.___Removed = true;
414 Meta.___ColorCycle = nil;
415 else
416 error("OwO what's this? (Incorrect Meta).");
417 end;
418 end
419};
420local VCv_Meta = {
421 __tostring = function(Proxy)
422 if type(VCv_Data[Proxy]) == "table" then
423 return "VeraniumColorVariant";
424 else
425 error("OwO what's this? (Incorrect Meta).");
426 end;
427 end,
428 __index = function(Proxy, Field)
429 local Meta = VCv_Data[Proxy];
430 if type(Meta) == "table" then
431 local Value = Meta["___"..Field];
432 if Value and Field ~= "Linked" and Field ~= "Tweens" then
433 return Value;
434 elseif Field == "Link" then
435 return VLb_ColorVariants.LinkFunction;
436 elseif Field == "Unlink" then
437 return VLb_ColorVariants.UnlinkFunction;
438 elseif Field == "Remove" or Field == "Destroy" then
439 return VLb_ColorVariants.RemoveVariant;
440 else
441 return error("Attempt to index field '"..Field.."'.");
442 end;
443 else
444 error("OwO what's this? (Incorrect Meta)");
445 end;
446 end,
447 __newindex = function(Proxy, Field, Value)
448 local Meta = VCv_Data[Proxy];
449 if type(Meta) == "table" then
450 if Field == "On" then
451 if type(Value) ~= "boolean" then
452 return error("Invalid property type. (Expected boolean, got "..typeof(Value)..")");
453 end;
454 Meta.___On = Value;
455 return;
456 end;
457 error("ColorVariants cannot be modified after creation.");
458 else
459 error("OwO what's this? (Incorrect Meta.)");
460 end;
461 end,
462 __metatable = "I-... I can't let you see that! >///<"--No Context x2 uwu
463}
464
465local function VCv_Create(EasingStyle, EasingDirection, Interval, ...)
466 local VCv_Cycle = {...};
467 --Type Checks | EasingStyle
468 if typeof(EasingStyle) == "EnumItem" then
469 if not string.find(tostring(EasingStyle), "Enum.EasingStyle.") then
470 error("Arg#1 Must Be A Color3 Or An EasingStyle.");
471 end;
472 elseif typeof(EasingStyle) == "Color3" then
473 table.insert(VCv_Cycle, 1, EasingStyle);
474 EasingStyle = Enum.EasingStyle.Sine;
475 else
476 error("Arg#1 Must Be A Color3 Or An EasingStyle.");
477 end;
478 --Type Checks | EasingDirection
479 if typeof(EasingDirection) == "EnumItem" then
480 if not string.find(tostring(EasingDirection), "Enum.EasingDirection.") then
481 error("Arg#2 Must Be A Color3 Or An EasingDirection.");
482 end;
483 elseif typeof(EasingDirection) == "Color3" then
484 table.insert(VCv_Cycle, 2, EasingDirection);
485 EasingDirection = Enum.EasingDirection.Out;
486 else
487 error("Arg#2 Must Be A Color3 Or An EasingDirection.");
488 end;
489 --Type Checks | Interval
490 if typeof(Interval) == "Color3" or Interval == nil then
491 table.insert(VCv_Cycle, 3, Interval);
492 Interval = 1;
493 elseif type(Interval) ~= "number" then
494 error("Arg#3 Must Be A Color3 Or A Number.");
495 end;
496 if #VCv_Cycle < 2 then
497 error("There Must Be At Least 2 Colors In The Cycle.");
498 end;
499 VCf_SetReadOnly(VCv_Cycle);
500 --Proxy Creation
501 local Proxy = newproxy(true);
502 local Meta = getmetatable(Proxy);
503 local Tweens = {};
504 local Linked = {};
505 local Base = Instance.new("Color3Value");
506 Base.Value = VCv_Cycle[1];
507 Base.Name = _PREFIX.."VeraniumColorVariantBase";
508 --Metatable Setup
509 Meta.___EasingStyle = EasingStyle;
510 Meta.___EasingDirection = EasingDirection;
511 Meta.___Interval = Interval;
512 Meta.___ColorCycle = VCv_Cycle;
513 Meta.___On = true;
514 Meta.___Value = Base;
515 Meta.___Linked = Linked;
516 Meta.___Tweens = Tweens;
517 Meta.___Removed = false;
518 Meta.___Connection = Base.Changed:Connect(function()
519 local Color = Base.Value;
520 if Meta.___On then
521 for Object, Fields in pairs(Linked)do
522 for Field, _ in pairs(Fields)do
523 if _ then
524 Object[Field] = Color;
525 end;
526 end;
527 end;
528 end;
529 end);
530 --Metamethod Setup
531 Meta.__tostring = VCv_Meta.__tostring;
532 Meta.__index = VCv_Meta.__index;
533 Meta.__newindex = VCv_Meta.__newindex;
534 Meta.__metatable = VCv_Meta.__metatable;
535 --Linking Proxy To Meta
536 VCv_Data[Proxy] = Meta;
537 --Creating Tweens
538 for _, Color in pairs(VCv_Cycle)do
539 table.insert(Tweens, TweenService:Create(Base, TweenInfo.new(
540 Interval,
541 EasingStyle,
542 EasingDirection,
543 0,
544 false,
545 0
546 ), {
547 Value = Color,nil
548 }));
549 end;
550 spawn(function()
551 while not Meta.___Removed do
552 if Meta.___On then
553 for _, Tween in pairs(Tweens)do
554 if Meta.___On then
555 Tween:Play();
556 wait(Interval);
557 end;
558 end;
559 else
560 wait(Interval);
561 end;
562 end;
563 Linked = nil;
564 Tweens = nil;
565 VCv_Cycle = nil;
566 end);
567 return Proxy;
568end;
569VLb_ColorVariants.Create = VCv_Create;
570VCf_SetReadOnly(VLb_ColorVariants);
571
572--Libraries | ModernColors | Source: https://flatuicolors.com/
573local VLb_ModernColors = {
574 DimMidnightBlue = Color3.fromRGB(32, 34, 37),
575 MidnightBlue = Color3.fromRGB(47, 49, 54),
576 LightMidnightBlue = Color3.fromRGB(54, 57, 63),
577 WetAsphalt = Color3.fromRGB(44, 62, 80),
578 Asphalt = Color3.fromRGB(52, 73, 94),
579 Midnight = Color3.fromRGB(47, 53, 66),
580 ElectricBlue = Color3.fromRGB(52, 152, 219),
581 Blurple = Color3.fromRGB(72, 52, 212),
582 Exodus = Color3.fromRGB(104, 109, 224),
583 Komaru = Color3.fromRGB(48, 51, 107),
584 DimKomaru = Color3.fromRGB(19, 15, 64),
585 LightExodus = Color3.fromRGB(126, 214, 223),
586 Amythest = Color3.fromRGB(155, 89, 182),
587 Wisteria = Color3.fromRGB(142, 68, 173),
588 Emerald = Color3.fromRGB(46, 204, 113),
589 Carrot = Color3.fromRGB(230, 126, 34),
590 Orange = Color3.fromRGB(243, 156, 18),
591 SunFlower = Color3.fromRGB(241, 196, 15),
592 Ruby = Color3.fromRGB(231, 76, 60),
593 Rose = Color3.fromRGB(192, 57, 43),
594 LightPink = Color3.fromRGB(255, 121, 121),
595 DimPink = Color3.fromRGB(235, 77, 75),
596 Pink = Color3.fromRGB(224, 86, 253),
597 SteelPink = Color3.fromRGB(224, 86, 253),
598 Light = Color3.fromRGB(213, 217, 255),
599 Cloud = Color3.fromRGB(236, 240, 241),
600 Silver = Color3.fromRGB(189, 195, 199),
601 Concrete = Color3.fromRGB(149, 165, 166),
602 Abestos = Color3.fromRGB(127, 140, 141)
603};
604
605--Veranium Defaults Library.
606--This is used to define defaults for VIn Objects.
607local VLb_Defaults = {
608 --Background:Corners
609 CornerSize = 6,
610 CornerType = VLb_Enums.CornerType.Smooth,
611 --Background:Self
612 BackgroundColor = VLb_ModernColors.MidnightBlue,
613 BackgroundTransparency = 0,
614 --Background:Borders
615 BorderSize = 0,
616 BorderColor = Color3.new(0, 0, 0),
617 BorderTransparency = 1,
618 --Text Properties
619 TextColor = VLb_ModernColors.Silver,
620 TextTransparency = 0,
621 Font = Enum.Font.Legacy,
622 --Text:Stroke
623 TextStrokeColor = VLb_ModernColors.Abestos,
624 TextStrokeTransparency = 1,
625 --Text:Alignment
626 TextXAlignment = Enum.TextXAlignment.Center,
627 TextYAlignment = Enum.TextYAlignment.Center,
628 --Text:Placeholder
629 PlaceholderColor = VLb_ModernColors.Silver,
630 --Global
631 ZIndex = 1,
632 SecondaryColor = VLb_ModernColors.DimMidnightBlue,
633 HighlightColor = VLb_ModernColors.ElectricBlue,
634 MetroStyle = true
635};
636
637local VIn_References = {};--Stores refrences by proxies as keys.
638local VIn_Data = {};--Contains data for different instances, such as their Propeties, TypeLocks, & so on.
639local VIn_ParseD = {};--Contains all proxies created by Veranium by MainInstances as keys.
640local VIn_Methods = {};--Contains most common methods for VeraniumInstances.
641local VIn_SReg = {};--Contains frequently used tables/proxies. Exists to stop the creation of new tables/proxies.(SReg = Secondary Registry).
642local VIn_Meta = {};--Main metatable for VeraniumInstances.
643
644local function GetMeta(Proxy)--Gets the metatable of Veranium Proxies, ignoring __metatable.
645 return VIn_References[Proxy];
646end;
647
648local VCn_Main = function(Class, ...)--Main Constructor. Usef for Veranium.Create.
649 local Constructor = VIn_Data[Class];
650 if type(Constructor) == "table" then
651 Constructor = Constructor.Constructor;
652 if type(Constructor) == "function" then
653 local Proxy = Constructor(...);
654 local Meta = GetMeta(Proxy);
655 VIn_ParseD[Proxy] = Meta.___Instance;
656 return Proxy;
657 else
658 return error("Unable to create Instance of type "..tostring(Class));
659 end;
660 else
661 return error("Unable to create Instance of type "..tostring(Class));
662 end;
663end;
664
665local function GetInstance(Object)
666 if not Object then return nil end;
667 if typeof(Object) == "Instance" then return Object end;
668 local Meta = VIn_References[Object];
669 if type(Meta) == "table" and typeof(Meta.___Instance) == "Instance" then
670 return Meta.___Instance;
671 end;
672 return nil;
673end;
674
675local function GetPInstance(Object)
676 if not Object then return nil end;
677 if typeof(Object) == "Instance" then return Object end;
678 local Meta = VIn_References[Object];
679 if type(Meta) == "table" and typeof(Meta.___Instance) == "Instance" then
680 if Meta.___Children then
681 return Meta.___Children;
682 end;
683 return Meta.___Instance;
684 end;
685 return nil;
686end;
687
688local function VCf_ParseInstance(Object, RemoveJunk)
689 if typeof(Object) ~= "Instance" then
690 return error("Invalid type for Argument #1: Instance expected, got "..typeof(Object)..".");
691 end
692 if VIn_ParseD[Object] then
693 if RemoveJunk then
694 if not string.find(Object.Name, _PREFIX) then
695 return VIn_ParseD[Object];
696 end;
697 else
698 return VIn_ParseD[Object];
699 end;
700 end;
701 return Object;
702end;
703
704local function VCf_IsVera(Object)
705 return (VIn_References[Object] ~= nil);
706end;
707
708local function VCf_AssertIsVera(Object, ArgN)--Makes it easy for me to say: error if Proxy isn't Veranium. ArgN = Argument Number.
709 if not VIn_References[Object] then
710 error("Expected VeraniumInstance for arg#"..tostring(ArgN or 1)..". got "..typeof(Object).." (Object might be destroyed).");
711 end;
712end;
713
714
715--metatable Setup.
716--__tostring
717VIn_Meta.__tostring = function(self)
718 VCf_AssertIsVera(self);
719 local Meta = GetMeta(self);
720 local Fields = Meta.___Fields;
721 local Object = GetInstance(self);
722 --Instance Name tostring
723 if typeof(Object) == "Instance" then
724 if Object.Name:find(_PREFIX) then
725 return Object.Name:sub(#_PREFIX+1, -1);
726 else
727 return Object.Name;
728 end;
729 end;
730 --Field tostring
731 if Fields and Fields.Name then
732 return Fields.Name;
733 elseif Fields and Fields.ClassName then--ClassName tostring
734 return Fields.ClassName;
735 end;
736 --Exception tostring
737 return "VeraniumInstance";
738end;
739
740--__index
741VIn_Meta.__index = function(self, Field)
742 local Meta = GetMeta(self);
743 if (Field == "Destructor" or Field == "Destroy" or Field == "Remove") then
744 return VCf_Destructor;
745 elseif Field == "IsDestroyed" then
746 return not VCf_IsVera(self);
747 else
748 VCf_AssertIsVera(self);
749 end;
750 local Fields = Meta.___Fields;
751 local MetaData = Meta.___MetaData;
752 if MetaData then
753 --Changed Idx
754 if Field == "Changed" then
755 return Meta.___ChangeSignal.Event;
756 end;
757 --Method Idx
758 if VIn_Methods[Field] then
759 return VIn_Methods[Field];
760 end;
761 --Property Idx
762 local Route = MetaData.Routing[Field];
763 local IVRouting = VIn_SReg.IVRouting[Field];
764 if MetaData.Fields[Field] then
765 return Fields[Field];
766 end;
767 --Routing Idx
768 if type(Route) == "string" then
769 return self[Route];
770 elseif type(Route) == "table" then
771 return Meta[Route.RouteInstance][Route.RouteField];
772 end;
773 --IVRouting Idx
774 if type(IVRouting) == "string" then
775 IVRouting = Meta[IVRouting]
776 if IVRouting then
777 return IVRouting[Field];
778 end;
779 end;
780 --Children Idx
781 local Object = GetInstance(self);
782 if typeof(Object) == "Instance" then
783 local Child = Object:FindFirstChild(Field);
784 if Child then
785 return VCf_ParseInstance(Child);
786 end;
787 end;
788 --Exception Error
789 error("Unable to index VeraniumInstance with '"..tostring(Field).."'");
790 else
791 error("Unable to get MetaData. [001]");
792 end;
793 error("Unable to index VeraniumInstance with '"..tostring(Field).."'");
794end;
795
796--__newindex
797VIn_Meta.__newindex = function(self, Field, Value)
798 VCf_AssertIsVera(self);
799 local Meta = GetMeta(self);
800 local Fields = Meta.___Fields;
801 local MetaData = Meta.___MetaData;
802 if MetaData then
803 local Route = MetaData.Routing[Field];
804 local IVRouting = VIn_SReg.IVRouting[Field];
805 local FieldData = MetaData.Fields[Field];
806 local ReadOnly;
807 if FieldData then
808 ReadOnly = (FieldData:sub(3, 3) == "\1");
809 end;
810 --Direct Ndx
811 if FieldData and not ReadOnly then
812 if not VCf_IsA(Value, FieldData) then
813 return error("Invalid type for "..Field..". ("..FieldData:sub(4, -1).." expected, got "..typeof(Value)..").");
814 end;
815 if Field == "Parent" then
816 Meta.___Instance.Parent = GetPInstance(Value);
817 end;
818 Fields[Field] = Value;
819 MetaData.Redraw(self, Field, Value);
820 if Meta.___ChangeSignal then
821 Meta.___ChangeSignal:Fire(Field, Value);
822 end;
823 return;
824 elseif FieldData and ReadOnly then
825 error(Field.." is read-only.");
826 end;
827 --Routing Ndx
828 if type(Route) == "string" then
829 self[Route] = Value
830 if Meta.___ChangeSignal then
831 Meta.___ChangeSignal:Fire(Field, Value);
832 end;
833 return
834 elseif type(Route) == "table" then
835 Meta[Route.RouteInstance][Route.RouteField] = Value
836 if Meta.___ChangeSignal then
837 Meta.___ChangeSignal:Fire(Field, Value);
838 end;
839 return;
840 end;
841 --IVRouting Ndx
842 if typeof(IVRouting) == "string" then
843 IVRouting = Meta[IVRouting]
844 if IVRouting then
845 IVRouting[Field] = Value
846 if Meta.___ChangeSignal then
847 Meta.___ChangeSignal:Fire(Field, Value);
848 end;
849 return;
850 end;
851 end;
852 --Exceptional Error
853 error("Unable to index VeraniumInstance with '"..tostring(Field).."'");
854 end;
855end;
856
857--metatable Protection
858VIn_Meta.__metatable = "Hewo, can you pwease not cwash Vewanium? uwu";
859
860
861--Inputs
862local function VIn_CreateClass(ClassName, Fields, Routing, Constructor, Redraw, Methods)
863 local ClassData = {};
864 VIn_Data[ClassName] = ClassData;
865 --Fields
866 ClassData.Fields = Fields;
867 --Routing
868 ClassData.Routing = Routing;
869 --Constructor
870 ClassData.Constructor = Constructor;
871 --Redraw
872 if type(Redraw) == "function" then
873 ClassData.Redraw = Redraw;
874 elseif type(Redraw) == "table" then
875 ClassData.Redraw = function(self, Field, Value)
876 if Field == nil then
877 for Idx, Function in pairs(Redraw) do
878 if Idx == "Main" then
879 Function(self, Field, Value);
880 else
881 Function(self, Value);
882 end;
883 end;
884 return;
885 end;
886 if type(Redraw[Field]) == "function" then
887 return Redraw[Field](self, Value);
888 elseif type(Redraw.Main) == "function" then
889 return Redraw.Main(self, Field, Value);
890 end;
891 end;
892 end;
893 --Methods Implement
894 if Methods then
895 for MethodName, Method in pairs(Methods)do
896 ClassData[MethodName] = Method;
897 end;
898 end;
899
900 return ClassData;
901end;
902
903local function VIn_CreateInstance(MetaData)
904 local Proxy = newproxy(true);
905 local Meta = getmetatable(Proxy);
906 local ChangeSignal = Instance.new("BindableEvent");
907 local Fields = {};
908 ChangeSignal.Name = "VeraniumChangeSignal";
909 Meta.___MetaData = MetaData;
910 Meta.__index = VIn_Meta.__index;
911 Meta.__newindex = VIn_Meta.__newindex;
912 Meta.__tostring = VIn_Meta.__tostring;
913 Meta.__metatable = VIn_Meta.__metatable;
914 VIn_References[Proxy] = Meta;
915 Meta.___Fields = Fields;
916 Meta.___ChangeSignal = ChangeSignal;
917 return Proxy, Meta, Fields, ChangeSignal;
918end;
919
920--VIn_SReg IVRouting Setup
921VIn_SReg.IVRouting = {
922 --Properties
923 --Base2D
924 AbsolutePosition = "___Base2D",
925 AbsoluteRotation = "___Base2D",
926 AbsoluteSize = "___Base2D",
927 Active = "___Base2D",
928 AnchorPoint = "___Base2D",
929 ClipsDescendants = "___Base2D",
930 LayoutOrder = "___Base2D",
931 Position = "___Base2D",
932 Rotation = "___Base2D",
933 Size = "___Base2D",
934 SizeConstraint = "___Base2D",
935 Visible = "___Base2D",
936 ZIndex = "___Base2D",
937 Parent = "___Base2D",
938 Name = "___Base2D",
939
940 --TextRender
941 Font = "___TextRender",
942 LineHeight = "___TextRender",
943 LocalizedText = "___TextRender",
944 Text = "___TextRender",
945 TextBounds = "___TextRender",
946 TextColor3 = "___TextRender",
947 TextFits = "___TextRender",
948 TextScaled = "___TextRender",
949 TextSize = "___TextRender",
950 TextStrokeColor3 = "___TextRender",
951 TextStrokeTransparency = "___TextRender",
952 TextTransparency = "___TextRender",
953 TextTruncate = "___TextRender",
954 TextWrapped = "___TextRender",
955 TextXAlignment = "___TextRender",
956 TextYAlignment = "___TextRender",
957
958 --ImageRender
959 HoverImage = "___ImageRender",
960 Image = "___ImageRender",
961 ImageColor3 = "___ImageRender",
962 ImageRectOffset = "___ImageRender",
963 ImageRectSize = "___ImageRender",
964 ImageTransparency = "___ImageRender",
965 IsLoaded = "___ImageRender",
966 PressedImage = "___ImageRender",
967 ScaleType = "___ImageRender",
968 SliceCenter = "___ImageRender",
969 SliceScale = "___ImageRender",
970 TileSize = "___ImageRender",
971
972 --TextBox
973 IsFocused = "___TextBox",
974 PlaceholderColor3 = "___TextBox",
975 PlaceholderText = "___TextBox",
976 ClearTextOnFocus = "___TextBox",
977 TextEditable = "___TextBox",
978 CursorPosition = "___TextBox",
979 SelectionStart = "___TextBox",
980 Selectable = "___TextBox",
981
982 --Background
983 Color = "___Background",
984 BackgroundColor = "___Background",
985 BackgroundColor3 = "___Background",
986 BackgroundTransparency = "___Background",
987 Transparency = "___Background",
988 Type = "___Background",
989 CornerType = "___Background",
990 CornerSize = "___Background",
991 TopLeft = "___Background",
992 TopBorder = "___Background",
993 TopRight = "___Background",
994 LeftBorder = "___Background",
995 RightBorder = "___Background",
996 BottomLeft = "___Background",
997 BottomBorder = "___Background",
998 BottomRight = "___Background",
999
1000 BorderSizePixel = "___Background",
1001 BorderSize = "___Background",
1002 BorderColor3 = "___Background",
1003 BorderColor = "___Background",
1004 BorderTransparency = "___Background",
1005
1006 --Methods
1007 --Background
1008 CreateBorder = "___Background",
1009 --Base2D
1010 TweenPosition = "___Base2D",
1011 TweennSize = "___Base2D",
1012 TweenSizeAndPosition = "___Base2D",
1013
1014 --Hitbox
1015 SetTextFromInput = "___CHitbox",
1016
1017 --TextBox
1018 CaptureFocus = "___TextBox",
1019 ReleaseFocus = "___TextBox",
1020 --Signals
1021 --Hitbox
1022 MouseButton1Click = "___CHitbox",
1023 MouseButton2Click = "___CHitbox",
1024 MouseButton1Down = "___CHitbox",
1025 MouseButton2Down = "___CHitbox",
1026 MouseButton1Up = "___CHitbox",
1027 MouseButton2Up = "___CHitbox",
1028 MouseEnter = "___CHitbox",
1029 MouseLeave = "___CHitbox",
1030 MouseMoved = "___CHitbox",
1031 MouseWheelBackward = "___Base2D",
1032 MouseWheelForward = "___Base2D",
1033 InputBegan = "___CHitbox",
1034 InputEnded = "___CHitbox",
1035 InputChanged = "___CHitbox",
1036
1037 --Textbox
1038 Focused = "___TextBox",
1039 FocusLost = "___TextBox"
1040};
1041
1042--VIn_SReg OffsetMap Setup
1043VIn_SReg.OffsetMap = {
1044 [0] = {
1045 AnchorPoint = Vector2.new(1, 1),
1046 Position = UDim2.new(0, 0, 0, 0),
1047 SizeConstraint = Vector2.new(0, 0),
1048 ImageRectSize = Vector2.new(400, 400),
1049 ImageRectOffset = Vector2.new(0, 0),
1050 Name = "TopLeft"
1051 },
1052 [1] = {
1053 AnchorPoint = Vector2.new(0.5, 1),
1054 Position = UDim2.new(0.5, 0, 0, 0),
1055 SizeConstraint = Vector2.new(1, 0),
1056 ImageRectSize = Vector2.new(1, 1),
1057 ImageRectOffset = Vector2.new(399, 399),
1058 Name = "TopCenter"
1059 },
1060 [2] = {
1061 AnchorPoint = Vector2.new(0, 1),
1062 Position = UDim2.new(1, 0, 0, 0),
1063 SizeConstraint = Vector2.new(0, 0),
1064 ImageRectSize = Vector2.new(400, 400),
1065 ImageRectOffset = Vector2.new(400, 0),
1066 Name = "TopRight"
1067 },
1068 [3] = {
1069 AnchorPoint = Vector2.new(1, 0.5),
1070 Position = UDim2.new(0, 0, 0.5, 0),
1071 SizeConstraint = Vector2.new(0, 1),
1072 ImageRectSize = Vector2.new(1, 1),
1073 ImageRectOffset = Vector2.new(399, 399),
1074 Name = "LeftCenter"
1075 },
1076 [4] = {
1077 AnchorPoint = Vector2.new(0, 0.5),
1078 Position = UDim2.new(1, 0, 0.5, 0),
1079 SizeConstraint = Vector2.new(0, 1),
1080 ImageRectSize = Vector2.new(1, 1),
1081 ImageRectOffset = Vector2.new(399, 399),
1082 Name = "RightCenter"
1083 },
1084 [5] = {
1085 AnchorPoint = Vector2.new(1, 0),
1086 Position = UDim2.new(0, 0, 1, 0),
1087 SizeConstraint = Vector2.new(0, 0),
1088 ImageRectSize = Vector2.new(400, 400),
1089 ImageRectOffset = Vector2.new(0, 400),
1090 Name = "BottomLeft"
1091 },
1092 [6] = {
1093 AnchorPoint = Vector2.new(0.5, 0),
1094 Position = UDim2.new(0.5, 0, 1, 0),
1095 SizeConstraint = Vector2.new(1, 0),
1096 ImageRectSize = Vector2.new(1, 1),
1097 ImageRectOffset = Vector2.new(399, 399),
1098 Name = "BottomCenter"
1099 },
1100 [7] = {
1101 AnchorPoint = Vector2.new(0, 0),
1102 Position = UDim2.new(1, 0, 1, 0),
1103 SizeConstraint = Vector2.new(0, 0),
1104 ImageRectSize = Vector2.new(400, 400),
1105 ImageRectOffset = Vector2.new(400, 400),
1106 Name = "BottomRight"
1107 }
1108};
1109
1110--[[Offset Map
1111 ____________________
1112 | |
1113 |0 1 2|
1114 | |
1115 |3 4|
1116 | |
1117 |5 6 7|
1118 |____________________|
1119
1120 Typelock Syntax
1121
1122 [Byte#]: Definer
1123 [1]: VCf_IsA Instruction (Explained Below)
1124 [2]: Nullable (Property can be NULL/NIL)
1125 [3]: Read-Only (Property cannot be written to)
1126 [4-#s]: Type DataString
1127
1128 VCf_IsA Instructions:
1129 [0]: VEnum IsA (Checks if the value is a VEnum of the type provided in DataString)
1130 [1]: VCv IsA (Checks if the value is a VeraniumColorVariant | Doesn't need a DataString)
1131 [2]: BaseInstance IsA (BaseInstance = VeraniumProxy/RbxInstance | Doesn't need a DataString)
1132 [3]: type() IsA (Checks the type() of the Value and compares it to DataString)
1133 [4]: typeof() IsA (Check the typeof() of the Value and compares it to DataString)
1134 [5]: Accepts all value types (No DataString needed)
1135
1136 All VCf_IsA Instructions could be altered by [Byte#2], Nullable.
1137 No instruction uses [Byte#3]. It is only used by __newindex.
1138]]
1139
1140--VIn_SReg TransparencyLayer Setup
1141VIn_SReg.TransparencyLayer = {
1142 VeraniumLabel = {"BackgroundTransparency", "TextTransparency"},
1143 VeraniumButton = {"BackgroundTransparency", "TextTransparency"},
1144 VeraniumTextBox = {"BackgroundTransparency", "TextTransparency"},
1145
1146 VeraniumSlider = {"BarTransparency", "MarkupTransparency"},
1147 VeraniumCheckBox = {"StartBoxTransparency", "EndBoxTransparency", "StartCheckTransparency", "EndCheckTransparency"},
1148 VeraniumFillBox = {"StartBoxTransparency", "EndBoxTransparency"},
1149 VeraniumCounter = {"BackgroundTransparency", "SubtractTransparency", "AddTransparency"},
1150 VeraniumDropdownBox = {"BackgroundTransparency", "TextTransparency"}
1151};
1152
1153--ClassData Creations
1154--Boundary
1155VIn_CreateClass("Boundary",
1156 {
1157 BackgroundColor3 = "\4\0\0Color3",
1158 BackgroundTransparency = "\3\0\0number",
1159
1160 Size = "\3\0\0number",
1161 Offset = "\3\0\1number",
1162
1163 Background = "\2\1\1",
1164 ClassName = "\3\0\1string",
1165
1166 Type = "\0\0\0CornerType",
1167
1168 --Border Properties
1169 BorderColor3 = "\4\0\0Color3",
1170 BorderTransparency = "\3\0\0number",
1171 BorderSizePixel = "\3\0\0number",
1172
1173 --Methods
1174 Redraw = "\3\0\1function",
1175 Destructor = "\3\0\1function",
1176 CreateBorder = "\3\0\1function"
1177 },
1178 {
1179 BoundarySize = "Size",
1180
1181 BoundaryColor3 = "BackgroundColor3",
1182 BoundaryColor = "BackgroundColor3",
1183 Color = "BackgroundColor3",
1184 --Color
1185
1186 BoundaryTransparency = "BackgroundTransparency",
1187 Transparency = "BackgroundTransparency",
1188 --Transparency
1189
1190 BorderColor = "BorderColor3",
1191 BorderSize = "BorderSizePixel",
1192 --Border
1193 },
1194 function(Background, Offset)
1195 local BGMeta = GetMeta(Background);
1196 if BGMeta and BGMeta.___Fields.ClassName == "VeraniumBoundary" then
1197 Offset = Background.Offset;
1198 end;
1199 if type(Offset) ~= "number" then Offset = 0 end
1200 local Proxy, Meta, Fields, Cs = VIn_CreateInstance(VIn_Data.Boundary)
1201 --Proxy Setup
1202 Fields.BackgroundColor3 = VLb_Defaults.BackgroundColor;
1203 Fields.BackgroundTransparency = VLb_Defaults.BackgroundTransparency;
1204
1205 Fields.Size = VLb_Defaults.CornerSize;
1206 Fields.Offset = Offset or 0;
1207
1208 Fields.Background = Background;
1209 Fields.ClassName = "VeraniumBoundary";
1210
1211 Fields.Type = VLb_Defaults.CornerType;
1212
1213 Fields.BorderColor3 = VLb_Defaults.BorderColor;
1214 Fields.BorderTransparency = VLb_Defaults.BorderTransparency;
1215 Fields.BorderSizePixel = VLb_Defaults.BorderSize;
1216
1217 --Methods Setup
1218 Fields.CreateBorder = VIn_Data.Boundary.CreateBorder;
1219 Fields.Redraw = VIn_Data.Boundary.Redraw;
1220 --Defaults Setup
1221 local Boundary = Instance.new("ImageLabel", GetInstance(Background));
1222 local OffsetMap = VIn_SReg.OffsetMap[Offset or 0];
1223 --Boundary Setup
1224 Boundary.Name = _PREFIX..OffsetMap.Name.."Boundary";
1225 Boundary.BackgroundTransparency = 1;
1226 Boundary.AnchorPoint = OffsetMap.AnchorPoint;
1227 Boundary.Position = OffsetMap.Position;
1228 Boundary.BorderSizePixel = 0;
1229 Boundary.ImageRectSize = OffsetMap.ImageRectSize;
1230 Boundary.ImageRectOffset = OffsetMap.ImageRectOffset;
1231 --ChangedSignal
1232 Cs.Parent = Boundary;
1233 --MetaData Setup
1234 Meta.___Instance = Boundary;
1235 Meta.___Base2D = Boundary;
1236 --Border Linkage
1237 if BGMeta and BGMeta.___Fields.ClassName == "VeraniumBoundary" then
1238 Meta.IsBorder = true;
1239 BGMeta.___Border = Boundary;
1240 Boundary.Parent = Background.Background;
1241 Boundary.Name = _PREFIX..OffsetMap.Name.."Border";
1242 for Idx, Value in pairs(BGMeta.___Fields) do
1243 Fields[Idx] = Value;
1244 end;
1245 Fields.CornerSize = Background.Size+Background.BorderSizePixel;
1246 Fields.BackgroundColor3 = Background.BorderColor3;
1247 Fields.BackgroundTransparency = Background.BorderTransparency;
1248 Boundary.ZIndex = 0;
1249
1250 local function RefreshSize()
1251 local OffsetMap = VIn_SReg.OffsetMap[Background.Offset];
1252 local SizeConstraint = OffsetMap.SizeConstraint;
1253 local BorderSizePixel = Background.BorderSizePixel + Background.Size;
1254 Boundary.Size = UDim2.new(
1255 SizeConstraint.X,
1256 BorderSizePixel-(SizeConstraint.X*BorderSizePixel),
1257 SizeConstraint.Y,
1258 BorderSizePixel-(SizeConstraint.Y*BorderSizePixel)
1259 );
1260 end;
1261
1262 Background.Changed:Connect(function(Field)
1263 if Field == "Size" or Field == "BorderSizePixel" then
1264 RefreshSize();
1265 elseif Field == "Type" then
1266 Proxy.Type = Background.Type;
1267 end;
1268 end);
1269
1270 VIn_Data.Boundary.Redraw(Proxy);
1271 Background:Redraw();
1272 RefreshSize();
1273 else
1274 VIn_Data.Boundary.Redraw(Proxy);
1275 end;
1276
1277 return Proxy;
1278 end,
1279 function(self, Field, Value)
1280 --Setup
1281 local Meta = GetMeta(self);
1282 local Boundary = Meta.___Instance;
1283 local Fields = Meta.___Fields;
1284 local Border = Meta.___Border;
1285 local IsBorder = Meta.IsBorder;
1286 --Type
1287 if Field == nil or Field == "Type" then
1288 Boundary.Image = VCf_GetEnumLValue("CornerType", Fields.Type);
1289 if Field then return; end;
1290 end;
1291 --BackgroundColor3
1292 if Field == nil or Field == "BackgroundColor3" then
1293 Boundary.ImageColor3 = Fields.BackgroundColor3;
1294 if Field then return; end;
1295 end;
1296 --BackgroundTransparency
1297 if Field == nil or Field == "BackgroundTransparency" then
1298 Boundary.ImageTransparency = Fields.BackgroundTransparency;
1299 if Field then return; end;
1300 end;
1301 --Size
1302 if Field == nil or Field == "Size" and not IsBorder then
1303 local OffsetMap = VIn_SReg.OffsetMap[Fields.Offset];
1304 local SizeConstraint = OffsetMap.SizeConstraint;
1305 Boundary.Size = UDim2.new(
1306 SizeConstraint.X,
1307 Fields.Size-(SizeConstraint.X*Fields.Size),
1308 SizeConstraint.Y,
1309 Fields.Size-(SizeConstraint.Y*Fields.Size)
1310 );
1311 if Field then return; end;
1312 end;
1313 --BorderColor3
1314 if Field == nil or Field == "BorderColor3" then
1315 if Border then
1316 Border.ImageColor3 = Fields.BorderColor3;
1317 if Field then return; end;
1318 elseif Field then
1319 return; --warn("This Boundary has no Border. Use CreateBorder() to make one.");
1320 end;
1321 end;
1322 --BorderTransparency
1323 if Field == nil or Field == "BorderTransparency" then
1324 if Border then
1325 Border.ImageTransparency = Fields.BorderTransparency;
1326 if Field then return; end;
1327 elseif Field then
1328 return; --warn("This Boundary has no Border. Use CreateBorder() to make one.");
1329 end;
1330 end;
1331 end,
1332 {
1333 CreateBorder = function(self, Core)
1334 if Core then
1335 return VIn_Data.Boundary.Constructor(self);
1336 else
1337 VIn_Data.Boundary.Constructor(self);
1338 end;
1339 end
1340 }
1341);
1342
1343VIn_CreateClass("Background",
1344 {
1345 BackgroundColor3 = "\4\0\0Color3";
1346 BackgroundTransparency = "\3\0\0number",
1347 CornerSize = "\3\0\0number",
1348 Container = "\2\1\1",
1349 ClassName = "\3\0\1string",
1350 CornerType = "\0\0\0CornerType",
1351
1352 --Border Properties
1353 BorderColor3 = "\4\0\0Color3",
1354 BorderTransparency = "\3\0\0number",
1355 BorderSizePixel = "\3\0\0number",
1356
1357 --Methods
1358 Redraw = "\3\0\1function",
1359 CreateBorder = "\3\0\1function",
1360
1361 TopLeft = "\2\1\1",
1362 TopCenter = "\2\1\1",
1363 TopRight = "\2\1\1",
1364 LeftCenter = "\2\1\1",
1365 RightCenter = "\2\1\1",
1366 BottomLeft = "\2\1\1",
1367 BottomCenter = "\2\1\1",
1368 BottomRight = "\2\1\1"
1369 --Boundaries
1370 },
1371 {
1372 BoundarySize = "CornerSize",
1373 BoundaryType = "CornerType",
1374 Type = "CornerType",
1375 --Boundary
1376
1377 BoundaryColor3 = "BackgroundColor3",
1378 BoundaryColor = "BackgroundColor3",
1379 Color = "BackgroundColor3",
1380 --Color
1381
1382 BoundaryTransparency = "BackgroundTransparency",
1383 Transparency = "BackgroundTransparency",
1384 --Transparency
1385
1386 BorderColor = "BorderColor3",
1387 BorderSize = "BorderSizePixel"
1388 --Border
1389 },
1390 function(Container)
1391 local Proxy, Meta, Fields, Cs = VIn_CreateInstance(VIn_Data.Background);
1392 --Proxy Setup
1393 Fields.BackgroundColor3 = VLb_Defaults.BackgroundColor;
1394 Fields.BackgroundTransparency = VLb_Defaults.BackgroundTransparency;
1395 Fields.Container = Container;
1396 Fields.ClassName = "VeraniumBackground";
1397 Fields.CornerSize = VLb_Defaults.CornerSize;
1398 Fields.CornerType = VLb_Defaults.CornerType;
1399
1400 Fields.BorderColor3 = VLb_Defaults.BorderColor;
1401 Fields.BorderTransparency = VLb_Defaults.BorderTransparency;
1402 Fields.BorderSizePixel = VLb_Defaults.BorderSize;
1403
1404 --Methods Setup
1405 Fields.CreateBorder = VIn_Data.Background.CreateBorder;
1406 Fields.Redraw = VIn_Data.Background.Redraw;
1407 --Elements Creation
1408 local Background = Instance.new("Frame", GetInstance(Container));
1409 local TopLeft = VIn_Data.Boundary.Constructor(Background, 0);
1410 local TopCenter = VIn_Data.Boundary.Constructor(Background, 1);
1411 local TopRight = VIn_Data.Boundary.Constructor(Background, 2);
1412 local LeftCenter = VIn_Data.Boundary.Constructor(Background, 3);
1413 local RightCenter = VIn_Data.Boundary.Constructor(Background, 4);
1414 local BottomLeft = VIn_Data.Boundary.Constructor(Background, 5);
1415 local BottomCenter = VIn_Data.Boundary.Constructor(Background, 6);
1416 local BottomRight = VIn_Data.Boundary.Constructor(Background, 7);
1417 --Follow:Proxy Setup
1418 Fields.TopLeft = TopLeft;
1419 Fields.TopCenter = TopCenter;
1420 Fields.TopRight = TopRight;
1421 Fields.LeftCenter = LeftCenter;
1422 Fields.RightCenter = RightCenter;
1423 Fields.BottomLeft = BottomLeft;
1424 Fields.BottomCenter = BottomCenter;
1425 Fields.BottomRight = BottomRight;
1426 --Background Setup
1427 Background.Name = _PREFIX.."VeraniumBackground";
1428 Background.BorderSizePixel = 0;
1429 Background.AnchorPoint = Vector2.new(0.5, 0.5);
1430 Background.Position = UDim2.new(0.5, 0, 0.5, 0);
1431 --ChangedSignal
1432 Cs.Parent = Background;
1433 --MetaData Setup
1434 Meta.___Instance = Background;
1435 Meta.___Base2D = Background;
1436 Meta.Boundaries = {
1437 TopLeft = TopLeft,
1438 TopCenter = TopCenter,
1439 TopRight = TopRight,
1440 LeftCenter = LeftCenter,
1441 RightCenter = RightCenter,
1442 BottomLeft = BottomLeft,
1443 BottomCenter = BottomCenter,
1444 BottomRight = BottomRight
1445 };
1446 --First Draw
1447 VIn_Data.Background.Redraw(Proxy);
1448
1449 return Proxy;
1450 end,
1451 function(self, Field, Value)
1452 --Setup
1453 local Meta = GetMeta(self);
1454 local Background = Meta.___Instance;
1455 local Fields = Meta.___Fields;
1456 local SetAll = VIn_Data.Background.SetAll;
1457 --Type
1458 if Field == nil or Field == "CornerType" then
1459 SetAll(self, "Type", Fields.CornerType);
1460 if Field then return; end;
1461 end;
1462 --Size
1463 if Field == nil or Field == "CornerSize" then
1464 Background.Size = UDim2.new(
1465 1,
1466 -(Fields.CornerSize+Fields.BorderSizePixel)*2,
1467 1,
1468 -(Fields.CornerSize+Fields.BorderSizePixel)*2
1469 );
1470 SetAll(self, "Size", Fields.CornerSize);
1471 if Field then return; end;
1472 end;
1473 --BackgroundColor3
1474 if Field == nil or Field == "BackgroundColor3" then
1475 Background.BackgroundColor3 = Fields.BackgroundColor3;
1476 SetAll(self, "BackgroundColor3", Fields.BackgroundColor3);
1477 if Field then return; end;
1478 end;
1479 --BackgroundTransparency
1480 if Field == nil or Field == "BackgroundTransparency" then
1481 Background.BackgroundTransparency = Fields.BackgroundTransparency;
1482 SetAll(self, "BackgroundTransparency", Fields.BackgroundTransparency);
1483 if Field then return; end;
1484 end;
1485 --BorderColor3
1486 if Field == nil or Field == "BorderColor3" then
1487 SetAll(self, "BorderColor3", Fields.BorderColor3);
1488 if Field then return; end;
1489 end;
1490 --BorderTransparency
1491 if Field == nil or Field == "BorderTransparency" then
1492 SetAll(self, "BorderTransparency", Fields.BorderTransparency);
1493 if Field then return; end;
1494 end;
1495 --BorderSizePixel
1496 if Field == nil or Field == "BorderSizePixel" then
1497 Background.Size = UDim2.new(
1498 1,
1499 -(Fields.CornerSize+Fields.BorderSizePixel)*2,
1500 1,
1501 -(Fields.CornerSize+Fields.BorderSizePixel)*2
1502 );
1503 SetAll(self, "BorderSizePixel", Fields.BorderSizePixel);
1504 if Field then return; end;
1505 end;
1506 end,
1507 {
1508 CreateBorder = function(self)
1509 local Meta = GetMeta(self);
1510 if Meta.___Background then
1511 self = Meta.___Background;
1512 Meta = GetMeta(self);
1513 end;
1514 if type(Meta) == "table" and type(Meta.Boundaries) == "table" then
1515 for Idx, Boundary in pairs(Meta.Boundaries)do
1516 Boundary:CreateBorder();
1517 end;
1518 end;
1519 end,
1520 SetAll = function(self, Field, Value)
1521 local Meta = GetMeta(self);
1522 if type(Meta) == "table" and type(Meta.Boundaries) == "table" then
1523 for Idx, Boundary in pairs(Meta.Boundaries)do
1524 Boundary[Field] = Value;
1525 end;
1526 end;
1527 end
1528 }
1529);
1530
1531VIn_CreateClass("Label",
1532 {
1533 --Main
1534 Parent = "\2\1\0",
1535 ClassName = "\3\0\1string",
1536 ZIndex = "\3\0\0number",
1537
1538 --Methods
1539 Redraw = "\3\0\1function"
1540 },
1541 {
1542
1543 },
1544 function(Parent)
1545 local Proxy, Meta, Fields, Cs = VIn_CreateInstance(VIn_Data.Label);
1546 --Proxy Setup
1547 Fields.ClassName = "VeraniumLabel";
1548 Fields.Parent = Parent;
1549 Fields.ZIndex = VLb_Defaults.ZIndex;
1550 --Methods Setup
1551 Fields.Redraw = VIn_Data.Label.Redraw;
1552 --Elements Creation
1553 local Main = Instance.new("Frame", GetPInstance(Parent));
1554 local Background = VIn_Data.Background.Constructor(Main);
1555 local ImageRender = Instance.new("ImageLabel", Main);
1556 local TextRender = Instance.new("TextLabel", Main);
1557 --Main Setup
1558 Main.BackgroundTransparency = 1;
1559 Main.BorderSizePixel = 0;
1560 Main.Name = "VeraniumLabel";
1561 Main.Size = UDim2.new(0, 105, 0, 25);
1562 --TextRender Setup
1563 TextRender.Name = _PREFIX.."TextRender";
1564 TextRender.Text = "Veranium Label";
1565 TextRender.BackgroundTransparency = 1;
1566 TextRender.BorderSizePixel = 0;
1567 TextRender.Size = UDim2.new(1, 0, 1, 0);
1568 TextRender.Position = UDim2.new(0.5, 0, 0.5, 0);
1569 TextRender.AnchorPoint = Vector2.new(0.5, 0.5);
1570 --TextRender Defaults
1571 TextRender.TextColor3 = VLb_Defaults.TextColor;
1572 TextRender.TextTransparency = VLb_Defaults.TextTransparency;
1573 TextRender.Font = VLb_Defaults.Font;
1574
1575 TextRender.TextStrokeColor3 = VLb_Defaults.TextStrokeColor;
1576 TextRender.TextStrokeTransparency = VLb_Defaults.TextStrokeTransparency;
1577
1578 TextRender.TextXAlignment = VLb_Defaults.TextXAlignment;
1579 TextRender.TextYAlignment = VLb_Defaults.TextYAlignment;
1580 --ImageRender Setup
1581 ImageRender.Name = _PREFIX.."ImageRender";
1582 ImageRender.Image = "";
1583 ImageRender.BackgroundTransparency = 1;
1584 ImageRender.BorderSizePixel = 0;
1585 ImageRender.Size = UDim2.new(1, 0, 1, 0);
1586 ImageRender.Position = UDim2.new(0.5, 0, 0.5, 0);
1587 ImageRender.AnchorPoint = Vector2.new(0.5, 0.5);
1588 --ChangedSignal
1589 Cs.Parent = Main;
1590 --MetaData Setup
1591 Meta.___Instance = Main;
1592 Meta.___Base2D = Main;
1593 Meta.___Background = Background;
1594 Meta.___TextRender = TextRender;
1595 Meta.___ImageRender = ImageRender;
1596 --First Draw
1597 VIn_Data.Label.Redraw(Proxy);
1598
1599 return Proxy;
1600 end,
1601 function(self, Field, Value)
1602 --Setup
1603 local Meta = GetMeta(self);
1604 local Main = Meta.___Instance;
1605 local Fields = Meta.___Fields;
1606 --Shortest Redraw known to man!
1607 Main.ZIndex = Fields.ZIndex;
1608 end,
1609 {
1610
1611 }
1612);
1613
1614VIn_CreateClass("Button",
1615 {
1616 --Main
1617 Parent = "\2\1\0",
1618 ClassName = "\3\0\1string",
1619 ZIndex = "\3\0\0number",
1620 BackgroundColor3 = "\4\0\0Color3",
1621 Image = "\3\0\0string",
1622 ClipsDescendants = "\3\0\0boolean",
1623
1624 --Hovers
1625 HoverColor3 = "\4\0\0Color3",
1626 HoverImage = "\3\0\0string",
1627 --MouseDown
1628 MouseDownColor3 = "\4\0\0Color3",
1629 MouseDownImage = "\3\0\0string",
1630 --Metro Properties
1631 MetroStyle = "\3\0\0boolean",
1632 MetroStartColor3 = "\4\0\0Color3",
1633 MetroEndColor3 = "\4\0\0Color3",
1634 MetroStartTransparency = "\3\0\0number",
1635 MetroEndTransparency = "\3\0\0number",
1636 MetroTweenInfo = "\4\0\0TweenInfo",
1637 AutoButtonColor = "\3\0\0boolean",
1638 --Methods
1639 Redraw = "\3\0\1function"
1640 },
1641 {
1642 MetroStartColor = "MetroStartColor3",
1643 MetroEndColor3 = "MetroEndColor",
1644 HoverColor3 = "HoverColor",
1645 MouseDownColor3 = "MouseDownColor",
1646 BackgroundColor = "BackgroundColor3",
1647 Color = "BackgroundColor3"
1648 },
1649 function(Parent)
1650 local Proxy, Meta, Fields, Cs = VIn_CreateInstance(VIn_Data.Button);
1651 --Proxy Setup
1652 Fields.ClassName = "VeraniumButton";
1653 Fields.Parent = Parent;
1654 Fields.ZIndex = VLb_Defaults.ZIndex;
1655 Fields.BackgroundColor3 = VLb_Defaults.BackgroundColor;
1656 Fields.Image = "";
1657
1658 Fields.MetroStyle = VLb_Defaults.MetroStyle;
1659
1660 Fields.MetroStartColor3 = VLb_Defaults.HighlightColor;
1661 Fields.MetroEndColor = VLb_Defaults.HighlightColor;
1662
1663 Fields.MetroStartTransparency = 0.5;
1664 Fields.MetroEndTransparency = 1;
1665
1666 Fields.MetroTweenInfo = TweenInfo.new(
1667 0.5,
1668 Enum.EasingStyle.Sine,
1669 Enum.EasingDirection.Out
1670 );
1671 Fields.AutoButtonColor = false;
1672 Fields.ClipsDescendants = false;
1673 Fields.HoverColor3 = VLb_Defaults.SecondaryColor;
1674 Fields.MouseDownColor3 = VLb_Defaults.SecondaryColor;
1675 Fields.HoverImage = "";
1676 Fields.MouseDownImage = "";
1677 --Methods Setup
1678 Fields.Redraw = VIn_Data.Button.Redraw;
1679 --Elements Creation
1680 local Main = Instance.new("Frame", GetPInstance(Parent));
1681 local Background = VIn_Data.Background.Constructor(Main);
1682 local ImageRender = Instance.new("ImageLabel", Main);
1683 local TextRender = Instance.new("TextButton", Main);
1684 --Main Setup
1685 Main.BackgroundTransparency = 1;
1686 Main.BorderSizePixel = 0;
1687 Main.Name = "VeraniumButton";
1688 Main.Size = UDim2.new(0, 105, 0, 25);
1689 --TextRender Setup
1690 TextRender.Name = _PREFIX.."TextRender";
1691 TextRender.Text = "Veranium Button";
1692 TextRender.BackgroundTransparency = 1;
1693 TextRender.BorderSizePixel = 0;
1694 TextRender.Size = UDim2.new(1, 0, 1, 0);
1695 TextRender.Position = UDim2.new(0.5, 0, 0.5, 0);
1696 TextRender.AnchorPoint = Vector2.new(0.5, 0.5);
1697 TextRender.AutoButtonColor = false;
1698 --TextRender Defaults
1699 TextRender.TextColor3 = VLb_Defaults.TextColor;
1700 TextRender.TextTransparency = VLb_Defaults.TextTransparency;
1701 TextRender.Font = VLb_Defaults.Font;
1702
1703 TextRender.TextStrokeColor3 = VLb_Defaults.TextStrokeColor;
1704 TextRender.TextStrokeTransparency = VLb_Defaults.TextStrokeTransparency;
1705
1706 TextRender.TextXAlignment = VLb_Defaults.TextXAlignment;
1707 TextRender.TextYAlignment = VLb_Defaults.TextYAlignment;
1708 --ImageRender Setup
1709 ImageRender.Name = _PREFIX.."ImageRender";
1710 ImageRender.Image = "";
1711 ImageRender.BackgroundTransparency = 1;
1712 ImageRender.BorderSizePixel = 0;
1713 ImageRender.Size = UDim2.new(1, 0, 1, 0);
1714 ImageRender.Position = UDim2.new(0.5, 0, 0.5, 0);
1715 ImageRender.AnchorPoint = Vector2.new(0.5, 0.5);
1716 --ChangedSignal
1717 Cs.Parent = Main;
1718 --Connections
1719 TextRender.MouseEnter:Connect(function()
1720 if Fields.AutoButtonColor then
1721 Background.BackgroundColor3 = Fields.HoverColor3;
1722 ImageRender.Image = Fields.HoverImage;
1723 end;
1724 end);
1725
1726 TextRender.MouseLeave:Connect(function()
1727 if Fields.AutoButtonColor then
1728 Background.BackgroundColor3 = Fields.BackgroundColor3;
1729 ImageRender.Image = Fields.Image;
1730 end;
1731 end);
1732
1733 local MetroCircle;
1734
1735 TextRender.MouseButton1Down:Connect(function()
1736 if Fields.AutoButtonColor then
1737 Background.BackgroundColor3 = Fields.MouseDownColor3;
1738 ImageRender.Image = Fields.MouseDownImage;
1739 end;
1740 end);
1741
1742 TextRender.MouseButton1Up:Connect(function(X, Y)
1743 if Fields.AutoButtonColor then
1744 Background.BackgroundColor3 = Fields.HoverColor3;
1745 ImageRender.Image = Fields.HoverImage;
1746 end;
1747 if Fields.MetroStyle then
1748 Main.ClipsDescendants = true;
1749 MetroCircle = Instance.new("ImageLabel", Main);
1750 MetroCircle.Name = _PREFIX.."MetroCircle";
1751 MetroCircle.ImageColor3 = Fields.MetroStartColor3;
1752 MetroCircle.ImageTransparency = Fields.MetroStartTransparency;
1753 MetroCircle.Image = "rbxassetid://3457843087";
1754 MetroCircle.BackgroundTransparency = 1;
1755 MetroCircle.BorderSizePixel = 0;
1756 MetroCircle.AnchorPoint = Vector2.new(0.5, 0.5);
1757 MetroCircle.Position = UDim2.new(
1758 0,
1759 X-Main.AbsolutePosition.X,
1760 0,
1761 Y-Main.AbsolutePosition.Y-36
1762 );
1763 MetroCircle.Size = UDim2.new(0, 5, 0, 5);
1764 local TargetSize = math.floor(math.max(
1765 Main.AbsoluteSize.X,
1766 Main.AbsoluteSize.Y
1767 )*1.5);
1768 TweenService:Create(
1769 MetroCircle,
1770 Fields.MetroTweenInfo,
1771 {
1772 ImageTransparency = Fields.MetroEndTransparency,
1773 ImageColor3 = Fields.MetroEndColor3,
1774 Size = UDim2.new(
1775 0,
1776 TargetSize,
1777 0,
1778 TargetSize
1779 )
1780 }
1781 ):Play();
1782 Debris:AddItem(MetroCircle, Fields.MetroTweenInfo.Time+0.1);
1783 local MetroLocation = MetroCircle;
1784 wait(Fields.MetroTweenInfo.Time+0.1);
1785 if MetroLocation == MetroCircle then
1786 MetroLocation, MetroCircle = nil;
1787 Main.ClipsDescendants = Fields.ClipsDescendants;
1788 end;
1789 end;
1790 end);
1791 --MetaData Setup
1792 Meta.___Instance = Main;
1793 Meta.___Base2D = Main;
1794 Meta.___Background = Background;
1795 Meta.___TextRender = TextRender;
1796 Meta.___CHitbox = TextRender;
1797 Meta.___ImageRender = ImageRender;
1798 --First Draw
1799 VIn_Data.Button.Redraw(Proxy);
1800
1801 return Proxy;
1802 end,
1803 function(self, Field, Value)
1804 --Setup
1805 local Meta = GetMeta(self);
1806 local Main = Meta.___Instance;
1807 local Fields = Meta.___Fields;
1808 local Background = Meta.___Background;
1809 local ImageRender = Meta.___ImageRender;
1810 --ZIndex
1811 if Field == nil or Field == "ZIndex" then
1812 Main.ZIndex = Fields.ZIndex;
1813 if Field then return; end;
1814 end;
1815 --BackgroundColor3
1816 if Field == nil or Field == "BackgroundColor3" then
1817 Background.BackgroundColor3 = Fields.BackgroundColor3;
1818 if Field then return; end;
1819 end;
1820 --Image
1821 if Field == nil or Field == "Image" then
1822 ImageRender.Image = Fields.Image;
1823 if Field then return; end;
1824 end;
1825 --ClipsDescendants
1826 if Field == nil or Field == "ClipsDescendants" then
1827 Main.ClipsDescendants = Fields.ClipsDescendants;
1828 if Field then return; end;
1829 end;
1830 end,
1831 {
1832
1833 }
1834);
1835
1836--[[MetroDirection Instructions:
1837 The value given is a UDim2.
1838 X[0]: StartX Location
1839 X[1]: StartY Location
1840 Y[0]: EndX Location
1841 Y[1]: EndY Location
1842
1843 Locations can be values from 0-1 (usually 1, 0.5 or 0)
1844 1 = Start
1845 0.5 = Center
1846 0 = End
1847
1848 1 1 0 1
1849 -1 0
1850
1851 Examples:
1852 UDim2.new(0, 0, 1, 0)
1853 This refers to a MetroLine that starts from TopLeft(0, 0) to TopRight(1, 0)
1854 The default value is UDim2.new(0, 1, 1, 1)
1855]]
1856
1857VIn_CreateClass("TextBox",
1858 {
1859 --Main
1860 Parent = "\2\1\0",
1861 ClassName = "\3\0\1string",
1862 BackgroundColor3 = "\4\0\0Color3",
1863 AutoTextBoxColor = "\3\0\0boolean",
1864 FocusedColor3 = "\4\0\0Color3",
1865 PasswordChar = "\3\0\0string",
1866 TextTransparency = "\3\0\0number",
1867 --Metro Properties
1868 MetroStyle = "\3\0\0boolean",
1869 MetroDirection = "\4\0\0UDim2",
1870 MetroStartColor3 = "\4\0\0Color3",
1871 MetroEndColor3 = "\4\0\0Color3",
1872 MetroStartTransparency = "\3\0\0number",
1873 MetroEndTransparency = "\3\0\0number",
1874 MetroStartSize = "\3\0\0number",
1875 MetroEndSize = "\3\0\0number",
1876 MetroTweenInfo = "\4\0\0TweenInfo",
1877 --Methods
1878 Redraw = "\3\0\1function"
1879 },
1880 {
1881 MetroStartColor = "MetroStartColor3",
1882 MetroEndColor = "MetroEndColor",
1883 },
1884 function(Parent)
1885 local Proxy, Meta, Fields, Cs = VIn_CreateInstance(VIn_Data.TextBox);
1886 --Proxy Setup
1887 Fields.ClassName = "VeraniumTextBox";
1888 Fields.Parent = Parent;
1889 Fields.BackgroundColor3 = VLb_Defaults.BackgroundColor;
1890 Fields.AutoTextBoxColor = true;
1891 Fields.FocusedColor3 = VLb_Defaults.SecondaryColor;
1892 Fields.PasswordChar = "";
1893 Fields.TextTransparency = VLb_Defaults.TextTransparency or 0;
1894
1895 Fields.MetroStyle = true;
1896
1897 Fields.MetroStartColor3 = VLb_Defaults.HighlightColor;
1898 Fields.MetroEndColor3 = VLb_Defaults.HighlightColor;
1899
1900 Fields.MetroStartTransparency = 0;
1901 Fields.MetroEndTransparency = 0;
1902
1903 Fields.MetroStartSize = 3;
1904 Fields.MetroEndSize = 3;
1905 Fields.MetroDirection = UDim2.new(0, 1, 1, 1);
1906
1907 Fields.MetroTweenInfo = TweenInfo.new(
1908 0.5,
1909 Enum.EasingStyle.Sine,
1910 Enum.EasingDirection.Out
1911 );
1912 --Methods Setup
1913 Fields.Redraw = VIn_Data.TextBox.Redraw;
1914 --Elements Creation
1915 local Main = Instance.new("Frame", GetPInstance(Parent));
1916 local Background = VIn_Data.Background.Constructor(Main);
1917 local MetroClip = Instance.new("Frame", Main);
1918 local MetroCont = Instance.new("Frame", MetroClip)
1919 local MetroBG = VIn_Data.Background.Constructor(MetroCont);
1920 local TextRender = Instance.new("TextBox", Main);
1921 local PasswordChar = Instance.new("TextLabel", Main);
1922 --Main Setup
1923 Main.BackgroundTransparency = 1;
1924 Main.BorderSizePixel = 0;
1925 Main.Name = "VeraniumTextBox";
1926 Main.Size = UDim2.new(0, 105, 0, 25);
1927 Main.ZIndex = VLb_Defaults.ZIndex;
1928 --MetroClip Setup
1929 MetroClip.BackgroundTransparency = 1;
1930 MetroClip.BorderSizePixel = 0;
1931 MetroClip.Name = _PREFIX.."MetroClip";
1932 MetroClip.ClipsDescendants = true;
1933 MetroClip.Changed:Connect(function()
1934 MetroBG.BackgroundColor3 = MetroClip.BackgroundColor3;
1935 MetroBG.BackgroundTransparency = MetroClip.BorderColor3.r;
1936 end);
1937 --MetroCont Setup
1938 MetroCont.BackgroundTransparency = 1;
1939 MetroCont.BorderSizePixel = 0;
1940 MetroCont.Name = _PREFIX.."MetroCont";
1941 --TextRender Setup
1942 TextRender.Name = _PREFIX.."TextRender";
1943 TextRender.Text = "Veranium TextBox";
1944 TextRender.BackgroundTransparency = 1;
1945 TextRender.BorderSizePixel = 0;
1946 TextRender.Size = UDim2.new(1, 0, 1, 0);
1947 TextRender.Position = UDim2.new(0.5, 0, 0.5, 0);
1948 TextRender.AnchorPoint = Vector2.new(0.5, 0.5);
1949 --TextRender Defaults
1950 TextRender.TextColor3 = VLb_Defaults.TextColor;
1951 TextRender.TextTransparency = VLb_Defaults.TextTransparency;
1952 TextRender.Font = VLb_Defaults.Font;
1953
1954 TextRender.TextStrokeColor3 = VLb_Defaults.TextStrokeColor;
1955 TextRender.TextStrokeTransparency = VLb_Defaults.TextStrokeTransparency;
1956
1957 TextRender.TextXAlignment = VLb_Defaults.TextXAlignment;
1958 TextRender.TextYAlignment = VLb_Defaults.TextYAlignment;
1959
1960 TextRender.PlaceholderColor3 = VLb_Defaults.PlaceholderColor;
1961 --PasswordChar Setup
1962 PasswordChar.Name = _PREFIX.."PasswordChar";
1963 PasswordChar.Text = "";
1964 PasswordChar.BackgroundTransparency = 1;
1965 PasswordChar.BorderSizePixel = 0;
1966 PasswordChar.Size = UDim2.new(1, 0, 1, 0);
1967 PasswordChar.Position = UDim2.new(0.5, 0, 0.5, 0);
1968 PasswordChar.AnchorPoint = Vector2.new(0.5, 0.5);
1969 --PasswordChar Defaults
1970 PasswordChar.TextColor3 = VLb_Defaults.TextColor;
1971 PasswordChar.TextTransparency = VLb_Defaults.TextTransparency;
1972 PasswordChar.Font = VLb_Defaults.Font;
1973
1974 PasswordChar.TextStrokeColor3 = VLb_Defaults.TextStrokeColor;
1975 PasswordChar.TextStrokeTransparency = VLb_Defaults.TextStrokeTransparency;
1976
1977 PasswordChar.TextXAlignment = VLb_Defaults.TextXAlignment;
1978 PasswordChar.TextYAlignment = VLb_Defaults.TextYAlignment;
1979 --ChangedSignal
1980 Cs.Parent = Main;
1981 --Connections
1982 TextRender.Changed:Connect(function(Field)
1983 if Field == "Text" then
1984 if Fields.PasswordChar == "" then
1985 return;
1986 end;
1987 local Lenght = #TextRender.Text;
1988 local PChr0 = Fields.PasswordChar;
1989 local PChr = "";
1990 for Chars = 1, Lenght do
1991 PChr = PChr..PChr0;
1992 end;
1993 if TextRender.Text == "" then
1994 TextRender.TextTransparency = Fields.TextTransparency;
1995 PasswordChar.TextTransparency = 1;
1996 else
1997 TextRender.TextTransparency = 1;
1998 PasswordChar.TextTransparency = Fields.TextTransparency;
1999 end;
2000 PasswordChar.Text = PChr;
2001 return;
2002 elseif Field == "TextTransparency" then
2003 if Fields.PasswordChar == "" then
2004 PasswordChar.TextTransparency = 1;
2005 return;
2006 end;
2007 end;
2008 if VIn_SReg.IVRouting[Field] == "___TextRender" then
2009 pcall(function()
2010 PasswordChar[Field] = TextRender[Field];
2011 end);
2012 end;
2013 end);
2014 TextRender.FocusLost:Connect(function()
2015 if Fields.AutoTextBoxColor then
2016 Background.BackgroundColor3 = Fields.BackgroundColor3;
2017 end;
2018 if Fields.MetroStyle then
2019 local Position, AnchorPoint, MetroDirection, Size, CornerSize;
2020 MetroClip.BackgroundColor3 = Fields.MetroEndColor3;
2021 MetroClip.BorderColor3 = Color3.new(Fields.MetroEndTransparency, 0, 0);
2022 MetroBG.CornerSize = Background.CornerSize;
2023 Size = Background.AbsoluteSize;
2024 CornerSize = (Background.CornerSize + Background.BorderSizePixel)*2;
2025 MetroCont.Size = UDim2.new(
2026 0, Size.X +CornerSize,
2027 0, Size.Y +CornerSize
2028 );
2029 Size = Background.BorderSizePixel;
2030 MetroDirection = Fields.MetroDirection;
2031 Position = UDim2.new(
2032 MetroDirection.X.Scale,
2033 0,
2034 MetroDirection.X.Offset,
2035 0
2036 );
2037 AnchorPoint = Vector2.new(
2038 MetroDirection.X.Scale,
2039 MetroDirection.X.Offset
2040 );
2041 MetroClip.Position = Position;
2042 MetroClip.AnchorPoint = AnchorPoint;
2043
2044 Position = UDim2.new(
2045 MetroDirection.X.Scale,
2046 0,
2047 MetroDirection.X.Offset,
2048 0
2049 );
2050 MetroCont.Position = Position;
2051 MetroCont.AnchorPoint = AnchorPoint;
2052
2053 local SizeConstraint, ThicknessConstraint;
2054 local TX, TY, UT;
2055 TX = MetroDirection.Y.Scale - MetroDirection.X.Scale;
2056 TY = MetroDirection.Y.Offset - MetroDirection.X.Offset;
2057 UT = {
2058 X0 = 0, X1 = 0,
2059 Y0 = 0, Y1 = 0
2060 };
2061
2062 if math.abs(TX) >= math.abs(TY) then
2063 SizeConstraint, ThicknessConstraint = "X", "Y";
2064 else
2065 SizeConstraint, ThicknessConstraint = "Y", "X";
2066 end;
2067
2068 UT[SizeConstraint.."0"] = 1;
2069 UT[ThicknessConstraint.."1"] = 1;
2070
2071 local MetroTween = TweenService:Create(
2072 MetroClip,
2073 Fields.MetroTweenInfo,
2074 {
2075 Size = UDim2.new(
2076 0,
2077 UT.X1*Fields.MetroStartSize,
2078 0,
2079 UT.Y1*Fields.MetroStartSize
2080 ),
2081 BackgroundColor3 = Fields.MetroStartColor3,
2082 BorderColor3 = Color3.new(Fields.MetroStartTransparency)
2083 }
2084 );
2085 MetroTween:Play();
2086 CornerSize = nil;
2087 end;
2088 end);
2089 TextRender.Focused:Connect(function()
2090 if Fields.AutoTextBoxColor then
2091 Background.BackgroundColor3 = Fields.FocusedColor3;
2092 end;
2093 if Fields.MetroStyle then
2094 local Position, AnchorPoint, MetroDirection, Size, CornerSize;
2095 MetroClip.BackgroundColor3 = Fields.MetroStartColor3;
2096 MetroClip.BorderColor3 = Color3.new(Fields.MetroStartTransparency, 0, 0);
2097 MetroBG.CornerSize = Background.CornerSize;
2098 Size = Background.AbsoluteSize;
2099 CornerSize = (Background.CornerSize --[[+ Background.BorderSizePixel]])*2;
2100 MetroCont.Size = UDim2.new(
2101 0, Size.X +CornerSize,
2102 0, Size.Y +CornerSize
2103 );
2104 Size = Background.BorderSizePixel;
2105 CornerSize = function(Offset)
2106 if Offset == 1 then
2107 return -1;
2108 end;
2109 return 1;
2110 end;
2111 MetroDirection = Fields.MetroDirection;
2112 Position = UDim2.new(
2113 MetroDirection.X.Scale,
2114 CornerSize(MetroDirection.X.Scale)*Size,
2115 MetroDirection.X.Offset,
2116 CornerSize(MetroDirection.X.Offset)*Size
2117 );
2118 AnchorPoint = Vector2.new(
2119 MetroDirection.X.Scale,
2120 MetroDirection.X.Offset
2121 );
2122 MetroClip.Position = Position;
2123 MetroClip.AnchorPoint = AnchorPoint;
2124
2125 Position = UDim2.new(
2126 MetroDirection.X.Scale,
2127 0,
2128 MetroDirection.X.Offset,
2129 0
2130 );
2131 MetroCont.Position = Position;
2132 MetroCont.AnchorPoint = AnchorPoint;
2133
2134 local SizeConstraint, ThicknessConstraint;
2135 local TX, TY, UT;
2136 TX = MetroDirection.Y.Scale - MetroDirection.X.Scale;
2137 TY = MetroDirection.Y.Offset - MetroDirection.X.Offset;
2138 UT = {
2139 X0 = 0, X1 = 0,
2140 Y0 = 0, Y1 = 0
2141 };
2142
2143 if math.abs(TX) >= math.abs(TY) then
2144 SizeConstraint, ThicknessConstraint = "X", "Y";
2145 else
2146 SizeConstraint, ThicknessConstraint = "Y", "X";
2147 end;
2148
2149 UT[SizeConstraint.."0"] = 1;
2150 UT[ThicknessConstraint.."1"] = 1;
2151
2152 MetroClip.Size = UDim2.new(
2153 0,
2154 UT.X1*Fields.MetroStartSize,
2155 0,
2156 UT.Y1*Fields.MetroStartSize
2157 );
2158
2159 local MetroTween = TweenService:Create(
2160 MetroClip,
2161 Fields.MetroTweenInfo,
2162 {
2163 Size = UDim2.new(
2164 UT.X0,
2165 UT.X1*Fields.MetroEndSize,
2166 UT.Y0,
2167 UT.Y1*Fields.MetroEndSize
2168 ),
2169 BackgroundColor3 = Fields.MetroEndColor3,
2170 BorderColor3 = Color3.new(Fields.MetroEndTransparency)
2171 }
2172 );
2173 MetroTween:Play();
2174 CornerSize = nil;
2175 end;
2176 end);
2177 --MetaData Setup
2178 Meta.___Instance = Main;
2179 Meta.___Base2D = Main;
2180 Meta.___Background = Background;
2181 Meta.___TextRender = TextRender;
2182 Meta.___TextBox = TextRender;
2183
2184 Meta.PasswordChar = PasswordChar;
2185 Meta.MetroClip = MetroClip;
2186 Meta.MetroCont = MetroCont;
2187 Meta.MetroBG = MetroBG;
2188 --First Draw
2189 VIn_Data.TextBox.Redraw(Proxy);
2190
2191 return Proxy;
2192 end,
2193 function(self, Field, Value)
2194 --Setup
2195 local Meta = GetMeta(self);
2196 local Main = Meta.___Instance;
2197 local Fields = Meta.___Fields;
2198 local Background = Meta.___Background;
2199 local TextBox = Meta.___TextBox;
2200
2201 local PasswordChar = Meta.PasswordChar;
2202 local MetroClip = Meta.MetroClip;
2203 local MetroCont = Meta.MetroCont;
2204 local MetroBG = Meta.MetroBG;
2205 --BackgroundColor3
2206 if (Field == nil or Field == "BackgroundColor3") and (not Fields.AutoTextBoxColor or not TextBox:IsFocused()) then
2207 Background.BackgroundColor3 = Fields.BackgroundColor3;
2208 if Field then return; end;
2209 end;
2210 --TextTransparency | PasswordChar
2211 if (Field == nil) or (Field == "TextTransparency" or Field == "PasswordChar") then
2212 if Fields.PasswordChar == "" then
2213 PasswordChar.TextTransparency = 1;
2214 TextBox.TextTransparency = Fields.TextTransparency;
2215 else
2216 if TextBox.Text == "" then
2217 TextBox.TextTransparency = Fields.TextTransparency;
2218 PasswordChar.TextTransparency = 1;
2219 if Field then return; end;
2220 else
2221 TextBox.TextTransparency = 1;
2222 PasswordChar.TextTransparency = Fields.TextTransparency;
2223 end;
2224 local Lenght = #TextBox.Text;
2225 local PChr0 = Fields.PasswordChar;
2226 local PChr = "";
2227 for Chars = 1, Lenght do
2228 PChr = PChr..PChr0;
2229 end;
2230 PasswordChar.Text = PChr;
2231 end;
2232 if Field then return; end;
2233 end;
2234 --AutoTextBoxColor | FocusedColor3
2235 if (Field == nil or Field == "AutoTextBoxColor" or Field == "FocusedColor3") and TextBox.IsFocused then
2236 Background.BackgroundColor3 = Fields.FocusedColor3;
2237 if Field then return; end;
2238 end;
2239 end,
2240 {
2241
2242 }
2243);
2244
2245--Standard Instances
2246VIn_CreateClass("Slider", {
2247 --Main
2248 Parent = "\2\1\0",
2249 ClassName = "\3\0\1string",
2250
2251 --Functionality
2252 MinValue = "\3\0\0number",
2253 MaxValue = "\3\0\0number",
2254 Value = "\3\0\0number",
2255 Step = "\3\0\0number",
2256 Size = "\4\0\0Vector2",
2257
2258 --Metro Properties
2259 MetroStyle = "\3\0\0boolean",
2260 MetroTweenInfo = "\4\0\0TweenInfo",
2261
2262 --MISC
2263 SliderType = "\0\0\0SliderType",
2264 SideSheet = "\3\0\0string",
2265 MarkupImage = "\3\0\0string",
2266
2267 --Appearance
2268 BarColor3 = "\4\0\0Color3",
2269 BarTransparency = "\3\0\0number",
2270 BarThickness = "\3\0\0number",
2271
2272 MarkupColor3 = "\4\0\0Color3",
2273 MarkupTransparency = "\3\0\0number",
2274 MarkupSize = "\3\0\0number",
2275
2276 --Eevents
2277 DragEnd = "\4\0\1Instance",
2278 DragStart = "\4\0\1Instance",
2279 ValueChanged = "\4\0\1Instance",
2280 --Methods
2281 Redraw = "\3\0\1function",
2282 RelocateMarkup = "\3\0\1function"
2283 },
2284 {
2285
2286 },
2287 function(Parent)
2288 local Proxy, Meta, Fields, Cs = VIn_CreateInstance(VIn_Data.Slider);
2289 local Connections = {};
2290 --Proxy Setup
2291 Fields.ClassName = "VeraniumSlider";
2292 Fields.Parent = Parent;
2293
2294 Fields.MinValue = 0;
2295 Fields.MaxValue = 1;
2296 Fields.Value = 0.5;
2297 Fields.Step = 0.01;
2298 Fields.Size = Vector2.new(0, 100);
2299
2300 Fields.MetroStyle = true;
2301 Fields.MetroTweenInfo = TweenInfo.new(
2302 0.25,
2303 Enum.EasingStyle.Sine,
2304 Enum.EasingDirection.Out
2305 );
2306
2307 Fields.SliderType = VLb_Enums.SliderType.Round;
2308 Fields.SideSheet = "";
2309 Fields.MarkupImage = "";
2310
2311 Fields.BarColor3 = VLb_Defaults.SecondaryColor;
2312 Fields.BarTransparency = 0;
2313 Fields.BarThickness = 10;
2314
2315 Fields.MarkupColor3 = VLb_Defaults.HighlightColor;
2316 Fields.MarkupTransparency = 0;
2317 Fields.MarkupSize = 0.6;
2318 --Methods Setup
2319 Fields.Redraw = VIn_Data.Slider.Redraw;
2320 Fields.RelocateMarkup = VIn_Data.Slider.RelocateMarkup;
2321 --Elements Creation
2322 local Main = Instance.new("Frame", GetPInstance(Parent));
2323 local Bar = Instance.new("Frame", Main);
2324 local LeftSide = Instance.new("ImageLabel", Bar);
2325 local RightSide = Instance.new("ImageLabel", Bar);
2326 local Markup = Instance.new("ImageLabel", Bar);
2327 local Hitbox = Instance.new("TextButton", Main);
2328
2329 local DragEnd, DragStart, ValueChanged = Instance.new("BindableEvent", Main);
2330 DragStart = DragEnd:Clone();
2331 ValueChanged = DragEnd:Clone();
2332 --Main Setup
2333 Main.BackgroundTransparency = 1;
2334 Main.BorderSizePixel = 0;
2335 Main.Name = "VeraniumSlider";
2336 Main.ZIndex = VLb_Defaults.ZIndex;
2337 --Bar Setup
2338 Bar.BorderSizePixel = 0;
2339 Bar.AnchorPoint = Vector2.new(0.5, 0.5);
2340 Bar.Position = UDim2.new(0.5, 0, 0.5, 0);
2341 Bar.Name = _PREFIX.."Bar";
2342 --LeftSide Setup
2343 LeftSide.BackgroundTransparency = 1;
2344 LeftSide.BorderSizePixel = 0;
2345 LeftSide.AnchorPoint = Vector2.new(1, 0.5);
2346 LeftSide.Position = UDim2.new(0, 0, 0.5, 0);
2347 LeftSide.ImageRectSize = Vector2.new(400, 800);
2348 LeftSide.ImageRectOffset = Vector2.new(0, 0);
2349 LeftSide.Name = _PREFIX.."LeftSide";
2350 --RightSide Setup
2351 RightSide.BackgroundTransparency = 1;
2352 RightSide.BorderSizePixel = 0;
2353 RightSide.AnchorPoint = Vector2.new(0, 0.5);
2354 RightSide.Position = UDim2.new(1, 0, 0.5, 0);
2355 RightSide.ImageRectSize = Vector2.new(400, 800);
2356 RightSide.ImageRectOffset = Vector2.new(400, 0);
2357 RightSide.Name = _PREFIX.."RightSide";
2358 --Markup Setup
2359 Markup.BackgroundTransparency = 1;
2360 Markup.BorderSizePixel = 0;
2361 Markup.AnchorPoint = Vector2.new(0.5, 0.5);
2362 Markup.Name = _PREFIX.."Markup";
2363 --Hitbox Setup
2364 Hitbox.Text = "";
2365 Hitbox.TextTransparency = 1;
2366 Hitbox.BackgroundTransparency = 1;
2367 Hitbox.BorderSizePixel = 0;
2368 Hitbox.AnchorPoint = Vector2.new(0.5, 0.5);
2369 Hitbox.Position = UDim2.new(0.5, 0, 0.5, 0);
2370 Hitbox.Size = UDim2.new(1, 5, 1, 5);
2371 Hitbox.Name = _PREFIX.."Hitbox";
2372 --Events
2373 DragEnd.Name = _PREFIX.."DragEnd";
2374 DragStart.Name = _PREFIX.."DragStart";
2375 ValueChanged.Name = _PREFIX.."ValueChanged";
2376
2377 DragStart.Parent, ValueChanged.Parent = Main, Main;
2378
2379 Fields.DragEnd = DragEnd.Event;
2380 Fields.DragStart = DragStart.Event;
2381 Fields.ValueChanged = ValueChanged.Event;
2382 --ChangedSignal
2383 Cs.Parent = Main;
2384 --Connections
2385 local IsDown = false;
2386 local function MoveMarkup()
2387 if IsDown then
2388 local X = Mouse.X - Bar.AbsolutePosition.X;
2389 Fields.Value = VLb_CVMath.Map(X, 0, Bar.AbsoluteSize.X, Fields.MinValue, Fields.MaxValue);
2390 if Fields.Value > Fields.MaxValue then
2391 Fields.Value = Fields.MaxValue;
2392 elseif Fields.Value < Fields.MinValue then
2393 Fields.Value = Fields.MinValue;
2394 end;
2395 if Fields.Step ~= 0 then
2396 Fields.Value = VLb_CVMath.Round(Fields.Value/Fields.Step)*Fields.Step
2397 end
2398 ValueChanged:Fire(Fields.Value);
2399 end;
2400
2401 if Fields.MetroStyle then
2402 TweenService:Create(
2403 Markup,
2404 Fields.MetroTweenInfo,
2405 {
2406 Position = UDim2.new(VLb_CVMath.Map(
2407 Fields.Value,
2408 Fields.MinValue,
2409 Fields.MaxValue, 0, 1
2410 ), 0, 0.5, 0)
2411 }
2412 ):Play();
2413 else
2414 Proxy:RelocateMarkup();
2415 end;
2416 end;
2417 Hitbox.MouseButton1Down:Connect(function()
2418 IsDown = true;
2419 DragStart:Fire();
2420 MoveMarkup();
2421 end);
2422 Connections[0] = UserInputService.InputEnded:Connect(function(Input)
2423 if Input.UserInputType == Enum.UserInputType.MouseButton1 and IsDown then
2424 IsDown = false;
2425 DragEnd:Fire();
2426 end;
2427 end);
2428 Connections[1] = Mouse.Move:Connect(MoveMarkup);
2429 Hitbox.MouseMoved:Connect(function(X)
2430
2431 end);
2432 --MetaData Setup
2433 Meta.___Instance = Main;
2434 Meta.___Base2D = Main;
2435 Meta.___Connection = Connections;
2436
2437 Meta.Bar = Bar;
2438 Meta.LeftSide = LeftSide;
2439 Meta.RightSide = RightSide;
2440 Meta.Markup = Markup;
2441 Meta.Hitbox = Hitbox;
2442 --First Draw
2443 VIn_Data.Slider.Redraw(Proxy);
2444
2445 return Proxy;
2446 end,
2447 function(self, Field, Value)
2448 --Setup
2449 local Meta = GetMeta(self);
2450 local Main = Meta.___Instance;
2451 local Fields = Meta.___Fields;
2452
2453 local Bar = Meta.Bar;
2454 local LeftSide = Meta.LeftSide;
2455 local RightSide = Meta.RightSide;
2456 local Markup = Meta.Markup;
2457 local Hitbox = Meta.Hitbox;
2458 --SliderType | SlideSheet | MarkupImage
2459 if (Field == nil or Field == "SliderType" or Field == "SlideSheet" or Field == "MarkupImage") then
2460 local SideSheet = VCf_GetEnumLValue("SliderType", Fields.SliderType);
2461 if SideSheet == "" then
2462 LeftSide.Image = Fields.SideSheet;
2463 RightSide.Image = Fields.SideSheet;
2464
2465 Markup.Image = Fields.MarkupImage;
2466 else
2467 LeftSide.Image = SideSheet;
2468 RightSide.Image = SideSheet;
2469
2470 Markup.Image = SideSheet;
2471 end;
2472 if Field then return; end;
2473 end;
2474 --BarColor3
2475 if Field == nil or Field == "BarColor3" then
2476 Bar.BackgroundColor3 = Fields.BarColor3;
2477 LeftSide.ImageColor3 = Fields.BarColor3;
2478 RightSide.ImageColor3 = Fields.BarColor3;
2479 if Field then return; end;
2480 end;
2481 --BarTransparency
2482 if Field == nil or Field == "BarTransparency" then
2483 Bar.BackgroundTransparency = Fields.BarTransparency;
2484 LeftSide.ImageTransparency = Fields.BarTransparency;
2485 RightSide.ImageTransparency = Fields.BarTransparency;
2486 if Field then return; end;
2487 end;
2488 --BarThickness | Size | MarkupSize
2489 if Field == nil or Field == "BarThickness" or Field == "Size" then
2490 Main.Size = UDim2.new(
2491 Fields.Size.X,
2492 Fields.Size.Y,
2493 0,
2494 Fields.BarThickness
2495 );
2496
2497 LeftSide.Size = UDim2.new(0, Fields.BarThickness/2, 1, 0);
2498 RightSide.Size = UDim2.new(0, Fields.BarThickness/2, 1, 0);
2499 Bar.Size = UDim2.new(
2500 1,
2501 -Fields.BarThickness,
2502 1,
2503 0
2504 );
2505
2506 local Size = math.min(Bar.AbsoluteSize.X, Bar.AbsoluteSize.Y)*Fields.MarkupSize;
2507 Markup.Size = UDim2.new(0, Size, 0, Size);
2508 if Field then return; end;
2509 end;
2510 --MarkupColor3
2511 if Field == nil or Field == "MarkupColor3" then
2512 Markup.ImageColor3 = Fields.MarkupColor3;
2513 if Field then return; end;
2514 end;
2515 --MarkupTransparency
2516 if Field == nil or Field == "MarkupTransparency" then
2517 Markup.ImageTransparency = Fields.MarkupTransparency;
2518 if Field then return; end;
2519 end;
2520 self:RelocateMarkup();
2521 end,
2522 {
2523 RelocateMarkup = function(Proxy)
2524 local Meta = GetMeta(Proxy)
2525 local Fields = Meta.___Fields
2526 local Markup = Meta.Markup
2527 if Fields.Step ~= 0 then
2528 Fields.Value = VLb_CVMath.Round(Fields.Value/Fields.Step)*Fields.Step
2529 end
2530 if Fields.Value > Fields.MaxValue then
2531 Fields.Value = Fields.MaxValue
2532 end
2533 if Fields.Value < Fields.MinValue then
2534 Fields.Value = Fields.MinValue
2535 end
2536 Markup.Position = UDim2.new(VLb_CVMath.Map(
2537 Fields.Value,
2538 Fields.MinValue,
2539 Fields.MaxValue, 0, 1
2540 ), 0, 0.5, 0)
2541 end
2542 }
2543);
2544
2545VIn_CreateClass("CheckBox",
2546 {
2547 --Main
2548 Parent = "\2\1\0",
2549 ClassName = "\3\0\1string",
2550 Checked = "\3\0\0boolean",
2551 Size = "\3\0\0number",
2552 LeftLabel = "\3\0\0boolean",
2553 LabelPadding = "\3\0\0number",
2554
2555 --Box Appearance
2556 StartBoxColor3 = "\4\0\0Color3",
2557 EndBoxColor3 = "\4\0\0Color3",
2558 StartBoxTransparency = "\3\0\0number",
2559 EndBoxTransparency = "\3\0\0number",
2560 CheckBoxType = "\0\0\0CheckBoxType",
2561 CheckBoxImage = "\3\0\0string",
2562 CheckBoxFill = "\3\0\0boolean",
2563
2564 --Check Appearance
2565 CheckImage = "\3\0\0string",
2566 StartCheckColor3 = "\4\0\0Color3",
2567 EndCheckColor3 = "\4\0\0Color3",
2568 StartCheckTransparency = "\3\0\0number",
2569 EndCheckTransparency = "\3\0\0number",
2570 StartCheckSize = "\3\0\0number",
2571 EndCheckSize = "\3\0\0number",
2572
2573 --Metro Style
2574 MetroStyle = "\3\0\0boolean",
2575 MetroTweenInfo = "\4\0\0TweenInfo",
2576
2577 --Events
2578 CheckChanged = "\4\0\1Instance",
2579
2580 --Methods
2581 Redraw = "\4\0\1function",
2582 CreateLabel = "\4\0\1function",
2583 Check = "\4\0\1function"
2584 },
2585 {
2586
2587 },
2588 function(Parent)
2589 local Proxy, Meta, Fields, Cs = VIn_CreateInstance(VIn_Data.CheckBox);
2590 --Proxy Setup
2591 Fields.ClassName = "VeraniumCheckBox";
2592 Fields.Parent = Parent;
2593 Fields.Checked = false;
2594 Fields.Size = 17;
2595 Fields.LeftLabel = false;
2596 Fields.LabelPadding = 2;
2597
2598 Fields.StartBoxColor3 = VLb_Defaults.SecondaryColor;
2599 Fields.EndBoxColor3 = VLb_Defaults.SecondaryColor;
2600 Fields.StartBoxTransparency = 0;
2601 Fields.EndBoxTransparency = 0;
2602 Fields.CheckBoxType = VLb_Enums.CheckBoxType.Smooth;
2603 Fields.CheckBoxImage = "";
2604 Fields.CheckBoxFill = true;
2605
2606 Fields.CheckImage = "";
2607 Fields.StartCheckColor3 = VLb_Defaults.HighlightColor;
2608 Fields.EndCheckColor3 = VLb_Defaults.HighlightColor;
2609 Fields.StartCheckTransparency = 1;
2610 Fields.EndCheckTransparency = 0;
2611 Fields.StartCheckSize = 0;
2612 Fields.EndCheckSize = 0.5;
2613
2614 Fields.MetroStyle = true;
2615 Fields.MetroTweenInfo = TweenInfo.new(
2616 0.15,
2617 Enum.EasingStyle.Sine,
2618 Enum.EasingDirection.Out
2619 );
2620 --Methods Setup
2621 Fields.Redraw = VIn_Data.CheckBox.Redraw;
2622 Fields.Check = VIn_Data.CheckBox.Check;
2623 Fields.CreateLabel = VIn_Data.CheckBox.CreateLabel;
2624 --Elements Creation
2625 local Main = Instance.new("Frame", GetPInstance(Parent));
2626 local Box = Instance.new("ImageLabel", Main);
2627 local Check = Instance.new("ImageLabel", Box);
2628 local Hitbox = Instance.new("TextButton", Main);
2629
2630 local CheckChanged = Instance.new("BindableEvent", Main);
2631 --Main Setup
2632 Main.BackgroundTransparency = 1;
2633 Main.BorderSizePixel = 0;
2634 Main.Name = "VeraniumCheckBox";
2635 Main.ZIndex = VLb_Defaults.ZIndex;
2636 Main.Size = UDim2.new(0, 17, 0, 17);
2637 --Box Setup
2638 Box.BackgroundTransparency = 1;
2639 Box.BorderSizePixel = 0;
2640 Box.Size = UDim2.new(1, 0, 1, 0);
2641 Box.Position = UDim2.new(0.5, 0, 0.5, 0);
2642 Box.AnchorPoint = Vector2.new(0.5, 0.5);
2643 Box.Name = _PREFIX.."Box";
2644 --Check Setup
2645 Check.BackgroundTransparency = 1;
2646 Check.BorderSizePixel = 0;
2647 Check.Position = UDim2.new(0.5, 0, 0.5, 0);
2648 Check.AnchorPoint = Vector2.new(0.5, 0.5);
2649 Check.Name = _PREFIX.."CheckMark"
2650 --Hitbox Setup
2651 Hitbox.BackgroundTransparency = 1;
2652 Hitbox.Text = "";
2653 Hitbox.AnchorPoint = Vector2.new(0.5, 0.5);
2654 Hitbox.Position = UDim2.new(0.5, 0, 0.5, 0);
2655 Hitbox.Size = UDim2.new(1, 5, 1, 5);
2656 Hitbox.Name = _PREFIX.."Hitbox";
2657 --Events
2658 CheckChanged.Name = _PREFIX.."CheckChanged";
2659
2660 Fields.CheckChanged = CheckChanged.Event;
2661 --ChangedSignal
2662 Cs.Parent = Main;
2663 --Connections
2664 Hitbox.MouseButton1Down:Connect(function()
2665 Fields.Checked = not Fields.Checked;
2666 CheckChanged:Fire(true);
2667 Proxy:Check();
2668 end);
2669 --MetaData Setup
2670 Meta.___Instance = Main;
2671 Meta.___Base2D = Main;
2672
2673 Meta.Box = Box;
2674 Meta.Check = Check;
2675 Meta.Hitbox = Hitbox;
2676
2677 Meta.CheckChanged = CheckChanged;
2678 --First Draw
2679 Proxy:Check(false);
2680 VIn_Data.CheckBox.Redraw(Proxy);
2681
2682 return Proxy;
2683 end,
2684 function(self, Field, Value)
2685 --Setup
2686 local Meta = GetMeta(self);
2687 local Main = Meta.___Instance;
2688 local Fields = Meta.___Fields;
2689 local Label = Meta.___TextRender;
2690
2691 local Box = Meta.Box;
2692 local Check = Meta.Check;
2693 local Hitbox = Meta.Hitbox;
2694
2695 local CheckChanged = Meta.CheckChanged;
2696
2697 --Size
2698 if Field == nil or Field == "Size" then
2699 Main.Size = UDim2.new(0, Fields.Size, 0, Fields.Size);
2700 end;
2701
2702 --Label | LeftLabel | LabelPadding
2703 if (Field == nil or Field == "Label"
2704 or Field == "LeftLabel" or Field == "LabelPadding") and Label then
2705 if Fields.LeftLabel then
2706 Label.AnchorPoint = Vector2.new(1, 0.5);
2707 Label.Position = UDim2.new(0, -Fields.LabelPadding, 0.5, 0);
2708 Label.TextXAlignment = Enum.TextXAlignment.Right;
2709 else
2710 Label.AnchorPoint = Vector2.new(0, 0.5);
2711 Label.Position = UDim2.new(1, Fields.LabelPadding, 0.5, 0);
2712 Label.TextXAlignment = Enum.TextXAlignment.Left;
2713 end;
2714 end;
2715
2716 --Uhh... A lot...?
2717 if Field == nil or Field == "Checked"
2718 or Field == "StartBoxColor3" or Field == "EndBoxColor3"
2719 or Field == "StartBoxTransparency" or Field == "EndBoxTransparency"
2720 or Field == "StartCheckColor3" or Field == "EndCheckColor3"
2721 or Field == "StartCheckTransparency" or Field == "EndCheckTransparency"
2722 or Field == "StartCheckSize" or Field == "EndCheckSize" then
2723 if Field == "Checked" then
2724 CheckChanged:Fire(false);
2725 end;
2726 self:Check(false);
2727 if Field then return;end;
2728 end;
2729
2730 --Once more, a lot.
2731 if Field == nil or Field == "CheckBoxType" or Field == "CheckImage"
2732 or Field == "CheckBoxImage" or Field == "CheckBoxFill" then
2733 local Offset = VCf_GetEnumLValue("CheckBoxType", Fields.CheckBoxType);
2734 if Offset == 4 then
2735 Box.Image = Fields.CheckBoxImage;
2736 Box.ImageRectSize = Vector2.new(0, 0);
2737 Box.ImageRectOffset = Vector2.new(0, 0);
2738 else
2739 Box.Image = "rbxassetid://4018402187";
2740 Box.ImageRectSize = Vector2.new(100, 100);
2741 if Fields.CheckBoxFill then
2742 Box.ImageRectOffset = Vector2.new(Offset*100, 100);
2743 else
2744 Box.ImageRectOffset = Vector2.new(Offset*100, 0);
2745 end;
2746 end;
2747 if Fields.CheckImage == "" then
2748 Check.Image = "rbxassetid://4018402187";
2749 Check.ImageRectSize = Vector2.new(100, 100);
2750 if Offset == 4 then
2751 Check.ImageRectOffset = Vector2.new(0, 100);
2752 else
2753 Check.ImageRectOffset = Vector2.new(Offset*100, 100);
2754 end
2755 else
2756 Check.Image = Fields.CheckImage;
2757 Check.ImageRectSize = Vector2.new(0, 0);
2758 Check.ImageRectOffset = Vector2.new(0, 0);
2759 end;
2760 end;
2761 end,
2762 {
2763 CreateLabel = function(self, Text)
2764 --Setup
2765 local Meta = GetMeta(self);
2766 local Main = Meta.___Instance;
2767
2768 local Label = Instance.new("TextLabel", Main);
2769 Label.Text = Text;
2770 Label.Name = _PREFIX.."Label";
2771 Label.BackgroundTransparency = 1;
2772 Label.BorderSizePixel = 0;
2773 Label.Font = VLb_Defaults.Font;
2774 Label.TextColor3 = VLb_Defaults.TextColor;
2775 Label.TextTransparency = VLb_Defaults.TextTransparency;
2776 Label.TextYAlignment = Enum.TextYAlignment.Center;
2777 Label.Size = UDim2.new(0, 0, 1, 0);
2778
2779 Meta.___TextRender = Label;
2780
2781 self:Redraw("Label");
2782 end,
2783 Check = function(self, MetroStyle)
2784 --Setup
2785 local Meta = GetMeta(self);
2786 local Main = Meta.___Instance;
2787 local Fields = Meta.___Fields;
2788
2789 if MetroStyle == nil then
2790 MetroStyle = Fields.MetroStyle;
2791 end;
2792
2793 local Box = Meta.Box;
2794 local Check = Meta.Check;
2795 local BoxTarget, CheckTarget;
2796
2797 if not Fields.Checked then
2798 BoxTarget = {
2799 ImageColor3 = Fields.StartBoxColor3,
2800 ImageTransparency = Fields.StartBoxTransparency
2801 };
2802 CheckTarget = {
2803 ImageColor3 = Fields.StartCheckColor3,
2804 ImageTransparency = Fields.StartCheckTransparency,
2805 Size = UDim2.new(
2806 Fields.StartCheckSize,
2807 0,
2808 Fields.StartCheckSize,
2809 0
2810 )
2811 };
2812 else
2813 BoxTarget = {
2814 ImageColor3 = Fields.EndBoxColor3,
2815 ImageTransparency = Fields.EndBoxTransparency
2816 };
2817 CheckTarget = {
2818 ImageColor3 = Fields.EndCheckColor3,
2819 ImageTransparency = Fields.EndCheckTransparency,
2820 Size = UDim2.new(
2821 Fields.EndCheckSize,
2822 0,
2823 Fields.EndCheckSize,
2824 0
2825 )
2826 };
2827 end;
2828
2829 if MetroStyle then
2830 TweenService:Create(
2831 Box,
2832 Fields.MetroTweenInfo,
2833 {
2834 ImageColor3 = BoxTarget.ImageColor3,
2835 ImageTransparency = BoxTarget.ImageTransparency
2836 }
2837 ):Play();
2838 TweenService:Create(
2839 Check,
2840 Fields.MetroTweenInfo,
2841 {
2842 ImageColor3 = CheckTarget.ImageColor3,
2843 ImageTransparency = CheckTarget.ImageTransparency,
2844 Size = CheckTarget.Size
2845 }
2846 ):Play();
2847 else
2848 Box.ImageColor3 = BoxTarget.ImageColor3;
2849 Box.ImageTransparency = BoxTarget.ImageTransparency;
2850
2851 Check.ImageColor3 = CheckTarget.ImageColor3;
2852 Check.ImageTransparency = CheckTarget.ImageTransparency;
2853 Check.Size = CheckTarget.Size;
2854 end;
2855 end;
2856 }
2857);
2858
2859VIn_CreateClass("FillBox",
2860 {
2861 --Main
2862 Parent = "\2\1\0",
2863 ClassName = "\3\0\1string",
2864 Checked = "\3\0\0boolean",
2865 Size = "\3\0\0number",
2866 LeftLabel = "\3\0\0boolean",
2867 LabelPadding = "\3\0\0number",
2868
2869 --Appearance
2870 StartBoxColor3 = "\4\0\0Color3",
2871 EndBoxColor3 = "\4\0\0Color3",
2872 StartBoxTransparency = "\3\0\0number",
2873 EndBoxTransparency = "\3\0\0number",
2874 FillBoxType = "\0\0\0FillBoxType",
2875
2876 --Events
2877 CheckChanged = "\4\0\1Instance",
2878
2879 --Methods
2880 Check = "\4\0\1function",
2881 CreateLabel = "\4\0\1function",
2882 Redraw = "\4\0\1function"
2883 },
2884 {
2885
2886 },
2887 function(Parent)
2888 local Proxy, Meta, Fields, Cs = VIn_CreateInstance(VIn_Data.FillBox);
2889 --Proxy Setup
2890 Fields.ClassName = "VeraniumFillBox";
2891 Fields.Parent = Parent;
2892 Fields.Checked = false;
2893 Fields.Size = 20;
2894 Fields.LeftLabel = false;
2895 Fields.LabelPadding = 2;
2896
2897 Fields.StartBoxColor3 = VLb_Defaults.SecondaryColor;
2898 Fields.EndBoxColor3 = VLb_Defaults.HighlightColor;
2899 Fields.StartBoxTransparency = 0;
2900 Fields.EndBoxTransparency = 0;
2901 Fields.FillBoxType = VLb_Enums.FillBoxType.Smooth;
2902 --Methods Setup
2903 Fields.Redraw = VIn_Data.FillBox.Redraw;
2904 Fields.Check = VIn_Data.FillBox.Check;
2905 Fields.CreateLabel = VIn_Data.FillBox.CreateLabel;
2906 --Elements Creation
2907 local Main = Instance.new("Frame", GetPInstance(Parent));
2908 local Box = Instance.new("ImageButton", Main);
2909
2910 local CheckChanged = Instance.new("BindableEvent", Main);
2911 --Main Setup
2912 Main.BackgroundTransparency = 1;
2913 Main.BorderSizePixel = 0;
2914 Main.Name = "VeraniumFillBox";
2915 Main.ZIndex = VLb_Defaults.ZIndex;
2916 Main.Size = UDim2.new(0, 17, 0, 17);
2917 --Box Setup
2918 Box.BackgroundTransparency = 1;
2919 Box.BorderSizePixel = 0;
2920 Box.Size = UDim2.new(1, 0, 1, 0);
2921 Box.Position = UDim2.new(0.5, 0, 0.5, 0);
2922 Box.AnchorPoint = Vector2.new(0.5, 0.5);
2923 Box.ImageRectSize = Vector2.new(50, 50);
2924 Box.Name = _PREFIX.."Box";
2925 --Events
2926 CheckChanged.Name = _PREFIX.."CheckChanged";
2927 Fields.CheckChanged = CheckChanged.Event;
2928 --Changed Signal
2929 Cs.Parent = Main;
2930 --Connections
2931 Box.MouseButton1Up:Connect(function()
2932 Fields.Checked = not Fields.Checked;
2933 CheckChanged:Fire(true);
2934 Proxy:Check(true, true);
2935 end);
2936 --MetaData Setup
2937 Meta.___Instance = Main;
2938 Meta.___Base2D = Main;
2939
2940 Meta.Box = Box;
2941 Meta.CheckChanged = CheckChanged;
2942 --First Draw
2943 Proxy:Check(false, true);
2944 VIn_Data.FillBox.Redraw(Proxy);
2945
2946 return Proxy;
2947 end,
2948 function(self, Field, Value)
2949 --Setup
2950 local Meta = GetMeta(self);
2951 local Main = Meta.___Instance;
2952 local Fields = Meta.___Fields;
2953 local Label = Meta.___TextRender;
2954 local Box = Meta.Box;
2955 local CheckChanged = Meta.CheckChanged;
2956
2957 --Size
2958 if Field == nil or Field == "Size" then
2959 Main.Size = UDim2.new(0, Fields.Size, 0, Fields.Size);
2960 if Field then return; end;
2961 end;
2962 --FillBoxType
2963 if Field == nil or Field == "FillBoxType" then
2964 local Texture = VCf_GetEnumLValue("FillBoxType", Fields.FillBoxType);
2965 Box.Image = Texture;
2966 if Field then return; end;
2967 end;
2968 --Label | LeftLabel | LabelPadding
2969 if (Field == nil or Field == "Label"
2970 or Field == "LeftLabel" or Field == "LabelPadding") and Label then
2971 if Fields.LeftLabel then
2972 Label.AnchorPoint = Vector2.new(1, 0.5);
2973 Label.Position = UDim2.new(0, -Fields.LabelPadding, 0.5, 0);
2974 Label.TextXAlignment = Enum.TextXAlignment.Right;
2975 else
2976 Label.AnchorPoint = Vector2.new(0, 0.5);
2977 Label.Position = UDim2.new(1, Fields.LabelPadding, 0.5, 0);
2978 Label.TextXAlignment = Enum.TextXAlignment.Left;
2979 end;
2980 end;
2981 --Pretty much all appearance-related properties
2982 if Field == nil or Field == "StartBoxColor3"
2983 or Field == "EndBoxTransparency" or Field == "StartBoxTransparency"
2984 or Field == "EndBoxTransparency" or Field == "Checked" then
2985 if Field == "Checked" then
2986 CheckChanged:Fire(false);
2987 end;
2988 self:Check(true, true);
2989 if Field then return; end;
2990 end;
2991 end,
2992 {
2993 CreateLabel = function(self, Text)
2994 --Setup
2995 local Meta = GetMeta(self);
2996 local Main = Meta.___Instance;
2997
2998 local Label = Instance.new("TextLabel", Main);
2999 Label.Name = _PREFIX.."Label";
3000 Label.Text = Text;
3001 Label.BackgroundTransparency = 1;
3002 Label.BorderSizePixel = 0;
3003 Label.Font = VLb_Defaults.Font;
3004 Label.TextColor3 = VLb_Defaults.TextColor;
3005 Label.TextTransparency = VLb_Defaults.TextTransparency;
3006 Label.TextYAlignment = Enum.TextYAlignment.Center;
3007 Label.Size = UDim2.new(0, 0, 1, 0);
3008
3009 Meta.___TextRender = Label;
3010
3011 self:Redraw("Label");
3012 end,
3013 Check = function(self, Tween, Yield)
3014 local Meta = GetMeta(self);
3015 local Main = Meta.___Instance;
3016 local Box = Meta.Box;
3017 local Fields = Meta.___Fields;
3018
3019 if Tween == nil then
3020 Tween = true;
3021 end;
3022 if Yield == nil then
3023 Yield = true;
3024 end;
3025
3026 local StartOffset, EndOffset, Step, SCol, ECol, St, Et =
3027 0, 700, 50, Fields.StartBoxColor3, Fields.EndBoxColor3,
3028 Fields.StartBoxTransparency, Fields.EndBoxTransparency;
3029 if not Fields.Checked then
3030 StartOffset, EndOffset, Step, SCol, ECol, St, Et =
3031 650, -50, -50, Fields.EndBoxColor3, Fields.StartBoxColor3,
3032 Fields.EndBoxTransparency, Fields.StartBoxTransparency;
3033 end;
3034 if math.floor(Box.ImageRectOffset.X) == math.floor(EndOffset-Step) and Tween then
3035 Box.ImageColor3 = ECol;
3036 Box.ImageTransparency = Et;
3037 return;
3038 end;
3039 local CVal = StartOffset;
3040
3041 local function Animate()
3042 repeat RunService.Heartbeat:Wait();
3043 Box.ImageRectOffset = Vector2.new(CVal, 0);
3044 Box.ImageColor3 = VLb_CVMath.MapColor(SCol, ECol, StartOffset, EndOffset, CVal);
3045 Box.ImageTransparency = VLb_CVMath.Map(CVal, StartOffset, EndOffset, St, Et);
3046 CVal = CVal + Step;
3047 until math.floor(CVal) == math.floor(EndOffset); -- Because lua:tm: is very epic it switches integers to floats at random!
3048 Box.ImageColor3 = ECol;
3049 Box.ImageTransparency = Et;
3050 end;
3051 if Tween then
3052 if Yield then
3053 spawn(Animate);
3054 else
3055 Animate();
3056 end;
3057 else
3058 Box.ImageRectOffset = Vector2.new(EndOffset-Step);
3059 Box.ImageColor3 = ECol;
3060 Box.ImageTransparency = Et;
3061 end;
3062 Animate = nil;
3063 end;
3064 }
3065);
3066
3067VIn_CreateClass("Counter",
3068 {
3069 --Main
3070 Parent = "\2\1\0",
3071 ClassName = "\3\0\1string",
3072 Padding = "\3\0\0number",
3073
3074 --Functionality
3075 Value = "\3\0\0number",
3076 MinValue = "\3\0\0number",
3077 MaxValue = "\3\0\0number",
3078 Step = "\3\0\0number",
3079
3080 --Appearance
3081 SubtractColor3 = "\4\0\0Color3",
3082 AddColor3 = "\4\0\0Color3",
3083 SubtractTransparency = "\3\0\0number",
3084 AddTransparency = "\3\0\0number",
3085 SubtractImage = "\3\0\0string",
3086 AddImage = "\3\0\0string",
3087 ButtonSize = "\3\0\0number",
3088 DisabledButtonColor3 = "\4\0\0Color3",
3089
3090 --Events
3091 ValueChanged = "\4\0\1Instance",
3092
3093 --Methods
3094 Redraw = "\3\0\1function"
3095 },
3096 {
3097
3098 },
3099 function(Parent)
3100 local Proxy, Meta, Fields, Cs = VIn_CreateInstance(VIn_Data.Counter);
3101 --Proxy Setup
3102 Fields.ClassName = "VeraniumCounter";
3103 Fields.Parent = Parent;
3104 Fields.Padding = 3;
3105
3106 Fields.Value = 1;
3107 Fields.MinValue = 0;
3108 Fields.MaxValue = 10;
3109 Fields.Step = 1;
3110
3111 Fields.SubtractColor3 = VLb_Defaults.HighlightColor;
3112 Fields.AddColor3 = VLb_Defaults.HighlightColor;
3113 Fields.SubtractTransparency = 0;
3114 Fields.AddTransparency = 0;
3115 Fields.SubtractImage = "";
3116 Fields.AddImage = "";
3117 Fields.ButtonSize = 15;
3118 Fields.DisabledButtonColor3 = VLb_Defaults.SecondaryColor;
3119 --Methods Setup
3120 Fields.Redraw = VIn_Data.Counter.Redraw;
3121 --Elements Creation
3122 local Main = Instance.new("Frame", GetPInstance(Parent));
3123 local Background = VIn_Data.Background.Constructor(Main);
3124 local TextRender = Instance.new("TextLabel", Main);
3125 local Subtract = Instance.new("ImageButton", Main);
3126 local Add = Instance.new("ImageButton", Main);
3127
3128 local ValueChanged = Instance.new("BindableEvent", Main);
3129 --Main Setup
3130 Main.BackgroundTransparency = 1;
3131 Main.BorderSizePixel = 0;
3132 Main.Name = "VeraniumCounter";
3133 Main.Size = UDim2.new(0, 60, 0, 20);
3134 Main.ZIndex = VLb_Defaults.ZIndex
3135 --TextRender Setup
3136 TextRender.BackgroundTransparency = 1;
3137 TextRender.BorderSizePixel = 0;
3138 TextRender.AnchorPoint = Vector2.new(0.5, 0.5);
3139 TextRender.Position = UDim2.new(0.5, 0, 0.5, 0);
3140 TextRender.Name = _PREFIX.."TextRender";
3141 --TextRender Defaults
3142 TextRender.TextColor3 = VLb_Defaults.TextColor;
3143 TextRender.TextTransparency = VLb_Defaults.TextTransparency;
3144 TextRender.Font = VLb_Defaults.Font;
3145 TextRender.TextStrokeColor3 = VLb_Defaults.TextStrokeColor;
3146 TextRender.TextStrokeTransparency = VLb_Defaults.TextStrokeTransparency;
3147 TextRender.TextXAlignment = VLb_Defaults.TextXAlignment;
3148 TextRender.TextYAlignment = VLb_Defaults.TextYAlignment;
3149 --Subtract Setup
3150 Subtract.BackgroundTransparency = 1;
3151 Subtract.BorderSizePixel = 0;
3152 Subtract.Position = UDim2.new(0, 0, 0.5, 0);
3153 Subtract.AnchorPoint = Vector2.new(0, 0.5);
3154 Subtract.Name = _PREFIX.."Subtract";
3155 --Add Setup
3156 Add.BackgroundTransparency = 1;
3157 Add.BorderSizePixel = 0;
3158 Add.Position = UDim2.new(1, 0, 0.5, 0);
3159 Add.AnchorPoint = Vector2.new(1, 0.5);
3160 Add.Name = _PREFIX.."Add";
3161 --Events
3162 ValueChanged.Name = _PREFIX.."ValueChanged";
3163 Fields.ValueChanged = ValueChanged.Event;
3164 --Changed Signal
3165 Cs.Parent = Main;
3166 --Connections
3167 Subtract.MouseButton1Up:Connect(function()
3168 if Fields.Value - Fields.Step < Fields.MinValue then
3169 Fields.Value = Fields.MinValue;
3170 else
3171 Fields.Value = Fields.Value - Fields.Step;
3172 end;
3173 TextRender.Text = tostring(Fields.Value);
3174 Proxy:Redraw("Value");
3175 end);
3176 Add.MouseButton1Up:Connect(function()
3177 if Fields.Value + Fields.Step > Fields.MaxValue then
3178 Fields.Value = Fields.MaxValue;
3179 else
3180 Fields.Value = Fields.Value + Fields.Step;
3181 end;
3182 TextRender.Text = tostring(Fields.Value);
3183 Proxy:Redraw("Value");
3184 end);
3185 --MetaData Setup
3186 Meta.___Instance = Main;
3187 Meta.___Base2D = Main;
3188 Meta.___TextRender = TextRender;
3189
3190 Meta.Subtract = Subtract;
3191 Meta.Add = Add;
3192 Meta.ValueChanged = ValueChanged;
3193 --First Draw
3194 VIn_Data.Counter.Redraw(Proxy);
3195
3196 return Proxy;
3197 end,
3198 function(self, Field, Value)
3199 --Setup
3200 local Meta = GetMeta(self);
3201 local Main = Meta.___Instance;
3202 local Fields = Meta.___Fields;
3203 local TextRender = Meta.___TextRender;
3204 local Subtract = Meta.Subtract;
3205 local Add = Meta.Add;
3206 local ValueChanged = Meta.ValueChanged;
3207
3208 --Values
3209 if Field == nil or Field == "Value" or Field == "MinValue"
3210 or Field == "MaxValue" or Field == "Step"
3211 or Field == "DisabledButtonColor3" then
3212 if Fields.Value >= Fields.MaxValue then
3213 Fields.Value = Fields.MaxValue;
3214 Add.ImageColor3 = Fields.DisabledButtonColor3;
3215 else
3216 Add.ImageColor3 = Fields.AddColor3;
3217 end;
3218 if Fields.Value <= Fields.MinValue then
3219 Fields.Value = Fields.MinValue;
3220 Subtract.ImageColor3 = Fields.DisabledButtonColor3;
3221 else
3222 Subtract.ImageColor3 = Fields.SubtractColor3;
3223 end;
3224 TextRender.Text = tostring(Fields.Value);
3225 if Field then return; end;
3226 end;
3227 --Subtract Appearance
3228 if Field == nil or Field == "SubtractColor3"
3229 or Field == "SubtractTransparency" or Field == "SubtractImage" then
3230 Subtract.ImageColor3 = Fields.SubtractColor3
3231 Subtract.ImageTransparency = Fields.SubtractTransparency
3232 if Fields.SubtractImage == "" then
3233 Subtract.Image = "rbxassetid://4486615470";
3234 else
3235 Subtract.Image = Fields.SubtractImage
3236 end;
3237 if Field then return; end;
3238 end;
3239 --Add Appearance
3240 if Field == nil or Field == "AddColor3"
3241 or Field == "AddTransparency" or Field == "AddImage" then
3242 Add.ImageColor3 = Fields.AddColor3
3243 Add.ImageTransparency = Fields.AddTransparency
3244 if Fields.AddImage == "" then
3245 Add.Image = "rbxassetid://4486614839";
3246 else
3247 Add.Image = Fields.AddImage
3248 end;
3249 if Field then return; end;
3250 end;
3251 --ButtonSize
3252 if Field == nil or Field == "ButtonSize" or Field == "Padding" then
3253 Subtract.Size = UDim2.new(0, Fields.ButtonSize, 0, Fields.ButtonSize);
3254 Add.Size = Subtract.Size;
3255 Subtract.Position = UDim2.new(0, Fields.Padding, 0.5, 0);
3256 Add.Position = UDim2.new(1, -Fields.Padding, 0.5, 0);
3257 TextRender.Size = UDim2.new(1, -Fields.ButtonSize*2, 1, 0);
3258 if Field then return; end;
3259 end;
3260 end,
3261 {
3262
3263 }
3264);
3265
3266--DropdownBox is written by Uniqua, it should be a different style.
3267local function GetNdx(List, Idx)
3268 for Ndx, Val in pairs(List)do
3269 if Val.Idx == Idx then
3270 return Ndx-1;
3271 end;
3272 end;
3273end;
3274VIn_CreateClass("DropdownBox",
3275 {
3276 --Main
3277 Parent = "\2\1\0",
3278 ClassName = "\3\0\1string",
3279 Size = "\4\0\0Vector2",
3280 Enabled = "\3\0\0boolean",
3281 Padding = "\3\0\0Vector2",
3282
3283 --Text
3284 Text = "\3\0\0string",
3285 Font = "\4\0\0EnumItem",
3286 TextSize = "\3\0\0number",
3287 TextColor3 = "\4\0\0Color3",
3288
3289 --Utility
3290 Scroll = "\3\0\0number",
3291 IsOpen = "\3\0\1boolean",
3292 CanUnselect = "\3\0\0boolean",
3293 SelectedIndex = "\5\1\1", -- OwO I don't know if there is a VCf_IsA that accept
3294 SelectedValue = "\5\1\1", -- every type of value passed, So \5 is my answer OwO !
3295 MaxDrop = "\3\0\0number", -- You can customize the max drop of the open :3
3296 ShowSelected = "\3\0\0boolean", -- If true and IsOpen true When you select an Item, the Button.Text will change to the index of the item selected
3297 UseIndex = "\3\0\0boolean", -- If true all Items will be named with their index, else all items will be named with their values
3298
3299 --Appearance
3300 BoxColor3 = "\4\0\0Color3",
3301 BoxHoverColor3 = "\4\0\0Color3",
3302 BoxOpenedColor3 = "\4\0\0Color3",
3303 ArrowColor3 = "\4\0\0Color3",
3304 ArrowSize = "\3\0\0number",
3305
3306 --Events
3307 Opened = "\4\0\1Instance",
3308 Closed = "\4\0\1Instance",
3309 ListChanged = "\4\0\1Instance",
3310 SelectionChanged = "\4\0\1Instance",
3311
3312 --TweenInfo
3313 ExpandTweenInfo = "\4\0\0TweenInfo",
3314 SlideTweenInfo = "\4\0\0TweenInfo",
3315 ScrollTweenInfo = "\4\0\0TweenInfo",
3316 ElasticyTweenInfo = "\4\0\0TweenInfo",
3317
3318 --ItemFields
3319 ItemHoverColor3 = "\4\0\0Color3",
3320 ItemHoverOffset = "\3\0\0number",
3321 ItemSelectedColor3 = "\4\0\0Color3",
3322 ItemSelectedOffset = "\3\0\0number",
3323 --Title
3324 TitleHoverColor3 = "\4\0\0Color3",
3325
3326 --End/Start Animation
3327 BorderSizePixel = "\3\0\0number",
3328 HoverBorderSizePixel = "\3\0\0number",
3329 OpenBorderSizePixel = "\3\0\0number",
3330 EndArrowColor3 = "\4\0\0Color3",
3331
3332 --Methods
3333 Redraw = "\4\0\1function",
3334 Reset = "\4\0\1function",
3335 Open = "\4\0\1function",
3336 Close = "\4\0\1function",
3337 Select = "\4\0\1function",
3338 Unselect = "\4\0\1function",
3339 RemoveItem = "\4\0\1function",
3340 AddItem = "\4\0\1function"
3341 },
3342 {
3343 TextColor = "TextColor3",
3344 ArrowColor = "ArrowColor3",
3345 BoxColor = "BoxColor3",
3346 TitleOverColor = "TitleOverColor3",
3347 SelectedColor = "ItemSelectedColor3",
3348 },
3349 function(Parent, List)
3350 local Proxy, Meta, Fields, Cs = VIn_CreateInstance(VIn_Data.DropdownBox);
3351 List = List or {};
3352
3353 if typeof(List) ~= "table" then
3354 Proxy, Meta, Fields = nil;
3355 Cs:Remove();
3356 Cs:Destroy();
3357 return error("Expected a table or nil for List.");
3358 else
3359 local Items = {};
3360 for Idx, Val in pairs(List)do
3361 Items[Idx] = Val;
3362 end;
3363 List = Items;
3364 Items = nil;
3365 end;
3366 --Fields Setup
3367 Fields.ClassName = "VeraniumDropdownBox";
3368 Fields.Parent = Parent;
3369 Fields.Size = Vector2.new(115, 25);
3370 Fields.Enabled = true;
3371 Fields.Padding = Vector2.new(5, 0);
3372
3373 Fields.Text = "DropdownBox";
3374 Fields.Font = VLb_Defaults.Font;
3375 Fields.TextColor3 = VLb_Defaults.TextColor;
3376 Fields.TextSize = 8;
3377
3378 Fields.Scroll = 0;
3379 Fields.IsOpen = false;
3380 Fields.SelectedIndex = 0;
3381 Fields.SelectedValue = nil;
3382 Fields.MaxDrop = 3;
3383 Fields.ShowSelected = true;
3384 Fields.UseIndex = false;
3385 Fields.SelectedBox = nil;
3386
3387 Fields.BoxColor3 = VLb_Defaults.BackgroundColor;
3388 Fields.BoxHoverColor3 = VLb_Defaults.BackgroundColor;
3389 Fields.BoxOpenedColor3 = VLb_Defaults.SecondaryColor;
3390 Fields.ArrowColor3 = VLb_ModernColors.Silver;
3391 Fields.ArrowSize = 10;
3392
3393 Fields.ExpandTweenInfo = TweenInfo.new(
3394 0.5,
3395 Enum.EasingStyle.Sine,
3396 Enum.EasingDirection.Out
3397 );
3398 Fields.SlideTweenInfo = TweenInfo.new(
3399 0.25,
3400 Enum.EasingStyle.Sine,
3401 Enum.EasingDirection.Out
3402 );
3403 Fields.ScrollTweenInfo = TweenInfo.new(
3404 0.25,
3405 Enum.EasingStyle.Quad,
3406 Enum.EasingDirection.Out
3407 );
3408 Fields.ElasticyTweenInfo = TweenInfo.new(
3409 0.25,
3410 Enum.EasingStyle.Sine,
3411 Enum.EasingDirection.Out
3412 );
3413
3414 Fields.ItemHoverColor3 = VLb_Defaults.HighlightColor;
3415 Fields.ItemHoverOffset = 10;
3416 Fields.ItemSelectedColor3 = VLb_Defaults.HighlightColor;
3417 Fields.ItemSelectedOffset = 5;
3418
3419 Fields.TitleHoverColor3 = VLb_Defaults.TextColor;
3420
3421 Fields.BorderSizePixel = VLb_Defaults.BorderSize;
3422 Fields.HoverBorderSizePixel = VLb_Defaults.BorderSize;
3423 Fields.OpenBorderSizePixel = VLb_Defaults.BorderSize;
3424 Fields.EndArrowColor3 = VLb_ModernColors.Silver;
3425
3426 --Methods Setup
3427 Fields.AddItem = VIn_Data.DropdownBox.AddItem;
3428 Fields.RemoveItem = VIn_Data.DropdownBox.RemoveItem;
3429 Fields.Open = VIn_Data.DropdownBox.Open;
3430 Fields.Close = VIn_Data.DropdownBox.Close;
3431 Fields.Select = VIn_Data.DropdownBox.Select;
3432 Fields.Unselect = VIn_Data.DropdownBox.Unselect;
3433 Fields.Redraw = VIn_Data.DropdownBox.Redraw;
3434
3435 --Elements Creation
3436 local Main = Instance.new("Frame", GetPInstance(Parent));
3437 local Background = VIn_Data.Background.Constructor(Main);
3438 Background:CreateBorder();
3439 local Arrow = Instance.new("ImageLabel", Main);
3440 local Title = Instance.new("TextButton", Main);
3441 local ElementCanvas = Instance.new("Frame", Main);
3442 local ElementContainer = Instance.new("Frame", ElementCanvas);
3443
3444 local SelectionChanged = Instance.new("BindableEvent", Main);
3445 local Opened = Instance.new("BindableEvent", Main);
3446 local Closed = Instance.new("BindableEvent", Main);
3447 local ListChanged = Instance.new("BindableEvent", Main);
3448
3449 --Main Setup
3450 Main.BackgroundTransparency = 1;
3451 Main.BorderSizePixel = 0;
3452 Main.Name = _PREFIX.."VeraniumDropdownBox";
3453
3454 --Arrow Setup
3455 Arrow.Name = _PREFIX.."Arrow";
3456 Arrow.BackgroundTransparency = 1;
3457 Arrow.BorderSizePixel = 0;
3458 Arrow.Image = "rbxassetid://3931363707";
3459 Arrow.AnchorPoint = Vector2.new(1, 0.5);
3460
3461 --Title Setup
3462 Title.Name = _PREFIX.."Title";
3463 Title.BackgroundTransparency = 1;
3464 Title.AnchorPoint = Vector2.new(0.5, 0);
3465 Title.TextXAlignment = Enum.TextXAlignment.Left;
3466
3467 --ElementCanvas Setup
3468 ElementCanvas.Name = _PREFIX.."ElementCanvas";
3469 ElementCanvas.BackgroundTransparency = 1;
3470 ElementCanvas.BorderSizePixel = 0;
3471 ElementCanvas.AnchorPoint = Vector2.new(0.5, 1);
3472 ElementCanvas.Position = UDim2.new(0.5, 0, 1, 0);
3473 ElementCanvas.ClipsDescendants = true;
3474
3475 --ElementContainer Setup
3476 ElementContainer.Name = _PREFIX.."ElementContainer";
3477 ElementContainer.BackgroundTransparency = 1;
3478 ElementContainer.BorderSizePixel = 0;
3479 ElementContainer.AnchorPoint = Vector2.new(0.5, 0);
3480 ElementContainer.Position = UDim2.new(0.5, 0, 0, 0);
3481 ElementContainer.Size = UDim2.new(1, 0, 0, 0);
3482 ElementContainer.ClipsDescendants = false;
3483
3484 --Signal Setups
3485 ListChanged.Name = "ListChanged";
3486 Opened.Name = "Opened";
3487 Closed.Name = "Closed";
3488 SelectionChanged.Name = "SelectionChanged";
3489
3490 Fields.SelectionChanged = SelectionChanged.Event;
3491 Fields.Opened = Opened.Event;
3492 Fields.Closed = Closed.Event;
3493 Fields.ListChanged = ListChanged.Event;
3494
3495 --Connections
3496 local Layer = 0;
3497 Main.Changed:Connect(function(Field)
3498 if Field == "BackgroundColor3" then
3499 Background.BackgroundColor3 = Main.BackgroundColor3;
3500 end;
3501 end);
3502 Main.MouseEnter:Connect(function()
3503 if not Fields.IsOpen then
3504 Main.BackgroundColor3 = Fields.BoxHoverColor3;
3505 end;
3506 end);
3507 Main.MouseLeave:Connect(function()
3508 if not Fields.IsOpen then
3509 Main.BackgroundColor3 = Fields.BoxColor3;
3510 end;
3511 end);
3512 Title.MouseEnter:Connect(function()
3513 Title.TextColor3 = Fields.TitleHoverColor3;
3514 end);
3515 Title.MouseLeave:Connect(function()
3516 Title.TextColor3 = Fields.TextColor3;
3517 end);
3518 Title.MouseButton1Down:Connect(function()
3519 if not Fields.Enabled then return; end;
3520 Fields.IsOpen = not Fields.IsOpen;
3521 if Fields.IsOpen then
3522 Proxy:Open();
3523 Opened:Fire();
3524 else
3525 Proxy:Close();
3526 Closed:Fire();
3527 end;
3528 end);
3529 ElementCanvas.MouseWheelBackward:Connect(function()
3530 local MaxDrop = math.min(Fields.MaxDrop-1, #List-1);
3531 Fields.Scroll = Fields.Scroll + 1;
3532 if Fields.Scroll > (#List - MaxDrop - 1) then
3533 Fields.Scroll = #List - MaxDrop - 1;--Elasticy Effect
3534 TweenService:Create(
3535 ElementContainer,
3536 Fields.ElasticyTweenInfo,
3537 {
3538 Position = UDim2.new(0.5, 0, 0,
3539 (-Fields.Scroll - 0.25)*Fields.Size.Y)
3540 }
3541 ):Play();
3542 Layer = Layer + 1;
3543 local LayerBackup = Layer;
3544 wait(Fields.ElasticyTweenInfo.Time);
3545 if LayerBackup ~= Layer then
3546 return;
3547 else
3548 Layer = 0;
3549 end;
3550 end;
3551 TweenService:Create(
3552 ElementContainer,
3553 Fields.ScrollTweenInfo,
3554 {
3555 Position = UDim2.new(0.5, 0, 0,
3556 (-Fields.Scroll)*Fields.Size.Y)
3557 }
3558 ):Play();
3559 end);
3560 ElementCanvas.MouseWheelForward:Connect(function()
3561 Fields.Scroll = Fields.Scroll - 1;
3562 if Fields.Scroll < 0 then
3563 Fields.Scroll = 0;--Elasticy Effect
3564 TweenService:Create(
3565 ElementContainer,
3566 Fields.ElasticyTweenInfo,
3567 {
3568 Position = UDim2.new(0.5, 0, 0,
3569 Fields.Size.Y*0.25)
3570 }
3571 ):Play();
3572 Layer = Layer + 1;
3573 local LayerBackup = Layer;
3574 wait(Fields.ElasticyTweenInfo.Time);
3575 if LayerBackup ~= Layer then
3576 return;
3577 else
3578 Layer = 0;
3579 end;
3580 end;
3581 TweenService:Create(
3582 ElementContainer,
3583 Fields.ScrollTweenInfo,
3584 {
3585 Position = UDim2.new(0.5, 0, 0,
3586 (-Fields.Scroll)*Fields.Size.Y)
3587 }
3588 ):Play();
3589 end);
3590 --ChangedSignal Setup
3591 Cs.Parent = Main;
3592 --Meta Setup
3593 Meta.___Instance = Main;
3594 Meta.___Base2D = Main;
3595 Meta.___Background = Background;
3596 Meta.___TextRender = Title;
3597
3598 Meta.ElementCanvas = ElementCanvas;
3599 Meta.ElementContainer = ElementContainer;
3600 Meta.Arrow = Arrow;
3601 Meta.Title = Title;
3602
3603 Meta.List = {};
3604 Meta.MouseHover = false;
3605
3606 Meta.ListChanged = ListChanged;
3607 Meta.SelectionChanged = SelectionChanged;
3608 Meta.Opened = Opened;
3609 Meta.Closed = Closed;
3610
3611 --List Setup
3612 for Idx, Val in pairs(List) do
3613 Proxy:AddItem(Idx, Val);
3614 end;
3615 --First Draw
3616 VIn_Data.DropdownBox.Redraw(Proxy);
3617
3618 return Proxy;
3619 end,
3620 function(self, Field, Value)
3621 local Meta = GetMeta(self);
3622 --Instances
3623 local Main = Meta.___Instance;
3624 local Background = Meta.___Background;
3625 local Title = Meta.___TextRender;
3626 local Arrow = Meta.Arrow;
3627 local ElementCanvas = Meta.ElementCanvas;
3628 --Utility
3629 local Items = Meta.Items;
3630 local List = Meta.List;
3631 --Fields
3632 local Fields = Meta.___Fields;
3633
3634 --Padding/Size
3635 if Field == nil or Field == "Padding" or Field == "Size"
3636 or Field == "ArrowSize" then
3637 if not Fields.IsOpen then
3638 Main.Size = UDim2.new(0, Fields.Size.X, 0, Fields.Size.Y);
3639 else
3640 Main.Size = UDim2.new(0, Fields.Size.X,
3641 0, Fields.Size.Y * (Fields.MaxDrop + 1));
3642 end;
3643 Title.Position = UDim2.new(0.5, Fields.Padding.X, 0, 0);
3644 Title.Size = UDim2.new(1, -Fields.Padding.X, 0, Fields.Size.Y);
3645 Arrow.Position = UDim2.new(1, -Fields.Padding.X, 0, math.floor(Fields.Size.Y/2));
3646 Arrow.Size = UDim2.new(0, Fields.ArrowSize, 0, Fields.ArrowSize);
3647 ElementCanvas.Size = UDim2.new(1, 0, 1, - Fields.Size.Y);
3648 for Idx, Val in pairs(List)do
3649 local Item = Val.Item;
3650 Item.Position = UDim2.new(0, Fields.Padding.X, 0,
3651 Fields.Size.Y * (Idx-1));
3652 Item.Size = UDim2.new(1, 0, 0, Fields.Size.Y);
3653 end;
3654 if Field then return; end;
3655 end;
3656
3657 --Text
3658 if Field == nil or Field == "Text" or Field == "Font"
3659 or Field == "TextSize" or Field == "TextColor3" then
3660 if Fields.ShowSelected then
3661 if Fields.UseIndex then
3662 if Fields.SelectedIndex ~= nil then
3663 Title.Text = tostring(Fields.SelectedIndex);
3664 else
3665 Title.Text = Fields.Text;
3666 end;
3667 else
3668 if Fields.SelectedValue ~= nil then
3669 Title.Text = tostring(Fields.SelectedValue);
3670 else
3671 Title.Text = Fields.Text;
3672 end;
3673 end;
3674 else
3675 Title.Text = Fields.Text;
3676 end;
3677 Title.Font = Fields.Font;
3678 Title.TextSize = Fields.TextSize;
3679 Title.TextColor3 = Fields.TextColor3;
3680 for Idx, Val in pairs(List)do
3681 local Item = Val.Item;
3682 Item.Font = Fields.Font;
3683 Item.TextSize = Fields.TextSize;
3684 Item.TextColor3 = Fields.TextColor3;
3685 end;
3686 if Field then return; end;
3687 end;
3688
3689 --MaxDrop Scroll
3690 if (Field == nil or Field == "MaxDrop") and Fields.IsOpen or Field == "Scroll" then
3691 Main.Size = UDim2.new(0, Fields.Size.X,
3692 0, Fields.Size.Y * (Fields.MaxDrop + 1));
3693 if Fields.Scroll < 0 then
3694 Fields.Scroll = 0;
3695 end;
3696 if Fields.Scroll > (#List - Fields.MaxDrop - 1) then
3697 Fields.Scroll = #List - Fields.MaxDrop - 1;
3698 end;
3699 TweenService:Create(
3700 ElementContainer,
3701 Fields.ScrollTweenInfo,
3702 {
3703 Position = UDim2.new(0.5, 0, 0,
3704 (-Fields.Scroll)*Fields.Size.Y)
3705 }
3706 ):Play();
3707 if Field then return; end;
3708 end;
3709
3710 --UseIndex
3711 if Field == nil or Field == "UseIndex" then
3712 for Idx, Val in pairs(List) do
3713 local Item = Val.Item;
3714 if Fields.UseIndex then
3715 Item.Text = Val.Idx;
3716 else
3717 Item.Text = Val.Val;
3718 end;
3719 end;
3720 if Field then return; end;
3721 end;
3722
3723 --Box Appearance
3724 if Field == nil or Field == "BoxColor3"
3725 or Field == "BoxHoverColor3" or Field == "BoxOpenedColor3"
3726 or Field == "BorderSizePixel" or Field == "HoverBorderSizePixel"
3727 or Field == "OpenBorderSizePixel" then
3728 if Fields.IsOpen then
3729 Main.BackgroundColor3 = Fields.BoxOpenedColor3;
3730 Background.BorderSizePixel = Fields.OpenBorderSizePixel;
3731 elseif Meta.MouseHover then
3732 Main.BackgroundColor3 = Fields.BoxHoverColor3;
3733 Background.BorderSizePixel = Fields.HoverBorderSizePixel;
3734 else
3735 Main.BackgroundColor3 = Fields.BoxColor3;
3736 Background.BorderSizePixel = Fields.BorderSizePixel;
3737 end;
3738 if Field then return; end;
3739 end;
3740
3741 --Arrow Appearance
3742 if Field == nil or Field == "ArrowColor3"
3743 or Field == "EndArrowColor3" then
3744 if Fields.IsOpen then
3745 Arrow.ImageColor3 = Fields.EndArrowColor3;
3746 else
3747 Arrow.ImageColor3 = Fields.ArrowColor3;
3748 end;
3749 if Field then return; end;
3750 end;
3751 end,
3752 {
3753 AddItem = function(self, Idx, Val)
3754 if Idx == nil or Val == nil then
3755 return error("Idx/Val cannot be nil.");
3756 end;
3757 local Meta = GetMeta(self);
3758 local ElementCanvas = Meta.ElementCanvas;
3759 local ElementContainer = Meta.ElementContainer;
3760 local List = Meta.List;
3761 local Fields = Meta.___Fields;
3762 local Padding = Fields.Padding;
3763 local ListChanged = Meta.ListChanged;
3764
3765 local TextRender = Instance.new("TextButton", ElementContainer);
3766 TextRender.Name = _PREFIX..tostring(Idx);
3767 TextRender.BackgroundTransparency = 1;
3768 TextRender.BorderSizePixel = 0;
3769 TextRender.TextColor3 = Fields.TextColor3;
3770 TextRender.Font = Fields.Font;
3771 TextRender.TextSize = Fields.TextSize;
3772 TextRender.TextColor3 = Fields.TextColor3;
3773 TextRender.TextXAlignment = Enum.TextXAlignment.Left;
3774 if Fields.UseIndex then
3775 TextRender.Text = Idx;
3776 else
3777 TextRender.Text = Val;
3778 end;
3779 local Ndx = #List;
3780 TextRender.Position = UDim2.new(0, Fields.Padding.X, 0,
3781 Fields.Size.Y * (Ndx));
3782 TextRender.Size = UDim2.new(1, 0, 0, Fields.Size.Y);
3783 table.insert(List, {
3784 Idx = Idx,
3785 Val = Val,
3786 Item = TextRender
3787 });
3788 TextRender.MouseEnter:Connect(function()
3789 if Fields.SelectedIndex == Idx then return; end;
3790 Ndx = GetNdx(List, Idx);
3791 TweenService:Create(
3792 TextRender,
3793 Fields.SlideTweenInfo,
3794 {
3795 TextColor3 = Fields.ItemHoverColor3,
3796 Position = UDim2.new(0, Fields.ItemHoverOffset, 0,
3797 Fields.Size.Y * (Ndx));
3798 }
3799 ):Play();
3800 end);
3801 TextRender.MouseLeave:Connect(function()
3802 if Fields.SelectedIndex == Idx then return; end;
3803 Ndx = GetNdx(List, Idx);
3804 TweenService:Create(
3805 TextRender,
3806 Fields.SlideTweenInfo,
3807 {
3808 TextColor3 = Fields.TextColor3,
3809 Position = UDim2.new(0, Fields.Padding.X, 0,
3810 Fields.Size.Y * (Ndx));
3811 }
3812 ):Play();
3813 end);
3814 TextRender.MouseButton1Up:Connect(function()
3815 if Fields.SelectedIndex == Idx then
3816 if Fields.CanUnselect then
3817 self:Unselect();
3818 end;
3819 else
3820 self:Select(Idx);
3821 end;
3822 end);
3823 ListChanged:Fire(true, Idx);
3824 return TextRender;
3825 end,
3826 RemoveItem = function(self, Idx)
3827 local Meta = GetMeta(self);
3828 local List = Meta.List;
3829 local Fields = Meta.___Fields;
3830 local Padding = Fields.Padding;
3831 local ListChanged = Meta.ListChanged;
3832
3833 local Tdx;
3834 for Ndx, Val in pairs(List) do
3835 if Val.Idx == Idx then
3836 Tdx = Ndx;
3837 break;
3838 end;
3839 end;
3840 for Ndx = Tdx+1, #List, 1 do
3841 local Item = List[Ndx].Item;
3842 Item.Position = UDim2.new(0, Fields.Padding.X, 0,
3843 Fields.Size.Y * (Ndx-2));
3844 end;
3845 Tdx = table.remove(List, Tdx);
3846 Tdx.Item:Remove();Tdx.Item:Destroy();
3847 Tdx = nil;
3848 ListChanged:Fire(false, Idx);
3849 return;
3850 end,
3851 Open = function(self)
3852 local Meta = GetMeta(self);
3853 local List = Meta.List;
3854 local Fields = Meta.___Fields;
3855 local Main = Meta.___Instance;
3856 local Arrow = Meta.Arrow;
3857 local MaxDrop = math.min(Fields.MaxDrop+1, #List+1);
3858 TweenService:Create(
3859 Main,
3860 Fields.ExpandTweenInfo,
3861 {
3862 Size = UDim2.new(0, Fields.Size.X,
3863 0, Fields.Size.Y*MaxDrop),
3864 BackgroundColor3 = Fields.BoxOpenedColor3
3865 }
3866 ):Play();
3867 TweenService:Create(
3868 Arrow,
3869 Fields.ExpandTweenInfo,
3870 {
3871 Rotation = 180
3872 }
3873 ):Play();
3874 Meta.Opened:Fire();
3875 end,
3876 Close = function(self)
3877 local Meta = GetMeta(self);
3878 local List = Meta.List;
3879 local Fields = Meta.___Fields;
3880 local Main = Meta.___Instance;
3881 local Arrow = Meta.Arrow;
3882 TweenService:Create(
3883 Main,
3884 Fields.ExpandTweenInfo,
3885 {
3886 Size = UDim2.new(0, Fields.Size.X,
3887 0, Fields.Size.Y),
3888 BackgroundColor3 = Fields.BoxColor3
3889 }
3890 ):Play();
3891 TweenService:Create(
3892 Arrow,
3893 Fields.ExpandTweenInfo,
3894 {
3895 Rotation = 0
3896 }
3897 ):Play();
3898 Meta.Closed:Fire();
3899 end,
3900 Select = function(self, Idx)
3901 local Meta = GetMeta(self);
3902 local Fields = Meta.___Fields;
3903 local List = Meta.List;
3904 local Item;
3905 for Ndx, Val in pairs(List)do
3906 if Val.Idx == Idx then
3907 Item = Val;
3908 break;
3909 end;
3910 end;
3911 Fields.SelectedIndex = Idx;
3912 Fields.SelectedValue = Item and Item.Val;
3913 self:Redraw("Text");
3914
3915 TweenService:Create(Item.Item,
3916 Fields.SlideTweenInfo,
3917 {
3918 TextColor3 = Fields.ItemSelectedColor3,
3919 Position = UDim2.new(0, Fields.ItemSelectedOffset, 0,
3920 Item.Item.Position.Y.Offset)
3921 }
3922 ):Play();
3923 Meta.SelectionChanged:Fire(Idx, Item.Val);
3924 end,
3925 Unselect = function(self)
3926 local Meta = GetMeta(self);
3927 local Fields = Meta.___Fields;
3928 local List = Meta.List;
3929 local Item;
3930 for Ndx, Val in pairs(List)do
3931 if Val.Idx == Fields.SelectedIndex then
3932 Item = Val;
3933 break;
3934 end;
3935 end;
3936 Fields.SelectedIndex = nil;
3937 Fields.SelectedValue = nil;
3938 self:Redraw("Text");
3939
3940 TweenService:Create(Item.Item,
3941 Fields.SlideTweenInfo,
3942 {
3943 TextColor3 = Fields.ItemSelectedColor3,
3944 Position = UDim2.new(0, Fields.Padding.X, 0,
3945 Item.Item.Position.Y.Offset)
3946 }
3947 ):Play();
3948 Meta.SelectionChanged:Fire();
3949 end
3950 }
3951);
3952
3953VIn_CreateClass("Expander",
3954 {
3955 --Main
3956 Parent = "\2\1\0",
3957 ClassName = "\3\0\1string",
3958 MinSize = "\4\0\0Vector2",
3959 MaxSize = "\4\0\0Vector2",
3960 Enabled = "\3\0\0boolean",
3961 Padding = "\3\0\0Vector2",
3962
3963 --Utility
3964 IsOpen = "\3\0\1boolean",
3965
3966 --Appearane
3967 ArrowColor3 = "\4\0\0Color3",
3968 ArrowSize = "\3\0\0number",
3969
3970 --Events
3971 ExpandChanged = "\4\0\1Instance",
3972
3973 --TweenInfo
3974 ExpandTweenInfo = "\4\0\0TweenInfo",
3975
3976 --End/Start Animation
3977 EndArrowColor3 = "\4\0\0Color3",
3978
3979 --Methods
3980 Redraw = "\4\0\1function",
3981 Expand = "\4\0\1function"
3982 },
3983 {
3984 Title = "Text",
3985 TitleColor = "TextColor3",
3986 TitleColor3 = "TextColor3"
3987 },
3988 function(Parent, List)
3989 local Proxy, Meta, Fields, Cs = VIn_CreateInstance(VIn_Data.Expander);
3990 --Fields Setup
3991 Fields.ClassName = "VeraniumExpander";
3992 Fields.Parent = Parent;
3993 Fields.MinSize = Vector2.new(115, 25);
3994 Fields.MaxSize = Vector2.new(115, 100);
3995 Fields.Enabled = true;
3996 Fields.Padding = Vector2.new(5, 0);
3997
3998 Fields.IsOpen = false;
3999
4000 Fields.ArrowColor3 = VLb_ModernColors.Silver;
4001 Fields.ArrowSize = 10;
4002
4003 Fields.ExpandTweenInfo = TweenInfo.new(
4004 0.5,
4005 Enum.EasingStyle.Sine,
4006 Enum.EasingDirection.Out
4007 );
4008
4009 Fields.EndArrowColor3 = VLb_ModernColors.Silver;
4010
4011 --Methods Setup
4012 Fields.Expand = VIn_Data.Expander.Expand;
4013 Fields.Redraw = VIn_Data.Expander.Redraw;
4014
4015 --Elements Creation
4016 local Main = Instance.new("Frame", GetPInstance(Parent));
4017 local Background = VIn_Data.Background.Constructor(Main);
4018 local Arrow = Instance.new("ImageLabel", Main);
4019 local Title = Instance.new("TextButton", Main);
4020 local ElementCanvas = Instance.new("Frame", Main);
4021
4022 local ExpandChanged = Instance.new("BindableEvent", Main);
4023
4024 --Main Setup
4025 Main.BackgroundTransparency = 1;
4026 Main.BorderSizePixel = 0;
4027 Main.Name = _PREFIX.."VeraniumExpander";
4028
4029 --Arrow Setup
4030 Arrow.Name = _PREFIX.."Arrow";
4031 Arrow.BackgroundTransparency = 1;
4032 Arrow.BorderSizePixel = 0;
4033 Arrow.Image = "rbxassetid://3931363707";
4034 Arrow.AnchorPoint = Vector2.new(1, 0.5);
4035
4036 --Title Setup
4037 Title.Name = _PREFIX.."Title";
4038 Title.Text = "Expander"
4039 Title.BackgroundTransparency = 1;
4040 Title.AnchorPoint = Vector2.new(0.5, 0);
4041 Title.TextXAlignment = Enum.TextXAlignment.Left;
4042 --Title Defaults
4043 Title.TextColor3 = VLb_Defaults.TextColor;
4044 Title.TextTransparency = VLb_Defaults.TextTransparency;
4045 Title.Font = VLb_Defaults.Font;
4046
4047 Title.TextStrokeColor3 = VLb_Defaults.TextStrokeColor;
4048 Title.TextStrokeTransparency = VLb_Defaults.TextStrokeTransparency;
4049
4050 --ElementCanvas Setup
4051 ElementCanvas.Name = _PREFIX.."ElementCanvas";
4052 ElementCanvas.BackgroundTransparency = 1;
4053 ElementCanvas.BorderSizePixel = 0;
4054 ElementCanvas.AnchorPoint = Vector2.new(0.5, 1);
4055 ElementCanvas.Position = UDim2.new(0.5, 0, 1, 0);
4056 ElementCanvas.ClipsDescendants = true;
4057
4058 --Signal Setups
4059 ExpandChanged.Name = "ExpandChanged";
4060 Fields.ExpandChanged = ExpandChanged.Event;
4061
4062 --Connections
4063 Title.MouseButton1Down:Connect(function()
4064 if not Fields.Enabled then return; end;
4065 Proxy:Expand();
4066 end);
4067 --ChangedSignal Setup
4068 Cs.Parent = Main;
4069 --Meta Setup
4070 Meta.___Instance = Main;
4071 Meta.___Base2D = Main;
4072 Meta.___Background = Background;
4073 Meta.___TextRender = Title;
4074 Meta.___Children = ElementCanvas;
4075
4076 Meta.ElementCanvas = ElementCanvas;
4077 Meta.Arrow = Arrow;
4078 Meta.Title = Title;
4079
4080 Meta.ExpandChanged = ExpandChanged;
4081 --First Draw
4082 VIn_Data.Expander.Redraw(Proxy);
4083
4084 return Proxy;
4085 end,
4086 function(self, Field, Value)
4087 local Meta = GetMeta(self);
4088 --Instances
4089 local Main = Meta.___Instance;
4090 local Background = Meta.___Background;
4091 local Title = Meta.___TextRender;
4092 local Arrow = Meta.Arrow;
4093 local ElementCanvas = Meta.___Children;
4094 --Fields
4095 local Fields = Meta.___Fields;
4096
4097 --Padding/Size
4098 if Field == nil or Field == "Padding" or Field == "Size"
4099 or Field == "ArrowSize" then
4100 if not Fields.IsOpen then
4101 Main.Size = UDim2.new(0, Fields.MinSize.X, 0, Fields.MinSize.Y);
4102 else
4103 Main.Size = UDim2.new(0, Fields.MaxSize.X, 0, Fields.MaxSize.Y);
4104 end;
4105 Title.Position = UDim2.new(0.5, Fields.Padding.X, 0, 0);
4106 Title.Size = UDim2.new(1, -Fields.Padding.X, 0, Fields.MinSize.Y);
4107 Arrow.Position = UDim2.new(1, -Fields.Padding.X, 0, math.floor(Fields.MinSize.Y/2));
4108 Arrow.Size = UDim2.new(0, Fields.ArrowSize, 0, Fields.ArrowSize);
4109 ElementCanvas.Size = UDim2.new(1, 0, 1, - Fields.MinSize.Y);
4110 if Field then return; end;
4111 end;
4112 --Arrow Appearance
4113 if Field == nil or Field == "ArrowColor3"
4114 or Field == "EndArrowColor3" then
4115 if Fields.IsOpen then
4116 Arrow.ImageColor3 = Fields.EndArrowColor3;
4117 else
4118 Arrow.ImageColor3 = Fields.ArrowColor3;
4119 end;
4120 if Field then return; end;
4121 end;
4122 end,
4123 {
4124 Expand = function(self)
4125 local Meta = GetMeta(self);
4126 local Fields = Meta.___Fields;
4127 local Main = Meta.___Instance;
4128 local Arrow = Meta.Arrow;
4129 Fields.IsOpen = not Fields.IsOpen;
4130 if Fields.IsOpen then
4131 TweenService:Create(
4132 Main,
4133 Fields.ExpandTweenInfo,
4134 {
4135 Size = UDim2.new(0, Fields.MaxSize.X, 0, Fields.MaxSize.Y)
4136 }
4137 ):Play();
4138 TweenService:Create(
4139 Arrow,
4140 Fields.ExpandTweenInfo,
4141 {
4142 Rotation = 180
4143 }
4144 ):Play();
4145 else
4146 TweenService:Create(
4147 Main,
4148 Fields.ExpandTweenInfo,
4149 {
4150 Size = UDim2.new(0, Fields.MinSize.X, 0, Fields.MinSize.Y)
4151 }
4152 ):Play();
4153 TweenService:Create(
4154 Arrow,
4155 Fields.ExpandTweenInfo,
4156 {
4157 Rotation = 0
4158 }
4159 ):Play();
4160 end;
4161 Meta.ExpandChanged:Fire();
4162 end
4163 }
4164);
4165
4166VIn_CreateClass("Switch",
4167 {
4168 --Main
4169 Parent = "\2\1\0",
4170 ClassName = "\3\0\1string",
4171 Size = "\4\0\0Vector2",
4172 Enabled = "\3\0\0boolean",
4173
4174 --Utility
4175 Value = "\3\0\1boolean",
4176
4177 --Bar
4178 BarTransparency = "\3\0\0number",
4179 BarThickness = "\3\0\0number",
4180 MarkupImage = "\3\0\0string",
4181 MarkupColor3 = "\4\0\0Color3",
4182 MarkupTransparency = "\3\0\0number",
4183
4184 --MISC
4185 MarkupSize = "\4\0\0number",
4186 SliderType = "\0\0\0SliderType",
4187 SideSheet = "\3\0\0string",
4188
4189 --Appearance
4190 BarOnlineColor3 = "\4\0\0Color3", -- Bar Color when Value is false
4191 BarOfflineColor3 = "\4\0\0Color3", -- Bar Color when Value is true
4192 MarkupSizeOffset = "\4\0\0number",
4193 MarkupDistance = "\4\0\0number", -- Distance from Border
4194 ClickDarkness = "\4\0\0number", -- Color darkness after MouseButton1Down
4195
4196 --TweenInfo
4197 ToggleTweenInfo = "\4\0\0TweenInfo",
4198
4199 --Event
4200 ValueChanged = "\4\0\1Instance",
4201
4202 --Method
4203 Redraw = "\3\0\1function",
4204 Toggle = "\3\0\1function"
4205 },
4206 {
4207 BarOnlineColor = "BarOnlineColor3",
4208 BarOfflineColor = "BarOfflineColor3",
4209 MarkupColor = "MarkupColor3",
4210 },
4211 function(Parent, Value)
4212 Proxy, Meta, Fields, Cs = VIn_CreateInstance(VIn_Data.Switch);
4213 if type(Value) ~= "boolean" then Value = false; end;
4214 --Main
4215 Fields.ClassName = "Switch";
4216 Fields.Parent = GetInstance(Parent);
4217 Fields.Size = Vector2.new(40, 20);
4218 Fields.Enabled = true;
4219 --Bar
4220 Fields.BarTransparency = 0;
4221 Fields.BarThickness = 18;
4222 Fields.MarkupSize = 0.8;
4223 Fields.MarkupColor3 = VLb_ModernColors.Cloud;
4224 Fields.MarkupTransparency = 0;
4225 --Utility
4226 Fields.Value = Value;
4227 --MISC
4228 Fields.SliderType = VLb_Enums.SliderType.Round;
4229 Fields.SideSheet = "";
4230 Fields.MarkupImage = "rbxassetid://3457843087";
4231 --Appearance
4232 Fields.BarOnlineColor3 = Color3.fromRGB(115, 135, 219);
4233 Fields.BarOfflineColor3 = Color3.fromRGB(112, 115, 124);
4234 Fields.MarkupSizeOffset = 4;
4235 Fields.MarkupDistance = 3;
4236 Fields.ClickDarkness = 20;
4237 --Creation
4238 local Main = Instance.new("Frame", Fields.Parent);
4239 local Bar = Instance.new("Frame", Main);
4240 local LeftSide = Instance.new("ImageLabel", Bar);
4241 local RightSide = Instance.new("ImageLabel", Bar);
4242 local Markup = Instance.new("ImageLabel", Bar);
4243 local Hitbox = Instance.new("TextButton", Main);
4244 local ValueChanged = Instance.new("BindableEvent", Main);
4245
4246 --Instances Setup
4247 Main.Name = _PREFIX.."VeraniumSwitch";
4248 Main.BorderSizePixel = 0;
4249 Main.BackgroundTransparency = 1;
4250 --RightSide
4251 RightSide.BackgroundTransparency = 1;
4252 RightSide.BorderSizePixel = 0;
4253 RightSide.AnchorPoint = Vector2.new(0, 0.5);
4254 RightSide.Position = UDim2.new(1, 0, 0.5, 0);
4255 RightSide.ImageRectSize = Vector2.new(400, 800);
4256 RightSide.ImageRectOffset = Vector2.new(400, 0);
4257 RightSide.Name = _PREFIX.."RightSide";
4258 --LeftSide
4259 LeftSide.BackgroundTransparency = 1;
4260 LeftSide.BorderSizePixel = 0;
4261 LeftSide.AnchorPoint = Vector2.new(1, 0.5);
4262 LeftSide.Position = UDim2.new(0, 0, 0.5, 0);
4263 LeftSide.ImageRectSize = Vector2.new(400, 800);
4264 LeftSide.ImageRectOffset = Vector2.new(0, 0);
4265 LeftSide.Name = _PREFIX.."LeftSide";
4266 --Hitbox
4267 Hitbox.Text = "";
4268 Hitbox.Name = _PREFIX.."Hitbox";
4269 Hitbox.BorderSizePixel = 0;
4270 Hitbox.BackgroundTransparency = 1;
4271 Hitbox.Size = UDim2.new(1,0,1,0);
4272 Hitbox.AnchorPoint = Vector2.new(0.5, 0.5);
4273 Hitbox.Position = UDim2.new(0.5, 0, 0.5, 0);
4274 Hitbox.ZIndex = 2;
4275 --Bar
4276 Bar.BorderSizePixel = 0;
4277 Bar.AnchorPoint = Vector2.new(0.5, 0.5);
4278 Bar.Position = UDim2.new(0.5, 0, 0.5, 0);
4279 Bar.Name = _PREFIX.."Bar";
4280 --Markup
4281 Markup.Name = _PREFIX.."Markup";
4282 Markup.BorderSizePixel = 1;
4283 Markup.BackgroundTransparency = 1;
4284 Markup.Image = Fields.MarkupImage;
4285
4286 ValueChanged.Name = "ValueChanged";
4287
4288 --Event/Methods
4289 Fields.ValueChanged = ValueChanged.Event;
4290 Fields.Toggle = VIn_Data.Switch.Toggle;
4291 Fields.Redraw = VIn_Data.Switch.Redraw;
4292
4293 --TweenInfo
4294 Fields.ToggleTweenInfo = TweenInfo.new(
4295 0.5,
4296 Enum.EasingStyle.Sine,
4297 Enum.EasingDirection.Out
4298 );
4299
4300 --Connections
4301 Main.Changed:Connect(function(Field)
4302 if Field == "BackgroundColor3" then
4303 LeftSide.ImageColor3 = Main.BackgroundColor3;
4304 RightSide.ImageColor3 = Main.BackgroundColor3;
4305 Bar.BackgroundColor3 = Main.BackgroundColor3;
4306 end;
4307 end);
4308 local MouseOver = false;
4309 local MouseDown = true;
4310 Hitbox.MouseEnter:Connect(function() MouseOver = true; end);
4311 Hitbox.MouseLeave:Connect(function() MouseOver = false; end);
4312 Hitbox.MouseButton1Down:Connect(function()
4313 MouseDown = true;
4314 if Fields.Enabled then
4315 local ActualColor;
4316 if Fields.Value then ActualColor = Fields.BarOnlineColor3 else ActualColor = Fields.BarOfflineColor3 end;
4317 H,S,V = Color3.toHSV(ActualColor);
4318 V = V - (Fields.ClickDarkness/100 * V); -- Hewww, efficent dark effect on different color!
4319 TweenService:Create(
4320 Main,
4321 Fields.ToggleTweenInfo,
4322 {
4323 BackgroundColor3 = Color3.fromHSV(H, S, V);
4324 }
4325 ):Play();
4326 end;
4327 end)
4328 --ToggleSystem
4329 local Toggle = function()
4330 if Fields.Enabled then
4331 if MouseOver and MouseDown then
4332 Fields.Toggle(Proxy);
4333 else
4334 local Color;
4335 if Fields.Value then
4336 Color = Fields.BarOnlineColor3;
4337 else
4338 Color = Fields.BarOfflineColor3;
4339 end;
4340 TweenService:Create(
4341 Main,
4342 Fields.ToggleTweenInfo,
4343 {
4344 BackgroundColor3 = Color;
4345 }
4346 ):Play();
4347 end;
4348 end;
4349 MouseDown = false;
4350 end;
4351 Hitbox.MouseButton1Up:Connect(Toggle);
4352 UserInputService.InputEnded:Connect(function(input)
4353 if input.UserInputType == Enum.UserInputType.MouseButton1 and MouseDown then
4354 Toggle();
4355 end;
4356 end);
4357
4358 --Cs Setup
4359 Cs.Parent = Main;
4360 --Meta Setup
4361 Meta.___Instance = Main;
4362 Meta.___Base2D = Main;
4363 Meta.___CHitbox = Hitbox;
4364 Meta.___Background = Main;
4365
4366 Meta.Bar = Bar;
4367 Meta.RightSide = RightSide;
4368 Meta.LeftSide = LeftSide;
4369 Meta.Markup = Markup;
4370 Meta.ValueChanged = ValueChanged;
4371
4372 --First Draw
4373 Fields.Redraw(Proxy);
4374 Fields.Toggle(Proxy, Fields.Value);
4375 return Proxy;
4376 end,
4377 function(self, Field, Value)
4378 local Meta = GetMeta(self);
4379 local Markup = Meta.Markup;
4380 local Main = Meta.___Instance;
4381 local LeftSide = Meta.LeftSide;
4382 local RightSide = Meta.RightSide;
4383 local Bar = Meta.Bar;
4384 local Fields = Meta.___Fields;
4385
4386 if Field == nil or Field == "BarOnlineColor3" or Field == "BarOfflineColo3" then
4387 local ActualColor;
4388 if Fields.Value then ActualColor = Fields.BarOnlineColor3 else ActualColor = Fields.BarOfflineColor3 end;
4389 Bar.BackgroundColor3 = ActualColor;
4390 LeftSide.ImageColor3 = ActualColor;
4391 RightSide.ImageColor3 = ActualColor;
4392 end;
4393 if Field == nil or Field == "BarTransparency" then
4394 Bar.BackgroundTransparency = Fields.BarTransparency;
4395 LeftSide.ImageTransparency = Fields.BarTransparency;
4396 RightSide.ImageTransparency = Fields.BarTransparency;
4397 if Field then return; end;
4398 end;
4399 if Field == nil or Field == "MarkupSize" or Field == "MarkupColor3" or Field == "MarkupDistance" or Field == "MarkupTransparency" then
4400 local Size = math.min(Bar.AbsoluteSize.X, Bar.AbsoluteSize.Y)*Fields.MarkupSize;
4401 Markup.ImageTransparency = Fields.MarkupTransparency;
4402 Markup.Size = UDim2.new(0, Size, 0, Size);
4403 Markup.ImageColor3 = Fields.MarkupColor3;
4404 self:Toggle(Fields.Value);
4405 if Field then return; end;
4406 end;
4407 if (Field == nil or Field == "SliderType" or Field == "SlideSheet" or Field == "MarkupImage") then
4408 local SideSheet = VCf_GetEnumLValue("SliderType", Fields.SliderType);
4409 if SideSheet == "" then
4410 LeftSide.Image = Fields.SideSheet;
4411 RightSide.Image = Fields.SideSheet;
4412
4413 Markup.Image = Fields.MarkupImage;
4414 else
4415 LeftSide.Image = SideSheet;
4416 RightSide.Image = SideSheet;
4417
4418 Markup.Image = SideSheet;
4419 end;
4420 end;
4421 if Field == nil or Field == "BarThickness" or Field == "Size" then
4422 Main.Size = UDim2.new(
4423 0,
4424 Fields.Size.X,
4425 0,
4426 Fields.Size.Y
4427 );
4428
4429 LeftSide.Size = UDim2.new(0, Fields.BarThickness/2, 1, 0);
4430 RightSide.Size = UDim2.new(0, Fields.BarThickness/2, 1, 0);
4431 Bar.Size = UDim2.new(
4432 1,
4433 -Fields.BarThickness,
4434 1,
4435 0
4436 );
4437
4438 local Size = math.min(Bar.AbsoluteSize.X, Bar.AbsoluteSize.Y)*Fields.MarkupSize;
4439 Markup.Size = UDim2.new(0, Size, 0, Size);
4440 if Field then return; end;
4441 end;
4442 end,
4443 {
4444 Toggle = function(self, Value)
4445 local Meta = GetMeta(self);
4446 local ValueChanged = Meta.ValueChanged;
4447 local Main = Meta.___Instance;
4448 local Markup = Meta.Markup;
4449 local Fields = Meta.___Fields;
4450 local MarkupDistance = Fields.MarkupDistance;
4451 local BarOnlineColor3 = Fields.BarOnlineColor3;
4452 local BarOfflineColor3 = Fields.BarOfflineColor3;
4453 if type(Value) ~= "boolean" then Value = not Fields.Value; end;
4454 if Value == false then
4455 --Markup Animation
4456 TweenService:Create(
4457 Markup,
4458 Fields.ToggleTweenInfo,
4459 {
4460 Position = UDim2.new(0, MarkupDistance-Fields.BarThickness/2, 0.5, 0);
4461 AnchorPoint = Vector2.new(0, 0.5);
4462 }
4463 ):Play();
4464 --Background Animation
4465 TweenService:Create(
4466 Main,
4467 Fields.ToggleTweenInfo,
4468 {
4469 BackgroundColor3 = BarOfflineColor3;
4470 }
4471 ):Play();
4472 Fields.Value = false;
4473 elseif Value == true then
4474 --Markup Animation
4475 TweenService:Create(
4476 Markup,
4477 Fields.ToggleTweenInfo,
4478 {
4479 Position = UDim2.new(1, Fields.BarThickness/2-MarkupDistance, 0.5, 0);
4480 AnchorPoint = Vector2.new(1, 0.5);
4481 }
4482 ):Play();
4483 --Background Animation
4484 TweenService:Create(
4485 Main,
4486 Fields.ToggleTweenInfo,
4487 {
4488 BackgroundColor3 = BarOnlineColor3;
4489 }
4490 ):Play();
4491 Fields.Value = true;
4492 end;
4493 ValueChanged:Fire(Fields.Value);
4494 end;
4495 }
4496);
4497
4498VIn_CreateClass("GifPlayer",
4499 {
4500 Parent = "\2\1\0",
4501 ClassName = "\3\0\1string",
4502 Size = "\4\0\0Vector2",
4503 RectSize = "\4\0\0Vector2",
4504 --Utility
4505 Loop = "\3\0\0boolean",
4506 Layout = "\4\0\0Vector2", -- X Rows, Y Columns
4507 CurrentFrame = "\3\0\1number",
4508 Playing = "\3\0\1boolean",
4509 Delay = "\3\0\0number",
4510 --Appearence
4511 ImageColor3 = "\4\0\0Color3",
4512 Image = "\3\0\0string",
4513 --Methods
4514 Redraw = "\3\0\1function",
4515 Setup = "\3\0\1function",
4516 Play = "\3\0\1function",
4517 Pause = "\3\0\1function",
4518 Resume = "\3\0\1function",
4519 JumpToFrame = "\3\0\1function",
4520 --Events
4521 Resumed = "\4\0\1Instance",
4522 Played = "\4\0\1Instance",
4523 Stopped = "\4\0\1Instance",
4524 FrameChanged = "\4\0\1Instance",
4525 },
4526 {
4527
4528 },
4529 function(Parent)
4530 local Proxy, Meta, Fields, Cs = VIn_CreateInstance(VIn_Data.GifPlayer);
4531 Fields.ClassName = "GifPlayer";
4532 Fields.Parent = GetInstance(Parent);
4533 Fields.Size = UDim2.new(200, 200);
4534 Fields.RectSize = Vector2.new(256, 256);
4535 --Utility
4536 Fields.Loop = true;
4537 Fields.Layout = Vector2.new(4, 3);
4538 Fields.CurrentFrame = 1;
4539 Fields.Playing = false;
4540 Fields.Delay = 0.4;
4541 --Appearence
4542 Fields.ImageColor3 = Color3.fromRGB(255, 255, 255);
4543 Fields.Image = "rbxassetid://848623155";
4544 --Methods
4545 Fields.Redraw = VIn_Data.GifPlayer.Redraw;
4546 Fields.Setup = VIn_Data.GifPlayer.Setup;
4547 Fields.Play = VIn_Data.GifPlayer.Play;
4548 Fields.Pause = VIn_Data.GifPlayer.Pause;
4549 Fields.Resume = VIn_Data.GifPlayer.Resume;
4550 Fields.JumpToFrame = VIn_Data.GifPlayer.FrameChanged;
4551 --Creation
4552 local Main = Instance.new("Frame", Fields.Parent);
4553 local Gif = Instance.new("ImageButton", Main),
4554 --First Draw
4555 Fields.Redraw(Proxy);
4556 return Proxy
4557 end,
4558 function(self, Field, Value)
4559 local Meta = GetMeta(self);
4560 end,
4561 {
4562
4563 }
4564)
4565
4566--[[Instance List: [12/17]
4567 Core Instances: [2/2]
4568 [1]: Boundary [Done]
4569 [2]: Background [Done]
4570
4571 Basic Instances: [3/3]
4572 [3]: Label [Done]
4573 [4]: Button [Done]
4574 [5]: TextBox [Done]
4575
4576 Standard Instances: [5/7]
4577 [6]: Slider [Done]
4578 [7]: CheckBox [Done]
4579 [8]: FillBox [Done]
4580 [9]: Swicth
4581 [10]: TabControl
4582 [11]: Counter [Done]
4583 [12]: DropdownBox [Done]
4584
4585 Complex Instances: [2/5]
4586 [13]: Window [Done]
4587 [14]: Expander [Done]
4588 [15]: 2DParticleEmmitter
4589 [16]: GifPlayer
4590 [17]: DisplayList
4591
4592 Note:
4593 "Veranium" is a UIL that follows the same rules that RLua does.
4594 "Vera" is a sub-library that follows the traditional UIL system.
4595 Veranium can work alone. Vera however, needs Veranium to work.
4596
4597 Veranium: {Boundary, Background, Label, Button, ScrollBG, Slider, CheckBox
4598 FillBox, TabControl, Counter, DropdownBox, Expander, 2DParticleEmmitter}
4599 Vera: {Window, GifPlayer, DisplayList}
4600]]
4601
4602local VLb_CTweenService, VCt_BaseData, VCt_Methods, VCt_Meta;
4603VCt_BaseData = {};
4604VCt_Methods = {
4605 Play = function(self, DisposeAfterPlay)
4606 local Meta = VCt_BaseData[self];
4607
4608 if not Meta then return error("Unable to get tween meta, It might be destroyed."); end;
4609 local VeraniumInstance = Meta.Instance;
4610 local Tween = Meta[_PREFIX.."Tween"];
4611 local Properties = Meta[_PREFIX.."Properties"];
4612 local Base = Meta[_PREFIX.."Base"];
4613 local MapValue = VLb_CTweenService.MapValue;
4614 local StartProperties = {};
4615 local VTweens = VCt_BaseData[Meta.Instance];
4616 for Idx, Val in pairs(Properties) do
4617 StartProperties[Idx] = VeraniumInstance[Idx];
4618 end;
4619 for Idx, Val in pairs(VTweens)do
4620 if Val ~= self then
4621 local VMeta = VCt_BaseData[Val];
4622 for Property, Val0 in pairs(VMeta[_PREFIX.."Properties"]) do
4623 for Property0, Val1 in pairs(Properties)do
4624 if Property == Property0 then
4625 VMeta[_PREFIX.."Properties"][Property] = nil;
4626 break;
4627 end;
4628 end;
4629 end;
4630 end;
4631 end;
4632
4633 local function Update()
4634 local Markup = Base.Value;
4635 for Idx, Val in pairs(Properties) do
4636 if not VCf_IsVera(VeraniumInstance) then
4637 return;
4638 end;
4639 VeraniumInstance[Idx] = MapValue(
4640 StartProperties[Idx],
4641 Properties[Idx],
4642 Markup
4643 );
4644 end;
4645 end;
4646
4647 local LValue = 0;
4648 local Connection = RunService.Heartbeat:Connect(function()
4649 if (Base.Value - LValue) < 0.001 then return; end;
4650 LValue = Base.Value;
4651 Update();
4652 end);
4653 Tween:Play();
4654
4655 spawn(function()
4656 repeat RunService.Heartbeat:Wait();
4657 until Tween.PlaybackState == Enum.PlaybackState.Completed
4658 or Tween.PlaybackState == Enum.PlaybackState.Cancelled;
4659 RunService.Heartbeat:Wait();
4660 Connection:Disconnect();
4661 Update();
4662 Update = nil;
4663 if Tween.PlaybackState == Enum.PlaybackState.Completed then
4664 Base.Value = 0;
4665 end;
4666 if DisposeAfterPlay then
4667 self:Remove();
4668 end;
4669 end);
4670 return self;
4671 end,
4672 Pause = function(self)
4673 local Meta = VCt_BaseData[self];
4674 if not Meta then return error("Unable to get tween meta, It might be destroyed."); end;
4675 local Tween = Meta[_PREFIX.."Tween"];
4676 Tween:Pause();
4677 return self;
4678 end,
4679 Cancel = function(self)
4680 local Meta = VCt_BaseData[self];
4681 if not Meta then return error("Unable to get tween meta, It might be destroyed."); end;
4682 local Tween = Meta[_PREFIX.."Tween"];
4683 Tween:Cancel();
4684 return self;
4685 end,
4686 Destructor = function(self)
4687 local Meta = VCt_BaseData[self];
4688 if Meta then
4689 if type(VCt_BaseData[Meta.Instance]) == "table" then
4690 for Idx, Val in pairs(VCt_BaseData[Meta.Instance]) do
4691 if Val == self then
4692 table.remove(VCt_BaseData[Meta.Instance], Idx);
4693 end;
4694 end;
4695 if #VCt_BaseData[Meta.Instance] == 0 then
4696 VCt_BaseData[Meta.Instance] = nil;
4697 end;
4698 end;
4699 VCt_BaseData[self] = nil;
4700 Meta.Instance = nil;
4701 Meta.TweenInfo = nil;
4702 Meta.Cancel = nil;
4703 Meta.Play = nil;
4704 Meta.Pause = nil;
4705 Meta[_PREFIX.."Properties"] = nil;
4706 Meta[_PREFIX.."Base"]:Destroy();
4707 Meta[_PREFIX.."Base"] = nil;
4708 Meta[_PREFIX.."Tween"]:Destroy();
4709 Meta[_PREFIX.."Tween"] = nil;
4710 Meta[_PREFIX.."Meta"] = nil;
4711 Meta = nil;
4712
4713 return true;
4714 else
4715 return false;
4716 end;
4717 end
4718};
4719VCt_Methods.Destroy = VCt_Methods.Destructor;
4720VCt_Methods.Remove = VCt_Methods.Destructor;
4721
4722VCt_Meta = {
4723 __tostring = function(self)
4724 if VCt_BaseData[self] then
4725 return "VeraniumTween";
4726 else
4727 return "";
4728 end;
4729 end,
4730 __index = function(self, Field)
4731 if Field == nil then
4732 return error("Field can't be nil.");
4733 end;
4734 Field = tostring(Field);
4735 local Meta = VCt_BaseData[self];
4736 if not Meta then return error("Unable to get tween meta, It might be destroyed."); end;
4737 if VCt_Methods[Field] then
4738 return VCt_Methods[Field];
4739 end;
4740 if Meta[Field] ~= nil then
4741 return Meta[Field]
4742 else
4743 return Meta[_PREFIX.."Tween"][Field];
4744 end;
4745 end,
4746 __newindex = function(self, Field, Value)
4747 if Field == nil then
4748 return error("Field can't be nil.");
4749 end;
4750 Field = tostring(Field);
4751 local Meta = VCt_BaseData[self];
4752 if not Meta then return error("Unable to get tween meta, It might be destroyed."); end;
4753 Meta[_PREFIX.."Tween"][Field] = Value;
4754 end,
4755 __metatable = "Ara Ara~ What are you doing, User-kun?"--No Context x3
4756};
4757VLb_CTweenService = {
4758 Create = function(self, VeraniumInstance, TInfo, Properties)
4759 local Base = Instance.new("NumberValue");
4760 Base.Name = _PREFIX.."TweenBase";
4761 Base.Value = 0;
4762
4763 local Tween = TweenService:Create(Base, TInfo, {Value = 1});
4764 Base.Parent = Tween;
4765
4766 local Proxy = newproxy(true);
4767 local Meta = getmetatable(Proxy);
4768 Meta.__index = VCt_Meta.__index;
4769 Meta.__newindex = VCt_Meta.__newindex;
4770 Meta.__tostring = VCt_Meta.__tostring;
4771 Meta.__metatable = VCt_Meta.__metatable;
4772
4773 local Fields = {};
4774 for Idx, Val in pairs(Properties)do
4775 if type(Idx) == "string" and typeof(VeraniumInstance[Idx]) == typeof(Val) then
4776 Fields[Idx] = Val;
4777 else
4778 return error("Invalid setting for "..tostring(Idx)..".");
4779 end;
4780 end;
4781 Properties = Fields;
4782 Fields = nil;
4783
4784 VCt_BaseData[Proxy] = {
4785 Instance = VeraniumInstance,
4786 TweenInfo = TInfo,
4787
4788 Cancel = VCt_Methods.Cancel,
4789 Play = VCt_Methods.Play,
4790 Pause = VCt_Methods.Pause,
4791
4792 [_PREFIX.."Properties"] = Properties,
4793 [_PREFIX.."Base"] = Base,
4794 [_PREFIX.."Tween"] = Tween,
4795 [_PREFIX.."Meta"] = Meta
4796 };
4797 if type(VCt_BaseData[VeraniumInstance]) == "table" then
4798 table.insert(VCt_BaseData[VeraniumInstance], Proxy);
4799 else
4800 VCt_BaseData[VeraniumInstance] = {Proxy};
4801 end;
4802
4803 Tween.Parent = GetMeta(VeraniumInstance).___Instance;
4804
4805 return Proxy;
4806 end,
4807 MapValue = function(StartValue, EndValue, Markup)
4808 if typeof(StartValue) ~= typeof(EndValue) then
4809 return;
4810 end;
4811 if type(StartValue) == "number" then
4812 local Difference = EndValue - StartValue;
4813 return StartValue + (Difference*Markup);
4814 elseif type(StartValue) == "string" then
4815 local TargetLenght = math.floor((#EndValue)*Markup);
4816 if Markup == 1 then
4817 return EndValue;
4818 end;
4819 return EndValue:sub(1, TargetLenght)..StartValue:sub(TargetLenght+1, -1);
4820 elseif typeof(StartValue) == "Color3" then
4821 local R, G, B;
4822 R = EndValue.r - StartValue.r;
4823 G = EndValue.g - StartValue.g;
4824 B = EndValue.b - StartValue.b;
4825
4826 R = StartValue.r + (R*Markup);
4827 G = StartValue.g + (G*Markup);
4828 B = StartValue.b + (B*Markup);
4829
4830 return Color3.new(R, G, B);
4831 elseif typeof(StartValue) == "Vector2" then
4832 local X, Y;
4833 X = EndValue.X - StartValue.X;
4834 Y = EndValue.Y - StartValue.Y;
4835
4836 X = StartValue.X + (X*Markup);
4837 Y = StartValue.Y + (Y*Markup);
4838
4839 return Vector2.new(X, Y);
4840 elseif typeof(StartValue) == "UDim2" then
4841 local X0, X1, Y0, Y1;
4842
4843 X0 = EndValue.X.Scale - StartValue.X.Scale;
4844 X1 = EndValue.X.Offset - StartValue.X.Offset;
4845 Y0 = EndValue.Y.Scale - StartValue.Y.Scale;
4846 Y1 = EndValue.Y.Offset - StartValue.Y.Offset;
4847
4848 X0 = StartValue.X.Scale + (X0*Markup);
4849 X1 = StartValue.X.Offset + (X1*Markup);
4850 Y0 = StartValue.Y.Scale + (Y0*Markup);
4851 Y1 = StartValue.Y.Offset + (Y1*Markup);
4852
4853 return UDim2.new(X0, X1, Y0, Y1);
4854 else
4855 if Markup >= 0.5 then
4856 return EndValue;
4857 else
4858 return StartValue;
4859 end;
4860 end;
4861 end
4862};
4863VIn_Methods.Tween = function(self, ...)
4864 return VLb_CTweenService:Create(self, ...);
4865end;
4866
4867VIn_Methods.Fade = function(self, Time, Transparency, EasingStyle, EasingDirection)
4868 --Defaults
4869 VCf_AssertIsVera(self);
4870 Time = Time or 1;
4871 Transparency = Transparency or 1;
4872 EasingStyle = EasingStyle or Enum.EasingStyle.Sine;
4873 EasingDirection = EasingDirection or Enum.EasingDirection.Out;
4874
4875 --Tween Create
4876 local Layer = VIn_SReg.TransparencyLayer[self.ClassName];
4877 if not Layer then
4878 return warn("This Class doesn't have a fade method.");
4879 end;
4880 local Properties = {};
4881 for Idx, Val in pairs(Layer)do
4882 Properties[Val] = Transparency;
4883 end;
4884
4885 local Tween = self:Tween(TweenInfo.new(
4886 Time,
4887 EasingStyle,
4888 EasingDirection
4889 ), Properties):Play();
4890 Tween.Name = _PREFIX.."FadeTween";
4891
4892 spawn(function()
4893 wait(Time);
4894 Tween:Destroy();
4895 end);
4896
4897 return;
4898end;
4899
4900--Bridge Library
4901--NotificationService
4902local function VLb_NotificationService()
4903 local NotificationDefaults;
4904 local function UpdateDefaults()
4905 NotificationDefaults = {
4906 --Background:Corners
4907 CornerSize = VLb_Defaults.CornerSize,
4908 CornerType = VLb_Defaults.CornerType,
4909 --Background:Border
4910 BorderSize = VLb_Defaults.BorderSize,
4911 BorderTransparency = VLb_Defaults.BorderTransparency,
4912 BorderColor3 = VLb_Defaults.BorderColor,
4913 --Backgroun:self
4914 BackgroundColor3 = VLb_Defaults.BackgroundColor,
4915 BackgroundTransparency = VLb_Defaults.BackgroundTransparency,
4916 --Text Properties
4917 TextColor3 = VLb_Defaults.TextColor,
4918 TextTransparency = VLb_Defaults.TextTransparency,
4919 Font = VLb_Defaults.Font,
4920 --Text:Stroke
4921 TextStrokeColor3 = VLb_Defaults.TextStrokeColor,
4922 TextStrokeTransparency = VLb_Defaults.TextStrokeTransparency,
4923
4924 IconColor = VLb_Defaults.TextColor,
4925 IconSize = 12,
4926 Padding = 4
4927 };
4928 end;
4929 UpdateDefaults();
4930 local function ApplyNotificationProperties(Notification, Properties)
4931 for Idx, Val in pairs(NotificationDefaults) do
4932 Val = Properties[Idx] or Val;
4933 if Idx ~= "IconColor" and Idx ~= "Padding" and Idx ~= "IconSize" then
4934 Notification[Idx] = Val;
4935 end;
4936 end;
4937 local Val = Properties.SideColor;
4938 if Val then
4939 Notification.TopLeft.BackgroundColor3 = Val;
4940 Notification.LeftBorder.BackgroundColor3 = Val;
4941 Notification.BottomLeft.BackgroundColor3 = Val;
4942 end;
4943 end;
4944
4945 local Notifications = {};
4946 local NotificationFrame = Instance.new("Frame", VeraniumSpace);
4947 NotificationFrame.Name = "NotificationFrame";
4948 NotificationFrame.BackgroundTransparency = 1;
4949 NotificationFrame.BorderSizePixel = 0;
4950 NotificationFrame.Size = UDim2.new(1, 0, 0.3, 0);
4951 NotificationFrame.Position = UDim2.new(0.5, 0, 1, 0);
4952 NotificationFrame.AnchorPoint = Vector2.new(0.5, 1);
4953
4954 local function Pop(Ndx, Pixels)
4955 for Idx, Notification in pairs(Notifications)do
4956 local AbsolutePosition;
4957 if VCf_IsVera(Notification) then
4958 AbsolutePosition = Notification.Abs;
4959 end;
4960 if Notification and VCf_IsVera(Notification) and AbsolutePosition.Value < Ndx then
4961 AbsolutePosition.Value = AbsolutePosition.Value + Pixels;
4962 Notification:Tween(
4963 TweenInfo.new(
4964 0.5,
4965 Enum.EasingStyle.Sine,
4966 Enum.EasingDirection.Out
4967 ),
4968 {
4969 Position = UDim2.new(
4970 0.5,
4971 Notification.Position.X.Offset,
4972 0.5,
4973 AbsolutePosition.Value
4974 )
4975 }
4976 ):Play(true);
4977 end;
4978 end;
4979 end;
4980
4981 local function Push(Pixels)
4982 for Idx, Notification in pairs(Notifications) do if VCf_IsVera(Notification) then
4983 local AbsolutePosition = Notification.Abs;
4984 AbsolutePosition.Value = AbsolutePosition.Value - Pixels;
4985 Notification:Tween(
4986 TweenInfo.new(
4987 0.5,
4988 Enum.EasingStyle.Sine,
4989 Enum.EasingDirection.Out
4990 ),
4991 {
4992 Position = UDim2.new(
4993 0.5,
4994 Notification.Position.X.Offset,
4995 0.5,
4996 AbsolutePosition.Value
4997 )
4998 }
4999 ):Play(true);
5000 end; end;
5001 end;
5002
5003 local function ToastNotification(Text, NotificationType, Properties, Duration, ClickFunction)
5004 --Defaults
5005 Text = Text or "Veranium ToastNotification";
5006 if type(NotificationType) ~= "string" then
5007 NotificationType = NotificationType or VLb_Enums.NotificationType.None;
5008 NotificationType = VCf_GetEnumLValue("NotificationType", NotificationType);
5009 end;
5010 Properties = Properties or {};
5011 Duration = Duration or (#Text/20);
5012
5013 local IconSize = Properties.IconSize or NotificationDefaults.IconSize;
5014 local IconColor = Properties.IconColor or NotificationDefaults.IconColor;
5015 local Padding = Properties.Padding or NotificationDefaults.Padding;
5016 local CornerSize = Properties.CornerSize or NotificationDefaults.CornerSize;
5017
5018 local NotificationBg = VCn_Main("Label", NotificationFrame);
5019 local Notification = VCn_Main("Button", NotificationBg);
5020 local AbsolutePosition = Instance.new("NumberValue", NotificationBg:GetInstance());
5021 AbsolutePosition.Name = "Abs";
5022 AbsolutePosition.Value = 0;
5023 NotificationBg.Name = "ToastNotification";
5024 NotificationBg.Text = "";
5025 Notification.Name = "Text";
5026 Notification.Text = Text;
5027 Notification.Size = UDim2.new(1, 0, 1, 0);
5028 Notification.AnchorPoint = Vector2.new(0.5, 0.5);
5029 Notification.Position = UDim2.new(0.5, 0, 0.5, 0);
5030 Notification.TextXAlignment = Enum.TextXAlignment.Center;
5031 Notification.TextYAlignment = Enum.TextYAlignment.Center;
5032 local Icon = Instance.new("ImageLabel", Notification:GetInstance());
5033 if NotificationType ~= "" then
5034 Icon.Name = "Icon";
5035 Icon.BackgroundTransparency = 1;
5036 Icon.BorderSizePixel = 0;
5037 Icon.Image = NotificationType;
5038 Icon.Size = UDim2.new(0, IconSize, 0, IconSize);
5039 Icon.Name = "Icon";
5040 Icon.Position = UDim2.new(0, Padding, 0.5, 0);
5041 Icon.AnchorPoint = Vector2.new(1, 0.5);
5042 Icon.ImageColor3 = IconColor;
5043 else
5044 Icon:Remove();
5045 Icon:Destroy();
5046 end;
5047 ApplyNotificationProperties(Notification, Properties);
5048 Notification.BackgroundTransparency = 1;
5049 Notification.BorderTransparency = 1;
5050 ApplyNotificationProperties(NotificationBg, Properties);
5051 if NotificationType == "" then
5052 NotificationBg.Size = UDim2.new(
5053 0,
5054 Notification.TextBounds.X+CornerSize+Padding,
5055 0,
5056 Notification.TextBounds.Y+Padding
5057 );
5058 else
5059 NotificationBg.Size = UDim2.new(
5060 0,
5061 Notification.TextBounds.X+CornerSize+Padding+IconSize,
5062 0,
5063 math.max(IconSize, Notification.TextBounds.Y)+Padding
5064 );
5065 Notification.Position = UDim2.new(
5066 0,
5067 IconSize,
5068 0.5,
5069 0
5070 );
5071 Notification.Size = UDim2.new(
5072 1,
5073 -IconSize,
5074 0.5,
5075 0
5076 );
5077 Notification.AnchorPoint = Vector2.new(0, 0.5);
5078 end;
5079 NotificationBg.Position = UDim2.new(0.5, 0, 1, 0);
5080 NotificationBg.AnchorPoint = Vector2.new(0.5, 0);
5081 if type(ClickFunction) == "function" then
5082 Notification.MouseButton1Click:Connect(ClickFunction);
5083 end;
5084
5085 Push(Notification.TextBounds.Y+Padding);
5086 NotificationBg:Tween(
5087 TweenInfo.new(
5088 0.5,
5089 Enum.EasingStyle.Sine,
5090 Enum.EasingDirection.Out
5091 ),
5092 {
5093 Position = UDim2.new(0.5, 0, 0.5, 0),
5094 AnchorPoint = Vector2.new(0.5, 0.5)
5095 }
5096 ):Play(true);
5097 local Ndx = #Notifications;
5098 spawn(function()
5099 Notifications[Ndx+1] = NotificationBg;
5100 wait(0.6);
5101 wait(Duration);
5102 NotificationBg:Fade(0.5);
5103 Notification:Fade(0.5);
5104 TweenService:Create(
5105 Icon,
5106 TweenInfo.new(
5107 0.5,
5108 Enum.EasingStyle.Sine,
5109 Enum.EasingDirection.Out
5110 ),
5111 {
5112 ImageTransparency = 1
5113 }
5114 ):Play();
5115 wait(0.5);
5116 table.remove(Notifications, Ndx+1);
5117 Pop(AbsolutePosition.Value, Notification.TextBounds.Y+(Padding*2));
5118 wait(0.1);
5119 NotificationBg:Remove();
5120 Notification:Remove();
5121 Icon:Remove();
5122 Icon:Destroy();
5123 NotificationBg = nil;
5124 Notification = nil;
5125 Icon = nil;
5126 end);
5127 return NotificationBg;
5128 end;
5129
5130 return ToastNotification, NotificationDefaults, UpdateDefaults;
5131end;
5132--Tooltip
5133local function VLb_Tooltip()
5134 local Tooltip = VCn_Main("Label", VeraniumSpace);
5135 local TooltipConnections = {};
5136 Tooltip.Name = "Tooltip";
5137 Tooltip.ZIndex = 9e5;
5138 Tooltip.Visible = false;
5139 Tooltip:CreateBorder();
5140 local Tooltip_Defaults = {
5141 --Background:Corners
5142 CornerSize = 8,
5143 CornerType = VLb_Enums.CornerType.Smooth,
5144 --Background:Self
5145 BackgroundColor3 = VLb_ModernColors.DimMidnightBlue,
5146 BackgroundTransparency = 0.5,
5147 --Background:Borders
5148 BorderSize = 0,
5149 BorderColor3 = Color3.new(0, 0, 0),
5150 BorderTransparency = 1,
5151 --Text Properties
5152 TextColor3 = VLb_ModernColors.Silver,
5153 TextSize = 8,
5154 TextTransparency = 0,
5155 Font = Enum.Font.Legacy,
5156 --Text:Stroke
5157 TextStrokeColor3 = VLb_ModernColors.Abestos,
5158 TextStrokeTransparency = 1,
5159
5160 Padding = 8;
5161 };
5162 local function ApplyTooltipProperties(Properties)
5163 for Idx, Val in pairs(Tooltip_Defaults) do
5164 if Properties[Idx] and Idx ~= "Padding" then
5165 Tooltip[Idx] = Properties[Idx];
5166 elseif Idx ~= "Padding" then
5167 Tooltip[Idx] = Val;
5168 end;
5169 end;
5170 end;
5171
5172 local HoveredElement;
5173 --Update
5174 RunService.Heartbeat:Connect(function()
5175 local Object = GetInstance(HoveredElement);
5176 local Connections = TooltipConnections[HoveredElement];
5177 if typeof(Object) == "Instance" and type(Connections) == "table" then
5178 Tooltip.Visible = true;
5179 local APos, ASz, X, Y = Object.AbsolutePosition, Object.AbsoluteSize, Mouse.X, Mouse.Y;
5180 local Range = APos + ASz;
5181 if not (APos.X-10 < X and Range.X+10 > X and APos.Y-10 < Y and Range.Y+10 > Y) then
5182 HoveredElement = nil;
5183 return;
5184 end;
5185 ApplyTooltipProperties(Connections.Properties);
5186 local Padding = Connections.Properties.Padding or Tooltip_Defaults.Padding;
5187 Tooltip.Text = Connections.Text;
5188 Tooltip.Size = UDim2.new(
5189 0,
5190 Tooltip.TextBounds.X + Padding,
5191 0,
5192 Tooltip.TextBounds.Y + Padding
5193 );
5194 local XPos, YPos = 1, 1;
5195 APos, ASz = Vector2.new(X + 20, Y + 20), Tooltip.AbsoluteSize;
5196 Range = APos + ASz;
5197 --X Check
5198 if (Range.X) > VeraniumSpace.AbsoluteSize.X then
5199 XPos = 0;
5200 end;
5201 --Y Check
5202 if (Range.Y) > VeraniumSpace.AbsoluteSize.Y then
5203 YPos = 0;
5204 end;
5205
5206 Tooltip.Position = UDim2.new(
5207 0,
5208 X + (20*XPos),
5209 0,
5210 Y + (20*YPos)
5211 );
5212 Tooltip.AnchorPoint = Vector2.new(math.abs(XPos-1), math.abs(YPos-1));
5213 else
5214 Tooltip.Visible = false;
5215 end;
5216 end);
5217
5218 local function LinkTooltip(self, Text, Properties)
5219 VCf_AssertIsVera(self);
5220 Text = Text or "";
5221 Properties = Properties or {};
5222
5223 if Text == "" then
5224 local Connections = TooltipConnections[self];
5225 if Connections then
5226 Connections.MouseEnter:Disconnect();
5227 Connections.MouseLeave:Disconnect();
5228 Connections.MouseLeave = nil;
5229 Connections.MouseEnter = nil;
5230 TooltipConnections[self] = nil;
5231 Connections = nil;
5232 return false;
5233 else
5234 return false;
5235 end;
5236 end;
5237 local Connections = TooltipConnections[self];
5238 if Connections then
5239 local Fields = {};
5240 for Idx, Field in pairs(Properties)do
5241 Fields[Idx] = Field;
5242 end;
5243 Properties, Fields = Fields;
5244
5245 Connections.Text = Text;
5246 Connections.Properties = Properties;
5247
5248 return false;
5249 end;
5250
5251 local Object = self:GetInstance();
5252 Connections = {};
5253 local Fields = {};
5254 for Idx, Field in pairs(Properties)do
5255 Fields[Idx] = Field;
5256 end;
5257 Properties, Fields = Fields;
5258 Connections.MouseEnter = Object.MouseEnter:Connect(function()
5259 HoveredElement = self;
5260 end);
5261 Connections.Text = Text;
5262 Connections.Properties = Properties;
5263 TooltipConnections[self] = Connections;
5264 return true;
5265 end;
5266
5267 return TooltipConnections, Tooltip_Defaults, LinkTooltip, Tooltip;
5268end;
5269
5270local TooltipConnections, Tooltip_Defaults, LinkTooltip;
5271local ToastNotification, NotificationDefaults, UpdateDefaults;
5272
5273--VCf_Destructor Assignment
5274VCf_Destructor = function(self)
5275 --Tooltip Removal
5276 if TooltipConnections[self] then
5277 LinkTooltip(self);
5278 end;
5279 --Setup
5280 local Meta = GetMeta(self);
5281 if type(Meta) ~= "table" then
5282 return false;
5283 end;
5284 if Meta.___Instance then
5285 VIn_ParseD[Meta.___Instance] = nil;
5286 end;
5287 local Connections = Meta.___Connection;
5288
5289 if type(Connections) == "table" then
5290 for Idx, Val in pairs(Connections) do
5291 Val:Disconnect();
5292 Connections[Idx] = nil;
5293 end;
5294 end;
5295
5296 for Idx, Val in pairs(Meta) do
5297 if typeof(Val) == "Instance" or VCf_IsA(Val, "\2\0\0") then
5298 Val:Remove();
5299 Val:Destroy();
5300 Val = nil;
5301 Meta[Idx] = nil;
5302 end;
5303 end;
5304
5305 Meta.___Fields = nil;
5306 Meta.___MetaData = nil;
5307 Meta.___Connection = nil;
5308 VIn_References[self] = nil;
5309 self, Meta, Connections = nil;
5310
5311 return true;
5312end;
5313--VCf_IsA Assignment
5314VCf_IsA = function(Value, ClassName)
5315 local Instruction = ClassName:sub(1, 1);
5316 local Nullable = ClassName:sub(2, 2);
5317 ClassName = ClassName:sub(4, -1);
5318 if Instruction == "\0" then--VEnum IsA
5319 local EnumLibrary = VEn_Data[ClassName];
5320 if EnumLibrary[Value] ~= nil then
5321 return true;
5322 elseif VEn_References[Value] ~= nil then
5323 return VEn_References[Value].___SubLib == ClassName;
5324 elseif Nullable == "\1" and Value == nil then
5325 return true;
5326 else
5327 return false;
5328 end;
5329 elseif Instruction == "\1" then--VCv IsA
5330 local VCv = (VCv_Data[Value] ~= nil);
5331 if VCv then
5332 return true;
5333 elseif Nullable == "\1" then
5334 return (Value == nil);
5335 end;
5336 elseif Instruction == "\2" then--BaseInstance IsA
5337 local BaseInstance = (typeof(Value) == "Instance" or VIn_References[Value] ~= nil);
5338 if BaseInstance then
5339 return true;
5340 elseif Nullable == "\1" then
5341 return (Value == nil);
5342 end;
5343 elseif Instruction == "\3" then--type() IsA
5344 if Nullable == "\0" then
5345 return (type(Value) == ClassName);
5346 else
5347 return ((Value == nil) or (type(Value) == ClassName));
5348 end;
5349 elseif Instruction == "\4" then--typeof IsA
5350 if Nullable == "\0" then
5351 return (typeof(Value) == ClassName);
5352 elseif Nullable == "\1" then
5353 return ((Value == nil) or (typeof(Value) == ClassName));
5354 end;
5355 elseif Instruction == "\5" then
5356 if Nullable == "\0" then
5357 return (Value ~= nil);
5358 else
5359 return true;
5360 end;
5361 end;
5362end;
5363
5364--Setting up Libraries that use Veranium's VIn.
5365TooltipConnections, Tooltip_Defaults, LinkTooltip = VLb_Tooltip();
5366VLb_Tooltip = {
5367 Defaults = Tooltip_Defaults,
5368 LinkTooltip = LinkTooltip
5369};
5370
5371ToastNotification, NotificationDefaults, UpdateDefaults = VLb_NotificationService();
5372VLb_NotificationService = {
5373 Defaults = NotificationDefaults,
5374 ToastNotification = ToastNotification,
5375 UpdateDefaults = UpdateDefaults
5376};
5377
5378--VIn_Methods Setup
5379VIn_Methods.Destructor = VCf_Destructor;
5380VIn_Methods.Destroy = VCf_Destructor;
5381VIn_Methods.Remove = VCf_Destructor;
5382VIn_Methods.GetInstance = GetInstance;
5383VIn_Methods.LinkTooltip = LinkTooltip;
5384
5385Veranium = {
5386 Create = VCn_Main,
5387 Enum = VLb_Enums,
5388 ModernColors = VLb_ModernColors,
5389 Defaults = VLb_Defaults,
5390 CVMath = VLb_CVMath,
5391 ColorVariant = VLb_ColorVariants,
5392 TweenService = VLb_CTweenService,
5393 TooltipService = VLb_Tooltip,
5394 NotificationService = VLb_NotificationService,
5395 Core = {
5396 Prefix = _PREFIX,
5397 InstanceData = VIn_Data,
5398 GetInstance = GetInstance,
5399 GetMeta = GetMeta,
5400 CreateInstance = VIn_CreateInstance,
5401 CreateClass = VIn_CreateClass,
5402 VeraniumSpace = VeraniumSpace
5403 }
5404};
5405
5406return Veranium;