1
0

plugin.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. /*
  2. LICENSE
  3. -------
  4. Copyright 2005-2013 Nullsoft, Inc.
  5. All rights reserved.
  6. Redistribution and use in source and binary forms, with or without modification,
  7. are permitted provided that the following conditions are met:
  8. * Redistributions of source code must retain the above copyright notice,
  9. this list of conditions and the following disclaimer.
  10. * Redistributions in binary form must reproduce the above copyright notice,
  11. this list of conditions and the following disclaimer in the documentation
  12. and/or other materials provided with the distribution.
  13. * Neither the name of Nullsoft nor the names of its contributors may be used to
  14. endorse or promote products derived from this software without specific prior written permission.
  15. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  16. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  18. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  20. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  21. IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  22. OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. */
  24. #ifndef __NULLSOFT_DX9_EXAMPLE_PLUGIN_H__
  25. #define __NULLSOFT_DX9_EXAMPLE_PLUGIN_H__ 1
  26. #include "pluginshell.h"
  27. #include "md_defines.h"
  28. #include "menu.h"
  29. #include "support.h"
  30. #include "texmgr.h"
  31. #include "state.h"
  32. #include <vector>
  33. #include "gstring.h"
  34. #include "ns-eel2/ns-eel.h"
  35. extern "C" int (*warand)(void);
  36. typedef enum { TEX_DISK, TEX_VS, TEX_BLUR0, TEX_BLUR1, TEX_BLUR2, TEX_BLUR3, TEX_BLUR4, TEX_BLUR5, TEX_BLUR6, TEX_BLUR_LAST } tex_code;
  37. typedef enum { UI_REGULAR, UI_MENU, UI_LOAD, UI_LOAD_DEL, UI_LOAD_RENAME, UI_SAVEAS, UI_SAVE_OVERWRITE, UI_EDIT_MENU_STRING, UI_CHANGEDIR, UI_IMPORT_WAVE, UI_EXPORT_WAVE, UI_IMPORT_SHAPE, UI_EXPORT_SHAPE, UI_UPGRADE_PIXEL_SHADER, UI_MASHUP } ui_mode;
  38. typedef struct { float rad; float ang; float a; float c; } td_vertinfo; // blending: mix = max(0,min(1,a*t + c));
  39. typedef char* CHARPTR;
  40. LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
  41. #define MY_FFT_SAMPLES 512 // for old [pre-vms] milkdrop sound analysis
  42. typedef struct
  43. {
  44. float imm[3]; // bass, mids, treble (absolute)
  45. float imm_rel[3]; // bass, mids, treble (relative to song; 1=avg, 0.9~below, 1.1~above)
  46. float avg[3]; // bass, mids, treble (absolute)
  47. float avg_rel[3]; // bass, mids, treble (relative to song; 1=avg, 0.9~below, 1.1~above)
  48. float long_avg[3]; // bass, mids, treble (absolute)
  49. float fWave[2][576];
  50. float fSpecLeft[MY_FFT_SAMPLES];
  51. } td_mysounddata;
  52. typedef struct
  53. {
  54. int bActive;
  55. int bFilterBadChars; // if true, it will filter out any characters that don't belong in a filename, plus the & symbol (because it doesn't display properly with DrawText)
  56. int bDisplayAsCode; // if true, semicolons will be followed by a newline, for display
  57. int nMaxLen; // can't be more than 511
  58. int nCursorPos;
  59. int nSelAnchorPos; // -1 if no selection made
  60. int bOvertypeMode;
  61. wchar_t szText[48000];
  62. wchar_t szPrompt[512];
  63. wchar_t szToolTip[512];
  64. char szClipboard[48000];
  65. wchar_t szClipboardW[48000];
  66. } td_waitstr;
  67. typedef struct
  68. {
  69. int bBold;
  70. int bItal;
  71. wchar_t szFace[128];
  72. int nColorR; // 0..255
  73. int nColorG; // 0..255
  74. int nColorB; // 0..255
  75. }
  76. td_custom_msg_font;
  77. enum
  78. {
  79. MD2_PS_NONE = 0,
  80. MD2_PS_2_0 = 2,
  81. MD2_PS_2_X = 3,
  82. MD2_PS_3_0 = 4,
  83. MD2_PS_4_0 = 5, // not supported by milkdrop
  84. };
  85. /*
  86. typedef struct
  87. {
  88. char szFace[256];
  89. int nSize;
  90. int bBold;
  91. int bItalic;
  92. } td_titlefontinfo;*/
  93. typedef struct
  94. {
  95. int nFont;
  96. float fSize; // 0..100
  97. float x;
  98. float y;
  99. float randx;
  100. float randy;
  101. float growth;
  102. float fTime; // total time to display the message, in seconds
  103. float fFade; // % (0..1) of the time that is spent fading in
  104. // overrides
  105. int bOverrideBold;
  106. int bOverrideItal;
  107. int bOverrideFace;
  108. int bOverrideColorR;
  109. int bOverrideColorG;
  110. int bOverrideColorB;
  111. int nColorR; // 0..255
  112. int nColorG; // 0..255
  113. int nColorB; // 0..255
  114. int nRandR;
  115. int nRandG;
  116. int nRandB;
  117. int bBold;
  118. int bItal;
  119. wchar_t szFace[128];
  120. wchar_t szText[256];
  121. }
  122. td_custom_msg;
  123. typedef struct
  124. {
  125. int bRedrawSuperText; // true if it needs redraw
  126. int bIsSongTitle; // false for custom message, true for song title
  127. //char szText[256];
  128. wchar_t szTextW[256];
  129. wchar_t nFontFace[128];
  130. int bBold;
  131. int bItal;
  132. float fX;
  133. float fY;
  134. float fFontSize; // [0..100] for custom messages, [0..4] for song titles
  135. float fGrowth; // applies to custom messages only
  136. int nFontSizeUsed; // height IN PIXELS
  137. float fStartTime;
  138. float fDuration;
  139. float fFadeTime; // applies to custom messages only; song title fade times are handled specially
  140. int nColorR;
  141. int nColorG;
  142. int nColorB;
  143. }
  144. td_supertext;
  145. typedef struct
  146. {
  147. wchar_t texname[256]; // ~filename, but without path or extension!
  148. LPDIRECT3DBASETEXTURE9 texptr;
  149. int w,h,d;
  150. //D3DXHANDLE texsize_param;
  151. bool bEvictable;
  152. int nAge; // only valid if bEvictable is true
  153. int nSizeInBytes; // only valid if bEvictable is true
  154. } TexInfo;
  155. typedef struct
  156. {
  157. GString texname; // just for ref
  158. D3DXHANDLE texsize_param;
  159. int w,h;
  160. } TexSizeParamInfo;
  161. typedef struct
  162. {
  163. LPDIRECT3DBASETEXTURE9 texptr;
  164. bool bBilinear;
  165. bool bWrap;
  166. } SamplerInfo;
  167. typedef struct
  168. {
  169. GString msg;
  170. bool bBold; // true == red bkg; false == black bkg
  171. float birthTime;
  172. float expireTime;
  173. int category;
  174. } ErrorMsg;
  175. typedef std::vector<ErrorMsg> ErrorMsgList;
  176. typedef std::vector<CShaderParams*> CShaderParamsList;
  177. class CShaderParams
  178. {
  179. public:
  180. // float4 handles:
  181. D3DXHANDLE rand_frame ;
  182. D3DXHANDLE rand_preset;
  183. D3DXHANDLE const_handles[24];
  184. D3DXHANDLE q_const_handles[(NUM_Q_VAR+3)/4];
  185. D3DXHANDLE rot_mat[24];
  186. typedef std::vector<TexSizeParamInfo> TexSizeParamInfoList;
  187. TexSizeParamInfoList texsize_params;
  188. // sampler stages for various PS texture bindings:
  189. //int texbind_vs;
  190. //int texbind_disk[32];
  191. //int texbind_voronoi;
  192. //...
  193. SamplerInfo m_texture_bindings[16]; // an entry for each sampler slot. These are ALIASES - DO NOT DELETE.
  194. tex_code m_texcode[16]; // if ==TEX_VS, forget the pointer - texture bound @ that stage is the double-buffered VS.
  195. void Clear();
  196. void CacheParams(LPD3DXCONSTANTTABLE pCT, bool bHardErrors);
  197. void OnTextureEvict(LPDIRECT3DBASETEXTURE9 texptr);
  198. CShaderParams();
  199. ~CShaderParams();
  200. };
  201. class VShaderInfo
  202. {
  203. public:
  204. IDirect3DVertexShader9* ptr;
  205. LPD3DXCONSTANTTABLE CT;
  206. CShaderParams params;
  207. VShaderInfo() { ptr=NULL; CT=NULL; params.Clear(); }
  208. ~VShaderInfo() { Clear(); }
  209. void Clear();
  210. };
  211. class PShaderInfo
  212. {
  213. public:
  214. IDirect3DPixelShader9* ptr;
  215. LPD3DXCONSTANTTABLE CT;
  216. CShaderParams params;
  217. PShaderInfo() { ptr=NULL; CT=NULL; params.Clear(); }
  218. ~PShaderInfo() { Clear(); }
  219. void Clear();
  220. };
  221. typedef struct
  222. {
  223. VShaderInfo vs;
  224. PShaderInfo ps;
  225. } ShaderPairInfo;
  226. typedef struct
  227. {
  228. PShaderInfo warp;
  229. PShaderInfo comp;
  230. } PShaderSet;
  231. typedef struct
  232. {
  233. VShaderInfo warp;
  234. VShaderInfo comp;
  235. } VShaderSet;
  236. /*
  237. typedef struct
  238. {
  239. void* ptr; // to IDirect3DPixelShader9 or IDirect3DVertexShader9
  240. LPD3DXCONSTANTTABLE CT;
  241. CShaderParams params;
  242. } ShaderInfo;
  243. typedef struct
  244. {
  245. ShaderInfo warp;
  246. ShaderInfo comp;
  247. } ShaderSet;
  248. */
  249. typedef struct
  250. {
  251. GString szFilename; // without path
  252. float fRatingThis;
  253. float fRatingCum;
  254. } PresetInfo;
  255. typedef std::vector<PresetInfo> PresetList;
  256. class CPlugin : public CPluginShell
  257. {
  258. public:
  259. //====[ 1. members added to create this specific example plugin: ]================================================
  260. /// CONFIG PANEL SETTINGS THAT WE'VE ADDED (TAB #2)
  261. bool m_bFirstRun;
  262. float m_fBlendTimeAuto; // blend time when preset auto-switches
  263. float m_fBlendTimeUser; // blend time when user loads a new preset
  264. float m_fTimeBetweenPresets; // <- this is in addition to m_fBlendTimeAuto
  265. float m_fTimeBetweenPresetsRand; // <- this is in addition to m_fTimeBetweenPresets
  266. bool m_bSequentialPresetOrder;
  267. bool m_bHardCutsDisabled;
  268. float m_fHardCutLoudnessThresh;
  269. float m_fHardCutHalflife;
  270. float m_fHardCutThresh;
  271. //int m_nWidth;
  272. //int m_nHeight;
  273. //int m_nDispBits;
  274. int m_nCanvasStretch; // 0=Auto, 100=None, 125 = 1.25X, 133, 150, 167, 200, 300, 400 (4X).
  275. int m_nTexSizeX; // -1 = exact match to screen; -2 = nearest power of 2.
  276. int m_nTexSizeY;
  277. float m_fAspectX;
  278. float m_fAspectY;
  279. float m_fInvAspectX;
  280. float m_fInvAspectY;
  281. int m_nTexBitsPerCh;
  282. int m_nGridX;
  283. int m_nGridY;
  284. bool m_bShowPressF1ForHelp;
  285. //char m_szMonitorName[256];
  286. bool m_bShowMenuToolTips;
  287. int m_n16BitGamma;
  288. bool m_bAutoGamma;
  289. //int m_nFpsLimit;
  290. //int m_cLeftEye3DColor[3];
  291. //int m_cRightEye3DColor[3];
  292. bool m_bEnableRating;
  293. //bool m_bInstaScan;
  294. bool m_bSongTitleAnims;
  295. float m_fSongTitleAnimDuration;
  296. float m_fTimeBetweenRandomSongTitles;
  297. float m_fTimeBetweenRandomCustomMsgs;
  298. int m_nSongTitlesSpawned;
  299. int m_nCustMsgsSpawned;
  300. //bool m_bAlways3D;
  301. //float m_fStereoSep;
  302. //bool m_bAlwaysOnTop;
  303. //bool m_bFixSlowText;
  304. //bool m_bWarningsDisabled; // messageboxes
  305. bool m_bWarningsDisabled2; // warnings/errors in upper-right corner (m_szUserMessage)
  306. //bool m_bAnisotropicFiltering;
  307. bool m_bPresetLockOnAtStartup;
  308. bool m_bPreventScollLockHandling;
  309. int m_nMaxPSVersion_ConfigPanel; // -1 = auto, 0 = disable shaders, 2 = ps_2_0, 3 = ps_3_0
  310. int m_nMaxPSVersion_DX9; // 0 = no shader support, 2 = ps_2_0, 3 = ps_3_0
  311. int m_nMaxPSVersion; // this one will be the ~min of the other two. 0/2/3.
  312. int m_nMaxImages;
  313. int m_nMaxBytes;
  314. /*
  315. char m_szFontFace[NUM_FONTS][128];
  316. int m_nFontSize[NUM_FONTS];
  317. bool m_bFontBold[NUM_FONTS];
  318. bool m_bFontItalic[NUM_FONTS];
  319. char m_szTitleFontFace[128];
  320. int m_nTitleFontSize; // percentage of screen width (0..100)
  321. bool m_bTitleFontBold;
  322. bool m_bTitleFontItalic;
  323. */
  324. HFONT m_gdi_title_font_doublesize;
  325. LPD3DXFONT m_d3dx_title_font_doublesize;
  326. // PIXEL SHADERS
  327. DWORD m_dwShaderFlags; // Shader compilation/linking flags
  328. //ID3DXFragmentLinker* m_pFragmentLinker; // Fragment linker interface
  329. //LPD3DXBUFFER m_pCompiledFragments; // Buffer containing compiled fragments
  330. LPD3DXBUFFER m_pShaderCompileErrors;
  331. VShaderSet m_fallbackShaders_vs; // *these are the only vertex shaders used for the whole app.*
  332. PShaderSet m_fallbackShaders_ps; // these are just used when the preset's pixel shaders fail to compile.
  333. PShaderSet m_shaders; // includes shader pointers and constant tables for warp & comp shaders, for cur. preset
  334. PShaderSet m_OldShaders; // includes shader pointers and constant tables for warp & comp shaders, for prev. preset
  335. PShaderSet m_NewShaders; // includes shader pointers and constant tables for warp & comp shaders, for coming preset
  336. ShaderPairInfo m_BlurShaders[2];
  337. bool m_bWarpShaderLock;
  338. bool m_bCompShaderLock;
  339. //bool LoadShaderFromFile( char* szFile, char* szFn, char* szProfile,
  340. // LPD3DXCONSTANTTABLE* ppConstTable, void** ppShader );
  341. #define SHADER_WARP 0
  342. #define SHADER_COMP 1
  343. #define SHADER_BLUR 2
  344. #define SHADER_OTHER 3
  345. bool LoadShaderFromMemory( const char* szShaderText, char* szFn, char* szProfile,
  346. LPD3DXCONSTANTTABLE* ppConstTable, void** ppShader, int shaderType, bool bHardErrors );
  347. bool RecompileVShader(const char* szShadersText, VShaderInfo *si, int shaderType, bool bHardErrors);
  348. bool RecompilePShader(const char* szShadersText, PShaderInfo *si, int shaderType, bool bHardErrors, int PSVersion);
  349. bool EvictSomeTexture();
  350. typedef std::vector<TexInfo> TexInfoList;
  351. TexInfoList m_textures;
  352. bool m_bNeedRescanTexturesDir;
  353. // vertex declarations:
  354. IDirect3DVertexDeclaration9* m_pSpriteVertDecl;
  355. IDirect3DVertexDeclaration9* m_pWfVertDecl;
  356. IDirect3DVertexDeclaration9* m_pMyVertDecl;
  357. D3DXVECTOR4 m_rand_frame; // 4 random floats (0..1); randomized once per frame; fed to pixel shaders.
  358. // RUNTIME SETTINGS THAT WE'VE ADDED
  359. float m_prev_time;
  360. bool m_bTexSizeWasAutoPow2;
  361. bool m_bTexSizeWasAutoExact;
  362. bool m_bPresetLockedByUser;
  363. bool m_bPresetLockedByCode;
  364. float m_fAnimTime;
  365. float m_fStartTime;
  366. float m_fPresetStartTime;
  367. float m_fNextPresetTime;
  368. float m_fSnapPoint;
  369. CState *m_pState; // points to current CState
  370. CState *m_pOldState; // points to previous CState
  371. CState *m_pNewState; // points to the coming CState - we're not yet blending to it b/c we're still compiling the shaders for it!
  372. int m_nLoadingPreset;
  373. wchar_t m_szLoadingPreset[MAX_PATH];
  374. float m_fLoadingPresetBlendTime;
  375. int m_nPresetsLoadedTotal; //important for texture eviction age-tracking...
  376. CState m_state_DO_NOT_USE[3]; // do not use; use pState and pOldState instead.
  377. ui_mode m_UI_mode; // can be UI_REGULAR, UI_LOAD, UI_SAVEHOW, or UI_SAVEAS
  378. #define MASH_SLOTS 5
  379. #define MASH_APPLY_DELAY_FRAMES 1
  380. int m_nMashSlot; //0..MASH_SLOTS-1
  381. //char m_szMashDir[MASH_SLOTS][MAX_PATH];
  382. int m_nMashPreset[MASH_SLOTS];
  383. int m_nLastMashChangeFrame[MASH_SLOTS];
  384. //td_playlist_entry *m_szPlaylist; // array of 128-char strings
  385. //int m_nPlaylistCurPos;
  386. //int m_nPlaylistLength;
  387. //int m_nTrackPlaying;
  388. //int m_nSongPosMS;
  389. //int m_nSongLenMS;
  390. bool m_bUserPagedUp;
  391. bool m_bUserPagedDown;
  392. float m_fMotionVectorsTempDx;
  393. float m_fMotionVectorsTempDy;
  394. td_waitstr m_waitstring;
  395. void WaitString_NukeSelection();
  396. void WaitString_Cut();
  397. void WaitString_Copy();
  398. void WaitString_Paste();
  399. void WaitString_SeekLeftWord();
  400. void WaitString_SeekRightWord();
  401. int WaitString_GetCursorColumn();
  402. int WaitString_GetLineLength();
  403. void WaitString_SeekUpOneLine();
  404. void WaitString_SeekDownOneLine();
  405. int m_nPresets; // the # of entries in the file listing. Includes directories and then files, sorted alphabetically.
  406. int m_nDirs; // the # of presets that are actually directories. Always between 0 and m_nPresets.
  407. int m_nPresetListCurPos;// Index of the currently-HIGHLIGHTED preset (the user must press Enter on it to select it).
  408. int m_nCurrentPreset; // Index of the currently-RUNNING preset.
  409. // Note that this is NOT the same as the currently-highlighted preset! (that's m_nPresetListCurPos)
  410. // Be careful - this can be -1 if the user changed dir. & a new preset hasn't been loaded yet.
  411. wchar_t m_szCurrentPresetFile[512]; // w/o path. this is always valid (unless no presets were found)
  412. PresetList m_presets;
  413. void UpdatePresetList(bool bBackground=false, bool bForce=false, bool bTryReselectCurrentPreset=true);
  414. wchar_t m_szUpdatePresetMask[MAX_PATH];
  415. bool m_bPresetListReady;
  416. //void UpdatePresetRatings();
  417. //int m_nRatingReadProgress; // equals 'm_nPresets' if all ratings are read in & ready to go; -1 if uninitialized; otherwise, it's still reading them in, and range is: [0 .. m_nPresets-1]
  418. bool m_bInitialPresetSelected;
  419. // PRESET HISTORY
  420. #define PRESET_HIST_LEN (64+2) // make this 2 more than the # you REALLY want to be able to go back.
  421. GString m_presetHistory[PRESET_HIST_LEN]; //circular
  422. int m_presetHistoryPos;
  423. int m_presetHistoryBackFence;
  424. int m_presetHistoryFwdFence;
  425. void PrevPreset(float fBlendTime);
  426. void NextPreset(float fBlendTime); // if not retracing our former steps, it will choose a random one.
  427. void OnFinishedLoadingPreset();
  428. FFT myfft;
  429. td_mysounddata mysound;
  430. // stuff for displaying text to user:
  431. //int m_nTextHeightPixels; // this is for the menu/detail font; NOT the "fancy font"
  432. //int m_nTextHeightPixels_Fancy;
  433. bool m_bShowFPS;
  434. bool m_bShowRating;
  435. bool m_bShowPresetInfo;
  436. bool m_bShowDebugInfo;
  437. bool m_bShowSongTitle;
  438. bool m_bShowSongTime;
  439. bool m_bShowSongLen;
  440. float m_fShowRatingUntilThisTime;
  441. //float m_fShowUserMessageUntilThisTime;
  442. //char m_szUserMessage[512];
  443. //bool m_bUserMessageIsError;
  444. #define ERR_ALL 0
  445. #define ERR_INIT 1 //specifically, loading a preset
  446. #define ERR_PRESET 2 //specifically, loading a preset
  447. #define ERR_MISC 3
  448. #define ERR_NOTIFY 4 // a simple notification - not an error at all. ("shuffle is now ON." etc.)
  449. // NOTE: each NOTIFY msg clears all the old NOTIFY messages!
  450. #define ERR_SCANNING_PRESETS 5
  451. ErrorMsgList m_errors;
  452. void AddError(wchar_t* szMsg, float fDuration, int category=ERR_ALL, bool bBold=true);
  453. void ClearErrors(int category=ERR_ALL); // 0=all categories
  454. char m_szDebugMessage[512];
  455. wchar_t m_szSongTitle [512];
  456. wchar_t m_szSongTitlePrev[512];
  457. //HFONT m_hfont[3]; // 0=fancy font (for song titles, preset name)
  458. // 1=legible font (the main font)
  459. // 2=tooltip font (for tooltips in the menu system)
  460. //HFONT m_htitlefont[NUM_TITLE_FONTS]; // ~25 different sizes
  461. // stuff for menu system:
  462. CMilkMenu *m_pCurMenu; // should always be valid!
  463. CMilkMenu m_menuPreset;
  464. CMilkMenu m_menuWave;
  465. CMilkMenu m_menuAugment;
  466. CMilkMenu m_menuCustomWave;
  467. CMilkMenu m_menuCustomShape;
  468. CMilkMenu m_menuMotion;
  469. CMilkMenu m_menuPost;
  470. CMilkMenu m_menuWavecode[MAX_CUSTOM_WAVES];
  471. CMilkMenu m_menuShapecode[MAX_CUSTOM_SHAPES];
  472. bool m_bShowShaderHelp;
  473. wchar_t m_szMilkdrop2Path[MAX_PATH]; // ends in a backslash
  474. wchar_t m_szMsgIniFile[MAX_PATH];
  475. wchar_t m_szImgIniFile[MAX_PATH];
  476. wchar_t m_szPresetDir[MAX_PATH];
  477. float m_fRandStart[4];
  478. // DIRECTX 9:
  479. IDirect3DTexture9 *m_lpVS[2];
  480. #define NUM_BLUR_TEX 6
  481. #if (NUM_BLUR_TEX>0)
  482. IDirect3DTexture9 *m_lpBlur[NUM_BLUR_TEX]; // each is successively 1/2 size of prev.
  483. int m_nBlurTexW[NUM_BLUR_TEX];
  484. int m_nBlurTexH[NUM_BLUR_TEX];
  485. #endif
  486. int m_nHighestBlurTexUsedThisFrame;
  487. IDirect3DTexture9 *m_lpDDSTitle; // CAREFUL: MIGHT BE NULL (if not enough mem)!
  488. int m_nTitleTexSizeX, m_nTitleTexSizeY;
  489. MYVERTEX *m_verts;
  490. MYVERTEX *m_verts_temp;
  491. td_vertinfo *m_vertinfo;
  492. int *m_indices_strip;
  493. int *m_indices_list;
  494. // for final composite grid:
  495. #define FCGSX 32 // final composite gridsize - # verts - should be EVEN.
  496. #define FCGSY 24 // final composite gridsize - # verts - should be EVEN.
  497. // # of grid *cells* is two less,
  498. // since we have redundant verts along the center line in X and Y (...for clean 'ang' interp)
  499. MYVERTEX m_comp_verts[FCGSX*FCGSY];
  500. int m_comp_indices[(FCGSX-2)*(FCGSY-2)*2*3];
  501. bool m_bMMX;
  502. //bool m_bSSE;
  503. bool m_bHasFocus;
  504. bool m_bHadFocus;
  505. bool m_bOrigScrollLockState;
  506. //bool m_bMilkdropScrollLockState; // saved when focus is lost; restored when focus is regained
  507. int m_nNumericInputMode; // NUMERIC_INPUT_MODE_CUST_MSG, NUMERIC_INPUT_MODE_SPRITE
  508. int m_nNumericInputNum;
  509. int m_nNumericInputDigits;
  510. td_custom_msg_font m_CustomMessageFont[MAX_CUSTOM_MESSAGE_FONTS];
  511. td_custom_msg m_CustomMessage[MAX_CUSTOM_MESSAGES];
  512. texmgr m_texmgr; // for user sprites
  513. td_supertext m_supertext; // **contains info about current Song Title or Custom Message.**
  514. IDirect3DTexture9 *m_tracer_tex;
  515. int m_nFramesSinceResize;
  516. char m_szShaderIncludeText[32768]; // note: this still has char 13's and 10's in it - it's never edited on screen or loaded/saved with a preset.
  517. int m_nShaderIncludeTextLen; // # of chars, not including the final NULL.
  518. char m_szDefaultWarpVShaderText[32768]; // THIS HAS CHAR 13/10 CONVERTED TO LINEFEED_CONTROL_CHAR
  519. char m_szDefaultWarpPShaderText[32768]; // THIS HAS CHAR 13/10 CONVERTED TO LINEFEED_CONTROL_CHAR
  520. char m_szDefaultCompVShaderText[32768]; // THIS HAS CHAR 13/10 CONVERTED TO LINEFEED_CONTROL_CHAR
  521. char m_szDefaultCompPShaderText[32768]; // THIS HAS CHAR 13/10 CONVERTED TO LINEFEED_CONTROL_CHAR
  522. char m_szBlurVS[32768];
  523. char m_szBlurPSX[32768];
  524. char m_szBlurPSY[32768];
  525. //const char* GetDefaultWarpShadersText() { return m_szDefaultWarpShaderText; }
  526. //const char* GetDefaultCompShadersText() { return m_szDefaultCompShaderText; }
  527. void GenWarpPShaderText(char *szShaderText, float decay, bool bWrap);
  528. void GenCompPShaderText(char *szShaderText, float brightness, float ve_alpha, float ve_zoom, int ve_orient, float hue_shader, bool bBrighten, bool bDarken, bool bSolarize, bool bInvert);
  529. //====[ 2. methods added: ]=====================================================================================
  530. void RefreshTab2(HWND hwnd);
  531. void RenderFrame(int bRedraw);
  532. void AlignWave(int nSamples);
  533. void DrawTooltip(wchar_t* str, int xR, int yB);
  534. void RandomizeBlendPattern();
  535. void GenPlasma(int x0, int x1, int y0, int y1, float dt);
  536. void LoadPerFrameEvallibVars(CState* pState);
  537. void LoadCustomWavePerFrameEvallibVars(CState* pState, int i);
  538. void LoadCustomShapePerFrameEvallibVars(CState* pState, int i, int instance);
  539. void WriteRealtimeConfig(); // called on Finish()
  540. void dumpmsg(wchar_t *s);
  541. void Randomize();
  542. void LoadRandomPreset(float fBlendTime);
  543. void LoadPreset(const wchar_t *szPresetFilename, float fBlendTime);
  544. void LoadPresetTick();
  545. void FindValidPresetDir();
  546. //char* GetConfigIniFile() { return m_szConfigIniFile; };
  547. wchar_t* GetMsgIniFile() { return m_szMsgIniFile; };
  548. wchar_t* GetPresetDir() { return m_szPresetDir; };
  549. void SavePresetAs(wchar_t *szNewFile); // overwrites the file if it was already there.
  550. void DeletePresetFile(wchar_t *szDelFile);
  551. void RenamePresetFile(wchar_t *szOldFile, wchar_t *szNewFile);
  552. void SetCurrentPresetRating(float fNewRating);
  553. void SeekToPreset(wchar_t cStartChar);
  554. bool ReversePropagatePoint(float fx, float fy, float *fx2, float *fy2);
  555. int HandleRegularKey(WPARAM wParam);
  556. bool OnResizeGraphicsWindow();
  557. bool OnResizeTextWindow();
  558. //bool InitFont();
  559. //void ToggleControlWindow(); // for Desktop Mode only
  560. //void DrawUI();
  561. void ClearGraphicsWindow(); // for windowed mode only
  562. //bool Update_Overlay();
  563. //void UpdatePlaylist();
  564. void LaunchCustomMessage(int nMsgNum);
  565. void ReadCustomMessages();
  566. void LaunchSongTitleAnim();
  567. bool RenderStringToTitleTexture();
  568. void ShowSongTitleAnim(/*IDirect3DTexture9* lpRenderTarget,*/ int w, int h, float fProgress);
  569. void DrawWave(float *fL, float *fR);
  570. void DrawCustomWaves();
  571. void DrawCustomShapes();
  572. void DrawSprites();
  573. void ComputeGridAlphaValues();
  574. //void WarpedBlit();
  575. // note: 'bFlipAlpha' just flips the alpha blending in fixed-fn pipeline - not the values for culling tiles.
  576. void WarpedBlit_Shaders (int nPass, bool bAlphaBlend, bool bFlipAlpha, bool bCullTiles, bool bFlipCulling);
  577. void WarpedBlit_NoShaders(int nPass, bool bAlphaBlend, bool bFlipAlpha, bool bCullTiles, bool bFlipCulling);
  578. void ShowToUser_Shaders (int nPass, bool bAlphaBlend, bool bFlipAlpha, bool bCullTiles, bool bFlipCulling);
  579. void ShowToUser_NoShaders();
  580. void BlurPasses();
  581. void GetSafeBlurMinMax(CState* pState, float* blur_min, float* blur_max);
  582. void RunPerFrameEquations(int code);
  583. void DrawUserSprites();
  584. void MergeSortPresets(int left, int right);
  585. void BuildMenus();
  586. void SetMenusForPresetVersion(int WarpPSVersion, int CompPSVersion);
  587. //void ResetWindowSizeOnDisk();
  588. bool LaunchSprite(int nSpriteNum, int nSlot);
  589. void KillSprite(int iSlot);
  590. void DoCustomSoundAnalysis();
  591. void DrawMotionVectors();
  592. bool LoadShaders(PShaderSet* sh, CState* pState, bool bTick);
  593. void UvToMathSpace(float u, float v, float* rad, float* ang);
  594. void ApplyShaderParams(CShaderParams* p, LPD3DXCONSTANTTABLE pCT, CState* pState);
  595. void RestoreShaderParams();
  596. bool AddNoiseTex(const wchar_t* szTexName, int size, int zoom_factor);
  597. bool AddNoiseVol(const wchar_t* szTexName, int size, int zoom_factor);
  598. //====[ 3. virtual functions: ]===========================================================================
  599. virtual void OverrideDefaults();
  600. virtual void MyPreInitialize();
  601. virtual void MyReadConfig();
  602. virtual void MyWriteConfig();
  603. virtual int AllocateMyNonDx9Stuff();
  604. virtual void CleanUpMyNonDx9Stuff();
  605. virtual int AllocateMyDX9Stuff();
  606. virtual void CleanUpMyDX9Stuff(int final_cleanup);
  607. virtual void MyRenderFn(int redraw);
  608. 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);
  609. virtual LRESULT MyWindowProc(HWND hWnd, unsigned uMsg, WPARAM wParam, LPARAM lParam);
  610. virtual BOOL MyConfigTabProc(int nPage, HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
  611. virtual void OnAltK();
  612. //====[ 4. methods from base class: ]===========================================================================
  613. /*
  614. // 'GET' METHODS
  615. // ------------------------------------------------------------
  616. int GetFrame(); // returns current frame # (starts at zero)
  617. float GetTime(); // returns current animation time (in seconds) (starts at zero) (updated once per frame)
  618. float GetFps(); // returns current estimate of framerate (frames per second)
  619. eScrMode GetScreenMode(); // returns WINDOWED, FULLSCREEN, FAKE_FULLSCREEN, or NOT_YET_KNOWN (if called before or during OverrideDefaults()).
  620. HWND GetWinampWindow(); // returns handle to Winamp main window
  621. HINSTANCE GetInstance(); // returns handle to the plugin DLL module; used for things like loading resources (dialogs, bitmaps, icons...) that are built into the plugin.
  622. char* GetPluginsDirPath(); // usually returns 'c:\\program files\\winamp\\plugins\\'
  623. char* GetConfigIniFile(); // usually returns 'c:\\program files\\winamp\\plugins\\something.ini' - filename is determined from identifiers in 'defines.h'
  624. // GET METHODS THAT ONLY WORK ONCE DIRECTX IS READY
  625. // ------------------------------------------------------------
  626. // The following 'Get' methods are only available after DirectX has been initialized.
  627. // If you call these from OverrideDefaults, MyPreInitialize, or MyReadConfig,
  628. // they will fail and return NULL (zero).
  629. // ------------------------------------------------------------
  630. HWND GetPluginWindow(); // returns handle to the plugin window. NOT persistent; can change.
  631. int GetWidth(); // returns width of plugin window interior, in pixels.
  632. int GetHeight(); // returns height of plugin window interior, in pixels.
  633. D3DFORMAT GetBackBufFormat(); // returns the pixelformat of the back buffer (probably D3DFMT_R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_X8R8G8B8, D3DFMT_R5G6B5, D3DFMT_X1R5G5B5, D3DFMT_A1R5G5B5, D3DFMT_A4R4G4B4, D3DFMT_R3G3B2, D3DFMT_A8R3G3B2, D3DFMT_X4R4G4B4, or D3DFMT_UNKNOWN)
  634. D3DFORMAT GetBackBufZFormat(); // returns the pixelformat of the back buffer's Z buffer (probably D3DFMT_D16_LOCKABLE, D3DFMT_D32, D3DFMT_D15S1, D3DFMT_D24S8, D3DFMT_D16, D3DFMT_D24X8, D3DFMT_D24X4S4, or D3DFMT_UNKNOWN)
  635. D3DCAPS8* GetCaps(); // returns a pointer to the D3DCAPS8 structer for the device. NOT persistent; can change.
  636. LPDIRECT3DDEVICE8 GetDevice(); // returns a pointer to the DirectX 8 Device. NOT persistent; can change.
  637. // FONTS & TEXT
  638. // ------------------------------------------------------------
  639. LPD3DXFONT GetFont(eFontIndex idx); // returns a handle to a D3DX font you can use to draw text on the screen
  640. int GetFontHeight(eFontIndex idx); // returns the height of the font, in pixels
  641. // MISC
  642. // ------------------------------------------------------------
  643. td_soundinfo m_sound; // a structure always containing the most recent sound analysis information; defined in pluginshell.h.
  644. void SuggestHowToFreeSomeMem(); // gives the user a 'smart' messagebox that suggests how they can free up some video memory.
  645. */
  646. //=====================================================================================================================
  647. };
  648. #endif