-
Notifications
You must be signed in to change notification settings - Fork 0
Flares #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
adam-drake1
wants to merge
23
commits into
main
Choose a base branch
from
CU-3wekf8k_Flare
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Flares #26
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
c2de70d
Created rodux store and added flare actions and reducer
adam-drake1 65a4343
chore: update eslintrc
christopher-buss 97145f4
Merge remote-tracking branch 'origin/main' into CU-3wekf8k_Flare
adam-drake1 cacc1fc
Moved package in studio to ReplicatedStorage so Roact components are …
adam-drake1 e0bda0c
Created a modal component which supports displaying in game and in Ho…
adam-drake1 09be31a
Merge remote-tracking branch 'origin/CU-384j922_Update-eslintrc' into…
adam-drake1 4adb55f
export StoreState and ClientStore type for use with rodux hooks
adam-drake1 70468b0
install roact-hooked and roact-rodux hooked
adam-drake1 ec10801
move rodux-utils to existing utilities folder
adam-drake1 ac4531a
move rodux-utils to existing utilities folder
adam-drake1 ad3013b
Moved functions relating to making Hoarcekat congruent with playing t…
adam-drake1 1fb6f17
Added message parameter to FireFlare action
adam-drake1 545225d
created common IFlare interface
adam-drake1 946fff3
created common padding element
adam-drake1 efff0a2
created ThemeContext for uniform text and frame styling
adam-drake1 dfad188
Fix jsxFragmentFactory setting
adam-drake1 fbdd178
Initial Flare and Console UI
adam-drake1 54ece0c
override no-unused-vars due to issue in .tsx files with Roact import
adam-drake1 bd2ab89
disable explicit-function-return-types for expressions
adam-drake1 b83b074
fix eslint warnings
adam-drake1 deb6902
Merge branch 'main' of https://github.com/AetherInteractiveLtd/Tina i…
RigidOfficial c222b60
merge
RigidOfficial fd3dc5f
console stuff
RigidOfficial File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export type IFlare = { eventName: string; amount: number; message?: string }; | ||
| export type EnumOrName<T extends EnumItem> = T | T["Name"]; |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import Roact from "@rbxts/roact"; | ||
| import { Div } from "@rbxts/rowind-mini"; | ||
|
|
||
| export = function (parent: Instance) { | ||
| const UI = ( | ||
| <Div className="bg-gray-800 w-100% h-100%"> | ||
| <Div className="bg-gray-700 w-100% h-12% flex-left"></Div> | ||
| </Div> | ||
| ); | ||
|
|
||
| const MountedUI = Roact.mount(UI, parent); | ||
|
|
||
| return function () { | ||
| Roact.unmount(MountedUI); | ||
| }; | ||
| }; |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import Roact from "@rbxts/roact"; | ||
|
|
||
| interface Props { | ||
| All?: number; | ||
| Horizontal?: number; | ||
| Vertical?: number; | ||
| Top?: number; | ||
| Bottom?: number; | ||
| Left?: number; | ||
| Right?: number; | ||
| } | ||
|
|
||
| const Padding: Roact.FunctionComponent<Props> = ({ | ||
| All = 0, | ||
| Horizontal = 0, | ||
| Vertical = 0, | ||
| Top = 0, | ||
| Bottom = 0, | ||
| Right = 0, | ||
| Left = 0, | ||
| }: Props) => { | ||
| return ( | ||
| <uipadding | ||
| PaddingBottom={new UDim(0, Bottom + Vertical + All)} | ||
| PaddingTop={new UDim(0, Top + Vertical + All)} | ||
| PaddingLeft={new UDim(0, Left + Horizontal + All)} | ||
| PaddingRight={new UDim(0, Right + Horizontal + All)} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| export default Padding; |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import Roact, { JsxInstanceProperties } from "@rbxts/roact"; | ||
| import { withHooks } from "@rbxts/roact-hooked"; | ||
|
|
||
| type CircleProps = JsxInstanceProperties<Frame>; | ||
|
|
||
| const Circle = withHooks((props: CircleProps) => { | ||
| return ( | ||
| <frame {...props}> | ||
| <uicorner CornerRadius={new UDim(1, 0)} /> | ||
| <uiaspectratioconstraint AspectRatio={1} /> | ||
| </frame> | ||
| ); | ||
| }); | ||
|
|
||
| export default Circle; |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import Roact from "@rbxts/roact"; | ||
| import { withHooks } from "@rbxts/roact-hooked"; | ||
|
|
||
| import Header from "./header"; | ||
|
|
||
| const Console = withHooks(() => { | ||
| return ( | ||
| <frame Size={new UDim2(1, 0, 1, 0)} Transparency={1}> | ||
| <Header /> | ||
| </frame> | ||
| ); | ||
| }); | ||
|
|
||
| export default Console; |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import Roact, { JsxInstanceProperties } from "@rbxts/roact"; | ||
| import { useCallback, useState, withHooks } from "@rbxts/roact-hooked"; | ||
| import { useSelector } from "@rbxts/roact-rodux-hooked"; | ||
|
|
||
| import { IFlare } from "../../../types/common"; | ||
| import Padding from "../../common/padding"; | ||
| import { StoreState } from "../../store"; | ||
| import Flare from "./flare"; | ||
|
|
||
| type FlareBarProps = Partial<Pick<JsxInstanceProperties<Frame>, "Position" | "AnchorPoint" | "Size">>; | ||
|
|
||
| export const FlareBar = withHooks((props: FlareBarProps) => { | ||
| const { Size = new UDim2(1, 0, 0, 36) } = props; | ||
| const flares = useSelector((state: StoreState) => state.flares); | ||
| const [selected, setSelected] = useState<IFlare | undefined>(); | ||
|
|
||
| const handleClick = useCallback((flare: IFlare) => { | ||
| setSelected(selected => { | ||
| if (flare.amount === 0) return; | ||
| return flare === selected ? undefined : flare; | ||
| }); | ||
| }, []); | ||
|
|
||
| return ( | ||
| <scrollingframe | ||
| Size={Size} | ||
| Position={props.Position} | ||
| AnchorPoint={props.AnchorPoint} | ||
| BackgroundTransparency={1} | ||
| CanvasSize={new UDim2(1, 0, 0, 36)} | ||
| AutomaticCanvasSize={"X"} | ||
| ScrollingDirection={"X"} | ||
| ScrollBarThickness={0} | ||
| > | ||
| <uilistlayout | ||
| FillDirection={"Horizontal"} | ||
| HorizontalAlignment={"Left"} | ||
| VerticalAlignment={"Center"} | ||
| Padding={new UDim(0, 4)} | ||
| /> | ||
| <Padding Horizontal={3} /> | ||
| {flares.map((flare, i) => ( | ||
| <Flare Key={i} Info={flare} Selected={flare === selected} OnClick={handleClick} /> | ||
| ))} | ||
| </scrollingframe> | ||
| ); | ||
| }); |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import Roact, { Element } from "@rbxts/roact"; | ||
| import { useRef, withHooksPure } from "@rbxts/roact-hooked"; | ||
| import { TextService } from "@rbxts/services"; | ||
|
|
||
| import { IFlare } from "../../../types/common"; | ||
| import { getAbsolutePosition } from "../../../utilities/hoarcekat"; | ||
| import Padding from "../../common/padding"; | ||
| import { useTheme } from "../../theme/theme"; | ||
| import Circle from "./circle"; | ||
| import Tooltip from "./tooltip"; | ||
|
|
||
| interface Props { | ||
| Info: IFlare; | ||
| Selected: boolean; | ||
| OnClick: (flare: IFlare) => void; | ||
| } | ||
|
|
||
| const Flare = withHooksPure(({ Info, Selected, OnClick }: Props) => { | ||
| const { eventName, amount, message } = Info; | ||
| const theme = useTheme(); | ||
| const buttonRef = useRef<TextButton>(); | ||
|
|
||
| const text = `${eventName} ${amount}x`; | ||
| const textSize = TextService.GetTextSize(text, theme.FontSize, theme.Font, new Vector2(math.huge, math.huge)); | ||
| const circleColour = amount > 0 ? Color3.fromRGB(255, 18, 18) : Color3.fromRGB(18, 18, 255); | ||
|
|
||
| let tooltip: Element | undefined; | ||
| if (Selected) { | ||
| const button = buttonRef.getValue()!; | ||
| const { X: positionX, Y: positionY } = getAbsolutePosition(button); | ||
| const { Y: sizeY } = button.AbsoluteSize; | ||
| const tooltipPosition = UDim2.fromOffset(positionX - 3, positionY + sizeY + 8); | ||
| tooltip = <Tooltip Message={message} Position={tooltipPosition} />; | ||
| } | ||
|
|
||
| return ( | ||
| <textbutton | ||
| Ref={buttonRef} | ||
| Size={UDim2.fromOffset(textSize.X, 30)} | ||
| AutomaticSize={"X"} | ||
| Text="" | ||
| BackgroundColor3={theme.SecondaryBackgroundColor3} | ||
| Event={{ | ||
| Activated: () => OnClick(Info), | ||
| }} | ||
| > | ||
| <Padding Horizontal={7} /> | ||
| <uicorner CornerRadius={new UDim(0.4, 0)} /> | ||
| <uilistlayout FillDirection={"Horizontal"} VerticalAlignment={"Center"} Padding={new UDim(0, 4)} /> | ||
| <Circle Size={UDim2.fromOffset(10, 10)} BackgroundColor3={circleColour} /> | ||
| <textlabel | ||
| TextColor3={new Color3(0.9, 0.9, 0.9)} | ||
| Text={text} | ||
| Font={theme.Font} | ||
| TextSize={theme.FontSize} | ||
| Size={UDim2.fromOffset(textSize.X, 32)} | ||
| BackgroundTransparency={1} | ||
| /> | ||
| <uistroke Color={theme.PrimaryTextColor3} Thickness={Selected ? 1 : 0} ApplyStrokeMode={"Border"} /> | ||
| {tooltip} | ||
| </textbutton> | ||
| ); | ||
| }); | ||
|
|
||
| export default Flare; |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import Roact from "@rbxts/roact"; | ||
| import { withHooksPure } from "@rbxts/roact-hooked"; | ||
|
|
||
| import { useTheme } from "../../theme/theme"; | ||
| import { FlareBar } from "./flare-bar"; | ||
|
|
||
| const Header = withHooksPure(() => { | ||
| const theme = useTheme(); | ||
|
|
||
| return ( | ||
| <frame | ||
| Size={new UDim2(1, 0, 0, 72)} | ||
| BackgroundColor3={theme.PrimaryBackgroundColor3} | ||
| BorderColor3={theme.SecondaryBackgroundColor3} | ||
| > | ||
| <FlareBar Position={UDim2.fromScale(0, 1)} AnchorPoint={new Vector2(0, 1)} /> | ||
| </frame> | ||
| ); | ||
| }); | ||
|
|
||
| export default Header; |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /// <reference types="@rbxts/types/plugin" /> | ||
|
|
||
| import Roact, { Children, Portal } from "@rbxts/roact"; | ||
| import { withHooks } from "@rbxts/roact-hooked"; | ||
| import { Players, RunService } from "@rbxts/services"; | ||
|
|
||
| import { hoarcekatFrame } from "../../../utilities/hoarcekat"; | ||
|
|
||
| const isGameRunning = RunService.IsRunning(); | ||
|
|
||
| /** | ||
| * Modal which can be used with .story scripts. Generally a modal will be added directly to the PlayerGui, but | ||
| * since .story scripts are ran inside studio PlayerGui won't exists. Instead, we'll parent the modal directly | ||
| * to Hoarcekat's preview window, simulating a modal without running the game. | ||
| * | ||
| * This is not perfect as the AbsolutePosition of the preview window is about (154, 5) rather than (0, 0), so | ||
| * the position may be skewed when positioning components absolutely. But it's better than the component erroring. | ||
| */ | ||
| const HoarcekatModal = withHooks(props => { | ||
| const parent = hoarcekatFrame; | ||
| if (!parent) { | ||
| warn("Unable to find Hoarcekat preview window"); | ||
| return <frame />; | ||
| } | ||
|
|
||
| const made = ( | ||
| <Portal target={parent}> | ||
| <frame Size={UDim2.fromScale(1, 1)} Transparency={1} ZIndex={10000}> | ||
| {props[Children]} | ||
| </frame> | ||
| </Portal> | ||
| ); | ||
|
|
||
| return made; | ||
| }); | ||
|
|
||
| /** | ||
| * Modal which parents itself to the PlayerGui and renders children in a separate ScreenGui | ||
| */ | ||
| const GameRunningModal = withHooks(props => { | ||
| const playerGui = Players.LocalPlayer.FindFirstChildOfClass("PlayerGui")!; | ||
| return ( | ||
| <Portal target={playerGui}> | ||
| <screengui DisplayOrder={10000}>{props[Children]}</screengui> | ||
| </Portal> | ||
| ); | ||
| }); | ||
|
|
||
| const Modal = withHooks(props => { | ||
| return isGameRunning ? ( | ||
| <GameRunningModal>{props[Children]}</GameRunningModal> | ||
| ) : ( | ||
| <HoarcekatModal>{props[Children]}</HoarcekatModal> | ||
| ); | ||
| }); | ||
|
|
||
| export default Modal; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was sarcasm, please find a better name for firing flares 😅