-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
90 additions
and
115 deletions.
There are no files selected for viewing
91 changes: 0 additions & 91 deletions
91
interfaces/src/main/kotlin/com/noxcrew/interfaces/interfaces/AbstractInterfaceBuilder.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 25 additions & 3 deletions
28
interfaces/src/main/kotlin/com/noxcrew/interfaces/interfaces/InterfaceBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,32 @@ | ||
package com.noxcrew.interfaces.interfaces | ||
|
||
import com.noxcrew.interfaces.pane.Pane | ||
import com.noxcrew.interfaces.properties.Trigger | ||
import com.noxcrew.interfaces.transform.AppliedTransform | ||
import com.noxcrew.interfaces.transform.ReactiveTransform | ||
import com.noxcrew.interfaces.transform.Transform | ||
import com.noxcrew.interfaces.utilities.IncrementingInteger | ||
|
||
/** A generic builder for creating an [Interface]. */ | ||
public abstract class InterfaceBuilder<P : Pane, T : Interface<P>> { | ||
/** Assists in creating a new interface. */ | ||
public abstract class InterfaceBuilder<P : Pane, I : Interface<P>> : InterfaceProperties<P>() { | ||
|
||
private val transformCounter by IncrementingInteger() | ||
private val _transforms: MutableCollection<AppliedTransform<P>> = mutableListOf() | ||
|
||
/** All transforms in this builder. */ | ||
public val transforms: Collection<AppliedTransform<P>> | ||
get() = _transforms | ||
|
||
/** Creates the interface. */ | ||
public abstract fun build(): T | ||
public abstract fun build(): I | ||
|
||
/** Adds a new transform to the interface that updates whenever [triggers] change. */ | ||
public fun withTransform(vararg triggers: Trigger, transform: Transform<P>) { | ||
_transforms += AppliedTransform(transformCounter, triggers.toSet(), transform) | ||
} | ||
|
||
/** Adds a new reactive transform to the interface. */ | ||
public fun addTransform(reactiveTransform: ReactiveTransform<P>) { | ||
_transforms += AppliedTransform(transformCounter, reactiveTransform.triggers.toSet(), reactiveTransform) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters