r_unkn.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. LICENSE
  3. -------
  4. Copyright 2005 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. #include <windows.h>
  25. #include <commctrl.h>
  26. #include "r_defs.h"
  27. #include "resource.h"
  28. #include "../Agave/Language/api_language.h"
  29. #define MOD_NAME "Unknown Render Object"
  30. #include "r_unkn.h"
  31. char *C_UnknClass::get_desc() { static char desc[128]; return (!desc[0]?WASABI_API_LNGSTRING_BUF(IDS_UNKNOWN_RENDER_OBJECT,desc,128):desc); }
  32. void C_UnknClass::SetID(int d, char *dString) { id=d; memset(idString,0,sizeof(idString)); strcpy(idString,dString); }
  33. #define PUT_INT(y) data[pos]=(y)&255; data[pos+1]=(y>>8)&255; data[pos+2]=(y>>16)&255; data[pos+3]=(y>>24)&255
  34. #define GET_INT() (data[pos]|(data[pos+1]<<8)|(data[pos+2]<<16)|(data[pos+3]<<24))
  35. void C_UnknClass::load_config(unsigned char *data, int len)
  36. {
  37. if (configdata) GlobalFree(configdata);
  38. configdata=(char *)GlobalAlloc(GMEM_FIXED,len);
  39. memcpy(configdata,data,len);
  40. configdata_len=len;
  41. // char s[1024]="";
  42. // for (int x = 0 ;x < configdata_len; x ++)
  43. // wsprintf(s+strlen(s),"%X,",configdata[x]);
  44. // MessageBox(NULL,s,"loaded config",0);
  45. }
  46. int C_UnknClass::save_config(unsigned char *data)
  47. {
  48. int pos=0;
  49. // char s[1024]="";
  50. // for (int x = 0 ;x < configdata_len; x ++)
  51. // wsprintf(s+strlen(s),"%X,",configdata[x]);
  52. // MessageBox(NULL,s,"saving config",0);
  53. memcpy(data+pos,configdata,configdata_len);
  54. pos+=configdata_len;
  55. return pos;
  56. }
  57. C_UnknClass::C_UnknClass()
  58. {
  59. configdata=0;
  60. configdata_len=0;
  61. id=0;
  62. idString[0]=0;
  63. }
  64. C_UnknClass::~C_UnknClass()
  65. {
  66. if (configdata) GlobalFree(configdata);
  67. configdata=0;
  68. }
  69. int C_UnknClass::render(char visdata[2][2][576], int isBeat, int *framebuffer, int *fbout, int w, int h)
  70. {
  71. return 0;
  72. }
  73. static C_UnknClass *g_this;
  74. BOOL CALLBACK C_UnknClass::g_DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  75. {
  76. switch (uMsg)
  77. {
  78. case WM_INITDIALOG:
  79. {
  80. char s[512]="";
  81. if (g_this->idString[0]) wsprintf(s,"APE: %s\r\n",g_this->idString);
  82. else wsprintf(s,WASABI_API_LNGSTRING(IDS_BUILTIN_ID),g_this->id);
  83. wsprintf(s+strlen(s),WASABI_API_LNGSTRING(IDS_CONFIG_SIZE),g_this->configdata_len);
  84. SetDlgItemText(hwndDlg,IDC_EDIT1,s);
  85. }
  86. return 1;
  87. }
  88. return 0;
  89. }
  90. HWND C_UnknClass::conf(HINSTANCE hInstance, HWND hwndParent)
  91. {
  92. g_this = this;
  93. return WASABI_API_CREATEDIALOG(IDD_CFG_UNKN,hwndParent,g_DlgProc);
  94. }