@@ -4,12 +4,12 @@ local Selection = game:GetService("Selection");
44
55local root = script .Parent .Parent .Parent ;
66local React = require (root .roblox_packages .react );
7- local useRefreshDialogueMakerScripts = require (root .DialogueEditor .hooks .useRefreshDialogueMakerScripts );
87local ToolbarButton = require (script .ToolbarButton );
9- local useStudioColors = require (root .DialogueEditor .hooks .useStudioColors );
10- local useDialogueScriptType = require (root .DialogueEditor .hooks .useDialogueScriptType );
118local useChangeHistory = require (root .DialogueEditor .hooks .useChangeHistory );
9+ local useDialogueScriptType = require (root .DialogueEditor .hooks .useDialogueScriptType );
1210local useDynamicSize = require (root .DialogueEditor .hooks .useDynamicSize );
11+ local useRefreshDialogueMakerScripts = require (root .DialogueEditor .hooks .useRefreshDialogueMakerScripts );
12+ local useStudioColors = require (root .DialogueEditor .hooks .useStudioColors );
1313local useStudioIcons = require (root .DialogueEditor .hooks .useStudioIcons );
1414
1515export type ToolbarProps = {
@@ -24,6 +24,7 @@ export type ToolbarProps = {
2424local function Toolbar (props : ToolbarProps )
2525
2626 local icons = useStudioIcons ();
27+ local plugin = props .plugin ;
2728 local pluginGUI = props .pluginGUI ;
2829 local colors = useStudioColors ();
2930 local refreshDialogueMakerScripts = useRefreshDialogueMakerScripts ();
@@ -114,109 +115,94 @@ local function Toolbar(props: ToolbarProps)
114115
115116 end , {selectedScript :: unknown , refreshDialogueMakerScripts });
116117
117- return React .createElement ("Frame" , {
118- Size = UDim2 .new (1 , 0 , 0 , 40 );
119- LayoutOrder = layoutOrder ;
120- BackgroundColor3 = colors .toolbar ;
121- BorderSizePixel = 0 ;
122- }, {
123- UIListLayout = React .createElement ("UIListLayout" , {
124- SortOrder = Enum.SortOrder.LayoutOrder ;
125- FillDirection = Enum.FillDirection.Horizontal ;
126- VerticalAlignment = Enum.VerticalAlignment.Center ;
127- });
128- UIPadding = React .createElement ("UIPadding" , {
129- PaddingLeft = UDim .new (0 , 15 );
130- PaddingRight = UDim .new (0 , 15 );
131- PaddingBottom = UDim .new (0 , 5 );
132- });
133- ViewParentButton = React .createElement (ToolbarButton , {
134- iconImage = "rbxassetid://14098871159" ;
135- text = if shouldShowLabels then "View parent" else nil ;
136- layoutOrder = 1 ;
137- isDisabled = settingsTarget ~= nil or not selectedScript ;
138- onClick = function ()
118+ local buttons = {};
139119
140- if selectedScript then
120+ local viewParentButton = React .createElement (ToolbarButton , {
121+ iconImage = "rbxassetid://14098871159" ;
122+ text = if shouldShowLabels then "View parent" else nil ;
123+ plugin = plugin ;
124+ layoutOrder = # buttons + 1 ;
125+ key = "ViewParentButton" ;
126+ isDisabled = settingsTarget ~= nil or not selectedScript ;
127+ onClick = function ()
141128
142- Selection : Set ({ selectedScript . Parent });
129+ if selectedScript then
143130
144- end ;
131+ Selection :Set ({selectedScript .Parent });
132+
133+ end ;
134+
135+ end ;
136+ });
137+
138+ table.insert (buttons , viewParentButton );
139+
140+ if dialogueScriptType then
141+
142+ local settingsButton = React .createElement (ToolbarButton , {
143+ iconImage = icons .settings ;
144+ text = if shouldShowLabels then (if settingsTarget == nil then "Settings" else "Close settings" ) else nil ;
145+ layoutOrder = # buttons + 1 ;
146+ plugin = plugin ;
147+ key = "SettingsButton" ;
148+ onClick = function ()
149+
150+ setSettingsTarget (if settingsTarget then nil else selectedScript );
145151
146152 end ;
147153 });
148- SettingsButton = if dialogueScriptType then
149- React .createElement (ToolbarButton , {
150- iconImage = icons .settings ;
151- text = if shouldShowLabels then (if settingsTarget == nil then "Settings" else "Close settings" ) else nil ;
152- layoutOrder = 2 ;
153- onClick = function ()
154154
155- if settingsTarget then
155+ table.insert ( buttons , settingsButton );
156156
157- setSettingsTarget ( nil ) ;
157+ end ;
158158
159- else
159+ if not selectedScript or dialogueScriptType == "Redirect" then
160160
161- setSettingsTarget ( selectedScript );
161+ for _ , dialogueType in { "Conversation" , "Message" , "Response" , "Redirect" } do
162162
163- end ;
163+ if not selectedScript and dialogueType ~= "Conversation" then
164164
165- end ;
166- })
167- else nil ;
168- AddConversationButton = if not selectedScript then
169- React .createElement (ToolbarButton , {
170- iconImage = icons .conversation ;
171- text = if shouldShowLabels then "Add conversation" else nil ;
172- layoutOrder = 3 ;
173- isDisabled = settingsTarget ~= nil or # Selection :Get () ~= 1 ;
174- onClick = function ()
165+ continue ;
175166
176- addDialogueScript ( "Conversation" ) ;
167+ end ;
177168
178- end ;
179- })
180- else nil ;
181- AddMessageButton = if selectedScript and dialogueScriptType ~= "Redirect" then
182- React .createElement (ToolbarButton , {
183- iconImage = icons .message ;
184- text = if shouldShowLabels then "Add message" else nil ;
185- layoutOrder = 4 ;
169+ local addDialogueButton = React .createElement (ToolbarButton , {
170+ iconImage = icons [dialogueType :lower ()];
171+ text = if shouldShowLabels then `Add {dialogueType :lower ()}` else nil ;
172+ layoutOrder = # buttons + 1 ;
173+ plugin = plugin ;
174+ key = `Add{dialogueType }Button` ;
186175 isDisabled = settingsTarget ~= nil or # Selection :Get () ~= 1 ;
187176 onClick = function ()
188177
189- addDialogueScript (" Message" );
178+ addDialogueScript (dialogueType :: "Conversation" | " Message" | "Response" | "Redirect " );
190179
191180 end ;
192- })
193- else nil ;
194- AddResponseButton = if selectedScript and dialogueScriptType ~= "Redirect" then
195- React .createElement (ToolbarButton , {
196- iconImage = icons .response ;
197- text = if shouldShowLabels then "Add response" else nil ;
198- layoutOrder = 5 ;
199- isDisabled = settingsTarget ~= nil or # Selection :Get () ~= 1 ;
200- onClick = function ()
181+ });
201182
202- addDialogueScript ( "Response" );
183+ table.insert ( buttons , addDialogueButton );
203184
204- end ;
205- })
206- else nil ;
207- AddRedirectButton = if selectedScript and dialogueScriptType ~= "Redirect" then
208- React .createElement (ToolbarButton , {
209- iconImage = icons .redirect ;
210- text = if shouldShowLabels then (if shouldShowLabels then "Add redirect" else nil ) else nil ;
211- layoutOrder = 6 ;
212- isDisabled = settingsTarget ~= nil or # Selection :Get () ~= 1 ;
213- onClick = function ()
185+ end ;
214186
215- addDialogueScript ( "Redirect" ) ;
187+ end ;
216188
217- end ;
218- })
219- else nil ;
189+ return React .createElement ("Frame" , {
190+ Size = UDim2 .new (1 , 0 , 0 , 40 );
191+ LayoutOrder = layoutOrder ;
192+ BackgroundColor3 = colors .toolbar ;
193+ BorderSizePixel = 0 ;
194+ }, {
195+ UIListLayout = React .createElement ("UIListLayout" , {
196+ SortOrder = Enum.SortOrder.LayoutOrder ;
197+ FillDirection = Enum.FillDirection.Horizontal ;
198+ VerticalAlignment = Enum.VerticalAlignment.Center ;
199+ });
200+ UIPadding = React .createElement ("UIPadding" , {
201+ PaddingLeft = UDim .new (0 , 15 );
202+ PaddingRight = UDim .new (0 , 15 );
203+ PaddingBottom = UDim .new (0 , 5 );
204+ });
205+ Buttons = React .createElement (React .Fragment , {}, buttons );
220206 });
221207
222208end ;
0 commit comments