void vgmstreamPreferences::apply() { cfg_LoopForever = IsDlgButtonChecked(IDC_LOOP_FOREVER)?true:false; cfg_IgnoreLoop = IsDlgButtonChecked(IDC_IGNORE_LOOP)?true:false; cfg_DisableSubsongs = IsDlgButtonChecked(IDC_DISABLE_SUBSONGS)?true:false; cfg_TagfileDisable = IsDlgButtonChecked(IDC_TAGFILE_DISABLE)?true:false; cfg_OverrideTitle = IsDlgButtonChecked(IDC_OVERRIDE_TITLE)?true:false; double temp_fade_seconds; double temp_fade_delay_seconds; double temp_loop_count; int consumed; int temp_downmix_channels; pfc::string buf; buf = uGetDlgItemText(m_hWnd, IDC_FADE_SECONDS); if (sscanf(buf.get_ptr(),"%lf%n",&temp_fade_seconds,&consumed)<1 || consumed!=strlen(buf.get_ptr()) || temp_fade_seconds<0) { uMessageBox(m_hWnd, "Invalid value for Fade Length\n" "Must be a number greater than or equal to zero", "Error",MB_OK|MB_ICONERROR); return; } else cfg_FadeLength = buf.get_ptr(); buf = uGetDlgItemText(m_hWnd, IDC_LOOP_COUNT); if (sscanf(buf.get_ptr(),"%lf%n",&temp_loop_count,&consumed)<1 || consumed!=strlen(buf.get_ptr()) || temp_loop_count<0) { uMessageBox(m_hWnd, "Invalid value for Loop Count\n" "Must be a number greater than or equal to zero", "Error",MB_OK|MB_ICONERROR); return; } else cfg_LoopCount = buf.get_ptr(); buf = uGetDlgItemText(m_hWnd, IDC_FADE_DELAY_SECONDS); if (sscanf(buf.get_ptr(),"%lf%n",&temp_fade_delay_seconds,&consumed)<1 || consumed!=strlen(buf.get_ptr()) || temp_fade_delay_seconds<0) { uMessageBox(m_hWnd, "Invalid value for Fade Delay\n" "Must be a number", "Error",MB_OK|MB_ICONERROR); return; } else cfg_FadeDelay = buf.get_ptr(); buf = uGetDlgItemText(m_hWnd, IDC_DOWNMIX_CHANNELS); if (sscanf(buf.get_ptr(),"%d%n",&temp_downmix_channels,&consumed)<1 || consumed!=strlen(buf.get_ptr()) || temp_downmix_channels<0) { uMessageBox(m_hWnd, "Invalid value for Downmix Channels\n" "Must be a number greater than or equal to zero", "Error",MB_OK|MB_ICONERROR); return; } else cfg_DownmixChannels = buf.get_ptr(); }
virtual result on_token(const char * token) { reset(); if (!stricmp_utf8_partial(token,"/columnsui:")) { const char * ptr = strchr(token,':')+1; if (!stricmp_utf8(ptr,"help") || !stricmp_utf8(ptr,"?")) { HWND parent = core_api::get_main_window(); if (parent) static_api_ptr_t<ui_control>()->activate();//SetActiveWindow(parent); uMessageBox(parent,g_help_text,"Columns UI commandline help",0); return RESULT_PROCESSED; } else if (!stricmp_utf8_partial(ptr,"import:")) { ptr += 7; if (*ptr && *ptr =='\"') ptr++; unsigned len = strlen(ptr); const char * end = strchr(ptr, '\"'); if (end) len = end-ptr; pfc::string8 path(ptr, len); HWND parent = core_api::get_main_window(); if (parent) static_api_ptr_t<ui_control>()->activate(); if (uMessageBox(parent,uStringPrintf("Are you sure you want to import the %s configuration? Your current configuration will be lost.",pfc::string_filename(path).get_ptr()),"Import configuration?",MB_YESNO) == IDYES) { pfc::string_extension ext(path); if (!stricmp_utf8("fcl", ext)) g_import_layout(core_api::get_main_window(), path); else if (!stricmp_utf8("fcs", ext)) g_import(path); } return RESULT_PROCESSED; } /*else if (!stricmp_utf8_partial(ptr,"export:")) { ptr += 7; if (*ptr && *ptr =='\"') ptr++; unsigned len = strlen(ptr); const char * end = strchr(ptr, '\"'); if (end) len = end-ptr; pfc::string8 path(ptr, len); g_export(path); return RESULT_PROCESSED; }*/ } return RESULT_NOT_OURS; }
void vgmstreamPreferences::apply() { cfg_LoopForever = IsDlgButtonChecked(IDC_LOOP_FOREVER)?true:false; cfg_IgnoreLoop = IsDlgButtonChecked(IDC_IGNORE_LOOP)?true:false; double temp_fade_seconds; double temp_fade_delay_seconds; double temp_loop_count; int consumed; pfc::string buf; buf = uGetDlgItemText(m_hWnd, IDC_FADE_SECONDS); if (sscanf(buf.get_ptr(),"%lf%n",&temp_fade_seconds,&consumed)<1 || consumed!=strlen(buf.get_ptr()) || temp_fade_seconds<0) { uMessageBox(m_hWnd, "Invalid value for Fade Length\n" "Must be a number greater than or equal to zero", "Error",MB_OK|MB_ICONERROR); return; } else cfg_FadeLength = buf.get_ptr(); buf = uGetDlgItemText(m_hWnd, IDC_LOOP_COUNT); if (sscanf(buf.get_ptr(),"%lf%n",&temp_loop_count,&consumed)<1 || consumed!=strlen(buf.get_ptr()) || temp_loop_count<0) { uMessageBox(m_hWnd, "Invalid value for Loop Count\n" "Must be a number greater than or equal to zero", "Error",MB_OK|MB_ICONERROR); return; } else cfg_LoopCount = buf.get_ptr(); buf = uGetDlgItemText(m_hWnd, IDC_FADE_DELAY_SECONDS); if (sscanf(buf.get_ptr(),"%lf%n",&temp_fade_delay_seconds,&consumed)<1 || consumed!=strlen(buf.get_ptr()) || temp_fade_delay_seconds<0) { uMessageBox(m_hWnd, "Invalid value for Fade Delay\n" "Must be a number", "Error",MB_OK|MB_ICONERROR); return; } else cfg_FadeDelay = buf.get_ptr(); }
void album_list_dlg::on_album_delete () { HWND p_listview = GetDlgItem (IDC_LISTVIEW_ALBUMS); pfc::string8 album_name; listview_get_sel_item_text (p_listview, album_name); if (!album_name.is_empty ()) { pfc::string8_fast message ("Are you sure what you want to delete album \""); message << album_name << "\"?"; int dlg_result = uMessageBox (*this, message, COMPONENT_NAME, MB_YESNO | MB_ICONQUESTION); if (dlg_result == IDYES) { run_in_separate_thread ([p_listview, album_name] () { user_album_list user_albums; if (user_albums.remove_item (user_albums.get_album_id_by_name (album_name))) listview_fill (p_listview, user_albums.get_albums ()); // Reload items (change to deleting single item instead) else if (!user_albums.aborted ()) uErrorBox ("Error while creating new album", user_albums.get_error ()); }); } } }
static BOOL CALLBACK ConfigProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { case WM_INITDIALOG: { uTCITEM tabs; memset(&tabs, 0, sizeof(tabs)); HWND wnd_tab = GetDlgItem(wnd, IDC_TAB1); tabs.mask = TCIF_TEXT; tabs.pszText = "Variables"; uTabCtrl_InsertItem(wnd_tab, 0, &tabs); tabs.pszText = "Style"; uTabCtrl_InsertItem(wnd_tab, 1, &tabs); TabCtrl_SetCurSel(wnd_tab, g_cur_tab2); uSendDlgItemMessageText(wnd, IDC_CHAR7, WM_SETTEXT, 0, "\x07"); colour_code_gen(wnd, IDC_COLOUR, false, true); uSendDlgItemMessage(wnd, IDC_STRING, EM_LIMITTEXT, 0, 0); refresh_me(wnd); editproc = (WNDPROC)SetWindowLongPtr(GetDlgItem(wnd, IDC_STRING), GWLP_WNDPROC, (LPARAM)EditHook); g_editor_font_notify.set(GetDlgItem(wnd, IDC_STRING)); } break; case WM_NOTIFY: switch (((LPNMHDR)lp)->idFrom) { case IDC_TAB1: switch (((LPNMHDR)lp)->code) { case TCN_SELCHANGE: { save_string(wnd); int id = TabCtrl_GetCurSel(GetDlgItem(wnd, IDC_TAB1)); g_cur_tab2 = id; uSendDlgItemMessageText(wnd, IDC_STRING, WM_SETTEXT, 0, (g_cur_tab2 == 0 ? cfg_globalstring : cfg_colour)); } break; } break; } break; case WM_DESTROY: { g_editor_font_notify.release(); save_string(wnd); refresh_all_playlist_views(); pvt::ng_playlist_view_t::g_update_all_items(); } break; case WM_COMMAND: switch (wp) { case IDC_GLOBAL: cfg_global = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); break; case IDC_DATE: cfg_playlist_date = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); set_day_timer(); pvt::ng_playlist_view_t::g_on_use_date_info_change(); break; case IDC_TFHELP: { RECT rc; GetWindowRect(GetDlgItem(wnd, IDC_TFHELP), &rc); // MapWindowPoints(HWND_DESKTOP, wnd, (LPPOINT)(&rc), 2); HMENU menu = CreatePopupMenu(); enum { IDM_TFHELP = 1, IDM_GHELP = 2, IDM_SPEEDTEST, IDM_PREVIEW, IDM_EDITORFONT, IDM_RESETSTYLE }; uAppendMenu(menu, (MF_STRING), IDM_TFHELP, "Titleformatting &help"); uAppendMenu(menu, (MF_STRING), IDM_GHELP, "&Global help"); uAppendMenu(menu, (MF_SEPARATOR), 0, ""); uAppendMenu(menu, (MF_STRING), IDM_SPEEDTEST, "&Speed test"); uAppendMenu(menu, (MF_STRING), IDM_PREVIEW, "&Preview to console"); uAppendMenu(menu, (MF_SEPARATOR), 0, ""); uAppendMenu(menu, (MF_STRING), IDM_EDITORFONT, "Change editor &font"); uAppendMenu(menu, (MF_SEPARATOR), 0, ""); uAppendMenu(menu, (MF_STRING), IDM_RESETSTYLE, "&Reset style string"); int cmd = TrackPopupMenu(menu, TPM_LEFTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, rc.left, rc.bottom, 0, wnd, 0); DestroyMenu(menu); if (cmd == IDM_TFHELP) { standard_commands::main_titleformat_help(); } else if (cmd == IDM_GHELP) { uMessageBox(wnd, COLOUR_HELP "\n\nNew global format: $set_global(var, val), retreive values using $get_global(var)", "Global help", 0); } else if (cmd == IDM_SPEEDTEST) { speedtest(g_columns, cfg_global != 0, cfg_oldglobal != 0, cfg_playlist_date != 0); } else if (cmd == IDM_PREVIEW) { preview_to_console(string_utf8_from_window(wnd, IDC_STRING), g_cur_tab2 != 0 && cfg_global); } else if (cmd == IDM_EDITORFONT) { if (font_picker(wnd, cfg_editor_font)) g_editor_font_notify.on_change(); } else if (cmd == IDM_RESETSTYLE) { extern const char * g_default_colour; cfg_colour = g_default_colour; if (g_cur_tab2 == 1) uSendDlgItemMessageText(wnd, IDC_STRING, WM_SETTEXT, 0, cfg_colour); refresh_all_playlist_views(); pvt::ng_playlist_view_t::g_update_all_items(); } } break; case IDC_OLDGLOBAL: cfg_oldglobal = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); break; case IDC_GLOBALSORT: cfg_global_sort = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); break; case IDC_APPLY: save_string(wnd); refresh_all_playlist_views(); pvt::ng_playlist_view_t::g_update_all_items(); break; case IDC_PICK_COLOUR: colour_code_gen(wnd, IDC_COLOUR, false, false); break; } } return 0; }
BOOL CALLBACK playlists_dropdown::preferences::DisplayDlgProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { case MSG_UPDATEPREVIEW: { static_api_ptr_t<playlist_manager> pm; t_size playlist = pm->get_active_playlist(); if (playlist != pfc_infinite) { static_api_ptr_t<titleformat_compiler> cmp; titleformat_object::ptr title_format; if (cmp->compile(title_format, cfg::title_string)) { titleformat_hook_impl_splitter hook(titleformat_hook_impl_splitter( &title_format_hook(playlist, false), &titleformat_hook_impl_list(playlist, pm->get_playlist_count()))); pfc::string8 title; title_format->run(&hook, title, NULL); pfc::string8 preview; cmp->remove_color_marks(title, preview); preview.replace_char('\t', ' '); uSetDlgItemText(wnd, IDC_PREVIEW, preview); } else { uSetDlgItemText(wnd, IDC_PREVIEW, "COMPILATION ERROR"); } } else { uSetDlgItemText(wnd, IDC_PREVIEW, "N/A"); } } break; case WM_COMMAND: switch (wp) { // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // GENERAL // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= case IDC_SHOW_ICONS: cfg::show_icons = uButton_GetCheck(wnd, IDC_SHOW_ICONS); playlists_dropdown::g_reload_icons(); playlists_dropdown::g_update_all_sizes(); playlists_dropdown::g_redraw_all(); break; case IDC_ICON_UTILS: { HMENU menu = CreatePopupMenu(); uAppendMenu(menu, MF_STRING, 1, "Clear custom icons history"); uAppendMenu(menu, MF_STRING, 2, "Reset all icons to default"); RECT rc; GetWindowRect(GetDlgItem(wnd, IDC_ICON_UTILS), &rc); int cmd = TrackPopupMenu(menu, TPM_NONOTIFY | TPM_RETURNCMD, rc.left, rc.bottom, 0, GetDlgItem(wnd, IDC_ICON_UTILS), 0); DestroyMenu(menu); if (cmd == 1 && uMessageBox(wnd, "Are you sure you want to clear all custom icons history?", "Continue?", MB_YESNO) == IDYES) { cfg::custom_icons_history.reset(); } else if (cmd == 2 && uMessageBox(wnd, "Are you sure you want to reset all icons to default?", "Continue?", MB_YESNO) == IDYES) { try { static_api_ptr_t<playlist_manager_v2> pm2; for (int i = 0, total = pm2->get_playlist_count(); i < total; i++) { pm2->playlist_remove_property(i, guid_icon_path); } } catch(...) { } } playlists_dropdown::g_reload_icons(); playlists_dropdown::g_update_all_sizes(); playlists_dropdown::g_redraw_all(); } break; case IDC_MIN_VISIBLE | EN_CHANGE << 16: cfg::min_visible = uGetDlgItemInt(wnd, IDC_MIN_VISIBLE, NULL, true); playlists_dropdown::g_update_all_min_visible(); break; case IDC_FORMATTING_STRING | EN_CHANGE << 16: if (TabCtrl_GetDlgCurSel(wnd, IDC_FS_TAB) == 0) { uGetDlgItemText(wnd, IDC_FORMATTING_STRING, cfg::title_string); uSendMessage(wnd, MSG_UPDATEPREVIEW, 0, 0); } else { uGetDlgItemText(wnd, IDC_FORMATTING_STRING, cfg::style_string); } uEnableWindow(uGetDlgItem(wnd, IDC_APPLY), true); break; // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // PADDING // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= case IDC_PADDING_TOP | EN_CHANGE << 16: cfg::padding.get_value().top = uGetDlgItemInt(wnd, IDC_PADDING_TOP, NULL, true); playlists_dropdown::g_update_all_sizes(); playlists_dropdown::g_redraw_all(); break; case IDC_PADDING_RIGHT | EN_CHANGE << 16: cfg::padding.get_value().right = uGetDlgItemInt(wnd, IDC_PADDING_RIGHT, NULL, true); playlists_dropdown::g_update_all_sizes(); playlists_dropdown::g_redraw_all(); break; case IDC_PADDING_BOTTOM | EN_CHANGE << 16: cfg::padding.get_value().bottom = uGetDlgItemInt(wnd, IDC_PADDING_BOTTOM, NULL, true); playlists_dropdown::g_update_all_sizes(); playlists_dropdown::g_redraw_all(); break; case IDC_PADDING_LEFT | EN_CHANGE << 16: cfg::padding.get_value().left = uGetDlgItemInt(wnd, IDC_PADDING_LEFT, NULL, true); playlists_dropdown::g_update_all_sizes(); playlists_dropdown::g_redraw_all(); break; // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // FIELDS BUTTON // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= case IDC_FIELDS: { HMENU menu = CreatePopupMenu(); for (int i = 1; i < tabsize(g_fields_list); i++) { uAppendMenu(menu, !!g_fields_list[i].label ? MF_STRING : MF_SEPARATOR, i, g_fields_list[i].label); } RECT rc; GetWindowRect(GetDlgItem(wnd, IDC_FIELDS), &rc); int cmd = TrackPopupMenu(menu, TPM_NONOTIFY | TPM_RETURNCMD, rc.left, rc.bottom, 0, GetDlgItem(wnd, IDC_FIELDS), 0); DestroyMenu(menu); if (cmd >= 0 && cmd < tabsize(g_fields_list) && !!g_fields_list[cmd].label) { uSendDlgItemMessageText(wnd, IDC_FORMATTING_STRING, EM_REPLACESEL, TRUE, g_fields_list[cmd].label); SetFocus(GetDlgItem(wnd, IDC_FORMATTING_STRING)); } } break; // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // APPLY // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= case IDC_APPLY: apply_config(); uEnableWindow(uGetDlgItem(wnd, IDC_APPLY), FALSE); break; } break; case WM_INITDIALOG: { EnableTheming(wnd); // Setup "Display/Style" TabControl HWND hTabWnd = uGetDlgItem(wnd, IDC_FS_TAB); uTabCtrl_InsertItemText(hTabWnd, 0, "Display"); uTabCtrl_InsertItemText(hTabWnd, 1, "Style"); TabCtrl_SetCurSel(hTabWnd, cfg::last_fs_tab); uSetDlgItemText(wnd, IDC_FORMATTING_STRING, get_formatting_string(TabCtrl_GetCurSel(hTabWnd))); uButton_SetCheck(wnd, IDC_SHOW_ICONS, cfg::show_icons); SetDlgSpinner(wnd, IDC_MIN_VISIBLE_SPIN, IDC_MIN_VISIBLE, 1, 1000, cfg::min_visible); SetDlgSpinner(wnd, IDC_PADDING_TOP_SPIN, IDC_PADDING_TOP, 0, 1024, cfg::padding.get_value().top); SetDlgSpinner(wnd, IDC_PADDING_RIGHT_SPIN, IDC_PADDING_RIGHT, 0, 1024, cfg::padding.get_value().right); SetDlgSpinner(wnd, IDC_PADDING_BOTTOM_SPIN, IDC_PADDING_BOTTOM, 0, 1024, cfg::padding.get_value().bottom); SetDlgSpinner(wnd, IDC_PADDING_LEFT_SPIN, IDC_PADDING_LEFT, 0, 1024, cfg::padding.get_value().left); uEnableWindow(uGetDlgItem(wnd, IDC_APPLY), FALSE); SendMessage(wnd, MSG_UPDATEPREVIEW, 0, 0); } break; case WM_DESTROY: cfg::last_fs_tab = TabCtrl_GetDlgCurSel(wnd, IDC_FS_TAB); break; case WM_NOTIFY: if (((LPNMHDR) lp)->idFrom == IDC_FS_TAB && ((LPNMHDR) lp)->code == TCN_SELCHANGE) { uSetDlgItemText(wnd, IDC_FORMATTING_STRING, get_formatting_string(TabCtrl_GetDlgCurSel(wnd, IDC_FS_TAB))); } break; default: return false; } return true; }
inline void uErrorBox (const char *p_title, const char *p_message) { uMessageBox (core_api::get_main_window (), p_message, p_title, MB_OK | MB_ICONERROR); }