diff --git a/src/Shared/Modules/Managers/UIManager/Types.lua b/src/Shared/Modules/Managers/UIManager/Types.lua index d6885e6..9aca0a1 100644 --- a/src/Shared/Modules/Managers/UIManager/Types.lua +++ b/src/Shared/Modules/Managers/UIManager/Types.lua @@ -5,42 +5,9 @@ local trove = require(replicated.Modules.Utility.Trove) -- ---[[ UIObjects testing]] - -export type DraggableClass = { - Parent: Page | Component, - Name: string, - DragButton: GuiButton, - DragEvent: signal.Signal, - - _: { - Status: "Stored" | "Built", - - IsDragging: boolean, - DragStartTime: number, - - OnBuild: (self: Draggable) -> ()?, - }, - - OnBuild: (self: Draggable, callback: (self: Draggable) -> ()) -> (), - - Build: (self: Draggable, parent: Page | Component) -> (), - IsDragging: (self: Draggable) -> (boolean), - - _DragStart: (self: Draggable) -> (), - _DragStop: (self: Draggable) -> (), - - _MobileDrag: (self: Draggable, touchPositions: {Vector2}, scale: number, velocity: number, state: Enum.UserInputState) -> (), - - Clean: (self: Draggable) -> (), - Destroy: (self: Draggable) -> (), -} - -export type Draggable = typeof(setmetatable({} :: DraggableClass, {})) - --[[ == Template == ]] -export type TemplateClass = { +type TemplateClass = { Files: { [string]: (self: Object, parameters: {}?) -> () }, @@ -100,6 +67,11 @@ type BuildableObject = { StatusIs: (self: Self, status: "Stored" | "Built") -> (boolean), } +type CleanableObject = { + Clean: (self: Self) -> (), + Remove: (self: Self) -> (), +} + type RenderableObject = { _: { OnOpen: (self: Self) -> ()?, @@ -165,10 +137,7 @@ export type ComponentClass = { OnUpdate: (self: Component, command: string, callback: (self: Component) -> ()) -> (), Update: (self: Component, command: string, parameters: {}?) -> (), - - Clean: (self: Component) -> (), - Remove: (self: Component) -> (), -} & BuildableObject & RenderableObject +} & BuildableObject & CleanableObject & RenderableObject export type Component = typeof(setmetatable({} :: ComponentClass, {})) @@ -184,11 +153,8 @@ export type PageClass = { Buttons: ObjectList, Components: ObjectList, - Clean: (self: Page) -> (), - Remove: (self: Page) -> (), - GetManager: (self: Window) -> (Manager), -} & BuildableObject & RenderableObject +} & BuildableObject & CleanableObject & RenderableObject export type Page = typeof(setmetatable({} :: PageClass, {})) @@ -204,10 +170,7 @@ export type WindowClass = { PageOpened: signal.Signal, PageClosed: signal.Signal, }, - - Clean: (self: Window) -> (), - Remove: (self: Window) -> (), -} & BuildableObject & RenderableObject +} & BuildableObject & CleanableObject & RenderableObject export type Window = typeof(setmetatable({} :: WindowClass, {})) diff --git a/src/Shared/Modules/Managers/UIManager/UIObjects/Draggable.lua b/src/Shared/Modules/Managers/UIManager/UIObjects/Draggable.lua deleted file mode 100644 index 5b55b88..0000000 --- a/src/Shared/Modules/Managers/UIManager/UIObjects/Draggable.lua +++ /dev/null @@ -1,94 +0,0 @@ -local ReplicatedStorage = game:GetService("ReplicatedStorage") -local uis = game:GetService("UserInputService") -local types = require(ReplicatedStorage.Modules.Managers.UIManager.Types) -local Signal = require(ReplicatedStorage.Modules.Utility.Signal) -local module = {} - -local draggable: types.DraggableClass = {} :: types.DraggableClass -draggable["__index"] = draggable - -function module.new(name: string): types.Draggable - local self = setmetatable({ - Name = name, - DragEvent = Signal.new(), - - _ = { - IsDragging = false, - DragStartTime = 0, - }, - }, draggable) - - return self -end - ---[[ Draggable ]] - ---[[ - Use TouchSwipe for mobile, and MouseButton1Down with MouseButton1Up for PC -]] - -function draggable:OnBuild(callback: (self: types.Draggable) -> ()) - self._.OnBuild = callback -end - -function draggable:Build(parent: types.Page | types.Component) - self.Parent = parent - - if self._.OnBuild then - self._.OnBuild(self) - end - - if self.DragButton then - if uis.MouseEnabled then - self.Parent.Container:ConnectMethod(self.DragButton.MouseButton1Down, "_DragStart", self, {}) - self.Parent.Container:ConnectMethod(self.DragButton.MouseButton1Up, "_DragStop", self, {}) - else - self.Parent.Container:Connect(self.DragButton.TouchPan, function(touchPositions: {Vector2}, scale: number, velocity: number, state: Enum.UserInputState) - self:_MobileDrag(touchPositions, scale, velocity, state) - end) - end - end -end - -function draggable:IsDragging(): boolean - return self._.IsDragging -end - -function draggable:_DragStart() - if self._.IsDragging then - return - end - - self._.IsDragging = true - self._.DragStartTime = os.clock() - - self.DragEvent:Fire(Enum.UserInputType.Touch, true) -end - -function draggable:_DragStop() - self._.IsDragging = false - - self.DragEvent:Fire(Enum.UserInputType.Touch, false) -end - -function draggable:_MobileDrag(touchPositions: {Vector2}, scale: number, velocity: number, state: Enum.UserInputState) - if self._.IsDragging and state == Enum.UserInputState.Begin then - return - end - - self._.IsDragging = state == Enum.UserInputState.Begin - self._.DragStartTime = self._.IsDragging and os.clock() or 0 - - self.DragEvent:Fire(Enum.UserInputType.Touch, state, touchPositions, scale, velocity) -end - -function draggable:Clean() - self.DragEvent:DisconnectAll() -end - -function draggable:Destroy() - self:Clean() - setmetatable(getmetatable(self), nil) -end - -return module \ No newline at end of file