int main_fft(int argc, char* argv[]) { bool unitary = false; bool inv = false; const struct opt_s opts[] = { OPT_SET('u', &unitary, "unitary"), OPT_SET('i', &inv, "inverse"), }; cmdline(&argc, argv, 3, 3, usage_str, help_str, ARRAY_SIZE(opts), opts); long dims[DIMS]; complex float* idata = load_cfl(argv[2], DIMS, dims); complex float* data = create_cfl(argv[3], DIMS, dims); unsigned long flags = labs(atol(argv[1])); md_copy(DIMS, dims, data, idata, sizeof(complex float)); unmap_cfl(DIMS, dims, idata); if (unitary) fftscale(DIMS, dims, flags, data, data); (inv ? ifftc : fftc)(DIMS, dims, flags, data, data); unmap_cfl(DIMS, dims, data); exit(0); }
static int parse() { char *arg = cmd; char *ep, *p, *q; char unit; size_t len; const char *cp; #if 0 int c, i, j; #else int c, i; #endif while ((c = *arg++)) { if (c == ' ' || c == '\t' || c == '\n') continue; for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++); ep = p; if (*p) *p++ = 0; if (c == '-') { while ((c = *arg++)) { if (c == 'P') { cp = "yes"; #if 0 } else { opts |= OPT_SET(RBX_DUAL) | OPT_SET(RBX_SERIAL); cp = "no"; } #endif printf("Keyboard: %s\n", cp); continue; #if 0 } else if (c == 'S') { j = 0; while ((unsigned int)(i = *arg++ - '0') <= 9) j = j * 10 + i; if (j > 0 && i == -'0') { comspeed = j; break; } /* Fall through to error below ('S' not in optstr[]). */ #endif } for (i = 0; c != optstr[i]; i++) if (i == NOPT - 1) return -1; opts ^= OPT_SET(flags[i]); } ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) : OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD; #if 0 if (ioctrl & IO_SERIAL) { if (sio_init(115200 / comspeed) != 0) ioctrl &= ~IO_SERIAL; } #endif } else {
void DialogSearchReplace::UpdateSettings() { Search.isReg = CheckRegExp->IsChecked() && CheckRegExp->IsEnabled(); Search.matchCase = CheckMatchCase->IsChecked(); Search.updateVideo = CheckUpdateVideo->IsChecked() && CheckUpdateVideo->IsEnabled(); OPT_SET("Tool/Search Replace/Match Case")->SetBool(CheckMatchCase->IsChecked()); OPT_SET("Tool/Search Replace/RegExp")->SetBool(CheckRegExp->IsChecked()); OPT_SET("Tool/Search Replace/Video Update")->SetBool(CheckUpdateVideo->IsChecked()); OPT_SET("Tool/Search Replace/Field")->SetInt(Field->GetSelection()); OPT_SET("Tool/Search Replace/Affect")->SetInt(Affect->GetSelection()); }
PersistLocation::PersistLocation(wxDialog *dialog, std::string options_prefix, bool size_too) : x_opt(OPT_SET(options_prefix + "/Last/X")) , y_opt(OPT_SET(options_prefix + "/Last/Y")) , w_opt(size_too ? OPT_SET(options_prefix + "/Last/Width") : nullptr) , h_opt(size_too ? OPT_SET(options_prefix + "/Last/Height") : nullptr) , maximize_opt(OPT_SET(options_prefix + "/Maximized")) , dialog(dialog) { int x = x_opt->GetInt(); int y = y_opt->GetInt(); if (x == -1 && y == -1) dialog->CenterOnParent(); else { // First move to the saved place so that it ends up on the right monitor dialog->Move(x, y); if (size_too && w_opt->GetInt() > 0 && h_opt->GetInt() > 0) dialog->SetSize(w_opt->GetInt(), h_opt->GetInt()); int display_index = wxDisplay::GetFromWindow(dialog); // If it's moved offscreen center on the parent and try again if (display_index == wxNOT_FOUND) { dialog->CenterOnParent(); display_index = wxDisplay::GetFromWindow(dialog); } // If it's still offscreen just give up if (display_index == wxNOT_FOUND) return; wxRect display_area = wxDisplay(display_index).GetClientArea(); wxSize dialog_size = dialog->GetSize(); // Ensure that the top-left corner is onscreen if (x < display_area.x) x = display_area.x; if (y < display_area.y) y = display_area.y; // Ensure that the bottom-right corner is onscreen as long as doing so // wouldn't force the top-left corner offscreen if (x + dialog_size.x > display_area.GetRight()) x = std::max(display_area.x, display_area.GetRight() - dialog_size.x); if (y + dialog_size.y > display_area.GetBottom()) y = std::max(display_area.y, display_area.GetBottom() - dialog_size.y); dialog->Move(x, y); } dialog->Bind(wxEVT_MOVE, &PersistLocation::OnMove, this); dialog->Bind(wxEVT_SIZE, &PersistLocation::OnSize, this); if ((dialog->GetWindowStyle() & wxMAXIMIZE_BOX) && maximize_opt->GetBool()) dialog->Maximize(); }
int parse_option( const char *option, struct option *opts ) { char *end; int ret = 0; for ( ; opts->type != OPTION_END; opts++ ) { if ( !prefixcmp( option, opts->prefix_opt ) ) { char *mask_ptr = NULL; if ( OPT_MASK_SET( opts->flags ) ) { mask_ptr = strchr( option, '/' ); *mask_ptr = '\0'; mask_ptr = mask_ptr + 1; } char *ptr = strchr( option, '=' ) + 1; switch( opts->type ) { case OPTION_UINT8: { *( uint8_t * ) opts->value = ( uint8_t ) strtol( ptr, &end, 10 ); OPT_SET( opts->flags ); } break; case OPTION_UINT16: { *( uint16_t * ) opts->value = ( uint16_t ) strtol( ptr, &end, 10 ); OPT_SET( opts->flags ); } break; case OPTION_UINT32: { *( uint32_t * ) opts->value = ( uint32_t ) strtol( ptr, &end, 10 ); OPT_SET( opts->flags ); } break; case OPTION_UINT64: { if ( OPT_MASK_SET( opts->flags ) ) { *( uint64_t * ) opts->value = ( uint64_t ) strtoll( ptr, &end, 0 ); *( ( uint64_t * ) opts->value + 1 ) = ( uint64_t ) strtoll( mask_ptr, &end, 0 ); } else { *( uint64_t * ) opts->value = ( uint64_t ) strtoll( ptr, &end, 0 ); } OPT_SET( opts->flags ); } break; default: warn( "Unsupported option type %d ", opts->type ); ret = -1; break; } } } return ret; }
void AudioBox::OnMouseWheel(wxMouseEvent &evt) { if (!ForwardMouseWheelEvent(audioDisplay, evt)) return; bool zoom = evt.CmdDown() != OPT_GET("Audio/Wheel Default to Zoom")->GetBool(); if (!zoom) { int amount = -evt.GetWheelRotation() * GetClientSize().GetWidth() / (evt.GetWheelDelta() * 3); // If the user did a horizontal scroll the amount should be inverted // for it to be natural. if (evt.GetWheelAxis() == 1) amount = -amount; // Reset any accumulated zoom mouse_zoom_accum = 0; audioDisplay->ScrollBy(amount); } else if (evt.GetWheelAxis() == 0) { mouse_zoom_accum += evt.GetWheelRotation(); int zoom_delta = mouse_zoom_accum / evt.GetWheelDelta(); mouse_zoom_accum %= evt.GetWheelDelta(); int new_zoom = audioDisplay->GetZoomLevel() + zoom_delta; audioDisplay->SetZoomLevel(new_zoom); HorizontalZoom->SetValue(-new_zoom); OPT_SET("Audio/Zoom/Horizontal")->SetInt(new_zoom); } }
int main_estdelay(int argc, char* argv[]) { bool ring = false; int pad_factor = 100; unsigned int no_intersec_sp = 1; float size = 1.5; const struct opt_s opts[] = { OPT_SET('R', &ring, "RING method"), OPT_INT('p', &pad_factor, "p", "[RING] Padding"), OPT_UINT('n', &no_intersec_sp, "n", "[RING] Number of intersecting spokes"), OPT_FLOAT('r', &size, "r", "[RING] Central region size"), }; cmdline(&argc, argv, 2, 2, usage_str, help_str, ARRAY_SIZE(opts), opts); num_init(); if (pad_factor % 2 != 0) error("Pad_factor -p should be even\n"); long tdims[DIMS]; const complex float* traj = load_cfl(argv[1], DIMS, tdims); long tdims1[DIMS]; md_select_dims(DIMS, ~MD_BIT(1), tdims1, tdims); complex float* traj1 = md_alloc(DIMS, tdims1, CFL_SIZE); md_slice(DIMS, MD_BIT(1), (long[DIMS]){ 0 }, tdims, traj1, traj, CFL_SIZE);
static int parse() { char *arg = cmd; char *ep, *p; int c, i; while ((c = *arg++)) { if (c == ' ' || c == '\t' || c == '\n') continue; for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++); ep = p; if (*p) *p++ = 0; if (c == '-') { while ((c = *arg++)) { for (i = 0; c != optstr[i]; i++) if (i == NOPT - 1) return -1; opts ^= OPT_SET(flags[i]); } } else { arg--; if ((i = ep - arg)) { if ((size_t)i >= sizeof(kname)) return -1; memcpy(kname, arg, i + 1); } } arg = p; } return 0; }
void DialogPasteOver::OnOK(wxCommandEvent &) { std::vector<bool> options; for (size_t i = 0; i < ListBox->GetCount(); ++i) options.push_back(ListBox->IsChecked(i)); OPT_SET("Tool/Paste Lines Over/Fields")->SetListBool(options); EndModal(0); }
void DialogDetachedVideo::OnVideoOpen() { if (context->videoController->IsLoaded()) SetTitle(wxString::Format(_("Video: %s"), context->videoController->GetVideoName().filename().wstring())); else { Close(); OPT_SET("Video/Detached/Enabled")->SetBool(true); } }
/// @brief OK pressed void DialogPasteOver::OnOK(wxCommandEvent &) { for (int i=0;i<10;i++) { options[i] = ListBox->IsChecked(i); } OPT_SET("Tool/Paste Lines Over/Fields")->SetListBool(options); EndModal(1); }
DialogSelection::~DialogSelection() { OPT_SET("Tool/Select Lines/Text")->SetString(from_wx(match_text->GetValue())); OPT_SET("Tool/Select Lines/Condition")->SetInt(select_unmatching_lines->GetValue()); OPT_SET("Tool/Select Lines/Field")->SetInt(dialogue_field->GetSelection()); OPT_SET("Tool/Select Lines/Action")->SetInt(selection_change_type->GetSelection()); OPT_SET("Tool/Select Lines/Mode")->SetInt(match_mode->GetSelection()); OPT_SET("Tool/Select Lines/Match/Case")->SetBool(case_sensitive->IsChecked()); OPT_SET("Tool/Select Lines/Match/Dialogue")->SetBool(apply_to_dialogue->IsChecked()); OPT_SET("Tool/Select Lines/Match/Comment")->SetBool(apply_to_comments->IsChecked()); }
/// @brief Change colour of preview's background void DialogStyleEditor::OnPreviewColourChange (wxCommandEvent &evt) { ColourButton *btn = static_cast<ColourButton*>(evt.GetClientData()); if (!btn) evt.Skip(); else { SubsPreview->SetColour(btn->GetColor()); OPT_SET("Colour/Style Editor/Background/Preview")->SetColor(btn->GetColor()); } }
std::unique_ptr<agi::SpellChecker> SpellCheckerFactory::GetSpellChecker() { #ifdef __APPLE__ return agi::CreateCocoaSpellChecker(OPT_SET("Tool/Spell Checker/Language")); #elif defined(WITH_HUNSPELL) return agi::make_unique<HunspellSpellChecker>(); #else return {}; #endif }
void BaseGrid::OnShowColMenu(wxCommandEvent &event) { int item = event.GetId() - MENU_SHOW_COL; showCol[item] = !showCol[item]; std::vector<bool> map(showCol, showCol + columns); OPT_SET("Subtitle/Grid/Column")->SetListBool(map); SetColumnWidths(); Refresh(false); }
void AudioBox::OnVerticalZoom(wxScrollEvent &event) { int pos = mid(1, event.GetPosition(), 100); OPT_SET("Audio/Zoom/Vertical")->SetInt(pos); double value = pow(pos / 50.0, 3); audioDisplay->SetAmplitudeScale(value); if (!VolumeBar->IsEnabled()) { VolumeBar->SetValue(pos); controller->SetVolume(value); } }
void FrameMain::LoadSubtitles(wxString const& filename, wxString const& charset) { if (context->ass->loaded) { if (TryToCloseSubs() == wxCANCEL) return; } try { // Make sure that file isn't actually a timecode file try { TextFileReader testSubs(filename, charset); wxString cur = testSubs.ReadLineFromFile(); if (cur.Left(10) == "# timecode") { context->videoController->LoadTimecodes(filename); return; } } catch (...) { // if trying to load the file as timecodes fails it's fairly // safe to assume that it is in fact not a timecode file } context->ass->Load(filename, charset); wxFileName file(filename); StandardPaths::SetPathValue("?script", file.GetPath()); config::mru->Add("Subtitle", STD_STR(filename)); OPT_SET("Path/Last/Subtitles")->SetString(STD_STR(file.GetPath())); // Save backup of file if (context->ass->CanSave() && OPT_GET("App/Auto/Backup")->GetBool()) { if (file.FileExists()) { wxString path = lagi_wxString(OPT_GET("Path/Auto/Backup")->GetString()); if (path.empty()) path = file.GetPath(); wxFileName dstpath(StandardPaths::DecodePath(path + "/")); if (!dstpath.DirExists()) wxMkdir(dstpath.GetPath()); dstpath.SetFullName(file.GetName() + ".ORIGINAL." + file.GetExt()); wxCopyFile(file.GetFullPath(), dstpath.GetFullPath(), true); } } } catch (agi::FileNotFoundError const&) { wxMessageBox(filename + " not found.", "Error", wxOK | wxICON_ERROR | wxCENTER, this); config::mru->Remove("Subtitle", STD_STR(filename)); return; } catch (agi::Exception const& err) { wxMessageBox(lagi_wxString(err.GetChainedMessage()), "Error", wxOK | wxICON_ERROR | wxCENTER, this); } catch (...) { wxMessageBox("Unknown error", "Error", wxOK | wxICON_ERROR | wxCENTER, this); return; } }
void DialogSearchReplace::FindReplace(bool (SearchReplaceEngine::*func)()) { TransferDataFromWindow(); if (settings->find.empty()) return; c->search->Configure(*settings); try { (c->search->*func)(); } catch (std::exception const& e) { wxMessageBox(to_wx(e.what()), "Error", wxOK | wxICON_ERROR | wxCENTER, this); return; } config::mru->Add("Find", settings->find); if (has_replace) config::mru->Add("Replace", settings->replace_with); OPT_SET("Tool/Search Replace/Match Case")->SetBool(settings->match_case); OPT_SET("Tool/Search Replace/RegExp")->SetBool(settings->use_regex); OPT_SET("Tool/Search Replace/Skip Comments")->SetBool(settings->ignore_comments); OPT_SET("Tool/Search Replace/Skip Tags")->SetBool(settings->skip_tags); OPT_SET("Tool/Search Replace/Field")->SetInt(static_cast<int>(settings->field)); OPT_SET("Tool/Search Replace/Affect")->SetInt(static_cast<int>(settings->limit_to)); UpdateDropDowns(); }
void DialogDetachedVideo::OnClose(wxCloseEvent &evt) { context->videoDisplay->Destroy(); context->videoDisplay = old_display; context->videoSlider = old_slider; OPT_SET("Video/Detached/Enabled")->SetBool(false); if (context->videoController->IsLoaded()) context->videoController->JumpToFrame(context->videoController->GetFrameN()); evt.Skip(); }
/// @brief DOCME /// @param evt /// void DialogAutomation::OnAdd(wxCommandEvent &evt) { // build filename filter list wxString fnfilter, catchall; const std::vector<Automation4::ScriptFactory*> &factories = Automation4::ScriptFactory::GetFactories(); for (int i = 0; i < (int)factories.size(); i++) { const Automation4::ScriptFactory *fact = factories[i]; if (fact->GetEngineName().IsEmpty() || fact->GetFilenamePattern().IsEmpty()) continue; fnfilter = wxString::Format(_T("%s%s scripts (%s)|%s|"), fnfilter.c_str(), fact->GetEngineName().c_str(), fact->GetFilenamePattern().c_str(), fact->GetFilenamePattern().c_str()); catchall << fact->GetFilenamePattern() << _T(";"); } #ifdef __WINDOWS__ fnfilter += _T("All files|*.*"); #else fnfilter += _T("All files|*"); #endif if (!catchall.IsEmpty()) { catchall.RemoveLast(); } if (factories.size() > 1) { fnfilter = _T("All supported scripts|") + catchall + _T("|") + fnfilter; } wxString fname = wxFileSelector(_("Add Automation script"), lagi_wxString(OPT_GET("Path/Last/Automation")->GetString()), wxEmptyString, wxEmptyString, fnfilter, wxFD_OPEN|wxFD_FILE_MUST_EXIST, this); if (!fname.IsEmpty()) { wxFileName fnpath(fname); OPT_SET("Path/Last/Automation")->SetString(STD_STR(fnpath.GetPath())); // TODO: make sure each script is only loaded once. check in both local and global managers!! // it doesn't break for macros, but will for export filters, and maybe for file formats, // and makes for confusion in the UI anyhow try { ExtraScriptInfo ei; ei.script = Automation4::ScriptFactory::CreateFromFile(fname, false); local_manager->Add(ei.script); ei.is_global = false; AddScript(ei); } catch (const wchar_t *e) { wxLogError(e); } catch (...) { wxLogError(_T("Unknown error loading script")); } } }
int main_mip(int argc, char* argv[argc]) { bool mIP = false; const struct opt_s opts[] = { OPT_SET('m', &mIP, "minimum" ), }; cmdline(&argc, argv, 3, 3, usage_str, help_str, ARRAY_SIZE(opts), opts); unsigned int flags = atoi(argv[1]); long idims[DIMS]; complex float* in = load_cfl(argv[2], DIMS, idims); long odims[DIMS]; md_select_dims(DIMS, ~flags, odims, idims); complex float* out = create_cfl(argv[3], DIMS, odims); complex float* tmp = md_alloc(DIMS, idims, CFL_SIZE); md_zabs(DIMS, idims, tmp, in); long istr[DIMS]; long ostr[DIMS]; md_calc_strides(DIMS, istr, idims, CFL_SIZE); md_calc_strides(DIMS, ostr, odims, CFL_SIZE); md_clear(DIMS, odims, out, CFL_SIZE); md_max2(DIMS, idims, ostr, (float*)out, ostr, (const float*)out, istr, (const float*)tmp); if (mIP) { // need result of max in output md_min2(DIMS, idims, ostr, (float*)out, ostr, (const float*)out, istr, (const float*)tmp); } md_free(tmp); unmap_cfl(DIMS, idims, in); unmap_cfl(DIMS, odims, out); exit(0); }
void AudioBox::OnSashDrag(wxSashEvent &event) { if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE) return; int new_height = std::min(event.GetDragRect().GetHeight(), GetParent()->GetSize().GetHeight() - 1); SetMinSize(wxSize(-1, new_height)); GetParent()->Layout(); // Karaoke mode is always disabled when the audio box is first opened, so // the initial height shouldn't include it if (context->karaoke->IsEnabled()) new_height -= context->karaoke->GetSize().GetHeight() + 6; OPT_SET("Audio/Display Height")->SetInt(new_height); }
DialogDetachedVideo::DialogDetachedVideo(agi::Context *context) : wxDialog(context->parent, -1, "Detached Video", wxDefaultPosition, wxSize(400,300), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX | wxWANTS_CHARS) , context(context) , old_display(context->videoDisplay) , old_slider(context->videoSlider) , video_open(context->videoController->AddVideoOpenListener(&DialogDetachedVideo::OnVideoOpen, this)) { // Set obscure stuff SetExtraStyle((GetExtraStyle() & ~wxWS_EX_BLOCK_EVENTS) | wxWS_EX_PROCESS_UI_UPDATES); SetTitle(wxString::Format(_("Video: %s"), wxFileName(context->videoController->GetVideoName()).GetFullName())); old_display->Unload(); // Video area; VideoBox *videoBox = new VideoBox(this, true, context); context->videoDisplay->SetMinClientSize(old_display->GetClientSize()); videoBox->Layout(); // Set sizer wxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); mainSizer->Add(videoBox,1,wxEXPAND | wxALL,5); SetSizerAndFit(mainSizer); // Ensure we can grow smaller, without these the window is locked to at least the initial size context->videoDisplay->SetMinSize(wxSize(1,1)); videoBox->SetMinSize(wxSize(1,1)); SetMinSize(wxSize(1,1)); persist.reset(new PersistLocation(this, "Video/Detached")); int display_index = wxDisplay::GetFromWindow(this); // Ensure that the dialog is no larger than the screen if (display_index != wxNOT_FOUND) { wxRect bounds_rect = GetRect(); wxRect disp_rect = wxDisplay(display_index).GetClientArea(); SetSize(std::min(bounds_rect.width, disp_rect.width), std::min(bounds_rect.height, disp_rect.height)); } OPT_SET("Video/Detached/Enabled")->SetBool(true); Bind(wxEVT_CLOSE_WINDOW, &DialogDetachedVideo::OnClose, this); Bind(wxEVT_ICONIZE, &DialogDetachedVideo::OnMinimize, this); Bind(wxEVT_CHAR_HOOK, &DialogDetachedVideo::OnKeyDown, this); AddFullScreenButton(this); }
DialogShiftTimes::~DialogShiftTimes() { long shift; shift_frames->GetValue().ToLong(&shift); OPT_SET("Tool/Shift Times/Time")->SetInt(shift_time->GetTime()); OPT_SET("Tool/Shift Times/Frames")->SetInt(shift); OPT_SET("Tool/Shift Times/ByTime")->SetBool(shift_by_time->GetValue()); OPT_SET("Tool/Shift Times/Type")->SetInt(time_fields->GetSelection()); OPT_SET("Tool/Shift Times/Affect")->SetInt(selection_mode->GetSelection()); OPT_SET("Tool/Shift Times/Direction")->SetBool(shift_backward->GetValue()); }
int main_resize(int argc, char* argv[]) { bool center = false; const struct opt_s opts[] = { OPT_SET('c', ¢er, "center"), }; cmdline(&argc, argv, 4, 1000, usage_str, help_str, ARRAY_SIZE(opts), opts); num_init(); unsigned int N = DIMS; int count = argc - 3; assert((count > 0) && (count % 2 == 0)); long in_dims[N]; long out_dims[N]; void* in_data = load_cfl(argv[argc - 2], N, in_dims); md_copy_dims(N, out_dims, in_dims); for (int i = 0; i < count; i += 2) { unsigned int dim = atoi(argv[i + 1]); unsigned int size = atoi(argv[i + 2]); assert(dim < N); assert(size >= 1); out_dims[dim] = size; } void* out_data = create_cfl(argv[argc - 1], N, out_dims); (center ? md_resize_center : md_resize)(N, out_dims, out_data, in_dims, in_data, CFL_SIZE); unmap_cfl(N, in_dims, in_data); unmap_cfl(N, out_dims, out_data); return 0; }
DialogShiftTimes::~DialogShiftTimes() { long shift; shift_frames->GetValue().ToLong(&shift); OPT_SET("Tool/Shift Times/Time")->SetInt(shift_time->GetTime()); OPT_SET("Tool/Shift Times/Frames")->SetInt(shift); OPT_SET("Tool/Shift Times/ByTime")->SetBool(shift_by_time->GetValue()); OPT_SET("Tool/Shift Times/Type")->SetInt(time_fields->GetSelection()); OPT_SET("Tool/Shift Times/Affect")->SetInt(selection_mode->GetSelection()); OPT_SET("Tool/Shift Times/Direction")->SetBool(shift_backward->GetValue()); context->selectionController->RemoveSelectionListener(this); }
std::string DialogDummyVideo::CreateDummyVideo(wxWindow *parent) { DialogDummyVideo dlg(parent); if (dlg.ShowModal() != wxID_OK) return ""; OPT_SET("Video/Dummy/FPS")->SetDouble(dlg.fps); OPT_SET("Video/Dummy/Last/Width")->SetInt(dlg.width); OPT_SET("Video/Dummy/Last/Height")->SetInt(dlg.height); OPT_SET("Video/Dummy/Last/Length")->SetInt(dlg.length); OPT_SET("Colour/Video Dummy/Last Colour")->SetColor(dlg.color); OPT_SET("Video/Dummy/Pattern")->SetBool(dlg.pattern); return DummyVideoProvider::MakeFilename(dlg.fps, dlg.length, dlg.width, dlg.height, dlg.color, dlg.pattern); }
void FrameMain::OnCloseWindow(wxCloseEvent &event) { wxEventBlocker blocker(this, wxEVT_CLOSE_WINDOW); context->videoController->Stop(); context->audioController->Stop(); // Ask user if he wants to save first if (context->subsController->TryToClose(event.CanVeto()) == wxCANCEL) { event.Veto(); return; } delete context->dialog; context->dialog = nullptr; // Store maximization state OPT_SET("App/Maximized")->SetBool(IsMaximized()); Destroy(); }
wxThread::ExitCode AegisubVersionCheckerThread::Entry() { if (!interactive) { // Automatic checking enabled? if (!OPT_GET("App/Auto/Check For Updates")->GetBool()) return 0; // Is it actually time for a check? time_t next_check = OPT_GET("Version/Next Check")->GetInt(); if (next_check > wxDateTime::GetTimeNow()) return 0; } if (VersionCheckLock.TryLock() != wxMUTEX_NO_ERROR) return 0; try { DoCheck(); } catch (const agi::Exception &e) { PostErrorEvent(wxString::Format( _("There was an error checking for updates to Aegisub:\n%s\n\nIf other applications can access the Internet fine, this is probably a temporary server problem on our end."), e.GetMessage())); } catch (...) { PostErrorEvent(_("An unknown error occurred while checking for updates to Aegisub.")); } VersionCheckLock.Unlock(); // While Options isn't perfectly thread safe, this should still be okay. // Traversing the std::map to find the key-value pair doesn't modify any data as long as // the key already exists (which it does at this point), and modifying the value only // touches that specific key-value pair and will never cause a rebalancing of the tree, // because the tree only depends on the keys. // Lastly, writing options to disk only happens when Options.Save() is called. time_t new_next_check_time = wxDateTime::GetTimeNow() + 60*60; // in one hour OPT_SET("Version/Next Check")->SetInt((int)new_next_check_time); return 0; }
void FrameMain::OnCloseWindow (wxCloseEvent &event) { // Stop audio and video context->videoController->Stop(); context->audioController->Stop(); // Ask user if he wants to save first bool canVeto = event.CanVeto(); int result = TryToCloseSubs(canVeto); if (canVeto && result == wxCANCEL) { event.Veto(); return; } delete context->dialog; context->dialog = 0; // Store maximization state OPT_SET("App/Maximized")->SetBool(IsMaximized()); Destroy(); }