MCPcopy Create free account
hub / github.com/TypesettingTools/Aegisub / LoadUnloadFiles

Method LoadUnloadFiles

src/project.cpp:173–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173void Project::LoadUnloadFiles(ProjectProperties properties) {
174 auto load_linked = OPT_GET("App/Auto/Load Linked Files")->GetInt();
175 if (!load_linked) return;
176
177 auto audio = context->path->MakeAbsolute(properties.audio_file, "?script");
178 auto video = context->path->MakeAbsolute(properties.video_file, "?script");
179 auto timecodes = context->path->MakeAbsolute(properties.timecodes_file, "?script");
180 auto keyframes = context->path->MakeAbsolute(properties.keyframes_file, "?script");
181
182 if (video == video_file && audio == audio_file && keyframes == keyframes_file && timecodes == timecodes_file)
183 return;
184
185 if (load_linked == 2) {
186 wxString str = _("Do you want to load/unload the associated files?");
187 str += "\n";
188
189 auto append_file = [&](agi::fs::path const& p, wxString const& unload, wxString const& load) {
190 if (p.empty())
191 str += "\n" + unload;
192 else
193 str += "\n" + agi::wxformat(load, p);
194 };
195
196 if (audio != audio_file)
197 append_file(audio, _("Unload audio"), _("Load audio file: %s"));
198 if (video != video_file)
199 append_file(video, _("Unload video"), _("Load video file: %s"));
200 if (timecodes != timecodes_file)
201 append_file(timecodes, _("Unload timecodes"), _("Load timecodes file: %s"));
202 if (keyframes != keyframes_file)
203 append_file(keyframes, _("Unload keyframes"), _("Load keyframes file: %s"));
204
205 if (wxMessageBox(str, _("(Un)Load files?"), wxYES_NO | wxCENTRE, context->parent) != wxYES)
206 return;
207 }
208
209 bool loaded_video = false;
210 if (video != video_file) {
211 if (video.empty())
212 CloseVideo();
213 else if ((loaded_video = DoLoadVideo(video))) {
214 auto vc = context->videoController.get();
215 vc->JumpToFrame(properties.video_position);
216
217 auto ar_mode = static_cast<AspectRatio>(properties.ar_mode);
218 if (ar_mode == AspectRatio::Custom)
219 vc->SetAspectRatio(properties.ar_value);
220 else
221 vc->SetAspectRatio(ar_mode);
222 context->videoDisplay->SetZoom(properties.video_zoom);
223 }
224 }
225
226 if (!timecodes.empty()) LoadTimecodes(timecodes);
227 if (!keyframes.empty()) LoadKeyframes(keyframes);
228
229 if (audio != audio_file) {
230 if (audio.empty())

Callers

nothing calls this directly

Calls 7

wxformatFunction · 0.85
MakeAbsoluteMethod · 0.80
JumpToFrameMethod · 0.80
SetAspectRatioMethod · 0.80
SetZoomMethod · 0.80
getMethod · 0.45
HasAudioMethod · 0.45

Tested by

no test coverage detected