BWAPI
|
00001 #pragma once 00002 #include <windows.h> 00003 00004 #include "offsets.h" 00005 00006 #define CTRL_UPDATE 0x00000001 00007 #define CTRL_DISABLED 0x00000002 00008 #define CTRL_ACTIVE 0x00000004 00009 #define CTRL_VISIBLE 0x00000008 00010 #define CTRL_EVENTS 0x00000010 00011 // 0x00000020 00012 #define CTRL_BTN_CANCEL 0x00000040 00013 #define CTRL_BTN_NO_SOUND 0x00000080 00014 #define CTRL_BTN_VIRT_HOTKEY 0x00000100 00015 #define CTRL_BTN_HOTKEY 0x00000200 00016 #define CTRL_FONT_SMALLEST 0x00000400 00017 #define CTRL_FONT_LARGE 0x00000800 00018 // 0x00001000 // button & option button uses this 00019 #define CTRL_TRANSPARENT 0x00002000 00020 #define CTRL_FONT_LARGEST 0x00004000 00021 // 0x00008000 00022 #define CTRL_FONT_SMALL 0x00010000 00023 #define CTRL_PLAIN 0x00020000 00024 #define CTRL_TRANSLUCENT 0x00040000 00025 #define CTRL_BTN_DEFAULT 0x00080000 00026 #define CTRL_TOP 0x00100000 00027 #define CTRL_HALIGN_LEFT 0x00200000 00028 #define CTRL_HALIGN_RIGHT 0x00400000 00029 #define CTRL_HALIGN_CENTER 0x00800000 00030 #define CTRL_VALIGN_TOP 0x01000000 00031 #define CTRL_VALIGN_MIDDLE 0x02000000 00032 #define CTRL_VALIGN_BOTTOM 0x04000000 00033 // 0x08000000 00034 #define CTRL_DLG_NOREDRAW 0x10000000 00035 #define CTRL_REVERSE 0x10000000 00036 #define CTRL_USELOCALGRAPHIC 0x20000000 00037 #define CTRL_DLG_ACTIVE 0x40000000 00038 #define CTRL_LBOX_NORECALC 0x80000000 00039 00040 #define BW_EVN_KEYFIRST 0 00041 #define BW_EVN_KEYDOWN 0 00042 #define BW_EVN_KEYRPT 1 00043 #define BW_EVN_KEYREPEAT 1 00044 #define BW_EVN_KEYUP 2 00045 #define BW_EVN_MOUSEMOVE 3 00046 #define BW_EVN_MOUSEFIRST 3 00047 #define BW_EVN_LBUTTONDOWN 4 00048 #define BW_EVN_LBUTTONUP 5 00049 #define BW_EVN_LBUTTONDBLCLK 6 00050 #define BW_EVN_RBUTTONDOWN 7 00051 #define BW_EVN_RBUTTONUP 8 00052 #define BW_EVN_RBUTTONDBLCLK 9 00053 #define BW_EVN_MBUTTONDOWN 10 00054 #define BW_EVN_MBUTTONUP 11 00055 #define BW_EVN_MBUTTONDBLCLK 12 00056 #define BW_EVN_IDLE 13 00057 #define BW_EVN_USER 14 00058 #define BW_EVN_CHAR 15 00059 #define BW_EVN_SYSCHAR 16 00060 #define BW_EVN_WHEELUP 17 00061 #define BW_EVN_WHEELDWN 18 00062 00063 #define BW_USER_CREATE 0 00064 #define BW_USER_DESTROY 1 00065 #define BW_USER_ACTIVATE 2 00066 #define BW_USER_HOTKEY 3 00067 #define BW_USER_MOUSEMOVE 4 00068 #define BW_USER_PREV 5 00069 #define BW_USER_NEXT 6 00070 #define BW_USER_UNK_7 7 00071 #define BW_USER_UNK_8 8 00072 #define BW_USER_MOUSEENTER 9 00073 #define BW_USER_INIT 10 00074 #define BW_USER_SELECT 11 00075 #define BW_USER_UNK_12 12 00076 #define BW_USER_SHOW 13 00077 #define BW_USER_HIDE 14 00078 #define BW_USER_SCROLLUP 15 00079 #define BW_USER_SCROLLDOWN 16 00080 00081 namespace BW 00082 { 00083 namespace ctrls 00084 { 00085 enum Enum 00086 { 00087 cDLG = 0, 00088 cDFLTBTN = 1, 00089 cBUTTON = 2, 00090 cOPTION = 3, 00091 cCHKBOX = 4, 00092 cIMAGE = 5, 00093 cHSCROLL = 6, 00094 cVSCROLL = 7, 00095 cEDIT = 8, 00096 cLSTATIC = 9, 00097 cRSTATIC = 10, 00098 cCSTATIC = 11, 00099 cLIST = 12, 00100 cCOMBO = 13, 00101 cFLCBTN = 14, 00102 max = cFLCBTN 00103 }; 00104 }; 00105 00106 struct pt 00107 { 00108 WORD x; 00109 WORD y; 00110 }; 00111 00112 struct bitmap 00113 { 00114 u16 wid; 00115 u16 ht; 00116 u8 *data; 00117 }; 00118 00119 struct dlgEvent 00120 { 00121 DWORD dwUser; 00122 WORD wSelection; 00123 WORD wUnk_0x06; 00124 WORD wVirtKey; 00125 WORD wUnk_0x0A; 00126 WORD wNo; 00127 pt cursor; 00128 WORD wUnk_0x12; 00129 }; 00130 00131 struct fntChr 00132 { 00133 BYTE w, h, x, y; 00134 BYTE data[1]; 00135 }; 00136 00137 struct fntHead 00138 { 00139 DWORD magic; 00140 BYTE low, high, Xmax, Ymax; 00141 fntChr *chrs[1]; 00142 }; 00143 00144 #pragma pack(1) 00145 class dialog // BIN Dialog 00146 { 00147 public: 00148 dialog(WORD ctrlType, short index, const char *text, WORD left, WORD top, WORD width, WORD height = 0, bool (__fastcall *pfInteract)(dialog*,dlgEvent*) = NULL); 00149 ~dialog(); 00150 00151 // global functions 00152 dialog *findIndex(short wIndex); // Searches for a control that matches the specified index 00153 dialog *findDialog(const char *pszName); // Searches for a dialog that matches the name specified 00154 dialog *next(); // Retrieves the next dialog or control in the list 00155 00156 bool setFlags(DWORD dwFlags); // Sets a flag or set of flags for the control or dialog 00157 bool clearFlags(DWORD dwFlags); // Clears a flag or set of flags for the control or dialog 00158 bool hasFlags(DWORD dwFlags); // Returns true if the dialog or control has all of the specified flags enabled 00159 bool setText(char *pszStr); // Sets the text of a control, or name of a dialog 00160 char *getText(); // Retrieves the text of a control, or name of a dialog 00161 int getHotkey(); // Retrieves the hotkey for the button 00162 00163 BW::bitmap *getSourceBuffer(); // Retrieves a pointer to a bitmap structure for reading or writing to the source buffer 00164 00165 bool enable(); // Enables the dialog or control 00166 bool disable(); // Disables the dialog or control 00167 bool isDisabled(); // Returns true if the dialog or control is disabled 00168 bool show(); // Shows the dialog or control 00169 bool hide(); // Hides the dialog or control 00170 bool isVisible(); // Returns true if the dialog or control is visible 00171 00172 u16 width(); 00173 u16 height(); 00174 00175 // event-specific functions 00176 bool doEvent(WORD wEvtNum, DWORD dwUser = 0, WORD wSelect = 0, WORD wVirtKey = 0); // Calls a dialog or control's interact function by generating event info using these parameters 00177 bool defaultInteract(BW::dlgEvent *pEvent); // Calls a dialog or control's default interact function using this event info 00178 bool activate(); // Activates a control or destroys a dialog 00179 bool update(); // Updates a control or dialog, refreshing it on the screen 00180 00181 // dialog-specific functions 00182 bool isDialog(); // Returns true if the control type is a dialog 00183 dialog *child(); // Retrieves the child control from the parent dialog 00184 BW::bitmap *getDestBuffer(); // Retrieves a pointer to a bitmap structure for reading or writing to the dialog's destination buffer 00185 bool addControl(dialog *ctrl); // Adds a control to this dialog 00186 bool initialize(); // Performs the dialog's initialization and adds it to the list 00187 bool isListed(); // Checks to see if this dialog is initialized/listed 00188 bool applyDialogBackground(); // Applies the standard transparent dialog background (like game menu) 00189 bool applyWindowBackground(); // Applies the custom window background for the window dialog 00190 bool applyBlankBackground(); // Applies a completely invisible background 00191 00192 // control-specific functions 00193 dialog *parent(); // Retrieves a control's parent dialog 00194 short getIndex(); // Retrieves the index of a control 00195 bool clearFontFlags(); // Clears all font formatting flags 00196 00197 // button-specific 00198 bool isButton(); // Returns true if the control type is a button 00199 00200 // checkbox & option button 00201 bool isOption(); // Returns true if the control type is a checkbox or radio button 00202 bool isChecked(); // Returns true if the control (checkbox/radio) is selected 00203 00204 // listbox & combobox 00205 bool isList(); // Returns true if the control type is a listbox or combobox 00206 BYTE getSelectedIndex(); // Returns the index of the selected element 00207 DWORD getSelectedValue(); // Returns the value of the selected element 00208 char *getSelectedString(); // Returns the name of the selected element 00209 00210 bool setSelectedIndex(BYTE bIndex); // Sets the selected index 00211 bool setSelectedByValue(DWORD dwValue); // Sets the selected index based on the given value 00212 bool setSelectedByString(const char *pszString); // Sets the selected index based on its name 00213 00214 bool addListEntry(char *pszString, DWORD dwValue = 0, BYTE bFlags = 0); // Adds an entry to a listbox or combobox 00215 bool removeListEntry(BYTE bIndex = 0); // Removes an entry from a listbox or combobox 00216 bool clearList(); // Removes all entries from a listbox or combobox 00217 BYTE getListCount(); // Retrieves the number of elements in a listbox or combobox 00218 00219 // Data // 00220 dialog *pNext; // 0x00 00221 rect rct; // 0x04 // official name 00222 bitmap srcBits; // 0x0C // official 00223 char *pszText; // 0x14 // official name 00224 LONG lFlags; // 0x18 // official name 00225 WORD wUnk_0x1C; 00226 WORD wUnk_0x1E; 00227 short wIndex; // 0x20 // official name 00228 WORD wCtrlType; // 0x22 // official name 00229 WORD wGraphic; // 0x24 00230 /* 00231 CHECKBOX 00232 0-2 Show/Hide minimap button 00233 5 Disabled bullet 00234 6 Standard bullet 00235 7 Active bullet 00236 10 Disabled checkbox 00237 11 Standard checkbox 00238 12 Active checkbox 00239 82 Disabled alliance 00240 83 Standard Alliance 00241 85 Disabled Skull 00242 86 Standard Skull (changes to bird when checked) 00243 87 Active Skull 00244 98 Grey bullet thingy 00245 129 Disabled Messaging 00246 130 Standard Messaging 00247 131 Active Messaging 00248 136 White box + white Xmark 00249 139 Disabled Vision 00250 140 Standard Vision 00251 141 Active Vision 00252 142 Weird glowy bullet 1 00253 143 Weird glowy bullet 2 00254 00255 BUTTON 00256 100 Grey Left menu button 00257 103 Left menu button 00258 106 Highlighted Left menu button 00259 109 Grey Center menu button 00260 112 Center menu button 00261 115 Highlighted Center menu button 00262 118 Grey Right menu button 00263 121 Right menu button 00264 124 Highlighted Right menu button 00265 00266 */ 00267 LONG lUser; // 0x26 // official name 00268 bool (__fastcall *pfcnInteract)(dialog*,dlgEvent*); // 0x2A 00269 // bool __fastcall pfcnInteract(dialog *dlg, dlgEvent *evt); 00270 void (__fastcall *pfcnUpdate)(dialog*,int,int,rect*); // 0x2E 00271 // void __fastcall pfcnUpdate(dialog *dlg, int x, int y, rect *dest); 00272 union _u // 0x32 // official 00273 { 00274 struct _ctrl // official 00275 { 00276 dialog *pDlg; // 0x32 // official 00277 } ctrl; 00278 00279 struct _dlg // official 00280 { 00281 DWORD dwUnk_0x32; 00282 bitmap dstBits; // 0x36 // official 00283 dialog *pActiveElement; // 0x3E 00284 dialog *pFirstChild; // 0x42 // official 00285 dialog *pMouseElement; 00286 void *pModalFcn; // 0x4A // official 00287 } dlg; 00288 00289 struct _btn 00290 { 00291 dialog *pDlg; // 0x32 // official 00292 rect responseRct; // 0x36 00293 WORD wHighlight; // 0x3E 00294 WORD wUnknown_0x40; // padding? 00295 void *pSmk; // 0x42 00296 rect textRct; // 0x46 00297 WORD wAlignment; // 0x4E 00298 } btn; 00299 00300 struct _optn 00301 { 00302 dialog *pDlg; // 0x32 // official 00303 BYTE bEnabled; // 0x36 00304 } optn; 00305 00306 struct _edit 00307 { 00308 dialog *pDlg; // 0x32 // official 00309 BYTE bColor; // 0x36 00310 BYTE bScrollPosition; // 0x37 00311 BYTE bLeftMargin; // 0x38 00312 BYTE bTopMargin; // 0x39 00313 WORD wUnk_0x3A; // 0x3A 00314 WORD wUnk_0x3C; 00315 BYTE bCursorPos; // 0x3E 00316 } edit; 00317 00318 struct _scroll // official 00319 { 00320 dialog *pDlg; // 0x32 // official 00321 void *pfcnScrollerUpdate; // 0x36 00322 WORD nCurPos; // 0x3A 00323 WORD nMin; // 0x3C // official 00324 WORD nMax; // 0x3E // official 00325 WORD wUnk_0x40; 00326 DWORD dwScrollFlags; // 0x42 00327 BYTE bSliderSkip; // 0x46 00328 BYTE bUpdateCounter; // 0x47 00329 BYTE bSliderGraphic; // 0x48 00330 BYTE bSliderSpacing; // 0x49 00331 WORD wUnk_0x4A; 00332 DWORD dwUnk_0x4C; 00333 } scroll; 00334 00335 struct _list // official 00336 { 00337 dialog *pDlg; // 0x32 // official 00338 dialog *pScrlBar; // 0x36 00339 char **ppStrs; // 0x3A // official 00340 BYTE *pbStrFlags; // 0x3E // official 00341 /* 00342 &0x0F specifies the colour of the entry (Standard colours unless noted) 00343 0x01 = Use previous (Uses the colour of the entry BEFORE the previous one) 00344 0x09 - 0x0D = Use last (Uses the colour of the previous entry) 00345 &0xF0 specifies additional properties 00346 0x10 = Gives entry an option button 00347 */ 00348 DWORD *pdwData; // 0x42 // official 00349 BYTE bStrs; // 0x46 // official 00350 BYTE unknown_0x47; 00351 BYTE bCurrStr; // 0x48 // official 00352 BYTE bSpacing; // 0x49 00353 BYTE bItemsPerPage; // 0x4A 00354 BYTE bUnknown_0x4B; 00355 BYTE bDirection; // 0x4C 00356 BYTE bOffset; // 0x4D 00357 BYTE bSelectedIndex; // 0x4E 00358 BYTE bUnknown_0x4F; // padding? 00359 WORD wVerticalOffset; // 0x4A 00360 void *pDrawItemFcn; // 0x4C 00361 } list; 00362 } u; 00363 }; 00364 #pragma pack() 00365 dialog *CreateDialogWindow(const char *pszText, WORD wLeft, WORD wTop, WORD wWidth, WORD wHeight); // Creates a custom window dialog 00366 dialog *FindDialogGlobal(const char *pszName); // Finds a dialog in Starcraft's global list of dialogs 00367 int GetTextWidth(const char *pszString, BYTE bSize); // Retrieves the width of the text string 00368 int GetTextHeight(const char *pszString, BYTE bSize); // Retrieves the height of the text string 00369 bool BlitText(const char *pszString, bitmap *dst, int x, int y, BYTE bSize); // Draws a string of text to a destination bitmap buffer 00370 }; 00371 00372 /* 00373 List entry: Format for lists (map list for example) 00374 pointed to by list.pdwData 00375 00376 char szListEntry[65]; 00377 char szName[32]; 00378 char szDescription[316]; 00379 char szHumanSlots[35]; 00380 char szComputerSlots[35]; 00381 char szPlayers[35]; 00382 char szDimensions[35]; 00383 char szTileset[35]; 00384 DWORD dwUnk1; 00385 DWORD dwUnk2; 00386 DWORD dwUnk3; 00387 DWORD dwUnk4; 00388 DWORD dwUnk5; 00389 char szFullPath[261]; 00390 char szFileName[261]; 00391 WORD wWidth; 00392 WORD wHeight; 00393 WORD wTileset; // or numPlayers? guess 00394 BYTE bReserved; // players reserved? guess 00395 BYTE bPlayers; 00396 BYTE bComputers; // for UMS 00397 BYTE bHumans; // guess 00398 */