123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729 |
- #ifndef __NULLSOFT_DX9_EXAMPLE_PLUGIN_H__
- #define __NULLSOFT_DX9_EXAMPLE_PLUGIN_H__ 1
- #include "pluginshell.h"
- #include "md_defines.h"
- #include "menu.h"
- #include "support.h"
- #include "texmgr.h"
- #include "state.h"
- #include <vector>
- #include "gstring.h"
- #include "ns-eel2/ns-eel.h"
- extern "C" int (*warand)(void);
- 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;
- 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;
- typedef struct { float rad; float ang; float a; float c; } td_vertinfo;
- typedef char* CHARPTR;
- LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
- #define MY_FFT_SAMPLES 512
- typedef struct
- {
- float imm[3];
- float imm_rel[3];
- float avg[3];
- float avg_rel[3];
- float long_avg[3];
- float fWave[2][576];
- float fSpecLeft[MY_FFT_SAMPLES];
- } td_mysounddata;
- typedef struct
- {
- int bActive;
- int bFilterBadChars;
- int bDisplayAsCode;
- int nMaxLen;
- int nCursorPos;
- int nSelAnchorPos;
- int bOvertypeMode;
- wchar_t szText[48000];
- wchar_t szPrompt[512];
- wchar_t szToolTip[512];
- char szClipboard[48000];
- wchar_t szClipboardW[48000];
- } td_waitstr;
- typedef struct
- {
- int bBold;
- int bItal;
- wchar_t szFace[128];
- int nColorR;
- int nColorG;
- int nColorB;
- }
- td_custom_msg_font;
- enum
- {
- MD2_PS_NONE = 0,
- MD2_PS_2_0 = 2,
- MD2_PS_2_X = 3,
- MD2_PS_3_0 = 4,
- MD2_PS_4_0 = 5,
- };
- typedef struct
- {
- int nFont;
- float fSize;
- float x;
- float y;
- float randx;
- float randy;
- float growth;
- float fTime;
- float fFade;
-
-
- int bOverrideBold;
- int bOverrideItal;
- int bOverrideFace;
- int bOverrideColorR;
- int bOverrideColorG;
- int bOverrideColorB;
- int nColorR;
- int nColorG;
- int nColorB;
- int nRandR;
- int nRandG;
- int nRandB;
- int bBold;
- int bItal;
- wchar_t szFace[128];
- wchar_t szText[256];
- }
- td_custom_msg;
- typedef struct
- {
- int bRedrawSuperText;
- int bIsSongTitle;
-
- wchar_t szTextW[256];
- wchar_t nFontFace[128];
- int bBold;
- int bItal;
- float fX;
- float fY;
- float fFontSize;
- float fGrowth;
- int nFontSizeUsed;
- float fStartTime;
- float fDuration;
- float fFadeTime;
- int nColorR;
- int nColorG;
- int nColorB;
- }
- td_supertext;
- typedef struct
- {
- wchar_t texname[256];
- LPDIRECT3DBASETEXTURE9 texptr;
- int w,h,d;
-
- bool bEvictable;
- int nAge;
- int nSizeInBytes;
- } TexInfo;
- typedef struct
- {
- GString texname;
- D3DXHANDLE texsize_param;
- int w,h;
- } TexSizeParamInfo;
- typedef struct
- {
- LPDIRECT3DBASETEXTURE9 texptr;
- bool bBilinear;
- bool bWrap;
- } SamplerInfo;
- typedef struct
- {
- GString msg;
- bool bBold;
- float birthTime;
- float expireTime;
- int category;
- } ErrorMsg;
- typedef std::vector<ErrorMsg> ErrorMsgList;
- typedef std::vector<CShaderParams*> CShaderParamsList;
- class CShaderParams
- {
- public:
-
- D3DXHANDLE rand_frame ;
- D3DXHANDLE rand_preset;
- D3DXHANDLE const_handles[24];
- D3DXHANDLE q_const_handles[(NUM_Q_VAR+3)/4];
- D3DXHANDLE rot_mat[24];
-
- typedef std::vector<TexSizeParamInfo> TexSizeParamInfoList;
- TexSizeParamInfoList texsize_params;
-
-
-
-
-
-
- SamplerInfo m_texture_bindings[16];
- tex_code m_texcode[16];
- void Clear();
- void CacheParams(LPD3DXCONSTANTTABLE pCT, bool bHardErrors);
- void OnTextureEvict(LPDIRECT3DBASETEXTURE9 texptr);
- CShaderParams();
- ~CShaderParams();
- };
- class VShaderInfo
- {
- public:
- IDirect3DVertexShader9* ptr;
- LPD3DXCONSTANTTABLE CT;
- CShaderParams params;
- VShaderInfo() { ptr=NULL; CT=NULL; params.Clear(); }
- ~VShaderInfo() { Clear(); }
- void Clear();
- };
- class PShaderInfo
- {
- public:
- IDirect3DPixelShader9* ptr;
- LPD3DXCONSTANTTABLE CT;
- CShaderParams params;
- PShaderInfo() { ptr=NULL; CT=NULL; params.Clear(); }
- ~PShaderInfo() { Clear(); }
- void Clear();
- };
- typedef struct
- {
- VShaderInfo vs;
- PShaderInfo ps;
- } ShaderPairInfo;
- typedef struct
- {
- PShaderInfo warp;
- PShaderInfo comp;
- } PShaderSet;
- typedef struct
- {
- VShaderInfo warp;
- VShaderInfo comp;
- } VShaderSet;
- typedef struct
- {
- GString szFilename;
- float fRatingThis;
- float fRatingCum;
- } PresetInfo;
- typedef std::vector<PresetInfo> PresetList;
- class CPlugin : public CPluginShell
- {
- public:
-
-
-
- bool m_bFirstRun;
- float m_fBlendTimeAuto;
- float m_fBlendTimeUser;
- float m_fTimeBetweenPresets;
- float m_fTimeBetweenPresetsRand;
- bool m_bSequentialPresetOrder;
- bool m_bHardCutsDisabled;
- float m_fHardCutLoudnessThresh;
- float m_fHardCutHalflife;
- float m_fHardCutThresh;
-
-
-
- int m_nCanvasStretch;
- int m_nTexSizeX;
- int m_nTexSizeY;
- float m_fAspectX;
- float m_fAspectY;
- float m_fInvAspectX;
- float m_fInvAspectY;
- int m_nTexBitsPerCh;
- int m_nGridX;
- int m_nGridY;
- bool m_bShowPressF1ForHelp;
-
- bool m_bShowMenuToolTips;
- int m_n16BitGamma;
- bool m_bAutoGamma;
-
-
-
- bool m_bEnableRating;
-
- bool m_bSongTitleAnims;
- float m_fSongTitleAnimDuration;
- float m_fTimeBetweenRandomSongTitles;
- float m_fTimeBetweenRandomCustomMsgs;
- int m_nSongTitlesSpawned;
- int m_nCustMsgsSpawned;
-
-
-
-
-
- bool m_bWarningsDisabled2;
-
- bool m_bPresetLockOnAtStartup;
- bool m_bPreventScollLockHandling;
- int m_nMaxPSVersion_ConfigPanel;
- int m_nMaxPSVersion_DX9;
- int m_nMaxPSVersion;
- int m_nMaxImages;
- int m_nMaxBytes;
-
- HFONT m_gdi_title_font_doublesize;
- LPD3DXFONT m_d3dx_title_font_doublesize;
-
- DWORD m_dwShaderFlags;
-
-
- LPD3DXBUFFER m_pShaderCompileErrors;
- VShaderSet m_fallbackShaders_vs;
- PShaderSet m_fallbackShaders_ps;
- PShaderSet m_shaders;
- PShaderSet m_OldShaders;
- PShaderSet m_NewShaders;
- ShaderPairInfo m_BlurShaders[2];
- bool m_bWarpShaderLock;
- bool m_bCompShaderLock;
-
-
- #define SHADER_WARP 0
- #define SHADER_COMP 1
- #define SHADER_BLUR 2
- #define SHADER_OTHER 3
- bool LoadShaderFromMemory( const char* szShaderText, char* szFn, char* szProfile,
- LPD3DXCONSTANTTABLE* ppConstTable, void** ppShader, int shaderType, bool bHardErrors );
- bool RecompileVShader(const char* szShadersText, VShaderInfo *si, int shaderType, bool bHardErrors);
- bool RecompilePShader(const char* szShadersText, PShaderInfo *si, int shaderType, bool bHardErrors, int PSVersion);
- bool EvictSomeTexture();
- typedef std::vector<TexInfo> TexInfoList;
- TexInfoList m_textures;
- bool m_bNeedRescanTexturesDir;
-
- IDirect3DVertexDeclaration9* m_pSpriteVertDecl;
- IDirect3DVertexDeclaration9* m_pWfVertDecl;
- IDirect3DVertexDeclaration9* m_pMyVertDecl;
- D3DXVECTOR4 m_rand_frame;
-
- float m_prev_time;
- bool m_bTexSizeWasAutoPow2;
- bool m_bTexSizeWasAutoExact;
- bool m_bPresetLockedByUser;
- bool m_bPresetLockedByCode;
- float m_fAnimTime;
- float m_fStartTime;
- float m_fPresetStartTime;
- float m_fNextPresetTime;
- float m_fSnapPoint;
- CState *m_pState;
- CState *m_pOldState;
- CState *m_pNewState;
- int m_nLoadingPreset;
- wchar_t m_szLoadingPreset[MAX_PATH];
- float m_fLoadingPresetBlendTime;
- int m_nPresetsLoadedTotal;
- CState m_state_DO_NOT_USE[3];
- ui_mode m_UI_mode;
- #define MASH_SLOTS 5
- #define MASH_APPLY_DELAY_FRAMES 1
- int m_nMashSlot;
-
- int m_nMashPreset[MASH_SLOTS];
- int m_nLastMashChangeFrame[MASH_SLOTS];
-
-
-
-
-
-
- bool m_bUserPagedUp;
- bool m_bUserPagedDown;
- float m_fMotionVectorsTempDx;
- float m_fMotionVectorsTempDy;
- td_waitstr m_waitstring;
- void WaitString_NukeSelection();
- void WaitString_Cut();
- void WaitString_Copy();
- void WaitString_Paste();
- void WaitString_SeekLeftWord();
- void WaitString_SeekRightWord();
- int WaitString_GetCursorColumn();
- int WaitString_GetLineLength();
- void WaitString_SeekUpOneLine();
- void WaitString_SeekDownOneLine();
- int m_nPresets;
- int m_nDirs;
- int m_nPresetListCurPos;
- int m_nCurrentPreset;
-
-
- wchar_t m_szCurrentPresetFile[512];
- PresetList m_presets;
- void UpdatePresetList(bool bBackground=false, bool bForce=false, bool bTryReselectCurrentPreset=true);
- wchar_t m_szUpdatePresetMask[MAX_PATH];
- bool m_bPresetListReady;
-
-
- bool m_bInitialPresetSelected;
-
- #define PRESET_HIST_LEN (64+2)
- GString m_presetHistory[PRESET_HIST_LEN];
- int m_presetHistoryPos;
- int m_presetHistoryBackFence;
- int m_presetHistoryFwdFence;
- void PrevPreset(float fBlendTime);
- void NextPreset(float fBlendTime);
- void OnFinishedLoadingPreset();
- FFT myfft;
- td_mysounddata mysound;
-
-
-
-
- bool m_bShowFPS;
- bool m_bShowRating;
- bool m_bShowPresetInfo;
- bool m_bShowDebugInfo;
- bool m_bShowSongTitle;
- bool m_bShowSongTime;
- bool m_bShowSongLen;
- float m_fShowRatingUntilThisTime;
-
-
-
-
- #define ERR_ALL 0
- #define ERR_INIT 1
- #define ERR_PRESET 2
- #define ERR_MISC 3
- #define ERR_NOTIFY 4
-
- #define ERR_SCANNING_PRESETS 5
- ErrorMsgList m_errors;
- void AddError(wchar_t* szMsg, float fDuration, int category=ERR_ALL, bool bBold=true);
- void ClearErrors(int category=ERR_ALL);
-
- char m_szDebugMessage[512];
- wchar_t m_szSongTitle [512];
- wchar_t m_szSongTitlePrev[512];
-
-
-
-
-
- CMilkMenu *m_pCurMenu;
- CMilkMenu m_menuPreset;
- CMilkMenu m_menuWave;
- CMilkMenu m_menuAugment;
- CMilkMenu m_menuCustomWave;
- CMilkMenu m_menuCustomShape;
- CMilkMenu m_menuMotion;
- CMilkMenu m_menuPost;
- CMilkMenu m_menuWavecode[MAX_CUSTOM_WAVES];
- CMilkMenu m_menuShapecode[MAX_CUSTOM_SHAPES];
- bool m_bShowShaderHelp;
- wchar_t m_szMilkdrop2Path[MAX_PATH];
- wchar_t m_szMsgIniFile[MAX_PATH];
- wchar_t m_szImgIniFile[MAX_PATH];
- wchar_t m_szPresetDir[MAX_PATH];
- float m_fRandStart[4];
-
- IDirect3DTexture9 *m_lpVS[2];
- #define NUM_BLUR_TEX 6
- #if (NUM_BLUR_TEX>0)
- IDirect3DTexture9 *m_lpBlur[NUM_BLUR_TEX];
- int m_nBlurTexW[NUM_BLUR_TEX];
- int m_nBlurTexH[NUM_BLUR_TEX];
- #endif
- int m_nHighestBlurTexUsedThisFrame;
- IDirect3DTexture9 *m_lpDDSTitle;
- int m_nTitleTexSizeX, m_nTitleTexSizeY;
- MYVERTEX *m_verts;
- MYVERTEX *m_verts_temp;
- td_vertinfo *m_vertinfo;
- int *m_indices_strip;
- int *m_indices_list;
-
- #define FCGSX 32
- #define FCGSY 24
-
-
- MYVERTEX m_comp_verts[FCGSX*FCGSY];
- int m_comp_indices[(FCGSX-2)*(FCGSY-2)*2*3];
- bool m_bMMX;
-
- bool m_bHasFocus;
- bool m_bHadFocus;
- bool m_bOrigScrollLockState;
-
- int m_nNumericInputMode;
- int m_nNumericInputNum;
- int m_nNumericInputDigits;
- td_custom_msg_font m_CustomMessageFont[MAX_CUSTOM_MESSAGE_FONTS];
- td_custom_msg m_CustomMessage[MAX_CUSTOM_MESSAGES];
- texmgr m_texmgr;
- td_supertext m_supertext;
- IDirect3DTexture9 *m_tracer_tex;
- int m_nFramesSinceResize;
- char m_szShaderIncludeText[32768];
- int m_nShaderIncludeTextLen;
- char m_szDefaultWarpVShaderText[32768];
- char m_szDefaultWarpPShaderText[32768];
- char m_szDefaultCompVShaderText[32768];
- char m_szDefaultCompPShaderText[32768];
- char m_szBlurVS[32768];
- char m_szBlurPSX[32768];
- char m_szBlurPSY[32768];
-
-
- void GenWarpPShaderText(char *szShaderText, float decay, bool bWrap);
- 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);
-
-
- void RefreshTab2(HWND hwnd);
- void RenderFrame(int bRedraw);
- void AlignWave(int nSamples);
- void DrawTooltip(wchar_t* str, int xR, int yB);
- void RandomizeBlendPattern();
- void GenPlasma(int x0, int x1, int y0, int y1, float dt);
- void LoadPerFrameEvallibVars(CState* pState);
- void LoadCustomWavePerFrameEvallibVars(CState* pState, int i);
- void LoadCustomShapePerFrameEvallibVars(CState* pState, int i, int instance);
- void WriteRealtimeConfig();
- void dumpmsg(wchar_t *s);
- void Randomize();
- void LoadRandomPreset(float fBlendTime);
- void LoadPreset(const wchar_t *szPresetFilename, float fBlendTime);
- void LoadPresetTick();
- void FindValidPresetDir();
-
- wchar_t* GetMsgIniFile() { return m_szMsgIniFile; };
- wchar_t* GetPresetDir() { return m_szPresetDir; };
- void SavePresetAs(wchar_t *szNewFile);
- void DeletePresetFile(wchar_t *szDelFile);
- void RenamePresetFile(wchar_t *szOldFile, wchar_t *szNewFile);
- void SetCurrentPresetRating(float fNewRating);
- void SeekToPreset(wchar_t cStartChar);
- bool ReversePropagatePoint(float fx, float fy, float *fx2, float *fy2);
- int HandleRegularKey(WPARAM wParam);
- bool OnResizeGraphicsWindow();
- bool OnResizeTextWindow();
-
-
-
- void ClearGraphicsWindow();
-
-
- void LaunchCustomMessage(int nMsgNum);
- void ReadCustomMessages();
- void LaunchSongTitleAnim();
- bool RenderStringToTitleTexture();
- void ShowSongTitleAnim( int w, int h, float fProgress);
- void DrawWave(float *fL, float *fR);
- void DrawCustomWaves();
- void DrawCustomShapes();
- void DrawSprites();
- void ComputeGridAlphaValues();
-
-
- void WarpedBlit_Shaders (int nPass, bool bAlphaBlend, bool bFlipAlpha, bool bCullTiles, bool bFlipCulling);
- void WarpedBlit_NoShaders(int nPass, bool bAlphaBlend, bool bFlipAlpha, bool bCullTiles, bool bFlipCulling);
- void ShowToUser_Shaders (int nPass, bool bAlphaBlend, bool bFlipAlpha, bool bCullTiles, bool bFlipCulling);
- void ShowToUser_NoShaders();
- void BlurPasses();
- void GetSafeBlurMinMax(CState* pState, float* blur_min, float* blur_max);
- void RunPerFrameEquations(int code);
- void DrawUserSprites();
- void MergeSortPresets(int left, int right);
- void BuildMenus();
- void SetMenusForPresetVersion(int WarpPSVersion, int CompPSVersion);
-
- bool LaunchSprite(int nSpriteNum, int nSlot);
- void KillSprite(int iSlot);
- void DoCustomSoundAnalysis();
- void DrawMotionVectors();
-
- bool LoadShaders(PShaderSet* sh, CState* pState, bool bTick);
- void UvToMathSpace(float u, float v, float* rad, float* ang);
- void ApplyShaderParams(CShaderParams* p, LPD3DXCONSTANTTABLE pCT, CState* pState);
- void RestoreShaderParams();
- bool AddNoiseTex(const wchar_t* szTexName, int size, int zoom_factor);
- bool AddNoiseVol(const wchar_t* szTexName, int size, int zoom_factor);
-
- virtual void OverrideDefaults();
- virtual void MyPreInitialize();
- virtual void MyReadConfig();
- virtual void MyWriteConfig();
- virtual int AllocateMyNonDx9Stuff();
- virtual void CleanUpMyNonDx9Stuff();
- virtual int AllocateMyDX9Stuff();
- virtual void CleanUpMyDX9Stuff(int final_cleanup);
- virtual void MyRenderFn(int redraw);
- 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);
- virtual LRESULT MyWindowProc(HWND hWnd, unsigned uMsg, WPARAM wParam, LPARAM lParam);
- virtual BOOL MyConfigTabProc(int nPage, HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
- virtual void OnAltK();
-
-
-
- };
- #endif
|