123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371 |
- #ifndef __NULLSOFT_DX9_PLUGIN_SHELL_H__
- #define __NULLSOFT_DX9_PLUGIN_SHELL_H__ 1
- #include "shell_defines.h"
- #include "dxcontext.h"
- #include "fft.h"
- #include "defines.h"
- #include "textmgr.h"
- #include "icon_t.h"
- #include <vector>
- #define TIME_HIST_SLOTS 128
- #define MAX_SONGS_PER_PAGE 40
- typedef struct
- {
- wchar_t szFace[256];
- int nSize;
- int bBold;
- int bItalic;
- int bAntiAliased;
- } td_fontinfo;
- typedef struct
- {
- float imm[2][3];
- float avg[2][3];
- float med_avg[2][3];
- float long_avg[2][3];
- float infinite_avg[2][3];
- float fWaveform[2][576];
- float fSpectrum[2][NUM_FREQUENCIES];
- } td_soundinfo;
- class CPluginShell
- {
- public:
-
-
- int GetFrame();
- float GetTime();
- float GetFps();
- eScrMode GetScreenMode();
- HWND GetWinampWindow();
- HINSTANCE GetInstance();
- wchar_t* GetPluginsDirPath();
- wchar_t* GetConfigIniFile();
- char* GetConfigIniFileA();
- protected:
-
-
-
-
-
-
- HWND GetPluginWindow();
- int GetWidth();
- int GetHeight();
- int GetBitDepth();
- LPDIRECT3DDEVICE9 GetDevice();
- D3DCAPS9* GetCaps();
- D3DFORMAT GetBackBufFormat();
- D3DFORMAT GetBackBufZFormat();
- char* GetDriverFilename();
- char* GetDriverDescription();
-
-
- public:
- LPD3DXFONT GetFont(eFontIndex idx);
- int GetFontHeight(eFontIndex idx);
- CTextManager m_text;
- protected:
-
-
- td_soundinfo m_sound;
- void SuggestHowToFreeSomeMem();
-
-
-
- int m_start_fullscreen;
- int m_start_desktop;
- int m_fake_fullscreen_mode;
- int m_max_fps_fs;
- int m_max_fps_dm;
- int m_max_fps_w;
- int m_show_press_f1_msg;
- int m_allow_page_tearing_w;
- int m_allow_page_tearing_fs;
- int m_allow_page_tearing_dm;
- int m_minimize_winamp;
- int m_desktop_show_icons;
- int m_desktop_textlabel_boxes;
- int m_desktop_manual_icon_scoot;
- int m_desktop_555_fix;
- int m_dualhead_horz;
- int m_dualhead_vert;
- int m_save_cpu;
- int m_skin;
- int m_fix_slow_text;
- td_fontinfo m_fontinfo[NUM_BASIC_FONTS + NUM_EXTRA_FONTS];
- D3DDISPLAYMODE m_disp_mode_fs;
-
-
- virtual void OverrideDefaults() = 0;
- virtual void MyPreInitialize() = 0;
- virtual void MyReadConfig() = 0;
- virtual void MyWriteConfig() = 0;
- virtual int AllocateMyNonDx9Stuff() = 0;
- virtual void CleanUpMyNonDx9Stuff() = 0;
- virtual int AllocateMyDX9Stuff() = 0;
- virtual void CleanUpMyDX9Stuff(int final_cleanup) = 0;
- virtual void MyRenderFn(int redraw) = 0;
- virtual void MyRenderUI(int *upper_left_corner_y, int *upper_right_corner_y, int *lower_left_corner_y, int *lower_right_corner_y, int xL, int xR) = 0;
- virtual LRESULT MyWindowProc(HWND hWnd, unsigned uMsg, WPARAM wParam, LPARAM lParam) = 0;
- virtual BOOL MyConfigTabProc(int nPage, HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) = 0;
- virtual void OnAltK() { };
- private:
-
- eScrMode m_screenmode;
- int m_frame;
- float m_time;
- float m_fps;
- HWND m_hWndWinamp;
- HINSTANCE m_hInstance;
- DXContext* m_lpDX;
- wchar_t m_szPluginsDirPath[MAX_PATH];
- wchar_t m_szConfigIniFile[MAX_PATH];
- char m_szConfigIniFileA[MAX_PATH];
-
-
- IDirect3DTexture9* m_lpDDSText;
- LPD3DXFONT m_d3dx_font[NUM_BASIC_FONTS + NUM_EXTRA_FONTS];
- LPD3DXFONT m_d3dx_desktop_font;
- HFONT m_font[NUM_BASIC_FONTS + NUM_EXTRA_FONTS];
- HFONT m_font_desktop;
-
-
- D3DMULTISAMPLE_TYPE m_multisample_fullscreen;
- D3DMULTISAMPLE_TYPE m_multisample_desktop;
- D3DMULTISAMPLE_TYPE m_multisample_windowed;
- GUID m_adapter_guid_fullscreen;
- GUID m_adapter_guid_desktop;
- GUID m_adapter_guid_windowed;
- char m_adapter_devicename_fullscreen[256];
- char m_adapter_devicename_desktop[256];
- char m_adapter_devicename_windowed[256];
-
- int m_lost_focus;
- int m_hidden;
- int m_resizing;
- int m_show_help;
- int m_show_playlist;
- int m_playlist_pos;
- int m_playlist_pageups;
- int m_playlist_top_idx;
- int m_playlist_btm_idx;
- int m_playlist_width_pixels;
- wchar_t m_playlist[MAX_SONGS_PER_PAGE][256];
- int m_exiting;
- int m_upper_left_corner_y;
- int m_lower_left_corner_y;
- int m_upper_right_corner_y;
- int m_lower_right_corner_y;
- int m_left_edge;
- int m_right_edge;
- int m_force_accept_WM_WINDOWPOSCHANGING;
-
- HMENU m_main_menu;
- HMENU m_context_menu;
-
-
- typedef std::vector<icon_t> IconList;
- IconList m_icon_list;
- IDirect3DTexture9* m_desktop_icons_texture[MAX_ICON_TEXTURES];
- HWND m_hWndProgMan;
- HWND m_hWndDesktop;
- HWND m_hWndDesktopListView;
- char m_szDesktopFolder[MAX_PATH];
- int m_desktop_icon_size;
- int m_desktop_dragging;
- int m_desktop_box;
- BYTE m_desktop_drag_pidl[1024];
- POINT m_desktop_drag_startpos;
- POINT m_desktop_drag_curpos;
- int m_desktop_wc_registered;
- DWORD m_desktop_bk_color;
- DWORD m_desktop_text_color;
- DWORD m_desktop_sel_color;
- DWORD m_desktop_sel_text_color;
- int m_desktop_icon_state;
- int m_desktop_icon_count;
- int m_desktop_icon_update_frame;
- CRITICAL_SECTION m_desktop_cs;
- int m_desktop_icons_disabled;
- int m_vms_desktop_loaded;
- int m_desktop_hook_set;
- bool m_bClearVJWindow;
-
- protected:
- double m_last_raw_time;
- LARGE_INTEGER m_high_perf_timer_freq;
- private:
- float m_time_hist[TIME_HIST_SLOTS];
- int m_time_hist_pos;
- LARGE_INTEGER m_prev_end_of_frame;
-
- FFT m_fftobj;
- float m_oldwave[2][576];
- int m_prev_align_offset[2];
- int m_align_weights_ready;
- public:
- CPluginShell();
- ~CPluginShell();
-
-
- int PluginPreInitialize(HWND hWinampWnd, HINSTANCE hWinampInstance);
- int PluginInitialize();
- int PluginRender(unsigned char *pWaveL, unsigned char *pWaveR);
- void PluginQuit();
- void ToggleHelp();
- void TogglePlaylist();
- void READ_FONT(int n);
- void WRITE_FONT(int n);
-
-
- static LRESULT CALLBACK WindowProc(HWND hWnd, unsigned uMsg, WPARAM wParam, LPARAM lParam);
- static LRESULT CALLBACK DesktopWndProc(HWND hWnd, unsigned uMsg, WPARAM wParam, LPARAM lParam);
- static LRESULT CALLBACK VJModeWndProc(HWND hWnd, unsigned uMsg, WPARAM wParam, LPARAM lParam);
- static INT_PTR CALLBACK ConfigDialogProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
- static INT_PTR CALLBACK TabCtrlProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
- static INT_PTR CALLBACK FontDialogProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
- static INT_PTR CALLBACK DesktopOptionsDialogProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
- static INT_PTR CALLBACK DualheadDialogProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
- private:
- void PushWindowToJustBeforeDesktop(HWND h);
- void DrawAndDisplay(int redraw);
- void ReadConfig();
- void WriteConfig();
- void DoTime();
- void AnalyzeNewSound(unsigned char *pWaveL, unsigned char *pWaveR);
- void AlignWaves();
- int InitDirectX();
- void CleanUpDirectX();
- int InitGDIStuff();
- void CleanUpGDIStuff();
- int AllocateDX9Stuff();
- void CleanUpDX9Stuff(int final_cleanup);
- int InitNondx9Stuff();
- void CleanUpNondx9Stuff();
- int InitVJStuff(RECT* pClientRect=NULL);
- void CleanUpVJStuff();
- int AllocateFonts(IDirect3DDevice9 *pDevice);
- void CleanUpFonts();
- void AllocateTextSurface();
- void ToggleDesktop();
- void OnUserResizeWindow();
- void OnUserResizeTextWindow();
- void PrepareFor2DDrawing_B(IDirect3DDevice9 *pDevice, int w, int h);
- void RenderBuiltInTextMsgs();
- int GetCanvasMarginX();
- int GetCanvasMarginY();
- public:
- void ToggleFullScreen();
- void DrawDarkTranslucentBox(RECT* pr);
- protected:
- void RenderPlaylist();
- void StuffParams(DXCONTEXT_PARAMS *pParams);
- void EnforceMaxFPS();
-
- int InitDesktopMode();
- void CleanUpDesktopMode();
- int CreateDesktopIconTexture(IDirect3DTexture9** ppTex);
- void DeselectDesktop();
- void UpdateDesktopBitmaps();
- int StuffIconBitmaps(int iStartIconIdx, int iTexNum, int *show_msgs);
- void RenderDesktop();
-
- int m_vj_mode;
- int m_hidden_textwnd;
- int m_resizing_textwnd;
- protected:
- HWND m_hTextWnd;
- private:
- int m_nTextWndWidth;
- int m_nTextWndHeight;
- bool m_bTextWindowClassRegistered;
- LPDIRECT3D9 m_vjd3d9;
- LPDIRECT3DDEVICE9 m_vjd3d9_device;
-
-
-
-
- LRESULT PluginShellWindowProc(HWND hWnd, unsigned uMsg, WPARAM wParam, LPARAM lParam);
- LRESULT PluginShellDesktopWndProc(HWND hWnd, unsigned uMsg, WPARAM wParam, LPARAM lParam);
- LRESULT PluginShellVJModeWndProc(HWND hWnd, unsigned uMsg, WPARAM wParam, LPARAM lParam);
-
- BOOL PluginShellConfigDialogProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
- BOOL PluginShellConfigTab1Proc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
- BOOL PluginShellFontDialogProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
- BOOL PluginShellDesktopOptionsDialogProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
- BOOL PluginShellDualheadDialogProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
- bool InitConfig(HWND hDialogWnd);
- void EndConfig();
- void UpdateAdapters(int screenmode);
- void UpdateFSAdapterDispModes();
- void UpdateDispModeMultiSampling(int screenmode);
- void UpdateMaxFps(int screenmode);
- int GetCurrentlySelectedAdapter(int screenmode);
- void SaveDisplayMode();
- void SaveMultiSamp(int screenmode);
- void SaveAdapter(int screenmode);
- void SaveMaxFps(int screenmode);
- void OnTabChanged(int nNewTab);
- LPDIRECT3DDEVICE9 GetTextDevice() { return (m_vjd3d9_device) ? m_vjd3d9_device : m_lpDX->m_lpDevice; }
-
- friend class CShaderParams;
- };
- #endif
|