File tree Expand file tree Collapse file tree 5 files changed +43
-6
lines changed
Sources/Overload/OvEditor Expand file tree Collapse file tree 5 files changed +43
-6
lines changed Original file line number Diff line number Diff line change @@ -336,6 +336,11 @@ namespace OvEditor::Core
336
336
* Refresh every scripts (Re-interpret)
337
337
*/
338
338
void RefreshScripts ();
339
+
340
+ /* *
341
+ * Migrate all scripts from the Scripts/ folder to the Assets/Scripts/ folder
342
+ */
343
+ void MigrateScriptsToAssets ();
339
344
#pragma endregion
340
345
341
346
#pragma region BUILDING
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ namespace OvEditor::Panels
46
46
void CreateActorsMenu ();
47
47
void CreateResourcesMenu ();
48
48
void CreateSettingsMenu ();
49
+ void CreateToolsMenu ();
49
50
void CreateLayoutMenu ();
50
51
void CreateHelpMenu ();
51
52
Original file line number Diff line number Diff line change @@ -134,6 +134,27 @@ void OvEditor::Core::EditorActions::RefreshScripts()
134
134
OVLOG_INFO (" Scripts interpretation succeeded!" );
135
135
}
136
136
137
+ void OvEditor::Core::EditorActions::MigrateScriptsToAssets ()
138
+ {
139
+ // Copy all scripts from the project scripts folder to the project assets folder + "Scripts/"
140
+ std::filesystem::copy (m_context.projectScriptsPath , m_context.projectAssetsPath + " Scripts\\ " , std::filesystem::copy_options::recursive);
141
+ std::filesystem::remove_all (m_context.projectScriptsPath );
142
+
143
+ auto previousName = OvTools::Utils::PathParser::MakeNonWindowsStyle (m_context.projectScriptsPath );
144
+ auto newName = OvTools::Utils::PathParser::MakeNonWindowsStyle (m_context.projectAssetsPath + " Scripts\\ " );
145
+
146
+ for (auto & p : std::filesystem::recursive_directory_iterator (newName))
147
+ {
148
+ if (!p.is_directory ())
149
+ {
150
+ std::string newFileName = GetResourcePath (OvTools::Utils::PathParser::MakeWindowsStyle (p.path ().string ()));
151
+ std::string previousFileName = std::filesystem::path{ newFileName }.stem ().string ();
152
+
153
+ PropagateScriptRename (OvTools::Utils::PathParser::MakeWindowsStyle (previousFileName), OvTools::Utils::PathParser::MakeWindowsStyle (newFileName));
154
+ }
155
+ }
156
+ }
157
+
137
158
std::optional<std::string> OvEditor::Core::EditorActions::SelectBuildFolder ()
138
159
{
139
160
OvWindowing::Dialogs::SaveFileDialog dialog (" Build location" );
Original file line number Diff line number Diff line change @@ -1012,17 +1012,20 @@ OvEditor::Panels::AssetBrowser::AssetBrowser
1012
1012
);
1013
1013
}
1014
1014
1015
- if (! std::filesystem::exists (m_projectScriptFolder))
1015
+ if (std::filesystem::exists (m_projectScriptFolder))
1016
1016
{
1017
- std::filesystem::create_directories (m_projectScriptFolder);
1018
-
1019
1017
OvWindowing::Dialogs::MessageBox message
1020
1018
(
1021
- " Scripts folder not found" ,
1022
- " The \" Scripts/\" folders hasn't been found in your project directory. \n It has been automatically generated " ,
1019
+ " Deprecated scripts folder found. " ,
1020
+ " A \" Scripts/\" folder was found outside of the \" Assets \" folder, which is now deprecated. Migrating your scripts is recommended. \n Do you want to proceed? " ,
1023
1021
OvWindowing::Dialogs::MessageBox::EMessageType::WARNING,
1024
- OvWindowing::Dialogs::MessageBox::EButtonLayout::OK
1022
+ OvWindowing::Dialogs::MessageBox::EButtonLayout::YES_NO
1025
1023
);
1024
+
1025
+ if (message.GetUserAction () == OvWindowing::Dialogs::MessageBox::EUserAction::YES)
1026
+ {
1027
+ EDITOR_EXEC (MigrateScriptsToAssets ());
1028
+ }
1026
1029
}
1027
1030
1028
1031
auto & refreshButton = CreateWidget<Buttons::Button>(" Rescan assets" );
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ OvEditor::Panels::MenuBar::MenuBar()
44
44
CreateActorsMenu ();
45
45
CreateResourcesMenu ();
46
46
CreateSettingsMenu ();
47
+ CreateToolsMenu ();
47
48
CreateLayoutMenu ();
48
49
CreateHelpMenu ();
49
50
}
@@ -195,6 +196,12 @@ void OvEditor::Panels::MenuBar::CreateSettingsMenu()
195
196
m_settingsMenu = &CreateWidget<MenuList>(" Settings" );
196
197
}
197
198
199
+ void OvEditor::Panels::MenuBar::CreateToolsMenu ()
200
+ {
201
+ auto & toolsMenu = CreateWidget<MenuList>(" Tools" );
202
+ toolsMenu.CreateWidget <MenuItem>(" Migrate Scripts To Assets Folder" ).ClickedEvent += EDITOR_BIND (MigrateScriptsToAssets);
203
+ }
204
+
198
205
void OvEditor::Panels::MenuBar::CreateLayoutMenu ()
199
206
{
200
207
auto & layoutMenu = CreateWidget<MenuList>(" Layout" );
You can’t perform that action at this time.
0 commit comments