Advertisement
Guest User

CideoConfigDiag.cpp

a guest
Dec 19th, 2012
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.34 KB | None | 0 0
  1. #include "VideoConfigDiag.h"
  2.  
  3. #include "FileUtil.h"
  4. #include "TextureCacheBase.h"
  5. #include "Core.h"
  6. #include "Frame.h"
  7.  
  8. #include <wx/intl.h>
  9.  
  10. #ifdef __APPLE__
  11. #include <ApplicationServices/ApplicationServices.h>
  12. #endif
  13.  
  14. #define _connect_macro_(b, f, c, s) (b)->Connect(wxID_ANY, (c), wxCommandEventHandler( f ), (wxObject*)0, (wxEvtHandler*)s)
  15.  
  16. extern CFrame* main_frame;
  17.  
  18. // template instantiation
  19. template class BoolSetting<wxCheckBox>;
  20. template class BoolSetting<wxRadioButton>;
  21.  
  22. template <>
  23. SettingCheckBox::BoolSetting(wxWindow* parent, const wxString& label, const wxString& tooltip, bool &setting, bool reverse, long style)
  24. : wxCheckBox(parent, -1, label, wxDefaultPosition, wxDefaultSize, style)
  25. , m_setting(setting)
  26. , m_reverse(reverse)
  27. {
  28. SetToolTip(tooltip);
  29. SetValue(m_setting ^ m_reverse);
  30. _connect_macro_(this, SettingCheckBox::UpdateValue, wxEVT_COMMAND_CHECKBOX_CLICKED, this);
  31. }
  32.  
  33. template <>
  34. SettingRadioButton::BoolSetting(wxWindow* parent, const wxString& label, const wxString& tooltip, bool &setting, bool reverse, long style)
  35. : wxRadioButton(parent, -1, label, wxDefaultPosition, wxDefaultSize, style)
  36. , m_setting(setting)
  37. , m_reverse(reverse)
  38. {
  39. SetToolTip(tooltip);
  40. SetValue(m_setting ^ m_reverse);
  41. _connect_macro_(this, SettingRadioButton::UpdateValue, wxEVT_COMMAND_RADIOBUTTON_SELECTED, this);
  42. }
  43.  
  44. SettingChoice::SettingChoice(wxWindow* parent, int &setting, const wxString& tooltip, int num, const wxString choices[], long style)
  45. : wxChoice(parent, -1, wxDefaultPosition, wxDefaultSize, num, choices)
  46. , m_setting(setting)
  47. {
  48. SetToolTip(tooltip);
  49. Select(m_setting);
  50. _connect_macro_(this, SettingChoice::UpdateValue, wxEVT_COMMAND_CHOICE_SELECTED, this);
  51. }
  52.  
  53. void SettingChoice::UpdateValue(wxCommandEvent& ev)
  54. {
  55. m_setting = ev.GetInt();
  56. ev.Skip();
  57. }
  58.  
  59. void VideoConfigDiag::Event_ClickClose(wxCommandEvent&)
  60. {
  61. Close();
  62. }
  63.  
  64. void VideoConfigDiag::Event_Close(wxCloseEvent& ev)
  65. {
  66. g_Config.Save((File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini").c_str());
  67.  
  68. EndModal(wxID_OK);
  69. }
  70.  
  71. wxString backend_desc = wxTRANSLATE("Selects what graphics API to use internally.\nDirect3D 9 usually is the fastest one. OpenGL is more accurate though. Direct3D 11 is somewhere between the two.\nNote that the Direct3D backends are only available on Windows.\n\nIf unsure, use Direct3D 9.");
  72. wxString adapter_desc = wxTRANSLATE("Select a hardware adapter to use.\n\nIf unsure, use the first one.");
  73. wxString display_res_desc = wxTRANSLATE("Selects the display resolution used in fullscreen mode.\nThis should always be bigger than or equal to the internal resolution. Performance impact is negligible.\n\nIf unsure, use your desktop resolution.\nIf still unsure, use the highest resolution which works for you.");
  74. wxString use_fullscreen_desc = wxTRANSLATE("Enable this if you want the whole screen to be used for rendering.\nIf this is disabled, a render window will be created instead.\n\nIf unsure, leave this unchecked.");
  75. wxString auto_window_size_desc = wxTRANSLATE("Automatically adjusts the window size to your internal resolution.\n\nIf unsure, leave this unchecked.");
  76. wxString keep_window_on_top_desc = wxTRANSLATE("Keep the game window on top of all other windows.\n\nIf unsure, leave this unchecked.");
  77. wxString hide_mouse_cursor_desc = wxTRANSLATE("Hides the mouse cursor if it's on top of the emulation window.\n\nIf unsure, leave this checked.");
  78. wxString render_to_main_win_desc = wxTRANSLATE("Enable this if you want to use the main Dolphin window for rendering rather than a separate render window.\n\nIf unsure, leave this unchecked.");
  79. wxString prog_scan_desc = wxTRANSLATE("Enables progressive scan if supported by the emulated software.\nMost games don't care about this.\n\nIf unsure, leave this unchecked.");
  80. wxString ar_desc = wxTRANSLATE("Select what aspect ratio to use when rendering:\nAuto: Use the native aspect ratio\nForce 16:9: Stretch the picture to an aspect ratio of 16:9.\nForce 4:3: Stretch the picture to an aspect ratio of 4:3.\nStretch to Window: Stretch the picture to the window size.\n\nIf unsure, select Auto.");
  81. wxString ws_hack_desc = wxTRANSLATE("Force the game to output graphics for widescreen resolutions.\nCauses graphical glitches is some games.\n\nIf unsure, leave this unchecked.");
  82. wxString vsync_desc = wxTRANSLATE("Wait for vertical blanks in order to reduce tearing.\nDecreases performance if emulation speed is below 100%.\n\nIf unsure, leave this unchecked.");
  83. wxString af_desc = wxTRANSLATE("Enable anisotropic filtering.\nEnhances visual quality of textures that are at oblique viewing angles.\nMight cause issues in a small number of games.\n\nIf unsure, select 1x.");
  84. wxString aa_desc = wxTRANSLATE("Reduces the amount of aliasing caused by rasterizing 3D graphics.\nThis makes the rendered picture look less blocky.\nHeavily decreases emulation speed and sometimes causes issues.\n\nIf unsure, select None.");
  85. wxString scaled_efb_copy_desc = wxTRANSLATE("Greatly increases quality of textures generated using render to texture effects.\nRaising the internal resolution will improve the effect of this setting.\nSlightly decreases performance and possibly causes issues (although unlikely).\n\nIf unsure, leave this checked.");
  86. wxString pixel_lighting_desc = wxTRANSLATE("Calculate lighting of 3D graphics per-pixel rather than per vertex.\nDecreases emulation speed by some percent (depending on your GPU).\nThis usually is a safe enhancement, but might cause issues sometimes.\n\nIf unsure, leave this unchecked.");
  87. wxString pixel_depth_desc = wxTRANSLATE("Calculate depth values of 3D graphics per-pixel rather than per vertex.\nIn contrast to pixel lighting (which is merely an enhancement), per-pixel depth calculations are necessary to properly emulate a small number of games.\n\nIf unsure, leave this checked.");
  88. wxString force_filtering_desc = wxTRANSLATE("Force texture filtering even if the emulated game explicitly disabled it.\nImproves texture quality slightly but causes glitches in some games.\n\nIf unsure, leave this unchecked.");
  89. wxString _3d_vision_desc = wxTRANSLATE("Enable 3D effects via stereoscopy using Nvidia 3D Vision technology if it's supported by your GPU.\nPossibly causes issues.\nRequires fullscreen to work.\n\nIf unsure, leave this unchecked.");
  90. wxString internal_res_desc = wxTRANSLATE("Specifies the resolution used to render at. A high resolution will improve visual quality a lot but is also quite heavy on performance and might cause glitches in certain games.\n\"Multiple of 640x528\" is a bit slower than \"Window Size\" but yields less issues. Generally speaking, the lower the internal resolution is, the better your performance will be.\n\nIf unsure, select 640x528.");
  91. wxString efb_access_desc = wxTRANSLATE("Ignore any requests of the CPU to read from or write to the EFB.\nImproves performance in some games, but might disable some gameplay-related features or graphical effects.\n\nIf unsure, leave this unchecked.");
  92. wxString efb_emulate_format_changes_desc = wxTRANSLATE("Ignore any changes to the EFB format.\nImproves performance in many games without any negative effect. Causes graphical defects in a small number of other games though.\n\nIf unsure, leave this checked.");
  93. wxString efb_copy_desc = wxTRANSLATE("Disable emulation of EFB copies.\nThese are often used for post-processing or render-to-texture effects, so while checking this setting gives a great speedup it almost always also causes issues.\n\nIf unsure, leave this unchecked.");
  94. wxString efb_copy_texture_desc = wxTRANSLATE("Store EFB copies in GPU texture objects.\nThis is not so accurate, but it works well enough for most games and gives a great speedup over EFB to RAM.\n\nIf unsure, leave this checked.");
  95. wxString efb_copy_ram_desc = wxTRANSLATE("Accurately emulate EFB copies.\nSome games depend on this for certain graphical effects or gameplay functionality.\n\nIf unsure, check EFB to Texture instead.");
  96. wxString stc_desc = wxTRANSLATE("The safer you adjust this, the less likely the emulator will be missing any texture updates from RAM.\n\nIf unsure, use the rightmost value.");
  97. wxString wireframe_desc = wxTRANSLATE("Render the scene as a wireframe.\n\nIf unsure, leave this unchecked.");
  98. <<<<<<< HEAD
  99. =======
  100. wxString disable_lighting_desc = wxTRANSLATE("Improves performance but causes lighting to disappear in most games.\n\nIf unsure, leave this unchecked.");
  101. wxString disable_textures_desc = wxTRANSLATE("Disable texturing.\n\nIf unsure, leave this unchecked.");
  102. >>>>>>> parent of 1dd6b97... Remove "Disable Lighting".
  103. wxString disable_fog_desc = wxTRANSLATE("Improves performance but causes glitches in most games which rely on proper fog emulation.\n\nIf unsure, leave this unchecked.");
  104. wxString disable_alphapass_desc = wxTRANSLATE("Skip the destination alpha pass used in many games for various graphical effects.\n\nIf unsure, leave this unchecked.");
  105. wxString show_fps_desc = wxTRANSLATE("Show the number of frames rendered per second as a measure of emulation speed.\n\nIf unsure, leave this unchecked.");
  106. wxString log_fps_to_file_desc = wxTRANSLATE("Log the number of frames rendered per second to User/Logs/fps.txt. Use this feature when you want to measure the performance of Dolphin.\n\nIf unsure, leave this unchecked.");
  107. wxString show_input_display_desc = wxTRANSLATE("Display the inputs read by the emulator.\n\nIf unsure, leave this unchecked.");
  108. wxString show_stats_desc = wxTRANSLATE("Show various statistics.\n\nIf unsure, leave this unchecked.");
  109. wxString texfmt_desc = wxTRANSLATE("Modify textures to show the format they're encoded in. Needs an emulation reset in most cases.\n\nIf unsure, leave this unchecked.");
  110. wxString efb_copy_regions_desc = wxTRANSLATE("[BROKEN]\nHighlight regions the EFB was copied from.\n\nIf unsure, leave this unchecked.");
  111. wxString xfb_desc = wxTRANSLATE("Disable any XFB emulation.\nSpeeds up emulation a lot but causes heavy glitches in many games which rely on them (especially homebrew applications).\n\nIf unsure, leave this checked.");
  112. wxString xfb_virtual_desc = wxTRANSLATE("Emulate XFBs using GPU texture objects.\nFixes many games which don't work without XFB emulation while not being as slow as real XFB emulation. However, it may still fail for a lot of other games (especially homebrew applications).\n\nIf unsure, leave this checked.");
  113. wxString xfb_real_desc = wxTRANSLATE("Emulate XFBs accurately.\nSlows down emulation a lot and prohibits high-resolution rendering but is necessary to emulate a number of games properly.\n\nIf unsure, check virtual XFB emulation instead.");
  114. wxString dump_textures_desc = wxTRANSLATE("Dump decoded game textures to User/Dump/Textures/<game_id>/\n\nIf unsure, leave this unchecked.");
  115. wxString load_hires_textures_desc = wxTRANSLATE("Load custom textures from User/Load/Textures/<game_id>/\n\nIf unsure, leave this unchecked.");
  116. wxString dump_efb_desc = wxTRANSLATE("Dump the contents of EFB copies to User/Dump/Textures/\n\nIf unsure, leave this unchecked.");
  117. wxString dump_frames_desc = wxTRANSLATE("Dump all rendered frames to an AVI file in User/Dump/Frames/\n\nIf unsure, leave this unchecked.");
  118. #if !defined WIN32 && defined HAVE_LIBAV
  119. wxString use_ffv1_desc = wxTRANSLATE("Encode frame dumps using the FFV1 codec.\n\nIf unsure, leave this unchecked.");
  120. #endif
  121. wxString free_look_desc = wxTRANSLATE("This feature allows you to change the game's camera.\nHold the right mouse button and move the mouse to pan the camera around. Hold SHIFT and press one of the WASD keys to move the camera by a certain step distance (SHIFT+0 to move faster and SHIFT+9 to move slower). Press SHIFT+R to reset the camera.\n\nIf unsure, leave this unchecked.");
  122. wxString crop_desc = wxTRANSLATE("Crop the picture from 4:3 to 5:4 or from 16:9 to 16:10.\n\nIf unsure, leave this unchecked.");
  123. wxString opencl_desc = wxTRANSLATE("[EXPERIMENTAL]\nAims to speed up emulation by offloading texture decoding to the GPU using the OpenCL framework.\nHowever, right now it's known to cause texture defects in various games. Also it's slower than regular CPU texture decoding in most cases.\n\nIf unsure, leave this unchecked.");
  124. wxString dlc_desc = wxTRANSLATE("[EXPERIMENTAL]\nSpeeds up emulation a bit by caching display lists.\nPossibly causes issues though.\n\nIf unsure, leave this unchecked.");
  125. wxString omp_desc = wxTRANSLATE("Use multiple threads to decode textures.\nMight result in a speedup (especially on CPUs with more than two cores).\n\nIf unsure, leave this unchecked.");
  126. wxString hotkeys_desc = wxTRANSLATE("Allows toggling certain options via the hotkeys 3, 4, 5, 6 and 7 within the emulation window.\n\nIf unsure, leave this unchecked.");
  127. wxString ppshader_desc = wxTRANSLATE("Apply a post-processing effect after finishing a frame.\n\nIf unsure, select (off).");
  128. wxString cache_efb_copies_desc = wxTRANSLATE("Slightly speeds up EFB to RAM copies by sacrificing emulation accuracy.\nSometimes also increases visual quality.\nIf you're experiencing any issues, try raising texture cache accuracy or disable this option.\n\nIf unsure, leave this unchecked.");
  129. wxString shader_errors_desc = wxTRANSLATE("Usually if shader compilation fails, an error message is displayed.\nHowever, one may skip the popups to allow interruption free gameplay by checking this option.\n\nIf unsure, leave this unchecked.");
  130.  
  131.  
  132. // Search for avaliable resolutions - TODO: Move to Common?
  133. wxArrayString GetListOfResolutions()
  134. {
  135. wxArrayString retlist;
  136. #ifdef _WIN32
  137. DWORD iModeNum = 0;
  138. DEVMODE dmi;
  139. ZeroMemory(&dmi, sizeof(dmi));
  140. dmi.dmSize = sizeof(dmi);
  141. std::vector<std::string> resos;
  142.  
  143. while (EnumDisplaySettings(NULL, iModeNum++, &dmi) != 0)
  144. {
  145. char res[100];
  146. sprintf(res, "%dx%d", dmi.dmPelsWidth, dmi.dmPelsHeight);
  147. std::string strRes(res);
  148. // Only add unique resolutions
  149. if (std::find(resos.begin(), resos.end(), strRes) == resos.end())
  150. {
  151. resos.push_back(strRes);
  152. retlist.Add(wxString::FromAscii(res));
  153. }
  154. ZeroMemory(&dmi, sizeof(dmi));
  155. }
  156. #elif defined(HAVE_XRANDR) && HAVE_XRANDR
  157. main_frame->m_XRRConfig->AddResolutions(retlist);
  158. #elif defined(__APPLE__)
  159. CFArrayRef modes = CGDisplayAvailableModes(CGMainDisplayID());
  160. for (CFIndex i = 0; i < CFArrayGetCount(modes); i++)
  161. {
  162. std::stringstream res;
  163. CFDictionaryRef mode;
  164. CFNumberRef ref;
  165. int w, h, d;
  166.  
  167. mode = (CFDictionaryRef)CFArrayGetValueAtIndex(modes, i);
  168. ref = (CFNumberRef)CFDictionaryGetValue(mode, kCGDisplayWidth);
  169. CFNumberGetValue(ref, kCFNumberIntType, &w);
  170. ref = (CFNumberRef)CFDictionaryGetValue(mode, kCGDisplayHeight);
  171. CFNumberGetValue(ref, kCFNumberIntType, &h);
  172. ref = (CFNumberRef)CFDictionaryGetValue(mode,
  173. kCGDisplayBitsPerPixel);
  174. CFNumberGetValue(ref, kCFNumberIntType, &d);
  175.  
  176. if (CFDictionaryContainsKey(mode, kCGDisplayModeIsStretched))
  177. continue;
  178. if (d != 32)
  179. continue;
  180.  
  181. res << w << "x" << h;
  182.  
  183. retlist.Add(res.str());
  184. }
  185. #endif
  186. return retlist;
  187. }
  188.  
  189. VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, const std::string& _ininame)
  190. : wxDialog(parent, -1,
  191. wxString::Format(_("Dolphin %s Graphics Configuration"),
  192. wxGetTranslation(wxString::From8BitData(title.c_str()))),
  193. wxDefaultPosition, wxDefaultSize)
  194. , vconfig(g_Config)
  195. , ininame(_ininame)
  196. {
  197. vconfig.Load((File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini").c_str());
  198.  
  199. Connect(wxID_ANY, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(VideoConfigDiag::OnUpdateUI), NULL, this);
  200.  
  201. wxNotebook* const notebook = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize);
  202.  
  203. // -- GENERAL --
  204. {
  205. wxPanel* const page_general = new wxPanel(notebook, -1, wxDefaultPosition);
  206. notebook->AddPage(page_general, _("General"));
  207. wxBoxSizer* const szr_general = new wxBoxSizer(wxVERTICAL);
  208.  
  209. // - basic
  210. {
  211. wxFlexGridSizer* const szr_basic = new wxFlexGridSizer(2, 5, 5);
  212.  
  213. // backend
  214. {
  215. wxStaticText* const label_backend = new wxStaticText(page_general, wxID_ANY, _("Backend:"));
  216. choice_backend = new wxChoice(page_general, wxID_ANY, wxDefaultPosition);
  217. RegisterControl(choice_backend, wxGetTranslation(backend_desc));
  218.  
  219. std::vector<VideoBackend*>::const_iterator
  220. it = g_available_video_backends.begin(),
  221. itend = g_available_video_backends.end();
  222. for (; it != itend; ++it)
  223. choice_backend->AppendString(wxGetTranslation(wxString::FromAscii((*it)->GetName().c_str())));
  224.  
  225. choice_backend->SetStringSelection(wxGetTranslation(wxString::FromAscii(g_video_backend->GetName().c_str())));
  226. _connect_macro_(choice_backend, VideoConfigDiag::Event_Backend, wxEVT_COMMAND_CHOICE_SELECTED, this);
  227.  
  228. szr_basic->Add(label_backend, 1, wxALIGN_CENTER_VERTICAL, 5);
  229. szr_basic->Add(choice_backend, 1, 0, 0);
  230.  
  231. if (Core::GetState() != Core::CORE_UNINITIALIZED)
  232. {
  233. label_backend->Disable();
  234. choice_backend->Disable();
  235. }
  236. }
  237.  
  238. // adapter (D3D only)
  239. if (vconfig.backend_info.Adapters.size())
  240. {
  241. wxChoice* const choice_adapter = CreateChoice(page_general, vconfig.iAdapter, wxGetTranslation(adapter_desc));
  242.  
  243. std::vector<std::string>::const_iterator
  244. it = vconfig.backend_info.Adapters.begin(),
  245. itend = vconfig.backend_info.Adapters.end();
  246. for (; it != itend; ++it)
  247. choice_adapter->AppendString(wxString::FromAscii(it->c_str()));
  248.  
  249. choice_adapter->Select(vconfig.iAdapter);
  250.  
  251. szr_basic->Add(new wxStaticText(page_general, -1, _("Adapter:")), 1, wxALIGN_CENTER_VERTICAL, 5);
  252. szr_basic->Add(choice_adapter, 1, 0, 0);
  253. }
  254.  
  255.  
  256. // - display
  257. wxFlexGridSizer* const szr_display = new wxFlexGridSizer(2, 5, 5);
  258.  
  259. {
  260. // display resolution
  261. {
  262. wxArrayString res_list = GetListOfResolutions();
  263. if (res_list.empty())
  264. res_list.Add(_("<No resolutions found>"));
  265. wxStaticText* const label_display_resolution = new wxStaticText(page_general, wxID_ANY, _("Fullscreen resolution:"));
  266. choice_display_resolution = new wxChoice(page_general, wxID_ANY, wxDefaultPosition, wxDefaultSize, res_list);
  267. RegisterControl(choice_display_resolution, wxGetTranslation(display_res_desc));
  268. _connect_macro_(choice_display_resolution, VideoConfigDiag::Event_DisplayResolution, wxEVT_COMMAND_CHOICE_SELECTED, this);
  269.  
  270. choice_display_resolution->SetStringSelection(wxString::FromAscii(SConfig::GetInstance().m_LocalCoreStartupParameter.strFullscreenResolution.c_str()));
  271.  
  272. szr_display->Add(label_display_resolution, 1, wxALIGN_CENTER_VERTICAL, 0);
  273. szr_display->Add(choice_display_resolution);
  274.  
  275. if (Core::GetState() != Core::CORE_UNINITIALIZED)
  276. {
  277. label_display_resolution->Disable();
  278. choice_display_resolution->Disable();
  279. }
  280. }
  281.  
  282. // aspect-ratio
  283. {
  284. const wxString ar_choices[] = { _("Auto"), _("Force 16:9"), _("Force 4:3"), _("Stretch to Window") };
  285.  
  286. szr_display->Add(new wxStaticText(page_general, -1, _("Aspect Ratio:")), 1, wxALIGN_CENTER_VERTICAL, 0);
  287. wxChoice* const choice_aspect = CreateChoice(page_general, vconfig.iAspectRatio, wxGetTranslation(ar_desc),
  288. sizeof(ar_choices)/sizeof(*ar_choices), ar_choices);
  289. szr_display->Add(choice_aspect, 1, 0, 0);
  290. }
  291.  
  292. // various other display options
  293. {
  294. szr_display->Add(CreateCheckBox(page_general, _("V-Sync"), wxGetTranslation(vsync_desc), vconfig.bVSync));
  295. szr_display->Add(CreateCheckBox(page_general, _("Use Fullscreen"), wxGetTranslation(use_fullscreen_desc), SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen));
  296. }
  297. }
  298.  
  299. // - other
  300. wxFlexGridSizer* const szr_other = new wxFlexGridSizer(2, 5, 5);
  301.  
  302. {
  303. SettingCheckBox* render_to_main_cb;
  304. szr_other->Add(CreateCheckBox(page_general, _("Show FPS"), wxGetTranslation(show_fps_desc), vconfig.bShowFPS));
  305. szr_other->Add(CreateCheckBox(page_general, _("Log FPS to file"), wxGetTranslation(log_fps_to_file_desc), vconfig.bLogFPSToFile));
  306. szr_other->Add(CreateCheckBox(page_general, _("Auto adjust Window Size"), wxGetTranslation(auto_window_size_desc), SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderWindowAutoSize));
  307. szr_other->Add(CreateCheckBox(page_general, _("Keep window on top"), wxGetTranslation(keep_window_on_top_desc), SConfig::GetInstance().m_LocalCoreStartupParameter.bKeepWindowOnTop));
  308. szr_other->Add(CreateCheckBox(page_general, _("Hide Mouse Cursor"), wxGetTranslation(hide_mouse_cursor_desc), SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor));
  309. szr_other->Add(render_to_main_cb = CreateCheckBox(page_general, _("Render to Main Window"), wxGetTranslation(render_to_main_win_desc), SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain));
  310.  
  311. if (Core::GetState() != Core::CORE_UNINITIALIZED)
  312. render_to_main_cb->Disable();
  313.  
  314. }
  315.  
  316.  
  317. wxStaticBoxSizer* const group_basic = new wxStaticBoxSizer(wxVERTICAL, page_general, _("Basic"));
  318. group_basic->Add(szr_basic, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
  319. szr_general->Add(group_basic, 0, wxEXPAND | wxALL, 5);
  320.  
  321. wxStaticBoxSizer* const group_display = new wxStaticBoxSizer(wxVERTICAL, page_general, _("Display"));
  322. group_display->Add(szr_display, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
  323. szr_general->Add(group_display, 0, wxEXPAND | wxALL, 5);
  324.  
  325. wxStaticBoxSizer* const group_other = new wxStaticBoxSizer(wxVERTICAL, page_general, _("Other"));
  326. group_other->Add(szr_other, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
  327. szr_general->Add(group_other, 0, wxEXPAND | wxALL, 5);
  328. }
  329.  
  330. szr_general->AddStretchSpacer();
  331. CreateDescriptionArea(page_general, szr_general);
  332. page_general->SetSizerAndFit(szr_general);
  333. }
  334.  
  335. // -- ENHANCEMENTS --
  336. {
  337. wxPanel* const page_enh = new wxPanel(notebook, -1, wxDefaultPosition);
  338. notebook->AddPage(page_enh, _("Enhancements"));
  339. wxBoxSizer* const szr_enh_main = new wxBoxSizer(wxVERTICAL);
  340.  
  341. // - enhancements
  342. wxFlexGridSizer* const szr_enh = new wxFlexGridSizer(2, 5, 5);
  343.  
  344. // Internal resolution
  345. {
  346. const wxString efbscale_choices[] = { _("Auto (Window Size)"), _("Auto (Multiple of 640x528)"),
  347. wxT("1x Native (640x528)"), wxT("1.5x Native (960x792)"), wxT("2x Native (1280x1056)"),
  348. wxT("2.5x Native (1600x1320)"), wxT("3x Native (1920x1584)"), wxT("4x Native (2560x2112)") };
  349.  
  350. wxChoice *const choice_efbscale = CreateChoice(page_enh,
  351. vconfig.iEFBScale, wxGetTranslation(internal_res_desc), sizeof(efbscale_choices)/sizeof(*efbscale_choices), efbscale_choices);
  352.  
  353. szr_enh->Add(new wxStaticText(page_enh, wxID_ANY, _("Internal Resolution:")), 1, wxALIGN_CENTER_VERTICAL, 0);
  354. szr_enh->Add(choice_efbscale);
  355. }
  356.  
  357. // AA
  358. {
  359. text_aamode = new wxStaticText(page_enh, -1, _("Anti-Aliasing:"));
  360. choice_aamode = CreateChoice(page_enh, vconfig.iMultisampleMode, wxGetTranslation(aa_desc));
  361.  
  362. std::vector<std::string>::const_iterator
  363. it = vconfig.backend_info.AAModes.begin(),
  364. itend = vconfig.backend_info.AAModes.end();
  365. for (; it != itend; ++it)
  366. choice_aamode->AppendString(wxGetTranslation(wxString::FromAscii(it->c_str())));
  367.  
  368. choice_aamode->Select(vconfig.iMultisampleMode);
  369. szr_enh->Add(text_aamode, 1, wxALIGN_CENTER_VERTICAL, 0);
  370. szr_enh->Add(choice_aamode);
  371. }
  372.  
  373. // AF
  374. {
  375. const wxString af_choices[] = {wxT("1x"), wxT("2x"), wxT("4x"), wxT("8x"), wxT("16x")};
  376. szr_enh->Add(new wxStaticText(page_enh, -1, _("Anisotropic Filtering:")), 1, wxALIGN_CENTER_VERTICAL, 0);
  377. szr_enh->Add(CreateChoice(page_enh, vconfig.iMaxAnisotropy, wxGetTranslation(af_desc), 5, af_choices));
  378. }
  379.  
  380. // postproc shader
  381. if (vconfig.backend_info.PPShaders.size())
  382. {
  383. wxChoice *const choice_ppshader = new wxChoice(page_enh, -1, wxDefaultPosition);
  384. RegisterControl(choice_ppshader, wxGetTranslation(ppshader_desc));
  385. choice_ppshader->AppendString(_("(off)"));
  386.  
  387. std::vector<std::string>::const_iterator
  388. it = vconfig.backend_info.PPShaders.begin(),
  389. itend = vconfig.backend_info.PPShaders.end();
  390. for (; it != itend; ++it)
  391. choice_ppshader->AppendString(wxString::FromAscii(it->c_str()));
  392.  
  393. if (vconfig.sPostProcessingShader.empty())
  394. choice_ppshader->Select(0);
  395. else
  396. choice_ppshader->SetStringSelection(wxString::FromAscii(vconfig.sPostProcessingShader.c_str()));
  397.  
  398. _connect_macro_(choice_ppshader, VideoConfigDiag::Event_PPShader, wxEVT_COMMAND_CHOICE_SELECTED, this);
  399.  
  400. szr_enh->Add(new wxStaticText(page_enh, -1, _("Post-Processing Effect:")), 1, wxALIGN_CENTER_VERTICAL, 0);
  401. szr_enh->Add(choice_ppshader);
  402. }
  403.  
  404. // Scaled copy, PL, Bilinear filter, 3D Vision
  405. szr_enh->Add(CreateCheckBox(page_enh, _("Scaled EFB Copy"), wxGetTranslation(scaled_efb_copy_desc), vconfig.bCopyEFBScaled));
  406. szr_enh->Add(pixel_lighting = CreateCheckBox(page_enh, _("Per-Pixel Lighting"), wxGetTranslation(pixel_lighting_desc), vconfig.bEnablePixelLighting));
  407. szr_enh->Add(CreateCheckBox(page_enh, _("Force Texture Filtering"), wxGetTranslation(force_filtering_desc), vconfig.bForceFiltering));
  408.  
  409. // 3D Vision
  410. _3d_vision = CreateCheckBox(page_enh, _("3D Vision"), wxGetTranslation(_3d_vision_desc), vconfig.b3DVision);
  411. _3d_vision->Show(vconfig.backend_info.bSupports3DVision);
  412. szr_enh->Add(_3d_vision);
  413. // TODO: Add anaglyph 3d here
  414.  
  415. wxStaticBoxSizer* const group_enh = new wxStaticBoxSizer(wxVERTICAL, page_enh, _("Enhancements"));
  416. group_enh->Add(szr_enh, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
  417. szr_enh_main->Add(group_enh, 0, wxEXPAND | wxALL, 5);
  418.  
  419.  
  420. szr_enh_main->AddStretchSpacer();
  421. CreateDescriptionArea(page_enh, szr_enh_main);
  422. page_enh->SetSizerAndFit(szr_enh_main);
  423. }
  424.  
  425.  
  426. // -- SPEED HACKS --
  427. {
  428. wxPanel* const page_hacks = new wxPanel(notebook, -1, wxDefaultPosition);
  429. notebook->AddPage(page_hacks, _("Hacks"));
  430. wxBoxSizer* const szr_hacks = new wxBoxSizer(wxVERTICAL);
  431.  
  432. // - EFB hacks
  433. wxStaticBoxSizer* const szr_efb = new wxStaticBoxSizer(wxVERTICAL, page_hacks, _("Embedded Frame Buffer"));
  434.  
  435. // format change emulation
  436. emulate_efb_format_changes = CreateCheckBox(page_hacks, _("Ignore Format Changes"), wxGetTranslation(efb_emulate_format_changes_desc), vconfig.bEFBEmulateFormatChanges, true);
  437.  
  438. // EFB copies
  439. wxStaticBoxSizer* const group_efbcopy = new wxStaticBoxSizer(wxHORIZONTAL, page_hacks, _("EFB Copies"));
  440.  
  441. SettingCheckBox* efbcopy_disable = CreateCheckBox(page_hacks, _("Disable"), wxGetTranslation(efb_copy_desc), vconfig.bEFBCopyEnable, true);
  442. efbcopy_texture = CreateRadioButton(page_hacks, _("Texture"), wxGetTranslation(efb_copy_texture_desc), vconfig.bCopyEFBToTexture, false, wxRB_GROUP);
  443. efbcopy_ram = CreateRadioButton(page_hacks, _("RAM"), wxGetTranslation(efb_copy_ram_desc), vconfig.bCopyEFBToTexture, true);
  444. cache_efb_copies = CreateCheckBox(page_hacks, _("Enable Cache"), wxGetTranslation(cache_efb_copies_desc), vconfig.bEFBCopyCacheEnable);
  445.  
  446. group_efbcopy->Add(efbcopy_disable, 0, wxLEFT | wxRIGHT | wxBOTTOM, 5);
  447. group_efbcopy->AddStretchSpacer(1);
  448. group_efbcopy->Add(efbcopy_texture, 0, wxRIGHT, 5);
  449. group_efbcopy->Add(efbcopy_ram, 0, wxRIGHT, 5);
  450. group_efbcopy->Add(cache_efb_copies, 0, wxRIGHT, 5);
  451.  
  452. szr_efb->Add(CreateCheckBox(page_hacks, _("Skip EFB Access from CPU"), wxGetTranslation(efb_access_desc), vconfig.bEFBAccessEnable, true), 0, wxBOTTOM | wxLEFT, 5);
  453. szr_efb->Add(emulate_efb_format_changes, 0, wxBOTTOM | wxLEFT, 5);
  454. szr_efb->Add(group_efbcopy, 0, wxEXPAND | wxALL, 5);
  455. szr_hacks->Add(szr_efb, 0, wxEXPAND | wxALL, 5);
  456.  
  457. // Texture cache
  458. {
  459. wxStaticBoxSizer* const szr_safetex = new wxStaticBoxSizer(wxHORIZONTAL, page_hacks, _("Texture Cache"));
  460.  
  461. // TODO: Use wxSL_MIN_MAX_LABELS or wxSL_VALUE_LABEL with wx 2.9.1
  462. wxSlider* const stc_slider = new wxSlider(page_hacks, wxID_ANY, 0, 0, 2, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_BOTTOM);
  463. _connect_macro_(stc_slider, VideoConfigDiag::Event_Stc, wxEVT_COMMAND_SLIDER_UPDATED, this);
  464. RegisterControl(stc_slider, wxGetTranslation(stc_desc));
  465.  
  466. if (vconfig.iSafeTextureCache_ColorSamples == 0) stc_slider->SetValue(0);
  467. else if (vconfig.iSafeTextureCache_ColorSamples == 512) stc_slider->SetValue(1);
  468. else if (vconfig.iSafeTextureCache_ColorSamples == 128) stc_slider->SetValue(2);
  469. else stc_slider->Disable(); // Using custom number of samples; TODO: Inform the user why this is disabled..
  470.  
  471. szr_safetex->Add(new wxStaticText(page_hacks, wxID_ANY, _("Accuracy:")), 0, wxALL, 5);
  472. szr_safetex->AddStretchSpacer(1);
  473. szr_safetex->Add(new wxStaticText(page_hacks, wxID_ANY, _("Safe")), 0, wxLEFT|wxTOP|wxBOTTOM, 5);
  474. szr_safetex->Add(stc_slider, 2, wxRIGHT, 0);
  475. szr_safetex->Add(new wxStaticText(page_hacks, wxID_ANY, _("Fast")), 0, wxRIGHT|wxTOP|wxBOTTOM, 5);
  476. szr_hacks->Add(szr_safetex, 0, wxEXPAND | wxALL, 5);
  477. }
  478.  
  479. // - XFB
  480. {
  481. wxStaticBoxSizer* const group_xfb = new wxStaticBoxSizer(wxHORIZONTAL, page_hacks, _("External Frame Buffer"));
  482.  
  483. SettingCheckBox* disable_xfb = CreateCheckBox(page_hacks, _("Disable"), wxGetTranslation(xfb_desc), vconfig.bUseXFB, true);
  484. virtual_xfb = CreateRadioButton(page_hacks, _("Virtual"), wxGetTranslation(xfb_virtual_desc), vconfig.bUseRealXFB, true, wxRB_GROUP);
  485. real_xfb = CreateRadioButton(page_hacks, _("Real"), wxGetTranslation(xfb_real_desc), vconfig.bUseRealXFB);
  486.  
  487. group_xfb->Add(disable_xfb, 0, wxLEFT | wxRIGHT | wxBOTTOM, 5);
  488. group_xfb->AddStretchSpacer(1);
  489. group_xfb->Add(virtual_xfb, 0, wxRIGHT, 5);
  490. group_xfb->Add(real_xfb, 0, wxRIGHT, 5);
  491. szr_hacks->Add(group_xfb, 0, wxEXPAND | wxALL, 5);
  492. } // xfb
  493.  
  494. // - other hacks
  495. {
  496. wxGridSizer* const szr_other = new wxGridSizer(2, 5, 5);
  497.  
  498. szr_other->Add(CreateCheckBox(page_hacks, _("Cache Display Lists"), wxGetTranslation(dlc_desc), vconfig.bDlistCachingEnable));
  499. szr_other->Add(CreateCheckBox(page_hacks, _("Disable Lighting"), wxGetTranslation(disable_lighting_desc), vconfig.bDisableLighting));
  500. szr_other->Add(CreateCheckBox(page_hacks, _("Disable Fog"), wxGetTranslation(disable_fog_desc), vconfig.bDisableFog));
  501. szr_other->Add(CreateCheckBox(page_hacks, _("Disable Per-Pixel Depth"), wxGetTranslation(pixel_depth_desc), vconfig.bEnablePerPixelDepth, true));
  502. szr_other->Add(CreateCheckBox(page_hacks, _("Skip Dest. Alpha Pass"), wxGetTranslation(disable_alphapass_desc), vconfig.bDstAlphaPass));
  503. szr_other->Add(CreateCheckBox(page_hacks, _("OpenCL Texture Decoder"), wxGetTranslation(opencl_desc), vconfig.bEnableOpenCL));
  504. szr_other->Add(CreateCheckBox(page_hacks, _("OpenMP Texture Decoder"), wxGetTranslation(omp_desc), vconfig.bOMPDecoder));
  505.  
  506. wxStaticBoxSizer* const group_other = new wxStaticBoxSizer(wxVERTICAL, page_hacks, _("Other"));
  507. group_other->Add(szr_other, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
  508. szr_hacks->Add(group_other, 0, wxEXPAND | wxALL, 5);
  509. }
  510.  
  511. szr_hacks->AddStretchSpacer();
  512. CreateDescriptionArea(page_hacks, szr_hacks);
  513. page_hacks->SetSizerAndFit(szr_hacks);
  514. }
  515.  
  516. // -- ADVANCED --
  517. {
  518. wxPanel* const page_advanced = new wxPanel(notebook, -1, wxDefaultPosition);
  519. notebook->AddPage(page_advanced, _("Advanced"));
  520. wxBoxSizer* const szr_advanced = new wxBoxSizer(wxVERTICAL);
  521.  
  522. // - debug
  523. {
  524. wxGridSizer* const szr_debug = new wxGridSizer(2, 5, 5);
  525.  
  526. szr_debug->Add(CreateCheckBox(page_advanced, _("Enable Wireframe"), wxGetTranslation(wireframe_desc), vconfig.bWireFrame));
  527. szr_debug->Add(CreateCheckBox(page_advanced, _("Show EFB Copy Regions"), wxGetTranslation(efb_copy_regions_desc), vconfig.bShowEFBCopyRegions));
  528. szr_debug->Add(CreateCheckBox(page_advanced, _("Show Statistics"), wxGetTranslation(show_stats_desc), vconfig.bOverlayStats));
  529. szr_debug->Add(CreateCheckBox(page_advanced, _("Texture Format Overlay"), wxGetTranslation(texfmt_desc), vconfig.bTexFmtOverlayEnable));
  530.  
  531. wxStaticBoxSizer* const group_debug = new wxStaticBoxSizer(wxVERTICAL, page_advanced, _("Debugging"));
  532. szr_advanced->Add(group_debug, 0, wxEXPAND | wxALL, 5);
  533. group_debug->Add(szr_debug, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
  534. }
  535.  
  536. // - utility
  537. {
  538. wxGridSizer* const szr_utility = new wxGridSizer(2, 5, 5);
  539.  
  540. szr_utility->Add(CreateCheckBox(page_advanced, _("Dump Textures"), wxGetTranslation(dump_textures_desc), vconfig.bDumpTextures));
  541. szr_utility->Add(CreateCheckBox(page_advanced, _("Load Custom Textures"), wxGetTranslation(load_hires_textures_desc), vconfig.bHiresTextures));
  542. szr_utility->Add(CreateCheckBox(page_advanced, _("Dump EFB Target"), wxGetTranslation(dump_efb_desc), vconfig.bDumpEFBTarget));
  543. szr_utility->Add(CreateCheckBox(page_advanced, _("Dump Frames"), wxGetTranslation(dump_frames_desc), vconfig.bDumpFrames));
  544. szr_utility->Add(CreateCheckBox(page_advanced, _("Free Look"), wxGetTranslation(free_look_desc), vconfig.bFreeLook));
  545. #if !defined WIN32 && defined HAVE_LIBAV
  546. szr_utility->Add(CreateCheckBox(page_advanced, _("Frame Dumps use FFV1"), wxGetTranslation(use_ffv1_desc), vconfig.bUseFFV1));
  547. #endif
  548.  
  549. wxStaticBoxSizer* const group_utility = new wxStaticBoxSizer(wxVERTICAL, page_advanced, _("Utility"));
  550. szr_advanced->Add(group_utility, 0, wxEXPAND | wxALL, 5);
  551. group_utility->Add(szr_utility, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
  552. }
  553.  
  554. // - misc
  555. {
  556. wxGridSizer* const szr_misc = new wxGridSizer(2, 5, 5);
  557.  
  558. szr_misc->Add(CreateCheckBox(page_advanced, _("Show Input Display"), wxGetTranslation(show_input_display_desc), vconfig.bShowInputDisplay));
  559. szr_misc->Add(CreateCheckBox(page_advanced, _("Crop"), wxGetTranslation(crop_desc), vconfig.bCrop));
  560. szr_misc->Add(CreateCheckBox(page_advanced, _("Enable Hotkeys"), wxGetTranslation(hotkeys_desc), vconfig.bOSDHotKey));
  561.  
  562. szr_misc->Add(CreateCheckBox(page_advanced, _("Widescreen Hack"), wxGetTranslation(ws_hack_desc), vconfig.bWidescreenHack));
  563.  
  564. // Progressive Scan
  565. {
  566. wxCheckBox* const cb_prog_scan = new wxCheckBox(page_advanced, wxID_ANY, _("Enable Progressive Scan"));
  567. RegisterControl(cb_prog_scan, wxGetTranslation(prog_scan_desc));
  568. _connect_macro_(cb_prog_scan, VideoConfigDiag::Event_ProgressiveScan, wxEVT_COMMAND_CHECKBOX_CLICKED, this);
  569. if (Core::GetState() != Core::CORE_UNINITIALIZED)
  570. cb_prog_scan->Disable();
  571.  
  572. cb_prog_scan->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bProgressive);
  573. // A bit strange behavior, but this needs to stay in sync with the main progressive boolean; TODO: Is this still necessary?
  574. SConfig::GetInstance().m_SYSCONF->SetData("IPL.PGS", SConfig::GetInstance().m_LocalCoreStartupParameter.bProgressive);
  575.  
  576. szr_misc->Add(cb_prog_scan);
  577. }
  578.  
  579.  
  580. wxStaticBoxSizer* const group_misc = new wxStaticBoxSizer(wxVERTICAL, page_advanced, _("Misc"));
  581. szr_advanced->Add(group_misc, 0, wxEXPAND | wxALL, 5);
  582. group_misc->Add(szr_misc, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
  583. }
  584.  
  585. szr_advanced->AddStretchSpacer();
  586. CreateDescriptionArea(page_advanced, szr_advanced);
  587. page_advanced->SetSizerAndFit(szr_advanced);
  588. }
  589.  
  590. wxButton* const btn_close = new wxButton(this, wxID_OK, _("Close"), wxDefaultPosition);
  591. _connect_macro_(btn_close, VideoConfigDiag::Event_ClickClose, wxEVT_COMMAND_BUTTON_CLICKED, this);
  592.  
  593. Connect(wxID_ANY, wxEVT_CLOSE_WINDOW, wxCloseEventHandler(VideoConfigDiag::Event_Close), (wxObject*)0, this);
  594.  
  595. wxBoxSizer* const szr_main = new wxBoxSizer(wxVERTICAL);
  596. szr_main->Add(notebook, 1, wxEXPAND | wxALL, 5);
  597. szr_main->Add(btn_close, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 5);
  598.  
  599. SetSizerAndFit(szr_main);
  600. Center();
  601. SetFocus();
  602.  
  603. UpdateWindowUI();
  604. }
  605.  
  606. void VideoConfigDiag::Event_DisplayResolution(wxCommandEvent &ev)
  607. {
  608. SConfig::GetInstance().m_LocalCoreStartupParameter.strFullscreenResolution =
  609. choice_display_resolution->GetStringSelection().mb_str();
  610. #if defined(HAVE_XRANDR) && HAVE_XRANDR
  611. main_frame->m_XRRConfig->Update();
  612. #endif
  613. ev.Skip();
  614. }
  615.  
  616. SettingCheckBox* VideoConfigDiag::CreateCheckBox(wxWindow* parent, const wxString& label, const wxString& description, bool &setting, bool reverse, long style)
  617. {
  618. SettingCheckBox* const cb = new SettingCheckBox(parent, label, wxString(), setting, reverse, style);
  619. RegisterControl(cb, description);
  620. return cb;
  621. }
  622.  
  623. SettingChoice* VideoConfigDiag::CreateChoice(wxWindow* parent, int& setting, const wxString& description, int num, const wxString choices[], long style)
  624. {
  625. SettingChoice* const ch = new SettingChoice(parent, setting, wxString(), num, choices, style);
  626. RegisterControl(ch, description);
  627. return ch;
  628. }
  629.  
  630. SettingRadioButton* VideoConfigDiag::CreateRadioButton(wxWindow* parent, const wxString& label, const wxString& description, bool &setting, bool reverse, long style)
  631. {
  632. SettingRadioButton* const rb = new SettingRadioButton(parent, label, wxString(), setting, reverse, style);
  633. RegisterControl(rb, description);
  634. return rb;
  635. }
  636.  
  637. /* Use this to register descriptions for controls which have NOT been created using the Create* functions from above */
  638. wxControl* VideoConfigDiag::RegisterControl(wxControl* const control, const wxString& description)
  639. {
  640. ctrl_descs.insert(std::pair<wxWindow*,wxString>(control, description));
  641. control->Connect(wxID_ANY, wxEVT_ENTER_WINDOW, wxMouseEventHandler(VideoConfigDiag::Evt_EnterControl), NULL, this);
  642. control->Connect(wxID_ANY, wxEVT_LEAVE_WINDOW, wxMouseEventHandler(VideoConfigDiag::Evt_LeaveControl), NULL, this);
  643. return control;
  644. }
  645.  
  646. void VideoConfigDiag::Evt_EnterControl(wxMouseEvent& ev)
  647. {
  648. // TODO: Re-Fit the sizer if necessary!
  649.  
  650. // Get settings control object from event
  651. wxWindow* ctrl = (wxWindow*)ev.GetEventObject();
  652. if (!ctrl) return;
  653.  
  654. // look up description text object from the control's parent (which is the wxPanel of the current tab)
  655. wxStaticText* descr_text = desc_texts[ctrl->GetParent()];
  656. if (!descr_text) return;
  657.  
  658. // look up the description of the selected control and assign it to the current description text object's label
  659. descr_text->SetLabel(ctrl_descs[ctrl]);
  660. descr_text->Wrap(descr_text->GetContainingSizer()->GetSize().x - 20);
  661.  
  662. ev.Skip();
  663. }
  664.  
  665. // TODO: Don't hardcode the size of the description area via line breaks
  666. #define DEFAULT_DESC_TEXT _("Move the mouse pointer over an option to display a detailed description.\n\n\n\n\n\n\n")
  667. void VideoConfigDiag::Evt_LeaveControl(wxMouseEvent& ev)
  668. {
  669. // look up description text control and reset its label
  670. wxWindow* ctrl = (wxWindow*)ev.GetEventObject();
  671. if (!ctrl) return;
  672. wxStaticText* descr_text = desc_texts[ctrl->GetParent()];
  673. if (!descr_text) return;
  674.  
  675. descr_text->SetLabel(DEFAULT_DESC_TEXT);
  676. descr_text->Wrap(descr_text->GetContainingSizer()->GetSize().x - 20);
  677. ev.Skip();
  678. }
  679.  
  680. void VideoConfigDiag::CreateDescriptionArea(wxPanel* const page, wxBoxSizer* const sizer)
  681. {
  682. // Create description frame
  683. wxStaticBoxSizer* const desc_sizer = new wxStaticBoxSizer(wxVERTICAL, page, _("Description"));
  684. sizer->Add(desc_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
  685.  
  686. // Need to call SetSizerAndFit here, since we don't want the description texts to change the dialog width
  687. page->SetSizerAndFit(sizer);
  688.  
  689. // Create description text
  690. wxStaticText* const desc_text = new wxStaticText(page, wxID_ANY, DEFAULT_DESC_TEXT);
  691. desc_text->Wrap(desc_sizer->GetSize().x - 20);
  692. desc_sizer->Add(desc_text, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
  693.  
  694. // Store description text object for later lookup
  695. desc_texts.insert(std::pair<wxWindow*,wxStaticText*>(page, desc_text));
  696. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement