src/osd/windows/ui/win32ui.c
| r995 | r996 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | M.A.M.E.32 - Multiple Arcade Machine Emulator for Win32 |
| 4 | | Win32 Portions Copyright (C) 1997-2003 Michael Soderstrom and Chris Kirmse |
| 5 | | |
| 6 | | This file is part of MAME32, and may only be used, modified and |
| 7 | | distributed under the terms of the MAME license, in "readme.txt". |
| 8 | | By continuing to use, modify or distribute this file you indicate |
| 9 | | that you have read the license and understand and accept it fully. |
| 10 | | |
| 11 | | ***************************************************************************/ |
| 12 | | |
| 13 | | /*************************************************************************** |
| 14 | | |
| 15 | | win32ui.c |
| 16 | | |
| 17 | | Win32 GUI code. |
| 18 | | |
| 19 | | Created 8/12/97 by Christopher Kirmse (ckirmse@ricochet.net) |
| 20 | | Additional code November 1997 by Jeff Miller (miller@aa.net) |
| 21 | | More July 1998 by Mike Haaland (mhaaland@hypertech.com) |
| 22 | | Added Spitters/Property Sheets/Removed Tabs/Added Tree Control in |
| 23 | | Nov/Dec 1998 - Mike Haaland |
| 24 | | |
| 25 | | ***************************************************************************/ |
| 26 | | |
| 27 | | #ifdef _MSC_VER |
| 28 | | #ifndef NONAMELESSUNION |
| 29 | | #define NONAMELESSUNION |
| 30 | | #endif |
| 31 | | #endif |
| 32 | | |
| 33 | | #define WIN32_LEAN_AND_MEAN |
| 34 | | #include <windows.h> |
| 35 | | #include <windowsx.h> |
| 36 | | #include <shellapi.h> |
| 37 | | #include <stdio.h> |
| 38 | | #include <ctype.h> |
| 39 | | #include <io.h> |
| 40 | | #include <fcntl.h> |
| 41 | | #include <commctrl.h> |
| 42 | | #include <dlgs.h> |
| 43 | | #include <string.h> |
| 44 | | #include <sys/stat.h> |
| 45 | | #include <wingdi.h> |
| 46 | | #include <time.h> |
| 47 | | #include <tchar.h> |
| 48 | | |
| 49 | | #include <driver.h> |
| 50 | | #include <osdepend.h> |
| 51 | | #include <unzip.h> |
| 52 | | |
| 53 | | #include "resource.h" |
| 54 | | #include "resource.hm" |
| 55 | | |
| 56 | | #include "screenshot.h" |
| 57 | | #include "mame32.h" |
| 58 | | #include "M32Util.h" |
| 59 | | #include "file.h" |
| 60 | | #include "audit32.h" |
| 61 | | #include "Directories.h" |
| 62 | | #include "Properties.h" |
| 63 | | #include "ColumnEdit.h" |
| 64 | | #include "picker.h" |
| 65 | | #include "tabview.h" |
| 66 | | #include "bitmask.h" |
| 67 | | #include "TreeView.h" |
| 68 | | #include "Splitters.h" |
| 69 | | #include "DirWatch.h" |
| 70 | | #include "help.h" |
| 71 | | #include "history.h" |
| 72 | | #include "m32opts.h" |
| 73 | | #include "dialogs.h" |
| 74 | | #include "state.h" |
| 75 | | #include "winmain.h" |
| 76 | | #include "winutf8.h" |
| 77 | | #include "strconv.h" |
| 78 | | #include "input.h" |
| 79 | | #include "windows/window.h" |
| 80 | | |
| 81 | | #include "DirectDraw.h" |
| 82 | | #include "DirectInput.h" |
| 83 | | #include "DIJoystick.h" /* For DIJoystick avalibility. */ |
| 84 | | |
| 85 | | #ifdef MESS |
| 86 | | #include "ui/mess32ui.h" |
| 87 | | #include "messopts.h" |
| 88 | | #endif // MESS |
| 89 | | |
| 90 | | #ifdef _MSC_VER |
| 91 | | #define snprintf _snprintf |
| 92 | | #endif |
| 93 | | |
| 94 | | #ifndef LVS_EX_LABELTIP |
| 95 | | #define LVS_EX_LABELTIP 0x00004000 // listview unfolds partly hidden labels if it does not have infotip text |
| 96 | | #endif // LVS_EX_LABELTIP |
| 97 | | |
| 98 | | // fix warning: cast does not match function type |
| 99 | | #if defined(__GNUC__) && defined(ListView_CreateDragImage) |
| 100 | | #undef ListView_CreateDragImage |
| 101 | | #endif |
| 102 | | |
| 103 | | #ifndef ListView_CreateDragImage |
| 104 | | #define ListView_CreateDragImage(hwnd, i, lpptUpLeft) \ |
| 105 | | (HIMAGELIST)(LRESULT)(int)SendMessage((hwnd), LVM_CREATEDRAGIMAGE, (WPARAM)(int)(i), (LPARAM)(LPPOINT)(lpptUpLeft)) |
| 106 | | #endif // ListView_CreateDragImage |
| 107 | | |
| 108 | | #ifndef TreeView_EditLabel |
| 109 | | #define TreeView_EditLabel(w, i) \ |
| 110 | | SNDMSG(w,TVM_EDITLABEL,0,(LPARAM)(i)) |
| 111 | | #endif // TreeView_EditLabel |
| 112 | | |
| 113 | | #ifndef HDF_SORTUP |
| 114 | | #define HDF_SORTUP 0x400 |
| 115 | | #endif // HDF_SORTUP |
| 116 | | |
| 117 | | #ifndef HDF_SORTDOWN |
| 118 | | #define HDF_SORTDOWN 0x200 |
| 119 | | #endif // HDF_SORTDOWN |
| 120 | | |
| 121 | | #ifndef LVM_SETBKIMAGEA |
| 122 | | #define LVM_SETBKIMAGEA (LVM_FIRST + 68) |
| 123 | | #endif // LVM_SETBKIMAGEA |
| 124 | | |
| 125 | | #ifndef LVM_SETBKIMAGEW |
| 126 | | #define LVM_SETBKIMAGEW (LVM_FIRST + 138) |
| 127 | | #endif // LVM_SETBKIMAGEW |
| 128 | | |
| 129 | | #ifndef LVM_GETBKIMAGEA |
| 130 | | #define LVM_GETBKIMAGEA (LVM_FIRST + 69) |
| 131 | | #endif // LVM_GETBKIMAGEA |
| 132 | | |
| 133 | | #ifndef LVM_GETBKIMAGEW |
| 134 | | #define LVM_GETBKIMAGEW (LVM_FIRST + 139) |
| 135 | | #endif // LVM_GETBKIMAGEW |
| 136 | | |
| 137 | | #ifndef LVBKIMAGE |
| 138 | | |
| 139 | | typedef struct tagLVBKIMAGEA |
| 140 | | { |
| 141 | | ULONG ulFlags; |
| 142 | | HBITMAP hbm; |
| 143 | | LPSTR pszImage; |
| 144 | | UINT cchImageMax; |
| 145 | | int xOffsetPercent; |
| 146 | | int yOffsetPercent; |
| 147 | | } LVBKIMAGEA, *LPLVBKIMAGEA; |
| 148 | | |
| 149 | | typedef struct tagLVBKIMAGEW |
| 150 | | { |
| 151 | | ULONG ulFlags; |
| 152 | | HBITMAP hbm; |
| 153 | | LPWSTR pszImage; |
| 154 | | UINT cchImageMax; |
| 155 | | int xOffsetPercent; |
| 156 | | int yOffsetPercent; |
| 157 | | } LVBKIMAGEW, *LPLVBKIMAGEW; |
| 158 | | |
| 159 | | #ifdef UNICODE |
| 160 | | #define LVBKIMAGE LVBKIMAGEW |
| 161 | | #define LPLVBKIMAGE LPLVBKIMAGEW |
| 162 | | #define LVM_SETBKIMAGE LVM_SETBKIMAGEW |
| 163 | | #define LVM_GETBKIMAGE LVM_GETBKIMAGEW |
| 164 | | #else |
| 165 | | #define LVBKIMAGE LVBKIMAGEA |
| 166 | | #define LPLVBKIMAGE LPLVBKIMAGEA |
| 167 | | #define LVM_SETBKIMAGE LVM_SETBKIMAGEA |
| 168 | | #define LVM_GETBKIMAGE LVM_GETBKIMAGEA |
| 169 | | #endif |
| 170 | | #endif |
| 171 | | |
| 172 | | #ifndef LVBKIF_SOURCE_NONE |
| 173 | | #define LVBKIF_SOURCE_NONE 0x00000000 |
| 174 | | #endif // LVBKIF_SOURCE_NONE |
| 175 | | |
| 176 | | #ifndef LVBKIF_SOURCE_HBITMAP |
| 177 | | #define LVBKIF_SOURCE_HBITMAP 0x00000001 |
| 178 | | #endif |
| 179 | | |
| 180 | | #ifndef LVBKIF_SOURCE_URL |
| 181 | | #define LVBKIF_SOURCE_URL 0x00000002 |
| 182 | | #endif // LVBKIF_SOURCE_URL |
| 183 | | |
| 184 | | #ifndef LVBKIF_SOURCE_MASK |
| 185 | | #define LVBKIF_SOURCE_MASK 0x00000003 |
| 186 | | #endif // LVBKIF_SOURCE_MASK |
| 187 | | |
| 188 | | #ifndef LVBKIF_STYLE_NORMAL |
| 189 | | #define LVBKIF_STYLE_NORMAL 0x00000000 |
| 190 | | #endif // LVBKIF_STYLE_NORMAL |
| 191 | | |
| 192 | | #ifndef LVBKIF_STYLE_TILE |
| 193 | | #define LVBKIF_STYLE_TILE 0x00000010 |
| 194 | | #endif // LVBKIF_STYLE_TILE |
| 195 | | |
| 196 | | #ifndef LVBKIF_STYLE_MASK |
| 197 | | #define LVBKIF_STYLE_MASK 0x00000010 |
| 198 | | #endif // LVBKIF_STYLE_MASK |
| 199 | | |
| 200 | | #ifndef ListView_SetBkImage |
| 201 | | #define ListView_SetBkImage(hwnd, plvbki) \ |
| 202 | | (BOOL)SNDMSG((hwnd), LVM_SETBKIMAGE, 0, (LPARAM)(plvbki)) |
| 203 | | #endif // ListView_SetBkImage |
| 204 | | |
| 205 | | #ifndef ListView_GetBkImage |
| 206 | | #define ListView_GetBkImage(hwnd, plvbki) \ |
| 207 | | (BOOL)SNDMSG((hwnd), LVM_GETBKIMAGE, 0, (LPARAM)(plvbki)) |
| 208 | | #endif // ListView_GetBkImage |
| 209 | | |
| 210 | | #define MM_PLAY_GAME (WM_APP + 15000) |
| 211 | | |
| 212 | | #define JOYGUI_MS 100 |
| 213 | | |
| 214 | | #define JOYGUI_TIMER 1 |
| 215 | | #define SCREENSHOT_TIMER 2 |
| 216 | | #define GAMEWND_TIMER 3 |
| 217 | | |
| 218 | | /* Max size of a sub-menu */ |
| 219 | | #define DBU_MIN_WIDTH 292 |
| 220 | | #define DBU_MIN_HEIGHT 190 |
| 221 | | |
| 222 | | int MIN_WIDTH = DBU_MIN_WIDTH; |
| 223 | | int MIN_HEIGHT = DBU_MIN_HEIGHT; |
| 224 | | |
| 225 | | /* Max number of bkground picture files */ |
| 226 | | #define MAX_BGFILES 100 |
| 227 | | |
| 228 | | #ifndef LVS_EX_LABELTIP |
| 229 | | #define LVS_EX_LABELTIP 0x00004000 // listview unfolds partly hidden labels if it does not have infotip text |
| 230 | | #endif |
| 231 | | |
| 232 | | #define NO_FOLDER -1 |
| 233 | | #define STATESAVE_VERSION 1 |
| 234 | | |
| 235 | | /*************************************************************************** |
| 236 | | externally defined global variables |
| 237 | | ***************************************************************************/ |
| 238 | | extern const ICONDATA g_iconData[]; |
| 239 | | extern const TCHAR g_szPlayGameString[]; |
| 240 | | extern const char g_szGameCountString[]; |
| 241 | | |
| 242 | | typedef struct _play_options play_options; |
| 243 | | struct _play_options |
| 244 | | { |
| 245 | | const char *record; // OPTION_RECORD |
| 246 | | const char *playback; // OPTION_PLAYBACK |
| 247 | | const char *state; // OPTION_STATE |
| 248 | | const char *wavwrite; // OPTION_WAVWRITE |
| 249 | | const char *mngwrite; // OPTION_MNGWRITE |
| 250 | | }; |
| 251 | | |
| 252 | | /*************************************************************************** |
| 253 | | function prototypes |
| 254 | | ***************************************************************************/ |
| 255 | | |
| 256 | | static BOOL Win32UI_init(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow); |
| 257 | | static void Win32UI_exit(void); |
| 258 | | |
| 259 | | static BOOL PumpMessage(void); |
| 260 | | static BOOL OnIdle(HWND hWnd); |
| 261 | | static void OnSize(HWND hwnd, UINT state, int width, int height); |
| 262 | | static long WINAPI MameWindowProc(HWND hwnd,UINT message,UINT wParam,LONG lParam); |
| 263 | | |
| 264 | | static void SetView(int menu_id); |
| 265 | | static void ResetListView(void); |
| 266 | | static void UpdateGameList(BOOL bUpdateRomAudit, BOOL bUpdateSampleAudit); |
| 267 | | static void DestroyIcons(void); |
| 268 | | static void ReloadIcons(void); |
| 269 | | static void PollGUIJoystick(void); |
| 270 | | static void PressKey(HWND hwnd,UINT vk); |
| 271 | | static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify); |
| 272 | | static void KeyboardKeyDown(int syskey, int vk_code, int special); |
| 273 | | static void KeyboardKeyUp(int syskey, int vk_code, int special); |
| 274 | | static void KeyboardStateClear(void); |
| 275 | | |
| 276 | | static void UpdateStatusBar(void); |
| 277 | | static BOOL PickerHitTest(HWND hWnd); |
| 278 | | static BOOL TreeViewNotify(NMHDR *nm); |
| 279 | | |
| 280 | | static void ResetBackground(char *szFile); |
| 281 | | static void RandomSelectBackground(void); |
| 282 | | static void LoadBackgroundBitmap(void); |
| 283 | | static void PaintBackgroundImage(HWND hWnd, HRGN hRgn, int x, int y); |
| 284 | | |
| 285 | | static int CLIB_DECL DriverDataCompareFunc(const void *arg1,const void *arg2); |
| 286 | | static int GamePicker_Compare(HWND hwndPicker, int index1, int index2, int sort_subitem); |
| 287 | | |
| 288 | | static void DisableSelection(void); |
| 289 | | static void EnableSelection(int nGame); |
| 290 | | |
| 291 | | static HICON GetSelectedPickItemIcon(void); |
| 292 | | static void SetRandomPickItem(void); |
| 293 | | static void PickColor(COLORREF *cDefault); |
| 294 | | |
| 295 | | static LPTREEFOLDER GetSelectedFolder(void); |
| 296 | | static HICON GetSelectedFolderIcon(void); |
| 297 | | |
| 298 | | static LRESULT CALLBACK HistoryWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 299 | | static LRESULT CALLBACK PictureFrameWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 300 | | static LRESULT CALLBACK PictureWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 301 | | static INT_PTR CALLBACK LanguageDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam); |
| 302 | | |
| 303 | | static BOOL SelectLanguageFile(HWND hWnd, TCHAR* filename); |
| 304 | | static void MamePlayRecordGame(void); |
| 305 | | static void MamePlayBackGame(void); |
| 306 | | static void MamePlayRecordWave(void); |
| 307 | | static void MamePlayRecordMNG(void); |
| 308 | | static void MameLoadState(void); |
| 309 | | static void MamePlayGameWithOptions(int nGame, const play_options *playopts); |
| 310 | | static BOOL GameCheck(void); |
| 311 | | static BOOL FolderCheck(void); |
| 312 | | |
| 313 | | static void ToggleScreenShot(void); |
| 314 | | static void AdjustMetrics(void); |
| 315 | | static void EnablePlayOptions(int nIndex, core_options *o); |
| 316 | | |
| 317 | | /* Icon routines */ |
| 318 | | static DWORD GetShellLargeIconSize(void); |
| 319 | | static DWORD GetShellSmallIconSize(void); |
| 320 | | static void CreateIcons(void); |
| 321 | | static int GetIconForDriver(int nItem); |
| 322 | | static void AddDriverIcon(int nItem,int default_icon_index); |
| 323 | | |
| 324 | | // Context Menu handlers |
| 325 | | static void UpdateMenu(HMENU hMenu); |
| 326 | | static void InitTreeContextMenu(HMENU hTreeMenu); |
| 327 | | static void InitBodyContextMenu(HMENU hBodyContextMenu); |
| 328 | | static void ToggleShowFolder(int folder); |
| 329 | | static BOOL HandleTreeContextMenu( HWND hWnd, WPARAM wParam, LPARAM lParam); |
| 330 | | static BOOL HandleScreenShotContextMenu( HWND hWnd, WPARAM wParam, LPARAM lParam); |
| 331 | | static void GamePicker_OnHeaderContextMenu(POINT pt, int nColumn); |
| 332 | | static void GamePicker_OnBodyContextMenu(POINT pt); |
| 333 | | |
| 334 | | static void InitListView(void); |
| 335 | | /* Re/initialize the ListView header columns */ |
| 336 | | static void ResetColumnDisplay(BOOL first_time); |
| 337 | | |
| 338 | | static void CopyToolTipText (LPTOOLTIPTEXT lpttt); |
| 339 | | |
| 340 | | static void ProgressBarShow(void); |
| 341 | | static void ProgressBarHide(void); |
| 342 | | static void ResizeProgressBar(void); |
| 343 | | static void ProgressBarStep(void); |
| 344 | | static void ProgressBarStepParam(int iGameIndex, int nGameCount); |
| 345 | | |
| 346 | | static HWND InitProgressBar(HWND hParent); |
| 347 | | static HWND InitToolbar(HWND hParent); |
| 348 | | static HWND InitStatusBar(HWND hParent); |
| 349 | | |
| 350 | | static LRESULT Statusbar_MenuSelect (HWND hwnd, WPARAM wParam, LPARAM lParam); |
| 351 | | |
| 352 | | static void UpdateHistory(void); |
| 353 | | |
| 354 | | |
| 355 | | void RemoveCurrentGameCustomFolder(void); |
| 356 | | void RemoveGameCustomFolder(int driver_index); |
| 357 | | |
| 358 | | void BeginListViewDrag(NM_LISTVIEW *pnmv); |
| 359 | | void MouseMoveListViewDrag(POINTS pt); |
| 360 | | void ButtonUpListViewDrag(POINTS p); |
| 361 | | |
| 362 | | void CalculateBestScreenShotRect(HWND hWnd, RECT *pRect, BOOL restrict_height); |
| 363 | | |
| 364 | | BOOL MouseHasBeenMoved(void); |
| 365 | | void SwitchFullScreenMode(void); |
| 366 | | |
| 367 | | /*************************************************************************** |
| 368 | | External variables |
| 369 | | ***************************************************************************/ |
| 370 | | |
| 371 | | /*************************************************************************** |
| 372 | | Internal structures |
| 373 | | ***************************************************************************/ |
| 374 | | |
| 375 | | /* |
| 376 | | * These next two structs represent how the icon information |
| 377 | | * is stored in an ICO file. |
| 378 | | */ |
| 379 | | typedef struct |
| 380 | | { |
| 381 | | BYTE bWidth; /* Width of the image */ |
| 382 | | BYTE bHeight; /* Height of the image (times 2) */ |
| 383 | | BYTE bColorCount; /* Number of colors in image (0 if >=8bpp) */ |
| 384 | | BYTE bReserved; /* Reserved */ |
| 385 | | WORD wPlanes; /* Color Planes */ |
| 386 | | WORD wBitCount; /* Bits per pixel */ |
| 387 | | DWORD dwBytesInRes; /* how many bytes in this resource? */ |
| 388 | | DWORD dwImageOffset; /* where in the file is this image */ |
| 389 | | } ICONDIRENTRY, *LPICONDIRENTRY; |
| 390 | | |
| 391 | | typedef struct |
| 392 | | { |
| 393 | | UINT Width, Height, Colors; /* Width, Height and bpp */ |
| 394 | | LPBYTE lpBits; /* ptr to DIB bits */ |
| 395 | | DWORD dwNumBytes; /* how many bytes? */ |
| 396 | | LPBITMAPINFO lpbi; /* ptr to header */ |
| 397 | | LPBYTE lpXOR; /* ptr to XOR image bits */ |
| 398 | | LPBYTE lpAND; /* ptr to AND image bits */ |
| 399 | | } ICONIMAGE, *LPICONIMAGE; |
| 400 | | |
| 401 | | /* Which edges of a control are anchored to the corresponding side of the parent window */ |
| 402 | | #define RA_LEFT 0x01 |
| 403 | | #define RA_RIGHT 0x02 |
| 404 | | #define RA_TOP 0x04 |
| 405 | | #define RA_BOTTOM 0x08 |
| 406 | | #define RA_ALL 0x0F |
| 407 | | |
| 408 | | #define RA_END 0 |
| 409 | | #define RA_ID 1 |
| 410 | | #define RA_HWND 2 |
| 411 | | |
| 412 | | typedef struct |
| 413 | | { |
| 414 | | int type; /* Either RA_ID or RA_HWND, to indicate which member of u is used; or RA_END |
| 415 | | to signify last entry */ |
| 416 | | union /* Can identify a child window by control id or by handle */ |
| 417 | | { |
| 418 | | int id; /* Window control id */ |
| 419 | | HWND hwnd; /* Window handle */ |
| 420 | | } u; |
| 421 | | BOOL setfont; /* Do we set this item's font? */ |
| 422 | | int action; /* What to do when control is resized */ |
| 423 | | void *subwindow; /* Points to a Resize structure for this subwindow; NULL if none */ |
| 424 | | } ResizeItem; |
| 425 | | |
| 426 | | typedef struct |
| 427 | | { |
| 428 | | RECT rect; /* Client rect of window; must be initialized before first resize */ |
| 429 | | ResizeItem* items; /* Array of subitems to be resized */ |
| 430 | | } Resize; |
| 431 | | |
| 432 | | static void ResizeWindow(HWND hParent, Resize *r); |
| 433 | | static void SetAllWindowsFont(HWND hParent, const Resize *r, HFONT hFont, BOOL bRedraw); |
| 434 | | |
| 435 | | /* List view Icon defines */ |
| 436 | | #define LG_ICONMAP_WIDTH GetSystemMetrics(SM_CXICON) |
| 437 | | #define LG_ICONMAP_HEIGHT GetSystemMetrics(SM_CYICON) |
| 438 | | #define ICONMAP_WIDTH GetSystemMetrics(SM_CXSMICON) |
| 439 | | #define ICONMAP_HEIGHT GetSystemMetrics(SM_CYSMICON) |
| 440 | | |
| 441 | | typedef struct tagPOPUPSTRING |
| 442 | | { |
| 443 | | HMENU hMenu; |
| 444 | | UINT uiString; |
| 445 | | } POPUPSTRING; |
| 446 | | |
| 447 | | #define MAX_MENUS 3 |
| 448 | | |
| 449 | | #define SPLITTER_WIDTH 4 |
| 450 | | #define MIN_VIEW_WIDTH 10 |
| 451 | | |
| 452 | | // Struct needed for Game Window Communication |
| 453 | | |
| 454 | | typedef struct |
| 455 | | { |
| 456 | | LPPROCESS_INFORMATION ProcessInfo; |
| 457 | | HWND hwndFound; |
| 458 | | } FINDWINDOWHANDLE; |
| 459 | | |
| 460 | | /*************************************************************************** |
| 461 | | Internal variables |
| 462 | | ***************************************************************************/ |
| 463 | | |
| 464 | | static HWND hMain = NULL; |
| 465 | | static HACCEL hAccel = NULL; |
| 466 | | |
| 467 | | static HWND hwndList = NULL; |
| 468 | | static HWND hTreeView = NULL; |
| 469 | | static HWND hProgWnd = NULL; |
| 470 | | static HWND hTabCtrl = NULL; |
| 471 | | |
| 472 | | static HINSTANCE hInst = NULL; |
| 473 | | |
| 474 | | static HFONT hFont = NULL; /* Font for list view */ |
| 475 | | |
| 476 | | static int optionfolder_count = 0; |
| 477 | | |
| 478 | | /* global data--know where to send messages */ |
| 479 | | static BOOL in_emulation; |
| 480 | | |
| 481 | | /* idle work at startup */ |
| 482 | | static BOOL idle_work; |
| 483 | | |
| 484 | | /* object pool in use */ |
| 485 | | static object_pool *mame32_pool; |
| 486 | | |
| 487 | | static int game_index; |
| 488 | | static int progBarStep; |
| 489 | | |
| 490 | | static BOOL bDoGameCheck = FALSE; |
| 491 | | |
| 492 | | /* Tree control variables */ |
| 493 | | static BOOL bShowTree = 1; |
| 494 | | static BOOL bShowToolBar = 1; |
| 495 | | static BOOL bShowStatusBar = 1; |
| 496 | | static BOOL bShowTabCtrl = 1; |
| 497 | | static BOOL bProgressShown = FALSE; |
| 498 | | static BOOL bListReady = FALSE; |
| 499 | | |
| 500 | | #define WM_MAME32_FILECHANGED (WM_USER + 0) |
| 501 | | #define WM_MAME32_AUDITGAME (WM_USER + 1) |
| 502 | | |
| 503 | | static PDIRWATCHER s_pWatcher; |
| 504 | | |
| 505 | | /* use a joystick subsystem in the gui? */ |
| 506 | | static struct OSDJoystick* g_pJoyGUI = NULL; |
| 507 | | |
| 508 | | /* store current keyboard state (in internal codes) here */ |
| 509 | | static input_code keyboard_state[ 2048 ]; /* __code_max #defines the number of internal key_codes */ |
| 510 | | |
| 511 | | /* table copied from windows/inputs.c */ |
| 512 | | // table entry indices |
| 513 | | #define MAME_KEY 0 |
| 514 | | #define DI_KEY 1 |
| 515 | | #define VIRTUAL_KEY 2 |
| 516 | | #define ASCII_KEY 3 |
| 517 | | |
| 518 | | // master keyboard translation table |
| 519 | | static const int win_key_trans_table[][4] = |
| 520 | | { |
| 521 | | // MAME key dinput key virtual key ascii |
| 522 | | { ITEM_ID_ESC, DIK_ESCAPE, VK_ESCAPE, 27 }, |
| 523 | | { ITEM_ID_1, DIK_1, '1', '1' }, |
| 524 | | { ITEM_ID_2, DIK_2, '2', '2' }, |
| 525 | | { ITEM_ID_3, DIK_3, '3', '3' }, |
| 526 | | { ITEM_ID_4, DIK_4, '4', '4' }, |
| 527 | | { ITEM_ID_5, DIK_5, '5', '5' }, |
| 528 | | { ITEM_ID_6, DIK_6, '6', '6' }, |
| 529 | | { ITEM_ID_7, DIK_7, '7', '7' }, |
| 530 | | { ITEM_ID_8, DIK_8, '8', '8' }, |
| 531 | | { ITEM_ID_9, DIK_9, '9', '9' }, |
| 532 | | { ITEM_ID_0, DIK_0, '0', '0' }, |
| 533 | | { ITEM_ID_BACKSPACE, DIK_BACK, VK_BACK, 8 }, |
| 534 | | { ITEM_ID_TAB, DIK_TAB, VK_TAB, 9 }, |
| 535 | | { ITEM_ID_Q, DIK_Q, 'Q', 'Q' }, |
| 536 | | { ITEM_ID_W, DIK_W, 'W', 'W' }, |
| 537 | | { ITEM_ID_E, DIK_E, 'E', 'E' }, |
| 538 | | { ITEM_ID_R, DIK_R, 'R', 'R' }, |
| 539 | | { ITEM_ID_T, DIK_T, 'T', 'T' }, |
| 540 | | { ITEM_ID_Y, DIK_Y, 'Y', 'Y' }, |
| 541 | | { ITEM_ID_U, DIK_U, 'U', 'U' }, |
| 542 | | { ITEM_ID_I, DIK_I, 'I', 'I' }, |
| 543 | | { ITEM_ID_O, DIK_O, 'O', 'O' }, |
| 544 | | { ITEM_ID_P, DIK_P, 'P', 'P' }, |
| 545 | | { ITEM_ID_OPENBRACE, DIK_LBRACKET, VK_OEM_4, '[' }, |
| 546 | | { ITEM_ID_CLOSEBRACE, DIK_RBRACKET, VK_OEM_6, ']' }, |
| 547 | | { ITEM_ID_ENTER, DIK_RETURN, VK_RETURN, 13 }, |
| 548 | | { ITEM_ID_LCONTROL, DIK_LCONTROL, VK_LCONTROL, 0 }, |
| 549 | | { ITEM_ID_A, DIK_A, 'A', 'A' }, |
| 550 | | { ITEM_ID_S, DIK_S, 'S', 'S' }, |
| 551 | | { ITEM_ID_D, DIK_D, 'D', 'D' }, |
| 552 | | { ITEM_ID_F, DIK_F, 'F', 'F' }, |
| 553 | | { ITEM_ID_G, DIK_G, 'G', 'G' }, |
| 554 | | { ITEM_ID_H, DIK_H, 'H', 'H' }, |
| 555 | | { ITEM_ID_J, DIK_J, 'J', 'J' }, |
| 556 | | { ITEM_ID_K, DIK_K, 'K', 'K' }, |
| 557 | | { ITEM_ID_L, DIK_L, 'L', 'L' }, |
| 558 | | { ITEM_ID_COLON, DIK_SEMICOLON, VK_OEM_1, ';' }, |
| 559 | | { ITEM_ID_QUOTE, DIK_APOSTROPHE, VK_OEM_7, '\'' }, |
| 560 | | { ITEM_ID_TILDE, DIK_GRAVE, VK_OEM_3, '`' }, |
| 561 | | { ITEM_ID_LSHIFT, DIK_LSHIFT, VK_LSHIFT, 0 }, |
| 562 | | { ITEM_ID_BACKSLASH, DIK_BACKSLASH, VK_OEM_5, '\\' }, |
| 563 | | { ITEM_ID_Z, DIK_Z, 'Z', 'Z' }, |
| 564 | | { ITEM_ID_X, DIK_X, 'X', 'X' }, |
| 565 | | { ITEM_ID_C, DIK_C, 'C', 'C' }, |
| 566 | | { ITEM_ID_V, DIK_V, 'V', 'V' }, |
| 567 | | { ITEM_ID_B, DIK_B, 'B', 'B' }, |
| 568 | | { ITEM_ID_N, DIK_N, 'N', 'N' }, |
| 569 | | { ITEM_ID_M, DIK_M, 'M', 'M' }, |
| 570 | | { ITEM_ID_SLASH, DIK_SLASH, VK_OEM_2, '/' }, |
| 571 | | { ITEM_ID_RSHIFT, DIK_RSHIFT, VK_RSHIFT, 0 }, |
| 572 | | { ITEM_ID_ASTERISK, DIK_MULTIPLY, VK_MULTIPLY, '*' }, |
| 573 | | { ITEM_ID_LALT, DIK_LMENU, VK_LMENU, 0 }, |
| 574 | | { ITEM_ID_SPACE, DIK_SPACE, VK_SPACE, ' ' }, |
| 575 | | { ITEM_ID_CAPSLOCK, DIK_CAPITAL, VK_CAPITAL, 0 }, |
| 576 | | { ITEM_ID_F1, DIK_F1, VK_F1, 0 }, |
| 577 | | { ITEM_ID_F2, DIK_F2, VK_F2, 0 }, |
| 578 | | { ITEM_ID_F3, DIK_F3, VK_F3, 0 }, |
| 579 | | { ITEM_ID_F4, DIK_F4, VK_F4, 0 }, |
| 580 | | { ITEM_ID_F5, DIK_F5, VK_F5, 0 }, |
| 581 | | { ITEM_ID_F6, DIK_F6, VK_F6, 0 }, |
| 582 | | { ITEM_ID_F7, DIK_F7, VK_F7, 0 }, |
| 583 | | { ITEM_ID_F8, DIK_F8, VK_F8, 0 }, |
| 584 | | { ITEM_ID_F9, DIK_F9, VK_F9, 0 }, |
| 585 | | { ITEM_ID_F10, DIK_F10, VK_F10, 0 }, |
| 586 | | { ITEM_ID_NUMLOCK, DIK_NUMLOCK, VK_NUMLOCK, 0 }, |
| 587 | | { ITEM_ID_SCRLOCK, DIK_SCROLL, VK_SCROLL, 0 }, |
| 588 | | { ITEM_ID_7_PAD, DIK_NUMPAD7, VK_NUMPAD7, 0 }, |
| 589 | | { ITEM_ID_8_PAD, DIK_NUMPAD8, VK_NUMPAD8, 0 }, |
| 590 | | { ITEM_ID_9_PAD, DIK_NUMPAD9, VK_NUMPAD9, 0 }, |
| 591 | | { ITEM_ID_MINUS_PAD, DIK_SUBTRACT, VK_SUBTRACT, 0 }, |
| 592 | | { ITEM_ID_4_PAD, DIK_NUMPAD4, VK_NUMPAD4, 0 }, |
| 593 | | { ITEM_ID_5_PAD, DIK_NUMPAD5, VK_NUMPAD5, 0 }, |
| 594 | | { ITEM_ID_6_PAD, DIK_NUMPAD6, VK_NUMPAD6, 0 }, |
| 595 | | { ITEM_ID_PLUS_PAD, DIK_ADD, VK_ADD, 0 }, |
| 596 | | { ITEM_ID_1_PAD, DIK_NUMPAD1, VK_NUMPAD1, 0 }, |
| 597 | | { ITEM_ID_2_PAD, DIK_NUMPAD2, VK_NUMPAD2, 0 }, |
| 598 | | { ITEM_ID_3_PAD, DIK_NUMPAD3, VK_NUMPAD3, 0 }, |
| 599 | | { ITEM_ID_0_PAD, DIK_NUMPAD0, VK_NUMPAD0, 0 }, |
| 600 | | { ITEM_ID_DEL_PAD, DIK_DECIMAL, VK_DECIMAL, 0 }, |
| 601 | | { ITEM_ID_F11, DIK_F11, VK_F11, 0 }, |
| 602 | | { ITEM_ID_F12, DIK_F12, VK_F12, 0 }, |
| 603 | | { ITEM_ID_F13, DIK_F13, VK_F13, 0 }, |
| 604 | | { ITEM_ID_F14, DIK_F14, VK_F14, 0 }, |
| 605 | | { ITEM_ID_F15, DIK_F15, VK_F15, 0 }, |
| 606 | | { ITEM_ID_ENTER_PAD, DIK_NUMPADENTER, VK_RETURN, 0 }, |
| 607 | | { ITEM_ID_RCONTROL, DIK_RCONTROL, VK_RCONTROL, 0 }, |
| 608 | | { ITEM_ID_SLASH_PAD, DIK_DIVIDE, VK_DIVIDE, 0 }, |
| 609 | | { ITEM_ID_PRTSCR, DIK_SYSRQ, 0, 0 }, |
| 610 | | { ITEM_ID_RALT, DIK_RMENU, VK_RMENU, 0 }, |
| 611 | | { ITEM_ID_HOME, DIK_HOME, VK_HOME, 0 }, |
| 612 | | { ITEM_ID_UP, DIK_UP, VK_UP, 0 }, |
| 613 | | { ITEM_ID_PGUP, DIK_PRIOR, VK_PRIOR, 0 }, |
| 614 | | { ITEM_ID_LEFT, DIK_LEFT, VK_LEFT, 0 }, |
| 615 | | { ITEM_ID_RIGHT, DIK_RIGHT, VK_RIGHT, 0 }, |
| 616 | | { ITEM_ID_END, DIK_END, VK_END, 0 }, |
| 617 | | { ITEM_ID_DOWN, DIK_DOWN, VK_DOWN, 0 }, |
| 618 | | { ITEM_ID_PGDN, DIK_NEXT, VK_NEXT, 0 }, |
| 619 | | { ITEM_ID_INSERT, DIK_INSERT, VK_INSERT, 0 }, |
| 620 | | { ITEM_ID_DEL, DIK_DELETE, VK_DELETE, 0 }, |
| 621 | | { ITEM_ID_LWIN, DIK_LWIN, VK_LWIN, 0 }, |
| 622 | | { ITEM_ID_RWIN, DIK_RWIN, VK_RWIN, 0 }, |
| 623 | | { ITEM_ID_MENU, DIK_APPS, VK_APPS, 0 }, |
| 624 | | { ITEM_ID_PAUSE, DIK_PAUSE, VK_PAUSE, 0 }, |
| 625 | | { ITEM_ID_CANCEL, 0, VK_CANCEL, 0 }, |
| 626 | | }; |
| 627 | | |
| 628 | | |
| 629 | | |
| 630 | | typedef struct |
| 631 | | { |
| 632 | | char name[40]; // functionality name (optional) |
| 633 | | input_seq is; // the input sequence (the keys pressed) |
| 634 | | UINT func_id; // the identifier |
| 635 | | input_seq* (*getiniptr)(void);// pointer to function to get the value from .ini file |
| 636 | | } GUISequence; |
| 637 | | |
| 638 | | static GUISequence GUISequenceControl[]= |
| 639 | | { |
| 640 | | {"gui_key_up", SEQ_DEF_0, ID_UI_UP, Get_ui_key_up }, |
| 641 | | {"gui_key_down", SEQ_DEF_0, ID_UI_DOWN, Get_ui_key_down }, |
| 642 | | {"gui_key_left", SEQ_DEF_0, ID_UI_LEFT, Get_ui_key_left }, |
| 643 | | {"gui_key_right", SEQ_DEF_0, ID_UI_RIGHT, Get_ui_key_right }, |
| 644 | | {"gui_key_start", SEQ_DEF_0, ID_UI_START, Get_ui_key_start }, |
| 645 | | {"gui_key_pgup", SEQ_DEF_0, ID_UI_PGUP, Get_ui_key_pgup }, |
| 646 | | {"gui_key_pgdwn", SEQ_DEF_0, ID_UI_PGDOWN, Get_ui_key_pgdwn }, |
| 647 | | {"gui_key_home", SEQ_DEF_0, ID_UI_HOME, Get_ui_key_home }, |
| 648 | | {"gui_key_end", SEQ_DEF_0, ID_UI_END, Get_ui_key_end }, |
| 649 | | {"gui_key_ss_change", SEQ_DEF_0, IDC_SSFRAME, Get_ui_key_ss_change }, |
| 650 | | {"gui_key_history_up", SEQ_DEF_0, ID_UI_HISTORY_UP, Get_ui_key_history_up }, |
| 651 | | {"gui_key_history_down", SEQ_DEF_0, ID_UI_HISTORY_DOWN, Get_ui_key_history_down }, |
| 652 | | |
| 653 | | {"gui_key_context_filters", SEQ_DEF_0, ID_CONTEXT_FILTERS, Get_ui_key_context_filters }, |
| 654 | | {"gui_key_select_random", SEQ_DEF_0, ID_CONTEXT_SELECT_RANDOM, Get_ui_key_select_random }, |
| 655 | | {"gui_key_game_audit", SEQ_DEF_0, ID_GAME_AUDIT, Get_ui_key_game_audit }, |
| 656 | | {"gui_key_game_properties", SEQ_DEF_0, ID_GAME_PROPERTIES, Get_ui_key_game_properties }, |
| 657 | | {"gui_key_help_contents", SEQ_DEF_0, ID_HELP_CONTENTS, Get_ui_key_help_contents }, |
| 658 | | {"gui_key_update_gamelist", SEQ_DEF_0, ID_UPDATE_GAMELIST, Get_ui_key_update_gamelist }, |
| 659 | | {"gui_key_view_folders", SEQ_DEF_0, ID_VIEW_FOLDERS, Get_ui_key_view_folders }, |
| 660 | | {"gui_key_view_fullscreen", SEQ_DEF_0, ID_VIEW_FULLSCREEN, Get_ui_key_view_fullscreen }, |
| 661 | | {"gui_key_view_pagetab", SEQ_DEF_0, ID_VIEW_PAGETAB, Get_ui_key_view_pagetab }, |
| 662 | | {"gui_key_view_picture_area", SEQ_DEF_0, ID_VIEW_PICTURE_AREA, Get_ui_key_view_picture_area }, |
| 663 | | {"gui_key_view_status", SEQ_DEF_0, ID_VIEW_STATUS, Get_ui_key_view_status }, |
| 664 | | {"gui_key_view_toolbars", SEQ_DEF_0, ID_VIEW_TOOLBARS, Get_ui_key_view_toolbars }, |
| 665 | | |
| 666 | | {"gui_key_view_tab_cabinet", SEQ_DEF_0, ID_VIEW_TAB_CABINET, Get_ui_key_view_tab_cabinet }, |
| 667 | | {"gui_key_view_tab_cpanel", SEQ_DEF_0, ID_VIEW_TAB_CONTROL_PANEL, Get_ui_key_view_tab_cpanel }, |
| 668 | | {"gui_key_view_tab_flyer", SEQ_DEF_0, ID_VIEW_TAB_FLYER, Get_ui_key_view_tab_flyer }, |
| 669 | | {"gui_key_view_tab_history", SEQ_DEF_0, ID_VIEW_TAB_HISTORY, Get_ui_key_view_tab_history }, |
| 670 | | {"gui_key_view_tab_marquee", SEQ_DEF_0, ID_VIEW_TAB_MARQUEE, Get_ui_key_view_tab_marquee }, |
| 671 | | {"gui_key_view_tab_screenshot", SEQ_DEF_0, ID_VIEW_TAB_SCREENSHOT, Get_ui_key_view_tab_screenshot }, |
| 672 | | {"gui_key_view_tab_title", SEQ_DEF_0, ID_VIEW_TAB_TITLE, Get_ui_key_view_tab_title }, |
| 673 | | {"gui_key_quit", SEQ_DEF_0, ID_FILE_EXIT, Get_ui_key_quit }, |
| 674 | | }; |
| 675 | | |
| 676 | | |
| 677 | | #define NUM_GUI_SEQUENCES (sizeof(GUISequenceControl) / sizeof(GUISequenceControl[0])) |
| 678 | | |
| 679 | | |
| 680 | | static UINT lastColumnClick = 0; |
| 681 | | static WNDPROC g_lpHistoryWndProc = NULL; |
| 682 | | static WNDPROC g_lpPictureFrameWndProc = NULL; |
| 683 | | static WNDPROC g_lpPictureWndProc = NULL; |
| 684 | | |
| 685 | | static POPUPSTRING popstr[MAX_MENUS + 1]; |
| 686 | | |
| 687 | | /* Tool and Status bar variables */ |
| 688 | | static HWND hStatusBar = 0; |
| 689 | | static HWND hToolBar = 0; |
| 690 | | |
| 691 | | /* Column Order as Displayed */ |
| 692 | | static BOOL oldControl = FALSE; |
| 693 | | static BOOL xpControl = FALSE; |
| 694 | | |
| 695 | | /* Used to recalculate the main window layout */ |
| 696 | | static int bottomMargin; |
| 697 | | static int topMargin; |
| 698 | | static int have_history = FALSE; |
| 699 | | |
| 700 | | static BOOL have_selection = FALSE; |
| 701 | | |
| 702 | | static HBITMAP hMissing_bitmap; |
| 703 | | |
| 704 | | /* Icon variables */ |
| 705 | | static HIMAGELIST hLarge = NULL; |
| 706 | | static HIMAGELIST hSmall = NULL; |
| 707 | | static HIMAGELIST hHeaderImages = NULL; |
| 708 | | static int *icon_index = NULL; /* for custom per-game icons */ |
| 709 | | |
| 710 | | static TBBUTTON tbb[] = |
| 711 | | { |
| 712 | | {0, ID_VIEW_FOLDERS, TBSTATE_ENABLED, TBSTYLE_CHECK, {0, 0}, 0, 0}, |
| 713 | | {1, ID_VIEW_PICTURE_AREA,TBSTATE_ENABLED, TBSTYLE_CHECK, {0, 0}, 0, 1}, |
| 714 | | {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0}, |
| 715 | | {2, ID_VIEW_LARGE_ICON, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, {0, 0}, 0, 2}, |
| 716 | | {3, ID_VIEW_SMALL_ICON, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, {0, 0}, 0, 3}, |
| 717 | | {4, ID_VIEW_LIST_MENU, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, {0, 0}, 0, 4}, |
| 718 | | {5, ID_VIEW_DETAIL, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, {0, 0}, 0, 5}, |
| 719 | | {6, ID_VIEW_GROUPED, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, {0, 0}, 0, 6}, |
| 720 | | {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0}, |
| 721 | | {7, ID_HELP_ABOUT, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 7}, |
| 722 | | {8, ID_HELP_CONTENTS, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 8} |
| 723 | | }; |
| 724 | | |
| 725 | | #define NUM_TOOLBUTTONS (sizeof(tbb) / sizeof(tbb[0])) |
| 726 | | |
| 727 | | #define NUM_TOOLTIPS 8 |
| 728 | | |
| 729 | | static const TCHAR szTbStrings[NUM_TOOLTIPS + 1][30] = |
| 730 | | { |
| 731 | | TEXT("Toggle Folder List"), |
| 732 | | TEXT("Toggle Screen Shot"), |
| 733 | | TEXT("Large Icons"), |
| 734 | | TEXT("Small Icons"), |
| 735 | | TEXT("List"), |
| 736 | | TEXT("Details"), |
| 737 | | TEXT("Grouped"), |
| 738 | | TEXT("About"), |
| 739 | | TEXT("Help") |
| 740 | | }; |
| 741 | | |
| 742 | | static int CommandToString[] = |
| 743 | | { |
| 744 | | ID_VIEW_FOLDERS, |
| 745 | | ID_VIEW_PICTURE_AREA, |
| 746 | | ID_VIEW_LARGE_ICON, |
| 747 | | ID_VIEW_SMALL_ICON, |
| 748 | | ID_VIEW_LIST_MENU, |
| 749 | | ID_VIEW_DETAIL, |
| 750 | | ID_VIEW_GROUPED, |
| 751 | | ID_HELP_ABOUT, |
| 752 | | ID_HELP_CONTENTS, |
| 753 | | -1 |
| 754 | | }; |
| 755 | | |
| 756 | | static const int s_nPickers[] = |
| 757 | | { |
| 758 | | IDC_LIST |
| 759 | | #ifdef MESS |
| 760 | | ,IDC_SWLIST |
| 761 | | #endif |
| 762 | | }; |
| 763 | | |
| 764 | | /* How to resize main window */ |
| 765 | | static ResizeItem main_resize_items[] = |
| 766 | | { |
| 767 | | { RA_HWND, { 0 }, FALSE, RA_LEFT | RA_RIGHT | RA_TOP, NULL }, |
| 768 | | { RA_HWND, { 0 }, FALSE, RA_LEFT | RA_RIGHT | RA_BOTTOM, NULL }, |
| 769 | | { RA_ID, { IDC_DIVIDER }, FALSE, RA_LEFT | RA_RIGHT | RA_TOP, NULL }, |
| 770 | | { RA_ID, { IDC_TREE }, TRUE, RA_LEFT | RA_BOTTOM | RA_TOP, NULL }, |
| 771 | | { RA_ID, { IDC_LIST }, TRUE, RA_ALL, NULL }, |
| 772 | | { RA_ID, { IDC_SPLITTER }, FALSE, RA_LEFT | RA_BOTTOM | RA_TOP, NULL }, |
| 773 | | { RA_ID, { IDC_SPLITTER2 },FALSE, RA_RIGHT | RA_BOTTOM | RA_TOP, NULL }, |
| 774 | | { RA_ID, { IDC_SSFRAME }, FALSE, RA_RIGHT | RA_BOTTOM | RA_TOP, NULL }, |
| 775 | | { RA_ID, { IDC_SSPICTURE },FALSE, RA_RIGHT | RA_BOTTOM | RA_TOP, NULL }, |
| 776 | | { RA_ID, { IDC_HISTORY }, TRUE, RA_RIGHT | RA_BOTTOM | RA_TOP, NULL }, |
| 777 | | { RA_ID, { IDC_SSTAB }, FALSE, RA_RIGHT | RA_TOP, NULL }, |
| 778 | | #ifdef MESS |
| 779 | | { RA_ID, { IDC_SWLIST }, TRUE, RA_RIGHT | RA_BOTTOM | RA_TOP, NULL }, |
| 780 | | { RA_ID, { IDC_SPLITTER3 },FALSE, RA_RIGHT | RA_BOTTOM | RA_TOP, NULL }, |
| 781 | | #endif /* MESS */ |
| 782 | | { RA_END, { 0 }, FALSE, 0, NULL } |
| 783 | | }; |
| 784 | | |
| 785 | | static Resize main_resize = { {0, 0, 0, 0}, main_resize_items }; |
| 786 | | |
| 787 | | /* last directory for common file dialogs */ |
| 788 | | TCHAR last_directory[MAX_PATH]; |
| 789 | | |
| 790 | | /* system-wide window message sent out with an ATOM of the current game name |
| 791 | | each time it changes */ |
| 792 | | static UINT g_mame32_message = 0; |
| 793 | | static BOOL g_bDoBroadcast = FALSE; |
| 794 | | |
| 795 | | static BOOL use_gui_romloading = FALSE; |
| 796 | | |
| 797 | | static BOOL g_listview_dragging = FALSE; |
| 798 | | HIMAGELIST himl_drag; |
| 799 | | int game_dragged; /* which game started the drag */ |
| 800 | | HTREEITEM prev_drag_drop_target; /* which tree view item we're currently highlighting */ |
| 801 | | |
| 802 | | static BOOL g_in_treeview_edit = FALSE; |
| 803 | | |
| 804 | | typedef struct |
| 805 | | { |
| 806 | | const char *name; |
| 807 | | int index; |
| 808 | | } driver_data_type; |
| 809 | | static driver_data_type *sorted_drivers; |
| 810 | | |
| 811 | | /*************************************************************************** |
| 812 | | Global variables |
| 813 | | ***************************************************************************/ |
| 814 | | |
| 815 | | /* Background Image handles also accessed from TreeView.c */ |
| 816 | | static HPALETTE hPALbg = 0; |
| 817 | | static HBITMAP hBackground = 0; |
| 818 | | static MYBITMAPINFO bmDesc; |
| 819 | | |
| 820 | | /* List view Column text */ |
| 821 | | LPCTSTR column_names[COLUMN_MAX] = |
| 822 | | { |
| 823 | | #ifdef MESS |
| 824 | | TEXT("System"), |
| 825 | | TEXT("Bios"), |
| 826 | | #else |
| 827 | | TEXT("Game"), |
| 828 | | TEXT("ROMs"), |
| 829 | | #endif |
| 830 | | TEXT("Samples"), |
| 831 | | TEXT("Directory"), |
| 832 | | TEXT("Type"), |
| 833 | | TEXT("Trackball"), |
| 834 | | TEXT("Played"), |
| 835 | | TEXT("Manufacturer"), |
| 836 | | TEXT("Year"), |
| 837 | | TEXT("Clone Of"), |
| 838 | | TEXT("Source"), |
| 839 | | TEXT("Play Time") |
| 840 | | }; |
| 841 | | |
| 842 | | /*************************************************************************** |
| 843 | | Message Macros |
| 844 | | ***************************************************************************/ |
| 845 | | |
| 846 | | #ifndef StatusBar_GetItemRect |
| 847 | | #define StatusBar_GetItemRect(hWnd, iPart, lpRect) \ |
| 848 | | SendMessage(hWnd, SB_GETRECT, (WPARAM) iPart, (LPARAM) (LPRECT) lpRect) |
| 849 | | #endif |
| 850 | | |
| 851 | | #ifndef ToolBar_CheckButton |
| 852 | | #define ToolBar_CheckButton(hWnd, idButton, fCheck) \ |
| 853 | | SendMessage(hWnd, TB_CHECKBUTTON, (WPARAM)idButton, (LPARAM)MAKELONG(fCheck, 0)) |
| 854 | | #endif |
| 855 | | |
| 856 | | /*************************************************************************** |
| 857 | | External functions |
| 858 | | ***************************************************************************/ |
| 859 | | |
| 860 | | static void CopyOptions(core_options *pDestOpts, core_options *pSourceOpts) |
| 861 | | { |
| 862 | | options_enumerator *enumerator; |
| 863 | | const char *option_name; |
| 864 | | const char *option_value; |
| 865 | | |
| 866 | | enumerator = options_enumerator_begin(pSourceOpts); |
| 867 | | if (enumerator != NULL) |
| 868 | | { |
| 869 | | while((option_name = options_enumerator_next(enumerator)) != NULL) |
| 870 | | { |
| 871 | | option_value = options_get_string(pSourceOpts, option_name); |
| 872 | | if (option_value != NULL) |
| 873 | | { |
| 874 | | dprintf("CopyOptions(): Copying %s = \"%s\"\n", option_name, option_value); |
| 875 | | options_set_string(pDestOpts, option_name, option_value, OPTION_PRIORITY_CMDLINE); |
| 876 | | } |
| 877 | | } |
| 878 | | options_enumerator_free(enumerator); |
| 879 | | } |
| 880 | | } |
| 881 | | |
| 882 | | |
| 883 | | |
| 884 | | static BOOL WaitWithMessageLoop(HANDLE hEvent) |
| 885 | | { |
| 886 | | DWORD dwRet; |
| 887 | | MSG msg; |
| 888 | | |
| 889 | | while (1) |
| 890 | | { |
| 891 | | dwRet = MsgWaitForMultipleObjects(1, &hEvent, FALSE, INFINITE, QS_ALLINPUT); |
| 892 | | |
| 893 | | if (dwRet == WAIT_OBJECT_0) |
| 894 | | return TRUE; |
| 895 | | |
| 896 | | if (dwRet != WAIT_OBJECT_0 + 1) |
| 897 | | break; |
| 898 | | |
| 899 | | while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) |
| 900 | | { |
| 901 | | TranslateMessage(&msg); |
| 902 | | DispatchMessage(&msg); |
| 903 | | if (WaitForSingleObject(hEvent, 0) == WAIT_OBJECT_0) |
| 904 | | return TRUE; |
| 905 | | } |
| 906 | | } |
| 907 | | return FALSE; |
| 908 | | } |
| 909 | | |
| 910 | | static DWORD RunMAME(int nGameIndex, const play_options *playopts) |
| 911 | | { |
| 912 | | DWORD dwExitCode = 0; |
| 913 | | core_options *pOpts; |
| 914 | | core_options *opts; |
| 915 | | LPTREEFOLDER folder; |
| 916 | | int i; |
| 917 | | |
| 918 | | // set up MAME options |
| 919 | | opts = mame_options_init(mame_win_options); |
| 920 | | |
| 921 | | // retrieve the options we're going to pass |
| 922 | | folder = GetFolderByName(FOLDER_SOURCE, GetDriverFilename(nGameIndex)); |
| 923 | | if (folder) |
| 924 | | pOpts = GetGameOptions(nGameIndex, folder->m_nFolderId); |
| 925 | | else |
| 926 | | pOpts = GetGameOptions(nGameIndex, NO_FOLDER); |
| 927 | | |
| 928 | | #ifdef MESS |
| 929 | | // add MESS specific device options |
| 930 | | mess_add_device_options(opts, drivers[nGameIndex]); |
| 931 | | #endif // MESS |
| 932 | | |
| 933 | | // load MAME options |
| 934 | | CopyOptions(opts, Mame32Global()); |
| 935 | | CopyOptions(opts, pOpts); |
| 936 | | |
| 937 | | // load specified play options |
| 938 | | if (playopts != NULL) |
| 939 | | { |
| 940 | | if (playopts->record != NULL) |
| 941 | | options_set_string(opts, OPTION_RECORD, playopts->record, OPTION_PRIORITY_CMDLINE); |
| 942 | | if (playopts->playback != NULL) |
| 943 | | options_set_string(opts, OPTION_PLAYBACK, playopts->playback, OPTION_PRIORITY_CMDLINE); |
| 944 | | if (playopts->state != NULL) |
| 945 | | options_set_string(opts, OPTION_STATE, playopts->state, OPTION_PRIORITY_CMDLINE); |
| 946 | | if (playopts->wavwrite != NULL) |
| 947 | | options_set_string(opts, OPTION_WAVWRITE, playopts->wavwrite, OPTION_PRIORITY_CMDLINE); |
| 948 | | if (playopts->mngwrite != NULL) |
| 949 | | options_set_string(opts, OPTION_MNGWRITE, playopts->mngwrite, OPTION_PRIORITY_CMDLINE); |
| 950 | | } |
| 951 | | |
| 952 | | // prepare MAME32 to run the game |
| 953 | | ShowWindow(hMain, SW_HIDE); |
| 954 | | for (i = 0; i < ARRAY_LENGTH(s_nPickers); i++) |
| 955 | | Picker_ClearIdle(GetDlgItem(hMain, s_nPickers[i])); |
| 956 | | |
| 957 | | // run the emulation |
| 958 | | options_set_string(opts, OPTION_GAMENAME, drivers[nGameIndex]->name, OPTION_PRIORITY_CMDLINE); |
| 959 | | mame_execute(opts); |
| 960 | | |
| 961 | | // the emulation is complete; continue |
| 962 | | for (i = 0; i < ARRAY_LENGTH(s_nPickers); i++) |
| 963 | | Picker_ResetIdle(GetDlgItem(hMain, s_nPickers[i])); |
| 964 | | ShowWindow(hMain, SW_SHOW); |
| 965 | | SetForegroundWindow(hMain); |
| 966 | | |
| 967 | | // close out MAME options |
| 968 | | options_free(opts); |
| 969 | | |
| 970 | | // NPW 16-Apr-2007 - God I hate this hack |
| 971 | | if (GetGameUsesDefaults(nGameIndex)) |
| 972 | | ResetGameOptions(nGameIndex); |
| 973 | | |
| 974 | | return dwExitCode; |
| 975 | | } |
| 976 | | |
| 977 | | int Mame32Main(HINSTANCE hInstance, |
| 978 | | LPSTR lpCmdLine, |
| 979 | | int nCmdShow) |
| 980 | | { |
| 981 | | dprintf("MAME32 starting\n"); |
| 982 | | |
| 983 | | use_gui_romloading = TRUE; |
| 984 | | |
| 985 | | if (__argc != 1) |
| 986 | | { |
| 987 | | /* Rename main because gcc will use it instead of WinMain even with -mwindows */ |
| 988 | | extern int DECL_SPEC mame_main(int, char**); |
| 989 | | exit(mame_main(__argc, __argv)); |
| 990 | | } |
| 991 | | if (!Win32UI_init(hInstance, lpCmdLine, nCmdShow)) |
| 992 | | return 1; |
| 993 | | |
| 994 | | // pump message, but quit on WM_QUIT |
| 995 | | while(PumpMessage()) |
| 996 | | ; |
| 997 | | |
| 998 | | Win32UI_exit(); |
| 999 | | return 0; |
| 1000 | | } |
| 1001 | | |
| 1002 | | |
| 1003 | | HWND GetMainWindow(void) |
| 1004 | | { |
| 1005 | | return hMain; |
| 1006 | | } |
| 1007 | | |
| 1008 | | HWND GetTreeView(void) |
| 1009 | | { |
| 1010 | | return hTreeView; |
| 1011 | | } |
| 1012 | | |
| 1013 | | HIMAGELIST GetLargeImageList(void) |
| 1014 | | { |
| 1015 | | return hLarge; |
| 1016 | | } |
| 1017 | | |
| 1018 | | HIMAGELIST GetSmallImageList(void) |
| 1019 | | { |
| 1020 | | return hSmall; |
| 1021 | | } |
| 1022 | | |
| 1023 | | object_pool *GetMame32MemoryPool(void) |
| 1024 | | { |
| 1025 | | return mame32_pool; |
| 1026 | | } |
| 1027 | | |
| 1028 | | void GetRealColumnOrder(int order[]) |
| 1029 | | { |
| 1030 | | int tmpOrder[COLUMN_MAX]; |
| 1031 | | int nColumnMax; |
| 1032 | | int i; |
| 1033 | | |
| 1034 | | nColumnMax = Picker_GetNumColumns(hwndList); |
| 1035 | | |
| 1036 | | /* Get the Column Order and save it */ |
| 1037 | | if (!oldControl) |
| 1038 | | { |
| 1039 | | ListView_GetColumnOrderArray(hwndList, nColumnMax, tmpOrder); |
| 1040 | | |
| 1041 | | for (i = 0; i < nColumnMax; i++) |
| 1042 | | { |
| 1043 | | order[i] = Picker_GetRealColumnFromViewColumn(hwndList, tmpOrder[i]); |
| 1044 | | } |
| 1045 | | } |
| 1046 | | } |
| 1047 | | |
| 1048 | | /* |
| 1049 | | * PURPOSE: Format raw data read from an ICO file to an HICON |
| 1050 | | * PARAMS: PBYTE ptrBuffer - Raw data from an ICO file |
| 1051 | | * UINT nBufferSize - Size of buffer ptrBuffer |
| 1052 | | * RETURNS: HICON - handle to the icon, NULL for failure |
| 1053 | | * History: July '95 - Created |
| 1054 | | * March '00- Seriously butchered from MSDN for mine own |
| 1055 | | * purposes, sayeth H0ek. |
| 1056 | | */ |
| 1057 | | HICON FormatICOInMemoryToHICON(PBYTE ptrBuffer, UINT nBufferSize) |
| 1058 | | { |
| 1059 | | ICONIMAGE IconImage; |
| 1060 | | LPICONDIRENTRY lpIDE = NULL; |
| 1061 | | UINT nNumImages; |
| 1062 | | UINT nBufferIndex = 0; |
| 1063 | | HICON hIcon = NULL; |
| 1064 | | |
| 1065 | | /* Is there a WORD? */ |
| 1066 | | if (nBufferSize < sizeof(WORD)) |
| 1067 | | { |
| 1068 | | return NULL; |
| 1069 | | } |
| 1070 | | |
| 1071 | | /* Was it 'reserved' ? (ie 0) */ |
| 1072 | | if ((WORD)(ptrBuffer[nBufferIndex]) != 0) |
| 1073 | | { |
| 1074 | | return NULL; |
| 1075 | | } |
| 1076 | | |
| 1077 | | nBufferIndex += sizeof(WORD); |
| 1078 | | |
| 1079 | | /* Is there a WORD? */ |
| 1080 | | if (nBufferSize - nBufferIndex < sizeof(WORD)) |
| 1081 | | { |
| 1082 | | return NULL; |
| 1083 | | } |
| 1084 | | |
| 1085 | | /* Was it type 1? */ |
| 1086 | | if ((WORD)(ptrBuffer[nBufferIndex]) != 1) |
| 1087 | | { |
| 1088 | | return NULL; |
| 1089 | | } |
| 1090 | | |
| 1091 | | nBufferIndex += sizeof(WORD); |
| 1092 | | |
| 1093 | | /* Is there a WORD? */ |
| 1094 | | if (nBufferSize - nBufferIndex < sizeof(WORD)) |
| 1095 | | { |
| 1096 | | return NULL; |
| 1097 | | } |
| 1098 | | |
| 1099 | | /* Then that's the number of images in the ICO file */ |
| 1100 | | nNumImages = (WORD)(ptrBuffer[nBufferIndex]); |
| 1101 | | |
| 1102 | | /* Is there at least one icon in the file? */ |
| 1103 | | if ( nNumImages < 1 ) |
| 1104 | | { |
| 1105 | | return NULL; |
| 1106 | | } |
| 1107 | | |
| 1108 | | nBufferIndex += sizeof(WORD); |
| 1109 | | |
| 1110 | | /* Is there enough space for the icon directory entries? */ |
| 1111 | | if ((nBufferIndex + nNumImages * sizeof(ICONDIRENTRY)) > nBufferSize) |
| 1112 | | { |
| 1113 | | return NULL; |
| 1114 | | } |
| 1115 | | |
| 1116 | | /* Assign icon directory entries from buffer */ |
| 1117 | | lpIDE = (LPICONDIRENTRY)(&ptrBuffer[nBufferIndex]); |
| 1118 | | nBufferIndex += nNumImages * sizeof (ICONDIRENTRY); |
| 1119 | | |
| 1120 | | IconImage.dwNumBytes = lpIDE->dwBytesInRes; |
| 1121 | | |
| 1122 | | /* Seek to beginning of this image */ |
| 1123 | | if ( lpIDE->dwImageOffset > nBufferSize ) |
| 1124 | | { |
| 1125 | | return NULL; |
| 1126 | | } |
| 1127 | | |
| 1128 | | nBufferIndex = lpIDE->dwImageOffset; |
| 1129 | | |
| 1130 | | /* Read it in */ |
| 1131 | | if ((nBufferIndex + lpIDE->dwBytesInRes) > nBufferSize) |
| 1132 | | { |
| 1133 | | return NULL; |
| 1134 | | } |
| 1135 | | |
| 1136 | | IconImage.lpBits = &ptrBuffer[nBufferIndex]; |
| 1137 | | nBufferIndex += lpIDE->dwBytesInRes; |
| 1138 | | |
| 1139 | | hIcon = CreateIconFromResourceEx(IconImage.lpBits, IconImage.dwNumBytes, TRUE, 0x00030000, |
| 1140 | | (*(LPBITMAPINFOHEADER)(IconImage.lpBits)).biWidth, (*(LPBITMAPINFOHEADER)(IconImage.lpBits)).biHeight/2, 0 ); |
| 1141 | | |
| 1142 | | /* It failed, odds are good we're on NT so try the non-Ex way */ |
| 1143 | | if (hIcon == NULL) |
| 1144 | | { |
| 1145 | | /* We would break on NT if we try with a 16bpp image */ |
| 1146 | | if (((LPBITMAPINFO)IconImage.lpBits)->bmiHeader.biBitCount != 16) |
| 1147 | | { |
| 1148 | | hIcon = CreateIconFromResource(IconImage.lpBits, IconImage.dwNumBytes, TRUE, 0x00030000); |
| 1149 | | } |
| 1150 | | } |
| 1151 | | return hIcon; |
| 1152 | | } |
| 1153 | | |
| 1154 | | HICON LoadIconFromFile(const char *iconname) |
| 1155 | | { |
| 1156 | | HICON hIcon = 0; |
| 1157 | | struct stat file_stat; |
| 1158 | | char tmpStr[MAX_PATH]; |
| 1159 | | char tmpIcoName[MAX_PATH]; |
| 1160 | | const char* sDirName = GetImgDir(); |
| 1161 | | PBYTE bufferPtr; |
| 1162 | | zip_error ziperr; |
| 1163 | | zip_file *zip; |
| 1164 | | const zip_file_header *entry; |
| 1165 | | |
| 1166 | | sprintf(tmpStr, "%s/%s.ico", GetIconsDir(), iconname); |
| 1167 | | if (stat(tmpStr, &file_stat) != 0 |
| 1168 | | || (hIcon = win_extract_icon_utf8(hInst, tmpStr, 0)) == 0) |
| 1169 | | { |
| 1170 | | sprintf(tmpStr, "%s/%s.ico", sDirName, iconname); |
| 1171 | | if (stat(tmpStr, &file_stat) != 0 |
| 1172 | | || (hIcon = win_extract_icon_utf8(hInst, tmpStr, 0)) == 0) |
| 1173 | | { |
| 1174 | | sprintf(tmpStr, "%s/icons.zip", GetIconsDir()); |
| 1175 | | sprintf(tmpIcoName, "%s.ico", iconname); |
| 1176 | | |
| 1177 | | ziperr = zip_file_open(tmpStr, &zip); |
| 1178 | | if (ziperr == ZIPERR_NONE) |
| 1179 | | { |
| 1180 | | entry = zip_file_first_file(zip); |
| 1181 | | while(!hIcon && entry) |
| 1182 | | { |
| 1183 | | if (!mame_stricmp(entry->filename, tmpIcoName)) |
| 1184 | | { |
| 1185 | | bufferPtr = malloc(entry->uncompressed_length); |
| 1186 | | if (bufferPtr) |
| 1187 | | { |
| 1188 | | ziperr = zip_file_decompress(zip, bufferPtr, entry->uncompressed_length); |
| 1189 | | if (ziperr == ZIPERR_NONE) |
| 1190 | | { |
| 1191 | | hIcon = FormatICOInMemoryToHICON(bufferPtr, entry->uncompressed_length); |
| 1192 | | } |
| 1193 | | free(bufferPtr); |
| 1194 | | } |
| 1195 | | } |
| 1196 | | entry = zip_file_next_file(zip); |
| 1197 | | } |
| 1198 | | zip_file_close(zip); |
| 1199 | | } |
| 1200 | | } |
| 1201 | | } |
| 1202 | | return hIcon; |
| 1203 | | } |
| 1204 | | |
| 1205 | | /* Return the number of folders with options */ |
| 1206 | | int GetNumOptionFolders() |
| 1207 | | { |
| 1208 | | return optionfolder_count; |
| 1209 | | } |
| 1210 | | |
| 1211 | | /* Return the number of folders with options */ |
| 1212 | | void SetNumOptionFolders(int count) |
| 1213 | | { |
| 1214 | | optionfolder_count = count; |
| 1215 | | } |
| 1216 | | |
| 1217 | | |
| 1218 | | /* Sets the treeview and listviews sizes in accordance with their visibility and the splitters */ |
| 1219 | | static void ResizeTreeAndListViews(BOOL bResizeHidden) |
| 1220 | | { |
| 1221 | | int i; |
| 1222 | | int nLastWidth = 0; |
| 1223 | | int nLastWidth2 = 0; |
| 1224 | | int nLeftWindowWidth = 0; |
| 1225 | | RECT rect; |
| 1226 | | BOOL bVisible; |
| 1227 | | |
| 1228 | | /* Size the List Control in the Picker */ |
| 1229 | | GetClientRect(hMain, &rect); |
| 1230 | | |
| 1231 | | if (bShowStatusBar) |
| 1232 | | rect.bottom -= bottomMargin; |
| 1233 | | if (bShowToolBar) |
| 1234 | | rect.top += topMargin; |
| 1235 | | |
| 1236 | | /* Tree control */ |
| 1237 | | ShowWindow(GetDlgItem(hMain, IDC_TREE), bShowTree ? SW_SHOW : SW_HIDE); |
| 1238 | | |
| 1239 | | for (i = 0; g_splitterInfo[i].nSplitterWindow; i++) |
| 1240 | | { |
| 1241 | | bVisible = GetWindowLong(GetDlgItem(hMain, g_splitterInfo[i].nLeftWindow), GWL_STYLE) & WS_VISIBLE ? TRUE : FALSE; |
| 1242 | | if (bResizeHidden || bVisible) |
| 1243 | | { |
| 1244 | | nLeftWindowWidth = nSplitterOffset[i] - SPLITTER_WIDTH/2 - nLastWidth; |
| 1245 | | |
| 1246 | | /* special case for the rightmost pane when the screenshot is gone */ |
| 1247 | | if (!GetShowScreenShot() && !g_splitterInfo[i+1].nSplitterWindow) |
| 1248 | | nLeftWindowWidth = rect.right - nLastWidth; |
| 1249 | | |
| 1250 | | /* woah? are we overlapping ourselves? */ |
| 1251 | | if (nLeftWindowWidth < MIN_VIEW_WIDTH) |
| 1252 | | { |
| 1253 | | nLastWidth = nLastWidth2; |
| 1254 | | nLeftWindowWidth = nSplitterOffset[i] - MIN_VIEW_WIDTH - (SPLITTER_WIDTH*3/2) - nLastWidth; |
| 1255 | | i--; |
| 1256 | | } |
| 1257 | | |
| 1258 | | MoveWindow(GetDlgItem(hMain, g_splitterInfo[i].nLeftWindow), nLastWidth, rect.top + 2, |
| 1259 | | nLeftWindowWidth, (rect.bottom - rect.top) - 4 , TRUE); |
| 1260 | | |
| 1261 | | MoveWindow(GetDlgItem(hMain, g_splitterInfo[i].nSplitterWindow), nSplitterOffset[i], rect.top + 2, |
| 1262 | | SPLITTER_WIDTH, (rect.bottom - rect.top) - 4, TRUE); |
| 1263 | | } |
| 1264 | | |
| 1265 | | if (bVisible) |
| 1266 | | { |
| 1267 | | nLastWidth2 = nLastWidth; |
| 1268 | | nLastWidth += nLeftWindowWidth + SPLITTER_WIDTH; |
| 1269 | | } |
| 1270 | | } |
| 1271 | | } |
| 1272 | | |
| 1273 | | /* Adjust the list view and screenshot button based on GetShowScreenShot() */ |
| 1274 | | void UpdateScreenShot(void) |
| 1275 | | { |
| 1276 | | RECT rect; |
| 1277 | | int nWidth; |
| 1278 | | RECT fRect; |
| 1279 | | POINT p = {0, 0}; |
| 1280 | | |
| 1281 | | /* first time through can't do this stuff */ |
| 1282 | | if (hwndList == NULL) |
| 1283 | | return; |
| 1284 | | |
| 1285 | | /* Size the List Control in the Picker */ |
| 1286 | | GetClientRect(hMain, &rect); |
| 1287 | | |
| 1288 | | if (bShowStatusBar) |
| 1289 | | rect.bottom -= bottomMargin; |
| 1290 | | if (bShowToolBar) |
| 1291 | | rect.top += topMargin; |
| 1292 | | |
| 1293 | | if (GetShowScreenShot()) |
| 1294 | | { |
| 1295 | | nWidth = nSplitterOffset[GetSplitterCount() - 1]; |
| 1296 | | CheckMenuItem(GetMenu(hMain),ID_VIEW_PICTURE_AREA, MF_CHECKED); |
| 1297 | | ToolBar_CheckButton(hToolBar, ID_VIEW_PICTURE_AREA, MF_CHECKED); |
| 1298 | | } |
| 1299 | | else |
| 1300 | | { |
| 1301 | | nWidth = rect.right; |
| 1302 | | CheckMenuItem(GetMenu(hMain),ID_VIEW_PICTURE_AREA, MF_UNCHECKED); |
| 1303 | | ToolBar_CheckButton(hToolBar, ID_VIEW_PICTURE_AREA, MF_UNCHECKED); |
| 1304 | | } |
| 1305 | | |
| 1306 | | ResizeTreeAndListViews(FALSE); |
| 1307 | | |
| 1308 | | FreeScreenShot(); |
| 1309 | | |
| 1310 | | if (have_selection) |
| 1311 | | { |
| 1312 | | #ifdef MESS |
| 1313 | | if (!g_szSelectedItem[0] || !LoadScreenShotEx(Picker_GetSelectedItem(hwndList), g_szSelectedItem, |
| 1314 | | TabView_GetCurrentTab(hTabCtrl))) |
| 1315 | | #endif |
| 1316 | | { |
| 1317 | | // load and set image, or empty it if we don't have one |
| 1318 | | LoadScreenShot(Picker_GetSelectedItem(hwndList), TabView_GetCurrentTab(hTabCtrl)); |
| 1319 | | } |
| 1320 | | } |
| 1321 | | |
| 1322 | | // figure out if we have a history or not, to place our other windows properly |
| 1323 | | UpdateHistory(); |
| 1324 | | |
| 1325 | | // setup the picture area |
| 1326 | | |
| 1327 | | if (GetShowScreenShot()) |
| 1328 | | { |
| 1329 | | DWORD dwStyle; |
| 1330 | | DWORD dwStyleEx; |
| 1331 | | BOOL showing_history; |
| 1332 | | |
| 1333 | | ClientToScreen(hMain, &p); |
| 1334 | | GetWindowRect(GetDlgItem(hMain, IDC_SSFRAME), &fRect); |
| 1335 | | OffsetRect(&fRect, -p.x, -p.y); |
| 1336 | | |
| 1337 | | // show history on this tab IFF |
| 1338 | | // - we have history for the game |
| 1339 | | // - we're on the first tab |
| 1340 | | // - we DON'T have a separate history tab |
| 1341 | | showing_history = (have_history && (TabView_GetCurrentTab(hTabCtrl) == GetHistoryTab() || GetHistoryTab() == TAB_ALL ) && |
| 1342 | | GetShowTab(TAB_HISTORY) == FALSE); |
| 1343 | | CalculateBestScreenShotRect(GetDlgItem(hMain, IDC_SSFRAME), &rect,showing_history); |
| 1344 | | |
| 1345 | | dwStyle = GetWindowLong(GetDlgItem(hMain, IDC_SSPICTURE), GWL_STYLE); |
| 1346 | | dwStyleEx = GetWindowLong(GetDlgItem(hMain, IDC_SSPICTURE), GWL_EXSTYLE); |
| 1347 | | |
| 1348 | | AdjustWindowRectEx(&rect, dwStyle, FALSE, dwStyleEx); |
| 1349 | | MoveWindow(GetDlgItem(hMain, IDC_SSPICTURE), |
| 1350 | | fRect.left + rect.left, |
| 1351 | | fRect.top + rect.top, |
| 1352 | | rect.right - rect.left, |
| 1353 | | rect.bottom - rect.top, |
| 1354 | | TRUE); |
| 1355 | | |
| 1356 | | ShowWindow(GetDlgItem(hMain,IDC_SSPICTURE), |
| 1357 | | (TabView_GetCurrentTab(hTabCtrl) != TAB_HISTORY) ? SW_SHOW : SW_HIDE); |
| 1358 | | ShowWindow(GetDlgItem(hMain,IDC_SSFRAME),SW_SHOW); |
| 1359 | | ShowWindow(GetDlgItem(hMain,IDC_SSTAB),bShowTabCtrl ? SW_SHOW : SW_HIDE); |
| 1360 | | |
| 1361 | | InvalidateRect(GetDlgItem(hMain,IDC_SSPICTURE),NULL,FALSE); |
| 1362 | | } |
| 1363 | | else |
| 1364 | | { |
| 1365 | | ShowWindow(GetDlgItem(hMain,IDC_SSPICTURE),SW_HIDE); |
| 1366 | | ShowWindow(GetDlgItem(hMain,IDC_SSFRAME),SW_HIDE); |
| 1367 | | ShowWindow(GetDlgItem(hMain,IDC_SSTAB),SW_HIDE); |
| 1368 | | } |
| 1369 | | |
| 1370 | | } |
| 1371 | | |
| 1372 | | void ResizePickerControls(HWND hWnd) |
| 1373 | | { |
| 1374 | | RECT frameRect; |
| 1375 | | RECT rect, sRect; |
| 1376 | | int nListWidth, nScreenShotWidth; |
| 1377 | | static BOOL firstTime = TRUE; |
| 1378 | | int doSSControls = TRUE; |
| 1379 | | int i, nSplitterCount; |
| 1380 | | |
| 1381 | | nSplitterCount = GetSplitterCount(); |
| 1382 | | |
| 1383 | | /* Size the List Control in the Picker */ |
| 1384 | | GetClientRect(hWnd, &rect); |
| 1385 | | |
| 1386 | | /* Calc the display sizes based on g_splitterInfo */ |
| 1387 | | if (firstTime) |
| 1388 | | { |
| 1389 | | RECT rWindow; |
| 1390 | | |
| 1391 | | for (i = 0; i < nSplitterCount; i++) |
| 1392 | | nSplitterOffset[i] = rect.right * g_splitterInfo[i].dPosition; |
| 1393 | | |
| 1394 | | GetWindowRect(hStatusBar, &rWindow); |
| 1395 | | bottomMargin = rWindow.bottom - rWindow.top; |
| 1396 | | GetWindowRect(hToolBar, &rWindow); |
| 1397 | | topMargin = rWindow.bottom - rWindow.top; |
| 1398 | | /*buttonMargin = (sRect.bottom + 4); */ |
| 1399 | | |
| 1400 | | firstTime = FALSE; |
| 1401 | | } |
| 1402 | | else |
| 1403 | | { |
| 1404 | | doSSControls = GetShowScreenShot(); |
| 1405 | | } |
| 1406 | | |
| 1407 | | if (bShowStatusBar) |
| 1408 | | rect.bottom -= bottomMargin; |
| 1409 | | |
| 1410 | | if (bShowToolBar) |
| 1411 | | rect.top += topMargin; |
| 1412 | | |
| 1413 | | MoveWindow(GetDlgItem(hWnd, IDC_DIVIDER), rect.left, rect.top - 4, rect.right, 2, TRUE); |
| 1414 | | |
| 1415 | | ResizeTreeAndListViews(TRUE); |
| 1416 | | |
| 1417 | | nListWidth = nSplitterOffset[nSplitterCount-1]; |
| 1418 | | nScreenShotWidth = (rect.right - nListWidth) - 4; |
| 1419 | | |
| 1420 | | /* Screen shot Page tab control */ |
| 1421 | | if (bShowTabCtrl) |
| 1422 | | { |
| 1423 | | MoveWindow(GetDlgItem(hWnd, IDC_SSTAB), nListWidth + 4, rect.top + 2, |
| 1424 | | nScreenShotWidth - 2, rect.top + 20, doSSControls); |
| 1425 | | rect.top += 20; |
| 1426 | | } |
| 1427 | | |
| 1428 | | /* resize the Screen shot frame */ |
| 1429 | | MoveWindow(GetDlgItem(hWnd, IDC_SSFRAME), nListWidth + 4, rect.top + 2, |
| 1430 | | nScreenShotWidth - 2, (rect.bottom - rect.top) - 4, doSSControls); |
| 1431 | | |
| 1432 | | /* The screen shot controls */ |
| 1433 | | GetClientRect(GetDlgItem(hWnd, IDC_SSFRAME), &frameRect); |
| 1434 | | |
| 1435 | | /* Text control - game history */ |
| 1436 | | sRect.left = nListWidth + 14; |
| 1437 | | sRect.right = sRect.left + (nScreenShotWidth - 22); |
| 1438 | | |
| 1439 | | |
| 1440 | | if (GetShowTab(TAB_HISTORY)) |
| 1441 | | { |
| 1442 | | // We're using the new mode, with the history filling the entire tab (almost) |
| 1443 | | sRect.top = rect.top + 14; |
| 1444 | | sRect.bottom = (rect.bottom - rect.top) - 30; |
| 1445 | | } |
| 1446 | | else |
| 1447 | | { |
| 1448 | | // We're using the original mode, with the history beneath the SS picture |
| 1449 | | sRect.top = rect.top + 264; |
| 1450 | | sRect.bottom = (rect.bottom - rect.top) - 278; |
| 1451 | | } |
| 1452 | | |
| 1453 | | MoveWindow(GetDlgItem(hWnd, IDC_HISTORY), |
| 1454 | | sRect.left, sRect.top, |
| 1455 | | sRect.right - sRect.left, sRect.bottom, doSSControls); |
| 1456 | | |
| 1457 | | /* the other screen shot controls will be properly placed in UpdateScreenshot() */ |
| 1458 | | |
| 1459 | | } |
| 1460 | | |
| 1461 | | char *ModifyThe(const char *str) |
| 1462 | | { |
| 1463 | | static int bufno = 0; |
| 1464 | | static char buffer[4][255]; |
| 1465 | | |
| 1466 | | if (strncmp(str, "The ", 4) == 0) |
| 1467 | | { |
| 1468 | | char *s, *p; |
| 1469 | | char temp[255]; |
| 1470 | | |
| 1471 | | strcpy(temp, &str[4]); |
| 1472 | | |
| 1473 | | bufno = (bufno + 1) % 4; |
| 1474 | | |
| 1475 | | s = buffer[bufno]; |
| 1476 | | |
| 1477 | | /* Check for version notes in parens */ |
| 1478 | | p = strchr(temp, '('); |
| 1479 | | if (p) |
| 1480 | | { |
| 1481 | | p[-1] = '\0'; |
| 1482 | | } |
| 1483 | | |
| 1484 | | strcpy(s, temp); |
| 1485 | | strcat(s, ", The"); |
| 1486 | | |
| 1487 | | if (p) |
| 1488 | | { |
| 1489 | | strcat(s, " "); |
| 1490 | | strcat(s, p); |
| 1491 | | } |
| 1492 | | |
| 1493 | | return s; |
| 1494 | | } |
| 1495 | | return (char *)str; |
| 1496 | | } |
| 1497 | | |
| 1498 | | HBITMAP GetBackgroundBitmap(void) |
| 1499 | | { |
| 1500 | | return hBackground; |
| 1501 | | } |
| 1502 | | |
| 1503 | | HPALETTE GetBackgroundPalette(void) |
| 1504 | | { |
| 1505 | | return hPALbg; |
| 1506 | | } |
| 1507 | | |
| 1508 | | MYBITMAPINFO * GetBackgroundInfo(void) |
| 1509 | | { |
| 1510 | | return &bmDesc; |
| 1511 | | } |
| 1512 | | |
| 1513 | | BOOL GetUseOldControl(void) |
| 1514 | | { |
| 1515 | | return oldControl; |
| 1516 | | } |
| 1517 | | |
| 1518 | | BOOL GetUseXPControl(void) |
| 1519 | | { |
| 1520 | | return xpControl; |
| 1521 | | } |
| 1522 | | |
| 1523 | | int GetMinimumScreenShotWindowWidth(void) |
| 1524 | | { |
| 1525 | | BITMAP bmp; |
| 1526 | | GetObject(hMissing_bitmap,sizeof(BITMAP),&bmp); |
| 1527 | | |
| 1528 | | return bmp.bmWidth + 6; // 6 is for a little breathing room |
| 1529 | | } |
| 1530 | | |
| 1531 | | |
| 1532 | | int GetDriverIndex(const game_driver *driver) |
| 1533 | | { |
| 1534 | | return GetGameNameIndex(driver->name); |
| 1535 | | } |
| 1536 | | |
| 1537 | | int GetParentIndex(const game_driver *driver) |
| 1538 | | { |
| 1539 | | return GetGameNameIndex(driver->parent); |
| 1540 | | } |
| 1541 | | |
| 1542 | | int GetParentRomSetIndex(const game_driver *driver) |
| 1543 | | { |
| 1544 | | int nParentIndex = GetGameNameIndex(driver->parent); |
| 1545 | | |
| 1546 | | if( nParentIndex >= 0) |
| 1547 | | { |
| 1548 | | if ((drivers[nParentIndex]->flags & GAME_IS_BIOS_ROOT) == 0) |
| 1549 | | return nParentIndex; |
| 1550 | | } |
| 1551 | | |
| 1552 | | return -1; |
| 1553 | | } |
| 1554 | | |
| 1555 | | int GetGameNameIndex(const char *name) |
| 1556 | | { |
| 1557 | | driver_data_type *driver_index_info; |
| 1558 | | driver_data_type key; |
| 1559 | | key.name = name; |
| 1560 | | |
| 1561 | | // uses our sorted array of driver names to get the index in log time |
| 1562 | | driver_index_info = bsearch(&key,sorted_drivers,driver_list_get_count(drivers),sizeof(driver_data_type), |
| 1563 | | DriverDataCompareFunc); |
| 1564 | | |
| 1565 | | if (driver_index_info == NULL) |
| 1566 | | return -1; |
| 1567 | | |
| 1568 | | return driver_index_info->index; |
| 1569 | | |
| 1570 | | } |
| 1571 | | |
| 1572 | | int GetIndexFromSortedIndex(int sorted_index) |
| 1573 | | { |
| 1574 | | return sorted_drivers[sorted_index].index; |
| 1575 | | } |
| 1576 | | |
| 1577 | | /*************************************************************************** |
| 1578 | | Internal functions |
| 1579 | | ***************************************************************************/ |
| 1580 | | |
| 1581 | | // used for our sorted array of game names |
| 1582 | | int CLIB_DECL DriverDataCompareFunc(const void *arg1,const void *arg2) |
| 1583 | | { |
| 1584 | | return strcmp( ((driver_data_type *)arg1)->name, ((driver_data_type *)arg2)->name ); |
| 1585 | | } |
| 1586 | | |
| 1587 | | static void ResetBackground(char *szFile) |
| 1588 | | { |
| 1589 | | char szDestFile[MAX_PATH]; |
| 1590 | | |
| 1591 | | /* The MAME core load the .png file first, so we only need replace this file */ |
| 1592 | | sprintf(szDestFile, "%s\\bkground.png", GetBgDir()); |
| 1593 | | win_set_file_attributes_utf8(szDestFile, FILE_ATTRIBUTE_NORMAL); |
| 1594 | | win_copy_file_utf8(szFile, szDestFile, FALSE); |
| 1595 | | } |
| 1596 | | |
| 1597 | | static void RandomSelectBackground(void) |
| 1598 | | { |
| 1599 | | struct _finddata_t c_file; |
| 1600 | | long hFile; |
| 1601 | | char szFile[MAX_PATH]; |
| 1602 | | int count=0; |
| 1603 | | const char *szDir=GetBgDir(); |
| 1604 | | char *buf=malloc(_MAX_FNAME * MAX_BGFILES); |
| 1605 | | |
| 1606 | | if (buf == NULL) |
| 1607 | | return; |
| 1608 | | |
| 1609 | | sprintf(szFile, "%s\\*.bmp", szDir); |
| 1610 | | hFile = _findfirst(szFile, &c_file); |
| 1611 | | if (hFile != -1L) |
| 1612 | | { |
| 1613 | | int Done = 0; |
| 1614 | | while (!Done && count < MAX_BGFILES) |
| 1615 | | { |
| 1616 | | memcpy(buf + count * _MAX_FNAME, c_file.name, _MAX_FNAME); |
| 1617 | | count++; |
| 1618 | | Done = _findnext(hFile, &c_file); |
| 1619 | | } |
| 1620 | | _findclose(hFile); |
| 1621 | | } |
| 1622 | | sprintf(szFile, "%s\\*.png", szDir); |
| 1623 | | hFile = _findfirst(szFile, &c_file); |
| 1624 | | if (hFile != -1L) |
| 1625 | | { |
| 1626 | | int Done = 0; |
| 1627 | | while (!Done && count < MAX_BGFILES) |
| 1628 | | { |
| 1629 | | memcpy(buf + count * _MAX_FNAME, c_file.name, _MAX_FNAME); |
| 1630 | | count++; |
| 1631 | | Done = _findnext(hFile, &c_file); |
| 1632 | | } |
| 1633 | | _findclose(hFile); |
| 1634 | | } |
| 1635 | | |
| 1636 | | if (count) |
| 1637 | | { |
| 1638 | | #ifdef rand |
| 1639 | | #undef rand |
| 1640 | | #endif |
| 1641 | | |
| 1642 | | srand( (unsigned)time( NULL ) ); |
| 1643 | | sprintf(szFile, "%s\\%s", szDir, buf + (rand() % count) * _MAX_FNAME); |
| 1644 | | ResetBackground(szFile); |
| 1645 | | } |
| 1646 | | |
| 1647 | | free(buf); |
| 1648 | | } |
| 1649 | | |
| 1650 | | void SetMainTitle(void) |
| 1651 | | { |
| 1652 | | char version[50]; |
| 1653 | | char buffer[100]; |
| 1654 | | |
| 1655 | | sscanf(build_version,"%s",version); |
| 1656 | | snprintf(buffer, ARRAY_LENGTH(buffer), "%s %s", MAME32NAME, version); |
| 1657 | | win_set_window_text_utf8(hMain,buffer); |
| 1658 | | } |
| 1659 | | |
| 1660 | | static void winui_output_error(void *param, const char *format, va_list argptr) |
| 1661 | | { |
| 1662 | | char buffer[1024]; |
| 1663 | | |
| 1664 | | // if we are in fullscreen mode, go to windowed mode |
| 1665 | | if ((video_config.windowed == 0) && (win_window_list != NULL)) |
| 1666 | | winwindow_toggle_full_screen(); |
| 1667 | | |
| 1668 | | vsnprintf(buffer, ARRAY_LENGTH(buffer), format, argptr); |
| 1669 | | win_message_box_utf8(win_window_list ? win_window_list->hwnd : NULL, buffer, APPNAME, MB_OK); |
| 1670 | | } |
| 1671 | | |
| 1672 | | static void memory_error(const char *message) |
| 1673 | | { |
| 1674 | | win_message_box_utf8(hMain, message, APPNAME, MB_OK); |
| 1675 | | exit(-1); |
| 1676 | | } |
| 1677 | | |
| 1678 | | static BOOL Win32UI_init(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) |
| 1679 | | { |
| 1680 | | extern int mame_validitychecks(int game); |
| 1681 | | WNDCLASS wndclass; |
| 1682 | | RECT rect; |
| 1683 | | int i, nSplitterCount; |
| 1684 | | extern FOLDERDATA g_folderData[]; |
| 1685 | | extern FILTER_ITEM g_filterList[]; |
| 1686 | | extern const char *history_filename; |
| 1687 | | extern const char *mameinfo_filename; |
| 1688 | | LONG common_control_version = GetCommonControlVersion(); |
| 1689 | | int validity_failed = 0; |
| 1690 | | TCHAR* t_inpdir; |
| 1691 | | |
| 1692 | | dprintf("about to init options\n"); |
| 1693 | | if (!OptionsInit()) |
| 1694 | | return FALSE; |
| 1695 | | dprintf("options loaded\n"); |
| 1696 | | |
| 1697 | | srand((unsigned)time(NULL)); |
| 1698 | | |
| 1699 | | // output errors to message boxes |
| 1700 | | mame_set_output_channel(OUTPUT_CHANNEL_ERROR, winui_output_error, NULL, NULL, NULL); |
| 1701 | | |
| 1702 | | // create the memory pool |
| 1703 | | mame32_pool = pool_alloc(memory_error); |
| 1704 | | |
| 1705 | | // custom per-game icons |
| 1706 | | icon_index = pool_malloc(mame32_pool, sizeof(int) * driver_list_get_count(drivers)); |
| 1707 | | memset(icon_index, '\0', sizeof(int) * driver_list_get_count(drivers)); |
| 1708 | | |
| 1709 | | // sorted list of drivers by name |
| 1710 | | sorted_drivers = (driver_data_type *) pool_malloc(mame32_pool, sizeof(driver_data_type) * driver_list_get_count(drivers)); |
| 1711 | | memset(sorted_drivers, '\0', sizeof(driver_data_type) * driver_list_get_count(drivers)); |
| 1712 | | for (i = 0; i < driver_list_get_count(drivers); i++) |
| 1713 | | { |
| 1714 | | sorted_drivers[i].name = drivers[i]->name; |
| 1715 | | sorted_drivers[i].index = i; |
| 1716 | | } |
| 1717 | | qsort(sorted_drivers, driver_list_get_count(drivers), sizeof(driver_data_type), DriverDataCompareFunc); |
| 1718 | | |
| 1719 | | // set up window class |
| 1720 | | wndclass.style = CS_HREDRAW | CS_VREDRAW; |
| 1721 | | wndclass.lpfnWndProc = MameWindowProc; |
| 1722 | | wndclass.cbClsExtra = 0; |
| 1723 | | wndclass.cbWndExtra = DLGWINDOWEXTRA; |
| 1724 | | wndclass.hInstance = hInstance; |
| 1725 | | wndclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAME32_ICON)); |
| 1726 | | wndclass.hCursor = NULL; |
| 1727 | | wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); |
| 1728 | | wndclass.lpszMenuName = MAKEINTRESOURCE(IDR_UI_MENU); |
| 1729 | | wndclass.lpszClassName = TEXT("MainClass"); |
| 1730 | | |
| 1731 | | RegisterClass(&wndclass); |
| 1732 | | |
| 1733 | | #ifdef MESS |
| 1734 | | DevView_RegisterClass(); |
| 1735 | | #endif //MESS |
| 1736 | | |
| 1737 | | InitCommonControls(); |
| 1738 | | |
| 1739 | | // Are we using an Old comctl32.dll? |
| 1740 | | dprintf("common controlversion %i %i",common_control_version >> 16, |
| 1741 | | common_control_version & 0xffff); |
| 1742 | | |
| 1743 | | oldControl = (common_control_version < PACKVERSION(4,71)); |
| 1744 | | xpControl = (common_control_version >= PACKVERSION(6,0)); |
| 1745 | | if (oldControl) |
| 1746 | | { |
| 1747 | | char buf[] = MAME32NAME " has detected an old version of comctl32.dll\n\n" |
| 1748 | | "Game Properties, many configuration options and\n" |
| 1749 | | "features are not available without an updated DLL\n\n" |
| 1750 | | "Please install the common control update found at:\n\n" |
| 1751 | | "http://www.microsoft.com/msdownload/ieplatform/ie/comctrlx86.asp\n\n" |
| 1752 | | "Would you like to continue without using the new features?\n"; |
| 1753 | | |
| 1754 | | if (IDNO == win_message_box_utf8(0, buf, MAME32NAME " Outdated comctl32.dll Warning", MB_YESNO | MB_ICONWARNING)) |
| 1755 | | return FALSE; |
| 1756 | | } |
| 1757 | | |
| 1758 | | g_mame32_message = RegisterWindowMessage(TEXT("MAME32")); |
| 1759 | | g_bDoBroadcast = GetBroadcast(); |
| 1760 | | |
| 1761 | | HelpInit(); |
| 1762 | | |
| 1763 | | t_inpdir = tstring_from_utf8(GetInpDir()); |
| 1764 | | if( ! t_inpdir ) |
| 1765 | | return FALSE; |
| 1766 | | |
| 1767 | | _tcscpy(last_directory,t_inpdir); |
| 1768 | | free(t_inpdir); |
| 1769 | | hMain = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_MAIN), 0, NULL); |
| 1770 | | if (hMain == NULL) |
| 1771 | | { |
| 1772 | | dprintf("error creating main dialog, aborting"); |
| 1773 | | return FALSE; |
| 1774 | | } |
| 1775 | | |
| 1776 | | s_pWatcher = DirWatcher_Init(hMain, WM_MAME32_FILECHANGED); |
| 1777 | | if (s_pWatcher) |
| 1778 | | { |
| 1779 | | DirWatcher_Watch(s_pWatcher, 0, GetRomDirs(), TRUE); |
| 1780 | | DirWatcher_Watch(s_pWatcher, 1, GetSampleDirs(), TRUE); |
| 1781 | | } |
| 1782 | | |
| 1783 | | SetMainTitle(); |
| 1784 | | hTabCtrl = GetDlgItem(hMain, IDC_SSTAB); |
| 1785 | | |
| 1786 | | { |
| 1787 | | struct TabViewOptions opts; |
| 1788 | | |
| 1789 | | static struct TabViewCallbacks s_tabviewCallbacks = |
| 1790 | | { |
| 1791 | | GetShowTabCtrl, // pfnGetShowTabCtrl |
| 1792 | | SetCurrentTab, // pfnSetCurrentTab |
| 1793 | | GetCurrentTab, // pfnGetCurrentTab |
| 1794 | | SetShowTab, // pfnSetShowTab |
| 1795 | | GetShowTab, // pfnGetShowTab |
| 1796 | | |
| 1797 | | GetImageTabShortName, // pfnGetTabShortName |
| 1798 | | GetImageTabLongName, // pfnGetTabLongName |
| 1799 | | UpdateScreenShot // pfnOnSelectionChanged |
| 1800 | | }; |
| 1801 | | |
| 1802 | | memset(&opts, 0, sizeof(opts)); |
| 1803 | | opts.pCallbacks = &s_tabviewCallbacks; |
| 1804 | | opts.nTabCount = MAX_TAB_TYPES; |
| 1805 | | |
| 1806 | | if (!SetupTabView(hTabCtrl, &opts)) |
| 1807 | | return FALSE; |
| 1808 | | } |
| 1809 | | |
| 1810 | | /* subclass history window */ |
| 1811 | | g_lpHistoryWndProc = (WNDPROC)(LONG)(int)GetWindowLong(GetDlgItem(hMain, IDC_HISTORY), GWL_WNDPROC); |
| 1812 | | SetWindowLong(GetDlgItem(hMain, IDC_HISTORY), GWL_WNDPROC, (LONG)HistoryWndProc); |
| 1813 | | |
| 1814 | | /* subclass picture frame area */ |
| 1815 | | g_lpPictureFrameWndProc = (WNDPROC)(LONG)(int)GetWindowLong(GetDlgItem(hMain, IDC_SSFRAME), GWL_WNDPROC); |
| 1816 | | SetWindowLong(GetDlgItem(hMain, IDC_SSFRAME), GWL_WNDPROC, (LONG)PictureFrameWndProc); |
| 1817 | | |
| 1818 | | /* subclass picture area */ |
| 1819 | | g_lpPictureWndProc = (WNDPROC)(LONG)(int)GetWindowLong(GetDlgItem(hMain, IDC_SSPICTURE), GWL_WNDPROC); |
| 1820 | | SetWindowLong(GetDlgItem(hMain, IDC_SSPICTURE), GWL_WNDPROC, (LONG)PictureWndProc); |
| 1821 | | |
| 1822 | | /* Load the pic for the default screenshot. */ |
| 1823 | | hMissing_bitmap = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT)); |
| 1824 | | |
| 1825 | | /* Stash hInstance for later use */ |
| 1826 | | hInst = hInstance; |
| 1827 | | |
| 1828 | | hToolBar = InitToolbar(hMain); |
| 1829 | | hStatusBar = InitStatusBar(hMain); |
| 1830 | | hProgWnd = InitProgressBar(hStatusBar); |
| 1831 | | |
| 1832 | | main_resize_items[0].u.hwnd = hToolBar; |
| 1833 | | main_resize_items[1].u.hwnd = hStatusBar; |
| 1834 | | |
| 1835 | | /* In order to handle 'Large Fonts' as the Windows |
| 1836 | | * default setting, we need to make the dialogs small |
| 1837 | | * enough to fit in our smallest window size with |
| 1838 | | * large fonts, then resize the picker, tab and button |
| 1839 | | * controls to fill the window, no matter which font |
| 1840 | | * is currently set. This will still look like bad |
| 1841 | | * if the user uses a bigger default font than 125% |
| 1842 | | * (Large Fonts) on the Windows display setting tab. |
| 1843 | | * |
| 1844 | | * NOTE: This has to do with Windows default font size |
| 1845 | | * settings, NOT our picker font size. |
| 1846 | | */ |
| 1847 | | |
| 1848 | | GetClientRect(hMain, &rect); |
| 1849 | | |
| 1850 | | hTreeView = GetDlgItem(hMain, IDC_TREE); |
| 1851 | | hwndList = GetDlgItem(hMain, IDC_LIST); |
| 1852 | | |
| 1853 | | history_filename = mame_strdup(GetHistoryFileName()); |
| 1854 | | mameinfo_filename = mame_strdup(GetMAMEInfoFileName()); |
| 1855 | | |
| 1856 | | if (!InitSplitters()) |
| 1857 | | return FALSE; |
| 1858 | | |
| 1859 | | nSplitterCount = GetSplitterCount(); |
| 1860 | | for (i = 0; i < nSplitterCount; i++) |
| 1861 | | { |
| 1862 | | HWND hWnd; |
| 1863 | | HWND hWndLeft; |
| 1864 | | HWND hWndRight; |
| 1865 | | |
| 1866 | | hWnd = GetDlgItem(hMain, g_splitterInfo[i].nSplitterWindow); |
| 1867 | | hWndLeft = GetDlgItem(hMain, g_splitterInfo[i].nLeftWindow); |
| 1868 | | hWndRight = GetDlgItem(hMain, g_splitterInfo[i].nRightWindow); |
| 1869 | | |
| 1870 | | AddSplitter(hWnd, hWndLeft, hWndRight, g_splitterInfo[i].pfnAdjust); |
| 1871 | | } |
| 1872 | | |
| 1873 | | /* Initial adjustment of controls on the Picker window */ |
| 1874 | | ResizePickerControls(hMain); |
| 1875 | | |
| 1876 | | TabView_UpdateSelection(hTabCtrl); |
| 1877 | | |
| 1878 | | bDoGameCheck = GetGameCheck(); |
| 1879 | | idle_work = TRUE; |
| 1880 | | game_index = 0; |
| 1881 | | |
| 1882 | | bShowTree = GetShowFolderList(); |
| 1883 | | bShowToolBar = GetShowToolBar(); |
| 1884 | | bShowStatusBar = GetShowStatusBar(); |
| 1885 | | bShowTabCtrl = GetShowTabCtrl(); |
| 1886 | | |
| 1887 | | CheckMenuItem(GetMenu(hMain), ID_VIEW_FOLDERS, (bShowTree) ? MF_CHECKED : MF_UNCHECKED); |
| 1888 | | ToolBar_CheckButton(hToolBar, ID_VIEW_FOLDERS, (bShowTree) ? MF_CHECKED : MF_UNCHECKED); |
| 1889 | | CheckMenuItem(GetMenu(hMain), ID_VIEW_TOOLBARS, (bShowToolBar) ? MF_CHECKED : MF_UNCHECKED); |
| 1890 | | ShowWindow(hToolBar, (bShowToolBar) ? SW_SHOW : SW_HIDE); |
| 1891 | | CheckMenuItem(GetMenu(hMain), ID_VIEW_STATUS, (bShowStatusBar) ? MF_CHECKED : MF_UNCHECKED); |
| 1892 | | ShowWindow(hStatusBar, (bShowStatusBar) ? SW_SHOW : SW_HIDE); |
| 1893 | | CheckMenuItem(GetMenu(hMain), ID_VIEW_PAGETAB, (bShowTabCtrl) ? MF_CHECKED : MF_UNCHECKED); |
| 1894 | | |
| 1895 | | if (oldControl) |
| 1896 | | { |
| 1897 | | EnableMenuItem(GetMenu(hMain), ID_CUSTOMIZE_FIELDS, MF_GRAYED); |
| 1898 | | EnableMenuItem(GetMenu(hMain), ID_GAME_PROPERTIES, MF_GRAYED); |
| 1899 | | EnableMenuItem(GetMenu(hMain), ID_OPTIONS_DEFAULTS, MF_GRAYED); |
| 1900 | | } |
| 1901 | | |
| 1902 | | /* Init DirectDraw */ |
| 1903 | | if (!DirectDraw_Initialize()) |
| 1904 | | { |
| 1905 | | DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIRECTX), NULL, DirectXDialogProc); |
| 1906 | | return FALSE; |
| 1907 | | } |
| 1908 | | |
| 1909 | | if (GetRandomBackground()) |
| 1910 | | RandomSelectBackground(); |
| 1911 | | |
| 1912 | | LoadBackgroundBitmap(); |
| 1913 | | |
| 1914 | | dprintf("about to init tree"); |
| 1915 | | InitTree(g_folderData, g_filterList); |
| 1916 | | dprintf("did init tree"); |
| 1917 | | FolderOptionsInit(); |
| 1918 | | PropertiesInit(); |
| 1919 | | |
| 1920 | | /* Initialize listview columns */ |
| 1921 | | #ifdef MESS |
| 1922 | | InitMessPicker(); |
| 1923 | | #endif |
| 1924 | | InitListView(); |
| 1925 | | SetFocus(hwndList); |
| 1926 | | |
| 1927 | | /* Reset the font */ |
| 1928 | | { |
| 1929 | | LOGFONT logfont; |
| 1930 | | |
| 1931 | | GetListFont(&logfont); |
| 1932 | | hFont = CreateFontIndirect(&logfont); |
| 1933 | | if (hFont != NULL) |
| 1934 | | SetAllWindowsFont(hMain, &main_resize, hFont, FALSE); |
| 1935 | | } |
| 1936 | | |
| 1937 | | /* Init DirectInput */ |
| 1938 | | if (!DirectInputInitialize()) |
| 1939 | | { |
| 1940 | | DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIRECTX), NULL, DirectXDialogProc); |
| 1941 | | return FALSE; |
| 1942 | | } |
| 1943 | | |
| 1944 | | AdjustMetrics(); |
| 1945 | | UpdateScreenShot(); |
| 1946 | | |
| 1947 | | hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDA_TAB_KEYS)); |
| 1948 | | |
| 1949 | | /* clear keyboard state */ |
| 1950 | | KeyboardStateClear(); |
| 1951 | | |
| 1952 | | for (i = 0; i < NUM_GUI_SEQUENCES; i++) |
| 1953 | | { |
| 1954 | | input_seq *is1; |
| 1955 | | input_seq *is2; |
| 1956 | | is1 = &(GUISequenceControl[i].is); |
| 1957 | | is2 = GUISequenceControl[i].getiniptr(); |
| 1958 | | // FIXME |
| 1959 | | //input_seq_copy(is1, is2); |
| 1960 | | //dprintf("seq =%s is: %4i %4i %4i %4i\n",GUISequenceControl[i].name, (*is1)[0], (*is1)[1], (*is1)[2], (*is1)[3]); |
| 1961 | | } |
| 1962 | | |
| 1963 | | if (GetJoyGUI() == TRUE) |
| 1964 | | { |
| 1965 | | g_pJoyGUI = &DIJoystick; |
| 1966 | | if (g_pJoyGUI->init() != 0) |
| 1967 | | g_pJoyGUI = NULL; |
| 1968 | | else |
| 1969 | | SetTimer(hMain, JOYGUI_TIMER, JOYGUI_MS, NULL); |
| 1970 | | } |
| 1971 | | else |
| 1972 | | g_pJoyGUI = NULL; |
| 1973 | | |
| 1974 | | if (GetHideMouseOnStartup()) |
| 1975 | | { |
| 1976 | | /* For some reason the mouse is centered when a game is exited, which of |
| 1977 | | course causes a WM_MOUSEMOVE event that shows the mouse. So we center |
| 1978 | | it now, before the startup coords are initilized, and that way the mouse |
| 1979 | | will still be hidden when exiting from a game (i hope) :) |
| 1980 | | */ |
| 1981 | | SetCursorPos(GetSystemMetrics(SM_CXSCREEN)/2,GetSystemMetrics(SM_CYSCREEN)/2); |
| 1982 | | |
| 1983 | | // Then hide it |
| 1984 | | ShowCursor(FALSE); |
| 1985 | | } |
| 1986 | | |
| 1987 | | dprintf("about to show window\n"); |
| 1988 | | |
| 1989 | | nCmdShow = GetWindowState(); |
| 1990 | | if (nCmdShow == SW_HIDE || nCmdShow == SW_MINIMIZE || nCmdShow == SW_SHOWMINIMIZED) |
| 1991 | | { |
| 1992 | | nCmdShow = SW_RESTORE; |
| 1993 | | } |
| 1994 | | |
| 1995 | | if (GetRunFullScreen()) |
| 1996 | | { |
| 1997 | | LONG lMainStyle; |
| 1998 | | |
| 1999 | | // Remove menu |
| 2000 | | SetMenu(hMain,NULL); |
| 2001 | | |
| 2002 | | // Frameless dialog (fake fullscreen) |
| 2003 | | lMainStyle = GetWindowLong(hMain, GWL_STYLE); |
| 2004 | | lMainStyle = lMainStyle & (WS_BORDER ^ 0xffffffff); |
| 2005 | | SetWindowLong(hMain, GWL_STYLE, lMainStyle); |
| 2006 | | |
| 2007 | | nCmdShow = SW_MAXIMIZE; |
| 2008 | | } |
| 2009 | | |
| 2010 | | ShowWindow(hMain, nCmdShow); |
| 2011 | | |
| 2012 | | |
| 2013 | | switch (GetViewMode()) |
| 2014 | | { |
| 2015 | | case VIEW_LARGE_ICONS : |
| 2016 | | SetView(ID_VIEW_LARGE_ICON); |
| 2017 | | break; |
| 2018 | | case VIEW_SMALL_ICONS : |
| 2019 | | SetView(ID_VIEW_SMALL_ICON); |
| 2020 | | break; |
| 2021 | | case VIEW_INLIST : |
| 2022 | | SetView(ID_VIEW_LIST_MENU); |
| 2023 | | break; |
| 2024 | | case VIEW_REPORT : |
| 2025 | | SetView(ID_VIEW_DETAIL); |
| 2026 | | break; |
| 2027 | | case VIEW_GROUPED : |
| 2028 | | default : |
| 2029 | | SetView(ID_VIEW_GROUPED); |
| 2030 | | break; |
| 2031 | | } |
| 2032 | | |
| 2033 | | if (GetCycleScreenshot() > 0) |
| 2034 | | { |
| 2035 | | SetTimer(hMain, SCREENSHOT_TIMER, GetCycleScreenshot()*1000, NULL); //scale to Seconds |
| 2036 | | } |
| 2037 | | |
| 2038 | | if (validity_failed) |
| 2039 | | { |
| 2040 | | win_message_box_utf8(hMain, MAMENAME " has failed its validity checks. The GUI will " |
| 2041 | | "still work, but emulations will fail to execute", MAMENAME, MB_OK); |
| 2042 | | } |
| 2043 | | |
| 2044 | | return TRUE; |
| 2045 | | } |
| 2046 | | |
| 2047 | | |
| 2048 | | static void Win32UI_exit() |
| 2049 | | { |
| 2050 | | if (g_bDoBroadcast == TRUE) |
| 2051 | | { |
| 2052 | | ATOM a = GlobalAddAtom(TEXT("")); |
| 2053 | | SendMessage(HWND_BROADCAST, g_mame32_message, a, a); |
| 2054 | | GlobalDeleteAtom(a); |
| 2055 | | } |
| 2056 | | |
| 2057 | | if (g_pJoyGUI != NULL) |
| 2058 | | g_pJoyGUI->exit(); |
| 2059 | | |
| 2060 | | /* Free GDI resources */ |
| 2061 | | |
| 2062 | | if (hMissing_bitmap) |
| 2063 | | { |
| 2064 | | DeleteObject(hMissing_bitmap); |
| 2065 | | hMissing_bitmap = NULL; |
| 2066 | | } |
| 2067 | | |
| 2068 | | if (hBackground) |
| 2069 | | { |
| 2070 | | DeleteObject(hBackground); |
| 2071 | | hBackground = NULL; |
| 2072 | | } |
| 2073 | | |
| 2074 | | if (hPALbg) |
| 2075 | | { |
| 2076 | | DeleteObject(hPALbg); |
| 2077 | | hPALbg = NULL; |
| 2078 | | } |
| 2079 | | |
| 2080 | | if (hFont) |
| 2081 | | { |
| 2082 | | DeleteObject(hFont); |
| 2083 | | hFont = NULL; |
| 2084 | | } |
| 2085 | | |
| 2086 | | DestroyIcons(); |
| 2087 | | |
| 2088 | | DestroyAcceleratorTable(hAccel); |
| 2089 | | |
| 2090 | | DirectInputClose(); |
| 2091 | | DirectDraw_Close(); |
| 2092 | | |
| 2093 | | SetSavedFolderID(GetCurrentFolderID()); |
| 2094 | | |
| 2095 | | SaveOptions(); |
| 2096 | | |
| 2097 | | FreeFolders(); |
| 2098 | | |
| 2099 | | /* DestroyTree(hTreeView); */ |
| 2100 | | |
| 2101 | | FreeScreenShot(); |
| 2102 | | |
| 2103 | | OptionsExit(); |
| 2104 | | |
| 2105 | | HelpExit(); |
| 2106 | | |
| 2107 | | pool_free(mame32_pool); |
| 2108 | | mame32_pool = NULL; |
| 2109 | | } |
| 2110 | | |
| 2111 | | static long WINAPI MameWindowProc(HWND hWnd, UINT message, UINT wParam, LONG lParam) |
| 2112 | | { |
| 2113 | | MINMAXINFO *mminfo; |
| 2114 | | int i; |
| 2115 | | TCHAR szClass[128]; |
| 2116 | | |
| 2117 | | switch (message) |
| 2118 | | { |
| 2119 | | case WM_CTLCOLORSTATIC: |
| 2120 | | if (hBackground && (HWND)lParam == GetDlgItem(hMain, IDC_HISTORY)) |
| 2121 | | { |
| 2122 | | static HBRUSH hBrush=0; |
| 2123 | | HDC hDC=(HDC)wParam; |
| 2124 | | LOGBRUSH lb; |
| 2125 | | |
| 2126 | | if (hBrush) |
| 2127 | | DeleteObject(hBrush); |
| 2128 | | lb.lbStyle = BS_HOLLOW; |
| 2129 | | hBrush = CreateBrushIndirect(&lb); |
| 2130 | | SetBkMode(hDC, TRANSPARENT); |
| 2131 | | SetTextColor(hDC, GetListFontColor()); |
| 2132 | | return (LRESULT) hBrush; |
| 2133 | | } |
| 2134 | | break; |
| 2135 | | |
| 2136 | | case WM_INITDIALOG: |
| 2137 | | /* Initialize info for resizing subitems */ |
| 2138 | | GetClientRect(hWnd, &main_resize.rect); |
| 2139 | | return TRUE; |
| 2140 | | |
| 2141 | | case WM_SETFOCUS: |
| 2142 | | SetFocus(hwndList); |
| 2143 | | break; |
| 2144 | | |
| 2145 | | case WM_SETTINGCHANGE: |
| 2146 | | AdjustMetrics(); |
| 2147 | | return 0; |
| 2148 | | |
| 2149 | | case WM_SIZE: |
| 2150 | | OnSize(hWnd, wParam, LOWORD(lParam), HIWORD(wParam)); |
| 2151 | | return TRUE; |
| 2152 | | |
| 2153 | | case WM_MENUSELECT: |
| 2154 | | return Statusbar_MenuSelect(hWnd, wParam, lParam); |
| 2155 | | |
| 2156 | | case MM_PLAY_GAME: |
| 2157 | | MamePlayGame(); |
| 2158 | | return TRUE; |
| 2159 | | |
| 2160 | | case WM_INITMENUPOPUP: |
| 2161 | | UpdateMenu(GetMenu(hWnd)); |
| 2162 | | break; |
| 2163 | | |
| 2164 | | case WM_CONTEXTMENU: |
| 2165 | | if (HandleTreeContextMenu(hWnd, wParam, lParam) |
| 2166 | | || HandleScreenShotContextMenu(hWnd, wParam, lParam)) |
| 2167 | | return FALSE; |
| 2168 | | break; |
| 2169 | | |
| 2170 | | case WM_COMMAND: |
| 2171 | | return MameCommand(hWnd,(int)(LOWORD(wParam)),(HWND)(lParam),(UINT)HIWORD(wParam)); |
| 2172 | | |
| 2173 | | case WM_GETMINMAXINFO: |
| 2174 | | /* Don't let the window get too small; it can break resizing */ |
| 2175 | | mminfo = (MINMAXINFO *) lParam; |
| 2176 | | mminfo->ptMinTrackSize.x = MIN_WIDTH; |
| 2177 | | mminfo->ptMinTrackSize.y = MIN_HEIGHT; |
| 2178 | | return 0; |
| 2179 | | |
| 2180 | | case WM_TIMER: |
| 2181 | | switch (wParam) |
| 2182 | | { |
| 2183 | | case JOYGUI_TIMER: |
| 2184 | | PollGUIJoystick(); |
| 2185 | | break; |
| 2186 | | case SCREENSHOT_TIMER: |
| 2187 | | TabView_CalculateNextTab(hTabCtrl); |
| 2188 | | UpdateScreenShot(); |
| 2189 | | TabView_UpdateSelection(hTabCtrl); |
| 2190 | | break; |
| 2191 | | default: |
| 2192 | | break; |
| 2193 | | } |
| 2194 | | return TRUE; |
| 2195 | | |
| 2196 | | case WM_CLOSE: |
| 2197 | | { |
| 2198 | | /* save current item */ |
| 2199 | | RECT rect; |
| 2200 | | AREA area; |
| 2201 | | int nItem; |
| 2202 | | WINDOWPLACEMENT wndpl; |
| 2203 | | UINT state; |
| 2204 | | |
| 2205 | | wndpl.length = sizeof(WINDOWPLACEMENT); |
| 2206 | | GetWindowPlacement(hMain, &wndpl); |
| 2207 | | state = wndpl.showCmd; |
| 2208 | | |
| 2209 | | /* Restore the window before we attempt to save parameters, |
| 2210 | | * This fixed the lost window on startup problem, among other problems |
| 2211 | | */ |
| 2212 | | if (state == SW_MINIMIZE || state == SW_SHOWMINIMIZED || state == SW_MAXIMIZE) |
| 2213 | | { |
| 2214 | | if( wndpl.flags & WPF_RESTORETOMAXIMIZED || state == SW_MAXIMIZE) |
| 2215 | | state = SW_MAXIMIZE; |
| 2216 | | else |
| 2217 | | { |
| 2218 | | state = SW_RESTORE; |
| 2219 | | ShowWindow(hWnd, SW_RESTORE); |
| 2220 | | } |
| 2221 | | } |
| 2222 | | for (i = 0; i < GetSplitterCount(); i++) |
| 2223 | | SetSplitterPos(i, nSplitterOffset[i]); |
| 2224 | | SetWindowState(state); |
| 2225 | | |
| 2226 | | for (i = 0; i < sizeof(s_nPickers) / sizeof(s_nPickers[0]); i++) |
| 2227 | | Picker_SaveColumnWidths(GetDlgItem(hMain, s_nPickers[i])); |
| 2228 | | |
| 2229 | | GetWindowRect(hWnd, &rect); |
| 2230 | | area.x = rect.left; |
| 2231 | | area.y = rect.top; |
| 2232 | | area.width = rect.right - rect.left; |
| 2233 | | area.height = rect.bottom - rect.top; |
| 2234 | | SetWindowArea(&area); |
| 2235 | | |
| 2236 | | /* Save the users current game options and default game */ |
| 2237 | | nItem = Picker_GetSelectedItem(hwndList); |
| 2238 | | SetDefaultGame(ModifyThe(drivers[nItem]->name)); |
| 2239 | | |
| 2240 | | /* hide window to prevent orphan empty rectangles on the taskbar */ |
| 2241 | | /* ShowWindow(hWnd,SW_HIDE); */ |
| 2242 | | DestroyWindow( hWnd ); |
| 2243 | | |
| 2244 | | /* PostQuitMessage(0); */ |
| 2245 | | break; |
| 2246 | | } |
| 2247 | | |
| 2248 | | case WM_DESTROY: |
| 2249 | | PostQuitMessage(0); |
| 2250 | | return 0; |
| 2251 | | |
| 2252 | | case WM_LBUTTONDOWN: |
| 2253 | | OnLButtonDown(hWnd, (UINT)wParam, MAKEPOINTS(lParam)); |
| 2254 | | break; |
| 2255 | | |
| 2256 | | /* |
| 2257 | | Check to see if the mouse has been moved by the user since |
| 2258 | | startup. I'd like this checking to be done only in the |
| 2259 | | main WinProc (here), but somehow the WM_MOUSEDOWN messages |
| 2260 | | are eaten up before they reach MameWindowProc. That's why |
| 2261 | | there is one check for each of the subclassed windows too. |
| 2262 | | |
| 2263 | | POSSIBLE BUGS: |
| 2264 | | I've included this check in the subclassed windows, but a |
| 2265 | | mose move in either the title bar, the menu, or the |
| 2266 | | toolbar will not generate a WM_MOUSEOVER message. At least |
| 2267 | | not one that I know how to pick up. A solution could maybe |
| 2268 | | be to subclass those too, but that's too much work :) |
| 2269 | | */ |
| 2270 | | |
| 2271 | | case WM_MOUSEMOVE: |
| 2272 | | { |
| 2273 | | if (MouseHasBeenMoved()) |
| 2274 | | ShowCursor(TRUE); |
| 2275 | | |
| 2276 | | if (g_listview_dragging) |
| 2277 | | MouseMoveListViewDrag(MAKEPOINTS(lParam)); |
| 2278 | | else |
| 2279 | | /* for splitters */ |
| 2280 | | OnMouseMove(hWnd, (UINT)wParam, MAKEPOINTS(lParam)); |
| 2281 | | break; |
| 2282 | | } |
| 2283 | | |
| 2284 | | case WM_LBUTTONUP: |
| 2285 | | if (g_listview_dragging) |
| 2286 | | ButtonUpListViewDrag(MAKEPOINTS(lParam)); |
| 2287 | | else |
| 2288 | | /* for splitters */ |
| 2289 | | OnLButtonUp(hWnd, (UINT)wParam, MAKEPOINTS(lParam)); |
| 2290 | | break; |
| 2291 | | |
| 2292 | | case WM_NOTIFY: |
| 2293 | | /* Where is this message intended to go */ |
| 2294 | | { |
| 2295 | | LPNMHDR lpNmHdr = (LPNMHDR)lParam; |
| 2296 | | |
| 2297 | | /* Fetch tooltip text */ |
| 2298 | | if (lpNmHdr->code == TTN_NEEDTEXT) |
| 2299 | | { |
| 2300 | | LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT)lParam; |
| 2301 | | CopyToolTipText(lpttt); |
| 2302 | | } |
| 2303 | | |
| 2304 | | if (lpNmHdr->hwndFrom == hTreeView) |
| 2305 | | return TreeViewNotify(lpNmHdr); |
| 2306 | | |
| 2307 | | GetClassName(lpNmHdr->hwndFrom, szClass, sizeof(szClass) / sizeof(szClass[0])); |
| 2308 | | if (!_tcscmp(szClass, TEXT("SysListView32"))) |
| 2309 | | return Picker_HandleNotify(lpNmHdr); |
| 2310 | | if (!_tcscmp(szClass, TEXT("SysTabControl32"))) |
| 2311 | | return TabView_HandleNotify(lpNmHdr); |
| 2312 | | } |
| 2313 | | break; |
| 2314 | | |
| 2315 | | case WM_DRAWITEM: |
| 2316 | | { |
| 2317 | | LPDRAWITEMSTRUCT lpDis = (LPDRAWITEMSTRUCT)lParam; |
| 2318 | | |
| 2319 | | GetClassName(lpDis->hwndItem, szClass, sizeof(szClass) / sizeof(szClass[0])); |
| 2320 | | if (!_tcscmp(szClass, TEXT("SysListView32"))) |
| 2321 | | Picker_HandleDrawItem(GetDlgItem(hMain, lpDis->CtlID), lpDis); |
| 2322 | | } |
| 2323 | | break; |
| 2324 | | |
| 2325 | | case WM_MEASUREITEM : |
| 2326 | | { |
| 2327 | | LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam; |
| 2328 | | |
| 2329 | | // tell the list view that each row (item) should be just taller than our font |
| 2330 | | |
| 2331 | | //DefWindowProc(hWnd, message, wParam, lParam); |
| 2332 | | //dprintf("default row height calculation gives %u\n",lpmis->itemHeight); |
| 2333 | | |
| 2334 | | TEXTMETRIC tm; |
| 2335 | | HDC hDC = GetDC(NULL); |
| 2336 | | HFONT hFontOld = (HFONT)SelectObject(hDC,hFont); |
| 2337 | | |
| 2338 | | GetTextMetrics(hDC,&tm); |
| 2339 | | |
| 2340 | | lpmis->itemHeight = tm.tmHeight + tm.tmExternalLeading + 1; |
| 2341 | | if (lpmis->itemHeight < 17) |
| 2342 | | lpmis->itemHeight = 17; |
| 2343 | | //dprintf("we would do %u\n",tm.tmHeight + tm.tmExternalLeading + 1); |
| 2344 | | SelectObject(hDC,hFontOld); |
| 2345 | | ReleaseDC(NULL,hDC); |
| 2346 | | |
| 2347 | | return TRUE; |
| 2348 | | } |
| 2349 | | |
| 2350 | | case WM_MAME32_FILECHANGED: |
| 2351 | | { |
| 2352 | | char szFileName[32]; |
| 2353 | | char *s; |
| 2354 | | int nGameIndex; |
| 2355 | | int (*pfnGetAuditResults)(int driver_index) = NULL; |
| 2356 | | void (*pfnSetAuditResults)(int driver_index, int audit_results) = NULL; |
| 2357 | | |
| 2358 | | switch(HIWORD(wParam)) |
| 2359 | | { |
| 2360 | | case 0: |
| 2361 | | pfnGetAuditResults = GetRomAuditResults; |
| 2362 | | pfnSetAuditResults = SetRomAuditResults; |
| 2363 | | break; |
| 2364 | | |
| 2365 | | case 1: |
| 2366 | | pfnGetAuditResults = GetSampleAuditResults; |
| 2367 | | pfnSetAuditResults = SetSampleAuditResults; |
| 2368 | | break; |
| 2369 | | } |
| 2370 | | |
| 2371 | | if (pfnGetAuditResults && pfnSetAuditResults) |
| 2372 | | { |
| 2373 | | int nParentIndex = -1; |
| 2374 | | |
| 2375 | | snprintf(szFileName, sizeof(szFileName), "%s", (LPCSTR) lParam); |
| 2376 | | s = strchr(szFileName, '.'); |
| 2377 | | if (s) |
| 2378 | | *s = '\0'; |
| 2379 | | s = strchr(szFileName, '\\'); |
| 2380 | | if (s) |
| 2381 | | *s = '\0'; |
| 2382 | | |
| 2383 | | for (nGameIndex = 0; drivers[nGameIndex]; nGameIndex++) |
| 2384 | | { |
| 2385 | | for (nParentIndex = nGameIndex; nGameIndex == -1; nParentIndex = GetParentIndex(drivers[nParentIndex])) |
| 2386 | | { |
| 2387 | | if (!mame_stricmp(drivers[nParentIndex]->name, szFileName)) |
| 2388 | | { |
| 2389 | | if (pfnGetAuditResults(nGameIndex) != UNKNOWN) |
| 2390 | | { |
| 2391 | | pfnSetAuditResults(nGameIndex, UNKNOWN); |
| 2392 | | PostMessage(hMain, WM_MAME32_AUDITGAME, wParam, nGameIndex); |
| 2393 | | } |
| 2394 | | break; |
| 2395 | | } |
| 2396 | | } |
| 2397 | | } |
| 2398 | | } |
| 2399 | | } |
| 2400 | | break; |
| 2401 | | |
| 2402 | | case WM_MAME32_AUDITGAME: |
| 2403 | | { |
| 2404 | | LV_FINDINFO lvfi; |
| 2405 | | int nGameIndex; |
| 2406 | | |
| 2407 | | nGameIndex = lParam; |
| 2408 | | |
| 2409 | | switch(HIWORD(wParam)) |
| 2410 | | { |
| 2411 | | case 0: |
| 2412 | | Mame32VerifyRomSet(nGameIndex); |
| 2413 | | break; |
| 2414 | | case 1: |
| 2415 | | Mame32VerifySampleSet(nGameIndex); |
| 2416 | | break; |
| 2417 | | } |
| 2418 | | |
| 2419 | | memset(&lvfi, 0, sizeof(lvfi)); |
| 2420 | | lvfi.flags = LVFI_PARAM; |
| 2421 | | lvfi.lParam = nGameIndex; |
| 2422 | | |
| 2423 | | i = ListView_FindItem(hwndList, -1, &lvfi); |
| 2424 | | if (i != -1) |
| 2425 | | { |
| 2426 | | ListView_RedrawItems(hwndList, i, i); |
| 2427 | | } |
| 2428 | | } |
| 2429 | | break; |
| 2430 | | |
| 2431 | | default: |
| 2432 | | |
| 2433 | | break; |
| 2434 | | } |
| 2435 | | |
| 2436 | | return DefWindowProc(hWnd, message, wParam, lParam); |
| 2437 | | } |
| 2438 | | |
| 2439 | | static int HandleKeyboardGUIMessage(HWND hWnd, UINT message, UINT wParam, LONG lParam) |
| 2440 | | { |
| 2441 | | switch (message) |
| 2442 | | { |
| 2443 | | case WM_CHAR: /* List-View controls use this message for searching the items "as user types" */ |
| 2444 | | //MessageBox(NULL,"wm_char message arrived","TitleBox",MB_OK); |
| 2445 | | return TRUE; |
| 2446 | | |
| 2447 | | case WM_KEYDOWN: |
| 2448 | | KeyboardKeyDown(0, wParam, lParam); |
| 2449 | | return TRUE; |
| 2450 | | |
| 2451 | | case WM_KEYUP: |
| 2452 | | KeyboardKeyUp(0, wParam, lParam); |
| 2453 | | return TRUE; |
| 2454 | | |
| 2455 | | case WM_SYSKEYDOWN: |
| 2456 | | KeyboardKeyDown(1, wParam, lParam); |
| 2457 | | return TRUE; |
| 2458 | | |
| 2459 | | case WM_SYSKEYUP: |
| 2460 | | KeyboardKeyUp(1, wParam, lParam); |
| 2461 | | return TRUE; |
| 2462 | | } |
| 2463 | | |
| 2464 | | return FALSE; /* message not processed */ |
| 2465 | | } |
| 2466 | | |
| 2467 | | static BOOL PumpMessage() |
| 2468 | | { |
| 2469 | | MSG msg; |
| 2470 | | |
| 2471 | | if (!GetMessage(&msg, NULL, 0, 0)) |
| 2472 | | { |
| 2473 | | return FALSE; |
| 2474 | | } |
| 2475 | | |
| 2476 | | if (IsWindow(hMain)) |
| 2477 | | { |
| 2478 | | BOOL absorbed_key = FALSE; |
| 2479 | | if (GetKeyGUI()) |
| 2480 | | absorbed_key = HandleKeyboardGUIMessage(msg.hwnd, msg.message, |
| 2481 | | msg.wParam, msg.lParam); |
| 2482 | | else |
| 2483 | | absorbed_key = TranslateAccelerator(hMain, hAccel, &msg); |
| 2484 | | |
| 2485 | | if (!absorbed_key) |
| 2486 | | { |
| 2487 | | if (!IsDialogMessage(hMain, &msg)) |
| 2488 | | { |
| 2489 | | TranslateMessage(&msg); |
| 2490 | | DispatchMessage(&msg); |
| 2491 | | } |
| 2492 | | } |
| 2493 | | } |
| 2494 | | |
| 2495 | | return TRUE; |
| 2496 | | } |
| 2497 | | |
| 2498 | | static BOOL FolderCheck(void) |
| 2499 | | { |
| 2500 | | |
| 2501 | | char *pDescription = NULL; |
| 2502 | | int nGameIndex = 0; |
| 2503 | | int i=0; |
| 2504 | | int iStep = 0; |
| 2505 | | LV_FINDINFO lvfi; |
| 2506 | | int nCount = ListView_GetItemCount(hwndList); |
| 2507 | | BOOL changed = FALSE; |
| 2508 | | |
| 2509 | | MSG msg; |
| 2510 | | for(i=0; i<nCount;i++) |
| 2511 | | { |
| 2512 | | LV_ITEM lvi; |
| 2513 | | |
| 2514 | | lvi.iItem = i; |
| 2515 | | lvi.iSubItem = 0; |
| 2516 | | lvi.mask = LVIF_PARAM; |
| 2517 | | ListView_GetItem(hwndList, &lvi); |
| 2518 | | nGameIndex = lvi.lParam; |
| 2519 | | SetRomAuditResults(nGameIndex, UNKNOWN); |
| 2520 | | SetSampleAuditResults(nGameIndex, UNKNOWN); |
| 2521 | | } |
| 2522 | | if( nCount > 0) |
| 2523 | | ProgressBarShow(); |
| 2524 | | else |
| 2525 | | return FALSE; |
| 2526 | | if( nCount < 100 ) |
| 2527 | | iStep = 100 / nCount; |
| 2528 | | else |
| 2529 | | iStep = nCount/100; |
| 2530 | | UpdateListView(); |
| 2531 | | UpdateWindow(hMain); |
| 2532 | | for(i=0; i<nCount;i++) |
| 2533 | | { |
| 2534 | | LV_ITEM lvi; |
| 2535 | | |
| 2536 | | lvi.iItem = i; |
| 2537 | | lvi.iSubItem = 0; |
| 2538 | | lvi.mask = LVIF_PARAM; |
| 2539 | | ListView_GetItem(hwndList, &lvi); |
| 2540 | | nGameIndex = lvi.lParam; |
| 2541 | | if (GetRomAuditResults(nGameIndex) == UNKNOWN) |
| 2542 | | { |
| 2543 | | Mame32VerifyRomSet(nGameIndex); |
| 2544 | | changed = TRUE; |
| 2545 | | } |
| 2546 | | |
| 2547 | | if (GetSampleAuditResults(nGameIndex) == UNKNOWN) |
| 2548 | | { |
| 2549 | | Mame32VerifySampleSet(nGameIndex); |
| 2550 | | changed = TRUE; |
| 2551 | | } |
| 2552 | | |
| 2553 | | lvfi.flags = LVFI_PARAM; |
| 2554 | | lvfi.lParam = nGameIndex; |
| 2555 | | |
| 2556 | | i = ListView_FindItem(hwndList, -1, &lvfi); |
| 2557 | | if (changed && i != -1); |
| 2558 | | { |
| 2559 | | ListView_RedrawItems(hwndList, i, i); |
| 2560 | | while( PeekMessage( &msg, hwndList, 0, 0, PM_REMOVE ) != 0) |
| 2561 | | { |
| 2562 | | TranslateMessage(&msg); |
| 2563 | | DispatchMessage(&msg); |
| 2564 | | } |
| 2565 | | } |
| 2566 | | changed = FALSE; |
| 2567 | | if ((i % iStep) == 0) |
| 2568 | | ProgressBarStepParam(i, nCount); |
| 2569 | | } |
| 2570 | | ProgressBarHide(); |
| 2571 | | pDescription = ModifyThe(drivers[Picker_GetSelectedItem(hwndList)]->description); |
| 2572 | | SetStatusBarText(0, pDescription); |
| 2573 | | UpdateStatusBar(); |
| 2574 | | return TRUE; |
| 2575 | | } |
| 2576 | | |
| 2577 | | static BOOL GameCheck(void) |
| 2578 | | { |
| 2579 | | LV_FINDINFO lvfi; |
| 2580 | | int i; |
| 2581 | | BOOL changed = FALSE; |
| 2582 | | |
| 2583 | | if (game_index == 0) |
| 2584 | | ProgressBarShow(); |
| 2585 | | |
| 2586 | | if (game_index >= driver_list_get_count(drivers)) |
| 2587 | | { |
| 2588 | | bDoGameCheck = FALSE; |
| 2589 | | ProgressBarHide(); |
| 2590 | | ResetWhichGamesInFolders(); |
| 2591 | | return FALSE; |
| 2592 | | } |
| 2593 | | |
| 2594 | | if (GetRomAuditResults(game_index) == UNKNOWN) |
| 2595 | | { |
| 2596 | | Mame32VerifyRomSet(game_index); |
| 2597 | | changed = TRUE; |
| 2598 | | } |
| 2599 | | |
| 2600 | | if (GetSampleAuditResults(game_index) == UNKNOWN) |
| 2601 | | { |
| 2602 | | Mame32VerifySampleSet(game_index); |
| 2603 | | changed = TRUE; |
| 2604 | | } |
| 2605 | | |
| 2606 | | lvfi.flags = LVFI_PARAM; |
| 2607 | | lvfi.lParam = game_index; |
| 2608 | | |
| 2609 | | i = ListView_FindItem(hwndList, -1, &lvfi); |
| 2610 | | if (changed && i != -1); |
| 2611 | | ListView_RedrawItems(hwndList, i, i); |
| 2612 | | if ((game_index % progBarStep) == 0) |
| 2613 | | ProgressBarStep(); |
| 2614 | | game_index++; |
| 2615 | | |
| 2616 | | return changed; |
| 2617 | | } |
| 2618 | | |
| 2619 | | static BOOL OnIdle(HWND hWnd) |
| 2620 | | { |
| 2621 | | static int bFirstTime = TRUE; |
| 2622 | | static int bResetList = TRUE; |
| 2623 | | |
| 2624 | | char *pDescription; |
| 2625 | | int driver_index; |
| 2626 | | |
| 2627 | | if (bFirstTime) |
| 2628 | | { |
| 2629 | | bResetList = FALSE; |
| 2630 | | bFirstTime = FALSE; |
| 2631 | | } |
| 2632 | | if (bDoGameCheck) |
| 2633 | | { |
| 2634 | | bResetList |= GameCheck(); |
| 2635 | | return idle_work; |
| 2636 | | } |
| 2637 | | // NPW 17-Jun-2003 - Commenting this out because it is redundant |
| 2638 | | // and it causes the game to reset back to the original game after an F5 |
| 2639 | | // refresh |
| 2640 | | //driver_index = GetGameNameIndex(GetDefaultGame()); |
| 2641 | | //SetSelectedPickItem(driver_index); |
| 2642 | | |
| 2643 | | // in case it's not found, get it back |
| 2644 | | driver_index = Picker_GetSelectedItem(hwndList); |
| 2645 | | |
| 2646 | | pDescription = ModifyThe(drivers[driver_index]->description); |
| 2647 | | SetStatusBarText(0, pDescription); |
| 2648 | | idle_work = FALSE; |
| 2649 | | UpdateStatusBar(); |
| 2650 | | bFirstTime = TRUE; |
| 2651 | | |
| 2652 | | if (!idle_work) |
| 2653 | | PostMessage(GetMainWindow(),WM_COMMAND, MAKEWPARAM(ID_VIEW_LINEUPICONS, TRUE),(LPARAM)NULL); |
| 2654 | | return idle_work; |
| 2655 | | } |
| 2656 | | |
| 2657 | | static void OnSize(HWND hWnd, UINT nState, int nWidth, int nHeight) |
| 2658 | | { |
| 2659 | | static BOOL firstTime = TRUE; |
| 2660 | | |
| 2661 | | if (nState != SIZE_MAXIMIZED && nState != SIZE_RESTORED) |
| 2662 | | return; |
| 2663 | | |
| 2664 | | ResizeWindow(hWnd, &main_resize); |
| 2665 | | ResizeProgressBar(); |
| 2666 | | if (firstTime == FALSE) |
| 2667 | | OnSizeSplitter(hMain); |
| 2668 | | //firstTime = FALSE; |
| 2669 | | /* Update the splitters structures as appropriate */ |
| 2670 | | RecalcSplitters(); |
| 2671 | | if (firstTime == FALSE) |
| 2672 | | ResizePickerControls(hMain); |
| 2673 | | firstTime = FALSE; |
| 2674 | | UpdateScreenShot(); |
| 2675 | | } |
| 2676 | | |
| 2677 | | |
| 2678 | | |
| 2679 | | static HWND GetResizeItemWindow(HWND hParent, const ResizeItem *ri) |
| 2680 | | { |
| 2681 | | HWND hControl; |
| 2682 | | if (ri->type == RA_ID) |
| 2683 | | hControl = GetDlgItem(hParent, ri->u.id); |
| 2684 | | else |
| 2685 | | hControl = ri->u.hwnd; |
| 2686 | | return hControl; |
| 2687 | | } |
| 2688 | | |
| 2689 | | |
| 2690 | | |
| 2691 | | static void SetAllWindowsFont(HWND hParent, const Resize *r, HFONT hTheFont, BOOL bRedraw) |
| 2692 | | { |
| 2693 | | int i; |
| 2694 | | HWND hControl; |
| 2695 | | |
| 2696 | | for (i = 0; r->items[i].type != RA_END; i++) |
| 2697 | | { |
| 2698 | | if (r->items[i].setfont) |
| 2699 | | { |
| 2700 | | hControl = GetResizeItemWindow(hParent, &r->items[i]); |
| 2701 | | SetWindowFont(hControl, hTheFont, bRedraw); |
| 2702 | | } |
| 2703 | | } |
| 2704 | | } |
| 2705 | | |
| 2706 | | |
| 2707 | | |
| 2708 | | static void ResizeWindow(HWND hParent, Resize *r) |
| 2709 | | { |
| 2710 | | int cmkindex = 0, dx, dy, dx1, dtempx; |
| 2711 | | HWND hControl; |
| 2712 | | RECT parent_rect, rect; |
| 2713 | | ResizeItem *ri; |
| 2714 | | POINT p = {0, 0}; |
| 2715 | | |
| 2716 | | if (hParent == NULL) |
| 2717 | | return; |
| 2718 | | |
| 2719 | | /* Calculate change in width and height of parent window */ |
| 2720 | | GetClientRect(hParent, &parent_rect); |
| 2721 | | //dx = parent_rect.right - r->rect.right; |
| 2722 | | dtempx = parent_rect.right - r->rect.right; |
| 2723 | | dy = parent_rect.bottom - r->rect.bottom; |
| 2724 | | dx = dtempx/2; |
| 2725 | | dx1 = dtempx - dx; |
| 2726 | | ClientToScreen(hParent, &p); |
| 2727 | | |
| 2728 | | while (r->items[cmkindex].type != RA_END) |
| 2729 | | { |
| 2730 | | ri = &r->items[cmkindex]; |
| 2731 | | if (ri->type == RA_ID) |
| 2732 | | hControl = GetDlgItem(hParent, ri->u.id); |
| 2733 | | else |
| 2734 | | hControl = ri->u.hwnd; |
| 2735 | | |
| 2736 | | if (hControl == NULL) |
| 2737 | | { |
| 2738 | | cmkindex++; |
| 2739 | | continue; |
| 2740 | | } |
| 2741 | | |
| 2742 | | /* Get control's rectangle relative to parent */ |
| 2743 | | GetWindowRect(hControl, &rect); |
| 2744 | | OffsetRect(&rect, -p.x, -p.y); |
| 2745 | | |
| 2746 | | if (!(ri->action & RA_LEFT)) |
| 2747 | | rect.left += dx; |
| 2748 | | |
| 2749 | | if (!(ri->action & RA_TOP)) |
| 2750 | | rect.top += dy; |
| 2751 | | |
| 2752 | | if (ri->action & RA_RIGHT) |
| 2753 | | rect.right += dx; |
| 2754 | | |
| 2755 | | if (ri->action & RA_BOTTOM) |
| 2756 | | rect.bottom += dy; |
| 2757 | | |
| 2758 | | MoveWindow(hControl, rect.left, rect.top, |
| 2759 | | (rect.right - rect.left), |
| 2760 | | (rect.bottom - rect.top), TRUE); |
| 2761 | | |
| 2762 | | /* Take care of subcontrols, if appropriate */ |
| 2763 | | if (ri->subwindow != NULL) |
| 2764 | | ResizeWindow(hControl, ri->subwindow); |
| 2765 | | |
| 2766 | | cmkindex++; |
| 2767 | | } |
| 2768 | | |
| 2769 | | /* Record parent window's new location */ |
| 2770 | | memcpy(&r->rect, &parent_rect, sizeof(RECT)); |
| 2771 | | } |
| 2772 | | |
| 2773 | | static void ProgressBarShow() |
| 2774 | | { |
| 2775 | | RECT rect; |
| 2776 | | int widths[2] = {150, -1}; |
| 2777 | | |
| 2778 | | if (driver_list_get_count(drivers) < 100) |
| 2779 | | progBarStep = 100 / driver_list_get_count(drivers); |
| 2780 | | else |
| 2781 | | progBarStep = (driver_list_get_count(drivers) / 100); |
| 2782 | | |
| 2783 | | SendMessage(hStatusBar, SB_SETPARTS, (WPARAM)2, (LPARAM)(LPINT)widths); |
| 2784 | | SendMessage(hProgWnd, PBM_SETRANGE, 0, (LPARAM)MAKELONG(0, driver_list_get_count(drivers))); |
| 2785 | | SendMessage(hProgWnd, PBM_SETSTEP, (WPARAM)progBarStep, 0); |
| 2786 | | SendMessage(hProgWnd, PBM_SETPOS, 0, 0); |
| 2787 | | |
| 2788 | | StatusBar_GetItemRect(hStatusBar, 1, &rect); |
| 2789 | | |
| 2790 | | MoveWindow(hProgWnd, rect.left, rect.top, |
| 2791 | | rect.right - rect.left, |
| 2792 | | rect.bottom - rect.top, TRUE); |
| 2793 | | |
| 2794 | | bProgressShown = TRUE; |
| 2795 | | } |
| 2796 | | |
| 2797 | | static void ProgressBarHide() |
| 2798 | | { |
| 2799 | | RECT rect; |
| 2800 | | int widths[4]; |
| 2801 | | HDC hDC; |
| 2802 | | SIZE size; |
| 2803 | | int numParts = 4; |
| 2804 | | |
| 2805 | | if (hProgWnd == NULL) |
| 2806 | | { |
| 2807 | | return; |
| 2808 | | } |
| 2809 | | |
| 2810 | | hDC = GetDC(hProgWnd); |
| 2811 | | |
| 2812 | | ShowWindow(hProgWnd, SW_HIDE); |
| 2813 | | |
| 2814 | | GetTextExtentPoint32(hDC, TEXT("MMX"), 3, &size); |
| 2815 | | widths[3] = size.cx; |
| 2816 | | GetTextExtentPoint32(hDC, TEXT("MMMM games"), 10, &size); |
| 2817 | | widths[2] = size.cx; |
| 2818 | | //Just specify 24 instead of 30, gives us sufficient space to display the message, and saves some space |
| 2819 | | GetTextExtentPoint32(hDC, TEXT("Screen flip support is missing"), 24, &size); |
| 2820 | | widths[1] = size.cx; |
| 2821 | | |
| 2822 | | ReleaseDC(hProgWnd, hDC); |
| 2823 | | |
| 2824 | | widths[0] = -1; |
| 2825 | | SendMessage(hStatusBar, SB_SETPARTS, (WPARAM)1, (LPARAM)(LPINT)widths); |
| 2826 | | StatusBar_GetItemRect(hStatusBar, 0, &rect); |
| 2827 | | |
| 2828 | | widths[0] = (rect.right - rect.left) - (widths[1] + widths[2] + widths[3]); |
| 2829 | | widths[1] += widths[0]; |
| 2830 | | widths[2] += widths[1]; |
| 2831 | | widths[3] = -1; |
| 2832 | | |
| 2833 | | SendMessage(hStatusBar, SB_SETPARTS, (WPARAM)numParts, (LPARAM)(LPINT)widths); |
| 2834 | | UpdateStatusBar(); |
| 2835 | | |
| 2836 | | bProgressShown = FALSE; |
| 2837 | | } |
| 2838 | | |
| 2839 | | static void ResizeProgressBar() |
| 2840 | | { |
| 2841 | | if (bProgressShown) |
| 2842 | | { |
| 2843 | | RECT rect; |
| 2844 | | int widths[2] = {150, -1}; |
| 2845 | | |
| 2846 | | SendMessage(hStatusBar, SB_SETPARTS, (WPARAM)2, (LPARAM)(LPINT)widths); |
| 2847 | | StatusBar_GetItemRect(hStatusBar, 1, &rect); |
| 2848 | | MoveWindow(hProgWnd, rect.left, rect.top, |
| 2849 | | rect.right - rect.left, |
| 2850 | | rect.bottom - rect.top, TRUE); |
| 2851 | | } |
| 2852 | | else |
| 2853 | | { |
| 2854 | | ProgressBarHide(); |
| 2855 | | } |
| 2856 | | } |
| 2857 | | |
| 2858 | | static void ProgressBarStepParam(int iGameIndex, int nGameCount) |
| 2859 | | { |
| 2860 | | SetStatusBarTextF(0, "Game search %d%% complete", |
| 2861 | | ((iGameIndex + 1) * 100) / nGameCount); |
| 2862 | | if (iGameIndex == 0) |
| 2863 | | ShowWindow(hProgWnd, SW_SHOW); |
| 2864 | | SendMessage(hProgWnd, PBM_STEPIT, 0, 0); |
| 2865 | | } |
| 2866 | | |
| 2867 | | static void ProgressBarStep() |
| 2868 | | { |
| 2869 | | ProgressBarStepParam(game_index, driver_list_get_count(drivers)); |
| 2870 | | } |
| 2871 | | |
| 2872 | | static HWND InitProgressBar(HWND hParent) |
| 2873 | | { |
| 2874 | | RECT rect; |
| 2875 | | |
| 2876 | | StatusBar_GetItemRect(hStatusBar, 0, &rect); |
| 2877 | | |
| 2878 | | rect.left += 150; |
| 2879 | | |
| 2880 | | return CreateWindowEx(WS_EX_STATICEDGE, |
| 2881 | | PROGRESS_CLASS, |
| 2882 | | TEXT("Progress Bar"), |
| 2883 | | WS_CHILD | PBS_SMOOTH, |
| 2884 | | rect.left, |
| 2885 | | rect.top, |
| 2886 | | rect.right - rect.left, |
| 2887 | | rect.bottom - rect.top, |
| 2888 | | hParent, |
| 2889 | | NULL, |
| 2890 | | hInst, |
| 2891 | | NULL); |
| 2892 | | } |
| 2893 | | |
| 2894 | | static void CopyToolTipText(LPTOOLTIPTEXT lpttt) |
| 2895 | | { |
| 2896 | | int i; |
| 2897 | | int iButton = lpttt->hdr.idFrom; |
| 2898 | | static TCHAR String[1024]; |
| 2899 | | BOOL bConverted = FALSE; |
| 2900 | | TCHAR* t_gameinfostatus; |
| 2901 | | |
| 2902 | | /* Map command ID to string index */ |
| 2903 | | for (i = 0; CommandToString[i] != -1; i++) |
| 2904 | | { |
| 2905 | | if (CommandToString[i] == iButton) |
| 2906 | | { |
| 2907 | | iButton = i; |
| 2908 | | bConverted = TRUE; |
| 2909 | | break; |
| 2910 | | } |
| 2911 | | } |
| 2912 | | if( bConverted ) |
| 2913 | | { |
| 2914 | | /* Check for valid parameter */ |
| 2915 | | if(iButton > NUM_TOOLTIPS) |
| 2916 | | { |
| 2917 | | _tcscpy(String,TEXT("Invalid Button Index")); |
| 2918 | | } |
| 2919 | | else |
| 2920 | | { |
| 2921 | | _tcscpy(String,szTbStrings[iButton]); |
| 2922 | | } |
| 2923 | | } |
| 2924 | | else if ( iButton <= 2 ) |
| 2925 | | { |
| 2926 | | //Statusbar |
| 2927 | | SendMessage(lpttt->hdr.hwndFrom, TTM_SETMAXTIPWIDTH, 0, 200); |
| 2928 | | if( iButton != 1) |
| 2929 | | SendMessage(hStatusBar, SB_GETTEXT, (WPARAM)iButton, (LPARAM)&String ); |
| 2930 | | else { |
| 2931 | | //for first pane we get the Status directly, to get the line breaks |
| 2932 | | t_gameinfostatus = tstring_from_utf8( GameInfoStatus(Picker_GetSelectedItem(hwndList), FALSE)); |
| 2933 | | if( !t_gameinfostatus ) |
| 2934 | | return; |
| 2935 | | _tcscpy(String, t_gameinfostatus); |
| 2936 | | free(t_gameinfostatus); |
| 2937 | | } |
| 2938 | | } |
| 2939 | | else |
| 2940 | | _tcscpy(String,TEXT("Invalid Button Index")); |
| 2941 | | |
| 2942 | | lpttt->lpszText = String; |
| 2943 | | } |
| 2944 | | |
| 2945 | | static HWND InitToolbar(HWND hParent) |
| 2946 | | { |
| 2947 | | return CreateToolbarEx(hParent, |
| 2948 | | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | |
| 2949 | | CCS_TOP | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS, |
| 2950 | | 1, |
| 2951 | | 8, |
| 2952 | | hInst, |
| 2953 | | IDB_TOOLBAR, |
| 2954 | | tbb, |
| 2955 | | NUM_TOOLBUTTONS, |
| 2956 | | 16, |
| 2957 | | 16, |
| 2958 | | 0, |
| 2959 | | 0, |
| 2960 | | sizeof(TBBUTTON)); |
| 2961 | | } |
| 2962 | | |
| 2963 | | static HWND InitStatusBar(HWND hParent) |
| 2964 | | { |
| 2965 | | HMENU hMenu = GetMenu(hParent); |
| 2966 | | |
| 2967 | | popstr[0].hMenu = 0; |
| 2968 | | popstr[0].uiString = 0; |
| 2969 | | popstr[1].hMenu = hMenu; |
| 2970 | | popstr[1].uiString = IDS_UI_FILE; |
| 2971 | | popstr[2].hMenu = GetSubMenu(hMenu, 1); |
| 2972 | | popstr[2].uiString = IDS_UI_TOOLBAR; |
| 2973 | | popstr[3].hMenu = 0; |
| 2974 | | popstr[3].uiString = 0; |
| 2975 | | |
| 2976 | | return CreateStatusWindow(WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | |
| 2977 | | CCS_BOTTOM | SBARS_SIZEGRIP | SBT_TOOLTIPS, |
| 2978 | | TEXT("Ready"), |
| 2979 | | hParent, |
| 2980 | | 2); |
| 2981 | | } |
| 2982 | | |
| 2983 | | |
| 2984 | | static LRESULT Statusbar_MenuSelect(HWND hwnd, WPARAM wParam, LPARAM lParam) |
| 2985 | | { |
| 2986 | | UINT fuFlags = (UINT)HIWORD(wParam); |
| 2987 | | HMENU hMainMenu = NULL; |
| 2988 | | int iMenu = 0; |
| 2989 | | |
| 2990 | | /* Handle non-system popup menu descriptions. */ |
| 2991 | | if ( (fuFlags & MF_POPUP) |
| 2992 | | && (!(fuFlags & MF_SYSMENU))) |
| 2993 | | { |
| 2994 | | for (iMenu = 1; iMenu < MAX_MENUS; iMenu++) |
| 2995 | | { |
| 2996 | | if ((HMENU)lParam == popstr[iMenu].hMenu) |
| 2997 | | { |
| 2998 | | hMainMenu = (HMENU)lParam; |
| 2999 | | break ; |
| 3000 | | } |
| 3001 | | } |
| 3002 | | } |
| 3003 | | |
| 3004 | | if (hMainMenu) |
| 3005 | | { |
| 3006 | | /* Display helpful text in status bar */ |
| 3007 | | MenuHelp(WM_MENUSELECT, wParam, lParam, hMainMenu, hInst, |
| 3008 | | hStatusBar, (UINT *)&popstr[iMenu]); |
| 3009 | | } |
| 3010 | | else |
| 3011 | | { |
| 3012 | | UINT nZero = 0; |
| 3013 | | MenuHelp(WM_MENUSELECT, wParam, lParam, NULL, hInst, |
| 3014 | | hStatusBar, &nZero); |
| 3015 | | } |
| 3016 | | |
| 3017 | | return 0; |
| 3018 | | } |
| 3019 | | |
| 3020 | | static void UpdateStatusBar() |
| 3021 | | { |
| 3022 | | LPTREEFOLDER lpFolder = GetCurrentFolder(); |
| 3023 | | int games_shown = 0; |
| 3024 | | int i = -1; |
| 3025 | | |
| 3026 | | if (!lpFolder) |
| 3027 | | return; |
| 3028 | | |
| 3029 | | while (1) |
| 3030 | | { |
| 3031 | | i = FindGame(lpFolder,i+1); |
| 3032 | | if (i == -1) |
| 3033 | | break; |
| 3034 | | |
| 3035 | | if (!GameFiltered(i, lpFolder->m_dwFlags)) |
| 3036 | | games_shown++; |
| 3037 | | } |
| 3038 | | |
| 3039 | | /* Show number of games in the current 'View' in the status bar */ |
| 3040 | | SetStatusBarTextF(2, g_szGameCountString, games_shown); |
| 3041 | | |
| 3042 | | i = Picker_GetSelectedItem(hwndList); |
| 3043 | | |
| 3044 | | if (games_shown == 0) |
| 3045 | | DisableSelection(); |
| 3046 | | else |
| 3047 | | { |
| 3048 | | const char* pStatus = GameInfoStatus(i, FALSE); |
| 3049 | | SetStatusBarText(1, pStatus); |
| 3050 | | } |
| 3051 | | } |
| 3052 | | |
| 3053 | | static void UpdateHistory(void) |
| 3054 | | { |
| 3055 | | HDC hDC; |
| 3056 | | RECT rect; |
| 3057 | | TEXTMETRIC tm ; |
| 3058 | | int nLines, nLineHeight; |
| 3059 | | //DWORD dwStyle = GetWindowLong(GetDlgItem(hMain, IDC_HISTORY), GWL_STYLE); |
| 3060 | | have_history = FALSE; |
| 3061 | | |
| 3062 | | if (GetSelectedPick() >= 0) |
| 3063 | | { |
| 3064 | | char *histText = GetGameHistory(Picker_GetSelectedItem(hwndList)); |
| 3065 | | |
| 3066 | | have_history = (histText && histText[0]) ? TRUE : FALSE; |
| 3067 | | win_set_window_text_utf8(GetDlgItem(hMain, IDC_HISTORY), histText); |
| 3068 | | } |
| 3069 | | |
| 3070 | | if (have_history && GetShowScreenShot() |
| 3071 | | && ((TabView_GetCurrentTab(hTabCtrl) == TAB_HISTORY) || |
| 3072 | | (TabView_GetCurrentTab(hTabCtrl) == GetHistoryTab() && GetShowTab(TAB_HISTORY) == FALSE) || |
| 3073 | | (TAB_ALL == GetHistoryTab() && GetShowTab(TAB_HISTORY) == FALSE) )) |
| 3074 | | { |
| 3075 | | Edit_GetRect(GetDlgItem(hMain, IDC_HISTORY),&rect); |
| 3076 | | nLines = Edit_GetLineCount(GetDlgItem(hMain, IDC_HISTORY) ); |
| 3077 | | hDC = GetDC(GetDlgItem(hMain, IDC_HISTORY)); |
| 3078 | | GetTextMetrics (hDC, &tm); |
| 3079 | | nLineHeight = tm.tmHeight - tm.tmInternalLeading; |
| 3080 | | if( ( (rect.bottom - rect.top) / nLineHeight) < (nLines) ) |
| 3081 | | { |
| 3082 | | //more than one Page, so show Scrollbar |
| 3083 | | SetScrollRange(GetDlgItem(hMain, IDC_HISTORY), SB_VERT, 0, nLines, TRUE); |
| 3084 | | } |
| 3085 | | else |
| 3086 | | { |
| 3087 | | //hide Scrollbar |
| 3088 | | SetScrollRange(GetDlgItem(hMain, IDC_HISTORY),SB_VERT, 0, 0, TRUE); |
| 3089 | | |
| 3090 | | } |
| 3091 | | ShowWindow(GetDlgItem(hMain, IDC_HISTORY), SW_SHOW); |
| 3092 | | } |
| 3093 | | else |
| 3094 | | ShowWindow(GetDlgItem(hMain, IDC_HISTORY), SW_HIDE); |
| 3095 | | |
| 3096 | | } |
| 3097 | | |
| 3098 | | |
| 3099 | | static void DisableSelection() |
| 3100 | | { |
| 3101 | | MENUITEMINFO mmi; |
| 3102 | | HMENU hMenu = GetMenu(hMain); |
| 3103 | | BOOL prev_have_selection = have_selection; |
| 3104 | | |
| 3105 | | mmi.cbSize = sizeof(mmi); |
| 3106 | | mmi.fMask = MIIM_TYPE; |
| 3107 | | mmi.fType = MFT_STRING; |
| 3108 | | mmi.dwTypeData = (TCHAR *) TEXT("&Play"); |
| 3109 | | mmi.cch = _tcslen(mmi.dwTypeData); |
| 3110 | | SetMenuItemInfo(hMenu, ID_FILE_PLAY, FALSE, &mmi); |
| 3111 | | |
| 3112 | | EnableMenuItem(hMenu, ID_FILE_PLAY, MF_GRAYED); |
| 3113 | | EnableMenuItem(hMenu, ID_FILE_PLAY_RECORD, MF_GRAYED); |
| 3114 | | EnableMenuItem(hMenu, ID_GAME_PROPERTIES, MF_GRAYED); |
| 3115 | | |
| 3116 | | SetStatusBarText(0, "No Selection"); |
| 3117 | | SetStatusBarText(1, ""); |
| 3118 | | SetStatusBarText(3, ""); |
| 3119 | | |
| 3120 | | have_selection = FALSE; |
| 3121 | | |
| 3122 | | if (prev_have_selection != have_selection) |
| 3123 | | UpdateScreenShot(); |
| 3124 | | } |
| 3125 | | |
| 3126 | | static void EnableSelection(int nGame) |
| 3127 | | { |
| 3128 | | TCHAR buf[200]; |
| 3129 | | const char * pText; |
| 3130 | | MENUITEMINFO mmi; |
| 3131 | | HMENU hMenu = GetMenu(hMain); |
| 3132 | | TCHAR* t_description; |
| 3133 | | |
| 3134 | | #ifdef MESS |
| 3135 | | MyFillSoftwareList(nGame, FALSE); |
| 3136 | | #endif |
| 3137 | | |
| 3138 | | t_description = tstring_from_utf8(ConvertAmpersandString(ModifyThe(drivers[nGame]->description))); |
| 3139 | | if( !t_description ) |
| 3140 | | return; |
| 3141 | | |
| 3142 | | _sntprintf(buf, sizeof(buf) / sizeof(buf[0]), g_szPlayGameString, t_description); |
| 3143 | | mmi.cbSize = sizeof(mmi); |
| 3144 | | mmi.fMask = MIIM_TYPE; |
| 3145 | | mmi.fType = MFT_STRING; |
| 3146 | | mmi.dwTypeData = buf; |
| 3147 | | mmi.cch = _tcslen(mmi.dwTypeData); |
| 3148 | | SetMenuItemInfo(hMenu, ID_FILE_PLAY, FALSE, &mmi); |
| 3149 | | |
| 3150 | | pText = ModifyThe(drivers[nGame]->description); |
| 3151 | | SetStatusBarText(0, pText); |
| 3152 | | /* Add this game's status to the status bar */ |
| 3153 | | pText = GameInfoStatus(nGame, FALSE); |
| 3154 | | SetStatusBarText(1, pText); |
| 3155 | | SetStatusBarText(3, ""); |
| 3156 | | |
| 3157 | | /* If doing updating game status and the game name is NOT pacman.... */ |
| 3158 | | |
| 3159 | | EnableMenuItem(hMenu, ID_FILE_PLAY, MF_ENABLED); |
| 3160 | | EnableMenuItem(hMenu, ID_FILE_PLAY_RECORD, MF_ENABLED); |
| 3161 | | |
| 3162 | | if (!oldControl) |
| 3163 | | EnableMenuItem(hMenu, ID_GAME_PROPERTIES, MF_ENABLED); |
| 3164 | | |
| 3165 | | if (bProgressShown && bListReady == TRUE) |
| 3166 | | { |
| 3167 | | SetDefaultGame(ModifyThe(drivers[nGame]->name)); |
| 3168 | | } |
| 3169 | | have_selection = TRUE; |
| 3170 | | |
| 3171 | | UpdateScreenShot(); |
| 3172 | | |
| 3173 | | free(t_description); |
| 3174 | | } |
| 3175 | | |
| 3176 | | static void PaintBackgroundImage(HWND hWnd, HRGN hRgn, int x, int y) |
| 3177 | | { |
| 3178 | | RECT rcClient; |
| 3179 | | HRGN rgnBitmap; |
| 3180 | | HPALETTE hPAL; |
| 3181 | | HDC hDC = GetDC(hWnd); |
| 3182 | | int i, j; |
| 3183 | | HDC htempDC; |
| 3184 | | HBITMAP oldBitmap; |
| 3185 | | |
| 3186 | | /* x and y are offsets within the background image that should be at 0,0 in hWnd */ |
| 3187 | | |
| 3188 | | /* So we don't paint over the control's border */ |
| 3189 | | GetClientRect(hWnd, &rcClient); |
| 3190 | | |
| 3191 | | htempDC = CreateCompatibleDC(hDC); |
| 3192 | | oldBitmap = SelectObject(htempDC, hBackground); |
| 3193 | | |
| 3194 | | if (hRgn == NULL) |
| 3195 | | { |
| 3196 | | /* create a region of our client area */ |
| 3197 | | rgnBitmap = CreateRectRgnIndirect(&rcClient); |
| 3198 | | SelectClipRgn(hDC, rgnBitmap); |
| 3199 | | DeleteObject(rgnBitmap); |
| 3200 | | } |
| 3201 | | else |
| 3202 | | { |
| 3203 | | /* use the passed in region */ |
| 3204 | | SelectClipRgn(hDC, hRgn); |
| 3205 | | } |
| 3206 | | |
| 3207 | | hPAL = GetBackgroundPalette(); |
| 3208 | | if (hPAL == NULL) |
| 3209 | | hPAL = CreateHalftonePalette(hDC); |
| 3210 | | |
| 3211 | | if (GetDeviceCaps(htempDC, RASTERCAPS) & RC_PALETTE && hPAL != NULL) |
| 3212 | | { |
| 3213 | | SelectPalette(htempDC, hPAL, FALSE); |
| 3214 | | RealizePalette(htempDC); |
| 3215 | | } |
| 3216 | | |
| 3217 | | for (i = rcClient.left-x; i < rcClient.right; i += bmDesc.bmWidth) |
| 3218 | | for (j = rcClient.top-y; j < rcClient.bottom; j += bmDesc.bmHeight) |
| 3219 | | BitBlt(hDC, i, j, bmDesc.bmWidth, bmDesc.bmHeight, htempDC, 0, 0, SRCCOPY); |
| 3220 | | |
| 3221 | | SelectObject(htempDC, oldBitmap); |
| 3222 | | DeleteDC(htempDC); |
| 3223 | | |
| 3224 | | if (GetBackgroundPalette() == NULL) |
| 3225 | | { |
| 3226 | | DeleteObject(hPAL); |
| 3227 | | hPAL = NULL; |
| 3228 | | } |
| 3229 | | |
| 3230 | | ReleaseDC(hWnd, hDC); |
| 3231 | | } |
| 3232 | | |
| 3233 | | static LPCSTR GetCloneParentName(int nItem) |
| 3234 | | { |
| 3235 | | int nParentIndex = -1; |
| 3236 | | |
| 3237 | | if (DriverIsClone(nItem) == TRUE) |
| 3238 | | { |
| 3239 | | nParentIndex = GetParentIndex(drivers[nItem]); |
| 3240 | | if( nParentIndex >= 0) |
| 3241 | | return ModifyThe(drivers[nParentIndex]->description); |
| 3242 | | } |
| 3243 | | return ""; |
| 3244 | | } |
| 3245 | | |
| 3246 | | static BOOL PickerHitTest(HWND hWnd) |
| 3247 | | { |
| 3248 | | RECT rect; |
| 3249 | | POINTS p; |
| 3250 | | DWORD res = GetMessagePos(); |
| 3251 | | LVHITTESTINFO htInfo; |
| 3252 | | |
| 3253 | | ZeroMemory(&htInfo,sizeof(LVHITTESTINFO)); |
| 3254 | | p = MAKEPOINTS(res); |
| 3255 | | GetWindowRect(hWnd, &rect); |
| 3256 | | htInfo.pt.x = p.x - rect.left; |
| 3257 | | htInfo.pt.y = p.y - rect.top; |
| 3258 | | ListView_HitTest(hWnd, &htInfo); |
| 3259 | | |
| 3260 | | return (! (htInfo.flags & LVHT_NOWHERE)); |
| 3261 | | } |
| 3262 | | |
| 3263 | | static BOOL TreeViewNotify(LPNMHDR nm) |
| 3264 | | { |
| 3265 | | switch (nm->code) |
| 3266 | | { |
| 3267 | | case TVN_SELCHANGED : |
| 3268 | | { |
| 3269 | | HTREEITEM hti = TreeView_GetSelection(hTreeView); |
| 3270 | | TVITEM tvi; |
| 3271 | | |
| 3272 | | tvi.mask = TVIF_PARAM | TVIF_HANDLE; |
| 3273 | | tvi.hItem = hti; |
| 3274 | | |
| 3275 | | if (TreeView_GetItem(hTreeView, &tvi)) |
| 3276 | | { |
| 3277 | | SetCurrentFolder((LPTREEFOLDER)tvi.lParam); |
| 3278 | | if (bListReady) |
| 3279 | | { |
| 3280 | | ResetListView(); |
| 3281 | | UpdateScreenShot(); |
| 3282 | | } |
| 3283 | | } |
| 3284 | | return TRUE; |
| 3285 | | } |
| 3286 | | case TVN_BEGINLABELEDIT : |
| 3287 | | { |
| 3288 | | TV_DISPINFO *ptvdi = (TV_DISPINFO *)nm; |
| 3289 | | LPTREEFOLDER folder = (LPTREEFOLDER)ptvdi->item.lParam; |
| 3290 | | |
| 3291 | | if (folder->m_dwFlags & F_CUSTOM) |
| 3292 | | { |
| 3293 | | // user can edit custom folder names |
| 3294 | | g_in_treeview_edit = TRUE; |
| 3295 | | return FALSE; |
| 3296 | | } |
| 3297 | | // user can't edit built in folder names |
| 3298 | | return TRUE; |
| 3299 | | } |
| 3300 | | case TVN_ENDLABELEDIT : |
| 3301 | | { |
| 3302 | | TV_DISPINFO *ptvdi = (TV_DISPINFO *)nm; |
| 3303 | | LPTREEFOLDER folder = (LPTREEFOLDER)ptvdi->item.lParam; |
| 3304 | | char* szText; |
| 3305 | | BOOL result; |
| 3306 | | |
| 3307 | | g_in_treeview_edit = FALSE; |
| 3308 | | |
| 3309 | | if (ptvdi->item.pszText == NULL || _tcslen(ptvdi->item.pszText) == 0) |
| 3310 | | return FALSE; |
| 3311 | | |
| 3312 | | szText = utf8_from_tstring(ptvdi->item.pszText); |
| 3313 | | if( !szText ) |
| 3314 | | return FALSE; |
| 3315 | | |
| 3316 | | result = TryRenameCustomFolder(folder,szText); |
| 3317 | | |
| 3318 | | free(szText); |
| 3319 | | |
| 3320 | | return result; |
| 3321 | | } |
| 3322 | | } |
| 3323 | | return FALSE; |
| 3324 | | } |
| 3325 | | |
| 3326 | | |
| 3327 | | |
| 3328 | | static void GamePicker_OnHeaderContextMenu(POINT pt, int nColumn) |
| 3329 | | { |
| 3330 | | // Right button was clicked on header |
| 3331 | | HMENU hMenuLoad; |
| 3332 | | HMENU hMenu; |
| 3333 | | |
| 3334 | | hMenuLoad = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT_HEADER)); |
| 3335 | | hMenu = GetSubMenu(hMenuLoad, 0); |
| 3336 | | lastColumnClick = nColumn; |
| 3337 | | TrackPopupMenu(hMenu,TPM_LEFTALIGN | TPM_RIGHTBUTTON,pt.x,pt.y,0,hMain,NULL); |
| 3338 | | |
| 3339 | | DestroyMenu(hMenuLoad); |
| 3340 | | } |
| 3341 | | |
| 3342 | | |
| 3343 | | |
| 3344 | | char* ConvertAmpersandString(const char *s) |
| 3345 | | { |
| 3346 | | /* takes a string and changes any ampersands to double ampersands, |
| 3347 | | for setting text of window controls that don't allow us to disable |
| 3348 | | the ampersand underlining. |
| 3349 | | */ |
| 3350 | | /* returns a static buffer--use before calling again */ |
| 3351 | | |
| 3352 | | static char buf[200]; |
| 3353 | | char *ptr; |
| 3354 | | |
| 3355 | | ptr = buf; |
| 3356 | | while (*s) |
| 3357 | | { |
| 3358 | | if (*s == '&') |
| 3359 | | *ptr++ = *s; |
| 3360 | | *ptr++ = *s++; |
| 3361 | | } |
| 3362 | | *ptr = 0; |
| 3363 | | |
| 3364 | | return buf; |
| 3365 | | } |
| 3366 | | |
| 3367 | | static int GUI_seq_pressed(const input_seq *seq) |
| 3368 | | { |
| 3369 | | int codenum; |
| 3370 | | int res = 1; |
| 3371 | | int invert = 0; |
| 3372 | | int count = 0; |
| 3373 | | |
| 3374 | | for (codenum = 0; codenum < ARRAY_LENGTH(seq->code); codenum++) |
| 3375 | | { |
| 3376 | | input_code code = seq->code[codenum]; |
| 3377 | | |
| 3378 | | switch (code) |
| 3379 | | { |
| 3380 | | case SEQCODE_OR : |
| 3381 | | if (res && count) |
| 3382 | | return 1; |
| 3383 | | res = 1; |
| 3384 | | count = 0; |
| 3385 | | break; |
| 3386 | | case SEQCODE_NOT : |
| 3387 | | invert = !invert; |
| 3388 | | break; |
| 3389 | | default: |
| 3390 | | if (res) |
| 3391 | | { |
| 3392 | | int pressed = keyboard_state[code]; |
| 3393 | | if ((pressed != 0) == invert) |
| 3394 | | res = 0; |
| 3395 | | } |
| 3396 | | invert = 0; |
| 3397 | | ++count; |
| 3398 | | } |
| 3399 | | } |
| 3400 | | return res && count; |
| 3401 | | } |
| 3402 | | |
| 3403 | | static void check_for_GUI_action(void) |
| 3404 | | { |
| 3405 | | int i; |
| 3406 | | |
| 3407 | | for (i = 0; i < NUM_GUI_SEQUENCES; i++) |
| 3408 | | { |
| 3409 | | input_seq *is = &(GUISequenceControl[i].is); |
| 3410 | | |
| 3411 | | if (GUI_seq_pressed(is)) |
| 3412 | | { |
| 3413 | | dprintf("seq =%s pressed\n", GUISequenceControl[i].name); |
| 3414 | | switch (GUISequenceControl[i].func_id) |
| 3415 | | { |
| 3416 | | case ID_GAME_AUDIT: |
| 3417 | | case ID_GAME_PROPERTIES: |
| 3418 | | case ID_CONTEXT_FILTERS: |
| 3419 | | case ID_UI_START: |
| 3420 | | KeyboardStateClear(); /* beacuse whe won't receive KeyUp mesage when we loose focus */ |
| 3421 | | break; |
| 3422 | | default: |
| 3423 | | break; |
| 3424 | | } |
| 3425 | | SendMessage(hMain, WM_COMMAND, GUISequenceControl[i].func_id, 0); |
| 3426 | | } |
| 3427 | | } |
| 3428 | | } |
| 3429 | | |
| 3430 | | static void KeyboardStateClear(void) |
| 3431 | | { |
| 3432 | | memset(keyboard_state, 0, sizeof(keyboard_state)); |
| 3433 | | dprintf("keyboard gui state cleared.\n"); |
| 3434 | | } |
| 3435 | | |
| 3436 | | |
| 3437 | | static void KeyboardKeyDown(int syskey, int vk_code, int special) |
| 3438 | | { |
| 3439 | | int i, found = 0; |
| 3440 | | input_code icode = 0; |
| 3441 | | int special_code = (special >> 24) & 1; |
| 3442 | | int scancode = (special>>16) & 0xff; |
| 3443 | | |
| 3444 | | if ((vk_code==VK_MENU) || (vk_code==VK_CONTROL) || (vk_code==VK_SHIFT)) |
| 3445 | | { |
| 3446 | | found = 1; |
| 3447 | | |
| 3448 | | /* a hack for right shift - it's better to use Direct X for keyboard input it seems......*/ |
| 3449 | | if (vk_code==VK_SHIFT) |
| 3450 | | if (scancode>0x30) /* on my keyboard left shift scancode is 0x2a, right shift is 0x36 */ |
| 3451 | | special_code = 1; |
| 3452 | | |
| 3453 | | if (special_code) /* right hand keys */ |
| 3454 | | { |
| 3455 | | switch(vk_code) |
| 3456 | | { |
| 3457 | | case VK_MENU: |
| 3458 | | icode = KEYCODE_RALT; |
| 3459 | | break; |
| 3460 | | case VK_CONTROL: |
| 3461 | | icode = KEYCODE_RCONTROL; |
| 3462 | | break; |
| 3463 | | case VK_SHIFT: |
| 3464 | | icode = KEYCODE_RSHIFT; |
| 3465 | | break; |
| 3466 | | } |
| 3467 | | } |
| 3468 | | else /* left hand keys */ |
| 3469 | | { |
| 3470 | | switch(vk_code) |
| 3471 | | { |
| 3472 | | case VK_MENU: |
| 3473 | | icode = KEYCODE_LALT; |
| 3474 | | break; |
| 3475 | | case VK_CONTROL: |
| 3476 | | icode = KEYCODE_LCONTROL; |
| 3477 | | break; |
| 3478 | | case VK_SHIFT: |
| 3479 | | icode = KEYCODE_LSHIFT; |
| 3480 | | break; |
| 3481 | | } |
| 3482 | | } |
| 3483 | | } |
| 3484 | | else |
| 3485 | | { |
| 3486 | | for (i = 0; i < ARRAY_LENGTH(win_key_trans_table); i++) |
| 3487 | | { |
| 3488 | | if ( vk_code == win_key_trans_table[i][VIRTUAL_KEY]) |
| 3489 | | { |
| 3490 | | icode = win_key_trans_table[i][MAME_KEY]; |
| 3491 | | found = 1; |
| 3492 | | break; |
| 3493 | | } |
| 3494 | | } |
| 3495 | | } |
| 3496 | | if (!found) |
| 3497 | | { |
| 3498 | | dprintf("VK_code pressed not found = %i\n",vk_code); |
| 3499 | | //MessageBox(NULL,"keydown message arrived not processed","TitleBox",MB_OK); |
| 3500 | | return; |
| 3501 | | } |
| 3502 | | dprintf("VK_code pressed found = %i, sys=%i, mame_keycode=%i special=%08x\n", vk_code, syskey, icode, special); |
| 3503 | | keyboard_state[icode] = 1; |
| 3504 | | check_for_GUI_action(); |
| 3505 | | } |
| 3506 | | |
| 3507 | | static void KeyboardKeyUp(int syskey, int vk_code, int special) |
| 3508 | | { |
| 3509 | | int i, found = 0; |
| 3510 | | input_code icode = 0; |
| 3511 | | int special_code = (special >> 24) & 1; |
| 3512 | | int scancode = (special>>16) & 0xff; |
| 3513 | | |
| 3514 | | if ((vk_code==VK_MENU) || (vk_code==VK_CONTROL) || (vk_code==VK_SHIFT)) |
| 3515 | | { |
| 3516 | | found = 1; |
| 3517 | | |
| 3518 | | /* a hack for right shift - it's better to use Direct X for keyboard input it seems......*/ |
| 3519 | | if (vk_code==VK_SHIFT) |
| 3520 | | if (scancode>0x30) /* on my keyboard left shift scancode is 0x2a, right shift is 0x36 */ |
| 3521 | | special_code = 1; |
| 3522 | | |
| 3523 | | if (special_code) /* right hand keys */ |
| 3524 | | { |
| 3525 | | switch(vk_code) |
| 3526 | | { |
| 3527 | | case VK_MENU: |
| 3528 | | icode = KEYCODE_RALT; |
| 3529 | | break; |
| 3530 | | case VK_CONTROL: |
| 3531 | | icode = KEYCODE_RCONTROL; |
| 3532 | | break; |
| 3533 | | case VK_SHIFT: |
| 3534 | | icode = KEYCODE_RSHIFT; |
| 3535 | | break; |
| 3536 | | } |
| 3537 | | } |
| 3538 | | else /* left hand keys */ |
| 3539 | | { |
| 3540 | | switch(vk_code) |
| 3541 | | { |
| 3542 | | case VK_MENU: |
| 3543 | | icode = KEYCODE_LALT; |
| 3544 | | break; |
| 3545 | | case VK_CONTROL: |
| 3546 | | icode = KEYCODE_LCONTROL; |
| 3547 | | break; |
| 3548 | | case VK_SHIFT: |
| 3549 | | icode = KEYCODE_LSHIFT; |
| 3550 | | break; |
| 3551 | | } |
| 3552 | | } |
| 3553 | | } |
| 3554 | | else |
| 3555 | | { |
| 3556 | | for (i = 0; i < ARRAY_LENGTH(win_key_trans_table); i++) |
| 3557 | | { |
| 3558 | | if (vk_code == win_key_trans_table[i][VIRTUAL_KEY]) |
| 3559 | | { |
| 3560 | | icode = win_key_trans_table[i][MAME_KEY]; |
| 3561 | | found = 1; |
| 3562 | | break; |
| 3563 | | } |
| 3564 | | } |
| 3565 | | } |
| 3566 | | if (!found) |
| 3567 | | { |
| 3568 | | dprintf("VK_code released not found = %i",vk_code); |
| 3569 | | //MessageBox(NULL,"keyup message arrived not processed","TitleBox",MB_OK); |
| 3570 | | return; |
| 3571 | | } |
| 3572 | | keyboard_state[icode] = 0; |
| 3573 | | dprintf("VK_code released found= %i, sys=%i, mame_keycode=%i special=%08x\n", vk_code, syskey, icode, special ); |
| 3574 | | check_for_GUI_action(); |
| 3575 | | } |
| 3576 | | |
| 3577 | | static void PollGUIJoystick() |
| 3578 | | { |
| 3579 | | // For the exec timer, will keep track of how long the button has been pressed |
| 3580 | | static int exec_counter = 0; |
| 3581 | | const char* exec_command; |
| 3582 | | TCHAR* t_exec_command; |
| 3583 | | |
| 3584 | | if (in_emulation) |
| 3585 | | return; |
| 3586 | | |
| 3587 | | if (g_pJoyGUI == NULL) |
| 3588 | | return; |
| 3589 | | |
| 3590 | | g_pJoyGUI->poll_joysticks(); |
| 3591 | | |
| 3592 | | |
| 3593 | | // User pressed UP |
| 3594 | | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyUp(0), GetUIJoyUp(1), GetUIJoyUp(2),GetUIJoyUp(3)))) |
| 3595 | | { |
| 3596 | | SendMessage(hMain, WM_COMMAND, ID_UI_UP, 0); |
| 3597 | | } |
| 3598 | | |
| 3599 | | // User pressed DOWN |
| 3600 | | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyDown(0), GetUIJoyDown(1), GetUIJoyDown(2),GetUIJoyDown(3)))) |
| 3601 | | { |
| 3602 | | SendMessage(hMain, WM_COMMAND, ID_UI_DOWN, 0); |
| 3603 | | } |
| 3604 | | |
| 3605 | | // User pressed LEFT |
| 3606 | | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyLeft(0), GetUIJoyLeft(1), GetUIJoyLeft(2),GetUIJoyLeft(3)))) |
| 3607 | | { |
| 3608 | | SendMessage(hMain, WM_COMMAND, ID_UI_LEFT, 0); |
| 3609 | | } |
| 3610 | | |
| 3611 | | // User pressed RIGHT |
| 3612 | | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyRight(0), GetUIJoyRight(1), GetUIJoyRight(2),GetUIJoyRight(3)))) |
| 3613 | | { |
| 3614 | | SendMessage(hMain, WM_COMMAND, ID_UI_RIGHT, 0); |
| 3615 | | } |
| 3616 | | |
| 3617 | | // User pressed START GAME |
| 3618 | | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyStart(0), GetUIJoyStart(1), GetUIJoyStart(2),GetUIJoyStart(3)))) |
| 3619 | | { |
| 3620 | | SendMessage(hMain, WM_COMMAND, ID_UI_START, 0); |
| 3621 | | } |
| 3622 | | |
| 3623 | | // User pressed PAGE UP |
| 3624 | | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyPageUp(0), GetUIJoyPageUp(1), GetUIJoyPageUp(2),GetUIJoyPageUp(3)))) |
| 3625 | | { |
| 3626 | | SendMessage(hMain, WM_COMMAND, ID_UI_PGUP, 0); |
| 3627 | | } |
| 3628 | | |
| 3629 | | // User pressed PAGE DOWN |
| 3630 | | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyPageDown(0), GetUIJoyPageDown(1), GetUIJoyPageDown(2),GetUIJoyPageDown(3)))) |
| 3631 | | { |
| 3632 | | SendMessage(hMain, WM_COMMAND, ID_UI_PGDOWN, 0); |
| 3633 | | } |
| 3634 | | |
| 3635 | | // User pressed HOME |
| 3636 | | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyHome(0), GetUIJoyHome(1), GetUIJoyHome(2),GetUIJoyHome(3)))) |
| 3637 | | { |
| 3638 | | SendMessage(hMain, WM_COMMAND, ID_UI_HOME, 0); |
| 3639 | | } |
| 3640 | | |
| 3641 | | // User pressed END |
| 3642 | | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyEnd(0), GetUIJoyEnd(1), GetUIJoyEnd(2),GetUIJoyEnd(3)))) |
| 3643 | | { |
| 3644 | | SendMessage(hMain, WM_COMMAND, ID_UI_END, 0); |
| 3645 | | } |
| 3646 | | |
| 3647 | | // User pressed CHANGE SCREENSHOT |
| 3648 | | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoySSChange(0), GetUIJoySSChange(1), GetUIJoySSChange(2),GetUIJoySSChange(3)))) |
| 3649 | | { |
| 3650 | | SendMessage(hMain, WM_COMMAND, IDC_SSFRAME, 0); |
| 3651 | | } |
| 3652 | | |
| 3653 | | // User pressed SCROLL HISTORY UP |
| 3654 | | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyHistoryUp(0), GetUIJoyHistoryUp(1), GetUIJoyHistoryUp(2),GetUIJoyHistoryUp(3)))) |
| 3655 | | { |
| 3656 | | SendMessage(hMain, WM_COMMAND, ID_UI_HISTORY_UP, 0); |
| 3657 | | } |
| 3658 | | |
| 3659 | | // User pressed SCROLL HISTORY DOWN |
| 3660 | | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyHistoryDown(0), GetUIJoyHistoryDown(1), GetUIJoyHistoryDown(2),GetUIJoyHistoryDown(3)))) |
| 3661 | | { |
| 3662 | | SendMessage(hMain, WM_COMMAND, ID_UI_HISTORY_DOWN, 0); |
| 3663 | | } |
| 3664 | | |
| 3665 | | // User pressed EXECUTE COMMANDLINE |
| 3666 | | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyExec(0), GetUIJoyExec(1), GetUIJoyExec(2),GetUIJoyExec(3)))) |
| 3667 | | { |
| 3668 | | if (++exec_counter >= GetExecWait()) // Button has been pressed > exec timeout |
| 3669 | | { |
| 3670 | | PROCESS_INFORMATION pi; |
| 3671 | | STARTUPINFO si; |
| 3672 | | |
| 3673 | | // Reset counter |
| 3674 | | exec_counter = 0; |
| 3675 | | |
| 3676 | | ZeroMemory( &si, sizeof(si) ); |
| 3677 | | ZeroMemory( &pi, sizeof(pi) ); |
| 3678 | | si.dwFlags = STARTF_FORCEONFEEDBACK; |
| 3679 | | si.cb = sizeof(si); |
| 3680 | | |
| 3681 | | exec_command = GetExecCommand(); |
| 3682 | | t_exec_command = tstring_from_utf8(exec_command); |
| 3683 | | if( !t_exec_command ) |
| 3684 | | return; |
| 3685 | | CreateProcess(NULL, t_exec_command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); |
| 3686 | | |
| 3687 | | free(t_exec_command); |
| 3688 | | |
| 3689 | | // We will not wait for the process to finish cause it might be a background task |
| 3690 | | // The process won't get closed when MAME32 closes either. |
| 3691 | | |
| 3692 | | // But close the handles cause we won't need them anymore. Will not close process. |
| 3693 | | CloseHandle(pi.hProcess); |
| 3694 | | CloseHandle(pi.hThread); |
| 3695 | | } |
| 3696 | | } |
| 3697 | | else |
| 3698 | | { |
| 3699 | | // Button has been released within the timeout period, reset the counter |
| 3700 | | exec_counter = 0; |
| 3701 | | } |
| 3702 | | } |
| 3703 | | |
| 3704 | | static void PressKey(HWND hwnd, UINT vk) |
| 3705 | | { |
| 3706 | | SendMessage(hwnd, WM_KEYDOWN, vk, 0); |
| 3707 | | SendMessage(hwnd, WM_KEYUP, vk, 0xc0000000); |
| 3708 | | } |
| 3709 | | |
| 3710 | | static void SetView(int menu_id) |
| 3711 | | { |
| 3712 | | BOOL force_reset = FALSE; |
| 3713 | | int i; |
| 3714 | | |
| 3715 | | // first uncheck previous menu item, check new one |
| 3716 | | CheckMenuRadioItem(GetMenu(hMain), ID_VIEW_LARGE_ICON, ID_VIEW_GROUPED, menu_id, MF_CHECKED); |
| 3717 | | ToolBar_CheckButton(hToolBar, menu_id, MF_CHECKED); |
| 3718 | | |
| 3719 | | if (Picker_GetViewID(hwndList) == VIEW_GROUPED || menu_id == ID_VIEW_GROUPED) |
| 3720 | | { |
| 3721 | | // this changes the sort order, so redo everything |
| 3722 | | force_reset = TRUE; |
| 3723 | | } |
| 3724 | | |
| 3725 | | for (i = 0; i < sizeof(s_nPickers) / sizeof(s_nPickers[0]); i++) |
| 3726 | | Picker_SetViewID(GetDlgItem(hMain, s_nPickers[i]), menu_id - ID_VIEW_LARGE_ICON); |
| 3727 | | |
| 3728 | | if (force_reset) |
| 3729 | | { |
| 3730 | | for (i = 0; i < sizeof(s_nPickers) / sizeof(s_nPickers[0]); i++) |
| 3731 | | Picker_Sort(GetDlgItem(hMain, s_nPickers[i])); |
| 3732 | | } |
| 3733 | | } |
| 3734 | | |
| 3735 | | static void ResetListView() |
| 3736 | | { |
| 3737 | | int i; |
| 3738 | | int current_game; |
| 3739 | | LV_ITEM lvi; |
| 3740 | | BOOL no_selection = FALSE; |
| 3741 | | LPTREEFOLDER lpFolder = GetCurrentFolder(); |
| 3742 | | |
| 3743 | | if (!lpFolder) |
| 3744 | | { |
| 3745 | | return; |
| 3746 | | } |
| 3747 | | |
| 3748 | | /* If the last folder was empty, no_selection is TRUE */ |
| 3749 | | if (have_selection == FALSE) |
| 3750 | | { |
| 3751 | | no_selection = TRUE; |
| 3752 | | } |
| 3753 | | |
| 3754 | | current_game = Picker_GetSelectedItem(hwndList); |
| 3755 | | |
| 3756 | | SetWindowRedraw(hwndList,FALSE); |
| 3757 | | |
| 3758 | | ListView_DeleteAllItems(hwndList); |
| 3759 | | |
| 3760 | | // hint to have it allocate it all at once |
| 3761 | | ListView_SetItemCount(hwndList,driver_list_get_count(drivers)); |
| 3762 | | |
| 3763 | | lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; |
| 3764 | | lvi.stateMask = 0; |
| 3765 | | |
| 3766 | | i = -1; |
| 3767 | | |
| 3768 | | do |
| 3769 | | { |
| 3770 | | /* Add the games that are in this folder */ |
| 3771 | | if ((i = FindGame(lpFolder, i + 1)) != -1) |
| 3772 | | { |
| 3773 | | if (GameFiltered(i, lpFolder->m_dwFlags)) |
| 3774 | | continue; |
| 3775 | | |
| 3776 | | lvi.iItem = i; |
| 3777 | | lvi.iSubItem = 0; |
| 3778 | | lvi.lParam = i; |
| 3779 | | lvi.pszText = LPSTR_TEXTCALLBACK; |
| 3780 | | lvi.iImage = I_IMAGECALLBACK; |
| 3781 | | ListView_InsertItem(hwndList, &lvi); |
| 3782 | | } |
| 3783 | | } while (i != -1); |
| 3784 | | |
| 3785 | | Picker_Sort(hwndList); |
| 3786 | | |
| 3787 | | if (bListReady) |
| 3788 | | { |
| 3789 | | /* If last folder was empty, select the first item in this folder */ |
| 3790 | | if (no_selection) |
| 3791 | | Picker_SetSelectedPick(hwndList, 0); |
| 3792 | | else |
| 3793 | | Picker_SetSelectedItem(hwndList, current_game); |
| 3794 | | } |
| 3795 | | |
| 3796 | | /*RS Instead of the Arrange Call that was here previously on all Views |
| 3797 | | We now need to set the ViewMode for SmallIcon again, |
| 3798 | | for an explanation why, see SetView*/ |
| 3799 | | if (GetViewMode() == VIEW_SMALL_ICONS) |
| 3800 | | SetView(ID_VIEW_SMALL_ICON); |
| 3801 | | |
| 3802 | | SetWindowRedraw(hwndList, TRUE); |
| 3803 | | |
| 3804 | | UpdateStatusBar(); |
| 3805 | | |
| 3806 | | } |
| 3807 | | |
| 3808 | | static void UpdateGameList(BOOL bUpdateRomAudit, BOOL bUpdateSampleAudit) |
| 3809 | | { |
| 3810 | | int i; |
| 3811 | | |
| 3812 | | for (i = 0; i < driver_list_get_count(drivers); i++) |
| 3813 | | { |
| 3814 | | if (bUpdateRomAudit && DriverUsesRoms(i)) |
| 3815 | | SetRomAuditResults(i, UNKNOWN); |
| 3816 | | if (bUpdateSampleAudit && DriverUsesSamples(i)) |
| 3817 | | SetSampleAuditResults(i, UNKNOWN); |
| 3818 | | } |
| 3819 | | |
| 3820 | | idle_work = TRUE; |
| 3821 | | bDoGameCheck = TRUE; |
| 3822 | | game_index = 0; |
| 3823 | | |
| 3824 | | ReloadIcons(); |
| 3825 | | |
| 3826 | | // Let REFRESH also load new background if found |
| 3827 | | LoadBackgroundBitmap(); |
| 3828 | | InvalidateRect(hMain,NULL,TRUE); |
| 3829 | | Picker_ResetIdle(hwndList); |
| 3830 | | } |
| 3831 | | |
| 3832 | | UINT_PTR CALLBACK CFHookProc( |
| 3833 | | HWND hdlg, // handle to dialog box |
| 3834 | | UINT uiMsg, // message identifier |
| 3835 | | WPARAM wParam, // message parameter |
| 3836 | | LPARAM lParam // message parameter |
| 3837 | | ) |
| 3838 | | { |
| 3839 | | int iIndex, i; |
| 3840 | | COLORREF cCombo, cList; |
| 3841 | | switch (uiMsg) |
| 3842 | | { |
| 3843 | | case WM_INITDIALOG: |
| 3844 | | SendDlgItemMessage(hdlg, cmb4, CB_ADDSTRING, 0, (LPARAM)TEXT("Custom")); |
| 3845 | | iIndex = SendDlgItemMessage(hdlg, cmb4, CB_GETCOUNT, 0, 0); |
| 3846 | | cList = GetListFontColor(); |
| 3847 | | SendDlgItemMessage(hdlg, cmb4, CB_SETITEMDATA,(WPARAM)iIndex-1,(LPARAM)cList ); |
| 3848 | | for( i = 0; i< iIndex; i++) |
| 3849 | | { |
| 3850 | | cCombo = SendDlgItemMessage(hdlg, cmb4, CB_GETITEMDATA,(WPARAM)i,0 ); |
| 3851 | | if( cList == cCombo) |
| 3852 | | { |
| 3853 | | SendDlgItemMessage(hdlg, cmb4, CB_SETCURSEL,(WPARAM)i,0 ); |
| 3854 | | break; |
| 3855 | | } |
| 3856 | | } |
| 3857 | | break; |
| 3858 | | case WM_COMMAND: |
| 3859 | | if( LOWORD(wParam) == cmb4) |
| 3860 | | { |
| 3861 | | switch (HIWORD(wParam)) |
| 3862 | | { |
| 3863 | | case CBN_SELCHANGE: // The color ComboBox changed selection |
| 3864 | | iIndex = (int)SendDlgItemMessage(hdlg, cmb4, |
| 3865 | | CB_GETCURSEL, 0, 0L); |
| 3866 | | if( iIndex == SendDlgItemMessage(hdlg, cmb4, CB_GETCOUNT, 0, 0)-1) |
| 3867 | | { |
| 3868 | | //Custom color selected |
| 3869 | | cList = GetListFontColor(); |
| 3870 | | PickColor(&cList); |
| 3871 | | SendDlgItemMessage(hdlg, cmb4, CB_DELETESTRING, iIndex, 0); |
| 3872 | | SendDlgItemMessage(hdlg, cmb4, CB_ADDSTRING, 0, (LPARAM)TEXT("Custom")); |
| 3873 | | SendDlgItemMessage(hdlg, cmb4, CB_SETITEMDATA,(WPARAM)iIndex,(LPARAM)cList); |
| 3874 | | SendDlgItemMessage(hdlg, cmb4, CB_SETCURSEL,(WPARAM)iIndex,0 ); |
| 3875 | | return TRUE; |
| 3876 | | } |
| 3877 | | } |
| 3878 | | } |
| 3879 | | break; |
| 3880 | | } |
| 3881 | | return FALSE; |
| 3882 | | } |
| 3883 | | |
| 3884 | | static void PickFont(void) |
| 3885 | | { |
| 3886 | | LOGFONT font; |
| 3887 | | CHOOSEFONT cf; |
| 3888 | | TCHAR szClass[128]; |
| 3889 | | HWND hWnd; |
| 3890 | | |
| 3891 | | GetListFont(&font); |
| 3892 | | font.lfQuality = DEFAULT_QUALITY; |
| 3893 | | |
| 3894 | | cf.lStructSize = sizeof(CHOOSEFONT); |
| 3895 | | cf.hwndOwner = hMain; |
| 3896 | | cf.lpLogFont = &font; |
| 3897 | | cf.lpfnHook = &CFHookProc; |
| 3898 | | cf.rgbColors = GetListFontColor(); |
| 3899 | | cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT | CF_EFFECTS | CF_ENABLEHOOK; |
| 3900 | | if (!ChooseFont(&cf)) |
| 3901 | | return; |
| 3902 | | |
| 3903 | | SetListFont(&font); |
| 3904 | | if (hFont != NULL) |
| 3905 | | DeleteObject(hFont); |
| 3906 | | hFont = CreateFontIndirect(&font); |
| 3907 | | if (hFont != NULL) |
| 3908 | | { |
| 3909 | | COLORREF textColor = cf.rgbColors; |
| 3910 | | |
| 3911 | | if (textColor == RGB(255,255,255)) |
| 3912 | | { |
| 3913 | | textColor = RGB(240, 240, 240); |
| 3914 | | } |
| 3915 | | |
| 3916 | | SetAllWindowsFont(hMain, &main_resize, hFont, TRUE); |
| 3917 | | |
| 3918 | | hWnd = GetWindow(hMain, GW_CHILD); |
| 3919 | | while(hWnd) |
| 3920 | | { |
| 3921 | | if (GetClassName(hWnd, szClass, sizeof(szClass) / sizeof(szClass[0]))) |
| 3922 | | { |
| 3923 | | if (!_tcscmp(szClass, TEXT("SysListView32"))) |
| 3924 | | { |
| 3925 | | ListView_SetTextColor(hWnd, textColor); |
| 3926 | | } |
| 3927 | | else if (!_tcscmp(szClass, TEXT("SysTreeView32"))) |
| 3928 | | { |
| 3929 | | TreeView_SetTextColor(hTreeView, textColor); |
| 3930 | | } |
| 3931 | | } |
| 3932 | | hWnd = GetWindow(hWnd, GW_HWNDNEXT); |
| 3933 | | } |
| 3934 | | SetListFontColor(cf.rgbColors); |
| 3935 | | ResetListView(); |
| 3936 | | } |
| 3937 | | } |
| 3938 | | |
| 3939 | | static void PickColor(COLORREF *cDefault) |
| 3940 | | { |
| 3941 | | CHOOSECOLOR cc; |
| 3942 | | COLORREF choice_colors[16]; |
| 3943 | | int i; |
| 3944 | | |
| 3945 | | for (i=0;i<16;i++) |
| 3946 | | choice_colors[i] = GetCustomColor(i); |
| 3947 | | |
| 3948 | | cc.lStructSize = sizeof(CHOOSECOLOR); |
| 3949 | | cc.hwndOwner = hMain; |
| 3950 | | cc.rgbResult = *cDefault; |
| 3951 | | cc.lpCustColors = choice_colors; |
| 3952 | | cc.Flags = CC_ANYCOLOR | CC_RGBINIT | CC_SOLIDCOLOR; |
| 3953 | | if (!ChooseColor(&cc)) |
| 3954 | | return; |
| 3955 | | for (i=0;i<16;i++) |
| 3956 | | SetCustomColor(i,choice_colors[i]); |
| 3957 | | *cDefault = cc.rgbResult; |
| 3958 | | } |
| 3959 | | |
| 3960 | | static void PickCloneColor(void) |
| 3961 | | { |
| 3962 | | COLORREF cClonecolor; |
| 3963 | | cClonecolor = GetListCloneColor(); |
| 3964 | | PickColor( &cClonecolor); |
| 3965 | | SetListCloneColor(cClonecolor); |
| 3966 | | InvalidateRect(hwndList,NULL,FALSE); |
| 3967 | | } |
| 3968 | | |
| 3969 | | static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify) |
| 3970 | | { |
| 3971 | | int i; |
| 3972 | | LPTREEFOLDER folder; |
| 3973 | | char* t_szFile; |
| 3974 | | |
| 3975 | | switch (id) |
| 3976 | | { |
| 3977 | | case ID_FILE_PLAY: |
| 3978 | | MamePlayGame(); |
| 3979 | | return TRUE; |
| 3980 | | |
| 3981 | | case ID_FILE_PLAY_RECORD: |
| 3982 | | MamePlayRecordGame(); |
| 3983 | | return TRUE; |
| 3984 | | |
| 3985 | | case ID_FILE_PLAY_BACK: |
| 3986 | | MamePlayBackGame(); |
| 3987 | | return TRUE; |
| 3988 | | |
| 3989 | | case ID_FILE_PLAY_RECORD_WAVE: |
| 3990 | | MamePlayRecordWave(); |
| 3991 | | return TRUE; |
| 3992 | | |
| 3993 | | case ID_FILE_PLAY_RECORD_MNG: |
| 3994 | | MamePlayRecordMNG(); |
| 3995 | | return TRUE; |
| 3996 | | |
| 3997 | | case ID_FILE_LOADSTATE : |
| 3998 | | MameLoadState(); |
| 3999 | | return TRUE; |
| 4000 | | |
| 4001 | | case ID_FILE_AUDIT: |
| 4002 | | AuditDialog(hMain); |
| 4003 | | ResetWhichGamesInFolders(); |
| 4004 | | ResetListView(); |
| 4005 | | SetFocus(hwndList); |
| 4006 | | return TRUE; |
| 4007 | | |
| 4008 | | case ID_FILE_EXIT: |
| 4009 | | PostMessage(hMain, WM_CLOSE, 0, 0); |
| 4010 | | return TRUE; |
| 4011 | | |
| 4012 | | case ID_VIEW_LARGE_ICON: |
| 4013 | | SetView(ID_VIEW_LARGE_ICON); |
| 4014 | | return TRUE; |
| 4015 | | |
| 4016 | | case ID_VIEW_SMALL_ICON: |
| 4017 | | SetView(ID_VIEW_SMALL_ICON); |
| 4018 | | ResetListView(); |
| 4019 | | return TRUE; |
| 4020 | | |
| 4021 | | case ID_VIEW_LIST_MENU: |
| 4022 | | SetView(ID_VIEW_LIST_MENU); |
| 4023 | | return TRUE; |
| 4024 | | |
| 4025 | | case ID_VIEW_DETAIL: |
| 4026 | | SetView(ID_VIEW_DETAIL); |
| 4027 | | return TRUE; |
| 4028 | | |
| 4029 | | case ID_VIEW_GROUPED: |
| 4030 | | SetView(ID_VIEW_GROUPED); |
| 4031 | | return TRUE; |
| 4032 | | |
| 4033 | | /* Arrange Icons submenu */ |
| 4034 | | case ID_VIEW_BYGAME: |
| 4035 | | SetSortReverse(FALSE); |
| 4036 | | SetSortColumn(COLUMN_GAMES); |
| 4037 | | Picker_Sort(hwndList); |
| 4038 | | break; |
| 4039 | | |
| 4040 | | case ID_VIEW_BYDIRECTORY: |
| 4041 | | SetSortReverse(FALSE); |
| 4042 | | SetSortColumn(COLUMN_DIRECTORY); |
| 4043 | | Picker_Sort(hwndList); |
| 4044 | | break; |
| 4045 | | |
| 4046 | | case ID_VIEW_BYMANUFACTURER: |
| 4047 | | SetSortReverse(FALSE); |
| 4048 | | SetSortColumn(COLUMN_MANUFACTURER); |
| 4049 | | Picker_Sort(hwndList); |
| 4050 | | break; |
| 4051 | | |
| 4052 | | case ID_VIEW_BYTIMESPLAYED: |
| 4053 | | SetSortReverse(FALSE); |
| 4054 | | SetSortColumn(COLUMN_PLAYED); |
| 4055 | | Picker_Sort(hwndList); |
| 4056 | | break; |
| 4057 | | |
| 4058 | | case ID_VIEW_BYTYPE: |
| 4059 | | SetSortReverse(FALSE); |
| 4060 | | SetSortColumn(COLUMN_TYPE); |
| 4061 | | Picker_Sort(hwndList); |
| 4062 | | break; |
| 4063 | | |
| 4064 | | case ID_VIEW_BYYEAR: |
| 4065 | | SetSortReverse(FALSE); |
| 4066 | | SetSortColumn(COLUMN_YEAR); |
| 4067 | | Picker_Sort(hwndList); |
| 4068 | | break; |
| 4069 | | |
| 4070 | | case ID_VIEW_FOLDERS: |
| 4071 | | bShowTree = !bShowTree; |
| 4072 | | SetShowFolderList(bShowTree); |
| 4073 | | CheckMenuItem(GetMenu(hMain), ID_VIEW_FOLDERS, (bShowTree) ? MF_CHECKED : MF_UNCHECKED); |
| 4074 | | ToolBar_CheckButton(hToolBar, ID_VIEW_FOLDERS, (bShowTree) ? MF_CHECKED : MF_UNCHECKED); |
| 4075 | | UpdateScreenShot(); |
| 4076 | | break; |
| 4077 | | |
| 4078 | | case ID_VIEW_TOOLBARS: |
| 4079 | | bShowToolBar = !bShowToolBar; |
| 4080 | | SetShowToolBar(bShowToolBar); |
| 4081 | | CheckMenuItem(GetMenu(hMain), ID_VIEW_TOOLBARS, (bShowToolBar) ? MF_CHECKED : MF_UNCHECKED); |
| 4082 | | ToolBar_CheckButton(hToolBar, ID_VIEW_TOOLBARS, (bShowToolBar) ? MF_CHECKED : MF_UNCHECKED); |
| 4083 | | ShowWindow(hToolBar, (bShowToolBar) ? SW_SHOW : SW_HIDE); |
| 4084 | | ResizePickerControls(hMain); |
| 4085 | | UpdateScreenShot(); |
| 4086 | | break; |
| 4087 | | |
| 4088 | | case ID_VIEW_STATUS: |
| 4089 | | bShowStatusBar = !bShowStatusBar; |
| 4090 | | SetShowStatusBar(bShowStatusBar); |
| 4091 | | CheckMenuItem(GetMenu(hMain), ID_VIEW_STATUS, (bShowStatusBar) ? MF_CHECKED : MF_UNCHECKED); |
| 4092 | | ToolBar_CheckButton(hToolBar, ID_VIEW_STATUS, (bShowStatusBar) ? MF_CHECKED : MF_UNCHECKED); |
| 4093 | | ShowWindow(hStatusBar, (bShowStatusBar) ? SW_SHOW : SW_HIDE); |
| 4094 | | ResizePickerControls(hMain); |
| 4095 | | UpdateScreenShot(); |
| 4096 | | break; |
| 4097 | | |
| 4098 | | case ID_VIEW_PAGETAB: |
| 4099 | | bShowTabCtrl = !bShowTabCtrl; |
| 4100 | | SetShowTabCtrl(bShowTabCtrl); |
| 4101 | | ShowWindow(hTabCtrl, (bShowTabCtrl) ? SW_SHOW : SW_HIDE); |
| 4102 | | ResizePickerControls(hMain); |
| 4103 | | UpdateScreenShot(); |
| 4104 | | InvalidateRect(hMain,NULL,TRUE); |
| 4105 | | break; |
| 4106 | | |
| 4107 | | /* |
| 4108 | | Switches to fullscreen mode. No check mark handeling |
| 4109 | | for this item cause in fullscreen mode the menu won't |
| 4110 | | be visible anyways. |
| 4111 | | */ |
| 4112 | | case ID_VIEW_FULLSCREEN: |
| 4113 | | SwitchFullScreenMode(); |
| 4114 | | break; |
| 4115 | | |
| 4116 | | case ID_GAME_AUDIT: |
| 4117 | | InitGameAudit(0); |
| 4118 | | if (!oldControl) |
| 4119 | | { |
| 4120 | | InitPropertyPageToPage(hInst, hwnd, Picker_GetSelectedItem(hwndList), GetSelectedPickItemIcon(), AUDIT_PAGE, -1, SRC_GAME); |
| 4121 | | SaveGameOptions(Picker_GetSelectedItem(hwndList)); |
| 4122 | | } |
| 4123 | | /* Just in case the toggle MMX on/off */ |
| 4124 | | UpdateStatusBar(); |
| 4125 | | break; |
| 4126 | | |
| 4127 | | /* ListView Context Menu */ |
| 4128 | | case ID_CONTEXT_ADD_CUSTOM: |
| 4129 | | { |
| 4130 | | int nResult; |
| 4131 | | |
| 4132 | | nResult = DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_CUSTOM_FILE), |
| 4133 | | hMain,AddCustomFileDialogProc,Picker_GetSelectedItem(hwndList)); |
| 4134 | | SetFocus(hwndList); |
| 4135 | | break; |
| 4136 | | } |
| 4137 | | |
| 4138 | | case ID_CONTEXT_REMOVE_CUSTOM: |
| 4139 | | { |
| 4140 | | RemoveCurrentGameCustomFolder(); |
| 4141 | | break; |
| 4142 | | } |
| 4143 | | |
| 4144 | | /* Tree Context Menu */ |
| 4145 | | case ID_CONTEXT_FILTERS: |
| 4146 | | if (DialogBox(GetModuleHandle(NULL), |
| 4147 | | MAKEINTRESOURCE(IDD_FILTERS), hMain, FilterDialogProc) == TRUE) |
| 4148 | | ResetListView(); |
| 4149 | | SetFocus(hwndList); |
| 4150 | | return TRUE; |
| 4151 | | |
| 4152 | | // ScreenShot Context Menu |
| 4153 | | // select current tab |
| 4154 | | case ID_VIEW_TAB_SCREENSHOT : |
| 4155 | | case ID_VIEW_TAB_FLYER : |
| 4156 | | case ID_VIEW_TAB_CABINET : |
| 4157 | | case ID_VIEW_TAB_MARQUEE : |
| 4158 | | case ID_VIEW_TAB_TITLE : |
| 4159 | | case ID_VIEW_TAB_CONTROL_PANEL : |
| 4160 | | case ID_VIEW_TAB_HISTORY: |
| 4161 | | if (id == ID_VIEW_TAB_HISTORY && GetShowTab(TAB_HISTORY) == FALSE) |
| 4162 | | break; |
| 4163 | | |
| 4164 | | TabView_SetCurrentTab(hTabCtrl, id - ID_VIEW_TAB_SCREENSHOT); |
| 4165 | | UpdateScreenShot(); |
| 4166 | | TabView_UpdateSelection(hTabCtrl); |
| 4167 | | break; |
| 4168 | | |
| 4169 | | // toggle tab's existence |
| 4170 | | case ID_TOGGLE_TAB_SCREENSHOT : |
| 4171 | | case ID_TOGGLE_TAB_FLYER : |
| 4172 | | case ID_TOGGLE_TAB_CABINET : |
| 4173 | | case ID_TOGGLE_TAB_MARQUEE : |
| 4174 | | case ID_TOGGLE_TAB_TITLE : |
| 4175 | | case ID_TOGGLE_TAB_CONTROL_PANEL : |
| 4176 | | case ID_TOGGLE_TAB_HISTORY : |
| 4177 | | { |
| 4178 | | int toggle_flag = id - ID_TOGGLE_TAB_SCREENSHOT; |
| 4179 | | |
| 4180 | | if (AllowedToSetShowTab(toggle_flag,!GetShowTab(toggle_flag)) == FALSE) |
| 4181 | | { |
| 4182 | | // attempt to hide the last tab |
| 4183 | | // should show error dialog? hide picture area? or ignore? |
| 4184 | | break; |
| 4185 | | } |
| 4186 | | |
| 4187 | | SetShowTab(toggle_flag,!GetShowTab(toggle_flag)); |
| 4188 | | |
| 4189 | | TabView_Reset(hTabCtrl); |
| 4190 | | |
| 4191 | | if (TabView_GetCurrentTab(hTabCtrl) == toggle_flag && GetShowTab(toggle_flag) == FALSE) |
| 4192 | | { |
| 4193 | | // we're deleting the tab we're on, so go to the next one |
| 4194 | | TabView_CalculateNextTab(hTabCtrl); |
| 4195 | | } |
| 4196 | | |
| 4197 | | |
| 4198 | | // Resize the controls in case we toggled to another history |
| 4199 | | // mode (and the history control needs resizing). |
| 4200 | | |
| 4201 | | ResizePickerControls(hMain); |
| 4202 | | UpdateScreenShot(); |
| 4203 | | |
| 4204 | | TabView_UpdateSelection(hTabCtrl); |
| 4205 | | |
| 4206 | | break; |
| 4207 | | } |
| 4208 | | |
| 4209 | | /* Header Context Menu */ |
| 4210 | | case ID_SORT_ASCENDING: |
| 4211 | | SetSortReverse(FALSE); |
| 4212 | | SetSortColumn(Picker_GetRealColumnFromViewColumn(hwndList, lastColumnClick)); |
| 4213 | | Picker_Sort(hwndList); |
| 4214 | | break; |
| 4215 | | |
| 4216 | | case ID_SORT_DESCENDING: |
| 4217 | | SetSortReverse(TRUE); |
| 4218 | | SetSortColumn(Picker_GetRealColumnFromViewColumn(hwndList, lastColumnClick)); |
| 4219 | | Picker_Sort(hwndList); |
| 4220 | | break; |
| 4221 | | |
| 4222 | | case ID_CUSTOMIZE_FIELDS: |
| 4223 | | if (DialogBox(GetModuleHandle(NULL), |
| 4224 | | MAKEINTRESOURCE(IDD_COLUMNS), hMain, ColumnDialogProc) == TRUE) |
| 4225 | | ResetColumnDisplay(FALSE); |
| 4226 | | SetFocus(hwndList); |
| 4227 | | return TRUE; |
| 4228 | | |
| 4229 | | /* View Menu */ |
| 4230 | | case ID_VIEW_LINEUPICONS: |
| 4231 | | if( codeNotify == FALSE) |
| 4232 | | ResetListView(); |
| 4233 | | else |
| 4234 | | { |
| 4235 | | /*it was sent after a refresh (F5) was done, we only reset the View if "available" is the selected folder |
| 4236 | | as it doesn't affect the others*/ |
| 4237 | | folder = GetSelectedFolder(); |
| 4238 | | if( folder ) |
| 4239 | | { |
| 4240 | | if (folder->m_nFolderId == FOLDER_AVAILABLE ) |
| 4241 | | ResetListView(); |
| 4242 | | |
| 4243 | | } |
| 4244 | | } |
| 4245 | | break; |
| 4246 | | |
| 4247 | | case ID_GAME_PROPERTIES: |
| 4248 | | if (!oldControl) |
| 4249 | | { |
| 4250 | | //folder = GetSelectedFolder(); |
| 4251 | | folder = GetFolderByName(FOLDER_SOURCE, GetDriverFilename(Picker_GetSelectedItem(hwndList)) ); |
| 4252 | | InitPropertyPage(hInst, hwnd, Picker_GetSelectedItem(hwndList), GetSelectedPickItemIcon(), folder->m_nFolderId, SRC_GAME); |
| 4253 | | SaveGameOptions(Picker_GetSelectedItem(hwndList)); |
| 4254 | | #ifdef MESS |
| 4255 | | { |
| 4256 | | extern BOOL g_bModifiedSoftwarePaths; |
| 4257 | | if (g_bModifiedSoftwarePaths) { |
| 4258 | | g_bModifiedSoftwarePaths = FALSE; |
| 4259 | | MessUpdateSoftwareList(); |
| 4260 | | } |
| 4261 | | } |
| 4262 | | #endif |
| 4263 | | } |
| 4264 | | /* Just in case the toggle MMX on/off */ |
| 4265 | | UpdateStatusBar(); |
| 4266 | | break; |
| 4267 | | |
| 4268 | | case ID_FOLDER_PROPERTIES: |
| 4269 | | if (!oldControl) |
| 4270 | | { |
| 4271 | | folder = GetSelectedFolder(); |
| 4272 | | InitPropertyPage(hInst, hwnd, folder->m_nFolderId, GetSelectedFolderIcon(), Picker_GetSelectedItem(hwndList), SRC_FOLDER); |
| 4273 | | SaveFolderOptions(folder->m_nFolderId, Picker_GetSelectedItem(hwndList) ); |
| 4274 | | } |
| 4275 | | /* Just in case the toggle MMX on/off */ |
| 4276 | | UpdateStatusBar(); |
| 4277 | | break; |
| 4278 | | |
| 4279 | | case ID_FOLDER_SOURCEPROPERTIES: |
| 4280 | | if (!oldControl) |
| 4281 | | { |
| 4282 | | folder = GetFolderByName(FOLDER_SOURCE, GetDriverFilename(Picker_GetSelectedItem(hwndList)) ); |
| 4283 | | InitPropertyPage(hInst, hwnd, folder->m_nFolderId, GetSelectedFolderIcon(), Picker_GetSelectedItem(hwndList), SRC_FOLDER); |
| 4284 | | SaveFolderOptions(folder->m_nFolderId, Picker_GetSelectedItem(hwndList) ); |
| 4285 | | } |
| 4286 | | /* Just in case the toggle MMX on/off */ |
| 4287 | | UpdateStatusBar(); |
| 4288 | | break; |
| 4289 | | |
| 4290 | | case ID_FOLDER_VECTORPROPERTIES: |
| 4291 | | if (!oldControl) |
| 4292 | | { |
| 4293 | | folder = GetFolderByID( FOLDER_VECTOR ); |
| 4294 | | InitPropertyPage(hInst, hwnd, folder->m_nFolderId, GetSelectedFolderIcon(), Picker_GetSelectedItem(hwndList), SRC_FOLDER); |
| 4295 | | SaveFolderOptions(folder->m_nFolderId, Picker_GetSelectedItem(hwndList) ); |
| 4296 | | } |
| 4297 | | /* Just in case the toggle MMX on/off */ |
| 4298 | | UpdateStatusBar(); |
| 4299 | | break; |
| 4300 | | |
| 4301 | | case ID_FOLDER_AUDIT: |
| 4302 | | FolderCheck(); |
| 4303 | | /* Just in case the toggle MMX on/off */ |
| 4304 | | UpdateStatusBar(); |
| 4305 | | break; |
| 4306 | | |
| 4307 | | case ID_VIEW_PICTURE_AREA : |
| 4308 | | ToggleScreenShot(); |
| 4309 | | break; |
| 4310 | | |
| 4311 | | case ID_UPDATE_GAMELIST: |
| 4312 | | UpdateGameList(TRUE, TRUE); |
| 4313 | | break; |
| 4314 | | |
| 4315 | | case ID_OPTIONS_FONT: |
| 4316 | | PickFont(); |
| 4317 | | return TRUE; |
| 4318 | | |
| 4319 | | case ID_OPTIONS_CLONE_COLOR: |
| 4320 | | PickCloneColor(); |
| 4321 | | return TRUE; |
| 4322 | | |
| 4323 | | case ID_OPTIONS_DEFAULTS: |
| 4324 | | /* Check the return value to see if changes were applied */ |
| 4325 | | if (!oldControl) |
| 4326 | | { |
| 4327 | | InitDefaultPropertyPage(hInst, hwnd); |
| 4328 | | SaveDefaultOptions(); |
| 4329 | | } |
| 4330 | | SetFocus(hwndList); |
| 4331 | | return TRUE; |
| 4332 | | |
| 4333 | | case ID_OPTIONS_DIR: |
| 4334 | | { |
| 4335 | | int nResult; |
| 4336 | | BOOL bUpdateRoms; |
| 4337 | | BOOL bUpdateSamples; |
| 4338 | | #ifdef MESS |
| 4339 | | BOOL bUpdateSoftware; |
| 4340 | | #endif |
| 4341 | | |
| 4342 | | nResult = DialogBox(GetModuleHandle(NULL), |
| 4343 | | MAKEINTRESOURCE(IDD_DIRECTORIES), |
| 4344 | | hMain, |
| 4345 | | DirectoriesDialogProc); |
| 4346 | | |
| 4347 | | SaveDefaultOptions(); |
| 4348 | | |
| 4349 | | bUpdateRoms = ((nResult & DIRDLG_ROMS) == DIRDLG_ROMS) ? TRUE : FALSE; |
| 4350 | | bUpdateSamples = ((nResult & DIRDLG_SAMPLES) == DIRDLG_SAMPLES) ? TRUE : FALSE; |
| 4351 | | #ifdef MESS |
| 4352 | | bUpdateSoftware = ((nResult & DIRDLG_SOFTWARE) == DIRDLG_SOFTWARE) ? TRUE : FALSE; |
| 4353 | | |
| 4354 | | if (bUpdateSoftware) |
| 4355 | | MessUpdateSoftwareList(); |
| 4356 | | #endif /* MESS */ |
| 4357 | | |
| 4358 | | if (s_pWatcher) |
| 4359 | | { |
| 4360 | | if (bUpdateRoms) |
| 4361 | | DirWatcher_Watch(s_pWatcher, 0, GetRomDirs(), TRUE); |
| 4362 | | if (bUpdateSamples) |
| 4363 | | DirWatcher_Watch(s_pWatcher, 1, GetSampleDirs(), TRUE); |
| 4364 | | } |
| 4365 | | |
| 4366 | | /* update game list */ |
| 4367 | | if (bUpdateRoms == TRUE || bUpdateSamples == TRUE) |
| 4368 | | UpdateGameList(bUpdateRoms, bUpdateSamples); |
| 4369 | | |
| 4370 | | SetFocus(hwndList); |
| 4371 | | } |
| 4372 | | return TRUE; |
| 4373 | | |
| 4374 | | case ID_OPTIONS_RESET_DEFAULTS: |
| 4375 | | if (DialogBox(GetModuleHandle(NULL), |
| 4376 | | MAKEINTRESOURCE(IDD_RESET), hMain, ResetDialogProc) == TRUE) |
| 4377 | | { |
| 4378 | | // these may have been changed |
| 4379 | | SaveDefaultOptions(); |
| 4380 | | DestroyWindow(hwnd); |
| 4381 | | PostQuitMessage(0); |
| 4382 | | } |
| 4383 | | return TRUE; |
| 4384 | | |
| 4385 | | case ID_OPTIONS_INTERFACE: |
| 4386 | | DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_INTERFACE_OPTIONS), |
| 4387 | | hMain, InterfaceDialogProc); |
| 4388 | | SaveDefaultOptions(); |
| 4389 | | |
| 4390 | | KillTimer(hMain, SCREENSHOT_TIMER); |
| 4391 | | if( GetCycleScreenshot() > 0) |
| 4392 | | { |
| 4393 | | SetTimer(hMain, SCREENSHOT_TIMER, GetCycleScreenshot()*1000, NULL ); // Scale to seconds |
| 4394 | | } |
| 4395 | | |
| 4396 | | return TRUE; |
| 4397 | | |
| 4398 | | case ID_OPTIONS_BG: |
| 4399 | | { |
| 4400 | | OPENFILENAME OpenFileName; |
| 4401 | | static TCHAR szFile[MAX_PATH] = TEXT("\0"); |
| 4402 | | TCHAR* t_bgdir = tstring_from_utf8(GetBgDir()); |
| 4403 | | if( !t_bgdir ) |
| 4404 | | return FALSE; |
| 4405 | | |
| 4406 | | OpenFileName.lStructSize = sizeof(OPENFILENAME); |
| 4407 | | OpenFileName.hwndOwner = hMain; |
| 4408 | | OpenFileName.hInstance = 0; |
| 4409 | | OpenFileName.lpstrFilter = TEXT("Image Files (*.png, *.bmp)\0*.PNG;*.BMP\0"); |
| 4410 | | OpenFileName.lpstrCustomFilter = NULL; |
| 4411 | | OpenFileName.nMaxCustFilter = 0; |
| 4412 | | OpenFileName.nFilterIndex = 1; |
| 4413 | | OpenFileName.lpstrFile = szFile; |
| 4414 | | OpenFileName.nMaxFile = sizeof(szFile); |
| 4415 | | OpenFileName.lpstrFileTitle = NULL; |
| 4416 | | OpenFileName.nMaxFileTitle = 0; |
| 4417 | | OpenFileName.lpstrInitialDir = t_bgdir; |
| 4418 | | OpenFileName.lpstrTitle = TEXT("Select a Background Image"); |
| 4419 | | OpenFileName.nFileOffset = 0; |
| 4420 | | OpenFileName.nFileExtension = 0; |
| 4421 | | OpenFileName.lpstrDefExt = NULL; |
| 4422 | | OpenFileName.lCustData = 0; |
| 4423 | | OpenFileName.lpfnHook = NULL; |
| 4424 | | OpenFileName.lpTemplateName = NULL; |
| 4425 | | OpenFileName.Flags = OFN_NOCHANGEDIR | OFN_SHOWHELP | OFN_EXPLORER; |
| 4426 | | |
| 4427 | | if (GetOpenFileName(&OpenFileName)) |
| 4428 | | { |
| 4429 | | t_szFile = utf8_from_tstring(szFile); |
| 4430 | | if( !t_szFile ) |
| 4431 | | return FALSE; |
| 4432 | | ResetBackground(t_szFile); |
| 4433 | | LoadBackgroundBitmap(); |
| 4434 | | InvalidateRect(hMain, NULL, TRUE); |
| 4435 | | free(t_bgdir); |
| 4436 | | free(t_szFile); |
| 4437 | | return TRUE; |
| 4438 | | } |
| 4439 | | free(t_bgdir); |
| 4440 | | } |
| 4441 | | break; |
| 4442 | | |
| 4443 | | case ID_OPTIONS_LANGUAGE: |
| 4444 | | DialogBox(GetModuleHandle(NULL), |
| 4445 | | MAKEINTRESOURCE(IDD_LANGUAGE), |
| 4446 | | hMain, |
| 4447 | | LanguageDialogProc); |
| 4448 | | return TRUE; |
| 4449 | | |
| 4450 | | case ID_HELP_ABOUT: |
| 4451 | | DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_ABOUT), |
| 4452 | | hMain, AboutDialogProc); |
| 4453 | | SetFocus(hwndList); |
| 4454 | | return TRUE; |
| 4455 | | |
| 4456 | | case IDOK : |
| 4457 | | /* cmk -- might need to check more codes here, not sure */ |
| 4458 | | if (codeNotify != EN_CHANGE && codeNotify != EN_UPDATE) |
| 4459 | | { |
| 4460 | | /* enter key */ |
| 4461 | | if (g_in_treeview_edit) |
| 4462 | | { |
| 4463 | | TreeView_EndEditLabelNow(hTreeView, FALSE); |
| 4464 | | return TRUE; |
| 4465 | | } |
| 4466 | | else |
| 4467 | | if (have_selection) |
| 4468 | | MamePlayGame(); |
| 4469 | | } |
| 4470 | | break; |
| 4471 | | |
| 4472 | | case IDCANCEL : /* esc key */ |
| 4473 | | if (g_in_treeview_edit) |
| 4474 | | TreeView_EndEditLabelNow(hTreeView, TRUE); |
| 4475 | | break; |
| 4476 | | |
| 4477 | | case IDC_PLAY_GAME : |
| 4478 | | if (have_selection) |
| 4479 | | MamePlayGame(); |
| 4480 | | break; |
| 4481 | | |
| 4482 | | case ID_UI_START: |
| 4483 | | SetFocus(hwndList); |
| 4484 | | MamePlayGame(); |
| 4485 | | break; |
| 4486 | | |
| 4487 | | case ID_UI_UP: |
| 4488 | | Picker_SetSelectedPick(hwndList, GetSelectedPick() - 1); |
| 4489 | | break; |
| 4490 | | |
| 4491 | | case ID_UI_DOWN: |
| 4492 | | Picker_SetSelectedPick(hwndList, GetSelectedPick() + 1); |
| 4493 | | break; |
| 4494 | | |
| 4495 | | case ID_UI_PGUP: |
| 4496 | | Picker_SetSelectedPick(hwndList, GetSelectedPick() - ListView_GetCountPerPage(hwndList)); |
| 4497 | | break; |
| 4498 | | |
| 4499 | | case ID_UI_PGDOWN: |
| 4500 | | if ( (GetSelectedPick() + ListView_GetCountPerPage(hwndList)) < ListView_GetItemCount(hwndList) ) |
| 4501 | | Picker_SetSelectedPick(hwndList, GetSelectedPick() + ListView_GetCountPerPage(hwndList) ); |
| 4502 | | else |
| 4503 | | Picker_SetSelectedPick(hwndList, ListView_GetItemCount(hwndList)-1 ); |
| 4504 | | break; |
| 4505 | | |
| 4506 | | case ID_UI_HOME: |
| 4507 | | Picker_SetSelectedPick(hwndList, 0); |
| 4508 | | break; |
| 4509 | | |
| 4510 | | case ID_UI_END: |
| 4511 | | Picker_SetSelectedPick(hwndList, ListView_GetItemCount(hwndList)-1 ); |
| 4512 | | break; |
| 4513 | | case ID_UI_LEFT: |
| 4514 | | /* hmmmmm..... */ |
| 4515 | | SendMessage(hwndList,WM_HSCROLL, SB_LINELEFT, 0); |
| 4516 | | break; |
| 4517 | | |
| 4518 | | case ID_UI_RIGHT: |
| 4519 | | /* hmmmmm..... */ |
| 4520 | | SendMessage(hwndList,WM_HSCROLL, SB_LINERIGHT, 0); |
| 4521 | | break; |
| 4522 | | case ID_UI_HISTORY_UP: |
| 4523 | | /* hmmmmm..... */ |
| 4524 | | { |
| 4525 | | HWND hHistory = GetDlgItem(hMain, IDC_HISTORY); |
| 4526 | | SendMessage(hHistory, EM_SCROLL, SB_PAGEUP, 0); |
| 4527 | | } |
| 4528 | | break; |
| 4529 | | |
| 4530 | | case ID_UI_HISTORY_DOWN: |
| 4531 | | /* hmmmmm..... */ |
| 4532 | | { |
| 4533 | | HWND hHistory = GetDlgItem(hMain, IDC_HISTORY); |
| 4534 | | SendMessage(hHistory, EM_SCROLL, SB_PAGEDOWN, 0); |
| 4535 | | } |
| 4536 | | break; |
| 4537 | | |
| 4538 | | case IDC_SSFRAME: |
| 4539 | | TabView_CalculateNextTab(hTabCtrl); |
| 4540 | | UpdateScreenShot(); |
| 4541 | | TabView_UpdateSelection(hTabCtrl); |
| 4542 | | break; |
| 4543 | | |
| 4544 | | case ID_CONTEXT_SELECT_RANDOM: |
| 4545 | | SetRandomPickItem(); |
| 4546 | | break; |
| 4547 | | |
| 4548 | | case ID_CONTEXT_RESET_PLAYTIME: |
| 4549 | | ResetPlayTime( Picker_GetSelectedItem(hwndList) ); |
| 4550 | | ListView_RedrawItems(hwndList, GetSelectedPick(), GetSelectedPick()); |
| 4551 | | break; |
| 4552 | | |
| 4553 | | case ID_CONTEXT_RESET_PLAYCOUNT: |
| 4554 | | ResetPlayCount( Picker_GetSelectedItem(hwndList) ); |
| 4555 | | ListView_RedrawItems(hwndList, GetSelectedPick(), GetSelectedPick()); |
| 4556 | | break; |
| 4557 | | |
| 4558 | | case ID_CONTEXT_RENAME_CUSTOM : |
| 4559 | | TreeView_EditLabel(hTreeView,TreeView_GetSelection(hTreeView)); |
| 4560 | | break; |
| 4561 | | |
| 4562 | | default: |
| 4563 | | if (id >= ID_CONTEXT_SHOW_FOLDER_START && id < ID_CONTEXT_SHOW_FOLDER_END) |
| 4564 | | { |
| 4565 | | ToggleShowFolder(id - ID_CONTEXT_SHOW_FOLDER_START); |
| 4566 | | break; |
| 4567 | | } |
| 4568 | | for (i = 0; g_helpInfo[i].nMenuItem > 0; i++) |
| 4569 | | { |
| 4570 | | if (g_helpInfo[i].nMenuItem == id) |
| 4571 | | { |
| 4572 | | if (g_helpInfo[i].bIsHtmlHelp) |
| 4573 | | HelpFunction(hMain, g_helpInfo[i].lpFile, HH_DISPLAY_TOPIC, 0); |
| 4574 | | else |
| 4575 | | DisplayTextFile(hMain, g_helpInfo[i].lpFile); |
| 4576 | | return FALSE; |
| 4577 | | } |
| 4578 | | } |
| 4579 | | #ifdef MESS |
| 4580 | | return MessCommand(hwnd, id, hwndCtl, codeNotify); |
| 4581 | | #else |
| 4582 | | break; |
| 4583 | | #endif |
| 4584 | | } |
| 4585 | | |
| 4586 | | return FALSE; |
| 4587 | | } |
| 4588 | | |
| 4589 | | static void LoadBackgroundBitmap() |
| 4590 | | { |
| 4591 | | HGLOBAL hDIBbg; |
| 4592 | | char* pFileName = 0; |
| 4593 | | |
| 4594 | | if (hBackground) |
| 4595 | | { |
| 4596 | | DeleteObject(hBackground); |
| 4597 | | hBackground = 0; |
| 4598 | | } |
| 4599 | | |
| 4600 | | if (hPALbg) |
| 4601 | | { |
| 4602 | | DeleteObject(hPALbg); |
| 4603 | | hPALbg = 0; |
| 4604 | | } |
| 4605 | | |
| 4606 | | /* Pick images based on number of colors avaliable. */ |
| 4607 | | if (GetDepth(hwndList) <= 8) |
| 4608 | | { |
| 4609 | | pFileName = (char *)"bkgnd16"; |
| 4610 | | /*nResource = IDB_BKGROUND16;*/ |
| 4611 | | } |
| 4612 | | else |
| 4613 | | { |
| 4614 | | pFileName = (char *)"bkground"; |
| 4615 | | /*nResource = IDB_BKGROUND;*/ |
| 4616 | | } |
| 4617 | | |
| 4618 | | if (LoadDIB(pFileName, &hDIBbg, &hPALbg, BACKGROUND)) |
| 4619 | | { |
| 4620 | | HDC hDC = GetDC(hwndList); |
| 4621 | | hBackground = DIBToDDB(hDC, hDIBbg, &bmDesc); |
| 4622 | | GlobalFree(hDIBbg); |
| 4623 | | ReleaseDC(hwndList, hDC); |
| 4624 | | } |
| 4625 | | } |
| 4626 | | |
| 4627 | | static void ResetColumnDisplay(BOOL first_time) |
| 4628 | | { |
| 4629 | | int driver_index; |
| 4630 | | |
| 4631 | | if (!first_time) |
| 4632 | | Picker_ResetColumnDisplay(hwndList); |
| 4633 | | |
| 4634 | | ResetListView(); |
| 4635 | | |
| 4636 | | driver_index = GetGameNameIndex(GetDefaultGame()); |
| 4637 | | Picker_SetSelectedItem(hwndList, driver_index); |
| 4638 | | } |
| 4639 | | |
| 4640 | | int GamePicker_GetItemImage(HWND hwndPicker, int nItem) |
| 4641 | | { |
| 4642 | | return GetIconForDriver(nItem); |
| 4643 | | } |
| 4644 | | |
| 4645 | | const TCHAR *GamePicker_GetItemString(HWND hwndPicker, int nItem, int nColumn, |
| 4646 | | TCHAR *pszBuffer, UINT nBufferLength) |
| 4647 | | { |
| 4648 | | const TCHAR *s = NULL; |
| 4649 | | const char* utf8_s = NULL; |
| 4650 | | char playtime_buf[256]; |
| 4651 | | |
| 4652 | | switch(nColumn) |
| 4653 | | { |
| 4654 | | case COLUMN_GAMES: |
| 4655 | | /* Driver description */ |
| 4656 | | utf8_s = ModifyThe(drivers[nItem]->description); |
| 4657 | | break; |
| 4658 | | |
| 4659 | | case COLUMN_ROMS: |
| 4660 | | /* Has Roms */ |
| 4661 | | utf8_s = GetAuditString(GetRomAuditResults(nItem)); |
| 4662 | | break; |
| 4663 | | |
| 4664 | | case COLUMN_SAMPLES: |
| 4665 | | /* Samples */ |
| 4666 | | if (DriverUsesSamples(nItem)) |
| 4667 | | utf8_s = GetAuditString(GetSampleAuditResults(nItem)); |
| 4668 | | break; |
| 4669 | | |
| 4670 | | case COLUMN_DIRECTORY: |
| 4671 | | /* Driver name (directory) */ |
| 4672 | | utf8_s = drivers[nItem]->name; |
| 4673 | | break; |
| 4674 | | |
| 4675 | | case COLUMN_SRCDRIVERS: |
| 4676 | | /* Source drivers */ |
| 4677 | | utf8_s = GetDriverFilename(nItem); |
| 4678 | | break; |
| 4679 | | |
| 4680 | | case COLUMN_PLAYTIME: |
| 4681 | | /* Source drivers */ |
| 4682 | | GetTextPlayTime(nItem, playtime_buf); |
| 4683 | | utf8_s = playtime_buf; |
| 4684 | | break; |
| 4685 | | |
| 4686 | | case COLUMN_TYPE: |
| 4687 | | { |
| 4688 | | machine_config drv; |
| 4689 | | expand_machine_driver(drivers[nItem]->drv,&drv); |
| 4690 | | |
| 4691 | | /* Vector/Raster */ |
| 4692 | | if (drv.video_attributes & VIDEO_TYPE_VECTOR) |
| 4693 | | s = TEXT("Vector"); |
| 4694 | | else |
| 4695 | | s = TEXT("Raster"); |
| 4696 | | break; |
| 4697 | | } |
| 4698 | | case COLUMN_TRACKBALL: |
| 4699 | | /* Trackball */ |
| 4700 | | if (DriverUsesTrackball(nItem)) |
| 4701 | | s = TEXT("Yes"); |
| 4702 | | else |
| 4703 | | s = TEXT("No"); |
| 4704 | | break; |
| 4705 | | |
| 4706 | | case COLUMN_PLAYED: |
| 4707 | | /* times played */ |
| 4708 | | _sntprintf(pszBuffer, nBufferLength, TEXT("%i"), GetPlayCount(nItem)); |
| 4709 | | s = pszBuffer; |
| 4710 | | break; |
| 4711 | | |
| 4712 | | case COLUMN_MANUFACTURER: |
| 4713 | | /* Manufacturer */ |
| 4714 | | utf8_s = drivers[nItem]->manufacturer; |
| 4715 | | break; |
| 4716 | | |
| 4717 | | case COLUMN_YEAR: |
| 4718 | | /* Year */ |
| 4719 | | utf8_s = drivers[nItem]->year; |
| 4720 | | break; |
| 4721 | | |
| 4722 | | case COLUMN_CLONE: |
| 4723 | | utf8_s = GetCloneParentName(nItem); |
| 4724 | | break; |
| 4725 | | } |
| 4726 | | |
| 4727 | | if( utf8_s ) |
| 4728 | | { |
| 4729 | | TCHAR* t_s = tstring_from_utf8(utf8_s); |
| 4730 | | if( !t_s ) |
| 4731 | | return s; |
| 4732 | | |
| 4733 | | _sntprintf(pszBuffer, nBufferLength, TEXT("%s"), t_s); |
| 4734 | | free(t_s); |
| 4735 | | |
| 4736 | | s = pszBuffer; |
| 4737 | | } |
| 4738 | | |
| 4739 | | return s; |
| 4740 | | } |
| 4741 | | |
| 4742 | | static void GamePicker_LeavingItem(HWND hwndPicker, int nItem) |
| 4743 | | { |
| 4744 | | // leaving item |
| 4745 | | // printf("leaving %s\n",drivers[nItem]->name); |
| 4746 | | } |
| 4747 | | |
| 4748 | | static void GamePicker_EnteringItem(HWND hwndPicker, int nItem) |
| 4749 | | { |
| 4750 | | TCHAR* t_description; |
| 4751 | | ATOM a; |
| 4752 | | // printf("entering %s\n",drivers[nItem]->name); |
| 4753 | | if (g_bDoBroadcast == TRUE) |
| 4754 | | { |
| 4755 | | t_description = tstring_from_utf8(drivers[nItem]->description); |
| 4756 | | if( !t_description ) |
| 4757 | | return; |
| 4758 | | a = GlobalAddAtom(t_description); |
| 4759 | | SendMessage(HWND_BROADCAST, g_mame32_message, a, a); |
| 4760 | | GlobalDeleteAtom(a); |
| 4761 | | free(t_description); |
| 4762 | | } |
| 4763 | | |
| 4764 | | EnableSelection(nItem); |
| 4765 | | #ifdef MESS |
| 4766 | | MessReadMountedSoftware(nItem); |
| 4767 | | #endif |
| 4768 | | } |
| 4769 | | |
| 4770 | | static int GamePicker_FindItemParent(HWND hwndPicker, int nItem) |
| 4771 | | { |
| 4772 | | return GetParentRomSetIndex(drivers[nItem]); |
| 4773 | | } |
| 4774 | | |
| 4775 | | /* Initialize the Picker and List controls */ |
| 4776 | | static void InitListView() |
| 4777 | | { |
| 4778 | | LVBKIMAGE bki; |
| 4779 | | TCHAR path[MAX_PATH]; |
| 4780 | | TCHAR* t_bgdir; |
| 4781 | | |
| 4782 | | static const struct PickerCallbacks s_gameListCallbacks = |
| 4783 | | { |
| 4784 | | SetSortColumn, /* pfnSetSortColumn */ |
| 4785 | | GetSortColumn, /* pfnGetSortColumn */ |
| 4786 | | SetSortReverse, /* pfnSetSortReverse */ |
| 4787 | | GetSortReverse, /* pfnGetSortReverse */ |
| 4788 | | SetViewMode, /* pfnSetViewMode */ |
| 4789 | | GetViewMode, /* pfnGetViewMode */ |
| 4790 | | SetColumnWidths, /* pfnSetColumnWidths */ |
| 4791 | | GetColumnWidths, /* pfnGetColumnWidths */ |
| 4792 | | SetColumnOrder, /* pfnSetColumnOrder */ |
| 4793 | | GetColumnOrder, /* pfnGetColumnOrder */ |
| 4794 | | SetColumnShown, /* pfnSetColumnShown */ |
| 4795 | | GetColumnShown, /* pfnGetColumnShown */ |
| 4796 | | GetOffsetClones, /* pfnGetOffsetChildren */ |
| 4797 | | |
| 4798 | | GamePicker_Compare, /* pfnCompare */ |
| 4799 | | MamePlayGame, /* pfnDoubleClick */ |
| 4800 | | GamePicker_GetItemString, /* pfnGetItemString */ |
| 4801 | | GamePicker_GetItemImage, /* pfnGetItemImage */ |
| 4802 | | GamePicker_LeavingItem, /* pfnLeavingItem */ |
| 4803 | | GamePicker_EnteringItem, /* pfnEnteringItem */ |
| 4804 | | BeginListViewDrag, /* pfnBeginListViewDrag */ |
| 4805 | | GamePicker_FindItemParent, /* pfnFindItemParent */ |
| 4806 | | OnIdle, /* pfnIdle */ |
| 4807 | | GamePicker_OnHeaderContextMenu, /* pfnOnHeaderContextMenu */ |
| 4808 | | GamePicker_OnBodyContextMenu /* pfnOnBodyContextMenu */ |
| 4809 | | }; |
| 4810 | | |
| 4811 | | struct PickerOptions opts; |
| 4812 | | |
| 4813 | | // subclass the list view |
| 4814 | | memset(&opts, 0, sizeof(opts)); |
| 4815 | | opts.pCallbacks = &s_gameListCallbacks; |
| 4816 | | opts.nColumnCount = COLUMN_MAX; |
| 4817 | | opts.ppszColumnNames = column_names; |
| 4818 | | SetupPicker(hwndList, &opts); |
| 4819 | | |
| 4820 | | ListView_SetTextBkColor(hwndList, CLR_NONE); |
| 4821 | | ListView_SetBkColor(hwndList, CLR_NONE); |
| 4822 | | t_bgdir = tstring_from_utf8(GetBgDir()); |
| 4823 | | if( !t_bgdir ) |
| 4824 | | return; |
| 4825 | | _stprintf(path, TEXT("%s\\bkground.png"), t_bgdir); |
| 4826 | | bki.ulFlags = LVBKIF_SOURCE_URL | LVBKIF_STYLE_TILE; |
| 4827 | | bki.pszImage = path; |
| 4828 | | if( hBackground ) |
| 4829 | | ListView_SetBkImage(hwndList, &bki); |
| 4830 | | |
| 4831 | | CreateIcons(); |
| 4832 | | |
| 4833 | | ResetColumnDisplay(TRUE); |
| 4834 | | |
| 4835 | | // Allow selection to change the default saved game |
| 4836 | | bListReady = TRUE; |
| 4837 | | free(t_bgdir); |
| 4838 | | } |
| 4839 | | |
| 4840 | | static void AddDriverIcon(int nItem,int default_icon_index) |
| 4841 | | { |
| 4842 | | HICON hIcon = 0; |
| 4843 | | int nParentIndex = -1; |
| 4844 | | |
| 4845 | | /* if already set to rom or clone icon, we've been here before */ |
| 4846 | | if (icon_index[nItem] == 1 || icon_index[nItem] == 3) |
| 4847 | | return; |
| 4848 | | |
| 4849 | | hIcon = LoadIconFromFile((char *)drivers[nItem]->name); |
| 4850 | | if (hIcon == NULL) |
| 4851 | | { |
| 4852 | | nParentIndex = GetParentIndex(drivers[nItem]); |
| 4853 | | if( nParentIndex >= 0) |
| 4854 | | { |
| 4855 | | hIcon = LoadIconFromFile((char *)drivers[nParentIndex]->name); |
| 4856 | | nParentIndex = GetParentIndex(drivers[nParentIndex]); |
| 4857 | | if (hIcon == NULL && nParentIndex >= 0) |
| 4858 | | hIcon = LoadIconFromFile((char *)drivers[nParentIndex]->name); |
| 4859 | | } |
| 4860 | | } |
| 4861 | | |
| 4862 | | if (hIcon != NULL) |
| 4863 | | { |
| 4864 | | int nIconPos = ImageList_AddIcon(hSmall, hIcon); |
| 4865 | | ImageList_AddIcon(hLarge, hIcon); |
| 4866 | | if (nIconPos != -1) |
| 4867 | | icon_index[nItem] = nIconPos; |
| 4868 | | } |
| 4869 | | if (icon_index[nItem] == 0) |
| 4870 | | icon_index[nItem] = default_icon_index; |
| 4871 | | } |
| 4872 | | |
| 4873 | | static void DestroyIcons(void) |
| 4874 | | { |
| 4875 | | if (hSmall != NULL) |
| 4876 | | { |
| 4877 | | ImageList_Destroy(hSmall); |
| 4878 | | hSmall = NULL; |
| 4879 | | } |
| 4880 | | |
| 4881 | | if (icon_index != NULL) |
| 4882 | | { |
| 4883 | | int i; |
| 4884 | | for (i=0;i<driver_list_get_count(drivers);i++) |
| 4885 | | icon_index[i] = 0; // these are indices into hSmall |
| 4886 | | } |
| 4887 | | |
| 4888 | | if (hLarge != NULL) |
| 4889 | | { |
| 4890 | | ImageList_Destroy(hLarge); |
| 4891 | | hLarge = NULL; |
| 4892 | | } |
| 4893 | | |
| 4894 | | if (hHeaderImages != NULL) |
| 4895 | | { |
| 4896 | | ImageList_Destroy(hHeaderImages); |
| 4897 | | hHeaderImages = NULL; |
| 4898 | | } |
| 4899 | | |
| 4900 | | } |
| 4901 | | |
| 4902 | | static void ReloadIcons(void) |
| 4903 | | { |
| 4904 | | HICON hIcon; |
| 4905 | | INT i; |
| 4906 | | |
| 4907 | | // clear out all the images |
| 4908 | | ImageList_Remove(hSmall,-1); |
| 4909 | | ImageList_Remove(hLarge,-1); |
| 4910 | | |
| 4911 | | if (icon_index != NULL) |
| 4912 | | { |
| 4913 | | for (i=0;i<driver_list_get_count(drivers);i++) |
| 4914 | | icon_index[i] = 0; // these are indices into hSmall |
| 4915 | | } |
| 4916 | | |
| 4917 | | for (i = 0; g_iconData[i].icon_name; i++) |
| 4918 | | { |
| 4919 | | hIcon = LoadIconFromFile((char *) g_iconData[i].icon_name); |
| 4920 | | if (hIcon == NULL) |
| 4921 | | hIcon = LoadIcon(hInst, MAKEINTRESOURCE(g_iconData[i].resource)); |
| 4922 | | |
| 4923 | | ImageList_AddIcon(hSmall, hIcon); |
| 4924 | | ImageList_AddIcon(hLarge, hIcon); |
| 4925 | | } |
| 4926 | | } |
| 4927 | | |
| 4928 | | static DWORD GetShellLargeIconSize(void) |
| 4929 | | { |
| 4930 | | DWORD dwSize, dwLength = 512, dwType = REG_SZ; |
| 4931 | | TCHAR szBuffer[512]; |
| 4932 | | HKEY hKey; |
| 4933 | | |
| 4934 | | /* Get the Key */ |
| 4935 | | RegOpenKey(HKEY_CURRENT_USER, TEXT("Control Panel\\desktop\\WindowMetrics"), &hKey); |
| 4936 | | /* Save the last size */ |
| 4937 | | RegQueryValueEx(hKey, TEXT("Shell Icon Size"), NULL, &dwType, (LPBYTE)szBuffer, &dwLength); |
| 4938 | | dwSize = _ttol(szBuffer); |
| 4939 | | if (dwSize < 32) |
| 4940 | | dwSize = 32; |
| 4941 | | |
| 4942 | | if (dwSize > 48) |
| 4943 | | dwSize = 48; |
| 4944 | | |
| 4945 | | /* Clean up */ |
| 4946 | | RegCloseKey(hKey); |
| 4947 | | return dwSize; |
| 4948 | | } |
| 4949 | | |
| 4950 | | static DWORD GetShellSmallIconSize(void) |
| 4951 | | { |
| 4952 | | DWORD dwSize = ICONMAP_WIDTH; |
| 4953 | | |
| 4954 | | if (dwSize < 48) |
| 4955 | | { |
| 4956 | | if (dwSize < 32) |
| 4957 | | dwSize = 16; |
| 4958 | | else |
| 4959 | | dwSize = 32; |
| 4960 | | } |
| 4961 | | else |
| 4962 | | { |
| 4963 | | dwSize = 48; |
| 4964 | | } |
| 4965 | | return dwSize; |
| 4966 | | } |
| 4967 | | |
| 4968 | | // create iconlist for Listview control |
| 4969 | | static void CreateIcons(void) |
| 4970 | | { |
| 4971 | | DWORD dwLargeIconSize = GetShellLargeIconSize(); |
| 4972 | | HICON hIcon; |
| 4973 | | int icon_count; |
| 4974 | | DWORD dwStyle; |
| 4975 | | int i; |
| 4976 | | |
| 4977 | | icon_count = 0; |
| 4978 | | while(g_iconData[icon_count].icon_name) |
| 4979 | | icon_count++; |
| 4980 | | |
| 4981 | | // the current window style affects the sizing of the rows when changing |
| 4982 | | // between list views, so put it in small icon mode temporarily while we associate |
| 4983 | | // our image list |
| 4984 | | // |
| 4985 | | // using large icon mode instead kills the horizontal scrollbar when doing |
| 4986 | | // full refresh, which seems odd (it should recreate the scrollbar when |
| 4987 | | // set back to report mode, for example, but it doesn't). |
| 4988 | | |
| 4989 | | dwStyle = GetWindowLong(hwndList,GWL_STYLE); |
| 4990 | | SetWindowLong(hwndList,GWL_STYLE,(dwStyle & ~LVS_TYPEMASK) | LVS_ICON); |
| 4991 | | |
| 4992 | | hSmall = ImageList_Create(GetShellSmallIconSize(),GetShellSmallIconSize(), |
| 4993 | | ILC_COLORDDB | ILC_MASK, icon_count, 500); |
| 4994 | | hLarge = ImageList_Create(dwLargeIconSize, dwLargeIconSize, |
| 4995 | | ILC_COLORDDB | ILC_MASK, icon_count, 500); |
| 4996 | | |
| 4997 | | ReloadIcons(); |
| 4998 | | |
| 4999 | | // Associate the image lists with the list view control. |
| 5000 | | (void)ListView_SetImageList(hwndList, hSmall, LVSIL_SMALL); |
| 5001 | | (void)ListView_SetImageList(hwndList, hLarge, LVSIL_NORMAL); |
| 5002 | | |
| 5003 | | // restore our view |
| 5004 | | SetWindowLong(hwndList,GWL_STYLE,dwStyle); |
| 5005 | | |
| 5006 | | #ifdef MESS |
| 5007 | | CreateMessIcons(); |
| 5008 | | #endif |
| 5009 | | |
| 5010 | | // Now set up header specific stuff |
| 5011 | | hHeaderImages = ImageList_Create(8,8,ILC_COLORDDB | ILC_MASK,2,2); |
| 5012 | | hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_HEADER_UP)); |
| 5013 | | ImageList_AddIcon(hHeaderImages,hIcon); |
| 5014 | | hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_HEADER_DOWN)); |
| 5015 | | ImageList_AddIcon(hHeaderImages,hIcon); |
| 5016 | | |
| 5017 | | for (i = 0; i < sizeof(s_nPickers) / sizeof(s_nPickers[0]); i++) |
| 5018 | | Picker_SetHeaderImageList(GetDlgItem(hMain, s_nPickers[i]), hHeaderImages); |
| 5019 | | } |
| 5020 | | |
| 5021 | | |
| 5022 | | |
| 5023 | | static int GamePicker_Compare(HWND hwndPicker, int index1, int index2, int sort_subitem) |
| 5024 | | { |
| 5025 | | int value; |
| 5026 | | const char *name1 = NULL; |
| 5027 | | const char *name2 = NULL; |
| 5028 | | int nTemp1, nTemp2; |
| 5029 | | |
| 5030 | | #ifdef DEBUG |
| 5031 | | if (strcmp(drivers[index1]->name,"1941") == 0 && strcmp(drivers[index2]->name,"1942") == 0) |
| 5032 | | { |
| 5033 | | dprintf("comparing 1941, 1942"); |
| 5034 | | } |
| 5035 | | |
| 5036 | | if (strcmp(drivers[index1]->name,"1942") == 0 && strcmp(drivers[index2]->name,"1941") == 0) |
| 5037 | | { |
| 5038 | | dprintf("comparing 1942, 1941"); |
| 5039 | | } |
| 5040 | | #endif |
| 5041 | | |
| 5042 | | switch (sort_subitem) |
| 5043 | | { |
| 5044 | | case COLUMN_GAMES: |
| 5045 | | value = mame_stricmp(ModifyThe(drivers[index1]->description), |
| 5046 | | ModifyThe(drivers[index2]->description)); |
| 5047 | | break; |
| 5048 | | |
| 5049 | | case COLUMN_ROMS: |
| 5050 | | nTemp1 = GetRomAuditResults(index1); |
| 5051 | | nTemp2 = GetRomAuditResults(index2); |
| 5052 | | |
| 5053 | | if (IsAuditResultKnown(nTemp1) == FALSE && IsAuditResultKnown(nTemp2) == FALSE) |
| 5054 | | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5055 | | |
| 5056 | | if (IsAuditResultKnown(nTemp1) == FALSE) |
| 5057 | | { |
| 5058 | | value = 1; |
| 5059 | | break; |
| 5060 | | } |
| 5061 | | |
| 5062 | | if (IsAuditResultKnown(nTemp2) == FALSE) |
| 5063 | | { |
| 5064 | | value = -1; |
| 5065 | | break; |
| 5066 | | } |
| 5067 | | |
| 5068 | | // ok, both are known |
| 5069 | | |
| 5070 | | if (IsAuditResultYes(nTemp1) && IsAuditResultYes(nTemp2)) |
| 5071 | | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5072 | | |
| 5073 | | if (IsAuditResultNo(nTemp1) && IsAuditResultNo(nTemp2)) |
| 5074 | | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5075 | | |
| 5076 | | if (IsAuditResultYes(nTemp1) && IsAuditResultNo(nTemp2)) |
| 5077 | | value = -1; |
| 5078 | | else |
| 5079 | | value = 1; |
| 5080 | | break; |
| 5081 | | |
| 5082 | | case COLUMN_SAMPLES: |
| 5083 | | nTemp1 = -1; |
| 5084 | | if (DriverUsesSamples(index1)) |
| 5085 | | { |
| 5086 | | int audit_result = GetSampleAuditResults(index1); |
| 5087 | | if (IsAuditResultKnown(audit_result)) |
| 5088 | | { |
| 5089 | | if (IsAuditResultYes(audit_result)) |
| 5090 | | nTemp1 = 1; |
| 5091 | | else |
| 5092 | | nTemp1 = 0; |
| 5093 | | } |
| 5094 | | else |
| 5095 | | nTemp1 = 2; |
| 5096 | | } |
| 5097 | | |
| 5098 | | nTemp2 = -1; |
| 5099 | | if (DriverUsesSamples(index2)) |
| 5100 | | { |
| 5101 | | int audit_result = GetSampleAuditResults(index1); |
| 5102 | | if (IsAuditResultKnown(audit_result)) |
| 5103 | | { |
| 5104 | | if (IsAuditResultYes(audit_result)) |
| 5105 | | nTemp2 = 1; |
| 5106 | | else |
| 5107 | | nTemp2 = 0; |
| 5108 | | } |
| 5109 | | else |
| 5110 | | nTemp2 = 2; |
| 5111 | | } |
| 5112 | | |
| 5113 | | if (nTemp1 == nTemp2) |
| 5114 | | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5115 | | |
| 5116 | | value = nTemp2 - nTemp1; |
| 5117 | | break; |
| 5118 | | |
| 5119 | | case COLUMN_DIRECTORY: |
| 5120 | | value = mame_stricmp(drivers[index1]->name, drivers[index2]->name); |
| 5121 | | break; |
| 5122 | | |
| 5123 | | case COLUMN_SRCDRIVERS: |
| 5124 | | if (mame_stricmp(drivers[index1]->source_file+12, drivers[index2]->source_file+12) == 0) |
| 5125 | | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5126 | | |
| 5127 | | value = mame_stricmp(drivers[index1]->source_file+12, drivers[index2]->source_file+12); |
| 5128 | | break; |
| 5129 | | case COLUMN_PLAYTIME: |
| 5130 | | value = GetPlayTime(index1) - GetPlayTime(index2); |
| 5131 | | if (value == 0) |
| 5132 | | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5133 | | |
| 5134 | | break; |
| 5135 | | |
| 5136 | | case COLUMN_TYPE: |
| 5137 | | { |
| 5138 | | machine_config drv1,drv2; |
| 5139 | | expand_machine_driver(drivers[index1]->drv,&drv1); |
| 5140 | | expand_machine_driver(drivers[index2]->drv,&drv2); |
| 5141 | | |
| 5142 | | if ((drv1.video_attributes & VIDEO_TYPE_VECTOR) == |
| 5143 | | (drv2.video_attributes & VIDEO_TYPE_VECTOR)) |
| 5144 | | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5145 | | |
| 5146 | | value = (drv1.video_attributes & VIDEO_TYPE_VECTOR) - |
| 5147 | | (drv2.video_attributes & VIDEO_TYPE_VECTOR); |
| 5148 | | break; |
| 5149 | | } |
| 5150 | | case COLUMN_TRACKBALL: |
| 5151 | | if (DriverUsesTrackball(index1) == DriverUsesTrackball(index2)) |
| 5152 | | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5153 | | |
| 5154 | | value = DriverUsesTrackball(index1) - DriverUsesTrackball(index2); |
| 5155 | | break; |
| 5156 | | |
| 5157 | | case COLUMN_PLAYED: |
| 5158 | | value = GetPlayCount(index1) - GetPlayCount(index2); |
| 5159 | | if (value == 0) |
| 5160 | | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5161 | | |
| 5162 | | break; |
| 5163 | | |
| 5164 | | case COLUMN_MANUFACTURER: |
| 5165 | | if (mame_stricmp(drivers[index1]->manufacturer, drivers[index2]->manufacturer) == 0) |
| 5166 | | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5167 | | |
| 5168 | | value = mame_stricmp(drivers[index1]->manufacturer, drivers[index2]->manufacturer); |
| 5169 | | break; |
| 5170 | | |
| 5171 | | case COLUMN_YEAR: |
| 5172 | | if (mame_stricmp(drivers[index1]->year, drivers[index2]->year) == 0) |
| 5173 | | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5174 | | |
| 5175 | | value = mame_stricmp(drivers[index1]->year, drivers[index2]->year); |
| 5176 | | break; |
| 5177 | | |
| 5178 | | case COLUMN_CLONE: |
| 5179 | | name1 = GetCloneParentName(index1); |
| 5180 | | name2 = GetCloneParentName(index2); |
| 5181 | | |
| 5182 | | if (*name1 == '\0') |
| 5183 | | name1 = NULL; |
| 5184 | | if (*name2 == '\0') |
| 5185 | | name2 = NULL; |
| 5186 | | |
| 5187 | | if (name1 == name2) |
| 5188 | | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5189 | | |
| 5190 | | if (name2 == NULL) |
| 5191 | | value = -1; |
| 5192 | | else if (name1 == NULL) |
| 5193 | | value = 1; |
| 5194 | | else |
| 5195 | | value = mame_stricmp(name1, name2); |
| 5196 | | break; |
| 5197 | | |
| 5198 | | default : |
| 5199 | | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5200 | | } |
| 5201 | | |
| 5202 | | #ifdef DEBUG |
| 5203 | | if ((strcmp(drivers[index1]->name,"1941") == 0 && strcmp(drivers[index2]->name,"1942") == 0) || |
| 5204 | | (strcmp(drivers[index1]->name,"1942") == 0 && strcmp(drivers[index2]->name,"1941") == 0)) |
| 5205 | | dprintf("result: %i",value); |
| 5206 | | #endif |
| 5207 | | |
| 5208 | | return value; |
| 5209 | | } |
| 5210 | | |
| 5211 | | int GetSelectedPick() |
| 5212 | | { |
| 5213 | | /* returns index of listview selected item */ |
| 5214 | | /* This will return -1 if not found */ |
| 5215 | | return ListView_GetNextItem(hwndList, -1, LVIS_SELECTED | LVIS_FOCUSED); |
| 5216 | | } |
| 5217 | | |
| 5218 | | static HICON GetSelectedPickItemIcon() |
| 5219 | | { |
| 5220 | | LV_ITEM lvi; |
| 5221 | | |
| 5222 | | lvi.iItem = GetSelectedPick(); |
| 5223 | | lvi.iSubItem = 0; |
| 5224 | | lvi.mask = LVIF_IMAGE; |
| 5225 | | ListView_GetItem(hwndList, &lvi); |
| 5226 | | |
| 5227 | | return ImageList_GetIcon(hLarge, lvi.iImage, ILD_TRANSPARENT); |
| 5228 | | } |
| 5229 | | |
| 5230 | | static void SetRandomPickItem() |
| 5231 | | { |
| 5232 | | int nListCount; |
| 5233 | | |
| 5234 | | nListCount = ListView_GetItemCount(hwndList); |
| 5235 | | |
| 5236 | | if (nListCount > 0) |
| 5237 | | { |
| 5238 | | Picker_SetSelectedPick(hwndList, rand() % nListCount); |
| 5239 | | } |
| 5240 | | } |
| 5241 | | |
| 5242 | | BOOL CommonFileDialog(common_file_dialog_proc cfd, char *filename, int filetype) |
| 5243 | | { |
| 5244 | | BOOL success; |
| 5245 | | OPENFILENAME of; |
| 5246 | | TCHAR* t_filename; |
| 5247 | | TCHAR* t_statedir = 0; |
| 5248 | | TCHAR* t_artdir = 0; |
| 5249 | | TCHAR t_filename_buffer[MAX_PATH] = {0, }; |
| 5250 | | char *utf8_filename; |
| 5251 | | |
| 5252 | | // convert the filename to UTF-8 and copy into buffer |
| 5253 | | t_filename = tstring_from_utf8(filename); |
| 5254 | | if (t_filename != NULL) |
| 5255 | | { |
| 5256 | | _sntprintf(t_filename_buffer, ARRAY_LENGTH(t_filename_buffer), TEXT("%s"), t_filename); |
| 5257 | | free(t_filename); |
| 5258 | | } |
| 5259 | | |
| 5260 | | of.lStructSize = sizeof(of); |
| 5261 | | of.hwndOwner = hMain; |
| 5262 | | of.hInstance = NULL; |
| 5263 | | switch (filetype) |
| 5264 | | { |
| 5265 | | case FILETYPE_INPUT_FILES : |
| 5266 | | of.lpstrFilter = TEXT(MAMENAME " input files (*.inp,*.zip)\0*.inp;*.zip\0All files (*.*)\0*.*\0"); |
| 5267 | | break; |
| 5268 | | case FILETYPE_SAVESTATE_FILES : |
| 5269 | | of.lpstrFilter = TEXT(MAMENAME " savestate files (*.sta)\0*.sta;\0All files (*.*)\0*.*\0"); |
| 5270 | | break; |
| 5271 | | case FILETYPE_WAVE_FILES : |
| 5272 | | of.lpstrFilter = TEXT("sounds (*.wav)\0*.wav;\0All files (*.*)\0*.*\0"); |
| 5273 | | break; |
| 5274 | | case FILETYPE_MNG_FILES : |
| 5275 | | of.lpstrFilter = TEXT("videos (*.mng)\0*.mng;\0All files (*.*)\0*.*\0"); |
| 5276 | | break; |
| 5277 | | case FILETYPE_EFFECT_FILES : |
| 5278 | | of.lpstrFilter = TEXT("effects (*.png)\0*.png;\0All files (*.*)\0*.*\0"); |
| 5279 | | break; |
| 5280 | | } |
| 5281 | | of.lpstrCustomFilter = NULL; |
| 5282 | | of.nMaxCustFilter = 0; |
| 5283 | | of.nFilterIndex = 1; |
| 5284 | | of.lpstrFile = t_filename_buffer; |
| 5285 | | of.nMaxFile = ARRAY_LENGTH(t_filename_buffer); |
| 5286 | | of.lpstrFileTitle = NULL; |
| 5287 | | of.nMaxFileTitle = 0; |
| 5288 | | if (filetype == FILETYPE_SAVESTATE_FILES) |
| 5289 | | { |
| 5290 | | t_statedir = tstring_from_utf8(GetStateDir()); |
| 5291 | | if( !t_statedir ) |
| 5292 | | return FALSE; |
| 5293 | | |
| 5294 | | of.lpstrInitialDir = t_statedir; |
| 5295 | | } |
| 5296 | | else |
| 5297 | | { |
| 5298 | | if (filetype == FILETYPE_EFFECT_FILES) |
| 5299 | | { |
| 5300 | | t_artdir = tstring_from_utf8(GetArtDir()); |
| 5301 | | if( !t_artdir ) |
| 5302 | | return FALSE; |
| 5303 | | |
| 5304 | | of.lpstrInitialDir = t_artdir; |
| 5305 | | } |
| 5306 | | else |
| 5307 | | of.lpstrInitialDir = last_directory; |
| 5308 | | } |
| 5309 | | of.lpstrTitle = NULL; |
| 5310 | | of.Flags = OFN_EXPLORER | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY; |
| 5311 | | of.nFileOffset = 0; |
| 5312 | | of.nFileExtension = 0; |
| 5313 | | switch (filetype) |
| 5314 | | { |
| 5315 | | case FILETYPE_INPUT_FILES : |
| 5316 | | of.lpstrDefExt = TEXT("inp"); |
| 5317 | | break; |
| 5318 | | case FILETYPE_SAVESTATE_FILES : |
| 5319 | | of.lpstrDefExt = TEXT("sta"); |
| 5320 | | break; |
| 5321 | | case FILETYPE_WAVE_FILES : |
| 5322 | | of.lpstrDefExt = TEXT("wav"); |
| 5323 | | break; |
| 5324 | | case FILETYPE_MNG_FILES : |
| 5325 | | of.lpstrDefExt = TEXT("mng"); |
| 5326 | | break; |
| 5327 | | case FILETYPE_EFFECT_FILES : |
| 5328 | | of.lpstrDefExt = TEXT("png"); |
| 5329 | | break; |
| 5330 | | } |
| 5331 | | of.lCustData = 0; |
| 5332 | | of.lpfnHook = NULL; |
| 5333 | | of.lpTemplateName = NULL; |
| 5334 | | |
| 5335 | | success = cfd(&of); |
| 5336 | | if (success) |
| 5337 | | { |
| 5338 | | //dprintf("got filename %s nFileExtension %u\n",filename,of.nFileExtension); |
| 5339 | | /*GetDirectory(filename,last_directory,sizeof(last_directory));*/ |
| 5340 | | } |
| 5341 | | |
| 5342 | | if( t_artdir ) |
| 5343 | | free(t_artdir); |
| 5344 | | if( t_statedir ) |
| 5345 | | free(t_statedir); |
| 5346 | | |
| 5347 | | utf8_filename = utf8_from_tstring(t_filename_buffer); |
| 5348 | | if (utf8_filename != NULL) |
| 5349 | | { |
| 5350 | | snprintf(filename, MAX_PATH, "%s", utf8_filename); |
| 5351 | | } |
| 5352 | | |
| 5353 | | return success; |
| 5354 | | } |
| 5355 | | |
| 5356 | | static BOOL SelectLanguageFile(HWND hWnd, TCHAR* filename) |
| 5357 | | { |
| 5358 | | OPENFILENAME of; |
| 5359 | | |
| 5360 | | of.lStructSize = sizeof(of); |
| 5361 | | of.hwndOwner = hWnd; |
| 5362 | | of.hInstance = NULL; |
| 5363 | | of.lpstrFilter = TEXT(MAMENAME " Language files (*.lng)\0*.lng\0"); |
| 5364 | | of.lpstrCustomFilter = NULL; |
| 5365 | | of.nMaxCustFilter = 0; |
| 5366 | | of.nFilterIndex = 1; |
| 5367 | | of.lpstrFile = filename; |
| 5368 | | of.nMaxFile = MAX_PATH; |
| 5369 | | of.lpstrFileTitle = NULL; |
| 5370 | | of.nMaxFileTitle = 0; |
| 5371 | | of.lpstrInitialDir = NULL; |
| 5372 | | of.lpstrTitle = NULL; |
| 5373 | | of.Flags = OFN_EXPLORER | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST; |
| 5374 | | of.nFileOffset = 0; |
| 5375 | | of.nFileExtension = 0; |
| 5376 | | of.lpstrDefExt = TEXT("lng"); |
| 5377 | | of.lCustData = 0; |
| 5378 | | of.lpfnHook = NULL; |
| 5379 | | of.lpTemplateName = NULL; |
| 5380 | | |
| 5381 | | return GetOpenFileName(&of); |
| 5382 | | } |
| 5383 | | |
| 5384 | | static INT_PTR CALLBACK LanguageDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) |
| 5385 | | { |
| 5386 | | TCHAR pLangFile[MAX_PATH]; |
| 5387 | | DWORD dwHelpIDs[] = { IDC_LANGUAGECHECK, HIDC_LANGUAGECHECK, |
| 5388 | | IDC_LANGUAGEEDIT, HIDC_LANGUAGEEDIT, |
| 5389 | | 0, 0}; |
| 5390 | | char* utf8_LangFile; |
| 5391 | | |
| 5392 | | switch (Msg) |
| 5393 | | { |
| 5394 | | case WM_INITDIALOG: |
| 5395 | | { |
| 5396 | | const char* pLang = GetLanguage(); |
| 5397 | | if (pLang == NULL || *pLang == '\0') |
| 5398 | | { |
| 5399 | | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_LANGUAGEEDIT), ""); |
| 5400 | | Button_SetCheck(GetDlgItem(hDlg, IDC_LANGUAGECHECK), FALSE); |
| 5401 | | EnableWindow(GetDlgItem(hDlg, IDC_LANGUAGEEDIT), FALSE); |
| 5402 | | EnableWindow(GetDlgItem(hDlg, IDC_LANGUAGEBROWSE), FALSE); |
| 5403 | | } |
| 5404 | | else |
| 5405 | | { |
| 5406 | | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_LANGUAGEEDIT), pLang); |
| 5407 | | Button_SetCheck(GetDlgItem(hDlg, IDC_LANGUAGECHECK), TRUE); |
| 5408 | | EnableWindow(GetDlgItem(hDlg, IDC_LANGUAGEEDIT), TRUE); |
| 5409 | | EnableWindow(GetDlgItem(hDlg, IDC_LANGUAGEBROWSE), TRUE); |
| 5410 | | } |
| 5411 | | |
| 5412 | | return TRUE; |
| 5413 | | } |
| 5414 | | |
| 5415 | | case WM_HELP: |
| 5416 | | HelpFunction(((LPHELPINFO)lParam)->hItemHandle, MAME32CONTEXTHELP, HH_TP_HELP_WM_HELP, (DWORD)dwHelpIDs); |
| 5417 | | break; |
| 5418 | | |
| 5419 | | case WM_CONTEXTMENU: |
| 5420 | | HelpFunction((HWND)wParam, MAME32CONTEXTHELP, HH_TP_HELP_CONTEXTMENU, (DWORD)dwHelpIDs); |
| 5421 | | break; |
| 5422 | | |
| 5423 | | case WM_COMMAND: |
| 5424 | | switch (GET_WM_COMMAND_ID(wParam, lParam)) |
| 5425 | | { |
| 5426 | | case IDOK: |
| 5427 | | Edit_GetText(GetDlgItem(hDlg, IDC_LANGUAGEEDIT), pLangFile, MAX_PATH); |
| 5428 | | utf8_LangFile = utf8_from_tstring(pLangFile); |
| 5429 | | if( !utf8_LangFile ) |
| 5430 | | return FALSE; |
| 5431 | | SetLanguage(utf8_LangFile); |
| 5432 | | free(utf8_LangFile); |
| 5433 | | |
| 5434 | | case IDCANCEL: |
| 5435 | | EndDialog(hDlg, 0); |
| 5436 | | return TRUE; |
| 5437 | | |
| 5438 | | case IDC_LANGUAGECHECK: |
| 5439 | | { |
| 5440 | | BOOL bCheck = Button_GetCheck(GetDlgItem(hDlg, IDC_LANGUAGECHECK)); |
| 5441 | | EnableWindow(GetDlgItem(hDlg, IDC_LANGUAGEEDIT), bCheck); |
| 5442 | | EnableWindow(GetDlgItem(hDlg, IDC_LANGUAGEBROWSE), bCheck); |
| 5443 | | if (bCheck == FALSE) |
| 5444 | | Edit_SetText(GetDlgItem(hDlg, IDC_LANGUAGEEDIT), TEXT("")); |
| 5445 | | return TRUE; |
| 5446 | | } |
| 5447 | | |
| 5448 | | case IDC_LANGUAGEBROWSE: |
| 5449 | | Edit_GetText(GetDlgItem(hDlg, IDC_LANGUAGEEDIT), pLangFile, MAX_PATH); |
| 5450 | | if (SelectLanguageFile(hDlg, pLangFile) == TRUE) |
| 5451 | | Edit_SetText(GetDlgItem(hDlg, IDC_LANGUAGEEDIT), pLangFile); |
| 5452 | | break; |
| 5453 | | } |
| 5454 | | break; |
| 5455 | | } |
| 5456 | | return 0; |
| 5457 | | } |
| 5458 | | |
| 5459 | | void SetStatusBarText(int part_index, const char *message) |
| 5460 | | { |
| 5461 | | TCHAR* t_message = tstring_from_utf8(message); |
| 5462 | | if( !t_message ) |
| 5463 | | return; |
| 5464 | | SendMessage(hStatusBar, SB_SETTEXT, (WPARAM) part_index, (LPARAM)(LPCTSTR) win_tstring_strdup(t_message)); |
| 5465 | | free(t_message); |
| 5466 | | } |
| 5467 | | |
| 5468 | | void SetStatusBarTextF(int part_index, const char *fmt, ...) |
| 5469 | | { |
| 5470 | | char buf[256]; |
| 5471 | | va_list va; |
| 5472 | | |
| 5473 | | va_start(va, fmt); |
| 5474 | | vsprintf(buf, fmt, va); |
| 5475 | | va_end(va); |
| 5476 | | |
| 5477 | | SetStatusBarText(part_index, buf); |
| 5478 | | } |
| 5479 | | |
| 5480 | | static void CLIB_DECL MameMessageBox(const char *fmt, ...) |
| 5481 | | { |
| 5482 | | char buf[2048]; |
| 5483 | | va_list va; |
| 5484 | | |
| 5485 | | va_start(va, fmt); |
| 5486 | | vsprintf(buf, fmt, va); |
| 5487 | | win_message_box_utf8(GetMainWindow(), buf, MAME32NAME, MB_OK | MB_ICONERROR); |
| 5488 | | va_end(va); |
| 5489 | | } |
| 5490 | | |
| 5491 | | static void MamePlayBackGame() |
| 5492 | | { |
| 5493 | | int nGame; |
| 5494 | | char filename[MAX_PATH]; |
| 5495 | | |
| 5496 | | *filename = 0; |
| 5497 | | |
| 5498 | | nGame = Picker_GetSelectedItem(hwndList); |
| 5499 | | if (nGame != -1) |
| 5500 | | strcpy(filename, drivers[nGame]->name); |
| 5501 | | |
| 5502 | | if (CommonFileDialog(GetOpenFileName, filename, FILETYPE_INPUT_FILES)) |
| 5503 | | { |
| 5504 | | file_error fileerr; |
| 5505 | | mame_file* pPlayBack; |
| 5506 | | char drive[_MAX_DRIVE]; |
| 5507 | | char dir[_MAX_DIR]; |
| 5508 | | char bare_fname[_MAX_FNAME]; |
| 5509 | | char ext[_MAX_EXT]; |
| 5510 | | |
| 5511 | | char path[MAX_PATH]; |
| 5512 | | char fname[MAX_PATH]; |
| 5513 | | play_options playopts; |
| 5514 | | |
| 5515 | | _splitpath(filename, drive, dir, bare_fname, ext); |
| 5516 | | |
| 5517 | | sprintf(path,"%s%s",drive,dir); |
| 5518 | | sprintf(fname,"%s%s",bare_fname,ext); |
| 5519 | | if (path[strlen(path)-1] == '\\') |
| 5520 | | path[strlen(path)-1] = 0; // take off trailing back slash |
| 5521 | | |
| 5522 | | fileerr = mame_fopen_options(Mame32Global(), SEARCHPATH_INPUTLOG, fname, OPEN_FLAG_READ, &pPlayBack); |
| 5523 | | if (fileerr != FILERR_NONE) |
| 5524 | | { |
| 5525 | | MameMessageBox("Could not open '%s' as a valid input file.", filename); |
| 5526 | | return; |
| 5527 | | } |
| 5528 | | |
| 5529 | | // check for game name embedded in .inp header |
| 5530 | | if (pPlayBack) |
| 5531 | | { |
| 5532 | | inp_header input_header; |
| 5533 | | |
| 5534 | | // read playback header |
| 5535 | | mame_fread(pPlayBack, &input_header, sizeof(inp_header)); |
| 5536 | | |
| 5537 | | if (!isalnum(input_header.name[0])) // If first byte is not alpha-numeric |
| 5538 | | mame_fseek(pPlayBack, 0, SEEK_SET); // old .inp file - no header |
| 5539 | | else |
| 5540 | | { |
| 5541 | | int i; |
| 5542 | | for (i = 0; drivers[i] != 0; i++) // find game and play it |
| 5543 | | { |
| 5544 | | if (strcmp(drivers[i]->name, input_header.name) == 0) |
| 5545 | | { |
| 5546 | | nGame = i; |
| 5547 | | break; |
| 5548 | | } |
| 5549 | | } |
| 5550 | | } |
| 5551 | | } |
| 5552 | | mame_fclose(pPlayBack); |
| 5553 | | |
| 5554 | | memset(&playopts, 0, sizeof(playopts)); |
| 5555 | | playopts.playback = fname; |
| 5556 | | MamePlayGameWithOptions(nGame, &playopts); |
| 5557 | | } |
| 5558 | | } |
| 5559 | | |
| 5560 | | static void MameLoadState() |
| 5561 | | { |
| 5562 | | int nGame; |
| 5563 | | char filename[MAX_PATH]; |
| 5564 | | char selected_filename[MAX_PATH]; |
| 5565 | | play_options playopts; |
| 5566 | | |
| 5567 | | *filename = 0; |
| 5568 | | |
| 5569 | | nGame = Picker_GetSelectedItem(hwndList); |
| 5570 | | if (nGame != -1) |
| 5571 | | { |
| 5572 | | strcpy(filename, drivers[nGame]->name); |
| 5573 | | strcpy(selected_filename, drivers[nGame]->name); |
| 5574 | | } |
| 5575 | | if (CommonFileDialog(GetOpenFileName, filename, FILETYPE_SAVESTATE_FILES)) |
| 5576 | | { |
| 5577 | | mame_file* pSaveState; |
| 5578 | | char drive[_MAX_DRIVE]; |
| 5579 | | char dir[_MAX_DIR]; |
| 5580 | | char ext[_MAX_EXT]; |
| 5581 | | |
| 5582 | | char path[MAX_PATH]; |
| 5583 | | char fname[MAX_PATH]; |
| 5584 | | char bare_fname[_MAX_FNAME]; |
| 5585 | | char *state_fname; |
| 5586 | | int rc; |
| 5587 | | |
| 5588 | | _splitpath(filename, drive, dir, bare_fname, ext); |
| 5589 | | |
| 5590 | | // parse path |
| 5591 | | sprintf(path,"%s%s",drive,dir); |
| 5592 | | sprintf(fname,"%s%s",bare_fname,ext); |
| 5593 | | if (path[strlen(path)-1] == '\\') |
| 5594 | | path[strlen(path)-1] = 0; // take off trailing back slash |
| 5595 | | |
| 5596 | | #ifdef MESS |
| 5597 | | { |
| 5598 | | state_fname = filename; |
| 5599 | | } |
| 5600 | | #else // !MESS |
| 5601 | | { |
| 5602 | | char *cPos=0; |
| 5603 | | int iPos=0; |
| 5604 | | char romname[MAX_PATH]; |
| 5605 | | |
| 5606 | | cPos = strchr(bare_fname, '-' ); |
| 5607 | | iPos = cPos ? cPos - bare_fname : strlen(bare_fname); |
| 5608 | | strncpy(romname, bare_fname, iPos ); |
| 5609 | | romname[iPos] = '\0'; |
| 5610 | | if( strcmp(selected_filename,romname) != 0 ) |
| 5611 | | { |
| 5612 | | MameMessageBox("'%s' is not a valid savestate file for game '%s'.", filename, selected_filename); |
| 5613 | | return; |
| 5614 | | } |
| 5615 | | state_fname = fname; |
| 5616 | | } |
| 5617 | | #endif // MESS |
| 5618 | | |
| 5619 | | mame_fopen_options(Mame32Global(), SEARCHPATH_STATE, state_fname, OPEN_FLAG_READ, &pSaveState); |
| 5620 | | if (pSaveState == NULL) |
| 5621 | | { |
| 5622 | | MameMessageBox("Could not open '%s' as a valid savestate file.", filename); |
| 5623 | | return; |
| 5624 | | } |
| 5625 | | |
| 5626 | | // call the MAME core function to check the save state file |
| 5627 | | rc = state_save_check_file(pSaveState, selected_filename, TRUE, MameMessageBox); |
| 5628 | | mame_fclose(pSaveState); |
| 5629 | | if (rc) |
| 5630 | | return; |
| 5631 | | |
| 5632 | | memset(&playopts, 0, sizeof(playopts)); |
| 5633 | | #ifdef MESS |
| 5634 | | playopts.state = state_fname; |
| 5635 | | #else |
| 5636 | | { |
| 5637 | | char *cPos; |
| 5638 | | cPos = strrchr(bare_fname, '-' ); |
| 5639 | | cPos = cPos+1; |
| 5640 | | if( strlen(cPos) >0) |
| 5641 | | { |
| 5642 | | playopts.state = cPos; |
| 5643 | | } |
| 5644 | | } |
| 5645 | | #endif |
| 5646 | | |
| 5647 | | MamePlayGameWithOptions(nGame, &playopts); |
| 5648 | | } |
| 5649 | | } |
| 5650 | | |
| 5651 | | static void MamePlayRecordGame() |
| 5652 | | { |
| 5653 | | int nGame; |
| 5654 | | char filename[MAX_PATH]; |
| 5655 | | *filename = 0; |
| 5656 | | |
| 5657 | | nGame = Picker_GetSelectedItem(hwndList); |
| 5658 | | strcpy(filename, drivers[nGame]->name); |
| 5659 | | |
| 5660 | | if (CommonFileDialog(GetSaveFileName, filename, FILETYPE_INPUT_FILES)) |
| 5661 | | { |
| 5662 | | char drive[_MAX_DRIVE]; |
| 5663 | | char dir[_MAX_DIR]; |
| 5664 | | char fname[_MAX_FNAME]; |
| 5665 | | char ext[_MAX_EXT]; |
| 5666 | | char path[MAX_PATH]; |
| 5667 | | play_options playopts; |
| 5668 | | |
| 5669 | | _splitpath(filename, drive, dir, fname, ext); |
| 5670 | | |
| 5671 | | sprintf(path,"%s%s",drive,dir); |
| 5672 | | if (path[strlen(path)-1] == '\\') |
| 5673 | | path[strlen(path)-1] = 0; // take off trailing back slash |
| 5674 | | |
| 5675 | | memset(&playopts, 0, sizeof(playopts)); |
| 5676 | | playopts.record = fname; |
| 5677 | | MamePlayGameWithOptions(nGame, &playopts); |
| 5678 | | } |
| 5679 | | } |
| 5680 | | |
| 5681 | | void MamePlayGame(void) |
| 5682 | | { |
| 5683 | | int nGame; |
| 5684 | | play_options playopts; |
| 5685 | | |
| 5686 | | nGame = Picker_GetSelectedItem(hwndList); |
| 5687 | | |
| 5688 | | memset(&playopts, 0, sizeof(playopts)); |
| 5689 | | MamePlayGameWithOptions(nGame, &playopts); |
| 5690 | | } |
| 5691 | | |
| 5692 | | static void MamePlayRecordWave() |
| 5693 | | { |
| 5694 | | int nGame; |
| 5695 | | char filename[MAX_PATH]; |
| 5696 | | play_options playopts; |
| 5697 | | |
| 5698 | | nGame = Picker_GetSelectedItem(hwndList); |
| 5699 | | strcpy(filename, drivers[nGame]->name); |
| 5700 | | |
| 5701 | | if (CommonFileDialog(GetSaveFileName, filename, FILETYPE_WAVE_FILES)) |
| 5702 | | { |
| 5703 | | memset(&playopts, 0, sizeof(playopts)); |
| 5704 | | playopts.wavwrite = filename; |
| 5705 | | MamePlayGameWithOptions(nGame, &playopts); |
| 5706 | | } |
| 5707 | | } |
| 5708 | | |
| 5709 | | static void MamePlayRecordMNG() |
| 5710 | | { |
| 5711 | | int nGame; |
| 5712 | | char filename[MAX_PATH] = { 0, }; |
| 5713 | | play_options playopts; |
| 5714 | | |
| 5715 | | nGame = Picker_GetSelectedItem(hwndList); |
| 5716 | | strcpy(filename, drivers[nGame]->name); |
| 5717 | | |
| 5718 | | if (CommonFileDialog(GetSaveFileName, filename, FILETYPE_MNG_FILES)) |
| 5719 | | { |
| 5720 | | memset(&playopts, 0, sizeof(playopts)); |
| 5721 | | playopts.mngwrite = filename; |
| 5722 | | MamePlayGameWithOptions(nGame, &playopts); |
| 5723 | | } |
| 5724 | | } |
| 5725 | | |
| 5726 | | static void MamePlayGameWithOptions(int nGame, const play_options *playopts) |
| 5727 | | { |
| 5728 | | DWORD dwExitCode; |
| 5729 | | |
| 5730 | | #ifdef MESS |
| 5731 | | if (!MessApproveImageList(hMain, nGame)) |
| 5732 | | return; |
| 5733 | | #endif |
| 5734 | | |
| 5735 | | if (g_pJoyGUI != NULL) |
| 5736 | | KillTimer(hMain, JOYGUI_TIMER); |
| 5737 | | if (GetCycleScreenshot() > 0) |
| 5738 | | KillTimer(hMain, SCREENSHOT_TIMER); |
| 5739 | | |
| 5740 | | in_emulation = TRUE; |
| 5741 | | |
| 5742 | | dwExitCode = RunMAME(nGame, playopts); |
| 5743 | | if (dwExitCode == 0) |
| 5744 | | { |
| 5745 | | IncrementPlayCount(nGame); |
| 5746 | | ListView_RedrawItems(hwndList, GetSelectedPick(), GetSelectedPick()); |
| 5747 | | } |
| 5748 | | else |
| 5749 | | { |
| 5750 | | ShowWindow(hMain, SW_SHOW); |
| 5751 | | } |
| 5752 | | |
| 5753 | | in_emulation = FALSE; |
| 5754 | | |
| 5755 | | // re-sort if sorting on # of times played |
| 5756 | | if (GetSortColumn() == COLUMN_PLAYED) |
| 5757 | | Picker_Sort(hwndList); |
| 5758 | | |
| 5759 | | UpdateStatusBar(); |
| 5760 | | |
| 5761 | | ShowWindow(hMain, SW_SHOW); |
| 5762 | | SetFocus(hwndList); |
| 5763 | | |
| 5764 | | if (g_pJoyGUI != NULL) |
| 5765 | | SetTimer(hMain, JOYGUI_TIMER, JOYGUI_MS, NULL); |
| 5766 | | if (GetCycleScreenshot() > 0) |
| 5767 | | SetTimer(hMain, SCREENSHOT_TIMER, GetCycleScreenshot()*1000, NULL); //scale to seconds |
| 5768 | | } |
| 5769 | | |
| 5770 | | /* Toggle ScreenShot ON/OFF */ |
| 5771 | | static void ToggleScreenShot(void) |
| 5772 | | { |
| 5773 | | BOOL showScreenShot = GetShowScreenShot(); |
| 5774 | | |
| 5775 | | SetShowScreenShot((showScreenShot) ? FALSE : TRUE); |
| 5776 | | UpdateScreenShot(); |
| 5777 | | |
| 5778 | | /* Redraw list view */ |
| 5779 | | if (hBackground != NULL && showScreenShot) |
| 5780 | | InvalidateRect(hwndList, NULL, FALSE); |
| 5781 | | } |
| 5782 | | |
| 5783 | | static void AdjustMetrics(void) |
| 5784 | | { |
| 5785 | | HDC hDC; |
| 5786 | | TEXTMETRIC tm; |
| 5787 | | int xtraX, xtraY; |
| 5788 | | AREA area; |
| 5789 | | int offX, offY; |
| 5790 | | int maxX, maxY; |
| 5791 | | COLORREF textColor; |
| 5792 | | TCHAR szClass[128]; |
| 5793 | | HWND hWnd; |
| 5794 | | |
| 5795 | | /* WM_SETTINGCHANGE also */ |
| 5796 | | xtraX = GetSystemMetrics(SM_CXFIXEDFRAME); /* Dialog frame width */ |
| 5797 | | xtraY = GetSystemMetrics(SM_CYFIXEDFRAME); /* Dialog frame height */ |
| 5798 | | xtraY += GetSystemMetrics(SM_CYMENUSIZE); /* Menu height */ |
| 5799 | | xtraY += GetSystemMetrics(SM_CYCAPTION); /* Caption Height */ |
| 5800 | | maxX = GetSystemMetrics(SM_CXSCREEN); /* Screen Width */ |
| 5801 | | maxY = GetSystemMetrics(SM_CYSCREEN); /* Screen Height */ |
| 5802 | | |
| 5803 | | hDC = GetDC(hMain); |
| 5804 | | GetTextMetrics (hDC, &tm); |
| 5805 | | |
| 5806 | | /* Convert MIN Width/Height from Dialog Box Units to pixels. */ |
| 5807 | | MIN_WIDTH = (int)((tm.tmAveCharWidth / 4.0) * DBU_MIN_WIDTH) + xtraX; |
| 5808 | | MIN_HEIGHT = (int)((tm.tmHeight / 8.0) * DBU_MIN_HEIGHT) + xtraY; |
| 5809 | | ReleaseDC(hMain, hDC); |
| 5810 | | |
| 5811 | | if ((textColor = GetListFontColor()) == RGB(255, 255, 255)) |
| 5812 | | textColor = RGB(240, 240, 240); |
| 5813 | | |
| 5814 | | hWnd = GetWindow(hMain, GW_CHILD); |
| 5815 | | while(hWnd) |
| 5816 | | { |
| 5817 | | if (GetClassName(hWnd, szClass, sizeof(szClass) / sizeof(szClass[0]))) |
| 5818 | | { |
| 5819 | | if (!_tcscmp(szClass, TEXT("SysListView32"))) |
| 5820 | | { |
| 5821 | | ListView_SetBkColor(hWnd, GetSysColor(COLOR_WINDOW)); |
| 5822 | | ListView_SetTextColor(hWnd, textColor); |
| 5823 | | } |
| 5824 | | else if (!_tcscmp(szClass, TEXT("SysTreeView32"))) |
| 5825 | | { |
| 5826 | | TreeView_SetBkColor(hTreeView, GetSysColor(COLOR_WINDOW)); |
| 5827 | | TreeView_SetTextColor(hTreeView, textColor); |
| 5828 | | } |
| 5829 | | } |
| 5830 | | hWnd = GetWindow(hWnd, GW_HWNDNEXT); |
| 5831 | | } |
| 5832 | | |
| 5833 | | GetWindowArea(&area); |
| 5834 | | |
| 5835 | | offX = area.x + area.width; |
| 5836 | | offY = area.y + area.height; |
| 5837 | | |
| 5838 | | if (offX > maxX) |
| 5839 | | { |
| 5840 | | offX = maxX; |
| 5841 | | area.x = (offX - area.width > 0) ? (offX - area.width) : 0; |
| 5842 | | } |
| 5843 | | if (offY > maxY) |
| 5844 | | { |
| 5845 | | offY = maxY; |
| 5846 | | area.y = (offY - area.height > 0) ? (offY - area.height) : 0; |
| 5847 | | } |
| 5848 | | |
| 5849 | | SetWindowArea(&area); |
| 5850 | | SetWindowPos(hMain, 0, area.x, area.y, area.width, area.height, SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE); |
| 5851 | | } |
| 5852 | | |
| 5853 | | |
| 5854 | | /* Adjust options - tune them to the currently selected game */ |
| 5855 | | static void EnablePlayOptions(int nIndex, core_options *o) |
| 5856 | | { |
| 5857 | | } |
| 5858 | | |
| 5859 | | int FindIconIndex(int nIconResource) |
| 5860 | | { |
| 5861 | | int i; |
| 5862 | | for(i = 0; g_iconData[i].icon_name; i++) |
| 5863 | | { |
| 5864 | | if (g_iconData[i].resource == nIconResource) |
| 5865 | | return i; |
| 5866 | | } |
| 5867 | | return -1; |
| 5868 | | } |
| 5869 | | |
| 5870 | | int FindIconIndexByName(const char *icon_name) |
| 5871 | | { |
| 5872 | | int i; |
| 5873 | | for (i = 0; g_iconData[i].icon_name; i++) |
| 5874 | | { |
| 5875 | | if (!strcmp(g_iconData[i].icon_name, icon_name)) |
| 5876 | | return i; |
| 5877 | | } |
| 5878 | | return -1; |
| 5879 | | } |
| 5880 | | |
| 5881 | | static int GetIconForDriver(int nItem) |
| 5882 | | { |
| 5883 | | int iconRoms; |
| 5884 | | |
| 5885 | | if (DriverUsesRoms(nItem)) |
| 5886 | | { |
| 5887 | | int audit_result = GetRomAuditResults(nItem); |
| 5888 | | if (IsAuditResultKnown(audit_result) == FALSE) |
| 5889 | | return 2; |
| 5890 | | |
| 5891 | | if (IsAuditResultYes(audit_result)) |
| 5892 | | iconRoms = 1; |
| 5893 | | else |
| 5894 | | iconRoms = 0; |
| 5895 | | } |
| 5896 | | else |
| 5897 | | iconRoms = 1; |
| 5898 | | |
| 5899 | | // iconRoms is now either 0 (no roms), 1 (roms), or 2 (unknown) |
| 5900 | | |
| 5901 | | /* these are indices into icon_names, which maps into our image list |
| 5902 | | * also must match IDI_WIN_NOROMS + iconRoms |
| 5903 | | */ |
| 5904 | | |
| 5905 | | // Show Red-X if the ROMs are present and flagged as NOT WORKING |
| 5906 | | if (iconRoms == 1 && DriverIsBroken(nItem)) |
| 5907 | | iconRoms = FindIconIndex(IDI_WIN_REDX); |
| 5908 | | |
| 5909 | | // show clone icon if we have roms and game is working |
| 5910 | | if (iconRoms == 1 && DriverIsClone(nItem)) |
| 5911 | | iconRoms = FindIconIndex(IDI_WIN_CLONE); |
| 5912 | | |
| 5913 | | // if we have the roms, then look for a custom per-game icon to override |
| 5914 | | if (iconRoms == 1 || iconRoms == 3) |
| 5915 | | { |
| 5916 | | if (icon_index[nItem] == 0) |
| 5917 | | AddDriverIcon(nItem,iconRoms); |
| 5918 | | iconRoms = icon_index[nItem]; |
| 5919 | | } |
| 5920 | | |
| 5921 | | return iconRoms; |
| 5922 | | } |
| 5923 | | |
| 5924 | | static BOOL HandleTreeContextMenu(HWND hWnd, WPARAM wParam, LPARAM lParam) |
| 5925 | | { |
| 5926 | | HMENU hTreeMenu; |
| 5927 | | HMENU hMenu; |
| 5928 | | TVHITTESTINFO hti; |
| 5929 | | POINT pt; |
| 5930 | | |
| 5931 | | if ((HWND)wParam != GetDlgItem(hWnd, IDC_TREE)) |
| 5932 | | return FALSE; |
| 5933 | | |
| 5934 | | pt.x = GET_X_LPARAM(lParam); |
| 5935 | | pt.y = GET_Y_LPARAM(lParam); |
| 5936 | | if (pt.x < 0 && pt.y < 0) |
| 5937 | | GetCursorPos(&pt); |
| 5938 | | |
| 5939 | | /* select the item that was right clicked or shift-F10'ed */ |
| 5940 | | hti.pt = pt; |
| 5941 | | ScreenToClient(hTreeView,&hti.pt); |
| 5942 | | (void)TreeView_HitTest(hTreeView,&hti); |
| 5943 | | if ((hti.flags & TVHT_ONITEM) != 0) |
| 5944 | | TreeView_SelectItem(hTreeView,hti.hItem); |
| 5945 | | |
| 5946 | | hTreeMenu = LoadMenu(hInst,MAKEINTRESOURCE(IDR_CONTEXT_TREE)); |
| 5947 | | |
| 5948 | | InitTreeContextMenu(hTreeMenu); |
| 5949 | | |
| 5950 | | hMenu = GetSubMenu(hTreeMenu, 0); |
| 5951 | | |
| 5952 | | UpdateMenu(hMenu); |
| 5953 | | |
| 5954 | | TrackPopupMenu(hMenu,TPM_LEFTALIGN | TPM_RIGHTBUTTON,pt.x,pt.y,0,hWnd,NULL); |
| 5955 | | |
| 5956 | | DestroyMenu(hTreeMenu); |
| 5957 | | |
| 5958 | | return TRUE; |
| 5959 | | } |
| 5960 | | |
| 5961 | | |
| 5962 | | |
| 5963 | | static void GamePicker_OnBodyContextMenu(POINT pt) |
| 5964 | | { |
| 5965 | | HMENU hMenuLoad; |
| 5966 | | HMENU hMenu; |
| 5967 | | |
| 5968 | | hMenuLoad = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT_MENU)); |
| 5969 | | hMenu = GetSubMenu(hMenuLoad, 0); |
| 5970 | | InitBodyContextMenu(hMenu); |
| 5971 | | |
| 5972 | | UpdateMenu(hMenu); |
| 5973 | | |
| 5974 | | TrackPopupMenu(hMenu,TPM_LEFTALIGN | TPM_RIGHTBUTTON,pt.x,pt.y,0,hMain,NULL); |
| 5975 | | |
| 5976 | | DestroyMenu(hMenuLoad); |
| 5977 | | } |
| 5978 | | |
| 5979 | | |
| 5980 | | |
| 5981 | | static BOOL HandleScreenShotContextMenu(HWND hWnd, WPARAM wParam, LPARAM lParam) |
| 5982 | | { |
| 5983 | | HMENU hMenuLoad; |
| 5984 | | HMENU hMenu; |
| 5985 | | POINT pt; |
| 5986 | | |
| 5987 | | if ((HWND)wParam != GetDlgItem(hWnd, IDC_SSPICTURE) && (HWND)wParam != GetDlgItem(hWnd, IDC_SSFRAME)) |
| 5988 | | return FALSE; |
| 5989 | | |
| 5990 | | pt.x = GET_X_LPARAM(lParam); |
| 5991 | | pt.y = GET_Y_LPARAM(lParam); |
| 5992 | | if (pt.x < 0 && pt.y < 0) |
| 5993 | | GetCursorPos(&pt); |
| 5994 | | |
| 5995 | | hMenuLoad = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT_SCREENSHOT)); |
| 5996 | | hMenu = GetSubMenu(hMenuLoad, 0); |
| 5997 | | |
| 5998 | | UpdateMenu(hMenu); |
| 5999 | | |
| 6000 | | TrackPopupMenu(hMenu,TPM_LEFTALIGN | TPM_RIGHTBUTTON,pt.x,pt.y,0,hWnd,NULL); |
| 6001 | | |
| 6002 | | DestroyMenu(hMenuLoad); |
| 6003 | | |
| 6004 | | return TRUE; |
| 6005 | | } |
| 6006 | | |
| 6007 | | static void UpdateMenu(HMENU hMenu) |
| 6008 | | { |
| 6009 | | TCHAR buf[200]; |
| 6010 | | MENUITEMINFO mItem; |
| 6011 | | int nGame = Picker_GetSelectedItem(hwndList); |
| 6012 | | LPTREEFOLDER lpFolder = GetCurrentFolder(); |
| 6013 | | int i; |
| 6014 | | const char *pParent; |
| 6015 | | TCHAR* t_description; |
| 6016 | | |
| 6017 | | if (have_selection) |
| 6018 | | { |
| 6019 | | t_description = tstring_from_utf8(ConvertAmpersandString(ModifyThe(drivers[nGame]->description))); |
| 6020 | | if( !t_description ) |
| 6021 | | return; |
| 6022 | | |
| 6023 | | _sntprintf(buf, ARRAY_LENGTH(buf), g_szPlayGameString, t_description); |
| 6024 | | |
| 6025 | | mItem.cbSize = sizeof(mItem); |
| 6026 | | mItem.fMask = MIIM_TYPE; |
| 6027 | | mItem.fType = MFT_STRING; |
| 6028 | | mItem.dwTypeData = buf; |
| 6029 | | mItem.cch = _tcslen(mItem.dwTypeData); |
| 6030 | | |
| 6031 | | SetMenuItemInfo(hMenu, ID_FILE_PLAY, FALSE, &mItem); |
| 6032 | | |
| 6033 | | EnableMenuItem(hMenu, ID_CONTEXT_SELECT_RANDOM, MF_ENABLED); |
| 6034 | | |
| 6035 | | free(t_description); |
| 6036 | | } |
| 6037 | | else |
| 6038 | | { |
| 6039 | | EnableMenuItem(hMenu, ID_FILE_PLAY, MF_GRAYED); |
| 6040 | | EnableMenuItem(hMenu, ID_FILE_PLAY_RECORD, MF_GRAYED); |
| 6041 | | EnableMenuItem(hMenu, ID_GAME_PROPERTIES, MF_GRAYED); |
| 6042 | | EnableMenuItem(hMenu, ID_CONTEXT_SELECT_RANDOM, MF_GRAYED); |
| 6043 | | } |
| 6044 | | |
| 6045 | | if (oldControl) |
| 6046 | | { |
| 6047 | | EnableMenuItem(hMenu, ID_CUSTOMIZE_FIELDS, MF_GRAYED); |
| 6048 | | EnableMenuItem(hMenu, ID_GAME_PROPERTIES, MF_GRAYED); |
| 6049 | | EnableMenuItem(hMenu, ID_OPTIONS_DEFAULTS, MF_GRAYED); |
| 6050 | | } |
| 6051 | | |
| 6052 | | if (lpFolder->m_dwFlags & F_CUSTOM) |
| 6053 | | { |
| 6054 | | EnableMenuItem(hMenu,ID_CONTEXT_REMOVE_CUSTOM,MF_ENABLED); |
| 6055 | | EnableMenuItem(hMenu,ID_CONTEXT_RENAME_CUSTOM,MF_ENABLED); |
| 6056 | | } |
| 6057 | | else |
| 6058 | | { |
| 6059 | | EnableMenuItem(hMenu,ID_CONTEXT_REMOVE_CUSTOM,MF_GRAYED); |
| 6060 | | EnableMenuItem(hMenu,ID_CONTEXT_RENAME_CUSTOM,MF_GRAYED); |
| 6061 | | } |
| 6062 | | pParent = GetFolderNameByID(lpFolder->m_nParent+1); |
| 6063 | | |
| 6064 | | if( (strcmp(lpFolder->m_lpTitle, "Vector" ) == 0) || |
| 6065 | | (pParent && (strcmp(pParent, "Source" ) == 0) ) ) |
| 6066 | | EnableMenuItem(hMenu,ID_FOLDER_PROPERTIES,MF_ENABLED); |
| 6067 | | else |
| 6068 | | EnableMenuItem(hMenu,ID_FOLDER_PROPERTIES,MF_GRAYED); |
| 6069 | | |
| 6070 | | CheckMenuRadioItem(hMenu, ID_VIEW_TAB_SCREENSHOT, ID_VIEW_TAB_HISTORY, |
| 6071 | | ID_VIEW_TAB_SCREENSHOT + TabView_GetCurrentTab(hTabCtrl), MF_BYCOMMAND); |
| 6072 | | |
| 6073 | | // set whether we're showing the tab control or not |
| 6074 | | if (bShowTabCtrl) |
| 6075 | | CheckMenuItem(hMenu,ID_VIEW_PAGETAB,MF_BYCOMMAND | MF_CHECKED); |
| 6076 | | else |
| 6077 | | CheckMenuItem(hMenu,ID_VIEW_PAGETAB,MF_BYCOMMAND | MF_UNCHECKED); |
| 6078 | | |
| 6079 | | |
| 6080 | | for (i=0;i<MAX_TAB_TYPES;i++) |
| 6081 | | { |
| 6082 | | // disable menu items for tabs we're not currently showing |
| 6083 | | if (GetShowTab(i)) |
| 6084 | | EnableMenuItem(hMenu,ID_VIEW_TAB_SCREENSHOT + i,MF_BYCOMMAND | MF_ENABLED); |
| 6085 | | else |
| 6086 | | EnableMenuItem(hMenu,ID_VIEW_TAB_SCREENSHOT + i,MF_BYCOMMAND | MF_GRAYED); |
| 6087 | | |
| 6088 | | // check toggle menu items |
| 6089 | | if (GetShowTab(i)) |
| 6090 | | CheckMenuItem(hMenu, ID_TOGGLE_TAB_SCREENSHOT + i,MF_BYCOMMAND | MF_CHECKED); |
| 6091 | | else |
| 6092 | | CheckMenuItem(hMenu, ID_TOGGLE_TAB_SCREENSHOT + i,MF_BYCOMMAND | MF_UNCHECKED); |
| 6093 | | } |
| 6094 | | |
| 6095 | | for (i=0;i<MAX_FOLDERS;i++) |
| 6096 | | { |
| 6097 | | if (GetShowFolder(i)) |
| 6098 | | CheckMenuItem(hMenu,ID_CONTEXT_SHOW_FOLDER_START + i,MF_BYCOMMAND | MF_CHECKED); |
| 6099 | | else |
| 6100 | | CheckMenuItem(hMenu,ID_CONTEXT_SHOW_FOLDER_START + i,MF_BYCOMMAND | MF_UNCHECKED); |
| 6101 | | } |
| 6102 | | |
| 6103 | | } |
| 6104 | | |
| 6105 | | void InitTreeContextMenu(HMENU hTreeMenu) |
| 6106 | | { |
| 6107 | | MENUITEMINFO mii; |
| 6108 | | HMENU hMenu; |
| 6109 | | int i; |
| 6110 | | extern FOLDERDATA g_folderData[]; |
| 6111 | | |
| 6112 | | ZeroMemory(&mii,sizeof(mii)); |
| 6113 | | mii.cbSize = sizeof(mii); |
| 6114 | | |
| 6115 | | mii.wID = -1; |
| 6116 | | mii.fMask = MIIM_SUBMENU | MIIM_ID; |
| 6117 | | |
| 6118 | | hMenu = GetSubMenu(hTreeMenu, 0); |
| 6119 | | |
| 6120 | | if (GetMenuItemInfo(hMenu,3,TRUE,&mii) == FALSE) |
| 6121 | | { |
| 6122 | | dprintf("can't find show folders context menu"); |
| 6123 | | return; |
| 6124 | | } |
| 6125 | | |
| 6126 | | if (mii.hSubMenu == NULL) |
| 6127 | | { |
| 6128 | | dprintf("can't find submenu for show folders context menu"); |
| 6129 | | return; |
| 6130 | | } |
| 6131 | | |
| 6132 | | hMenu = mii.hSubMenu; |
| 6133 | | |
| 6134 | | for (i=0;g_folderData[i].m_lpTitle != NULL;i++) |
| 6135 | | { |
| 6136 | | TCHAR* t_title = tstring_from_utf8(g_folderData[i].m_lpTitle); |
| 6137 | | if( !t_title ) |
| 6138 | | return; |
| 6139 | | |
| 6140 | | mii.fMask = MIIM_TYPE | MIIM_ID; |
| 6141 | | mii.fType = MFT_STRING; |
| 6142 | | mii.dwTypeData = t_title; |
| 6143 | | mii.cch = _tcslen(mii.dwTypeData); |
| 6144 | | mii.wID = ID_CONTEXT_SHOW_FOLDER_START + g_folderData[i].m_nFolderId; |
| 6145 | | |
| 6146 | | |
| 6147 | | // menu in resources has one empty item (needed for the submenu to setup properly) |
| 6148 | | // so overwrite this one, append after |
| 6149 | | if (i == 0) |
| 6150 | | SetMenuItemInfo(hMenu,ID_CONTEXT_SHOW_FOLDER_START,FALSE,&mii); |
| 6151 | | else |
| 6152 | | InsertMenuItem(hMenu,i,FALSE,&mii); |
| 6153 | | |
| 6154 | | free(t_title); |
| 6155 | | } |
| 6156 | | |
| 6157 | | } |
| 6158 | | |
| 6159 | | void InitBodyContextMenu(HMENU hBodyContextMenu) |
| 6160 | | { |
| 6161 | | LPTREEFOLDER lpFolder; |
| 6162 | | TCHAR tmp[30]; |
| 6163 | | MENUITEMINFO mii; |
| 6164 | | ZeroMemory(&mii,sizeof(mii)); |
| 6165 | | mii.cbSize = sizeof(mii); |
| 6166 | | |
| 6167 | | if (GetMenuItemInfo(hBodyContextMenu,ID_FOLDER_SOURCEPROPERTIES,FALSE,&mii) == FALSE) |
| 6168 | | { |
| 6169 | | dprintf("can't find show folders context menu"); |
| 6170 | | return; |
| 6171 | | } |
| 6172 | | lpFolder = GetFolderByName(FOLDER_SOURCE, GetDriverFilename(Picker_GetSelectedItem(hwndList)) ); |
| 6173 | | _sntprintf(tmp,ARRAY_LENGTH(tmp),TEXT("Properties for %s"),lpFolder->m_lptTitle ); |
| 6174 | | mii.fMask = MIIM_TYPE | MIIM_ID; |
| 6175 | | mii.fType = MFT_STRING; |
| 6176 | | mii.dwTypeData = tmp; |
| 6177 | | mii.cch = _tcslen(mii.dwTypeData); |
| 6178 | | mii.wID = ID_FOLDER_SOURCEPROPERTIES; |
| 6179 | | |
| 6180 | | |
| 6181 | | // menu in resources has one default item |
| 6182 | | // so overwrite this one |
| 6183 | | SetMenuItemInfo(hBodyContextMenu,ID_FOLDER_SOURCEPROPERTIES,FALSE,&mii); |
| 6184 | | if( ! DriverIsVector(Picker_GetSelectedItem(hwndList) ) ) |
| 6185 | | EnableMenuItem(hBodyContextMenu, ID_FOLDER_VECTORPROPERTIES, MF_GRAYED); |
| 6186 | | } |
| 6187 | | |
| 6188 | | |
| 6189 | | void ToggleShowFolder(int folder) |
| 6190 | | { |
| 6191 | | int current_id = GetCurrentFolderID(); |
| 6192 | | |
| 6193 | | SetWindowRedraw(hwndList,FALSE); |
| 6194 | | |
| 6195 | | SetShowFolder(folder,!GetShowFolder(folder)); |
| 6196 | | |
| 6197 | | ResetTreeViewFolders(); |
| 6198 | | SelectTreeViewFolder(current_id); |
| 6199 | | |
| 6200 | | SetWindowRedraw(hwndList,TRUE); |
| 6201 | | } |
| 6202 | | |
| 6203 | | static LRESULT CALLBACK HistoryWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 6204 | | { |
| 6205 | | if (hBackground) |
| 6206 | | { |
| 6207 | | switch (uMsg) |
| 6208 | | { |
| 6209 | | case WM_MOUSEMOVE: |
| 6210 | | { |
| 6211 | | if (MouseHasBeenMoved()) |
| 6212 | | ShowCursor(TRUE); |
| 6213 | | break; |
| 6214 | | } |
| 6215 | | |
| 6216 | | case WM_ERASEBKGND: |
| 6217 | | return TRUE; |
| 6218 | | case WM_PAINT: |
| 6219 | | { |
| 6220 | | POINT p = { 0, 0 }; |
| 6221 | | |
| 6222 | | /* get base point of background bitmap */ |
| 6223 | | MapWindowPoints(hWnd,hTreeView,&p,1); |
| 6224 | | PaintBackgroundImage(hWnd, NULL, p.x, p.y); |
| 6225 | | /* to ensure our parent procedure repaints the whole client area */ |
| 6226 | | InvalidateRect(hWnd, NULL, FALSE); |
| 6227 | | break; |
| 6228 | | } |
| 6229 | | } |
| 6230 | | } |
| 6231 | | return CallWindowProc(g_lpHistoryWndProc, hWnd, uMsg, wParam, lParam); |
| 6232 | | } |
| 6233 | | |
| 6234 | | static LRESULT CALLBACK PictureFrameWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 6235 | | { |
| 6236 | | switch (uMsg) |
| 6237 | | { |
| 6238 | | case WM_MOUSEMOVE: |
| 6239 | | { |
| 6240 | | if (MouseHasBeenMoved()) |
| 6241 | | ShowCursor(TRUE); |
| 6242 | | break; |
| 6243 | | } |
| 6244 | | |
| 6245 | | case WM_NCHITTEST : |
| 6246 | | { |
| 6247 | | POINT pt; |
| 6248 | | RECT rect; |
| 6249 | | HWND hHistory = GetDlgItem(hMain, IDC_HISTORY); |
| 6250 | | |
| 6251 | | pt.x = LOWORD(lParam); |
| 6252 | | pt.y = HIWORD(lParam); |
| 6253 | | GetWindowRect(hHistory, &rect); |
| 6254 | | // check if they clicked on the picture area (leave 6 pixel no man's land |
| 6255 | | // by the history window to reduce mistaken clicks) |
| 6256 | | // no more no man's land, the Cursor changes when Edit control is left, should be enough feedback |
| 6257 | | if (have_history && |
| 6258 | | ( ( (TabView_GetCurrentTab(hTabCtrl) == TAB_HISTORY) || |
| 6259 | | (TabView_GetCurrentTab(hTabCtrl) == GetHistoryTab() && GetShowTab(TAB_HISTORY) == FALSE) || |
| 6260 | | (TAB_ALL == GetHistoryTab() && GetShowTab(TAB_HISTORY) == FALSE) ) && |
| 6261 | | // (rect.top - 6) < pt.y && pt.y < (rect.bottom + 6) ) ) |
| 6262 | | PtInRect( &rect, pt ) ) ) |
| 6263 | | |
| 6264 | | { |
| 6265 | | return HTTRANSPARENT; |
| 6266 | | } |
| 6267 | | else |
| 6268 | | { |
| 6269 | | return HTCLIENT; |
| 6270 | | } |
| 6271 | | } |
| 6272 | | break; |
| 6273 | | case WM_CONTEXTMENU: |
| 6274 | | if ( HandleScreenShotContextMenu(hWnd, wParam, lParam)) |
| 6275 | | return FALSE; |
| 6276 | | break; |
| 6277 | | } |
| 6278 | | |
| 6279 | | if (hBackground) |
| 6280 | | { |
| 6281 | | switch (uMsg) |
| 6282 | | { |
| 6283 | | case WM_ERASEBKGND : |
| 6284 | | return TRUE; |
| 6285 | | case WM_PAINT : |
| 6286 | | { |
| 6287 | | RECT rect,nodraw_rect; |
| 6288 | | HRGN region,nodraw_region; |
| 6289 | | POINT p = { 0, 0 }; |
| 6290 | | |
| 6291 | | /* get base point of background bitmap */ |
| 6292 | | MapWindowPoints(hWnd,hTreeView,&p,1); |
| 6293 | | |
| 6294 | | /* get big region */ |
| 6295 | | GetClientRect(hWnd,&rect); |
| 6296 | | region = CreateRectRgnIndirect(&rect); |
| 6297 | | |
| 6298 | | if (IsWindowVisible(GetDlgItem(hMain,IDC_HISTORY))) |
| 6299 | | { |
| 6300 | | /* don't draw over this window */ |
| 6301 | | GetWindowRect(GetDlgItem(hMain,IDC_HISTORY),&nodraw_rect); |
| 6302 | | MapWindowPoints(HWND_DESKTOP,hWnd,(LPPOINT)&nodraw_rect,2); |
| 6303 | | nodraw_region = CreateRectRgnIndirect(&nodraw_rect); |
| 6304 | | CombineRgn(region,region,nodraw_region,RGN_DIFF); |
| 6305 | | DeleteObject(nodraw_region); |
| 6306 | | } |
| 6307 | | if (IsWindowVisible(GetDlgItem(hMain,IDC_SSPICTURE))) |
| 6308 | | { |
| 6309 | | /* don't draw over this window */ |
| 6310 | | GetWindowRect(GetDlgItem(hMain,IDC_SSPICTURE),&nodraw_rect); |
| 6311 | | MapWindowPoints(HWND_DESKTOP,hWnd,(LPPOINT)&nodraw_rect,2); |
| 6312 | | nodraw_region = CreateRectRgnIndirect(&nodraw_rect); |
| 6313 | | CombineRgn(region,region,nodraw_region,RGN_DIFF); |
| 6314 | | DeleteObject(nodraw_region); |
| 6315 | | } |
| 6316 | | |
| 6317 | | PaintBackgroundImage(hWnd,region,p.x,p.y); |
| 6318 | | |
| 6319 | | DeleteObject(region); |
| 6320 | | |
| 6321 | | /* to ensure our parent procedure repaints the whole client area */ |
| 6322 | | InvalidateRect(hWnd, NULL, FALSE); |
| 6323 | | |
| 6324 | | break; |
| 6325 | | } |
| 6326 | | } |
| 6327 | | } |
| 6328 | | return CallWindowProc(g_lpPictureFrameWndProc, hWnd, uMsg, wParam, lParam); |
| 6329 | | } |
| 6330 | | |
| 6331 | | static LRESULT CALLBACK PictureWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 6332 | | { |
| 6333 | | switch (uMsg) |
| 6334 | | { |
| 6335 | | case WM_ERASEBKGND : |
| 6336 | | return TRUE; |
| 6337 | | case WM_PAINT : |
| 6338 | | { |
| 6339 | | PAINTSTRUCT ps; |
| 6340 | | HDC hdc,hdc_temp; |
| 6341 | | RECT rect; |
| 6342 | | HBITMAP old_bitmap; |
| 6343 | | |
| 6344 | | int width,height; |
| 6345 | | |
| 6346 | | RECT rect2; |
| 6347 | | HBRUSH hBrush; |
| 6348 | | HBRUSH holdBrush; |
| 6349 | | HRGN region1, region2; |
| 6350 | | int nBordersize; |
| 6351 | | nBordersize = GetScreenshotBorderSize(); |
| 6352 | | hBrush = CreateSolidBrush(GetScreenshotBorderColor()); |
| 6353 | | |
| 6354 | | hdc = BeginPaint(hWnd,&ps); |
| 6355 | | |
| 6356 | | hdc_temp = CreateCompatibleDC(hdc); |
| 6357 | | if (ScreenShotLoaded()) |
| 6358 | | { |
| 6359 | | width = GetScreenShotWidth(); |
| 6360 | | height = GetScreenShotHeight(); |
| 6361 | | |
| 6362 | | old_bitmap = SelectObject(hdc_temp,GetScreenShotHandle()); |
| 6363 | | } |
| 6364 | | else |
| 6365 | | { |
| 6366 | | BITMAP bmp; |
| 6367 | | |
| 6368 | | GetObject(hMissing_bitmap,sizeof(BITMAP),&bmp); |
| 6369 | | width = bmp.bmWidth; |
| 6370 | | height = bmp.bmHeight; |
| 6371 | | |
| 6372 | | old_bitmap = SelectObject(hdc_temp,hMissing_bitmap); |
| 6373 | | } |
| 6374 | | |
| 6375 | | GetClientRect(hWnd,&rect); |
| 6376 | | |
| 6377 | | rect2 = rect; |
| 6378 | | //Configurable Borders around images |
| 6379 | | rect.bottom -= nBordersize; |
| 6380 | | if( rect.bottom < 0) |
| 6381 | | rect.bottom = rect2.bottom; |
| 6382 | | rect.right -= nBordersize; |
| 6383 | | if( rect.right < 0) |
| 6384 | | rect.right = rect2.right; |
| 6385 | | rect.top += nBordersize; |
| 6386 | | if( rect.top > rect.bottom ) |
| 6387 | | rect.top = rect2.top; |
| 6388 | | rect.left += nBordersize; |
| 6389 | | if( rect.left > rect.right ) |
| 6390 | | rect.left = rect2.left; |
| 6391 | | region1 = CreateRectRgnIndirect(&rect); |
| 6392 | | region2 = CreateRectRgnIndirect(&rect2); |
| 6393 | | CombineRgn(region2,region2,region1,RGN_DIFF); |
| 6394 | | holdBrush = SelectObject(hdc, hBrush); |
| 6395 | | |
| 6396 | | FillRgn(hdc,region2, hBrush ); |
| 6397 | | SelectObject(hdc, holdBrush); |
| 6398 | | DeleteObject(hBrush); |
| 6399 | | |
| 6400 | | SetStretchBltMode(hdc,STRETCH_HALFTONE); |
| 6401 | | StretchBlt(hdc,nBordersize,nBordersize,rect.right-rect.left,rect.bottom-rect.top, |
| 6402 | | hdc_temp,0,0,width,height,SRCCOPY); |
| 6403 | | SelectObject(hdc_temp,old_bitmap); |
| 6404 | | DeleteDC(hdc_temp); |
| 6405 | | |
| 6406 | | EndPaint(hWnd,&ps); |
| 6407 | | |
| 6408 | | return TRUE; |
| 6409 | | } |
| 6410 | | } |
| 6411 | | |
| 6412 | | return CallWindowProc(g_lpPictureWndProc, hWnd, uMsg, wParam, lParam); |
| 6413 | | } |
| 6414 | | |
| 6415 | | void RemoveCurrentGameCustomFolder(void) |
| 6416 | | { |
| 6417 | | RemoveGameCustomFolder(Picker_GetSelectedItem(hwndList)); |
| 6418 | | } |
| 6419 | | |
| 6420 | | void RemoveGameCustomFolder(int driver_index) |
| 6421 | | { |
| 6422 | | int i; |
| 6423 | | TREEFOLDER **folders; |
| 6424 | | int num_folders; |
| 6425 | | |
| 6426 | | GetFolders(&folders,&num_folders); |
| 6427 | | |
| 6428 | | for (i=0;i<num_folders;i++) |
| 6429 | | { |
| 6430 | | if (folders[i]->m_dwFlags & F_CUSTOM && folders[i]->m_nFolderId == GetCurrentFolderID()) |
| 6431 | | { |
| 6432 | | int current_pick_index; |
| 6433 | | |
| 6434 | | RemoveFromCustomFolder(folders[i],driver_index); |
| 6435 | | |
| 6436 | | if (driver_index == Picker_GetSelectedItem(hwndList)) |
| 6437 | | { |
| 6438 | | /* if we just removed the current game, |
| 6439 | | move the current selection so that when we rebuild the listview it |
| 6440 | | leaves the cursor on next or previous one */ |
| 6441 | | |
| 6442 | | current_pick_index = GetSelectedPick(); |
| 6443 | | Picker_SetSelectedPick(hwndList, GetSelectedPick() + 1); |
| 6444 | | if (current_pick_index == GetSelectedPick()) /* we must have deleted the last item */ |
| 6445 | | Picker_SetSelectedPick(hwndList, GetSelectedPick() - 1); |
| 6446 | | } |
| 6447 | | |
| 6448 | | ResetListView(); |
| 6449 | | return; |
| 6450 | | } |
| 6451 | | } |
| 6452 | | MessageBox(GetMainWindow(), TEXT("Error searching for custom folder"), TEXT(MAME32NAME), MB_OK | MB_ICONERROR); |
| 6453 | | |
| 6454 | | } |
| 6455 | | |
| 6456 | | |
| 6457 | | void BeginListViewDrag(NM_LISTVIEW *pnmv) |
| 6458 | | { |
| 6459 | | LV_ITEM lvi; |
| 6460 | | POINT pt; |
| 6461 | | |
| 6462 | | lvi.iItem = pnmv->iItem; |
| 6463 | | lvi.mask = LVIF_PARAM; |
| 6464 | | ListView_GetItem(hwndList, &lvi); |
| 6465 | | |
| 6466 | | game_dragged = lvi.lParam; |
| 6467 | | |
| 6468 | | pt.x = 0; |
| 6469 | | pt.y = 0; |
| 6470 | | |
| 6471 | | /* Tell the list view control to create an image to use |
| 6472 | | for dragging. */ |
| 6473 | | himl_drag = ListView_CreateDragImage(hwndList,pnmv->iItem,&pt); |
| 6474 | | |
| 6475 | | /* Start the drag operation. */ |
| 6476 | | ImageList_BeginDrag(himl_drag, 0, 0, 0); |
| 6477 | | |
| 6478 | | pt = pnmv->ptAction; |
| 6479 | | ClientToScreen(hwndList,&pt); |
| 6480 | | ImageList_DragEnter(GetDesktopWindow(),pt.x,pt.y); |
| 6481 | | |
| 6482 | | /* Hide the mouse cursor, and direct mouse input to the |
| 6483 | | parent window. */ |
| 6484 | | SetCapture(hMain); |
| 6485 | | |
| 6486 | | prev_drag_drop_target = NULL; |
| 6487 | | |
| 6488 | | g_listview_dragging = TRUE; |
| 6489 | | |
| 6490 | | } |
| 6491 | | |
| 6492 | | void MouseMoveListViewDrag(POINTS p) |
| 6493 | | { |
| 6494 | | HTREEITEM htiTarget; |
| 6495 | | TV_HITTESTINFO tvht; |
| 6496 | | |
| 6497 | | POINT pt; |
| 6498 | | pt.x = p.x; |
| 6499 | | pt.y = p.y; |
| 6500 | | |
| 6501 | | ClientToScreen(hMain,&pt); |
| 6502 | | |
| 6503 | | ImageList_DragMove(pt.x,pt.y); |
| 6504 | | |
| 6505 | | MapWindowPoints(GetDesktopWindow(),hTreeView,&pt,1); |
| 6506 | | |
| 6507 | | tvht.pt = pt; |
| 6508 | | htiTarget = TreeView_HitTest(hTreeView,&tvht); |
| 6509 | | |
| 6510 | | if (htiTarget != prev_drag_drop_target) |
| 6511 | | { |
| 6512 | | ImageList_DragShowNolock(FALSE); |
| 6513 | | if (htiTarget != NULL) |
| 6514 | | TreeView_SelectDropTarget(hTreeView,htiTarget); |
| 6515 | | else |
| 6516 | | TreeView_SelectDropTarget(hTreeView,NULL); |
| 6517 | | ImageList_DragShowNolock(TRUE); |
| 6518 | | |
| 6519 | | prev_drag_drop_target = htiTarget; |
| 6520 | | } |
| 6521 | | } |
| 6522 | | |
| 6523 | | void ButtonUpListViewDrag(POINTS p) |
| 6524 | | { |
| 6525 | | POINT pt; |
| 6526 | | HTREEITEM htiTarget; |
| 6527 | | TV_HITTESTINFO tvht; |
| 6528 | | TVITEM tvi; |
| 6529 | | |
| 6530 | | ReleaseCapture(); |
| 6531 | | |
| 6532 | | ImageList_DragLeave(hwndList); |
| 6533 | | ImageList_EndDrag(); |
| 6534 | | ImageList_Destroy(himl_drag); |
| 6535 | | |
| 6536 | | TreeView_SelectDropTarget(hTreeView,NULL); |
| 6537 | | |
| 6538 | | g_listview_dragging = FALSE; |
| 6539 | | |
| 6540 | | /* see where the game was dragged */ |
| 6541 | | |
| 6542 | | pt.x = p.x; |
| 6543 | | pt.y = p.y; |
| 6544 | | |
| 6545 | | MapWindowPoints(hMain,hTreeView,&pt,1); |
| 6546 | | |
| 6547 | | tvht.pt = pt; |
| 6548 | | htiTarget = TreeView_HitTest(hTreeView,&tvht); |
| 6549 | | if (htiTarget == NULL) |
| 6550 | | { |
| 6551 | | LVHITTESTINFO lvhtti; |
| 6552 | | LPTREEFOLDER folder; |
| 6553 | | RECT rcList; |
| 6554 | | |
| 6555 | | /* the user dragged a game onto something other than the treeview */ |
| 6556 | | /* try to remove if we're in a custom folder */ |
| 6557 | | |
| 6558 | | /* see if it was dragged within the list view; if so, ignore */ |
| 6559 | | |
| 6560 | | MapWindowPoints(hTreeView,hwndList,&pt,1); |
| 6561 | | lvhtti.pt = pt; |
| 6562 | | GetWindowRect(hwndList, &rcList); |
| 6563 | | ClientToScreen(hwndList, &pt); |
| 6564 | | if( PtInRect(&rcList, pt) != 0 ) |
| 6565 | | return; |
| 6566 | | |
| 6567 | | folder = GetCurrentFolder(); |
| 6568 | | if (folder->m_dwFlags & F_CUSTOM) |
| 6569 | | { |
| 6570 | | /* dragged out of a custom folder, so let's remove it */ |
| 6571 | | RemoveCurrentGameCustomFolder(); |
| 6572 | | } |
| 6573 | | return; |
| 6574 | | } |
| 6575 | | |
| 6576 | | |
| 6577 | | tvi.lParam = 0; |
| 6578 | | tvi.mask = TVIF_PARAM | TVIF_HANDLE; |
| 6579 | | tvi.hItem = htiTarget; |
| 6580 | | |
| 6581 | | if (TreeView_GetItem(hTreeView, &tvi)) |
| 6582 | | { |
| 6583 | | LPTREEFOLDER folder = (LPTREEFOLDER)tvi.lParam; |
| 6584 | | AddToCustomFolder(folder,game_dragged); |
| 6585 | | } |
| 6586 | | |
| 6587 | | } |
| 6588 | | |
| 6589 | | static LPTREEFOLDER GetSelectedFolder(void) |
| 6590 | | { |
| 6591 | | HTREEITEM htree; |
| 6592 | | TVITEM tvi; |
| 6593 | | htree = TreeView_GetSelection(hTreeView); |
| 6594 | | if(htree != NULL) |
| 6595 | | { |
| 6596 | | tvi.hItem = htree; |
| 6597 | | tvi.mask = TVIF_PARAM; |
| 6598 | | TreeView_GetItem(hTreeView,&tvi); |
| 6599 | | return (LPTREEFOLDER)tvi.lParam; |
| 6600 | | } |
| 6601 | | return NULL; |
| 6602 | | } |
| 6603 | | |
| 6604 | | static HICON GetSelectedFolderIcon(void) |
| 6605 | | { |
| 6606 | | HTREEITEM htree; |
| 6607 | | TVITEM tvi; |
| 6608 | | HIMAGELIST hSmall_icon; |
| 6609 | | LPTREEFOLDER folder; |
| 6610 | | htree = TreeView_GetSelection(hTreeView); |
| 6611 | | |
| 6612 | | if (htree != NULL) |
| 6613 | | { |
| 6614 | | tvi.hItem = htree; |
| 6615 | | tvi.mask = TVIF_PARAM; |
| 6616 | | TreeView_GetItem(hTreeView,&tvi); |
| 6617 | | |
| 6618 | | folder = (LPTREEFOLDER)tvi.lParam; |
| 6619 | | //hSmall_icon = TreeView_GetImageList(hTreeView,(int)tvi.iImage); |
| 6620 | | hSmall_icon = NULL; |
| 6621 | | return ImageList_GetIcon(hSmall_icon, tvi.iImage, ILD_TRANSPARENT); |
| 6622 | | } |
| 6623 | | return NULL; |
| 6624 | | } |
| 6625 | | |
| 6626 | | /* Updates all currently displayed Items in the List with the latest Data*/ |
| 6627 | | void UpdateListView(void) |
| 6628 | | { |
| 6629 | | if( (GetViewMode() == VIEW_GROUPED) || (GetViewMode() == VIEW_DETAILS ) ) |
| 6630 | | ListView_RedrawItems(hwndList,ListView_GetTopIndex(hwndList), |
| 6631 | | ListView_GetTopIndex(hwndList)+ ListView_GetCountPerPage(hwndList) ); |
| 6632 | | } |
| 6633 | | |
| 6634 | | void CalculateBestScreenShotRect(HWND hWnd, RECT *pRect, BOOL restrict_height) |
| 6635 | | { |
| 6636 | | int destX, destY; |
| 6637 | | int destW, destH; |
| 6638 | | int nBorder; |
| 6639 | | RECT rect; |
| 6640 | | /* for scaling */ |
| 6641 | | int x, y; |
| 6642 | | int rWidth, rHeight; |
| 6643 | | double scale; |
| 6644 | | BOOL bReduce = FALSE; |
| 6645 | | |
| 6646 | | GetClientRect(hWnd, &rect); |
| 6647 | | |
| 6648 | | // Scale the bitmap to the frame specified by the passed in hwnd |
| 6649 | | if (ScreenShotLoaded()) |
| 6650 | | { |
| 6651 | | x = GetScreenShotWidth(); |
| 6652 | | y = GetScreenShotHeight(); |
| 6653 | | } |
| 6654 | | else |
| 6655 | | { |
| 6656 | | BITMAP bmp; |
| 6657 | | GetObject(hMissing_bitmap,sizeof(BITMAP),&bmp); |
| 6658 | | |
| 6659 | | x = bmp.bmWidth; |
| 6660 | | y = bmp.bmHeight; |
| 6661 | | } |
| 6662 | | rWidth = (rect.right - rect.left); |
| 6663 | | rHeight = (rect.bottom - rect.top); |
| 6664 | | |
| 6665 | | /* Limit the screen shot to max height of 264 */ |
| 6666 | | if (restrict_height == TRUE && rHeight > 264) |
| 6667 | | { |
| 6668 | | rect.bottom = rect.top + 264; |
| 6669 | | rHeight = 264; |
| 6670 | | } |
| 6671 | | |
| 6672 | | /* If the bitmap does NOT fit in the screenshot area */ |
| 6673 | | if (x > rWidth - 10 || y > rHeight - 10) |
| 6674 | | { |
| 6675 | | rect.right -= 10; |
| 6676 | | rect.bottom -= 10; |
| 6677 | | rWidth -= 10; |
| 6678 | | rHeight -= 10; |
| 6679 | | bReduce = TRUE; |
| 6680 | | /* Try to scale it properly */ |
| 6681 | | /* assumes square pixels, doesn't consider aspect ratio */ |
| 6682 | | if (x > y) |
| 6683 | | scale = (double)rWidth / x; |
| 6684 | | else |
| 6685 | | scale = (double)rHeight / y; |
| 6686 | | |
| 6687 | | destW = (int)(x * scale); |
| 6688 | | destH = (int)(y * scale); |
| 6689 | | |
| 6690 | | /* If it's still too big, scale again */ |
| 6691 | | if (destW > rWidth || destH > rHeight) |
| 6692 | | { |
| 6693 | | if (destW > rWidth) |
| 6694 | | scale = (double)rWidth / destW; |
| 6695 | | else |
| 6696 | | scale = (double)rHeight / destH; |
| 6697 | | |
| 6698 | | destW = (int)(destW * scale); |
| 6699 | | destH = (int)(destH * scale); |
| 6700 | | } |
| 6701 | | } |
| 6702 | | else |
| 6703 | | { |
| 6704 | | if (GetStretchScreenShotLarger()) |
| 6705 | | { |
| 6706 | | rect.right -= 10; |
| 6707 | | rect.bottom -= 10; |
| 6708 | | rWidth -= 10; |
| 6709 | | rHeight -= 10; |
| 6710 | | bReduce = TRUE; |
| 6711 | | // Try to scale it properly |
| 6712 | | // assumes square pixels, doesn't consider aspect ratio |
| 6713 | | if (x < y) |
| 6714 | | scale = (double)rWidth / x; |
| 6715 | | else |
| 6716 | | scale = (double)rHeight / y; |
| 6717 | | |
| 6718 | | destW = (int)(x * scale); |
| 6719 | | destH = (int)(y * scale); |
| 6720 | | |
| 6721 | | // If it's too big, scale again |
| 6722 | | if (destW > rWidth || destH > rHeight) |
| 6723 | | { |
| 6724 | | if (destW > rWidth) |
| 6725 | | scale = (double)rWidth / destW; |
| 6726 | | else |
| 6727 | | scale = (double)rHeight / destH; |
| 6728 | | |
| 6729 | | destW = (int)(destW * scale); |
| 6730 | | destH = (int)(destH * scale); |
| 6731 | | } |
| 6732 | | } |
| 6733 | | else |
| 6734 | | { |
| 6735 | | // Use the bitmaps size if it fits |
| 6736 | | destW = x; |
| 6737 | | destH = y; |
| 6738 | | } |
| 6739 | | |
| 6740 | | } |
| 6741 | | |
| 6742 | | |
| 6743 | | destX = ((rWidth - destW) / 2); |
| 6744 | | destY = ((rHeight - destH) / 2); |
| 6745 | | |
| 6746 | | if (bReduce) |
| 6747 | | { |
| 6748 | | destX += 5; |
| 6749 | | destY += 5; |
| 6750 | | } |
| 6751 | | nBorder = GetScreenshotBorderSize(); |
| 6752 | | if( destX > nBorder+1) |
| 6753 | | pRect->left = destX - nBorder; |
| 6754 | | else |
| 6755 | | pRect->left = 2; |
| 6756 | | if( destY > nBorder+1) |
| 6757 | | pRect->top = destY - nBorder; |
| 6758 | | else |
| 6759 | | pRect->top = 2; |
| 6760 | | if( rWidth >= destX + destW + nBorder) |
| 6761 | | pRect->right = destX + destW + nBorder; |
| 6762 | | else |
| 6763 | | pRect->right = rWidth - pRect->left; |
| 6764 | | if( rHeight >= destY + destH + nBorder) |
| 6765 | | pRect->bottom = destY + destH + nBorder; |
| 6766 | | else |
| 6767 | | pRect->bottom = rHeight - pRect->top; |
| 6768 | | } |
| 6769 | | |
| 6770 | | /* |
| 6771 | | Switches to either fullscreen or normal mode, based on the |
| 6772 | | current mode. |
| 6773 | | |
| 6774 | | POSSIBLE BUGS: |
| 6775 | | Removing the menu might cause problems later if some |
| 6776 | | function tries to poll info stored in the menu. Don't |
| 6777 | | know if you've done that, but this was the only way I |
| 6778 | | knew to remove the menu dynamically. |
| 6779 | | */ |
| 6780 | | |
| 6781 | | void SwitchFullScreenMode(void) |
| 6782 | | { |
| 6783 | | LONG lMainStyle; |
| 6784 | | |
| 6785 | | if (GetRunFullScreen()) |
| 6786 | | { |
| 6787 | | // Return to normal |
| 6788 | | |
| 6789 | | // Restore the menu |
| 6790 | | SetMenu(hMain, LoadMenu(hInst,MAKEINTRESOURCE(IDR_UI_MENU))); |
| 6791 | | |
| 6792 | | // Refresh the checkmarks |
| 6793 | | CheckMenuItem(GetMenu(hMain), ID_VIEW_FOLDERS, GetShowFolderList() ? MF_CHECKED : MF_UNCHECKED); |
| 6794 | | CheckMenuItem(GetMenu(hMain), ID_VIEW_TOOLBARS, GetShowToolBar() ? MF_CHECKED : MF_UNCHECKED); |
| 6795 | | CheckMenuItem(GetMenu(hMain), ID_VIEW_STATUS, GetShowStatusBar() ? MF_CHECKED : MF_UNCHECKED); |
| 6796 | | CheckMenuItem(GetMenu(hMain), ID_VIEW_PAGETAB, GetShowTabCtrl() ? MF_CHECKED : MF_UNCHECKED); |
| 6797 | | |
| 6798 | | // Add frame to dialog again |
| 6799 | | lMainStyle = GetWindowLong(hMain, GWL_STYLE); |
| 6800 | | lMainStyle = lMainStyle | WS_BORDER; |
| 6801 | | SetWindowLong(hMain, GWL_STYLE, lMainStyle); |
| 6802 | | |
| 6803 | | // Show the window maximized |
| 6804 | | if( GetWindowState() == SW_MAXIMIZE ) |
| 6805 | | { |
| 6806 | | ShowWindow(hMain, SW_NORMAL); |
| 6807 | | ShowWindow(hMain, SW_MAXIMIZE); |
| 6808 | | } |
| 6809 | | else |
| 6810 | | ShowWindow(hMain, SW_RESTORE); |
| 6811 | | |
| 6812 | | SetRunFullScreen(FALSE); |
| 6813 | | } |
| 6814 | | else |
| 6815 | | { |
| 6816 | | // Set to fullscreen |
| 6817 | | |
| 6818 | | // Remove menu |
| 6819 | | SetMenu(hMain,NULL); |
| 6820 | | |
| 6821 | | // Frameless dialog (fake fullscreen) |
| 6822 | | lMainStyle = GetWindowLong(hMain, GWL_STYLE); |
| 6823 | | lMainStyle = lMainStyle & (WS_BORDER ^ 0xffffffff); |
| 6824 | | SetWindowLong(hMain, GWL_STYLE, lMainStyle); |
| 6825 | | if( IsMaximized(hMain) ) |
| 6826 | | { |
| 6827 | | ShowWindow(hMain, SW_NORMAL); |
| 6828 | | SetWindowState( SW_MAXIMIZE ); |
| 6829 | | } |
| 6830 | | ShowWindow(hMain, SW_MAXIMIZE); |
| 6831 | | |
| 6832 | | SetRunFullScreen(TRUE); |
| 6833 | | } |
| 6834 | | } |
| 6835 | | |
| 6836 | | /* |
| 6837 | | Checks to see if the mouse has been moved since this func |
| 6838 | | was first called (which is at startup). The reason for |
| 6839 | | storing the startup coordinates of the mouse is that when |
| 6840 | | a window is created it generates WM_MOUSEOVER events, even |
| 6841 | | though the user didn't actually move the mouse. So we need |
| 6842 | | to know when the WM_MOUSEOVER event is user-triggered. |
| 6843 | | |
| 6844 | | POSSIBLE BUGS: |
| 6845 | | Gets polled at every WM_MOUSEMOVE so it might cause lag, |
| 6846 | | but there's probably another way to code this that's |
| 6847 | | way better? |
| 6848 | | |
| 6849 | | */ |
| 6850 | | |
| 6851 | | BOOL MouseHasBeenMoved(void) |
| 6852 | | { |
| 6853 | | static int mouse_x = -1; |
| 6854 | | static int mouse_y = -1; |
| 6855 | | POINT p; |
| 6856 | | |
| 6857 | | GetCursorPos(&p); |
| 6858 | | |
| 6859 | | if (mouse_x == -1) // First time |
| 6860 | | { |
| 6861 | | mouse_x = p.x; |
| 6862 | | mouse_y = p.y; |
| 6863 | | } |
| 6864 | | |
| 6865 | | return (p.x != mouse_x || p.y != mouse_y); |
| 6866 | | } |
| 6867 | | |
| 6868 | | /* End of source file */ |
src/osd/windows/ui/mame32.rc
| r995 | r996 | |
| 1 | | //Microsoft Developer Studio generated resource script. |
| 2 | | // |
| 3 | | #include "resource.h" |
| 4 | | |
| 5 | | #ifdef MESS |
| 6 | | #include "resourcems.h" |
| 7 | | #endif |
| 8 | | |
| 9 | | // Generated Help ID header file |
| 10 | | #define APSTUDIO_HIDDEN_SYMBOLS |
| 11 | | #include "resource.hm" |
| 12 | | #undef APSTUDIO_HIDDEN_SYMBOLS |
| 13 | | |
| 14 | | #define APSTUDIO_READONLY_SYMBOLS |
| 15 | | ///////////////////////////////////////////////////////////////////////////// |
| 16 | | // |
| 17 | | // Generated from the TEXTINCLUDE 2 resource. |
| 18 | | // |
| 19 | | #define NOWINRES |
| 20 | | #include "windows.h" |
| 21 | | #include "commctrl.h" |
| 22 | | |
| 23 | | ///////////////////////////////////////////////////////////////////////////// |
| 24 | | #undef APSTUDIO_READONLY_SYMBOLS |
| 25 | | |
| 26 | | ///////////////////////////////////////////////////////////////////////////// |
| 27 | | // Englisch (USA) resources |
| 28 | | |
| 29 | | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) |
| 30 | | #ifdef _WIN32 |
| 31 | | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US |
| 32 | | #pragma code_page(1252) |
| 33 | | #endif //_WIN32 |
| 34 | | |
| 35 | | ///////////////////////////////////////////////////////////////////////////// |
| 36 | | // |
| 37 | | // Menu |
| 38 | | // |
| 39 | | |
| 40 | | IDR_MAIN_MENU MENU DISCARDABLE |
| 41 | | BEGIN |
| 42 | | POPUP "&File" |
| 43 | | BEGIN |
| 44 | | MENUITEM "&Exit", ID_FILE_EXIT |
| 45 | | END |
| 46 | | POPUP "&Help" |
| 47 | | BEGIN |
| 48 | | #ifdef MESS |
| 49 | | MENUITEM "&About MESS", ID_ABOUT |
| 50 | | #else |
| 51 | | MENUITEM "&About MAME32", ID_ABOUT |
| 52 | | #endif |
| 53 | | END |
| 54 | | END |
| 55 | | |
| 56 | | IDR_UI_MENU MENU DISCARDABLE |
| 57 | | BEGIN |
| 58 | | POPUP "&File" |
| 59 | | BEGIN |
| 60 | | MENUITEM "&Play", ID_FILE_PLAY |
| 61 | | MENUITEM SEPARATOR |
| 62 | | MENUITEM "Play and &Record Input...", ID_FILE_PLAY_RECORD |
| 63 | | MENUITEM "P&layback Input...", ID_FILE_PLAY_BACK |
| 64 | | MENUITEM SEPARATOR |
| 65 | | MENUITEM "Play and Record &Wave Output...", ID_FILE_PLAY_RECORD_WAVE |
| 66 | | MENUITEM SEPARATOR |
| 67 | | MENUITEM "Play and Record &MNG Output...", ID_FILE_PLAY_RECORD_MNG |
| 68 | | MENUITEM SEPARATOR |
| 69 | | MENUITEM "Loa&d Savestate...", ID_FILE_LOADSTATE |
| 70 | | MENUITEM SEPARATOR |
| 71 | | #ifdef MESS |
| 72 | | MENUITEM "&Select Random System", ID_CONTEXT_SELECT_RANDOM |
| 73 | | MENUITEM SEPARATOR |
| 74 | | MENUITEM "Op&en Other Software...", ID_MESS_OPEN_SOFTWARE |
| 75 | | MENUITEM "&Create Image...", ID_MESS_CREATE_SOFTWARE |
| 76 | | #ifdef MAME_DEBUG |
| 77 | | MENUITEM SEPARATOR |
| 78 | | MENUITEM "Run Tests", ID_MESS_RUN_TESTS |
| 79 | | #endif |
| 80 | | #else /* !MESS */ |
| 81 | | MENUITEM "&Select Random Game", ID_CONTEXT_SELECT_RANDOM |
| 82 | | #endif /* MESS */ |
| 83 | | MENUITEM SEPARATOR |
| 84 | | MENUITEM "Pr&operties", ID_GAME_PROPERTIES |
| 85 | | MENUITEM SEPARATOR |
| 86 | | #ifdef MESS |
| 87 | | MENUITEM "&Audit all systems", ID_FILE_AUDIT |
| 88 | | #else |
| 89 | | MENUITEM "&Audit all games", ID_FILE_AUDIT |
| 90 | | #endif /* MESS */ |
| 91 | | MENUITEM SEPARATOR |
| 92 | | MENUITEM "E&xit", ID_FILE_EXIT |
| 93 | | END |
| 94 | | POPUP "&View" |
| 95 | | BEGIN |
| 96 | | MENUITEM "&Toolbar\tAlt+T", ID_VIEW_TOOLBARS |
| 97 | | MENUITEM "&Status bar\tAlt+S", ID_VIEW_STATUS |
| 98 | | MENUITEM "Fold&er List\tAlt+D", ID_VIEW_FOLDERS |
| 99 | | MENUITEM "&Picture Area\tAlt+P", ID_VIEW_PICTURE_AREA |
| 100 | | MENUITEM "Screenshot Ta&b\tAlt+B", ID_VIEW_PAGETAB |
| 101 | | MENUITEM SEPARATOR |
| 102 | | MENUITEM "&Fullscreen\tF11", ID_VIEW_FULLSCREEN |
| 103 | | MENUITEM SEPARATOR |
| 104 | | POPUP "S&how Pictures" |
| 105 | | BEGIN |
| 106 | | MENUITEM "&Snapshot", ID_TOGGLE_TAB_SCREENSHOT |
| 107 | | MENUITEM "&Flyer", ID_TOGGLE_TAB_FLYER |
| 108 | | MENUITEM "&Cabinet", ID_TOGGLE_TAB_CABINET |
| 109 | | MENUITEM "&Marquee", ID_TOGGLE_TAB_MARQUEE |
| 110 | | MENUITEM "&Title", ID_TOGGLE_TAB_TITLE |
| 111 | | MENUITEM "Control &Panel", ID_TOGGLE_TAB_CONTROL_PANEL |
| 112 | | |
| 113 | | MENUITEM "&History", ID_TOGGLE_TAB_HISTORY |
| 114 | | END |
| 115 | | MENUITEM SEPARATOR |
| 116 | | MENUITEM "L&arge Icons", ID_VIEW_LARGE_ICON |
| 117 | | MENUITEM "S&mall Icons", ID_VIEW_SMALL_ICON |
| 118 | | MENUITEM "&List", ID_VIEW_LIST_MENU |
| 119 | | MENUITEM "&Details", ID_VIEW_DETAIL |
| 120 | | MENUITEM "&Grouped", ID_VIEW_GROUPED |
| 121 | | MENUITEM SEPARATOR |
| 122 | | POPUP "Arrange &Icons" |
| 123 | | BEGIN |
| 124 | | MENUITEM "by &Name", ID_VIEW_BYGAME |
| 125 | | MENUITEM "by D&irectory", ID_VIEW_BYDIRECTORY |
| 126 | | MENUITEM "by &Manufacturer", ID_VIEW_BYMANUFACTURER |
| 127 | | MENUITEM "by Times &Played", ID_VIEW_BYTIMESPLAYED |
| 128 | | MENUITEM "by &Type", ID_VIEW_BYTYPE |
| 129 | | MENUITEM "by &Date", ID_VIEW_BYYEAR |
| 130 | | END |
| 131 | | MENUITEM "Line &Up Icons", ID_VIEW_LINEUPICONS |
| 132 | | MENUITEM SEPARATOR |
| 133 | | MENUITEM "&Refresh\tF5", ID_UPDATE_GAMELIST |
| 134 | | MENUITEM "&Custom Filters...\tCtrl+F", ID_CONTEXT_FILTERS |
| 135 | | MENUITEM "Customi&ze Fields...", ID_CUSTOMIZE_FIELDS |
| 136 | | END |
| 137 | | POPUP "&Options" |
| 138 | | BEGIN |
| 139 | | #ifdef MESS |
| 140 | | MENUITEM "System List &Font...", ID_OPTIONS_FONT |
| 141 | | MENUITEM "System List &Clone Color...", ID_OPTIONS_CLONE_COLOR |
| 142 | | MENUITEM "&Directories...", ID_OPTIONS_DIR |
| 143 | | MENUITEM "Default System &Options...", ID_OPTIONS_DEFAULTS |
| 144 | | #else |
| 145 | | MENUITEM "Game List &Font...", ID_OPTIONS_FONT |
| 146 | | MENUITEM "Game List &Clone Color...", ID_OPTIONS_CLONE_COLOR |
| 147 | | MENUITEM "&Directories...", ID_OPTIONS_DIR |
| 148 | | MENUITEM "Default Game &Options...", ID_OPTIONS_DEFAULTS |
| 149 | | #endif |
| 150 | | MENUITEM "&Reset to Default...", ID_OPTIONS_RESET_DEFAULTS |
| 151 | | MENUITEM "&Interface Options...", ID_OPTIONS_INTERFACE |
| 152 | | MENUITEM "&Background Image...", ID_OPTIONS_BG |
| 153 | | END |
| 154 | | POPUP "&Help" |
| 155 | | BEGIN |
| 156 | | #ifdef MESS |
| 157 | | MENUITEM "&Mess Release Notes", ID_HELP_RELEASE |
| 158 | | MENUITEM "&New Mess Features", ID_HELP_WHATS_NEW |
| 159 | | #else |
| 160 | | MENUITEM "&Contents\tF1", ID_HELP_CONTENTS |
| 161 | | MENUITEM "&Troubleshooting", ID_HELP_TROUBLE |
| 162 | | MENUITEM SEPARATOR |
| 163 | | MENUITEM "&New Game Changes", ID_HELP_WHATS_NEW32 |
| 164 | | MENUITEM "&Mame Release Notes", ID_HELP_WHATS_NEW |
| 165 | | #endif |
| 166 | | MENUITEM SEPARATOR |
| 167 | | MENUITEM "&About", ID_HELP_ABOUT |
| 168 | | END |
| 169 | | END |
| 170 | | |
| 171 | | IDR_CONTEXT_MENU MENU DISCARDABLE |
| 172 | | BEGIN |
| 173 | | POPUP "Context Menu" |
| 174 | | BEGIN |
| 175 | | MENUITEM "&Play", ID_FILE_PLAY |
| 176 | | MENUITEM SEPARATOR |
| 177 | | MENUITEM "Play and &Record Input...", ID_FILE_PLAY_RECORD |
| 178 | | MENUITEM SEPARATOR |
| 179 | | MENUITEM "&Add to Custom Folder...", ID_CONTEXT_ADD_CUSTOM |
| 180 | | MENUITEM "R&emove From This Folder", ID_CONTEXT_REMOVE_CUSTOM |
| 181 | | MENUITEM "&Custom Filters...", ID_CONTEXT_FILTERS |
| 182 | | MENUITEM SEPARATOR |
| 183 | | #ifdef MESS |
| 184 | | MENUITEM "&Select Random System", ID_CONTEXT_SELECT_RANDOM |
| 185 | | #else |
| 186 | | MENUITEM "&Select Random Game", ID_CONTEXT_SELECT_RANDOM |
| 187 | | #endif |
| 188 | | MENUITEM SEPARATOR |
| 189 | | MENUITEM "Rese&t Playcount", ID_CONTEXT_RESET_PLAYCOUNT |
| 190 | | MENUITEM "Reset Pla&y Time", ID_CONTEXT_RESET_PLAYTIME |
| 191 | | MENUITEM SEPARATOR |
| 192 | | MENUITEM "A&udit", ID_GAME_AUDIT |
| 193 | | MENUITEM SEPARATOR |
| 194 | | MENUITEM "Pr&operties", ID_GAME_PROPERTIES |
| 195 | | MENUITEM "Source propert&ies", ID_FOLDER_SOURCEPROPERTIES |
| 196 | | MENUITEM "&Vector properties", ID_FOLDER_VECTORPROPERTIES |
| 197 | | END |
| 198 | | END |
| 199 | | |
| 200 | | IDR_CONTEXT_HEADER MENU DISCARDABLE |
| 201 | | BEGIN |
| 202 | | POPUP "Header Context Menu" |
| 203 | | BEGIN |
| 204 | | MENUITEM "Sort &Ascending", ID_SORT_ASCENDING |
| 205 | | MENUITEM "Sort &Descending", ID_SORT_DESCENDING |
| 206 | | MENUITEM SEPARATOR |
| 207 | | MENUITEM "Customi&ze Fields...", ID_CUSTOMIZE_FIELDS |
| 208 | | END |
| 209 | | END |
| 210 | | |
| 211 | | IDR_CONTEXT_TREE MENU DISCARDABLE |
| 212 | | BEGIN |
| 213 | | POPUP "Context Menu Tree" |
| 214 | | BEGIN |
| 215 | | MENUITEM "&Rename", ID_CONTEXT_RENAME_CUSTOM |
| 216 | | MENUITEM "&Custom Filters...", ID_CONTEXT_FILTERS |
| 217 | | MENUITEM SEPARATOR |
| 218 | | POPUP "&Show Folders" |
| 219 | | BEGIN |
| 220 | | MENUITEM "overridden by code", ID_CONTEXT_SHOW_FOLDER_START |
| 221 | | |
| 222 | | END |
| 223 | | MENUITEM SEPARATOR |
| 224 | | MENUITEM "&Audit", ID_FOLDER_AUDIT |
| 225 | | MENUITEM SEPARATOR |
| 226 | | MENUITEM "&Properties", ID_FOLDER_PROPERTIES |
| 227 | | END |
| 228 | | END |
| 229 | | |
| 230 | | IDR_CONTEXT_SCREENSHOT MENU DISCARDABLE |
| 231 | | BEGIN |
| 232 | | POPUP "Context Screen Shot" |
| 233 | | BEGIN |
| 234 | | MENUITEM "Show Tab &Control", ID_VIEW_PAGETAB |
| 235 | | MENUITEM SEPARATOR |
| 236 | | POPUP "S&how Pictures" |
| 237 | | BEGIN |
| 238 | | MENUITEM "&Snapshot", ID_TOGGLE_TAB_SCREENSHOT |
| 239 | | MENUITEM "&Flyer", ID_TOGGLE_TAB_FLYER |
| 240 | | MENUITEM "&Cabinet", ID_TOGGLE_TAB_CABINET |
| 241 | | MENUITEM "&Marquee", ID_TOGGLE_TAB_MARQUEE |
| 242 | | MENUITEM "&Title", ID_TOGGLE_TAB_TITLE |
| 243 | | MENUITEM "Control &Panel", ID_TOGGLE_TAB_CONTROL_PANEL |
| 244 | | |
| 245 | | MENUITEM "&History", ID_TOGGLE_TAB_HISTORY |
| 246 | | END |
| 247 | | MENUITEM SEPARATOR |
| 248 | | MENUITEM "&Snapshot", ID_VIEW_TAB_SCREENSHOT |
| 249 | | MENUITEM "&Flyer", ID_VIEW_TAB_FLYER |
| 250 | | MENUITEM "&Cabinet", ID_VIEW_TAB_CABINET |
| 251 | | MENUITEM "&Marquee", ID_VIEW_TAB_MARQUEE |
| 252 | | MENUITEM "&Title", ID_VIEW_TAB_TITLE |
| 253 | | MENUITEM "Control &Panel", ID_VIEW_TAB_CONTROL_PANEL |
| 254 | | MENUITEM "&History", ID_VIEW_TAB_HISTORY |
| 255 | | END |
| 256 | | END |
| 257 | | |
| 258 | | |
| 259 | | #ifdef APSTUDIO_INVOKED |
| 260 | | ///////////////////////////////////////////////////////////////////////////// |
| 261 | | // |
| 262 | | // TEXTINCLUDE |
| 263 | | // |
| 264 | | |
| 265 | | 1 TEXTINCLUDE MOVEABLE PURE |
| 266 | | BEGIN |
| 267 | | "resource.h\0" |
| 268 | | END |
| 269 | | |
| 270 | | 2 TEXTINCLUDE MOVEABLE PURE |
| 271 | | BEGIN |
| 272 | | "#define NOWINRES\r\n" |
| 273 | | "#include ""windows.h""\r\n" |
| 274 | | "#include ""commctrl.h""\r\n" |
| 275 | | "\0" |
| 276 | | END |
| 277 | | |
| 278 | | 3 TEXTINCLUDE MOVEABLE PURE |
| 279 | | BEGIN |
| 280 | | "\r\n" |
| 281 | | "\0" |
| 282 | | END |
| 283 | | |
| 284 | | #endif // APSTUDIO_INVOKED |
| 285 | | |
| 286 | | |
| 287 | | #ifndef _MAC |
| 288 | | ///////////////////////////////////////////////////////////////////////////// |
| 289 | | // |
| 290 | | // Version |
| 291 | | // |
| 292 | | |
| 293 | | VS_VERSION_INFO VERSIONINFO |
| 294 | | FILEVERSION 0,119,0,0 |
| 295 | | PRODUCTVERSION 0,119,0,0 |
| 296 | | FILEFLAGSMASK 0x3fL |
| 297 | | #ifdef _DEBUG |
| 298 | | FILEFLAGS 0x1L |
| 299 | | #else |
| 300 | | FILEFLAGS 0x0L |
| 301 | | #endif |
| 302 | | FILEOS 0x40004L |
| 303 | | FILETYPE 0x1L |
| 304 | | FILESUBTYPE 0x0L |
| 305 | | BEGIN |
| 306 | | BLOCK "StringFileInfo" |
| 307 | | BEGIN |
| 308 | | BLOCK "040904b0" |
| 309 | | BEGIN |
| 310 | | #ifdef MESS |
| 311 | | VALUE "Author", "Michael Soderstrom and Christopher Kirmse\0" |
| 312 | | VALUE "Comments", "Multiple Emulation Super System for Win32\0" |
| 313 | | VALUE "CompanyName", "MESS Team\0" |
| 314 | | VALUE "FileDescription", "Multiple Emulation Super System for Win32\0" |
| 315 | | #else |
| 316 | | VALUE "Author", "Christopher Kirmse and Michael Soderstrom" |
| 317 | | VALUE "Comments", "Multiple Arcade Machine Emulator for Win32" |
| 318 | | VALUE "CompanyName", "MAME Team" |
| 319 | | VALUE "FileDescription", "Multiple Arcade Machine Emulator for Win32" |
| 320 | | #endif |
| 321 | | VALUE "FileVersion", "0, 119, 0, 0" |
| 322 | | VALUE "InternalName", "MAME32" |
| 323 | | VALUE "LegalCopyright", "Copyright 1997-2007 Nicola Salmoria and the MAME team" |
| 324 | | #ifdef MESS |
| 325 | | VALUE "OriginalFilename", "MESS.exe\0" |
| 326 | | VALUE "ProductName", "MESS\0" |
| 327 | | #else |
| 328 | | VALUE "OriginalFilename", "MAME32.exe\0" |
| 329 | | VALUE "ProductName", "MAME32" |
| 330 | | #endif |
| 331 | | VALUE "ProductVersion", "0, 119, 0, 0" |
| 332 | | END |
| 333 | | END |
| 334 | | BLOCK "VarFileInfo" |
| 335 | | BEGIN |
| 336 | | VALUE "Translation", 0x409, 1200 |
| 337 | | END |
| 338 | | END |
| 339 | | |
| 340 | | #endif // !_MAC |
| 341 | | |
| 342 | | |
| 343 | | ///////////////////////////////////////////////////////////////////////////// |
| 344 | | // |
| 345 | | // Icon |
| 346 | | // |
| 347 | | |
| 348 | | // Icon with lowest ID value placed first to ensure application icon |
| 349 | | // remains consistent on all systems. |
| 350 | | #ifdef MESS |
| 351 | | IDI_MAME32_ICON ICON "res/mess.ico" |
| 352 | | #else |
| 353 | | IDI_MAME32_ICON ICON DISCARDABLE "res\\mame32.ico" |
| 354 | | #endif |
| 355 | | IDI_WIN_ROMS ICON DISCARDABLE "res\\win_roms.ico" |
| 356 | | IDI_WIN_NOROMS ICON DISCARDABLE "res\\win_noro.ico" |
| 357 | | IDI_WIN_UNKNOWN ICON DISCARDABLE "res\\win_unkn.ico" |
| 358 | | IDI_WIN_CLONE ICON DISCARDABLE "res\\win_clone.ico" |
| 359 | | IDI_WIN_REDX ICON DISCARDABLE "res/win_redx.ico" |
| 360 | | IDI_FOLDER_AVAILABLE ICON DISCARDABLE "res\\foldavail.ico" |
| 361 | | IDI_FOLDER ICON DISCARDABLE "res\\folder.ico" |
| 362 | | IDI_FOLDER_MANUFACTURER ICON DISCARDABLE "res\\foldmanu.ico" |
| 363 | | IDI_FOLDER_OPEN ICON DISCARDABLE "res\\foldopen.ico" |
| 364 | | IDI_FOLDER_UNAVAILABLE ICON DISCARDABLE "res\\foldunav.ico" |
| 365 | | IDI_MANUFACTURER ICON DISCARDABLE "res\\manufact.ico" |
| 366 | | IDI_FOLDER_YEAR ICON DISCARDABLE "res\\foldyear.ico" |
| 367 | | IDI_FOLDER_SOURCE ICON DISCARDABLE "Res\\foldsrc.ico" |
| 368 | | IDI_WORKING ICON DISCARDABLE "res\\working.ico" |
| 369 | | IDI_NONWORKING ICON DISCARDABLE "res\\nonwork.ico" |
| 370 | | IDI_YEAR ICON DISCARDABLE "res\\year.ico" |
| 371 | | IDI_KEYBOARD ICON DISCARDABLE "Res\\keyboard.ico" |
| 372 | | IDI_JOYSTICK ICON DISCARDABLE "Res\\joystick.ico" |
| 373 | | IDI_CPU ICON DISCARDABLE "Res\\cpu.ico" |
| 374 | | IDI_SOUND ICON DISCARDABLE "Res\\samples.ico" |
| 375 | | IDI_SOUNDTAB ICON DISCARDABLE "res\\sound.ico" |
| 376 | | IDI_SOURCE ICON DISCARDABLE "res\\source.ico" |
| 377 | | IDI_HARDDISK ICON DISCARDABLE "res\\harddisk.ico" |
| 378 | | IDI_DISPLAY ICON DISCARDABLE "Res\\display.ico" |
| 379 | | IDI_CHECKMARK ICON DISCARDABLE "Res\\checkmark.ico" |
| 380 | | IDI_HEADER_UP ICON DISCARDABLE "res\\header_up.ico" |
| 381 | | IDI_HEADER_DOWN ICON DISCARDABLE "res\\header_down.ico" |
| 382 | | |
| 383 | | #ifdef MESS |
| 384 | | IDI_WIN_NOROMSNEEDED ICON "res/win_nrnd.ico" |
| 385 | | IDI_WIN_MISSINGOPTROM ICON "res/win_noor.ico" |
| 386 | | IDI_WIN_FLOP ICON DISCARDABLE "res/win_flop.ico" |
| 387 | | IDI_WIN_CASS ICON DISCARDABLE "res/win_cass.ico" |
| 388 | | IDI_WIN_SERL ICON DISCARDABLE "res/win_serl.ico" |
| 389 | | IDI_WIN_SNAP ICON DISCARDABLE "res/win_snap.ico" |
| 390 | | IDI_WIN_PRIN ICON DISCARDABLE "res/win_prin.ico" |
| 391 | | IDI_WIN_HARD ICON DISCARDABLE "res/win_hard.ico" |
| 392 | | IDI_WIN_CYLN ICON DISCARDABLE "res/win_cyln.ico" |
| 393 | | IDI_WIN_PTAP ICON DISCARDABLE "res/win_ptap.ico" |
| 394 | | IDI_WIN_PCRD ICON DISCARDABLE "res/win_pcrd.ico" |
| 395 | | |
| 396 | | #endif |
| 397 | | |
| 398 | | ///////////////////////////////////////////////////////////////////////////// |
| 399 | | // |
| 400 | | // Dialog |
| 401 | | // |
| 402 | | |
| 403 | | IDD_ABOUT DIALOG DISCARDABLE 0, 0, 296, 129 |
| 404 | | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU |
| 405 | | #ifdef MESS |
| 406 | | CAPTION "About MESS" |
| 407 | | #else |
| 408 | | CAPTION "About MAME32" |
| 409 | | #endif |
| 410 | | FONT 8, "MS Shell Dlg" |
| 411 | | BEGIN |
| 412 | | DEFPUSHBUTTON "&OK",IDOK,200,109,50,14,WS_GROUP |
| 413 | | #ifdef MESS |
| 414 | | CTEXT "Multi Emulator Super System",IDC_STATIC,147,7,142, |
| 415 | | 11,NOT WS_GROUP |
| 416 | | CTEXT "Version 0",IDC_VERSION,147,18,142,11,NOT WS_GROUP |
| 417 | | CTEXT "Copyright (C) 1998-2005 The MESS Team",IDC_STATIC,147, |
| 418 | | 29,142,10,NOT WS_GROUP |
| 419 | | CTEXT "MESS GUI based on MAME32 version by",IDC_STATIC,147,51,142,10,NOT |
| 420 | | WS_GROUP |
| 421 | | CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,147,44,142,1 |
| 422 | | CTEXT "Additional MAME32 code by",IDC_STATIC,147,74,142,9 |
| 423 | | CTEXT "Robert Schlabbach, Dan Miller (Help file)",IDC_STATIC, |
| 424 | | 147,96,142,9 |
| 425 | | CTEXT "Michael Soderstrom and Christopher Kirmse",IDC_STATIC, |
| 426 | | 147,62,142,9,NOT WS_GROUP |
| 427 | | CTEXT "Mike Haaland, Andrew Kirmse, Jeff Miller",IDC_STATIC, |
| 428 | | 147,85,142,9 |
| 429 | | #else |
| 430 | | CTEXT "Multiple Arcade Machine Emulator",IDC_STATIC,147,7,142, |
| 431 | | 11,NOT WS_GROUP |
| 432 | | CTEXT "Version 0",IDC_VERSION,147,18,142,11,NOT WS_GROUP |
| 433 | | CTEXT "Copyright (C) 1997-2005 The MAME Team",IDC_STATIC,147, |
| 434 | | 29,142,10,NOT WS_GROUP |
| 435 | | CTEXT "MAME32 version by",IDC_STATIC,147,51,142,10,NOT |
| 436 | | WS_GROUP |
| 437 | | CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,147,44,142,1 |
| 438 | | CTEXT "Additional MAME32 code by",IDC_STATIC,147,74,142,9 |
| 439 | | CTEXT "Christopher Kirmse and Michael Soderstrom",IDC_STATIC, |
| 440 | | 147,62,142,9,NOT WS_GROUP |
| 441 | | CTEXT "Mike Haaland, Andrew Kirmse, Jeff Miller",IDC_STATIC, |
| 442 | | 147,85,142,9 |
| 443 | | CTEXT "and John Hardy IV",IDC_STATIC,147,96,142,9 |
| 444 | | #endif |
| 445 | | CONTROL "",IDC_ABOUT,"Static",SS_BITMAP | SS_SUNKEN,7,7,16,14 |
| 446 | | END |
| 447 | | |
| 448 | | IDD_DIRECTX DIALOG DISCARDABLE 0, 0, 236, 69 |
| 449 | | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU |
| 450 | | #ifdef MESS |
| 451 | | CAPTION "MESS" |
| 452 | | #else |
| 453 | | CAPTION "MAME32" |
| 454 | | #endif |
| 455 | | FONT 8, "MS Shell Dlg" |
| 456 | | BEGIN |
| 457 | | DEFPUSHBUTTON "Go to Microsoft's DirectX Web Page",IDB_WEB_PAGE,48,52, |
| 458 | | 140,14 |
| 459 | | EDITTEXT IDC_DIRECTX_HELP,7,0,222,48,ES_MULTILINE | |
| 460 | | ES_AUTOHSCROLL | ES_READONLY |
| 461 | | END |
| 462 | | |
| 463 | | IDD_AUDIT DIALOG DISCARDABLE 0, 0, 283, 188 |
| 464 | | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU |
| 465 | | CAPTION "File Audit" |
| 466 | | FONT 8, "MS Shell Dlg" |
| 467 | | BEGIN |
| 468 | | PUSHBUTTON "&Pause",IDPAUSE,98,168,40,14 |
| 469 | | PUSHBUTTON "&Cancel",IDCANCEL,144,168,40,14 |
| 470 | | GROUPBOX "ROMs",IDC_STATIC,6,4,132,65 |
| 471 | | LTEXT "Correct:",IDC_STATIC,51,28,32,8 |
| 472 | | CONTROL "Progress1",IDC_ROMS_PROGRESS,"msctls_progress32", |
| 473 | | PBS_SMOOTH | WS_BORDER,14,16,116,8 |
| 474 | | LTEXT "Incorrect:",IDC_STATIC,51,42,32,8 |
| 475 | | LTEXT "Total:",IDC_STATIC,51,56,32,8 |
| 476 | | LTEXT "0",IDC_ROMS_CORRECT,87,28,20,8 |
| 477 | | LTEXT "0",IDC_ROMS_INCORRECT,87,42,20,8 |
| 478 | | LTEXT "0",IDC_ROMS_TOTAL,87,56,20,8 |
| 479 | | GROUPBOX "Samples",IDC_STATIC,145,4,132,65 |
| 480 | | CONTROL "Progress1",IDC_SAMPLES_PROGRESS,"msctls_progress32", |
| 481 | | PBS_SMOOTH | WS_BORDER,153,16,116,8 |
| 482 | | LTEXT "Correct:",IDC_STATIC,191,28,33,8 |
| 483 | | LTEXT "Incorrect:",IDC_STATIC,191,42,33,8 |
| 484 | | LTEXT "Total:",IDC_STATIC,191,56,33,8 |
| 485 | | LTEXT "0",IDC_SAMPLES_CORRECT,227,28,20,8 |
| 486 | | LTEXT "0",IDC_SAMPLES_INCORRECT,227,42,20,8 |
| 487 | | LTEXT "0",IDC_SAMPLES_TOTAL,227,56,20,8 |
| 488 | | GROUPBOX "Details",IDC_STATIC,6,72,271,90 |
| 489 | | EDITTEXT IDC_AUDIT_DETAILS,12,82,259,74,ES_MULTILINE | |
| 490 | | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_HSCROLL | |
| 491 | | NOT WS_TABSTOP |
| 492 | | END |
| 493 | | |
| 494 | | IDD_DIRECTORIES DIALOG DISCARDABLE 0, 0, 230, 107 |
| 495 | | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU |
| 496 | | CAPTION "Directories" |
| 497 | | FONT 8, "MS Shell Dlg" |
| 498 | | BEGIN |
| 499 | | LTEXT "Show directories for:",IDC_STATIC,6,6,67,10 |
| 500 | | COMBOBOX IDC_DIR_COMBO,6,18,160,79,CBS_DROPDOWNLIST | CBS_SORT | |
| 501 | | WS_VSCROLL | WS_TABSTOP |
| 502 | | LTEXT "Directories:",IDC_STATIC,6,38,38,10 |
| 503 | | CONTROL "List1",IDC_DIR_LIST,"SysListView32",LVS_REPORT | |
| 504 | | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_EDITLABELS | |
| 505 | | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | WS_BORDER | |
| 506 | | WS_TABSTOP,6,50,160,51 |
| 507 | | DEFPUSHBUTTON "OK",IDOK,173,8,50,14 |
| 508 | | PUSHBUTTON "Cancel",IDCANCEL,173,26,50,14 |
| 509 | | PUSHBUTTON "Browse...",IDC_DIR_BROWSE,173,50,50,14 |
| 510 | | PUSHBUTTON "Insert",IDC_DIR_INSERT,173,68,50,14 |
| 511 | | PUSHBUTTON "Delete",IDC_DIR_DELETE,173,87,50,14 |
| 512 | | END |
| 513 | | |
| 514 | | IDD_COLUMNS DIALOG DISCARDABLE 0, 0, 302, 145 |
| 515 | | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU |
| 516 | | CAPTION "Customize Fields" |
| 517 | | FONT 8, "MS Shell Dlg" |
| 518 | | BEGIN |
| 519 | | LTEXT "Available fields:",IDC_STATIC,6,6,80,10,SS_CENTERIMAGE |
| 520 | | CONTROL "List1",IDC_LISTAVAILABLECOLUMNS,"SysListView32", |
| 521 | | LVS_LIST | LVS_SINGLESEL | LVS_NOCOLUMNHEADER | |
| 522 | | LVS_NOSORTHEADER | WS_BORDER | WS_HSCROLL | WS_TABSTOP,6, |
| 523 | | 18,90,100 |
| 524 | | PUSHBUTTON "Add ->",IDC_BUTTONADD,102,18,46,14,WS_DISABLED |
| 525 | | PUSHBUTTON "<- Remove",IDC_BUTTONREMOVE,102,36,46,14,WS_DISABLED |
| 526 | | LTEXT "Show these fields in this order:",IDC_STATIC,154,6,96, |
| 527 | | 10,SS_CENTERIMAGE |
| 528 | | CONTROL "List1",IDC_LISTSHOWCOLUMNS,"SysListView32",LVS_LIST | |
| 529 | | LVS_SINGLESEL | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | |
| 530 | | WS_BORDER | WS_HSCROLL | WS_TABSTOP,154,18,90,100 |
| 531 | | PUSHBUTTON "Move Up",IDC_BUTTONMOVEUP,250,18,46,14,WS_DISABLED |
| 532 | | PUSHBUTTON "Move Down",IDC_BUTTONMOVEDOWN,250,36,46,14,WS_DISABLED |
| 533 | | DEFPUSHBUTTON "OK",IDOK,105,124,44,14 |
| 534 | | PUSHBUTTON "Cancel",IDCANCEL,155,124,44,14 |
| 535 | | END |
| 536 | | |
| 537 | | IDD_PROP_GAME DIALOG DISCARDABLE 0, 0, 220, 240 |
| 538 | | STYLE WS_CHILD | WS_CAPTION |
| 539 | | CAPTION "General" |
| 540 | | FONT 8, "MS Shell Dlg" |
| 541 | | BEGIN |
| 542 | | ICON IDI_MAME32_ICON,IDC_GAME_ICON,20,10,20,20 |
| 543 | | LTEXT "Title\nDirectory\nExtra",IDC_PROP_TITLE,52,9,161,25, |
| 544 | | SS_NOPREFIX |
| 545 | | CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,20,38,178,1 |
| 546 | | LTEXT "Manufactured:",IDC_STATIC,18,45,47,8 |
| 547 | | LTEXT "Static",IDC_PROP_MANUFACTURED,75,45,139,9,SS_NOPREFIX |
| 548 | | LTEXT "Status:",IDC_STATIC,18,55,47,8 |
| 549 | | LTEXT "Static",IDC_PROP_STATUS,75,55,139,30 |
| 550 | | CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,18,85,178,1 |
| 551 | | LTEXT "CPU:",IDC_STATIC,18,90,47,8 |
| 552 | | LTEXT "Static\nStatic\nStatic\nStatic\nStatic",IDC_PROP_CPU,75, |
| 553 | | 90,139,40 |
| 554 | | CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,18,130,178,1 |
| 555 | | LTEXT "Sound:",IDC_STATIC,18,135,47,8 |
| 556 | | LTEXT "Static\nStatic\nStatic\nStatic\nStatic",IDC_PROP_SOUND, |
| 557 | | 75,135,139,45 |
| 558 | | CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,18,181,178,1 |
| 559 | | LTEXT "Screen:",IDC_STATIC,18,188,47,8 |
| 560 | | LTEXT "Static",IDC_PROP_SCREEN,75,188,139,8 |
| 561 | | LTEXT "Colors:",IDC_STATIC,18,198,47,8 |
| 562 | | LTEXT "Static",IDC_PROP_COLORS,75,198,139,8 |
| 563 | | LTEXT "Clone of:",IDC_PROP_CLONEOF_TEXT,18,218,50,8 |
| 564 | | LTEXT "Static",IDC_PROP_CLONEOF,75,218,130,18 |
| 565 | | LTEXT "Source:",IDC_STATIC,18,208,47,8 |
| 566 | | LTEXT "Static",IDC_PROP_SOURCE,75,208,139,8 |
| 567 | | END |
| 568 | | |
| 569 | | IDD_PROP_AUDIT DIALOG DISCARDABLE 0, 0, 220, 240 |
| 570 | | STYLE WS_CHILD | WS_CAPTION |
| 571 | | CAPTION "Audit" |
| 572 | | FONT 8, "MS Shell Dlg" |
| 573 | | BEGIN |
| 574 | | ICON IDI_CHECKMARK,IDC_STATIC,20,10,20,20 |
| 575 | | LTEXT "Title\nDirectory\nExtra",IDC_PROP_TITLE,52,9,161,25, |
| 576 | | SS_NOPREFIX |
| 577 | | LTEXT "ROM check:",IDC_STATIC,10,40,50,8 |
| 578 | | LTEXT "Checking...",IDC_PROP_ROMS,66,40,139,8 |
| 579 | | LTEXT "Sample check:",IDC_STATIC,10,52,50,8 |
| 580 | | LTEXT "Checking...",IDC_PROP_SAMPLES,66,52,139,8 |
| 581 | | GROUPBOX "Details",IDC_STATIC,4,64,211,171 |
| 582 | | EDITTEXT IDC_AUDIT_DETAILS_PROP,10,74,199,155,ES_MULTILINE | |
| 583 | | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_HSCROLL | |
| 584 | | NOT WS_TABSTOP |
| 585 | | END |
| 586 | | |
| 587 | | IDD_PROP_DISPLAY DIALOGEX 0, 0, 220, 240 |
| 588 | | STYLE WS_CHILD | WS_CAPTION |
| 589 | | CAPTION "Display" |
| 590 | | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 591 | | BEGIN |
| 592 | | ICON IDI_DISPLAY,IDC_STATIC,20,10,20,20 |
| 593 | | LTEXT "Title\nDirectory\nExtra",IDC_PROP_TITLE,52,9,169,25, |
| 594 | | SS_NOPREFIX |
| 595 | | CONTROL "Run in a window",IDC_WINDOWED,"Button",BS_AUTOCHECKBOX | |
| 596 | | WS_TABSTOP,10,40,69,10,0,HIDC_WINDOWED |
| 597 | | CONTROL "Start out maximized",IDC_MAXIMIZE,"Button", |
| 598 | | BS_AUTOCHECKBOX | WS_TABSTOP,10,52,74,10,0,HIDC_MAXIMIZE |
| 599 | | CONTROL "Enforce aspect ratio",IDC_KEEPASPECT,"Button", |
| 600 | | BS_AUTOCHECKBOX | WS_TABSTOP,10,64,77,10,0, |
| 601 | | HIDC_KEEPASPECT |
| 602 | | CONTROL "Throttle",IDC_THROTTLE,"Button",BS_AUTOCHECKBOX | |
| 603 | | WS_TABSTOP,10,76,39,10,0,HIDC_THROTTLE |
| 604 | | GROUPBOX "Bitmap prescaling",IDC_STATIC,4,89,103,24 |
| 605 | | CONTROL "GammaSlider",IDC_PRESCALE,"msctls_trackbar32",TBS_BOTH | |
| 606 | | TBS_NOTICKS | WS_TABSTOP,10,99,71,10,0,HIDC_PRESCALE |
| 607 | | RTEXT "1.00",IDC_PRESCALEDISP,84,98,14,11,SS_CENTERIMAGE | NOT |
| 608 | | WS_GROUP |
| 609 | | GROUPBOX "Gamma Correction",IDC_STATIC,4,115,103,24 |
| 610 | | CONTROL "GammaSlider",IDC_GAMMA,"msctls_trackbar32",TBS_BOTH | |
| 611 | | TBS_NOTICKS | WS_TABSTOP,10,125,71,10,0,HIDC_GAMMA |
| 612 | | RTEXT "2.00",IDC_GAMMADISP,84,124,14,10,SS_CENTERIMAGE | NOT |
| 613 | | WS_GROUP |
| 614 | | GROUPBOX "Brightness Correction",IDC_STATIC,4,141,103,24 |
| 615 | | CONTROL "GammaSlider",IDC_BRIGHTCORRECT,"msctls_trackbar32", |
| 616 | | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,10,151,71,10,0, |
| 617 | | HIDC_BRIGHTCORRECT |
| 618 | | RTEXT "1.00",IDC_BRIGHTCORRECTDISP,84,150,14,10,SS_CENTERIMAGE | |
| 619 | | NOT WS_GROUP |
| 620 | | GROUPBOX "Contrast Correction",IDC_STATIC,4,167,103,24 |
| 621 | | CONTROL "GammaSlider",IDC_CONTRAST,"msctls_trackbar32",TBS_BOTH | |
| 622 | | TBS_NOTICKS | WS_TABSTOP,10,176,71,10,0,HIDC_CONTRAST |
| 623 | | RTEXT "1.00",IDC_CONTRASTDISP,84,175,14,11,SS_CENTERIMAGE | |
| 624 | | NOT WS_GROUP |
| 625 | | GROUPBOX "Pause Brightness",IDC_STATIC,4,193,103,24 |
| 626 | | CONTROL "Slider1",IDC_PAUSEBRIGHT,"msctls_trackbar32",TBS_BOTH | |
| 627 | | TBS_NOTICKS | WS_TABSTOP,10,203,71,10,0,HIDC_PAUSEBRIGHT |
| 628 | | RTEXT "0.65",IDC_PAUSEBRIGHTDISP,84,202,14,11,SS_CENTERIMAGE | |
| 629 | | NOT WS_GROUP |
| 630 | | GROUPBOX "Videomode",IDC_STATIC,113,40,102,28 |
| 631 | | COMBOBOX IDC_VIDEO_MODE,119,50,90,50,CBS_DROPDOWNLIST | CBS_SORT | |
| 632 | | WS_VSCROLL | WS_TABSTOP,0,HIDC_VIDEO_MODE |
| 633 | | GROUPBOX "Rotation",IDC_STATIC,113,71,102,55 |
| 634 | | COMBOBOX IDC_ROTATE,119,81,90,57,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 635 | | WS_TABSTOP,0,HIDC_ROTATE |
| 636 | | CONTROL "Flip screen upside-down",IDC_FLIPY,"Button", |
| 637 | | BS_AUTOCHECKBOX | WS_TABSTOP,119,98,91,10,0,HIDC_FLIPY |
| 638 | | CONTROL "Flip screen left-right",IDC_FLIPX,"Button", |
| 639 | | BS_AUTOCHECKBOX | WS_TABSTOP,119,110,77,10,0,HIDC_FLIPX |
| 640 | | GROUPBOX "Direct3D",IDC_STATIC,113,128,102,57 |
| 641 | | CONTROL "Use Bilinear filtering",IDC_D3D_FILTER,"Button", |
| 642 | | BS_AUTOCHECKBOX | WS_TABSTOP,119,138,85,10,0, |
| 643 | | HIDC_D3D_FILTER |
| 644 | | GROUPBOX "Version",IDC_STATIC,119,150,90,28 |
| 645 | | COMBOBOX IDC_D3D_VERSION,125,160,78,95,CBS_DROPDOWNLIST | |
| 646 | | WS_VSCROLL | WS_TABSTOP,0,HIDC_D3D_VERSION |
| 647 | | GROUPBOX "DirectDraw",IDC_STATIC,113,187,102,26 |
| 648 | | CONTROL "Stretch using hardware",IDC_HWSTRETCH,"Button", |
| 649 | | BS_AUTOCHECKBOX | WS_TABSTOP,119,197,85,10,0, |
| 650 | | HIDC_HWSTRETCH |
| 651 | | PUSHBUTTON "Reset",IDC_PROP_RESET,4,222,97,14,0,0,HIDC_PROP_RESET |
| 652 | | PUSHBUTTON "Restore Default Settings",IDC_USE_DEFAULT,118,222,97,14, |
| 653 | | 0,0,HIDC_USE_DEFAULT |
| 654 | | END |
| 655 | | |
| 656 | | IDD_PROP_SOUND DIALOGEX 0, 0, 220, 240 |
| 657 | | STYLE WS_CHILD | WS_CAPTION |
| 658 | | CAPTION "Sound" |
| 659 | | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 660 | | BEGIN |
| 661 | | ICON IDI_SOUNDTAB,IDC_STATIC,20,10,20,20 |
| 662 | | LTEXT "Title\nDirectory\nExtra",IDC_PROP_TITLE,52,9,161,25, |
| 663 | | SS_NOPREFIX |
| 664 | | GROUPBOX "",IDC_STATIC,4,40,211,122 |
| 665 | | CONTROL "Enable sound and sound CPUs",IDC_USE_SOUND,"Button", |
| 666 | | BS_AUTOCHECKBOX | WS_TABSTOP,10,40,112,10,0, |
| 667 | | HIDC_USE_SOUND |
| 668 | | CONTROL "Use samples",IDC_SAMPLES,"Button",BS_AUTOCHECKBOX | |
| 669 | | WS_TABSTOP,10,52,55,10,0,HIDC_SAMPLES |
| 670 | | GROUPBOX "Sample rate",IDC_RATETEXT,60,65,100,28 |
| 671 | | COMBOBOX IDC_SAMPLERATE,66,75,88,60,CBS_DROPDOWNLIST | |
| 672 | | WS_VSCROLL | WS_TABSTOP,0, |
| 673 | | HIDC_SAMPLERATE |
| 674 | | GROUPBOX "Volume attenuation",IDC_STATIC,60,96,100,28 |
| 675 | | CONTROL "Slider1",IDC_VOLUME,"msctls_trackbar32",TBS_BOTH | |
| 676 | | TBS_NOTICKS | WS_TABSTOP,66,108,68,10,0,HIDC_VOLUME |
| 677 | | RTEXT "0dB",IDC_VOLUMEDISP,132,107,20,11,SS_CENTERIMAGE |
| 678 | | GROUPBOX "Audio latency",IDC_AUDIO_LATENCY_TEXT,60,127,100,28 |
| 679 | | CONTROL "Slider1",IDC_AUDIO_LATENCY,"msctls_trackbar32",TBS_BOTH | |
| 680 | | TBS_NOTICKS | WS_TABSTOP,66,139,68,10,0, |
| 681 | | HIDC_AUDIO_LATENCY |
| 682 | | RTEXT "1/5",IDC_AUDIO_LATENCY_DISP,132,138,20,11, |
| 683 | | SS_CENTERIMAGE |
| 684 | | PUSHBUTTON "Reset",IDC_PROP_RESET,4,222,97,14,0,0,HIDC_PROP_RESET |
| 685 | | PUSHBUTTON "Restore Default Settings",IDC_USE_DEFAULT,118,222,97,14, |
| 686 | | 0,0,HIDC_USE_DEFAULT |
| 687 | | END |
| 688 | | |
| 689 | | IDD_PROP_ADVANCED DIALOGEX 0, 0, 220, 240 |
| 690 | | STYLE WS_CHILD | WS_CAPTION |
| 691 | | CAPTION "Advanced" |
| 692 | | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 693 | | BEGIN |
| 694 | | ICON IDI_DISPLAY,IDC_STATIC,20,10,20,20 |
| 695 | | LTEXT "Title\nDirectory\nExtra",IDC_PROP_TITLE,52,9,161,25, |
| 696 | | SS_NOPREFIX |
| 697 | | CONTROL "Triple buffering",IDC_TRIPLE_BUFFER,"Button", |
| 698 | | BS_AUTOCHECKBOX | WS_TABSTOP,10,40,93,10,0, |
| 699 | | HIDC_TRIPLE_BUFFER |
| 700 | | CONTROL "Sync to monitor refresh",IDC_SYNCREFRESH,"Button", |
| 701 | | BS_AUTOCHECKBOX | WS_TABSTOP,10,52,93,10,0, |
| 702 | | HIDC_SYNCREFRESH |
| 703 | | CONTROL "Wait for vertical sync",IDC_WAITVSYNC,"Button", |
| 704 | | BS_AUTOCHECKBOX | WS_TABSTOP,10,64,93,10,0, |
| 705 | | HIDC_WAITVSYNC |
| 706 | | GROUPBOX "Frame skipping",IDC_STATIC,4,76,103,42 |
| 707 | | CONTROL "Automatic",IDC_AUTOFRAMESKIP,"Button",BS_AUTOCHECKBOX | |
| 708 | | WS_TABSTOP,10,86,77,10,0,HIDC_AUTOFRAMESKIP |
| 709 | | COMBOBOX IDC_FRAMESKIP,10,99,91,88,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 710 | | WS_TABSTOP,0,HIDC_FRAMESKIP |
| 711 | | GROUPBOX "Full screen gamma",IDC_FSGAMMATEXT,113,40,102,24 |
| 712 | | CONTROL "Slider1",IDC_FSGAMMA,"msctls_trackbar32",TBS_BOTH | |
| 713 | | TBS_NOTICKS | WS_TABSTOP,119,50,71,10,0,HIDC_FSGAMMA |
| 714 | | RTEXT "2.00",IDC_FSGAMMADISP,193,49,14,10,SS_CENTERIMAGE | NOT |
| 715 | | WS_GROUP |
| 716 | | GROUPBOX "Full screen brightness",IDC_FSBRIGHTNESSTEXT,113,67,102, |
| 717 | | 24 |
| 718 | | CONTROL "Slider1",IDC_FSBRIGHTNESS,"msctls_trackbar32",TBS_BOTH | |
| 719 | | TBS_NOTICKS | WS_TABSTOP,119,77,71,10,0, |
| 720 | | HIDC_FSBRIGHTNESS |
| 721 | | RTEXT "2.00",IDC_FSBRIGHTNESSDISP,193,76,14,10,SS_CENTERIMAGE | |
| 722 | | NOT WS_GROUP |
| 723 | | GROUPBOX "Full screen contrast",IDC_FSCONTRASTTEXT,113,94,102,24 |
| 724 | | CONTROL "Slider1",IDC_FSCONTRAST,"msctls_trackbar32",TBS_BOTH | |
| 725 | | TBS_NOTICKS | WS_TABSTOP,119,104,71,10,0,HIDC_FSCONTRAST |
| 726 | | RTEXT "2.00",IDC_FSCONTRASTDISP,193,103,14,11,SS_CENTERIMAGE | |
| 727 | | NOT WS_GROUP |
| 728 | | EDITTEXT IDC_EFFECT,10,123,200,14,ES_AUTOHSCROLL | WS_DISABLED |
| 729 | | PUSHBUTTON "Select Effect",IDC_SELECT_EFFECT,10,142,60,14,0,0, |
| 730 | | HIDC_SELECT_EFFECT |
| 731 | | PUSHBUTTON "Reset Effect",IDC_RESET_EFFECT,150,142,60,14,0,0, |
| 732 | | HIDC_RESET_EFFECT |
| 733 | | PUSHBUTTON "Reset",IDC_PROP_RESET,4,222,97,14,0,0,HIDC_PROP_RESET |
| 734 | | PUSHBUTTON "Restore Default Settings",IDC_USE_DEFAULT,118,222,97,14, |
| 735 | | 0,0,HIDC_USE_DEFAULT |
| 736 | | END |
| 737 | | |
| 738 | | IDD_PROP_INPUT DIALOGEX 0, 0, 220, 263 |
| 739 | | STYLE WS_CHILD | WS_CAPTION |
| 740 | | CAPTION "Controllers" |
| 741 | | FONT 8, "MS Shell Dlg" |
| 742 | | BEGIN |
| 743 | | ICON IDI_JOYSTICK,IDC_STATIC,20,10,21,20 |
| 744 | | LTEXT "Title\nDirectory\nExtra",IDC_PROP_TITLE,52,9,161,25, |
| 745 | | SS_NOPREFIX |
| 746 | | CONTROL "Enable mouse input",IDC_USE_MOUSE,"Button", |
| 747 | | BS_AUTOCHECKBOX | WS_TABSTOP,10,40,86,10,0, |
| 748 | | HIDC_USE_MOUSE |
| 749 | | CONTROL "Enable steadykey support",IDC_STEADYKEY,"Button", |
| 750 | | BS_AUTOCHECKBOX | WS_TABSTOP,10,52,95,10,0, |
| 751 | | HIDC_STEADYKEY |
| 752 | | GROUPBOX "",IDC_STATIC,4,64,103,74 |
| 753 | | CONTROL "Enable joystick input",IDC_JOYSTICK,"Button", |
| 754 | | BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,10,64,78,10,0, |
| 755 | | HIDC_JOYSTICK |
| 756 | | GROUPBOX "Joystick deadzone",IDC_JDZTEXT,10,76,91,28 |
| 757 | | CONTROL "IntensitySlider",IDC_JDZ,"msctls_trackbar32",TBS_BOTH | |
| 758 | | TBS_NOTICKS | WS_TABSTOP,15,88,60,10,0,HIDC_JDZ |
| 759 | | RTEXT "0.3",IDC_JDZDISP,76,87,16,11,SS_CENTERIMAGE | NOT |
| 760 | | WS_GROUP |
| 761 | | GROUPBOX "Default input layout",IDC_STATIC,113,40,102,28 |
| 762 | | COMBOBOX IDC_DEFAULT_INPUT,119,50,90,53,CBS_DROPDOWNLIST | |
| 763 | | WS_VSCROLL | WS_TABSTOP,0,HIDC_DEFAULT_INPUT |
| 764 | | GROUPBOX "",IDC_STATIC,113,71,102,66 |
| 765 | | CONTROL "Enable lightgun input",IDC_LIGHTGUN,"Button", |
| 766 | | BS_AUTOCHECKBOX | WS_TABSTOP,119,71,80,10,0, |
| 767 | | HIDC_LIGHTGUN |
| 768 | | CONTROL "Offscreen shots reload",IDC_RELOAD,"Button", |
| 769 | | BS_AUTOCHECKBOX | WS_TABSTOP,119,83,86,10,0,HIDC_RELOAD |
| 770 | | CONTROL "Dual lightguns",IDC_DUAL_LIGHTGUN,"Button", |
| 771 | | BS_AUTOCHECKBOX | WS_TABSTOP,119,96,86,10,0, |
| 772 | | HIDC_DUAL_LIGHTGUN |
| 773 | | CONTROL "Multiple keyboards",IDC_MULTIKEYBOARD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,119,109,75,10 |
| 774 | | CONTROL "Multiple mice",IDC_MULTIMOUSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,119,122,56,10 |
| 775 | | PUSHBUTTON "Reset",IDC_PROP_RESET,4,243,97,14,0,0,HIDC_PROP_RESET |
| 776 | | PUSHBUTTON "Restore Default Settings",IDC_USE_DEFAULT,118,243,97,14, |
| 777 | | 0,0,HIDC_USE_DEFAULT |
| 778 | | GROUPBOX "Joystick saturation",IDC_JSATTEXT,10,106,91,28 |
| 779 | | CONTROL "IntensitySlider",IDC_JSAT,"msctls_trackbar32",TBS_BOTH | |
| 780 | | TBS_NOTICKS | WS_TABSTOP,16,118,60,10,0,HIDC_JSAT |
| 781 | | RTEXT "0.85",IDC_JSATDISP,76,116,16,11,SS_CENTERIMAGE | NOT |
| 782 | | WS_GROUP |
| 783 | | END |
| 784 | | |
| 785 | | IDD_PROP_MISC DIALOGEX 0, 0, 220, 240 |
| 786 | | STYLE WS_CHILD | WS_CAPTION |
| 787 | | CAPTION "Miscellaneous" |
| 788 | | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 789 | | BEGIN |
| 790 | | ICON IDI_MAME32_ICON,IDC_STATIC,20,10,21,20 |
| 791 | | LTEXT "Title\nDirectory\nExtra",IDC_PROP_TITLE,52,9,161,25, |
| 792 | | SS_NOPREFIX |
| 793 | | #ifdef MESS |
| 794 | | CONTROL "Enable system cheats",IDC_CHEAT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,40,86,10,0,HIDC_CHEAT |
| 795 | | #else |
| 796 | | CONTROL "Enable game cheats",IDC_CHEAT,"Button",BS_AUTOCHECKBOX | |
| 797 | | WS_TABSTOP,10,40,86,10,0,HIDC_CHEAT |
| 798 | | #endif |
| 799 | | CONTROL "Error log (for developers)",IDC_LOG,"Button", |
| 800 | | BS_AUTOCHECKBOX | WS_TABSTOP,10,52,96,10,0,HIDC_LOG |
| 801 | | CONTROL "Sleep when possible",IDC_SLEEP,"Button",BS_AUTOCHECKBOX | |
| 802 | | WS_TABSTOP,10,64,86,10,0,HIDC_SLEEP |
| 803 | | #ifdef MESS |
| 804 | | CONTROL "Skip system info",IDC_SKIP_GAME_INFO,"Button", |
| 805 | | BS_AUTOCHECKBOX | WS_TABSTOP,10,88,96,10,0, |
| 806 | | HIDC_SKIP_GAME_INFO |
| 807 | | #else |
| 808 | | CONTROL "Skip game info",IDC_SKIP_GAME_INFO,"Button", |
| 809 | | BS_AUTOCHECKBOX | WS_TABSTOP,10,88,96,10,0, |
| 810 | | HIDC_SKIP_GAME_INFO |
| 811 | | #endif |
| 812 | | CONTROL "Save game state on exit",IDC_ENABLE_AUTOSAVE,"Button", |
| 813 | | BS_AUTOCHECKBOX | WS_TABSTOP,10,100,96,10,0, |
| 814 | | HIDC_ENABLE_AUTOSAVE |
| 815 | | CONTROL "Multi-threaded rendering",IDC_MULTITHREAD_RENDERING, |
| 816 | | "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,112,96,10,0, |
| 817 | | HIDC_MULTITHREAD_RENDERING |
| 818 | | GROUPBOX "Thread Priority",IDC_HIGH_PRIORITY_TEXT,4,124,103,34 |
| 819 | | CONTROL "Slider1",IDC_HIGH_PRIORITY,"msctls_trackbar32",TBS_BOTH | |
| 820 | | TBS_NOTICKS | WS_TABSTOP,10,135,75,10,0, |
| 821 | | HIDC_HIGH_PRIORITY |
| 822 | | LTEXT "idle",IDC_STATIC,13,144,12,8 |
| 823 | | RTEXT "-15",IDC_HIGH_PRIORITYTXT,84,134,14,10,SS_CENTERIMAGE |
| 824 | | RTEXT "real-time",IDC_STATIC,53,144,28,8 |
| 825 | | GROUPBOX "Artwork options",IDC_STATIC,113,40,102,61 |
| 826 | | CONTROL "Backdrops",IDC_BACKDROPS,"Button",BS_AUTOCHECKBOX | |
| 827 | | WS_TABSTOP,119,50,86,10,0,HIDC_BACKDROPS |
| 828 | | CONTROL "Bezels",IDC_BEZELS,"Button",BS_AUTOCHECKBOX | |
| 829 | | WS_TABSTOP,119,62,86,10,0,HIDC_BEZELS |
| 830 | | CONTROL "Overlays",IDC_OVERLAYS,"Button",BS_AUTOCHECKBOX | |
| 831 | | WS_TABSTOP,119,74,84,10,0,HIDC_OVERLAYS |
| 832 | | CONTROL "Crop artwork",IDC_ARTWORK_CROP,"Button",BS_AUTOCHECKBOX | |
| 833 | | WS_TABSTOP,119,86,53,10,0,HIDC_ARTWORK_CROP |
| 834 | | GROUPBOX "BIOS",IDC_STATIC,113,104,102,28 |
| 835 | | COMBOBOX IDC_BIOS,119,114,90,60,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 836 | | WS_TABSTOP,0,HIDC_BIOS |
| 837 | | PUSHBUTTON "Reset",IDC_PROP_RESET,4,222,97,14,0,0,HIDC_PROP_RESET |
| 838 | | PUSHBUTTON "Restore Default Settings",IDC_USE_DEFAULT,118,222,97,14, |
| 839 | | 0,0,HIDC_USE_DEFAULT |
| 840 | | #ifdef MESS |
| 841 | | CONTROL "Skip warnings",IDC_SKIP_WARNINGS,"Button", |
| 842 | | BS_AUTOCHECKBOX | WS_TABSTOP,10,180,86,10,0 |
| 843 | | CONTROL "Use New UI",IDC_USE_NEW_UI,"Button", |
| 844 | | BS_AUTOCHECKBOX | WS_TABSTOP,10,192,86,10,0 |
| 845 | | #endif |
| 846 | | END |
| 847 | | |
| 848 | | IDD_PROP_VECTOR DIALOGEX 0, 0, 220, 240 |
| 849 | | STYLE WS_CHILD | WS_CAPTION |
| 850 | | CAPTION "Vector" |
| 851 | | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 852 | | BEGIN |
| 853 | | ICON IDI_MAME32_ICON,IDC_STATIC,20,10,20,20 |
| 854 | | LTEXT "Title\nDirectory\nExtra",IDC_PROP_TITLE,52,9,161,25, |
| 855 | | SS_NOPREFIX |
| 856 | | CONTROL "Draw antialiased vectors",IDC_ANTIALIAS,"Button", |
| 857 | | BS_AUTOCHECKBOX | WS_TABSTOP,10,40,92,10,0, |
| 858 | | HIDC_ANTIALIAS |
| 859 | | GROUPBOX "Beam width",IDC_BEAMTEXT,60,53,100,28 |
| 860 | | CONTROL "BeamSlider",IDC_BEAM,"msctls_trackbar32",TBS_BOTH | |
| 861 | | TBS_NOTICKS | WS_TABSTOP,66,65,64,10,0,HIDC_BEAM |
| 862 | | RTEXT "16.00",IDC_BEAMDISP,132,64,20,11,SS_CENTERIMAGE |
| 863 | | GROUPBOX "Flicker",IDC_FLICKERTEXT,60,84,100,28 |
| 864 | | CONTROL "FlickerSlider",IDC_FLICKER,"msctls_trackbar32",TBS_BOTH | |
| 865 | | TBS_NOTICKS | WS_TABSTOP,66,96,64,10,0,HIDC_FLICKER |
| 866 | | RTEXT "100.00",IDC_FLICKERDISP,128,95,24,11,SS_CENTERIMAGE | |
| 867 | | NOT WS_GROUP |
| 868 | | PUSHBUTTON "Reset",IDC_PROP_RESET,4,222,97,14,0,0,HIDC_PROP_RESET |
| 869 | | PUSHBUTTON "Restore Default Settings",IDC_USE_DEFAULT,118,222,97,14, |
| 870 | | 0,0,HIDC_USE_DEFAULT |
| 871 | | END |
| 872 | | |
| 873 | | |
| 874 | | #ifdef MESS |
| 875 | | IDD_MAIN DIALOGEX 0, 0, 364, 206 |
| 876 | | #else |
| 877 | | IDD_MAIN DIALOGEX 0, 0, 304, 206 |
| 878 | | #endif |
| 879 | | STYLE DS_3DLOOK | DS_NOFAILCREATE | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | |
| 880 | | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME |
| 881 | | EXSTYLE WS_EX_CONTROLPARENT |
| 882 | | CAPTION "MAME32 - overwritten at runtime" |
| 883 | | CLASS "MainClass" |
| 884 | | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 885 | | BEGIN |
| 886 | | CONTROL "",IDC_DIVIDER,"Static",SS_ETCHEDHORZ,0,5,304,1 |
| 887 | | CONTROL "Tree1",IDC_TREE,"SysTreeView32",TVS_HASBUTTONS | |
| 888 | | TVS_HASLINES | TVS_LINESATROOT | TVS_EDITLABELS | |
| 889 | | TVS_SHOWSELALWAYS | TVS_FULLROWSELECT | WS_BORDER | |
| 890 | | WS_TABSTOP,5,28,48,172 |
| 891 | | CONTROL "List1",IDC_LIST,"SysListView32",LVS_REPORT | |
| 892 | | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_AUTOARRANGE | |
| 893 | | LVS_OWNERDRAWFIXED | WS_BORDER | WS_TABSTOP,65,28,42,172 |
| 894 | | GROUPBOX "",IDC_SPLITTER,55,28,8,172,BS_NOTIFY | NOT WS_VISIBLE |
| 895 | | GROUPBOX "",IDC_SPLITTER2,109,28,8,172,BS_NOTIFY | NOT WS_VISIBLE |
| 896 | | #ifdef MESS |
| 897 | | CONTROL "",IDC_SSTAB,"SysTabControl32",TCS_HOTTRACK,121,0,181,18 |
| 898 | | CONTROL "",IDC_SWTAB,"SysTabControl32",TCS_HOTTRACK,119,0,200,100 |
| 899 | | CONTROL "List2",IDC_SWLIST,"SysListView32",LVS_REPORT | |
| 900 | | LVS_SHOWSELALWAYS | LVS_OWNERDRAWFIXED | WS_BORDER | |
| 901 | | WS_TABSTOP,119,60,42,140 |
| 902 | | CONTROL "",IDC_SWDEVVIEW,"MessSoftwareDevView",WS_VISIBLE,119,0,200,100 |
| 903 | | GROUPBOX "",IDC_SPLITTER3,163,28,8,172,BS_NOTIFY | NOT WS_VISIBLE |
| 904 | | CONTROL "",IDC_SSFRAME,"Static",SS_ETCHEDFRAME,175,11,181,194 |
| 905 | | CONTROL "",IDC_SSPICTURE,"Static",SS_BITMAP | SS_NOTIFY | |
| 906 | | SS_CENTERIMAGE | NOT WS_VISIBLE,195,18,141,127 |
| 907 | | EDITTEXT IDC_HISTORY,183,150,167,49,ES_MULTILINE | ES_READONLY | |
| 908 | | WS_VSCROLL,WS_EX_STATICEDGE,HIDC_HISTORY |
| 909 | | #else |
| 910 | | CONTROL "",IDC_SSFRAME,"Static",SS_ETCHEDFRAME | SS_NOTIFY,121, |
| 911 | | 11,181,194 |
| 912 | | CONTROL "",IDC_SSTAB,"SysTabControl32",TCS_HOTTRACK,121,0,181,18 |
| 913 | | CONTROL "",IDC_SSPICTURE,"Static",SS_BITMAP | NOT WS_VISIBLE,141, |
| 914 | | 18,141,127 |
| 915 | | EDITTEXT IDC_HISTORY,129,150,167,49,ES_MULTILINE | ES_READONLY | |
| 916 | | NOT WS_BORDER | WS_VSCROLL | NOT WS_TABSTOP,0, |
| 917 | | HIDC_HISTORY |
| 918 | | #endif |
| 919 | | END |
| 920 | | |
| 921 | | IDD_FILTERS DIALOGEX 0, 0, 190, 182 |
| 922 | | STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_CAPTION | WS_SYSMENU |
| 923 | | EXSTYLE WS_EX_CONTEXTHELP |
| 924 | | #ifdef MESS |
| 925 | | CAPTION "System Filters" |
| 926 | | #else |
| 927 | | CAPTION "Game Filters" |
| 928 | | #endif |
| 929 | | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 930 | | BEGIN |
| 931 | | #ifdef MESS |
| 932 | | GROUPBOX "System filters",IDC_STATIC,6,4,178,85 |
| 933 | | #else |
| 934 | | GROUPBOX "Game filters",IDC_STATIC,6,4,178,85 |
| 935 | | #endif |
| 936 | | CONTROL "&Vector Graphics",IDC_FILTER_VECTOR,"Button", |
| 937 | | BS_AUTOCHECKBOX | WS_TABSTOP,14,16,70,10,0, |
| 938 | | HIDC_FILTER_VECTOR |
| 939 | | CONTROL "C&lones",IDC_FILTER_CLONES,"Button",BS_AUTOCHECKBOX | |
| 940 | | WS_TABSTOP,14,30,41,10,0,HIDC_FILTER_CLONES |
| 941 | | CONTROL "Non-Wor&king",IDC_FILTER_NONWORKING,"Button", |
| 942 | | BS_AUTOCHECKBOX | WS_TABSTOP,14,44,61,10,0, |
| 943 | | HIDC_FILTER_NONWORKING |
| 944 | | CONTROL "&Unavailable",IDC_FILTER_UNAVAILABLE,"Button", |
| 945 | | BS_AUTOCHECKBOX | WS_TABSTOP,14,58,57,10,0, |
| 946 | | HIDC_FILTER_UNAVAILABLE |
| 947 | | #ifdef MESS |
| 948 | | CONTROL "&Computers",IDC_FILTER_COMPUTER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,72,57,10,0,HIDC_FILTER_UNAVAILABLE |
| 949 | | CONTROL "C&onsoles",IDC_FILTER_CONSOLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,100,58,57,10,0,HIDC_FILTER_UNAVAILABLE |
| 950 | | #endif |
| 951 | | CONTROL "&Raster Graphics",IDC_FILTER_RASTER,"Button", |
| 952 | | BS_AUTOCHECKBOX | WS_TABSTOP,100,16,70,10,0, |
| 953 | | HIDC_FILTER_RASTER |
| 954 | | CONTROL "Ori&ginals",IDC_FILTER_ORIGINALS,"Button", |
| 955 | | BS_AUTOCHECKBOX | WS_TABSTOP,100,30,47,10,0, |
| 956 | | HIDC_FILTER_ORIGINALS |
| 957 | | CONTROL "&Working",IDC_FILTER_WORKING,"Button",BS_AUTOCHECKBOX | |
| 958 | | WS_TABSTOP,100,44,47,10,0,HIDC_FILTER_WORKING |
| 959 | | LTEXT "(*) = inherited from parent folder",IDC_INHERITED,14,72, |
| 960 | | 99,10 |
| 961 | | #ifdef MESS |
| 962 | | CTEXT "System filters allow customizing the systems that are displayed in each folder by hiding games that match the filters applied.",IDC_STATIC,6,94,178,27 |
| 963 | | #else |
| 964 | | CTEXT "Game filters allow customizing the games that are displayed in each folder by hiding games that match the filters applied.", |
| 965 | | IDC_STATIC,6,94,178,27 |
| 966 | | #endif |
| 967 | | GROUPBOX "&Description filter",IDC_STATIC,6,122,178,33 |
| 968 | | EDITTEXT IDC_FILTER_EDIT,14,134,162,13,ES_AUTOHSCROLL,0, |
| 969 | | HIDC_FILTER_EDIT |
| 970 | | DEFPUSHBUTTON "&OK",IDOK,42,161,50,14 |
| 971 | | PUSHBUTTON "&Cancel",IDCANCEL,98,161,50,14 |
| 972 | | END |
| 973 | | |
| 974 | | IDD_RESET DIALOGEX 0, 0, 190, 122 |
| 975 | | STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_CAPTION | WS_SYSMENU |
| 976 | | EXSTYLE WS_EX_CONTEXTHELP |
| 977 | | CAPTION "Reset Options" |
| 978 | | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 979 | | BEGIN |
| 980 | | GROUPBOX "Categories",IDC_STATIC,6,4,178,70 |
| 981 | | CONTROL "&User Interface (Fonts, Colors, Sizes)",IDC_RESET_UI, |
| 982 | | "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,16,146,10,0, |
| 983 | | HIDC_RESET_UI |
| 984 | | #ifdef MESS |
| 985 | | CONTROL "&Default system options",IDC_RESET_DEFAULT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,30,146,10,0,HIDC_RESET_DEFAULT |
| 986 | | CONTROL "&All systems to use default options",IDC_RESET_GAMES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,44,146,10,0,HIDC_RESET_GAMES |
| 987 | | #else |
| 988 | | CONTROL "&Default game options",IDC_RESET_DEFAULT,"Button", |
| 989 | | BS_AUTOCHECKBOX | WS_TABSTOP,14,30,146,10,0, |
| 990 | | HIDC_RESET_DEFAULT |
| 991 | | CONTROL "&All games to use default options",IDC_RESET_GAMES, |
| 992 | | "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,44,146,10,0, |
| 993 | | HIDC_RESET_GAMES |
| 994 | | #endif |
| 995 | | CONTROL "&Folder 'filters'",IDC_RESET_FILTERS,"Button", |
| 996 | | BS_AUTOCHECKBOX | WS_TABSTOP,14,58,146,10,0, |
| 997 | | HIDC_RESET_FILTERS |
| 998 | | CTEXT "Select the options to be restored to the default settings.\nThe options will be restored when MAME32 is run next.", |
| 999 | | IDC_STATIC,6,79,178,20 |
| 1000 | | DEFPUSHBUTTON "&OK",IDOK,42,101,50,14 |
| 1001 | | PUSHBUTTON "&Cancel",IDCANCEL,98,101,50,14 |
| 1002 | | END |
| 1003 | | |
| 1004 | | IDD_LOAD_PROGRESS DIALOGEX 0, 0, 260, 187 |
| 1005 | | STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU |
| 1006 | | EXSTYLE WS_EX_CONTROLPARENT |
| 1007 | | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 1008 | | BEGIN |
| 1009 | | CONTROL "Progress1",IDC_LOAD_PROGRESS,"msctls_progress32", |
| 1010 | | PBS_SMOOTH | WS_BORDER,6,7,248,12 |
| 1011 | | CTEXT "",IDC_LOAD_ROMNAME,6,21,248,10,SS_CENTERIMAGE | NOT |
| 1012 | | WS_GROUP |
| 1013 | | EDITTEXT IDC_LOAD_STATUS,6,32,248,116,ES_MULTILINE | ES_READONLY | |
| 1014 | | WS_VSCROLL |
| 1015 | | CTEXT "",IDC_ERROR_TEXT,6,150,248,13,SS_NOPREFIX | |
| 1016 | | SS_CENTERIMAGE |
| 1017 | | PUSHBUTTON "&OK",IDOK,77,166,50,14,WS_DISABLED |
| 1018 | | PUSHBUTTON "&Cancel",IDCANCEL,133,166,50,14 |
| 1019 | | END |
| 1020 | | |
| 1021 | | IDD_INTERFACE_OPTIONS DIALOGEX 0, 0, 378, 225 |
| 1022 | | STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_CAPTION | WS_SYSMENU |
| 1023 | | EXSTYLE WS_EX_CONTEXTHELP |
| 1024 | | CAPTION "Interface Options" |
| 1025 | | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 1026 | | BEGIN |
| 1027 | | #ifdef MESS |
| 1028 | | GROUPBOX "System Selection",IDC_STATIC,6,4,189,194 |
| 1029 | | CONTROL "&Search for new systems on start",IDC_START_GAME_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,16,112,10,0,HIDC_START_GAME_CHECK |
| 1030 | | CONTROL "Allow system selection by a &joystick (requires restart)",IDC_JOY_GUI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,30,178,10,0,HIDC_JOY_GUI |
| 1031 | | CONTROL "Allow system selection by custom &key sequences",IDC_KEY_GUI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,44,166,10 |
| 1032 | | #else |
| 1033 | | GROUPBOX "Game Selection",IDC_STATIC,6,4,189,194 |
| 1034 | | CONTROL "&Search for new games on start",IDC_START_GAME_CHECK, |
| 1035 | | "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,16,111,10,0, |
| 1036 | | HIDC_START_GAME_CHECK |
| 1037 | | CONTROL "Allow game selection by a &joystick (requires restart)", |
| 1038 | | IDC_JOY_GUI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,30, |
| 1039 | | 174,10,0,HIDC_JOY_GUI |
| 1040 | | CONTROL "Allow game selection by custom &key sequences", |
| 1041 | | IDC_KEY_GUI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,44, |
| 1042 | | 166,10 |
| 1043 | | #endif |
| 1044 | | CONTROL "Select &random background image",IDC_RANDOM_BG,"Button", |
| 1045 | | BS_AUTOCHECKBOX | WS_TABSTOP,14,58,122,10,0, |
| 1046 | | HIDC_RANDOM_BG |
| 1047 | | CONTROL "&Broadcast selected game to all windows",IDC_BROADCAST, |
| 1048 | | "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,72,141,10,0, |
| 1049 | | HIDC_BROADCAST |
| 1050 | | CONTROL "Hide &mouse cursor (requires restart)",IDC_HIDE_MOUSE, |
| 1051 | | "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,86,126,10,0, |
| 1052 | | HIDC_HIDE_MOUSE |
| 1053 | | CONTROL "Inheritable Filters",IDC_FILTER_INHERIT,"Button", |
| 1054 | | BS_AUTOCHECKBOX | WS_TABSTOP,14,100,68,10 |
| 1055 | | CONTROL "No offset for clones missing parent in view", |
| 1056 | | IDC_NOOFFSET_CLONES,"Button",BS_AUTOCHECKBOX | |
| 1057 | | WS_TABSTOP,14,114,148,10 |
| 1058 | | GROUPBOX "Show History on Tab",IDC_STATIC,14,128,173,28 |
| 1059 | | COMBOBOX IDC_HISTORY_TAB,57,138,88,50,CBS_DROPDOWNLIST | |
| 1060 | | WS_VSCROLL | WS_TABSTOP |
| 1061 | | GROUPBOX "Emulation",IDC_STATIC,202,4,170,28 |
| 1062 | | #ifdef MESS |
| 1063 | | CONTROL "Show System Ca&ption",IDC_GAME_CAPTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,210,16,81,10 |
| 1064 | | #else |
| 1065 | | CONTROL "Show Game Ca&ption",IDC_GAME_CAPTION,"Button", |
| 1066 | | BS_AUTOCHECKBOX | WS_TABSTOP,210,16,80,10,0, |
| 1067 | | HIDC_GAME_CAPTION |
| 1068 | | #endif |
| 1069 | | GROUPBOX "Bookkeeping",IDC_STATIC,202,36,170,43 |
| 1070 | | CONTROL "Reset all Playcounts",IDC_RESET_PLAYCOUNT,"Button", |
| 1071 | | BS_AUTOCHECKBOX | WS_TABSTOP,210,48,80,10 |
| 1072 | | CONTROL "Reset all Play Times",IDC_RESET_PLAYTIME,"Button", |
| 1073 | | BS_AUTOCHECKBOX | WS_TABSTOP,210,62,79,10 |
| 1074 | | GROUPBOX "Screenshot Area",IDC_STATIC,202,83,170,115 |
| 1075 | | CONTROL "S&tretch screenshot larger than natural size", |
| 1076 | | IDC_STRETCH_SCREENSHOT_LARGER,"Button",BS_AUTOCHECKBOX | |
| 1077 | | WS_TABSTOP,210,95,148,10,0, |
| 1078 | | HIDC_STRETCH_SCREENSHOT_LARGER |
| 1079 | | GROUPBOX "Screenshot Cycletime in Seconds",IDC_STATIC,210,109,154, |
| 1080 | | 28 |
| 1081 | | CONTROL "Slider1",IDC_CYCLETIMESEC,"msctls_trackbar32",TBS_BOTH | |
| 1082 | | TBS_NOTICKS | WS_TABSTOP,218,121,120,10,0, |
| 1083 | | HIDC_CYCLETIMESEC |
| 1084 | | RTEXT "60",IDC_CYCLETIMESECTXT,340,120,13,10,SS_CENTERIMAGE |
| 1085 | | GROUPBOX "Screenshot Bordersize",IDC_STATIC,210,141,154,28 |
| 1086 | | CONTROL "Slider1",IDC_SCREENSHOT_BORDERSIZE,"msctls_trackbar32", |
| 1087 | | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,218,153,120,10 |
| 1088 | | RTEXT "100",IDC_SCREENSHOT_BORDERSIZETXT,340,152,13,10, |
| 1089 | | SS_CENTERIMAGE |
| 1090 | | PUSHBUTTON "Set Screenshot Border Color",IDC_SCREENSHOT_BORDERCOLOR, |
| 1091 | | 210,176,154,14 |
| 1092 | | DEFPUSHBUTTON "&OK",IDOK,136,204,50,14 |
| 1093 | | PUSHBUTTON "&Cancel",IDCANCEL,192,204,50,14 |
| 1094 | | END |
| 1095 | | |
| 1096 | | IDD_LANGUAGE DIALOGEX 0, 0, 190, 66 |
| 1097 | | STYLE DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_CAPTION | WS_SYSMENU |
| 1098 | | EXSTYLE WS_EX_CONTEXTHELP |
| 1099 | | CAPTION "Language" |
| 1100 | | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 1101 | | BEGIN |
| 1102 | | GROUPBOX "",IDC_STATIC,6,4,178,34 |
| 1103 | | CONTROL "Use language file",IDC_LANGUAGECHECK,"Button", |
| 1104 | | BS_AUTOCHECKBOX | WS_TABSTOP,12,4,66,10,0, |
| 1105 | | HIDC_LANGUAGECHECK |
| 1106 | | EDITTEXT IDC_LANGUAGEEDIT,14,17,142,13,ES_AUTOHSCROLL,0, |
| 1107 | | HIDC_LANGUAGEEDIT |
| 1108 | | PUSHBUTTON "...",IDC_LANGUAGEBROWSE,162,17,14,13 |
| 1109 | | DEFPUSHBUTTON "OK",IDOK,42,45,50,14 |
| 1110 | | PUSHBUTTON "Cancel",IDCANCEL,98,45,50,14 |
| 1111 | | END |
| 1112 | | |
| 1113 | | IDD_CUSTOM_FILE DIALOG DISCARDABLE 0, 0, 190, 135 |
| 1114 | | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU |
| 1115 | | CAPTION "Add Game To Custom Folder" |
| 1116 | | FONT 8, "MS Shell Dlg" |
| 1117 | | BEGIN |
| 1118 | | LTEXT "",IDC_CUSTOMFILE_GAME,6,6,175,10,SS_NOPREFIX | |
| 1119 | | SS_CENTERIMAGE |
| 1120 | | CONTROL "CustomTree",IDC_CUSTOM_TREE,"SysTreeView32", |
| 1121 | | TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | |
| 1122 | | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | |
| 1123 | | TVS_FULLROWSELECT | WS_BORDER | WS_TABSTOP,6,18,178,90 |
| 1124 | | DEFPUSHBUTTON "OK",IDOK,42,114,50,14 |
| 1125 | | PUSHBUTTON "Cancel",IDCANCEL,98,114,50,14 |
| 1126 | | END |
| 1127 | | |
| 1128 | | IDD_PROP_CONTROLLER DIALOGEX 0, 0, 220, 240 |
| 1129 | | STYLE WS_CHILD | WS_DISABLED | WS_CAPTION |
| 1130 | | CAPTION "Controller Mapping" |
| 1131 | | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 1132 | | BEGIN |
| 1133 | | ICON IDI_JOYSTICK,IDC_STATIC,20,10,20,20 |
| 1134 | | LTEXT "Title\nDirectory\nExtra",IDC_PROP_TITLE,52,9,161,25, |
| 1135 | | SS_NOPREFIX |
| 1136 | | GROUPBOX "Paddle device",IDC_STATIC,4,40,103,28 |
| 1137 | | COMBOBOX IDC_PADDLE,10,50,91,62,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 1138 | | WS_TABSTOP,0,HIDC_PADDLE |
| 1139 | | GROUPBOX "ADStick device",IDC_STATIC,4,71,103,28 |
| 1140 | | COMBOBOX IDC_ADSTICK,10,80,91,62,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 1141 | | WS_TABSTOP,0,HIDC_ADSTICK |
| 1142 | | GROUPBOX "Pedal device",IDC_STATIC,4,102,103,28 |
| 1143 | | COMBOBOX IDC_PEDAL,10,112,91,62,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 1144 | | WS_TABSTOP,0,HIDC_PEDAL |
| 1145 | | GROUPBOX "Dial device",IDC_STATIC,113,40,102,28 |
| 1146 | | COMBOBOX IDC_DIAL,119,50,90,62,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 1147 | | WS_TABSTOP,0,HIDC_DIAL |
| 1148 | | GROUPBOX "Trackball device",IDC_STATIC,113,71,102,28 |
| 1149 | | COMBOBOX IDC_TRACKBALL,119,80,90,62,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 1150 | | WS_TABSTOP,0,HIDC_TRACKBALL |
| 1151 | | GROUPBOX "Lightgun device",IDC_STATIC,113,102,102,28 |
| 1152 | | COMBOBOX IDC_LIGHTGUNDEVICE,119,112,90,62,CBS_DROPDOWNLIST | |
| 1153 | | WS_VSCROLL | WS_TABSTOP,0,HIDC_LIGHTGUNDEVICE |
| 1154 | | PUSHBUTTON "Reset",IDC_PROP_RESET,4,222,97,14,0,0,HIDC_PROP_RESET |
| 1155 | | PUSHBUTTON "Restore Default Settings",IDC_USE_DEFAULT,118,222,97,14, |
| 1156 | | 0,0,HIDC_USE_DEFAULT |
| 1157 | | END |
| 1158 | | |
| 1159 | | IDD_PROP_SCREEN DIALOGEX 0, 0, 220, 240 |
| 1160 | | STYLE WS_CHILD | WS_CAPTION |
| 1161 | | CAPTION "Screen" |
| 1162 | | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 1163 | | BEGIN |
| 1164 | | ICON IDI_DISPLAY,IDC_STATIC,20,10,21,20 |
| 1165 | | LTEXT "Title\nDirectory\nExtra",IDC_PROP_TITLE,52,9,161,25, |
| 1166 | | SS_NOPREFIX |
| 1167 | | GROUPBOX "Number of screens",IDC_STATIC,4,40,103,24 |
| 1168 | | CONTROL "GammaSlider",IDC_NUMSCREENS,"msctls_trackbar32", |
| 1169 | | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,10,50,75,10,0, |
| 1170 | | HIDC_NUMSCREENS |
| 1171 | | RTEXT "1",IDC_NUMSCREENSDISP,84,49,14,10,SS_CENTERIMAGE | NOT |
| 1172 | | WS_GROUP |
| 1173 | | GROUPBOX "Screen",IDC_STATIC,4,66,103,29 |
| 1174 | | COMBOBOX IDC_SCREEN,10,76,91,64,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 1175 | | WS_TABSTOP,0,HIDC_SCREEN |
| 1176 | | GROUPBOX "",IDC_STATIC,4,97,103,28 |
| 1177 | | CONTROL "Autoselect aspect",IDC_ASPECT,"Button",BS_AUTOCHECKBOX | |
| 1178 | | WS_TABSTOP,10,97,73,10,0,HIDC_ASPECT |
| 1179 | | LTEXT "Aspect ratio",IDC_ASPECTRATIOTEXT,17,108,40,11, |
| 1180 | | SS_CENTERIMAGE | NOT WS_GROUP |
| 1181 | | EDITTEXT IDC_ASPECTRATION,60,108,14,12,ES_RIGHT | ES_AUTOHSCROLL | |
| 1182 | | ES_NUMBER,0,HIDC_ASPECTRATION |
| 1183 | | LTEXT ":",IDC_STATIC,76,108,8,10,SS_CENTERIMAGE | NOT WS_GROUP |
| 1184 | | EDITTEXT IDC_ASPECTRATIOD,80,108,14,12,ES_RIGHT | ES_AUTOHSCROLL | |
| 1185 | | ES_NUMBER,0,HIDC_ASPECTRATIOD |
| 1186 | | GROUPBOX "View",IDC_STATIC,4,128,103,28 |
| 1187 | | COMBOBOX IDC_VIEW,10,137,91,64,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 1188 | | WS_TABSTOP,0,HIDC_VIEW |
| 1189 | | GROUPBOX "Screennumber",IDC_SCREENSELECTTEXT,113,40,102,28 |
| 1190 | | COMBOBOX IDC_SCREENSELECT,119,50,90,64,CBS_DROPDOWNLIST | |
| 1191 | | WS_VSCROLL | WS_TABSTOP,0,HIDC_SCREENSELECT |
| 1192 | | GROUPBOX "Resolution",IDC_STATIC,113,71,102,76,WS_GROUP |
| 1193 | | GROUPBOX "Size",IDC_STATIC,119,81,90,28,WS_GROUP |
| 1194 | | COMBOBOX IDC_SIZES,126,91,77,70,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 1195 | | WS_TABSTOP,0,HIDC_SIZES |
| 1196 | | GROUPBOX "Refresh",IDC_REFRESHTEXT,119,112,90,28,WS_GROUP |
| 1197 | | COMBOBOX IDC_REFRESH,126,121,77,76,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 1198 | | WS_TABSTOP,0,HIDC_REFRESH |
| 1199 | | CONTROL "Switch resolutions to fit",IDC_SWITCHRES,"Button", |
| 1200 | | BS_AUTOCHECKBOX | WS_TABSTOP,119,151,93,10,0, |
| 1201 | | HIDC_SWITCHRES |
| 1202 | | PUSHBUTTON "Reset",IDC_PROP_RESET,4,222,97,14,0,0,HIDC_PROP_RESET |
| 1203 | | PUSHBUTTON "Restore Default Settings",IDC_USE_DEFAULT,118,222,97,14, |
| 1204 | | 0,0,HIDC_USE_DEFAULT |
| 1205 | | END |
| 1206 | | |
| 1207 | | |
| 1208 | | ///////////////////////////////////////////////////////////////////////////// |
| 1209 | | // |
| 1210 | | // Accelerator |
| 1211 | | // |
| 1212 | | |
| 1213 | | IDA_TAB_KEYS ACCELERATORS MOVEABLE PURE |
| 1214 | | BEGIN |
| 1215 | | "1", ID_VIEW_TAB_SCREENSHOT, VIRTKEY, ALT, NOINVERT |
| 1216 | | "2", ID_VIEW_TAB_FLYER, VIRTKEY, ALT, NOINVERT |
| 1217 | | "3", ID_VIEW_TAB_CABINET, VIRTKEY, ALT, NOINVERT |
| 1218 | | "4", ID_VIEW_TAB_MARQUEE, VIRTKEY, ALT, NOINVERT |
| 1219 | | "5", ID_VIEW_TAB_TITLE, VIRTKEY, ALT, NOINVERT |
| 1220 | | "6", ID_VIEW_TAB_CONTROL_PANEL, VIRTKEY, ALT, NOINVERT |
| 1221 | | "7", ID_VIEW_TAB_HISTORY, VIRTKEY, ALT, NOINVERT |
| 1222 | | "A", ID_GAME_AUDIT, VIRTKEY, ALT, NOINVERT |
| 1223 | | "B", ID_VIEW_PAGETAB, VIRTKEY, ALT, NOINVERT |
| 1224 | | "D", ID_VIEW_FOLDERS, VIRTKEY, ALT, NOINVERT |
| 1225 | | "F", ID_CONTEXT_FILTERS, VIRTKEY, CONTROL, NOINVERT |
| 1226 | | "U", ID_FOLDER_AUDIT, VIRTKEY, ALT, NOINVERT |
| 1227 | | "P", ID_VIEW_PICTURE_AREA, VIRTKEY, ALT, NOINVERT |
| 1228 | | "R", ID_CONTEXT_SELECT_RANDOM, VIRTKEY, CONTROL, NOINVERT |
| 1229 | | "S", ID_VIEW_STATUS, VIRTKEY, ALT, NOINVERT |
| 1230 | | "T", ID_VIEW_TOOLBARS, VIRTKEY, ALT, NOINVERT |
| 1231 | | VK_F1, ID_HELP_CONTENTS, VIRTKEY, NOINVERT |
| 1232 | | VK_F11, ID_VIEW_FULLSCREEN, VIRTKEY, NOINVERT |
| 1233 | | VK_F5, ID_UPDATE_GAMELIST, VIRTKEY, NOINVERT |
| 1234 | | VK_NEXT, ID_UI_HISTORY_DOWN, VIRTKEY, CONTROL, NOINVERT |
| 1235 | | VK_PRIOR, ID_UI_HISTORY_UP, VIRTKEY, CONTROL, NOINVERT |
| 1236 | | VK_RETURN, ID_GAME_PROPERTIES, VIRTKEY, ALT, NOINVERT |
| 1237 | | END |
| 1238 | | |
| 1239 | | |
| 1240 | | ///////////////////////////////////////////////////////////////////////////// |
| 1241 | | // |
| 1242 | | // DESIGNINFO |
| 1243 | | // |
| 1244 | | |
| 1245 | | #ifdef APSTUDIO_INVOKED |
| 1246 | | GUIDELINES DESIGNINFO MOVEABLE PURE |
| 1247 | | BEGIN |
| 1248 | | IDD_ABOUT, DIALOG |
| 1249 | | BEGIN |
| 1250 | | LEFTMARGIN, 7 |
| 1251 | | RIGHTMARGIN, 289 |
| 1252 | | TOPMARGIN, 7 |
| 1253 | | BOTTOMMARGIN, 123 |
| 1254 | | END |
| 1255 | | |
| 1256 | | IDD_DIRECTX, DIALOG |
| 1257 | | BEGIN |
| 1258 | | LEFTMARGIN, 7 |
| 1259 | | RIGHTMARGIN, 229 |
| 1260 | | TOPMARGIN, 7 |
| 1261 | | BOTTOMMARGIN, 62 |
| 1262 | | END |
| 1263 | | |
| 1264 | | IDD_AUDIT, DIALOG |
| 1265 | | BEGIN |
| 1266 | | LEFTMARGIN, 7 |
| 1267 | | RIGHTMARGIN, 280 |
| 1268 | | TOPMARGIN, 7 |
| 1269 | | BOTTOMMARGIN, 187 |
| 1270 | | HORZGUIDE, 19 |
| 1271 | | END |
| 1272 | | |
| 1273 | | IDD_DIRECTORIES, DIALOG |
| 1274 | | BEGIN |
| 1275 | | LEFTMARGIN, 7 |
| 1276 | | RIGHTMARGIN, 224 |
| 1277 | | TOPMARGIN, 7 |
| 1278 | | BOTTOMMARGIN, 98 |
| 1279 | | END |
| 1280 | | |
| 1281 | | IDD_COLUMNS, DIALOG |
| 1282 | | BEGIN |
| 1283 | | LEFTMARGIN, 7 |
| 1284 | | RIGHTMARGIN, 301 |
| 1285 | | TOPMARGIN, 7 |
| 1286 | | BOTTOMMARGIN, 143 |
| 1287 | | END |
| 1288 | | |
| 1289 | | IDD_PROP_GAME, DIALOG |
| 1290 | | BEGIN |
| 1291 | | LEFTMARGIN, 7 |
| 1292 | | RIGHTMARGIN, 213 |
| 1293 | | VERTGUIDE, 19 |
| 1294 | | VERTGUIDE, 66 |
| 1295 | | VERTGUIDE, 74 |
| 1296 | | VERTGUIDE, 201 |
| 1297 | | BOTTOMMARGIN, 232 |
| 1298 | | END |
| 1299 | | |
| 1300 | | IDD_PROP_AUDIT, DIALOG |
| 1301 | | BEGIN |
| 1302 | | LEFTMARGIN, 7 |
| 1303 | | RIGHTMARGIN, 213 |
| 1304 | | VERTGUIDE, 12 |
| 1305 | | VERTGUIDE, 208 |
| 1306 | | BOTTOMMARGIN, 198 |
| 1307 | | HORZGUIDE, 38 |
| 1308 | | END |
| 1309 | | |
| 1310 | | IDD_PROP_DISPLAY, DIALOG |
| 1311 | | BEGIN |
| 1312 | | LEFTMARGIN, 4 |
| 1313 | | RIGHTMARGIN, 223 |
| 1314 | | VERTGUIDE, 7 |
| 1315 | | VERTGUIDE, 123 |
| 1316 | | BOTTOMMARGIN, 257 |
| 1317 | | HORZGUIDE, 179 |
| 1318 | | END |
| 1319 | | |
| 1320 | | IDD_PROP_SOUND, DIALOG |
| 1321 | | BEGIN |
| 1322 | | LEFTMARGIN, 7 |
| 1323 | | RIGHTMARGIN, 213 |
| 1324 | | VERTGUIDE, 50 |
| 1325 | | BOTTOMMARGIN, 198 |
| 1326 | | END |
| 1327 | | |
| 1328 | | IDD_PROP_ADVANCED, DIALOG |
| 1329 | | BEGIN |
| 1330 | | LEFTMARGIN, 7 |
| 1331 | | RIGHTMARGIN, 230 |
| 1332 | | BOTTOMMARGIN, 211 |
| 1333 | | END |
| 1334 | | |
| 1335 | | IDD_PROP_INPUT, DIALOG |
| 1336 | | BEGIN |
| 1337 | | LEFTMARGIN, 4 |
| 1338 | | RIGHTMARGIN, 215 |
| 1339 | | VERTGUIDE, 50 |
| 1340 | | VERTGUIDE, 170 |
| 1341 | | BOTTOMMARGIN, 257 |
| 1342 | | END |
| 1343 | | |
| 1344 | | IDD_PROP_MISC, DIALOG |
| 1345 | | BEGIN |
| 1346 | | LEFTMARGIN, 7 |
| 1347 | | RIGHTMARGIN, 213 |
| 1348 | | VERTGUIDE, 25 |
| 1349 | | VERTGUIDE, 40 |
| 1350 | | VERTGUIDE, 104 |
| 1351 | | VERTGUIDE, 114 |
| 1352 | | VERTGUIDE, 204 |
| 1353 | | BOTTOMMARGIN, 183 |
| 1354 | | END |
| 1355 | | |
| 1356 | | IDD_PROP_VECTOR, DIALOG |
| 1357 | | BEGIN |
| 1358 | | LEFTMARGIN, 7 |
| 1359 | | RIGHTMARGIN, 213 |
| 1360 | | VERTGUIDE, 50 |
| 1361 | | BOTTOMMARGIN, 198 |
| 1362 | | END |
| 1363 | | |
| 1364 | | IDD_FILTERS, DIALOG |
| 1365 | | BEGIN |
| 1366 | | LEFTMARGIN, 7 |
| 1367 | | TOPMARGIN, 7 |
| 1368 | | BOTTOMMARGIN, 178 |
| 1369 | | END |
| 1370 | | |
| 1371 | | IDD_RESET, DIALOG |
| 1372 | | BEGIN |
| 1373 | | LEFTMARGIN, 7 |
| 1374 | | RIGHTMARGIN, 175 |
| 1375 | | VERTGUIDE, 18 |
| 1376 | | VERTGUIDE, 164 |
| 1377 | | TOPMARGIN, 7 |
| 1378 | | END |
| 1379 | | |
| 1380 | | IDD_LANGUAGE, DIALOG |
| 1381 | | BEGIN |
| 1382 | | LEFTMARGIN, 7 |
| 1383 | | RIGHTMARGIN, 179 |
| 1384 | | TOPMARGIN, 7 |
| 1385 | | BOTTOMMARGIN, 59 |
| 1386 | | END |
| 1387 | | |
| 1388 | | IDD_PROP_CONTROLLER, DIALOG |
| 1389 | | BEGIN |
| 1390 | | RIGHTMARGIN, 210 |
| 1391 | | BOTTOMMARGIN, 154 |
| 1392 | | END |
| 1393 | | |
| 1394 | | IDD_PROP_SCREEN, DIALOG |
| 1395 | | BEGIN |
| 1396 | | LEFTMARGIN, 4 |
| 1397 | | RIGHTMARGIN, 223 |
| 1398 | | VERTGUIDE, 7 |
| 1399 | | VERTGUIDE, 123 |
| 1400 | | BOTTOMMARGIN, 199 |
| 1401 | | HORZGUIDE, 179 |
| 1402 | | END |
| 1403 | | END |
| 1404 | | #endif // APSTUDIO_INVOKED |
| 1405 | | |
| 1406 | | |
| 1407 | | ///////////////////////////////////////////////////////////////////////////// |
| 1408 | | // |
| 1409 | | // Bitmap |
| 1410 | | // |
| 1411 | | |
| 1412 | | #ifdef MESS |
| 1413 | | IDB_ABOUT BITMAP DISCARDABLE "res\\about_mess.bmp" |
| 1414 | | #else |
| 1415 | | IDB_ABOUT BITMAP MOVEABLE PURE "res\\about.bmp" |
| 1416 | | #endif |
| 1417 | | IDB_TOOLBAR BITMAP MOVEABLE PURE "res\\toolbar.bmp" |
| 1418 | | |
| 1419 | | ///////////////////////////////////////////////////////////////////////////// |
| 1420 | | // |
| 1421 | | // Cursor |
| 1422 | | // |
| 1423 | | |
| 1424 | | IDC_CURSOR_HSPLIT CURSOR DISCARDABLE "Res\\Splith.cur" |
| 1425 | | |
| 1426 | | ///////////////////////////////////////////////////////////////////////////// |
| 1427 | | // |
| 1428 | | // 24 |
| 1429 | | // |
| 1430 | | |
| 1431 | | 1 24 MOVEABLE PURE "res\\mame32.manifest" |
| 1432 | | |
| 1433 | | ///////////////////////////////////////////////////////////////////////////// |
| 1434 | | // |
| 1435 | | // String Table |
| 1436 | | // |
| 1437 | | |
| 1438 | | STRINGTABLE DISCARDABLE |
| 1439 | | BEGIN |
| 1440 | | IDS_UI_FILE "Contains commands for working with the selected items" |
| 1441 | | IDS_UI_VIEW "Contains commands for manupulating the view" |
| 1442 | | IDS_UI_OPTIONS "Contains commands for user interface options" |
| 1443 | | IDS_UI_HELP "Contains commands for displaying help" |
| 1444 | | END |
| 1445 | | |
| 1446 | | STRINGTABLE DISCARDABLE |
| 1447 | | BEGIN |
| 1448 | | IDS_UI_TOOLBAR "Show or hide the toolbar" |
| 1449 | | IDS_UI_STATUSBAR "Show or hide the status bar" |
| 1450 | | IDS_UI_FOLDERLIST "Show or hide the folder list" |
| 1451 | | IDS_UI_SCREENSHOT "Show or hide the screen shot" |
| 1452 | | IDS_UI_SPACER1 "Spacer" |
| 1453 | | IDS_UI_LARGEICONS "Display items by using large icons." |
| 1454 | | IDS_UI_SMALLICONS "Display items by using small icons." |
| 1455 | | IDS_UI_LIST "Displays items in a list." |
| 1456 | | IDS_UI_DETAILS "Displays detailed information about each item in the window." |
| 1457 | | IDS_UI_SPACER2 "Spacer" |
| 1458 | | IDS_UI_ARRANGE "Contains commands for sorting by various columns" |
| 1459 | | IDS_UI_LINEUPICONS "Arranges icons in a grid" |
| 1460 | | #ifdef MESS |
| 1461 | | IDS_UI_REFRESH "Refresh system list" |
| 1462 | | IDS_UI_CUSTOMIZE "Customize which columns are used in the system list" |
| 1463 | | #else |
| 1464 | | IDS_UI_REFRESH "Refresh game list" |
| 1465 | | IDS_UI_CUSTOMIZE "Customize which columns are used in the game list" |
| 1466 | | #endif |
| 1467 | | END |
| 1468 | | |
| 1469 | | STRINGTABLE DISCARDABLE |
| 1470 | | BEGIN |
| 1471 | | ID_FILE_EXIT "Exit the application" |
| 1472 | | #ifdef MESS |
| 1473 | | ID_FILE_PLAY "Play currently selected system" |
| 1474 | | #else |
| 1475 | | ID_FILE_PLAY "Play currently selected game" |
| 1476 | | #endif |
| 1477 | | ID_HELP_ABOUT "Displays program and copyright information" |
| 1478 | | ID_VIEW_LARGE_ICON "Display items by using large icons." |
| 1479 | | ID_VIEW_SMALL_ICON "Display items by using small icons." |
| 1480 | | ID_VIEW_LIST_MENU "Displays items in a list." |
| 1481 | | ID_VIEW_DETAIL "Displays detailed information about each item in the window." |
| 1482 | | #ifdef MESS |
| 1483 | | ID_OPTIONS_FONT "Set system list and folder list font" |
| 1484 | | ID_OPTIONS_DIR "Set directory configuration" |
| 1485 | | ID_OPTIONS_DEFAULTS "Set default system options" |
| 1486 | | #else |
| 1487 | | ID_OPTIONS_FONT "Set game list and folder list font" |
| 1488 | | ID_OPTIONS_DIR "Set directory configuration" |
| 1489 | | ID_OPTIONS_DEFAULTS "Set default game options" |
| 1490 | | #endif |
| 1491 | | END |
| 1492 | | |
| 1493 | | STRINGTABLE DISCARDABLE |
| 1494 | | BEGIN |
| 1495 | | #ifdef MESS |
| 1496 | | ID_FILE_LOADSTATE "Run a system starting with the given savestate" |
| 1497 | | #else |
| 1498 | | ID_FILE_LOADSTATE "Play a game starting with the given savestate" |
| 1499 | | #endif |
| 1500 | | END |
| 1501 | | |
| 1502 | | STRINGTABLE DISCARDABLE |
| 1503 | | BEGIN |
| 1504 | | ID_OPTIONS_RESET_DEFAULTS "Allow restoring options to 'sane' values." |
| 1505 | | ID_OPTIONS_INTERFACE "Customize interface options." |
| 1506 | | ID_FILE_AUDIT "Audit ROM and samples sets" |
| 1507 | | #ifdef MESS |
| 1508 | | ID_FILE_PLAY_RECORD "Record a system for later playback" |
| 1509 | | ID_FILE_PLAY_BACK "Playback a recorded system" |
| 1510 | | ID_FILE_PLAY_RECORD_WAVE "Record the sound output of a system" |
| 1511 | | #else |
| 1512 | | ID_FILE_PLAY_RECORD "Record a game for later playback" |
| 1513 | | ID_FILE_PLAY_BACK "Playback a recorded game" |
| 1514 | | ID_FILE_PLAY_RECORD_MNG "Record the video output of a game" |
| 1515 | | #endif |
| 1516 | | ID_VIEW_PICTURE_AREA "Show or hide the picture area" |
| 1517 | | ID_HELP_CONTENTS "Display help contents" |
| 1518 | | #ifdef MESS |
| 1519 | | ID_HELP_WHATS_NEW32 "Recent changes" |
| 1520 | | ID_HELP_TROUBLE "Troubleshooting Documentation" |
| 1521 | | ID_HELP_RELEASE "MESS release notes" |
| 1522 | | ID_HELP_WHATS_NEW "What's new in MESS" |
| 1523 | | ID_HELP_CHEATS "How cheats work" |
| 1524 | | #else |
| 1525 | | ID_HELP_WHATS_NEW32 "New game changes" |
| 1526 | | ID_HELP_TROUBLE "Troubleshooting Documentation" |
| 1527 | | ID_HELP_RELEASE "MAME release notes" |
| 1528 | | ID_HELP_WHATS_NEW "What's new in MAME" |
| 1529 | | ID_HELP_CHEATS "How cheats work" |
| 1530 | | #endif |
| 1531 | | END |
| 1532 | | |
| 1533 | | STRINGTABLE DISCARDABLE |
| 1534 | | BEGIN |
| 1535 | | #ifdef MESS |
| 1536 | | ID_CUSTOMIZE_FIELDS "Customize which columns are used in the system list" |
| 1537 | | #else |
| 1538 | | ID_CUSTOMIZE_FIELDS "Customize which columns are used in the game list" |
| 1539 | | #endif |
| 1540 | | ID_GAME_PROPERTIES "Display the properties of the selected items" |
| 1541 | | ID_VIEW_FOLDERS "Show or hide the folder list" |
| 1542 | | ID_VIEW_TOOLBARS "Show or hide the toolbar" |
| 1543 | | ID_VIEW_STATUS "Show or hide the status bar" |
| 1544 | | #ifdef MESS |
| 1545 | | ID_CONTEXT_FILTERS "Allows filtering out systems from a folder" |
| 1546 | | ID_CONTEXT_SELECT_RANDOM "Randomly select a system." |
| 1547 | | #else |
| 1548 | | ID_CONTEXT_FILTERS "Allows filtering out games from a folder" |
| 1549 | | ID_CONTEXT_SELECT_RANDOM "Randomly select a game." |
| 1550 | | #endif |
| 1551 | | END |
| 1552 | | |
| 1553 | | STRINGTABLE DISCARDABLE |
| 1554 | | BEGIN |
| 1555 | | #ifdef MESS |
| 1556 | | ID_VIEW_BYGAME "Sort items by system" |
| 1557 | | #else |
| 1558 | | ID_VIEW_BYGAME "Sort items by game" |
| 1559 | | #endif |
| 1560 | | ID_VIEW_BYDIRECTORY "Sort items by directories" |
| 1561 | | ID_VIEW_BYMANUFACTURER "Sort items by manufacturer" |
| 1562 | | ID_VIEW_BYYEAR "Sort items by year" |
| 1563 | | ID_VIEW_BYTYPE "Sort items by type" |
| 1564 | | ID_VIEW_BYTIMESPLAYED "Sort by number of plays" |
| 1565 | | ID_VIEW_LINEUPICONS "Arranges icons in a grid" |
| 1566 | | #ifdef MESS |
| 1567 | | ID_UPDATE_GAMELIST "Refresh system list" |
| 1568 | | #else |
| 1569 | | ID_UPDATE_GAMELIST "Refresh game list" |
| 1570 | | #endif |
| 1571 | | ID_SORT_ASCENDING "Sort column in ascending (A-Z) order" |
| 1572 | | ID_SORT_DESCENDING "Sort column in descending (Z-A) order" |
| 1573 | | END |
| 1574 | | |
| 1575 | | #endif // Englisch (USA) resources |
| 1576 | | ///////////////////////////////////////////////////////////////////////////// |
| 1577 | | |
| 1578 | | |
| 1579 | | |
| 1580 | | #ifndef APSTUDIO_INVOKED |
| 1581 | | ///////////////////////////////////////////////////////////////////////////// |
| 1582 | | // |
| 1583 | | // Generated from the TEXTINCLUDE 3 resource. |
| 1584 | | // |
| 1585 | | |
| 1586 | | |
| 1587 | | ///////////////////////////////////////////////////////////////////////////// |
| 1588 | | #endif // not APSTUDIO_INVOKED |
| 1589 | | |
src/osd/windows/ui/picker.c
| r995 | r996 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | M.A.M.E.32 - Multiple Arcade Machine Emulator for Win32 |
| 4 | | Win32 Portions Copyright (C) 1997-2003 Michael Soderstrom and Chris Kirmse |
| 5 | | |
| 6 | | This file is part of MAME32, and may only be used, modified and |
| 7 | | distributed under the terms of the MAME license, in "readme.txt". |
| 8 | | By continuing to use, modify or distribute this file you indicate |
| 9 | | that you have read the license and understand and accept it fully. |
| 10 | | |
| 11 | | ***************************************************************************/ |
| 12 | | |
| 13 | | #define WIN32_LEAN_AND_MEAN |
| 14 | | #define _WIN32_IE 0x0500 |
| 15 | | #include <windows.h> |
| 16 | | #include <windowsx.h> |
| 17 | | #include <shellapi.h> |
| 18 | | #include <stdio.h> |
| 19 | | #include <ctype.h> |
| 20 | | #include <commctrl.h> |
| 21 | | #include <commdlg.h> |
| 22 | | #include <string.h> |
| 23 | | #include <sys/stat.h> |
| 24 | | #include <wingdi.h> |
| 25 | | #include <time.h> |
| 26 | | #include <tchar.h> |
| 27 | | |
| 28 | | #include "picker.h" |
| 29 | | #include "resource.h" |
| 30 | | #include "screenshot.h" |
| 31 | | #include "win32ui.h" |
| 32 | | #include "bitmask.h" |
| 33 | | #include "m32util.h" |
| 34 | | #include "m32opts.h" |
| 35 | | |
| 36 | | |
| 37 | | // fix warning: cast does not match function type |
| 38 | | #if defined(__GNUC__) && defined(ListView_GetHeader) |
| 39 | | #undef ListView_GetHeader |
| 40 | | #endif |
| 41 | | #if defined(__GNUC__) && defined(ListView_GetImageList) |
| 42 | | #undef ListView_GetImageList |
| 43 | | #undef ListView_GetItemRect |
| 44 | | #endif |
| 45 | | |
| 46 | | #ifndef ListView_GetItemRect |
| 47 | | #define ListView_GetItemRect(w,i,p,c) \ |
| 48 | | (BOOL)SNDMSG((w),LVM_GETITEMRECT,i,((p != NULL)?(((LPRECT)(p))->left=(c),(LPARAM)(LPRECT)(p)):0)) |
| 49 | | #endif |
| 50 | | |
| 51 | | #ifndef ListView_GetImageList |
| 52 | | #define ListView_GetImageList(w,i) (HIMAGELIST)(LRESULT)(int)SendMessage((w),LVM_GETIMAGELIST,(i),0) |
| 53 | | #endif // ListView_GetImageList |
| 54 | | |
| 55 | | #ifndef ListView_GetHeader |
| 56 | | #define ListView_GetHeader(w) (HWND)(LRESULT)(int)SNDMSG((w),LVM_GETHEADER,0,0) |
| 57 | | #endif // ListView_GetHeader |
| 58 | | |
| 59 | | #ifndef HDM_SETIMAGELIST |
| 60 | | #define HDM_SETIMAGELIST (HDM_FIRST + 8) |
| 61 | | #endif // HDM_SETIMAGELIST |
| 62 | | |
| 63 | | #ifndef Header_SetImageList |
| 64 | | #define Header_SetImageList(h,i) (HIMAGELIST)(LRESULT)(int)SNDMSG((h), HDM_SETIMAGELIST, 0, (LPARAM)i) |
| 65 | | #endif // Header_SetImageList |
| 66 | | |
| 67 | | #ifndef HDF_SORTUP |
| 68 | | #define HDF_SORTUP 0x400 |
| 69 | | #endif |
| 70 | | |
| 71 | | #ifndef HDF_SORTDOWN |
| 72 | | #define HDF_SORTDOWN 0x200 |
| 73 | | #endif |
| 74 | | |
| 75 | | |
| 76 | | |
| 77 | | struct PickerInfo |
| 78 | | { |
| 79 | | const struct PickerCallbacks *pCallbacks; |
| 80 | | WNDPROC pfnParentWndProc; |
| 81 | | int nCurrentViewID; |
| 82 | | int nLastItem; |
| 83 | | int nColumnCount; |
| 84 | | int *pnColumnsShown; |
| 85 | | int *pnColumnsOrder; |
| 86 | | UINT_PTR nTimer; |
| 87 | | LPCTSTR *ppszColumnNames; |
| 88 | | }; |
| 89 | | |
| 90 | | |
| 91 | | static struct PickerInfo *GetPickerInfo(HWND hWnd) |
| 92 | | { |
| 93 | | LONG_PTR l; |
| 94 | | l = GetWindowLongPtr(hWnd, GWLP_USERDATA); |
| 95 | | return (struct PickerInfo *) l; |
| 96 | | } |
| 97 | | |
| 98 | | |
| 99 | | |
| 100 | | static LRESULT CallParentWndProc(WNDPROC pfnParentWndProc, |
| 101 | | HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) |
| 102 | | { |
| 103 | | LRESULT rc; |
| 104 | | |
| 105 | | if (!pfnParentWndProc) |
| 106 | | pfnParentWndProc = GetPickerInfo(hWnd)->pfnParentWndProc; |
| 107 | | |
| 108 | | if (IsWindowUnicode(hWnd)) |
| 109 | | rc = CallWindowProcW(pfnParentWndProc, hWnd, message, wParam, lParam); |
| 110 | | else |
| 111 | | rc = CallWindowProcA(pfnParentWndProc, hWnd, message, wParam, lParam); |
| 112 | | return rc; |
| 113 | | } |
| 114 | | |
| 115 | | static BOOL ListViewOnErase(HWND hWnd, HDC hDC) |
| 116 | | { |
| 117 | | RECT rcClient; |
| 118 | | HRGN rgnBitmap; |
| 119 | | HPALETTE hPAL; |
| 120 | | |
| 121 | | int i, j; |
| 122 | | HDC htempDC; |
| 123 | | POINT ptOrigin; |
| 124 | | POINT pt = {0,0}; |
| 125 | | HBITMAP hOldBitmap; |
| 126 | | MYBITMAPINFO *pbmDesc = GetBackgroundInfo(); |
| 127 | | HBITMAP hBackground = GetBackgroundBitmap(); |
| 128 | | HPALETTE hPALbg = GetBackgroundPalette(); |
| 129 | | |
| 130 | | // this does not draw the background properly in report view |
| 131 | | |
| 132 | | GetClientRect(hWnd, &rcClient); |
| 133 | | |
| 134 | | htempDC = CreateCompatibleDC(hDC); |
| 135 | | hOldBitmap = SelectObject(htempDC, hBackground); |
| 136 | | |
| 137 | | rgnBitmap = CreateRectRgnIndirect(&rcClient); |
| 138 | | SelectClipRgn(hDC, rgnBitmap); |
| 139 | | DeleteObject(rgnBitmap); |
| 140 | | |
| 141 | | hPAL = (!hPALbg) ? CreateHalftonePalette(hDC) : hPALbg; |
| 142 | | |
| 143 | | if (GetDeviceCaps(htempDC, RASTERCAPS) & RC_PALETTE && hPAL != NULL) |
| 144 | | { |
| 145 | | SelectPalette(htempDC, hPAL, FALSE); |
| 146 | | RealizePalette(htempDC); |
| 147 | | } |
| 148 | | |
| 149 | | // Get x and y offset |
| 150 | | MapWindowPoints(hWnd, GetTreeView(), &pt, 1); |
| 151 | | GetDCOrgEx(hDC, &ptOrigin); |
| 152 | | ptOrigin.x -= pt.x; |
| 153 | | ptOrigin.y -= pt.y; |
| 154 | | ptOrigin.x = -GetScrollPos(hWnd, SB_HORZ); |
| 155 | | ptOrigin.y = -GetScrollPos(hWnd, SB_VERT); |
| 156 | | |
| 157 | | if (pbmDesc->bmWidth && pbmDesc->bmHeight) |
| 158 | | { |
| 159 | | for (i = ptOrigin.x; i < rcClient.right; i += pbmDesc->bmWidth) |
| 160 | | for (j = ptOrigin.y; j < rcClient.bottom; j += pbmDesc->bmHeight) |
| 161 | | BitBlt(hDC, i, j, pbmDesc->bmWidth, pbmDesc->bmHeight, htempDC, 0, 0, SRCCOPY); |
| 162 | | } |
| 163 | | |
| 164 | | SelectObject(htempDC, hOldBitmap); |
| 165 | | DeleteDC(htempDC); |
| 166 | | |
| 167 | | if (!pbmDesc->bmColors) |
| 168 | | { |
| 169 | | DeleteObject(hPAL); |
| 170 | | hPAL = 0; |
| 171 | | } |
| 172 | | |
| 173 | | return TRUE; |
| 174 | | } |
| 175 | | |
| 176 | | |
| 177 | | |
| 178 | | static BOOL ListViewNotify(HWND hWnd, LPNMHDR lpNmHdr) |
| 179 | | { |
| 180 | | RECT rcClient; |
| 181 | | DWORD dwPos; |
| 182 | | POINT pt; |
| 183 | | |
| 184 | | // This code is for using bitmap in the background |
| 185 | | // Invalidate the right side of the control when a column is resized |
| 186 | | if (lpNmHdr->code == HDN_ITEMCHANGINGA || lpNmHdr->code == HDN_ITEMCHANGINGW) |
| 187 | | { |
| 188 | | dwPos = GetMessagePos(); |
| 189 | | pt.x = LOWORD(dwPos); |
| 190 | | pt.y = HIWORD(dwPos); |
| 191 | | |
| 192 | | GetClientRect(hWnd, &rcClient); |
| 193 | | ScreenToClient(hWnd, &pt); |
| 194 | | rcClient.left = pt.x; |
| 195 | | InvalidateRect(hWnd, &rcClient, FALSE); |
| 196 | | } |
| 197 | | return FALSE; |
| 198 | | } |
| 199 | | |
| 200 | | |
| 201 | | |
| 202 | | static BOOL ListViewContextMenu(HWND hwndPicker, LPARAM lParam) |
| 203 | | { |
| 204 | | struct PickerInfo *pPickerInfo; |
| 205 | | POINT pt, headerPt; |
| 206 | | int i, nViewID, nColumn = -1; |
| 207 | | HWND hwndHeader; |
| 208 | | RECT rcCol; |
| 209 | | |
| 210 | | pPickerInfo = GetPickerInfo(hwndPicker); |
| 211 | | |
| 212 | | // Extract the point out of the lparam |
| 213 | | pt.x = GET_X_LPARAM(lParam); |
| 214 | | pt.y = GET_Y_LPARAM(lParam); |
| 215 | | if (pt.x < 0 && pt.y < 0) |
| 216 | | GetCursorPos(&pt); |
| 217 | | |
| 218 | | // Figure out which header column was clicked, if at all |
| 219 | | nViewID = Picker_GetViewID(hwndPicker); |
| 220 | | if ((nViewID == VIEW_REPORT) || (nViewID == VIEW_GROUPED)) |
| 221 | | { |
| 222 | | hwndHeader = ListView_GetHeader(hwndPicker); |
| 223 | | headerPt = pt; |
| 224 | | ScreenToClient(hwndHeader, &headerPt); |
| 225 | | |
| 226 | | for (i = 0; Header_GetItemRect(hwndHeader, i, &rcCol); i++) |
| 227 | | { |
| 228 | | if (PtInRect(&rcCol, headerPt)) |
| 229 | | { |
| 230 | | nColumn = i; |
| 231 | | break; |
| 232 | | } |
| 233 | | } |
| 234 | | } |
| 235 | | |
| 236 | | if (nColumn >= 0) |
| 237 | | { |
| 238 | | // A column header was clicked |
| 239 | | if (pPickerInfo->pCallbacks->pfnOnHeaderContextMenu) |
| 240 | | pPickerInfo->pCallbacks->pfnOnHeaderContextMenu(pt, nColumn); |
| 241 | | } |
| 242 | | else |
| 243 | | { |
| 244 | | // The body was clicked |
| 245 | | if (pPickerInfo->pCallbacks->pfnOnBodyContextMenu) |
| 246 | | pPickerInfo->pCallbacks->pfnOnBodyContextMenu(pt); |
| 247 | | } |
| 248 | | return TRUE; |
| 249 | | } |
| 250 | | |
| 251 | | |
| 252 | | |
| 253 | | static void Picker_Free(struct PickerInfo *pPickerInfo) |
| 254 | | { |
| 255 | | // Free up all resources associated with this picker structure |
| 256 | | if (pPickerInfo->pnColumnsShown) |
| 257 | | free(pPickerInfo->pnColumnsShown); |
| 258 | | if (pPickerInfo->pnColumnsOrder) |
| 259 | | free(pPickerInfo->pnColumnsOrder); |
| 260 | | free(pPickerInfo); |
| 261 | | } |
| 262 | | |
| 263 | | |
| 264 | | |
| 265 | | static LRESULT CALLBACK ListViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) |
| 266 | | { |
| 267 | | struct PickerInfo *pPickerInfo; |
| 268 | | LRESULT rc = 0; |
| 269 | | BOOL bHandled = FALSE; |
| 270 | | WNDPROC pfnParentWndProc; |
| 271 | | HWND hwndHeaderCtrl = NULL; |
| 272 | | HFONT hHeaderCtrlFont = NULL; |
| 273 | | |
| 274 | | pPickerInfo = GetPickerInfo(hWnd); |
| 275 | | pfnParentWndProc = pPickerInfo->pfnParentWndProc; |
| 276 | | |
| 277 | | switch(message) |
| 278 | | { |
| 279 | | case WM_MOUSEMOVE: |
| 280 | | if (MouseHasBeenMoved()) |
| 281 | | ShowCursor(TRUE); |
| 282 | | break; |
| 283 | | |
| 284 | | case WM_ERASEBKGND: |
| 285 | | if (GetBackgroundBitmap()) |
| 286 | | { |
| 287 | | rc = ListViewOnErase(hWnd, (HDC) wParam); |
| 288 | | bHandled = TRUE; |
| 289 | | } |
| 290 | | break; |
| 291 | | |
| 292 | | case WM_NOTIFY: |
| 293 | | bHandled = ListViewNotify(hWnd, (LPNMHDR) lParam); |
| 294 | | break; |
| 295 | | |
| 296 | | case WM_SETFONT: |
| 297 | | hwndHeaderCtrl = ListView_GetHeader(hWnd); |
| 298 | | if (hwndHeaderCtrl) |
| 299 | | hHeaderCtrlFont = GetWindowFont(hwndHeaderCtrl); |
| 300 | | break; |
| 301 | | |
| 302 | | case WM_CONTEXTMENU: |
| 303 | | bHandled = ListViewContextMenu(hWnd, lParam); |
| 304 | | break; |
| 305 | | |
| 306 | | case WM_DESTROY: |
| 307 | | // Received WM_DESTROY; time to clean up |
| 308 | | if (pPickerInfo->pCallbacks->pfnSetViewMode) |
| 309 | | pPickerInfo->pCallbacks->pfnSetViewMode(pPickerInfo->nCurrentViewID); |
| 310 | | Picker_Free(pPickerInfo); |
| 311 | | SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR) pfnParentWndProc); |
| 312 | | SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) NULL); |
| 313 | | break; |
| 314 | | } |
| 315 | | |
| 316 | | if (!bHandled) |
| 317 | | rc = CallParentWndProc(pfnParentWndProc, hWnd, message, wParam, lParam); |
| 318 | | |
| 319 | | // If we received WM_SETFONT, reset header ctrl font back to original font |
| 320 | | if (hwndHeaderCtrl) |
| 321 | | SetWindowFont(hwndHeaderCtrl, hHeaderCtrlFont, TRUE); |
| 322 | | |
| 323 | | return rc; |
| 324 | | } |
| 325 | | |
| 326 | | |
| 327 | | |
| 328 | | // Re/initialize the ListControl Columns |
| 329 | | static void Picker_InternalResetColumnDisplay(HWND hWnd, BOOL bFirstTime) |
| 330 | | { |
| 331 | | LV_COLUMN lvc; |
| 332 | | int i; |
| 333 | | int nColumn; |
| 334 | | int *widths; |
| 335 | | int *order; |
| 336 | | int *shown; |
| 337 | | int shown_columns; |
| 338 | | LVCOLUMN col; |
| 339 | | struct PickerInfo *pPickerInfo; |
| 340 | | |
| 341 | | pPickerInfo = GetPickerInfo(hWnd); |
| 342 | | |
| 343 | | widths = malloc(pPickerInfo->nColumnCount * sizeof(*widths)); |
| 344 | | order = malloc(pPickerInfo->nColumnCount * sizeof(*order)); |
| 345 | | shown = malloc(pPickerInfo->nColumnCount * sizeof(*shown)); |
| 346 | | if (!widths || !order || !shown) |
| 347 | | goto done; |
| 348 | | |
| 349 | | memset(widths, 0, pPickerInfo->nColumnCount * sizeof(*widths)); |
| 350 | | memset(order, 0, pPickerInfo->nColumnCount * sizeof(*order)); |
| 351 | | memset(shown, 0, pPickerInfo->nColumnCount * sizeof(*shown)); |
| 352 | | pPickerInfo->pCallbacks->pfnGetColumnWidths(widths); |
| 353 | | pPickerInfo->pCallbacks->pfnGetColumnOrder(order); |
| 354 | | pPickerInfo->pCallbacks->pfnGetColumnShown(shown); |
| 355 | | |
| 356 | | if (!bFirstTime) |
| 357 | | { |
| 358 | | DWORD style = GetWindowLong(hWnd, GWL_STYLE); |
| 359 | | |
| 360 | | // switch the list view to LVS_REPORT style so column widths reported correctly |
| 361 | | SetWindowLong(hWnd, GWL_STYLE, |
| 362 | | (GetWindowLong(hWnd, GWL_STYLE) & ~LVS_TYPEMASK) | LVS_REPORT); |
| 363 | | |
| 364 | | // Retrieve each of the column widths |
| 365 | | i = 0; |
| 366 | | memset(&col, 0, sizeof(col)); |
| 367 | | col.mask = LVCF_WIDTH; |
| 368 | | while(ListView_GetColumn(hWnd, 0, &col)) |
| 369 | | { |
| 370 | | nColumn = Picker_GetRealColumnFromViewColumn(hWnd, i++); |
| 371 | | widths[nColumn] = col.cx; |
| 372 | | ListView_DeleteColumn(hWnd, 0); |
| 373 | | } |
| 374 | | |
| 375 | | pPickerInfo->pCallbacks->pfnSetColumnWidths(widths); |
| 376 | | |
| 377 | | // restore old style |
| 378 | | SetWindowLong(hWnd, GWL_STYLE, style); |
| 379 | | } |
| 380 | | |
| 381 | | nColumn = 0; |
| 382 | | for (i = 0; i < pPickerInfo->nColumnCount; i++) |
| 383 | | { |
| 384 | | if (shown[order[i]]) |
| 385 | | { |
| 386 | | lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT; |
| 387 | | lvc.pszText = (LPTSTR) pPickerInfo->ppszColumnNames[order[i]]; |
| 388 | | lvc.iSubItem = nColumn; |
| 389 | | lvc.cx = widths[order[i]]; |
| 390 | | lvc.fmt = LVCFMT_LEFT; |
| 391 | | ListView_InsertColumn(hWnd, nColumn, &lvc); |
| 392 | | pPickerInfo->pnColumnsOrder[nColumn] = order[i]; |
| 393 | | |
| 394 | | dprintf("Visible column %d: Logical column %d; Width=%d\n", nColumn, order[i], widths[order[i]]); |
| 395 | | |
| 396 | | nColumn++; |
| 397 | | } |
| 398 | | } |
| 399 | | |
| 400 | | shown_columns = nColumn; |
| 401 | | |
| 402 | | /* Fill this in so we can still sort on columns NOT shown */ |
| 403 | | for (i = 0; i < pPickerInfo->nColumnCount && nColumn < pPickerInfo->nColumnCount; i++) |
| 404 | | { |
| 405 | | if (!shown[order[i]]) |
| 406 | | { |
| 407 | | pPickerInfo->pnColumnsOrder[nColumn] = order[i]; |
| 408 | | nColumn++; |
| 409 | | } |
| 410 | | } |
| 411 | | |
| 412 | | if (GetListFontColor() == RGB(255, 255, 255)) |
| 413 | | ListView_SetTextColor(hWnd, RGB(240, 240, 240)); |
| 414 | | else |
| 415 | | ListView_SetTextColor(hWnd, GetListFontColor()); |
| 416 | | |
| 417 | | done: |
| 418 | | if (widths) |
| 419 | | free(widths); |
| 420 | | if (order) |
| 421 | | free(order); |
| 422 | | if (shown) |
| 423 | | free(shown); |
| 424 | | } |
| 425 | | |
| 426 | | |
| 427 | | |
| 428 | | void Picker_ResetColumnDisplay(HWND hWnd) |
| 429 | | { |
| 430 | | Picker_InternalResetColumnDisplay(hWnd, FALSE); |
| 431 | | } |
| 432 | | |
| 433 | | |
| 434 | | |
| 435 | | void Picker_ClearIdle(HWND hwndPicker) |
| 436 | | { |
| 437 | | struct PickerInfo *pPickerInfo; |
| 438 | | |
| 439 | | pPickerInfo = GetPickerInfo(hwndPicker); |
| 440 | | if (pPickerInfo->nTimer) |
| 441 | | { |
| 442 | | KillTimer(hwndPicker, 0); |
| 443 | | pPickerInfo->nTimer = 0; |
| 444 | | } |
| 445 | | } |
| 446 | | |
| 447 | | |
| 448 | | |
| 449 | | static void CALLBACK Picker_TimerProc(HWND hwndPicker, UINT uMsg, |
| 450 | | UINT_PTR idEvent, DWORD dwTime) |
| 451 | | { |
| 452 | | struct PickerInfo *pPickerInfo; |
| 453 | | BOOL bContinueIdle; |
| 454 | | DWORD nTickCount, nBaseTickCount; |
| 455 | | DWORD nMaxIdleTicks = 50; |
| 456 | | |
| 457 | | pPickerInfo = GetPickerInfo(hwndPicker); |
| 458 | | bContinueIdle = FALSE; |
| 459 | | nBaseTickCount = GetTickCount(); |
| 460 | | |
| 461 | | // This idle procedure will loop until either idling is over, or until |
| 462 | | // a specified amount of time elapses (in this case, 50ms). This frees |
| 463 | | // idle callbacks of any responsibility for balancing their workloads; the |
| 464 | | // picker code will |
| 465 | | do |
| 466 | | { |
| 467 | | if (pPickerInfo->pCallbacks->pfnOnIdle) |
| 468 | | bContinueIdle = pPickerInfo->pCallbacks->pfnOnIdle(hwndPicker); |
| 469 | | nTickCount = GetTickCount(); |
| 470 | | } |
| 471 | | while(bContinueIdle && ((nTickCount - nBaseTickCount) < nMaxIdleTicks)); |
| 472 | | |
| 473 | | if (!bContinueIdle) |
| 474 | | Picker_ClearIdle(hwndPicker); |
| 475 | | } |
| 476 | | |
| 477 | | |
| 478 | | |
| 479 | | // Instructs this picker to reset idling; idling will continue until the |
| 480 | | // idle function returns FALSE |
| 481 | | void Picker_ResetIdle(HWND hwndPicker) |
| 482 | | { |
| 483 | | struct PickerInfo *pPickerInfo; |
| 484 | | |
| 485 | | pPickerInfo = GetPickerInfo(hwndPicker); |
| 486 | | |
| 487 | | Picker_ClearIdle(hwndPicker); |
| 488 | | if (pPickerInfo->pCallbacks->pfnOnIdle) |
| 489 | | pPickerInfo->nTimer = SetTimer(hwndPicker, 0, 0, Picker_TimerProc); |
| 490 | | } |
| 491 | | |
| 492 | | |
| 493 | | |
| 494 | | BOOL Picker_IsIdling(HWND hwndPicker) |
| 495 | | { |
| 496 | | struct PickerInfo *pPickerInfo; |
| 497 | | pPickerInfo = GetPickerInfo(hwndPicker); |
| 498 | | return pPickerInfo->nTimer != 0; |
| 499 | | } |
| 500 | | |
| 501 | | |
| 502 | | |
| 503 | | BOOL SetupPicker(HWND hwndPicker, const struct PickerOptions *pOptions) |
| 504 | | { |
| 505 | | struct PickerInfo *pPickerInfo; |
| 506 | | int i; |
| 507 | | LONG_PTR l; |
| 508 | | |
| 509 | | assert(hwndPicker); |
| 510 | | |
| 511 | | // Allocate the list view struct |
| 512 | | pPickerInfo = (struct PickerInfo *) malloc(sizeof(struct PickerInfo)); |
| 513 | | if (!pPickerInfo) |
| 514 | | return FALSE; |
| 515 | | |
| 516 | | // And fill it out |
| 517 | | memset(pPickerInfo, 0, sizeof(*pPickerInfo)); |
| 518 | | pPickerInfo->pCallbacks = pOptions->pCallbacks; |
| 519 | | pPickerInfo->nColumnCount = pOptions->nColumnCount; |
| 520 | | pPickerInfo->ppszColumnNames = pOptions->ppszColumnNames; |
| 521 | | pPickerInfo->nLastItem = -1; |
| 522 | | |
| 523 | | if (pPickerInfo->nColumnCount) |
| 524 | | { |
| 525 | | // Allocate space for the column order and columns shown array |
| 526 | | pPickerInfo->pnColumnsOrder = malloc(pPickerInfo->nColumnCount * |
| 527 | | sizeof(*pPickerInfo->pnColumnsOrder)); |
| 528 | | pPickerInfo->pnColumnsShown = malloc(pPickerInfo->nColumnCount * |
| 529 | | sizeof(*pPickerInfo->pnColumnsShown)); |
| 530 | | if (!pPickerInfo->pnColumnsOrder || !pPickerInfo->pnColumnsShown) |
| 531 | | goto error; |
| 532 | | |
| 533 | | // set up initial values |
| 534 | | for (i = 0; i < pPickerInfo->nColumnCount; i++) |
| 535 | | { |
| 536 | | pPickerInfo->pnColumnsOrder[i] = i; |
| 537 | | pPickerInfo->pnColumnsShown[i] = TRUE; |
| 538 | | } |
| 539 | | |
| 540 | | if (GetUseOldControl()) |
| 541 | | { |
| 542 | | if (pPickerInfo->pCallbacks->pfnSetColumnOrder) |
| 543 | | pPickerInfo->pCallbacks->pfnSetColumnOrder(pPickerInfo->pnColumnsOrder); |
| 544 | | if (pPickerInfo->pCallbacks->pfnSetColumnShown) |
| 545 | | pPickerInfo->pCallbacks->pfnSetColumnShown(pPickerInfo->pnColumnsShown); |
| 546 | | } |
| 547 | | else |
| 548 | | { |
| 549 | | if (pPickerInfo->pCallbacks->pfnGetColumnOrder) |
| 550 | | pPickerInfo->pCallbacks->pfnGetColumnOrder(pPickerInfo->pnColumnsOrder); |
| 551 | | if (pPickerInfo->pCallbacks->pfnGetColumnShown) |
| 552 | | pPickerInfo->pCallbacks->pfnGetColumnShown(pPickerInfo->pnColumnsShown); |
| 553 | | } |
| 554 | | } |
| 555 | | |
| 556 | | // Hook in our wndproc and userdata pointer |
| 557 | | l = GetWindowLongPtr(hwndPicker, GWLP_WNDPROC); |
| 558 | | pPickerInfo->pfnParentWndProc = (WNDPROC) l; |
| 559 | | SetWindowLongPtr(hwndPicker, GWLP_USERDATA, (LONG_PTR) pPickerInfo); |
| 560 | | SetWindowLongPtr(hwndPicker, GWLP_WNDPROC, (LONG_PTR) ListViewWndProc); |
| 561 | | |
| 562 | | ListView_SetExtendedListViewStyle(hwndPicker, LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP | |
| 563 | | LVS_EX_UNDERLINEHOT | LVS_EX_UNDERLINECOLD | LVS_EX_LABELTIP); |
| 564 | | |
| 565 | | Picker_InternalResetColumnDisplay(hwndPicker, TRUE); |
| 566 | | Picker_ResetIdle(hwndPicker); |
| 567 | | return TRUE; |
| 568 | | |
| 569 | | error: |
| 570 | | if (pPickerInfo) |
| 571 | | Picker_Free(pPickerInfo); |
| 572 | | return FALSE; |
| 573 | | } |
| 574 | | |
| 575 | | |
| 576 | | |
| 577 | | int Picker_GetViewID(HWND hwndPicker) |
| 578 | | { |
| 579 | | struct PickerInfo *pPickerInfo; |
| 580 | | pPickerInfo = GetPickerInfo(hwndPicker); |
| 581 | | return pPickerInfo->nCurrentViewID; |
| 582 | | } |
| 583 | | |
| 584 | | |
| 585 | | |
| 586 | | void Picker_SetViewID(HWND hwndPicker, int nViewID) |
| 587 | | { |
| 588 | | struct PickerInfo *pPickerInfo; |
| 589 | | LONG_PTR nListViewStyle; |
| 590 | | DWORD dwStyle; |
| 591 | | |
| 592 | | pPickerInfo = GetPickerInfo(hwndPicker); |
| 593 | | |
| 594 | | // Change the nCurrentViewID member |
| 595 | | pPickerInfo->nCurrentViewID = nViewID; |
| 596 | | if (pPickerInfo->pCallbacks->pfnSetViewMode) |
| 597 | | pPickerInfo->pCallbacks->pfnSetViewMode(pPickerInfo->nCurrentViewID); |
| 598 | | |
| 599 | | // Change the ListView flags in accordance |
| 600 | | switch(nViewID) |
| 601 | | { |
| 602 | | case VIEW_LARGE_ICONS: |
| 603 | | nListViewStyle = LVS_ICON; |
| 604 | | break; |
| 605 | | case VIEW_SMALL_ICONS: |
| 606 | | nListViewStyle = LVS_SMALLICON; |
| 607 | | break; |
| 608 | | case VIEW_INLIST: |
| 609 | | nListViewStyle = LVS_LIST; |
| 610 | | break; |
| 611 | | case VIEW_GROUPED: |
| 612 | | case VIEW_REPORT: |
| 613 | | default: |
| 614 | | nListViewStyle = LVS_REPORT; |
| 615 | | break; |
| 616 | | } |
| 617 | | |
| 618 | | dwStyle = GetWindowLong(hwndPicker, GWL_STYLE); |
| 619 | | if (GetUseXPControl()) |
| 620 | | { |
| 621 | | // RS Microsoft must have changed something in the Ownerdraw handling with Version 6 of the Common Controls |
| 622 | | // as on all other OSes it works without this... |
| 623 | | if (nViewID == VIEW_LARGE_ICONS || nViewID == VIEW_SMALL_ICONS) |
| 624 | | { |
| 625 | | // remove Ownerdraw style for Icon views |
| 626 | | dwStyle &= ~LVS_OWNERDRAWFIXED; |
| 627 | | if( nViewID == VIEW_SMALL_ICONS ) |
| 628 | | { |
| 629 | | // to properly get them to arrange, otherwise the entries might overlap |
| 630 | | // we have to call SetWindowLong to get it into effect !! |
| 631 | | // It's no use just setting the Style, as it's changed again further down... |
| 632 | | SetWindowLong(hwndPicker, GWL_STYLE, (GetWindowLong(hwndPicker, GWL_STYLE) |
| 633 | | & ~LVS_TYPEMASK) | LVS_ICON); |
| 634 | | } |
| 635 | | } |
| 636 | | else |
| 637 | | { |
| 638 | | // add again.. |
| 639 | | dwStyle |= LVS_OWNERDRAWFIXED; |
| 640 | | } |
| 641 | | } |
| 642 | | |
| 643 | | dwStyle &= ~LVS_TYPEMASK; |
| 644 | | dwStyle |= nListViewStyle; |
| 645 | | SetWindowLong(hwndPicker, GWL_STYLE, dwStyle); |
| 646 | | RedrawWindow(hwndPicker, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME); |
| 647 | | } |
| 648 | | |
| 649 | | |
| 650 | | |
| 651 | | static BOOL PickerHitTest(HWND hWnd) |
| 652 | | { |
| 653 | | RECT rect; |
| 654 | | POINTS p; |
| 655 | | DWORD res = GetMessagePos(); |
| 656 | | LVHITTESTINFO htInfo; |
| 657 | | |
| 658 | | memset(&htInfo, 0, sizeof(htInfo)); |
| 659 | | p = MAKEPOINTS(res); |
| 660 | | GetWindowRect(hWnd, &rect); |
| 661 | | htInfo.pt.x = p.x - rect.left; |
| 662 | | htInfo.pt.y = p.y - rect.top; |
| 663 | | ListView_HitTest(hWnd, &htInfo); |
| 664 | | |
| 665 | | return (! (htInfo.flags & LVHT_NOWHERE)); |
| 666 | | } |
| 667 | | |
| 668 | | |
| 669 | | |
| 670 | | int Picker_GetSelectedItem(HWND hWnd) |
| 671 | | { |
| 672 | | int nItem; |
| 673 | | LV_ITEM lvi; |
| 674 | | |
| 675 | | nItem = ListView_GetNextItem(hWnd, -1, LVIS_SELECTED | LVIS_FOCUSED); |
| 676 | | if (nItem < 0) |
| 677 | | return 0; |
| 678 | | |
| 679 | | memset(&lvi, 0, sizeof(lvi)); |
| 680 | | lvi.iItem = nItem; |
| 681 | | lvi.mask = LVIF_PARAM; |
| 682 | | ListView_GetItem(hWnd, &lvi); |
| 683 | | return lvi.lParam; |
| 684 | | } |
| 685 | | |
| 686 | | |
| 687 | | |
| 688 | | void Picker_SetSelectedPick(HWND hWnd, int nIndex) |
| 689 | | { |
| 690 | | if (nIndex < 0) |
| 691 | | nIndex = 0; |
| 692 | | |
| 693 | | ListView_SetItemState(hWnd, nIndex, LVIS_FOCUSED | LVIS_SELECTED, |
| 694 | | LVIS_FOCUSED | LVIS_SELECTED); |
| 695 | | ListView_EnsureVisible(hWnd, nIndex, FALSE); |
| 696 | | } |
| 697 | | |
| 698 | | |
| 699 | | |
| 700 | | void Picker_SetSelectedItem(HWND hWnd, int nItem) |
| 701 | | { |
| 702 | | int i; |
| 703 | | LV_FINDINFO lvfi; |
| 704 | | |
| 705 | | if (nItem < 0) |
| 706 | | return; |
| 707 | | |
| 708 | | lvfi.flags = LVFI_PARAM; |
| 709 | | lvfi.lParam = nItem; |
| 710 | | i = ListView_FindItem(hWnd, -1, &lvfi); |
| 711 | | if (i == -1) |
| 712 | | { |
| 713 | | POINT p = {0,0}; |
| 714 | | lvfi.flags = LVFI_NEARESTXY; |
| 715 | | lvfi.pt = p; |
| 716 | | i = ListView_FindItem(hWnd, -1, &lvfi); |
| 717 | | } |
| 718 | | Picker_SetSelectedPick(hWnd, (i == -1) ? 0 : i); |
| 719 | | } |
| 720 | | |
| 721 | | |
| 722 | | |
| 723 | | static const TCHAR *Picker_CallGetItemString(HWND hwndPicker, |
| 724 | | int nItem, int nColumn, TCHAR *pszBuffer, UINT nBufferLength) |
| 725 | | { |
| 726 | | // this call wraps the pfnGetItemString callback to properly set up the |
| 727 | | // buffers, and normalize the results |
| 728 | | struct PickerInfo *pPickerInfo; |
| 729 | | const TCHAR *s; |
| 730 | | |
| 731 | | pPickerInfo = GetPickerInfo(hwndPicker); |
| 732 | | pszBuffer[0] = '\0'; |
| 733 | | s = NULL; |
| 734 | | |
| 735 | | if (pPickerInfo->pCallbacks->pfnGetItemString) |
| 736 | | { |
| 737 | | s = pPickerInfo->pCallbacks->pfnGetItemString(hwndPicker, |
| 738 | | nItem, nColumn, pszBuffer, nBufferLength); |
| 739 | | } |
| 740 | | if (!s) |
| 741 | | s = pszBuffer; |
| 742 | | return s; |
| 743 | | } |
| 744 | | |
| 745 | | |
| 746 | | |
| 747 | | // put the arrow on the new sort column |
| 748 | | static void Picker_ResetHeaderSortIcon(HWND hwndPicker) |
| 749 | | { |
| 750 | | struct PickerInfo *pPickerInfo; |
| 751 | | HWND hwndHeader; |
| 752 | | HD_ITEM hdi; |
| 753 | | int i, nViewColumn; |
| 754 | | |
| 755 | | pPickerInfo = GetPickerInfo(hwndPicker); |
| 756 | | |
| 757 | | hwndHeader = ListView_GetHeader(hwndPicker); |
| 758 | | |
| 759 | | // take arrow off non-current columns |
| 760 | | hdi.mask = HDI_FORMAT; |
| 761 | | hdi.fmt = HDF_STRING; |
| 762 | | for (i = 0; i < pPickerInfo->nColumnCount; i++) |
| 763 | | { |
| 764 | | if (i != pPickerInfo->pCallbacks->pfnGetSortColumn()) |
| 765 | | Header_SetItem(hwndHeader, Picker_GetViewColumnFromRealColumn(hwndPicker, i), &hdi); |
| 766 | | } |
| 767 | | |
| 768 | | if (GetUseXPControl()) |
| 769 | | { |
| 770 | | // use built in sort arrows |
| 771 | | hdi.mask = HDI_FORMAT; |
| 772 | | hdi.fmt = HDF_STRING | (pPickerInfo->pCallbacks->pfnGetSortReverse() ? HDF_SORTDOWN : HDF_SORTUP); |
| 773 | | } |
| 774 | | else |
| 775 | | { |
| 776 | | // put our arrow icon next to the text |
| 777 | | hdi.mask = HDI_FORMAT | HDI_IMAGE; |
| 778 | | hdi.fmt = HDF_STRING | HDF_IMAGE | HDF_BITMAP_ON_RIGHT; |
| 779 | | hdi.iImage = pPickerInfo->pCallbacks->pfnGetSortReverse() ? 1 : 0; |
| 780 | | } |
| 781 | | |
| 782 | | nViewColumn = Picker_GetViewColumnFromRealColumn(hwndPicker, pPickerInfo->pCallbacks->pfnGetSortColumn()); |
| 783 | | Header_SetItem(hwndHeader, nViewColumn, &hdi); |
| 784 | | } |
| 785 | | |
| 786 | | |
| 787 | | |
| 788 | | struct CompareProcParams |
| 789 | | { |
| 790 | | HWND hwndPicker; |
| 791 | | struct PickerInfo *pPickerInfo; |
| 792 | | int nSortColumn; |
| 793 | | int nViewMode; |
| 794 | | BOOL bReverse; |
| 795 | | }; |
| 796 | | |
| 797 | | |
| 798 | | |
| 799 | | static void Picker_PopulateCompareProcParams(HWND hwndPicker, |
| 800 | | struct CompareProcParams *pParams) |
| 801 | | { |
| 802 | | struct PickerInfo *pPickerInfo; |
| 803 | | |
| 804 | | pPickerInfo = GetPickerInfo(hwndPicker); |
| 805 | | |
| 806 | | // populate the CompareProcParams structure |
| 807 | | memset(pParams, 0, sizeof(*pParams)); |
| 808 | | pParams->hwndPicker = hwndPicker; |
| 809 | | pParams->pPickerInfo = pPickerInfo; |
| 810 | | pParams->nViewMode = pPickerInfo->pCallbacks->pfnGetViewMode(); |
| 811 | | if (pPickerInfo->pCallbacks->pfnGetSortColumn) |
| 812 | | pParams->nSortColumn = pPickerInfo->pCallbacks->pfnGetSortColumn(); |
| 813 | | if (pPickerInfo->pCallbacks->pfnGetSortReverse) |
| 814 | | pParams->bReverse = pPickerInfo->pCallbacks->pfnGetSortReverse(); |
| 815 | | } |
| 816 | | |
| 817 | | |
| 818 | | |
| 819 | | static int CALLBACK Picker_CompareProc(LPARAM index1, LPARAM index2, LPARAM nParamSort) |
| 820 | | { |
| 821 | | struct CompareProcParams *pcpp = (struct CompareProcParams *) nParamSort; |
| 822 | | struct PickerInfo *pPickerInfo = pcpp->pPickerInfo; |
| 823 | | BOOL bCallCompare = TRUE; |
| 824 | | int nResult = 0, nParent1, nParent2; |
| 825 | | TCHAR szBuffer1[256], szBuffer2[256]; |
| 826 | | const TCHAR *s1, *s2; |
| 827 | | |
| 828 | | if (pcpp->nViewMode == VIEW_GROUPED) |
| 829 | | { |
| 830 | | // do our fancy compare, with clones grouped under parents |
| 831 | | // first thing we need to do is identify both item's parents |
| 832 | | if (pPickerInfo->pCallbacks->pfnFindItemParent) |
| 833 | | { |
| 834 | | nParent1 = pPickerInfo->pCallbacks->pfnFindItemParent(pcpp->hwndPicker, index1); |
| 835 | | nParent2 = pPickerInfo->pCallbacks->pfnFindItemParent(pcpp->hwndPicker, index2); |
| 836 | | } |
| 837 | | else |
| 838 | | { |
| 839 | | nParent1 = nParent2 = -1; |
| 840 | | } |
| 841 | | |
| 842 | | if ((nParent1 < 0) && (nParent2 < 0)) |
| 843 | | { |
| 844 | | // if both entries are both parents, we just do a basic sort |
| 845 | | } |
| 846 | | else if ((nParent1 >= 0) && (nParent2 >= 0)) |
| 847 | | { |
| 848 | | // if both entries are children and the parents are different, |
| 849 | | // sort on their parents |
| 850 | | if (nParent1 != nParent2) |
| 851 | | { |
| 852 | | index1 = nParent1; |
| 853 | | index2 = nParent2; |
| 854 | | } |
| 855 | | } |
| 856 | | else |
| 857 | | { |
| 858 | | // one parent, one child |
| 859 | | if (nParent1 >= 0) |
| 860 | | { |
| 861 | | // first one is a child |
| 862 | | if (nParent1 == index2) |
| 863 | | { |
| 864 | | // if this is a child and its parent, put child after |
| 865 | | nResult = 1; |
| 866 | | bCallCompare = FALSE; |
| 867 | | } |
| 868 | | else |
| 869 | | { |
| 870 | | // sort on parent |
| 871 | | index1 = nParent1; |
| 872 | | } |
| 873 | | } |
| 874 | | else |
| 875 | | { |
| 876 | | // second one is a child |
| 877 | | if (nParent2 == index1) |
| 878 | | { |
| 879 | | // if this is a child and its parent, put child after |
| 880 | | nResult = -1; |
| 881 | | bCallCompare = FALSE; |
| 882 | | } |
| 883 | | else |
| 884 | | { |
| 885 | | // sort on parent |
| 886 | | index2 = nParent2; |
| 887 | | } |
| 888 | | } |
| 889 | | } |
| 890 | | } |
| 891 | | |
| 892 | | if (bCallCompare) |
| 893 | | { |
| 894 | | if (pPickerInfo->pCallbacks->pfnCompare) |
| 895 | | { |
| 896 | | nResult = pPickerInfo->pCallbacks->pfnCompare(pcpp->hwndPicker, |
| 897 | | index1, index2, pcpp->nSortColumn); |
| 898 | | } |
| 899 | | else |
| 900 | | { |
| 901 | | // no default sort proc, just get the string and compare them |
| 902 | | s1 = Picker_CallGetItemString(pcpp->hwndPicker, index1, pcpp->nSortColumn, |
| 903 | | szBuffer1, sizeof(szBuffer1) / sizeof(szBuffer1[0])); |
| 904 | | s2 = Picker_CallGetItemString(pcpp->hwndPicker, index2, pcpp->nSortColumn, |
| 905 | | szBuffer2, sizeof(szBuffer2) / sizeof(szBuffer2[0])); |
| 906 | | nResult = _tcsicmp(s1, s2); |
| 907 | | } |
| 908 | | |
| 909 | | if (pcpp->bReverse) |
| 910 | | nResult = -nResult; |
| 911 | | } |
| 912 | | return nResult; |
| 913 | | } |
| 914 | | |
| 915 | | |
| 916 | | |
| 917 | | void Picker_Sort(HWND hwndPicker) |
| 918 | | { |
| 919 | | LV_FINDINFO lvfi; |
| 920 | | struct PickerInfo *pPickerInfo; |
| 921 | | struct CompareProcParams params; |
| 922 | | int nItem; |
| 923 | | |
| 924 | | pPickerInfo = GetPickerInfo(hwndPicker); |
| 925 | | |
| 926 | | // populate the CompareProcParams structure |
| 927 | | Picker_PopulateCompareProcParams(hwndPicker, ¶ms); |
| 928 | | |
| 929 | | ListView_SortItems(hwndPicker, Picker_CompareProc, (LPARAM) ¶ms); |
| 930 | | |
| 931 | | Picker_ResetHeaderSortIcon(hwndPicker); |
| 932 | | |
| 933 | | memset(&lvfi, 0, sizeof(lvfi)); |
| 934 | | lvfi.flags = LVFI_PARAM; |
| 935 | | lvfi.lParam = Picker_GetSelectedItem(hwndPicker); |
| 936 | | nItem = ListView_FindItem(hwndPicker, -1, &lvfi); |
| 937 | | |
| 938 | | ListView_EnsureVisible(hwndPicker, nItem, FALSE); |
| 939 | | } |
| 940 | | |
| 941 | | |
| 942 | | |
| 943 | | int Picker_InsertItemSorted(HWND hwndPicker, int nParam) |
| 944 | | { |
| 945 | | struct PickerInfo *pPickerInfo; |
| 946 | | int nHigh, nLow, nMid; |
| 947 | | struct CompareProcParams params; |
| 948 | | int nCompareResult; |
| 949 | | LVITEM lvi; |
| 950 | | |
| 951 | | pPickerInfo = GetPickerInfo(hwndPicker); |
| 952 | | |
| 953 | | nLow = 0; |
| 954 | | nHigh = ListView_GetItemCount(hwndPicker); |
| 955 | | |
| 956 | | // populate the CompareProcParams structure |
| 957 | | Picker_PopulateCompareProcParams(hwndPicker, ¶ms); |
| 958 | | |
| 959 | | while(nLow < nHigh) |
| 960 | | { |
| 961 | | nMid = (nHigh + nLow) / 2; |
| 962 | | |
| 963 | | memset(&lvi, 0, sizeof(lvi)); |
| 964 | | lvi.mask = LVIF_PARAM; |
| 965 | | lvi.iItem = nMid; |
| 966 | | ListView_GetItem(hwndPicker, &lvi); |
| 967 | | |
| 968 | | nCompareResult = Picker_CompareProc(nParam, lvi.lParam, (LPARAM) ¶ms); |
| 969 | | |
| 970 | | if (nCompareResult > 0) |
| 971 | | nLow = nMid + 1; |
| 972 | | else if (nCompareResult < 0) |
| 973 | | nHigh = nMid; |
| 974 | | else |
| 975 | | { |
| 976 | | nLow = nMid; |
| 977 | | break; |
| 978 | | } |
| 979 | | } |
| 980 | | |
| 981 | | memset(&lvi, 0, sizeof(lvi)); |
| 982 | | lvi.mask = LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM; |
| 983 | | lvi.iItem = nLow; |
| 984 | | lvi.iSubItem = 0; |
| 985 | | lvi.lParam = nParam; |
| 986 | | lvi.pszText = LPSTR_TEXTCALLBACK; |
| 987 | | lvi.iImage = I_IMAGECALLBACK; |
| 988 | | |
| 989 | | return ListView_InsertItem(hwndPicker, &lvi); |
| 990 | | } |
| 991 | | |
| 992 | | |
| 993 | | |
| 994 | | int Picker_GetRealColumnFromViewColumn(HWND hWnd, int nViewColumn) |
| 995 | | { |
| 996 | | struct PickerInfo *pPickerInfo; |
| 997 | | int nRealColumn = 0; |
| 998 | | |
| 999 | | pPickerInfo = GetPickerInfo(hWnd); |
| 1000 | | if (nViewColumn >= 0 && nViewColumn < pPickerInfo->nColumnCount) |
| 1001 | | nRealColumn = pPickerInfo->pnColumnsOrder[nViewColumn]; |
| 1002 | | return nRealColumn; |
| 1003 | | } |
| 1004 | | |
| 1005 | | |
| 1006 | | |
| 1007 | | int Picker_GetViewColumnFromRealColumn(HWND hWnd, int nRealColumn) |
| 1008 | | { |
| 1009 | | struct PickerInfo *pPickerInfo; |
| 1010 | | int i; |
| 1011 | | |
| 1012 | | pPickerInfo = GetPickerInfo(hWnd); |
| 1013 | | for (i = 0; i < pPickerInfo->nColumnCount; i++) |
| 1014 | | { |
| 1015 | | if (pPickerInfo->pnColumnsOrder[i] == nRealColumn) |
| 1016 | | return i; |
| 1017 | | } |
| 1018 | | |
| 1019 | | // major error, shouldn't be possible, but no good way to warn |
| 1020 | | return 0; |
| 1021 | | } |
| 1022 | | |
| 1023 | | |
| 1024 | | |
| 1025 | | BOOL Picker_HandleNotify(LPNMHDR lpNmHdr) |
| 1026 | | { |
| 1027 | | struct PickerInfo *pPickerInfo; |
| 1028 | | HWND hWnd; |
| 1029 | | BOOL bResult = FALSE; |
| 1030 | | NM_LISTVIEW *pnmv; |
| 1031 | | LV_DISPINFO *pDispInfo; |
| 1032 | | int nItem, nColumn; |
| 1033 | | const TCHAR *s; |
| 1034 | | BOOL bReverse; |
| 1035 | | |
| 1036 | | hWnd = lpNmHdr->hwndFrom; |
| 1037 | | pPickerInfo = GetPickerInfo(hWnd); |
| 1038 | | pnmv = (NM_LISTVIEW *) lpNmHdr; |
| 1039 | | |
| 1040 | | switch(lpNmHdr->code) |
| 1041 | | { |
| 1042 | | case NM_RCLICK: |
| 1043 | | case NM_CLICK: |
| 1044 | | case NM_DBLCLK: |
| 1045 | | // don't allow selection of blank spaces in the listview |
| 1046 | | if (!PickerHitTest(hWnd)) |
| 1047 | | { |
| 1048 | | // we have no current item selected |
| 1049 | | if (pPickerInfo->nLastItem != -1) |
| 1050 | | { |
| 1051 | | Picker_SetSelectedItem(hWnd, pPickerInfo->nLastItem); |
| 1052 | | } |
| 1053 | | bResult = TRUE; |
| 1054 | | } |
| 1055 | | else if ((lpNmHdr->code == NM_DBLCLK) && (pPickerInfo->pCallbacks->pfnDoubleClick)) |
| 1056 | | { |
| 1057 | | // double click! |
| 1058 | | pPickerInfo->pCallbacks->pfnDoubleClick(); |
| 1059 | | bResult = TRUE; |
| 1060 | | } |
| 1061 | | break; |
| 1062 | | |
| 1063 | | case LVN_GETDISPINFO: |
| 1064 | | pDispInfo = (LV_DISPINFO *) lpNmHdr; |
| 1065 | | nItem = (int) pDispInfo->item.lParam; |
| 1066 | | |
| 1067 | | if (pDispInfo->item.mask & LVIF_IMAGE) |
| 1068 | | { |
| 1069 | | // retrieve item image |
| 1070 | | if (pPickerInfo->pCallbacks->pfnGetItemImage) |
| 1071 | | pDispInfo->item.iImage = pPickerInfo->pCallbacks->pfnGetItemImage(hWnd, nItem); |
| 1072 | | else |
| 1073 | | pDispInfo->item.iImage = 0; |
| 1074 | | bResult = TRUE; |
| 1075 | | } |
| 1076 | | |
| 1077 | | if (pDispInfo->item.mask & LVIF_STATE) |
| 1078 | | { |
| 1079 | | pDispInfo->item.state = 0; |
| 1080 | | bResult = TRUE; |
| 1081 | | } |
| 1082 | | |
| 1083 | | if (pDispInfo->item.mask & LVIF_TEXT) |
| 1084 | | { |
| 1085 | | // retrieve item text |
| 1086 | | nColumn = Picker_GetRealColumnFromViewColumn(hWnd, pDispInfo->item.iSubItem); |
| 1087 | | |
| 1088 | | s = Picker_CallGetItemString(hWnd, nItem, nColumn, |
| 1089 | | pDispInfo->item.pszText, pDispInfo->item.cchTextMax); |
| 1090 | | |
| 1091 | | pDispInfo->item.pszText = (TCHAR *) s; |
| 1092 | | bResult = TRUE; |
| 1093 | | } |
| 1094 | | break; |
| 1095 | | |
| 1096 | | case LVN_ITEMCHANGED: |
| 1097 | | if ((pnmv->uOldState & LVIS_SELECTED) |
| 1098 | | && !(pnmv->uNewState & LVIS_SELECTED)) |
| 1099 | | { |
| 1100 | | if (pnmv->lParam != -1) |
| 1101 | | pPickerInfo->nLastItem = pnmv->lParam; |
| 1102 | | if (pPickerInfo->pCallbacks->pfnLeavingItem) |
| 1103 | | pPickerInfo->pCallbacks->pfnLeavingItem(hWnd, pnmv->lParam); |
| 1104 | | } |
| 1105 | | if (!(pnmv->uOldState & LVIS_SELECTED) |
| 1106 | | && (pnmv->uNewState & LVIS_SELECTED)) |
| 1107 | | { |
| 1108 | | if (pPickerInfo->pCallbacks->pfnEnteringItem) |
| 1109 | | pPickerInfo->pCallbacks->pfnEnteringItem(hWnd, pnmv->lParam); |
| 1110 | | } |
| 1111 | | bResult = TRUE; |
| 1112 | | break; |
| 1113 | | |
| 1114 | | case LVN_COLUMNCLICK: |
| 1115 | | // if clicked on the same column we're sorting by, reverse it |
| 1116 | | if (pPickerInfo->pCallbacks->pfnGetSortColumn() == Picker_GetRealColumnFromViewColumn(hWnd, pnmv->iSubItem)) |
| 1117 | | bReverse = !pPickerInfo->pCallbacks->pfnGetSortReverse(); |
| 1118 | | else |
| 1119 | | bReverse = FALSE; |
| 1120 | | pPickerInfo->pCallbacks->pfnSetSortReverse(bReverse); |
| 1121 | | pPickerInfo->pCallbacks->pfnSetSortColumn(Picker_GetRealColumnFromViewColumn(hWnd, pnmv->iSubItem)); |
| 1122 | | Picker_Sort(hWnd); |
| 1123 | | bResult = TRUE; |
| 1124 | | break; |
| 1125 | | |
| 1126 | | case LVN_BEGINDRAG: |
| 1127 | | if (pPickerInfo->pCallbacks->pfnBeginListViewDrag) |
| 1128 | | pPickerInfo->pCallbacks->pfnBeginListViewDrag(pnmv); |
| 1129 | | break; |
| 1130 | | } |
| 1131 | | return bResult; |
| 1132 | | } |
| 1133 | | |
| 1134 | | |
| 1135 | | |
| 1136 | | int Picker_GetNumColumns(HWND hWnd) |
| 1137 | | { |
| 1138 | | int nColumnCount = 0; |
| 1139 | | int i; |
| 1140 | | HWND hwndHeader; |
| 1141 | | int *shown; |
| 1142 | | struct PickerInfo *pPickerInfo; |
| 1143 | | |
| 1144 | | pPickerInfo = GetPickerInfo(hWnd); |
| 1145 | | |
| 1146 | | shown = malloc(pPickerInfo->nColumnCount * sizeof(*shown)); |
| 1147 | | if (!shown) |
| 1148 | | return -1; |
| 1149 | | |
| 1150 | | pPickerInfo->pCallbacks->pfnGetColumnShown(shown); |
| 1151 | | hwndHeader = ListView_GetHeader(hWnd); |
| 1152 | | |
| 1153 | | if (GetUseOldControl() || (nColumnCount = Header_GetItemCount(hWnd)) < 1) |
| 1154 | | { |
| 1155 | | nColumnCount = 0; |
| 1156 | | for (i = 0; i < pPickerInfo->nColumnCount ; i++ ) |
| 1157 | | { |
| 1158 | | if (shown[i]) |
| 1159 | | nColumnCount++; |
| 1160 | | } |
| 1161 | | } |
| 1162 | | |
| 1163 | | free(shown); |
| 1164 | | return nColumnCount; |
| 1165 | | } |
| 1166 | | |
| 1167 | | |
| 1168 | | |
| 1169 | | /* Add ... to Items in ListView if needed */ |
| 1170 | | static LPCTSTR MakeShortString(HDC hDC, LPCTSTR lpszLong, int nColumnLen, int nOffset) |
| 1171 | | { |
| 1172 | | static const TCHAR szThreeDots[] = TEXT("..."); |
| 1173 | | static TCHAR szShort[MAX_PATH]; |
| 1174 | | int nStringLen = lstrlen(lpszLong); |
| 1175 | | int nAddLen; |
| 1176 | | SIZE size; |
| 1177 | | int i; |
| 1178 | | |
| 1179 | | GetTextExtentPoint32(hDC, lpszLong, nStringLen, &size); |
| 1180 | | if (nStringLen == 0 || size.cx + nOffset <= nColumnLen) |
| 1181 | | return lpszLong; |
| 1182 | | |
| 1183 | | lstrcpy(szShort, lpszLong); |
| 1184 | | GetTextExtentPoint32(hDC, szThreeDots, sizeof(szThreeDots), &size); |
| 1185 | | nAddLen = size.cx; |
| 1186 | | |
| 1187 | | for (i = nStringLen - 1; i > 0; i--) |
| 1188 | | { |
| 1189 | | szShort[i] = 0; |
| 1190 | | GetTextExtentPoint32(hDC, szShort, i, &size); |
| 1191 | | if (size.cx + nOffset + nAddLen <= nColumnLen) |
| 1192 | | break; |
| 1193 | | } |
| 1194 | | |
| 1195 | | lstrcat(szShort, szThreeDots); |
| 1196 | | |
| 1197 | | return szShort; |
| 1198 | | } |
| 1199 | | |
| 1200 | | |
| 1201 | | |
| 1202 | | void Picker_HandleDrawItem(HWND hWnd, LPDRAWITEMSTRUCT lpDrawItemStruct) |
| 1203 | | { |
| 1204 | | struct PickerInfo *pPickerInfo; |
| 1205 | | HDC hDC = lpDrawItemStruct->hDC; |
| 1206 | | RECT rcItem = lpDrawItemStruct->rcItem; |
| 1207 | | UINT uiFlags = ILD_TRANSPARENT; |
| 1208 | | HIMAGELIST hImageList; |
| 1209 | | int nItem = lpDrawItemStruct->itemID; |
| 1210 | | COLORREF clrTextSave = 0; |
| 1211 | | COLORREF clrBkSave = 0; |
| 1212 | | COLORREF clrImage = GetSysColor(COLOR_WINDOW); |
| 1213 | | static TCHAR szBuff[MAX_PATH]; |
| 1214 | | BOOL bFocus = (GetFocus() == hWnd); |
| 1215 | | LPCTSTR pszText; |
| 1216 | | UINT nStateImageMask; |
| 1217 | | BOOL bSelected; |
| 1218 | | LV_COLUMN lvc; |
| 1219 | | LV_ITEM lvi; |
| 1220 | | RECT rcAllLabels; |
| 1221 | | RECT rcLabel; |
| 1222 | | RECT rcIcon; |
| 1223 | | int offset; |
| 1224 | | SIZE size; |
| 1225 | | int i, j; |
| 1226 | | int nColumn; |
| 1227 | | int nColumnMax = 0; |
| 1228 | | int *order; |
| 1229 | | BOOL bDrawAsChild; |
| 1230 | | int indent_space; |
| 1231 | | BOOL bColorChild = FALSE; |
| 1232 | | BOOL bParentFound = FALSE; |
| 1233 | | int nParent; |
| 1234 | | HBITMAP hBackground = GetBackgroundBitmap(); |
| 1235 | | MYBITMAPINFO *pbmDesc = GetBackgroundInfo(); |
| 1236 | | |
| 1237 | | pPickerInfo = GetPickerInfo(hWnd); |
| 1238 | | |
| 1239 | | order = malloc(pPickerInfo->nColumnCount * sizeof(*order)); |
| 1240 | | if (!order) |
| 1241 | | return; |
| 1242 | | nColumnMax = Picker_GetNumColumns(hWnd); |
| 1243 | | |
| 1244 | | if (GetUseOldControl()) |
| 1245 | | { |
| 1246 | | pPickerInfo->pCallbacks->pfnGetColumnOrder(order); |
| 1247 | | } |
| 1248 | | else |
| 1249 | | { |
| 1250 | | /* Get the Column Order and save it */ |
| 1251 | | ListView_GetColumnOrderArray(hWnd, nColumnMax, order); |
| 1252 | | |
| 1253 | | /* Disallow moving column 0 */ |
| 1254 | | if (order[0] != 0) |
| 1255 | | { |
| 1256 | | for (i = 0; i < nColumnMax; i++) |
| 1257 | | { |
| 1258 | | if (order[i] == 0) |
| 1259 | | { |
| 1260 | | order[i] = order[0]; |
| 1261 | | order[0] = 0; |
| 1262 | | } |
| 1263 | | } |
| 1264 | | ListView_SetColumnOrderArray(hWnd, nColumnMax, order); |
| 1265 | | } |
| 1266 | | } |
| 1267 | | |
| 1268 | | /* Labels are offset by a certain amount */ |
| 1269 | | /* This offset is related to the width of a space character */ |
| 1270 | | GetTextExtentPoint32(hDC, TEXT(" "), 1 , &size); |
| 1271 | | offset = size.cx; |
| 1272 | | |
| 1273 | | lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_PARAM; |
| 1274 | | lvi.iItem = nItem; |
| 1275 | | lvi.iSubItem = order[0]; |
| 1276 | | lvi.pszText = szBuff; |
| 1277 | | lvi.cchTextMax = sizeof(szBuff) / sizeof(szBuff[0]); |
| 1278 | | lvi.stateMask = 0xFFFF; /* get all state flags */ |
| 1279 | | ListView_GetItem(hWnd, &lvi); |
| 1280 | | |
| 1281 | | bSelected = ((lvi.state & LVIS_DROPHILITED) || ( (lvi.state & LVIS_SELECTED) |
| 1282 | | && ((bFocus) || (GetWindowLong(hWnd, GWL_STYLE) & LVS_SHOWSELALWAYS)))); |
| 1283 | | |
| 1284 | | /* figure out if we indent and draw grayed */ |
| 1285 | | if (pPickerInfo->pCallbacks->pfnFindItemParent) |
| 1286 | | nParent = pPickerInfo->pCallbacks->pfnFindItemParent(hWnd, lvi.lParam); |
| 1287 | | else |
| 1288 | | nParent = -1; |
| 1289 | | bDrawAsChild = (pPickerInfo->pCallbacks->pfnGetViewMode() == VIEW_GROUPED && (nParent >= 0)); |
| 1290 | | |
| 1291 | | /* only indent if parent is also in this view */ |
| 1292 | | if ((nParent >= 0) && bDrawAsChild) |
| 1293 | | { |
| 1294 | | for (i = 0; i < ListView_GetItemCount(hWnd); i++) |
| 1295 | | { |
| 1296 | | lvi.mask = LVIF_PARAM; |
| 1297 | | lvi.iItem = i; |
| 1298 | | ListView_GetItem(hWnd, &lvi); |
| 1299 | | |
| 1300 | | if (lvi.lParam == nParent) |
| 1301 | | { |
| 1302 | | bParentFound = TRUE; |
| 1303 | | break; |
| 1304 | | } |
| 1305 | | } |
| 1306 | | } |
| 1307 | | |
| 1308 | | if (pPickerInfo->pCallbacks->pfnGetOffsetChildren && pPickerInfo->pCallbacks->pfnGetOffsetChildren()) |
| 1309 | | { |
| 1310 | | if (!bParentFound && bDrawAsChild) |
| 1311 | | { |
| 1312 | | /*Reset it, as no Parent is there*/ |
| 1313 | | bDrawAsChild = FALSE; |
| 1314 | | bColorChild = TRUE; |
| 1315 | | } |
| 1316 | | else |
| 1317 | | { |
| 1318 | | nParent = -1; |
| 1319 | | bParentFound = FALSE; |
| 1320 | | } |
| 1321 | | } |
| 1322 | | |
| 1323 | | ListView_GetItemRect(hWnd, nItem, &rcAllLabels, LVIR_BOUNDS); |
| 1324 | | ListView_GetItemRect(hWnd, nItem, &rcLabel, LVIR_LABEL); |
| 1325 | | |
| 1326 | | rcAllLabels.left = rcLabel.left; |
| 1327 | | |
| 1328 | | if (hBackground != NULL) |
| 1329 | | { |
| 1330 | | RECT rcClient; |
| 1331 | | HRGN rgnBitmap; |
| 1332 | | RECT rcTmpBmp = rcItem; |
| 1333 | | RECT rcFirstItem; |
| 1334 | | HPALETTE hPAL; |
| 1335 | | HDC htempDC; |
| 1336 | | HBITMAP oldBitmap; |
| 1337 | | |
| 1338 | | htempDC = CreateCompatibleDC(hDC); |
| 1339 | | |
| 1340 | | oldBitmap = SelectObject(htempDC, hBackground); |
| 1341 | | |
| 1342 | | GetClientRect(hWnd, &rcClient); |
| 1343 | | rcTmpBmp.right = rcClient.right; |
| 1344 | | /* We also need to check whether it is the last item |
| 1345 | | The update region has to be extended to the bottom if it is */ |
| 1346 | | if (nItem == ListView_GetItemCount(hWnd) - 1) |
| 1347 | | rcTmpBmp.bottom = rcClient.bottom; |
| 1348 | | |
| 1349 | | rgnBitmap = CreateRectRgnIndirect(&rcTmpBmp); |
| 1350 | | SelectClipRgn(hDC, rgnBitmap); |
| 1351 | | DeleteObject(rgnBitmap); |
| 1352 | | |
| 1353 | | hPAL = GetBackgroundPalette(); |
| 1354 | | if (hPAL == NULL) |
| 1355 | | hPAL = CreateHalftonePalette(hDC); |
| 1356 | | |
| 1357 | | if (GetDeviceCaps(htempDC, RASTERCAPS) & RC_PALETTE && hPAL != NULL) |
| 1358 | | { |
| 1359 | | SelectPalette(htempDC, hPAL, FALSE); |
| 1360 | | RealizePalette(htempDC); |
| 1361 | | } |
| 1362 | | |
| 1363 | | ListView_GetItemRect(hWnd, 0, &rcFirstItem, LVIR_BOUNDS); |
| 1364 | | |
| 1365 | | for (i = rcFirstItem.left; i < rcClient.right; i += pbmDesc->bmWidth) |
| 1366 | | for (j = rcFirstItem.top; j < rcClient.bottom; j += pbmDesc->bmHeight) |
| 1367 | | BitBlt(hDC, i, j, pbmDesc->bmWidth, pbmDesc->bmHeight, htempDC, 0, 0, SRCCOPY); |
| 1368 | | |
| 1369 | | SelectObject(htempDC, oldBitmap); |
| 1370 | | DeleteDC(htempDC); |
| 1371 | | |
| 1372 | | if (GetBackgroundPalette() == NULL) |
| 1373 | | { |
| 1374 | | DeleteObject(hPAL); |
| 1375 | | hPAL = NULL; |
| 1376 | | } |
| 1377 | | } |
| 1378 | | |
| 1379 | | indent_space = 0; |
| 1380 | | |
| 1381 | | if (bDrawAsChild) |
| 1382 | | { |
| 1383 | | RECT rect; |
| 1384 | | |
| 1385 | | ListView_GetItemRect(hWnd, nItem, &rect, LVIR_ICON); |
| 1386 | | |
| 1387 | | /* indent width of icon + the space between the icon and text |
| 1388 | | * so left of clone icon starts at text of parent |
| 1389 | | */ |
| 1390 | | indent_space = rect.right - rect.left + offset; |
| 1391 | | } |
| 1392 | | |
| 1393 | | rcAllLabels.left += indent_space; |
| 1394 | | |
| 1395 | | if (bSelected) |
| 1396 | | { |
| 1397 | | HBRUSH hBrush; |
| 1398 | | HBRUSH hOldBrush; |
| 1399 | | |
| 1400 | | if (bFocus) |
| 1401 | | { |
| 1402 | | clrTextSave = SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); |
| 1403 | | clrBkSave = SetBkColor(hDC, GetSysColor(COLOR_HIGHLIGHT)); |
| 1404 | | hBrush = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT)); |
| 1405 | | } |
| 1406 | | else |
| 1407 | | { |
| 1408 | | clrTextSave = SetTextColor(hDC, GetSysColor(COLOR_BTNTEXT)); |
| 1409 | | clrBkSave = SetBkColor(hDC, GetSysColor(COLOR_BTNFACE)); |
| 1410 | | hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); |
| 1411 | | } |
| 1412 | | |
| 1413 | | hOldBrush = SelectObject(hDC, hBrush); |
| 1414 | | FillRect(hDC, &rcAllLabels, hBrush); |
| 1415 | | SelectObject(hDC, hOldBrush); |
| 1416 | | DeleteObject(hBrush); |
| 1417 | | } |
| 1418 | | else |
| 1419 | | { |
| 1420 | | if (hBackground == NULL) |
| 1421 | | { |
| 1422 | | HBRUSH hBrush; |
| 1423 | | |
| 1424 | | hBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW)); |
| 1425 | | FillRect(hDC, &rcAllLabels, hBrush); |
| 1426 | | DeleteObject(hBrush); |
| 1427 | | } |
| 1428 | | |
| 1429 | | if (pPickerInfo->pCallbacks->pfnGetOffsetChildren && pPickerInfo->pCallbacks->pfnGetOffsetChildren()) |
| 1430 | | { |
| 1431 | | if (bDrawAsChild || bColorChild) |
| 1432 | | clrTextSave = SetTextColor(hDC, GetListCloneColor()); |
| 1433 | | else |
| 1434 | | clrTextSave = SetTextColor(hDC, GetListFontColor()); |
| 1435 | | } |
| 1436 | | else |
| 1437 | | { |
| 1438 | | if (bDrawAsChild) |
| 1439 | | clrTextSave = SetTextColor(hDC, GetListCloneColor()); |
| 1440 | | else |
| 1441 | | clrTextSave = SetTextColor(hDC, GetListFontColor()); |
| 1442 | | } |
| 1443 | | |
| 1444 | | clrBkSave = SetBkColor(hDC, GetSysColor(COLOR_WINDOW)); |
| 1445 | | } |
| 1446 | | |
| 1447 | | |
| 1448 | | if (lvi.state & LVIS_CUT) |
| 1449 | | { |
| 1450 | | clrImage = GetSysColor(COLOR_WINDOW); |
| 1451 | | uiFlags |= ILD_BLEND50; |
| 1452 | | } |
| 1453 | | else if (bSelected) |
| 1454 | | { |
| 1455 | | if (bFocus) |
| 1456 | | clrImage = GetSysColor(COLOR_HIGHLIGHT); |
| 1457 | | else |
| 1458 | | clrImage = GetSysColor(COLOR_BTNFACE); |
| 1459 | | |
| 1460 | | uiFlags |= ILD_BLEND50; |
| 1461 | | } |
| 1462 | | |
| 1463 | | nStateImageMask = lvi.state & LVIS_STATEIMAGEMASK; |
| 1464 | | |
| 1465 | | if (nStateImageMask) |
| 1466 | | { |
| 1467 | | int nImage = (nStateImageMask >> 12) - 1; |
| 1468 | | hImageList = ListView_GetImageList(hWnd, LVSIL_STATE); |
| 1469 | | if (hImageList) |
| 1470 | | ImageList_Draw(hImageList, nImage, hDC, rcItem.left, rcItem.top, ILD_TRANSPARENT); |
| 1471 | | } |
| 1472 | | |
| 1473 | | ListView_GetItemRect(hWnd, nItem, &rcIcon, LVIR_ICON); |
| 1474 | | |
| 1475 | | rcIcon.left += indent_space; |
| 1476 | | |
| 1477 | | ListView_GetItemRect(hWnd, nItem, &rcItem, LVIR_LABEL); |
| 1478 | | |
| 1479 | | hImageList = ListView_GetImageList(hWnd, LVSIL_SMALL); |
| 1480 | | if (hImageList) |
| 1481 | | { |
| 1482 | | UINT nOvlImageMask = lvi.state & LVIS_OVERLAYMASK; |
| 1483 | | if (rcIcon.left + 16 + indent_space < rcItem.right) |
| 1484 | | { |
| 1485 | | ImageList_DrawEx(hImageList, lvi.iImage, hDC, rcIcon.left, rcIcon.top, 16, 16, |
| 1486 | | GetSysColor(COLOR_WINDOW), clrImage, uiFlags | nOvlImageMask); |
| 1487 | | } |
| 1488 | | } |
| 1489 | | |
| 1490 | | ListView_GetItemRect(hWnd, nItem, &rcItem, LVIR_LABEL); |
| 1491 | | |
| 1492 | | pszText = MakeShortString(hDC, szBuff, rcItem.right - rcItem.left, 2*offset + indent_space); |
| 1493 | | |
| 1494 | | rcLabel = rcItem; |
| 1495 | | rcLabel.left += offset + indent_space; |
| 1496 | | rcLabel.right -= offset; |
| 1497 | | |
| 1498 | | DrawText(hDC, pszText, -1, &rcLabel, |
| 1499 | | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER); |
| 1500 | | |
| 1501 | | for (nColumn = 1; nColumn < nColumnMax; nColumn++) |
| 1502 | | { |
| 1503 | | int nRetLen; |
| 1504 | | UINT nJustify; |
| 1505 | | LV_ITEM lvItem; |
| 1506 | | |
| 1507 | | lvc.mask = LVCF_FMT | LVCF_WIDTH; |
| 1508 | | ListView_GetColumn(hWnd, order[nColumn], &lvc); |
| 1509 | | |
| 1510 | | lvItem.mask = LVIF_TEXT; |
| 1511 | | lvItem.iItem = nItem; |
| 1512 | | lvItem.iSubItem = order[nColumn]; |
| 1513 | | lvItem.pszText = szBuff; |
| 1514 | | lvItem.cchTextMax = sizeof(szBuff) / sizeof(szBuff[0]); |
| 1515 | | |
| 1516 | | if (ListView_GetItem(hWnd, &lvItem) == FALSE) |
| 1517 | | continue; |
| 1518 | | |
| 1519 | | rcItem.left = rcItem.right; |
| 1520 | | rcItem.right += lvc.cx; |
| 1521 | | |
| 1522 | | nRetLen = _tcslen(szBuff); |
| 1523 | | if (nRetLen == 0) |
| 1524 | | continue; |
| 1525 | | |
| 1526 | | pszText = MakeShortString(hDC, szBuff, rcItem.right - rcItem.left, 2 * offset); |
| 1527 | | |
| 1528 | | nJustify = DT_LEFT; |
| 1529 | | |
| 1530 | | if (pszText == szBuff) |
| 1531 | | { |
| 1532 | | switch (lvc.fmt & LVCFMT_JUSTIFYMASK) |
| 1533 | | { |
| 1534 | | case LVCFMT_RIGHT: |
| 1535 | | nJustify = DT_RIGHT; |
| 1536 | | break; |
| 1537 | | |
| 1538 | | case LVCFMT_CENTER: |
| 1539 | | nJustify = DT_CENTER; |
| 1540 | | break; |
| 1541 | | |
| 1542 | | default: |
| 1543 | | break; |
| 1544 | | } |
| 1545 | | } |
| 1546 | | |
| 1547 | | rcLabel = rcItem; |
| 1548 | | rcLabel.left += offset; |
| 1549 | | rcLabel.right -= offset; |
| 1550 | | DrawText(hDC, pszText, -1, &rcLabel, |
| 1551 | | nJustify | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER); |
| 1552 | | } |
| 1553 | | |
| 1554 | | if (lvi.state & LVIS_FOCUSED && bFocus) |
| 1555 | | DrawFocusRect(hDC, &rcAllLabels); |
| 1556 | | |
| 1557 | | SetTextColor(hDC, clrTextSave); |
| 1558 | | SetBkColor(hDC, clrBkSave); |
| 1559 | | free(order); |
| 1560 | | } |
| 1561 | | |
| 1562 | | |
| 1563 | | |
| 1564 | | const struct PickerCallbacks *Picker_GetCallbacks(HWND hwndPicker) |
| 1565 | | { |
| 1566 | | struct PickerInfo *pPickerInfo; |
| 1567 | | pPickerInfo = GetPickerInfo(hwndPicker); |
| 1568 | | return pPickerInfo->pCallbacks; |
| 1569 | | } |
| 1570 | | |
| 1571 | | |
| 1572 | | |
| 1573 | | int Picker_GetColumnCount(HWND hwndPicker) |
| 1574 | | { |
| 1575 | | struct PickerInfo *pPickerInfo; |
| 1576 | | pPickerInfo = GetPickerInfo(hwndPicker); |
| 1577 | | return pPickerInfo->nColumnCount; |
| 1578 | | } |
| 1579 | | |
| 1580 | | |
| 1581 | | |
| 1582 | | LPCTSTR *Picker_GetColumnNames(HWND hwndPicker) |
| 1583 | | { |
| 1584 | | struct PickerInfo *pPickerInfo; |
| 1585 | | pPickerInfo = GetPickerInfo(hwndPicker); |
| 1586 | | return pPickerInfo->ppszColumnNames; |
| 1587 | | } |
| 1588 | | |
| 1589 | | |
| 1590 | | |
| 1591 | | void Picker_SetHeaderImageList(HWND hwndPicker, HIMAGELIST hHeaderImages) |
| 1592 | | { |
| 1593 | | HWND hwndHeader; |
| 1594 | | hwndHeader = ListView_GetHeader(hwndPicker); |
| 1595 | | SendMessage(hwndHeader, HDM_SETIMAGELIST, 0, (LPARAM) (void *) hHeaderImages); |
| 1596 | | } |
| 1597 | | |
| 1598 | | |
| 1599 | | |
| 1600 | | BOOL Picker_SaveColumnWidths(HWND hwndPicker) |
| 1601 | | { |
| 1602 | | struct PickerInfo *pPickerInfo; |
| 1603 | | int *widths; |
| 1604 | | int *order; |
| 1605 | | int *tmpOrder; |
| 1606 | | int nColumnMax, i; |
| 1607 | | BOOL bSuccess = FALSE; |
| 1608 | | |
| 1609 | | pPickerInfo = GetPickerInfo(hwndPicker); |
| 1610 | | |
| 1611 | | /* allocate space for the column info */ |
| 1612 | | widths = malloc(pPickerInfo->nColumnCount * sizeof(*widths)); |
| 1613 | | order = malloc(pPickerInfo->nColumnCount * sizeof(*order)); |
| 1614 | | tmpOrder = malloc(pPickerInfo->nColumnCount * sizeof(*tmpOrder)); |
| 1615 | | if (!widths || !order || !tmpOrder) |
| 1616 | | goto done; |
| 1617 | | |
| 1618 | | /* retrieve the values */ |
| 1619 | | memset(widths, 0, pPickerInfo->nColumnCount * sizeof(*widths)); |
| 1620 | | memset(order, 0, pPickerInfo->nColumnCount * sizeof(*order)); |
| 1621 | | pPickerInfo->pCallbacks->pfnGetColumnWidths(widths); |
| 1622 | | pPickerInfo->pCallbacks->pfnGetColumnOrder(order); |
| 1623 | | |
| 1624 | | /* switch the list view to LVS_REPORT style so column widths reported correctly */ |
| 1625 | | SetWindowLong(hwndPicker, GWL_STYLE, |
| 1626 | | (GetWindowLong(hwndPicker, GWL_STYLE) & ~LVS_TYPEMASK) | LVS_REPORT); |
| 1627 | | |
| 1628 | | nColumnMax = Picker_GetNumColumns(hwndPicker); |
| 1629 | | |
| 1630 | | if (GetUseOldControl()) |
| 1631 | | { |
| 1632 | | for (i = 0; i < nColumnMax; i++) |
| 1633 | | { |
| 1634 | | widths[Picker_GetRealColumnFromViewColumn(hwndPicker, i)] = |
| 1635 | | ListView_GetColumnWidth(hwndPicker, i); |
| 1636 | | } |
| 1637 | | } |
| 1638 | | else |
| 1639 | | { |
| 1640 | | /* Get the Column Order and save it */ |
| 1641 | | ListView_GetColumnOrderArray(hwndPicker, nColumnMax, tmpOrder); |
| 1642 | | |
| 1643 | | for (i = 0; i < nColumnMax; i++) |
| 1644 | | { |
| 1645 | | widths[Picker_GetRealColumnFromViewColumn(hwndPicker, i)] |
| 1646 | | = ListView_GetColumnWidth(hwndPicker, i); |
| 1647 | | order[i] = Picker_GetRealColumnFromViewColumn(hwndPicker, tmpOrder[i]); |
| 1648 | | } |
| 1649 | | } |
| 1650 | | |
| 1651 | | pPickerInfo->pCallbacks->pfnSetColumnWidths(widths); |
| 1652 | | pPickerInfo->pCallbacks->pfnSetColumnOrder(order); |
| 1653 | | bSuccess = TRUE; |
| 1654 | | |
| 1655 | | done: |
| 1656 | | if (widths) |
| 1657 | | free(widths); |
| 1658 | | if (order) |
| 1659 | | free(order); |
| 1660 | | if (tmpOrder) |
| 1661 | | free(tmpOrder); |
| 1662 | | return bSuccess; |
| 1663 | | } |
src/osd/windows/ui/m32opts.c
| r995 | r996 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | M.A.M.E.32 - Multiple Arcade Machine Emulator for Win32 |
| 4 | | Win32 Portions Copyright (C) 1997-2003 Michael Soderstrom and Chris Kirmse |
| 5 | | |
| 6 | | This file is part of MAME32, and may only be used, modified and |
| 7 | | distributed under the terms of the MAME license, in "readme.txt". |
| 8 | | By continuing to use, modify or distribute this file you indicate |
| 9 | | that you have read the license and understand and accept it fully. |
| 10 | | |
| 11 | | ***************************************************************************/ |
| 12 | | |
| 13 | | /*************************************************************************** |
| 14 | | |
| 15 | | options.c |
| 16 | | |
| 17 | | Stores global options and per-game options; |
| 18 | | |
| 19 | | ***************************************************************************/ |
| 20 | | |
| 21 | | #define WIN32_LEAN_AND_MEAN |
| 22 | | |
| 23 | | #include <windows.h> |
| 24 | | #include <windowsx.h> |
| 25 | | #include <winreg.h> |
| 26 | | #include <commctrl.h> |
| 27 | | #include <assert.h> |
| 28 | | #include <stdio.h> |
| 29 | | #include <sys/stat.h> |
| 30 | | #include <math.h> |
| 31 | | #include <direct.h> |
| 32 | | #include <driver.h> |
| 33 | | #include <stddef.h> |
| 34 | | #include <tchar.h> |
| 35 | | |
| 36 | | #include "screenshot.h" |
| 37 | | #include "bitmask.h" |
| 38 | | #include "mame32.h" |
| 39 | | #include "m32util.h" |
| 40 | | #include "resource.h" |
| 41 | | #include "treeview.h" |
| 42 | | #include "file.h" |
| 43 | | #include "splitters.h" |
| 44 | | #include "dijoystick.h" |
| 45 | | #include "audit.h" |
| 46 | | #include "m32opts.h" |
| 47 | | #include "picker.h" |
| 48 | | #include "winmain.h" |
| 49 | | #include "windows/winutf8.h" |
| 50 | | #include "windows/strconv.h" |
| 51 | | |
| 52 | | #ifdef MESS |
| 53 | | #include "osd/windows/ui/optionsms.h" |
| 54 | | #endif // MESS |
| 55 | | |
| 56 | | #ifdef _MSC_VER |
| 57 | | #define snprintf _snprintf |
| 58 | | #endif |
| 59 | | |
| 60 | | /*************************************************************************** |
| 61 | | Internal function prototypes |
| 62 | | ***************************************************************************/ |
| 63 | | |
| 64 | | static void LoadFolderFilter(int folder_index,int filters); |
| 65 | | |
| 66 | | static file_error LoadSettingsFile(core_options *opts, const char *filename); |
| 67 | | static file_error SaveSettingsFile(core_options *opts, const char *filename); |
| 68 | | |
| 69 | | static void LoadOptionsAndSettings(void); |
| 70 | | |
| 71 | | static void CusColorEncodeString(const COLORREF *value, char* str); |
| 72 | | static void CusColorDecodeString(const char* str, COLORREF *value); |
| 73 | | |
| 74 | | static void SplitterEncodeString(const int *value, char* str); |
| 75 | | static void SplitterDecodeString(const char *str, int *value); |
| 76 | | |
| 77 | | static void FontEncodeString(const LOGFONT *f, char *str); |
| 78 | | static void FontDecodeString(const char* str, LOGFONT *f); |
| 79 | | |
| 80 | | static void TabFlagsEncodeString(int data, char *str); |
| 81 | | static void TabFlagsDecodeString(const char *str, int *data); |
| 82 | | |
| 83 | | #ifdef _MSC_VER |
| 84 | | #define snprintf _snprintf |
| 85 | | #endif |
| 86 | | |
| 87 | | /*************************************************************************** |
| 88 | | Internal defines |
| 89 | | ***************************************************************************/ |
| 90 | | |
| 91 | | #define UI_INI_FILENAME MAME32NAME "ui.ini" |
| 92 | | #define DEFAULT_OPTIONS_INI_FILENAME MAME32NAME ".ini" |
| 93 | | |
| 94 | | #define M32OPTION_LIST_MODE "list_mode" |
| 95 | | #define M32OPTION_CHECK_GAME "check_game" |
| 96 | | #define M32OPTION_JOYSTICK_IN_INTERFACE "joystick_in_interface" |
| 97 | | #define M32OPTION_KEYBOARD_IN_INTERFACE "keyboard_in_interface" |
| 98 | | #define M32OPTION_CYCLE_SCREENSHOT "cycle_screenshot" |
| 99 | | #define M32OPTION_STRETCH_SCREENSHOT_LARGER "stretch_screenshot_larger" |
| 100 | | #define M32OPTION_SCREENSHOT_BORDER_SIZE "screenshot_bordersize" |
| 101 | | #define M32OPTION_SCREENSHOT_BORDER_COLOR "screenshot_bordercolor" |
| 102 | | #define M32OPTION_INHERIT_FILTER "inherit_filter" |
| 103 | | #define M32OPTION_OFFSET_CLONES "offset_clones" |
| 104 | | #define M32OPTION_GAME_CAPTION "game_caption" |
| 105 | | #define M32OPTION_BROADCAST_GAME_NAME "broadcast_game_name" |
| 106 | | #define M32OPTION_RANDOM_BACKGROUND "random_background" |
| 107 | | #define M32OPTION_DEFAULT_FOLDER_ID "default_folder_id" |
| 108 | | #define M32OPTION_SHOW_IMAGE_SECTION "show_image_section" |
| 109 | | #define M32OPTION_SHOW_FOLDER_SECTION "show_folder_section" |
| 110 | | #define M32OPTION_HIDE_FOLDERS "hide_folders" |
| 111 | | #define M32OPTION_SHOW_STATUS_BAR "show_status_bar" |
| 112 | | #define M32OPTION_SHOW_TABS "show_tabs" |
| 113 | | #define M32OPTION_SHOW_TOOLBAR "show_tool_bar" |
| 114 | | #define M32OPTION_CURRENT_TAB "current_tab" |
| 115 | | #define M32OPTION_WINDOW_X "window_x" |
| 116 | | #define M32OPTION_WINDOW_Y "window_y" |
| 117 | | #define M32OPTION_WINDOW_WIDTH "window_width" |
| 118 | | #define M32OPTION_WINDOW_HEIGHT "window_height" |
| 119 | | #define M32OPTION_WINDOW_STATE "window_state" |
| 120 | | #define M32OPTION_CUSTOM_COLOR "custom_color" |
| 121 | | #define M32OPTION_LIST_FONT "list_font" |
| 122 | | #define M32OPTION_TEXT_COLOR "text_color" |
| 123 | | #define M32OPTION_CLONE_COLOR "clone_color" |
| 124 | | #define M32OPTION_HIDE_TABS "hide_tabs" |
| 125 | | #define M32OPTION_HISTORY_TAB "history_tab" |
| 126 | | #define M32OPTION_COLUMN_WIDTHS "column_widths" |
| 127 | | #define M32OPTION_COLUMN_ORDER "column_order" |
| 128 | | #define M32OPTION_COLUMN_SHOWN "column_shown" |
| 129 | | #define M32OPTION_SPLITTERS "splitters" |
| 130 | | #define M32OPTION_SORT_COLUMN "sort_column" |
| 131 | | #define M32OPTION_SORT_REVERSED "sort_reversed" |
| 132 | | #define M32OPTION_LANGUAGE "language" |
| 133 | | #define M32OPTION_FLYER_DIRECTORY "flyer_directory" |
| 134 | | #define M32OPTION_CABINET_DIRECTORY "cabinet_directory" |
| 135 | | #define M32OPTION_MARQUEE_DIRECTORY "marquee_directory" |
| 136 | | #define M32OPTION_TITLE_DIRECTORY "title_directory" |
| 137 | | #define M32OPTION_CPANEL_DIRECTORY "cpanel_directory" |
| 138 | | #define M32OPTION_ICONS_DIRECTORY "icons_directory" |
| 139 | | #define M32OPTION_BACKGROUND_DIRECTORY "background_directory" |
| 140 | | #define M32OPTION_FOLDER_DIRECTORY "folder_directory" |
| 141 | | #define M32OPTION_UI_KEY_UP "ui_key_up" |
| 142 | | #define M32OPTION_UI_KEY_DOWN "ui_key_down" |
| 143 | | #define M32OPTION_UI_KEY_LEFT "ui_key_left" |
| 144 | | #define M32OPTION_UI_KEY_RIGHT "ui_key_right" |
| 145 | | #define M32OPTION_UI_KEY_START "ui_key_start" |
| 146 | | #define M32OPTION_UI_KEY_PGUP "ui_key_pgup" |
| 147 | | #define M32OPTION_UI_KEY_PGDWN "ui_key_pgdwn" |
| 148 | | #define M32OPTION_UI_KEY_HOME "ui_key_home" |
| 149 | | #define M32OPTION_UI_KEY_END "ui_key_end" |
| 150 | | #define M32OPTION_UI_KEY_SS_CHANGE "ui_key_ss_change" |
| 151 | | #define M32OPTION_UI_KEY_HISTORY_UP "ui_key_history_up" |
| 152 | | #define M32OPTION_UI_KEY_HISTORY_DOWN "ui_key_history_down" |
| 153 | | #define M32OPTION_UI_KEY_CONTEXT_FILTERS "ui_key_context_filters" |
| 154 | | #define M32OPTION_UI_KEY_SELECT_RANDOM "ui_key_select_random" |
| 155 | | #define M32OPTION_UI_KEY_GAME_AUDIT "ui_key_game_audit" |
| 156 | | #define M32OPTION_UI_KEY_GAME_PROPERTIES "ui_key_game_properties" |
| 157 | | #define M32OPTION_UI_KEY_HELP_CONTENTS "ui_key_help_contents" |
| 158 | | #define M32OPTION_UI_KEY_UPDATE_GAMELIST "ui_key_update_gamelist" |
| 159 | | #define M32OPTION_UI_KEY_VIEW_FOLDERS "ui_key_view_folders" |
| 160 | | #define M32OPTION_UI_KEY_VIEW_FULLSCREEN "ui_key_view_fullscreen" |
| 161 | | #define M32OPTION_UI_KEY_VIEW_PAGETAB "ui_key_view_pagetab" |
| 162 | | #define M32OPTION_UI_KEY_VIEW_PICTURE_AREA "ui_key_view_picture_area" |
| 163 | | #define M32OPTION_UI_KEY_VIEW_STATUS "ui_key_view_status" |
| 164 | | #define M32OPTION_UI_KEY_VIEW_TOOLBARS "ui_key_view_toolbars" |
| 165 | | #define M32OPTION_UI_KEY_VIEW_TAB_CABINET "ui_key_view_tab_cabinet" |
| 166 | | #define M32OPTION_UI_KEY_VIEW_TAB_CPANEL "ui_key_view_tab_cpanel" |
| 167 | | #define M32OPTION_UI_KEY_VIEW_TAB_FLYER "ui_key_view_tab_flyer" |
| 168 | | #define M32OPTION_UI_KEY_VIEW_TAB_HISTORY "ui_key_view_tab_history" |
| 169 | | #define M32OPTION_UI_KEY_VIEW_TAB_MARQUEE "ui_key_view_tab_marquee" |
| 170 | | #define M32OPTION_UI_KEY_VIEW_TAB_SCREENSHOT "ui_key_view_tab_screenshot" |
| 171 | | #define M32OPTION_UI_KEY_VIEW_TAB_TITLE "ui_key_view_tab_title" |
| 172 | | #define M32OPTION_UI_KEY_QUIT "ui_key_quit" |
| 173 | | #define M32OPTION_UI_JOY_UP "ui_joy_up" |
| 174 | | #define M32OPTION_UI_JOY_DOWN "ui_joy_down" |
| 175 | | #define M32OPTION_UI_JOY_LEFT "ui_joy_left" |
| 176 | | #define M32OPTION_UI_JOY_RIGHT "ui_joy_right" |
| 177 | | #define M32OPTION_UI_JOY_START "ui_joy_start" |
| 178 | | #define M32OPTION_UI_JOY_PGUP "ui_joy_pgup" |
| 179 | | #define M32OPTION_UI_JOY_PGDWN "ui_joy_pgdwn" |
| 180 | | #define M32OPTION_UI_JOY_HOME "ui_joy_home" |
| 181 | | #define M32OPTION_UI_JOY_END "ui_joy_end" |
| 182 | | #define M32OPTION_UI_JOY_SS_CHANGE "ui_joy_ss_change" |
| 183 | | #define M32OPTION_UI_JOY_HISTORY_UP "ui_joy_history_up" |
| 184 | | #define M32OPTION_UI_JOY_HISTORY_DOWN "ui_joy_history_down" |
| 185 | | #define M32OPTION_UI_JOY_EXEC "ui_joy_exec" |
| 186 | | #define M32OPTION_EXEC_COMMAND "exec_command" |
| 187 | | #define M32OPTION_EXEC_WAIT "exec_wait" |
| 188 | | #define M32OPTION_HIDE_MOUSE "hide_mouse" |
| 189 | | #define M32OPTION_FULL_SCREEN "full_screen" |
| 190 | | |
| 191 | | #ifdef MESS |
| 192 | | #define M32OPTION_DEFAULT_GAME "default_system" |
| 193 | | #define M32OPTION_HISTORY_FILE "sysinfo_file" |
| 194 | | #define M32OPTION_MAMEINFO_FILE "messinfo_file" |
| 195 | | #else |
| 196 | | #define M32OPTION_DEFAULT_GAME "default_game" |
| 197 | | #define M32OPTION_HISTORY_FILE "history_file" |
| 198 | | #define M32OPTION_MAMEINFO_FILE "mameinfo_file" |
| 199 | | #endif |
| 200 | | |
| 201 | | |
| 202 | | |
| 203 | | /*************************************************************************** |
| 204 | | Internal structures |
| 205 | | ***************************************************************************/ |
| 206 | | |
| 207 | | typedef struct |
| 208 | | { |
| 209 | | int folder_index; |
| 210 | | int filters; |
| 211 | | } folder_filter_type; |
| 212 | | |
| 213 | | /*************************************************************************** |
| 214 | | Internal variables |
| 215 | | ***************************************************************************/ |
| 216 | | |
| 217 | | static object_pool *options_memory_pool; |
| 218 | | |
| 219 | | static core_options *settings; |
| 220 | | |
| 221 | | static core_options *global; // Global 'default' options |
| 222 | | static core_options *vector_options; // Vector options |
| 223 | | static core_options **game_options; // Array of Game specific options |
| 224 | | static core_options **folder_options; // Array of Folder specific options |
| 225 | | static int *folder_options_redirect; // Array of Folder Ids for redirecting Folder specific options |
| 226 | | |
| 227 | | // UI options in mame32ui.ini |
| 228 | | static const options_entry regSettings[] = |
| 229 | | { |
| 230 | | // UI options |
| 231 | | { NULL, NULL, OPTION_HEADER, "UI OPTIONS" }, |
| 232 | | #ifdef MESS |
| 233 | | { M32OPTION_DEFAULT_GAME, "nes", 0, NULL }, |
| 234 | | #else |
| 235 | | { M32OPTION_DEFAULT_GAME, "puckman", 0, NULL }, |
| 236 | | #endif |
| 237 | | { M32OPTION_DEFAULT_FOLDER_ID, "0", 0, NULL }, |
| 238 | | { M32OPTION_SHOW_IMAGE_SECTION, "1", OPTION_BOOLEAN, NULL }, |
| 239 | | { M32OPTION_CURRENT_TAB, "0", 0, NULL }, |
| 240 | | { M32OPTION_SHOW_TOOLBAR, "1", OPTION_BOOLEAN, NULL }, |
| 241 | | { M32OPTION_SHOW_STATUS_BAR, "1", OPTION_BOOLEAN, NULL }, |
| 242 | | #ifdef MESS |
| 243 | | { M32OPTION_SHOW_FOLDER_SECTION, "0", OPTION_BOOLEAN, NULL }, |
| 244 | | #else |
| 245 | | { M32OPTION_SHOW_FOLDER_SECTION, "1", OPTION_BOOLEAN, NULL }, |
| 246 | | #endif |
| 247 | | { M32OPTION_HIDE_FOLDERS, "", 0, NULL }, |
| 248 | | |
| 249 | | #ifdef MESS |
| 250 | | { M32OPTION_SHOW_TABS, "0", OPTION_BOOLEAN, NULL }, |
| 251 | | { M32OPTION_HIDE_TABS, "flyer, cabinet, marquee, title, cpanel", 0, NULL }, |
| 252 | | { M32OPTION_HISTORY_TAB, "1", 0, NULL }, |
| 253 | | #else |
| 254 | | { M32OPTION_SHOW_TABS, "1", OPTION_BOOLEAN, NULL }, |
| 255 | | { M32OPTION_HIDE_TABS, "marquee, title, cpanel, history", 0, NULL }, |
| 256 | | { M32OPTION_HISTORY_TAB, "0", 0, NULL }, |
| 257 | | #endif |
| 258 | | |
| 259 | | { M32OPTION_CHECK_GAME, "1", OPTION_BOOLEAN, NULL }, |
| 260 | | { M32OPTION_JOYSTICK_IN_INTERFACE, "0", OPTION_BOOLEAN, NULL }, |
| 261 | | { M32OPTION_KEYBOARD_IN_INTERFACE, "0", OPTION_BOOLEAN, NULL }, |
| 262 | | { M32OPTION_BROADCAST_GAME_NAME, "0", OPTION_BOOLEAN, NULL }, |
| 263 | | { M32OPTION_RANDOM_BACKGROUND, "0", OPTION_BOOLEAN, NULL }, |
| 264 | | |
| 265 | | { M32OPTION_SORT_COLUMN, "0", 0, NULL }, |
| 266 | | { M32OPTION_SORT_REVERSED, "0", OPTION_BOOLEAN, NULL }, |
| 267 | | { M32OPTION_WINDOW_X, "0", 0, NULL }, |
| 268 | | { M32OPTION_WINDOW_Y, "0", 0, NULL }, |
| 269 | | { M32OPTION_WINDOW_WIDTH, "640", 0, NULL }, |
| 270 | | { M32OPTION_WINDOW_HEIGHT, "400", 0, NULL }, |
| 271 | | { M32OPTION_WINDOW_STATE, "1", 0, NULL }, |
| 272 | | |
| 273 | | { M32OPTION_TEXT_COLOR, "-1", 0, NULL }, |
| 274 | | { M32OPTION_CLONE_COLOR, "-1", 0, NULL }, |
| 275 | | { M32OPTION_CUSTOM_COLOR, "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0", 0, NULL }, |
| 276 | | /* ListMode needs to be before ColumnWidths settings */ |
| 277 | | { M32OPTION_LIST_MODE, "5", 0, NULL }, |
| 278 | | #ifdef MESS |
| 279 | | { M32OPTION_SPLITTERS, "152,310,468", 0, NULL }, |
| 280 | | #else |
| 281 | | { M32OPTION_SPLITTERS, "152,362", 0, NULL }, |
| 282 | | #endif |
| 283 | | { M32OPTION_LIST_FONT, "-8,0,0,0,400,0,0,0,0,0,0,0,0,MS Sans Serif", 0, NULL }, |
| 284 | | { M32OPTION_COLUMN_WIDTHS, "185,68,84,84,64,88,74,108,60,144,84,60", 0, NULL }, |
| 285 | | { M32OPTION_COLUMN_ORDER, "0,2,3,4,5,6,7,8,9,1,10,11", 0, NULL }, |
| 286 | | { M32OPTION_COLUMN_SHOWN, "1,0,1,1,1,1,1,1,1,1,0,0", 0, NULL }, |
| 287 | | |
| 288 | | { M32OPTION_UI_KEY_UP, "KEYCODE_UP", 0, NULL }, |
| 289 | | { M32OPTION_UI_KEY_DOWN, "KEYCODE_DOWN", 0, NULL }, |
| 290 | | { M32OPTION_UI_KEY_LEFT, "KEYCODE_LEFT", 0, NULL }, |
| 291 | | { M32OPTION_UI_KEY_RIGHT, "KEYCODE_RIGHT", 0, NULL }, |
| 292 | | { M32OPTION_UI_KEY_START, "KEYCODE_ENTER NOT KEYCODE_LALT", 0, NULL }, |
| 293 | | { M32OPTION_UI_KEY_PGUP, "KEYCODE_PGUP", 0, NULL }, |
| 294 | | { M32OPTION_UI_KEY_PGDWN, "KEYCODE_PGDN", 0, NULL }, |
| 295 | | { M32OPTION_UI_KEY_HOME, "KEYCODE_HOME", 0, NULL }, |
| 296 | | { M32OPTION_UI_KEY_END, "KEYCODE_END", 0, NULL }, |
| 297 | | { M32OPTION_UI_KEY_SS_CHANGE, "KEYCODE_INSERT", 0, NULL }, |
| 298 | | { M32OPTION_UI_KEY_HISTORY_UP, "KEYCODE_DEL", 0, NULL }, |
| 299 | | { M32OPTION_UI_KEY_HISTORY_DOWN, "KEYCODE_LALT KEYCODE_0", 0, NULL }, |
| 300 | | |
| 301 | | { M32OPTION_UI_KEY_CONTEXT_FILTERS, "KEYCODE_LCONTROL KEYCODE_F", 0, NULL }, |
| 302 | | { M32OPTION_UI_KEY_SELECT_RANDOM, "KEYCODE_LCONTROL KEYCODE_R", 0, NULL }, |
| 303 | | { M32OPTION_UI_KEY_GAME_AUDIT, "KEYCODE_LALT KEYCODE_A", 0, NULL }, |
| 304 | | { M32OPTION_UI_KEY_GAME_PROPERTIES, "KEYCODE_LALT KEYCODE_ENTER", 0, NULL }, |
| 305 | | { M32OPTION_UI_KEY_HELP_CONTENTS, "KEYCODE_F1", 0, NULL }, |
| 306 | | { M32OPTION_UI_KEY_UPDATE_GAMELIST, "KEYCODE_F5", 0, NULL }, |
| 307 | | { M32OPTION_UI_KEY_VIEW_FOLDERS, "KEYCODE_LALT KEYCODE_D", 0, NULL }, |
| 308 | | { M32OPTION_UI_KEY_VIEW_FULLSCREEN, "KEYCODE_F11", 0, NULL }, |
| 309 | | { M32OPTION_UI_KEY_VIEW_PAGETAB, "KEYCODE_LALT KEYCODE_B", 0, NULL }, |
| 310 | | { M32OPTION_UI_KEY_VIEW_PICTURE_AREA, "KEYCODE_LALT KEYCODE_P", 0, NULL }, |
| 311 | | { M32OPTION_UI_KEY_VIEW_STATUS, "KEYCODE_LALT KEYCODE_S", 0, NULL }, |
| 312 | | { M32OPTION_UI_KEY_VIEW_TOOLBARS, "KEYCODE_LALT KEYCODE_T", 0, NULL }, |
| 313 | | |
| 314 | | { M32OPTION_UI_KEY_VIEW_TAB_CABINET, "KEYCODE_LALT KEYCODE_3", 0, NULL }, |
| 315 | | { M32OPTION_UI_KEY_VIEW_TAB_CPANEL, "KEYCODE_LALT KEYCODE_6", 0, NULL }, |
| 316 | | { M32OPTION_UI_KEY_VIEW_TAB_FLYER, "KEYCODE_LALT KEYCODE_2", 0, NULL }, |
| 317 | | { M32OPTION_UI_KEY_VIEW_TAB_HISTORY, "KEYCODE_LALT KEYCODE_7", 0, NULL }, |
| 318 | | { M32OPTION_UI_KEY_VIEW_TAB_MARQUEE, "KEYCODE_LALT KEYCODE_4", 0, NULL }, |
| 319 | | { M32OPTION_UI_KEY_VIEW_TAB_SCREENSHOT, "KEYCODE_LALT KEYCODE_1", 0, NULL }, |
| 320 | | { M32OPTION_UI_KEY_VIEW_TAB_TITLE, "KEYCODE_LALT KEYCODE_5", 0, NULL }, |
| 321 | | { M32OPTION_UI_KEY_QUIT, "KEYCODE_LALT KEYCODE_Q", 0, NULL }, |
| 322 | | |
| 323 | | { M32OPTION_UI_JOY_UP, "", 0, NULL }, |
| 324 | | { M32OPTION_UI_JOY_DOWN, "", 0, NULL }, |
| 325 | | { M32OPTION_UI_JOY_LEFT, "", 0, NULL }, |
| 326 | | { M32OPTION_UI_JOY_RIGHT, "", 0, NULL }, |
| 327 | | { M32OPTION_UI_JOY_START, "", 0, NULL }, |
| 328 | | { M32OPTION_UI_JOY_PGUP, "", 0, NULL }, |
| 329 | | { M32OPTION_UI_JOY_PGDWN, "", 0, NULL }, |
| 330 | | { M32OPTION_UI_JOY_HOME, "0,0,0,0", 0, NULL }, |
| 331 | | { M32OPTION_UI_JOY_END, "0,0,0,0", 0, NULL }, |
| 332 | | { M32OPTION_UI_JOY_SS_CHANGE, "", 0, NULL }, |
| 333 | | { M32OPTION_UI_JOY_HISTORY_UP, "", 0, NULL }, |
| 334 | | { M32OPTION_UI_JOY_HISTORY_DOWN, "", 0, NULL }, |
| 335 | | { M32OPTION_UI_JOY_EXEC, "0,0,0,0", 0, NULL }, |
| 336 | | { M32OPTION_EXEC_COMMAND, "", 0, NULL }, |
| 337 | | { M32OPTION_EXEC_WAIT, "0", 0, NULL }, |
| 338 | | { M32OPTION_HIDE_MOUSE, "0", OPTION_BOOLEAN, NULL }, |
| 339 | | { M32OPTION_FULL_SCREEN, "0", OPTION_BOOLEAN, NULL }, |
| 340 | | { M32OPTION_CYCLE_SCREENSHOT, "0", 0, NULL }, |
| 341 | | { M32OPTION_STRETCH_SCREENSHOT_LARGER, "0", OPTION_BOOLEAN, NULL }, |
| 342 | | { M32OPTION_SCREENSHOT_BORDER_SIZE, "11", 0, NULL }, |
| 343 | | { M32OPTION_SCREENSHOT_BORDER_COLOR, "-1", 0, NULL }, |
| 344 | | { M32OPTION_INHERIT_FILTER, "0", OPTION_BOOLEAN, NULL }, |
| 345 | | { M32OPTION_OFFSET_CLONES, "0", OPTION_BOOLEAN, NULL }, |
| 346 | | { M32OPTION_GAME_CAPTION, "1", OPTION_BOOLEAN, NULL }, |
| 347 | | |
| 348 | | { M32OPTION_LANGUAGE, "english", 0, NULL }, |
| 349 | | { M32OPTION_FLYER_DIRECTORY, "flyers", 0, NULL }, |
| 350 | | { M32OPTION_CABINET_DIRECTORY, "cabinets", 0, NULL }, |
| 351 | | { M32OPTION_MARQUEE_DIRECTORY, "marquees", 0, NULL }, |
| 352 | | { M32OPTION_TITLE_DIRECTORY, "titles", 0, NULL }, |
| 353 | | { M32OPTION_CPANEL_DIRECTORY, "cpanel", 0, NULL }, |
| 354 | | { M32OPTION_BACKGROUND_DIRECTORY, "bkground", 0, NULL }, |
| 355 | | { M32OPTION_FOLDER_DIRECTORY, "folders", 0, NULL }, |
| 356 | | { M32OPTION_ICONS_DIRECTORY, "icons", 0, NULL }, |
| 357 | | #ifdef MESS |
| 358 | | { M32OPTION_HISTORY_FILE, "sysinfo.dat", 0, NULL }, |
| 359 | | { M32OPTION_MAMEINFO_FILE, "messinfo.dat", 0, NULL }, |
| 360 | | #else |
| 361 | | { M32OPTION_HISTORY_FILE, "history.dat", 0, NULL }, |
| 362 | | { M32OPTION_MAMEINFO_FILE, "mameinfo.dat", 0, NULL }, |
| 363 | | #endif |
| 364 | | { NULL } |
| 365 | | }; |
| 366 | | |
| 367 | | static const options_entry perGameOptions[] = |
| 368 | | { |
| 369 | | // per game options |
| 370 | | { "_play_count", "0", 0, NULL }, |
| 371 | | { "_play_time", "0", 0, NULL }, |
| 372 | | { "_rom_audit", "-1", 0, NULL }, |
| 373 | | { "_samples_audit", "-1", 0, NULL }, |
| 374 | | #ifdef MESS |
| 375 | | { "_extra_software", "", 0, NULL }, |
| 376 | | #endif |
| 377 | | |
| 378 | | // filters |
| 379 | | { "_filters", "0", 0, NULL }, |
| 380 | | |
| 381 | | { NULL } |
| 382 | | }; |
| 383 | | |
| 384 | | |
| 385 | | |
| 386 | | // Screen shot Page tab control text |
| 387 | | // these must match the order of the options flags in options.h |
| 388 | | // (TAB_...) |
| 389 | | const char* image_tabs_long_name[MAX_TAB_TYPES] = |
| 390 | | { |
| 391 | | "Snapshot ", |
| 392 | | "Flyer ", |
| 393 | | "Cabinet ", |
| 394 | | "Marquee", |
| 395 | | "Title", |
| 396 | | "Control Panel", |
| 397 | | "History ", |
| 398 | | }; |
| 399 | | |
| 400 | | const char* image_tabs_short_name[MAX_TAB_TYPES] = |
| 401 | | { |
| 402 | | "snapshot", |
| 403 | | "flyer", |
| 404 | | "cabinet", |
| 405 | | "marquee", |
| 406 | | "title", |
| 407 | | "cpanel", |
| 408 | | "history" |
| 409 | | }; |
| 410 | | |
| 411 | | |
| 412 | | static BOOL save_gui_settings = TRUE; |
| 413 | | static BOOL save_default_options = TRUE; |
| 414 | | |
| 415 | | folder_filter_type *folder_filters; |
| 416 | | int size_folder_filters; |
| 417 | | int num_folder_filters; |
| 418 | | |
| 419 | | /*************************************************************************** |
| 420 | | External functions |
| 421 | | ***************************************************************************/ |
| 422 | | |
| 423 | | static void memory_error(const char *message) |
| 424 | | { |
| 425 | | win_message_box_utf8(NULL, message, NULL, MB_OK); |
| 426 | | exit(-1); |
| 427 | | } |
| 428 | | |
| 429 | | |
| 430 | | |
| 431 | | void AddOptions(core_options *opts, const options_entry *entrylist, BOOL is_global) |
| 432 | | { |
| 433 | | static const char *blacklist[] = |
| 434 | | { |
| 435 | | WINOPTION_SCREEN, |
| 436 | | WINOPTION_ASPECT, |
| 437 | | WINOPTION_RESOLUTION, |
| 438 | | WINOPTION_VIEW |
| 439 | | }; |
| 440 | | options_entry entries[2]; |
| 441 | | BOOL good_option; |
| 442 | | int i; |
| 443 | | |
| 444 | | for ( ; entrylist->name != NULL || (entrylist->flags & OPTION_HEADER); entrylist++) |
| 445 | | { |
| 446 | | good_option = TRUE; |
| 447 | | |
| 448 | | // check blacklist |
| 449 | | if (entrylist->name != NULL) |
| 450 | | { |
| 451 | | for (i = 0; i < ARRAY_LENGTH(blacklist); i++) |
| 452 | | { |
| 453 | | if (!strcmp(entrylist->name, blacklist[i])) |
| 454 | | { |
| 455 | | good_option = FALSE; |
| 456 | | break; |
| 457 | | } |
| 458 | | } |
| 459 | | } |
| 460 | | |
| 461 | | // if is_global is FALSE, blacklist global options |
| 462 | | if (entrylist->name && !is_global && IsGlobalOption(entrylist->name)) |
| 463 | | good_option = FALSE; |
| 464 | | |
| 465 | | if (good_option) |
| 466 | | { |
| 467 | | memcpy(entries, entrylist, sizeof(options_entry)); |
| 468 | | memset(&entries[1], 0, sizeof(entries[1])); |
| 469 | | options_add_entries(opts, entries); |
| 470 | | } |
| 471 | | } |
| 472 | | } |
| 473 | | |
| 474 | | |
| 475 | | |
| 476 | | core_options *CreateGameOptions(int driver_index) |
| 477 | | { |
| 478 | | core_options *opts; |
| 479 | | BOOL is_global = (driver_index == OPTIONS_TYPE_GLOBAL); |
| 480 | | extern const options_entry mame_win_options[]; |
| 481 | | |
| 482 | | // create the options |
| 483 | | opts = options_create(memory_error); |
| 484 | | |
| 485 | | // add the options |
| 486 | | AddOptions(opts, mame_core_options, is_global); |
| 487 | | AddOptions(opts, mame_win_options, is_global); |
| 488 | | |
| 489 | | // customize certain options |
| 490 | | if (is_global) |
| 491 | | options_set_option_default_value(opts, OPTION_INIPATH, "ini"); |
| 492 | | |
| 493 | | #ifdef MESS |
| 494 | | MessSetupGameOptions(opts, driver_index); |
| 495 | | #endif // MESS |
| 496 | | |
| 497 | | return opts; |
| 498 | | } |
| 499 | | |
| 500 | | |
| 501 | | |
| 502 | | BOOL OptionsInit() |
| 503 | | { |
| 504 | | // create a memory pool for our data |
| 505 | | options_memory_pool = pool_alloc(memory_error); |
| 506 | | if (!options_memory_pool) |
| 507 | | return FALSE; |
| 508 | | |
| 509 | | // set up the MAME32 settings (these get placed in MAME32ui.ini |
| 510 | | settings = options_create(memory_error); |
| 511 | | options_add_entries(settings, regSettings); |
| 512 | | #ifdef MESS |
| 513 | | MessSetupSettings(settings); |
| 514 | | #endif |
| 515 | | |
| 516 | | // set up per game options |
| 517 | | { |
| 518 | | char buffer[128]; |
| 519 | | int i, j; |
| 520 | | int game_option_count = 0; |
| 521 | | options_entry *driver_per_game_options; |
| 522 | | options_entry *ent; |
| 523 | | |
| 524 | | while(perGameOptions[game_option_count].name) |
| 525 | | game_option_count++; |
| 526 | | |
| 527 | | driver_per_game_options = (options_entry *) pool_malloc(options_memory_pool, |
| 528 | | (game_option_count * driver_list_get_count(drivers) + 1) * sizeof(*driver_per_game_options)); |
| 529 | | |
| 530 | | for (i = 0; i < driver_list_get_count(drivers); i++) |
| 531 | | { |
| 532 | | for (j = 0; j < game_option_count; j++) |
| 533 | | { |
| 534 | | ent = &driver_per_game_options[i * game_option_count + j]; |
| 535 | | |
| 536 | | snprintf(buffer, ARRAY_LENGTH(buffer), "%s%s", drivers[i]->name, perGameOptions[j].name); |
| 537 | | |
| 538 | | memset(ent, 0, sizeof(*ent)); |
| 539 | | ent->name = pool_strdup(options_memory_pool, buffer); |
| 540 | | ent->defvalue = perGameOptions[j].defvalue; |
| 541 | | ent->flags = perGameOptions[j].flags; |
| 542 | | ent->description = perGameOptions[j].description; |
| 543 | | } |
| 544 | | } |
| 545 | | ent = &driver_per_game_options[driver_list_get_count(drivers) * game_option_count]; |
| 546 | | memset(ent, 0, sizeof(*ent)); |
| 547 | | options_add_entries(settings, driver_per_game_options); |
| 548 | | } |
| 549 | | |
| 550 | | // set up global options |
| 551 | | global = CreateGameOptions(OPTIONS_TYPE_GLOBAL); |
| 552 | | |
| 553 | | // set up game options |
| 554 | | game_options = (core_options **) pool_malloc(options_memory_pool, driver_list_get_count(drivers) * sizeof(*game_options)); |
| 555 | | memset(game_options, 0, driver_list_get_count(drivers) * sizeof(*game_options)); |
| 556 | | |
| 557 | | // set up folders |
| 558 | | size_folder_filters = 1; |
| 559 | | num_folder_filters = 0; |
| 560 | | folder_filters = (folder_filter_type *) pool_malloc(options_memory_pool, size_folder_filters * sizeof(*folder_filters)); |
| 561 | | |
| 562 | | // now load the options and settings |
| 563 | | LoadOptionsAndSettings(); |
| 564 | | |
| 565 | | return TRUE; |
| 566 | | |
| 567 | | } |
| 568 | | |
| 569 | | void FolderOptionsInit() |
| 570 | | { |
| 571 | | //Get Number of Folder Entries with options from folder_options_redirect |
| 572 | | int i=GetNumOptionFolders(); |
| 573 | | |
| 574 | | folder_options = (core_options **) pool_malloc(options_memory_pool, i * sizeof(*folder_options)); |
| 575 | | memset(folder_options, 0, i * sizeof(*folder_options)); |
| 576 | | } |
| 577 | | |
| 578 | | void OptionsExit(void) |
| 579 | | { |
| 580 | | int i; |
| 581 | | |
| 582 | | // free all game specific options |
| 583 | | for (i = 0; i < driver_list_get_count(drivers); i++) |
| 584 | | { |
| 585 | | if (game_options[i] != NULL) |
| 586 | | { |
| 587 | | options_free(game_options[i]); |
| 588 | | game_options[i] = NULL; |
| 589 | | } |
| 590 | | } |
| 591 | | |
| 592 | | // free all folder specific options |
| 593 | | for (i = 0; i < GetNumOptionFolders(); i++) |
| 594 | | { |
| 595 | | if (folder_options[i] != NULL) |
| 596 | | { |
| 597 | | options_free(folder_options[i]); |
| 598 | | folder_options[i] = NULL; |
| 599 | | } |
| 600 | | } |
| 601 | | |
| 602 | | // free global options |
| 603 | | options_free(global); |
| 604 | | global = NULL; |
| 605 | | |
| 606 | | // free settings |
| 607 | | options_free(settings); |
| 608 | | settings = NULL; |
| 609 | | |
| 610 | | // free vector options |
| 611 | | if (vector_options != NULL) |
| 612 | | { |
| 613 | | options_free(vector_options); |
| 614 | | vector_options = NULL; |
| 615 | | } |
| 616 | | |
| 617 | | // free the memory pool |
| 618 | | pool_free(options_memory_pool); |
| 619 | | options_memory_pool = NULL; |
| 620 | | } |
| 621 | | |
| 622 | | |
| 623 | | |
| 624 | | int GetRedirectIndex(int folder_index) |
| 625 | | { |
| 626 | | int i=0; |
| 627 | | int *redirect_arr = GetFolderOptionsRedirectArr(); |
| 628 | | //Use the redirect array, to get correct folder |
| 629 | | for( i=0; i<GetNumOptionFolders();i++) |
| 630 | | { |
| 631 | | |
| 632 | | if( redirect_arr[i] == folder_index) |
| 633 | | { |
| 634 | | //found correct folderId |
| 635 | | return i; |
| 636 | | } |
| 637 | | } |
| 638 | | return -1; |
| 639 | | } |
| 640 | | |
| 641 | | int GetRedirectValue(int index) |
| 642 | | { |
| 643 | | int *redirect_arr = GetFolderOptionsRedirectArr(); |
| 644 | | //Use the redirect array, to get correct folder |
| 645 | | if( GetNumOptionFolders() < index ) |
| 646 | | return redirect_arr[index]; |
| 647 | | else |
| 648 | | return -1; |
| 649 | | } |
| 650 | | |
| 651 | | |
| 652 | | |
| 653 | | static void GetDriverSettingsFileName(int driver_index, char *filename, size_t filename_len) |
| 654 | | { |
| 655 | | char title[32]; |
| 656 | | char *s; |
| 657 | | |
| 658 | | snprintf(title, ARRAY_LENGTH(title), "%s", GetDriverFilename(driver_index)); |
| 659 | | s = strrchr(title, '.'); |
| 660 | | if (s) |
| 661 | | *s = '\0'; |
| 662 | | |
| 663 | | snprintf(filename, filename_len, "%s\\drivers\\%s.ini", GetIniDir(), title); |
| 664 | | } |
| 665 | | |
| 666 | | |
| 667 | | |
| 668 | | static BOOL GetFolderSettingsFileName(int folder_index, char *filename, size_t filename_len) |
| 669 | | { |
| 670 | | extern FOLDERDATA g_folderData[]; |
| 671 | | extern LPEXFOLDERDATA ExtraFolderData[]; |
| 672 | | extern int numExtraFolders; |
| 673 | | int i, j; |
| 674 | | const char *pParent; |
| 675 | | BOOL result = FALSE; |
| 676 | | |
| 677 | | filename[0] = '\0'; |
| 678 | | |
| 679 | | if (folder_index < MAX_FOLDERS) |
| 680 | | { |
| 681 | | for (i = 0; g_folderData[i].m_lpTitle; i++) |
| 682 | | { |
| 683 | | if (g_folderData[i].m_nFolderId == folder_index) |
| 684 | | { |
| 685 | | snprintf(filename, filename_len, "%s\\%s.ini", GetIniDir(), g_folderData[i].m_lpTitle); |
| 686 | | result = TRUE; |
| 687 | | break; |
| 688 | | } |
| 689 | | } |
| 690 | | } |
| 691 | | else if (folder_index < MAX_FOLDERS + numExtraFolders) |
| 692 | | { |
| 693 | | for (i = 0; i < MAX_EXTRA_FOLDERS * MAX_EXTRA_SUBFOLDERS; i++) |
| 694 | | { |
| 695 | | if (ExtraFolderData[i]) |
| 696 | | { |
| 697 | | snprintf(filename, filename_len, "%s\\%s.ini", GetIniDir(), ExtraFolderData[i]->m_szTitle); |
| 698 | | result = TRUE; |
| 699 | | break; |
| 700 | | } |
| 701 | | } |
| 702 | | } |
| 703 | | else |
| 704 | | { |
| 705 | | //we jump to the corresponding folderData |
| 706 | | if( ExtraFolderData[folder_index] ) |
| 707 | | { |
| 708 | | //SubDirName is ParentFolderName |
| 709 | | pParent = GetFolderNameByID(ExtraFolderData[folder_index]->m_nParent); |
| 710 | | if( pParent ) |
| 711 | | { |
| 712 | | if( ExtraFolderData[folder_index]->m_nParent == FOLDER_SOURCE ) |
| 713 | | { |
| 714 | | for (j = 0; drivers[j]; j++) |
| 715 | | { |
| 716 | | if (!strcmp(GetDriverFilename(j), ExtraFolderData[folder_index]->m_szTitle)) |
| 717 | | { |
| 718 | | GetDriverSettingsFileName(j, filename, filename_len); |
| 719 | | result = TRUE; |
| 720 | | break; |
| 721 | | } |
| 722 | | } |
| 723 | | } |
| 724 | | else |
| 725 | | { |
| 726 | | pParent = GetFolderNameByID(ExtraFolderData[folder_index]->m_nParent); |
| 727 | | snprintf(filename, filename_len, "%s\\%s\\%s.ini", GetIniDir(), pParent, ExtraFolderData[folder_index]->m_szTitle ); |
| 728 | | result = TRUE; |
| 729 | | } |
| 730 | | } |
| 731 | | } |
| 732 | | } |
| 733 | | return result; |
| 734 | | } |
| 735 | | |
| 736 | | // sync in the options specified in filename |
| 737 | | void SyncInFolderOptions(core_options *opts, int folder_index) |
| 738 | | { |
| 739 | | char filename[MAX_PATH]; |
| 740 | | |
| 741 | | if (GetFolderSettingsFileName(folder_index, filename, ARRAY_LENGTH(filename))) |
| 742 | | { |
| 743 | | LoadSettingsFile(opts, filename); |
| 744 | | } |
| 745 | | } |
| 746 | | |
| 747 | | |
| 748 | | core_options * GetDefaultOptions(int iProperty, BOOL bVectorFolder ) |
| 749 | | { |
| 750 | | if( iProperty == GLOBAL_OPTIONS) |
| 751 | | return global; |
| 752 | | else if( iProperty == FOLDER_OPTIONS) |
| 753 | | { |
| 754 | | if (bVectorFolder) |
| 755 | | return global; |
| 756 | | else |
| 757 | | return GetVectorOptions(); |
| 758 | | } |
| 759 | | else |
| 760 | | { |
| 761 | | assert(0 <= iProperty && iProperty < driver_list_get_count(drivers)); |
| 762 | | return GetSourceOptions( iProperty ); |
| 763 | | } |
| 764 | | } |
| 765 | | |
| 766 | | core_options * GetFolderOptions(int folder_index, BOOL bIsVector) |
| 767 | | { |
| 768 | | int redirect_index=0; |
| 769 | | if( folder_index >= (MAX_FOLDERS + (MAX_EXTRA_FOLDERS * MAX_EXTRA_SUBFOLDERS) ) ) |
| 770 | | { |
| 771 | | dprintf("Folder Index out of bounds"); |
| 772 | | return NULL; |
| 773 | | } |
| 774 | | //Use the redirect array, to get correct folder |
| 775 | | redirect_index = GetRedirectIndex(folder_index); |
| 776 | | if( redirect_index < 0) |
| 777 | | return NULL; |
| 778 | | if (folder_options[redirect_index] == NULL) |
| 779 | | folder_options[redirect_index] = CreateGameOptions(OPTIONS_TYPE_FOLDER); |
| 780 | | options_copy(folder_options[redirect_index], global); |
| 781 | | LoadFolderOptions(folder_index); |
| 782 | | if( bIsVector) |
| 783 | | { |
| 784 | | SyncInFolderOptions(folder_options[redirect_index], FOLDER_VECTOR); |
| 785 | | } |
| 786 | | return folder_options[redirect_index]; |
| 787 | | } |
| 788 | | |
| 789 | | int * GetFolderOptionsRedirectArr(void) |
| 790 | | { |
| 791 | | return &folder_options_redirect[0]; |
| 792 | | } |
| 793 | | |
| 794 | | void SetFolderOptionsRedirectArr(int *redirect_arr) |
| 795 | | { |
| 796 | | folder_options_redirect = redirect_arr; |
| 797 | | } |
| 798 | | |
| 799 | | |
| 800 | | core_options * GetVectorOptions(void) |
| 801 | | { |
| 802 | | if (vector_options == NULL) |
| 803 | | { |
| 804 | | vector_options = CreateGameOptions(OPTIONS_TYPE_FOLDER); |
| 805 | | options_copy(vector_options, global); |
| 806 | | } |
| 807 | | |
| 808 | | //If it is a Vector game sync in the Vector.ini settings |
| 809 | | SyncInFolderOptions(vector_options, FOLDER_VECTOR); |
| 810 | | |
| 811 | | return vector_options; |
| 812 | | } |
| 813 | | |
| 814 | | core_options * GetSourceOptions(int driver_index ) |
| 815 | | { |
| 816 | | static core_options *source_opts; |
| 817 | | char filename[MAX_PATH]; |
| 818 | | |
| 819 | | assert(0 <= driver_index && driver_index < driver_list_get_count(drivers)); |
| 820 | | |
| 821 | | if (source_opts != NULL) |
| 822 | | { |
| 823 | | options_free(source_opts); |
| 824 | | source_opts = NULL; |
| 825 | | } |
| 826 | | |
| 827 | | source_opts = CreateGameOptions(OPTIONS_TYPE_FOLDER); |
| 828 | | |
| 829 | | //initialize source_opts with global settings, we accumulate all settings there and copy them |
| 830 | | //to game_options[driver_index] in the end |
| 831 | | options_copy(source_opts, global); |
| 832 | | |
| 833 | | if( DriverIsVector(driver_index) ) |
| 834 | | { |
| 835 | | //If it is a Vector game sync in the Vector.ini settings |
| 836 | | SyncInFolderOptions(source_opts, FOLDER_VECTOR); |
| 837 | | } |
| 838 | | |
| 839 | | //If it has source folder settings sync in the source\sourcefile.ini settings |
| 840 | | GetDriverSettingsFileName(driver_index, filename, ARRAY_LENGTH(filename)); |
| 841 | | LoadSettingsFile(source_opts, filename); |
| 842 | | |
| 843 | | return source_opts; |
| 844 | | } |
| 845 | | |
| 846 | | core_options * GetGameOptions(int driver_index, int folder_index ) |
| 847 | | { |
| 848 | | int parent_index; |
| 849 | | char filename[MAX_PATH]; |
| 850 | | |
| 851 | | assert(0 <= driver_index && driver_index < driver_list_get_count(drivers)); |
| 852 | | |
| 853 | | // do we have to load these options? |
| 854 | | if (game_options[driver_index] == NULL) |
| 855 | | { |
| 856 | | game_options[driver_index] = CreateGameOptions(driver_index); |
| 857 | | options_copy(game_options[driver_index], global); |
| 858 | | |
| 859 | | if (DriverIsVector(driver_index)) |
| 860 | | { |
| 861 | | //If it is a Vector game sync in the Vector.ini settings |
| 862 | | SyncInFolderOptions(game_options[driver_index], FOLDER_VECTOR); |
| 863 | | } |
| 864 | | |
| 865 | | //If it has source folder settings sync in the source\sourcefile.ini settings |
| 866 | | GetDriverSettingsFileName(driver_index, filename, ARRAY_LENGTH(filename)); |
| 867 | | LoadSettingsFile(game_options[driver_index], filename); |
| 868 | | |
| 869 | | //Sync in parent settings if it has one |
| 870 | | if( DriverIsClone(driver_index)) |
| 871 | | { |
| 872 | | parent_index = GetParentIndex(drivers[driver_index]); |
| 873 | | snprintf(filename, ARRAY_LENGTH(filename), "%s\\%s.ini", GetIniDir(), drivers[parent_index]->name); |
| 874 | | LoadSettingsFile(game_options[driver_index], filename); |
| 875 | | } |
| 876 | | |
| 877 | | // last but not least, sync in game specific settings |
| 878 | | snprintf(filename, ARRAY_LENGTH(filename), "%s\\%s.ini", GetIniDir(), drivers[driver_index]->name); |
| 879 | | LoadSettingsFile(game_options[driver_index], filename); |
| 880 | | } |
| 881 | | |
| 882 | | // return the result |
| 883 | | return game_options[driver_index]; |
| 884 | | } |
| 885 | | |
| 886 | | core_options * Mame32Settings(void) |
| 887 | | { |
| 888 | | return settings; |
| 889 | | } |
| 890 | | |
| 891 | | core_options * Mame32Global(void) |
| 892 | | { |
| 893 | | return global; |
| 894 | | } |
| 895 | | |
| 896 | | void SetGameUsesDefaults(int driver_index,BOOL use_defaults) |
| 897 | | { |
| 898 | | assert((0 <= driver_index) && (driver_index < driver_list_get_count(drivers))); |
| 899 | | |
| 900 | | if (use_defaults && (game_options[driver_index] != NULL)) |
| 901 | | { |
| 902 | | options_free(game_options[driver_index]); |
| 903 | | game_options[driver_index] = NULL; |
| 904 | | } |
| 905 | | } |
| 906 | | |
| 907 | | void LoadFolderFilter(int folder_index,int filters) |
| 908 | | { |
| 909 | | //dprintf("loaded folder filter %i %i",folder_index,filters); |
| 910 | | |
| 911 | | if (num_folder_filters == size_folder_filters) |
| 912 | | { |
| 913 | | size_folder_filters *= 2; |
| 914 | | folder_filters = (folder_filter_type *)realloc( |
| 915 | | folder_filters,size_folder_filters * sizeof(folder_filter_type)); |
| 916 | | } |
| 917 | | folder_filters[num_folder_filters].folder_index = folder_index; |
| 918 | | folder_filters[num_folder_filters].filters = filters; |
| 919 | | |
| 920 | | num_folder_filters++; |
| 921 | | } |
| 922 | | |
| 923 | | void ResetGUI(void) |
| 924 | | { |
| 925 | | save_gui_settings = FALSE; |
| 926 | | } |
| 927 | | |
| 928 | | const char * GetImageTabLongName(int tab_index) |
| 929 | | { |
| 930 | | assert((0 <= tab_index) && (tab_index < ARRAY_LENGTH(image_tabs_long_name))); |
| 931 | | return image_tabs_long_name[tab_index]; |
| 932 | | } |
| 933 | | |
| 934 | | const char * GetImageTabShortName(int tab_index) |
| 935 | | { |
| 936 | | assert((0 <= tab_index) && (tab_index < ARRAY_LENGTH(image_tabs_short_name))); |
| 937 | | return image_tabs_short_name[tab_index]; |
| 938 | | } |
| 939 | | |
| 940 | | //============================================================ |
| 941 | | // OPTIONS WRAPPERS |
| 942 | | //============================================================ |
| 943 | | |
| 944 | | static COLORREF options_get_color(core_options *opts, const char *name) |
| 945 | | { |
| 946 | | const char *value_str; |
| 947 | | unsigned int r, g, b; |
| 948 | | COLORREF value; |
| 949 | | |
| 950 | | value_str = options_get_string(opts, name); |
| 951 | | |
| 952 | | if (sscanf(value_str, "%u,%u,%u", &r, &g, &b) == 3) |
| 953 | | value = RGB(r,g,b); |
| 954 | | else |
| 955 | | value = (COLORREF) - 1; |
| 956 | | return value; |
| 957 | | } |
| 958 | | |
| 959 | | static void options_set_color(core_options *opts, const char *name, COLORREF value) |
| 960 | | { |
| 961 | | char value_str[32]; |
| 962 | | |
| 963 | | if (value == (COLORREF) -1) |
| 964 | | { |
| 965 | | snprintf(value_str, ARRAY_LENGTH(value_str), "%d", (int) value); |
| 966 | | } |
| 967 | | else |
| 968 | | { |
| 969 | | snprintf(value_str, ARRAY_LENGTH(value_str), "%d,%d,%d", |
| 970 | | (((int) value) >> 0) & 0xFF, |
| 971 | | (((int) value) >> 8) & 0xFF, |
| 972 | | (((int) value) >> 16) & 0xFF); |
| 973 | | } |
| 974 | | options_set_string(opts, name, value_str, OPTION_PRIORITY_CMDLINE); |
| 975 | | } |
| 976 | | |
| 977 | | static COLORREF options_get_color_default(core_options *opts, const char *name, int default_color) |
| 978 | | { |
| 979 | | COLORREF value = options_get_color(opts, name); |
| 980 | | if (value == (COLORREF) -1) |
| 981 | | value = GetSysColor(default_color); |
| 982 | | return value; |
| 983 | | } |
| 984 | | |
| 985 | | static void options_set_color_default(core_options *opts, const char *name, COLORREF value, int default_color) |
| 986 | | { |
| 987 | | if (value == GetSysColor(default_color)) |
| 988 | | options_set_color(settings, name, (COLORREF) -1); |
| 989 | | else |
| 990 | | options_set_color(settings, name, value); |
| 991 | | } |
| 992 | | |
| 993 | | static input_seq *options_get_input_seq(core_options *opts, const char *name) |
| 994 | | { |
| 995 | | static input_seq seq; |
| 996 | | const char *seq_string; |
| 997 | | |
| 998 | | seq_string = options_get_string(opts, name); |
| 999 | | input_seq_from_tokens(seq_string, &seq); |
| 1000 | | return &seq; |
| 1001 | | } |
| 1002 | | |
| 1003 | | |
| 1004 | | |
| 1005 | | //============================================================ |
| 1006 | | // OPTIONS CALLS |
| 1007 | | //============================================================ |
| 1008 | | |
| 1009 | | void SetViewMode(int val) |
| 1010 | | { |
| 1011 | | options_set_int(settings, M32OPTION_LIST_MODE, val, OPTION_PRIORITY_CMDLINE); |
| 1012 | | } |
| 1013 | | |
| 1014 | | int GetViewMode(void) |
| 1015 | | { |
| 1016 | | return options_get_int(settings, M32OPTION_LIST_MODE); |
| 1017 | | } |
| 1018 | | |
| 1019 | | void SetGameCheck(BOOL game_check) |
| 1020 | | { |
| 1021 | | options_set_bool(settings, M32OPTION_CHECK_GAME, game_check, OPTION_PRIORITY_CMDLINE); |
| 1022 | | } |
| 1023 | | |
| 1024 | | BOOL GetGameCheck(void) |
| 1025 | | { |
| 1026 | | return options_get_bool(settings,M32OPTION_CHECK_GAME); |
| 1027 | | } |
| 1028 | | |
| 1029 | | void SetJoyGUI(BOOL use_joygui) |
| 1030 | | { |
| 1031 | | options_set_bool(settings, M32OPTION_JOYSTICK_IN_INTERFACE, use_joygui, OPTION_PRIORITY_CMDLINE); |
| 1032 | | } |
| 1033 | | |
| 1034 | | BOOL GetJoyGUI(void) |
| 1035 | | { |
| 1036 | | return options_get_bool(settings, M32OPTION_JOYSTICK_IN_INTERFACE); |
| 1037 | | } |
| 1038 | | |
| 1039 | | void SetKeyGUI(BOOL use_keygui) |
| 1040 | | { |
| 1041 | | options_set_bool(settings, M32OPTION_KEYBOARD_IN_INTERFACE, use_keygui, OPTION_PRIORITY_CMDLINE); |
| 1042 | | } |
| 1043 | | |
| 1044 | | BOOL GetKeyGUI(void) |
| 1045 | | { |
| 1046 | | return options_get_bool(settings, M32OPTION_KEYBOARD_IN_INTERFACE); |
| 1047 | | } |
| 1048 | | |
| 1049 | | void SetCycleScreenshot(int cycle_screenshot) |
| 1050 | | { |
| 1051 | | options_set_int(settings, M32OPTION_CYCLE_SCREENSHOT, cycle_screenshot, OPTION_PRIORITY_CMDLINE); |
| 1052 | | } |
| 1053 | | |
| 1054 | | int GetCycleScreenshot(void) |
| 1055 | | { |
| 1056 | | return options_get_int(settings, M32OPTION_CYCLE_SCREENSHOT); |
| 1057 | | } |
| 1058 | | |
| 1059 | | void SetStretchScreenShotLarger(BOOL stretch) |
| 1060 | | { |
| 1061 | | options_set_bool(settings, M32OPTION_STRETCH_SCREENSHOT_LARGER, stretch, OPTION_PRIORITY_CMDLINE); |
| 1062 | | } |
| 1063 | | |
| 1064 | | BOOL GetStretchScreenShotLarger(void) |
| 1065 | | { |
| 1066 | | return options_get_bool(settings, M32OPTION_STRETCH_SCREENSHOT_LARGER); |
| 1067 | | } |
| 1068 | | |
| 1069 | | void SetScreenshotBorderSize(int size) |
| 1070 | | { |
| 1071 | | options_set_int(settings, M32OPTION_SCREENSHOT_BORDER_SIZE, size, OPTION_PRIORITY_CMDLINE); |
| 1072 | | } |
| 1073 | | |
| 1074 | | int GetScreenshotBorderSize(void) |
| 1075 | | { |
| 1076 | | return options_get_int(settings, M32OPTION_SCREENSHOT_BORDER_SIZE); |
| 1077 | | } |
| 1078 | | |
| 1079 | | void SetScreenshotBorderColor(COLORREF uColor) |
| 1080 | | { |
| 1081 | | options_set_color_default(settings, M32OPTION_SCREENSHOT_BORDER_COLOR, uColor, COLOR_3DFACE); |
| 1082 | | } |
| 1083 | | |
| 1084 | | COLORREF GetScreenshotBorderColor(void) |
| 1085 | | { |
| 1086 | | return options_get_color_default(settings, M32OPTION_SCREENSHOT_BORDER_COLOR, COLOR_3DFACE); |
| 1087 | | } |
| 1088 | | |
| 1089 | | void SetFilterInherit(BOOL inherit) |
| 1090 | | { |
| 1091 | | options_set_bool(settings, M32OPTION_INHERIT_FILTER, inherit, OPTION_PRIORITY_CMDLINE); |
| 1092 | | } |
| 1093 | | |
| 1094 | | BOOL GetFilterInherit(void) |
| 1095 | | { |
| 1096 | | return options_get_bool(settings, M32OPTION_INHERIT_FILTER); |
| 1097 | | } |
| 1098 | | |
| 1099 | | void SetOffsetClones(BOOL offset) |
| 1100 | | { |
| 1101 | | options_set_bool(settings, M32OPTION_OFFSET_CLONES, offset, OPTION_PRIORITY_CMDLINE); |
| 1102 | | } |
| 1103 | | |
| 1104 | | BOOL GetOffsetClones(void) |
| 1105 | | { |
| 1106 | | return options_get_bool(settings, M32OPTION_OFFSET_CLONES); |
| 1107 | | } |
| 1108 | | |
| 1109 | | void SetGameCaption(BOOL caption) |
| 1110 | | { |
| 1111 | | options_set_bool(settings, M32OPTION_GAME_CAPTION, caption, OPTION_PRIORITY_CMDLINE); |
| 1112 | | } |
| 1113 | | |
| 1114 | | BOOL GetGameCaption(void) |
| 1115 | | { |
| 1116 | | return options_get_bool(settings, M32OPTION_GAME_CAPTION); |
| 1117 | | } |
| 1118 | | |
| 1119 | | void SetBroadcast(BOOL broadcast) |
| 1120 | | { |
| 1121 | | options_set_bool(settings, M32OPTION_BROADCAST_GAME_NAME, broadcast, OPTION_PRIORITY_CMDLINE); |
| 1122 | | } |
| 1123 | | |
| 1124 | | BOOL GetBroadcast(void) |
| 1125 | | { |
| 1126 | | return options_get_bool(settings, M32OPTION_BROADCAST_GAME_NAME); |
| 1127 | | } |
| 1128 | | |
| 1129 | | void SetRandomBackground(BOOL random_bg) |
| 1130 | | { |
| 1131 | | options_set_bool(settings, M32OPTION_RANDOM_BACKGROUND, random_bg, OPTION_PRIORITY_CMDLINE); |
| 1132 | | } |
| 1133 | | |
| 1134 | | BOOL GetRandomBackground(void) |
| 1135 | | { |
| 1136 | | return options_get_bool(settings, M32OPTION_RANDOM_BACKGROUND); |
| 1137 | | } |
| 1138 | | |
| 1139 | | void SetSavedFolderID(UINT val) |
| 1140 | | { |
| 1141 | | options_set_int(settings, M32OPTION_DEFAULT_FOLDER_ID, (int) val, OPTION_PRIORITY_CMDLINE); |
| 1142 | | } |
| 1143 | | |
| 1144 | | UINT GetSavedFolderID(void) |
| 1145 | | { |
| 1146 | | return (UINT) options_get_int(settings, M32OPTION_DEFAULT_FOLDER_ID); |
| 1147 | | } |
| 1148 | | |
| 1149 | | void SetShowScreenShot(BOOL val) |
| 1150 | | { |
| 1151 | | options_set_bool(settings, M32OPTION_SHOW_IMAGE_SECTION, val, OPTION_PRIORITY_CMDLINE); |
| 1152 | | } |
| 1153 | | |
| 1154 | | BOOL GetShowScreenShot(void) |
| 1155 | | { |
| 1156 | | return options_get_bool(settings, M32OPTION_SHOW_IMAGE_SECTION); |
| 1157 | | } |
| 1158 | | |
| 1159 | | void SetShowFolderList(BOOL val) |
| 1160 | | { |
| 1161 | | options_set_bool(settings, M32OPTION_SHOW_FOLDER_SECTION, val, OPTION_PRIORITY_CMDLINE); |
| 1162 | | } |
| 1163 | | |
| 1164 | | BOOL GetShowFolderList(void) |
| 1165 | | { |
| 1166 | | return options_get_bool(settings, M32OPTION_SHOW_FOLDER_SECTION); |
| 1167 | | } |
| 1168 | | |
| 1169 | | static void GetsShowFolderFlags(LPBITS bits) |
| 1170 | | { |
| 1171 | | char s[2000]; |
| 1172 | | extern FOLDERDATA g_folderData[]; |
| 1173 | | char *token; |
| 1174 | | |
| 1175 | | snprintf(s, ARRAY_LENGTH(s), "%s", options_get_string(settings, M32OPTION_HIDE_FOLDERS)); |
| 1176 | | |
| 1177 | | SetAllBits(bits, TRUE); |
| 1178 | | |
| 1179 | | token = strtok(s,", \t"); |
| 1180 | | while (token != NULL) |
| 1181 | | { |
| 1182 | | int j; |
| 1183 | | |
| 1184 | | for (j=0;g_folderData[j].m_lpTitle != NULL;j++) |
| 1185 | | { |
| 1186 | | if (strcmp(g_folderData[j].short_name,token) == 0) |
| 1187 | | { |
| 1188 | | ClearBit(bits, g_folderData[j].m_nFolderId); |
| 1189 | | break; |
| 1190 | | } |
| 1191 | | } |
| 1192 | | token = strtok(NULL,", \t"); |
| 1193 | | } |
| 1194 | | } |
| 1195 | | |
| 1196 | | BOOL GetShowFolder(int folder) |
| 1197 | | { |
| 1198 | | BOOL result; |
| 1199 | | LPBITS show_folder_flags = NewBits(MAX_FOLDERS); |
| 1200 | | GetsShowFolderFlags(show_folder_flags); |
| 1201 | | result = TestBit(show_folder_flags, folder); |
| 1202 | | DeleteBits(show_folder_flags); |
| 1203 | | return result; |
| 1204 | | } |
| 1205 | | |
| 1206 | | void SetShowFolder(int folder,BOOL show) |
| 1207 | | { |
| 1208 | | LPBITS show_folder_flags = NewBits(MAX_FOLDERS); |
| 1209 | | int i; |
| 1210 | | int num_saved = 0; |
| 1211 | | char str[10000]; |
| 1212 | | extern FOLDERDATA g_folderData[]; |
| 1213 | | |
| 1214 | | GetsShowFolderFlags(show_folder_flags); |
| 1215 | | |
| 1216 | | if (show) |
| 1217 | | SetBit(show_folder_flags, folder); |
| 1218 | | else |
| 1219 | | ClearBit(show_folder_flags, folder); |
| 1220 | | |
| 1221 | | strcpy(str, ""); |
| 1222 | | |
| 1223 | | // we save the ones that are NOT displayed, so we can add new ones |
| 1224 | | // and upgraders will see them |
| 1225 | | for (i=0;i<MAX_FOLDERS;i++) |
| 1226 | | { |
| 1227 | | if (TestBit(show_folder_flags, i) == FALSE) |
| 1228 | | { |
| 1229 | | int j; |
| 1230 | | |
| 1231 | | if (num_saved != 0) |
| 1232 | | strcat(str,", "); |
| 1233 | | |
| 1234 | | for (j=0;g_folderData[j].m_lpTitle != NULL;j++) |
| 1235 | | { |
| 1236 | | if (g_folderData[j].m_nFolderId == i) |
| 1237 | | { |
| 1238 | | strcat(str,g_folderData[j].short_name); |
| 1239 | | num_saved++; |
| 1240 | | break; |
| 1241 | | } |
| 1242 | | } |
| 1243 | | } |
| 1244 | | } |
| 1245 | | options_set_string(settings, M32OPTION_HIDE_FOLDERS, str, OPTION_PRIORITY_CMDLINE); |
| 1246 | | DeleteBits(show_folder_flags); |
| 1247 | | } |
| 1248 | | |
| 1249 | | void SetShowStatusBar(BOOL val) |
| 1250 | | { |
| 1251 | | options_set_bool(settings, M32OPTION_SHOW_STATUS_BAR, val, OPTION_PRIORITY_CMDLINE); |
| 1252 | | } |
| 1253 | | |
| 1254 | | BOOL GetShowStatusBar(void) |
| 1255 | | { |
| 1256 | | return options_get_bool(settings, M32OPTION_SHOW_STATUS_BAR); |
| 1257 | | } |
| 1258 | | |
| 1259 | | void SetShowTabCtrl (BOOL val) |
| 1260 | | { |
| 1261 | | options_set_bool(settings, M32OPTION_SHOW_TABS, val, OPTION_PRIORITY_CMDLINE); |
| 1262 | | } |
| 1263 | | |
| 1264 | | BOOL GetShowTabCtrl (void) |
| 1265 | | { |
| 1266 | | return options_get_bool(settings, M32OPTION_SHOW_TABS); |
| 1267 | | } |
| 1268 | | |
| 1269 | | void SetShowToolBar(BOOL val) |
| 1270 | | { |
| 1271 | | options_set_bool(settings, M32OPTION_SHOW_TOOLBAR, val, OPTION_PRIORITY_CMDLINE); |
| 1272 | | } |
| 1273 | | |
| 1274 | | BOOL GetShowToolBar(void) |
| 1275 | | { |
| 1276 | | return options_get_bool(settings, M32OPTION_SHOW_TOOLBAR); |
| 1277 | | } |
| 1278 | | |
| 1279 | | void SetCurrentTab(const char *shortname) |
| 1280 | | { |
| 1281 | | options_set_string(settings, M32OPTION_CURRENT_TAB, shortname, OPTION_PRIORITY_CMDLINE); |
| 1282 | | } |
| 1283 | | |
| 1284 | | const char *GetCurrentTab(void) |
| 1285 | | { |
| 1286 | | return options_get_string(settings, M32OPTION_CURRENT_TAB); |
| 1287 | | } |
| 1288 | | |
| 1289 | | void SetDefaultGame(const char *name) |
| 1290 | | { |
| 1291 | | options_set_string(settings, M32OPTION_DEFAULT_GAME, name, OPTION_PRIORITY_CMDLINE); |
| 1292 | | } |
| 1293 | | |
| 1294 | | const char *GetDefaultGame(void) |
| 1295 | | { |
| 1296 | | return options_get_string(settings, M32OPTION_DEFAULT_GAME); |
| 1297 | | } |
| 1298 | | |
| 1299 | | void SetWindowArea(const AREA *area) |
| 1300 | | { |
| 1301 | | options_set_int(settings, M32OPTION_WINDOW_X, area->x, OPTION_PRIORITY_CMDLINE); |
| 1302 | | options_set_int(settings, M32OPTION_WINDOW_Y, area->y, OPTION_PRIORITY_CMDLINE); |
| 1303 | | options_set_int(settings, M32OPTION_WINDOW_WIDTH, area->width, OPTION_PRIORITY_CMDLINE); |
| 1304 | | options_set_int(settings, M32OPTION_WINDOW_HEIGHT, area->height, OPTION_PRIORITY_CMDLINE); |
| 1305 | | } |
| 1306 | | |
| 1307 | | void GetWindowArea(AREA *area) |
| 1308 | | { |
| 1309 | | area->x = options_get_int(settings, M32OPTION_WINDOW_X); |
| 1310 | | area->y = options_get_int(settings, M32OPTION_WINDOW_Y); |
| 1311 | | area->width = options_get_int(settings, M32OPTION_WINDOW_WIDTH); |
| 1312 | | area->height = options_get_int(settings, M32OPTION_WINDOW_HEIGHT); |
| 1313 | | } |
| 1314 | | |
| 1315 | | void SetWindowState(UINT state) |
| 1316 | | { |
| 1317 | | options_set_int(settings, M32OPTION_WINDOW_STATE, state, OPTION_PRIORITY_CMDLINE); |
| 1318 | | } |
| 1319 | | |
| 1320 | | UINT GetWindowState(void) |
| 1321 | | { |
| 1322 | | return options_get_int(settings, M32OPTION_WINDOW_STATE); |
| 1323 | | } |
| 1324 | | |
| 1325 | | void SetCustomColor(int iIndex, COLORREF uColor) |
| 1326 | | { |
| 1327 | | const char *custom_color_string; |
| 1328 | | COLORREF custom_color[256]; |
| 1329 | | char buffer[10000]; |
| 1330 | | |
| 1331 | | custom_color_string = options_get_string(settings, M32OPTION_CUSTOM_COLOR); |
| 1332 | | CusColorDecodeString(custom_color_string, custom_color); |
| 1333 | | |
| 1334 | | custom_color[iIndex] = uColor; |
| 1335 | | |
| 1336 | | CusColorEncodeString(custom_color, buffer); |
| 1337 | | options_set_string(settings, M32OPTION_CUSTOM_COLOR, buffer, OPTION_PRIORITY_CMDLINE); |
| 1338 | | } |
| 1339 | | |
| 1340 | | COLORREF GetCustomColor(int iIndex) |
| 1341 | | { |
| 1342 | | const char *custom_color_string; |
| 1343 | | COLORREF custom_color[256]; |
| 1344 | | |
| 1345 | | custom_color_string = options_get_string(settings, M32OPTION_CUSTOM_COLOR); |
| 1346 | | CusColorDecodeString(custom_color_string, custom_color); |
| 1347 | | |
| 1348 | | if (custom_color[iIndex] == (COLORREF)-1) |
| 1349 | | return (COLORREF)RGB(0,0,0); |
| 1350 | | |
| 1351 | | return custom_color[iIndex]; |
| 1352 | | } |
| 1353 | | |
| 1354 | | void SetListFont(const LOGFONT *font) |
| 1355 | | { |
| 1356 | | char font_string[10000]; |
| 1357 | | FontEncodeString(font, font_string); |
| 1358 | | options_set_string(settings, M32OPTION_LIST_FONT, font_string, OPTION_PRIORITY_CMDLINE); |
| 1359 | | } |
| 1360 | | |
| 1361 | | void GetListFont(LOGFONT *font) |
| 1362 | | { |
| 1363 | | const char *font_string = options_get_string(settings, M32OPTION_LIST_FONT); |
| 1364 | | FontDecodeString(font_string, font); |
| 1365 | | } |
| 1366 | | |
| 1367 | | void SetListFontColor(COLORREF uColor) |
| 1368 | | { |
| 1369 | | options_set_color_default(settings, M32OPTION_TEXT_COLOR, uColor, COLOR_WINDOWTEXT); |
| 1370 | | } |
| 1371 | | |
| 1372 | | COLORREF GetListFontColor(void) |
| 1373 | | { |
| 1374 | | return options_get_color_default(settings, M32OPTION_TEXT_COLOR, COLOR_WINDOWTEXT); |
| 1375 | | } |
| 1376 | | |
| 1377 | | void SetListCloneColor(COLORREF uColor) |
| 1378 | | { |
| 1379 | | options_set_color_default(settings, M32OPTION_CLONE_COLOR, uColor, COLOR_WINDOWTEXT); |
| 1380 | | } |
| 1381 | | |
| 1382 | | COLORREF GetListCloneColor(void) |
| 1383 | | { |
| 1384 | | return options_get_color_default(settings, M32OPTION_CLONE_COLOR, COLOR_WINDOWTEXT); |
| 1385 | | } |
| 1386 | | |
| 1387 | | int GetShowTab(int tab) |
| 1388 | | { |
| 1389 | | const char *show_tabs_string; |
| 1390 | | int show_tab_flags; |
| 1391 | | |
| 1392 | | show_tabs_string = options_get_string(settings, M32OPTION_HIDE_TABS); |
| 1393 | | TabFlagsDecodeString(show_tabs_string, &show_tab_flags); |
| 1394 | | return (show_tab_flags & (1 << tab)) != 0; |
| 1395 | | } |
| 1396 | | |
| 1397 | | void SetShowTab(int tab,BOOL show) |
| 1398 | | { |
| 1399 | | const char *show_tabs_string; |
| 1400 | | int show_tab_flags; |
| 1401 | | char buffer[10000]; |
| 1402 | | |
| 1403 | | show_tabs_string = options_get_string(settings, M32OPTION_HIDE_TABS); |
| 1404 | | TabFlagsDecodeString(show_tabs_string, &show_tab_flags); |
| 1405 | | |
| 1406 | | if (show) |
| 1407 | | show_tab_flags |= 1 << tab; |
| 1408 | | else |
| 1409 | | show_tab_flags &= ~(1 << tab); |
| 1410 | | |
| 1411 | | TabFlagsEncodeString(show_tab_flags, buffer); |
| 1412 | | options_set_string(settings, M32OPTION_HIDE_TABS, buffer, OPTION_PRIORITY_CMDLINE); |
| 1413 | | } |
| 1414 | | |
| 1415 | | // don't delete the last one |
| 1416 | | BOOL AllowedToSetShowTab(int tab,BOOL show) |
| 1417 | | { |
| 1418 | | const char *show_tabs_string; |
| 1419 | | int show_tab_flags; |
| 1420 | | |
| 1421 | | if (show == TRUE) |
| 1422 | | return TRUE; |
| 1423 | | |
| 1424 | | show_tabs_string = options_get_string(settings, M32OPTION_HIDE_TABS); |
| 1425 | | TabFlagsDecodeString(show_tabs_string, &show_tab_flags); |
| 1426 | | |
| 1427 | | show_tab_flags &= ~(1 << tab); |
| 1428 | | return show_tab_flags != 0; |
| 1429 | | } |
| 1430 | | |
| 1431 | | int GetHistoryTab(void) |
| 1432 | | { |
| 1433 | | return options_get_int(settings, M32OPTION_HISTORY_TAB); |
| 1434 | | } |
| 1435 | | |
| 1436 | | void SetHistoryTab(int tab, BOOL show) |
| 1437 | | { |
| 1438 | | if (show) |
| 1439 | | options_set_int(settings, M32OPTION_HISTORY_TAB, tab, OPTION_PRIORITY_CMDLINE); |
| 1440 | | else |
| 1441 | | options_set_int(settings, M32OPTION_HISTORY_TAB, TAB_NONE, OPTION_PRIORITY_CMDLINE); |
| 1442 | | } |
| 1443 | | |
| 1444 | | void SetColumnWidths(int width[]) |
| 1445 | | { |
| 1446 | | char column_width_string[10000]; |
| 1447 | | ColumnEncodeStringWithCount(width, column_width_string, COLUMN_MAX); |
| 1448 | | options_set_string(settings, M32OPTION_COLUMN_WIDTHS, column_width_string, OPTION_PRIORITY_CMDLINE); |
| 1449 | | } |
| 1450 | | |
| 1451 | | void GetColumnWidths(int width[]) |
| 1452 | | { |
| 1453 | | const char *column_width_string; |
| 1454 | | column_width_string = options_get_string(settings, M32OPTION_COLUMN_WIDTHS); |
| 1455 | | ColumnDecodeStringWithCount(column_width_string, width, COLUMN_MAX); |
| 1456 | | } |
| 1457 | | |
| 1458 | | void SetSplitterPos(int splitterId, int pos) |
| 1459 | | { |
| 1460 | | const char *splitter_string; |
| 1461 | | int *splitter; |
| 1462 | | char buffer[10000]; |
| 1463 | | |
| 1464 | | if (splitterId < GetSplitterCount()) |
| 1465 | | { |
| 1466 | | splitter_string = options_get_string(settings, M32OPTION_SPLITTERS); |
| 1467 | | splitter = (int *) alloca(GetSplitterCount() * sizeof(*splitter)); |
| 1468 | | SplitterDecodeString(splitter_string, splitter); |
| 1469 | | |
| 1470 | | splitter[splitterId] = pos; |
| 1471 | | |
| 1472 | | SplitterEncodeString(splitter, buffer); |
| 1473 | | options_set_string(settings, M32OPTION_SPLITTERS, buffer, OPTION_PRIORITY_CMDLINE); |
| 1474 | | } |
| 1475 | | } |
| 1476 | | |
| 1477 | | int GetSplitterPos(int splitterId) |
| 1478 | | { |
| 1479 | | const char *splitter_string; |
| 1480 | | int *splitter; |
| 1481 | | |
| 1482 | | splitter_string = options_get_string(settings, M32OPTION_SPLITTERS); |
| 1483 | | splitter = (int *) alloca(GetSplitterCount() * sizeof(*splitter)); |
| 1484 | | SplitterDecodeString(splitter_string, splitter); |
| 1485 | | |
| 1486 | | if (splitterId < GetSplitterCount()) |
| 1487 | | return splitter[splitterId]; |
| 1488 | | |
| 1489 | | return -1; /* Error */ |
| 1490 | | } |
| 1491 | | |
| 1492 | | void SetColumnOrder(int order[]) |
| 1493 | | { |
| 1494 | | char column_order_string[10000]; |
| 1495 | | ColumnEncodeStringWithCount(order, column_order_string, COLUMN_MAX); |
| 1496 | | options_set_string(settings, M32OPTION_COLUMN_ORDER, column_order_string, OPTION_PRIORITY_CMDLINE); |
| 1497 | | } |
| 1498 | | |
| 1499 | | void GetColumnOrder(int order[]) |
| 1500 | | { |
| 1501 | | const char *column_order_string; |
| 1502 | | column_order_string = options_get_string(settings, M32OPTION_COLUMN_ORDER); |
| 1503 | | ColumnDecodeStringWithCount(column_order_string, order, COLUMN_MAX); |
| 1504 | | } |
| 1505 | | |
| 1506 | | void SetColumnShown(int shown[]) |
| 1507 | | { |
| 1508 | | char column_shown_string[10000]; |
| 1509 | | ColumnEncodeStringWithCount(shown, column_shown_string, COLUMN_MAX); |
| 1510 | | options_set_string(settings, M32OPTION_COLUMN_SHOWN, column_shown_string, OPTION_PRIORITY_CMDLINE); |
| 1511 | | } |
| 1512 | | |
| 1513 | | void GetColumnShown(int shown[]) |
| 1514 | | { |
| 1515 | | const char *column_shown_string; |
| 1516 | | column_shown_string = options_get_string(settings, M32OPTION_COLUMN_SHOWN); |
| 1517 | | ColumnDecodeStringWithCount(column_shown_string, shown, COLUMN_MAX); |
| 1518 | | } |
| 1519 | | |
| 1520 | | void SetSortColumn(int column) |
| 1521 | | { |
| 1522 | | options_set_int(settings, M32OPTION_SORT_COLUMN, column, OPTION_PRIORITY_CMDLINE); |
| 1523 | | } |
| 1524 | | |
| 1525 | | int GetSortColumn(void) |
| 1526 | | { |
| 1527 | | return options_get_int(settings, M32OPTION_SORT_COLUMN); |
| 1528 | | } |
| 1529 | | |
| 1530 | | void SetSortReverse(BOOL reverse) |
| 1531 | | { |
| 1532 | | options_set_bool(settings, M32OPTION_SORT_REVERSED, reverse, OPTION_PRIORITY_CMDLINE); |
| 1533 | | } |
| 1534 | | |
| 1535 | | BOOL GetSortReverse(void) |
| 1536 | | { |
| 1537 | | return options_get_bool(settings, M32OPTION_SORT_REVERSED); |
| 1538 | | } |
| 1539 | | |
| 1540 | | const char* GetLanguage(void) |
| 1541 | | { |
| 1542 | | return options_get_string(settings, M32OPTION_LANGUAGE); |
| 1543 | | } |
| 1544 | | |
| 1545 | | void SetLanguage(const char* lang) |
| 1546 | | { |
| 1547 | | options_set_string(settings, M32OPTION_LANGUAGE, lang, OPTION_PRIORITY_CMDLINE); |
| 1548 | | } |
| 1549 | | |
| 1550 | | const char* GetRomDirs(void) |
| 1551 | | { |
| 1552 | | return options_get_string(global, OPTION_ROMPATH); |
| 1553 | | } |
| 1554 | | |
| 1555 | | void SetRomDirs(const char* paths) |
| 1556 | | { |
| 1557 | | options_set_string(global, OPTION_ROMPATH, paths, OPTION_PRIORITY_CMDLINE); |
| 1558 | | } |
| 1559 | | |
| 1560 | | const char* GetSampleDirs(void) |
| 1561 | | { |
| 1562 | | return options_get_string(global, OPTION_SAMPLEPATH); |
| 1563 | | } |
| 1564 | | |
| 1565 | | void SetSampleDirs(const char* paths) |
| 1566 | | { |
| 1567 | | options_set_string(global, OPTION_SAMPLEPATH, paths, OPTION_PRIORITY_CMDLINE); |
| 1568 | | } |
| 1569 | | |
| 1570 | | const char * GetIniDir(void) |
| 1571 | | { |
| 1572 | | const char *ini_dir; |
| 1573 | | const char *s; |
| 1574 | | |
| 1575 | | ini_dir = options_get_string(global, OPTION_INIPATH); |
| 1576 | | while((s = strchr(ini_dir, ';')) != NULL) |
| 1577 | | { |
| 1578 | | ini_dir = s + 1; |
| 1579 | | } |
| 1580 | | return ini_dir; |
| 1581 | | |
| 1582 | | } |
| 1583 | | |
| 1584 | | void SetIniDir(const char *path) |
| 1585 | | { |
| 1586 | | options_set_string(global, OPTION_INIPATH, path, OPTION_PRIORITY_CMDLINE); |
| 1587 | | } |
| 1588 | | |
| 1589 | | const char* GetCtrlrDir(void) |
| 1590 | | { |
| 1591 | | return options_get_string(global, OPTION_CTRLRPATH); |
| 1592 | | } |
| 1593 | | |
| 1594 | | void SetCtrlrDir(const char* path) |
| 1595 | | { |
| 1596 | | options_set_string(global, OPTION_CTRLRPATH, path, OPTION_PRIORITY_CMDLINE); |
| 1597 | | } |
| 1598 | | |
| 1599 | | const char* GetCommentDir(void) |
| 1600 | | { |
| 1601 | | return options_get_string(global, OPTION_COMMENT_DIRECTORY); |
| 1602 | | } |
| 1603 | | |
| 1604 | | void SetCommentDir(const char* path) |
| 1605 | | { |
| 1606 | | options_set_string(global, OPTION_COMMENT_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1607 | | } |
| 1608 | | |
| 1609 | | const char* GetCfgDir(void) |
| 1610 | | { |
| 1611 | | return options_get_string(global, OPTION_CFG_DIRECTORY); |
| 1612 | | } |
| 1613 | | |
| 1614 | | void SetCfgDir(const char* path) |
| 1615 | | { |
| 1616 | | options_set_string(global, OPTION_CFG_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1617 | | } |
| 1618 | | |
| 1619 | | const char* GetNvramDir(void) |
| 1620 | | { |
| 1621 | | return options_get_string(global, OPTION_NVRAM_DIRECTORY); |
| 1622 | | } |
| 1623 | | |
| 1624 | | void SetNvramDir(const char* path) |
| 1625 | | { |
| 1626 | | options_set_string(global, OPTION_NVRAM_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1627 | | } |
| 1628 | | |
| 1629 | | const char* GetInpDir(void) |
| 1630 | | { |
| 1631 | | return options_get_string(global, OPTION_INPUT_DIRECTORY); |
| 1632 | | } |
| 1633 | | |
| 1634 | | void SetInpDir(const char* path) |
| 1635 | | { |
| 1636 | | options_set_string(global, OPTION_INPUT_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1637 | | } |
| 1638 | | |
| 1639 | | const char* GetImgDir(void) |
| 1640 | | { |
| 1641 | | return options_get_string(global, OPTION_SNAPSHOT_DIRECTORY); |
| 1642 | | } |
| 1643 | | |
| 1644 | | void SetImgDir(const char* path) |
| 1645 | | { |
| 1646 | | options_set_string(global, OPTION_SNAPSHOT_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1647 | | } |
| 1648 | | |
| 1649 | | const char* GetStateDir(void) |
| 1650 | | { |
| 1651 | | return options_get_string(global, OPTION_STATE_DIRECTORY); |
| 1652 | | } |
| 1653 | | |
| 1654 | | void SetStateDir(const char* path) |
| 1655 | | { |
| 1656 | | options_set_string(global, OPTION_STATE_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1657 | | } |
| 1658 | | |
| 1659 | | const char* GetArtDir(void) |
| 1660 | | { |
| 1661 | | return options_get_string(global, OPTION_ARTPATH); |
| 1662 | | } |
| 1663 | | |
| 1664 | | void SetArtDir(const char* path) |
| 1665 | | { |
| 1666 | | options_set_string(global, OPTION_ARTPATH, path, OPTION_PRIORITY_CMDLINE); |
| 1667 | | } |
| 1668 | | |
| 1669 | | const char* GetMemcardDir(void) |
| 1670 | | { |
| 1671 | | return options_get_string(global, OPTION_MEMCARD_DIRECTORY); |
| 1672 | | } |
| 1673 | | |
| 1674 | | void SetMemcardDir(const char* path) |
| 1675 | | { |
| 1676 | | options_set_string(global, OPTION_MEMCARD_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1677 | | } |
| 1678 | | |
| 1679 | | const char* GetFlyerDir(void) |
| 1680 | | { |
| 1681 | | return options_get_string(settings, M32OPTION_FLYER_DIRECTORY); |
| 1682 | | } |
| 1683 | | |
| 1684 | | void SetFlyerDir(const char* path) |
| 1685 | | { |
| 1686 | | options_set_string(settings, M32OPTION_FLYER_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1687 | | } |
| 1688 | | |
| 1689 | | const char* GetCabinetDir(void) |
| 1690 | | { |
| 1691 | | return options_get_string(settings, M32OPTION_CABINET_DIRECTORY); |
| 1692 | | } |
| 1693 | | |
| 1694 | | void SetCabinetDir(const char* path) |
| 1695 | | { |
| 1696 | | options_set_string(settings, M32OPTION_CABINET_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1697 | | } |
| 1698 | | |
| 1699 | | const char* GetMarqueeDir(void) |
| 1700 | | { |
| 1701 | | return options_get_string(settings, M32OPTION_MARQUEE_DIRECTORY); |
| 1702 | | } |
| 1703 | | |
| 1704 | | void SetMarqueeDir(const char* path) |
| 1705 | | { |
| 1706 | | options_set_string(settings, M32OPTION_MARQUEE_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1707 | | } |
| 1708 | | |
| 1709 | | const char* GetTitlesDir(void) |
| 1710 | | { |
| 1711 | | return options_get_string(settings, M32OPTION_TITLE_DIRECTORY); |
| 1712 | | } |
| 1713 | | |
| 1714 | | void SetTitlesDir(const char* path) |
| 1715 | | { |
| 1716 | | options_set_string(settings, M32OPTION_TITLE_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1717 | | } |
| 1718 | | |
| 1719 | | const char * GetControlPanelDir(void) |
| 1720 | | { |
| 1721 | | return options_get_string(settings, M32OPTION_CPANEL_DIRECTORY); |
| 1722 | | } |
| 1723 | | |
| 1724 | | void SetControlPanelDir(const char *path) |
| 1725 | | { |
| 1726 | | options_set_string(settings, M32OPTION_CPANEL_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1727 | | } |
| 1728 | | |
| 1729 | | const char * GetDiffDir(void) |
| 1730 | | { |
| 1731 | | return options_get_string(global, OPTION_DIFF_DIRECTORY); |
| 1732 | | } |
| 1733 | | |
| 1734 | | void SetDiffDir(const char* path) |
| 1735 | | { |
| 1736 | | options_set_string(global, OPTION_DIFF_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1737 | | } |
| 1738 | | |
| 1739 | | const char* GetIconsDir(void) |
| 1740 | | { |
| 1741 | | return options_get_string(settings, M32OPTION_ICONS_DIRECTORY); |
| 1742 | | } |
| 1743 | | |
| 1744 | | void SetIconsDir(const char* path) |
| 1745 | | { |
| 1746 | | options_set_string(settings, M32OPTION_ICONS_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1747 | | } |
| 1748 | | |
| 1749 | | const char* GetBgDir (void) |
| 1750 | | { |
| 1751 | | return options_get_string(settings, M32OPTION_BACKGROUND_DIRECTORY); |
| 1752 | | } |
| 1753 | | |
| 1754 | | void SetBgDir (const char* path) |
| 1755 | | { |
| 1756 | | options_set_string(settings, M32OPTION_BACKGROUND_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1757 | | } |
| 1758 | | |
| 1759 | | const char* GetFolderDir(void) |
| 1760 | | { |
| 1761 | | return options_get_string(settings, M32OPTION_FOLDER_DIRECTORY); |
| 1762 | | } |
| 1763 | | |
| 1764 | | void SetFolderDir(const char* path) |
| 1765 | | { |
| 1766 | | options_set_string(settings, M32OPTION_FOLDER_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1767 | | } |
| 1768 | | |
| 1769 | | const char* GetCheatFileName(void) |
| 1770 | | { |
| 1771 | | return options_get_string(global, OPTION_CHEAT_FILE); |
| 1772 | | } |
| 1773 | | |
| 1774 | | void SetCheatFileName(const char* path) |
| 1775 | | { |
| 1776 | | options_set_string(global, OPTION_CHEAT_FILE, path, OPTION_PRIORITY_CMDLINE); |
| 1777 | | } |
| 1778 | | |
| 1779 | | const char* GetHistoryFileName(void) |
| 1780 | | { |
| 1781 | | return options_get_string(settings, M32OPTION_HISTORY_FILE); |
| 1782 | | } |
| 1783 | | |
| 1784 | | void SetHistoryFileName(const char* path) |
| 1785 | | { |
| 1786 | | options_set_string(settings, M32OPTION_HISTORY_FILE, path, OPTION_PRIORITY_CMDLINE); |
| 1787 | | } |
| 1788 | | |
| 1789 | | |
| 1790 | | const char* GetMAMEInfoFileName(void) |
| 1791 | | { |
| 1792 | | return options_get_string(settings, M32OPTION_MAMEINFO_FILE); |
| 1793 | | } |
| 1794 | | |
| 1795 | | void SetMAMEInfoFileName(const char* path) |
| 1796 | | { |
| 1797 | | options_set_string(settings, M32OPTION_MAMEINFO_FILE, path, OPTION_PRIORITY_CMDLINE); |
| 1798 | | } |
| 1799 | | |
| 1800 | | void ResetGameOptions(int driver_index) |
| 1801 | | { |
| 1802 | | assert(0 <= driver_index && driver_index < driver_list_get_count(drivers)); |
| 1803 | | |
| 1804 | | // make sure it's all loaded up. |
| 1805 | | GetGameOptions(driver_index, GLOBAL_OPTIONS); |
| 1806 | | |
| 1807 | | if (game_options[driver_index] != NULL) |
| 1808 | | { |
| 1809 | | options_free(game_options[driver_index]); |
| 1810 | | game_options[driver_index] = NULL; |
| 1811 | | |
| 1812 | | // this will delete the custom file |
| 1813 | | SaveGameOptions(driver_index); |
| 1814 | | } |
| 1815 | | } |
| 1816 | | |
| 1817 | | void ResetGameDefaults(void) |
| 1818 | | { |
| 1819 | | save_default_options = FALSE; |
| 1820 | | } |
| 1821 | | |
| 1822 | | void ResetAllGameOptions(void) |
| 1823 | | { |
| 1824 | | int i; |
| 1825 | | int redirect_value = 0; |
| 1826 | | |
| 1827 | | for (i = 0; i < driver_list_get_count(drivers); i++) |
| 1828 | | { |
| 1829 | | ResetGameOptions(i); |
| 1830 | | } |
| 1831 | | |
| 1832 | | //with our new code we also need to delete the Source Folder Options and the Vector Options |
| 1833 | | //Reset the Folder Options, can be done in one step |
| 1834 | | for (i=0;i<GetNumOptionFolders();i++) |
| 1835 | | { |
| 1836 | | //Use the redirect array, to get correct folder |
| 1837 | | redirect_value = GetRedirectValue(i); |
| 1838 | | if( redirect_value < 0) |
| 1839 | | continue; |
| 1840 | | options_copy(folder_options[i], GetDefaultOptions(GLOBAL_OPTIONS, FALSE)); |
| 1841 | | SaveFolderOptions(redirect_value, 0); |
| 1842 | | } |
| 1843 | | } |
| 1844 | | |
| 1845 | | static void GetDriverOptionName(int driver_index, const char *option_name, char *buffer, size_t buffer_len) |
| 1846 | | { |
| 1847 | | assert(0 <= driver_index && driver_index < driver_list_get_count(drivers)); |
| 1848 | | snprintf(buffer, buffer_len, "%s_%s", drivers[driver_index]->name, option_name); |
| 1849 | | } |
| 1850 | | |
| 1851 | | int GetRomAuditResults(int driver_index) |
| 1852 | | { |
| 1853 | | char buffer[128]; |
| 1854 | | GetDriverOptionName(driver_index, "rom_audit", buffer, ARRAY_LENGTH(buffer)); |
| 1855 | | return options_get_int(settings, buffer); |
| 1856 | | } |
| 1857 | | |
| 1858 | | void SetRomAuditResults(int driver_index, int audit_results) |
| 1859 | | { |
| 1860 | | char buffer[128]; |
| 1861 | | GetDriverOptionName(driver_index, "rom_audit", buffer, ARRAY_LENGTH(buffer)); |
| 1862 | | options_set_int(settings, buffer, audit_results, OPTION_PRIORITY_CMDLINE); |
| 1863 | | } |
| 1864 | | |
| 1865 | | int GetSampleAuditResults(int driver_index) |
| 1866 | | { |
| 1867 | | char buffer[128]; |
| 1868 | | GetDriverOptionName(driver_index, "samples_audit", buffer, ARRAY_LENGTH(buffer)); |
| 1869 | | return options_get_int(settings, buffer); |
| 1870 | | } |
| 1871 | | |
| 1872 | | void SetSampleAuditResults(int driver_index, int audit_results) |
| 1873 | | { |
| 1874 | | char buffer[128]; |
| 1875 | | GetDriverOptionName(driver_index, "samples_audit", buffer, ARRAY_LENGTH(buffer)); |
| 1876 | | options_set_int(settings, buffer, audit_results, OPTION_PRIORITY_CMDLINE); |
| 1877 | | } |
| 1878 | | |
| 1879 | | static void IncrementPlayVariable(int driver_index, const char *play_variable, int increment) |
| 1880 | | { |
| 1881 | | char buffer[128]; |
| 1882 | | int count; |
| 1883 | | |
| 1884 | | GetDriverOptionName(driver_index, play_variable, buffer, ARRAY_LENGTH(buffer)); |
| 1885 | | count = options_get_int(settings, buffer); |
| 1886 | | options_set_int(settings, buffer, count + increment, OPTION_PRIORITY_CMDLINE); |
| 1887 | | } |
| 1888 | | |
| 1889 | | void IncrementPlayCount(int driver_index) |
| 1890 | | { |
| 1891 | | IncrementPlayVariable(driver_index, "play_count", 1); |
| 1892 | | } |
| 1893 | | |
| 1894 | | int GetPlayCount(int driver_index) |
| 1895 | | { |
| 1896 | | char buffer[128]; |
| 1897 | | GetDriverOptionName(driver_index, "play_count", buffer, ARRAY_LENGTH(buffer)); |
| 1898 | | return options_get_int(settings, buffer); |
| 1899 | | } |
| 1900 | | |
| 1901 | | static void ResetPlayVariable(int driver_index, const char *play_variable) |
| 1902 | | { |
| 1903 | | int i; |
| 1904 | | if (driver_index < 0) |
| 1905 | | { |
| 1906 | | // all games |
| 1907 | | for (i = 0; i< driver_list_get_count(drivers); i++) |
| 1908 | | { |
| 1909 | | ResetPlayVariable(driver_index, play_variable); |
| 1910 | | } |
| 1911 | | } |
| 1912 | | else |
| 1913 | | { |
| 1914 | | char buffer[128]; |
| 1915 | | GetDriverOptionName(driver_index, play_variable, buffer, ARRAY_LENGTH(buffer)); |
| 1916 | | options_set_int(settings, buffer, 0, OPTION_PRIORITY_CMDLINE); |
| 1917 | | } |
| 1918 | | } |
| 1919 | | |
| 1920 | | void ResetPlayCount(int driver_index) |
| 1921 | | { |
| 1922 | | ResetPlayVariable(driver_index, "play_count"); |
| 1923 | | } |
| 1924 | | |
| 1925 | | void ResetPlayTime(int driver_index) |
| 1926 | | { |
| 1927 | | ResetPlayVariable(driver_index, "play_time"); |
| 1928 | | } |
| 1929 | | |
| 1930 | | int GetPlayTime(int driver_index) |
| 1931 | | { |
| 1932 | | char buffer[128]; |
| 1933 | | GetDriverOptionName(driver_index, "play_time", buffer, ARRAY_LENGTH(buffer)); |
| 1934 | | return options_get_int(settings, buffer); |
| 1935 | | } |
| 1936 | | |
| 1937 | | void IncrementPlayTime(int driver_index,int playtime) |
| 1938 | | { |
| 1939 | | IncrementPlayVariable(driver_index, "play_time", playtime); |
| 1940 | | } |
| 1941 | | |
| 1942 | | void GetTextPlayTime(int driver_index,char *buf) |
| 1943 | | { |
| 1944 | | int hour, minute, second; |
| 1945 | | int temp = GetPlayTime(driver_index); |
| 1946 | | |
| 1947 | | assert(0 <= driver_index && driver_index < driver_list_get_count(drivers)); |
| 1948 | | |
| 1949 | | hour = temp / 3600; |
| 1950 | | temp = temp - 3600*hour; |
| 1951 | | minute = temp / 60; //Calc Minutes |
| 1952 | | second = temp - 60*minute; |
| 1953 | | |
| 1954 | | if (hour == 0) |
| 1955 | | sprintf(buf, "%d:%02d", minute, second ); |
| 1956 | | else |
| 1957 | | sprintf(buf, "%d:%02d:%02d", hour, minute, second ); |
| 1958 | | } |
| 1959 | | |
| 1960 | | input_seq* Get_ui_key_up(void) |
| 1961 | | { |
| 1962 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_UP); |
| 1963 | | } |
| 1964 | | input_seq* Get_ui_key_down(void) |
| 1965 | | { |
| 1966 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_DOWN); |
| 1967 | | } |
| 1968 | | input_seq* Get_ui_key_left(void) |
| 1969 | | { |
| 1970 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_LEFT); |
| 1971 | | } |
| 1972 | | input_seq* Get_ui_key_right(void) |
| 1973 | | { |
| 1974 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_RIGHT); |
| 1975 | | } |
| 1976 | | input_seq* Get_ui_key_start(void) |
| 1977 | | { |
| 1978 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_START); |
| 1979 | | } |
| 1980 | | input_seq* Get_ui_key_pgup(void) |
| 1981 | | { |
| 1982 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_PGUP); |
| 1983 | | } |
| 1984 | | input_seq* Get_ui_key_pgdwn(void) |
| 1985 | | { |
| 1986 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_PGDWN); |
| 1987 | | } |
| 1988 | | input_seq* Get_ui_key_home(void) |
| 1989 | | { |
| 1990 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_HOME); |
| 1991 | | } |
| 1992 | | input_seq* Get_ui_key_end(void) |
| 1993 | | { |
| 1994 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_END); |
| 1995 | | } |
| 1996 | | input_seq* Get_ui_key_ss_change(void) |
| 1997 | | { |
| 1998 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_SS_CHANGE); |
| 1999 | | } |
| 2000 | | input_seq* Get_ui_key_history_up(void) |
| 2001 | | { |
| 2002 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_HISTORY_UP); |
| 2003 | | } |
| 2004 | | input_seq* Get_ui_key_history_down(void) |
| 2005 | | { |
| 2006 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_HISTORY_DOWN); |
| 2007 | | } |
| 2008 | | |
| 2009 | | |
| 2010 | | input_seq* Get_ui_key_context_filters(void) |
| 2011 | | { |
| 2012 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_CONTEXT_FILTERS); |
| 2013 | | } |
| 2014 | | input_seq* Get_ui_key_select_random(void) |
| 2015 | | { |
| 2016 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_SELECT_RANDOM); |
| 2017 | | } |
| 2018 | | input_seq* Get_ui_key_game_audit(void) |
| 2019 | | { |
| 2020 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_GAME_AUDIT); |
| 2021 | | } |
| 2022 | | input_seq* Get_ui_key_game_properties(void) |
| 2023 | | { |
| 2024 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_GAME_PROPERTIES); |
| 2025 | | } |
| 2026 | | input_seq* Get_ui_key_help_contents(void) |
| 2027 | | { |
| 2028 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_HELP_CONTENTS); |
| 2029 | | } |
| 2030 | | input_seq* Get_ui_key_update_gamelist(void) |
| 2031 | | { |
| 2032 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_UPDATE_GAMELIST); |
| 2033 | | } |
| 2034 | | input_seq* Get_ui_key_view_folders(void) |
| 2035 | | { |
| 2036 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_FOLDERS); |
| 2037 | | } |
| 2038 | | input_seq* Get_ui_key_view_fullscreen(void) |
| 2039 | | { |
| 2040 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_FULLSCREEN); |
| 2041 | | } |
| 2042 | | input_seq* Get_ui_key_view_pagetab(void) |
| 2043 | | { |
| 2044 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_PAGETAB); |
| 2045 | | } |
| 2046 | | input_seq* Get_ui_key_view_picture_area(void) |
| 2047 | | { |
| 2048 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_PICTURE_AREA); |
| 2049 | | } |
| 2050 | | input_seq* Get_ui_key_view_status(void) |
| 2051 | | { |
| 2052 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_STATUS); |
| 2053 | | } |
| 2054 | | input_seq* Get_ui_key_view_toolbars(void) |
| 2055 | | { |
| 2056 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_TOOLBARS); |
| 2057 | | } |
| 2058 | | |
| 2059 | | input_seq* Get_ui_key_view_tab_cabinet(void) |
| 2060 | | { |
| 2061 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_TAB_CABINET); |
| 2062 | | } |
| 2063 | | input_seq* Get_ui_key_view_tab_cpanel(void) |
| 2064 | | { |
| 2065 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_TAB_CPANEL); |
| 2066 | | } |
| 2067 | | input_seq* Get_ui_key_view_tab_flyer(void) |
| 2068 | | { |
| 2069 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_TAB_FLYER); |
| 2070 | | } |
| 2071 | | input_seq* Get_ui_key_view_tab_history(void) |
| 2072 | | { |
| 2073 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_TAB_HISTORY); |
| 2074 | | } |
| 2075 | | input_seq* Get_ui_key_view_tab_marquee(void) |
| 2076 | | { |
| 2077 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_TAB_MARQUEE); |
| 2078 | | } |
| 2079 | | input_seq* Get_ui_key_view_tab_screenshot(void) |
| 2080 | | { |
| 2081 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_TAB_SCREENSHOT); |
| 2082 | | } |
| 2083 | | input_seq* Get_ui_key_view_tab_title(void) |
| 2084 | | { |
| 2085 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_TAB_TITLE); |
| 2086 | | } |
| 2087 | | input_seq* Get_ui_key_quit(void) |
| 2088 | | { |
| 2089 | | return options_get_input_seq(settings, M32OPTION_UI_KEY_QUIT); |
| 2090 | | } |
| 2091 | | |
| 2092 | | |
| 2093 | | |
| 2094 | | static int GetUIJoy(const char *option_name, int joycodeIndex) |
| 2095 | | { |
| 2096 | | const char *joycodes_string; |
| 2097 | | int joycodes[4]; |
| 2098 | | |
| 2099 | | assert(0 <= joycodeIndex && joycodeIndex < 4); |
| 2100 | | joycodes_string = options_get_string(settings, option_name); |
| 2101 | | ColumnDecodeStringWithCount(joycodes_string, joycodes, ARRAY_LENGTH(joycodes)); |
| 2102 | | return joycodes[joycodeIndex]; |
| 2103 | | } |
| 2104 | | |
| 2105 | | static void SetUIJoy(const char *option_name, int joycodeIndex, int val) |
| 2106 | | { |
| 2107 | | const char *joycodes_string; |
| 2108 | | int joycodes[4]; |
| 2109 | | char buffer[1024]; |
| 2110 | | |
| 2111 | | assert(0 <= joycodeIndex && joycodeIndex < 4); |
| 2112 | | joycodes_string = options_get_string(settings, option_name); |
| 2113 | | ColumnDecodeStringWithCount(joycodes_string, joycodes, ARRAY_LENGTH(joycodes)); |
| 2114 | | |
| 2115 | | joycodes[joycodeIndex] = val; |
| 2116 | | ColumnEncodeStringWithCount(joycodes, buffer, ARRAY_LENGTH(joycodes)); |
| 2117 | | options_set_string(settings, option_name, buffer, OPTION_PRIORITY_CMDLINE); |
| 2118 | | |
| 2119 | | |
| 2120 | | } |
| 2121 | | |
| 2122 | | int GetUIJoyUp(int joycodeIndex) |
| 2123 | | { |
| 2124 | | return GetUIJoy(M32OPTION_UI_JOY_UP, joycodeIndex); |
| 2125 | | } |
| 2126 | | |
| 2127 | | void SetUIJoyUp(int joycodeIndex, int val) |
| 2128 | | { |
| 2129 | | SetUIJoy(M32OPTION_UI_JOY_UP, joycodeIndex, val); |
| 2130 | | } |
| 2131 | | |
| 2132 | | int GetUIJoyDown(int joycodeIndex) |
| 2133 | | { |
| 2134 | | return GetUIJoy(M32OPTION_UI_JOY_DOWN, joycodeIndex); |
| 2135 | | } |
| 2136 | | |
| 2137 | | void SetUIJoyDown(int joycodeIndex, int val) |
| 2138 | | { |
| 2139 | | SetUIJoy(M32OPTION_UI_JOY_DOWN, joycodeIndex, val); |
| 2140 | | } |
| 2141 | | |
| 2142 | | int GetUIJoyLeft(int joycodeIndex) |
| 2143 | | { |
| 2144 | | return GetUIJoy(M32OPTION_UI_JOY_LEFT, joycodeIndex); |
| 2145 | | } |
| 2146 | | |
| 2147 | | void SetUIJoyLeft(int joycodeIndex, int val) |
| 2148 | | { |
| 2149 | | SetUIJoy(M32OPTION_UI_JOY_LEFT, joycodeIndex, val); |
| 2150 | | } |
| 2151 | | |
| 2152 | | int GetUIJoyRight(int joycodeIndex) |
| 2153 | | { |
| 2154 | | return GetUIJoy(M32OPTION_UI_JOY_RIGHT, joycodeIndex); |
| 2155 | | } |
| 2156 | | |
| 2157 | | void SetUIJoyRight(int joycodeIndex, int val) |
| 2158 | | { |
| 2159 | | SetUIJoy(M32OPTION_UI_JOY_RIGHT, joycodeIndex, val); |
| 2160 | | } |
| 2161 | | |
| 2162 | | int GetUIJoyStart(int joycodeIndex) |
| 2163 | | { |
| 2164 | | return GetUIJoy(M32OPTION_UI_JOY_START, joycodeIndex); |
| 2165 | | } |
| 2166 | | |
| 2167 | | void SetUIJoyStart(int joycodeIndex, int val) |
| 2168 | | { |
| 2169 | | SetUIJoy(M32OPTION_UI_JOY_START, joycodeIndex, val); |
| 2170 | | } |
| 2171 | | |
| 2172 | | int GetUIJoyPageUp(int joycodeIndex) |
| 2173 | | { |
| 2174 | | return GetUIJoy(M32OPTION_UI_JOY_PGUP, joycodeIndex); |
| 2175 | | } |
| 2176 | | |
| 2177 | | void SetUIJoyPageUp(int joycodeIndex, int val) |
| 2178 | | { |
| 2179 | | SetUIJoy(M32OPTION_UI_JOY_PGUP, joycodeIndex, val); |
| 2180 | | } |
| 2181 | | |
| 2182 | | int GetUIJoyPageDown(int joycodeIndex) |
| 2183 | | { |
| 2184 | | return GetUIJoy(M32OPTION_UI_JOY_PGDWN, joycodeIndex); |
| 2185 | | } |
| 2186 | | |
| 2187 | | void SetUIJoyPageDown(int joycodeIndex, int val) |
| 2188 | | { |
| 2189 | | SetUIJoy(M32OPTION_UI_JOY_PGDWN, joycodeIndex, val); |
| 2190 | | } |
| 2191 | | |
| 2192 | | int GetUIJoyHome(int joycodeIndex) |
| 2193 | | { |
| 2194 | | return GetUIJoy(M32OPTION_UI_JOY_HOME, joycodeIndex); |
| 2195 | | } |
| 2196 | | |
| 2197 | | void SetUIJoyHome(int joycodeIndex, int val) |
| 2198 | | { |
| 2199 | | SetUIJoy(M32OPTION_UI_JOY_HOME, joycodeIndex, val); |
| 2200 | | } |
| 2201 | | |
| 2202 | | int GetUIJoyEnd(int joycodeIndex) |
| 2203 | | { |
| 2204 | | return GetUIJoy(M32OPTION_UI_JOY_END, joycodeIndex); |
| 2205 | | } |
| 2206 | | |
| 2207 | | void SetUIJoyEnd(int joycodeIndex, int val) |
| 2208 | | { |
| 2209 | | SetUIJoy(M32OPTION_UI_JOY_END, joycodeIndex, val); |
| 2210 | | } |
| 2211 | | |
| 2212 | | int GetUIJoySSChange(int joycodeIndex) |
| 2213 | | { |
| 2214 | | return GetUIJoy(M32OPTION_UI_JOY_SS_CHANGE, joycodeIndex); |
| 2215 | | } |
| 2216 | | |
| 2217 | | void SetUIJoySSChange(int joycodeIndex, int val) |
| 2218 | | { |
| 2219 | | SetUIJoy(M32OPTION_UI_JOY_SS_CHANGE, joycodeIndex, val); |
| 2220 | | } |
| 2221 | | |
| 2222 | | int GetUIJoyHistoryUp(int joycodeIndex) |
| 2223 | | { |
| 2224 | | return GetUIJoy(M32OPTION_UI_JOY_HISTORY_UP, joycodeIndex); |
| 2225 | | } |
| 2226 | | |
| 2227 | | void SetUIJoyHistoryUp(int joycodeIndex, int val) |
| 2228 | | { |
| 2229 | | SetUIJoy(M32OPTION_UI_JOY_HISTORY_UP, joycodeIndex, val); |
| 2230 | | } |
| 2231 | | |
| 2232 | | int GetUIJoyHistoryDown(int joycodeIndex) |
| 2233 | | { |
| 2234 | | return GetUIJoy(M32OPTION_UI_JOY_HISTORY_DOWN, joycodeIndex); |
| 2235 | | } |
| 2236 | | |
| 2237 | | void SetUIJoyHistoryDown(int joycodeIndex, int val) |
| 2238 | | { |
| 2239 | | SetUIJoy(M32OPTION_UI_JOY_HISTORY_DOWN, joycodeIndex, val); |
| 2240 | | } |
| 2241 | | |
| 2242 | | void SetUIJoyExec(int joycodeIndex, int val) |
| 2243 | | { |
| 2244 | | SetUIJoy(M32OPTION_UI_JOY_EXEC, joycodeIndex, val); |
| 2245 | | } |
| 2246 | | |
| 2247 | | int GetUIJoyExec(int joycodeIndex) |
| 2248 | | { |
| 2249 | | return GetUIJoy(M32OPTION_UI_JOY_EXEC, joycodeIndex); |
| 2250 | | } |
| 2251 | | |
| 2252 | | const char * GetExecCommand(void) |
| 2253 | | { |
| 2254 | | return options_get_string(settings, M32OPTION_EXEC_COMMAND); |
| 2255 | | } |
| 2256 | | |
| 2257 | | void SetExecCommand(char *cmd) |
| 2258 | | { |
| 2259 | | options_set_string(settings, M32OPTION_EXEC_COMMAND, cmd, OPTION_PRIORITY_CMDLINE); |
| 2260 | | } |
| 2261 | | |
| 2262 | | int GetExecWait(void) |
| 2263 | | { |
| 2264 | | return options_get_int(settings, M32OPTION_EXEC_WAIT); |
| 2265 | | } |
| 2266 | | |
| 2267 | | void SetExecWait(int wait) |
| 2268 | | { |
| 2269 | | options_set_int(settings, M32OPTION_EXEC_WAIT, wait, OPTION_PRIORITY_CMDLINE); |
| 2270 | | } |
| 2271 | | |
| 2272 | | BOOL GetHideMouseOnStartup(void) |
| 2273 | | { |
| 2274 | | return options_get_bool(settings, M32OPTION_HIDE_MOUSE); |
| 2275 | | } |
| 2276 | | |
| 2277 | | void SetHideMouseOnStartup(BOOL hide) |
| 2278 | | { |
| 2279 | | options_set_bool(settings, M32OPTION_HIDE_MOUSE, hide, OPTION_PRIORITY_CMDLINE); |
| 2280 | | } |
| 2281 | | |
| 2282 | | BOOL GetRunFullScreen(void) |
| 2283 | | { |
| 2284 | | return options_get_bool(settings, M32OPTION_FULL_SCREEN); |
| 2285 | | } |
| 2286 | | |
| 2287 | | void SetRunFullScreen(BOOL fullScreen) |
| 2288 | | { |
| 2289 | | options_set_bool(settings, M32OPTION_FULL_SCREEN, fullScreen, OPTION_PRIORITY_CMDLINE); |
| 2290 | | } |
| 2291 | | |
| 2292 | | /*************************************************************************** |
| 2293 | | Internal functions |
| 2294 | | ***************************************************************************/ |
| 2295 | | |
| 2296 | | static void CusColorEncodeString(const COLORREF *value, char* str) |
| 2297 | | { |
| 2298 | | int i; |
| 2299 | | char tmpStr[256]; |
| 2300 | | |
| 2301 | | sprintf(tmpStr, "%u", (int) value[0]); |
| 2302 | | |
| 2303 | | strcpy(str, tmpStr); |
| 2304 | | |
| 2305 | | for (i = 1; i < 16; i++) |
| 2306 | | { |
| 2307 | | sprintf(tmpStr, ",%u", (unsigned) value[i]); |
| 2308 | | strcat(str, tmpStr); |
| 2309 | | } |
| 2310 | | } |
| 2311 | | |
| 2312 | | static void CusColorDecodeString(const char* str, COLORREF *value) |
| 2313 | | { |
| 2314 | | int i; |
| 2315 | | char *s, *p; |
| 2316 | | char tmpStr[256]; |
| 2317 | | |
| 2318 | | strcpy(tmpStr, str); |
| 2319 | | p = tmpStr; |
| 2320 | | |
| 2321 | | for (i = 0; p && i < 16; i++) |
| 2322 | | { |
| 2323 | | s = p; |
| 2324 | | |
| 2325 | | if ((p = strchr(s,',')) != NULL && *p == ',') |
| 2326 | | { |
| 2327 | | *p = '\0'; |
| 2328 | | p++; |
| 2329 | | } |
| 2330 | | value[i] = atoi(s); |
| 2331 | | } |
| 2332 | | } |
| 2333 | | |
| 2334 | | |
| 2335 | | void ColumnEncodeStringWithCount(const int *value, char *str, int count) |
| 2336 | | { |
| 2337 | | int i; |
| 2338 | | char buffer[100]; |
| 2339 | | |
| 2340 | | snprintf(buffer,sizeof(buffer),"%d",value[0]); |
| 2341 | | |
| 2342 | | strcpy(str,buffer); |
| 2343 | | |
| 2344 | | for (i = 1; i < count; i++) |
| 2345 | | { |
| 2346 | | snprintf(buffer,sizeof(buffer),",%d",value[i]); |
| 2347 | | strcat(str,buffer); |
| 2348 | | } |
| 2349 | | } |
| 2350 | | |
| 2351 | | void ColumnDecodeStringWithCount(const char* str, int *value, int count) |
| 2352 | | { |
| 2353 | | int i; |
| 2354 | | char *s, *p; |
| 2355 | | char tmpStr[100]; |
| 2356 | | |
| 2357 | | if (str == NULL) |
| 2358 | | return; |
| 2359 | | |
| 2360 | | strcpy(tmpStr, str); |
| 2361 | | p = tmpStr; |
| 2362 | | |
| 2363 | | for (i = 0; p && i < count; i++) |
| 2364 | | { |
| 2365 | | s = p; |
| 2366 | | |
| 2367 | | if ((p = strchr(s,',')) != NULL && *p == ',') |
| 2368 | | { |
| 2369 | | *p = '\0'; |
| 2370 | | p++; |
| 2371 | | } |
| 2372 | | value[i] = atoi(s); |
| 2373 | | } |
| 2374 | | } |
| 2375 | | |
| 2376 | | static void SplitterEncodeString(const int *value, char* str) |
| 2377 | | { |
| 2378 | | int i; |
| 2379 | | char tmpStr[100]; |
| 2380 | | |
| 2381 | | sprintf(tmpStr, "%d", value[0]); |
| 2382 | | |
| 2383 | | strcpy(str, tmpStr); |
| 2384 | | |
| 2385 | | for (i = 1; i < GetSplitterCount(); i++) |
| 2386 | | { |
| 2387 | | sprintf(tmpStr, ",%d", value[i]); |
| 2388 | | strcat(str, tmpStr); |
| 2389 | | } |
| 2390 | | } |
| 2391 | | |
| 2392 | | static void SplitterDecodeString(const char *str, int *value) |
| 2393 | | { |
| 2394 | | int i; |
| 2395 | | char *s, *p; |
| 2396 | | char tmpStr[100]; |
| 2397 | | |
| 2398 | | strcpy(tmpStr, str); |
| 2399 | | p = tmpStr; |
| 2400 | | |
| 2401 | | for (i = 0; p && i < GetSplitterCount(); i++) |
| 2402 | | { |
| 2403 | | s = p; |
| 2404 | | |
| 2405 | | if ((p = strchr(s,',')) != NULL && *p == ',') |
| 2406 | | { |
| 2407 | | *p = '\0'; |
| 2408 | | p++; |
| 2409 | | } |
| 2410 | | value[i] = atoi(s); |
| 2411 | | } |
| 2412 | | } |
| 2413 | | |
| 2414 | | /* Parse the given comma-delimited string into a LOGFONT structure */ |
| 2415 | | static void FontDecodeString(const char* str, LOGFONT *f) |
| 2416 | | { |
| 2417 | | char* ptr; |
| 2418 | | TCHAR* t_ptr; |
| 2419 | | |
| 2420 | | sscanf(str, "%li,%li,%li,%li,%li,%i,%i,%i,%i,%i,%i,%i,%i", |
| 2421 | | &f->lfHeight, |
| 2422 | | &f->lfWidth, |
| 2423 | | &f->lfEscapement, |
| 2424 | | &f->lfOrientation, |
| 2425 | | &f->lfWeight, |
| 2426 | | (int*)&f->lfItalic, |
| 2427 | | (int*)&f->lfUnderline, |
| 2428 | | (int*)&f->lfStrikeOut, |
| 2429 | | (int*)&f->lfCharSet, |
| 2430 | | (int*)&f->lfOutPrecision, |
| 2431 | | (int*)&f->lfClipPrecision, |
| 2432 | | (int*)&f->lfQuality, |
| 2433 | | (int*)&f->lfPitchAndFamily); |
| 2434 | | ptr = strrchr(str, ','); |
| 2435 | | if (ptr != NULL) { |
| 2436 | | t_ptr = tstring_from_utf8(ptr + 1); |
| 2437 | | if( !t_ptr ) |
| 2438 | | return; |
| 2439 | | _tcscpy(f->lfFaceName, t_ptr); |
| 2440 | | free(t_ptr); |
| 2441 | | } |
| 2442 | | } |
| 2443 | | |
| 2444 | | /* Encode the given LOGFONT structure into a comma-delimited string */ |
| 2445 | | static void FontEncodeString(const LOGFONT *f, char *str) |
| 2446 | | { |
| 2447 | | char* utf8_FaceName = utf8_from_tstring(f->lfFaceName); |
| 2448 | | if( !utf8_FaceName ) |
| 2449 | | return; |
| 2450 | | |
| 2451 | | sprintf(str, "%li,%li,%li,%li,%li,%i,%i,%i,%i,%i,%i,%i,%i,%s", |
| 2452 | | f->lfHeight, |
| 2453 | | f->lfWidth, |
| 2454 | | f->lfEscapement, |
| 2455 | | f->lfOrientation, |
| 2456 | | f->lfWeight, |
| 2457 | | f->lfItalic, |
| 2458 | | f->lfUnderline, |
| 2459 | | f->lfStrikeOut, |
| 2460 | | f->lfCharSet, |
| 2461 | | f->lfOutPrecision, |
| 2462 | | f->lfClipPrecision, |
| 2463 | | f->lfQuality, |
| 2464 | | f->lfPitchAndFamily, |
| 2465 | | utf8_FaceName); |
| 2466 | | |
| 2467 | | free(utf8_FaceName); |
| 2468 | | } |
| 2469 | | |
| 2470 | | static void TabFlagsEncodeString(int data, char *str) |
| 2471 | | { |
| 2472 | | int i; |
| 2473 | | int num_saved = 0; |
| 2474 | | |
| 2475 | | strcpy(str,""); |
| 2476 | | |
| 2477 | | // we save the ones that are NOT displayed, so we can add new ones |
| 2478 | | // and upgraders will see them |
| 2479 | | for (i=0;i<MAX_TAB_TYPES;i++) |
| 2480 | | { |
| 2481 | | if (((data & (1 << i)) == 0) && GetImageTabShortName(i)) |
| 2482 | | { |
| 2483 | | if (num_saved != 0) |
| 2484 | | strcat(str, ", "); |
| 2485 | | |
| 2486 | | strcat(str,GetImageTabShortName(i)); |
| 2487 | | num_saved++; |
| 2488 | | } |
| 2489 | | } |
| 2490 | | } |
| 2491 | | |
| 2492 | | static void TabFlagsDecodeString(const char *str, int *data) |
| 2493 | | { |
| 2494 | | char s[2000]; |
| 2495 | | char *token; |
| 2496 | | |
| 2497 | | snprintf(s, ARRAY_LENGTH(s), "%s", str); |
| 2498 | | |
| 2499 | | // simple way to set all tab bits "on" |
| 2500 | | *data = (1 << MAX_TAB_TYPES) - 1; |
| 2501 | | |
| 2502 | | token = strtok(s,", \t"); |
| 2503 | | while (token != NULL) |
| 2504 | | { |
| 2505 | | int j; |
| 2506 | | |
| 2507 | | for (j=0;j<MAX_TAB_TYPES;j++) |
| 2508 | | { |
| 2509 | | if (!GetImageTabShortName(j) || (strcmp(GetImageTabShortName(j), token) == 0)) |
| 2510 | | { |
| 2511 | | // turn off this bit |
| 2512 | | *data &= ~(1 << j); |
| 2513 | | break; |
| 2514 | | } |
| 2515 | | } |
| 2516 | | token = strtok(NULL,", \t"); |
| 2517 | | } |
| 2518 | | |
| 2519 | | if (*data == 0) |
| 2520 | | { |
| 2521 | | // not allowed to hide all tabs, because then why even show the area? |
| 2522 | | *data = (1 << TAB_SCREENSHOT); |
| 2523 | | } |
| 2524 | | } |
| 2525 | | |
| 2526 | | |
| 2527 | | |
| 2528 | | static file_error LoadSettingsFile(core_options *opts, const char *filename) |
| 2529 | | { |
| 2530 | | core_file *file; |
| 2531 | | file_error filerr; |
| 2532 | | |
| 2533 | | filerr = core_fopen(filename, OPEN_FLAG_READ, &file); |
| 2534 | | if (filerr == FILERR_NONE) |
| 2535 | | { |
| 2536 | | options_parse_ini_file(opts, file, OPTION_PRIORITY_CMDLINE); |
| 2537 | | core_fclose(file); |
| 2538 | | } |
| 2539 | | return filerr; |
| 2540 | | } |
| 2541 | | |
| 2542 | | |
| 2543 | | |
| 2544 | | static file_error SaveSettingsFile(core_options *opts, const char *filename) |
| 2545 | | { |
| 2546 | | core_file *file; |
| 2547 | | file_error filerr; |
| 2548 | | |
| 2549 | | if (opts != NULL) |
| 2550 | | { |
| 2551 | | filerr = core_fopen(filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file); |
| 2552 | | if (filerr == FILERR_NONE) |
| 2553 | | { |
| 2554 | | options_output_ini_file(opts, file); |
| 2555 | | core_fclose(file); |
| 2556 | | } |
| 2557 | | } |
| 2558 | | else |
| 2559 | | { |
| 2560 | | filerr = osd_rmfile(filename); |
| 2561 | | } |
| 2562 | | |
| 2563 | | return filerr; |
| 2564 | | } |
| 2565 | | |
| 2566 | | |
| 2567 | | |
| 2568 | | static void GetGlobalOptionsFileName(char *filename, size_t filename_size) |
| 2569 | | { |
| 2570 | | char buffer[MAX_PATH]; |
| 2571 | | char *base; |
| 2572 | | char *s; |
| 2573 | | |
| 2574 | | // retrieve filename of executable |
| 2575 | | win_get_module_file_name_utf8(GetModuleHandle(NULL), buffer, ARRAY_LENGTH(buffer)); |
| 2576 | | |
| 2577 | | // locate base filename |
| 2578 | | base = strrchr(buffer, '\\'); |
| 2579 | | base = base ? base + 1 : buffer; |
| 2580 | | |
| 2581 | | // remove ".exe" |
| 2582 | | s = strstr(base, ".exe"); |
| 2583 | | if (s) |
| 2584 | | *s = '\0'; |
| 2585 | | |
| 2586 | | // copy INI directory |
| 2587 | | snprintf(filename, filename_size, "%s\\%s.ini", GetIniDir(), base); |
| 2588 | | } |
| 2589 | | |
| 2590 | | |
| 2591 | | |
| 2592 | | /* Register access functions below */ |
| 2593 | | static void LoadOptionsAndSettings(void) |
| 2594 | | { |
| 2595 | | char buffer[MAX_PATH]; |
| 2596 | | |
| 2597 | | // parse MAME32.ini |
| 2598 | | LoadSettingsFile(settings, UI_INI_FILENAME); |
| 2599 | | |
| 2600 | | // parse global options |
| 2601 | | GetGlobalOptionsFileName(buffer, ARRAY_LENGTH(buffer)); |
| 2602 | | LoadSettingsFile(global, buffer); |
| 2603 | | } |
| 2604 | | |
| 2605 | | void LoadGameOptions(int driver_index) |
| 2606 | | { |
| 2607 | | char filename[MAX_PATH]; |
| 2608 | | |
| 2609 | | options_copy(game_options[driver_index], global); |
| 2610 | | |
| 2611 | | snprintf(filename, ARRAY_LENGTH(filename), "%s\\%s.ini", GetIniDir(), drivers[driver_index]->name); |
| 2612 | | LoadSettingsFile(game_options[driver_index], filename); |
| 2613 | | } |
| 2614 | | |
| 2615 | | const char * GetFolderNameByID(UINT nID) |
| 2616 | | { |
| 2617 | | UINT i; |
| 2618 | | extern FOLDERDATA g_folderData[]; |
| 2619 | | extern LPEXFOLDERDATA ExtraFolderData[]; |
| 2620 | | |
| 2621 | | for (i = 0; i < MAX_EXTRA_FOLDERS * MAX_EXTRA_SUBFOLDERS; i++) |
| 2622 | | { |
| 2623 | | if( ExtraFolderData[i] ) |
| 2624 | | { |
| 2625 | | if (ExtraFolderData[i]->m_nFolderId == nID) |
| 2626 | | { |
| 2627 | | return ExtraFolderData[i]->m_szTitle; |
| 2628 | | } |
| 2629 | | } |
| 2630 | | } |
| 2631 | | for( i = 0; i < MAX_FOLDERS; i++) |
| 2632 | | { |
| 2633 | | if (g_folderData[i].m_nFolderId == nID) |
| 2634 | | { |
| 2635 | | |
| 2636 | | return g_folderData[i].m_lpTitle; |
| 2637 | | } |
| 2638 | | } |
| 2639 | | return NULL; |
| 2640 | | } |
| 2641 | | |
| 2642 | | void LoadFolderOptions(int folder_index ) |
| 2643 | | { |
| 2644 | | int redirect_index; |
| 2645 | | char filename[MAX_PATH]; |
| 2646 | | |
| 2647 | | GetFolderSettingsFileName(folder_index, filename, ARRAY_LENGTH(filename)); |
| 2648 | | |
| 2649 | | //Use the redirect array, to get correct folder |
| 2650 | | redirect_index = GetRedirectIndex(folder_index); |
| 2651 | | if( redirect_index < 0) |
| 2652 | | return; |
| 2653 | | |
| 2654 | | options_copy(folder_options[redirect_index], global); |
| 2655 | | LoadSettingsFile(folder_options[redirect_index], filename); |
| 2656 | | } |
| 2657 | | |
| 2658 | | DWORD GetFolderFlags(int folder_index) |
| 2659 | | { |
| 2660 | | int i; |
| 2661 | | |
| 2662 | | for (i=0;i<num_folder_filters;i++) |
| 2663 | | { |
| 2664 | | if (folder_filters[i].folder_index == folder_index) |
| 2665 | | { |
| 2666 | | //dprintf("found folder filter %i %i",folder_index,folder_filters[i].filters); |
| 2667 | | return folder_filters[i].filters; |
| 2668 | | } |
| 2669 | | } |
| 2670 | | return 0; |
| 2671 | | } |
| 2672 | | |
| 2673 | | |
| 2674 | | |
| 2675 | | void SaveOptions(void) |
| 2676 | | { |
| 2677 | | SaveSettingsFile(settings, UI_INI_FILENAME); |
| 2678 | | } |
| 2679 | | |
| 2680 | | //returns true if same |
| 2681 | | BOOL GetVectorUsesDefaults(void) |
| 2682 | | { |
| 2683 | | int redirect_index = 0; |
| 2684 | | |
| 2685 | | //Use the redirect array, to get correct folder |
| 2686 | | redirect_index = GetRedirectIndex(FOLDER_VECTOR); |
| 2687 | | if( redirect_index < 0) |
| 2688 | | return TRUE; |
| 2689 | | |
| 2690 | | return options_equal(folder_options[redirect_index], global); |
| 2691 | | } |
| 2692 | | |
| 2693 | | //returns true if same |
| 2694 | | BOOL GetFolderUsesDefaults(int folder_index, int driver_index) |
| 2695 | | { |
| 2696 | | core_options *opts; |
| 2697 | | int redirect_index; |
| 2698 | | |
| 2699 | | if (DriverIsVector(driver_index) && (folder_index != FOLDER_VECTOR)) |
| 2700 | | opts = GetVectorOptions(); |
| 2701 | | else |
| 2702 | | opts = global; |
| 2703 | | |
| 2704 | | //Use the redirect array, to get correct folder |
| 2705 | | redirect_index = GetRedirectIndex(folder_index); |
| 2706 | | if( redirect_index < 0) |
| 2707 | | return TRUE; |
| 2708 | | |
| 2709 | | return options_equal(folder_options[redirect_index], opts); |
| 2710 | | } |
| 2711 | | |
| 2712 | | //returns true if same |
| 2713 | | BOOL GetGameUsesDefaults(int driver_index) |
| 2714 | | { |
| 2715 | | core_options *opts = NULL; |
| 2716 | | int nParentIndex = -1; |
| 2717 | | BOOL bUsesDefaults = TRUE; |
| 2718 | | |
| 2719 | | assert(0 <= driver_index && driver_index < driver_list_get_count(drivers)); |
| 2720 | | |
| 2721 | | if (game_options[driver_index] != NULL) |
| 2722 | | { |
| 2723 | | if ((driver_index >= 0) && DriverIsClone(driver_index)) |
| 2724 | | { |
| 2725 | | nParentIndex = GetParentIndex(drivers[driver_index]); |
| 2726 | | if( nParentIndex >= 0) |
| 2727 | | opts = GetGameOptions(nParentIndex, FALSE); |
| 2728 | | else |
| 2729 | | //No Parent found, use source |
| 2730 | | opts = GetSourceOptions(driver_index); |
| 2731 | | } |
| 2732 | | else |
| 2733 | | opts = GetSourceOptions(driver_index); |
| 2734 | | |
| 2735 | | bUsesDefaults = options_equal(game_options[driver_index], opts); |
| 2736 | | } |
| 2737 | | return bUsesDefaults; |
| 2738 | | } |
| 2739 | | |
| 2740 | | void SaveGameOptions(int driver_index) |
| 2741 | | { |
| 2742 | | core_options *opts; |
| 2743 | | char filename[MAX_PATH]; |
| 2744 | | |
| 2745 | | // save out the actual settings file |
| 2746 | | snprintf(filename, ARRAY_LENGTH(filename), "%s\\%s.ini", GetIniDir(), drivers[driver_index]->name); |
| 2747 | | opts = GetGameUsesDefaults(driver_index) ? NULL : game_options[driver_index]; |
| 2748 | | SaveSettingsFile(opts, filename); |
| 2749 | | } |
| 2750 | | |
| 2751 | | void SaveFolderOptions(int folder_index, int game_index) |
| 2752 | | { |
| 2753 | | int redirect_index; |
| 2754 | | char filename[MAX_PATH]; |
| 2755 | | core_options *opts; |
| 2756 | | |
| 2757 | | GetFolderSettingsFileName(folder_index, filename, ARRAY_LENGTH(filename)); |
| 2758 | | |
| 2759 | | //Use the redirect array, to get correct folder |
| 2760 | | redirect_index = GetRedirectIndex(folder_index); |
| 2761 | | if( redirect_index < 0) |
| 2762 | | return; |
| 2763 | | |
| 2764 | | opts = GetFolderUsesDefaults(folder_index, game_index) ? NULL : folder_options[redirect_index]; |
| 2765 | | SaveSettingsFile(opts, filename); |
| 2766 | | } |
| 2767 | | |
| 2768 | | |
| 2769 | | void SaveDefaultOptions(void) |
| 2770 | | { |
| 2771 | | char buffer[MAX_PATH]; |
| 2772 | | GetGlobalOptionsFileName(buffer, ARRAY_LENGTH(buffer)); |
| 2773 | | SaveSettingsFile(global, buffer); |
| 2774 | | } |
| 2775 | | |
| 2776 | | char * GetVersionString(void) |
| 2777 | | { |
| 2778 | | return build_version; |
| 2779 | | } |
| 2780 | | |
| 2781 | | |
| 2782 | | BOOL IsGlobalOption(const char *option_name) |
| 2783 | | { |
| 2784 | | static const char *global_options[] = |
| 2785 | | { |
| 2786 | | OPTION_ROMPATH, |
| 2787 | | #ifdef MESS |
| 2788 | | OPTION_HASHPATH, |
| 2789 | | #endif // MESS |
| 2790 | | OPTION_SAMPLEPATH, |
| 2791 | | OPTION_ARTPATH, |
| 2792 | | OPTION_CTRLRPATH, |
| 2793 | | OPTION_INIPATH, |
| 2794 | | OPTION_FONTPATH, |
| 2795 | | OPTION_CFG_DIRECTORY, |
| 2796 | | OPTION_NVRAM_DIRECTORY, |
| 2797 | | OPTION_MEMCARD_DIRECTORY, |
| 2798 | | OPTION_INPUT_DIRECTORY, |
| 2799 | | OPTION_STATE_DIRECTORY, |
| 2800 | | OPTION_SNAPSHOT_DIRECTORY, |
| 2801 | | OPTION_DIFF_DIRECTORY, |
| 2802 | | OPTION_COMMENT_DIRECTORY |
| 2803 | | }; |
| 2804 | | int i; |
| 2805 | | char command_name[128]; |
| 2806 | | char *s; |
| 2807 | | |
| 2808 | | // determine command name |
| 2809 | | snprintf(command_name, ARRAY_LENGTH(command_name), "%s", option_name); |
| 2810 | | s = strchr(command_name, ';'); |
| 2811 | | if (s) |
| 2812 | | *s = '\0'; |
| 2813 | | |
| 2814 | | for (i = 0; i < ARRAY_LENGTH(global_options); i++) |
| 2815 | | { |
| 2816 | | if (!strcmp(command_name, global_options[i])) |
| 2817 | | return TRUE; |
| 2818 | | } |
| 2819 | | return FALSE; |
| 2820 | | } |
| 2821 | | |
src/osd/windows/ui/treeview.c
| r995 | r996 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | M.A.M.E.32 - Multiple Arcade Machine Emulator for Win32 |
| 4 | | Win32 Portions Copyright (C) 1997-2003 Michael Soderstrom and Chris Kirmse |
| 5 | | |
| 6 | | This file is part of MAME32, and may only be used, modified and |
| 7 | | distributed under the terms of the MAME license, in "readme.txt". |
| 8 | | By continuing to use, modify or distribute this file you indicate |
| 9 | | that you have read the license and understand and accept it fully. |
| 10 | | |
| 11 | | ***************************************************************************/ |
| 12 | | |
| 13 | | /*************************************************************************** |
| 14 | | |
| 15 | | TreeView.c |
| 16 | | |
| 17 | | TreeView support routines - MSH 11/19/1998 |
| 18 | | |
| 19 | | ***************************************************************************/ |
| 20 | | |
| 21 | | #define WIN32_LEAN_AND_MEAN |
| 22 | | |
| 23 | | #ifdef _MSC_VER |
| 24 | | #ifndef NONAMELESSUNION |
| 25 | | #define NONAMELESSUNION |
| 26 | | #endif |
| 27 | | #endif |
| 28 | | |
| 29 | | |
| 30 | | #include <windows.h> |
| 31 | | #include <windowsx.h> |
| 32 | | #include <shellapi.h> |
| 33 | | #include <commctrl.h> |
| 34 | | #include <stdio.h> /* for sprintf */ |
| 35 | | #include <stdlib.h> /* For malloc and free */ |
| 36 | | #include <ctype.h> /* For tolower */ |
| 37 | | #include <string.h> |
| 38 | | #include <sys/stat.h> |
| 39 | | #include <sys/types.h> |
| 40 | | #ifdef _MSC_VER |
| 41 | | #include <direct.h> |
| 42 | | #endif |
| 43 | | #include <tchar.h> |
| 44 | | |
| 45 | | #include <io.h> |
| 46 | | #include <driver.h> |
| 47 | | #include "hash.h" |
| 48 | | #include "M32Util.h" |
| 49 | | #include "bitmask.h" |
| 50 | | #include "screenshot.h" |
| 51 | | #include "mame32.h" |
| 52 | | #include "TreeView.h" |
| 53 | | #include "resource.h" |
| 54 | | #include "properties.h" |
| 55 | | #include "m32opts.h" |
| 56 | | #include "help.h" |
| 57 | | #include "dialogs.h" |
| 58 | | #include "winutf8.h" |
| 59 | | #include "strconv.h" |
| 60 | | |
| 61 | | #ifdef _MSC_VER |
| 62 | | #if _MSC_VER > 1200 |
| 63 | | #define HAS_DUMMYUNIONNAME |
| 64 | | #endif |
| 65 | | #endif |
| 66 | | |
| 67 | | #ifdef _MSC_VER |
| 68 | | #define snprintf _snprintf |
| 69 | | #endif |
| 70 | | |
| 71 | | #define MAX_EXTRA_FOLDERS 256 |
| 72 | | |
| 73 | | /*************************************************************************** |
| 74 | | public structures |
| 75 | | ***************************************************************************/ |
| 76 | | |
| 77 | | #define ICON_MAX (sizeof(treeIconNames) / sizeof(treeIconNames[0])) |
| 78 | | |
| 79 | | /* Name used for user-defined custom icons */ |
| 80 | | /* external *.ico file to look for. */ |
| 81 | | |
| 82 | | typedef struct |
| 83 | | { |
| 84 | | int nResourceID; |
| 85 | | LPCSTR lpName; |
| 86 | | } TREEICON; |
| 87 | | |
| 88 | | static TREEICON treeIconNames[] = |
| 89 | | { |
| 90 | | { IDI_FOLDER_OPEN, "foldopen" }, |
| 91 | | { IDI_FOLDER, "folder" }, |
| 92 | | { IDI_FOLDER_AVAILABLE, "foldavail" }, |
| 93 | | { IDI_FOLDER_MANUFACTURER, "foldmanu" }, |
| 94 | | { IDI_FOLDER_UNAVAILABLE, "foldunav" }, |
| 95 | | { IDI_FOLDER_YEAR, "foldyear" }, |
| 96 | | { IDI_FOLDER_SOURCE, "foldsrc" }, |
| 97 | | { IDI_MANUFACTURER, "manufact" }, |
| 98 | | { IDI_WORKING, "working" }, |
| 99 | | { IDI_NONWORKING, "nonwork" }, |
| 100 | | { IDI_YEAR, "year" }, |
| 101 | | { IDI_SOUND, "sound" }, |
| 102 | | { IDI_CPU, "cpu" }, |
| 103 | | { IDI_HARDDISK, "harddisk" }, |
| 104 | | { IDI_SOURCE, "source" } |
| 105 | | }; |
| 106 | | |
| 107 | | /*************************************************************************** |
| 108 | | private variables |
| 109 | | ***************************************************************************/ |
| 110 | | |
| 111 | | /* this has an entry for every folder eventually in the UI, including subfolders */ |
| 112 | | static TREEFOLDER **treeFolders = 0; |
| 113 | | static UINT numFolders = 0; /* Number of folder in the folder array */ |
| 114 | | static UINT next_folder_id = MAX_FOLDERS; |
| 115 | | static UINT folderArrayLength = 0; /* Size of the folder array */ |
| 116 | | static LPTREEFOLDER lpCurrentFolder = 0; /* Currently selected folder */ |
| 117 | | static UINT nCurrentFolder = 0; /* Current folder ID */ |
| 118 | | static WNDPROC g_lpTreeWndProc = 0; /* for subclassing the TreeView */ |
| 119 | | static HIMAGELIST hTreeSmall = 0; /* TreeView Image list of icons */ |
| 120 | | |
| 121 | | /* this only has an entry for each TOP LEVEL extra folder + SubFolders*/ |
| 122 | | LPEXFOLDERDATA ExtraFolderData[MAX_EXTRA_FOLDERS * MAX_EXTRA_SUBFOLDERS]; |
| 123 | | int numExtraFolders = 0; |
| 124 | | static int numExtraIcons = 0; |
| 125 | | static char *ExtraFolderIcons[MAX_EXTRA_FOLDERS]; |
| 126 | | |
| 127 | | // built in folders and filters |
| 128 | | static LPFOLDERDATA g_lpFolderData; |
| 129 | | static LPFILTER_ITEM g_lpFilterList; |
| 130 | | |
| 131 | | /*************************************************************************** |
| 132 | | private function prototypes |
| 133 | | ***************************************************************************/ |
| 134 | | |
| 135 | | extern BOOL InitFolders(void); |
| 136 | | static BOOL CreateTreeIcons(void); |
| 137 | | static void TreeCtrlOnPaint(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 138 | | static const char* ParseManufacturer(const char *s, int *pParsedChars ); |
| 139 | | static const char* TrimManufacturer(const char *s); |
| 140 | | static void CreateAllChildFolders(void); |
| 141 | | static BOOL AddFolder(LPTREEFOLDER lpFolder); |
| 142 | | static LPTREEFOLDER NewFolder(const char *lpTitle, |
| 143 | | UINT nFolderId, int nParent, UINT nIconId, |
| 144 | | DWORD dwFlags); |
| 145 | | static void DeleteFolder(LPTREEFOLDER lpFolder); |
| 146 | | |
| 147 | | static LRESULT CALLBACK TreeWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 148 | | |
| 149 | | static int InitExtraFolders(void); |
| 150 | | static void FreeExtraFolders(void); |
| 151 | | static void SetExtraIcons(char *name, int *id); |
| 152 | | static BOOL TryAddExtraFolderAndChildren(int parent_index); |
| 153 | | |
| 154 | | static BOOL TrySaveExtraFolder(LPTREEFOLDER lpFolder); |
| 155 | | |
| 156 | | /*************************************************************************** |
| 157 | | public functions |
| 158 | | ***************************************************************************/ |
| 159 | | |
| 160 | | /************************************************************************** |
| 161 | | * ci_strncmp - case insensitive character array compare |
| 162 | | * |
| 163 | | * Returns zero if the first n characters of s1 and s2 are equal, |
| 164 | | * ignoring case. |
| 165 | | * stolen from datafile.c |
| 166 | | **************************************************************************/ |
| 167 | | static int ci_strncmp (const char *s1, const char *s2, int n) |
| 168 | | { |
| 169 | | int c1, c2; |
| 170 | | |
| 171 | | while (n) |
| 172 | | { |
| 173 | | if ((c1 = tolower (*s1)) != (c2 = tolower (*s2))) |
| 174 | | return (c1 - c2); |
| 175 | | else if (!c1) |
| 176 | | break; |
| 177 | | --n; |
| 178 | | |
| 179 | | s1++; |
| 180 | | s2++; |
| 181 | | } |
| 182 | | return 0; |
| 183 | | } |
| 184 | | |
| 185 | | |
| 186 | | |
| 187 | | /* De-allocate all folder memory */ |
| 188 | | void FreeFolders(void) |
| 189 | | { |
| 190 | | int i = 0; |
| 191 | | |
| 192 | | if (treeFolders != NULL) |
| 193 | | { |
| 194 | | if (numExtraFolders) |
| 195 | | { |
| 196 | | FreeExtraFolders(); |
| 197 | | numFolders -= numExtraFolders; |
| 198 | | } |
| 199 | | |
| 200 | | for (i = numFolders - 1; i >= 0; i--) |
| 201 | | { |
| 202 | | DeleteFolder(treeFolders[i]); |
| 203 | | treeFolders[i] = NULL; |
| 204 | | numFolders--; |
| 205 | | } |
| 206 | | free(treeFolders); |
| 207 | | treeFolders = NULL; |
| 208 | | } |
| 209 | | numFolders = 0; |
| 210 | | } |
| 211 | | |
| 212 | | /* Reset folder filters */ |
| 213 | | void ResetFilters(void) |
| 214 | | { |
| 215 | | int i = 0; |
| 216 | | |
| 217 | | if (treeFolders != 0) |
| 218 | | { |
| 219 | | for (i = 0; i < (int)numFolders; i++) |
| 220 | | { |
| 221 | | treeFolders[i]->m_dwFlags &= ~F_MASK; |
| 222 | | } |
| 223 | | } |
| 224 | | } |
| 225 | | |
| 226 | | void InitTree(LPFOLDERDATA lpFolderData, LPFILTER_ITEM lpFilterList) |
| 227 | | { |
| 228 | | g_lpFolderData = lpFolderData; |
| 229 | | g_lpFilterList = lpFilterList; |
| 230 | | |
| 231 | | InitFolders(); |
| 232 | | |
| 233 | | /* this will subclass the treeview (where WM_DRAWITEM gets sent for |
| 234 | | the header control) */ |
| 235 | | g_lpTreeWndProc = (WNDPROC)(LONG)(int)GetWindowLong(GetTreeView(), GWL_WNDPROC); |
| 236 | | SetWindowLong(GetTreeView(), GWL_WNDPROC, (LONG)TreeWndProc); |
| 237 | | } |
| 238 | | |
| 239 | | void DestroyTree(HWND hWnd) |
| 240 | | { |
| 241 | | if ( hTreeSmall ) |
| 242 | | { |
| 243 | | ImageList_Destroy( hTreeSmall ); |
| 244 | | hTreeSmall = NULL; |
| 245 | | } |
| 246 | | } |
| 247 | | |
| 248 | | void SetCurrentFolder(LPTREEFOLDER lpFolder) |
| 249 | | { |
| 250 | | lpCurrentFolder = (lpFolder == 0) ? treeFolders[0] : lpFolder; |
| 251 | | nCurrentFolder = (lpCurrentFolder) ? lpCurrentFolder->m_nFolderId : 0; |
| 252 | | } |
| 253 | | |
| 254 | | LPTREEFOLDER GetCurrentFolder(void) |
| 255 | | { |
| 256 | | return lpCurrentFolder; |
| 257 | | } |
| 258 | | |
| 259 | | UINT GetCurrentFolderID(void) |
| 260 | | { |
| 261 | | return nCurrentFolder; |
| 262 | | } |
| 263 | | |
| 264 | | int GetNumFolders(void) |
| 265 | | { |
| 266 | | return numFolders; |
| 267 | | } |
| 268 | | |
| 269 | | LPTREEFOLDER GetFolder(UINT nFolder) |
| 270 | | { |
| 271 | | return (nFolder < numFolders) ? treeFolders[nFolder] : NULL; |
| 272 | | } |
| 273 | | |
| 274 | | LPTREEFOLDER GetFolderByID(UINT nID) |
| 275 | | { |
| 276 | | UINT i; |
| 277 | | |
| 278 | | for (i = 0; i < numFolders; i++) |
| 279 | | { |
| 280 | | if (treeFolders[i]->m_nFolderId == nID) |
| 281 | | { |
| 282 | | return treeFolders[i]; |
| 283 | | } |
| 284 | | } |
| 285 | | |
| 286 | | return (LPTREEFOLDER)0; |
| 287 | | } |
| 288 | | |
| 289 | | void AddGame(LPTREEFOLDER lpFolder, UINT nGame) |
| 290 | | { |
| 291 | | SetBit(lpFolder->m_lpGameBits, nGame); |
| 292 | | } |
| 293 | | |
| 294 | | void RemoveGame(LPTREEFOLDER lpFolder, UINT nGame) |
| 295 | | { |
| 296 | | ClearBit(lpFolder->m_lpGameBits, nGame); |
| 297 | | } |
| 298 | | |
| 299 | | int FindGame(LPTREEFOLDER lpFolder, int nGame) |
| 300 | | { |
| 301 | | return FindBit(lpFolder->m_lpGameBits, nGame, TRUE); |
| 302 | | } |
| 303 | | |
| 304 | | // Called to re-associate games with folders |
| 305 | | void ResetWhichGamesInFolders(void) |
| 306 | | { |
| 307 | | UINT i, jj, k; |
| 308 | | BOOL b; |
| 309 | | int nGames = driver_list_get_count(drivers); |
| 310 | | |
| 311 | | for (i = 0; i < numFolders; i++) |
| 312 | | { |
| 313 | | LPTREEFOLDER lpFolder = treeFolders[i]; |
| 314 | | |
| 315 | | // setup the games in our built-in folders |
| 316 | | for (k = 0; g_lpFolderData[k].m_lpTitle; k++) |
| 317 | | { |
| 318 | | if (lpFolder->m_nFolderId == g_lpFolderData[k].m_nFolderId) |
| 319 | | { |
| 320 | | if (g_lpFolderData[k].m_pfnQuery || g_lpFolderData[k].m_bExpectedResult) |
| 321 | | { |
| 322 | | SetAllBits(lpFolder->m_lpGameBits, FALSE); |
| 323 | | for (jj = 0; jj < nGames; jj++) |
| 324 | | { |
| 325 | | // invoke the query function |
| 326 | | b = g_lpFolderData[k].m_pfnQuery ? g_lpFolderData[k].m_pfnQuery(jj) : TRUE; |
| 327 | | |
| 328 | | // if we expect FALSE, flip the result |
| 329 | | if (!g_lpFolderData[k].m_bExpectedResult) |
| 330 | | b = !b; |
| 331 | | |
| 332 | | // if we like what we hear, add the game |
| 333 | | if (b) |
| 334 | | AddGame(lpFolder, jj); |
| 335 | | } |
| 336 | | } |
| 337 | | break; |
| 338 | | } |
| 339 | | } |
| 340 | | } |
| 341 | | } |
| 342 | | |
| 343 | | |
| 344 | | /* Used to build the GameList */ |
| 345 | | BOOL GameFiltered(int nGame, DWORD dwMask) |
| 346 | | { |
| 347 | | int i; |
| 348 | | LPTREEFOLDER lpFolder = GetCurrentFolder(); |
| 349 | | LPTREEFOLDER lpParent = NULL; |
| 350 | | |
| 351 | | //Filter out the Bioses on all Folders, except for the Bios Folder |
| 352 | | if( lpFolder->m_nFolderId != FOLDER_BIOS ) |
| 353 | | { |
| 354 | | if( !( (drivers[nGame]->flags & GAME_IS_BIOS_ROOT ) == 0) ) |
| 355 | | return TRUE; |
| 356 | | } |
| 357 | | // Filter games--return TRUE if the game should be HIDDEN in this view |
| 358 | | if( GetFilterInherit() ) |
| 359 | | { |
| 360 | | if( lpFolder ) |
| 361 | | { |
| 362 | | lpParent = GetFolder( lpFolder->m_nParent ); |
| 363 | | if( lpParent ) |
| 364 | | { |
| 365 | | /* Check the Parent Filters and inherit them on child, |
| 366 | | * The inherited filters don't display on the custom Filter Dialog for the Child folder |
| 367 | | * No need to promote all games to parent folder, works as is */ |
| 368 | | dwMask |= lpParent->m_dwFlags; |
| 369 | | } |
| 370 | | } |
| 371 | | } |
| 372 | | /*Filter Text is already global*/ |
| 373 | | |
| 374 | | if (MyStrStrI(drivers[nGame]->description,GetFilterText()) == NULL && |
| 375 | | MyStrStrI(drivers[nGame]->name,GetFilterText()) == NULL && |
| 376 | | MyStrStrI(drivers[nGame]->source_file,GetFilterText()) == NULL && |
| 377 | | MyStrStrI(drivers[nGame]->manufacturer,GetFilterText()) == NULL) |
| 378 | | { |
| 379 | | return TRUE; |
| 380 | | } |
| 381 | | // Are there filters set on this folder? |
| 382 | | if ((dwMask & F_MASK) == 0) |
| 383 | | return FALSE; |
| 384 | | |
| 385 | | // Filter out clones? |
| 386 | | if (dwMask & F_CLONES && DriverIsClone(nGame)) |
| 387 | | return TRUE; |
| 388 | | |
| 389 | | for (i = 0; g_lpFilterList[i].m_dwFilterType; i++) |
| 390 | | { |
| 391 | | if (dwMask & g_lpFilterList[i].m_dwFilterType) |
| 392 | | { |
| 393 | | if (g_lpFilterList[i].m_pfnQuery(nGame) == g_lpFilterList[i].m_bExpectedResult) |
| 394 | | return TRUE; |
| 395 | | } |
| 396 | | } |
| 397 | | return FALSE; |
| 398 | | } |
| 399 | | |
| 400 | | /* Get the parent of game in this view */ |
| 401 | | BOOL GetParentFound(int nGame) |
| 402 | | { |
| 403 | | int nParentIndex = -1; |
| 404 | | LPTREEFOLDER lpFolder = GetCurrentFolder(); |
| 405 | | |
| 406 | | if( lpFolder ) |
| 407 | | { |
| 408 | | nParentIndex = GetParentIndex(drivers[nGame]); |
| 409 | | |
| 410 | | /* return FALSE if no parent is there in this view */ |
| 411 | | if( nParentIndex == -1) |
| 412 | | return FALSE; |
| 413 | | |
| 414 | | /* return FALSE if the folder should be HIDDEN in this view */ |
| 415 | | if (TestBit(lpFolder->m_lpGameBits, nParentIndex) == 0) |
| 416 | | return FALSE; |
| 417 | | |
| 418 | | /* return FALSE if the game should be HIDDEN in this view */ |
| 419 | | if (GameFiltered(nParentIndex, lpFolder->m_dwFlags)) |
| 420 | | return FALSE; |
| 421 | | |
| 422 | | return TRUE; |
| 423 | | } |
| 424 | | |
| 425 | | return FALSE; |
| 426 | | } |
| 427 | | |
| 428 | | LPFILTER_ITEM GetFilterList(void) |
| 429 | | { |
| 430 | | return g_lpFilterList; |
| 431 | | } |
| 432 | | |
| 433 | | /*************************************************************************** |
| 434 | | private functions |
| 435 | | ***************************************************************************/ |
| 436 | | |
| 437 | | void CreateSourceFolders(int parent_index) |
| 438 | | { |
| 439 | | int i,jj, k=0; |
| 440 | | int nGames = driver_list_get_count(drivers); |
| 441 | | int start_folder = numFolders; |
| 442 | | LPTREEFOLDER lpFolder = treeFolders[parent_index]; |
| 443 | | int *redirect_arr = GetFolderOptionsRedirectArr(); |
| 444 | | // no games in top level folder |
| 445 | | SetAllBits(lpFolder->m_lpGameBits,FALSE); |
| 446 | | if( redirect_arr == NULL) |
| 447 | | { |
| 448 | | redirect_arr = (int*)malloc(sizeof(int*) ); |
| 449 | | memset(redirect_arr, '\0', sizeof (int*)); |
| 450 | | } |
| 451 | | //We also allow setting of options for the Vector Folder |
| 452 | | redirect_arr = realloc(redirect_arr, ((k+1)* sizeof(int)) ); |
| 453 | | redirect_arr[k++] = FOLDER_VECTOR; |
| 454 | | for (jj = 0; jj < nGames; jj++) |
| 455 | | { |
| 456 | | const char *s = GetDriverFilename(jj); |
| 457 | | |
| 458 | | if (s == NULL || s[0] == '\0') |
| 459 | | continue; |
| 460 | | |
| 461 | | // look for an existant source treefolder for this game |
| 462 | | // (likely to be the previous one, so start at the end) |
| 463 | | for (i=numFolders-1;i>=start_folder;i--) |
| 464 | | { |
| 465 | | if (strcmp(treeFolders[i]->m_lpTitle,s) == 0) |
| 466 | | { |
| 467 | | AddGame(treeFolders[i],jj); |
| 468 | | break; |
| 469 | | } |
| 470 | | } |
| 471 | | if (i == start_folder-1) |
| 472 | | { |
| 473 | | // nope, it's a source file we haven't seen before, make it. |
| 474 | | LPTREEFOLDER lpTemp; |
| 475 | | lpTemp = NewFolder(s, next_folder_id, parent_index, IDI_SOURCE, |
| 476 | | GetFolderFlags(numFolders)); |
| 477 | | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 478 | | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 479 | | |
| 480 | | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 481 | | ExtraFolderData[next_folder_id]->m_nIconId = IDI_SOURCE; |
| 482 | | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 483 | | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 484 | | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, s ); |
| 485 | | //Add it to the FolderOptionsRedirectArray |
| 486 | | redirect_arr = realloc(redirect_arr, ((k+1)* sizeof(int)) ); |
| 487 | | redirect_arr[k++] = next_folder_id; |
| 488 | | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 489 | | |
| 490 | | AddFolder(lpTemp); |
| 491 | | AddGame(lpTemp,jj); |
| 492 | | } |
| 493 | | } |
| 494 | | SetNumOptionFolders(k-1); |
| 495 | | SetFolderOptionsRedirectArr(redirect_arr); |
| 496 | | } |
| 497 | | |
| 498 | | void CreateManufacturerFolders(int parent_index) |
| 499 | | { |
| 500 | | int i,jj; |
| 501 | | int nGames = driver_list_get_count(drivers); |
| 502 | | int start_folder = numFolders; |
| 503 | | LPTREEFOLDER lpFolder = treeFolders[parent_index]; |
| 504 | | LPTREEFOLDER lpTemp; |
| 505 | | |
| 506 | | // no games in top level folder |
| 507 | | SetAllBits(lpFolder->m_lpGameBits,FALSE); |
| 508 | | |
| 509 | | for (jj = 0; jj < nGames; jj++) |
| 510 | | { |
| 511 | | const char *manufacturer = drivers[jj]->manufacturer; |
| 512 | | int iChars = 0; |
| 513 | | while( manufacturer != NULL && manufacturer[0] != '\0' ) |
| 514 | | { |
| 515 | | const char *s = ParseManufacturer(manufacturer, &iChars); |
| 516 | | manufacturer += iChars; |
| 517 | | //shift to next start char |
| 518 | | if( s != NULL && strlen(s) > 0 ) |
| 519 | | { |
| 520 | | const char *t = TrimManufacturer(s); |
| 521 | | for (i=numFolders-1;i>=start_folder;i--) |
| 522 | | { |
| 523 | | //RS Made it case insensitive |
| 524 | | if (ci_strncmp(treeFolders[i]->m_lpTitle,t,20) == 0 ) |
| 525 | | { |
| 526 | | AddGame(treeFolders[i],jj); |
| 527 | | break; |
| 528 | | } |
| 529 | | } |
| 530 | | if (i == start_folder-1) |
| 531 | | { |
| 532 | | // nope, it's a manufacturer we haven't seen before, make it. |
| 533 | | lpTemp = NewFolder(t, next_folder_id, parent_index, IDI_MANUFACTURER, |
| 534 | | GetFolderFlags(numFolders)); |
| 535 | | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 536 | | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 537 | | |
| 538 | | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 539 | | ExtraFolderData[next_folder_id]->m_nIconId = IDI_MANUFACTURER; |
| 540 | | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 541 | | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 542 | | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, s ); |
| 543 | | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 544 | | AddFolder(lpTemp); |
| 545 | | AddGame(lpTemp,jj); |
| 546 | | } |
| 547 | | } |
| 548 | | } |
| 549 | | } |
| 550 | | } |
| 551 | | |
| 552 | | /* Make a reasonable name out of the one found in the driver array */ |
| 553 | | static const char* ParseManufacturer(const char *s, int *pParsedChars ) |
| 554 | | { |
| 555 | | static char tmp[256]; |
| 556 | | char* ptmp; |
| 557 | | char *t; |
| 558 | | *pParsedChars= 0; |
| 559 | | |
| 560 | | if ( *s == '?' || *s == '<' || s[3] == '?' ) |
| 561 | | { |
| 562 | | (*pParsedChars) = strlen(s); |
| 563 | | return "<unknown>"; |
| 564 | | } |
| 565 | | |
| 566 | | ptmp = tmp; |
| 567 | | /*if first char is a space, skip it*/ |
| 568 | | if( *s == ' ' ) |
| 569 | | { |
| 570 | | (*pParsedChars)++; |
| 571 | | ++s; |
| 572 | | } |
| 573 | | while( *s ) |
| 574 | | { |
| 575 | | /* combinations where to end string */ |
| 576 | | |
| 577 | | if ( |
| 578 | | ( (*s == ' ') && ( s[1] == '(' || s[1] == '/' || s[1] == '+' ) ) || |
| 579 | | ( *s == ']' ) || |
| 580 | | ( *s == '/' ) || |
| 581 | | ( *s == '?' ) |
| 582 | | ) |
| 583 | | { |
| 584 | | (*pParsedChars)++; |
| 585 | | if( s[1] == '/' || s[1] == '+' ) |
| 586 | | (*pParsedChars)++; |
| 587 | | break; |
| 588 | | } |
| 589 | | if( s[0] == ' ' && s[1] == '?' ) |
| 590 | | { |
| 591 | | (*pParsedChars) += 2; |
| 592 | | s+=2; |
| 593 | | } |
| 594 | | |
| 595 | | /* skip over opening braces*/ |
| 596 | | |
| 597 | | if ( *s != '[' ) |
| 598 | | { |
| 599 | | *ptmp++ = *s; |
| 600 | | } |
| 601 | | (*pParsedChars)++; |
| 602 | | /*for "distributed by" and "supported by" handling*/ |
| 603 | | if( ( (s[1] == ',') && (s[2] == ' ') && ( (s[3] == 's') || (s[3] == 'd') ) ) ) |
| 604 | | { |
| 605 | | //*ptmp++ = *s; |
| 606 | | ++s; |
| 607 | | break; |
| 608 | | } |
| 609 | | ++s; |
| 610 | | } |
| 611 | | *ptmp = '\0'; |
| 612 | | t = tmp; |
| 613 | | if( tmp[0] == '(' || tmp[strlen(tmp)-1] == ')' || tmp[0] == ',') |
| 614 | | { |
| 615 | | ptmp = strchr( tmp,'(' ); |
| 616 | | if ( ptmp == NULL ) |
| 617 | | { |
| 618 | | ptmp = strchr( tmp,',' ); |
| 619 | | if( ptmp != NULL) |
| 620 | | { |
| 621 | | //parse the new "supported by" and "distributed by" |
| 622 | | ptmp++; |
| 623 | | |
| 624 | | if (ci_strncmp(ptmp, " supported by", 13) == 0) |
| 625 | | { |
| 626 | | ptmp += 13; |
| 627 | | } |
| 628 | | else if (ci_strncmp(ptmp, " distributed by", 15) == 0) |
| 629 | | { |
| 630 | | ptmp += 15; |
| 631 | | } |
| 632 | | else |
| 633 | | { |
| 634 | | return NULL; |
| 635 | | } |
| 636 | | } |
| 637 | | else |
| 638 | | { |
| 639 | | ptmp = tmp; |
| 640 | | if ( ptmp == NULL ) |
| 641 | | { |
| 642 | | return NULL; |
| 643 | | } |
| 644 | | } |
| 645 | | } |
| 646 | | if( tmp[0] == '(' || tmp[0] == ',') |
| 647 | | { |
| 648 | | ptmp++; |
| 649 | | } |
| 650 | | if (ci_strncmp(ptmp, "licensed from ", 14) == 0) |
| 651 | | { |
| 652 | | ptmp += 14; |
| 653 | | } |
| 654 | | // for the licenced from case |
| 655 | | if (ci_strncmp(ptmp, "licenced from ", 14) == 0) |
| 656 | | { |
| 657 | | ptmp += 14; |
| 658 | | } |
| 659 | | |
| 660 | | while ( (*ptmp != ')' ) && (*ptmp != '/' ) && *ptmp != '\0') |
| 661 | | { |
| 662 | | if (*ptmp == ' ' && ci_strncmp(ptmp, " license", 8) == 0) |
| 663 | | { |
| 664 | | break; |
| 665 | | } |
| 666 | | if (*ptmp == ' ' && ci_strncmp(ptmp, " licence", 8) == 0) |
| 667 | | { |
| 668 | | break; |
| 669 | | } |
| 670 | | *t++ = *ptmp++; |
| 671 | | } |
| 672 | | |
| 673 | | *t = '\0'; |
| 674 | | } |
| 675 | | |
| 676 | | *ptmp = '\0'; |
| 677 | | return tmp; |
| 678 | | } |
| 679 | | |
| 680 | | /* Analyze Manufacturer Names for typical patterns, that don't distinguish between companies (e.g. Co., Ltd., Inc., etc. */ |
| 681 | | static const char* TrimManufacturer(const char *s) |
| 682 | | { |
| 683 | | //Also remove Country specific suffixes (e.g. Japan, Italy, America, USA, ...) |
| 684 | | int i=0; |
| 685 | | char strTemp[256]; |
| 686 | | static char strTemp2[256]; |
| 687 | | int j=0; |
| 688 | | int k=0; |
| 689 | | int l = 0; |
| 690 | | memset(strTemp, '\0', 256 ); |
| 691 | | memset(strTemp2, '\0', 256 ); |
| 692 | | //start analyzing from the back, as these are usually suffixes |
| 693 | | for(i=strlen(s)-1; i>=0;i-- ) |
| 694 | | { |
| 695 | | |
| 696 | | l = strlen(strTemp); |
| 697 | | for(k=l;k>=0; k--) |
| 698 | | strTemp[k+1] = strTemp[k]; |
| 699 | | strTemp[0] = s[i]; |
| 700 | | strTemp[++l] = '\0'; |
| 701 | | switch (l) |
| 702 | | { |
| 703 | | case 2: |
| 704 | | if( ci_strncmp(strTemp, "co", 2) == 0 ) |
| 705 | | { |
| 706 | | j=l; |
| 707 | | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 708 | | { |
| 709 | | j++; |
| 710 | | } |
| 711 | | if( j!=l) |
| 712 | | { |
| 713 | | memset(strTemp2, '\0', 256 ); |
| 714 | | strncpy(strTemp2, s, strlen(s)-j ); |
| 715 | | } |
| 716 | | } |
| 717 | | break; |
| 718 | | case 3: |
| 719 | | if( ci_strncmp(strTemp, "co.", 3) == 0 || ci_strncmp(strTemp, "ltd", 3) == 0 || ci_strncmp(strTemp, "inc", 3) == 0 || ci_strncmp(strTemp, "SRL", 3) == 0 || ci_strncmp(strTemp, "USA", 3) == 0) |
| 720 | | { |
| 721 | | j=l; |
| 722 | | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 723 | | { |
| 724 | | j++; |
| 725 | | } |
| 726 | | if( j!=l) |
| 727 | | { |
| 728 | | memset(strTemp2, '\0', 256 ); |
| 729 | | strncpy(strTemp2, s, strlen(s)-j ); |
| 730 | | } |
| 731 | | } |
| 732 | | break; |
| 733 | | case 4: |
| 734 | | if( ci_strncmp(strTemp, "inc.", 4) == 0 || ci_strncmp(strTemp, "ltd.", 4) == 0 || ci_strncmp(strTemp, "corp", 4) == 0 || ci_strncmp(strTemp, "game", 4) == 0) |
| 735 | | { |
| 736 | | j=l; |
| 737 | | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 738 | | { |
| 739 | | j++; |
| 740 | | } |
| 741 | | if( j!=l) |
| 742 | | { |
| 743 | | memset(strTemp2, '\0', 256 ); |
| 744 | | strncpy(strTemp2, s, strlen(s)-j ); |
| 745 | | } |
| 746 | | } |
| 747 | | break; |
| 748 | | case 5: |
| 749 | | if( ci_strncmp(strTemp, "corp.", 5) == 0 || ci_strncmp(strTemp, "Games", 5) == 0 || ci_strncmp(strTemp, "Italy", 5) == 0 || ci_strncmp(strTemp, "Japan", 5) == 0) |
| 750 | | { |
| 751 | | j=l; |
| 752 | | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 753 | | { |
| 754 | | j++; |
| 755 | | } |
| 756 | | if( j!=l) |
| 757 | | { |
| 758 | | memset(strTemp2, '\0', 256 ); |
| 759 | | strncpy(strTemp2, s, strlen(s)-j ); |
| 760 | | } |
| 761 | | } |
| 762 | | break; |
| 763 | | case 6: |
| 764 | | if( ci_strncmp(strTemp, "co-ltd", 6) == 0 || ci_strncmp(strTemp, "S.R.L.", 6) == 0) |
| 765 | | { |
| 766 | | j=l; |
| 767 | | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 768 | | { |
| 769 | | j++; |
| 770 | | } |
| 771 | | if( j!=l) |
| 772 | | { |
| 773 | | memset(strTemp2, '\0', 256 ); |
| 774 | | strncpy(strTemp2, s, strlen(s)-j ); |
| 775 | | } |
| 776 | | } |
| 777 | | break; |
| 778 | | case 7: |
| 779 | | if( ci_strncmp(strTemp, "co. ltd", 7) == 0 || ci_strncmp(strTemp, "America", 7) == 0) |
| 780 | | { |
| 781 | | j=l; |
| 782 | | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 783 | | { |
| 784 | | j++; |
| 785 | | } |
| 786 | | if( j!=l) |
| 787 | | { |
| 788 | | memset(strTemp2, '\0', 256 ); |
| 789 | | strncpy(strTemp2, s, strlen(s)-j ); |
| 790 | | } |
| 791 | | } |
| 792 | | break; |
| 793 | | case 8: |
| 794 | | if( ci_strncmp(strTemp, "co. ltd.", 8) == 0 ) |
| 795 | | { |
| 796 | | j=l; |
| 797 | | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 798 | | { |
| 799 | | j++; |
| 800 | | } |
| 801 | | if( j!=l) |
| 802 | | { |
| 803 | | memset(strTemp2, '\0', 256 ); |
| 804 | | strncpy(strTemp2, s, strlen(s)-j ); |
| 805 | | } |
| 806 | | } |
| 807 | | break; |
| 808 | | case 9: |
| 809 | | if( ci_strncmp(strTemp, "co., ltd.", 9) == 0 || ci_strncmp(strTemp, "gmbh & co", 9) == 0 ) |
| 810 | | { |
| 811 | | j=l; |
| 812 | | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 813 | | { |
| 814 | | j++; |
| 815 | | } |
| 816 | | if( j!=l) |
| 817 | | { |
| 818 | | memset(strTemp2, '\0', 256 ); |
| 819 | | strncpy(strTemp2, s, strlen(s)-j ); |
| 820 | | } |
| 821 | | } |
| 822 | | break; |
| 823 | | case 10: |
| 824 | | if( ci_strncmp(strTemp, "corp, ltd.", 10) == 0 || ci_strncmp(strTemp, "industries", 10) == 0 || ci_strncmp(strTemp, "of America", 10) == 0) |
| 825 | | { |
| 826 | | j=l; |
| 827 | | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 828 | | { |
| 829 | | j++; |
| 830 | | } |
| 831 | | if( j!=l) |
| 832 | | { |
| 833 | | memset(strTemp2, '\0', 256 ); |
| 834 | | strncpy(strTemp2, s, strlen(s)-j ); |
| 835 | | } |
| 836 | | } |
| 837 | | break; |
| 838 | | case 11: |
| 839 | | if( ci_strncmp(strTemp, "corporation", 11) == 0 || ci_strncmp(strTemp, "enterprises", 11) == 0 ) |
| 840 | | { |
| 841 | | j=l; |
| 842 | | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 843 | | { |
| 844 | | j++; |
| 845 | | } |
| 846 | | if( j!=l) |
| 847 | | { |
| 848 | | memset(strTemp2, '\0', 256 ); |
| 849 | | strncpy(strTemp2, s, strlen(s)-j ); |
| 850 | | } |
| 851 | | } |
| 852 | | break; |
| 853 | | case 16: |
| 854 | | if( ci_strncmp(strTemp, "industries japan", 16) == 0 ) |
| 855 | | { |
| 856 | | j=l; |
| 857 | | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 858 | | { |
| 859 | | j++; |
| 860 | | } |
| 861 | | if( j!=l) |
| 862 | | { |
| 863 | | memset(strTemp2, '\0', 256 ); |
| 864 | | strncpy(strTemp2, s, strlen(s)-j ); |
| 865 | | } |
| 866 | | } |
| 867 | | break; |
| 868 | | default: |
| 869 | | break; |
| 870 | | } |
| 871 | | } |
| 872 | | if( strlen(strTemp2) == 0 ) |
| 873 | | return s; |
| 874 | | return strTemp2; |
| 875 | | } |
| 876 | | |
| 877 | | |
| 878 | | |
| 879 | | void CreateCPUFolders(int parent_index) |
| 880 | | { |
| 881 | | int i,jj; |
| 882 | | int nGames = driver_list_get_count(drivers); |
| 883 | | int nFolder = numFolders; |
| 884 | | LPTREEFOLDER lpFolder = treeFolders[parent_index]; |
| 885 | | LPTREEFOLDER map[CPU_COUNT]; |
| 886 | | |
| 887 | | ZeroMemory(map, sizeof(map)); |
| 888 | | cpuintrf_init(NULL); |
| 889 | | |
| 890 | | // no games in top level folder |
| 891 | | SetAllBits(lpFolder->m_lpGameBits,FALSE); |
| 892 | | |
| 893 | | for (i=1;i<CPU_COUNT;i++) |
| 894 | | { |
| 895 | | LPTREEFOLDER lpTemp; |
| 896 | | |
| 897 | | for (jj = 1; jj < i; jj++) |
| 898 | | if (!strcmp(cputype_name(i), cputype_name(jj))) |
| 899 | | break; |
| 900 | | |
| 901 | | if (i != jj) |
| 902 | | { |
| 903 | | map[i] = map[jj]; |
| 904 | | continue; |
| 905 | | } |
| 906 | | if( strlen( cputype_name(i) ) <=0 ) |
| 907 | | continue; |
| 908 | | lpTemp = NewFolder(cputype_name(i), next_folder_id, parent_index, IDI_CPU, |
| 909 | | GetFolderFlags(numFolders)); |
| 910 | | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 911 | | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 912 | | |
| 913 | | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 914 | | ExtraFolderData[next_folder_id]->m_nIconId = IDI_CPU; |
| 915 | | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 916 | | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 917 | | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, cputype_name(i) ); |
| 918 | | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 919 | | AddFolder(lpTemp); |
| 920 | | map[i] = treeFolders[nFolder++]; |
| 921 | | } |
| 922 | | |
| 923 | | for (jj = 0; jj < nGames; jj++) |
| 924 | | { |
| 925 | | int n; |
| 926 | | machine_config drv; |
| 927 | | expand_machine_driver(drivers[jj]->drv,&drv); |
| 928 | | for (n = 0; n < MAX_CPU; n++) |
| 929 | | if (drv.cpu[n].cpu_type != CPU_DUMMY) |
| 930 | | { |
| 931 | | // cpu type #'s are one-based |
| 932 | | AddGame(map[drv.cpu[n].cpu_type],jj); |
| 933 | | } |
| 934 | | } |
| 935 | | } |
| 936 | | |
| 937 | | void CreateSoundFolders(int parent_index) |
| 938 | | { |
| 939 | | int i,jj; |
| 940 | | int nGames = driver_list_get_count(drivers); |
| 941 | | int nFolder = numFolders; |
| 942 | | LPTREEFOLDER lpFolder = treeFolders[parent_index]; |
| 943 | | LPTREEFOLDER map[SOUND_COUNT]; |
| 944 | | |
| 945 | | sndintrf_init(NULL); |
| 946 | | |
| 947 | | // no games in top level folder |
| 948 | | SetAllBits(lpFolder->m_lpGameBits,FALSE); |
| 949 | | |
| 950 | | for (i=1;i<SOUND_COUNT;i++) |
| 951 | | { |
| 952 | | LPTREEFOLDER lpTemp; |
| 953 | | |
| 954 | | // empty fields get filled in with SOUND_DUMMY, so check for this and |
| 955 | | // don't add it |
| 956 | | if (strcmp(sndtype_name(SOUND_DUMMY),sndtype_name(i)) == 0) |
| 957 | | continue; |
| 958 | | |
| 959 | | //dprintf("%i %s\n",i,sndtype_name(i)); |
| 960 | | lpTemp = NewFolder(sndtype_name(i), next_folder_id, parent_index, IDI_SOUND, |
| 961 | | GetFolderFlags(numFolders)); |
| 962 | | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 963 | | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 964 | | |
| 965 | | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 966 | | ExtraFolderData[next_folder_id]->m_nIconId = IDI_SOUND; |
| 967 | | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 968 | | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 969 | | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, sndtype_name(i) ); |
| 970 | | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 971 | | AddFolder(lpTemp); |
| 972 | | map[i] = treeFolders[nFolder++]; |
| 973 | | } |
| 974 | | |
| 975 | | for (jj = 0; jj < nGames; jj++) |
| 976 | | { |
| 977 | | int n; |
| 978 | | machine_config drv; |
| 979 | | expand_machine_driver(drivers[jj]->drv,&drv); |
| 980 | | |
| 981 | | for (n = 0; n < MAX_SOUND; n++) |
| 982 | | if (drv.sound[n].sound_type != SOUND_DUMMY) |
| 983 | | { |
| 984 | | // sound type #'s are one-based, though that doesn't affect us here |
| 985 | | AddGame(map[drv.sound[n].sound_type],jj); |
| 986 | | } |
| 987 | | } |
| 988 | | |
| 989 | | } |
| 990 | | |
| 991 | | void CreateOrientationFolders(int parent_index) |
| 992 | | { |
| 993 | | int jj; |
| 994 | | int nGames = driver_list_get_count(drivers); |
| 995 | | LPTREEFOLDER lpFolder = treeFolders[parent_index]; |
| 996 | | |
| 997 | | // create our two subfolders |
| 998 | | LPTREEFOLDER lpVert, lpHorz; |
| 999 | | lpVert = NewFolder("Vertical", next_folder_id, parent_index, IDI_FOLDER, |
| 1000 | | GetFolderFlags(numFolders)); |
| 1001 | | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1002 | | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1003 | | |
| 1004 | | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1005 | | ExtraFolderData[next_folder_id]->m_nIconId = IDI_FOLDER; |
| 1006 | | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1007 | | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1008 | | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, "Vertical" ); |
| 1009 | | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1010 | | AddFolder(lpVert); |
| 1011 | | lpHorz = NewFolder("Horizontal", next_folder_id, parent_index, IDI_FOLDER, |
| 1012 | | GetFolderFlags(numFolders)); |
| 1013 | | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1014 | | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1015 | | |
| 1016 | | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1017 | | ExtraFolderData[next_folder_id]->m_nIconId = IDI_FOLDER; |
| 1018 | | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1019 | | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1020 | | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, "Horizontal" ); |
| 1021 | | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1022 | | AddFolder(lpHorz); |
| 1023 | | |
| 1024 | | // no games in top level folder |
| 1025 | | SetAllBits(lpFolder->m_lpGameBits,FALSE); |
| 1026 | | |
| 1027 | | for (jj = 0; jj < nGames; jj++) |
| 1028 | | { |
| 1029 | | if (drivers[jj]->flags & ORIENTATION_SWAP_XY) |
| 1030 | | { |
| 1031 | | AddGame(lpVert,jj); |
| 1032 | | } |
| 1033 | | else |
| 1034 | | { |
| 1035 | | AddGame(lpHorz,jj); |
| 1036 | | } |
| 1037 | | } |
| 1038 | | } |
| 1039 | | |
| 1040 | | void CreateDeficiencyFolders(int parent_index) |
| 1041 | | { |
| 1042 | | int jj; |
| 1043 | | int nGames = driver_list_get_count(drivers); |
| 1044 | | LPTREEFOLDER lpFolder = treeFolders[parent_index]; |
| 1045 | | |
| 1046 | | // create our two subfolders |
| 1047 | | LPTREEFOLDER lpProt, lpWrongCol, lpImpCol, lpImpGraph, lpMissSnd, lpImpSnd, lpFlip; |
| 1048 | | lpProt = NewFolder("Unemulated Protection", next_folder_id, parent_index, IDI_FOLDER, |
| 1049 | | GetFolderFlags(numFolders)); |
| 1050 | | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1051 | | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1052 | | |
| 1053 | | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1054 | | ExtraFolderData[next_folder_id]->m_nIconId = IDI_FOLDER; |
| 1055 | | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1056 | | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1057 | | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, "Unemulated Protection" ); |
| 1058 | | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1059 | | AddFolder(lpProt); |
| 1060 | | lpWrongCol = NewFolder("Wrong Colors", next_folder_id, parent_index, IDI_FOLDER, |
| 1061 | | GetFolderFlags(numFolders)); |
| 1062 | | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1063 | | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1064 | | |
| 1065 | | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1066 | | ExtraFolderData[next_folder_id]->m_nIconId = IDI_FOLDER; |
| 1067 | | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1068 | | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1069 | | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, "Wrong Colors" ); |
| 1070 | | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1071 | | AddFolder(lpWrongCol); |
| 1072 | | |
| 1073 | | lpImpCol = NewFolder("Imperfect Colors", next_folder_id, parent_index, IDI_FOLDER, |
| 1074 | | GetFolderFlags(numFolders)); |
| 1075 | | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1076 | | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1077 | | |
| 1078 | | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1079 | | ExtraFolderData[next_folder_id]->m_nIconId = IDI_FOLDER; |
| 1080 | | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1081 | | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1082 | | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, "Imperfect Colors" ); |
| 1083 | | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1084 | | AddFolder(lpImpCol); |
| 1085 | | |
| 1086 | | lpImpGraph = NewFolder("Imperfect Graphics", next_folder_id, parent_index, IDI_FOLDER, |
| 1087 | | GetFolderFlags(numFolders)); |
| 1088 | | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1089 | | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1090 | | |
| 1091 | | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1092 | | ExtraFolderData[next_folder_id]->m_nIconId = IDI_FOLDER; |
| 1093 | | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1094 | | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1095 | | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, "Imperfect Graphics" ); |
| 1096 | | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1097 | | AddFolder(lpImpGraph); |
| 1098 | | |
| 1099 | | lpMissSnd = NewFolder("Missing Sound", next_folder_id, parent_index, IDI_FOLDER, |
| 1100 | | GetFolderFlags(numFolders)); |
| 1101 | | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1102 | | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1103 | | |
| 1104 | | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1105 | | ExtraFolderData[next_folder_id]->m_nIconId = IDI_FOLDER; |
| 1106 | | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1107 | | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1108 | | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, "Missing Sound" ); |
| 1109 | | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1110 | | AddFolder(lpMissSnd); |
| 1111 | | |
| 1112 | | lpImpSnd = NewFolder("Imperfect Sound", next_folder_id, parent_index, IDI_FOLDER, |
| 1113 | | GetFolderFlags(numFolders)); |
| 1114 | | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1115 | | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1116 | | |
| 1117 | | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1118 | | ExtraFolderData[next_folder_id]->m_nIconId = IDI_FOLDER; |
| 1119 | | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1120 | | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1121 | | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, "Imperfect Sound" ); |
| 1122 | | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1123 | | AddFolder(lpImpSnd); |
| 1124 | | |
| 1125 | | lpFlip = NewFolder("No Cocktail", next_folder_id, parent_index, IDI_FOLDER, |
| 1126 | | GetFolderFlags(numFolders)); |
| 1127 | | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1128 | | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1129 | | |
| 1130 | | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1131 | | ExtraFolderData[next_folder_id]->m_nIconId = IDI_FOLDER; |
| 1132 | | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1133 | | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1134 | | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, "No Cocktail" ); |
| 1135 | | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1136 | | AddFolder(lpFlip); |
| 1137 | | |
| 1138 | | // no games in top level folder |
| 1139 | | SetAllBits(lpFolder->m_lpGameBits,FALSE); |
| 1140 | | |
| 1141 | | for (jj = 0; jj < nGames; jj++) |
| 1142 | | { |
| 1143 | | if (drivers[jj]->flags & GAME_WRONG_COLORS) |
| 1144 | | { |
| 1145 | | AddGame(lpWrongCol,jj); |
| 1146 | | } |
| 1147 | | if (drivers[jj]->flags & GAME_UNEMULATED_PROTECTION) |
| 1148 | | { |
| 1149 | | AddGame(lpProt,jj); |
| 1150 | | } |
| 1151 | | if (drivers[jj]->flags & GAME_IMPERFECT_COLORS) |
| 1152 | | { |
| 1153 | | AddGame(lpImpCol,jj); |
| 1154 | | } |
| 1155 | | if (drivers[jj]->flags & GAME_IMPERFECT_GRAPHICS) |
| 1156 | | { |
| 1157 | | AddGame(lpImpGraph,jj); |
| 1158 | | } |
| 1159 | | if (drivers[jj]->flags & GAME_NO_SOUND) |
| 1160 | | { |
| 1161 | | AddGame(lpMissSnd,jj); |
| 1162 | | } |
| 1163 | | if (drivers[jj]->flags & GAME_IMPERFECT_SOUND) |
| 1164 | | { |
| 1165 | | AddGame(lpImpSnd,jj); |
| 1166 | | } |
| 1167 | | if (drivers[jj]->flags & GAME_NO_COCKTAIL) |
| 1168 | | { |
| 1169 | | AddGame(lpFlip,jj); |
| 1170 | | } |
| 1171 | | } |
| 1172 | | } |
| 1173 | | |
| 1174 | | void CreateDumpingFolders(int parent_index) |
| 1175 | | { |
| 1176 | | int jj; |
| 1177 | | BOOL bBadDump = FALSE; |
| 1178 | | BOOL bNoDump = FALSE; |
| 1179 | | int nGames = driver_list_get_count(drivers); |
| 1180 | | LPTREEFOLDER lpFolder = treeFolders[parent_index]; |
| 1181 | | const rom_entry *region, *rom; |
| 1182 | | const char *name; |
| 1183 | | const game_driver *gamedrv; |
| 1184 | | |
| 1185 | | // create our two subfolders |
| 1186 | | LPTREEFOLDER lpBad, lpNo; |
| 1187 | | lpBad = NewFolder("Bad Dump", next_folder_id, parent_index, IDI_FOLDER, |
| 1188 | | GetFolderFlags(numFolders)); |
| 1189 | | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1190 | | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1191 | | |
| 1192 | | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1193 | | ExtraFolderData[next_folder_id]->m_nIconId = IDI_FOLDER; |
| 1194 | | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1195 | | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1196 | | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, "Bad Dump" ); |
| 1197 | | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1198 | | AddFolder(lpBad); |
| 1199 | | lpNo = NewFolder("No Dump", next_folder_id, parent_index, IDI_FOLDER, |
| 1200 | | GetFolderFlags(numFolders)); |
| 1201 | | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1202 | | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1203 | | |
| 1204 | | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1205 | | ExtraFolderData[next_folder_id]->m_nIconId = IDI_FOLDER; |
| 1206 | | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1207 | | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1208 | | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, "No Dump" ); |
| 1209 | | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1210 | | AddFolder(lpNo); |
| 1211 | | |
| 1212 | | // no games in top level folder |
| 1213 | | SetAllBits(lpFolder->m_lpGameBits,FALSE); |
| 1214 | | |
| 1215 | | for (jj = 0; jj < nGames; jj++) |
| 1216 | | { |
| 1217 | | gamedrv = drivers[jj]; |
| 1218 | | |
| 1219 | | if (!gamedrv->rom) |
| 1220 | | continue; |
| 1221 | | bBadDump = FALSE; |
| 1222 | | bNoDump = FALSE; |
| 1223 | | for (region = rom_first_region(gamedrv); region; region = rom_next_region(region)) |
| 1224 | | { |
| 1225 | | for (rom = rom_first_file(region); rom; rom = rom_next_file(rom)) |
| 1226 | | { |
| 1227 | | if (ROMREGION_ISROMDATA(region) || ROMREGION_ISDISKDATA(region) ) |
| 1228 | | { |
| 1229 | | name = ROM_GETNAME(rom); |
| 1230 | | if (hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_BAD_DUMP)) |
| 1231 | | bBadDump = TRUE; |
| 1232 | | if (hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_NO_DUMP)) |
| 1233 | | bNoDump = TRUE; |
| 1234 | | } |
| 1235 | | } |
| 1236 | | } |
| 1237 | | if (bBadDump) |
| 1238 | | { |
| 1239 | | AddGame(lpBad,jj); |
| 1240 | | } |
| 1241 | | if (bNoDump) |
| 1242 | | { |
| 1243 | | AddGame(lpNo,jj); |
| 1244 | | } |
| 1245 | | } |
| 1246 | | } |
| 1247 | | |
| 1248 | | |
| 1249 | | void CreateYearFolders(int parent_index) |
| 1250 | | { |
| 1251 | | int i,jj; |
| 1252 | | int nGames = driver_list_get_count(drivers); |
| 1253 | | int start_folder = numFolders; |
| 1254 | | LPTREEFOLDER lpFolder = treeFolders[parent_index]; |
| 1255 | | |
| 1256 | | // no games in top level folder |
| 1257 | | SetAllBits(lpFolder->m_lpGameBits,FALSE); |
| 1258 | | |
| 1259 | | for (jj = 0; jj < nGames; jj++) |
| 1260 | | { |
| 1261 | | char s[100]; |
| 1262 | | strcpy(s,drivers[jj]->year); |
| 1263 | | |
| 1264 | | if (s[0] == '\0') |
| 1265 | | continue; |
| 1266 | | |
| 1267 | | if (s[4] == '?') |
| 1268 | | s[4] = '\0'; |
| 1269 | | |
| 1270 | | // look for an extant year treefolder for this game |
| 1271 | | // (likely to be the previous one, so start at the end) |
| 1272 | | for (i=numFolders-1;i>=start_folder;i--) |
| 1273 | | { |
| 1274 | | if (strncmp(treeFolders[i]->m_lpTitle,s,4) == 0) |
| 1275 | | { |
| 1276 | | AddGame(treeFolders[i],jj); |
| 1277 | | break; |
| 1278 | | } |
| 1279 | | } |
| 1280 | | if (i == start_folder-1) |
| 1281 | | { |
| 1282 | | // nope, it's a year we haven't seen before, make it. |
| 1283 | | LPTREEFOLDER lpTemp; |
| 1284 | | lpTemp = NewFolder(s, next_folder_id, parent_index, IDI_YEAR, |
| 1285 | | GetFolderFlags(numFolders)); |
| 1286 | | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1287 | | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1288 | | |
| 1289 | | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1290 | | ExtraFolderData[next_folder_id]->m_nIconId = IDI_YEAR; |
| 1291 | | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1292 | | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1293 | | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, s ); |
| 1294 | | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1295 | | AddFolder(lpTemp); |
| 1296 | | AddGame(lpTemp,jj); |
| 1297 | | } |
| 1298 | | } |
| 1299 | | } |
| 1300 | | |
| 1301 | | // creates child folders of all the top level folders, including custom ones |
| 1302 | | void CreateAllChildFolders(void) |
| 1303 | | { |
| 1304 | | int num_top_level_folders = numFolders; |
| 1305 | | int i, j; |
| 1306 | | |
| 1307 | | for (i = 0; i < num_top_level_folders; i++) |
| 1308 | | { |
| 1309 | | LPTREEFOLDER lpFolder = treeFolders[i]; |
| 1310 | | LPFOLDERDATA lpFolderData = NULL; |
| 1311 | | |
| 1312 | | for (j = 0; g_lpFolderData[j].m_lpTitle; j++) |
| 1313 | | { |
| 1314 | | if (g_lpFolderData[j].m_nFolderId == lpFolder->m_nFolderId) |
| 1315 | | { |
| 1316 | | lpFolderData = &g_lpFolderData[j]; |
| 1317 | | break; |
| 1318 | | } |
| 1319 | | } |
| 1320 | | |
| 1321 | | if (lpFolderData != NULL) |
| 1322 | | { |
| 1323 | | //dprintf("Found built-in-folder id %i %i",i,lpFolder->m_nFolderId); |
| 1324 | | if (lpFolderData->m_pfnCreateFolders != NULL) |
| 1325 | | lpFolderData->m_pfnCreateFolders(i); |
| 1326 | | } |
| 1327 | | else |
| 1328 | | { |
| 1329 | | if ((lpFolder->m_dwFlags & F_CUSTOM) == 0) |
| 1330 | | { |
| 1331 | | dprintf("Internal inconsistency with non-built-in folder, but not custom"); |
| 1332 | | continue; |
| 1333 | | } |
| 1334 | | |
| 1335 | | //dprintf("Loading custom folder %i %i",i,lpFolder->m_nFolderId); |
| 1336 | | |
| 1337 | | // load the extra folder files, which also adds children |
| 1338 | | if (TryAddExtraFolderAndChildren(i) == FALSE) |
| 1339 | | { |
| 1340 | | lpFolder->m_nFolderId = FOLDER_NONE; |
| 1341 | | } |
| 1342 | | } |
| 1343 | | } |
| 1344 | | } |
| 1345 | | |
| 1346 | | // adds these folders to the treeview |
| 1347 | | void ResetTreeViewFolders(void) |
| 1348 | | { |
| 1349 | | HWND hTreeView = GetTreeView(); |
| 1350 | | int i; |
| 1351 | | TVITEM tvi; |
| 1352 | | TVINSERTSTRUCT tvs; |
| 1353 | | |
| 1354 | | HTREEITEM shti; // for current child branches |
| 1355 | | |
| 1356 | | // currently "cached" parent |
| 1357 | | HTREEITEM hti_parent = NULL; |
| 1358 | | int index_parent = -1; |
| 1359 | | |
| 1360 | | TreeView_DeleteAllItems(hTreeView); |
| 1361 | | |
| 1362 | | //dprintf("Adding folders to tree ui indices %i to %i",start_index,end_index); |
| 1363 | | |
| 1364 | | tvs.hInsertAfter = TVI_SORT; |
| 1365 | | |
| 1366 | | for (i=0;i<numFolders;i++) |
| 1367 | | { |
| 1368 | | LPTREEFOLDER lpFolder = treeFolders[i]; |
| 1369 | | |
| 1370 | | if (lpFolder->m_nParent == -1) |
| 1371 | | { |
| 1372 | | if (lpFolder->m_nFolderId < MAX_FOLDERS) |
| 1373 | | { |
| 1374 | | // it's a built in folder, let's see if we should show it |
| 1375 | | if (GetShowFolder(lpFolder->m_nFolderId) == FALSE) |
| 1376 | | { |
| 1377 | | continue; |
| 1378 | | } |
| 1379 | | } |
| 1380 | | |
| 1381 | | tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; |
| 1382 | | tvs.hParent = TVI_ROOT; |
| 1383 | | tvi.pszText = lpFolder->m_lptTitle; |
| 1384 | | tvi.lParam = (LPARAM)lpFolder; |
| 1385 | | tvi.iImage = GetTreeViewIconIndex(lpFolder->m_nIconId); |
| 1386 | | tvi.iSelectedImage = 0; |
| 1387 | | |
| 1388 | | #if defined(__GNUC__) /* bug in commctrl.h */ |
| 1389 | | tvs.item = tvi; |
| 1390 | | #else |
| 1391 | | tvs.DUMMYUNIONNAME.item = tvi; |
| 1392 | | #endif |
| 1393 | | |
| 1394 | | // Add root branch |
| 1395 | | hti_parent = TreeView_InsertItem(hTreeView, &tvs); |
| 1396 | | |
| 1397 | | continue; |
| 1398 | | } |
| 1399 | | |
| 1400 | | // not a top level branch, so look for parent |
| 1401 | | if (treeFolders[i]->m_nParent != index_parent) |
| 1402 | | { |
| 1403 | | |
| 1404 | | hti_parent = TreeView_GetRoot(hTreeView); |
| 1405 | | while (1) |
| 1406 | | { |
| 1407 | | if (hti_parent == NULL) |
| 1408 | | { |
| 1409 | | // couldn't find parent folder, so it's a built-in but |
| 1410 | | // not shown folder |
| 1411 | | break; |
| 1412 | | } |
| 1413 | | |
| 1414 | | tvi.hItem = hti_parent; |
| 1415 | | tvi.mask = TVIF_PARAM; |
| 1416 | | TreeView_GetItem(hTreeView,&tvi); |
| 1417 | | if (((LPTREEFOLDER)tvi.lParam) == treeFolders[treeFolders[i]->m_nParent]) |
| 1418 | | break; |
| 1419 | | |
| 1420 | | hti_parent = TreeView_GetNextSibling(hTreeView,hti_parent); |
| 1421 | | } |
| 1422 | | |
| 1423 | | // if parent is not shown, then don't show the child either obviously! |
| 1424 | | if (hti_parent == NULL) |
| 1425 | | continue; |
| 1426 | | |
| 1427 | | index_parent = treeFolders[i]->m_nParent; |
| 1428 | | } |
| 1429 | | |
| 1430 | | tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; |
| 1431 | | tvs.hParent = hti_parent; |
| 1432 | | tvi.iImage = GetTreeViewIconIndex(treeFolders[i]->m_nIconId); |
| 1433 | | tvi.iSelectedImage = 0; |
| 1434 | | tvi.pszText = treeFolders[i]->m_lptTitle; |
| 1435 | | tvi.lParam = (LPARAM)treeFolders[i]; |
| 1436 | | |
| 1437 | | #if defined(__GNUC__) /* bug in commctrl.h */ |
| 1438 | | tvs.item = tvi; |
| 1439 | | #else |
| 1440 | | tvs.DUMMYUNIONNAME.item = tvi; |
| 1441 | | #endif |
| 1442 | | // Add it to this tree branch |
| 1443 | | shti = TreeView_InsertItem(hTreeView, &tvs); |
| 1444 | | |
| 1445 | | } |
| 1446 | | } |
| 1447 | | |
| 1448 | | void SelectTreeViewFolder(int folder_id) |
| 1449 | | { |
| 1450 | | HWND hTreeView = GetTreeView(); |
| 1451 | | HTREEITEM hti; |
| 1452 | | TVITEM tvi; |
| 1453 | | |
| 1454 | | memset(&tvi,0,sizeof(tvi)); |
| 1455 | | |
| 1456 | | hti = TreeView_GetRoot(hTreeView); |
| 1457 | | |
| 1458 | | while (hti != NULL) |
| 1459 | | { |
| 1460 | | HTREEITEM hti_next; |
| 1461 | | |
| 1462 | | tvi.hItem = hti; |
| 1463 | | tvi.mask = TVIF_PARAM; |
| 1464 | | TreeView_GetItem(hTreeView,&tvi); |
| 1465 | | |
| 1466 | | if (((LPTREEFOLDER)tvi.lParam)->m_nFolderId == folder_id) |
| 1467 | | { |
| 1468 | | TreeView_SelectItem(hTreeView,tvi.hItem); |
| 1469 | | SetCurrentFolder((LPTREEFOLDER)tvi.lParam); |
| 1470 | | return; |
| 1471 | | } |
| 1472 | | |
| 1473 | | hti_next = TreeView_GetChild(hTreeView,hti); |
| 1474 | | if (hti_next == NULL) |
| 1475 | | { |
| 1476 | | hti_next = TreeView_GetNextSibling(hTreeView,hti); |
| 1477 | | if (hti_next == NULL) |
| 1478 | | { |
| 1479 | | hti_next = TreeView_GetParent(hTreeView,hti); |
| 1480 | | if (hti_next != NULL) |
| 1481 | | hti_next = TreeView_GetNextSibling(hTreeView,hti_next); |
| 1482 | | } |
| 1483 | | } |
| 1484 | | hti = hti_next; |
| 1485 | | } |
| 1486 | | |
| 1487 | | // could not find folder to select |
| 1488 | | // make sure we select something |
| 1489 | | tvi.hItem = TreeView_GetRoot(hTreeView); |
| 1490 | | tvi.mask = TVIF_PARAM; |
| 1491 | | TreeView_GetItem(hTreeView,&tvi); |
| 1492 | | |
| 1493 | | TreeView_SelectItem(hTreeView,tvi.hItem); |
| 1494 | | SetCurrentFolder((LPTREEFOLDER)tvi.lParam); |
| 1495 | | |
| 1496 | | } |
| 1497 | | |
| 1498 | | /* Add a folder to the list. Does not allocate */ |
| 1499 | | static BOOL AddFolder(LPTREEFOLDER lpFolder) |
| 1500 | | { |
| 1501 | | if (numFolders + 1 >= folderArrayLength) |
| 1502 | | { |
| 1503 | | folderArrayLength += 500; |
| 1504 | | treeFolders = realloc(treeFolders,sizeof(TREEFOLDER **) * folderArrayLength); |
| 1505 | | } |
| 1506 | | |
| 1507 | | treeFolders[numFolders] = lpFolder; |
| 1508 | | numFolders++; |
| 1509 | | |
| 1510 | | return TRUE; |
| 1511 | | } |
| 1512 | | |
| 1513 | | /* Allocate and initialize a NEW TREEFOLDER */ |
| 1514 | | static LPTREEFOLDER NewFolder(const char *lpTitle, |
| 1515 | | UINT nFolderId, int nParent, UINT nIconId, DWORD dwFlags) |
| 1516 | | { |
| 1517 | | LPTREEFOLDER lpFolder = (LPTREEFOLDER)malloc(sizeof(TREEFOLDER)); |
| 1518 | | |
| 1519 | | memset(lpFolder, '\0', sizeof (TREEFOLDER)); |
| 1520 | | lpFolder->m_lpTitle = (LPSTR)malloc(strlen(lpTitle) + 1); |
| 1521 | | strcpy((char *)lpFolder->m_lpTitle,lpTitle); |
| 1522 | | lpFolder->m_lptTitle = tstring_from_utf8(lpFolder->m_lpTitle); |
| 1523 | | lpFolder->m_lpGameBits = NewBits(driver_list_get_count(drivers)); |
| 1524 | | lpFolder->m_nFolderId = nFolderId; |
| 1525 | | lpFolder->m_nParent = nParent; |
| 1526 | | lpFolder->m_nIconId = nIconId; |
| 1527 | | lpFolder->m_dwFlags = dwFlags; |
| 1528 | | |
| 1529 | | return lpFolder; |
| 1530 | | } |
| 1531 | | |
| 1532 | | /* Deallocate the passed in LPTREEFOLDER */ |
| 1533 | | static void DeleteFolder(LPTREEFOLDER lpFolder) |
| 1534 | | { |
| 1535 | | if (lpFolder) |
| 1536 | | { |
| 1537 | | if (lpFolder->m_lpGameBits) |
| 1538 | | { |
| 1539 | | DeleteBits(lpFolder->m_lpGameBits); |
| 1540 | | lpFolder->m_lpGameBits = 0; |
| 1541 | | } |
| 1542 | | free(lpFolder->m_lptTitle); |
| 1543 | | lpFolder->m_lptTitle = 0; |
| 1544 | | free(lpFolder->m_lpTitle); |
| 1545 | | lpFolder->m_lpTitle = 0; |
| 1546 | | free(lpFolder); |
| 1547 | | lpFolder = 0; |
| 1548 | | } |
| 1549 | | } |
| 1550 | | |
| 1551 | | /* Can be called to re-initialize the array of treeFolders */ |
| 1552 | | BOOL InitFolders(void) |
| 1553 | | { |
| 1554 | | int i = 0; |
| 1555 | | DWORD dwFolderFlags; |
| 1556 | | LPFOLDERDATA fData = 0; |
| 1557 | | |
| 1558 | | if (treeFolders != NULL) |
| 1559 | | { |
| 1560 | | for (i = numFolders - 1; i >= 0; i--) |
| 1561 | | { |
| 1562 | | DeleteFolder(treeFolders[i]); |
| 1563 | | treeFolders[i] = 0; |
| 1564 | | numFolders--; |
| 1565 | | } |
| 1566 | | } |
| 1567 | | numFolders = 0; |
| 1568 | | if (folderArrayLength == 0) |
| 1569 | | { |
| 1570 | | folderArrayLength = 200; |
| 1571 | | treeFolders = (TREEFOLDER **)malloc(sizeof(TREEFOLDER **) * folderArrayLength); |
| 1572 | | if (!treeFolders) |
| 1573 | | { |
| 1574 | | folderArrayLength = 0; |
| 1575 | | return 0; |
| 1576 | | } |
| 1577 | | else |
| 1578 | | { |
| 1579 | | memset(treeFolders,'\0', sizeof(TREEFOLDER **) * folderArrayLength); |
| 1580 | | } |
| 1581 | | } |
| 1582 | | // built-in top level folders |
| 1583 | | for (i = 0; g_lpFolderData[i].m_lpTitle; i++) |
| 1584 | | { |
| 1585 | | fData = &g_lpFolderData[i]; |
| 1586 | | /* get the saved folder flags */ |
| 1587 | | dwFolderFlags = GetFolderFlags(numFolders); |
| 1588 | | /* create the folder */ |
| 1589 | | AddFolder(NewFolder(fData->m_lpTitle, fData->m_nFolderId, -1, |
| 1590 | | fData->m_nIconId, dwFolderFlags)); |
| 1591 | | } |
| 1592 | | |
| 1593 | | numExtraFolders = InitExtraFolders(); |
| 1594 | | |
| 1595 | | for (i = 0; i < numExtraFolders; i++) |
| 1596 | | { |
| 1597 | | LPEXFOLDERDATA fExData = ExtraFolderData[i]; |
| 1598 | | |
| 1599 | | // OR in the saved folder flags |
| 1600 | | dwFolderFlags = fExData->m_dwFlags | GetFolderFlags(numFolders); |
| 1601 | | // create the folder |
| 1602 | | //dprintf("creating top level custom folder with icon %i",fExData->m_nIconId); |
| 1603 | | AddFolder(NewFolder(fExData->m_szTitle,fExData->m_nFolderId,fExData->m_nParent, |
| 1604 | | fExData->m_nIconId,dwFolderFlags)); |
| 1605 | | } |
| 1606 | | |
| 1607 | | CreateAllChildFolders(); |
| 1608 | | |
| 1609 | | CreateTreeIcons(); |
| 1610 | | |
| 1611 | | ResetWhichGamesInFolders(); |
| 1612 | | |
| 1613 | | ResetTreeViewFolders(); |
| 1614 | | |
| 1615 | | SelectTreeViewFolder(GetSavedFolderID()); |
| 1616 | | |
| 1617 | | return TRUE; |
| 1618 | | } |
| 1619 | | |
| 1620 | | // create iconlist and Treeview control |
| 1621 | | static BOOL CreateTreeIcons() |
| 1622 | | { |
| 1623 | | HICON hIcon; |
| 1624 | | INT i; |
| 1625 | | HINSTANCE hInst = GetModuleHandle(0); |
| 1626 | | |
| 1627 | | int numIcons = ICON_MAX + numExtraIcons; |
| 1628 | | |
| 1629 | | hTreeSmall = ImageList_Create (16, 16, ILC_COLORDDB | ILC_MASK, numIcons, numIcons); |
| 1630 | | |
| 1631 | | //dprintf("Trying to load %i normal icons",ICON_MAX); |
| 1632 | | for (i = 0; i < ICON_MAX; i++) |
| 1633 | | { |
| 1634 | | hIcon = LoadIconFromFile(treeIconNames[i].lpName); |
| 1635 | | if (!hIcon) |
| 1636 | | hIcon = LoadIcon(hInst, MAKEINTRESOURCE(treeIconNames[i].nResourceID)); |
| 1637 | | |
| 1638 | | if (ImageList_AddIcon (hTreeSmall, hIcon) == -1) |
| 1639 | | { |
| 1640 | | ErrorMsg("Error creating icon on regular folder, %i %i",i,hIcon != NULL); |
| 1641 | | return FALSE; |
| 1642 | | } |
| 1643 | | } |
| 1644 | | |
| 1645 | | //dprintf("Trying to load %i extra custom-folder icons",numExtraIcons); |
| 1646 | | for (i = 0; i < numExtraIcons; i++) |
| 1647 | | { |
| 1648 | | if ((hIcon = LoadIconFromFile(ExtraFolderIcons[i])) == 0) |
| 1649 | | hIcon = LoadIcon (hInst, MAKEINTRESOURCE(IDI_FOLDER)); |
| 1650 | | |
| 1651 | | if (ImageList_AddIcon(hTreeSmall, hIcon) == -1) |
| 1652 | | { |
| 1653 | | ErrorMsg("Error creating icon on extra folder, %i %i",i,hIcon != NULL); |
| 1654 | | return FALSE; |
| 1655 | | } |
| 1656 | | } |
| 1657 | | |
| 1658 | | // Be sure that all the small icons were added. |
| 1659 | | if (ImageList_GetImageCount(hTreeSmall) < numIcons) |
| 1660 | | { |
| 1661 | | ErrorMsg("Error with icon list--too few images. %i %i", |
| 1662 | | ImageList_GetImageCount(hTreeSmall),numIcons); |
| 1663 | | return FALSE; |
| 1664 | | } |
| 1665 | | |
| 1666 | | // Be sure that all the small icons were added. |
| 1667 | | |
| 1668 | | if (ImageList_GetImageCount (hTreeSmall) < ICON_MAX) |
| 1669 | | { |
| 1670 | | ErrorMsg("Error with icon list--too few images. %i < %i", |
| 1671 | | ImageList_GetImageCount(hTreeSmall),ICON_MAX); |
| 1672 | | return FALSE; |
| 1673 | | } |
| 1674 | | |
| 1675 | | // Associate the image lists with the list view control. |
| 1676 | | (void) TreeView_SetImageList(GetTreeView(), hTreeSmall, TVSIL_NORMAL); |
| 1677 | | |
| 1678 | | return TRUE; |
| 1679 | | } |
| 1680 | | |
| 1681 | | |
| 1682 | | static void TreeCtrlOnPaint(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 1683 | | { |
| 1684 | | PAINTSTRUCT ps; |
| 1685 | | HDC hDC; |
| 1686 | | RECT rcClip, rcClient; |
| 1687 | | HDC memDC; |
| 1688 | | HBITMAP bitmap; |
| 1689 | | HBITMAP hOldBitmap; |
| 1690 | | |
| 1691 | | HBITMAP hBackground = GetBackgroundBitmap(); |
| 1692 | | MYBITMAPINFO *bmDesc = GetBackgroundInfo(); |
| 1693 | | |
| 1694 | | hDC = BeginPaint(hWnd, &ps); |
| 1695 | | |
| 1696 | | GetClipBox(hDC, &rcClip); |
| 1697 | | GetClientRect(hWnd, &rcClient); |
| 1698 | | |
| 1699 | | // Create a compatible memory DC |
| 1700 | | memDC = CreateCompatibleDC(hDC); |
| 1701 | | |
| 1702 | | // Select a compatible bitmap into the memory DC |
| 1703 | | bitmap = CreateCompatibleBitmap(hDC, rcClient.right - rcClient.left, |
| 1704 | | rcClient.bottom - rcClient.top); |
| 1705 | | hOldBitmap = SelectObject(memDC, bitmap); |
| 1706 | | |
| 1707 | | // First let the control do its default drawing. |
| 1708 | | CallWindowProc(g_lpTreeWndProc, hWnd, uMsg, (WPARAM)memDC, 0); |
| 1709 | | |
| 1710 | | // Draw bitmap in the background |
| 1711 | | |
| 1712 | | { |
| 1713 | | HPALETTE hPAL; |
| 1714 | | HDC maskDC; |
| 1715 | | HBITMAP maskBitmap; |
| 1716 | | HDC tempDC; |
| 1717 | | HDC imageDC; |
| 1718 | | HBITMAP bmpImage; |
| 1719 | | HBITMAP hOldBmpImage; |
| 1720 | | HBITMAP hOldMaskBitmap; |
| 1721 | | HBITMAP hOldHBitmap; |
| 1722 | | int i, j; |
| 1723 | | RECT rcRoot; |
| 1724 | | |
| 1725 | | // Now create a mask |
| 1726 | | maskDC = CreateCompatibleDC(hDC); |
| 1727 | | |
| 1728 | | // Create monochrome bitmap for the mask |
| 1729 | | maskBitmap = CreateBitmap(rcClient.right - rcClient.left, |
| 1730 | | rcClient.bottom - rcClient.top, |
| 1731 | | 1, 1, NULL); |
| 1732 | | |
| 1733 | | hOldMaskBitmap = SelectObject(maskDC, maskBitmap); |
| 1734 | | SetBkColor(memDC, GetSysColor(COLOR_WINDOW)); |
| 1735 | | |
| 1736 | | // Create the mask from the memory DC |
| 1737 | | BitBlt(maskDC, 0, 0, rcClient.right - rcClient.left, |
| 1738 | | rcClient.bottom - rcClient.top, memDC, |
| 1739 | | rcClient.left, rcClient.top, SRCCOPY); |
| 1740 | | |
| 1741 | | tempDC = CreateCompatibleDC(hDC); |
| 1742 | | hOldHBitmap = SelectObject(tempDC, hBackground); |
| 1743 | | |
| 1744 | | imageDC = CreateCompatibleDC(hDC); |
| 1745 | | bmpImage = CreateCompatibleBitmap(hDC, |
| 1746 | | rcClient.right - rcClient.left, |
| 1747 | | rcClient.bottom - rcClient.top); |
| 1748 | | hOldBmpImage = SelectObject(imageDC, bmpImage); |
| 1749 | | |
| 1750 | | hPAL = GetBackgroundPalette(); |
| 1751 | | if (hPAL == NULL) |
| 1752 | | hPAL = CreateHalftonePalette(hDC); |
| 1753 | | |
| 1754 | | if (GetDeviceCaps(hDC, RASTERCAPS) & RC_PALETTE && hPAL != NULL) |
| 1755 | | { |
| 1756 | | SelectPalette(hDC, hPAL, FALSE); |
| 1757 | | RealizePalette(hDC); |
| 1758 | | SelectPalette(imageDC, hPAL, FALSE); |
| 1759 | | } |
| 1760 | | |
| 1761 | | // Get x and y offset |
| 1762 | | TreeView_GetItemRect(hWnd, TreeView_GetRoot(hWnd), &rcRoot, FALSE); |
| 1763 | | rcRoot.left = -GetScrollPos(hWnd, SB_HORZ); |
| 1764 | | |
| 1765 | | // Draw bitmap in tiled manner to imageDC |
| 1766 | | for (i = rcRoot.left; i < rcClient.right; i += bmDesc->bmWidth) |
| 1767 | | for (j = rcRoot.top; j < rcClient.bottom; j += bmDesc->bmHeight) |
| 1768 | | BitBlt(imageDC, i, j, bmDesc->bmWidth, bmDesc->bmHeight, |
| 1769 | | tempDC, 0, 0, SRCCOPY); |
| 1770 | | |
| 1771 | | // Set the background in memDC to black. Using SRCPAINT with black and any other |
| 1772 | | // color results in the other color, thus making black the transparent color |
| 1773 | | SetBkColor(memDC, RGB(0,0,0)); |
| 1774 | | SetTextColor(memDC, RGB(255,255,255)); |
| 1775 | | BitBlt(memDC, rcClip.left, rcClip.top, rcClip.right - rcClip.left, |
| 1776 | | rcClip.bottom - rcClip.top, |
| 1777 | | maskDC, rcClip.left, rcClip.top, SRCAND); |
| 1778 | | |
| 1779 | | // Set the foreground to black. See comment above. |
| 1780 | | SetBkColor(imageDC, RGB(255,255,255)); |
| 1781 | | SetTextColor(imageDC, RGB(0,0,0)); |
| 1782 | | BitBlt(imageDC, rcClip.left, rcClip.top, rcClip.right - rcClip.left, |
| 1783 | | rcClip.bottom - rcClip.top, |
| 1784 | | maskDC, rcClip.left, rcClip.top, SRCAND); |
| 1785 | | |
| 1786 | | // Combine the foreground with the background |
| 1787 | | BitBlt(imageDC, rcClip.left, rcClip.top, rcClip.right - rcClip.left, |
| 1788 | | rcClip.bottom - rcClip.top, |
| 1789 | | memDC, rcClip.left, rcClip.top, SRCPAINT); |
| 1790 | | |
| 1791 | | // Draw the final image to the screen |
| 1792 | | BitBlt(hDC, rcClip.left, rcClip.top, rcClip.right - rcClip.left, |
| 1793 | | rcClip.bottom - rcClip.top, |
| 1794 | | imageDC, rcClip.left, rcClip.top, SRCCOPY); |
| 1795 | | |
| 1796 | | SelectObject(maskDC, hOldMaskBitmap); |
| 1797 | | SelectObject(tempDC, hOldHBitmap); |
| 1798 | | SelectObject(imageDC, hOldBmpImage); |
| 1799 | | |
| 1800 | | DeleteDC(maskDC); |
| 1801 | | DeleteDC(imageDC); |
| 1802 | | DeleteDC(tempDC); |
| 1803 | | DeleteObject(bmpImage); |
| 1804 | | DeleteObject(maskBitmap); |
| 1805 | | |
| 1806 | | if (GetBackgroundPalette() == NULL) |
| 1807 | | { |
| 1808 | | DeleteObject(hPAL); |
| 1809 | | hPAL = 0; |
| 1810 | | } |
| 1811 | | } |
| 1812 | | |
| 1813 | | SelectObject(memDC, hOldBitmap); |
| 1814 | | DeleteObject(bitmap); |
| 1815 | | DeleteDC(memDC); |
| 1816 | | EndPaint(hWnd, &ps); |
| 1817 | | ReleaseDC(hWnd, hDC); |
| 1818 | | } |
| 1819 | | |
| 1820 | | /* Header code - Directional Arrows */ |
| 1821 | | static LRESULT CALLBACK TreeWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 1822 | | { |
| 1823 | | if (GetBackgroundBitmap() != NULL) |
| 1824 | | { |
| 1825 | | switch (uMsg) |
| 1826 | | { |
| 1827 | | case WM_MOUSEMOVE: |
| 1828 | | { |
| 1829 | | if (MouseHasBeenMoved()) |
| 1830 | | ShowCursor(TRUE); |
| 1831 | | break; |
| 1832 | | } |
| 1833 | | |
| 1834 | | case WM_KEYDOWN : |
| 1835 | | if (wParam == VK_F2) |
| 1836 | | { |
| 1837 | | if (lpCurrentFolder->m_dwFlags & F_CUSTOM) |
| 1838 | | { |
| 1839 | | TreeView_EditLabel(hWnd,TreeView_GetSelection(hWnd)); |
| 1840 | | return TRUE; |
| 1841 | | } |
| 1842 | | } |
| 1843 | | break; |
| 1844 | | |
| 1845 | | case WM_ERASEBKGND: |
| 1846 | | return TRUE; |
| 1847 | | break; |
| 1848 | | |
| 1849 | | case WM_PAINT: |
| 1850 | | TreeCtrlOnPaint(hWnd, uMsg, wParam, lParam); |
| 1851 | | UpdateWindow(hWnd); |
| 1852 | | break; |
| 1853 | | } |
| 1854 | | } |
| 1855 | | |
| 1856 | | /* message not handled */ |
| 1857 | | return CallWindowProc(g_lpTreeWndProc, hWnd, uMsg, wParam, lParam); |
| 1858 | | } |
| 1859 | | |
| 1860 | | /* |
| 1861 | | * Filter code - should be moved to filter.c/filter.h |
| 1862 | | * Added 01/09/99 - MSH <mhaaland@hypertech.com> |
| 1863 | | */ |
| 1864 | | |
| 1865 | | /* find a FOLDERDATA by folderID */ |
| 1866 | | LPFOLDERDATA FindFilter(DWORD folderID) |
| 1867 | | { |
| 1868 | | int i; |
| 1869 | | |
| 1870 | | for (i = 0; g_lpFolderData[i].m_lpTitle; i++) |
| 1871 | | { |
| 1872 | | if (g_lpFolderData[i].m_nFolderId == folderID) |
| 1873 | | return &g_lpFolderData[i]; |
| 1874 | | } |
| 1875 | | return (LPFOLDERDATA) 0; |
| 1876 | | } |
| 1877 | | |
| 1878 | | /*************************************************************************** |
| 1879 | | private structures |
| 1880 | | ***************************************************************************/ |
| 1881 | | |
| 1882 | | /*************************************************************************** |
| 1883 | | private functions prototypes |
| 1884 | | ***************************************************************************/ |
| 1885 | | |
| 1886 | | /*************************************************************************** |
| 1887 | | private functions |
| 1888 | | ***************************************************************************/ |
| 1889 | | |
| 1890 | | /**************************************************************************/ |
| 1891 | | |
| 1892 | | LPTREEFOLDER GetFolderByName(int nParentId, const char *pszFolderName) |
| 1893 | | { |
| 1894 | | int i = 0, nParent; |
| 1895 | | |
| 1896 | | //First Get the Parent TreeviewItem |
| 1897 | | //Enumerate Children |
| 1898 | | for(i = 0; i < numFolders/* ||treeFolders[i] != NULL*/; i++) |
| 1899 | | { |
| 1900 | | if (!strcmp(treeFolders[i]->m_lpTitle, pszFolderName)) |
| 1901 | | { |
| 1902 | | nParent = treeFolders[i]->m_nParent; |
| 1903 | | if ((nParent >= 0) && treeFolders[nParent]->m_nFolderId == nParentId) |
| 1904 | | return treeFolders[i]; |
| 1905 | | } |
| 1906 | | } |
| 1907 | | return NULL; |
| 1908 | | } |
| 1909 | | |
| 1910 | | static int InitExtraFolders(void) |
| 1911 | | { |
| 1912 | | struct stat stat_buffer; |
| 1913 | | struct _finddata_t files; |
| 1914 | | int i, count = 0; |
| 1915 | | long hLong; |
| 1916 | | char* ext; |
| 1917 | | char buf[256]; |
| 1918 | | char curdir[MAX_PATH]; |
| 1919 | | const char* dir = GetFolderDir(); |
| 1920 | | |
| 1921 | | memset(ExtraFolderData, 0, (MAX_EXTRA_FOLDERS * MAX_EXTRA_SUBFOLDERS)* sizeof(LPEXFOLDERDATA)); |
| 1922 | | |
| 1923 | | /* NPW 9-Feb-2003 - MSVC stat() doesn't like stat() called with an empty |
| 1924 | | * string |
| 1925 | | */ |
| 1926 | | if (dir[0] == '\0') |
| 1927 | | dir = "."; |
| 1928 | | |
| 1929 | | if (stat(dir, &stat_buffer) != 0) |
| 1930 | | { |
| 1931 | | _mkdir(dir); |
| 1932 | | } |
| 1933 | | |
| 1934 | | _getcwd(curdir, MAX_PATH); |
| 1935 | | |
| 1936 | | _chdir(dir); |
| 1937 | | |
| 1938 | | hLong = _findfirst("*", &files); |
| 1939 | | |
| 1940 | | for (i = 0; i < MAX_EXTRA_FOLDERS; i++) |
| 1941 | | { |
| 1942 | | ExtraFolderIcons[i] = NULL; |
| 1943 | | } |
| 1944 | | |
| 1945 | | numExtraIcons = 0; |
| 1946 | | |
| 1947 | | while (!_findnext(hLong, &files)) |
| 1948 | | { |
| 1949 | | if ((files.attrib & _A_SUBDIR) == 0) |
| 1950 | | { |
| 1951 | | FILE *fp; |
| 1952 | | |
| 1953 | | fp = fopen(files.name, "r"); |
| 1954 | | if (fp != NULL) |
| 1955 | | { |
| 1956 | | int icon[2] = { 0, 0 }; |
| 1957 | | char *p, *name; |
| 1958 | | |
| 1959 | | while (fgets(buf, 256, fp)) |
| 1960 | | { |
| 1961 | | if (buf[0] == '[') |
| 1962 | | { |
| 1963 | | p = strchr(buf, ']'); |
| 1964 | | if (p == NULL) |
| 1965 | | continue; |
| 1966 | | |
| 1967 | | *p = '\0'; |
| 1968 | | name = &buf[1]; |
| 1969 | | if (!strcmp(name, "FOLDER_SETTINGS")) |
| 1970 | | { |
| 1971 | | while (fgets(buf, 256, fp)) |
| 1972 | | { |
| 1973 | | name = strtok(buf, " =\r\n"); |
| 1974 | | if (name == NULL) |
| 1975 | | break; |
| 1976 | | |
| 1977 | | if (!strcmp(name, "RootFolderIcon")) |
| 1978 | | { |
| 1979 | | name = strtok(NULL, " =\r\n"); |
| 1980 | | if (name != NULL) |
| 1981 | | SetExtraIcons(name, &icon[0]); |
| 1982 | | } |
| 1983 | | if (!strcmp(name, "SubFolderIcon")) |
| 1984 | | { |
| 1985 | | name = strtok(NULL, " =\r\n"); |
| 1986 | | if (name != NULL) |
| 1987 | | SetExtraIcons(name, &icon[1]); |
| 1988 | | } |
| 1989 | | } |
| 1990 | | break; |
| 1991 | | } |
| 1992 | | } |
| 1993 | | } |
| 1994 | | fclose(fp); |
| 1995 | | |
| 1996 | | strcpy(buf, files.name); |
| 1997 | | ext = strrchr(buf, '.'); |
| 1998 | | |
| 1999 | | if (ext && *(ext + 1) && !mame_stricmp(ext + 1, "ini")) |
| 2000 | | { |
| 2001 | | ExtraFolderData[count] = malloc(sizeof(EXFOLDERDATA)); |
| 2002 | | if (ExtraFolderData[count]) |
| 2003 | | { |
| 2004 | | *ext = '\0'; |
| 2005 | | |
| 2006 | | memset(ExtraFolderData[count], 0, sizeof(EXFOLDERDATA)); |
| 2007 | | |
| 2008 | | strncpy(ExtraFolderData[count]->m_szTitle, buf, 63); |
| 2009 | | ExtraFolderData[count]->m_nFolderId = next_folder_id++; |
| 2010 | | ExtraFolderData[count]->m_nParent = -1; |
| 2011 | | ExtraFolderData[count]->m_dwFlags = F_CUSTOM; |
| 2012 | | ExtraFolderData[count]->m_nIconId = icon[0] ? -icon[0] : IDI_FOLDER; |
| 2013 | | ExtraFolderData[count]->m_nSubIconId = icon[1] ? -icon[1] : IDI_FOLDER; |
| 2014 | | //dprintf("extra folder with icon %i, subicon %i", |
| 2015 | | //ExtraFolderData[count]->m_nIconId, |
| 2016 | | //ExtraFolderData[count]->m_nSubIconId); |
| 2017 | | count++; |
| 2018 | | } |
| 2019 | | } |
| 2020 | | } |
| 2021 | | } |
| 2022 | | } |
| 2023 | | |
| 2024 | | _chdir(curdir); |
| 2025 | | return count; |
| 2026 | | } |
| 2027 | | |
| 2028 | | void FreeExtraFolders(void) |
| 2029 | | { |
| 2030 | | int i; |
| 2031 | | |
| 2032 | | for (i = 0; i < numExtraFolders; i++) |
| 2033 | | { |
| 2034 | | if (ExtraFolderData[i]) |
| 2035 | | { |
| 2036 | | free(ExtraFolderData[i]); |
| 2037 | | ExtraFolderData[i] = NULL; |
| 2038 | | } |
| 2039 | | } |
| 2040 | | |
| 2041 | | for (i = 0; i < numExtraIcons; i++) |
| 2042 | | { |
| 2043 | | free(ExtraFolderIcons[i]); |
| 2044 | | } |
| 2045 | | |
| 2046 | | numExtraIcons = 0; |
| 2047 | | |
| 2048 | | } |
| 2049 | | |
| 2050 | | |
| 2051 | | static void SetExtraIcons(char *name, int *id) |
| 2052 | | { |
| 2053 | | char *p = strchr(name, '.'); |
| 2054 | | |
| 2055 | | if (p != NULL) |
| 2056 | | *p = '\0'; |
| 2057 | | |
| 2058 | | ExtraFolderIcons[numExtraIcons] = malloc(strlen(name) + 1); |
| 2059 | | if (ExtraFolderIcons[numExtraIcons]) |
| 2060 | | { |
| 2061 | | *id = ICON_MAX + numExtraIcons; |
| 2062 | | strcpy(ExtraFolderIcons[numExtraIcons], name); |
| 2063 | | numExtraIcons++; |
| 2064 | | } |
| 2065 | | } |
| 2066 | | |
| 2067 | | |
| 2068 | | // Called to add child folders of the top level extra folders already created |
| 2069 | | BOOL TryAddExtraFolderAndChildren(int parent_index) |
| 2070 | | { |
| 2071 | | FILE* fp = NULL; |
| 2072 | | char fname[MAX_PATH]; |
| 2073 | | char readbuf[256]; |
| 2074 | | char* p; |
| 2075 | | char* name; |
| 2076 | | int id, current_id, i; |
| 2077 | | LPTREEFOLDER lpTemp = NULL; |
| 2078 | | LPTREEFOLDER lpFolder = treeFolders[parent_index]; |
| 2079 | | |
| 2080 | | current_id = lpFolder->m_nFolderId; |
| 2081 | | |
| 2082 | | id = lpFolder->m_nFolderId - MAX_FOLDERS; |
| 2083 | | |
| 2084 | | /* "folder\title.ini" */ |
| 2085 | | |
| 2086 | | sprintf( fname, "%s\\%s.ini", |
| 2087 | | GetFolderDir(), |
| 2088 | | ExtraFolderData[id]->m_szTitle); |
| 2089 | | |
| 2090 | | fp = fopen(fname, "r"); |
| 2091 | | if (fp == NULL) |
| 2092 | | return FALSE; |
| 2093 | | |
| 2094 | | while ( fgets(readbuf, 256, fp) ) |
| 2095 | | { |
| 2096 | | /* do we have [...] ? */ |
| 2097 | | |
| 2098 | | if (readbuf[0] == '[') |
| 2099 | | { |
| 2100 | | p = strchr(readbuf, ']'); |
| 2101 | | if (p == NULL) |
| 2102 | | { |
| 2103 | | continue; |
| 2104 | | } |
| 2105 | | |
| 2106 | | *p = '\0'; |
| 2107 | | name = &readbuf[1]; |
| 2108 | | |
| 2109 | | /* is it [FOLDER_SETTINGS]? */ |
| 2110 | | |
| 2111 | | if (strcmp(name, "FOLDER_SETTINGS") == 0) |
| 2112 | | { |
| 2113 | | current_id = -1; |
| 2114 | | continue; |
| 2115 | | } |
| 2116 | | else |
| 2117 | | { |
| 2118 | | /* it it [ROOT_FOLDER]? */ |
| 2119 | | |
| 2120 | | if (!strcmp(name, "ROOT_FOLDER")) |
| 2121 | | { |
| 2122 | | current_id = lpFolder->m_nFolderId; |
| 2123 | | lpTemp = lpFolder; |
| 2124 | | |
| 2125 | | } |
| 2126 | | else |
| 2127 | | { |
| 2128 | | /* must be [folder name] */ |
| 2129 | | |
| 2130 | | current_id = next_folder_id++; |
| 2131 | | /* create a new folder with this name, |
| 2132 | | and the flags for this folder as read from the registry */ |
| 2133 | | lpTemp = NewFolder(name,current_id,parent_index, |
| 2134 | | ExtraFolderData[id]->m_nSubIconId, |
| 2135 | | GetFolderFlags(numFolders) | F_CUSTOM); |
| 2136 | | ExtraFolderData[current_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 2137 | | memset(ExtraFolderData[current_id], 0, sizeof(EXFOLDERDATA)); |
| 2138 | | |
| 2139 | | ExtraFolderData[current_id]->m_nFolderId = current_id - MAX_EXTRA_FOLDERS; |
| 2140 | | ExtraFolderData[current_id]->m_nIconId = ExtraFolderData[id]->m_nSubIconId; |
| 2141 | | ExtraFolderData[current_id]->m_nParent = ExtraFolderData[id]->m_nFolderId; |
| 2142 | | ExtraFolderData[current_id]->m_nSubIconId = -1; |
| 2143 | | strcpy( ExtraFolderData[current_id]->m_szTitle, name ); |
| 2144 | | ExtraFolderData[current_id]->m_dwFlags = ExtraFolderData[id]->m_dwFlags; |
| 2145 | | AddFolder(lpTemp); |
| 2146 | | } |
| 2147 | | } |
| 2148 | | } |
| 2149 | | else if (current_id != -1) |
| 2150 | | { |
| 2151 | | /* string on a line by itself -- game name */ |
| 2152 | | |
| 2153 | | name = strtok(readbuf, " \t\r\n"); |
| 2154 | | if (name == NULL) |
| 2155 | | { |
| 2156 | | current_id = -1; |
| 2157 | | continue; |
| 2158 | | } |
| 2159 | | |
| 2160 | | /* IMPORTANT: This assumes that all driver names are lowercase! */ |
| 2161 | | for (i = 0; name[i]; i++) |
| 2162 | | name[i] = tolower(name[i]); |
| 2163 | | |
| 2164 | | if (lpTemp == NULL) |
| 2165 | | { |
| 2166 | | ErrorMsg("Error parsing %s: missing [folder name] or [ROOT_FOLDER]", |
| 2167 | | fname); |
| 2168 | | current_id = lpFolder->m_nFolderId; |
| 2169 | | lpTemp = lpFolder; |
| 2170 | | } |
| 2171 | | AddGame(lpTemp,GetGameNameIndex(name)); |
| 2172 | | } |
| 2173 | | } |
| 2174 | | |
| 2175 | | if ( fp ) |
| 2176 | | { |
| 2177 | | fclose( fp ); |
| 2178 | | } |
| 2179 | | |
| 2180 | | return TRUE; |
| 2181 | | } |
| 2182 | | |
| 2183 | | |
| 2184 | | void GetFolders(TREEFOLDER ***folders,int *num_folders) |
| 2185 | | { |
| 2186 | | *folders = treeFolders; |
| 2187 | | *num_folders = numFolders; |
| 2188 | | } |
| 2189 | | |
| 2190 | | BOOL TryRenameCustomFolderIni(LPTREEFOLDER lpFolder,const char *old_name,const char *new_name) |
| 2191 | | { |
| 2192 | | char filename[MAX_PATH]; |
| 2193 | | char new_filename[MAX_PATH]; |
| 2194 | | LPTREEFOLDER lpParent = NULL; |
| 2195 | | if (lpFolder->m_nParent >= 0) |
| 2196 | | { |
| 2197 | | //it is a custom SubFolder |
| 2198 | | lpParent = GetFolder( lpFolder->m_nParent ); |
| 2199 | | if( lpParent ) |
| 2200 | | { |
| 2201 | | snprintf(filename,ARRAY_LENGTH(filename),"%s\\%s\\%s.ini",GetIniDir(),lpParent->m_lpTitle, old_name ); |
| 2202 | | snprintf(new_filename,ARRAY_LENGTH(new_filename),"%s\\%s\\%s.ini",GetIniDir(),lpParent->m_lpTitle, new_name ); |
| 2203 | | win_move_file_utf8(filename,new_filename); |
| 2204 | | } |
| 2205 | | } |
| 2206 | | else |
| 2207 | | { |
| 2208 | | //Rename the File, if it exists |
| 2209 | | snprintf(filename,ARRAY_LENGTH(filename),"%s\\%s.ini",GetIniDir(),old_name ); |
| 2210 | | snprintf(new_filename,ARRAY_LENGTH(new_filename),"%s\\%s.ini",GetIniDir(), new_name ); |
| 2211 | | win_move_file_utf8(filename,new_filename); |
| 2212 | | //Rename the Directory, if it exists |
| 2213 | | snprintf(filename,ARRAY_LENGTH(filename),"%s\\%s",GetIniDir(),old_name ); |
| 2214 | | snprintf(new_filename,ARRAY_LENGTH(new_filename),"%s\\%s",GetIniDir(), new_name ); |
| 2215 | | win_move_file_utf8(filename,new_filename); |
| 2216 | | } |
| 2217 | | return TRUE; |
| 2218 | | } |
| 2219 | | |
| 2220 | | BOOL TryRenameCustomFolder(LPTREEFOLDER lpFolder, const char *new_name) |
| 2221 | | { |
| 2222 | | BOOL retval; |
| 2223 | | char filename[MAX_PATH]; |
| 2224 | | char new_filename[MAX_PATH]; |
| 2225 | | |
| 2226 | | if (lpFolder->m_nParent >= 0) |
| 2227 | | { |
| 2228 | | // a child extra folder was renamed, so do the rename and save the parent |
| 2229 | | |
| 2230 | | // save old title |
| 2231 | | char *old_title = lpFolder->m_lpTitle; |
| 2232 | | |
| 2233 | | // set new title |
| 2234 | | lpFolder->m_lpTitle = (char *)malloc(strlen(new_name) + 1); |
| 2235 | | strcpy(lpFolder->m_lpTitle,new_name); |
| 2236 | | |
| 2237 | | // try to save |
| 2238 | | if (TrySaveExtraFolder(lpFolder) == FALSE) |
| 2239 | | { |
| 2240 | | // failed, so free newly allocated title and restore old |
| 2241 | | free(lpFolder->m_lpTitle); |
| 2242 | | lpFolder->m_lpTitle = old_title; |
| 2243 | | return FALSE; |
| 2244 | | } |
| 2245 | | TryRenameCustomFolderIni(lpFolder, old_title, new_name); |
| 2246 | | // successful, so free old title |
| 2247 | | free(old_title); |
| 2248 | | return TRUE; |
| 2249 | | } |
| 2250 | | |
| 2251 | | // a parent extra folder was renamed, so rename the file |
| 2252 | | |
| 2253 | | snprintf(new_filename,ARRAY_LENGTH(new_filename),"%s\\%s.ini",GetFolderDir(),new_name); |
| 2254 | | snprintf(filename,ARRAY_LENGTH(filename),"%s\\%s.ini",GetFolderDir(),lpFolder->m_lpTitle); |
| 2255 | | |
| 2256 | | retval = win_move_file_utf8(filename,new_filename); |
| 2257 | | |
| 2258 | | if (retval) |
| 2259 | | { |
| 2260 | | TryRenameCustomFolderIni(lpFolder, lpFolder->m_lpTitle, new_name); |
| 2261 | | free(lpFolder->m_lpTitle); |
| 2262 | | lpFolder->m_lpTitle = (char *)malloc(strlen(new_name) + 1); |
| 2263 | | strcpy(lpFolder->m_lpTitle,new_name); |
| 2264 | | } |
| 2265 | | else |
| 2266 | | { |
| 2267 | | char buf[500]; |
| 2268 | | snprintf(buf,ARRAY_LENGTH(buf),"Error while renaming custom file %s to %s", |
| 2269 | | filename,new_filename); |
| 2270 | | win_message_box_utf8(GetMainWindow(), buf, MAME32NAME, MB_OK | MB_ICONERROR); |
| 2271 | | } |
| 2272 | | return retval; |
| 2273 | | } |
| 2274 | | |
| 2275 | | void AddToCustomFolder(LPTREEFOLDER lpFolder,int driver_index) |
| 2276 | | { |
| 2277 | | if ((lpFolder->m_dwFlags & F_CUSTOM) == 0) |
| 2278 | | { |
| 2279 | | win_message_box_utf8(GetMainWindow(),"Unable to add game to non-custom folder", |
| 2280 | | MAME32NAME,MB_OK | MB_ICONERROR); |
| 2281 | | return; |
| 2282 | | } |
| 2283 | | |
| 2284 | | if (TestBit(lpFolder->m_lpGameBits,driver_index) == 0) |
| 2285 | | { |
| 2286 | | AddGame(lpFolder,driver_index); |
| 2287 | | if (TrySaveExtraFolder(lpFolder) == FALSE) |
| 2288 | | RemoveGame(lpFolder,driver_index); // undo on error |
| 2289 | | } |
| 2290 | | } |
| 2291 | | |
| 2292 | | void RemoveFromCustomFolder(LPTREEFOLDER lpFolder,int driver_index) |
| 2293 | | { |
| 2294 | | if ((lpFolder->m_dwFlags & F_CUSTOM) == 0) |
| 2295 | | { |
| 2296 | | win_message_box_utf8(GetMainWindow(),"Unable to remove game from non-custom folder", |
| 2297 | | MAME32NAME,MB_OK | MB_ICONERROR); |
| 2298 | | return; |
| 2299 | | } |
| 2300 | | |
| 2301 | | if (TestBit(lpFolder->m_lpGameBits,driver_index) != 0) |
| 2302 | | { |
| 2303 | | RemoveGame(lpFolder,driver_index); |
| 2304 | | if (TrySaveExtraFolder(lpFolder) == FALSE) |
| 2305 | | AddGame(lpFolder,driver_index); // undo on error |
| 2306 | | } |
| 2307 | | } |
| 2308 | | |
| 2309 | | BOOL TrySaveExtraFolder(LPTREEFOLDER lpFolder) |
| 2310 | | { |
| 2311 | | char fname[MAX_PATH]; |
| 2312 | | FILE *fp; |
| 2313 | | BOOL error = FALSE; |
| 2314 | | int i,j; |
| 2315 | | |
| 2316 | | LPTREEFOLDER root_folder = NULL; |
| 2317 | | LPEXFOLDERDATA extra_folder = NULL; |
| 2318 | | |
| 2319 | | for (i=0;i<numExtraFolders;i++) |
| 2320 | | { |
| 2321 | | if (ExtraFolderData[i]->m_nFolderId == lpFolder->m_nFolderId) |
| 2322 | | { |
| 2323 | | root_folder = lpFolder; |
| 2324 | | extra_folder = ExtraFolderData[i]; |
| 2325 | | break; |
| 2326 | | } |
| 2327 | | |
| 2328 | | if (lpFolder->m_nParent >= 0 && |
| 2329 | | ExtraFolderData[i]->m_nFolderId == treeFolders[lpFolder->m_nParent]->m_nFolderId) |
| 2330 | | { |
| 2331 | | root_folder = treeFolders[lpFolder->m_nParent]; |
| 2332 | | extra_folder = ExtraFolderData[i]; |
| 2333 | | break; |
| 2334 | | } |
| 2335 | | } |
| 2336 | | |
| 2337 | | if (extra_folder == NULL || root_folder == NULL) |
| 2338 | | { |
| 2339 | | MessageBox(GetMainWindow(), TEXT("Error finding custom file name to save"), TEXT(MAME32NAME), MB_OK | MB_ICONERROR); |
| 2340 | | return FALSE; |
| 2341 | | } |
| 2342 | | /* "folder\title.ini" */ |
| 2343 | | |
| 2344 | | snprintf( fname, sizeof(fname), "%s\\%s.ini", GetFolderDir(), extra_folder->m_szTitle); |
| 2345 | | |
| 2346 | | fp = fopen(fname, "wt"); |
| 2347 | | if (fp == NULL) |
| 2348 | | error = TRUE; |
| 2349 | | else |
| 2350 | | { |
| 2351 | | TREEFOLDER *folder_data; |
| 2352 | | |
| 2353 | | |
| 2354 | | fprintf(fp,"[FOLDER_SETTINGS]\n"); |
| 2355 | | // negative values for icons means it's custom, so save 'em |
| 2356 | | if (extra_folder->m_nIconId < 0) |
| 2357 | | { |
| 2358 | | fprintf(fp, "RootFolderIcon %s\n", |
| 2359 | | ExtraFolderIcons[(-extra_folder->m_nIconId) - ICON_MAX]); |
| 2360 | | } |
| 2361 | | if (extra_folder->m_nSubIconId < 0) |
| 2362 | | { |
| 2363 | | fprintf(fp,"SubFolderIcon %s\n", |
| 2364 | | ExtraFolderIcons[(-extra_folder->m_nSubIconId) - ICON_MAX]); |
| 2365 | | } |
| 2366 | | |
| 2367 | | /* need to loop over all our TREEFOLDERs--first the root one, then each child. |
| 2368 | | start with the root */ |
| 2369 | | |
| 2370 | | folder_data = root_folder; |
| 2371 | | |
| 2372 | | fprintf(fp,"\n[ROOT_FOLDER]\n"); |
| 2373 | | |
| 2374 | | for (i=0;i<driver_list_get_count(drivers);i++) |
| 2375 | | { |
| 2376 | | int driver_index = GetIndexFromSortedIndex(i); |
| 2377 | | if (TestBit(folder_data->m_lpGameBits,driver_index)) |
| 2378 | | { |
| 2379 | | fprintf(fp,"%s\n",drivers[driver_index]->name); |
| 2380 | | } |
| 2381 | | } |
| 2382 | | |
| 2383 | | /* look through the custom folders for ones with our root as parent */ |
| 2384 | | for (j=0;j<numFolders;j++) |
| 2385 | | { |
| 2386 | | folder_data = treeFolders[j]; |
| 2387 | | |
| 2388 | | if (folder_data->m_nParent >= 0 && |
| 2389 | | treeFolders[folder_data->m_nParent] == root_folder) |
| 2390 | | { |
| 2391 | | fprintf(fp,"\n[%s]\n",folder_data->m_lpTitle); |
| 2392 | | |
| 2393 | | for (i=0;i<driver_list_get_count(drivers);i++) |
| 2394 | | { |
| 2395 | | int driver_index = GetIndexFromSortedIndex(i); |
| 2396 | | if (TestBit(folder_data->m_lpGameBits,driver_index)) |
| 2397 | | { |
| 2398 | | fprintf(fp,"%s\n",drivers[driver_index]->name); |
| 2399 | | } |
| 2400 | | } |
| 2401 | | } |
| 2402 | | } |
| 2403 | | if (fclose(fp) != 0) |
| 2404 | | error = TRUE; |
| 2405 | | } |
| 2406 | | |
| 2407 | | if (error) |
| 2408 | | { |
| 2409 | | char buf[500]; |
| 2410 | | snprintf(buf,ARRAY_LENGTH(buf),"Error while saving custom file %s",fname); |
| 2411 | | win_message_box_utf8(GetMainWindow(), buf, MAME32NAME, MB_OK | MB_ICONERROR); |
| 2412 | | } |
| 2413 | | return !error; |
| 2414 | | } |
| 2415 | | |
| 2416 | | HIMAGELIST GetTreeViewIconList(void) |
| 2417 | | { |
| 2418 | | return hTreeSmall; |
| 2419 | | } |
| 2420 | | |
| 2421 | | int GetTreeViewIconIndex(int icon_id) |
| 2422 | | { |
| 2423 | | int i; |
| 2424 | | |
| 2425 | | if (icon_id < 0) |
| 2426 | | return -icon_id; |
| 2427 | | |
| 2428 | | for (i = 0; i < sizeof(treeIconNames) / sizeof(treeIconNames[0]); i++) |
| 2429 | | { |
| 2430 | | if (icon_id == treeIconNames[i].nResourceID) |
| 2431 | | return i; |
| 2432 | | } |
| 2433 | | |
| 2434 | | return -1; |
| 2435 | | } |
| 2436 | | |
| 2437 | | /* End of source file */ |
src/osd/windows/ui/properties.c
| r995 | r996 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | M.A.M.E.32 - Multiple Arcade Machine Emulator for Win32 |
| 4 | | Win32 Portions Copyright (C) 1997-2003 Michael Soderstrom and Chris Kirmse |
| 5 | | |
| 6 | | This file is part of MAME32, and may only be used, modified and |
| 7 | | distributed under the terms of the MAME license, in "readme.txt". |
| 8 | | By continuing to use, modify or distribute this file you indicate |
| 9 | | that you have read the license and understand and accept it fully. |
| 10 | | |
| 11 | | ***************************************************************************/ |
| 12 | | |
| 13 | | /*************************************************************************** |
| 14 | | |
| 15 | | Properties.c |
| 16 | | |
| 17 | | Properties Popup and Misc UI support routines. |
| 18 | | |
| 19 | | Created 8/29/98 by Mike Haaland (mhaaland@hypertech.com) |
| 20 | | |
| 21 | | ***************************************************************************/ |
| 22 | | #define WIN32_LEAN_AND_MEAN |
| 23 | | #define NONAMELESSUNION 1 |
| 24 | | #include <windows.h> |
| 25 | | #include <windowsx.h> |
| 26 | | #include <commctrl.h> |
| 27 | | #include <commdlg.h> |
| 28 | | #undef NONAMELESSUNION |
| 29 | | #include <ddraw.h> |
| 30 | | #include <stdio.h> |
| 31 | | #include <string.h> |
| 32 | | #include <sys/stat.h> |
| 33 | | #include <tchar.h> |
| 34 | | |
| 35 | | #include <driver.h> |
| 36 | | #include <info.h> |
| 37 | | #include "audit.h" |
| 38 | | #include "audit32.h" |
| 39 | | #include "bitmask.h" |
| 40 | | #include "m32opts.h" |
| 41 | | #include "file.h" |
| 42 | | #include "resource.h" |
| 43 | | #include "DIJoystick.h" /* For DIJoystick avalibility. */ |
| 44 | | #include "m32util.h" |
| 45 | | #include "directdraw.h" |
| 46 | | #include "properties.h" |
| 47 | | #include "treeview.h" |
| 48 | | #include "win32ui.h" |
| 49 | | #include "screenshot.h" |
| 50 | | #include "Mame32.h" |
| 51 | | #include "DataMap.h" |
| 52 | | #include "help.h" |
| 53 | | #include "resource.hm" |
| 54 | | #include "winmain.h" |
| 55 | | #include "strconv.h" |
| 56 | | #include "winutf8.h" |
| 57 | | #include "ui/m32util.h" |
| 58 | | |
| 59 | | typedef HANDLE HTHEME; |
| 60 | | |
| 61 | | #ifdef _MSC_VER |
| 62 | | #define snprintf _snprintf |
| 63 | | #endif |
| 64 | | |
| 65 | | #ifdef MESS |
| 66 | | // done like this until I figure out a better idea |
| 67 | | #include "messopts.h" |
| 68 | | #include "ui/resourcems.h" |
| 69 | | #include "ui/propertiesms.h" |
| 70 | | #endif |
| 71 | | |
| 72 | | // missing win32 api defines |
| 73 | | #ifndef TBCD_TICS |
| 74 | | #define TBCD_TICS 1 |
| 75 | | #endif |
| 76 | | #ifndef TBCD_THUMB |
| 77 | | #define TBCD_THUMB 2 |
| 78 | | #endif |
| 79 | | #ifndef TBCD_CHANNEL |
| 80 | | #define TBCD_CHANNEL 3 |
| 81 | | #endif |
| 82 | | |
| 83 | | #if defined(__GNUC__) |
| 84 | | /* fix warning: cast does not match function type */ |
| 85 | | #undef PropSheet_GetTabControl |
| 86 | | #define PropSheet_GetTabControl(d) (HWND)(LRESULT)(int)SendMessage((d),PSM_GETTABCONTROL,0,0) |
| 87 | | #endif /* defined(__GNUC__) */ |
| 88 | | |
| 89 | | /*************************************************************** |
| 90 | | * Imported function prototypes |
| 91 | | ***************************************************************/ |
| 92 | | |
| 93 | | /************************************************************** |
| 94 | | * Local function prototypes |
| 95 | | **************************************************************/ |
| 96 | | |
| 97 | | static void SetStereoEnabled(HWND hWnd, int nIndex); |
| 98 | | static void SetYM3812Enabled(HWND hWnd, int nIndex); |
| 99 | | static void SetSamplesEnabled(HWND hWnd, int nIndex, BOOL bSoundEnabled); |
| 100 | | static void InitializeOptions(HWND hDlg); |
| 101 | | static void InitializeMisc(HWND hDlg); |
| 102 | | static void OptOnHScroll(HWND hWnd, HWND hwndCtl, UINT code, int pos); |
| 103 | | static void NumScreensSelectionChange(HWND hwnd); |
| 104 | | static void RefreshSelectionChange(HWND hWnd, HWND hWndCtrl); |
| 105 | | static void InitializeSoundUI(HWND hwnd); |
| 106 | | static void InitializeSkippingUI(HWND hwnd); |
| 107 | | static void InitializeRotateUI(HWND hwnd); |
| 108 | | static void UpdateSelectScreenUI(HWND hwnd); |
| 109 | | static void InitializeSelectScreenUI(HWND hwnd); |
| 110 | | static void InitializeD3DVersionUI(HWND hwnd); |
| 111 | | static void InitializeVideoUI(HWND hwnd); |
| 112 | | static void InitializeEffectUI(HWND hWnd); |
| 113 | | static void InitializeBIOSUI(HWND hwnd); |
| 114 | | static void InitializeControllerMappingUI(HWND hwnd); |
| 115 | | static void PropToOptions(HWND hWnd, core_options *o); |
| 116 | | static void OptionsToProp(HWND hWnd, core_options *o); |
| 117 | | static void SetPropEnabledControls(HWND hWnd); |
| 118 | | static BOOL SelectEffect(HWND hWnd); |
| 119 | | static BOOL ResetEffect(HWND hWnd); |
| 120 | | |
| 121 | | static void BuildDataMap(void); |
| 122 | | static void ResetDataMap(HWND hWnd); |
| 123 | | |
| 124 | | static BOOL IsControlOptionValue(HWND hDlg,HWND hwnd_ctrl, core_options *opts ); |
| 125 | | |
| 126 | | static void UpdateBackgroundBrush(HWND hwndTab); |
| 127 | | HBRUSH hBkBrush; |
| 128 | | |
| 129 | | /************************************************************** |
| 130 | | * Local private variables |
| 131 | | **************************************************************/ |
| 132 | | |
| 133 | | static core_options *origGameOpts; |
| 134 | | static BOOL orig_uses_defaults; |
| 135 | | static core_options *pGameOpts = NULL; |
| 136 | | static datamap *properties_datamap; |
| 137 | | |
| 138 | | static int g_nGame = 0; |
| 139 | | static int g_nFolder = 0; |
| 140 | | static int g_nFolderGame = 0; |
| 141 | | static int g_nPropertyMode = 0; |
| 142 | | static BOOL g_bUseDefaults = FALSE; |
| 143 | | static BOOL g_bReset = FALSE; |
| 144 | | static BOOL g_bAutoAspect[MAX_SCREENS] = {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}; |
| 145 | | static HICON g_hIcon = NULL; |
| 146 | | |
| 147 | | /* Property sheets */ |
| 148 | | |
| 149 | | #define HIGHLIGHT_COLOR RGB(0,196,0) |
| 150 | | HBRUSH highlight_brush = NULL; |
| 151 | | HBRUSH background_brush = NULL; |
| 152 | | #define VECTOR_COLOR RGB( 190, 0, 0) //DARK RED |
| 153 | | #define FOLDER_COLOR RGB( 0, 128, 0 ) // DARK GREEN |
| 154 | | #define PARENT_COLOR RGB( 190, 128, 192 ) // PURPLE |
| 155 | | #define GAME_COLOR RGB( 0, 128, 192 ) // DARK BLUE |
| 156 | | |
| 157 | | BOOL PropSheetFilter_Vector(const machine_config *drv, const game_driver *gamedrv) |
| 158 | | { |
| 159 | | return (drv->video_attributes & VIDEO_TYPE_VECTOR) != 0; |
| 160 | | } |
| 161 | | |
| 162 | | /* Help IDs */ |
| 163 | | static DWORD dwHelpIDs[] = |
| 164 | | { |
| 165 | | |
| 166 | | IDC_JDZ, HIDC_JDZ, |
| 167 | | IDC_ANTIALIAS, HIDC_ANTIALIAS, |
| 168 | | IDC_ARTWORK_CROP, HIDC_ARTWORK_CROP, |
| 169 | | IDC_ASPECTRATIOD, HIDC_ASPECTRATIOD, |
| 170 | | IDC_ASPECTRATION, HIDC_ASPECTRATION, |
| 171 | | IDC_AUTOFRAMESKIP, HIDC_AUTOFRAMESKIP, |
| 172 | | IDC_BACKDROPS, HIDC_BACKDROPS, |
| 173 | | IDC_BEAM, HIDC_BEAM, |
| 174 | | IDC_BEZELS, HIDC_BEZELS, |
| 175 | | IDC_FSGAMMA, HIDC_FSGAMMA, |
| 176 | | IDC_BRIGHTCORRECT, HIDC_BRIGHTCORRECT, |
| 177 | | IDC_BROADCAST, HIDC_BROADCAST, |
| 178 | | IDC_RANDOM_BG, HIDC_RANDOM_BG, |
| 179 | | IDC_CHEAT, HIDC_CHEAT, |
| 180 | | IDC_DEFAULT_INPUT, HIDC_DEFAULT_INPUT, |
| 181 | | IDC_FILTER_CLONES, HIDC_FILTER_CLONES, |
| 182 | | IDC_FILTER_EDIT, HIDC_FILTER_EDIT, |
| 183 | | IDC_FILTER_NONWORKING, HIDC_FILTER_NONWORKING, |
| 184 | | IDC_FILTER_ORIGINALS, HIDC_FILTER_ORIGINALS, |
| 185 | | IDC_FILTER_RASTER, HIDC_FILTER_RASTER, |
| 186 | | IDC_FILTER_UNAVAILABLE, HIDC_FILTER_UNAVAILABLE, |
| 187 | | IDC_FILTER_VECTOR, HIDC_FILTER_VECTOR, |
| 188 | | IDC_FILTER_WORKING, HIDC_FILTER_WORKING, |
| 189 | | IDC_FLICKER, HIDC_FLICKER, |
| 190 | | IDC_FLIPX, HIDC_FLIPX, |
| 191 | | IDC_FLIPY, HIDC_FLIPY, |
| 192 | | IDC_FRAMESKIP, HIDC_FRAMESKIP, |
| 193 | | IDC_GAMMA, HIDC_GAMMA, |
| 194 | | IDC_HISTORY, HIDC_HISTORY, |
| 195 | | IDC_HWSTRETCH, HIDC_HWSTRETCH, |
| 196 | | IDC_JOYSTICK, HIDC_JOYSTICK, |
| 197 | | IDC_KEEPASPECT, HIDC_KEEPASPECT, |
| 198 | | IDC_LANGUAGECHECK, HIDC_LANGUAGECHECK, |
| 199 | | IDC_LANGUAGEEDIT, HIDC_LANGUAGEEDIT, |
| 200 | | IDC_LOG, HIDC_LOG, |
| 201 | | IDC_SLEEP, HIDC_SLEEP, |
| 202 | | IDC_MAXIMIZE, HIDC_MAXIMIZE, |
| 203 | | IDC_OVERLAYS, HIDC_OVERLAYS, |
| 204 | | IDC_PROP_RESET, HIDC_PROP_RESET, |
| 205 | | IDC_REFRESH, HIDC_REFRESH, |
| 206 | | IDC_RESET_DEFAULT, HIDC_RESET_DEFAULT, |
| 207 | | IDC_RESET_FILTERS, HIDC_RESET_FILTERS, |
| 208 | | IDC_RESET_GAMES, HIDC_RESET_GAMES, |
| 209 | | IDC_RESET_UI, HIDC_RESET_UI, |
| 210 | | IDC_ROTATE, HIDC_ROTATE, |
| 211 | | IDC_SAMPLERATE, HIDC_SAMPLERATE, |
| 212 | | IDC_SAMPLES, HIDC_SAMPLES, |
| 213 | | IDC_SIZES, HIDC_SIZES, |
| 214 | | IDC_START_GAME_CHECK, HIDC_START_GAME_CHECK, |
| 215 | | IDC_SWITCHRES, HIDC_SWITCHRES, |
| 216 | | IDC_SYNCREFRESH, HIDC_SYNCREFRESH, |
| 217 | | IDC_THROTTLE, HIDC_THROTTLE, |
| 218 | | IDC_TRIPLE_BUFFER, HIDC_TRIPLE_BUFFER, |
| 219 | | IDC_USE_DEFAULT, HIDC_USE_DEFAULT, |
| 220 | | IDC_USE_MOUSE, HIDC_USE_MOUSE, |
| 221 | | IDC_USE_SOUND, HIDC_USE_SOUND, |
| 222 | | IDC_VOLUME, HIDC_VOLUME, |
| 223 | | IDC_WAITVSYNC, HIDC_WAITVSYNC, |
| 224 | | IDC_WINDOWED, HIDC_WINDOWED, |
| 225 | | IDC_PAUSEBRIGHT, HIDC_PAUSEBRIGHT, |
| 226 | | IDC_LIGHTGUN, HIDC_LIGHTGUN, |
| 227 | | IDC_STEADYKEY, HIDC_STEADYKEY, |
| 228 | | IDC_JOY_GUI, HIDC_JOY_GUI, |
| 229 | | IDC_RANDOM_BG, HIDC_RANDOM_BG, |
| 230 | | IDC_SKIP_GAME_INFO, HIDC_SKIP_GAME_INFO, |
| 231 | | IDC_HIGH_PRIORITY, HIDC_HIGH_PRIORITY, |
| 232 | | IDC_D3D_FILTER, HIDC_D3D_FILTER, |
| 233 | | IDC_AUDIO_LATENCY, HIDC_AUDIO_LATENCY, |
| 234 | | IDC_BIOS, HIDC_BIOS, |
| 235 | | IDC_STRETCH_SCREENSHOT_LARGER, HIDC_STRETCH_SCREENSHOT_LARGER, |
| 236 | | IDC_SCREEN, HIDC_SCREEN, |
| 237 | | IDC_PADDLE, HIDC_PADDLE, |
| 238 | | IDC_ADSTICK, HIDC_ADSTICK, |
| 239 | | IDC_PEDAL, HIDC_PEDAL, |
| 240 | | IDC_DIAL, HIDC_DIAL, |
| 241 | | IDC_TRACKBALL, HIDC_TRACKBALL, |
| 242 | | IDC_LIGHTGUNDEVICE, HIDC_LIGHTGUNDEVICE, |
| 243 | | IDC_ENABLE_AUTOSAVE, HIDC_ENABLE_AUTOSAVE, |
| 244 | | IDC_MULTITHREAD_RENDERING, HIDC_MULTITHREAD_RENDERING, |
| 245 | | IDC_JSAT, HIDC_JSAT, |
| 246 | | 0, 0 |
| 247 | | }; |
| 248 | | |
| 249 | | static struct ComboBoxVideo |
| 250 | | { |
| 251 | | const TCHAR* m_pText; |
| 252 | | const char* m_pData; |
| 253 | | } g_ComboBoxVideo[] = |
| 254 | | { |
| 255 | | { TEXT("GDI"), "gdi" }, |
| 256 | | { TEXT("DirectDraw"), "ddraw" }, |
| 257 | | { TEXT("Direct3D"), "d3d" }, |
| 258 | | }; |
| 259 | | #define NUMVIDEO (sizeof(g_ComboBoxVideo) / sizeof(g_ComboBoxVideo[0])) |
| 260 | | |
| 261 | | static struct ComboBoxD3DVersion |
| 262 | | { |
| 263 | | const TCHAR* m_pText; |
| 264 | | const int m_pData; |
| 265 | | } g_ComboBoxD3DVersion[] = |
| 266 | | { |
| 267 | | { TEXT("Version 9"), 9 }, |
| 268 | | { TEXT("Version 8"), 8 }, |
| 269 | | }; |
| 270 | | |
| 271 | | #define NUMD3DVERSIONS (sizeof(g_ComboBoxD3DVersion) / sizeof(g_ComboBoxD3DVersion[0])) |
| 272 | | |
| 273 | | static struct ComboBoxSelectScreen |
| 274 | | { |
| 275 | | const TCHAR* m_pText; |
| 276 | | const int m_pData; |
| 277 | | } g_ComboBoxSelectScreen[] = |
| 278 | | { |
| 279 | | { TEXT("Screen 0"), 0 }, |
| 280 | | { TEXT("Screen 1"), 1 }, |
| 281 | | { TEXT("Screen 2"), 2 }, |
| 282 | | { TEXT("Screen 3"), 3 }, |
| 283 | | }; |
| 284 | | #define NUMSELECTSCREEN (sizeof(g_ComboBoxSelectScreen) / sizeof(g_ComboBoxSelectScreen[0])) |
| 285 | | |
| 286 | | static struct ComboBoxView |
| 287 | | { |
| 288 | | const TCHAR* m_pText; |
| 289 | | const char* m_pData; |
| 290 | | } g_ComboBoxView[] = |
| 291 | | { |
| 292 | | { TEXT("Auto"), "auto" }, |
| 293 | | { TEXT("Standard"), "standard" }, |
| 294 | | { TEXT("Pixel Aspect"), "pixel" }, |
| 295 | | { TEXT("Cocktail"), "cocktail" }, |
| 296 | | }; |
| 297 | | #define NUMVIEW (sizeof(g_ComboBoxView) / sizeof(g_ComboBoxView[0])) |
| 298 | | |
| 299 | | |
| 300 | | |
| 301 | | static struct ComboBoxDevices |
| 302 | | { |
| 303 | | const TCHAR* m_pText; |
| 304 | | const char* m_pData; |
| 305 | | } g_ComboBoxDevice[] = |
| 306 | | { |
| 307 | | { TEXT("None"), "none" }, |
| 308 | | { TEXT("Keyboard"), "keyboard" }, |
| 309 | | { TEXT("Mouse"), "mouse" }, |
| 310 | | { TEXT("Joystick"), "joystick" }, |
| 311 | | { TEXT("Lightgun"), "lightgun" }, |
| 312 | | }; |
| 313 | | |
| 314 | | #define NUMDEVICES (sizeof(g_ComboBoxDevice) / sizeof(g_ComboBoxDevice[0])) |
| 315 | | |
| 316 | | /*************************************************************** |
| 317 | | * Public functions |
| 318 | | ***************************************************************/ |
| 319 | | |
| 320 | | void PropertiesInit(void) |
| 321 | | { |
| 322 | | } |
| 323 | | |
| 324 | | int PropertiesCurrentGame(HWND hDlg) |
| 325 | | { |
| 326 | | return g_nGame; |
| 327 | | } |
| 328 | | |
| 329 | | DWORD GetHelpIDs(void) |
| 330 | | { |
| 331 | | return (DWORD) (LPSTR) dwHelpIDs; |
| 332 | | } |
| 333 | | |
| 334 | | // This function (and the code that use it) is a gross hack - but at least the vile |
| 335 | | // and disgusting global variables are gone, making it less gross than what came before |
| 336 | | static int GetSelectedScreen(HWND hWnd) |
| 337 | | { |
| 338 | | int nSelectedScreen = 0; |
| 339 | | HWND hCtrl = GetDlgItem(hWnd, IDC_SCREENSELECT); |
| 340 | | if (hCtrl) |
| 341 | | nSelectedScreen = ComboBox_GetCurSel(hCtrl); |
| 342 | | if ((nSelectedScreen < 0) || (nSelectedScreen >= MAX_SCREENS)) |
| 343 | | nSelectedScreen = 0; |
| 344 | | return nSelectedScreen; |
| 345 | | |
| 346 | | } |
| 347 | | |
| 348 | | static PROPSHEETPAGE *CreatePropSheetPages(HINSTANCE hInst, BOOL bOnlyDefault, |
| 349 | | const game_driver *gamedrv, UINT *pnMaxPropSheets, PROP_SOURCE source ) |
| 350 | | { |
| 351 | | PROPSHEETPAGE *pspages; |
| 352 | | int maxPropSheets; |
| 353 | | int possiblePropSheets; |
| 354 | | int i; |
| 355 | | machine_config drv; |
| 356 | | |
| 357 | | if (gamedrv) |
| 358 | | expand_machine_driver(gamedrv->drv, &drv); |
| 359 | | |
| 360 | | if( source != SRC_GAME ) |
| 361 | | { |
| 362 | | i = 2; |
| 363 | | } |
| 364 | | else |
| 365 | | { |
| 366 | | i = 0; |
| 367 | | } |
| 368 | | for (; g_propSheets[i].pfnDlgProc; i++) |
| 369 | | ; |
| 370 | | |
| 371 | | if( source != SRC_GAME ) |
| 372 | | { |
| 373 | | possiblePropSheets = i - 1; |
| 374 | | } |
| 375 | | else |
| 376 | | { |
| 377 | | possiblePropSheets = i + 1; |
| 378 | | } |
| 379 | | |
| 380 | | pspages = malloc(sizeof(PROPSHEETPAGE) * possiblePropSheets); |
| 381 | | if (!pspages) |
| 382 | | return NULL; |
| 383 | | memset(pspages, 0, sizeof(PROPSHEETPAGE) * possiblePropSheets); |
| 384 | | |
| 385 | | maxPropSheets = 0; |
| 386 | | if( source != SRC_GAME ) |
| 387 | | { |
| 388 | | i = 2; |
| 389 | | } |
| 390 | | else |
| 391 | | { |
| 392 | | i = 0; |
| 393 | | } |
| 394 | | for (; g_propSheets[i].pfnDlgProc; i++) |
| 395 | | { |
| 396 | | if ((gamedrv != NULL) || g_propSheets[i].bOnDefaultPage) |
| 397 | | { |
| 398 | | if (!gamedrv || !g_propSheets[i].pfnFilterProc || g_propSheets[i].pfnFilterProc(&drv, gamedrv)) |
| 399 | | { |
| 400 | | pspages[maxPropSheets].dwSize = sizeof(PROPSHEETPAGE); |
| 401 | | pspages[maxPropSheets].dwFlags = 0; |
| 402 | | pspages[maxPropSheets].hInstance = hInst; |
| 403 | | pspages[maxPropSheets].DUMMYUNIONNAME.pszTemplate = MAKEINTRESOURCE(g_propSheets[i].dwDlgID); |
| 404 | | pspages[maxPropSheets].pfnCallback = NULL; |
| 405 | | pspages[maxPropSheets].lParam = 0; |
| 406 | | pspages[maxPropSheets].pfnDlgProc = g_propSheets[i].pfnDlgProc; |
| 407 | | maxPropSheets++; |
| 408 | | } |
| 409 | | } |
| 410 | | } |
| 411 | | |
| 412 | | if (pnMaxPropSheets) |
| 413 | | *pnMaxPropSheets = maxPropSheets; |
| 414 | | |
| 415 | | return pspages; |
| 416 | | } |
| 417 | | |
| 418 | | void InitDefaultPropertyPage(HINSTANCE hInst, HWND hWnd) |
| 419 | | { |
| 420 | | PROPSHEETHEADER pshead; |
| 421 | | PROPSHEETPAGE *pspage; |
| 422 | | |
| 423 | | // clear globals |
| 424 | | pGameOpts = NULL; |
| 425 | | |
| 426 | | g_nGame = GLOBAL_OPTIONS; |
| 427 | | |
| 428 | | /* Get default options to populate property sheets */ |
| 429 | | pGameOpts = GetDefaultOptions(-1, FALSE); |
| 430 | | g_bUseDefaults = FALSE; |
| 431 | | /* Stash the result for comparing later */ |
| 432 | | origGameOpts = CreateGameOptions(OPTIONS_TYPE_GLOBAL); |
| 433 | | options_copy(origGameOpts, pGameOpts); |
| 434 | | orig_uses_defaults = FALSE; |
| 435 | | g_bReset = FALSE; |
| 436 | | BuildDataMap(); |
| 437 | | |
| 438 | | ZeroMemory(&pshead, sizeof(pshead)); |
| 439 | | |
| 440 | | pspage = CreatePropSheetPages(hInst, TRUE, NULL, &pshead.nPages, SRC_GAME); |
| 441 | | if (!pspage) |
| 442 | | return; |
| 443 | | |
| 444 | | /* Fill in the property sheet header */ |
| 445 | | pshead.hwndParent = hWnd; |
| 446 | | pshead.dwSize = sizeof(PROPSHEETHEADER); |
| 447 | | pshead.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_PROPTITLE; |
| 448 | | pshead.hInstance = hInst; |
| 449 | | pshead.pszCaption = TEXT("Default Game"); |
| 450 | | pshead.DUMMYUNIONNAME2.nStartPage = 0; |
| 451 | | pshead.DUMMYUNIONNAME.pszIcon = MAKEINTRESOURCE(IDI_MAME32_ICON); |
| 452 | | pshead.DUMMYUNIONNAME3.ppsp = pspage; |
| 453 | | |
| 454 | | /* Create the Property sheet and display it */ |
| 455 | | if (PropertySheet(&pshead) == -1) |
| 456 | | { |
| 457 | | char temp[100]; |
| 458 | | DWORD dwError = GetLastError(); |
| 459 | | sprintf(temp, "Propery Sheet Error %d %X", (int)dwError, (int)dwError); |
| 460 | | win_message_box_utf8(0, temp, "Error", IDOK); |
| 461 | | } |
| 462 | | |
| 463 | | free(pspage); |
| 464 | | } |
| 465 | | |
| 466 | | void InitPropertyPage(HINSTANCE hInst, HWND hWnd, int game_num, HICON hIcon, int folder_index, PROP_SOURCE source) |
| 467 | | { |
| 468 | | InitPropertyPageToPage(hInst, hWnd, game_num, hIcon, PROPERTIES_PAGE, folder_index, source); |
| 469 | | } |
| 470 | | |
| 471 | | void InitPropertyPageToPage(HINSTANCE hInst, HWND hWnd, int game_num, HICON hIcon, int start_page, int folder_index, PROP_SOURCE source ) |
| 472 | | { |
| 473 | | PROPSHEETHEADER pshead; |
| 474 | | PROPSHEETPAGE *pspage; |
| 475 | | TCHAR* t_description = 0; |
| 476 | | TCHAR* t_foldername = 0; |
| 477 | | |
| 478 | | // clear globals |
| 479 | | pGameOpts = NULL; |
| 480 | | |
| 481 | | if (highlight_brush == NULL) |
| 482 | | highlight_brush = CreateSolidBrush(HIGHLIGHT_COLOR); |
| 483 | | |
| 484 | | if (background_brush == NULL) |
| 485 | | background_brush = CreateSolidBrush(GetSysColor(COLOR_3DFACE)); |
| 486 | | |
| 487 | | g_hIcon = CopyIcon(hIcon); |
| 488 | | InitGameAudit(game_num); |
| 489 | | g_nGame = game_num; |
| 490 | | g_nFolder = game_num; |
| 491 | | if( source == SRC_GAME ) |
| 492 | | { |
| 493 | | pGameOpts = GetGameOptions(game_num, folder_index); |
| 494 | | g_bUseDefaults = GetGameUsesDefaults(game_num); |
| 495 | | /* Stash the result for comparing later */ |
| 496 | | origGameOpts = CreateGameOptions(game_num); |
| 497 | | options_copy(origGameOpts, pGameOpts); |
| 498 | | g_nFolderGame = game_num; |
| 499 | | g_nPropertyMode = SOURCE_GAME; |
| 500 | | } |
| 501 | | else |
| 502 | | { |
| 503 | | g_nFolderGame = folder_index; |
| 504 | | //For our new scheme to work, we need the possibility to determine whether a sourcefolder contains vector games |
| 505 | | //so we take the selected game in the listview of a source file to check if it is a Vector game |
| 506 | | //this implies that vector games are not mixed up in the source with non-vector games |
| 507 | | //which I think is the case |
| 508 | | if (DriverIsVector( folder_index ) && (game_num != FOLDER_VECTOR ) ) |
| 509 | | { |
| 510 | | GetFolderOptions(game_num, TRUE); |
| 511 | | pGameOpts = GetSourceOptions( folder_index ); |
| 512 | | } |
| 513 | | else |
| 514 | | { |
| 515 | | pGameOpts = GetFolderOptions( game_num, FALSE ); |
| 516 | | } |
| 517 | | if( g_nFolder == FOLDER_VECTOR ) |
| 518 | | { |
| 519 | | g_nPropertyMode = SOURCE_VECTOR; |
| 520 | | g_bUseDefaults = GetVectorUsesDefaults() ? TRUE : FALSE; |
| 521 | | } |
| 522 | | else |
| 523 | | { |
| 524 | | g_nPropertyMode = SOURCE_FOLDER; |
| 525 | | g_bUseDefaults = GetFolderUsesDefaults(g_nFolder, g_nFolderGame) ? TRUE : FALSE; |
| 526 | | } |
| 527 | | if( DriverIsVector( folder_index ) && (game_num != FOLDER_VECTOR ) ) |
| 528 | | { |
| 529 | | pGameOpts =GetFolderOptions(game_num, TRUE); |
| 530 | | //CopyGameOptions(GetSourceOptions( folder_index ), &folder_options[folder_index] ); |
| 531 | | //pGameOpts = &folder_options[folder_index]; |
| 532 | | } |
| 533 | | else |
| 534 | | { |
| 535 | | pGameOpts = GetFolderOptions( game_num, FALSE ); |
| 536 | | } |
| 537 | | /* Stash the result for comparing later */ |
| 538 | | g_nGame = FOLDER_OPTIONS; |
| 539 | | origGameOpts = CreateGameOptions(OPTIONS_TYPE_FOLDER); |
| 540 | | options_copy(origGameOpts, pGameOpts); |
| 541 | | } |
| 542 | | orig_uses_defaults = g_bUseDefaults; |
| 543 | | g_bReset = FALSE; |
| 544 | | BuildDataMap(); |
| 545 | | |
| 546 | | ZeroMemory(&pshead, sizeof(PROPSHEETHEADER)); |
| 547 | | |
| 548 | | if( source == SRC_GAME ) |
| 549 | | { |
| 550 | | pspage = CreatePropSheetPages(hInst, FALSE, drivers[game_num], &pshead.nPages, source); |
| 551 | | } |
| 552 | | else |
| 553 | | { |
| 554 | | pspage = CreatePropSheetPages(hInst, FALSE, NULL, &pshead.nPages, source); |
| 555 | | } |
| 556 | | if (!pspage) |
| 557 | | return; |
| 558 | | |
| 559 | | /* Fill in the property sheet header */ |
| 560 | | pshead.hwndParent = hWnd; |
| 561 | | pshead.dwSize = sizeof(PROPSHEETHEADER); |
| 562 | | pshead.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_PROPTITLE; |
| 563 | | pshead.hInstance = hInst; |
| 564 | | if( source == SRC_GAME ) |
| 565 | | { |
| 566 | | t_description = tstring_from_utf8(ModifyThe(drivers[g_nGame]->description)); |
| 567 | | if( !t_description ) |
| 568 | | return; |
| 569 | | pshead.pszCaption = t_description; |
| 570 | | } |
| 571 | | else |
| 572 | | { |
| 573 | | t_foldername = tstring_from_utf8(GetFolderNameByID(g_nFolder)); |
| 574 | | if( !t_foldername ) |
| 575 | | return; |
| 576 | | pshead.pszCaption = t_foldername; |
| 577 | | } |
| 578 | | pshead.DUMMYUNIONNAME2.nStartPage = start_page; |
| 579 | | pshead.DUMMYUNIONNAME.pszIcon = MAKEINTRESOURCE(IDI_MAME32_ICON); |
| 580 | | pshead.DUMMYUNIONNAME3.ppsp = pspage; |
| 581 | | |
| 582 | | /* Create the Property sheet and display it */ |
| 583 | | if (PropertySheet(&pshead) == -1) |
| 584 | | { |
| 585 | | char temp[100]; |
| 586 | | DWORD dwError = GetLastError(); |
| 587 | | sprintf(temp, "Propery Sheet Error %d %X", (int)dwError, (int)dwError); |
| 588 | | win_message_box_utf8(0, temp, "Error", IDOK); |
| 589 | | } |
| 590 | | |
| 591 | | if( t_foldername ) |
| 592 | | free(t_foldername); |
| 593 | | if( t_description ) |
| 594 | | free(t_description); |
| 595 | | free(pspage); |
| 596 | | } |
| 597 | | |
| 598 | | /********************************************************************* |
| 599 | | * Local Functions |
| 600 | | *********************************************************************/ |
| 601 | | |
| 602 | | /* Build CPU info string */ |
| 603 | | static char *GameInfoCPU(UINT nIndex) |
| 604 | | { |
| 605 | | int i; |
| 606 | | static char buf[1024] = ""; |
| 607 | | machine_config drv; |
| 608 | | expand_machine_driver(drivers[nIndex]->drv,&drv); |
| 609 | | |
| 610 | | ZeroMemory(buf, sizeof(buf)); |
| 611 | | |
| 612 | | cpuintrf_init(NULL); |
| 613 | | |
| 614 | | i = 0; |
| 615 | | while (i < MAX_CPU && drv.cpu[i].cpu_type) |
| 616 | | { |
| 617 | | if (drv.cpu[i].cpu_clock >= 1000000) |
| 618 | | sprintf(&buf[strlen(buf)], "%s %d.%06d MHz", |
| 619 | | cputype_name(drv.cpu[i].cpu_type), |
| 620 | | drv.cpu[i].cpu_clock / 1000000, |
| 621 | | drv.cpu[i].cpu_clock % 1000000); |
| 622 | | else |
| 623 | | sprintf(&buf[strlen(buf)], "%s %d.%03d kHz", |
| 624 | | cputype_name(drv.cpu[i].cpu_type), |
| 625 | | drv.cpu[i].cpu_clock / 1000, |
| 626 | | drv.cpu[i].cpu_clock % 1000); |
| 627 | | |
| 628 | | strcat(buf, "\n"); |
| 629 | | |
| 630 | | i++; |
| 631 | | } |
| 632 | | |
| 633 | | return buf; |
| 634 | | } |
| 635 | | |
| 636 | | /* Build Sound system info string */ |
| 637 | | static char *GameInfoSound(UINT nIndex) |
| 638 | | { |
| 639 | | int i; |
| 640 | | static char buf[1024]; |
| 641 | | machine_config drv; |
| 642 | | expand_machine_driver(drivers[nIndex]->drv,&drv); |
| 643 | | |
| 644 | | buf[0] = 0; |
| 645 | | |
| 646 | | i = 0; |
| 647 | | while (i < MAX_SOUND && drv.sound[i].sound_type) |
| 648 | | { |
| 649 | | int clock,sound_type,count; |
| 650 | | |
| 651 | | sound_type = drv.sound[i].sound_type; |
| 652 | | clock = drv.sound[i].clock; |
| 653 | | |
| 654 | | count = 1; |
| 655 | | i++; |
| 656 | | |
| 657 | | while (i < MAX_SOUND |
| 658 | | && drv.sound[i].sound_type == sound_type |
| 659 | | && drv.sound[i].clock == clock) |
| 660 | | { |
| 661 | | count++; |
| 662 | | i++; |
| 663 | | } |
| 664 | | |
| 665 | | if (count > 1) |
| 666 | | sprintf(&buf[strlen(buf)],"%dx",count); |
| 667 | | |
| 668 | | sprintf(&buf[strlen(buf)],"%s",sndtype_name(sound_type)); |
| 669 | | |
| 670 | | if (clock) |
| 671 | | { |
| 672 | | if (clock >= 1000000) |
| 673 | | sprintf(&buf[strlen(buf)]," %d.%06d MHz", |
| 674 | | clock / 1000000, |
| 675 | | clock % 1000000); |
| 676 | | else |
| 677 | | sprintf(&buf[strlen(buf)]," %d.%03d kHz", |
| 678 | | clock / 1000, |
| 679 | | clock % 1000); |
| 680 | | } |
| 681 | | |
| 682 | | strcat(buf,"\n"); |
| 683 | | } |
| 684 | | |
| 685 | | return buf; |
| 686 | | } |
| 687 | | |
| 688 | | /* Build Display info string */ |
| 689 | | static char *GameInfoScreen(UINT nIndex) |
| 690 | | { |
| 691 | | static char buf[1024]; |
| 692 | | machine_config drv; |
| 693 | | expand_machine_driver(drivers[nIndex]->drv,&drv); |
| 694 | | |
| 695 | | if (drv.video_attributes & VIDEO_TYPE_VECTOR) |
| 696 | | strcpy(buf, "Vector Game"); |
| 697 | | else |
| 698 | | { |
| 699 | | if (drivers[nIndex]->flags & ORIENTATION_SWAP_XY) |
| 700 | | sprintf(buf,"%d x %d (V) %f Hz", |
| 701 | | drv.screen[0].defstate.visarea.max_y - drv.screen[0].defstate.visarea.min_y + 1, |
| 702 | | drv.screen[0].defstate.visarea.max_x - drv.screen[0].defstate.visarea.min_x + 1, |
| 703 | | SUBSECONDS_TO_HZ(drv.screen[0].defstate.refresh)); |
| 704 | | else |
| 705 | | sprintf(buf,"%d x %d (H) %f Hz", |
| 706 | | drv.screen[0].defstate.visarea.max_x - drv.screen[0].defstate.visarea.min_x + 1, |
| 707 | | drv.screen[0].defstate.visarea.max_y - drv.screen[0].defstate.visarea.min_y + 1, |
| 708 | | SUBSECONDS_TO_HZ(drv.screen[0].defstate.refresh)); |
| 709 | | } |
| 710 | | return buf; |
| 711 | | } |
| 712 | | |
| 713 | | /* Build color information string */ |
| 714 | | static char *GameInfoColors(UINT nIndex) |
| 715 | | { |
| 716 | | static char buf[1024]; |
| 717 | | machine_config drv; |
| 718 | | expand_machine_driver(drivers[nIndex]->drv,&drv); |
| 719 | | |
| 720 | | ZeroMemory(buf, sizeof(buf)); |
| 721 | | sprintf(buf, "%d colors ", drv.total_colors); |
| 722 | | |
| 723 | | return buf; |
| 724 | | } |
| 725 | | |
| 726 | | /* Build game status string */ |
| 727 | | const char *GameInfoStatus(int driver_index, BOOL bRomStatus) |
| 728 | | { |
| 729 | | static char buffer[1024]; |
| 730 | | int audit_result = GetRomAuditResults(driver_index); |
| 731 | | memset(buffer,0,sizeof(char)*1024); |
| 732 | | if ( bRomStatus ) |
| 733 | | { |
| 734 | | if (IsAuditResultKnown(audit_result) == FALSE) |
| 735 | | { |
| 736 | | strcpy(buffer, "Unknown"); |
| 737 | | } |
| 738 | | else if (IsAuditResultYes(audit_result)) |
| 739 | | { |
| 740 | | if (DriverIsBroken(driver_index)) |
| 741 | | { |
| 742 | | strcpy(buffer, "Not working"); |
| 743 | | |
| 744 | | if (drivers[driver_index]->flags & GAME_UNEMULATED_PROTECTION) |
| 745 | | { |
| 746 | | if (*buffer != '\0') |
| 747 | | strcat(buffer, "\r\n"); |
| 748 | | strcat(buffer, "Game protection isn't fully emulated"); |
| 749 | | } |
| 750 | | if (drivers[driver_index]->flags & GAME_WRONG_COLORS) |
| 751 | | { |
| 752 | | if (*buffer != '\0') |
| 753 | | strcat(buffer, "\r\n"); |
| 754 | | strcat(buffer, "Colors are completely wrong"); |
| 755 | | } |
| 756 | | if (drivers[driver_index]->flags & GAME_IMPERFECT_COLORS) |
| 757 | | { |
| 758 | | if (*buffer != '\0') |
| 759 | | strcat(buffer, "\r\n"); |
| 760 | | strcat(buffer, "Colors aren't 100% accurate"); |
| 761 | | } |
| 762 | | if (drivers[driver_index]->flags & GAME_IMPERFECT_GRAPHICS) |
| 763 | | { |
| 764 | | if (*buffer != '\0') |
| 765 | | strcat(buffer, "\r\n"); |
| 766 | | strcat(buffer, "Video emulation isn't 100% accurate"); |
| 767 | | } |
| 768 | | if (drivers[driver_index]->flags & GAME_NO_SOUND) |
| 769 | | { |
| 770 | | if (*buffer != '\0') |
| 771 | | strcat(buffer, "\r\n"); |
| 772 | | strcat(buffer, "Game lacks sound"); |
| 773 | | } |
| 774 | | if (drivers[driver_index]->flags & GAME_IMPERFECT_SOUND) |
| 775 | | { |
| 776 | | if (*buffer != '\0') |
| 777 | | strcat(buffer, "\r\n"); |
| 778 | | strcat(buffer, "Sound emulation isn't 100% accurate"); |
| 779 | | } |
| 780 | | if (drivers[driver_index]->flags & GAME_NO_COCKTAIL) |
| 781 | | { |
| 782 | | if (*buffer != '\0') |
| 783 | | strcat(buffer, "\r\n"); |
| 784 | | strcat(buffer, "Screen flipping is not supported"); |
| 785 | | } |
| 786 | | } |
| 787 | | else |
| 788 | | { |
| 789 | | strcpy(buffer, "Working"); |
| 790 | | |
| 791 | | if (drivers[driver_index]->flags & GAME_UNEMULATED_PROTECTION) |
| 792 | | { |
| 793 | | if (*buffer != '\0') |
| 794 | | strcat(buffer, "\r\n"); |
| 795 | | strcat(buffer, "Game protection isn't fully emulated"); |
| 796 | | } |
| 797 | | if (drivers[driver_index]->flags & GAME_WRONG_COLORS) |
| 798 | | { |
| 799 | | if (*buffer != '\0') |
| 800 | | strcat(buffer, "\r\n"); |
| 801 | | strcat(buffer, "Colors are completely wrong"); |
| 802 | | } |
| 803 | | if (drivers[driver_index]->flags & GAME_IMPERFECT_COLORS) |
| 804 | | { |
| 805 | | if (*buffer != '\0') |
| 806 | | strcat(buffer, "\r\n"); |
| 807 | | strcat(buffer, "Colors aren't 100% accurate"); |
| 808 | | } |
| 809 | | if (drivers[driver_index]->flags & GAME_IMPERFECT_GRAPHICS) |
| 810 | | { |
| 811 | | if (*buffer != '\0') |
| 812 | | strcat(buffer, "\r\n"); |
| 813 | | strcat(buffer, "Video emulation isn't 100% accurate"); |
| 814 | | } |
| 815 | | if (drivers[driver_index]->flags & GAME_NO_SOUND) |
| 816 | | { |
| 817 | | if (*buffer != '\0') |
| 818 | | strcat(buffer, "\r\n"); |
| 819 | | strcat(buffer, "Game lacks sound"); |
| 820 | | } |
| 821 | | if (drivers[driver_index]->flags & GAME_IMPERFECT_SOUND) |
| 822 | | { |
| 823 | | if (*buffer != '\0') |
| 824 | | strcat(buffer, "\r\n"); |
| 825 | | strcat(buffer, "Sound emulation isn't 100% accurate"); |
| 826 | | } |
| 827 | | if (drivers[driver_index]->flags & GAME_NO_COCKTAIL) |
| 828 | | { |
| 829 | | if (*buffer != '\0') |
| 830 | | strcat(buffer, "\r\n"); |
| 831 | | strcat(buffer, "Screen flipping is not supported"); |
| 832 | | } |
| 833 | | } |
| 834 | | } |
| 835 | | else |
| 836 | | { |
| 837 | | // audit result is no |
| 838 | | #ifdef MESS |
| 839 | | strcpy(buffer, "BIOS missing"); |
| 840 | | #else |
| 841 | | strcpy(buffer, "ROMs missing"); |
| 842 | | #endif |
| 843 | | } |
| 844 | | } |
| 845 | | else |
| 846 | | { |
| 847 | | //Just show the emulation flags |
| 848 | | if (DriverIsBroken(driver_index)) |
| 849 | | { |
| 850 | | strcpy(buffer, "Not working"); |
| 851 | | } |
| 852 | | else |
| 853 | | { |
| 854 | | strcpy(buffer, "Working"); |
| 855 | | } |
| 856 | | if (drivers[driver_index]->flags & GAME_UNEMULATED_PROTECTION) |
| 857 | | { |
| 858 | | if (*buffer != '\0') |
| 859 | | strcat(buffer, "\r\n"); |
| 860 | | strcat(buffer, "Game protection isn't fully emulated"); |
| 861 | | } |
| 862 | | if (drivers[driver_index]->flags & GAME_WRONG_COLORS) |
| 863 | | { |
| 864 | | if (*buffer != '\0') |
| 865 | | strcat(buffer, "\r\n"); |
| 866 | | strcat(buffer, "Colors are completely wrong"); |
| 867 | | } |
| 868 | | if (drivers[driver_index]->flags & GAME_IMPERFECT_COLORS) |
| 869 | | { |
| 870 | | if (*buffer != '\0') |
| 871 | | strcat(buffer, "\r\n"); |
| 872 | | strcat(buffer, "Colors aren't 100% accurate"); |
| 873 | | } |
| 874 | | if (drivers[driver_index]->flags & GAME_IMPERFECT_GRAPHICS) |
| 875 | | { |
| 876 | | if (*buffer != '\0') |
| 877 | | strcat(buffer, "\r\n"); |
| 878 | | strcat(buffer, "Video emulation isn't 100% accurate"); |
| 879 | | } |
| 880 | | if (drivers[driver_index]->flags & GAME_NO_SOUND) |
| 881 | | { |
| 882 | | if (*buffer != '\0') |
| 883 | | strcat(buffer, "\r\n"); |
| 884 | | strcat(buffer, "Game lacks sound"); |
| 885 | | } |
| 886 | | if (drivers[driver_index]->flags & GAME_IMPERFECT_SOUND) |
| 887 | | { |
| 888 | | if (*buffer != '\0') |
| 889 | | strcat(buffer, "\r\n"); |
| 890 | | strcat(buffer, "Sound emulation isn't 100% accurate"); |
| 891 | | } |
| 892 | | if (drivers[driver_index]->flags & GAME_NO_COCKTAIL) |
| 893 | | { |
| 894 | | if (*buffer != '\0') |
| 895 | | strcat(buffer, "\r\n"); |
| 896 | | strcat(buffer, "Screen flipping is not supported"); |
| 897 | | } |
| 898 | | } |
| 899 | | return buffer; |
| 900 | | } |
| 901 | | |
| 902 | | /* Build game manufacturer string */ |
| 903 | | static char *GameInfoManufactured(UINT nIndex) |
| 904 | | { |
| 905 | | static char buffer[1024]; |
| 906 | | |
| 907 | | snprintf(buffer,sizeof(buffer),"%s %s",drivers[nIndex]->year,drivers[nIndex]->manufacturer); |
| 908 | | return buffer; |
| 909 | | } |
| 910 | | |
| 911 | | /* Build Game title string */ |
| 912 | | char *GameInfoTitle(UINT nIndex) |
| 913 | | { |
| 914 | | static char buf[1024]; |
| 915 | | |
| 916 | | if (nIndex == GLOBAL_OPTIONS) |
| 917 | | strcpy(buf, "Global game options\nDefault options used by all games"); |
| 918 | | else if (nIndex == FOLDER_OPTIONS) |
| 919 | | strcpy(buf, "Global folder options\nDefault options used by all games in the folder"); |
| 920 | | else |
| 921 | | sprintf(buf, "%s\n\"%s\"", ModifyThe(drivers[nIndex]->description), drivers[nIndex]->name); |
| 922 | | return buf; |
| 923 | | } |
| 924 | | |
| 925 | | /* Build game clone infromation string */ |
| 926 | | static char *GameInfoCloneOf(UINT nIndex) |
| 927 | | { |
| 928 | | static char buf[1024]; |
| 929 | | int nParentIndex= -1; |
| 930 | | |
| 931 | | buf[0] = '\0'; |
| 932 | | |
| 933 | | if (DriverIsClone(nIndex)) |
| 934 | | { |
| 935 | | nParentIndex = GetParentIndex(drivers[nIndex]); |
| 936 | | sprintf(buf, "%s - \"%s\"", |
| 937 | | ConvertAmpersandString(ModifyThe(drivers[nParentIndex]->description)), |
| 938 | | drivers[nParentIndex]->name); |
| 939 | | } |
| 940 | | |
| 941 | | return buf; |
| 942 | | } |
| 943 | | |
| 944 | | static const char * GameInfoSource(UINT nIndex) |
| 945 | | { |
| 946 | | return GetDriverFilename(nIndex); |
| 947 | | } |
| 948 | | |
| 949 | | /* Handle the information property page */ |
| 950 | | INT_PTR CALLBACK GamePropertiesDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) |
| 951 | | { |
| 952 | | HWND hWnd; |
| 953 | | switch (Msg) |
| 954 | | { |
| 955 | | case WM_INITDIALOG: |
| 956 | | if (g_hIcon) |
| 957 | | SendDlgItemMessage(hDlg, IDC_GAME_ICON, STM_SETICON, (WPARAM) g_hIcon, 0); |
| 958 | | #if defined(USE_SINGLELINE_TABCONTROL) |
| 959 | | { |
| 960 | | HWND hWnd = PropSheet_GetTabControl(GetParent(hDlg)); |
| 961 | | DWORD tabStyle = (GetWindowLong(hWnd,GWL_STYLE) & ~TCS_MULTILINE); |
| 962 | | SetWindowLong(hWnd,GWL_STYLE,tabStyle | TCS_SINGLELINE); |
| 963 | | } |
| 964 | | #endif |
| 965 | | |
| 966 | | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_TITLE), GameInfoTitle(g_nGame)); |
| 967 | | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_MANUFACTURED), GameInfoManufactured(g_nGame)); |
| 968 | | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_STATUS), GameInfoStatus(g_nGame, FALSE)); |
| 969 | | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_CPU), GameInfoCPU(g_nGame)); |
| 970 | | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_SOUND), GameInfoSound(g_nGame)); |
| 971 | | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_SCREEN), GameInfoScreen(g_nGame)); |
| 972 | | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_COLORS), GameInfoColors(g_nGame)); |
| 973 | | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_CLONEOF), GameInfoCloneOf(g_nGame)); |
| 974 | | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_SOURCE), GameInfoSource(g_nGame)); |
| 975 | | |
| 976 | | if (DriverIsClone(g_nGame)) |
| 977 | | { |
| 978 | | ShowWindow(GetDlgItem(hDlg, IDC_PROP_CLONEOF_TEXT), SW_SHOW); |
| 979 | | } |
| 980 | | else |
| 981 | | { |
| 982 | | ShowWindow(GetDlgItem(hDlg, IDC_PROP_CLONEOF_TEXT), SW_HIDE); |
| 983 | | } |
| 984 | | hWnd = PropSheet_GetTabControl(GetParent(hDlg)); |
| 985 | | UpdateBackgroundBrush(hWnd); |
| 986 | | ShowWindow(hDlg, SW_SHOW); |
| 987 | | return 1; |
| 988 | | |
| 989 | | } |
| 990 | | return 0; |
| 991 | | } |
| 992 | | |
| 993 | | /* Handle all options property pages */ |
| 994 | | INT_PTR CALLBACK GameOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) |
| 995 | | { |
| 996 | | RECT rc; |
| 997 | | int nParentIndex = -1; |
| 998 | | switch (Msg) |
| 999 | | { |
| 1000 | | case WM_INITDIALOG: |
| 1001 | | /* Fill in the Game info at the top of the sheet */ |
| 1002 | | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_TITLE), GameInfoTitle(g_nGame)); |
| 1003 | | InitializeOptions(hDlg); |
| 1004 | | InitializeMisc(hDlg); |
| 1005 | | |
| 1006 | | datamap_populate_all_controls(properties_datamap, hDlg, pGameOpts); |
| 1007 | | OptionsToProp(hDlg, pGameOpts); |
| 1008 | | if( g_nGame >= 0) |
| 1009 | | { |
| 1010 | | g_bUseDefaults = GetGameUsesDefaults(g_nGame); |
| 1011 | | } |
| 1012 | | if( g_nGame == FOLDER_OPTIONS) |
| 1013 | | { |
| 1014 | | if( g_nFolder == FOLDER_VECTOR ) |
| 1015 | | { |
| 1016 | | g_bUseDefaults = GetVectorUsesDefaults() ? TRUE : FALSE; |
| 1017 | | } |
| 1018 | | else |
| 1019 | | { |
| 1020 | | g_bUseDefaults = GetFolderUsesDefaults(g_nFolder, g_nFolderGame) ? TRUE : FALSE; |
| 1021 | | } |
| 1022 | | } |
| 1023 | | SetPropEnabledControls(hDlg); |
| 1024 | | if (g_nGame == GLOBAL_OPTIONS) |
| 1025 | | ShowWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), SW_HIDE); |
| 1026 | | else |
| 1027 | | EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), (g_bUseDefaults) ? FALSE : TRUE); |
| 1028 | | |
| 1029 | | EnableWindow(GetDlgItem(hDlg, IDC_PROP_RESET), g_bReset); |
| 1030 | | ShowWindow(hDlg, SW_SHOW); |
| 1031 | | |
| 1032 | | return 1; |
| 1033 | | |
| 1034 | | case WM_HSCROLL: |
| 1035 | | /* slider changed */ |
| 1036 | | HANDLE_WM_HSCROLL(hDlg, wParam, lParam, OptOnHScroll); |
| 1037 | | g_bUseDefaults = FALSE; |
| 1038 | | g_bReset = TRUE; |
| 1039 | | EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), TRUE); |
| 1040 | | PropSheet_Changed(GetParent(hDlg), hDlg); |
| 1041 | | |
| 1042 | | // make sure everything's copied over, to determine what's changed |
| 1043 | | PropToOptions(hDlg,pGameOpts); |
| 1044 | | datamap_read_all_controls(properties_datamap, hDlg, pGameOpts); |
| 1045 | | // redraw it, it might be a new color now |
| 1046 | | InvalidateRect((HWND)lParam,NULL,TRUE); |
| 1047 | | |
| 1048 | | break; |
| 1049 | | |
| 1050 | | case WM_COMMAND: |
| 1051 | | { |
| 1052 | | /* Below, 'changed' is used to signify the 'Apply' |
| 1053 | | * button should be enabled. |
| 1054 | | */ |
| 1055 | | WORD wID = GET_WM_COMMAND_ID(wParam, lParam); |
| 1056 | | HWND hWndCtrl = GET_WM_COMMAND_HWND(wParam, lParam); |
| 1057 | | WORD wNotifyCode = GET_WM_COMMAND_CMD(wParam, lParam); |
| 1058 | | BOOL changed = FALSE; |
| 1059 | | int nCurSelection = 0; |
| 1060 | | TCHAR szClass[256]; |
| 1061 | | |
| 1062 | | switch (wID) |
| 1063 | | { |
| 1064 | | case IDC_REFRESH: |
| 1065 | | if (wNotifyCode == LBN_SELCHANGE) |
| 1066 | | { |
| 1067 | | RefreshSelectionChange(hDlg, hWndCtrl); |
| 1068 | | changed = TRUE; |
| 1069 | | } |
| 1070 | | break; |
| 1071 | | |
| 1072 | | case IDC_ASPECT: |
| 1073 | | nCurSelection = Button_GetCheck( GetDlgItem(hDlg, IDC_ASPECT)); |
| 1074 | | if( g_bAutoAspect[GetSelectedScreen(hDlg)] != nCurSelection ) |
| 1075 | | { |
| 1076 | | changed = TRUE; |
| 1077 | | g_bAutoAspect[GetSelectedScreen(hDlg)] = nCurSelection; |
| 1078 | | } |
| 1079 | | break; |
| 1080 | | |
| 1081 | | case IDC_SELECT_EFFECT: |
| 1082 | | changed = SelectEffect(hDlg); |
| 1083 | | break; |
| 1084 | | |
| 1085 | | case IDC_RESET_EFFECT: |
| 1086 | | changed = ResetEffect(hDlg); |
| 1087 | | break; |
| 1088 | | |
| 1089 | | case IDC_PROP_RESET: |
| 1090 | | if (wNotifyCode != BN_CLICKED) |
| 1091 | | break; |
| 1092 | | |
| 1093 | | options_copy(pGameOpts, origGameOpts); |
| 1094 | | if (g_nGame > -1) |
| 1095 | | SetGameUsesDefaults(g_nGame,orig_uses_defaults); |
| 1096 | | datamap_populate_all_controls(properties_datamap, hDlg, pGameOpts); |
| 1097 | | OptionsToProp(hDlg, pGameOpts); |
| 1098 | | SetPropEnabledControls(hDlg); |
| 1099 | | g_bReset = FALSE; |
| 1100 | | PropSheet_UnChanged(GetParent(hDlg), hDlg); |
| 1101 | | g_bUseDefaults = orig_uses_defaults; |
| 1102 | | EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), (g_bUseDefaults) ? FALSE : TRUE); |
| 1103 | | break; |
| 1104 | | |
| 1105 | | case IDC_USE_DEFAULT: |
| 1106 | | if (g_nGame != GLOBAL_OPTIONS) |
| 1107 | | { |
| 1108 | | // NPW 20-Apr-2007 - I hate this code. WTF were people thinking! This |
| 1109 | | // code has more spaghetti than the entire nation of Italy |
| 1110 | | if( g_nGame != FOLDER_OPTIONS ) |
| 1111 | | { |
| 1112 | | SetGameUsesDefaults(g_nGame,TRUE); |
| 1113 | | |
| 1114 | | SaveGameOptions(g_nGame); |
| 1115 | | pGameOpts = GetGameOptions(g_nGame, -1); |
| 1116 | | } |
| 1117 | | else |
| 1118 | | { |
| 1119 | | if( g_nFolder == FOLDER_VECTOR) |
| 1120 | | options_copy(pGameOpts, GetDefaultOptions(GLOBAL_OPTIONS, TRUE)); |
| 1121 | | //Not Vector Folder, but Source Folder of Vector Games |
| 1122 | | else if ( DriverIsVector(g_nFolderGame) ) |
| 1123 | | options_copy(pGameOpts, GetVectorOptions()); |
| 1124 | | // every other folder |
| 1125 | | else |
| 1126 | | options_copy(pGameOpts, GetDefaultOptions(GLOBAL_OPTIONS, FALSE)); |
| 1127 | | |
| 1128 | | SaveFolderOptions(g_nFolder, g_nFolderGame); |
| 1129 | | pGameOpts = GetFolderOptions(g_nFolder, (g_nFolder == FOLDER_VECTOR)); |
| 1130 | | } |
| 1131 | | datamap_populate_all_controls(properties_datamap, hDlg, pGameOpts); |
| 1132 | | OptionsToProp(hDlg, pGameOpts); |
| 1133 | | SetPropEnabledControls(hDlg); |
| 1134 | | g_bUseDefaults = TRUE; |
| 1135 | | |
| 1136 | | if (orig_uses_defaults != g_bUseDefaults) |
| 1137 | | { |
| 1138 | | PropSheet_Changed(GetParent(hDlg), hDlg); |
| 1139 | | g_bReset = TRUE; |
| 1140 | | } |
| 1141 | | else |
| 1142 | | { |
| 1143 | | PropSheet_UnChanged(GetParent(hDlg), hDlg); |
| 1144 | | g_bReset = FALSE; |
| 1145 | | } |
| 1146 | | EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), (g_bUseDefaults) ? FALSE : TRUE); |
| 1147 | | } |
| 1148 | | break; |
| 1149 | | |
| 1150 | | case IDC_SCREENSELECT: |
| 1151 | | if ((wNotifyCode == CBN_SELCHANGE) || (wNotifyCode == CBN_SELENDOK)) |
| 1152 | | { |
| 1153 | | changed = datamap_read_control(properties_datamap, hDlg, pGameOpts, wID); |
| 1154 | | datamap_populate_control(properties_datamap, hDlg, pGameOpts, IDC_SCREEN); |
| 1155 | | } |
| 1156 | | break; |
| 1157 | | |
| 1158 | | case IDC_SCREEN: |
| 1159 | | // NPW 3-Apr-2007: Ugh I'm only perpetuating the vile hacks in this code |
| 1160 | | if ((wNotifyCode == CBN_SELCHANGE) || (wNotifyCode == CBN_SELENDOK)) |
| 1161 | | { |
| 1162 | | changed = datamap_read_control(properties_datamap, hDlg, pGameOpts, wID); |
| 1163 | | datamap_populate_control(properties_datamap, hDlg, pGameOpts, IDC_REFRESH); |
| 1164 | | datamap_populate_control(properties_datamap, hDlg, pGameOpts, IDC_SIZES); |
| 1165 | | |
| 1166 | | if (strcmp(options_get_string(pGameOpts, "screen0"), options_get_string(origGameOpts, "screen0")) || |
| 1167 | | strcmp(options_get_string(pGameOpts, "screen1"), options_get_string(origGameOpts, "screen1")) || |
| 1168 | | strcmp(options_get_string(pGameOpts, "screen2"), options_get_string(origGameOpts, "screen2")) || |
| 1169 | | strcmp(options_get_string(pGameOpts, "screen3"), options_get_string(origGameOpts, "screen3"))) |
| 1170 | | { |
| 1171 | | changed = TRUE; |
| 1172 | | } |
| 1173 | | } |
| 1174 | | break; |
| 1175 | | |
| 1176 | | default: |
| 1177 | | #ifdef MESS |
| 1178 | | if (MessPropertiesCommand(hDlg, wNotifyCode, wID, &changed)) |
| 1179 | | break; |
| 1180 | | #endif // MESS |
| 1181 | | |
| 1182 | | // use default behavior; try to get the result out of the datamap if |
| 1183 | | // appropriate |
| 1184 | | GetClassName(hWndCtrl, szClass, ARRAY_LENGTH(szClass)); |
| 1185 | | if (!_tcscmp(szClass, WC_COMBOBOX)) |
| 1186 | | { |
| 1187 | | // combo box |
| 1188 | | if ((wNotifyCode == CBN_SELCHANGE) || (wNotifyCode == CBN_SELENDOK)) |
| 1189 | | { |
| 1190 | | changed = datamap_read_control(properties_datamap, hDlg, pGameOpts, wID); |
| 1191 | | } |
| 1192 | | } |
| 1193 | | else if (!_tcscmp(szClass, WC_BUTTON) && (GetWindowLong(hWndCtrl, GWL_STYLE) & BS_CHECKBOX)) |
| 1194 | | { |
| 1195 | | // check box |
| 1196 | | changed = datamap_read_control(properties_datamap, hDlg, pGameOpts, wID); |
| 1197 | | } |
| 1198 | | break; |
| 1199 | | } |
| 1200 | | |
| 1201 | | if (changed == TRUE) |
| 1202 | | { |
| 1203 | | // enable the apply button |
| 1204 | | if (g_nGame > -1) |
| 1205 | | SetGameUsesDefaults(g_nGame,FALSE); |
| 1206 | | g_bUseDefaults = FALSE; |
| 1207 | | PropSheet_Changed(GetParent(hDlg), hDlg); |
| 1208 | | g_bReset = TRUE; |
| 1209 | | EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), (g_bUseDefaults) ? FALSE : TRUE); |
| 1210 | | } |
| 1211 | | SetPropEnabledControls(hDlg); |
| 1212 | | |
| 1213 | | // make sure everything's copied over, to determine what's changed |
| 1214 | | datamap_read_all_controls(properties_datamap, hDlg, pGameOpts); |
| 1215 | | |
| 1216 | | // redraw it, it might be a new color now |
| 1217 | | if (GetDlgItem(hDlg,wID)) |
| 1218 | | InvalidateRect(GetDlgItem(hDlg,wID),NULL,FALSE); |
| 1219 | | |
| 1220 | | } |
| 1221 | | break; |
| 1222 | | |
| 1223 | | case WM_NOTIFY: |
| 1224 | | { |
| 1225 | | switch (((NMHDR *) lParam)->code) |
| 1226 | | { |
| 1227 | | //We'll need to use a CheckState Table |
| 1228 | | //Because this one gets called for all kinds of other things too, and not only if a check is set |
| 1229 | | case PSN_SETACTIVE: |
| 1230 | | /* Initialize the controls. */ |
| 1231 | | datamap_populate_all_controls(properties_datamap, hDlg, pGameOpts); |
| 1232 | | OptionsToProp(hDlg, pGameOpts); |
| 1233 | | SetPropEnabledControls(hDlg); |
| 1234 | | EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), (g_bUseDefaults) ? FALSE : TRUE); |
| 1235 | | break; |
| 1236 | | |
| 1237 | | case PSN_APPLY: |
| 1238 | | /* Save and apply the options here */ |
| 1239 | | if (g_nGame == GLOBAL_OPTIONS) |
| 1240 | | { |
| 1241 | | pGameOpts = GetDefaultOptions(g_nGame, FALSE); |
| 1242 | | datamap_read_all_controls(properties_datamap, hDlg, pGameOpts); |
| 1243 | | } |
| 1244 | | else if (g_nGame == FOLDER_OPTIONS) |
| 1245 | | { |
| 1246 | | pGameOpts = GetFolderOptions(g_nFolder, (g_nFolder == FOLDER_VECTOR)); |
| 1247 | | datamap_read_all_controls(properties_datamap, hDlg, pGameOpts); |
| 1248 | | SaveFolderOptions(g_nFolder, g_nFolderGame); |
| 1249 | | } |
| 1250 | | else |
| 1251 | | { |
| 1252 | | //SetGameUsesDefaults(g_nGame,g_bUseDefaults); |
| 1253 | | //orig_uses_defaults = g_bUseDefaults; |
| 1254 | | pGameOpts = GetGameOptions(g_nGame, -1); |
| 1255 | | } |
| 1256 | | |
| 1257 | | options_copy(origGameOpts, pGameOpts); |
| 1258 | | |
| 1259 | | datamap_populate_all_controls(properties_datamap, hDlg, pGameOpts); |
| 1260 | | OptionsToProp(hDlg, pGameOpts); |
| 1261 | | SetPropEnabledControls(hDlg); |
| 1262 | | EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), (g_bUseDefaults) ? FALSE : TRUE); |
| 1263 | | g_bReset = FALSE; |
| 1264 | | PropSheet_UnChanged(GetParent(hDlg), hDlg); |
| 1265 | | SetWindowLong(hDlg, DWL_MSGRESULT, TRUE); |
| 1266 | | return PSNRET_NOERROR; |
| 1267 | | |
| 1268 | | case PSN_KILLACTIVE: |
| 1269 | | /* Save Changes to the options here. */ |
| 1270 | | datamap_read_all_controls(properties_datamap, hDlg, pGameOpts); |
| 1271 | | ResetDataMap(hDlg); |
| 1272 | | SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); |
| 1273 | | return 1; |
| 1274 | | |
| 1275 | | case PSN_RESET: |
| 1276 | | // Reset to the original values. Disregard changes |
| 1277 | | options_copy(pGameOpts, origGameOpts); |
| 1278 | | SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); |
| 1279 | | break; |
| 1280 | | |
| 1281 | | case PSN_HELP: |
| 1282 | | // User wants help for this property page |
| 1283 | | break; |
| 1284 | | } |
| 1285 | | } |
| 1286 | | break; |
| 1287 | | case WM_CTLCOLORSTATIC : |
| 1288 | | case WM_CTLCOLOREDIT : |
| 1289 | | if( g_nGame >= 0 ) |
| 1290 | | { |
| 1291 | | if( DriverIsClone(g_nGame) ) |
| 1292 | | { |
| 1293 | | nParentIndex = GetParentIndex( drivers[g_nGame] ); |
| 1294 | | } |
| 1295 | | } |
| 1296 | | //Set the Coloring of the elements |
| 1297 | | if (GetWindowLong((HWND)lParam, GWL_ID) < 0) |
| 1298 | | break; |
| 1299 | | if (IsControlOptionValue(hDlg,(HWND)lParam, GetDefaultOptions( -1, FALSE) ) ) |
| 1300 | | { |
| 1301 | | //Normal Black case |
| 1302 | | SetTextColor((HDC)wParam,COLOR_WINDOWTEXT); |
| 1303 | | } |
| 1304 | | else if (IsControlOptionValue(hDlg,(HWND)lParam, GetVectorOptions() ) && DriverIsVector(g_nFolderGame) ) |
| 1305 | | { |
| 1306 | | SetTextColor((HDC)wParam,VECTOR_COLOR); |
| 1307 | | } |
| 1308 | | else if (IsControlOptionValue(hDlg,(HWND)lParam, GetSourceOptions(g_nFolderGame ) ) ) |
| 1309 | | { |
| 1310 | | SetTextColor((HDC)wParam,FOLDER_COLOR); |
| 1311 | | } |
| 1312 | | else if ((nParentIndex >=0) && (IsControlOptionValue(hDlg,(HWND)lParam, GetGameOptions(nParentIndex, g_nFolder ) ) ) ) |
| 1313 | | { |
| 1314 | | SetTextColor((HDC)wParam,PARENT_COLOR); |
| 1315 | | } |
| 1316 | | // else if ( (g_nGame >= 0) && (IsControlOptionValue(hDlg,(HWND)lParam, GetGameOptions(g_nGame, g_nFolder) ) ) ) |
| 1317 | | else if ( (g_nGame >= 0) && (IsControlOptionValue(hDlg,(HWND)lParam, origGameOpts ) ) ) |
| 1318 | | { |
| 1319 | | SetTextColor((HDC)wParam,GAME_COLOR); |
| 1320 | | } |
| 1321 | | else |
| 1322 | | { |
| 1323 | | switch ( g_nPropertyMode ) |
| 1324 | | { |
| 1325 | | case SOURCE_GAME: |
| 1326 | | SetTextColor((HDC)wParam,GAME_COLOR); |
| 1327 | | break; |
| 1328 | | case SOURCE_FOLDER: |
| 1329 | | SetTextColor((HDC)wParam,FOLDER_COLOR); |
| 1330 | | break; |
| 1331 | | case SOURCE_VECTOR: |
| 1332 | | SetTextColor((HDC)wParam,VECTOR_COLOR); |
| 1333 | | break; |
| 1334 | | default: |
| 1335 | | case SOURCE_GLOBAL: |
| 1336 | | SetTextColor((HDC)wParam,COLOR_WINDOWTEXT); |
| 1337 | | break; |
| 1338 | | } |
| 1339 | | } |
| 1340 | | if( Msg == WM_CTLCOLORSTATIC ) |
| 1341 | | { |
| 1342 | | if (SafeIsAppThemed()) |
| 1343 | | { |
| 1344 | | HWND hWnd = PropSheet_GetTabControl(GetParent(hDlg)); |
| 1345 | | // Set the background mode to transparent |
| 1346 | | SetBkMode((HDC)wParam, TRANSPARENT); |
| 1347 | | |
| 1348 | | // Get the controls window dimensions |
| 1349 | | GetWindowRect((HWND)lParam, &rc); |
| 1350 | | |
| 1351 | | // Map the coordinates to coordinates with the upper left corner of dialog control as base |
| 1352 | | MapWindowPoints(NULL, hWnd, (LPPOINT)(&rc), 2); |
| 1353 | | |
| 1354 | | // Adjust the position of the brush for this control (else we see the top left of the brush as background) |
| 1355 | | SetBrushOrgEx((HDC)wParam, -rc.left, -rc.top, NULL); |
| 1356 | | |
| 1357 | | // Return the brush |
| 1358 | | return (INT_PTR)(hBkBrush); |
| 1359 | | } |
| 1360 | | else |
| 1361 | | { |
| 1362 | | SetBkColor((HDC) wParam,GetSysColor(COLOR_3DFACE) ); |
| 1363 | | } |
| 1364 | | } |
| 1365 | | else |
| 1366 | | SetBkColor((HDC)wParam,RGB(255,255,255) ); |
| 1367 | | UnrealizeObject(background_brush); |
| 1368 | | return (DWORD)background_brush; |
| 1369 | | break; |
| 1370 | | case WM_HELP: |
| 1371 | | /* User clicked the ? from the upper right on a control */ |
| 1372 | | HelpFunction(((LPHELPINFO)lParam)->hItemHandle, MAME32CONTEXTHELP, HH_TP_HELP_WM_HELP, GetHelpIDs()); |
| 1373 | | break; |
| 1374 | | |
| 1375 | | case WM_CONTEXTMENU: |
| 1376 | | HelpFunction((HWND)wParam, MAME32CONTEXTHELP, HH_TP_HELP_CONTEXTMENU, GetHelpIDs()); |
| 1377 | | break; |
| 1378 | | |
| 1379 | | } |
| 1380 | | EnableWindow(GetDlgItem(hDlg, IDC_PROP_RESET), g_bReset); |
| 1381 | | |
| 1382 | | return 0; |
| 1383 | | } |
| 1384 | | |
| 1385 | | /* Read controls that are not handled in the DataMap */ |
| 1386 | | static void PropToOptions(HWND hWnd, core_options *o) |
| 1387 | | { |
| 1388 | | HWND hCtrl; |
| 1389 | | HWND hCtrl2; |
| 1390 | | HWND hCtrl3; |
| 1391 | | |
| 1392 | | if (g_nGame > -1) |
| 1393 | | SetGameUsesDefaults(g_nGame,g_bUseDefaults); |
| 1394 | | |
| 1395 | | /* aspect ratio */ |
| 1396 | | hCtrl = GetDlgItem(hWnd, IDC_ASPECTRATION); |
| 1397 | | hCtrl2 = GetDlgItem(hWnd, IDC_ASPECTRATIOD); |
| 1398 | | hCtrl3 = GetDlgItem(hWnd, IDC_ASPECT); |
| 1399 | | if (hCtrl && hCtrl2 && hCtrl3) |
| 1400 | | { |
| 1401 | | char aspect_option[32]; |
| 1402 | | snprintf(aspect_option, ARRAY_LENGTH(aspect_option), "aspect%d", GetSelectedScreen(hWnd)); |
| 1403 | | |
| 1404 | | if (Button_GetCheck(hCtrl3)) |
| 1405 | | { |
| 1406 | | options_set_string(o, aspect_option, "auto", OPTION_PRIORITY_CMDLINE); |
| 1407 | | } |
| 1408 | | else |
| 1409 | | { |
| 1410 | | int n = 0; |
| 1411 | | int d = 0; |
| 1412 | | TCHAR buffer[200]; |
| 1413 | | char buffer2[200]; |
| 1414 | | |
| 1415 | | Edit_GetText(hCtrl,buffer,sizeof(buffer)); |
| 1416 | | _stscanf(buffer,TEXT("%d"),&n); |
| 1417 | | |
| 1418 | | Edit_GetText(hCtrl2,buffer,sizeof(buffer)); |
| 1419 | | _stscanf(buffer,TEXT("%d"),&d); |
| 1420 | | |
| 1421 | | if (n == 0 || d == 0) |
| 1422 | | { |
| 1423 | | n = 4; |
| 1424 | | d = 3; |
| 1425 | | } |
| 1426 | | |
| 1427 | | snprintf(buffer2,sizeof(buffer2),"%d:%d",n,d); |
| 1428 | | options_set_string(o, aspect_option, buffer2, OPTION_PRIORITY_CMDLINE); |
| 1429 | | } |
| 1430 | | } |
| 1431 | | } |
| 1432 | | |
| 1433 | | /* Populate controls that are not handled in the DataMap */ |
| 1434 | | static void OptionsToProp(HWND hWnd, core_options* o) |
| 1435 | | { |
| 1436 | | HWND hCtrl; |
| 1437 | | HWND hCtrl2; |
| 1438 | | TCHAR buf[100]; |
| 1439 | | int n = 0; |
| 1440 | | int d = 0; |
| 1441 | | |
| 1442 | | /* video */ |
| 1443 | | |
| 1444 | | /* Setup refresh list based on depth. */ |
| 1445 | | datamap_update_control(properties_datamap, hWnd, pGameOpts, IDC_REFRESH); |
| 1446 | | /* Setup Select screen*/ |
| 1447 | | UpdateSelectScreenUI(hWnd ); |
| 1448 | | |
| 1449 | | hCtrl = GetDlgItem(hWnd, IDC_ASPECT); |
| 1450 | | if (hCtrl) |
| 1451 | | { |
| 1452 | | Button_SetCheck(hCtrl, g_bAutoAspect[GetSelectedScreen(hWnd)] ) ; |
| 1453 | | } |
| 1454 | | |
| 1455 | | /* Bios select list */ |
| 1456 | | hCtrl = GetDlgItem(hWnd, IDC_BIOS); |
| 1457 | | if (hCtrl) |
| 1458 | | { |
| 1459 | | const char* cBuffer; |
| 1460 | | int i = 0; |
| 1461 | | int iCount = ComboBox_GetCount( hCtrl ); |
| 1462 | | for( i=0; i< iCount; i++ ) |
| 1463 | | { |
| 1464 | | cBuffer = (const char*)ComboBox_GetItemData( hCtrl, i ); |
| 1465 | | if (strcmp(cBuffer, options_get_string(pGameOpts, OPTION_BIOS) ) == 0) |
| 1466 | | { |
| 1467 | | (void)ComboBox_SetCurSel(hCtrl, i); |
| 1468 | | break; |
| 1469 | | } |
| 1470 | | |
| 1471 | | } |
| 1472 | | } |
| 1473 | | |
| 1474 | | |
| 1475 | | hCtrl = GetDlgItem(hWnd, IDC_ASPECT); |
| 1476 | | if (hCtrl) |
| 1477 | | { |
| 1478 | | char aspect_option[32]; |
| 1479 | | snprintf(aspect_option, ARRAY_LENGTH(aspect_option), "aspect%d", GetSelectedScreen(hWnd)); |
| 1480 | | if( strcmp(options_get_string(o, aspect_option), "auto") == 0) |
| 1481 | | { |
| 1482 | | Button_SetCheck(hCtrl, TRUE); |
| 1483 | | g_bAutoAspect[GetSelectedScreen(hWnd)] = TRUE; |
| 1484 | | } |
| 1485 | | else |
| 1486 | | { |
| 1487 | | Button_SetCheck(hCtrl, FALSE); |
| 1488 | | g_bAutoAspect[GetSelectedScreen(hWnd)] = FALSE; |
| 1489 | | } |
| 1490 | | } |
| 1491 | | |
| 1492 | | /* aspect ratio */ |
| 1493 | | hCtrl = GetDlgItem(hWnd, IDC_ASPECTRATION); |
| 1494 | | hCtrl2 = GetDlgItem(hWnd, IDC_ASPECTRATIOD); |
| 1495 | | if (hCtrl && hCtrl2) |
| 1496 | | { |
| 1497 | | char aspect_option[32]; |
| 1498 | | snprintf(aspect_option, ARRAY_LENGTH(aspect_option), "aspect%d", GetSelectedScreen(hWnd)); |
| 1499 | | |
| 1500 | | n = 0; |
| 1501 | | d = 0; |
| 1502 | | if (options_get_string(o, aspect_option)) |
| 1503 | | { |
| 1504 | | if (sscanf(options_get_string(o, aspect_option), "%d:%d", &n, &d) == 2 && n != 0 && d != 0) |
| 1505 | | { |
| 1506 | | _stprintf(buf, TEXT("%d"), n); |
| 1507 | | Edit_SetText(hCtrl, buf); |
| 1508 | | _stprintf(buf, TEXT("%d"), d); |
| 1509 | | Edit_SetText(hCtrl2, buf); |
| 1510 | | } |
| 1511 | | else |
| 1512 | | { |
| 1513 | | Edit_SetText(hCtrl, TEXT("4")); |
| 1514 | | Edit_SetText(hCtrl2, TEXT("3")); |
| 1515 | | } |
| 1516 | | } |
| 1517 | | else |
| 1518 | | { |
| 1519 | | Edit_SetText(hCtrl, TEXT("4")); |
| 1520 | | Edit_SetText(hCtrl2, TEXT("3")); |
| 1521 | | } |
| 1522 | | } |
| 1523 | | } |
| 1524 | | |
| 1525 | | /* Adjust controls - tune them to the currently selected game */ |
| 1526 | | static void SetPropEnabledControls(HWND hWnd) |
| 1527 | | { |
| 1528 | | HWND hCtrl; |
| 1529 | | int nIndex; |
| 1530 | | int sound; |
| 1531 | | BOOL ddraw = FALSE; |
| 1532 | | BOOL d3d = FALSE; |
| 1533 | | BOOL gdi = FALSE; |
| 1534 | | BOOL useart = TRUE; |
| 1535 | | BOOL multimon = (DirectDraw_GetNumDisplays() >= 2); |
| 1536 | | int joystick_attached = 0; |
| 1537 | | int in_window = 0; |
| 1538 | | |
| 1539 | | nIndex = g_nGame; |
| 1540 | | |
| 1541 | | d3d = !mame_stricmp(options_get_string(pGameOpts, WINOPTION_VIDEO), "d3d"); |
| 1542 | | ddraw = !mame_stricmp(options_get_string(pGameOpts, WINOPTION_VIDEO), "ddraw"); |
| 1543 | | gdi = !d3d && !ddraw; |
| 1544 | | |
| 1545 | | in_window = options_get_bool(pGameOpts, WINOPTION_WINDOW); |
| 1546 | | Button_SetCheck(GetDlgItem(hWnd, IDC_ASPECT), g_bAutoAspect[GetSelectedScreen(hWnd)] ); |
| 1547 | | |
| 1548 | | EnableWindow(GetDlgItem(hWnd, IDC_WAITVSYNC), !gdi); |
| 1549 | | EnableWindow(GetDlgItem(hWnd, IDC_TRIPLE_BUFFER), !gdi); |
| 1550 | | EnableWindow(GetDlgItem(hWnd, IDC_PRESCALE), !gdi); |
| 1551 | | EnableWindow(GetDlgItem(hWnd, IDC_PRESCALEDISP), !gdi); |
| 1552 | | EnableWindow(GetDlgItem(hWnd, IDC_HWSTRETCH), ddraw && DirectDraw_HasHWStretch()); |
| 1553 | | EnableWindow(GetDlgItem(hWnd, IDC_SWITCHRES), TRUE); |
| 1554 | | EnableWindow(GetDlgItem(hWnd, IDC_SYNCREFRESH), TRUE); |
| 1555 | | EnableWindow(GetDlgItem(hWnd, IDC_REFRESH), !in_window ); |
| 1556 | | EnableWindow(GetDlgItem(hWnd, IDC_REFRESHTEXT), !in_window ); |
| 1557 | | EnableWindow(GetDlgItem(hWnd, IDC_FSGAMMA), !in_window); |
| 1558 | | EnableWindow(GetDlgItem(hWnd, IDC_FSGAMMATEXT), !in_window); |
| 1559 | | EnableWindow(GetDlgItem(hWnd, IDC_FSGAMMADISP), !in_window); |
| 1560 | | EnableWindow(GetDlgItem(hWnd, IDC_FSBRIGHTNESS), !in_window); |
| 1561 | | EnableWindow(GetDlgItem(hWnd, IDC_FSBRIGHTNESSTEXT), !in_window); |
| 1562 | | EnableWindow(GetDlgItem(hWnd, IDC_FSBRIGHTNESSDISP), !in_window); |
| 1563 | | EnableWindow(GetDlgItem(hWnd, IDC_FSCONTRAST), !in_window); |
| 1564 | | EnableWindow(GetDlgItem(hWnd, IDC_FSCONTRASTTEXT), !in_window); |
| 1565 | | EnableWindow(GetDlgItem(hWnd, IDC_FSCONTRASTDISP), !in_window); |
| 1566 | | |
| 1567 | | EnableWindow(GetDlgItem(hWnd, IDC_ASPECTRATIOTEXT), !g_bAutoAspect[GetSelectedScreen(hWnd)]); |
| 1568 | | EnableWindow(GetDlgItem(hWnd, IDC_ASPECTRATION), !g_bAutoAspect[GetSelectedScreen(hWnd)]); |
| 1569 | | EnableWindow(GetDlgItem(hWnd, IDC_ASPECTRATIOD), !g_bAutoAspect[GetSelectedScreen(hWnd)]); |
| 1570 | | |
| 1571 | | EnableWindow(GetDlgItem(hWnd,IDC_D3D_FILTER),d3d); |
| 1572 | | EnableWindow(GetDlgItem(hWnd,IDC_D3D_VERSION),d3d); |
| 1573 | | |
| 1574 | | //Switchres and D3D or ddraw enable the per screen parameters |
| 1575 | | |
| 1576 | | EnableWindow(GetDlgItem(hWnd, IDC_NUMSCREENS), (ddraw || d3d) && multimon); |
| 1577 | | EnableWindow(GetDlgItem(hWnd, IDC_NUMSCREENSDISP), (ddraw || d3d) && multimon); |
| 1578 | | EnableWindow(GetDlgItem(hWnd, IDC_SCREENSELECT), (ddraw || d3d) && multimon); |
| 1579 | | EnableWindow(GetDlgItem(hWnd, IDC_SCREENSELECTTEXT), (ddraw || d3d) && multimon); |
| 1580 | | |
| 1581 | | EnableWindow(GetDlgItem(hWnd, IDC_ARTWORK_CROP), useart); |
| 1582 | | EnableWindow(GetDlgItem(hWnd, IDC_BACKDROPS), useart); |
| 1583 | | EnableWindow(GetDlgItem(hWnd, IDC_BEZELS), useart); |
| 1584 | | EnableWindow(GetDlgItem(hWnd, IDC_OVERLAYS), useart); |
| 1585 | | EnableWindow(GetDlgItem(hWnd, IDC_ARTMISCTEXT), useart); |
| 1586 | | |
| 1587 | | /* Joystick options */ |
| 1588 | | joystick_attached = DIJoystick.Available(); |
| 1589 | | |
| 1590 | | Button_Enable(GetDlgItem(hWnd,IDC_JOYSTICK), joystick_attached); |
| 1591 | | EnableWindow(GetDlgItem(hWnd, IDC_JDZTEXT), joystick_attached); |
| 1592 | | EnableWindow(GetDlgItem(hWnd, IDC_JDZDISP), joystick_attached); |
| 1593 | | EnableWindow(GetDlgItem(hWnd, IDC_JDZ), joystick_attached); |
| 1594 | | EnableWindow(GetDlgItem(hWnd, IDC_JSATTEXT), joystick_attached); |
| 1595 | | EnableWindow(GetDlgItem(hWnd, IDC_JSATDISP), joystick_attached); |
| 1596 | | EnableWindow(GetDlgItem(hWnd, IDC_JSAT), joystick_attached); |
| 1597 | | /* Trackball / Mouse options */ |
| 1598 | | if (nIndex <= -1 || DriverUsesTrackball(nIndex) || DriverUsesLightGun(nIndex)) |
| 1599 | | Button_Enable(GetDlgItem(hWnd,IDC_USE_MOUSE),TRUE); |
| 1600 | | else |
| 1601 | | Button_Enable(GetDlgItem(hWnd,IDC_USE_MOUSE),FALSE); |
| 1602 | | |
| 1603 | | if (!in_window && (nIndex <= -1 || DriverUsesLightGun(nIndex))) |
| 1604 | | { |
| 1605 | | // on WinXP the Lightgun and Dual Lightgun switches are no longer supported use mouse instead |
| 1606 | | OSVERSIONINFOEX osvi; |
| 1607 | | BOOL bOsVersionInfoEx; |
| 1608 | | // Try calling GetVersionEx using the OSVERSIONINFOEX structure. |
| 1609 | | // If that fails, try using the OSVERSIONINFO structure. |
| 1610 | | |
| 1611 | | ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); |
| 1612 | | osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); |
| 1613 | | |
| 1614 | | if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) ) |
| 1615 | | { |
| 1616 | | osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); |
| 1617 | | bOsVersionInfoEx = GetVersionEx ( (OSVERSIONINFO *) &osvi); |
| 1618 | | } |
| 1619 | | |
| 1620 | | if( bOsVersionInfoEx && (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) && (osvi.dwMajorVersion >= 5) ) |
| 1621 | | { |
| 1622 | | BOOL use_lightgun; |
| 1623 | | //XP and above... |
| 1624 | | Button_Enable(GetDlgItem(hWnd,IDC_LIGHTGUN),FALSE); |
| 1625 | | use_lightgun = Button_GetCheck(GetDlgItem(hWnd,IDC_USE_MOUSE)); |
| 1626 | | Button_Enable(GetDlgItem(hWnd,IDC_DUAL_LIGHTGUN),FALSE); |
| 1627 | | Button_Enable(GetDlgItem(hWnd,IDC_RELOAD),use_lightgun); |
| 1628 | | } |
| 1629 | | else |
| 1630 | | { |
| 1631 | | BOOL use_lightgun; |
| 1632 | | // Older than XP |
| 1633 | | Button_Enable(GetDlgItem(hWnd,IDC_LIGHTGUN),TRUE); |
| 1634 | | use_lightgun = Button_GetCheck(GetDlgItem(hWnd,IDC_LIGHTGUN)); |
| 1635 | | Button_Enable(GetDlgItem(hWnd,IDC_DUAL_LIGHTGUN),use_lightgun); |
| 1636 | | Button_Enable(GetDlgItem(hWnd,IDC_RELOAD),use_lightgun); |
| 1637 | | } |
| 1638 | | } |
| 1639 | | else |
| 1640 | | { |
| 1641 | | Button_Enable(GetDlgItem(hWnd,IDC_LIGHTGUN),FALSE); |
| 1642 | | Button_Enable(GetDlgItem(hWnd,IDC_DUAL_LIGHTGUN),FALSE); |
| 1643 | | Button_Enable(GetDlgItem(hWnd,IDC_RELOAD),FALSE); |
| 1644 | | } |
| 1645 | | |
| 1646 | | |
| 1647 | | /* Sound options */ |
| 1648 | | hCtrl = GetDlgItem(hWnd, IDC_USE_SOUND); |
| 1649 | | if (hCtrl) |
| 1650 | | { |
| 1651 | | sound = Button_GetCheck(hCtrl); |
| 1652 | | ComboBox_Enable(GetDlgItem(hWnd, IDC_SAMPLERATE), (sound != 0)); |
| 1653 | | |
| 1654 | | EnableWindow(GetDlgItem(hWnd,IDC_VOLUME),sound); |
| 1655 | | EnableWindow(GetDlgItem(hWnd,IDC_RATETEXT),sound); |
| 1656 | | EnableWindow(GetDlgItem(hWnd,IDC_VOLUMEDISP),sound); |
| 1657 | | EnableWindow(GetDlgItem(hWnd,IDC_VOLUMETEXT),sound); |
| 1658 | | EnableWindow(GetDlgItem(hWnd,IDC_AUDIO_LATENCY),sound); |
| 1659 | | EnableWindow(GetDlgItem(hWnd,IDC_AUDIO_LATENCY_DISP),sound); |
| 1660 | | EnableWindow(GetDlgItem(hWnd,IDC_AUDIO_LATENCY_TEXT),sound); |
| 1661 | | SetSamplesEnabled(hWnd, nIndex, sound); |
| 1662 | | SetStereoEnabled(hWnd, nIndex); |
| 1663 | | SetYM3812Enabled(hWnd, nIndex); |
| 1664 | | } |
| 1665 | | |
| 1666 | | if (Button_GetCheck(GetDlgItem(hWnd, IDC_AUTOFRAMESKIP))) |
| 1667 | | EnableWindow(GetDlgItem(hWnd, IDC_FRAMESKIP), FALSE); |
| 1668 | | else |
| 1669 | | EnableWindow(GetDlgItem(hWnd, IDC_FRAMESKIP), TRUE); |
| 1670 | | |
| 1671 | | if (nIndex <= -1 || DriverHasOptionalBIOS(nIndex)) |
| 1672 | | EnableWindow(GetDlgItem(hWnd,IDC_BIOS),TRUE); |
| 1673 | | else |
| 1674 | | EnableWindow(GetDlgItem(hWnd,IDC_BIOS),FALSE); |
| 1675 | | |
| 1676 | | } |
| 1677 | | |
| 1678 | | //============================================================ |
| 1679 | | // CONTROL HELPER FUNCTIONS FOR DATA EXCHANGE |
| 1680 | | //============================================================ |
| 1681 | | |
| 1682 | | static void RotateReadControl(datamap *map, HWND dialog, HWND control, core_options *opts, const char *option_name) |
| 1683 | | { |
| 1684 | | int selected_index = ComboBox_GetCurSel(control); |
| 1685 | | options_set_bool(opts, OPTION_ROR, selected_index == 1, OPTION_PRIORITY_CMDLINE); |
| 1686 | | options_set_bool(opts, OPTION_ROL, selected_index == 2, OPTION_PRIORITY_CMDLINE); |
| 1687 | | options_set_bool(opts, OPTION_ROTATE, selected_index != 3, OPTION_PRIORITY_CMDLINE); |
| 1688 | | options_set_bool(opts, OPTION_AUTOROR, selected_index == 4, OPTION_PRIORITY_CMDLINE); |
| 1689 | | options_set_bool(opts, OPTION_AUTOROL, selected_index == 5, OPTION_PRIORITY_CMDLINE); |
| 1690 | | } |
| 1691 | | |
| 1692 | | |
| 1693 | | |
| 1694 | | static void RotatePopulateControl(datamap *map, HWND dialog, HWND control, core_options *opts, const char *option_name) |
| 1695 | | { |
| 1696 | | int selected_index = 0; |
| 1697 | | if (options_get_bool(opts, OPTION_ROR) && !options_get_bool(opts, OPTION_ROL)) |
| 1698 | | selected_index = 1; |
| 1699 | | else if (!options_get_bool(opts, OPTION_ROR) && options_get_bool(opts, OPTION_ROL)) |
| 1700 | | selected_index = 2; |
| 1701 | | else if (!options_get_bool(opts, OPTION_ROTATE)) |
| 1702 | | selected_index = 3; |
| 1703 | | else if (options_get_bool(opts, OPTION_AUTOROR)) |
| 1704 | | selected_index = 4; |
| 1705 | | else if (options_get_bool(opts, OPTION_AUTOROL)) |
| 1706 | | selected_index = 5; |
| 1707 | | |
| 1708 | | (void)ComboBox_SetCurSel(control, selected_index); |
| 1709 | | } |
| 1710 | | |
| 1711 | | |
| 1712 | | |
| 1713 | | static void ScreenReadControl(datamap *map, HWND dialog, HWND control, core_options *opts, const char *option_name) |
| 1714 | | { |
| 1715 | | char screen_option_name[32]; |
| 1716 | | const char *screen_option_value; |
| 1717 | | int selected_screen; |
| 1718 | | int screen_option_index; |
| 1719 | | |
| 1720 | | selected_screen = GetSelectedScreen(dialog); |
| 1721 | | screen_option_index = ComboBox_GetCurSel(control); |
| 1722 | | screen_option_value = (const char *) ComboBox_GetItemData(control, screen_option_index); |
| 1723 | | snprintf(screen_option_name, ARRAY_LENGTH(screen_option_name), "screen%d", selected_screen); |
| 1724 | | options_set_string(opts, screen_option_name, screen_option_value, OPTION_PRIORITY_CMDLINE); |
| 1725 | | } |
| 1726 | | |
| 1727 | | |
| 1728 | | |
| 1729 | | static void ScreenPopulateControl(datamap *map, HWND dialog, HWND control, core_options *opts, const char *option_name) |
| 1730 | | { |
| 1731 | | int iMonitors; |
| 1732 | | DISPLAY_DEVICE dd; |
| 1733 | | int i = 0; |
| 1734 | | int nSelection = 0; |
| 1735 | | TCHAR* t_option = 0; |
| 1736 | | |
| 1737 | | /* Remove all items in the list. */ |
| 1738 | | (void)ComboBox_ResetContent(control); |
| 1739 | | (void)ComboBox_InsertString(control, 0, TEXT("Auto")); |
| 1740 | | (void)ComboBox_SetItemData(control, 0, (const char*)mame_strdup("auto")); |
| 1741 | | |
| 1742 | | //Dynamically populate it, by enumerating the Monitors |
| 1743 | | iMonitors = GetSystemMetrics(SM_CMONITORS); // this gets the count of monitors attached |
| 1744 | | ZeroMemory(&dd, sizeof(dd)); |
| 1745 | | dd.cb = sizeof(dd); |
| 1746 | | for(i=0; EnumDisplayDevices(NULL, i, &dd, 0); i++) |
| 1747 | | { |
| 1748 | | if( !(dd.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) ) |
| 1749 | | { |
| 1750 | | char screen_option[32]; |
| 1751 | | |
| 1752 | | //we have to add 1 to account for the "auto" entry |
| 1753 | | (void)ComboBox_InsertString(control, i+1, win_tstring_strdup(dd.DeviceName)); |
| 1754 | | (void)ComboBox_SetItemData(control, i+1, (void*)win_tstring_strdup(dd.DeviceName)); |
| 1755 | | |
| 1756 | | snprintf(screen_option, ARRAY_LENGTH(screen_option), "screen%d", GetSelectedScreen(dialog)); |
| 1757 | | t_option = tstring_from_utf8(options_get_string(opts, screen_option)); |
| 1758 | | if( !t_option ) |
| 1759 | | return; |
| 1760 | | if (_tcscmp(t_option, dd.DeviceName) == 0) |
| 1761 | | nSelection = i+1; |
| 1762 | | free(t_option); |
| 1763 | | } |
| 1764 | | } |
| 1765 | | (void)ComboBox_SetCurSel(control, nSelection); |
| 1766 | | } |
| 1767 | | |
| 1768 | | |
| 1769 | | |
| 1770 | | static void ViewSetOptionName(datamap *map, HWND dialog, HWND control, char *buffer, size_t buffer_size) |
| 1771 | | { |
| 1772 | | snprintf(buffer, buffer_size, "view%d", GetSelectedScreen(dialog)); |
| 1773 | | } |
| 1774 | | |
| 1775 | | |
| 1776 | | |
| 1777 | | static void ViewPopulateControl(datamap *map, HWND dialog, HWND control, core_options *opts, const char *option_name) |
| 1778 | | { |
| 1779 | | int i; |
| 1780 | | int selected_index = 0; |
| 1781 | | char view_option[32]; |
| 1782 | | const char *view; |
| 1783 | | |
| 1784 | | // determine the view option value |
| 1785 | | snprintf(view_option, ARRAY_LENGTH(view_option), "view%d", GetSelectedScreen(dialog)); |
| 1786 | | view = options_get_string(opts, view_option); |
| 1787 | | |
| 1788 | | (void)ComboBox_ResetContent(control); |
| 1789 | | for (i = 0; i < NUMVIEW; i++) |
| 1790 | | { |
| 1791 | | (void)ComboBox_InsertString(control, i, g_ComboBoxView[i].m_pText); |
| 1792 | | (void)ComboBox_SetItemData(control, i, g_ComboBoxView[i].m_pData); |
| 1793 | | |
| 1794 | | if (!strcmp(view, g_ComboBoxView[i].m_pData)) |
| 1795 | | selected_index = i; |
| 1796 | | } |
| 1797 | | (void)ComboBox_SetCurSel(control, selected_index); |
| 1798 | | } |
| 1799 | | |
| 1800 | | |
| 1801 | | |
| 1802 | | static void DefaultInputPopulateControl(datamap *map, HWND dialog, HWND control, core_options *opts, const char *option_name) |
| 1803 | | { |
| 1804 | | WIN32_FIND_DATA FindFileData; |
| 1805 | | HANDLE hFind; |
| 1806 | | TCHAR *ext; |
| 1807 | | TCHAR root[256]; |
| 1808 | | TCHAR path[256]; |
| 1809 | | int selected = 0; |
| 1810 | | int index = 0; |
| 1811 | | LPCTSTR t_ctrlr_option = 0; |
| 1812 | | LPTSTR buf = 0; |
| 1813 | | const char *ctrlr_option; |
| 1814 | | TCHAR* t_ctrldir; |
| 1815 | | |
| 1816 | | // determine the ctrlr option |
| 1817 | | ctrlr_option = options_get_string(opts, OPTION_CTRLR); |
| 1818 | | if( ctrlr_option != NULL ) { |
| 1819 | | buf = tstring_from_utf8(ctrlr_option); |
| 1820 | | if( !buf ) |
| 1821 | | return; |
| 1822 | | t_ctrlr_option = buf; |
| 1823 | | } |
| 1824 | | else { |
| 1825 | | t_ctrlr_option = TEXT(""); |
| 1826 | | } |
| 1827 | | |
| 1828 | | // reset the controllers dropdown |
| 1829 | | (void)ComboBox_ResetContent(control); |
| 1830 | | (void)ComboBox_InsertString(control, index, TEXT("Standard")); |
| 1831 | | (void)ComboBox_SetItemData(control, index, ""); |
| 1832 | | index++; |
| 1833 | | |
| 1834 | | t_ctrldir = tstring_from_utf8(GetCtrlrDir()); |
| 1835 | | if( !t_ctrldir ) { |
| 1836 | | if( buf ) |
| 1837 | | free(buf); |
| 1838 | | return; |
| 1839 | | } |
| 1840 | | |
| 1841 | | _stprintf (path, TEXT("%s\\*.*"), t_ctrldir); |
| 1842 | | |
| 1843 | | free(t_ctrldir); |
| 1844 | | |
| 1845 | | hFind = FindFirstFile(path, &FindFileData); |
| 1846 | | |
| 1847 | | if (hFind != INVALID_HANDLE_VALUE) |
| 1848 | | { |
| 1849 | | do |
| 1850 | | { |
| 1851 | | // copy the filename |
| 1852 | | _tcscpy (root,FindFileData.cFileName); |
| 1853 | | |
| 1854 | | // find the extension |
| 1855 | | ext = _tcsrchr (root,'.'); |
| 1856 | | if (ext) |
| 1857 | | { |
| 1858 | | // check if it's a cfg file |
| 1859 | | if (_tcscmp (ext, TEXT(".cfg")) == 0) |
| 1860 | | { |
| 1861 | | // and strip off the extension |
| 1862 | | *ext = 0; |
| 1863 | | |
| 1864 | | // set the option? |
| 1865 | | if (!_tcscmp(root, t_ctrlr_option)) |
| 1866 | | selected = index; |
| 1867 | | |
| 1868 | | // add it as an option |
| 1869 | | (void)ComboBox_InsertString(control, index, root); |
| 1870 | | (void)ComboBox_SetItemData(control, index, (void*)win_tstring_strdup(root)); // FIXME - leaks memory! |
| 1871 | | index++; |
| 1872 | | } |
| 1873 | | } |
| 1874 | | } |
| 1875 | | while (FindNextFile (hFind, &FindFileData) != 0); |
| 1876 | | |
| 1877 | | FindClose (hFind); |
| 1878 | | } |
| 1879 | | |
| 1880 | | (void)ComboBox_SetCurSel(control, selected); |
| 1881 | | |
| 1882 | | if( buf ) |
| 1883 | | free(buf); |
| 1884 | | } |
| 1885 | | |
| 1886 | | |
| 1887 | | |
| 1888 | | static void ResolutionSetOptionName(datamap *map, HWND dialog, HWND control, char *buffer, size_t buffer_size) |
| 1889 | | { |
| 1890 | | snprintf(buffer, buffer_size, "resolution%d", GetSelectedScreen(dialog)); |
| 1891 | | } |
| 1892 | | |
| 1893 | | |
| 1894 | | |
| 1895 | | static void ResolutionReadControl(datamap *map, HWND dialog, HWND control, core_options *opts, const char *option_name) |
| 1896 | | { |
| 1897 | | HWND refresh_control = GetDlgItem(dialog, IDC_REFRESH); |
| 1898 | | HWND sizes_control = GetDlgItem(dialog, IDC_SIZES); |
| 1899 | | int refresh_index, refresh_value, width, height; |
| 1900 | | char option_value[256]; |
| 1901 | | TCHAR buffer[256]; |
| 1902 | | |
| 1903 | | if (refresh_control && sizes_control) |
| 1904 | | { |
| 1905 | | (void)ComboBox_GetText(sizes_control, buffer, ARRAY_LENGTH(buffer) - 1); |
| 1906 | | if (_stscanf(buffer, TEXT("%d x %d"), &width, &height) == 2) |
| 1907 | | { |
| 1908 | | refresh_index = ComboBox_GetCurSel(refresh_control); |
| 1909 | | refresh_value = ComboBox_GetItemData(refresh_control, refresh_index); |
| 1910 | | snprintf(option_value, ARRAY_LENGTH(option_value), "%dx%d@%d", width, height, refresh_value); |
| 1911 | | } |
| 1912 | | else |
| 1913 | | { |
| 1914 | | snprintf(option_value, ARRAY_LENGTH(option_value), "auto"); |
| 1915 | | } |
| 1916 | | options_set_string(opts, option_name, option_value, OPTION_PRIORITY_CMDLINE); |
| 1917 | | } |
| 1918 | | } |
| 1919 | | |
| 1920 | | |
| 1921 | | |
| 1922 | | static void ResolutionPopulateControl(datamap *map, HWND dialog, HWND control_, core_options *opts, const char *option_name) |
| 1923 | | { |
| 1924 | | HWND sizes_control = GetDlgItem(dialog, IDC_SIZES); |
| 1925 | | HWND refresh_control = GetDlgItem(dialog, IDC_REFRESH); |
| 1926 | | int width, height, refresh; |
| 1927 | | const char *option_value; |
| 1928 | | int sizes_index = 0; |
| 1929 | | int refresh_index = 0; |
| 1930 | | int sizes_selection = 0; |
| 1931 | | int refresh_selection = 0; |
| 1932 | | char screen_option[32]; |
| 1933 | | const char *screen; |
| 1934 | | LPTSTR t_screen; |
| 1935 | | TCHAR buf[16]; |
| 1936 | | int i; |
| 1937 | | DEVMODE devmode; |
| 1938 | | |
| 1939 | | if (sizes_control && refresh_control) |
| 1940 | | { |
| 1941 | | // determine the resolution |
| 1942 | | option_value = options_get_string(opts, option_name); |
| 1943 | | if (sscanf(option_value, "%dx%d@%d", &width, &height, &refresh) != 3) |
| 1944 | | { |
| 1945 | | width = 0; |
| 1946 | | height = 0; |
| 1947 | | refresh = 0; |
| 1948 | | } |
| 1949 | | |
| 1950 | | // reset sizes control |
| 1951 | | (void)ComboBox_ResetContent(sizes_control); |
| 1952 | | (void)ComboBox_InsertString(sizes_control, sizes_index, TEXT("Auto")); |
| 1953 | | (void)ComboBox_SetItemData(sizes_control, sizes_index, 0); |
| 1954 | | sizes_index++; |
| 1955 | | |
| 1956 | | // reset refresh control |
| 1957 | | (void)ComboBox_ResetContent(refresh_control); |
| 1958 | | (void)ComboBox_InsertString(refresh_control, refresh_index, TEXT("Auto")); |
| 1959 | | (void)ComboBox_SetItemData(refresh_control, refresh_index, 0); |
| 1960 | | refresh_index++; |
| 1961 | | |
| 1962 | | // determine which screen we're using |
| 1963 | | snprintf(screen_option, ARRAY_LENGTH(screen_option), "screen%d", GetSelectedScreen(dialog)); |
| 1964 | | screen = options_get_string(opts, screen_option); |
| 1965 | | t_screen = tstring_from_utf8(screen); |
| 1966 | | |
| 1967 | | // retrieve screen information |
| 1968 | | devmode.dmSize = sizeof(devmode); |
| 1969 | | for (i = 0; EnumDisplaySettings(t_screen, i, &devmode); i++) |
| 1970 | | { |
| 1971 | | if ((devmode.dmBitsPerPel == 32 ) // Only 32 bit depth supported by core |
| 1972 | | &&(devmode.dmDisplayFrequency == refresh || refresh == 0)) |
| 1973 | | { |
| 1974 | | _sntprintf(buf, ARRAY_LENGTH(buf), TEXT("%li x %li"), |
| 1975 | | devmode.dmPelsWidth, devmode.dmPelsHeight); |
| 1976 | | |
| 1977 | | if (ComboBox_FindString(sizes_control, 0, buf) == CB_ERR) |
| 1978 | | { |
| 1979 | | (void)ComboBox_InsertString(sizes_control, sizes_index, buf); |
| 1980 | | |
| 1981 | | if ((width == devmode.dmPelsWidth) && (height == devmode.dmPelsHeight)) |
| 1982 | | sizes_selection = sizes_index; |
| 1983 | | sizes_index++; |
| 1984 | | |
| 1985 | | } |
| 1986 | | } |
| 1987 | | if (devmode.dmDisplayFrequency >= 10 ) |
| 1988 | | { |
| 1989 | | // I have some devmode "vga" which specifes 1 Hz, which is probably bogus, so we filter it out |
| 1990 | | |
| 1991 | | _sntprintf(buf, ARRAY_LENGTH(buf), TEXT("%li Hz"), devmode.dmDisplayFrequency); |
| 1992 | | |
| 1993 | | if (ComboBox_FindString(refresh_control, 0, buf) == CB_ERR) |
| 1994 | | { |
| 1995 | | (void)ComboBox_InsertString(refresh_control, refresh_index, buf); |
| 1996 | | (void)ComboBox_SetItemData(refresh_control, refresh_index, devmode.dmDisplayFrequency); |
| 1997 | | |
| 1998 | | if (refresh == devmode.dmDisplayFrequency) |
| 1999 | | refresh_selection = refresh_index; |
| 2000 | | |
| 2001 | | refresh_index++; |
| 2002 | | } |
| 2003 | | } |
| 2004 | | } |
| 2005 | | free(t_screen); |
| 2006 | | |
| 2007 | | (void)ComboBox_SetCurSel(sizes_control, sizes_selection); |
| 2008 | | (void)ComboBox_SetCurSel(refresh_control, refresh_selection); |
| 2009 | | } |
| 2010 | | } |
| 2011 | | |
| 2012 | | |
| 2013 | | |
| 2014 | | //============================================================ |
| 2015 | | |
| 2016 | | /************************************************************ |
| 2017 | | * DataMap initializers |
| 2018 | | ************************************************************/ |
| 2019 | | |
| 2020 | | /* Initialize local helper variables */ |
| 2021 | | static void ResetDataMap(HWND hWnd) |
| 2022 | | { |
| 2023 | | char screen_option[32]; |
| 2024 | | |
| 2025 | | snprintf(screen_option, ARRAY_LENGTH(screen_option), "screen%d", GetSelectedScreen(hWnd)); |
| 2026 | | |
| 2027 | | if (options_get_string(pGameOpts, screen_option) == NULL |
| 2028 | | || (mame_stricmp(options_get_string(pGameOpts, screen_option), "") == 0 ) |
| 2029 | | || (mame_stricmp(options_get_string(pGameOpts, screen_option), "auto") == 0 ) ) |
| 2030 | | { |
| 2031 | | options_set_string(pGameOpts, screen_option, "auto", OPTION_PRIORITY_CMDLINE); |
| 2032 | | } |
| 2033 | | } |
| 2034 | | |
| 2035 | | /* Build the control mapping by adding all needed information to the DataMap */ |
| 2036 | | static void BuildDataMap(void) |
| 2037 | | { |
| 2038 | | properties_datamap = datamap_create(); |
| 2039 | | |
| 2040 | | /* video */ |
| 2041 | | datamap_add(properties_datamap, IDC_D3D_VERSION, DM_INT, WINOPTION_D3DVERSION); |
| 2042 | | datamap_add(properties_datamap, IDC_VIDEO_MODE, DM_STRING, WINOPTION_VIDEO); |
| 2043 | | datamap_add(properties_datamap, IDC_PRESCALE, DM_INT, WINOPTION_PRESCALE); |
| 2044 | | datamap_add(properties_datamap, IDC_PRESCALEDISP, DM_INT, WINOPTION_PRESCALE); |
| 2045 | | datamap_add(properties_datamap, IDC_NUMSCREENS, DM_INT, WINOPTION_NUMSCREENS); |
| 2046 | | datamap_add(properties_datamap, IDC_NUMSCREENSDISP, DM_INT, WINOPTION_NUMSCREENS); |
| 2047 | | datamap_add(properties_datamap, IDC_AUTOFRAMESKIP, DM_BOOL, OPTION_AUTOFRAMESKIP); |
| 2048 | | datamap_add(properties_datamap, IDC_FRAMESKIP, DM_INT, OPTION_FRAMESKIP); |
| 2049 | | datamap_add(properties_datamap, IDC_WAITVSYNC, DM_BOOL, WINOPTION_WAITVSYNC); |
| 2050 | | datamap_add(properties_datamap, IDC_TRIPLE_BUFFER, DM_BOOL, WINOPTION_TRIPLEBUFFER); |
| 2051 | | datamap_add(properties_datamap, IDC_WINDOWED, DM_BOOL, WINOPTION_WINDOW); |
| 2052 | | datamap_add(properties_datamap, IDC_HWSTRETCH, DM_BOOL, WINOPTION_HWSTRETCH); |
| 2053 | | datamap_add(properties_datamap, IDC_SWITCHRES, DM_BOOL, WINOPTION_SWITCHRES); |
| 2054 | | datamap_add(properties_datamap, IDC_MAXIMIZE, DM_BOOL, WINOPTION_MAXIMIZE); |
| 2055 | | datamap_add(properties_datamap, IDC_KEEPASPECT, DM_BOOL, WINOPTION_KEEPASPECT); |
| 2056 | | datamap_add(properties_datamap, IDC_SYNCREFRESH, DM_BOOL, WINOPTION_SYNCREFRESH); |
| 2057 | | datamap_add(properties_datamap, IDC_THROTTLE, DM_BOOL, OPTION_THROTTLE); |
| 2058 | | datamap_add(properties_datamap, IDC_FSGAMMA, DM_FLOAT, WINOPTION_FULLSCREENGAMMA); |
| 2059 | | datamap_add(properties_datamap, IDC_FSGAMMADISP, DM_FLOAT, WINOPTION_FULLSCREENGAMMA); |
| 2060 | | datamap_add(properties_datamap, IDC_FSBRIGHTNESS, DM_FLOAT, WINOPTION_FULLSCREENBRIGHTNESS); |
| 2061 | | datamap_add(properties_datamap, IDC_FSBRIGHTNESSDISP, DM_FLOAT, WINOPTION_FULLSCREENBRIGHTNESS); |
| 2062 | | datamap_add(properties_datamap, IDC_FSCONTRAST, DM_FLOAT, WINOPTION_FULLLSCREENCONTRAST); |
| 2063 | | datamap_add(properties_datamap, IDC_FSCONTRASTDISP, DM_FLOAT, WINOPTION_FULLLSCREENCONTRAST); |
| 2064 | | datamap_add(properties_datamap, IDC_EFFECT, DM_STRING, WINOPTION_EFFECT); |
| 2065 | | datamap_add(properties_datamap, IDC_ASPECTRATIOD, DM_STRING, NULL); |
| 2066 | | datamap_add(properties_datamap, IDC_ASPECTRATION, DM_STRING, NULL); |
| 2067 | | datamap_add(properties_datamap, IDC_REFRESH, DM_STRING, NULL); |
| 2068 | | datamap_add(properties_datamap, IDC_SIZES, DM_STRING, NULL); |
| 2069 | | |
| 2070 | | // direct3d |
| 2071 | | datamap_add(properties_datamap, IDC_D3D_FILTER, DM_BOOL, WINOPTION_FILTER); |
| 2072 | | |
| 2073 | | // input |
| 2074 | | datamap_add(properties_datamap, IDC_DEFAULT_INPUT, DM_STRING, OPTION_CTRLR); |
| 2075 | | datamap_add(properties_datamap, IDC_USE_MOUSE, DM_BOOL, OPTION_MOUSE); |
| 2076 | | datamap_add(properties_datamap, IDC_JOYSTICK, DM_BOOL, OPTION_JOYSTICK); |
| 2077 | | datamap_add(properties_datamap, IDC_JDZ, DM_FLOAT, OPTION_JOYSTICK_DEADZONE); |
| 2078 | | datamap_add(properties_datamap, IDC_JDZDISP, DM_FLOAT, OPTION_JOYSTICK_DEADZONE); |
| 2079 | | datamap_add(properties_datamap, IDC_JSAT, DM_FLOAT, OPTION_JOYSTICK_SATURATION); |
| 2080 | | datamap_add(properties_datamap, IDC_JSATDISP, DM_FLOAT, OPTION_JOYSTICK_SATURATION); |
| 2081 | | datamap_add(properties_datamap, IDC_STEADYKEY, DM_BOOL, OPTION_STEADYKEY); |
| 2082 | | datamap_add(properties_datamap, IDC_LIGHTGUN, DM_BOOL, OPTION_LIGHTGUN); |
| 2083 | | datamap_add(properties_datamap, IDC_DUAL_LIGHTGUN, DM_BOOL, WINOPTION_DUAL_LIGHTGUN); |
| 2084 | | datamap_add(properties_datamap, IDC_RELOAD, DM_BOOL, OPTION_OFFSCREEN_RELOAD); |
| 2085 | | datamap_add(properties_datamap, IDC_MULTIKEYBOARD, DM_BOOL, OPTION_MULTIKEYBOARD); |
| 2086 | | datamap_add(properties_datamap, IDC_MULTIMOUSE, DM_BOOL, OPTION_MULTIMOUSE); |
| 2087 | | |
| 2088 | | // controller mapping |
| 2089 | | datamap_add(properties_datamap, IDC_PADDLE, DM_STRING, OPTION_PADDLE_DEVICE); |
| 2090 | | datamap_add(properties_datamap, IDC_ADSTICK, DM_STRING, OPTION_ADSTICK_DEVICE); |
| 2091 | | datamap_add(properties_datamap, IDC_PEDAL, DM_STRING, OPTION_PEDAL_DEVICE); |
| 2092 | | datamap_add(properties_datamap, IDC_DIAL, DM_STRING, OPTION_DIAL_DEVICE); |
| 2093 | | datamap_add(properties_datamap, IDC_TRACKBALL, DM_STRING, OPTION_TRACKBALL_DEVICE); |
| 2094 | | datamap_add(properties_datamap, IDC_LIGHTGUNDEVICE, DM_STRING, OPTION_LIGHTGUN_DEVICE); |
| 2095 | | |
| 2096 | | // core video |
| 2097 | | datamap_add(properties_datamap, IDC_BRIGHTCORRECT, DM_FLOAT, OPTION_BRIGHTNESS); |
| 2098 | | datamap_add(properties_datamap, IDC_BRIGHTCORRECTDISP, DM_FLOAT, OPTION_BRIGHTNESS); |
| 2099 | | datamap_add(properties_datamap, IDC_PAUSEBRIGHT, DM_FLOAT, OPTION_PAUSE_BRIGHTNESS); |
| 2100 | | datamap_add(properties_datamap, IDC_PAUSEBRIGHTDISP, DM_FLOAT, OPTION_PAUSE_BRIGHTNESS); |
| 2101 | | datamap_add(properties_datamap, IDC_ROTATE, DM_INT, NULL); |
| 2102 | | datamap_add(properties_datamap, IDC_FLIPX, DM_BOOL, OPTION_FLIPX); |
| 2103 | | datamap_add(properties_datamap, IDC_FLIPY, DM_BOOL, OPTION_FLIPY); |
| 2104 | | datamap_add(properties_datamap, IDC_SCREEN, DM_STRING, NULL); |
| 2105 | | datamap_add(properties_datamap, IDC_SCREENSELECT, DM_STRING, NULL); |
| 2106 | | datamap_add(properties_datamap, IDC_VIEW, DM_STRING, NULL); |
| 2107 | | |
| 2108 | | // debugres |
| 2109 | | datamap_add(properties_datamap, IDC_GAMMA, DM_FLOAT, OPTION_GAMMA); |
| 2110 | | datamap_add(properties_datamap, IDC_GAMMADISP, DM_FLOAT, OPTION_GAMMA); |
| 2111 | | datamap_add(properties_datamap, IDC_CONTRAST, DM_FLOAT, OPTION_CONTRAST); |
| 2112 | | datamap_add(properties_datamap, IDC_CONTRASTDISP, DM_FLOAT, OPTION_CONTRAST); |
| 2113 | | |
| 2114 | | // vector |
| 2115 | | datamap_add(properties_datamap, IDC_ANTIALIAS, DM_BOOL, OPTION_ANTIALIAS); |
| 2116 | | datamap_add(properties_datamap, IDC_BEAM, DM_FLOAT, OPTION_BEAM); |
| 2117 | | datamap_add(properties_datamap, IDC_BEAMDISP, DM_FLOAT, OPTION_BEAM); |
| 2118 | | datamap_add(properties_datamap, IDC_FLICKER, DM_FLOAT, OPTION_FLICKER); |
| 2119 | | datamap_add(properties_datamap, IDC_FLICKERDISP, DM_FLOAT, OPTION_FLICKER); |
| 2120 | | |
| 2121 | | // sound |
| 2122 | | datamap_add(properties_datamap, IDC_SAMPLERATE, DM_INT, OPTION_SAMPLERATE); |
| 2123 | | datamap_add(properties_datamap, IDC_SAMPLES, DM_BOOL, OPTION_SAMPLES); |
| 2124 | | datamap_add(properties_datamap, IDC_USE_SOUND, DM_BOOL, OPTION_SOUND); |
| 2125 | | datamap_add(properties_datamap, IDC_VOLUME, DM_INT, OPTION_VOLUME); |
| 2126 | | datamap_add(properties_datamap, IDC_VOLUMEDISP, DM_INT, OPTION_VOLUME); |
| 2127 | | datamap_add(properties_datamap, IDC_AUDIO_LATENCY, DM_INT, WINOPTION_AUDIO_LATENCY); |
| 2128 | | datamap_add(properties_datamap, IDC_AUDIO_LATENCY_DISP, DM_INT, WINOPTION_AUDIO_LATENCY); |
| 2129 | | |
| 2130 | | // misc artwork options |
| 2131 | | datamap_add(properties_datamap, IDC_BACKDROPS, DM_BOOL, OPTION_USE_BACKDROPS); |
| 2132 | | datamap_add(properties_datamap, IDC_OVERLAYS, DM_BOOL, OPTION_USE_OVERLAYS); |
| 2133 | | datamap_add(properties_datamap, IDC_BEZELS, DM_BOOL, OPTION_USE_BEZELS); |
| 2134 | | datamap_add(properties_datamap, IDC_ARTWORK_CROP, DM_BOOL, OPTION_ARTWORK_CROP); |
| 2135 | | |
| 2136 | | // misc |
| 2137 | | datamap_add(properties_datamap, IDC_CHEAT, DM_BOOL, OPTION_CHEAT); |
| 2138 | | datamap_add(properties_datamap, IDC_LOG, DM_BOOL, OPTION_LOG); |
| 2139 | | datamap_add(properties_datamap, IDC_SLEEP, DM_BOOL, OPTION_SLEEP); |
| 2140 | | datamap_add(properties_datamap, IDC_HIGH_PRIORITY, DM_INT, WINOPTION_PRIORITY); |
| 2141 | | datamap_add(properties_datamap, IDC_HIGH_PRIORITYTXT, DM_INT, WINOPTION_PRIORITY); |
| 2142 | | datamap_add(properties_datamap, IDC_SKIP_GAME_INFO, DM_BOOL, OPTION_SKIP_GAMEINFO); |
| 2143 | | datamap_add(properties_datamap, IDC_BIOS, DM_STRING, OPTION_BIOS); |
| 2144 | | datamap_add(properties_datamap, IDC_ENABLE_AUTOSAVE, DM_BOOL, OPTION_AUTOSAVE); |
| 2145 | | datamap_add(properties_datamap, IDC_MULTITHREAD_RENDERING, DM_BOOL, WINOPTION_MULTITHREADING); |
| 2146 | | |
| 2147 | | // set up callbacks |
| 2148 | | datamap_set_callback(properties_datamap, IDC_ROTATE, DCT_READ_CONTROL, RotateReadControl); |
| 2149 | | datamap_set_callback(properties_datamap, IDC_ROTATE, DCT_POPULATE_CONTROL, RotatePopulateControl); |
| 2150 | | datamap_set_callback(properties_datamap, IDC_SCREEN, DCT_READ_CONTROL, ScreenReadControl); |
| 2151 | | datamap_set_callback(properties_datamap, IDC_SCREEN, DCT_POPULATE_CONTROL, ScreenPopulateControl); |
| 2152 | | datamap_set_callback(properties_datamap, IDC_VIEW, DCT_POPULATE_CONTROL, ViewPopulateControl); |
| 2153 | | datamap_set_callback(properties_datamap, IDC_REFRESH, DCT_READ_CONTROL, ResolutionReadControl); |
| 2154 | | datamap_set_callback(properties_datamap, IDC_REFRESH, DCT_POPULATE_CONTROL, ResolutionPopulateControl); |
| 2155 | | datamap_set_callback(properties_datamap, IDC_SIZES, DCT_READ_CONTROL, ResolutionReadControl); |
| 2156 | | datamap_set_callback(properties_datamap, IDC_SIZES, DCT_POPULATE_CONTROL, ResolutionPopulateControl); |
| 2157 | | datamap_set_callback(properties_datamap, IDC_DEFAULT_INPUT, DCT_POPULATE_CONTROL, DefaultInputPopulateControl); |
| 2158 | | datamap_set_option_name_callback(properties_datamap, IDC_VIEW, ViewSetOptionName); |
| 2159 | | datamap_set_option_name_callback(properties_datamap, IDC_REFRESH, ResolutionSetOptionName); |
| 2160 | | datamap_set_option_name_callback(properties_datamap, IDC_SIZES, ResolutionSetOptionName); |
| 2161 | | |
| 2162 | | // formats |
| 2163 | | datamap_set_int_format(properties_datamap, IDC_VOLUMEDISP, "%ddB"); |
| 2164 | | datamap_set_int_format(properties_datamap, IDC_AUDIO_LATENCY_DISP, "%d/5"); |
| 2165 | | datamap_set_float_format(properties_datamap, IDC_BEAMDISP, "%03.2f"); |
| 2166 | | datamap_set_float_format(properties_datamap, IDC_FLICKERDISP, "%03.2f"); |
| 2167 | | datamap_set_float_format(properties_datamap, IDC_GAMMADISP, "%03.2f"); |
| 2168 | | datamap_set_float_format(properties_datamap, IDC_BRIGHTCORRECTDISP, "%03.2f"); |
| 2169 | | datamap_set_float_format(properties_datamap, IDC_CONTRASTDISP, "%03.2f"); |
| 2170 | | datamap_set_float_format(properties_datamap, IDC_PAUSEBRIGHTDISP, "%03.2f"); |
| 2171 | | datamap_set_float_format(properties_datamap, IDC_FSGAMMADISP, "%03.2f"); |
| 2172 | | datamap_set_float_format(properties_datamap, IDC_FSBRIGHTNESSDISP, "%03.2f"); |
| 2173 | | datamap_set_float_format(properties_datamap, IDC_FSCONTRASTDISP, "%03.2f"); |
| 2174 | | datamap_set_float_format(properties_datamap, IDC_JDZDISP, "%03.2f"); |
| 2175 | | datamap_set_float_format(properties_datamap, IDC_JSATDISP, "%03.2f"); |
| 2176 | | |
| 2177 | | // trackbar ranges |
| 2178 | | datamap_set_trackbar_range(properties_datamap, IDC_PRESCALE, 1, 10, 1); |
| 2179 | | datamap_set_trackbar_range(properties_datamap, IDC_JDZ, 0.00, 1.00, 0.05); |
| 2180 | | datamap_set_trackbar_range(properties_datamap, IDC_JSAT, 0.00, 1.00, 0.05); |
| 2181 | | |
| 2182 | | #ifdef MESS |
| 2183 | | // MESS specific stuff |
| 2184 | | MessBuildDataMap(properties_datamap); |
| 2185 | | #endif // MESS |
| 2186 | | } |
| 2187 | | |
| 2188 | | BOOL IsControlOptionValue(HWND hDlg,HWND hwnd_ctrl, core_options *opts ) |
| 2189 | | { |
| 2190 | | int control_id = GetWindowLong(hwnd_ctrl, GWL_ID); |
| 2191 | | |
| 2192 | | // certain controls we need to handle specially |
| 2193 | | switch (control_id) |
| 2194 | | { |
| 2195 | | case IDC_ASPECTRATION : |
| 2196 | | { |
| 2197 | | char aspect_option[32]; |
| 2198 | | int n1 = 0, n2 = 0; |
| 2199 | | int d1 = 0, d2 = 0; |
| 2200 | | |
| 2201 | | snprintf(aspect_option, ARRAY_LENGTH(aspect_option), "aspect%d", GetSelectedScreen(hDlg)); |
| 2202 | | |
| 2203 | | sscanf(options_get_string(pGameOpts, aspect_option), "%d:%d", &n1, &d1); |
| 2204 | | sscanf(options_get_string(opts, aspect_option), "%d:%d", &n2, &d2); |
| 2205 | | |
| 2206 | | return n1 == n2; |
| 2207 | | } |
| 2208 | | case IDC_ASPECTRATIOD : |
| 2209 | | { |
| 2210 | | char aspect_option[32]; |
| 2211 | | int n1 = 0, n2 = 0; |
| 2212 | | int d1 = 0, d2 = 0; |
| 2213 | | |
| 2214 | | snprintf(aspect_option, ARRAY_LENGTH(aspect_option), "aspect%d", GetSelectedScreen(hDlg)); |
| 2215 | | |
| 2216 | | sscanf(options_get_string(pGameOpts, aspect_option), "%d:%d", &n1, &d1); |
| 2217 | | sscanf(options_get_string(opts, aspect_option), "%d:%d", &n2, &d2); |
| 2218 | | |
| 2219 | | return d1 == d2; |
| 2220 | | } |
| 2221 | | case IDC_SIZES : |
| 2222 | | { |
| 2223 | | char resolution_option[32]; |
| 2224 | | int x1=0,y1=0,x2=0,y2=0; |
| 2225 | | |
| 2226 | | snprintf(resolution_option, ARRAY_LENGTH(resolution_option), "resolution%d", GetSelectedScreen(hDlg)); |
| 2227 | | |
| 2228 | | if ((strcmp(options_get_string(pGameOpts, resolution_option), "auto") == 0) && |
| 2229 | | (strcmp(options_get_string(opts, resolution_option), "auto") == 0)) |
| 2230 | | return TRUE; |
| 2231 | | |
| 2232 | | sscanf(options_get_string(pGameOpts, resolution_option),"%d x %d",&x1,&y1); |
| 2233 | | sscanf(options_get_string(opts, resolution_option),"%d x %d",&x2,&y2); |
| 2234 | | |
| 2235 | | return x1 == x2 && y1 == y2; |
| 2236 | | } |
| 2237 | | case IDC_ROTATE : |
| 2238 | | { |
| 2239 | | datamap_read_control(properties_datamap, hDlg, pGameOpts, control_id); |
| 2240 | | |
| 2241 | | return (options_get_bool(pGameOpts, OPTION_ROR) == options_get_bool(opts, OPTION_ROR)) |
| 2242 | | || (options_get_bool(pGameOpts, OPTION_ROL) == options_get_bool(opts, OPTION_ROL)); |
| 2243 | | } |
| 2244 | | } |
| 2245 | | |
| 2246 | | // most options we can compare using data in the data map |
| 2247 | | //if (IsControlDifferent(hDlg,hwnd_ctrl,pGameOpts,opts)) |
| 2248 | | // return FALSE; |
| 2249 | | |
| 2250 | | return TRUE; |
| 2251 | | } |
| 2252 | | |
| 2253 | | |
| 2254 | | static void SetStereoEnabled(HWND hWnd, int nIndex) |
| 2255 | | { |
| 2256 | | BOOL enabled = FALSE; |
| 2257 | | HWND hCtrl; |
| 2258 | | machine_config drv; |
| 2259 | | int speakernum, num_speakers; |
| 2260 | | |
| 2261 | | num_speakers = 0; |
| 2262 | | |
| 2263 | | if ( nIndex > -1) |
| 2264 | | { |
| 2265 | | expand_machine_driver(drivers[nIndex]->drv,&drv); |
| 2266 | | for (speakernum = 0; speakernum < MAX_SPEAKER; speakernum++) |
| 2267 | | if (drv.speaker[speakernum].tag != NULL) |
| 2268 | | num_speakers++; |
| 2269 | | } |
| 2270 | | |
| 2271 | | hCtrl = GetDlgItem(hWnd, IDC_STEREO); |
| 2272 | | if (hCtrl) |
| 2273 | | { |
| 2274 | | if (nIndex <= -1 || num_speakers == 2) |
| 2275 | | enabled = TRUE; |
| 2276 | | |
| 2277 | | EnableWindow(hCtrl, enabled); |
| 2278 | | } |
| 2279 | | } |
| 2280 | | |
| 2281 | | static void SetYM3812Enabled(HWND hWnd, int nIndex) |
| 2282 | | { |
| 2283 | | int i; |
| 2284 | | BOOL enabled; |
| 2285 | | HWND hCtrl; |
| 2286 | | machine_config drv; |
| 2287 | | |
| 2288 | | if (nIndex > -1) |
| 2289 | | expand_machine_driver(drivers[nIndex]->drv,&drv); |
| 2290 | | |
| 2291 | | hCtrl = GetDlgItem(hWnd, IDC_USE_FM_YM3812); |
| 2292 | | if (hCtrl) |
| 2293 | | { |
| 2294 | | enabled = FALSE; |
| 2295 | | for (i = 0; i < MAX_SOUND; i++) |
| 2296 | | { |
| 2297 | | if (nIndex <= -1 |
| 2298 | | #if HAS_YM3812 |
| 2299 | | || drv.sound[i].sound_type == SOUND_YM3812 |
| 2300 | | #endif |
| 2301 | | #if HAS_YM3526 |
| 2302 | | || drv.sound[i].sound_type == SOUND_YM3526 |
| 2303 | | #endif |
| 2304 | | #if HAS_YM2413 |
| 2305 | | || drv.sound[i].sound_type == SOUND_YM2413 |
| 2306 | | #endif |
| 2307 | | ) |
| 2308 | | enabled = TRUE; |
| 2309 | | } |
| 2310 | | |
| 2311 | | EnableWindow(hCtrl, enabled); |
| 2312 | | } |
| 2313 | | } |
| 2314 | | |
| 2315 | | static void SetSamplesEnabled(HWND hWnd, int nIndex, BOOL bSoundEnabled) |
| 2316 | | { |
| 2317 | | #if (HAS_SAMPLES == 1) || (HAS_VLM5030 == 1) |
| 2318 | | int i; |
| 2319 | | BOOL enabled = FALSE; |
| 2320 | | HWND hCtrl; |
| 2321 | | machine_config drv; |
| 2322 | | |
| 2323 | | hCtrl = GetDlgItem(hWnd, IDC_SAMPLES); |
| 2324 | | |
| 2325 | | if ( nIndex > -1 ) |
| 2326 | | expand_machine_driver(drivers[nIndex]->drv,&drv); |
| 2327 | | |
| 2328 | | if (hCtrl) |
| 2329 | | { |
| 2330 | | for (i = 0; i < MAX_SOUND; i++) |
| 2331 | | { |
| 2332 | | if (nIndex <= -1 |
| 2333 | | || drv.sound[i].sound_type == SOUND_SAMPLES |
| 2334 | | #if HAS_VLM5030 |
| 2335 | | || drv.sound[i].sound_type == SOUND_VLM5030 |
| 2336 | | #endif |
| 2337 | | ) |
| 2338 | | enabled = TRUE; |
| 2339 | | } |
| 2340 | | enabled = enabled && bSoundEnabled; |
| 2341 | | EnableWindow(hCtrl, enabled); |
| 2342 | | } |
| 2343 | | #endif |
| 2344 | | } |
| 2345 | | |
| 2346 | | /* Moved here cause it's called in a few places */ |
| 2347 | | static void InitializeOptions(HWND hDlg) |
| 2348 | | { |
| 2349 | | InitializeSoundUI(hDlg); |
| 2350 | | InitializeSkippingUI(hDlg); |
| 2351 | | InitializeRotateUI(hDlg); |
| 2352 | | InitializeSelectScreenUI(hDlg); |
| 2353 | | InitializeEffectUI(hDlg); |
| 2354 | | InitializeBIOSUI(hDlg); |
| 2355 | | InitializeControllerMappingUI(hDlg); |
| 2356 | | InitializeD3DVersionUI(hDlg); |
| 2357 | | InitializeVideoUI(hDlg); |
| 2358 | | } |
| 2359 | | |
| 2360 | | /* Moved here because it is called in several places */ |
| 2361 | | static void InitializeMisc(HWND hDlg) |
| 2362 | | { |
| 2363 | | Button_Enable(GetDlgItem(hDlg, IDC_JOYSTICK), DIJoystick.Available()); |
| 2364 | | } |
| 2365 | | |
| 2366 | | static void OptOnHScroll(HWND hwnd, HWND hwndCtl, UINT code, int pos) |
| 2367 | | { |
| 2368 | | if (hwndCtl == GetDlgItem(hwnd, IDC_NUMSCREENS)) |
| 2369 | | { |
| 2370 | | NumScreensSelectionChange(hwnd); |
| 2371 | | } |
| 2372 | | } |
| 2373 | | |
| 2374 | | /* Handle changes to the Numscreens slider */ |
| 2375 | | static void NumScreensSelectionChange(HWND hwnd) |
| 2376 | | { |
| 2377 | | //Also Update the ScreenSelect Combo with the new number of screens |
| 2378 | | UpdateSelectScreenUI(hwnd ); |
| 2379 | | } |
| 2380 | | |
| 2381 | | /* Handle changes to the Refresh drop down */ |
| 2382 | | static void RefreshSelectionChange(HWND hWnd, HWND hWndCtrl) |
| 2383 | | { |
| 2384 | | int nCurSelection; |
| 2385 | | |
| 2386 | | nCurSelection = ComboBox_GetCurSel(hWndCtrl); |
| 2387 | | if (nCurSelection != CB_ERR) |
| 2388 | | { |
| 2389 | | datamap_populate_control(properties_datamap, hWnd, pGameOpts, IDC_SIZES); |
| 2390 | | } |
| 2391 | | } |
| 2392 | | |
| 2393 | | /* Initialize the sound options */ |
| 2394 | | static void InitializeSoundUI(HWND hwnd) |
| 2395 | | { |
| 2396 | | HWND hCtrl; |
| 2397 | | int i = 0; |
| 2398 | | |
| 2399 | | hCtrl = GetDlgItem(hwnd, IDC_SAMPLERATE); |
| 2400 | | if (hCtrl) |
| 2401 | | { |
| 2402 | | (void)ComboBox_AddString(hCtrl, TEXT("11025")); |
| 2403 | | (void)ComboBox_SetItemData(hCtrl, i++, 11025); |
| 2404 | | (void)ComboBox_AddString(hCtrl, TEXT("22050")); |
| 2405 | | (void)ComboBox_SetItemData(hCtrl, i++, 22050); |
| 2406 | | (void)ComboBox_AddString(hCtrl, TEXT("44100")); |
| 2407 | | (void)ComboBox_SetItemData(hCtrl, i++, 44100); |
| 2408 | | (void)ComboBox_AddString(hCtrl, TEXT("48000")); |
| 2409 | | (void)ComboBox_SetItemData(hCtrl, i++, 48000); |
| 2410 | | (void)ComboBox_SetCurSel(hCtrl, 1); |
| 2411 | | } |
| 2412 | | } |
| 2413 | | |
| 2414 | | /* Populate the Frame Skipping drop down */ |
| 2415 | | static void InitializeSkippingUI(HWND hwnd) |
| 2416 | | { |
| 2417 | | HWND hCtrl = GetDlgItem(hwnd, IDC_FRAMESKIP); |
| 2418 | | int i = 0; |
| 2419 | | |
| 2420 | | if (hCtrl) |
| 2421 | | { |
| 2422 | | (void)ComboBox_AddString(hCtrl, TEXT("Draw every frame")); |
| 2423 | | (void)ComboBox_SetItemData(hCtrl, i++, 0); |
| 2424 | | (void)ComboBox_AddString(hCtrl, TEXT("Skip 1 of 12 frames")); |
| 2425 | | (void)ComboBox_SetItemData(hCtrl, i++, 1); |
| 2426 | | (void)ComboBox_AddString(hCtrl, TEXT("Skip 2 of 12 frames")); |
| 2427 | | (void)ComboBox_SetItemData(hCtrl, i++, 2); |
| 2428 | | (void)ComboBox_AddString(hCtrl, TEXT("Skip 3 of 12 frames")); |
| 2429 | | (void)ComboBox_SetItemData(hCtrl, i++, 3); |
| 2430 | | (void)ComboBox_AddString(hCtrl, TEXT("Skip 4 of 12 frames")); |
| 2431 | | (void)ComboBox_SetItemData(hCtrl, i++, 4); |
| 2432 | | (void)ComboBox_AddString(hCtrl, TEXT("Skip 5 of 12 frames")); |
| 2433 | | (void)ComboBox_SetItemData(hCtrl, i++, 5); |
| 2434 | | (void)ComboBox_AddString(hCtrl, TEXT("Skip 6 of 12 frames")); |
| 2435 | | (void)ComboBox_SetItemData(hCtrl, i++, 6); |
| 2436 | | (void)ComboBox_AddString(hCtrl, TEXT("Skip 7 of 12 frames")); |
| 2437 | | (void)ComboBox_SetItemData(hCtrl, i++, 7); |
| 2438 | | (void)ComboBox_AddString(hCtrl, TEXT("Skip 8 of 12 frames")); |
| 2439 | | (void)ComboBox_SetItemData(hCtrl, i++, 8); |
| 2440 | | (void)ComboBox_AddString(hCtrl, TEXT("Skip 9 of 12 frames")); |
| 2441 | | (void)ComboBox_SetItemData(hCtrl, i++, 9); |
| 2442 | | (void)ComboBox_AddString(hCtrl, TEXT("Skip 10 of 12 frames")); |
| 2443 | | (void)ComboBox_SetItemData(hCtrl, i++, 10); |
| 2444 | | (void)ComboBox_AddString(hCtrl, TEXT("Skip 11 of 12 frames")); |
| 2445 | | (void)ComboBox_SetItemData(hCtrl, i++, 11); |
| 2446 | | } |
| 2447 | | } |
| 2448 | | |
| 2449 | | /* Populate the Rotate drop down */ |
| 2450 | | static void InitializeRotateUI(HWND hwnd) |
| 2451 | | { |
| 2452 | | HWND hCtrl = GetDlgItem(hwnd, IDC_ROTATE); |
| 2453 | | |
| 2454 | | if (hCtrl) |
| 2455 | | { |
| 2456 | | (void)ComboBox_AddString(hCtrl, TEXT("Default")); // 0 |
| 2457 | | (void)ComboBox_AddString(hCtrl, TEXT("Clockwise")); // 1 |
| 2458 | | (void)ComboBox_AddString(hCtrl, TEXT("Anti-clockwise")); // 2 |
| 2459 | | (void)ComboBox_AddString(hCtrl, TEXT("None")); // 3 |
| 2460 | | (void)ComboBox_AddString(hCtrl, TEXT("Auto clockwise")); // 4 |
| 2461 | | (void)ComboBox_AddString(hCtrl, TEXT("Auto anti-clockwise")); // 5 |
| 2462 | | } |
| 2463 | | } |
| 2464 | | |
| 2465 | | /* Populate the Video Mode drop down */ |
| 2466 | | static void InitializeVideoUI(HWND hwnd) |
| 2467 | | { |
| 2468 | | HWND hCtrl; |
| 2469 | | |
| 2470 | | hCtrl = GetDlgItem(hwnd, IDC_VIDEO_MODE); |
| 2471 | | if (hCtrl) |
| 2472 | | { |
| 2473 | | int i; |
| 2474 | | for (i = 0; i < NUMVIDEO; i++) |
| 2475 | | { |
| 2476 | | (void)ComboBox_InsertString(hCtrl, i, g_ComboBoxVideo[i].m_pText); |
| 2477 | | (void)ComboBox_SetItemData( hCtrl, i, g_ComboBoxVideo[i].m_pData); |
| 2478 | | } |
| 2479 | | } |
| 2480 | | } |
| 2481 | | |
| 2482 | | /* Populate the D3D Version drop down */ |
| 2483 | | static void InitializeD3DVersionUI(HWND hwnd) |
| 2484 | | { |
| 2485 | | HWND hCtrl = GetDlgItem(hwnd, IDC_D3D_VERSION); |
| 2486 | | if (hCtrl) |
| 2487 | | { |
| 2488 | | int i; |
| 2489 | | for (i = 0; i < NUMD3DVERSIONS; i++) |
| 2490 | | { |
| 2491 | | (void)ComboBox_InsertString(hCtrl, i, g_ComboBoxD3DVersion[i].m_pText); |
| 2492 | | (void)ComboBox_SetItemData( hCtrl, i, g_ComboBoxD3DVersion[i].m_pData); |
| 2493 | | } |
| 2494 | | } |
| 2495 | | } |
| 2496 | | |
| 2497 | | static void UpdateSelectScreenUI(HWND hwnd) |
| 2498 | | { |
| 2499 | | HWND hCtrl = GetDlgItem(hwnd, IDC_SCREENSELECT); |
| 2500 | | if (hCtrl) |
| 2501 | | { |
| 2502 | | int i, curSel; |
| 2503 | | curSel = ComboBox_GetCurSel(hCtrl); |
| 2504 | | if ((curSel < 0) || (curSel >= MAX_SCREENS)) |
| 2505 | | curSel = 0; |
| 2506 | | (void)ComboBox_ResetContent(hCtrl ); |
| 2507 | | for (i = 0; i < NUMSELECTSCREEN && i < options_get_int(pGameOpts, WINOPTION_NUMSCREENS) ; i++) |
| 2508 | | { |
| 2509 | | (void)ComboBox_InsertString(hCtrl, i, g_ComboBoxSelectScreen[i].m_pText); |
| 2510 | | (void)ComboBox_SetItemData( hCtrl, i, g_ComboBoxSelectScreen[i].m_pData); |
| 2511 | | } |
| 2512 | | // Smaller Amount of screens was selected, so use 0 |
| 2513 | | if( i< curSel ) |
| 2514 | | (void)ComboBox_SetCurSel(hCtrl, 0 ); |
| 2515 | | else |
| 2516 | | (void)ComboBox_SetCurSel(hCtrl, curSel ); |
| 2517 | | } |
| 2518 | | } |
| 2519 | | |
| 2520 | | /* Populate the Select Screen drop down */ |
| 2521 | | static void InitializeSelectScreenUI(HWND hwnd) |
| 2522 | | { |
| 2523 | | UpdateSelectScreenUI(hwnd); |
| 2524 | | } |
| 2525 | | |
| 2526 | | static void InitializeEffectUI(HWND hwnd) |
| 2527 | | { |
| 2528 | | } |
| 2529 | | |
| 2530 | | static void InitializeControllerMappingUI(HWND hwnd) |
| 2531 | | { |
| 2532 | | int i; |
| 2533 | | HWND hCtrl = GetDlgItem(hwnd,IDC_PADDLE); |
| 2534 | | HWND hCtrl1 = GetDlgItem(hwnd,IDC_ADSTICK); |
| 2535 | | HWND hCtrl2 = GetDlgItem(hwnd,IDC_PEDAL); |
| 2536 | | HWND hCtrl3 = GetDlgItem(hwnd,IDC_DIAL); |
| 2537 | | HWND hCtrl4 = GetDlgItem(hwnd,IDC_TRACKBALL); |
| 2538 | | HWND hCtrl5 = GetDlgItem(hwnd,IDC_LIGHTGUNDEVICE); |
| 2539 | | |
| 2540 | | if (hCtrl) |
| 2541 | | { |
| 2542 | | for (i = 0; i < NUMDEVICES; i++) |
| 2543 | | { |
| 2544 | | (void)ComboBox_InsertString(hCtrl, i, g_ComboBoxDevice[i].m_pText); |
| 2545 | | (void)ComboBox_SetItemData( hCtrl, i, g_ComboBoxDevice[i].m_pData); |
| 2546 | | } |
| 2547 | | } |
| 2548 | | if (hCtrl1) |
| 2549 | | { |
| 2550 | | for (i = 0; i < NUMDEVICES; i++) |
| 2551 | | { |
| 2552 | | (void)ComboBox_InsertString(hCtrl1, i, g_ComboBoxDevice[i].m_pText); |
| 2553 | | (void)ComboBox_SetItemData( hCtrl1, i, g_ComboBoxDevice[i].m_pData); |
| 2554 | | } |
| 2555 | | } |
| 2556 | | if (hCtrl2) |
| 2557 | | { |
| 2558 | | for (i = 0; i < NUMDEVICES; i++) |
| 2559 | | { |
| 2560 | | (void)ComboBox_InsertString(hCtrl2, i, g_ComboBoxDevice[i].m_pText); |
| 2561 | | (void)ComboBox_SetItemData( hCtrl2, i, g_ComboBoxDevice[i].m_pData); |
| 2562 | | } |
| 2563 | | } |
| 2564 | | if (hCtrl3) |
| 2565 | | { |
| 2566 | | for (i = 0; i < NUMDEVICES; i++) |
| 2567 | | { |
| 2568 | | (void)ComboBox_InsertString(hCtrl3, i, g_ComboBoxDevice[i].m_pText); |
| 2569 | | (void)ComboBox_SetItemData( hCtrl3, i, g_ComboBoxDevice[i].m_pData); |
| 2570 | | } |
| 2571 | | } |
| 2572 | | if (hCtrl4) |
| 2573 | | { |
| 2574 | | for (i = 0; i < NUMDEVICES; i++) |
| 2575 | | { |
| 2576 | | (void)ComboBox_InsertString(hCtrl4, i, g_ComboBoxDevice[i].m_pText); |
| 2577 | | (void)ComboBox_SetItemData( hCtrl4, i, g_ComboBoxDevice[i].m_pData); |
| 2578 | | } |
| 2579 | | } |
| 2580 | | if (hCtrl5) |
| 2581 | | { |
| 2582 | | for (i = 0; i < NUMDEVICES; i++) |
| 2583 | | { |
| 2584 | | (void)ComboBox_InsertString(hCtrl5, i, g_ComboBoxDevice[i].m_pText); |
| 2585 | | (void)ComboBox_SetItemData( hCtrl5, i, g_ComboBoxDevice[i].m_pData); |
| 2586 | | } |
| 2587 | | } |
| 2588 | | } |
| 2589 | | |
| 2590 | | |
| 2591 | | static void InitializeBIOSUI(HWND hwnd) |
| 2592 | | { |
| 2593 | | HWND hCtrl = GetDlgItem(hwnd,IDC_BIOS); |
| 2594 | | int i = 0; |
| 2595 | | TCHAR* t_s; |
| 2596 | | if (hCtrl) |
| 2597 | | { |
| 2598 | | const game_driver *gamedrv = drivers[g_nGame]; |
| 2599 | | const rom_entry *rom; |
| 2600 | | |
| 2601 | | if (g_nGame == GLOBAL_OPTIONS) |
| 2602 | | { |
| 2603 | | (void)ComboBox_InsertString(hCtrl, i, TEXT("None")); |
| 2604 | | (void)ComboBox_SetItemData( hCtrl, i++, "none"); |
| 2605 | | return; |
| 2606 | | } |
| 2607 | | if (g_nGame == FOLDER_OPTIONS) //Folder Options |
| 2608 | | { |
| 2609 | | gamedrv = drivers[g_nFolderGame]; |
| 2610 | | if (DriverHasOptionalBIOS(g_nFolderGame) == FALSE) |
| 2611 | | { |
| 2612 | | (void)ComboBox_InsertString(hCtrl, i, TEXT("None")); |
| 2613 | | (void)ComboBox_SetItemData( hCtrl, i++, "default"); |
| 2614 | | return; |
| 2615 | | } |
| 2616 | | (void)ComboBox_InsertString(hCtrl, i, TEXT("Default")); |
| 2617 | | (void)ComboBox_SetItemData( hCtrl, i++, "default"); |
| 2618 | | |
| 2619 | | if (gamedrv->rom != NULL) |
| 2620 | | { |
| 2621 | | for (rom = gamedrv->rom; !ROMENTRY_ISEND(rom); rom++) |
| 2622 | | { |
| 2623 | | if (ROMENTRY_ISSYSTEM_BIOS(rom)) |
| 2624 | | { |
| 2625 | | const char *name = ROM_GETHASHDATA(rom); |
| 2626 | | t_s = tstring_from_utf8(name); |
| 2627 | | if( !t_s ) |
| 2628 | | return; |
| 2629 | | (void)ComboBox_InsertString(hCtrl, i, win_tstring_strdup(t_s)); |
| 2630 | | (void)ComboBox_SetItemData( hCtrl, i++, name); |
| 2631 | | free(t_s); |
| 2632 | | } |
| 2633 | | } |
| 2634 | | } |
| 2635 | | return; |
| 2636 | | } |
| 2637 | | |
| 2638 | | if (DriverHasOptionalBIOS(g_nGame) == FALSE) |
| 2639 | | { |
| 2640 | | (void)ComboBox_InsertString(hCtrl, i, TEXT("None")); |
| 2641 | | (void)ComboBox_SetItemData( hCtrl, i++, "none"); |
| 2642 | | return; |
| 2643 | | } |
| 2644 | | (void)ComboBox_InsertString(hCtrl, i, TEXT("Default")); |
| 2645 | | (void)ComboBox_SetItemData( hCtrl, i++, "default"); |
| 2646 | | |
| 2647 | | if (gamedrv->rom != NULL) |
| 2648 | | { |
| 2649 | | for (rom = gamedrv->rom; !ROMENTRY_ISEND(rom); rom++) |
| 2650 | | { |
| 2651 | | if (ROMENTRY_ISSYSTEM_BIOS(rom)) |
| 2652 | | { |
| 2653 | | const char *name = ROM_GETHASHDATA(rom); |
| 2654 | | t_s = tstring_from_utf8(name); |
| 2655 | | if( !t_s ) |
| 2656 | | return; |
| 2657 | | (void)ComboBox_InsertString(hCtrl, i, win_tstring_strdup(t_s)); |
| 2658 | | (void)ComboBox_SetItemData( hCtrl, i++, name); |
| 2659 | | free(t_s); |
| 2660 | | } |
| 2661 | | } |
| 2662 | | } |
| 2663 | | } |
| 2664 | | } |
| 2665 | | |
| 2666 | | static BOOL SelectEffect(HWND hWnd) |
| 2667 | | { |
| 2668 | | char filename[MAX_PATH]; |
| 2669 | | BOOL changed = FALSE; |
| 2670 | | |
| 2671 | | *filename = 0; |
| 2672 | | if (CommonFileDialog(GetOpenFileName, filename, FILETYPE_EFFECT_FILES)) |
| 2673 | | { |
| 2674 | | //strip Path and extension |
| 2675 | | char buff[MAX_PATH]; |
| 2676 | | int i, j = 0, k = 0, l = 0; |
| 2677 | | for(i=0; i<strlen(filename); i++ ) |
| 2678 | | { |
| 2679 | | if( filename[i] == '\\' ) |
| 2680 | | j = i; |
| 2681 | | if( filename[i] == '.' ) |
| 2682 | | k = i; |
| 2683 | | } |
| 2684 | | for(i=j+1;i<k;i++) |
| 2685 | | { |
| 2686 | | buff[l++] = filename[i]; |
| 2687 | | } |
| 2688 | | buff[l] = '\0'; |
| 2689 | | |
| 2690 | | if (strcmp(buff, options_get_string(pGameOpts, WINOPTION_EFFECT))) |
| 2691 | | { |
| 2692 | | options_set_string(pGameOpts, WINOPTION_EFFECT, buff, OPTION_PRIORITY_CMDLINE); |
| 2693 | | datamap_populate_control(properties_datamap, hWnd, pGameOpts, IDC_EFFECT); |
| 2694 | | changed = TRUE; |
| 2695 | | } |
| 2696 | | } |
| 2697 | | return changed; |
| 2698 | | } |
| 2699 | | |
| 2700 | | static BOOL ResetEffect(HWND hWnd) |
| 2701 | | { |
| 2702 | | BOOL changed = FALSE; |
| 2703 | | const char *new_value = "none"; |
| 2704 | | |
| 2705 | | if (strcmp(new_value, options_get_string(pGameOpts, WINOPTION_EFFECT))) |
| 2706 | | { |
| 2707 | | options_set_string(pGameOpts, WINOPTION_EFFECT, new_value, OPTION_PRIORITY_CMDLINE); |
| 2708 | | datamap_populate_control(properties_datamap, hWnd, pGameOpts, IDC_EFFECT); |
| 2709 | | changed = TRUE; |
| 2710 | | } |
| 2711 | | return changed; |
| 2712 | | } |
| 2713 | | |
| 2714 | | |
| 2715 | | void UpdateBackgroundBrush(HWND hwndTab) |
| 2716 | | { |
| 2717 | | // Destroy old brush |
| 2718 | | if (hBkBrush) |
| 2719 | | DeleteObject(hBkBrush); |
| 2720 | | |
| 2721 | | hBkBrush = NULL; |
| 2722 | | |
| 2723 | | // Only do this if the theme is active |
| 2724 | | if (SafeIsAppThemed()) |
| 2725 | | { |
| 2726 | | RECT rc; |
| 2727 | | HDC hDC, hDCMem; |
| 2728 | | HBITMAP hBmp, hBmpOld; |
| 2729 | | // Get tab control dimensions |
| 2730 | | GetWindowRect( hwndTab, &rc); |
| 2731 | | |
| 2732 | | // Get the tab control DC |
| 2733 | | hDC = GetDC(hwndTab); |
| 2734 | | |
| 2735 | | // Create a compatible DC |
| 2736 | | hDCMem = CreateCompatibleDC(hDC); |
| 2737 | | hBmp = CreateCompatibleBitmap(hDC, |
| 2738 | | rc.right - rc.left, rc.bottom - rc.top); |
| 2739 | | hBmpOld = (HBITMAP)(SelectObject(hDCMem, hBmp)); |
| 2740 | | |
| 2741 | | // Tell the tab control to paint in our DC |
| 2742 | | SendMessage(hwndTab, WM_PRINTCLIENT, (WPARAM)(hDCMem), |
| 2743 | | (LPARAM)(PRF_ERASEBKGND | PRF_CLIENT | PRF_NONCLIENT)); |
| 2744 | | |
| 2745 | | // Create a pattern brush from the bitmap selected in our DC |
| 2746 | | hBkBrush = CreatePatternBrush(hBmp); |
| 2747 | | |
| 2748 | | // Restore the bitmap |
| 2749 | | SelectObject(hDCMem, hBmpOld); |
| 2750 | | |
| 2751 | | // Cleanup |
| 2752 | | DeleteObject(hBmp); |
| 2753 | | DeleteDC(hDCMem); |
| 2754 | | ReleaseDC(hwndTab, hDC); |
| 2755 | | } |
| 2756 | | } |
| 2757 | | |
| 2758 | | |
| 2759 | | /* End of source file */ |
src/osd/winui/win32ui.c
| r0 | r996 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | M.A.M.E.32 - Multiple Arcade Machine Emulator for Win32 |
| 4 | Win32 Portions Copyright (C) 1997-2003 Michael Soderstrom and Chris Kirmse |
| 5 | |
| 6 | This file is part of MAME32, and may only be used, modified and |
| 7 | distributed under the terms of the MAME license, in "readme.txt". |
| 8 | By continuing to use, modify or distribute this file you indicate |
| 9 | that you have read the license and understand and accept it fully. |
| 10 | |
| 11 | ***************************************************************************/ |
| 12 | |
| 13 | /*************************************************************************** |
| 14 | |
| 15 | win32ui.c |
| 16 | |
| 17 | Win32 GUI code. |
| 18 | |
| 19 | Created 8/12/97 by Christopher Kirmse (ckirmse@ricochet.net) |
| 20 | Additional code November 1997 by Jeff Miller (miller@aa.net) |
| 21 | More July 1998 by Mike Haaland (mhaaland@hypertech.com) |
| 22 | Added Spitters/Property Sheets/Removed Tabs/Added Tree Control in |
| 23 | Nov/Dec 1998 - Mike Haaland |
| 24 | |
| 25 | ***************************************************************************/ |
| 26 | |
| 27 | #define WIN32_LEAN_AND_MEAN |
| 28 | #define _WIN32_IE 0x0500 |
| 29 | #include <windows.h> |
| 30 | #include <windowsx.h> |
| 31 | #include <shellapi.h> |
| 32 | #include <stdio.h> |
| 33 | #include <ctype.h> |
| 34 | #include <io.h> |
| 35 | #include <fcntl.h> |
| 36 | #include <commctrl.h> |
| 37 | #include <dlgs.h> |
| 38 | #include <string.h> |
| 39 | #include <sys/stat.h> |
| 40 | #include <wingdi.h> |
| 41 | #include <time.h> |
| 42 | #include <tchar.h> |
| 43 | |
| 44 | #include <driver.h> |
| 45 | #include <osdepend.h> |
| 46 | #include <unzip.h> |
| 47 | |
| 48 | #include "resource.h" |
| 49 | #include "resource.hm" |
| 50 | |
| 51 | #include "screenshot.h" |
| 52 | #include "mame32.h" |
| 53 | #include "m32util.h" |
| 54 | #include "file.h" |
| 55 | #include "audit32.h" |
| 56 | #include "directories.h" |
| 57 | #include "m32opts.h" |
| 58 | #include "properties.h" |
| 59 | #include "columnedit.h" |
| 60 | #include "picker.h" |
| 61 | #include "tabview.h" |
| 62 | #include "bitmask.h" |
| 63 | #include "treeview.h" |
| 64 | #include "splitters.h" |
| 65 | #include "dirwatch.h" |
| 66 | #include "help.h" |
| 67 | #include "history.h" |
| 68 | #include "dialogs.h" |
| 69 | #include "state.h" |
| 70 | #include "winmain.h" |
| 71 | #include "winutf8.h" |
| 72 | #include "strconv.h" |
| 73 | #include "input.h" |
| 74 | #include "windows/window.h" |
| 75 | |
| 76 | #include "directdraw.h" |
| 77 | #include "directinput.h" |
| 78 | #include "dijoystick.h" /* For DIJoystick avalibility. */ |
| 79 | |
| 80 | #ifdef MESS |
| 81 | #include "mess32ui.h" |
| 82 | #include "messopts.h" |
| 83 | #endif // MESS |
| 84 | |
| 85 | #ifdef _MSC_VER |
| 86 | #define snprintf _snprintf |
| 87 | #endif |
| 88 | |
| 89 | #ifndef LVS_EX_LABELTIP |
| 90 | #define LVS_EX_LABELTIP 0x00004000 // listview unfolds partly hidden labels if it does not have infotip text |
| 91 | #endif // LVS_EX_LABELTIP |
| 92 | |
| 93 | // fix warning: cast does not match function type |
| 94 | #if defined(__GNUC__) && defined(ListView_CreateDragImage) |
| 95 | #undef ListView_CreateDragImage |
| 96 | #endif |
| 97 | |
| 98 | #ifndef ListView_CreateDragImage |
| 99 | #define ListView_CreateDragImage(hwnd, i, lpptUpLeft) \ |
| 100 | (HIMAGELIST)(LRESULT)(int)SendMessage((hwnd), LVM_CREATEDRAGIMAGE, (WPARAM)(int)(i), (LPARAM)(LPPOINT)(lpptUpLeft)) |
| 101 | #endif // ListView_CreateDragImage |
| 102 | |
| 103 | #ifndef TreeView_EditLabel |
| 104 | #define TreeView_EditLabel(w, i) \ |
| 105 | SNDMSG(w,TVM_EDITLABEL,0,(LPARAM)(i)) |
| 106 | #endif // TreeView_EditLabel |
| 107 | |
| 108 | #ifndef HDF_SORTUP |
| 109 | #define HDF_SORTUP 0x400 |
| 110 | #endif // HDF_SORTUP |
| 111 | |
| 112 | #ifndef HDF_SORTDOWN |
| 113 | #define HDF_SORTDOWN 0x200 |
| 114 | #endif // HDF_SORTDOWN |
| 115 | |
| 116 | #ifndef LVM_SETBKIMAGEA |
| 117 | #define LVM_SETBKIMAGEA (LVM_FIRST + 68) |
| 118 | #endif // LVM_SETBKIMAGEA |
| 119 | |
| 120 | #ifndef LVM_SETBKIMAGEW |
| 121 | #define LVM_SETBKIMAGEW (LVM_FIRST + 138) |
| 122 | #endif // LVM_SETBKIMAGEW |
| 123 | |
| 124 | #ifndef LVM_GETBKIMAGEA |
| 125 | #define LVM_GETBKIMAGEA (LVM_FIRST + 69) |
| 126 | #endif // LVM_GETBKIMAGEA |
| 127 | |
| 128 | #ifndef LVM_GETBKIMAGEW |
| 129 | #define LVM_GETBKIMAGEW (LVM_FIRST + 139) |
| 130 | #endif // LVM_GETBKIMAGEW |
| 131 | |
| 132 | #ifndef LVBKIMAGE |
| 133 | |
| 134 | typedef struct tagLVBKIMAGEA |
| 135 | { |
| 136 | ULONG ulFlags; |
| 137 | HBITMAP hbm; |
| 138 | LPSTR pszImage; |
| 139 | UINT cchImageMax; |
| 140 | int xOffsetPercent; |
| 141 | int yOffsetPercent; |
| 142 | } LVBKIMAGEA, *LPLVBKIMAGEA; |
| 143 | |
| 144 | typedef struct tagLVBKIMAGEW |
| 145 | { |
| 146 | ULONG ulFlags; |
| 147 | HBITMAP hbm; |
| 148 | LPWSTR pszImage; |
| 149 | UINT cchImageMax; |
| 150 | int xOffsetPercent; |
| 151 | int yOffsetPercent; |
| 152 | } LVBKIMAGEW, *LPLVBKIMAGEW; |
| 153 | |
| 154 | #ifdef UNICODE |
| 155 | #define LVBKIMAGE LVBKIMAGEW |
| 156 | #define LPLVBKIMAGE LPLVBKIMAGEW |
| 157 | #define LVM_SETBKIMAGE LVM_SETBKIMAGEW |
| 158 | #define LVM_GETBKIMAGE LVM_GETBKIMAGEW |
| 159 | #else |
| 160 | #define LVBKIMAGE LVBKIMAGEA |
| 161 | #define LPLVBKIMAGE LPLVBKIMAGEA |
| 162 | #define LVM_SETBKIMAGE LVM_SETBKIMAGEA |
| 163 | #define LVM_GETBKIMAGE LVM_GETBKIMAGEA |
| 164 | #endif |
| 165 | #endif |
| 166 | |
| 167 | #ifndef LVBKIF_SOURCE_NONE |
| 168 | #define LVBKIF_SOURCE_NONE 0x00000000 |
| 169 | #endif // LVBKIF_SOURCE_NONE |
| 170 | |
| 171 | #ifndef LVBKIF_SOURCE_HBITMAP |
| 172 | #define LVBKIF_SOURCE_HBITMAP 0x00000001 |
| 173 | #endif |
| 174 | |
| 175 | #ifndef LVBKIF_SOURCE_URL |
| 176 | #define LVBKIF_SOURCE_URL 0x00000002 |
| 177 | #endif // LVBKIF_SOURCE_URL |
| 178 | |
| 179 | #ifndef LVBKIF_SOURCE_MASK |
| 180 | #define LVBKIF_SOURCE_MASK 0x00000003 |
| 181 | #endif // LVBKIF_SOURCE_MASK |
| 182 | |
| 183 | #ifndef LVBKIF_STYLE_NORMAL |
| 184 | #define LVBKIF_STYLE_NORMAL 0x00000000 |
| 185 | #endif // LVBKIF_STYLE_NORMAL |
| 186 | |
| 187 | #ifndef LVBKIF_STYLE_TILE |
| 188 | #define LVBKIF_STYLE_TILE 0x00000010 |
| 189 | #endif // LVBKIF_STYLE_TILE |
| 190 | |
| 191 | #ifndef LVBKIF_STYLE_MASK |
| 192 | #define LVBKIF_STYLE_MASK 0x00000010 |
| 193 | #endif // LVBKIF_STYLE_MASK |
| 194 | |
| 195 | #ifndef ListView_SetBkImage |
| 196 | #define ListView_SetBkImage(hwnd, plvbki) \ |
| 197 | (BOOL)SNDMSG((hwnd), LVM_SETBKIMAGE, 0, (LPARAM)(plvbki)) |
| 198 | #endif // ListView_SetBkImage |
| 199 | |
| 200 | #ifndef ListView_GetBkImage |
| 201 | #define ListView_GetBkImage(hwnd, plvbki) \ |
| 202 | (BOOL)SNDMSG((hwnd), LVM_GETBKIMAGE, 0, (LPARAM)(plvbki)) |
| 203 | #endif // ListView_GetBkImage |
| 204 | |
| 205 | #define MM_PLAY_GAME (WM_APP + 15000) |
| 206 | |
| 207 | #define JOYGUI_MS 100 |
| 208 | |
| 209 | #define JOYGUI_TIMER 1 |
| 210 | #define SCREENSHOT_TIMER 2 |
| 211 | #define GAMEWND_TIMER 3 |
| 212 | |
| 213 | /* Max size of a sub-menu */ |
| 214 | #define DBU_MIN_WIDTH 292 |
| 215 | #define DBU_MIN_HEIGHT 190 |
| 216 | |
| 217 | int MIN_WIDTH = DBU_MIN_WIDTH; |
| 218 | int MIN_HEIGHT = DBU_MIN_HEIGHT; |
| 219 | |
| 220 | /* Max number of bkground picture files */ |
| 221 | #define MAX_BGFILES 100 |
| 222 | |
| 223 | #ifndef LVS_EX_LABELTIP |
| 224 | #define LVS_EX_LABELTIP 0x00004000 // listview unfolds partly hidden labels if it does not have infotip text |
| 225 | #endif |
| 226 | |
| 227 | #define NO_FOLDER -1 |
| 228 | #define STATESAVE_VERSION 1 |
| 229 | |
| 230 | /*************************************************************************** |
| 231 | externally defined global variables |
| 232 | ***************************************************************************/ |
| 233 | extern const ICONDATA g_iconData[]; |
| 234 | extern const TCHAR g_szPlayGameString[]; |
| 235 | extern const char g_szGameCountString[]; |
| 236 | |
| 237 | typedef struct _play_options play_options; |
| 238 | struct _play_options |
| 239 | { |
| 240 | const char *record; // OPTION_RECORD |
| 241 | const char *playback; // OPTION_PLAYBACK |
| 242 | const char *state; // OPTION_STATE |
| 243 | const char *wavwrite; // OPTION_WAVWRITE |
| 244 | const char *mngwrite; // OPTION_MNGWRITE |
| 245 | }; |
| 246 | |
| 247 | /*************************************************************************** |
| 248 | function prototypes |
| 249 | ***************************************************************************/ |
| 250 | |
| 251 | static BOOL Win32UI_init(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow); |
| 252 | static void Win32UI_exit(void); |
| 253 | |
| 254 | static BOOL PumpMessage(void); |
| 255 | static BOOL OnIdle(HWND hWnd); |
| 256 | static void OnSize(HWND hwnd, UINT state, int width, int height); |
| 257 | static long WINAPI MameWindowProc(HWND hwnd,UINT message,UINT wParam,LONG lParam); |
| 258 | |
| 259 | static void SetView(int menu_id); |
| 260 | static void ResetListView(void); |
| 261 | static void UpdateGameList(BOOL bUpdateRomAudit, BOOL bUpdateSampleAudit); |
| 262 | static void DestroyIcons(void); |
| 263 | static void ReloadIcons(void); |
| 264 | static void PollGUIJoystick(void); |
| 265 | static void PressKey(HWND hwnd,UINT vk); |
| 266 | static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify); |
| 267 | static void KeyboardKeyDown(int syskey, int vk_code, int special); |
| 268 | static void KeyboardKeyUp(int syskey, int vk_code, int special); |
| 269 | static void KeyboardStateClear(void); |
| 270 | |
| 271 | static void UpdateStatusBar(void); |
| 272 | static BOOL PickerHitTest(HWND hWnd); |
| 273 | static BOOL TreeViewNotify(NMHDR *nm); |
| 274 | |
| 275 | static void ResetBackground(char *szFile); |
| 276 | static void RandomSelectBackground(void); |
| 277 | static void LoadBackgroundBitmap(void); |
| 278 | static void PaintBackgroundImage(HWND hWnd, HRGN hRgn, int x, int y); |
| 279 | |
| 280 | static int CLIB_DECL DriverDataCompareFunc(const void *arg1,const void *arg2); |
| 281 | static int GamePicker_Compare(HWND hwndPicker, int index1, int index2, int sort_subitem); |
| 282 | |
| 283 | static void DisableSelection(void); |
| 284 | static void EnableSelection(int nGame); |
| 285 | |
| 286 | static HICON GetSelectedPickItemIcon(void); |
| 287 | static void SetRandomPickItem(void); |
| 288 | static void PickColor(COLORREF *cDefault); |
| 289 | |
| 290 | static LPTREEFOLDER GetSelectedFolder(void); |
| 291 | static HICON GetSelectedFolderIcon(void); |
| 292 | |
| 293 | static LRESULT CALLBACK HistoryWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 294 | static LRESULT CALLBACK PictureFrameWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 295 | static LRESULT CALLBACK PictureWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 296 | static INT_PTR CALLBACK LanguageDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam); |
| 297 | |
| 298 | static BOOL SelectLanguageFile(HWND hWnd, TCHAR* filename); |
| 299 | static void MamePlayRecordGame(void); |
| 300 | static void MamePlayBackGame(void); |
| 301 | static void MamePlayRecordWave(void); |
| 302 | static void MamePlayRecordMNG(void); |
| 303 | static void MameLoadState(void); |
| 304 | static void MamePlayGameWithOptions(int nGame, const play_options *playopts); |
| 305 | static BOOL GameCheck(void); |
| 306 | static BOOL FolderCheck(void); |
| 307 | |
| 308 | static void ToggleScreenShot(void); |
| 309 | static void AdjustMetrics(void); |
| 310 | static void EnablePlayOptions(int nIndex, core_options *o); |
| 311 | |
| 312 | /* Icon routines */ |
| 313 | static DWORD GetShellLargeIconSize(void); |
| 314 | static DWORD GetShellSmallIconSize(void); |
| 315 | static void CreateIcons(void); |
| 316 | static int GetIconForDriver(int nItem); |
| 317 | static void AddDriverIcon(int nItem,int default_icon_index); |
| 318 | |
| 319 | // Context Menu handlers |
| 320 | static void UpdateMenu(HMENU hMenu); |
| 321 | static void InitTreeContextMenu(HMENU hTreeMenu); |
| 322 | static void InitBodyContextMenu(HMENU hBodyContextMenu); |
| 323 | static void ToggleShowFolder(int folder); |
| 324 | static BOOL HandleTreeContextMenu( HWND hWnd, WPARAM wParam, LPARAM lParam); |
| 325 | static BOOL HandleScreenShotContextMenu( HWND hWnd, WPARAM wParam, LPARAM lParam); |
| 326 | static void GamePicker_OnHeaderContextMenu(POINT pt, int nColumn); |
| 327 | static void GamePicker_OnBodyContextMenu(POINT pt); |
| 328 | |
| 329 | static void InitListView(void); |
| 330 | /* Re/initialize the ListView header columns */ |
| 331 | static void ResetColumnDisplay(BOOL first_time); |
| 332 | |
| 333 | static void CopyToolTipText (LPTOOLTIPTEXT lpttt); |
| 334 | |
| 335 | static void ProgressBarShow(void); |
| 336 | static void ProgressBarHide(void); |
| 337 | static void ResizeProgressBar(void); |
| 338 | static void ProgressBarStep(void); |
| 339 | static void ProgressBarStepParam(int iGameIndex, int nGameCount); |
| 340 | |
| 341 | static HWND InitProgressBar(HWND hParent); |
| 342 | static HWND InitToolbar(HWND hParent); |
| 343 | static HWND InitStatusBar(HWND hParent); |
| 344 | |
| 345 | static LRESULT Statusbar_MenuSelect (HWND hwnd, WPARAM wParam, LPARAM lParam); |
| 346 | |
| 347 | static void UpdateHistory(void); |
| 348 | |
| 349 | |
| 350 | void RemoveCurrentGameCustomFolder(void); |
| 351 | void RemoveGameCustomFolder(int driver_index); |
| 352 | |
| 353 | void BeginListViewDrag(NM_LISTVIEW *pnmv); |
| 354 | void MouseMoveListViewDrag(POINTS pt); |
| 355 | void ButtonUpListViewDrag(POINTS p); |
| 356 | |
| 357 | void CalculateBestScreenShotRect(HWND hWnd, RECT *pRect, BOOL restrict_height); |
| 358 | |
| 359 | BOOL MouseHasBeenMoved(void); |
| 360 | void SwitchFullScreenMode(void); |
| 361 | |
| 362 | /*************************************************************************** |
| 363 | External variables |
| 364 | ***************************************************************************/ |
| 365 | |
| 366 | /*************************************************************************** |
| 367 | Internal structures |
| 368 | ***************************************************************************/ |
| 369 | |
| 370 | /* |
| 371 | * These next two structs represent how the icon information |
| 372 | * is stored in an ICO file. |
| 373 | */ |
| 374 | typedef struct |
| 375 | { |
| 376 | BYTE bWidth; /* Width of the image */ |
| 377 | BYTE bHeight; /* Height of the image (times 2) */ |
| 378 | BYTE bColorCount; /* Number of colors in image (0 if >=8bpp) */ |
| 379 | BYTE bReserved; /* Reserved */ |
| 380 | WORD wPlanes; /* Color Planes */ |
| 381 | WORD wBitCount; /* Bits per pixel */ |
| 382 | DWORD dwBytesInRes; /* how many bytes in this resource? */ |
| 383 | DWORD dwImageOffset; /* where in the file is this image */ |
| 384 | } ICONDIRENTRY, *LPICONDIRENTRY; |
| 385 | |
| 386 | typedef struct |
| 387 | { |
| 388 | UINT Width, Height, Colors; /* Width, Height and bpp */ |
| 389 | LPBYTE lpBits; /* ptr to DIB bits */ |
| 390 | DWORD dwNumBytes; /* how many bytes? */ |
| 391 | LPBITMAPINFO lpbi; /* ptr to header */ |
| 392 | LPBYTE lpXOR; /* ptr to XOR image bits */ |
| 393 | LPBYTE lpAND; /* ptr to AND image bits */ |
| 394 | } ICONIMAGE, *LPICONIMAGE; |
| 395 | |
| 396 | /* Which edges of a control are anchored to the corresponding side of the parent window */ |
| 397 | #define RA_LEFT 0x01 |
| 398 | #define RA_RIGHT 0x02 |
| 399 | #define RA_TOP 0x04 |
| 400 | #define RA_BOTTOM 0x08 |
| 401 | #define RA_ALL 0x0F |
| 402 | |
| 403 | #define RA_END 0 |
| 404 | #define RA_ID 1 |
| 405 | #define RA_HWND 2 |
| 406 | |
| 407 | typedef struct |
| 408 | { |
| 409 | int type; /* Either RA_ID or RA_HWND, to indicate which member of u is used; or RA_END |
| 410 | to signify last entry */ |
| 411 | union /* Can identify a child window by control id or by handle */ |
| 412 | { |
| 413 | int id; /* Window control id */ |
| 414 | HWND hwnd; /* Window handle */ |
| 415 | } u; |
| 416 | BOOL setfont; /* Do we set this item's font? */ |
| 417 | int action; /* What to do when control is resized */ |
| 418 | void *subwindow; /* Points to a Resize structure for this subwindow; NULL if none */ |
| 419 | } ResizeItem; |
| 420 | |
| 421 | typedef struct |
| 422 | { |
| 423 | RECT rect; /* Client rect of window; must be initialized before first resize */ |
| 424 | ResizeItem* items; /* Array of subitems to be resized */ |
| 425 | } Resize; |
| 426 | |
| 427 | static void ResizeWindow(HWND hParent, Resize *r); |
| 428 | static void SetAllWindowsFont(HWND hParent, const Resize *r, HFONT hFont, BOOL bRedraw); |
| 429 | |
| 430 | /* List view Icon defines */ |
| 431 | #define LG_ICONMAP_WIDTH GetSystemMetrics(SM_CXICON) |
| 432 | #define LG_ICONMAP_HEIGHT GetSystemMetrics(SM_CYICON) |
| 433 | #define ICONMAP_WIDTH GetSystemMetrics(SM_CXSMICON) |
| 434 | #define ICONMAP_HEIGHT GetSystemMetrics(SM_CYSMICON) |
| 435 | |
| 436 | typedef struct tagPOPUPSTRING |
| 437 | { |
| 438 | HMENU hMenu; |
| 439 | UINT uiString; |
| 440 | } POPUPSTRING; |
| 441 | |
| 442 | #define MAX_MENUS 3 |
| 443 | |
| 444 | #define SPLITTER_WIDTH 4 |
| 445 | #define MIN_VIEW_WIDTH 10 |
| 446 | |
| 447 | // Struct needed for Game Window Communication |
| 448 | |
| 449 | typedef struct |
| 450 | { |
| 451 | LPPROCESS_INFORMATION ProcessInfo; |
| 452 | HWND hwndFound; |
| 453 | } FINDWINDOWHANDLE; |
| 454 | |
| 455 | /*************************************************************************** |
| 456 | Internal variables |
| 457 | ***************************************************************************/ |
| 458 | |
| 459 | static HWND hMain = NULL; |
| 460 | static HACCEL hAccel = NULL; |
| 461 | |
| 462 | static HWND hwndList = NULL; |
| 463 | static HWND hTreeView = NULL; |
| 464 | static HWND hProgWnd = NULL; |
| 465 | static HWND hTabCtrl = NULL; |
| 466 | |
| 467 | static HINSTANCE hInst = NULL; |
| 468 | |
| 469 | static HFONT hFont = NULL; /* Font for list view */ |
| 470 | |
| 471 | static int optionfolder_count = 0; |
| 472 | |
| 473 | /* global data--know where to send messages */ |
| 474 | static BOOL in_emulation; |
| 475 | |
| 476 | /* idle work at startup */ |
| 477 | static BOOL idle_work; |
| 478 | |
| 479 | /* object pool in use */ |
| 480 | static object_pool *mame32_pool; |
| 481 | |
| 482 | static int game_index; |
| 483 | static int progBarStep; |
| 484 | |
| 485 | static BOOL bDoGameCheck = FALSE; |
| 486 | |
| 487 | /* Tree control variables */ |
| 488 | static BOOL bShowTree = 1; |
| 489 | static BOOL bShowToolBar = 1; |
| 490 | static BOOL bShowStatusBar = 1; |
| 491 | static BOOL bShowTabCtrl = 1; |
| 492 | static BOOL bProgressShown = FALSE; |
| 493 | static BOOL bListReady = FALSE; |
| 494 | |
| 495 | #define WM_MAME32_FILECHANGED (WM_USER + 0) |
| 496 | #define WM_MAME32_AUDITGAME (WM_USER + 1) |
| 497 | |
| 498 | static PDIRWATCHER s_pWatcher; |
| 499 | |
| 500 | /* use a joystick subsystem in the gui? */ |
| 501 | static struct OSDJoystick* g_pJoyGUI = NULL; |
| 502 | |
| 503 | /* store current keyboard state (in internal codes) here */ |
| 504 | static input_code keyboard_state[ 2048 ]; /* __code_max #defines the number of internal key_codes */ |
| 505 | |
| 506 | /* search */ |
| 507 | static char g_SearchText[256]; |
| 508 | /* table copied from windows/inputs.c */ |
| 509 | // table entry indices |
| 510 | #define MAME_KEY 0 |
| 511 | #define DI_KEY 1 |
| 512 | #define VIRTUAL_KEY 2 |
| 513 | #define ASCII_KEY 3 |
| 514 | |
| 515 | // master keyboard translation table |
| 516 | static const int win_key_trans_table[][4] = |
| 517 | { |
| 518 | // MAME key dinput key virtual key ascii |
| 519 | { ITEM_ID_ESC, DIK_ESCAPE, VK_ESCAPE, 27 }, |
| 520 | { ITEM_ID_1, DIK_1, '1', '1' }, |
| 521 | { ITEM_ID_2, DIK_2, '2', '2' }, |
| 522 | { ITEM_ID_3, DIK_3, '3', '3' }, |
| 523 | { ITEM_ID_4, DIK_4, '4', '4' }, |
| 524 | { ITEM_ID_5, DIK_5, '5', '5' }, |
| 525 | { ITEM_ID_6, DIK_6, '6', '6' }, |
| 526 | { ITEM_ID_7, DIK_7, '7', '7' }, |
| 527 | { ITEM_ID_8, DIK_8, '8', '8' }, |
| 528 | { ITEM_ID_9, DIK_9, '9', '9' }, |
| 529 | { ITEM_ID_0, DIK_0, '0', '0' }, |
| 530 | { ITEM_ID_BACKSPACE, DIK_BACK, VK_BACK, 8 }, |
| 531 | { ITEM_ID_TAB, DIK_TAB, VK_TAB, 9 }, |
| 532 | { ITEM_ID_Q, DIK_Q, 'Q', 'Q' }, |
| 533 | { ITEM_ID_W, DIK_W, 'W', 'W' }, |
| 534 | { ITEM_ID_E, DIK_E, 'E', 'E' }, |
| 535 | { ITEM_ID_R, DIK_R, 'R', 'R' }, |
| 536 | { ITEM_ID_T, DIK_T, 'T', 'T' }, |
| 537 | { ITEM_ID_Y, DIK_Y, 'Y', 'Y' }, |
| 538 | { ITEM_ID_U, DIK_U, 'U', 'U' }, |
| 539 | { ITEM_ID_I, DIK_I, 'I', 'I' }, |
| 540 | { ITEM_ID_O, DIK_O, 'O', 'O' }, |
| 541 | { ITEM_ID_P, DIK_P, 'P', 'P' }, |
| 542 | { ITEM_ID_OPENBRACE, DIK_LBRACKET, VK_OEM_4, '[' }, |
| 543 | { ITEM_ID_CLOSEBRACE, DIK_RBRACKET, VK_OEM_6, ']' }, |
| 544 | { ITEM_ID_ENTER, DIK_RETURN, VK_RETURN, 13 }, |
| 545 | { ITEM_ID_LCONTROL, DIK_LCONTROL, VK_LCONTROL, 0 }, |
| 546 | { ITEM_ID_A, DIK_A, 'A', 'A' }, |
| 547 | { ITEM_ID_S, DIK_S, 'S', 'S' }, |
| 548 | { ITEM_ID_D, DIK_D, 'D', 'D' }, |
| 549 | { ITEM_ID_F, DIK_F, 'F', 'F' }, |
| 550 | { ITEM_ID_G, DIK_G, 'G', 'G' }, |
| 551 | { ITEM_ID_H, DIK_H, 'H', 'H' }, |
| 552 | { ITEM_ID_J, DIK_J, 'J', 'J' }, |
| 553 | { ITEM_ID_K, DIK_K, 'K', 'K' }, |
| 554 | { ITEM_ID_L, DIK_L, 'L', 'L' }, |
| 555 | { ITEM_ID_COLON, DIK_SEMICOLON, VK_OEM_1, ';' }, |
| 556 | { ITEM_ID_QUOTE, DIK_APOSTROPHE, VK_OEM_7, '\'' }, |
| 557 | { ITEM_ID_TILDE, DIK_GRAVE, VK_OEM_3, '`' }, |
| 558 | { ITEM_ID_LSHIFT, DIK_LSHIFT, VK_LSHIFT, 0 }, |
| 559 | { ITEM_ID_BACKSLASH, DIK_BACKSLASH, VK_OEM_5, '\\' }, |
| 560 | { ITEM_ID_Z, DIK_Z, 'Z', 'Z' }, |
| 561 | { ITEM_ID_X, DIK_X, 'X', 'X' }, |
| 562 | { ITEM_ID_C, DIK_C, 'C', 'C' }, |
| 563 | { ITEM_ID_V, DIK_V, 'V', 'V' }, |
| 564 | { ITEM_ID_B, DIK_B, 'B', 'B' }, |
| 565 | { ITEM_ID_N, DIK_N, 'N', 'N' }, |
| 566 | { ITEM_ID_M, DIK_M, 'M', 'M' }, |
| 567 | { ITEM_ID_SLASH, DIK_SLASH, VK_OEM_2, '/' }, |
| 568 | { ITEM_ID_RSHIFT, DIK_RSHIFT, VK_RSHIFT, 0 }, |
| 569 | { ITEM_ID_ASTERISK, DIK_MULTIPLY, VK_MULTIPLY, '*' }, |
| 570 | { ITEM_ID_LALT, DIK_LMENU, VK_LMENU, 0 }, |
| 571 | { ITEM_ID_SPACE, DIK_SPACE, VK_SPACE, ' ' }, |
| 572 | { ITEM_ID_CAPSLOCK, DIK_CAPITAL, VK_CAPITAL, 0 }, |
| 573 | { ITEM_ID_F1, DIK_F1, VK_F1, 0 }, |
| 574 | { ITEM_ID_F2, DIK_F2, VK_F2, 0 }, |
| 575 | { ITEM_ID_F3, DIK_F3, VK_F3, 0 }, |
| 576 | { ITEM_ID_F4, DIK_F4, VK_F4, 0 }, |
| 577 | { ITEM_ID_F5, DIK_F5, VK_F5, 0 }, |
| 578 | { ITEM_ID_F6, DIK_F6, VK_F6, 0 }, |
| 579 | { ITEM_ID_F7, DIK_F7, VK_F7, 0 }, |
| 580 | { ITEM_ID_F8, DIK_F8, VK_F8, 0 }, |
| 581 | { ITEM_ID_F9, DIK_F9, VK_F9, 0 }, |
| 582 | { ITEM_ID_F10, DIK_F10, VK_F10, 0 }, |
| 583 | { ITEM_ID_NUMLOCK, DIK_NUMLOCK, VK_NUMLOCK, 0 }, |
| 584 | { ITEM_ID_SCRLOCK, DIK_SCROLL, VK_SCROLL, 0 }, |
| 585 | { ITEM_ID_7_PAD, DIK_NUMPAD7, VK_NUMPAD7, 0 }, |
| 586 | { ITEM_ID_8_PAD, DIK_NUMPAD8, VK_NUMPAD8, 0 }, |
| 587 | { ITEM_ID_9_PAD, DIK_NUMPAD9, VK_NUMPAD9, 0 }, |
| 588 | { ITEM_ID_MINUS_PAD, DIK_SUBTRACT, VK_SUBTRACT, 0 }, |
| 589 | { ITEM_ID_4_PAD, DIK_NUMPAD4, VK_NUMPAD4, 0 }, |
| 590 | { ITEM_ID_5_PAD, DIK_NUMPAD5, VK_NUMPAD5, 0 }, |
| 591 | { ITEM_ID_6_PAD, DIK_NUMPAD6, VK_NUMPAD6, 0 }, |
| 592 | { ITEM_ID_PLUS_PAD, DIK_ADD, VK_ADD, 0 }, |
| 593 | { ITEM_ID_1_PAD, DIK_NUMPAD1, VK_NUMPAD1, 0 }, |
| 594 | { ITEM_ID_2_PAD, DIK_NUMPAD2, VK_NUMPAD2, 0 }, |
| 595 | { ITEM_ID_3_PAD, DIK_NUMPAD3, VK_NUMPAD3, 0 }, |
| 596 | { ITEM_ID_0_PAD, DIK_NUMPAD0, VK_NUMPAD0, 0 }, |
| 597 | { ITEM_ID_DEL_PAD, DIK_DECIMAL, VK_DECIMAL, 0 }, |
| 598 | { ITEM_ID_F11, DIK_F11, VK_F11, 0 }, |
| 599 | { ITEM_ID_F12, DIK_F12, VK_F12, 0 }, |
| 600 | { ITEM_ID_F13, DIK_F13, VK_F13, 0 }, |
| 601 | { ITEM_ID_F14, DIK_F14, VK_F14, 0 }, |
| 602 | { ITEM_ID_F15, DIK_F15, VK_F15, 0 }, |
| 603 | { ITEM_ID_ENTER_PAD, DIK_NUMPADENTER, VK_RETURN, 0 }, |
| 604 | { ITEM_ID_RCONTROL, DIK_RCONTROL, VK_RCONTROL, 0 }, |
| 605 | { ITEM_ID_SLASH_PAD, DIK_DIVIDE, VK_DIVIDE, 0 }, |
| 606 | { ITEM_ID_PRTSCR, DIK_SYSRQ, 0, 0 }, |
| 607 | { ITEM_ID_RALT, DIK_RMENU, VK_RMENU, 0 }, |
| 608 | { ITEM_ID_HOME, DIK_HOME, VK_HOME, 0 }, |
| 609 | { ITEM_ID_UP, DIK_UP, VK_UP, 0 }, |
| 610 | { ITEM_ID_PGUP, DIK_PRIOR, VK_PRIOR, 0 }, |
| 611 | { ITEM_ID_LEFT, DIK_LEFT, VK_LEFT, 0 }, |
| 612 | { ITEM_ID_RIGHT, DIK_RIGHT, VK_RIGHT, 0 }, |
| 613 | { ITEM_ID_END, DIK_END, VK_END, 0 }, |
| 614 | { ITEM_ID_DOWN, DIK_DOWN, VK_DOWN, 0 }, |
| 615 | { ITEM_ID_PGDN, DIK_NEXT, VK_NEXT, 0 }, |
| 616 | { ITEM_ID_INSERT, DIK_INSERT, VK_INSERT, 0 }, |
| 617 | { ITEM_ID_DEL, DIK_DELETE, VK_DELETE, 0 }, |
| 618 | { ITEM_ID_LWIN, DIK_LWIN, VK_LWIN, 0 }, |
| 619 | { ITEM_ID_RWIN, DIK_RWIN, VK_RWIN, 0 }, |
| 620 | { ITEM_ID_MENU, DIK_APPS, VK_APPS, 0 }, |
| 621 | { ITEM_ID_PAUSE, DIK_PAUSE, VK_PAUSE, 0 }, |
| 622 | { ITEM_ID_CANCEL, 0, VK_CANCEL, 0 }, |
| 623 | }; |
| 624 | |
| 625 | |
| 626 | |
| 627 | typedef struct |
| 628 | { |
| 629 | char name[40]; // functionality name (optional) |
| 630 | input_seq is; // the input sequence (the keys pressed) |
| 631 | UINT func_id; // the identifier |
| 632 | input_seq* (*getiniptr)(void);// pointer to function to get the value from .ini file |
| 633 | } GUISequence; |
| 634 | |
| 635 | static GUISequence GUISequenceControl[]= |
| 636 | { |
| 637 | {"gui_key_up", SEQ_DEF_0, ID_UI_UP, Get_ui_key_up }, |
| 638 | {"gui_key_down", SEQ_DEF_0, ID_UI_DOWN, Get_ui_key_down }, |
| 639 | {"gui_key_left", SEQ_DEF_0, ID_UI_LEFT, Get_ui_key_left }, |
| 640 | {"gui_key_right", SEQ_DEF_0, ID_UI_RIGHT, Get_ui_key_right }, |
| 641 | {"gui_key_start", SEQ_DEF_0, ID_UI_START, Get_ui_key_start }, |
| 642 | {"gui_key_pgup", SEQ_DEF_0, ID_UI_PGUP, Get_ui_key_pgup }, |
| 643 | {"gui_key_pgdwn", SEQ_DEF_0, ID_UI_PGDOWN, Get_ui_key_pgdwn }, |
| 644 | {"gui_key_home", SEQ_DEF_0, ID_UI_HOME, Get_ui_key_home }, |
| 645 | {"gui_key_end", SEQ_DEF_0, ID_UI_END, Get_ui_key_end }, |
| 646 | {"gui_key_ss_change", SEQ_DEF_0, IDC_SSFRAME, Get_ui_key_ss_change }, |
| 647 | {"gui_key_history_up", SEQ_DEF_0, ID_UI_HISTORY_UP, Get_ui_key_history_up }, |
| 648 | {"gui_key_history_down", SEQ_DEF_0, ID_UI_HISTORY_DOWN, Get_ui_key_history_down }, |
| 649 | |
| 650 | {"gui_key_context_filters", SEQ_DEF_0, ID_CONTEXT_FILTERS, Get_ui_key_context_filters }, |
| 651 | {"gui_key_select_random", SEQ_DEF_0, ID_CONTEXT_SELECT_RANDOM, Get_ui_key_select_random }, |
| 652 | {"gui_key_game_audit", SEQ_DEF_0, ID_GAME_AUDIT, Get_ui_key_game_audit }, |
| 653 | {"gui_key_game_properties", SEQ_DEF_0, ID_GAME_PROPERTIES, Get_ui_key_game_properties }, |
| 654 | {"gui_key_help_contents", SEQ_DEF_0, ID_HELP_CONTENTS, Get_ui_key_help_contents }, |
| 655 | {"gui_key_update_gamelist", SEQ_DEF_0, ID_UPDATE_GAMELIST, Get_ui_key_update_gamelist }, |
| 656 | {"gui_key_view_folders", SEQ_DEF_0, ID_VIEW_FOLDERS, Get_ui_key_view_folders }, |
| 657 | {"gui_key_view_fullscreen", SEQ_DEF_0, ID_VIEW_FULLSCREEN, Get_ui_key_view_fullscreen }, |
| 658 | {"gui_key_view_pagetab", SEQ_DEF_0, ID_VIEW_PAGETAB, Get_ui_key_view_pagetab }, |
| 659 | {"gui_key_view_picture_area", SEQ_DEF_0, ID_VIEW_PICTURE_AREA, Get_ui_key_view_picture_area }, |
| 660 | {"gui_key_view_status", SEQ_DEF_0, ID_VIEW_STATUS, Get_ui_key_view_status }, |
| 661 | {"gui_key_view_toolbars", SEQ_DEF_0, ID_VIEW_TOOLBARS, Get_ui_key_view_toolbars }, |
| 662 | |
| 663 | {"gui_key_view_tab_cabinet", SEQ_DEF_0, ID_VIEW_TAB_CABINET, Get_ui_key_view_tab_cabinet }, |
| 664 | {"gui_key_view_tab_cpanel", SEQ_DEF_0, ID_VIEW_TAB_CONTROL_PANEL, Get_ui_key_view_tab_cpanel }, |
| 665 | {"gui_key_view_tab_flyer", SEQ_DEF_0, ID_VIEW_TAB_FLYER, Get_ui_key_view_tab_flyer }, |
| 666 | {"gui_key_view_tab_history", SEQ_DEF_0, ID_VIEW_TAB_HISTORY, Get_ui_key_view_tab_history }, |
| 667 | {"gui_key_view_tab_marquee", SEQ_DEF_0, ID_VIEW_TAB_MARQUEE, Get_ui_key_view_tab_marquee }, |
| 668 | {"gui_key_view_tab_screenshot", SEQ_DEF_0, ID_VIEW_TAB_SCREENSHOT, Get_ui_key_view_tab_screenshot }, |
| 669 | {"gui_key_view_tab_title", SEQ_DEF_0, ID_VIEW_TAB_TITLE, Get_ui_key_view_tab_title }, |
| 670 | {"gui_key_view_tab_pcb", SEQ_DEF_0, ID_VIEW_TAB_PCB, Get_ui_key_view_tab_pcb }, |
| 671 | {"gui_key_quit", SEQ_DEF_0, ID_FILE_EXIT, Get_ui_key_quit }, |
| 672 | }; |
| 673 | |
| 674 | |
| 675 | #define NUM_GUI_SEQUENCES (sizeof(GUISequenceControl) / sizeof(GUISequenceControl[0])) |
| 676 | |
| 677 | |
| 678 | static UINT lastColumnClick = 0; |
| 679 | static WNDPROC g_lpHistoryWndProc = NULL; |
| 680 | static WNDPROC g_lpPictureFrameWndProc = NULL; |
| 681 | static WNDPROC g_lpPictureWndProc = NULL; |
| 682 | |
| 683 | static POPUPSTRING popstr[MAX_MENUS + 1]; |
| 684 | |
| 685 | /* Tool and Status bar variables */ |
| 686 | static HWND hStatusBar = 0; |
| 687 | static HWND hToolBar = 0; |
| 688 | |
| 689 | /* Column Order as Displayed */ |
| 690 | static BOOL oldControl = FALSE; |
| 691 | static BOOL xpControl = FALSE; |
| 692 | |
| 693 | /* Used to recalculate the main window layout */ |
| 694 | static int bottomMargin; |
| 695 | static int topMargin; |
| 696 | static int have_history = FALSE; |
| 697 | |
| 698 | static BOOL have_selection = FALSE; |
| 699 | |
| 700 | static HBITMAP hMissing_bitmap; |
| 701 | |
| 702 | /* Icon variables */ |
| 703 | static HIMAGELIST hLarge = NULL; |
| 704 | static HIMAGELIST hSmall = NULL; |
| 705 | static HIMAGELIST hHeaderImages = NULL; |
| 706 | static int *icon_index = NULL; /* for custom per-game icons */ |
| 707 | |
| 708 | static TBBUTTON tbb[] = |
| 709 | { |
| 710 | {0, ID_VIEW_FOLDERS, TBSTATE_ENABLED, TBSTYLE_CHECK, {0, 0}, 0, 0}, |
| 711 | {1, ID_VIEW_PICTURE_AREA,TBSTATE_ENABLED, TBSTYLE_CHECK, {0, 0}, 0, 1}, |
| 712 | {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0}, |
| 713 | {2, ID_VIEW_LARGE_ICON, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, {0, 0}, 0, 2}, |
| 714 | {3, ID_VIEW_SMALL_ICON, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, {0, 0}, 0, 3}, |
| 715 | {4, ID_VIEW_LIST_MENU, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, {0, 0}, 0, 4}, |
| 716 | {5, ID_VIEW_DETAIL, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, {0, 0}, 0, 5}, |
| 717 | {6, ID_VIEW_GROUPED, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, {0, 0}, 0, 6}, |
| 718 | {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0}, |
| 719 | {7, ID_HELP_ABOUT, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 7}, |
| 720 | {8, ID_HELP_CONTENTS, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 8} |
| 721 | }; |
| 722 | |
| 723 | #define NUM_TOOLBUTTONS (sizeof(tbb) / sizeof(tbb[0])) |
| 724 | |
| 725 | #define NUM_TOOLTIPS 8 |
| 726 | |
| 727 | static const TCHAR szTbStrings[NUM_TOOLTIPS + 1][30] = |
| 728 | { |
| 729 | TEXT("Toggle Folder List"), |
| 730 | TEXT("Toggle Screen Shot"), |
| 731 | TEXT("Large Icons"), |
| 732 | TEXT("Small Icons"), |
| 733 | TEXT("List"), |
| 734 | TEXT("Details"), |
| 735 | TEXT("Grouped"), |
| 736 | TEXT("About"), |
| 737 | TEXT("Help") |
| 738 | }; |
| 739 | |
| 740 | static const int CommandToString[] = |
| 741 | { |
| 742 | ID_VIEW_FOLDERS, |
| 743 | ID_VIEW_PICTURE_AREA, |
| 744 | ID_VIEW_LARGE_ICON, |
| 745 | ID_VIEW_SMALL_ICON, |
| 746 | ID_VIEW_LIST_MENU, |
| 747 | ID_VIEW_DETAIL, |
| 748 | ID_VIEW_GROUPED, |
| 749 | ID_HELP_ABOUT, |
| 750 | ID_HELP_CONTENTS, |
| 751 | -1 |
| 752 | }; |
| 753 | |
| 754 | static const int s_nPickers[] = |
| 755 | { |
| 756 | IDC_LIST |
| 757 | #ifdef MESS |
| 758 | ,IDC_SWLIST |
| 759 | #endif |
| 760 | }; |
| 761 | |
| 762 | /* How to resize main window */ |
| 763 | static ResizeItem main_resize_items[] = |
| 764 | { |
| 765 | { RA_HWND, { 0 }, FALSE, RA_LEFT | RA_RIGHT | RA_TOP, NULL }, |
| 766 | { RA_HWND, { 0 }, FALSE, RA_LEFT | RA_RIGHT | RA_BOTTOM, NULL }, |
| 767 | { RA_ID, { IDC_DIVIDER }, FALSE, RA_LEFT | RA_RIGHT | RA_TOP, NULL }, |
| 768 | { RA_ID, { IDC_TREE }, TRUE, RA_LEFT | RA_BOTTOM | RA_TOP, NULL }, |
| 769 | { RA_ID, { IDC_LIST }, TRUE, RA_ALL, NULL }, |
| 770 | { RA_ID, { IDC_SPLITTER }, FALSE, RA_LEFT | RA_BOTTOM | RA_TOP, NULL }, |
| 771 | { RA_ID, { IDC_SPLITTER2 },FALSE, RA_RIGHT | RA_BOTTOM | RA_TOP, NULL }, |
| 772 | { RA_ID, { IDC_SSFRAME }, FALSE, RA_RIGHT | RA_BOTTOM | RA_TOP, NULL }, |
| 773 | { RA_ID, { IDC_SSPICTURE },FALSE, RA_RIGHT | RA_BOTTOM | RA_TOP, NULL }, |
| 774 | { RA_ID, { IDC_HISTORY }, TRUE, RA_RIGHT | RA_BOTTOM | RA_TOP, NULL }, |
| 775 | { RA_ID, { IDC_SSTAB }, FALSE, RA_RIGHT | RA_TOP, NULL }, |
| 776 | #ifdef MESS |
| 777 | { RA_ID, { IDC_SWLIST }, TRUE, RA_RIGHT | RA_BOTTOM | RA_TOP, NULL }, |
| 778 | { RA_ID, { IDC_SPLITTER3 },FALSE, RA_RIGHT | RA_BOTTOM | RA_TOP, NULL }, |
| 779 | #endif /* MESS */ |
| 780 | { RA_END, { 0 }, FALSE, 0, NULL } |
| 781 | }; |
| 782 | |
| 783 | static Resize main_resize = { {0, 0, 0, 0}, main_resize_items }; |
| 784 | |
| 785 | /* last directory for common file dialogs */ |
| 786 | TCHAR last_directory[MAX_PATH]; |
| 787 | |
| 788 | /* system-wide window message sent out with an ATOM of the current game name |
| 789 | each time it changes */ |
| 790 | static UINT g_mame32_message = 0; |
| 791 | static BOOL g_bDoBroadcast = FALSE; |
| 792 | |
| 793 | static BOOL use_gui_romloading = FALSE; |
| 794 | |
| 795 | static BOOL g_listview_dragging = FALSE; |
| 796 | HIMAGELIST himl_drag; |
| 797 | int game_dragged; /* which game started the drag */ |
| 798 | HTREEITEM prev_drag_drop_target; /* which tree view item we're currently highlighting */ |
| 799 | |
| 800 | static BOOL g_in_treeview_edit = FALSE; |
| 801 | |
| 802 | typedef struct |
| 803 | { |
| 804 | const char *name; |
| 805 | int index; |
| 806 | } driver_data_type; |
| 807 | static driver_data_type *sorted_drivers; |
| 808 | |
| 809 | /*************************************************************************** |
| 810 | Global variables |
| 811 | ***************************************************************************/ |
| 812 | |
| 813 | /* Background Image handles also accessed from TreeView.c */ |
| 814 | static HPALETTE hPALbg = 0; |
| 815 | static HBITMAP hBackground = 0; |
| 816 | static MYBITMAPINFO bmDesc; |
| 817 | |
| 818 | /* List view Column text */ |
| 819 | LPCTSTR column_names[COLUMN_MAX] = |
| 820 | { |
| 821 | #ifdef MESS |
| 822 | TEXT("System"), |
| 823 | #else |
| 824 | TEXT("Game"), |
| 825 | #endif |
| 826 | TEXT("Screen"), |
| 827 | //TEXT("ROMs"), |
| 828 | TEXT("Samples"), |
| 829 | TEXT("Directory"), |
| 830 | TEXT("Type"), |
| 831 | TEXT("Trackball"), |
| 832 | TEXT("Played"), |
| 833 | TEXT("Manufacturer"), |
| 834 | TEXT("Year"), |
| 835 | TEXT("Clone Of"), |
| 836 | TEXT("Source"), |
| 837 | TEXT("Play Time") |
| 838 | }; |
| 839 | |
| 840 | /*************************************************************************** |
| 841 | Message Macros |
| 842 | ***************************************************************************/ |
| 843 | |
| 844 | #ifndef StatusBar_GetItemRect |
| 845 | #define StatusBar_GetItemRect(hWnd, iPart, lpRect) \ |
| 846 | SendMessage(hWnd, SB_GETRECT, (WPARAM) iPart, (LPARAM) (LPRECT) lpRect) |
| 847 | #endif |
| 848 | |
| 849 | #ifndef ToolBar_CheckButton |
| 850 | #define ToolBar_CheckButton(hWnd, idButton, fCheck) \ |
| 851 | SendMessage(hWnd, TB_CHECKBUTTON, (WPARAM)idButton, (LPARAM)MAKELONG(fCheck, 0)) |
| 852 | #endif |
| 853 | |
| 854 | /*************************************************************************** |
| 855 | External functions |
| 856 | ***************************************************************************/ |
| 857 | |
| 858 | static void CopyOptions(core_options *pDestOpts, core_options *pSourceOpts) |
| 859 | { |
| 860 | options_enumerator *enumerator; |
| 861 | const char *option_name; |
| 862 | const char *option_value; |
| 863 | |
| 864 | enumerator = options_enumerator_begin(pSourceOpts); |
| 865 | if (enumerator != NULL) |
| 866 | { |
| 867 | while((option_name = options_enumerator_next(enumerator)) != NULL) |
| 868 | { |
| 869 | option_value = options_get_string(pSourceOpts, option_name); |
| 870 | if (option_value != NULL) |
| 871 | { |
| 872 | dprintf("CopyOptions(): Copying %s = \"%s\"\n", option_name, option_value); |
| 873 | options_set_string(pDestOpts, option_name, option_value, OPTION_PRIORITY_CMDLINE); |
| 874 | } |
| 875 | } |
| 876 | options_enumerator_free(enumerator); |
| 877 | } |
| 878 | } |
| 879 | |
| 880 | |
| 881 | |
| 882 | static BOOL WaitWithMessageLoop(HANDLE hEvent) |
| 883 | { |
| 884 | DWORD dwRet; |
| 885 | MSG msg; |
| 886 | |
| 887 | while (1) |
| 888 | { |
| 889 | dwRet = MsgWaitForMultipleObjects(1, &hEvent, FALSE, INFINITE, QS_ALLINPUT); |
| 890 | |
| 891 | if (dwRet == WAIT_OBJECT_0) |
| 892 | return TRUE; |
| 893 | |
| 894 | if (dwRet != WAIT_OBJECT_0 + 1) |
| 895 | break; |
| 896 | |
| 897 | while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) |
| 898 | { |
| 899 | TranslateMessage(&msg); |
| 900 | DispatchMessage(&msg); |
| 901 | if (WaitForSingleObject(hEvent, 0) == WAIT_OBJECT_0) |
| 902 | return TRUE; |
| 903 | } |
| 904 | } |
| 905 | return FALSE; |
| 906 | } |
| 907 | |
| 908 | static DWORD RunMAME(int nGameIndex, const play_options *playopts) |
| 909 | { |
| 910 | time_t start, end; |
| 911 | double elapsedtime; |
| 912 | DWORD dwExitCode = 0; |
| 913 | int i; |
| 914 | core_options *mame_opts; |
| 915 | |
| 916 | // set up MAME options |
| 917 | mame_opts = mame_options_init(mame_win_options); |
| 918 | |
| 919 | #ifdef MESS |
| 920 | // add MESS specific device options |
| 921 | mess_add_device_options(mame_opts, drivers[nGameIndex]); |
| 922 | #endif // MESS |
| 923 | |
| 924 | // set any specified play options |
| 925 | if (playopts != NULL) |
| 926 | { |
| 927 | if (playopts->record != NULL) |
| 928 | options_set_string(mame_opts, OPTION_RECORD, playopts->record, OPTION_PRIORITY_CMDLINE); |
| 929 | if (playopts->playback != NULL) |
| 930 | options_set_string(mame_opts, OPTION_PLAYBACK, playopts->playback, OPTION_PRIORITY_CMDLINE); |
| 931 | if (playopts->state != NULL) |
| 932 | options_set_string(mame_opts, OPTION_STATE, playopts->state, OPTION_PRIORITY_CMDLINE); |
| 933 | if (playopts->wavwrite != NULL) |
| 934 | options_set_string(mame_opts, OPTION_WAVWRITE, playopts->wavwrite, OPTION_PRIORITY_CMDLINE); |
| 935 | if (playopts->mngwrite != NULL) |
| 936 | options_set_string(mame_opts, OPTION_MNGWRITE, playopts->mngwrite, OPTION_PRIORITY_CMDLINE); |
| 937 | } |
| 938 | |
| 939 | // Mame will parse all the needed .ini files. |
| 940 | |
| 941 | // prepare MAME32 to run the game |
| 942 | ShowWindow(hMain, SW_HIDE); |
| 943 | |
| 944 | for (i = 0; i < ARRAY_LENGTH(s_nPickers); i++) |
| 945 | Picker_ClearIdle(GetDlgItem(hMain, s_nPickers[i])); |
| 946 | |
| 947 | // run the emulation |
| 948 | options_set_string(mame_opts, OPTION_GAMENAME, drivers[nGameIndex]->name, OPTION_PRIORITY_CMDLINE); |
| 949 | // Time the game run. |
| 950 | time(&start); |
| 951 | mame_execute(mame_opts); |
| 952 | // Calc the duration |
| 953 | time(&end); |
| 954 | elapsedtime = end - start; |
| 955 | // Increment our playtime. |
| 956 | IncrementPlayTime(nGameIndex, elapsedtime); |
| 957 | // the emulation is complete; continue |
| 958 | for (i = 0; i < ARRAY_LENGTH(s_nPickers); i++) |
| 959 | Picker_ResetIdle(GetDlgItem(hMain, s_nPickers[i])); |
| 960 | ShowWindow(hMain, SW_SHOW); |
| 961 | SetForegroundWindow(hMain); |
| 962 | |
| 963 | return dwExitCode; |
| 964 | } |
| 965 | |
| 966 | int Mame32Main(HINSTANCE hInstance, |
| 967 | LPSTR lpCmdLine, |
| 968 | int nCmdShow) |
| 969 | { |
| 970 | dprintf("MAME32 starting\n"); |
| 971 | |
| 972 | use_gui_romloading = TRUE; |
| 973 | |
| 974 | if (__argc != 1) |
| 975 | { |
| 976 | /* Rename main because gcc will use it instead of WinMain even with -mwindows */ |
| 977 | extern int DECL_SPEC mame_main(int, char**); |
| 978 | exit(mame_main(__argc, __argv)); |
| 979 | } |
| 980 | if (!Win32UI_init(hInstance, lpCmdLine, nCmdShow)) |
| 981 | return 1; |
| 982 | |
| 983 | // pump message, but quit on WM_QUIT |
| 984 | while(PumpMessage()) |
| 985 | ; |
| 986 | |
| 987 | Win32UI_exit(); |
| 988 | return 0; |
| 989 | } |
| 990 | |
| 991 | |
| 992 | HWND GetMainWindow(void) |
| 993 | { |
| 994 | return hMain; |
| 995 | } |
| 996 | |
| 997 | HWND GetTreeView(void) |
| 998 | { |
| 999 | return hTreeView; |
| 1000 | } |
| 1001 | |
| 1002 | HIMAGELIST GetLargeImageList(void) |
| 1003 | { |
| 1004 | return hLarge; |
| 1005 | } |
| 1006 | |
| 1007 | HIMAGELIST GetSmallImageList(void) |
| 1008 | { |
| 1009 | return hSmall; |
| 1010 | } |
| 1011 | |
| 1012 | object_pool *GetMame32MemoryPool(void) |
| 1013 | { |
| 1014 | return mame32_pool; |
| 1015 | } |
| 1016 | |
| 1017 | void GetRealColumnOrder(int order[]) |
| 1018 | { |
| 1019 | int tmpOrder[COLUMN_MAX]; |
| 1020 | int nColumnMax; |
| 1021 | int i; |
| 1022 | |
| 1023 | nColumnMax = Picker_GetNumColumns(hwndList); |
| 1024 | |
| 1025 | /* Get the Column Order and save it */ |
| 1026 | if (!oldControl) |
| 1027 | { |
| 1028 | ListView_GetColumnOrderArray(hwndList, nColumnMax, tmpOrder); |
| 1029 | |
| 1030 | for (i = 0; i < nColumnMax; i++) |
| 1031 | { |
| 1032 | order[i] = Picker_GetRealColumnFromViewColumn(hwndList, tmpOrder[i]); |
| 1033 | } |
| 1034 | } |
| 1035 | } |
| 1036 | |
| 1037 | /* |
| 1038 | * PURPOSE: Format raw data read from an ICO file to an HICON |
| 1039 | * PARAMS: PBYTE ptrBuffer - Raw data from an ICO file |
| 1040 | * UINT nBufferSize - Size of buffer ptrBuffer |
| 1041 | * RETURNS: HICON - handle to the icon, NULL for failure |
| 1042 | * History: July '95 - Created |
| 1043 | * March '00- Seriously butchered from MSDN for mine own |
| 1044 | * purposes, sayeth H0ek. |
| 1045 | */ |
| 1046 | HICON FormatICOInMemoryToHICON(PBYTE ptrBuffer, UINT nBufferSize) |
| 1047 | { |
| 1048 | ICONIMAGE IconImage; |
| 1049 | LPICONDIRENTRY lpIDE = NULL; |
| 1050 | UINT nNumImages; |
| 1051 | UINT nBufferIndex = 0; |
| 1052 | HICON hIcon = NULL; |
| 1053 | |
| 1054 | /* Is there a WORD? */ |
| 1055 | if (nBufferSize < sizeof(WORD)) |
| 1056 | { |
| 1057 | return NULL; |
| 1058 | } |
| 1059 | |
| 1060 | /* Was it 'reserved' ? (ie 0) */ |
| 1061 | if ((WORD)(ptrBuffer[nBufferIndex]) != 0) |
| 1062 | { |
| 1063 | return NULL; |
| 1064 | } |
| 1065 | |
| 1066 | nBufferIndex += sizeof(WORD); |
| 1067 | |
| 1068 | /* Is there a WORD? */ |
| 1069 | if (nBufferSize - nBufferIndex < sizeof(WORD)) |
| 1070 | { |
| 1071 | return NULL; |
| 1072 | } |
| 1073 | |
| 1074 | /* Was it type 1? */ |
| 1075 | if ((WORD)(ptrBuffer[nBufferIndex]) != 1) |
| 1076 | { |
| 1077 | return NULL; |
| 1078 | } |
| 1079 | |
| 1080 | nBufferIndex += sizeof(WORD); |
| 1081 | |
| 1082 | /* Is there a WORD? */ |
| 1083 | if (nBufferSize - nBufferIndex < sizeof(WORD)) |
| 1084 | { |
| 1085 | return NULL; |
| 1086 | } |
| 1087 | |
| 1088 | /* Then that's the number of images in the ICO file */ |
| 1089 | nNumImages = (WORD)(ptrBuffer[nBufferIndex]); |
| 1090 | |
| 1091 | /* Is there at least one icon in the file? */ |
| 1092 | if ( nNumImages < 1 ) |
| 1093 | { |
| 1094 | return NULL; |
| 1095 | } |
| 1096 | |
| 1097 | nBufferIndex += sizeof(WORD); |
| 1098 | |
| 1099 | /* Is there enough space for the icon directory entries? */ |
| 1100 | if ((nBufferIndex + nNumImages * sizeof(ICONDIRENTRY)) > nBufferSize) |
| 1101 | { |
| 1102 | return NULL; |
| 1103 | } |
| 1104 | |
| 1105 | /* Assign icon directory entries from buffer */ |
| 1106 | lpIDE = (LPICONDIRENTRY)(&ptrBuffer[nBufferIndex]); |
| 1107 | nBufferIndex += nNumImages * sizeof (ICONDIRENTRY); |
| 1108 | |
| 1109 | IconImage.dwNumBytes = lpIDE->dwBytesInRes; |
| 1110 | |
| 1111 | /* Seek to beginning of this image */ |
| 1112 | if ( lpIDE->dwImageOffset > nBufferSize ) |
| 1113 | { |
| 1114 | return NULL; |
| 1115 | } |
| 1116 | |
| 1117 | nBufferIndex = lpIDE->dwImageOffset; |
| 1118 | |
| 1119 | /* Read it in */ |
| 1120 | if ((nBufferIndex + lpIDE->dwBytesInRes) > nBufferSize) |
| 1121 | { |
| 1122 | return NULL; |
| 1123 | } |
| 1124 | |
| 1125 | IconImage.lpBits = &ptrBuffer[nBufferIndex]; |
| 1126 | nBufferIndex += lpIDE->dwBytesInRes; |
| 1127 | #if 0 // Not sure we want odd sized icons. |
| 1128 | hIcon = CreateIconFromResourceEx(IconImage.lpBits, IconImage.dwNumBytes, TRUE, 0x00030000, |
| 1129 | (*(LPBITMAPINFOHEADER)(IconImage.lpBits)).biWidth, (*(LPBITMAPINFOHEADER)(IconImage.lpBits)).biHeight/2, 0 ); |
| 1130 | #endif |
| 1131 | /* It failed, odds are good we're on NT so try the non-Ex way */ |
| 1132 | if (hIcon == NULL) |
| 1133 | { |
| 1134 | /* We would break on NT if we try with a 16bpp image */ |
| 1135 | if (((LPBITMAPINFO)IconImage.lpBits)->bmiHeader.biBitCount != 16) |
| 1136 | { |
| 1137 | hIcon = CreateIconFromResource(IconImage.lpBits, IconImage.dwNumBytes, TRUE, 0x00030000); |
| 1138 | } |
| 1139 | } |
| 1140 | return hIcon; |
| 1141 | } |
| 1142 | |
| 1143 | HICON LoadIconFromFile(const char *iconname) |
| 1144 | { |
| 1145 | HICON hIcon = 0; |
| 1146 | struct stat file_stat; |
| 1147 | char tmpStr[MAX_PATH]; |
| 1148 | char tmpIcoName[MAX_PATH]; |
| 1149 | const char* sDirName = GetImgDir(); |
| 1150 | PBYTE bufferPtr; |
| 1151 | zip_error ziperr; |
| 1152 | zip_file *zip; |
| 1153 | const zip_file_header *entry; |
| 1154 | |
| 1155 | sprintf(tmpStr, "%s/%s.ico", GetIconsDir(), iconname); |
| 1156 | if (stat(tmpStr, &file_stat) != 0 |
| 1157 | || (hIcon = win_extract_icon_utf8(hInst, tmpStr, 0)) == 0) |
| 1158 | { |
| 1159 | sprintf(tmpStr, "%s/%s.ico", sDirName, iconname); |
| 1160 | if (stat(tmpStr, &file_stat) != 0 |
| 1161 | || (hIcon = win_extract_icon_utf8(hInst, tmpStr, 0)) == 0) |
| 1162 | { |
| 1163 | sprintf(tmpStr, "%s/icons.zip", GetIconsDir()); |
| 1164 | sprintf(tmpIcoName, "%s.ico", iconname); |
| 1165 | |
| 1166 | ziperr = zip_file_open(tmpStr, &zip); |
| 1167 | if (ziperr == ZIPERR_NONE) |
| 1168 | { |
| 1169 | entry = zip_file_first_file(zip); |
| 1170 | while(!hIcon && entry) |
| 1171 | { |
| 1172 | if (!mame_stricmp(entry->filename, tmpIcoName)) |
| 1173 | { |
| 1174 | bufferPtr = malloc(entry->uncompressed_length); |
| 1175 | if (bufferPtr) |
| 1176 | { |
| 1177 | ziperr = zip_file_decompress(zip, bufferPtr, entry->uncompressed_length); |
| 1178 | if (ziperr == ZIPERR_NONE) |
| 1179 | { |
| 1180 | hIcon = FormatICOInMemoryToHICON(bufferPtr, entry->uncompressed_length); |
| 1181 | } |
| 1182 | free(bufferPtr); |
| 1183 | } |
| 1184 | } |
| 1185 | entry = zip_file_next_file(zip); |
| 1186 | } |
| 1187 | zip_file_close(zip); |
| 1188 | } |
| 1189 | } |
| 1190 | } |
| 1191 | return hIcon; |
| 1192 | } |
| 1193 | |
| 1194 | /* Return the number of folders with options */ |
| 1195 | int GetNumOptionFolders() |
| 1196 | { |
| 1197 | return optionfolder_count; |
| 1198 | } |
| 1199 | |
| 1200 | /* Return the number of folders with options */ |
| 1201 | void SetNumOptionFolders(int count) |
| 1202 | { |
| 1203 | optionfolder_count = count; |
| 1204 | } |
| 1205 | |
| 1206 | /* search */ |
| 1207 | const char * GetSearchText(void) |
| 1208 | { |
| 1209 | return g_SearchText; |
| 1210 | } |
| 1211 | |
| 1212 | |
| 1213 | /* Sets the treeview and listviews sizes in accordance with their visibility and the splitters */ |
| 1214 | static void ResizeTreeAndListViews(BOOL bResizeHidden) |
| 1215 | { |
| 1216 | int i; |
| 1217 | int nLastWidth = 0; |
| 1218 | int nLastWidth2 = 0; |
| 1219 | int nLeftWindowWidth = 0; |
| 1220 | RECT rect; |
| 1221 | BOOL bVisible; |
| 1222 | |
| 1223 | /* Size the List Control in the Picker */ |
| 1224 | GetClientRect(hMain, &rect); |
| 1225 | |
| 1226 | if (bShowStatusBar) |
| 1227 | rect.bottom -= bottomMargin; |
| 1228 | if (bShowToolBar) |
| 1229 | rect.top += topMargin; |
| 1230 | |
| 1231 | /* Tree control */ |
| 1232 | ShowWindow(GetDlgItem(hMain, IDC_TREE), bShowTree ? SW_SHOW : SW_HIDE); |
| 1233 | |
| 1234 | for (i = 0; g_splitterInfo[i].nSplitterWindow; i++) |
| 1235 | { |
| 1236 | bVisible = GetWindowLong(GetDlgItem(hMain, g_splitterInfo[i].nLeftWindow), GWL_STYLE) & WS_VISIBLE ? TRUE : FALSE; |
| 1237 | if (bResizeHidden || bVisible) |
| 1238 | { |
| 1239 | nLeftWindowWidth = nSplitterOffset[i] - SPLITTER_WIDTH/2 - nLastWidth; |
| 1240 | |
| 1241 | /* special case for the rightmost pane when the screenshot is gone */ |
| 1242 | if (!GetShowScreenShot() && !g_splitterInfo[i+1].nSplitterWindow) |
| 1243 | nLeftWindowWidth = rect.right - nLastWidth; |
| 1244 | |
| 1245 | /* woah? are we overlapping ourselves? */ |
| 1246 | if (nLeftWindowWidth < MIN_VIEW_WIDTH) |
| 1247 | { |
| 1248 | nLastWidth = nLastWidth2; |
| 1249 | nLeftWindowWidth = nSplitterOffset[i] - MIN_VIEW_WIDTH - (SPLITTER_WIDTH*3/2) - nLastWidth; |
| 1250 | i--; |
| 1251 | } |
| 1252 | |
| 1253 | MoveWindow(GetDlgItem(hMain, g_splitterInfo[i].nLeftWindow), nLastWidth, rect.top + 2, |
| 1254 | nLeftWindowWidth, (rect.bottom - rect.top) - 4 , TRUE); |
| 1255 | |
| 1256 | MoveWindow(GetDlgItem(hMain, g_splitterInfo[i].nSplitterWindow), nSplitterOffset[i], rect.top + 2, |
| 1257 | SPLITTER_WIDTH, (rect.bottom - rect.top) - 4, TRUE); |
| 1258 | } |
| 1259 | |
| 1260 | if (bVisible) |
| 1261 | { |
| 1262 | nLastWidth2 = nLastWidth; |
| 1263 | nLastWidth += nLeftWindowWidth + SPLITTER_WIDTH; |
| 1264 | } |
| 1265 | } |
| 1266 | } |
| 1267 | |
| 1268 | /* Adjust the list view and screenshot button based on GetShowScreenShot() */ |
| 1269 | void UpdateScreenShot(void) |
| 1270 | { |
| 1271 | RECT rect; |
| 1272 | int nWidth; |
| 1273 | RECT fRect; |
| 1274 | POINT p = {0, 0}; |
| 1275 | |
| 1276 | /* first time through can't do this stuff */ |
| 1277 | if (hwndList == NULL) |
| 1278 | return; |
| 1279 | |
| 1280 | /* Size the List Control in the Picker */ |
| 1281 | GetClientRect(hMain, &rect); |
| 1282 | |
| 1283 | if (bShowStatusBar) |
| 1284 | rect.bottom -= bottomMargin; |
| 1285 | if (bShowToolBar) |
| 1286 | rect.top += topMargin; |
| 1287 | |
| 1288 | if (GetShowScreenShot()) |
| 1289 | { |
| 1290 | nWidth = nSplitterOffset[GetSplitterCount() - 1]; |
| 1291 | CheckMenuItem(GetMenu(hMain),ID_VIEW_PICTURE_AREA, MF_CHECKED); |
| 1292 | ToolBar_CheckButton(hToolBar, ID_VIEW_PICTURE_AREA, MF_CHECKED); |
| 1293 | } |
| 1294 | else |
| 1295 | { |
| 1296 | nWidth = rect.right; |
| 1297 | CheckMenuItem(GetMenu(hMain),ID_VIEW_PICTURE_AREA, MF_UNCHECKED); |
| 1298 | ToolBar_CheckButton(hToolBar, ID_VIEW_PICTURE_AREA, MF_UNCHECKED); |
| 1299 | } |
| 1300 | |
| 1301 | ResizeTreeAndListViews(FALSE); |
| 1302 | |
| 1303 | FreeScreenShot(); |
| 1304 | |
| 1305 | if (have_selection) |
| 1306 | { |
| 1307 | #ifdef MESS |
| 1308 | if (!g_szSelectedItem[0] || !LoadScreenShotEx(Picker_GetSelectedItem(hwndList), g_szSelectedItem, |
| 1309 | TabView_GetCurrentTab(hTabCtrl))) |
| 1310 | #endif |
| 1311 | { |
| 1312 | // load and set image, or empty it if we don't have one |
| 1313 | LoadScreenShot(Picker_GetSelectedItem(hwndList), TabView_GetCurrentTab(hTabCtrl)); |
| 1314 | } |
| 1315 | } |
| 1316 | |
| 1317 | // figure out if we have a history or not, to place our other windows properly |
| 1318 | UpdateHistory(); |
| 1319 | |
| 1320 | // setup the picture area |
| 1321 | |
| 1322 | if (GetShowScreenShot()) |
| 1323 | { |
| 1324 | DWORD dwStyle; |
| 1325 | DWORD dwStyleEx; |
| 1326 | BOOL showing_history; |
| 1327 | |
| 1328 | ClientToScreen(hMain, &p); |
| 1329 | GetWindowRect(GetDlgItem(hMain, IDC_SSFRAME), &fRect); |
| 1330 | OffsetRect(&fRect, -p.x, -p.y); |
| 1331 | |
| 1332 | // show history on this tab IFF |
| 1333 | // - we have history for the game |
| 1334 | // - we're on the first tab |
| 1335 | // - we DON'T have a separate history tab |
| 1336 | showing_history = (have_history && (TabView_GetCurrentTab(hTabCtrl) == GetHistoryTab() || GetHistoryTab() == TAB_ALL ) && |
| 1337 | GetShowTab(TAB_HISTORY) == FALSE); |
| 1338 | CalculateBestScreenShotRect(GetDlgItem(hMain, IDC_SSFRAME), &rect,showing_history); |
| 1339 | |
| 1340 | dwStyle = GetWindowLong(GetDlgItem(hMain, IDC_SSPICTURE), GWL_STYLE); |
| 1341 | dwStyleEx = GetWindowLong(GetDlgItem(hMain, IDC_SSPICTURE), GWL_EXSTYLE); |
| 1342 | |
| 1343 | AdjustWindowRectEx(&rect, dwStyle, FALSE, dwStyleEx); |
| 1344 | MoveWindow(GetDlgItem(hMain, IDC_SSPICTURE), |
| 1345 | fRect.left + rect.left, |
| 1346 | fRect.top + rect.top, |
| 1347 | rect.right - rect.left, |
| 1348 | rect.bottom - rect.top, |
| 1349 | TRUE); |
| 1350 | |
| 1351 | ShowWindow(GetDlgItem(hMain,IDC_SSPICTURE), |
| 1352 | (TabView_GetCurrentTab(hTabCtrl) != TAB_HISTORY) ? SW_SHOW : SW_HIDE); |
| 1353 | ShowWindow(GetDlgItem(hMain,IDC_SSFRAME),SW_SHOW); |
| 1354 | ShowWindow(GetDlgItem(hMain,IDC_SSTAB),bShowTabCtrl ? SW_SHOW : SW_HIDE); |
| 1355 | |
| 1356 | InvalidateRect(GetDlgItem(hMain,IDC_SSPICTURE),NULL,FALSE); |
| 1357 | } |
| 1358 | else |
| 1359 | { |
| 1360 | ShowWindow(GetDlgItem(hMain,IDC_SSPICTURE),SW_HIDE); |
| 1361 | ShowWindow(GetDlgItem(hMain,IDC_SSFRAME),SW_HIDE); |
| 1362 | ShowWindow(GetDlgItem(hMain,IDC_SSTAB),SW_HIDE); |
| 1363 | } |
| 1364 | |
| 1365 | } |
| 1366 | |
| 1367 | void ResizePickerControls(HWND hWnd) |
| 1368 | { |
| 1369 | RECT frameRect; |
| 1370 | RECT rect, sRect; |
| 1371 | int nListWidth, nScreenShotWidth; |
| 1372 | static BOOL firstTime = TRUE; |
| 1373 | int doSSControls = TRUE; |
| 1374 | int i, nSplitterCount; |
| 1375 | |
| 1376 | nSplitterCount = GetSplitterCount(); |
| 1377 | |
| 1378 | /* Size the List Control in the Picker */ |
| 1379 | GetClientRect(hWnd, &rect); |
| 1380 | |
| 1381 | /* Calc the display sizes based on g_splitterInfo */ |
| 1382 | if (firstTime) |
| 1383 | { |
| 1384 | RECT rWindow; |
| 1385 | |
| 1386 | for (i = 0; i < nSplitterCount; i++) |
| 1387 | nSplitterOffset[i] = rect.right * g_splitterInfo[i].dPosition; |
| 1388 | |
| 1389 | GetWindowRect(hStatusBar, &rWindow); |
| 1390 | bottomMargin = rWindow.bottom - rWindow.top; |
| 1391 | GetWindowRect(hToolBar, &rWindow); |
| 1392 | topMargin = rWindow.bottom - rWindow.top; |
| 1393 | /*buttonMargin = (sRect.bottom + 4); */ |
| 1394 | |
| 1395 | firstTime = FALSE; |
| 1396 | } |
| 1397 | else |
| 1398 | { |
| 1399 | doSSControls = GetShowScreenShot(); |
| 1400 | } |
| 1401 | |
| 1402 | if (bShowStatusBar) |
| 1403 | rect.bottom -= bottomMargin; |
| 1404 | |
| 1405 | if (bShowToolBar) |
| 1406 | rect.top += topMargin; |
| 1407 | |
| 1408 | MoveWindow(GetDlgItem(hWnd, IDC_DIVIDER), rect.left, rect.top - 4, rect.right, 2, TRUE); |
| 1409 | |
| 1410 | ResizeTreeAndListViews(TRUE); |
| 1411 | |
| 1412 | nListWidth = nSplitterOffset[nSplitterCount-1]; |
| 1413 | nScreenShotWidth = (rect.right - nListWidth) - 4; |
| 1414 | |
| 1415 | /* Screen shot Page tab control */ |
| 1416 | if (bShowTabCtrl) |
| 1417 | { |
| 1418 | MoveWindow(GetDlgItem(hWnd, IDC_SSTAB), nListWidth + 4, rect.top + 2, |
| 1419 | nScreenShotWidth - 2, rect.top + 20, doSSControls); |
| 1420 | rect.top += 20; |
| 1421 | } |
| 1422 | |
| 1423 | /* resize the Screen shot frame */ |
| 1424 | MoveWindow(GetDlgItem(hWnd, IDC_SSFRAME), nListWidth + 4, rect.top + 2, |
| 1425 | nScreenShotWidth - 2, (rect.bottom - rect.top) - 4, doSSControls); |
| 1426 | |
| 1427 | /* The screen shot controls */ |
| 1428 | GetClientRect(GetDlgItem(hWnd, IDC_SSFRAME), &frameRect); |
| 1429 | |
| 1430 | /* Text control - game history */ |
| 1431 | sRect.left = nListWidth + 14; |
| 1432 | sRect.right = sRect.left + (nScreenShotWidth - 22); |
| 1433 | |
| 1434 | |
| 1435 | if (GetShowTab(TAB_HISTORY)) |
| 1436 | { |
| 1437 | // We're using the new mode, with the history filling the entire tab (almost) |
| 1438 | sRect.top = rect.top + 14; |
| 1439 | sRect.bottom = (rect.bottom - rect.top) - 30; |
| 1440 | } |
| 1441 | else |
| 1442 | { |
| 1443 | // We're using the original mode, with the history beneath the SS picture |
| 1444 | sRect.top = rect.top + 264; |
| 1445 | sRect.bottom = (rect.bottom - rect.top) - 278; |
| 1446 | } |
| 1447 | |
| 1448 | MoveWindow(GetDlgItem(hWnd, IDC_HISTORY), |
| 1449 | sRect.left, sRect.top, |
| 1450 | sRect.right - sRect.left, sRect.bottom, doSSControls); |
| 1451 | |
| 1452 | /* the other screen shot controls will be properly placed in UpdateScreenshot() */ |
| 1453 | |
| 1454 | } |
| 1455 | |
| 1456 | char *ModifyThe(const char *str) |
| 1457 | { |
| 1458 | static int bufno = 0; |
| 1459 | static char buffer[4][255]; |
| 1460 | |
| 1461 | if (strncmp(str, "The ", 4) == 0) |
| 1462 | { |
| 1463 | char *s, *p; |
| 1464 | char temp[255]; |
| 1465 | |
| 1466 | strcpy(temp, &str[4]); |
| 1467 | |
| 1468 | bufno = (bufno + 1) % 4; |
| 1469 | |
| 1470 | s = buffer[bufno]; |
| 1471 | |
| 1472 | /* Check for version notes in parens */ |
| 1473 | p = strchr(temp, '('); |
| 1474 | if (p) |
| 1475 | { |
| 1476 | p[-1] = '\0'; |
| 1477 | } |
| 1478 | |
| 1479 | strcpy(s, temp); |
| 1480 | strcat(s, ", The"); |
| 1481 | |
| 1482 | if (p) |
| 1483 | { |
| 1484 | strcat(s, " "); |
| 1485 | strcat(s, p); |
| 1486 | } |
| 1487 | |
| 1488 | return s; |
| 1489 | } |
| 1490 | return (char *)str; |
| 1491 | } |
| 1492 | |
| 1493 | HBITMAP GetBackgroundBitmap(void) |
| 1494 | { |
| 1495 | return hBackground; |
| 1496 | } |
| 1497 | |
| 1498 | HPALETTE GetBackgroundPalette(void) |
| 1499 | { |
| 1500 | return hPALbg; |
| 1501 | } |
| 1502 | |
| 1503 | MYBITMAPINFO * GetBackgroundInfo(void) |
| 1504 | { |
| 1505 | return &bmDesc; |
| 1506 | } |
| 1507 | |
| 1508 | BOOL GetUseOldControl(void) |
| 1509 | { |
| 1510 | return oldControl; |
| 1511 | } |
| 1512 | |
| 1513 | BOOL GetUseXPControl(void) |
| 1514 | { |
| 1515 | return xpControl; |
| 1516 | } |
| 1517 | |
| 1518 | int GetMinimumScreenShotWindowWidth(void) |
| 1519 | { |
| 1520 | BITMAP bmp; |
| 1521 | GetObject(hMissing_bitmap,sizeof(BITMAP),&bmp); |
| 1522 | |
| 1523 | return bmp.bmWidth + 6; // 6 is for a little breathing room |
| 1524 | } |
| 1525 | |
| 1526 | |
| 1527 | int GetDriverIndex(const game_driver *driver) |
| 1528 | { |
| 1529 | return GetGameNameIndex(driver->name); |
| 1530 | } |
| 1531 | |
| 1532 | int GetParentIndex(const game_driver *driver) |
| 1533 | { |
| 1534 | return GetGameNameIndex(driver->parent); |
| 1535 | } |
| 1536 | |
| 1537 | int GetParentRomSetIndex(const game_driver *driver) |
| 1538 | { |
| 1539 | int nParentIndex = GetGameNameIndex(driver->parent); |
| 1540 | |
| 1541 | if( nParentIndex >= 0) |
| 1542 | { |
| 1543 | if ((drivers[nParentIndex]->flags & GAME_IS_BIOS_ROOT) == 0) |
| 1544 | return nParentIndex; |
| 1545 | } |
| 1546 | |
| 1547 | return -1; |
| 1548 | } |
| 1549 | |
| 1550 | int GetGameNameIndex(const char *name) |
| 1551 | { |
| 1552 | driver_data_type *driver_index_info; |
| 1553 | driver_data_type key; |
| 1554 | key.name = name; |
| 1555 | |
| 1556 | // uses our sorted array of driver names to get the index in log time |
| 1557 | driver_index_info = bsearch(&key,sorted_drivers,driver_list_get_count(drivers),sizeof(driver_data_type), |
| 1558 | DriverDataCompareFunc); |
| 1559 | |
| 1560 | if (driver_index_info == NULL) |
| 1561 | return -1; |
| 1562 | |
| 1563 | return driver_index_info->index; |
| 1564 | |
| 1565 | } |
| 1566 | |
| 1567 | int GetIndexFromSortedIndex(int sorted_index) |
| 1568 | { |
| 1569 | return sorted_drivers[sorted_index].index; |
| 1570 | } |
| 1571 | |
| 1572 | /*************************************************************************** |
| 1573 | Internal functions |
| 1574 | ***************************************************************************/ |
| 1575 | |
| 1576 | // used for our sorted array of game names |
| 1577 | int CLIB_DECL DriverDataCompareFunc(const void *arg1,const void *arg2) |
| 1578 | { |
| 1579 | return strcmp( ((driver_data_type *)arg1)->name, ((driver_data_type *)arg2)->name ); |
| 1580 | } |
| 1581 | |
| 1582 | static void ResetBackground(char *szFile) |
| 1583 | { |
| 1584 | char szDestFile[MAX_PATH]; |
| 1585 | |
| 1586 | /* The MAME core load the .png file first, so we only need replace this file */ |
| 1587 | sprintf(szDestFile, "%s\\bkground.png", GetBgDir()); |
| 1588 | win_set_file_attributes_utf8(szDestFile, FILE_ATTRIBUTE_NORMAL); |
| 1589 | win_copy_file_utf8(szFile, szDestFile, FALSE); |
| 1590 | } |
| 1591 | |
| 1592 | static void RandomSelectBackground(void) |
| 1593 | { |
| 1594 | struct _finddata_t c_file; |
| 1595 | long hFile; |
| 1596 | char szFile[MAX_PATH]; |
| 1597 | int count=0; |
| 1598 | const char *szDir=GetBgDir(); |
| 1599 | char *buf=malloc(_MAX_FNAME * MAX_BGFILES); |
| 1600 | |
| 1601 | if (buf == NULL) |
| 1602 | return; |
| 1603 | |
| 1604 | sprintf(szFile, "%s\\*.bmp", szDir); |
| 1605 | hFile = _findfirst(szFile, &c_file); |
| 1606 | if (hFile != -1L) |
| 1607 | { |
| 1608 | int Done = 0; |
| 1609 | while (!Done && count < MAX_BGFILES) |
| 1610 | { |
| 1611 | memcpy(buf + count * _MAX_FNAME, c_file.name, _MAX_FNAME); |
| 1612 | count++; |
| 1613 | Done = _findnext(hFile, &c_file); |
| 1614 | } |
| 1615 | _findclose(hFile); |
| 1616 | } |
| 1617 | sprintf(szFile, "%s\\*.png", szDir); |
| 1618 | hFile = _findfirst(szFile, &c_file); |
| 1619 | if (hFile != -1L) |
| 1620 | { |
| 1621 | int Done = 0; |
| 1622 | while (!Done && count < MAX_BGFILES) |
| 1623 | { |
| 1624 | memcpy(buf + count * _MAX_FNAME, c_file.name, _MAX_FNAME); |
| 1625 | count++; |
| 1626 | Done = _findnext(hFile, &c_file); |
| 1627 | } |
| 1628 | _findclose(hFile); |
| 1629 | } |
| 1630 | |
| 1631 | if (count) |
| 1632 | { |
| 1633 | #ifdef rand |
| 1634 | #undef rand |
| 1635 | #endif |
| 1636 | |
| 1637 | srand( (unsigned)time( NULL ) ); |
| 1638 | sprintf(szFile, "%s\\%s", szDir, buf + (rand() % count) * _MAX_FNAME); |
| 1639 | ResetBackground(szFile); |
| 1640 | } |
| 1641 | |
| 1642 | free(buf); |
| 1643 | } |
| 1644 | |
| 1645 | void SetMainTitle(void) |
| 1646 | { |
| 1647 | char version[50]; |
| 1648 | char buffer[100]; |
| 1649 | |
| 1650 | sscanf(build_version,"%s",version); |
| 1651 | snprintf(buffer, ARRAY_LENGTH(buffer), "%s %s", MAME32NAME, version); |
| 1652 | win_set_window_text_utf8(hMain,buffer); |
| 1653 | } |
| 1654 | |
| 1655 | static void winui_output_error(void *param, const char *format, va_list argptr) |
| 1656 | { |
| 1657 | char buffer[1024]; |
| 1658 | |
| 1659 | // if we are in fullscreen mode, go to windowed mode |
| 1660 | if ((video_config.windowed == 0) && (win_window_list != NULL)) |
| 1661 | winwindow_toggle_full_screen(); |
| 1662 | |
| 1663 | vsnprintf(buffer, ARRAY_LENGTH(buffer), format, argptr); |
| 1664 | win_message_box_utf8(win_window_list ? win_window_list->hwnd : NULL, buffer, APPNAME, MB_OK); |
| 1665 | } |
| 1666 | |
| 1667 | static void memory_error(const char *message) |
| 1668 | { |
| 1669 | win_message_box_utf8(hMain, message, APPNAME, MB_OK); |
| 1670 | exit(-1); |
| 1671 | } |
| 1672 | |
| 1673 | static BOOL Win32UI_init(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) |
| 1674 | { |
| 1675 | extern int mame_validitychecks(int game); |
| 1676 | WNDCLASS wndclass; |
| 1677 | RECT rect; |
| 1678 | int i, nSplitterCount; |
| 1679 | extern FOLDERDATA g_folderData[]; |
| 1680 | extern FILTER_ITEM g_filterList[]; |
| 1681 | extern const char *history_filename; |
| 1682 | extern const char *mameinfo_filename; |
| 1683 | LONG common_control_version = GetCommonControlVersion(); |
| 1684 | int validity_failed = 0; |
| 1685 | TCHAR* t_inpdir; |
| 1686 | |
| 1687 | dprintf("about to init options\n"); |
| 1688 | if (!OptionsInit()) |
| 1689 | return FALSE; |
| 1690 | dprintf("options loaded\n"); |
| 1691 | |
| 1692 | srand((unsigned)time(NULL)); |
| 1693 | |
| 1694 | // output errors to message boxes |
| 1695 | mame_set_output_channel(OUTPUT_CHANNEL_ERROR, winui_output_error, NULL, NULL, NULL); |
| 1696 | |
| 1697 | // create the memory pool |
| 1698 | mame32_pool = pool_alloc(memory_error); |
| 1699 | |
| 1700 | // custom per-game icons |
| 1701 | icon_index = pool_malloc(mame32_pool, sizeof(int) * driver_list_get_count(drivers)); |
| 1702 | memset(icon_index, '\0', sizeof(int) * driver_list_get_count(drivers)); |
| 1703 | |
| 1704 | // sorted list of drivers by name |
| 1705 | sorted_drivers = (driver_data_type *) pool_malloc(mame32_pool, sizeof(driver_data_type) * driver_list_get_count(drivers)); |
| 1706 | memset(sorted_drivers, '\0', sizeof(driver_data_type) * driver_list_get_count(drivers)); |
| 1707 | for (i = 0; i < driver_list_get_count(drivers); i++) |
| 1708 | { |
| 1709 | sorted_drivers[i].name = drivers[i]->name; |
| 1710 | sorted_drivers[i].index = i; |
| 1711 | } |
| 1712 | qsort(sorted_drivers, driver_list_get_count(drivers), sizeof(driver_data_type), DriverDataCompareFunc); |
| 1713 | |
| 1714 | // set up window class |
| 1715 | wndclass.style = CS_HREDRAW | CS_VREDRAW; |
| 1716 | wndclass.lpfnWndProc = MameWindowProc; |
| 1717 | wndclass.cbClsExtra = 0; |
| 1718 | wndclass.cbWndExtra = DLGWINDOWEXTRA; |
| 1719 | wndclass.hInstance = hInstance; |
| 1720 | wndclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAME32_ICON)); |
| 1721 | wndclass.hCursor = NULL; |
| 1722 | wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); |
| 1723 | wndclass.lpszMenuName = MAKEINTRESOURCE(IDR_UI_MENU); |
| 1724 | wndclass.lpszClassName = TEXT("MainClass"); |
| 1725 | |
| 1726 | RegisterClass(&wndclass); |
| 1727 | |
| 1728 | #ifdef MESS |
| 1729 | DevView_RegisterClass(); |
| 1730 | #endif //MESS |
| 1731 | |
| 1732 | InitCommonControls(); |
| 1733 | |
| 1734 | // Are we using an Old comctl32.dll? |
| 1735 | dprintf("common controlversion %i %i",common_control_version >> 16, |
| 1736 | common_control_version & 0xffff); |
| 1737 | |
| 1738 | oldControl = (common_control_version < PACKVERSION(4,71)); |
| 1739 | xpControl = (common_control_version >= PACKVERSION(6,0)); |
| 1740 | if (oldControl) |
| 1741 | { |
| 1742 | char buf[] = MAME32NAME " has detected an old version of comctl32.dll\n\n" |
| 1743 | "Game Properties, many configuration options and\n" |
| 1744 | "features are not available without an updated DLL\n\n" |
| 1745 | "Please install the common control update found at:\n\n" |
| 1746 | "http://www.microsoft.com/msdownload/ieplatform/ie/comctrlx86.asp\n\n" |
| 1747 | "Would you like to continue without using the new features?\n"; |
| 1748 | |
| 1749 | if (IDNO == win_message_box_utf8(0, buf, MAME32NAME " Outdated comctl32.dll Warning", MB_YESNO | MB_ICONWARNING)) |
| 1750 | return FALSE; |
| 1751 | } |
| 1752 | |
| 1753 | g_mame32_message = RegisterWindowMessage(TEXT("MAME32")); |
| 1754 | g_bDoBroadcast = GetBroadcast(); |
| 1755 | |
| 1756 | HelpInit(); |
| 1757 | |
| 1758 | t_inpdir = tstring_from_utf8(GetInpDir()); |
| 1759 | if( ! t_inpdir ) |
| 1760 | return FALSE; |
| 1761 | |
| 1762 | _tcscpy(last_directory,t_inpdir); |
| 1763 | free(t_inpdir); |
| 1764 | hMain = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_MAIN), 0, NULL); |
| 1765 | if (hMain == NULL) |
| 1766 | { |
| 1767 | dprintf("error creating main dialog, aborting"); |
| 1768 | return FALSE; |
| 1769 | } |
| 1770 | |
| 1771 | s_pWatcher = DirWatcher_Init(hMain, WM_MAME32_FILECHANGED); |
| 1772 | if (s_pWatcher) |
| 1773 | { |
| 1774 | DirWatcher_Watch(s_pWatcher, 0, GetRomDirs(), TRUE); |
| 1775 | DirWatcher_Watch(s_pWatcher, 1, GetSampleDirs(), TRUE); |
| 1776 | } |
| 1777 | |
| 1778 | SetMainTitle(); |
| 1779 | hTabCtrl = GetDlgItem(hMain, IDC_SSTAB); |
| 1780 | |
| 1781 | { |
| 1782 | struct TabViewOptions opts; |
| 1783 | |
| 1784 | static struct TabViewCallbacks s_tabviewCallbacks = |
| 1785 | { |
| 1786 | GetShowTabCtrl, // pfnGetShowTabCtrl |
| 1787 | SetCurrentTab, // pfnSetCurrentTab |
| 1788 | GetCurrentTab, // pfnGetCurrentTab |
| 1789 | SetShowTab, // pfnSetShowTab |
| 1790 | GetShowTab, // pfnGetShowTab |
| 1791 | |
| 1792 | GetImageTabShortName, // pfnGetTabShortName |
| 1793 | GetImageTabLongName, // pfnGetTabLongName |
| 1794 | UpdateScreenShot // pfnOnSelectionChanged |
| 1795 | }; |
| 1796 | |
| 1797 | memset(&opts, 0, sizeof(opts)); |
| 1798 | opts.pCallbacks = &s_tabviewCallbacks; |
| 1799 | opts.nTabCount = MAX_TAB_TYPES; |
| 1800 | |
| 1801 | if (!SetupTabView(hTabCtrl, &opts)) |
| 1802 | return FALSE; |
| 1803 | } |
| 1804 | |
| 1805 | /* subclass history window */ |
| 1806 | g_lpHistoryWndProc = (WNDPROC)(LONG)(int)GetWindowLong(GetDlgItem(hMain, IDC_HISTORY), GWL_WNDPROC); |
| 1807 | SetWindowLong(GetDlgItem(hMain, IDC_HISTORY), GWL_WNDPROC, (LONG)HistoryWndProc); |
| 1808 | |
| 1809 | /* subclass picture frame area */ |
| 1810 | g_lpPictureFrameWndProc = (WNDPROC)(LONG)(int)GetWindowLong(GetDlgItem(hMain, IDC_SSFRAME), GWL_WNDPROC); |
| 1811 | SetWindowLong(GetDlgItem(hMain, IDC_SSFRAME), GWL_WNDPROC, (LONG)PictureFrameWndProc); |
| 1812 | |
| 1813 | /* subclass picture area */ |
| 1814 | g_lpPictureWndProc = (WNDPROC)(LONG)(int)GetWindowLong(GetDlgItem(hMain, IDC_SSPICTURE), GWL_WNDPROC); |
| 1815 | SetWindowLong(GetDlgItem(hMain, IDC_SSPICTURE), GWL_WNDPROC, (LONG)PictureWndProc); |
| 1816 | |
| 1817 | /* Load the pic for the default screenshot. */ |
| 1818 | hMissing_bitmap = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT)); |
| 1819 | |
| 1820 | /* Stash hInstance for later use */ |
| 1821 | hInst = hInstance; |
| 1822 | |
| 1823 | hToolBar = InitToolbar(hMain); |
| 1824 | hStatusBar = InitStatusBar(hMain); |
| 1825 | hProgWnd = InitProgressBar(hStatusBar); |
| 1826 | |
| 1827 | main_resize_items[0].u.hwnd = hToolBar; |
| 1828 | main_resize_items[1].u.hwnd = hStatusBar; |
| 1829 | |
| 1830 | /* In order to handle 'Large Fonts' as the Windows |
| 1831 | * default setting, we need to make the dialogs small |
| 1832 | * enough to fit in our smallest window size with |
| 1833 | * large fonts, then resize the picker, tab and button |
| 1834 | * controls to fill the window, no matter which font |
| 1835 | * is currently set. This will still look like bad |
| 1836 | * if the user uses a bigger default font than 125% |
| 1837 | * (Large Fonts) on the Windows display setting tab. |
| 1838 | * |
| 1839 | * NOTE: This has to do with Windows default font size |
| 1840 | * settings, NOT our picker font size. |
| 1841 | */ |
| 1842 | |
| 1843 | GetClientRect(hMain, &rect); |
| 1844 | |
| 1845 | hTreeView = GetDlgItem(hMain, IDC_TREE); |
| 1846 | hwndList = GetDlgItem(hMain, IDC_LIST); |
| 1847 | |
| 1848 | history_filename = mame_strdup(GetHistoryFileName()); |
| 1849 | mameinfo_filename = mame_strdup(GetMAMEInfoFileName()); |
| 1850 | |
| 1851 | if (!InitSplitters()) |
| 1852 | return FALSE; |
| 1853 | |
| 1854 | nSplitterCount = GetSplitterCount(); |
| 1855 | for (i = 0; i < nSplitterCount; i++) |
| 1856 | { |
| 1857 | HWND hWnd; |
| 1858 | HWND hWndLeft; |
| 1859 | HWND hWndRight; |
| 1860 | |
| 1861 | hWnd = GetDlgItem(hMain, g_splitterInfo[i].nSplitterWindow); |
| 1862 | hWndLeft = GetDlgItem(hMain, g_splitterInfo[i].nLeftWindow); |
| 1863 | hWndRight = GetDlgItem(hMain, g_splitterInfo[i].nRightWindow); |
| 1864 | |
| 1865 | AddSplitter(hWnd, hWndLeft, hWndRight, g_splitterInfo[i].pfnAdjust); |
| 1866 | } |
| 1867 | |
| 1868 | /* Initial adjustment of controls on the Picker window */ |
| 1869 | ResizePickerControls(hMain); |
| 1870 | |
| 1871 | TabView_UpdateSelection(hTabCtrl); |
| 1872 | |
| 1873 | bDoGameCheck = GetGameCheck(); |
| 1874 | idle_work = TRUE; |
| 1875 | game_index = 0; |
| 1876 | |
| 1877 | bShowTree = GetShowFolderList(); |
| 1878 | bShowToolBar = GetShowToolBar(); |
| 1879 | bShowStatusBar = GetShowStatusBar(); |
| 1880 | bShowTabCtrl = GetShowTabCtrl(); |
| 1881 | |
| 1882 | CheckMenuItem(GetMenu(hMain), ID_VIEW_FOLDERS, (bShowTree) ? MF_CHECKED : MF_UNCHECKED); |
| 1883 | ToolBar_CheckButton(hToolBar, ID_VIEW_FOLDERS, (bShowTree) ? MF_CHECKED : MF_UNCHECKED); |
| 1884 | CheckMenuItem(GetMenu(hMain), ID_VIEW_TOOLBARS, (bShowToolBar) ? MF_CHECKED : MF_UNCHECKED); |
| 1885 | ShowWindow(hToolBar, (bShowToolBar) ? SW_SHOW : SW_HIDE); |
| 1886 | CheckMenuItem(GetMenu(hMain), ID_VIEW_STATUS, (bShowStatusBar) ? MF_CHECKED : MF_UNCHECKED); |
| 1887 | ShowWindow(hStatusBar, (bShowStatusBar) ? SW_SHOW : SW_HIDE); |
| 1888 | CheckMenuItem(GetMenu(hMain), ID_VIEW_PAGETAB, (bShowTabCtrl) ? MF_CHECKED : MF_UNCHECKED); |
| 1889 | |
| 1890 | if (oldControl) |
| 1891 | { |
| 1892 | EnableMenuItem(GetMenu(hMain), ID_CUSTOMIZE_FIELDS, MF_GRAYED); |
| 1893 | EnableMenuItem(GetMenu(hMain), ID_GAME_PROPERTIES, MF_GRAYED); |
| 1894 | EnableMenuItem(GetMenu(hMain), ID_OPTIONS_DEFAULTS, MF_GRAYED); |
| 1895 | } |
| 1896 | |
| 1897 | /* Init DirectDraw */ |
| 1898 | if (!DirectDraw_Initialize()) |
| 1899 | { |
| 1900 | DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIRECTX), NULL, DirectXDialogProc); |
| 1901 | return FALSE; |
| 1902 | } |
| 1903 | |
| 1904 | if (GetRandomBackground()) |
| 1905 | RandomSelectBackground(); |
| 1906 | |
| 1907 | LoadBackgroundBitmap(); |
| 1908 | |
| 1909 | dprintf("about to init tree"); |
| 1910 | InitTree(g_folderData, g_filterList); |
| 1911 | dprintf("did init tree"); |
| 1912 | |
| 1913 | /* Initialize listview columns */ |
| 1914 | #ifdef MESS |
| 1915 | InitMessPicker(); |
| 1916 | #endif |
| 1917 | InitListView(); |
| 1918 | SetFocus(hwndList); |
| 1919 | |
| 1920 | /* Reset the font */ |
| 1921 | { |
| 1922 | LOGFONT logfont; |
| 1923 | |
| 1924 | GetListFont(&logfont); |
| 1925 | hFont = CreateFontIndirect(&logfont); |
| 1926 | if (hFont != NULL) |
| 1927 | SetAllWindowsFont(hMain, &main_resize, hFont, FALSE); |
| 1928 | } |
| 1929 | |
| 1930 | /* Init DirectInput */ |
| 1931 | if (!DirectInputInitialize()) |
| 1932 | { |
| 1933 | DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIRECTX), NULL, DirectXDialogProc); |
| 1934 | return FALSE; |
| 1935 | } |
| 1936 | |
| 1937 | AdjustMetrics(); |
| 1938 | UpdateScreenShot(); |
| 1939 | |
| 1940 | hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDA_TAB_KEYS)); |
| 1941 | |
| 1942 | /* clear keyboard state */ |
| 1943 | KeyboardStateClear(); |
| 1944 | |
| 1945 | for (i = 0; i < NUM_GUI_SEQUENCES; i++) |
| 1946 | { |
| 1947 | input_seq *is1; |
| 1948 | input_seq *is2; |
| 1949 | is1 = &(GUISequenceControl[i].is); |
| 1950 | is2 = GUISequenceControl[i].getiniptr(); |
| 1951 | // FIXME |
| 1952 | //input_seq_copy(is1, is2); |
| 1953 | //dprintf("seq =%s is: %4i %4i %4i %4i\n",GUISequenceControl[i].name, (*is1)[0], (*is1)[1], (*is1)[2], (*is1)[3]); |
| 1954 | } |
| 1955 | |
| 1956 | if (GetJoyGUI() == TRUE) |
| 1957 | { |
| 1958 | g_pJoyGUI = &DIJoystick; |
| 1959 | if (g_pJoyGUI->init() != 0) |
| 1960 | g_pJoyGUI = NULL; |
| 1961 | else |
| 1962 | SetTimer(hMain, JOYGUI_TIMER, JOYGUI_MS, NULL); |
| 1963 | } |
| 1964 | else |
| 1965 | g_pJoyGUI = NULL; |
| 1966 | |
| 1967 | if (GetHideMouseOnStartup()) |
| 1968 | { |
| 1969 | /* For some reason the mouse is centered when a game is exited, which of |
| 1970 | course causes a WM_MOUSEMOVE event that shows the mouse. So we center |
| 1971 | it now, before the startup coords are initilized, and that way the mouse |
| 1972 | will still be hidden when exiting from a game (i hope) :) |
| 1973 | */ |
| 1974 | SetCursorPos(GetSystemMetrics(SM_CXSCREEN)/2,GetSystemMetrics(SM_CYSCREEN)/2); |
| 1975 | |
| 1976 | // Then hide it |
| 1977 | ShowCursor(FALSE); |
| 1978 | } |
| 1979 | |
| 1980 | dprintf("about to show window\n"); |
| 1981 | |
| 1982 | nCmdShow = GetWindowState(); |
| 1983 | if (nCmdShow == SW_HIDE || nCmdShow == SW_MINIMIZE || nCmdShow == SW_SHOWMINIMIZED) |
| 1984 | { |
| 1985 | nCmdShow = SW_RESTORE; |
| 1986 | } |
| 1987 | |
| 1988 | if (GetRunFullScreen()) |
| 1989 | { |
| 1990 | LONG lMainStyle; |
| 1991 | |
| 1992 | // Remove menu |
| 1993 | SetMenu(hMain,NULL); |
| 1994 | |
| 1995 | // Frameless dialog (fake fullscreen) |
| 1996 | lMainStyle = GetWindowLong(hMain, GWL_STYLE); |
| 1997 | lMainStyle = lMainStyle & (WS_BORDER ^ 0xffffffff); |
| 1998 | SetWindowLong(hMain, GWL_STYLE, lMainStyle); |
| 1999 | |
| 2000 | nCmdShow = SW_MAXIMIZE; |
| 2001 | } |
| 2002 | |
| 2003 | ShowWindow(hMain, nCmdShow); |
| 2004 | |
| 2005 | |
| 2006 | switch (GetViewMode()) |
| 2007 | { |
| 2008 | case VIEW_LARGE_ICONS : |
| 2009 | SetView(ID_VIEW_LARGE_ICON); |
| 2010 | break; |
| 2011 | case VIEW_SMALL_ICONS : |
| 2012 | SetView(ID_VIEW_SMALL_ICON); |
| 2013 | break; |
| 2014 | case VIEW_INLIST : |
| 2015 | SetView(ID_VIEW_LIST_MENU); |
| 2016 | break; |
| 2017 | case VIEW_REPORT : |
| 2018 | SetView(ID_VIEW_DETAIL); |
| 2019 | break; |
| 2020 | case VIEW_GROUPED : |
| 2021 | default : |
| 2022 | SetView(ID_VIEW_GROUPED); |
| 2023 | break; |
| 2024 | } |
| 2025 | |
| 2026 | if (GetCycleScreenshot() > 0) |
| 2027 | { |
| 2028 | SetTimer(hMain, SCREENSHOT_TIMER, GetCycleScreenshot()*1000, NULL); //scale to Seconds |
| 2029 | } |
| 2030 | |
| 2031 | if (validity_failed) |
| 2032 | { |
| 2033 | win_message_box_utf8(hMain, MAMENAME " has failed its validity checks. The GUI will " |
| 2034 | "still work, but emulations will fail to execute", MAMENAME, MB_OK); |
| 2035 | } |
| 2036 | |
| 2037 | return TRUE; |
| 2038 | } |
| 2039 | |
| 2040 | |
| 2041 | static void Win32UI_exit() |
| 2042 | { |
| 2043 | if (g_bDoBroadcast == TRUE) |
| 2044 | { |
| 2045 | ATOM a = GlobalAddAtom(TEXT("")); |
| 2046 | SendMessage(HWND_BROADCAST, g_mame32_message, a, a); |
| 2047 | GlobalDeleteAtom(a); |
| 2048 | } |
| 2049 | |
| 2050 | if (g_pJoyGUI != NULL) |
| 2051 | g_pJoyGUI->exit(); |
| 2052 | |
| 2053 | /* Free GDI resources */ |
| 2054 | |
| 2055 | if (hMissing_bitmap) |
| 2056 | { |
| 2057 | DeleteObject(hMissing_bitmap); |
| 2058 | hMissing_bitmap = NULL; |
| 2059 | } |
| 2060 | |
| 2061 | if (hBackground) |
| 2062 | { |
| 2063 | DeleteObject(hBackground); |
| 2064 | hBackground = NULL; |
| 2065 | } |
| 2066 | |
| 2067 | if (hPALbg) |
| 2068 | { |
| 2069 | DeleteObject(hPALbg); |
| 2070 | hPALbg = NULL; |
| 2071 | } |
| 2072 | |
| 2073 | if (hFont) |
| 2074 | { |
| 2075 | DeleteObject(hFont); |
| 2076 | hFont = NULL; |
| 2077 | } |
| 2078 | |
| 2079 | DestroyIcons(); |
| 2080 | |
| 2081 | DestroyAcceleratorTable(hAccel); |
| 2082 | |
| 2083 | DirectInputClose(); |
| 2084 | DirectDraw_Close(); |
| 2085 | |
| 2086 | SetSavedFolderID(GetCurrentFolderID()); |
| 2087 | |
| 2088 | SaveOptions(); |
| 2089 | |
| 2090 | FreeFolders(); |
| 2091 | |
| 2092 | /* DestroyTree(hTreeView); */ |
| 2093 | |
| 2094 | FreeScreenShot(); |
| 2095 | |
| 2096 | OptionsExit(); |
| 2097 | |
| 2098 | HelpExit(); |
| 2099 | |
| 2100 | pool_free(mame32_pool); |
| 2101 | mame32_pool = NULL; |
| 2102 | } |
| 2103 | |
| 2104 | static long WINAPI MameWindowProc(HWND hWnd, UINT message, UINT wParam, LONG lParam) |
| 2105 | { |
| 2106 | MINMAXINFO *mminfo; |
| 2107 | int i; |
| 2108 | TCHAR szClass[128]; |
| 2109 | |
| 2110 | switch (message) |
| 2111 | { |
| 2112 | case WM_CTLCOLORSTATIC: |
| 2113 | if (hBackground && (HWND)lParam == GetDlgItem(hMain, IDC_HISTORY)) |
| 2114 | { |
| 2115 | static HBRUSH hBrush=0; |
| 2116 | HDC hDC=(HDC)wParam; |
| 2117 | LOGBRUSH lb; |
| 2118 | |
| 2119 | if (hBrush) |
| 2120 | DeleteObject(hBrush); |
| 2121 | lb.lbStyle = BS_HOLLOW; |
| 2122 | hBrush = CreateBrushIndirect(&lb); |
| 2123 | SetBkMode(hDC, TRANSPARENT); |
| 2124 | SetTextColor(hDC, GetListFontColor()); |
| 2125 | return (LRESULT) hBrush; |
| 2126 | } |
| 2127 | break; |
| 2128 | |
| 2129 | case WM_INITDIALOG: |
| 2130 | /* Initialize info for resizing subitems */ |
| 2131 | GetClientRect(hWnd, &main_resize.rect); |
| 2132 | return TRUE; |
| 2133 | |
| 2134 | case WM_SETFOCUS: |
| 2135 | SetFocus(hwndList); |
| 2136 | break; |
| 2137 | |
| 2138 | case WM_SETTINGCHANGE: |
| 2139 | AdjustMetrics(); |
| 2140 | return 0; |
| 2141 | |
| 2142 | case WM_SIZE: |
| 2143 | OnSize(hWnd, wParam, LOWORD(lParam), HIWORD(wParam)); |
| 2144 | return TRUE; |
| 2145 | |
| 2146 | case WM_MENUSELECT: |
| 2147 | return Statusbar_MenuSelect(hWnd, wParam, lParam); |
| 2148 | |
| 2149 | case MM_PLAY_GAME: |
| 2150 | MamePlayGame(); |
| 2151 | return TRUE; |
| 2152 | |
| 2153 | case WM_INITMENUPOPUP: |
| 2154 | UpdateMenu(GetMenu(hWnd)); |
| 2155 | break; |
| 2156 | |
| 2157 | case WM_CONTEXTMENU: |
| 2158 | if (HandleTreeContextMenu(hWnd, wParam, lParam) |
| 2159 | || HandleScreenShotContextMenu(hWnd, wParam, lParam)) |
| 2160 | return FALSE; |
| 2161 | break; |
| 2162 | |
| 2163 | case WM_COMMAND: |
| 2164 | return MameCommand(hWnd,(int)(LOWORD(wParam)),(HWND)(lParam),(UINT)HIWORD(wParam)); |
| 2165 | |
| 2166 | case WM_GETMINMAXINFO: |
| 2167 | /* Don't let the window get too small; it can break resizing */ |
| 2168 | mminfo = (MINMAXINFO *) lParam; |
| 2169 | mminfo->ptMinTrackSize.x = MIN_WIDTH; |
| 2170 | mminfo->ptMinTrackSize.y = MIN_HEIGHT; |
| 2171 | return 0; |
| 2172 | |
| 2173 | case WM_TIMER: |
| 2174 | switch (wParam) |
| 2175 | { |
| 2176 | case JOYGUI_TIMER: |
| 2177 | PollGUIJoystick(); |
| 2178 | break; |
| 2179 | case SCREENSHOT_TIMER: |
| 2180 | TabView_CalculateNextTab(hTabCtrl); |
| 2181 | UpdateScreenShot(); |
| 2182 | TabView_UpdateSelection(hTabCtrl); |
| 2183 | break; |
| 2184 | default: |
| 2185 | break; |
| 2186 | } |
| 2187 | return TRUE; |
| 2188 | |
| 2189 | case WM_CLOSE: |
| 2190 | { |
| 2191 | /* save current item */ |
| 2192 | RECT rect; |
| 2193 | AREA area; |
| 2194 | int nItem; |
| 2195 | WINDOWPLACEMENT wndpl; |
| 2196 | UINT state; |
| 2197 | |
| 2198 | wndpl.length = sizeof(WINDOWPLACEMENT); |
| 2199 | GetWindowPlacement(hMain, &wndpl); |
| 2200 | state = wndpl.showCmd; |
| 2201 | |
| 2202 | /* Restore the window before we attempt to save parameters, |
| 2203 | * This fixed the lost window on startup problem, among other problems |
| 2204 | */ |
| 2205 | if (state == SW_MINIMIZE || state == SW_SHOWMINIMIZED || state == SW_MAXIMIZE) |
| 2206 | { |
| 2207 | if( wndpl.flags & WPF_RESTORETOMAXIMIZED || state == SW_MAXIMIZE) |
| 2208 | state = SW_MAXIMIZE; |
| 2209 | else |
| 2210 | { |
| 2211 | state = SW_RESTORE; |
| 2212 | ShowWindow(hWnd, SW_RESTORE); |
| 2213 | } |
| 2214 | } |
| 2215 | for (i = 0; i < GetSplitterCount(); i++) |
| 2216 | SetSplitterPos(i, nSplitterOffset[i]); |
| 2217 | SetWindowState(state); |
| 2218 | |
| 2219 | for (i = 0; i < sizeof(s_nPickers) / sizeof(s_nPickers[0]); i++) |
| 2220 | Picker_SaveColumnWidths(GetDlgItem(hMain, s_nPickers[i])); |
| 2221 | |
| 2222 | GetWindowRect(hWnd, &rect); |
| 2223 | area.x = rect.left; |
| 2224 | area.y = rect.top; |
| 2225 | area.width = rect.right - rect.left; |
| 2226 | area.height = rect.bottom - rect.top; |
| 2227 | SetWindowArea(&area); |
| 2228 | |
| 2229 | /* Save the users current game options and default game */ |
| 2230 | nItem = Picker_GetSelectedItem(hwndList); |
| 2231 | SetDefaultGame(ModifyThe(drivers[nItem]->name)); |
| 2232 | |
| 2233 | /* hide window to prevent orphan empty rectangles on the taskbar */ |
| 2234 | /* ShowWindow(hWnd,SW_HIDE); */ |
| 2235 | DestroyWindow( hWnd ); |
| 2236 | |
| 2237 | /* PostQuitMessage(0); */ |
| 2238 | break; |
| 2239 | } |
| 2240 | |
| 2241 | case WM_DESTROY: |
| 2242 | PostQuitMessage(0); |
| 2243 | return 0; |
| 2244 | |
| 2245 | case WM_LBUTTONDOWN: |
| 2246 | OnLButtonDown(hWnd, (UINT)wParam, MAKEPOINTS(lParam)); |
| 2247 | break; |
| 2248 | |
| 2249 | /* |
| 2250 | Check to see if the mouse has been moved by the user since |
| 2251 | startup. I'd like this checking to be done only in the |
| 2252 | main WinProc (here), but somehow the WM_MOUSEDOWN messages |
| 2253 | are eaten up before they reach MameWindowProc. That's why |
| 2254 | there is one check for each of the subclassed windows too. |
| 2255 | |
| 2256 | POSSIBLE BUGS: |
| 2257 | I've included this check in the subclassed windows, but a |
| 2258 | mose move in either the title bar, the menu, or the |
| 2259 | toolbar will not generate a WM_MOUSEOVER message. At least |
| 2260 | not one that I know how to pick up. A solution could maybe |
| 2261 | be to subclass those too, but that's too much work :) |
| 2262 | */ |
| 2263 | |
| 2264 | case WM_MOUSEMOVE: |
| 2265 | { |
| 2266 | if (MouseHasBeenMoved()) |
| 2267 | ShowCursor(TRUE); |
| 2268 | |
| 2269 | if (g_listview_dragging) |
| 2270 | MouseMoveListViewDrag(MAKEPOINTS(lParam)); |
| 2271 | else |
| 2272 | /* for splitters */ |
| 2273 | OnMouseMove(hWnd, (UINT)wParam, MAKEPOINTS(lParam)); |
| 2274 | break; |
| 2275 | } |
| 2276 | |
| 2277 | case WM_LBUTTONUP: |
| 2278 | if (g_listview_dragging) |
| 2279 | ButtonUpListViewDrag(MAKEPOINTS(lParam)); |
| 2280 | else |
| 2281 | /* for splitters */ |
| 2282 | OnLButtonUp(hWnd, (UINT)wParam, MAKEPOINTS(lParam)); |
| 2283 | break; |
| 2284 | |
| 2285 | case WM_NOTIFY: |
| 2286 | /* Where is this message intended to go */ |
| 2287 | { |
| 2288 | LPNMHDR lpNmHdr = (LPNMHDR)lParam; |
| 2289 | |
| 2290 | /* Fetch tooltip text */ |
| 2291 | if (lpNmHdr->code == TTN_NEEDTEXT) |
| 2292 | { |
| 2293 | LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT)lParam; |
| 2294 | CopyToolTipText(lpttt); |
| 2295 | } |
| 2296 | |
| 2297 | if (lpNmHdr->hwndFrom == hTreeView) |
| 2298 | return TreeViewNotify(lpNmHdr); |
| 2299 | |
| 2300 | GetClassName(lpNmHdr->hwndFrom, szClass, sizeof(szClass) / sizeof(szClass[0])); |
| 2301 | if (!_tcscmp(szClass, TEXT("SysListView32"))) |
| 2302 | return Picker_HandleNotify(lpNmHdr); |
| 2303 | if (!_tcscmp(szClass, TEXT("SysTabControl32"))) |
| 2304 | return TabView_HandleNotify(lpNmHdr); |
| 2305 | } |
| 2306 | break; |
| 2307 | |
| 2308 | case WM_DRAWITEM: |
| 2309 | { |
| 2310 | LPDRAWITEMSTRUCT lpDis = (LPDRAWITEMSTRUCT)lParam; |
| 2311 | |
| 2312 | GetClassName(lpDis->hwndItem, szClass, sizeof(szClass) / sizeof(szClass[0])); |
| 2313 | if (!_tcscmp(szClass, TEXT("SysListView32"))) |
| 2314 | Picker_HandleDrawItem(GetDlgItem(hMain, lpDis->CtlID), lpDis); |
| 2315 | } |
| 2316 | break; |
| 2317 | |
| 2318 | case WM_MEASUREITEM : |
| 2319 | { |
| 2320 | LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam; |
| 2321 | |
| 2322 | // tell the list view that each row (item) should be just taller than our font |
| 2323 | |
| 2324 | //DefWindowProc(hWnd, message, wParam, lParam); |
| 2325 | //dprintf("default row height calculation gives %u\n",lpmis->itemHeight); |
| 2326 | |
| 2327 | TEXTMETRIC tm; |
| 2328 | HDC hDC = GetDC(NULL); |
| 2329 | HFONT hFontOld = (HFONT)SelectObject(hDC,hFont); |
| 2330 | |
| 2331 | GetTextMetrics(hDC,&tm); |
| 2332 | |
| 2333 | lpmis->itemHeight = tm.tmHeight + tm.tmExternalLeading + 1; |
| 2334 | if (lpmis->itemHeight < 17) |
| 2335 | lpmis->itemHeight = 17; |
| 2336 | //dprintf("we would do %u\n",tm.tmHeight + tm.tmExternalLeading + 1); |
| 2337 | SelectObject(hDC,hFontOld); |
| 2338 | ReleaseDC(NULL,hDC); |
| 2339 | |
| 2340 | return TRUE; |
| 2341 | } |
| 2342 | |
| 2343 | case WM_MAME32_FILECHANGED: |
| 2344 | { |
| 2345 | char szFileName[32]; |
| 2346 | char *s; |
| 2347 | int nGameIndex; |
| 2348 | int (*pfnGetAuditResults)(int driver_index) = NULL; |
| 2349 | void (*pfnSetAuditResults)(int driver_index, int audit_results) = NULL; |
| 2350 | |
| 2351 | switch(HIWORD(wParam)) |
| 2352 | { |
| 2353 | case 0: |
| 2354 | pfnGetAuditResults = GetRomAuditResults; |
| 2355 | pfnSetAuditResults = SetRomAuditResults; |
| 2356 | break; |
| 2357 | |
| 2358 | case 1: |
| 2359 | pfnGetAuditResults = GetSampleAuditResults; |
| 2360 | pfnSetAuditResults = SetSampleAuditResults; |
| 2361 | break; |
| 2362 | } |
| 2363 | |
| 2364 | if (pfnGetAuditResults && pfnSetAuditResults) |
| 2365 | { |
| 2366 | int nParentIndex = -1; |
| 2367 | |
| 2368 | snprintf(szFileName, sizeof(szFileName), "%s", (LPCSTR) lParam); |
| 2369 | s = strchr(szFileName, '.'); |
| 2370 | if (s) |
| 2371 | *s = '\0'; |
| 2372 | s = strchr(szFileName, '\\'); |
| 2373 | if (s) |
| 2374 | *s = '\0'; |
| 2375 | |
| 2376 | for (nGameIndex = 0; drivers[nGameIndex]; nGameIndex++) |
| 2377 | { |
| 2378 | for (nParentIndex = nGameIndex; nGameIndex == -1; nParentIndex = GetParentIndex(drivers[nParentIndex])) |
| 2379 | { |
| 2380 | if (!mame_stricmp(drivers[nParentIndex]->name, szFileName)) |
| 2381 | { |
| 2382 | if (pfnGetAuditResults(nGameIndex) != UNKNOWN) |
| 2383 | { |
| 2384 | pfnSetAuditResults(nGameIndex, UNKNOWN); |
| 2385 | PostMessage(hMain, WM_MAME32_AUDITGAME, wParam, nGameIndex); |
| 2386 | } |
| 2387 | break; |
| 2388 | } |
| 2389 | } |
| 2390 | } |
| 2391 | } |
| 2392 | } |
| 2393 | break; |
| 2394 | |
| 2395 | case WM_MAME32_AUDITGAME: |
| 2396 | { |
| 2397 | LV_FINDINFO lvfi; |
| 2398 | int nGameIndex; |
| 2399 | |
| 2400 | nGameIndex = lParam; |
| 2401 | |
| 2402 | switch(HIWORD(wParam)) |
| 2403 | { |
| 2404 | case 0: |
| 2405 | Mame32VerifyRomSet(nGameIndex); |
| 2406 | break; |
| 2407 | case 1: |
| 2408 | Mame32VerifySampleSet(nGameIndex); |
| 2409 | break; |
| 2410 | } |
| 2411 | |
| 2412 | memset(&lvfi, 0, sizeof(lvfi)); |
| 2413 | lvfi.flags = LVFI_PARAM; |
| 2414 | lvfi.lParam = nGameIndex; |
| 2415 | |
| 2416 | i = ListView_FindItem(hwndList, -1, &lvfi); |
| 2417 | if (i != -1) |
| 2418 | { |
| 2419 | ListView_RedrawItems(hwndList, i, i); |
| 2420 | } |
| 2421 | } |
| 2422 | break; |
| 2423 | |
| 2424 | default: |
| 2425 | |
| 2426 | break; |
| 2427 | } |
| 2428 | |
| 2429 | return DefWindowProc(hWnd, message, wParam, lParam); |
| 2430 | } |
| 2431 | |
| 2432 | static int HandleKeyboardGUIMessage(HWND hWnd, UINT message, UINT wParam, LONG lParam) |
| 2433 | { |
| 2434 | switch (message) |
| 2435 | { |
| 2436 | case WM_CHAR: /* List-View controls use this message for searching the items "as user types" */ |
| 2437 | //MessageBox(NULL,"wm_char message arrived","TitleBox",MB_OK); |
| 2438 | return TRUE; |
| 2439 | |
| 2440 | case WM_KEYDOWN: |
| 2441 | KeyboardKeyDown(0, wParam, lParam); |
| 2442 | return TRUE; |
| 2443 | |
| 2444 | case WM_KEYUP: |
| 2445 | KeyboardKeyUp(0, wParam, lParam); |
| 2446 | return TRUE; |
| 2447 | |
| 2448 | case WM_SYSKEYDOWN: |
| 2449 | KeyboardKeyDown(1, wParam, lParam); |
| 2450 | return TRUE; |
| 2451 | |
| 2452 | case WM_SYSKEYUP: |
| 2453 | KeyboardKeyUp(1, wParam, lParam); |
| 2454 | return TRUE; |
| 2455 | } |
| 2456 | |
| 2457 | return FALSE; /* message not processed */ |
| 2458 | } |
| 2459 | |
| 2460 | static BOOL PumpMessage() |
| 2461 | { |
| 2462 | MSG msg; |
| 2463 | |
| 2464 | if (!GetMessage(&msg, NULL, 0, 0)) |
| 2465 | { |
| 2466 | return FALSE; |
| 2467 | } |
| 2468 | |
| 2469 | if (IsWindow(hMain)) |
| 2470 | { |
| 2471 | BOOL absorbed_key = FALSE; |
| 2472 | if (GetKeyGUI()) |
| 2473 | absorbed_key = HandleKeyboardGUIMessage(msg.hwnd, msg.message, |
| 2474 | msg.wParam, msg.lParam); |
| 2475 | else |
| 2476 | absorbed_key = TranslateAccelerator(hMain, hAccel, &msg); |
| 2477 | |
| 2478 | if (!absorbed_key) |
| 2479 | { |
| 2480 | if (!IsDialogMessage(hMain, &msg)) |
| 2481 | { |
| 2482 | TranslateMessage(&msg); |
| 2483 | DispatchMessage(&msg); |
| 2484 | } |
| 2485 | } |
| 2486 | } |
| 2487 | |
| 2488 | return TRUE; |
| 2489 | } |
| 2490 | |
| 2491 | static BOOL FolderCheck(void) |
| 2492 | { |
| 2493 | |
| 2494 | char *pDescription = NULL; |
| 2495 | int nGameIndex = 0; |
| 2496 | int i=0; |
| 2497 | int iStep = 0; |
| 2498 | LV_FINDINFO lvfi; |
| 2499 | int nCount = ListView_GetItemCount(hwndList); |
| 2500 | BOOL changed = FALSE; |
| 2501 | |
| 2502 | MSG msg; |
| 2503 | for(i=0; i<nCount;i++) |
| 2504 | { |
| 2505 | LV_ITEM lvi; |
| 2506 | |
| 2507 | lvi.iItem = i; |
| 2508 | lvi.iSubItem = 0; |
| 2509 | lvi.mask = LVIF_PARAM; |
| 2510 | ListView_GetItem(hwndList, &lvi); |
| 2511 | nGameIndex = lvi.lParam; |
| 2512 | SetRomAuditResults(nGameIndex, UNKNOWN); |
| 2513 | SetSampleAuditResults(nGameIndex, UNKNOWN); |
| 2514 | } |
| 2515 | if( nCount > 0) |
| 2516 | ProgressBarShow(); |
| 2517 | else |
| 2518 | return FALSE; |
| 2519 | if( nCount < 100 ) |
| 2520 | iStep = 100 / nCount; |
| 2521 | else |
| 2522 | iStep = nCount/100; |
| 2523 | UpdateListView(); |
| 2524 | UpdateWindow(hMain); |
| 2525 | for(i=0; i<nCount;i++) |
| 2526 | { |
| 2527 | LV_ITEM lvi; |
| 2528 | |
| 2529 | lvi.iItem = i; |
| 2530 | lvi.iSubItem = 0; |
| 2531 | lvi.mask = LVIF_PARAM; |
| 2532 | ListView_GetItem(hwndList, &lvi); |
| 2533 | nGameIndex = lvi.lParam; |
| 2534 | if (GetRomAuditResults(nGameIndex) == UNKNOWN) |
| 2535 | { |
| 2536 | Mame32VerifyRomSet(nGameIndex); |
| 2537 | changed = TRUE; |
| 2538 | } |
| 2539 | |
| 2540 | if (GetSampleAuditResults(nGameIndex) == UNKNOWN) |
| 2541 | { |
| 2542 | Mame32VerifySampleSet(nGameIndex); |
| 2543 | changed = TRUE; |
| 2544 | } |
| 2545 | |
| 2546 | lvfi.flags = LVFI_PARAM; |
| 2547 | lvfi.lParam = nGameIndex; |
| 2548 | |
| 2549 | i = ListView_FindItem(hwndList, -1, &lvfi); |
| 2550 | if (changed && i != -1); |
| 2551 | { |
| 2552 | ListView_RedrawItems(hwndList, i, i); |
| 2553 | while( PeekMessage( &msg, hwndList, 0, 0, PM_REMOVE ) != 0) |
| 2554 | { |
| 2555 | TranslateMessage(&msg); |
| 2556 | DispatchMessage(&msg); |
| 2557 | } |
| 2558 | } |
| 2559 | changed = FALSE; |
| 2560 | if ((i % iStep) == 0) |
| 2561 | ProgressBarStepParam(i, nCount); |
| 2562 | } |
| 2563 | ProgressBarHide(); |
| 2564 | pDescription = ModifyThe(drivers[Picker_GetSelectedItem(hwndList)]->description); |
| 2565 | SetStatusBarText(0, pDescription); |
| 2566 | UpdateStatusBar(); |
| 2567 | return TRUE; |
| 2568 | } |
| 2569 | |
| 2570 | static BOOL GameCheck(void) |
| 2571 | { |
| 2572 | LV_FINDINFO lvfi; |
| 2573 | int i; |
| 2574 | BOOL changed = FALSE; |
| 2575 | |
| 2576 | if (game_index == 0) |
| 2577 | ProgressBarShow(); |
| 2578 | |
| 2579 | if (game_index >= driver_list_get_count(drivers)) |
| 2580 | { |
| 2581 | bDoGameCheck = FALSE; |
| 2582 | ProgressBarHide(); |
| 2583 | ResetWhichGamesInFolders(); |
| 2584 | return FALSE; |
| 2585 | } |
| 2586 | |
| 2587 | if (GetRomAuditResults(game_index) == UNKNOWN) |
| 2588 | { |
| 2589 | Mame32VerifyRomSet(game_index); |
| 2590 | changed = TRUE; |
| 2591 | } |
| 2592 | |
| 2593 | if (GetSampleAuditResults(game_index) == UNKNOWN) |
| 2594 | { |
| 2595 | Mame32VerifySampleSet(game_index); |
| 2596 | changed = TRUE; |
| 2597 | } |
| 2598 | |
| 2599 | lvfi.flags = LVFI_PARAM; |
| 2600 | lvfi.lParam = game_index; |
| 2601 | |
| 2602 | i = ListView_FindItem(hwndList, -1, &lvfi); |
| 2603 | if (changed && i != -1); |
| 2604 | ListView_RedrawItems(hwndList, i, i); |
| 2605 | if ((game_index % progBarStep) == 0) |
| 2606 | ProgressBarStep(); |
| 2607 | game_index++; |
| 2608 | |
| 2609 | return changed; |
| 2610 | } |
| 2611 | |
| 2612 | static BOOL OnIdle(HWND hWnd) |
| 2613 | { |
| 2614 | static int bFirstTime = TRUE; |
| 2615 | static int bResetList = TRUE; |
| 2616 | |
| 2617 | char *pDescription; |
| 2618 | int driver_index; |
| 2619 | |
| 2620 | if (bFirstTime) |
| 2621 | { |
| 2622 | bResetList = FALSE; |
| 2623 | bFirstTime = FALSE; |
| 2624 | } |
| 2625 | if (bDoGameCheck) |
| 2626 | { |
| 2627 | bResetList |= GameCheck(); |
| 2628 | return idle_work; |
| 2629 | } |
| 2630 | // NPW 17-Jun-2003 - Commenting this out because it is redundant |
| 2631 | // and it causes the game to reset back to the original game after an F5 |
| 2632 | // refresh |
| 2633 | //driver_index = GetGameNameIndex(GetDefaultGame()); |
| 2634 | //SetSelectedPickItem(driver_index); |
| 2635 | |
| 2636 | // in case it's not found, get it back |
| 2637 | driver_index = Picker_GetSelectedItem(hwndList); |
| 2638 | |
| 2639 | pDescription = ModifyThe(drivers[driver_index]->description); |
| 2640 | SetStatusBarText(0, pDescription); |
| 2641 | idle_work = FALSE; |
| 2642 | UpdateStatusBar(); |
| 2643 | bFirstTime = TRUE; |
| 2644 | |
| 2645 | if (!idle_work) |
| 2646 | PostMessage(GetMainWindow(),WM_COMMAND, MAKEWPARAM(ID_VIEW_LINEUPICONS, TRUE),(LPARAM)NULL); |
| 2647 | return idle_work; |
| 2648 | } |
| 2649 | |
| 2650 | static void OnSize(HWND hWnd, UINT nState, int nWidth, int nHeight) |
| 2651 | { |
| 2652 | static BOOL firstTime = TRUE; |
| 2653 | |
| 2654 | if (nState != SIZE_MAXIMIZED && nState != SIZE_RESTORED) |
| 2655 | return; |
| 2656 | |
| 2657 | ResizeWindow(hWnd, &main_resize); |
| 2658 | ResizeProgressBar(); |
| 2659 | if (firstTime == FALSE) |
| 2660 | OnSizeSplitter(hMain); |
| 2661 | //firstTime = FALSE; |
| 2662 | /* Update the splitters structures as appropriate */ |
| 2663 | RecalcSplitters(); |
| 2664 | if (firstTime == FALSE) |
| 2665 | ResizePickerControls(hMain); |
| 2666 | firstTime = FALSE; |
| 2667 | UpdateScreenShot(); |
| 2668 | } |
| 2669 | |
| 2670 | |
| 2671 | |
| 2672 | static HWND GetResizeItemWindow(HWND hParent, const ResizeItem *ri) |
| 2673 | { |
| 2674 | HWND hControl; |
| 2675 | if (ri->type == RA_ID) |
| 2676 | hControl = GetDlgItem(hParent, ri->u.id); |
| 2677 | else |
| 2678 | hControl = ri->u.hwnd; |
| 2679 | return hControl; |
| 2680 | } |
| 2681 | |
| 2682 | |
| 2683 | |
| 2684 | static void SetAllWindowsFont(HWND hParent, const Resize *r, HFONT hTheFont, BOOL bRedraw) |
| 2685 | { |
| 2686 | int i; |
| 2687 | HWND hControl; |
| 2688 | |
| 2689 | for (i = 0; r->items[i].type != RA_END; i++) |
| 2690 | { |
| 2691 | if (r->items[i].setfont) |
| 2692 | { |
| 2693 | hControl = GetResizeItemWindow(hParent, &r->items[i]); |
| 2694 | SetWindowFont(hControl, hTheFont, bRedraw); |
| 2695 | } |
| 2696 | } |
| 2697 | } |
| 2698 | |
| 2699 | |
| 2700 | |
| 2701 | static void ResizeWindow(HWND hParent, Resize *r) |
| 2702 | { |
| 2703 | int cmkindex = 0, dx, dy, dx1, dtempx; |
| 2704 | HWND hControl; |
| 2705 | RECT parent_rect, rect; |
| 2706 | ResizeItem *ri; |
| 2707 | POINT p = {0, 0}; |
| 2708 | |
| 2709 | if (hParent == NULL) |
| 2710 | return; |
| 2711 | |
| 2712 | /* Calculate change in width and height of parent window */ |
| 2713 | GetClientRect(hParent, &parent_rect); |
| 2714 | //dx = parent_rect.right - r->rect.right; |
| 2715 | dtempx = parent_rect.right - r->rect.right; |
| 2716 | dy = parent_rect.bottom - r->rect.bottom; |
| 2717 | dx = dtempx/2; |
| 2718 | dx1 = dtempx - dx; |
| 2719 | ClientToScreen(hParent, &p); |
| 2720 | |
| 2721 | while (r->items[cmkindex].type != RA_END) |
| 2722 | { |
| 2723 | ri = &r->items[cmkindex]; |
| 2724 | if (ri->type == RA_ID) |
| 2725 | hControl = GetDlgItem(hParent, ri->u.id); |
| 2726 | else |
| 2727 | hControl = ri->u.hwnd; |
| 2728 | |
| 2729 | if (hControl == NULL) |
| 2730 | { |
| 2731 | cmkindex++; |
| 2732 | continue; |
| 2733 | } |
| 2734 | |
| 2735 | /* Get control's rectangle relative to parent */ |
| 2736 | GetWindowRect(hControl, &rect); |
| 2737 | OffsetRect(&rect, -p.x, -p.y); |
| 2738 | |
| 2739 | if (!(ri->action & RA_LEFT)) |
| 2740 | rect.left += dx; |
| 2741 | |
| 2742 | if (!(ri->action & RA_TOP)) |
| 2743 | rect.top += dy; |
| 2744 | |
| 2745 | if (ri->action & RA_RIGHT) |
| 2746 | rect.right += dx; |
| 2747 | |
| 2748 | if (ri->action & RA_BOTTOM) |
| 2749 | rect.bottom += dy; |
| 2750 | |
| 2751 | MoveWindow(hControl, rect.left, rect.top, |
| 2752 | (rect.right - rect.left), |
| 2753 | (rect.bottom - rect.top), TRUE); |
| 2754 | |
| 2755 | /* Take care of subcontrols, if appropriate */ |
| 2756 | if (ri->subwindow != NULL) |
| 2757 | ResizeWindow(hControl, ri->subwindow); |
| 2758 | |
| 2759 | cmkindex++; |
| 2760 | } |
| 2761 | |
| 2762 | /* Record parent window's new location */ |
| 2763 | memcpy(&r->rect, &parent_rect, sizeof(RECT)); |
| 2764 | } |
| 2765 | |
| 2766 | static void ProgressBarShow() |
| 2767 | { |
| 2768 | RECT rect; |
| 2769 | int widths[2] = {150, -1}; |
| 2770 | |
| 2771 | if (driver_list_get_count(drivers) < 100) |
| 2772 | progBarStep = 100 / driver_list_get_count(drivers); |
| 2773 | else |
| 2774 | progBarStep = (driver_list_get_count(drivers) / 100); |
| 2775 | |
| 2776 | SendMessage(hStatusBar, SB_SETPARTS, (WPARAM)2, (LPARAM)(LPINT)widths); |
| 2777 | SendMessage(hProgWnd, PBM_SETRANGE, 0, (LPARAM)MAKELONG(0, driver_list_get_count(drivers))); |
| 2778 | SendMessage(hProgWnd, PBM_SETSTEP, (WPARAM)progBarStep, 0); |
| 2779 | SendMessage(hProgWnd, PBM_SETPOS, 0, 0); |
| 2780 | |
| 2781 | StatusBar_GetItemRect(hStatusBar, 1, &rect); |
| 2782 | |
| 2783 | MoveWindow(hProgWnd, rect.left, rect.top, |
| 2784 | rect.right - rect.left, |
| 2785 | rect.bottom - rect.top, TRUE); |
| 2786 | |
| 2787 | bProgressShown = TRUE; |
| 2788 | } |
| 2789 | |
| 2790 | static void ProgressBarHide() |
| 2791 | { |
| 2792 | RECT rect; |
| 2793 | int widths[4]; |
| 2794 | HDC hDC; |
| 2795 | SIZE size; |
| 2796 | int numParts = 4; |
| 2797 | |
| 2798 | if (hProgWnd == NULL) |
| 2799 | { |
| 2800 | return; |
| 2801 | } |
| 2802 | |
| 2803 | hDC = GetDC(hProgWnd); |
| 2804 | |
| 2805 | ShowWindow(hProgWnd, SW_HIDE); |
| 2806 | |
| 2807 | GetTextExtentPoint32(hDC, TEXT("MMX"), 3, &size); |
| 2808 | widths[3] = size.cx; |
| 2809 | GetTextExtentPoint32(hDC, TEXT("MMMM games"), 10, &size); |
| 2810 | widths[2] = size.cx; |
| 2811 | //Just specify 24 instead of 30, gives us sufficient space to display the message, and saves some space |
| 2812 | GetTextExtentPoint32(hDC, TEXT("Screen flip support is missing"), 24, &size); |
| 2813 | widths[1] = size.cx; |
| 2814 | |
| 2815 | ReleaseDC(hProgWnd, hDC); |
| 2816 | |
| 2817 | widths[0] = -1; |
| 2818 | SendMessage(hStatusBar, SB_SETPARTS, (WPARAM)1, (LPARAM)(LPINT)widths); |
| 2819 | StatusBar_GetItemRect(hStatusBar, 0, &rect); |
| 2820 | |
| 2821 | widths[0] = (rect.right - rect.left) - (widths[1] + widths[2] + widths[3]); |
| 2822 | widths[1] += widths[0]; |
| 2823 | widths[2] += widths[1]; |
| 2824 | widths[3] = -1; |
| 2825 | |
| 2826 | SendMessage(hStatusBar, SB_SETPARTS, (WPARAM)numParts, (LPARAM)(LPINT)widths); |
| 2827 | UpdateStatusBar(); |
| 2828 | |
| 2829 | bProgressShown = FALSE; |
| 2830 | } |
| 2831 | |
| 2832 | static void ResizeProgressBar() |
| 2833 | { |
| 2834 | if (bProgressShown) |
| 2835 | { |
| 2836 | RECT rect; |
| 2837 | int widths[2] = {150, -1}; |
| 2838 | |
| 2839 | SendMessage(hStatusBar, SB_SETPARTS, (WPARAM)2, (LPARAM)(LPINT)widths); |
| 2840 | StatusBar_GetItemRect(hStatusBar, 1, &rect); |
| 2841 | MoveWindow(hProgWnd, rect.left, rect.top, |
| 2842 | rect.right - rect.left, |
| 2843 | rect.bottom - rect.top, TRUE); |
| 2844 | } |
| 2845 | else |
| 2846 | { |
| 2847 | ProgressBarHide(); |
| 2848 | } |
| 2849 | } |
| 2850 | |
| 2851 | static void ProgressBarStepParam(int iGameIndex, int nGameCount) |
| 2852 | { |
| 2853 | SetStatusBarTextF(0, "Game search %d%% complete", |
| 2854 | ((iGameIndex + 1) * 100) / nGameCount); |
| 2855 | if (iGameIndex == 0) |
| 2856 | ShowWindow(hProgWnd, SW_SHOW); |
| 2857 | SendMessage(hProgWnd, PBM_STEPIT, 0, 0); |
| 2858 | } |
| 2859 | |
| 2860 | static void ProgressBarStep() |
| 2861 | { |
| 2862 | ProgressBarStepParam(game_index, driver_list_get_count(drivers)); |
| 2863 | } |
| 2864 | |
| 2865 | static HWND InitProgressBar(HWND hParent) |
| 2866 | { |
| 2867 | RECT rect; |
| 2868 | |
| 2869 | StatusBar_GetItemRect(hStatusBar, 0, &rect); |
| 2870 | |
| 2871 | rect.left += 150; |
| 2872 | |
| 2873 | return CreateWindowEx(WS_EX_STATICEDGE, |
| 2874 | PROGRESS_CLASS, |
| 2875 | TEXT("Progress Bar"), |
| 2876 | WS_CHILD | PBS_SMOOTH, |
| 2877 | rect.left, |
| 2878 | rect.top, |
| 2879 | rect.right - rect.left, |
| 2880 | rect.bottom - rect.top, |
| 2881 | hParent, |
| 2882 | NULL, |
| 2883 | hInst, |
| 2884 | NULL); |
| 2885 | } |
| 2886 | |
| 2887 | static void CopyToolTipText(LPTOOLTIPTEXT lpttt) |
| 2888 | { |
| 2889 | int i; |
| 2890 | int iButton = lpttt->hdr.idFrom; |
| 2891 | static TCHAR String[1024]; |
| 2892 | BOOL bConverted = FALSE; |
| 2893 | TCHAR* t_gameinfostatus; |
| 2894 | |
| 2895 | /* Map command ID to string index */ |
| 2896 | for (i = 0; CommandToString[i] != -1; i++) |
| 2897 | { |
| 2898 | if (CommandToString[i] == iButton) |
| 2899 | { |
| 2900 | iButton = i; |
| 2901 | bConverted = TRUE; |
| 2902 | break; |
| 2903 | } |
| 2904 | } |
| 2905 | if( bConverted ) |
| 2906 | { |
| 2907 | /* Check for valid parameter */ |
| 2908 | if(iButton > NUM_TOOLTIPS) |
| 2909 | { |
| 2910 | _tcscpy(String,TEXT("Invalid Button Index")); |
| 2911 | } |
| 2912 | else |
| 2913 | { |
| 2914 | _tcscpy(String,szTbStrings[iButton]); |
| 2915 | } |
| 2916 | } |
| 2917 | else if ( iButton <= 2 ) |
| 2918 | { |
| 2919 | //Statusbar |
| 2920 | SendMessage(lpttt->hdr.hwndFrom, TTM_SETMAXTIPWIDTH, 0, 200); |
| 2921 | if( iButton != 1) |
| 2922 | SendMessage(hStatusBar, SB_GETTEXT, (WPARAM)iButton, (LPARAM)&String ); |
| 2923 | else { |
| 2924 | //for first pane we get the Status directly, to get the line breaks |
| 2925 | t_gameinfostatus = tstring_from_utf8( GameInfoStatus(Picker_GetSelectedItem(hwndList), FALSE)); |
| 2926 | if( !t_gameinfostatus ) |
| 2927 | return; |
| 2928 | _tcscpy(String, t_gameinfostatus); |
| 2929 | free(t_gameinfostatus); |
| 2930 | } |
| 2931 | } |
| 2932 | else |
| 2933 | _tcscpy(String,TEXT("Invalid Button Index")); |
| 2934 | |
| 2935 | lpttt->lpszText = String; |
| 2936 | } |
| 2937 | |
| 2938 | static HWND InitToolbar(HWND hParent) |
| 2939 | { |
| 2940 | HWND hToolBar = CreateToolbarEx(hParent, |
| 2941 | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | |
| 2942 | CCS_TOP | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS, |
| 2943 | 1, |
| 2944 | 8, |
| 2945 | hInst, |
| 2946 | IDB_TOOLBAR, |
| 2947 | tbb, |
| 2948 | NUM_TOOLBUTTONS, |
| 2949 | 16, |
| 2950 | 16, |
| 2951 | 0, |
| 2952 | 0, |
| 2953 | sizeof(TBBUTTON)); |
| 2954 | RECT rect; |
| 2955 | int idx; |
| 2956 | int iPosX, iPosY, iHeight; |
| 2957 | |
| 2958 | // get Edit Control position |
| 2959 | idx = SendMessage(hToolBar, TB_BUTTONCOUNT, (WPARAM)0, (LPARAM)0) - 1; |
| 2960 | SendMessage(hToolBar, TB_GETITEMRECT, (WPARAM)idx, (LPARAM)&rect); |
| 2961 | iPosX = rect.right + 10; |
| 2962 | iPosY = rect.top + 1; |
| 2963 | iHeight = rect.bottom - rect.top - 2; |
| 2964 | |
| 2965 | // create Edit Control |
| 2966 | CreateWindowEx( 0L, TEXT("Edit"), SEARCH_PROMPT, WS_CHILD | WS_BORDER | WS_VISIBLE | ES_LEFT, |
| 2967 | iPosX, iPosY, 200, iHeight, hToolBar, (HMENU)ID_TOOLBAR_EDIT, hInst, NULL ); |
| 2968 | |
| 2969 | return hToolBar; |
| 2970 | } |
| 2971 | |
| 2972 | static HWND InitStatusBar(HWND hParent) |
| 2973 | { |
| 2974 | HMENU hMenu = GetMenu(hParent); |
| 2975 | |
| 2976 | popstr[0].hMenu = 0; |
| 2977 | popstr[0].uiString = 0; |
| 2978 | popstr[1].hMenu = hMenu; |
| 2979 | popstr[1].uiString = IDS_UI_FILE; |
| 2980 | popstr[2].hMenu = GetSubMenu(hMenu, 1); |
| 2981 | popstr[2].uiString = IDS_VIEW_TOOLBAR; |
| 2982 | popstr[3].hMenu = 0; |
| 2983 | popstr[3].uiString = 0; |
| 2984 | |
| 2985 | return CreateStatusWindow(WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | |
| 2986 | CCS_BOTTOM | SBARS_SIZEGRIP | SBT_TOOLTIPS, |
| 2987 | TEXT("Ready"), |
| 2988 | hParent, |
| 2989 | 2); |
| 2990 | } |
| 2991 | |
| 2992 | |
| 2993 | static LRESULT Statusbar_MenuSelect(HWND hwnd, WPARAM wParam, LPARAM lParam) |
| 2994 | { |
| 2995 | UINT fuFlags = (UINT)HIWORD(wParam); |
| 2996 | HMENU hMainMenu = NULL; |
| 2997 | int iMenu = 0; |
| 2998 | |
| 2999 | /* Handle non-system popup menu descriptions. */ |
| 3000 | if ( (fuFlags & MF_POPUP) |
| 3001 | && (!(fuFlags & MF_SYSMENU))) |
| 3002 | { |
| 3003 | for (iMenu = 1; iMenu < MAX_MENUS; iMenu++) |
| 3004 | { |
| 3005 | if ((HMENU)lParam == popstr[iMenu].hMenu) |
| 3006 | { |
| 3007 | hMainMenu = (HMENU)lParam; |
| 3008 | break ; |
| 3009 | } |
| 3010 | } |
| 3011 | } |
| 3012 | |
| 3013 | if (hMainMenu) |
| 3014 | { |
| 3015 | /* Display helpful text in status bar */ |
| 3016 | MenuHelp(WM_MENUSELECT, wParam, lParam, hMainMenu, hInst, |
| 3017 | hStatusBar, (UINT *)&popstr[iMenu]); |
| 3018 | } |
| 3019 | else |
| 3020 | { |
| 3021 | UINT nZero = 0; |
| 3022 | MenuHelp(WM_MENUSELECT, wParam, lParam, NULL, hInst, |
| 3023 | hStatusBar, &nZero); |
| 3024 | } |
| 3025 | |
| 3026 | return 0; |
| 3027 | } |
| 3028 | |
| 3029 | static void UpdateStatusBar() |
| 3030 | { |
| 3031 | LPTREEFOLDER lpFolder = GetCurrentFolder(); |
| 3032 | int games_shown = 0; |
| 3033 | int i = -1; |
| 3034 | |
| 3035 | if (!lpFolder) |
| 3036 | return; |
| 3037 | |
| 3038 | while (1) |
| 3039 | { |
| 3040 | i = FindGame(lpFolder,i+1); |
| 3041 | if (i == -1) |
| 3042 | break; |
| 3043 | |
| 3044 | if (!GameFiltered(i, lpFolder->m_dwFlags)) |
| 3045 | games_shown++; |
| 3046 | } |
| 3047 | |
| 3048 | /* Show number of games in the current 'View' in the status bar */ |
| 3049 | SetStatusBarTextF(2, g_szGameCountString, games_shown); |
| 3050 | |
| 3051 | i = Picker_GetSelectedItem(hwndList); |
| 3052 | |
| 3053 | if (games_shown == 0) |
| 3054 | DisableSelection(); |
| 3055 | else |
| 3056 | { |
| 3057 | const char* pStatus = GameInfoStatus(i, FALSE); |
| 3058 | SetStatusBarText(1, pStatus); |
| 3059 | } |
| 3060 | } |
| 3061 | |
| 3062 | static void UpdateHistory(void) |
| 3063 | { |
| 3064 | HDC hDC; |
| 3065 | RECT rect; |
| 3066 | TEXTMETRIC tm ; |
| 3067 | int nLines, nLineHeight; |
| 3068 | //DWORD dwStyle = GetWindowLong(GetDlgItem(hMain, IDC_HISTORY), GWL_STYLE); |
| 3069 | have_history = FALSE; |
| 3070 | |
| 3071 | if (GetSelectedPick() >= 0) |
| 3072 | { |
| 3073 | char *histText = GetGameHistory(Picker_GetSelectedItem(hwndList)); |
| 3074 | |
| 3075 | have_history = (histText && histText[0]) ? TRUE : FALSE; |
| 3076 | win_set_window_text_utf8(GetDlgItem(hMain, IDC_HISTORY), histText); |
| 3077 | } |
| 3078 | |
| 3079 | if (have_history && GetShowScreenShot() |
| 3080 | && ((TabView_GetCurrentTab(hTabCtrl) == TAB_HISTORY) || |
| 3081 | (TabView_GetCurrentTab(hTabCtrl) == GetHistoryTab() && GetShowTab(TAB_HISTORY) == FALSE) || |
| 3082 | (TAB_ALL == GetHistoryTab() && GetShowTab(TAB_HISTORY) == FALSE) )) |
| 3083 | { |
| 3084 | Edit_GetRect(GetDlgItem(hMain, IDC_HISTORY),&rect); |
| 3085 | nLines = Edit_GetLineCount(GetDlgItem(hMain, IDC_HISTORY) ); |
| 3086 | hDC = GetDC(GetDlgItem(hMain, IDC_HISTORY)); |
| 3087 | GetTextMetrics (hDC, &tm); |
| 3088 | nLineHeight = tm.tmHeight - tm.tmInternalLeading; |
| 3089 | if( ( (rect.bottom - rect.top) / nLineHeight) < (nLines) ) |
| 3090 | { |
| 3091 | //more than one Page, so show Scrollbar |
| 3092 | SetScrollRange(GetDlgItem(hMain, IDC_HISTORY), SB_VERT, 0, nLines, TRUE); |
| 3093 | } |
| 3094 | else |
| 3095 | { |
| 3096 | //hide Scrollbar |
| 3097 | SetScrollRange(GetDlgItem(hMain, IDC_HISTORY),SB_VERT, 0, 0, TRUE); |
| 3098 | |
| 3099 | } |
| 3100 | ShowWindow(GetDlgItem(hMain, IDC_HISTORY), SW_SHOW); |
| 3101 | } |
| 3102 | else |
| 3103 | ShowWindow(GetDlgItem(hMain, IDC_HISTORY), SW_HIDE); |
| 3104 | |
| 3105 | } |
| 3106 | |
| 3107 | |
| 3108 | static void DisableSelection() |
| 3109 | { |
| 3110 | MENUITEMINFO mmi; |
| 3111 | HMENU hMenu = GetMenu(hMain); |
| 3112 | BOOL prev_have_selection = have_selection; |
| 3113 | |
| 3114 | mmi.cbSize = sizeof(mmi); |
| 3115 | mmi.fMask = MIIM_TYPE; |
| 3116 | mmi.fType = MFT_STRING; |
| 3117 | mmi.dwTypeData = (TCHAR *) TEXT("&Play"); |
| 3118 | mmi.cch = _tcslen(mmi.dwTypeData); |
| 3119 | SetMenuItemInfo(hMenu, ID_FILE_PLAY, FALSE, &mmi); |
| 3120 | |
| 3121 | EnableMenuItem(hMenu, ID_FILE_PLAY, MF_GRAYED); |
| 3122 | EnableMenuItem(hMenu, ID_FILE_PLAY_RECORD, MF_GRAYED); |
| 3123 | EnableMenuItem(hMenu, ID_GAME_PROPERTIES, MF_GRAYED); |
| 3124 | |
| 3125 | SetStatusBarText(0, "No Selection"); |
| 3126 | SetStatusBarText(1, ""); |
| 3127 | SetStatusBarText(3, ""); |
| 3128 | |
| 3129 | have_selection = FALSE; |
| 3130 | |
| 3131 | if (prev_have_selection != have_selection) |
| 3132 | UpdateScreenShot(); |
| 3133 | } |
| 3134 | |
| 3135 | static void EnableSelection(int nGame) |
| 3136 | { |
| 3137 | TCHAR buf[200]; |
| 3138 | const char * pText; |
| 3139 | MENUITEMINFO mmi; |
| 3140 | HMENU hMenu = GetMenu(hMain); |
| 3141 | TCHAR* t_description; |
| 3142 | |
| 3143 | #ifdef MESS |
| 3144 | MyFillSoftwareList(nGame, FALSE); |
| 3145 | #endif |
| 3146 | |
| 3147 | t_description = tstring_from_utf8(ConvertAmpersandString(ModifyThe(drivers[nGame]->description))); |
| 3148 | if( !t_description ) |
| 3149 | return; |
| 3150 | |
| 3151 | _sntprintf(buf, sizeof(buf) / sizeof(buf[0]), g_szPlayGameString, t_description); |
| 3152 | mmi.cbSize = sizeof(mmi); |
| 3153 | mmi.fMask = MIIM_TYPE; |
| 3154 | mmi.fType = MFT_STRING; |
| 3155 | mmi.dwTypeData = buf; |
| 3156 | mmi.cch = _tcslen(mmi.dwTypeData); |
| 3157 | SetMenuItemInfo(hMenu, ID_FILE_PLAY, FALSE, &mmi); |
| 3158 | |
| 3159 | pText = ModifyThe(drivers[nGame]->description); |
| 3160 | SetStatusBarText(0, pText); |
| 3161 | /* Add this game's status to the status bar */ |
| 3162 | pText = GameInfoStatus(nGame, FALSE); |
| 3163 | SetStatusBarText(1, pText); |
| 3164 | SetStatusBarText(3, ""); |
| 3165 | |
| 3166 | /* If doing updating game status and the game name is NOT pacman.... */ |
| 3167 | |
| 3168 | EnableMenuItem(hMenu, ID_FILE_PLAY, MF_ENABLED); |
| 3169 | EnableMenuItem(hMenu, ID_FILE_PLAY_RECORD, MF_ENABLED); |
| 3170 | |
| 3171 | if (!oldControl) |
| 3172 | EnableMenuItem(hMenu, ID_GAME_PROPERTIES, MF_ENABLED); |
| 3173 | |
| 3174 | if (bProgressShown && bListReady == TRUE) |
| 3175 | { |
| 3176 | SetDefaultGame(ModifyThe(drivers[nGame]->name)); |
| 3177 | } |
| 3178 | have_selection = TRUE; |
| 3179 | |
| 3180 | UpdateScreenShot(); |
| 3181 | |
| 3182 | free(t_description); |
| 3183 | } |
| 3184 | |
| 3185 | static void PaintBackgroundImage(HWND hWnd, HRGN hRgn, int x, int y) |
| 3186 | { |
| 3187 | RECT rcClient; |
| 3188 | HRGN rgnBitmap; |
| 3189 | HPALETTE hPAL; |
| 3190 | HDC hDC = GetDC(hWnd); |
| 3191 | int i, j; |
| 3192 | HDC htempDC; |
| 3193 | HBITMAP oldBitmap; |
| 3194 | |
| 3195 | /* x and y are offsets within the background image that should be at 0,0 in hWnd */ |
| 3196 | |
| 3197 | /* So we don't paint over the control's border */ |
| 3198 | GetClientRect(hWnd, &rcClient); |
| 3199 | |
| 3200 | htempDC = CreateCompatibleDC(hDC); |
| 3201 | oldBitmap = SelectObject(htempDC, hBackground); |
| 3202 | |
| 3203 | if (hRgn == NULL) |
| 3204 | { |
| 3205 | /* create a region of our client area */ |
| 3206 | rgnBitmap = CreateRectRgnIndirect(&rcClient); |
| 3207 | SelectClipRgn(hDC, rgnBitmap); |
| 3208 | DeleteObject(rgnBitmap); |
| 3209 | } |
| 3210 | else |
| 3211 | { |
| 3212 | /* use the passed in region */ |
| 3213 | SelectClipRgn(hDC, hRgn); |
| 3214 | } |
| 3215 | |
| 3216 | hPAL = GetBackgroundPalette(); |
| 3217 | if (hPAL == NULL) |
| 3218 | hPAL = CreateHalftonePalette(hDC); |
| 3219 | |
| 3220 | if (GetDeviceCaps(htempDC, RASTERCAPS) & RC_PALETTE && hPAL != NULL) |
| 3221 | { |
| 3222 | SelectPalette(htempDC, hPAL, FALSE); |
| 3223 | RealizePalette(htempDC); |
| 3224 | } |
| 3225 | |
| 3226 | for (i = rcClient.left-x; i < rcClient.right; i += bmDesc.bmWidth) |
| 3227 | for (j = rcClient.top-y; j < rcClient.bottom; j += bmDesc.bmHeight) |
| 3228 | BitBlt(hDC, i, j, bmDesc.bmWidth, bmDesc.bmHeight, htempDC, 0, 0, SRCCOPY); |
| 3229 | |
| 3230 | SelectObject(htempDC, oldBitmap); |
| 3231 | DeleteDC(htempDC); |
| 3232 | |
| 3233 | if (GetBackgroundPalette() == NULL) |
| 3234 | { |
| 3235 | DeleteObject(hPAL); |
| 3236 | hPAL = NULL; |
| 3237 | } |
| 3238 | |
| 3239 | ReleaseDC(hWnd, hDC); |
| 3240 | } |
| 3241 | |
| 3242 | static LPCSTR GetCloneParentName(int nItem) |
| 3243 | { |
| 3244 | int nParentIndex = -1; |
| 3245 | |
| 3246 | if (DriverIsClone(nItem) == TRUE) |
| 3247 | { |
| 3248 | nParentIndex = GetParentIndex(drivers[nItem]); |
| 3249 | if( nParentIndex >= 0) |
| 3250 | return ModifyThe(drivers[nParentIndex]->description); |
| 3251 | } |
| 3252 | return ""; |
| 3253 | } |
| 3254 | |
| 3255 | static BOOL PickerHitTest(HWND hWnd) |
| 3256 | { |
| 3257 | RECT rect; |
| 3258 | POINTS p; |
| 3259 | DWORD res = GetMessagePos(); |
| 3260 | LVHITTESTINFO htInfo; |
| 3261 | |
| 3262 | ZeroMemory(&htInfo,sizeof(LVHITTESTINFO)); |
| 3263 | p = MAKEPOINTS(res); |
| 3264 | GetWindowRect(hWnd, &rect); |
| 3265 | htInfo.pt.x = p.x - rect.left; |
| 3266 | htInfo.pt.y = p.y - rect.top; |
| 3267 | ListView_HitTest(hWnd, &htInfo); |
| 3268 | |
| 3269 | return (! (htInfo.flags & LVHT_NOWHERE)); |
| 3270 | } |
| 3271 | |
| 3272 | static BOOL TreeViewNotify(LPNMHDR nm) |
| 3273 | { |
| 3274 | switch (nm->code) |
| 3275 | { |
| 3276 | case TVN_SELCHANGED : |
| 3277 | { |
| 3278 | HTREEITEM hti = TreeView_GetSelection(hTreeView); |
| 3279 | TVITEM tvi; |
| 3280 | |
| 3281 | tvi.mask = TVIF_PARAM | TVIF_HANDLE; |
| 3282 | tvi.hItem = hti; |
| 3283 | |
| 3284 | if (TreeView_GetItem(hTreeView, &tvi)) |
| 3285 | { |
| 3286 | SetCurrentFolder((LPTREEFOLDER)tvi.lParam); |
| 3287 | if (bListReady) |
| 3288 | { |
| 3289 | ResetListView(); |
| 3290 | UpdateScreenShot(); |
| 3291 | } |
| 3292 | } |
| 3293 | return TRUE; |
| 3294 | } |
| 3295 | case TVN_BEGINLABELEDIT : |
| 3296 | { |
| 3297 | TV_DISPINFO *ptvdi = (TV_DISPINFO *)nm; |
| 3298 | LPTREEFOLDER folder = (LPTREEFOLDER)ptvdi->item.lParam; |
| 3299 | |
| 3300 | if (folder->m_dwFlags & F_CUSTOM) |
| 3301 | { |
| 3302 | // user can edit custom folder names |
| 3303 | g_in_treeview_edit = TRUE; |
| 3304 | return FALSE; |
| 3305 | } |
| 3306 | // user can't edit built in folder names |
| 3307 | return TRUE; |
| 3308 | } |
| 3309 | case TVN_ENDLABELEDIT : |
| 3310 | { |
| 3311 | TV_DISPINFO *ptvdi = (TV_DISPINFO *)nm; |
| 3312 | LPTREEFOLDER folder = (LPTREEFOLDER)ptvdi->item.lParam; |
| 3313 | char* szText; |
| 3314 | BOOL result; |
| 3315 | |
| 3316 | g_in_treeview_edit = FALSE; |
| 3317 | |
| 3318 | if (ptvdi->item.pszText == NULL || _tcslen(ptvdi->item.pszText) == 0) |
| 3319 | return FALSE; |
| 3320 | |
| 3321 | szText = utf8_from_tstring(ptvdi->item.pszText); |
| 3322 | if( !szText ) |
| 3323 | return FALSE; |
| 3324 | |
| 3325 | result = TryRenameCustomFolder(folder,szText); |
| 3326 | |
| 3327 | free(szText); |
| 3328 | |
| 3329 | return result; |
| 3330 | } |
| 3331 | } |
| 3332 | return FALSE; |
| 3333 | } |
| 3334 | |
| 3335 | |
| 3336 | |
| 3337 | static void GamePicker_OnHeaderContextMenu(POINT pt, int nColumn) |
| 3338 | { |
| 3339 | // Right button was clicked on header |
| 3340 | HMENU hMenuLoad; |
| 3341 | HMENU hMenu; |
| 3342 | |
| 3343 | hMenuLoad = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT_HEADER)); |
| 3344 | hMenu = GetSubMenu(hMenuLoad, 0); |
| 3345 | lastColumnClick = nColumn; |
| 3346 | TrackPopupMenu(hMenu,TPM_LEFTALIGN | TPM_RIGHTBUTTON,pt.x,pt.y,0,hMain,NULL); |
| 3347 | |
| 3348 | DestroyMenu(hMenuLoad); |
| 3349 | } |
| 3350 | |
| 3351 | |
| 3352 | |
| 3353 | char* ConvertAmpersandString(const char *s) |
| 3354 | { |
| 3355 | /* takes a string and changes any ampersands to double ampersands, |
| 3356 | for setting text of window controls that don't allow us to disable |
| 3357 | the ampersand underlining. |
| 3358 | */ |
| 3359 | /* returns a static buffer--use before calling again */ |
| 3360 | |
| 3361 | static char buf[200]; |
| 3362 | char *ptr; |
| 3363 | |
| 3364 | ptr = buf; |
| 3365 | while (*s) |
| 3366 | { |
| 3367 | if (*s == '&') |
| 3368 | *ptr++ = *s; |
| 3369 | *ptr++ = *s++; |
| 3370 | } |
| 3371 | *ptr = 0; |
| 3372 | |
| 3373 | return buf; |
| 3374 | } |
| 3375 | |
| 3376 | static int GUI_seq_pressed(const input_seq *seq) |
| 3377 | { |
| 3378 | int codenum; |
| 3379 | int res = 1; |
| 3380 | int invert = 0; |
| 3381 | int count = 0; |
| 3382 | |
| 3383 | for (codenum = 0; codenum < ARRAY_LENGTH(seq->code); codenum++) |
| 3384 | { |
| 3385 | input_code code = seq->code[codenum]; |
| 3386 | |
| 3387 | switch (code) |
| 3388 | { |
| 3389 | case SEQCODE_OR : |
| 3390 | if (res && count) |
| 3391 | return 1; |
| 3392 | res = 1; |
| 3393 | count = 0; |
| 3394 | break; |
| 3395 | case SEQCODE_NOT : |
| 3396 | invert = !invert; |
| 3397 | break; |
| 3398 | default: |
| 3399 | if (res) |
| 3400 | { |
| 3401 | int pressed = keyboard_state[code]; |
| 3402 | if ((pressed != 0) == invert) |
| 3403 | res = 0; |
| 3404 | } |
| 3405 | invert = 0; |
| 3406 | ++count; |
| 3407 | } |
| 3408 | } |
| 3409 | return res && count; |
| 3410 | } |
| 3411 | |
| 3412 | static void check_for_GUI_action(void) |
| 3413 | { |
| 3414 | int i; |
| 3415 | |
| 3416 | for (i = 0; i < NUM_GUI_SEQUENCES; i++) |
| 3417 | { |
| 3418 | input_seq *is = &(GUISequenceControl[i].is); |
| 3419 | |
| 3420 | if (GUI_seq_pressed(is)) |
| 3421 | { |
| 3422 | dprintf("seq =%s pressed\n", GUISequenceControl[i].name); |
| 3423 | switch (GUISequenceControl[i].func_id) |
| 3424 | { |
| 3425 | case ID_GAME_AUDIT: |
| 3426 | case ID_GAME_PROPERTIES: |
| 3427 | case ID_CONTEXT_FILTERS: |
| 3428 | case ID_UI_START: |
| 3429 | KeyboardStateClear(); /* beacuse whe won't receive KeyUp mesage when we loose focus */ |
| 3430 | break; |
| 3431 | default: |
| 3432 | break; |
| 3433 | } |
| 3434 | SendMessage(hMain, WM_COMMAND, GUISequenceControl[i].func_id, 0); |
| 3435 | } |
| 3436 | } |
| 3437 | } |
| 3438 | |
| 3439 | static void KeyboardStateClear(void) |
| 3440 | { |
| 3441 | memset(keyboard_state, 0, sizeof(keyboard_state)); |
| 3442 | dprintf("keyboard gui state cleared.\n"); |
| 3443 | } |
| 3444 | |
| 3445 | |
| 3446 | static void KeyboardKeyDown(int syskey, int vk_code, int special) |
| 3447 | { |
| 3448 | int i, found = 0; |
| 3449 | input_code icode = 0; |
| 3450 | int special_code = (special >> 24) & 1; |
| 3451 | int scancode = (special>>16) & 0xff; |
| 3452 | |
| 3453 | if ((vk_code==VK_MENU) || (vk_code==VK_CONTROL) || (vk_code==VK_SHIFT)) |
| 3454 | { |
| 3455 | found = 1; |
| 3456 | |
| 3457 | /* a hack for right shift - it's better to use Direct X for keyboard input it seems......*/ |
| 3458 | if (vk_code==VK_SHIFT) |
| 3459 | if (scancode>0x30) /* on my keyboard left shift scancode is 0x2a, right shift is 0x36 */ |
| 3460 | special_code = 1; |
| 3461 | |
| 3462 | if (special_code) /* right hand keys */ |
| 3463 | { |
| 3464 | switch(vk_code) |
| 3465 | { |
| 3466 | case VK_MENU: |
| 3467 | icode = KEYCODE_RALT; |
| 3468 | break; |
| 3469 | case VK_CONTROL: |
| 3470 | icode = KEYCODE_RCONTROL; |
| 3471 | break; |
| 3472 | case VK_SHIFT: |
| 3473 | icode = KEYCODE_RSHIFT; |
| 3474 | break; |
| 3475 | } |
| 3476 | } |
| 3477 | else /* left hand keys */ |
| 3478 | { |
| 3479 | switch(vk_code) |
| 3480 | { |
| 3481 | case VK_MENU: |
| 3482 | icode = KEYCODE_LALT; |
| 3483 | break; |
| 3484 | case VK_CONTROL: |
| 3485 | icode = KEYCODE_LCONTROL; |
| 3486 | break; |
| 3487 | case VK_SHIFT: |
| 3488 | icode = KEYCODE_LSHIFT; |
| 3489 | break; |
| 3490 | } |
| 3491 | } |
| 3492 | } |
| 3493 | else |
| 3494 | { |
| 3495 | for (i = 0; i < ARRAY_LENGTH(win_key_trans_table); i++) |
| 3496 | { |
| 3497 | if ( vk_code == win_key_trans_table[i][VIRTUAL_KEY]) |
| 3498 | { |
| 3499 | icode = win_key_trans_table[i][MAME_KEY]; |
| 3500 | found = 1; |
| 3501 | break; |
| 3502 | } |
| 3503 | } |
| 3504 | } |
| 3505 | if (!found) |
| 3506 | { |
| 3507 | dprintf("VK_code pressed not found = %i\n",vk_code); |
| 3508 | //MessageBox(NULL,"keydown message arrived not processed","TitleBox",MB_OK); |
| 3509 | return; |
| 3510 | } |
| 3511 | dprintf("VK_code pressed found = %i, sys=%i, mame_keycode=%i special=%08x\n", vk_code, syskey, icode, special); |
| 3512 | keyboard_state[icode] = 1; |
| 3513 | check_for_GUI_action(); |
| 3514 | } |
| 3515 | |
| 3516 | static void KeyboardKeyUp(int syskey, int vk_code, int special) |
| 3517 | { |
| 3518 | int i, found = 0; |
| 3519 | input_code icode = 0; |
| 3520 | int special_code = (special >> 24) & 1; |
| 3521 | int scancode = (special>>16) & 0xff; |
| 3522 | |
| 3523 | if ((vk_code==VK_MENU) || (vk_code==VK_CONTROL) || (vk_code==VK_SHIFT)) |
| 3524 | { |
| 3525 | found = 1; |
| 3526 | |
| 3527 | /* a hack for right shift - it's better to use Direct X for keyboard input it seems......*/ |
| 3528 | if (vk_code==VK_SHIFT) |
| 3529 | if (scancode>0x30) /* on my keyboard left shift scancode is 0x2a, right shift is 0x36 */ |
| 3530 | special_code = 1; |
| 3531 | |
| 3532 | if (special_code) /* right hand keys */ |
| 3533 | { |
| 3534 | switch(vk_code) |
| 3535 | { |
| 3536 | case VK_MENU: |
| 3537 | icode = KEYCODE_RALT; |
| 3538 | break; |
| 3539 | case VK_CONTROL: |
| 3540 | icode = KEYCODE_RCONTROL; |
| 3541 | break; |
| 3542 | case VK_SHIFT: |
| 3543 | icode = KEYCODE_RSHIFT; |
| 3544 | break; |
| 3545 | } |
| 3546 | } |
| 3547 | else /* left hand keys */ |
| 3548 | { |
| 3549 | switch(vk_code) |
| 3550 | { |
| 3551 | case VK_MENU: |
| 3552 | icode = KEYCODE_LALT; |
| 3553 | break; |
| 3554 | case VK_CONTROL: |
| 3555 | icode = KEYCODE_LCONTROL; |
| 3556 | break; |
| 3557 | case VK_SHIFT: |
| 3558 | icode = KEYCODE_LSHIFT; |
| 3559 | break; |
| 3560 | } |
| 3561 | } |
| 3562 | } |
| 3563 | else |
| 3564 | { |
| 3565 | for (i = 0; i < ARRAY_LENGTH(win_key_trans_table); i++) |
| 3566 | { |
| 3567 | if (vk_code == win_key_trans_table[i][VIRTUAL_KEY]) |
| 3568 | { |
| 3569 | icode = win_key_trans_table[i][MAME_KEY]; |
| 3570 | found = 1; |
| 3571 | break; |
| 3572 | } |
| 3573 | } |
| 3574 | } |
| 3575 | if (!found) |
| 3576 | { |
| 3577 | dprintf("VK_code released not found = %i",vk_code); |
| 3578 | //MessageBox(NULL,"keyup message arrived not processed","TitleBox",MB_OK); |
| 3579 | return; |
| 3580 | } |
| 3581 | keyboard_state[icode] = 0; |
| 3582 | dprintf("VK_code released found= %i, sys=%i, mame_keycode=%i special=%08x\n", vk_code, syskey, icode, special ); |
| 3583 | check_for_GUI_action(); |
| 3584 | } |
| 3585 | |
| 3586 | static void PollGUIJoystick() |
| 3587 | { |
| 3588 | // For the exec timer, will keep track of how long the button has been pressed |
| 3589 | static int exec_counter = 0; |
| 3590 | const char* exec_command; |
| 3591 | TCHAR* t_exec_command; |
| 3592 | |
| 3593 | if (in_emulation) |
| 3594 | return; |
| 3595 | |
| 3596 | if (g_pJoyGUI == NULL) |
| 3597 | return; |
| 3598 | |
| 3599 | g_pJoyGUI->poll_joysticks(); |
| 3600 | |
| 3601 | |
| 3602 | // User pressed UP |
| 3603 | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyUp(0), GetUIJoyUp(1), GetUIJoyUp(2),GetUIJoyUp(3)))) |
| 3604 | { |
| 3605 | SendMessage(hMain, WM_COMMAND, ID_UI_UP, 0); |
| 3606 | } |
| 3607 | |
| 3608 | // User pressed DOWN |
| 3609 | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyDown(0), GetUIJoyDown(1), GetUIJoyDown(2),GetUIJoyDown(3)))) |
| 3610 | { |
| 3611 | SendMessage(hMain, WM_COMMAND, ID_UI_DOWN, 0); |
| 3612 | } |
| 3613 | |
| 3614 | // User pressed LEFT |
| 3615 | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyLeft(0), GetUIJoyLeft(1), GetUIJoyLeft(2),GetUIJoyLeft(3)))) |
| 3616 | { |
| 3617 | SendMessage(hMain, WM_COMMAND, ID_UI_LEFT, 0); |
| 3618 | } |
| 3619 | |
| 3620 | // User pressed RIGHT |
| 3621 | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyRight(0), GetUIJoyRight(1), GetUIJoyRight(2),GetUIJoyRight(3)))) |
| 3622 | { |
| 3623 | SendMessage(hMain, WM_COMMAND, ID_UI_RIGHT, 0); |
| 3624 | } |
| 3625 | |
| 3626 | // User pressed START GAME |
| 3627 | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyStart(0), GetUIJoyStart(1), GetUIJoyStart(2),GetUIJoyStart(3)))) |
| 3628 | { |
| 3629 | SendMessage(hMain, WM_COMMAND, ID_UI_START, 0); |
| 3630 | } |
| 3631 | |
| 3632 | // User pressed PAGE UP |
| 3633 | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyPageUp(0), GetUIJoyPageUp(1), GetUIJoyPageUp(2),GetUIJoyPageUp(3)))) |
| 3634 | { |
| 3635 | SendMessage(hMain, WM_COMMAND, ID_UI_PGUP, 0); |
| 3636 | } |
| 3637 | |
| 3638 | // User pressed PAGE DOWN |
| 3639 | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyPageDown(0), GetUIJoyPageDown(1), GetUIJoyPageDown(2),GetUIJoyPageDown(3)))) |
| 3640 | { |
| 3641 | SendMessage(hMain, WM_COMMAND, ID_UI_PGDOWN, 0); |
| 3642 | } |
| 3643 | |
| 3644 | // User pressed HOME |
| 3645 | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyHome(0), GetUIJoyHome(1), GetUIJoyHome(2),GetUIJoyHome(3)))) |
| 3646 | { |
| 3647 | SendMessage(hMain, WM_COMMAND, ID_UI_HOME, 0); |
| 3648 | } |
| 3649 | |
| 3650 | // User pressed END |
| 3651 | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyEnd(0), GetUIJoyEnd(1), GetUIJoyEnd(2),GetUIJoyEnd(3)))) |
| 3652 | { |
| 3653 | SendMessage(hMain, WM_COMMAND, ID_UI_END, 0); |
| 3654 | } |
| 3655 | |
| 3656 | // User pressed CHANGE SCREENSHOT |
| 3657 | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoySSChange(0), GetUIJoySSChange(1), GetUIJoySSChange(2),GetUIJoySSChange(3)))) |
| 3658 | { |
| 3659 | SendMessage(hMain, WM_COMMAND, IDC_SSFRAME, 0); |
| 3660 | } |
| 3661 | |
| 3662 | // User pressed SCROLL HISTORY UP |
| 3663 | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyHistoryUp(0), GetUIJoyHistoryUp(1), GetUIJoyHistoryUp(2),GetUIJoyHistoryUp(3)))) |
| 3664 | { |
| 3665 | SendMessage(hMain, WM_COMMAND, ID_UI_HISTORY_UP, 0); |
| 3666 | } |
| 3667 | |
| 3668 | // User pressed SCROLL HISTORY DOWN |
| 3669 | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyHistoryDown(0), GetUIJoyHistoryDown(1), GetUIJoyHistoryDown(2),GetUIJoyHistoryDown(3)))) |
| 3670 | { |
| 3671 | SendMessage(hMain, WM_COMMAND, ID_UI_HISTORY_DOWN, 0); |
| 3672 | } |
| 3673 | |
| 3674 | // User pressed EXECUTE COMMANDLINE |
| 3675 | if (g_pJoyGUI->is_joy_pressed(JOYCODE(GetUIJoyExec(0), GetUIJoyExec(1), GetUIJoyExec(2),GetUIJoyExec(3)))) |
| 3676 | { |
| 3677 | if (++exec_counter >= GetExecWait()) // Button has been pressed > exec timeout |
| 3678 | { |
| 3679 | PROCESS_INFORMATION pi; |
| 3680 | STARTUPINFO si; |
| 3681 | |
| 3682 | // Reset counter |
| 3683 | exec_counter = 0; |
| 3684 | |
| 3685 | ZeroMemory( &si, sizeof(si) ); |
| 3686 | ZeroMemory( &pi, sizeof(pi) ); |
| 3687 | si.dwFlags = STARTF_FORCEONFEEDBACK; |
| 3688 | si.cb = sizeof(si); |
| 3689 | |
| 3690 | exec_command = GetExecCommand(); |
| 3691 | t_exec_command = tstring_from_utf8(exec_command); |
| 3692 | if( !t_exec_command ) |
| 3693 | return; |
| 3694 | CreateProcess(NULL, t_exec_command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); |
| 3695 | |
| 3696 | free(t_exec_command); |
| 3697 | |
| 3698 | // We will not wait for the process to finish cause it might be a background task |
| 3699 | // The process won't get closed when MAME32 closes either. |
| 3700 | |
| 3701 | // But close the handles cause we won't need them anymore. Will not close process. |
| 3702 | CloseHandle(pi.hProcess); |
| 3703 | CloseHandle(pi.hThread); |
| 3704 | } |
| 3705 | } |
| 3706 | else |
| 3707 | { |
| 3708 | // Button has been released within the timeout period, reset the counter |
| 3709 | exec_counter = 0; |
| 3710 | } |
| 3711 | } |
| 3712 | |
| 3713 | static void PressKey(HWND hwnd, UINT vk) |
| 3714 | { |
| 3715 | SendMessage(hwnd, WM_KEYDOWN, vk, 0); |
| 3716 | SendMessage(hwnd, WM_KEYUP, vk, 0xc0000000); |
| 3717 | } |
| 3718 | |
| 3719 | static void SetView(int menu_id) |
| 3720 | { |
| 3721 | BOOL force_reset = FALSE; |
| 3722 | int i; |
| 3723 | |
| 3724 | // first uncheck previous menu item, check new one |
| 3725 | CheckMenuRadioItem(GetMenu(hMain), ID_VIEW_LARGE_ICON, ID_VIEW_GROUPED, menu_id, MF_CHECKED); |
| 3726 | ToolBar_CheckButton(hToolBar, menu_id, MF_CHECKED); |
| 3727 | |
| 3728 | if (Picker_GetViewID(hwndList) == VIEW_GROUPED || menu_id == ID_VIEW_GROUPED) |
| 3729 | { |
| 3730 | // this changes the sort order, so redo everything |
| 3731 | force_reset = TRUE; |
| 3732 | } |
| 3733 | |
| 3734 | for (i = 0; i < sizeof(s_nPickers) / sizeof(s_nPickers[0]); i++) |
| 3735 | Picker_SetViewID(GetDlgItem(hMain, s_nPickers[i]), menu_id - ID_VIEW_LARGE_ICON); |
| 3736 | |
| 3737 | if (force_reset) |
| 3738 | { |
| 3739 | for (i = 0; i < sizeof(s_nPickers) / sizeof(s_nPickers[0]); i++) |
| 3740 | Picker_Sort(GetDlgItem(hMain, s_nPickers[i])); |
| 3741 | } |
| 3742 | } |
| 3743 | |
| 3744 | static void ResetListView() |
| 3745 | { |
| 3746 | int i; |
| 3747 | int current_game; |
| 3748 | LV_ITEM lvi; |
| 3749 | BOOL no_selection = FALSE; |
| 3750 | LPTREEFOLDER lpFolder = GetCurrentFolder(); |
| 3751 | |
| 3752 | if (!lpFolder) |
| 3753 | { |
| 3754 | return; |
| 3755 | } |
| 3756 | |
| 3757 | /* If the last folder was empty, no_selection is TRUE */ |
| 3758 | if (have_selection == FALSE) |
| 3759 | { |
| 3760 | no_selection = TRUE; |
| 3761 | } |
| 3762 | |
| 3763 | current_game = Picker_GetSelectedItem(hwndList); |
| 3764 | |
| 3765 | SetWindowRedraw(hwndList,FALSE); |
| 3766 | |
| 3767 | ListView_DeleteAllItems(hwndList); |
| 3768 | |
| 3769 | // hint to have it allocate it all at once |
| 3770 | ListView_SetItemCount(hwndList,driver_list_get_count(drivers)); |
| 3771 | |
| 3772 | lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; |
| 3773 | lvi.stateMask = 0; |
| 3774 | |
| 3775 | i = -1; |
| 3776 | |
| 3777 | do |
| 3778 | { |
| 3779 | /* Add the games that are in this folder */ |
| 3780 | if ((i = FindGame(lpFolder, i + 1)) != -1) |
| 3781 | { |
| 3782 | if (GameFiltered(i, lpFolder->m_dwFlags)) |
| 3783 | continue; |
| 3784 | |
| 3785 | lvi.iItem = i; |
| 3786 | lvi.iSubItem = 0; |
| 3787 | lvi.lParam = i; |
| 3788 | lvi.pszText = LPSTR_TEXTCALLBACK; |
| 3789 | lvi.iImage = I_IMAGECALLBACK; |
| 3790 | ListView_InsertItem(hwndList, &lvi); |
| 3791 | } |
| 3792 | } while (i != -1); |
| 3793 | |
| 3794 | Picker_Sort(hwndList); |
| 3795 | |
| 3796 | if (bListReady) |
| 3797 | { |
| 3798 | /* If last folder was empty, select the first item in this folder */ |
| 3799 | if (no_selection) |
| 3800 | Picker_SetSelectedPick(hwndList, 0); |
| 3801 | else |
| 3802 | Picker_SetSelectedItem(hwndList, current_game); |
| 3803 | } |
| 3804 | |
| 3805 | /*RS Instead of the Arrange Call that was here previously on all Views |
| 3806 | We now need to set the ViewMode for SmallIcon again, |
| 3807 | for an explanation why, see SetView*/ |
| 3808 | if (GetViewMode() == VIEW_SMALL_ICONS) |
| 3809 | SetView(ID_VIEW_SMALL_ICON); |
| 3810 | |
| 3811 | SetWindowRedraw(hwndList, TRUE); |
| 3812 | |
| 3813 | UpdateStatusBar(); |
| 3814 | |
| 3815 | } |
| 3816 | |
| 3817 | static void UpdateGameList(BOOL bUpdateRomAudit, BOOL bUpdateSampleAudit) |
| 3818 | { |
| 3819 | int i; |
| 3820 | |
| 3821 | for (i = 0; i < driver_list_get_count(drivers); i++) |
| 3822 | { |
| 3823 | if (bUpdateRomAudit && DriverUsesRoms(i)) |
| 3824 | SetRomAuditResults(i, UNKNOWN); |
| 3825 | if (bUpdateSampleAudit && DriverUsesSamples(i)) |
| 3826 | SetSampleAuditResults(i, UNKNOWN); |
| 3827 | } |
| 3828 | |
| 3829 | idle_work = TRUE; |
| 3830 | bDoGameCheck = TRUE; |
| 3831 | game_index = 0; |
| 3832 | |
| 3833 | ReloadIcons(); |
| 3834 | |
| 3835 | // Let REFRESH also load new background if found |
| 3836 | LoadBackgroundBitmap(); |
| 3837 | InvalidateRect(hMain,NULL,TRUE); |
| 3838 | Picker_ResetIdle(hwndList); |
| 3839 | } |
| 3840 | |
| 3841 | UINT_PTR CALLBACK CFHookProc( |
| 3842 | HWND hdlg, // handle to dialog box |
| 3843 | UINT uiMsg, // message identifier |
| 3844 | WPARAM wParam, // message parameter |
| 3845 | LPARAM lParam // message parameter |
| 3846 | ) |
| 3847 | { |
| 3848 | int iIndex, i; |
| 3849 | COLORREF cCombo, cList; |
| 3850 | switch (uiMsg) |
| 3851 | { |
| 3852 | case WM_INITDIALOG: |
| 3853 | SendDlgItemMessage(hdlg, cmb4, CB_ADDSTRING, 0, (LPARAM)TEXT("Custom")); |
| 3854 | iIndex = SendDlgItemMessage(hdlg, cmb4, CB_GETCOUNT, 0, 0); |
| 3855 | cList = GetListFontColor(); |
| 3856 | SendDlgItemMessage(hdlg, cmb4, CB_SETITEMDATA,(WPARAM)iIndex-1,(LPARAM)cList ); |
| 3857 | for( i = 0; i< iIndex; i++) |
| 3858 | { |
| 3859 | cCombo = SendDlgItemMessage(hdlg, cmb4, CB_GETITEMDATA,(WPARAM)i,0 ); |
| 3860 | if( cList == cCombo) |
| 3861 | { |
| 3862 | SendDlgItemMessage(hdlg, cmb4, CB_SETCURSEL,(WPARAM)i,0 ); |
| 3863 | break; |
| 3864 | } |
| 3865 | } |
| 3866 | break; |
| 3867 | case WM_COMMAND: |
| 3868 | if( LOWORD(wParam) == cmb4) |
| 3869 | { |
| 3870 | switch (HIWORD(wParam)) |
| 3871 | { |
| 3872 | case CBN_SELCHANGE: // The color ComboBox changed selection |
| 3873 | iIndex = (int)SendDlgItemMessage(hdlg, cmb4, |
| 3874 | CB_GETCURSEL, 0, 0L); |
| 3875 | if( iIndex == SendDlgItemMessage(hdlg, cmb4, CB_GETCOUNT, 0, 0)-1) |
| 3876 | { |
| 3877 | //Custom color selected |
| 3878 | cList = GetListFontColor(); |
| 3879 | PickColor(&cList); |
| 3880 | SendDlgItemMessage(hdlg, cmb4, CB_DELETESTRING, iIndex, 0); |
| 3881 | SendDlgItemMessage(hdlg, cmb4, CB_ADDSTRING, 0, (LPARAM)TEXT("Custom")); |
| 3882 | SendDlgItemMessage(hdlg, cmb4, CB_SETITEMDATA,(WPARAM)iIndex,(LPARAM)cList); |
| 3883 | SendDlgItemMessage(hdlg, cmb4, CB_SETCURSEL,(WPARAM)iIndex,0 ); |
| 3884 | return TRUE; |
| 3885 | } |
| 3886 | } |
| 3887 | } |
| 3888 | break; |
| 3889 | } |
| 3890 | return FALSE; |
| 3891 | } |
| 3892 | |
| 3893 | static void PickFont(void) |
| 3894 | { |
| 3895 | LOGFONT font; |
| 3896 | CHOOSEFONT cf; |
| 3897 | TCHAR szClass[128]; |
| 3898 | HWND hWnd; |
| 3899 | |
| 3900 | GetListFont(&font); |
| 3901 | font.lfQuality = DEFAULT_QUALITY; |
| 3902 | |
| 3903 | cf.lStructSize = sizeof(CHOOSEFONT); |
| 3904 | cf.hwndOwner = hMain; |
| 3905 | cf.lpLogFont = &font; |
| 3906 | cf.lpfnHook = &CFHookProc; |
| 3907 | cf.rgbColors = GetListFontColor(); |
| 3908 | cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT | CF_EFFECTS | CF_ENABLEHOOK; |
| 3909 | if (!ChooseFont(&cf)) |
| 3910 | return; |
| 3911 | |
| 3912 | SetListFont(&font); |
| 3913 | if (hFont != NULL) |
| 3914 | DeleteObject(hFont); |
| 3915 | hFont = CreateFontIndirect(&font); |
| 3916 | if (hFont != NULL) |
| 3917 | { |
| 3918 | COLORREF textColor = cf.rgbColors; |
| 3919 | |
| 3920 | if (textColor == RGB(255,255,255)) |
| 3921 | { |
| 3922 | textColor = RGB(240, 240, 240); |
| 3923 | } |
| 3924 | |
| 3925 | SetAllWindowsFont(hMain, &main_resize, hFont, TRUE); |
| 3926 | |
| 3927 | hWnd = GetWindow(hMain, GW_CHILD); |
| 3928 | while(hWnd) |
| 3929 | { |
| 3930 | if (GetClassName(hWnd, szClass, sizeof(szClass) / sizeof(szClass[0]))) |
| 3931 | { |
| 3932 | if (!_tcscmp(szClass, TEXT("SysListView32"))) |
| 3933 | { |
| 3934 | ListView_SetTextColor(hWnd, textColor); |
| 3935 | } |
| 3936 | else if (!_tcscmp(szClass, TEXT("SysTreeView32"))) |
| 3937 | { |
| 3938 | TreeView_SetTextColor(hTreeView, textColor); |
| 3939 | } |
| 3940 | } |
| 3941 | hWnd = GetWindow(hWnd, GW_HWNDNEXT); |
| 3942 | } |
| 3943 | SetListFontColor(cf.rgbColors); |
| 3944 | ResetListView(); |
| 3945 | } |
| 3946 | } |
| 3947 | |
| 3948 | static void PickColor(COLORREF *cDefault) |
| 3949 | { |
| 3950 | CHOOSECOLOR cc; |
| 3951 | COLORREF choice_colors[16]; |
| 3952 | int i; |
| 3953 | |
| 3954 | for (i=0;i<16;i++) |
| 3955 | choice_colors[i] = GetCustomColor(i); |
| 3956 | |
| 3957 | cc.lStructSize = sizeof(CHOOSECOLOR); |
| 3958 | cc.hwndOwner = hMain; |
| 3959 | cc.rgbResult = *cDefault; |
| 3960 | cc.lpCustColors = choice_colors; |
| 3961 | cc.Flags = CC_ANYCOLOR | CC_RGBINIT | CC_SOLIDCOLOR; |
| 3962 | if (!ChooseColor(&cc)) |
| 3963 | return; |
| 3964 | for (i=0;i<16;i++) |
| 3965 | SetCustomColor(i,choice_colors[i]); |
| 3966 | *cDefault = cc.rgbResult; |
| 3967 | } |
| 3968 | |
| 3969 | static void PickCloneColor(void) |
| 3970 | { |
| 3971 | COLORREF cClonecolor; |
| 3972 | cClonecolor = GetListCloneColor(); |
| 3973 | PickColor( &cClonecolor); |
| 3974 | SetListCloneColor(cClonecolor); |
| 3975 | InvalidateRect(hwndList,NULL,FALSE); |
| 3976 | } |
| 3977 | |
| 3978 | static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify) |
| 3979 | { |
| 3980 | int i; |
| 3981 | LPTREEFOLDER folder; |
| 3982 | char* t_szFile; |
| 3983 | |
| 3984 | switch (id) |
| 3985 | { |
| 3986 | case ID_FILE_PLAY: |
| 3987 | MamePlayGame(); |
| 3988 | return TRUE; |
| 3989 | |
| 3990 | case ID_FILE_PLAY_RECORD: |
| 3991 | MamePlayRecordGame(); |
| 3992 | return TRUE; |
| 3993 | |
| 3994 | case ID_FILE_PLAY_BACK: |
| 3995 | MamePlayBackGame(); |
| 3996 | return TRUE; |
| 3997 | |
| 3998 | case ID_FILE_PLAY_RECORD_WAVE: |
| 3999 | MamePlayRecordWave(); |
| 4000 | return TRUE; |
| 4001 | |
| 4002 | case ID_FILE_PLAY_RECORD_MNG: |
| 4003 | MamePlayRecordMNG(); |
| 4004 | return TRUE; |
| 4005 | |
| 4006 | case ID_FILE_LOADSTATE : |
| 4007 | MameLoadState(); |
| 4008 | return TRUE; |
| 4009 | |
| 4010 | case ID_FILE_AUDIT: |
| 4011 | AuditDialog(hMain); |
| 4012 | ResetWhichGamesInFolders(); |
| 4013 | ResetListView(); |
| 4014 | SetFocus(hwndList); |
| 4015 | return TRUE; |
| 4016 | |
| 4017 | case ID_FILE_EXIT: |
| 4018 | PostMessage(hMain, WM_CLOSE, 0, 0); |
| 4019 | return TRUE; |
| 4020 | |
| 4021 | case ID_VIEW_LARGE_ICON: |
| 4022 | SetView(ID_VIEW_LARGE_ICON); |
| 4023 | return TRUE; |
| 4024 | |
| 4025 | case ID_VIEW_SMALL_ICON: |
| 4026 | SetView(ID_VIEW_SMALL_ICON); |
| 4027 | ResetListView(); |
| 4028 | return TRUE; |
| 4029 | |
| 4030 | case ID_VIEW_LIST_MENU: |
| 4031 | SetView(ID_VIEW_LIST_MENU); |
| 4032 | return TRUE; |
| 4033 | |
| 4034 | case ID_VIEW_DETAIL: |
| 4035 | SetView(ID_VIEW_DETAIL); |
| 4036 | return TRUE; |
| 4037 | |
| 4038 | case ID_VIEW_GROUPED: |
| 4039 | SetView(ID_VIEW_GROUPED); |
| 4040 | return TRUE; |
| 4041 | |
| 4042 | /* Arrange Icons submenu */ |
| 4043 | case ID_VIEW_BYGAME: |
| 4044 | SetSortReverse(FALSE); |
| 4045 | SetSortColumn(COLUMN_GAMES); |
| 4046 | Picker_Sort(hwndList); |
| 4047 | break; |
| 4048 | |
| 4049 | case ID_VIEW_BYDIRECTORY: |
| 4050 | SetSortReverse(FALSE); |
| 4051 | SetSortColumn(COLUMN_DIRECTORY); |
| 4052 | Picker_Sort(hwndList); |
| 4053 | break; |
| 4054 | |
| 4055 | case ID_VIEW_BYMANUFACTURER: |
| 4056 | SetSortReverse(FALSE); |
| 4057 | SetSortColumn(COLUMN_MANUFACTURER); |
| 4058 | Picker_Sort(hwndList); |
| 4059 | break; |
| 4060 | |
| 4061 | case ID_VIEW_BYTIMESPLAYED: |
| 4062 | SetSortReverse(FALSE); |
| 4063 | SetSortColumn(COLUMN_PLAYED); |
| 4064 | Picker_Sort(hwndList); |
| 4065 | break; |
| 4066 | |
| 4067 | case ID_VIEW_BYTYPE: |
| 4068 | SetSortReverse(FALSE); |
| 4069 | SetSortColumn(COLUMN_TYPE); |
| 4070 | Picker_Sort(hwndList); |
| 4071 | break; |
| 4072 | |
| 4073 | case ID_VIEW_BYYEAR: |
| 4074 | SetSortReverse(FALSE); |
| 4075 | SetSortColumn(COLUMN_YEAR); |
| 4076 | Picker_Sort(hwndList); |
| 4077 | break; |
| 4078 | |
| 4079 | case ID_VIEW_FOLDERS: |
| 4080 | bShowTree = !bShowTree; |
| 4081 | SetShowFolderList(bShowTree); |
| 4082 | CheckMenuItem(GetMenu(hMain), ID_VIEW_FOLDERS, (bShowTree) ? MF_CHECKED : MF_UNCHECKED); |
| 4083 | ToolBar_CheckButton(hToolBar, ID_VIEW_FOLDERS, (bShowTree) ? MF_CHECKED : MF_UNCHECKED); |
| 4084 | UpdateScreenShot(); |
| 4085 | break; |
| 4086 | |
| 4087 | case ID_VIEW_TOOLBARS: |
| 4088 | bShowToolBar = !bShowToolBar; |
| 4089 | SetShowToolBar(bShowToolBar); |
| 4090 | CheckMenuItem(GetMenu(hMain), ID_VIEW_TOOLBARS, (bShowToolBar) ? MF_CHECKED : MF_UNCHECKED); |
| 4091 | ToolBar_CheckButton(hToolBar, ID_VIEW_TOOLBARS, (bShowToolBar) ? MF_CHECKED : MF_UNCHECKED); |
| 4092 | ShowWindow(hToolBar, (bShowToolBar) ? SW_SHOW : SW_HIDE); |
| 4093 | ResizePickerControls(hMain); |
| 4094 | UpdateScreenShot(); |
| 4095 | break; |
| 4096 | |
| 4097 | case ID_VIEW_STATUS: |
| 4098 | bShowStatusBar = !bShowStatusBar; |
| 4099 | SetShowStatusBar(bShowStatusBar); |
| 4100 | CheckMenuItem(GetMenu(hMain), ID_VIEW_STATUS, (bShowStatusBar) ? MF_CHECKED : MF_UNCHECKED); |
| 4101 | ToolBar_CheckButton(hToolBar, ID_VIEW_STATUS, (bShowStatusBar) ? MF_CHECKED : MF_UNCHECKED); |
| 4102 | ShowWindow(hStatusBar, (bShowStatusBar) ? SW_SHOW : SW_HIDE); |
| 4103 | ResizePickerControls(hMain); |
| 4104 | UpdateScreenShot(); |
| 4105 | break; |
| 4106 | |
| 4107 | case ID_VIEW_PAGETAB: |
| 4108 | bShowTabCtrl = !bShowTabCtrl; |
| 4109 | SetShowTabCtrl(bShowTabCtrl); |
| 4110 | ShowWindow(hTabCtrl, (bShowTabCtrl) ? SW_SHOW : SW_HIDE); |
| 4111 | ResizePickerControls(hMain); |
| 4112 | UpdateScreenShot(); |
| 4113 | InvalidateRect(hMain,NULL,TRUE); |
| 4114 | break; |
| 4115 | |
| 4116 | /* |
| 4117 | Switches to fullscreen mode. No check mark handeling |
| 4118 | for this item cause in fullscreen mode the menu won't |
| 4119 | be visible anyways. |
| 4120 | */ |
| 4121 | case ID_VIEW_FULLSCREEN: |
| 4122 | SwitchFullScreenMode(); |
| 4123 | break; |
| 4124 | |
| 4125 | case ID_TOOLBAR_EDIT: |
| 4126 | { |
| 4127 | char buf[256]; |
| 4128 | |
| 4129 | Edit_GetText(hwndCtl, buf, sizeof(buf)); |
| 4130 | switch (codeNotify) |
| 4131 | { |
| 4132 | case EN_CHANGE: |
| 4133 | //put search routine here first, add a 200ms timer later. |
| 4134 | if ((!_stricmp(buf, SEARCH_PROMPT) && !_stricmp(g_SearchText, "")) || |
| 4135 | (!_stricmp(g_SearchText, SEARCH_PROMPT) && !_stricmp(buf, ""))) |
| 4136 | { |
| 4137 | strcpy(g_SearchText, buf); |
| 4138 | } |
| 4139 | else |
| 4140 | { |
| 4141 | strcpy(g_SearchText, buf); |
| 4142 | ResetListView(); |
| 4143 | } |
| 4144 | break; |
| 4145 | case EN_SETFOCUS: |
| 4146 | if (!_stricmp(buf, SEARCH_PROMPT)) |
| 4147 | SetWindowText(hwndCtl, ""); |
| 4148 | break; |
| 4149 | case EN_KILLFOCUS: |
| 4150 | if (strlen(buf) == 0) |
| 4151 | SetWindowText(hwndCtl, SEARCH_PROMPT); |
| 4152 | break; |
| 4153 | } |
| 4154 | } |
| 4155 | break; |
| 4156 | |
| 4157 | case ID_GAME_AUDIT: |
| 4158 | InitGameAudit(0); |
| 4159 | if (!oldControl) |
| 4160 | { |
| 4161 | InitPropertyPageToPage(hInst, hwnd, GetSelectedPickItemIcon(), OPTIONS_GAME, -1, Picker_GetSelectedItem(hwndList), AUDIT_PAGE); |
| 4162 | } |
| 4163 | /* Just in case the toggle MMX on/off */ |
| 4164 | UpdateStatusBar(); |
| 4165 | break; |
| 4166 | |
| 4167 | /* ListView Context Menu */ |
| 4168 | case ID_CONTEXT_ADD_CUSTOM: |
| 4169 | { |
| 4170 | int nResult; |
| 4171 | |
| 4172 | nResult = DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_CUSTOM_FILE), |
| 4173 | hMain,AddCustomFileDialogProc,Picker_GetSelectedItem(hwndList)); |
| 4174 | SetFocus(hwndList); |
| 4175 | break; |
| 4176 | } |
| 4177 | |
| 4178 | case ID_CONTEXT_REMOVE_CUSTOM: |
| 4179 | { |
| 4180 | RemoveCurrentGameCustomFolder(); |
| 4181 | break; |
| 4182 | } |
| 4183 | |
| 4184 | /* Tree Context Menu */ |
| 4185 | case ID_CONTEXT_FILTERS: |
| 4186 | if (DialogBox(GetModuleHandle(NULL), |
| 4187 | MAKEINTRESOURCE(IDD_FILTERS), hMain, FilterDialogProc) == TRUE) |
| 4188 | ResetListView(); |
| 4189 | SetFocus(hwndList); |
| 4190 | return TRUE; |
| 4191 | |
| 4192 | // ScreenShot Context Menu |
| 4193 | // select current tab |
| 4194 | case ID_VIEW_TAB_SCREENSHOT : |
| 4195 | case ID_VIEW_TAB_FLYER : |
| 4196 | case ID_VIEW_TAB_CABINET : |
| 4197 | case ID_VIEW_TAB_MARQUEE : |
| 4198 | case ID_VIEW_TAB_TITLE : |
| 4199 | case ID_VIEW_TAB_CONTROL_PANEL : |
| 4200 | case ID_VIEW_TAB_PCB : |
| 4201 | case ID_VIEW_TAB_HISTORY: |
| 4202 | if (id == ID_VIEW_TAB_HISTORY && GetShowTab(TAB_HISTORY) == FALSE) |
| 4203 | break; |
| 4204 | |
| 4205 | TabView_SetCurrentTab(hTabCtrl, id - ID_VIEW_TAB_SCREENSHOT); |
| 4206 | UpdateScreenShot(); |
| 4207 | TabView_UpdateSelection(hTabCtrl); |
| 4208 | break; |
| 4209 | |
| 4210 | // toggle tab's existence |
| 4211 | case ID_TOGGLE_TAB_SCREENSHOT : |
| 4212 | case ID_TOGGLE_TAB_FLYER : |
| 4213 | case ID_TOGGLE_TAB_CABINET : |
| 4214 | case ID_TOGGLE_TAB_MARQUEE : |
| 4215 | case ID_TOGGLE_TAB_TITLE : |
| 4216 | case ID_TOGGLE_TAB_CONTROL_PANEL : |
| 4217 | case ID_TOGGLE_TAB_PCB : |
| 4218 | case ID_TOGGLE_TAB_HISTORY : |
| 4219 | { |
| 4220 | int toggle_flag = id - ID_TOGGLE_TAB_SCREENSHOT; |
| 4221 | |
| 4222 | if (AllowedToSetShowTab(toggle_flag,!GetShowTab(toggle_flag)) == FALSE) |
| 4223 | { |
| 4224 | // attempt to hide the last tab |
| 4225 | // should show error dialog? hide picture area? or ignore? |
| 4226 | break; |
| 4227 | } |
| 4228 | |
| 4229 | SetShowTab(toggle_flag,!GetShowTab(toggle_flag)); |
| 4230 | |
| 4231 | TabView_Reset(hTabCtrl); |
| 4232 | |
| 4233 | if (TabView_GetCurrentTab(hTabCtrl) == toggle_flag && GetShowTab(toggle_flag) == FALSE) |
| 4234 | { |
| 4235 | // we're deleting the tab we're on, so go to the next one |
| 4236 | TabView_CalculateNextTab(hTabCtrl); |
| 4237 | } |
| 4238 | |
| 4239 | |
| 4240 | // Resize the controls in case we toggled to another history |
| 4241 | // mode (and the history control needs resizing). |
| 4242 | |
| 4243 | ResizePickerControls(hMain); |
| 4244 | UpdateScreenShot(); |
| 4245 | |
| 4246 | TabView_UpdateSelection(hTabCtrl); |
| 4247 | |
| 4248 | break; |
| 4249 | } |
| 4250 | |
| 4251 | /* Header Context Menu */ |
| 4252 | case ID_SORT_ASCENDING: |
| 4253 | SetSortReverse(FALSE); |
| 4254 | SetSortColumn(Picker_GetRealColumnFromViewColumn(hwndList, lastColumnClick)); |
| 4255 | Picker_Sort(hwndList); |
| 4256 | break; |
| 4257 | |
| 4258 | case ID_SORT_DESCENDING: |
| 4259 | SetSortReverse(TRUE); |
| 4260 | SetSortColumn(Picker_GetRealColumnFromViewColumn(hwndList, lastColumnClick)); |
| 4261 | Picker_Sort(hwndList); |
| 4262 | break; |
| 4263 | |
| 4264 | case ID_CUSTOMIZE_FIELDS: |
| 4265 | if (DialogBox(GetModuleHandle(NULL), |
| 4266 | MAKEINTRESOURCE(IDD_COLUMNS), hMain, ColumnDialogProc) == TRUE) |
| 4267 | ResetColumnDisplay(FALSE); |
| 4268 | SetFocus(hwndList); |
| 4269 | return TRUE; |
| 4270 | |
| 4271 | /* View Menu */ |
| 4272 | case ID_VIEW_LINEUPICONS: |
| 4273 | if( codeNotify == FALSE) |
| 4274 | ResetListView(); |
| 4275 | else |
| 4276 | { |
| 4277 | /*it was sent after a refresh (F5) was done, we only reset the View if "available" is the selected folder |
| 4278 | as it doesn't affect the others*/ |
| 4279 | folder = GetSelectedFolder(); |
| 4280 | if( folder ) |
| 4281 | { |
| 4282 | if (folder->m_nFolderId == FOLDER_AVAILABLE ) |
| 4283 | ResetListView(); |
| 4284 | |
| 4285 | } |
| 4286 | } |
| 4287 | break; |
| 4288 | |
| 4289 | case ID_GAME_PROPERTIES: |
| 4290 | if (!oldControl) |
| 4291 | { |
| 4292 | folder = GetFolderByName(FOLDER_SOURCE, GetDriverFilename(Picker_GetSelectedItem(hwndList)) ); |
| 4293 | InitPropertyPage(hInst, hwnd, GetSelectedPickItemIcon(), OPTIONS_GAME, folder->m_nFolderId, Picker_GetSelectedItem(hwndList)); |
| 4294 | #ifdef MESS |
| 4295 | { |
| 4296 | extern BOOL g_bModifiedSoftwarePaths; |
| 4297 | if (g_bModifiedSoftwarePaths) { |
| 4298 | g_bModifiedSoftwarePaths = FALSE; |
| 4299 | MessUpdateSoftwareList(); |
| 4300 | } |
| 4301 | } |
| 4302 | #endif |
| 4303 | } |
| 4304 | /* Just in case the toggle MMX on/off */ |
| 4305 | UpdateStatusBar(); |
| 4306 | break; |
| 4307 | |
| 4308 | case ID_FOLDER_PROPERTIES: |
| 4309 | if (!oldControl) |
| 4310 | { |
| 4311 | folder = GetSelectedFolder(); |
| 4312 | InitPropertyPage(hInst, hwnd, GetSelectedFolderIcon(), (folder->m_nFolderId == FOLDER_VECTOR) ? OPTIONS_VECTOR : OPTIONS_SOURCE, folder->m_nFolderId, Picker_GetSelectedItem(hwndList)); |
| 4313 | //SaveFolderOptions(folder->m_nFolderId, Picker_GetSelectedItem(hwndList) ); |
| 4314 | } |
| 4315 | /* Just in case the toggle MMX on/off */ |
| 4316 | UpdateStatusBar(); |
| 4317 | break; |
| 4318 | |
| 4319 | case ID_FOLDER_SOURCEPROPERTIES: |
| 4320 | if (!oldControl) |
| 4321 | { |
| 4322 | folder = GetFolderByName(FOLDER_SOURCE, GetDriverFilename(Picker_GetSelectedItem(hwndList)) ); |
| 4323 | InitPropertyPage(hInst, hwnd, GetSelectedFolderIcon(), (folder->m_nFolderId == FOLDER_VECTOR) ? OPTIONS_VECTOR : OPTIONS_SOURCE , folder->m_nFolderId, Picker_GetSelectedItem(hwndList)); |
| 4324 | //SaveFolderOptions(folder->m_nFolderId, Picker_GetSelectedItem(hwndList) ); |
| 4325 | } |
| 4326 | /* Just in case the toggle MMX on/off */ |
| 4327 | UpdateStatusBar(); |
| 4328 | break; |
| 4329 | |
| 4330 | case ID_FOLDER_VECTORPROPERTIES: |
| 4331 | if (!oldControl) |
| 4332 | { |
| 4333 | folder = GetFolderByID( FOLDER_VECTOR ); |
| 4334 | InitPropertyPage(hInst, hwnd, GetSelectedFolderIcon(), OPTIONS_VECTOR, folder->m_nFolderId, Picker_GetSelectedItem(hwndList)); |
| 4335 | //SaveFolderOptions(folder->m_nFolderId, Picker_GetSelectedItem(hwndList) ); |
| 4336 | } |
| 4337 | /* Just in case the toggle MMX on/off */ |
| 4338 | UpdateStatusBar(); |
| 4339 | break; |
| 4340 | |
| 4341 | case ID_FOLDER_AUDIT: |
| 4342 | FolderCheck(); |
| 4343 | /* Just in case the toggle MMX on/off */ |
| 4344 | UpdateStatusBar(); |
| 4345 | break; |
| 4346 | |
| 4347 | case ID_VIEW_PICTURE_AREA : |
| 4348 | ToggleScreenShot(); |
| 4349 | break; |
| 4350 | |
| 4351 | case ID_UPDATE_GAMELIST: |
| 4352 | UpdateGameList(TRUE, TRUE); |
| 4353 | break; |
| 4354 | |
| 4355 | case ID_OPTIONS_FONT: |
| 4356 | PickFont(); |
| 4357 | return TRUE; |
| 4358 | |
| 4359 | case ID_OPTIONS_CLONE_COLOR: |
| 4360 | PickCloneColor(); |
| 4361 | return TRUE; |
| 4362 | |
| 4363 | case ID_OPTIONS_DEFAULTS: |
| 4364 | /* Check the return value to see if changes were applied */ |
| 4365 | if (!oldControl) |
| 4366 | { |
| 4367 | InitDefaultPropertyPage(hInst, hwnd); |
| 4368 | SaveDefaultOptions(); |
| 4369 | } |
| 4370 | SetFocus(hwndList); |
| 4371 | return TRUE; |
| 4372 | |
| 4373 | case ID_OPTIONS_DIR: |
| 4374 | { |
| 4375 | int nResult; |
| 4376 | BOOL bUpdateRoms; |
| 4377 | BOOL bUpdateSamples; |
| 4378 | #ifdef MESS |
| 4379 | BOOL bUpdateSoftware; |
| 4380 | #endif |
| 4381 | |
| 4382 | nResult = DialogBox(GetModuleHandle(NULL), |
| 4383 | MAKEINTRESOURCE(IDD_DIRECTORIES), |
| 4384 | hMain, |
| 4385 | DirectoriesDialogProc); |
| 4386 | |
| 4387 | SaveDefaultOptions(); |
| 4388 | |
| 4389 | bUpdateRoms = ((nResult & DIRDLG_ROMS) == DIRDLG_ROMS) ? TRUE : FALSE; |
| 4390 | bUpdateSamples = ((nResult & DIRDLG_SAMPLES) == DIRDLG_SAMPLES) ? TRUE : FALSE; |
| 4391 | #ifdef MESS |
| 4392 | bUpdateSoftware = ((nResult & DIRDLG_SOFTWARE) == DIRDLG_SOFTWARE) ? TRUE : FALSE; |
| 4393 | |
| 4394 | if (bUpdateSoftware) |
| 4395 | MessUpdateSoftwareList(); |
| 4396 | #endif /* MESS */ |
| 4397 | |
| 4398 | if (s_pWatcher) |
| 4399 | { |
| 4400 | if (bUpdateRoms) |
| 4401 | DirWatcher_Watch(s_pWatcher, 0, GetRomDirs(), TRUE); |
| 4402 | if (bUpdateSamples) |
| 4403 | DirWatcher_Watch(s_pWatcher, 1, GetSampleDirs(), TRUE); |
| 4404 | } |
| 4405 | |
| 4406 | /* update game list */ |
| 4407 | if (bUpdateRoms == TRUE || bUpdateSamples == TRUE) |
| 4408 | UpdateGameList(bUpdateRoms, bUpdateSamples); |
| 4409 | |
| 4410 | SetFocus(hwndList); |
| 4411 | } |
| 4412 | return TRUE; |
| 4413 | |
| 4414 | case ID_OPTIONS_RESET_DEFAULTS: |
| 4415 | if (DialogBox(GetModuleHandle(NULL), |
| 4416 | MAKEINTRESOURCE(IDD_RESET), hMain, ResetDialogProc) == TRUE) |
| 4417 | { |
| 4418 | // these may have been changed |
| 4419 | SaveDefaultOptions(); |
| 4420 | DestroyWindow(hwnd); |
| 4421 | PostQuitMessage(0); |
| 4422 | } else { |
| 4423 | ResetListView(); |
| 4424 | SetFocus(hwndList); |
| 4425 | } |
| 4426 | return TRUE; |
| 4427 | |
| 4428 | case ID_OPTIONS_INTERFACE: |
| 4429 | DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_INTERFACE_OPTIONS), |
| 4430 | hMain, InterfaceDialogProc); |
| 4431 | SaveDefaultOptions(); |
| 4432 | |
| 4433 | KillTimer(hMain, SCREENSHOT_TIMER); |
| 4434 | if( GetCycleScreenshot() > 0) |
| 4435 | { |
| 4436 | SetTimer(hMain, SCREENSHOT_TIMER, GetCycleScreenshot()*1000, NULL ); // Scale to seconds |
| 4437 | } |
| 4438 | |
| 4439 | return TRUE; |
| 4440 | |
| 4441 | case ID_OPTIONS_BG: |
| 4442 | { |
| 4443 | OPENFILENAME OpenFileName; |
| 4444 | static TCHAR szFile[MAX_PATH] = TEXT("\0"); |
| 4445 | TCHAR* t_bgdir = tstring_from_utf8(GetBgDir()); |
| 4446 | if( !t_bgdir ) |
| 4447 | return FALSE; |
| 4448 | |
| 4449 | OpenFileName.lStructSize = sizeof(OPENFILENAME); |
| 4450 | OpenFileName.hwndOwner = hMain; |
| 4451 | OpenFileName.hInstance = 0; |
| 4452 | OpenFileName.lpstrFilter = TEXT("Image Files (*.png, *.bmp)\0*.PNG;*.BMP\0"); |
| 4453 | OpenFileName.lpstrCustomFilter = NULL; |
| 4454 | OpenFileName.nMaxCustFilter = 0; |
| 4455 | OpenFileName.nFilterIndex = 1; |
| 4456 | OpenFileName.lpstrFile = szFile; |
| 4457 | OpenFileName.nMaxFile = sizeof(szFile); |
| 4458 | OpenFileName.lpstrFileTitle = NULL; |
| 4459 | OpenFileName.nMaxFileTitle = 0; |
| 4460 | OpenFileName.lpstrInitialDir = t_bgdir; |
| 4461 | OpenFileName.lpstrTitle = TEXT("Select a Background Image"); |
| 4462 | OpenFileName.nFileOffset = 0; |
| 4463 | OpenFileName.nFileExtension = 0; |
| 4464 | OpenFileName.lpstrDefExt = NULL; |
| 4465 | OpenFileName.lCustData = 0; |
| 4466 | OpenFileName.lpfnHook = NULL; |
| 4467 | OpenFileName.lpTemplateName = NULL; |
| 4468 | OpenFileName.Flags = OFN_NOCHANGEDIR | OFN_SHOWHELP | OFN_EXPLORER; |
| 4469 | |
| 4470 | if (GetOpenFileName(&OpenFileName)) |
| 4471 | { |
| 4472 | t_szFile = utf8_from_tstring(szFile); |
| 4473 | if( !t_szFile ) |
| 4474 | return FALSE; |
| 4475 | ResetBackground(t_szFile); |
| 4476 | LoadBackgroundBitmap(); |
| 4477 | InvalidateRect(hMain, NULL, TRUE); |
| 4478 | free(t_bgdir); |
| 4479 | free(t_szFile); |
| 4480 | return TRUE; |
| 4481 | } |
| 4482 | free(t_bgdir); |
| 4483 | } |
| 4484 | break; |
| 4485 | |
| 4486 | case ID_OPTIONS_LANGUAGE: |
| 4487 | DialogBox(GetModuleHandle(NULL), |
| 4488 | MAKEINTRESOURCE(IDD_LANGUAGE), |
| 4489 | hMain, |
| 4490 | LanguageDialogProc); |
| 4491 | return TRUE; |
| 4492 | |
| 4493 | case ID_HELP_ABOUT: |
| 4494 | DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_ABOUT), |
| 4495 | hMain, AboutDialogProc); |
| 4496 | SetFocus(hwndList); |
| 4497 | return TRUE; |
| 4498 | |
| 4499 | case IDOK : |
| 4500 | /* cmk -- might need to check more codes here, not sure */ |
| 4501 | if (codeNotify != EN_CHANGE && codeNotify != EN_UPDATE) |
| 4502 | { |
| 4503 | /* enter key */ |
| 4504 | if (g_in_treeview_edit) |
| 4505 | { |
| 4506 | TreeView_EndEditLabelNow(hTreeView, FALSE); |
| 4507 | return TRUE; |
| 4508 | } |
| 4509 | else |
| 4510 | if (have_selection) |
| 4511 | MamePlayGame(); |
| 4512 | } |
| 4513 | break; |
| 4514 | |
| 4515 | case IDCANCEL : /* esc key */ |
| 4516 | if (g_in_treeview_edit) |
| 4517 | TreeView_EndEditLabelNow(hTreeView, TRUE); |
| 4518 | break; |
| 4519 | |
| 4520 | case IDC_PLAY_GAME : |
| 4521 | if (have_selection) |
| 4522 | MamePlayGame(); |
| 4523 | break; |
| 4524 | |
| 4525 | case ID_UI_START: |
| 4526 | SetFocus(hwndList); |
| 4527 | MamePlayGame(); |
| 4528 | break; |
| 4529 | |
| 4530 | case ID_UI_UP: |
| 4531 | Picker_SetSelectedPick(hwndList, GetSelectedPick() - 1); |
| 4532 | break; |
| 4533 | |
| 4534 | case ID_UI_DOWN: |
| 4535 | Picker_SetSelectedPick(hwndList, GetSelectedPick() + 1); |
| 4536 | break; |
| 4537 | |
| 4538 | case ID_UI_PGUP: |
| 4539 | Picker_SetSelectedPick(hwndList, GetSelectedPick() - ListView_GetCountPerPage(hwndList)); |
| 4540 | break; |
| 4541 | |
| 4542 | case ID_UI_PGDOWN: |
| 4543 | if ( (GetSelectedPick() + ListView_GetCountPerPage(hwndList)) < ListView_GetItemCount(hwndList) ) |
| 4544 | Picker_SetSelectedPick(hwndList, GetSelectedPick() + ListView_GetCountPerPage(hwndList) ); |
| 4545 | else |
| 4546 | Picker_SetSelectedPick(hwndList, ListView_GetItemCount(hwndList)-1 ); |
| 4547 | break; |
| 4548 | |
| 4549 | case ID_UI_HOME: |
| 4550 | Picker_SetSelectedPick(hwndList, 0); |
| 4551 | break; |
| 4552 | |
| 4553 | case ID_UI_END: |
| 4554 | Picker_SetSelectedPick(hwndList, ListView_GetItemCount(hwndList)-1 ); |
| 4555 | break; |
| 4556 | case ID_UI_LEFT: |
| 4557 | /* hmmmmm..... */ |
| 4558 | SendMessage(hwndList,WM_HSCROLL, SB_LINELEFT, 0); |
| 4559 | break; |
| 4560 | |
| 4561 | case ID_UI_RIGHT: |
| 4562 | /* hmmmmm..... */ |
| 4563 | SendMessage(hwndList,WM_HSCROLL, SB_LINERIGHT, 0); |
| 4564 | break; |
| 4565 | case ID_UI_HISTORY_UP: |
| 4566 | /* hmmmmm..... */ |
| 4567 | { |
| 4568 | HWND hHistory = GetDlgItem(hMain, IDC_HISTORY); |
| 4569 | SendMessage(hHistory, EM_SCROLL, SB_PAGEUP, 0); |
| 4570 | } |
| 4571 | break; |
| 4572 | |
| 4573 | case ID_UI_HISTORY_DOWN: |
| 4574 | /* hmmmmm..... */ |
| 4575 | { |
| 4576 | HWND hHistory = GetDlgItem(hMain, IDC_HISTORY); |
| 4577 | SendMessage(hHistory, EM_SCROLL, SB_PAGEDOWN, 0); |
| 4578 | } |
| 4579 | break; |
| 4580 | |
| 4581 | case IDC_SSFRAME: |
| 4582 | TabView_CalculateNextTab(hTabCtrl); |
| 4583 | UpdateScreenShot(); |
| 4584 | TabView_UpdateSelection(hTabCtrl); |
| 4585 | break; |
| 4586 | |
| 4587 | case ID_CONTEXT_SELECT_RANDOM: |
| 4588 | SetRandomPickItem(); |
| 4589 | break; |
| 4590 | |
| 4591 | case ID_CONTEXT_RESET_PLAYTIME: |
| 4592 | ResetPlayTime( Picker_GetSelectedItem(hwndList) ); |
| 4593 | ListView_RedrawItems(hwndList, GetSelectedPick(), GetSelectedPick()); |
| 4594 | break; |
| 4595 | |
| 4596 | case ID_CONTEXT_RESET_PLAYCOUNT: |
| 4597 | ResetPlayCount( Picker_GetSelectedItem(hwndList) ); |
| 4598 | ListView_RedrawItems(hwndList, GetSelectedPick(), GetSelectedPick()); |
| 4599 | break; |
| 4600 | |
| 4601 | case ID_CONTEXT_RENAME_CUSTOM : |
| 4602 | TreeView_EditLabel(hTreeView,TreeView_GetSelection(hTreeView)); |
| 4603 | break; |
| 4604 | |
| 4605 | default: |
| 4606 | if (id >= ID_CONTEXT_SHOW_FOLDER_START && id < ID_CONTEXT_SHOW_FOLDER_END) |
| 4607 | { |
| 4608 | ToggleShowFolder(id - ID_CONTEXT_SHOW_FOLDER_START); |
| 4609 | break; |
| 4610 | } |
| 4611 | for (i = 0; g_helpInfo[i].nMenuItem > 0; i++) |
| 4612 | { |
| 4613 | if (g_helpInfo[i].nMenuItem == id) |
| 4614 | { |
| 4615 | if (g_helpInfo[i].bIsHtmlHelp) |
| 4616 | HelpFunction(hMain, g_helpInfo[i].lpFile, HH_DISPLAY_TOPIC, 0); |
| 4617 | else |
| 4618 | DisplayTextFile(hMain, g_helpInfo[i].lpFile); |
| 4619 | return FALSE; |
| 4620 | } |
| 4621 | } |
| 4622 | #ifdef MESS |
| 4623 | return MessCommand(hwnd, id, hwndCtl, codeNotify); |
| 4624 | #else |
| 4625 | break; |
| 4626 | #endif |
| 4627 | } |
| 4628 | |
| 4629 | return FALSE; |
| 4630 | } |
| 4631 | |
| 4632 | static void LoadBackgroundBitmap() |
| 4633 | { |
| 4634 | HGLOBAL hDIBbg; |
| 4635 | char* pFileName = 0; |
| 4636 | |
| 4637 | if (hBackground) |
| 4638 | { |
| 4639 | DeleteObject(hBackground); |
| 4640 | hBackground = 0; |
| 4641 | } |
| 4642 | |
| 4643 | if (hPALbg) |
| 4644 | { |
| 4645 | DeleteObject(hPALbg); |
| 4646 | hPALbg = 0; |
| 4647 | } |
| 4648 | |
| 4649 | /* Pick images based on number of colors avaliable. */ |
| 4650 | if (GetDepth(hwndList) <= 8) |
| 4651 | { |
| 4652 | pFileName = (char *)"bkgnd16"; |
| 4653 | /*nResource = IDB_BKGROUND16;*/ |
| 4654 | } |
| 4655 | else |
| 4656 | { |
| 4657 | pFileName = (char *)"bkground"; |
| 4658 | /*nResource = IDB_BKGROUND;*/ |
| 4659 | } |
| 4660 | |
| 4661 | if (LoadDIB(pFileName, &hDIBbg, &hPALbg, BACKGROUND)) |
| 4662 | { |
| 4663 | HDC hDC = GetDC(hwndList); |
| 4664 | hBackground = DIBToDDB(hDC, hDIBbg, &bmDesc); |
| 4665 | GlobalFree(hDIBbg); |
| 4666 | ReleaseDC(hwndList, hDC); |
| 4667 | } |
| 4668 | } |
| 4669 | |
| 4670 | static void ResetColumnDisplay(BOOL first_time) |
| 4671 | { |
| 4672 | int driver_index; |
| 4673 | |
| 4674 | if (!first_time) |
| 4675 | Picker_ResetColumnDisplay(hwndList); |
| 4676 | |
| 4677 | ResetListView(); |
| 4678 | |
| 4679 | driver_index = GetGameNameIndex(GetDefaultGame()); |
| 4680 | Picker_SetSelectedItem(hwndList, driver_index); |
| 4681 | } |
| 4682 | |
| 4683 | int GamePicker_GetItemImage(HWND hwndPicker, int nItem) |
| 4684 | { |
| 4685 | return GetIconForDriver(nItem); |
| 4686 | } |
| 4687 | |
| 4688 | const TCHAR *GamePicker_GetItemString(HWND hwndPicker, int nItem, int nColumn, |
| 4689 | TCHAR *pszBuffer, UINT nBufferLength) |
| 4690 | { |
| 4691 | const TCHAR *s = NULL; |
| 4692 | const char* utf8_s = NULL; |
| 4693 | char playtime_buf[256]; |
| 4694 | |
| 4695 | switch(nColumn) |
| 4696 | { |
| 4697 | case COLUMN_GAMES: |
| 4698 | /* Driver description */ |
| 4699 | utf8_s = ModifyThe(drivers[nItem]->description); |
| 4700 | break; |
| 4701 | case COLUMN_ORIENTATION: |
| 4702 | utf8_s = DriverIsVertical(nItem) ? "Vertical" : "Horizontal"; |
| 4703 | break; |
| 4704 | #if 0 |
| 4705 | case COLUMN_ROMS: |
| 4706 | /* Has Roms */ |
| 4707 | utf8_s = GetAuditString(GetRomAuditResults(nItem)); |
| 4708 | break; |
| 4709 | #endif |
| 4710 | case COLUMN_SAMPLES: |
| 4711 | /* Samples */ |
| 4712 | if (DriverUsesSamples(nItem)) |
| 4713 | utf8_s = GetAuditString(GetSampleAuditResults(nItem)); |
| 4714 | break; |
| 4715 | |
| 4716 | case COLUMN_DIRECTORY: |
| 4717 | /* Driver name (directory) */ |
| 4718 | utf8_s = drivers[nItem]->name; |
| 4719 | break; |
| 4720 | |
| 4721 | case COLUMN_SRCDRIVERS: |
| 4722 | /* Source drivers */ |
| 4723 | utf8_s = GetDriverFilename(nItem); |
| 4724 | break; |
| 4725 | |
| 4726 | case COLUMN_PLAYTIME: |
| 4727 | /* Source drivers */ |
| 4728 | GetTextPlayTime(nItem, playtime_buf); |
| 4729 | utf8_s = playtime_buf; |
| 4730 | break; |
| 4731 | |
| 4732 | case COLUMN_TYPE: |
| 4733 | { |
| 4734 | machine_config drv; |
| 4735 | expand_machine_driver(drivers[nItem]->drv,&drv); |
| 4736 | |
| 4737 | /* Vector/Raster */ |
| 4738 | if (drv.video_attributes & VIDEO_TYPE_VECTOR) |
| 4739 | s = TEXT("Vector"); |
| 4740 | else |
| 4741 | s = TEXT("Raster"); |
| 4742 | break; |
| 4743 | } |
| 4744 | case COLUMN_TRACKBALL: |
| 4745 | /* Trackball */ |
| 4746 | if (DriverUsesTrackball(nItem)) |
| 4747 | s = TEXT("Yes"); |
| 4748 | else |
| 4749 | s = TEXT("No"); |
| 4750 | break; |
| 4751 | |
| 4752 | case COLUMN_PLAYED: |
| 4753 | /* times played */ |
| 4754 | _sntprintf(pszBuffer, nBufferLength, TEXT("%i"), GetPlayCount(nItem)); |
| 4755 | s = pszBuffer; |
| 4756 | break; |
| 4757 | |
| 4758 | case COLUMN_MANUFACTURER: |
| 4759 | /* Manufacturer */ |
| 4760 | utf8_s = drivers[nItem]->manufacturer; |
| 4761 | break; |
| 4762 | |
| 4763 | case COLUMN_YEAR: |
| 4764 | /* Year */ |
| 4765 | utf8_s = drivers[nItem]->year; |
| 4766 | break; |
| 4767 | |
| 4768 | case COLUMN_CLONE: |
| 4769 | utf8_s = GetCloneParentName(nItem); |
| 4770 | break; |
| 4771 | } |
| 4772 | |
| 4773 | if( utf8_s ) |
| 4774 | { |
| 4775 | TCHAR* t_s = tstring_from_utf8(utf8_s); |
| 4776 | if( !t_s ) |
| 4777 | return s; |
| 4778 | |
| 4779 | _sntprintf(pszBuffer, nBufferLength, TEXT("%s"), t_s); |
| 4780 | free(t_s); |
| 4781 | |
| 4782 | s = pszBuffer; |
| 4783 | } |
| 4784 | |
| 4785 | return s; |
| 4786 | } |
| 4787 | |
| 4788 | static void GamePicker_LeavingItem(HWND hwndPicker, int nItem) |
| 4789 | { |
| 4790 | // leaving item |
| 4791 | // printf("leaving %s\n",drivers[nItem]->name); |
| 4792 | } |
| 4793 | |
| 4794 | static void GamePicker_EnteringItem(HWND hwndPicker, int nItem) |
| 4795 | { |
| 4796 | TCHAR* t_description; |
| 4797 | ATOM a; |
| 4798 | // printf("entering %s\n",drivers[nItem]->name); |
| 4799 | if (g_bDoBroadcast == TRUE) |
| 4800 | { |
| 4801 | t_description = tstring_from_utf8(drivers[nItem]->description); |
| 4802 | if( !t_description ) |
| 4803 | return; |
| 4804 | a = GlobalAddAtom(t_description); |
| 4805 | SendMessage(HWND_BROADCAST, g_mame32_message, a, a); |
| 4806 | GlobalDeleteAtom(a); |
| 4807 | free(t_description); |
| 4808 | } |
| 4809 | |
| 4810 | EnableSelection(nItem); |
| 4811 | #ifdef MESS |
| 4812 | MessReadMountedSoftware(nItem); |
| 4813 | #endif |
| 4814 | } |
| 4815 | |
| 4816 | static int GamePicker_FindItemParent(HWND hwndPicker, int nItem) |
| 4817 | { |
| 4818 | return GetParentRomSetIndex(drivers[nItem]); |
| 4819 | } |
| 4820 | |
| 4821 | /* Initialize the Picker and List controls */ |
| 4822 | static void InitListView() |
| 4823 | { |
| 4824 | LVBKIMAGE bki; |
| 4825 | TCHAR path[MAX_PATH]; |
| 4826 | TCHAR* t_bgdir; |
| 4827 | |
| 4828 | static const struct PickerCallbacks s_gameListCallbacks = |
| 4829 | { |
| 4830 | SetSortColumn, /* pfnSetSortColumn */ |
| 4831 | GetSortColumn, /* pfnGetSortColumn */ |
| 4832 | SetSortReverse, /* pfnSetSortReverse */ |
| 4833 | GetSortReverse, /* pfnGetSortReverse */ |
| 4834 | SetViewMode, /* pfnSetViewMode */ |
| 4835 | GetViewMode, /* pfnGetViewMode */ |
| 4836 | SetColumnWidths, /* pfnSetColumnWidths */ |
| 4837 | GetColumnWidths, /* pfnGetColumnWidths */ |
| 4838 | SetColumnOrder, /* pfnSetColumnOrder */ |
| 4839 | GetColumnOrder, /* pfnGetColumnOrder */ |
| 4840 | SetColumnShown, /* pfnSetColumnShown */ |
| 4841 | GetColumnShown, /* pfnGetColumnShown */ |
| 4842 | GetOffsetClones, /* pfnGetOffsetChildren */ |
| 4843 | |
| 4844 | GamePicker_Compare, /* pfnCompare */ |
| 4845 | MamePlayGame, /* pfnDoubleClick */ |
| 4846 | GamePicker_GetItemString, /* pfnGetItemString */ |
| 4847 | GamePicker_GetItemImage, /* pfnGetItemImage */ |
| 4848 | GamePicker_LeavingItem, /* pfnLeavingItem */ |
| 4849 | GamePicker_EnteringItem, /* pfnEnteringItem */ |
| 4850 | BeginListViewDrag, /* pfnBeginListViewDrag */ |
| 4851 | GamePicker_FindItemParent, /* pfnFindItemParent */ |
| 4852 | OnIdle, /* pfnIdle */ |
| 4853 | GamePicker_OnHeaderContextMenu, /* pfnOnHeaderContextMenu */ |
| 4854 | GamePicker_OnBodyContextMenu /* pfnOnBodyContextMenu */ |
| 4855 | }; |
| 4856 | |
| 4857 | struct PickerOptions opts; |
| 4858 | |
| 4859 | // subclass the list view |
| 4860 | memset(&opts, 0, sizeof(opts)); |
| 4861 | opts.pCallbacks = &s_gameListCallbacks; |
| 4862 | opts.nColumnCount = COLUMN_MAX; |
| 4863 | opts.ppszColumnNames = column_names; |
| 4864 | SetupPicker(hwndList, &opts); |
| 4865 | |
| 4866 | ListView_SetTextBkColor(hwndList, CLR_NONE); |
| 4867 | ListView_SetBkColor(hwndList, CLR_NONE); |
| 4868 | t_bgdir = tstring_from_utf8(GetBgDir()); |
| 4869 | if( !t_bgdir ) |
| 4870 | return; |
| 4871 | _stprintf(path, TEXT("%s\\bkground.png"), t_bgdir); |
| 4872 | bki.ulFlags = LVBKIF_SOURCE_URL | LVBKIF_STYLE_TILE; |
| 4873 | bki.pszImage = path; |
| 4874 | if( hBackground ) |
| 4875 | ListView_SetBkImage(hwndList, &bki); |
| 4876 | |
| 4877 | CreateIcons(); |
| 4878 | |
| 4879 | ResetColumnDisplay(TRUE); |
| 4880 | |
| 4881 | // Allow selection to change the default saved game |
| 4882 | bListReady = TRUE; |
| 4883 | free(t_bgdir); |
| 4884 | } |
| 4885 | |
| 4886 | static void AddDriverIcon(int nItem,int default_icon_index) |
| 4887 | { |
| 4888 | HICON hIcon = 0; |
| 4889 | int nParentIndex = -1; |
| 4890 | |
| 4891 | /* if already set to rom or clone icon, we've been here before */ |
| 4892 | if (icon_index[nItem] == 1 || icon_index[nItem] == 3) |
| 4893 | return; |
| 4894 | |
| 4895 | hIcon = LoadIconFromFile((char *)drivers[nItem]->name); |
| 4896 | if (hIcon == NULL) |
| 4897 | { |
| 4898 | nParentIndex = GetParentIndex(drivers[nItem]); |
| 4899 | if( nParentIndex >= 0) |
| 4900 | { |
| 4901 | hIcon = LoadIconFromFile((char *)drivers[nParentIndex]->name); |
| 4902 | nParentIndex = GetParentIndex(drivers[nParentIndex]); |
| 4903 | if (hIcon == NULL && nParentIndex >= 0) |
| 4904 | hIcon = LoadIconFromFile((char *)drivers[nParentIndex]->name); |
| 4905 | } |
| 4906 | } |
| 4907 | |
| 4908 | if (hIcon != NULL) |
| 4909 | { |
| 4910 | int nIconPos = ImageList_AddIcon(hSmall, hIcon); |
| 4911 | ImageList_AddIcon(hLarge, hIcon); |
| 4912 | if (nIconPos != -1) |
| 4913 | icon_index[nItem] = nIconPos; |
| 4914 | } |
| 4915 | if (icon_index[nItem] == 0) |
| 4916 | icon_index[nItem] = default_icon_index; |
| 4917 | } |
| 4918 | |
| 4919 | static void DestroyIcons(void) |
| 4920 | { |
| 4921 | if (hSmall != NULL) |
| 4922 | { |
| 4923 | ImageList_Destroy(hSmall); |
| 4924 | hSmall = NULL; |
| 4925 | } |
| 4926 | |
| 4927 | if (icon_index != NULL) |
| 4928 | { |
| 4929 | int i; |
| 4930 | for (i=0;i<driver_list_get_count(drivers);i++) |
| 4931 | icon_index[i] = 0; // these are indices into hSmall |
| 4932 | } |
| 4933 | |
| 4934 | if (hLarge != NULL) |
| 4935 | { |
| 4936 | ImageList_Destroy(hLarge); |
| 4937 | hLarge = NULL; |
| 4938 | } |
| 4939 | |
| 4940 | if (hHeaderImages != NULL) |
| 4941 | { |
| 4942 | ImageList_Destroy(hHeaderImages); |
| 4943 | hHeaderImages = NULL; |
| 4944 | } |
| 4945 | |
| 4946 | } |
| 4947 | |
| 4948 | static void ReloadIcons(void) |
| 4949 | { |
| 4950 | HICON hIcon; |
| 4951 | INT i; |
| 4952 | |
| 4953 | // clear out all the images |
| 4954 | ImageList_RemoveAll(hSmall); |
| 4955 | ImageList_RemoveAll(hLarge); |
| 4956 | |
| 4957 | if (icon_index != NULL) |
| 4958 | { |
| 4959 | for (i=0;i<driver_list_get_count(drivers);i++) |
| 4960 | icon_index[i] = 0; // these are indices into hSmall |
| 4961 | } |
| 4962 | |
| 4963 | for (i = 0; g_iconData[i].icon_name; i++) |
| 4964 | { |
| 4965 | hIcon = LoadIconFromFile((char *) g_iconData[i].icon_name); |
| 4966 | if (hIcon == NULL) |
| 4967 | hIcon = LoadIcon(hInst, MAKEINTRESOURCE(g_iconData[i].resource)); |
| 4968 | |
| 4969 | ImageList_AddIcon(hSmall, hIcon); |
| 4970 | ImageList_AddIcon(hLarge, hIcon); |
| 4971 | } |
| 4972 | } |
| 4973 | |
| 4974 | static DWORD GetShellLargeIconSize(void) |
| 4975 | { |
| 4976 | DWORD dwSize, dwLength = 512, dwType = REG_SZ; |
| 4977 | TCHAR szBuffer[512]; |
| 4978 | HKEY hKey; |
| 4979 | |
| 4980 | /* Get the Key */ |
| 4981 | RegOpenKey(HKEY_CURRENT_USER, TEXT("Control Panel\\desktop\\WindowMetrics"), &hKey); |
| 4982 | /* Save the last size */ |
| 4983 | RegQueryValueEx(hKey, TEXT("Shell Icon Size"), NULL, &dwType, (LPBYTE)szBuffer, &dwLength); |
| 4984 | dwSize = _ttol(szBuffer); |
| 4985 | if (dwSize < 32) |
| 4986 | dwSize = 32; |
| 4987 | |
| 4988 | if (dwSize > 48) |
| 4989 | dwSize = 48; |
| 4990 | |
| 4991 | /* Clean up */ |
| 4992 | RegCloseKey(hKey); |
| 4993 | return dwSize; |
| 4994 | } |
| 4995 | |
| 4996 | static DWORD GetShellSmallIconSize(void) |
| 4997 | { |
| 4998 | DWORD dwSize = ICONMAP_WIDTH; |
| 4999 | |
| 5000 | if (dwSize < 48) |
| 5001 | { |
| 5002 | if (dwSize < 32) |
| 5003 | dwSize = 16; |
| 5004 | else |
| 5005 | dwSize = 32; |
| 5006 | } |
| 5007 | else |
| 5008 | { |
| 5009 | dwSize = 48; |
| 5010 | } |
| 5011 | return dwSize; |
| 5012 | } |
| 5013 | |
| 5014 | // create iconlist for Listview control |
| 5015 | static void CreateIcons(void) |
| 5016 | { |
| 5017 | DWORD dwLargeIconSize = GetShellLargeIconSize(); |
| 5018 | HICON hIcon; |
| 5019 | int icon_count; |
| 5020 | DWORD dwStyle; |
| 5021 | int i; |
| 5022 | |
| 5023 | icon_count = 0; |
| 5024 | while(g_iconData[icon_count].icon_name) |
| 5025 | icon_count++; |
| 5026 | |
| 5027 | // the current window style affects the sizing of the rows when changing |
| 5028 | // between list views, so put it in small icon mode temporarily while we associate |
| 5029 | // our image list |
| 5030 | // |
| 5031 | // using large icon mode instead kills the horizontal scrollbar when doing |
| 5032 | // full refresh, which seems odd (it should recreate the scrollbar when |
| 5033 | // set back to report mode, for example, but it doesn't). |
| 5034 | |
| 5035 | dwStyle = GetWindowLong(hwndList,GWL_STYLE); |
| 5036 | SetWindowLong(hwndList,GWL_STYLE,(dwStyle & ~LVS_TYPEMASK) | LVS_ICON); |
| 5037 | |
| 5038 | hSmall = ImageList_Create(GetShellSmallIconSize(),GetShellSmallIconSize(), |
| 5039 | ILC_COLORDDB | ILC_MASK, icon_count, icon_count + 5000); |
| 5040 | hLarge = ImageList_Create(dwLargeIconSize, dwLargeIconSize, |
| 5041 | ILC_COLORDDB | ILC_MASK, icon_count, icon_count + 5000); |
| 5042 | |
| 5043 | if (NULL == hSmall || NULL == hLarge) { |
| 5044 | MessageBox(hwndList, "Cannot allocate Icon lists", TEXT("Allocation error - Exiting"), IDOK); |
| 5045 | PostQuitMessage(0); |
| 5046 | } |
| 5047 | |
| 5048 | ReloadIcons(); |
| 5049 | |
| 5050 | // Associate the image lists with the list view control. |
| 5051 | (void)ListView_SetImageList(hwndList, hSmall, LVSIL_SMALL); |
| 5052 | (void)ListView_SetImageList(hwndList, hLarge, LVSIL_NORMAL); |
| 5053 | |
| 5054 | // restore our view |
| 5055 | SetWindowLong(hwndList,GWL_STYLE,dwStyle); |
| 5056 | |
| 5057 | #ifdef MESS |
| 5058 | CreateMessIcons(); |
| 5059 | #endif |
| 5060 | |
| 5061 | // Now set up header specific stuff |
| 5062 | hHeaderImages = ImageList_Create(8,8,ILC_COLORDDB | ILC_MASK,2,2); |
| 5063 | hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_HEADER_UP)); |
| 5064 | ImageList_AddIcon(hHeaderImages,hIcon); |
| 5065 | hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_HEADER_DOWN)); |
| 5066 | ImageList_AddIcon(hHeaderImages,hIcon); |
| 5067 | |
| 5068 | for (i = 0; i < sizeof(s_nPickers) / sizeof(s_nPickers[0]); i++) |
| 5069 | Picker_SetHeaderImageList(GetDlgItem(hMain, s_nPickers[i]), hHeaderImages); |
| 5070 | } |
| 5071 | |
| 5072 | |
| 5073 | |
| 5074 | static int GamePicker_Compare(HWND hwndPicker, int index1, int index2, int sort_subitem) |
| 5075 | { |
| 5076 | int value; |
| 5077 | const char *name1 = NULL; |
| 5078 | const char *name2 = NULL; |
| 5079 | int nTemp1, nTemp2; |
| 5080 | |
| 5081 | #ifdef DEBUG |
| 5082 | if (strcmp(drivers[index1]->name,"1941") == 0 && strcmp(drivers[index2]->name,"1942") == 0) |
| 5083 | { |
| 5084 | dprintf("comparing 1941, 1942"); |
| 5085 | } |
| 5086 | |
| 5087 | if (strcmp(drivers[index1]->name,"1942") == 0 && strcmp(drivers[index2]->name,"1941") == 0) |
| 5088 | { |
| 5089 | dprintf("comparing 1942, 1941"); |
| 5090 | } |
| 5091 | #endif |
| 5092 | |
| 5093 | switch (sort_subitem) |
| 5094 | { |
| 5095 | case COLUMN_GAMES: |
| 5096 | value = mame_stricmp(ModifyThe(drivers[index1]->description), |
| 5097 | ModifyThe(drivers[index2]->description)); |
| 5098 | break; |
| 5099 | |
| 5100 | case COLUMN_ORIENTATION: |
| 5101 | nTemp1 = DriverIsVertical(index1) ? 1 : 0; |
| 5102 | nTemp2 = DriverIsVertical(index2) ? 1 : 0; |
| 5103 | value = nTemp1 - nTemp2; |
| 5104 | break; |
| 5105 | #if 0 |
| 5106 | case COLUMN_ROMS: |
| 5107 | nTemp1 = GetRomAuditResults(index1); |
| 5108 | nTemp2 = GetRomAuditResults(index2); |
| 5109 | |
| 5110 | if (IsAuditResultKnown(nTemp1) == FALSE && IsAuditResultKnown(nTemp2) == FALSE) |
| 5111 | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5112 | |
| 5113 | if (IsAuditResultKnown(nTemp1) == FALSE) |
| 5114 | { |
| 5115 | value = 1; |
| 5116 | break; |
| 5117 | } |
| 5118 | |
| 5119 | if (IsAuditResultKnown(nTemp2) == FALSE) |
| 5120 | { |
| 5121 | value = -1; |
| 5122 | break; |
| 5123 | } |
| 5124 | |
| 5125 | // ok, both are known |
| 5126 | |
| 5127 | if (IsAuditResultYes(nTemp1) && IsAuditResultYes(nTemp2)) |
| 5128 | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5129 | |
| 5130 | if (IsAuditResultNo(nTemp1) && IsAuditResultNo(nTemp2)) |
| 5131 | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5132 | |
| 5133 | if (IsAuditResultYes(nTemp1) && IsAuditResultNo(nTemp2)) |
| 5134 | value = -1; |
| 5135 | else |
| 5136 | value = 1; |
| 5137 | break; |
| 5138 | #endif |
| 5139 | case COLUMN_SAMPLES: |
| 5140 | nTemp1 = -1; |
| 5141 | if (DriverUsesSamples(index1)) |
| 5142 | { |
| 5143 | int audit_result = GetSampleAuditResults(index1); |
| 5144 | if (IsAuditResultKnown(audit_result)) |
| 5145 | { |
| 5146 | if (IsAuditResultYes(audit_result)) |
| 5147 | nTemp1 = 1; |
| 5148 | else |
| 5149 | nTemp1 = 0; |
| 5150 | } |
| 5151 | else |
| 5152 | nTemp1 = 2; |
| 5153 | } |
| 5154 | |
| 5155 | nTemp2 = -1; |
| 5156 | if (DriverUsesSamples(index2)) |
| 5157 | { |
| 5158 | int audit_result = GetSampleAuditResults(index1); |
| 5159 | if (IsAuditResultKnown(audit_result)) |
| 5160 | { |
| 5161 | if (IsAuditResultYes(audit_result)) |
| 5162 | nTemp2 = 1; |
| 5163 | else |
| 5164 | nTemp2 = 0; |
| 5165 | } |
| 5166 | else |
| 5167 | nTemp2 = 2; |
| 5168 | } |
| 5169 | |
| 5170 | if (nTemp1 == nTemp2) |
| 5171 | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5172 | |
| 5173 | value = nTemp2 - nTemp1; |
| 5174 | break; |
| 5175 | |
| 5176 | case COLUMN_DIRECTORY: |
| 5177 | value = mame_stricmp(drivers[index1]->name, drivers[index2]->name); |
| 5178 | break; |
| 5179 | |
| 5180 | case COLUMN_SRCDRIVERS: |
| 5181 | if (mame_stricmp(drivers[index1]->source_file+12, drivers[index2]->source_file+12) == 0) |
| 5182 | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5183 | |
| 5184 | value = mame_stricmp(drivers[index1]->source_file+12, drivers[index2]->source_file+12); |
| 5185 | break; |
| 5186 | case COLUMN_PLAYTIME: |
| 5187 | value = GetPlayTime(index1) - GetPlayTime(index2); |
| 5188 | if (value == 0) |
| 5189 | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5190 | |
| 5191 | break; |
| 5192 | |
| 5193 | case COLUMN_TYPE: |
| 5194 | { |
| 5195 | machine_config drv1,drv2; |
| 5196 | expand_machine_driver(drivers[index1]->drv,&drv1); |
| 5197 | expand_machine_driver(drivers[index2]->drv,&drv2); |
| 5198 | |
| 5199 | if ((drv1.video_attributes & VIDEO_TYPE_VECTOR) == |
| 5200 | (drv2.video_attributes & VIDEO_TYPE_VECTOR)) |
| 5201 | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5202 | |
| 5203 | value = (drv1.video_attributes & VIDEO_TYPE_VECTOR) - |
| 5204 | (drv2.video_attributes & VIDEO_TYPE_VECTOR); |
| 5205 | break; |
| 5206 | } |
| 5207 | case COLUMN_TRACKBALL: |
| 5208 | if (DriverUsesTrackball(index1) == DriverUsesTrackball(index2)) |
| 5209 | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5210 | |
| 5211 | value = DriverUsesTrackball(index1) - DriverUsesTrackball(index2); |
| 5212 | break; |
| 5213 | |
| 5214 | case COLUMN_PLAYED: |
| 5215 | value = GetPlayCount(index1) - GetPlayCount(index2); |
| 5216 | if (value == 0) |
| 5217 | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5218 | |
| 5219 | break; |
| 5220 | |
| 5221 | case COLUMN_MANUFACTURER: |
| 5222 | if (mame_stricmp(drivers[index1]->manufacturer, drivers[index2]->manufacturer) == 0) |
| 5223 | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5224 | |
| 5225 | value = mame_stricmp(drivers[index1]->manufacturer, drivers[index2]->manufacturer); |
| 5226 | break; |
| 5227 | |
| 5228 | case COLUMN_YEAR: |
| 5229 | if (mame_stricmp(drivers[index1]->year, drivers[index2]->year) == 0) |
| 5230 | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5231 | |
| 5232 | value = mame_stricmp(drivers[index1]->year, drivers[index2]->year); |
| 5233 | break; |
| 5234 | |
| 5235 | case COLUMN_CLONE: |
| 5236 | name1 = GetCloneParentName(index1); |
| 5237 | name2 = GetCloneParentName(index2); |
| 5238 | |
| 5239 | if (*name1 == '\0') |
| 5240 | name1 = NULL; |
| 5241 | if (*name2 == '\0') |
| 5242 | name2 = NULL; |
| 5243 | |
| 5244 | if (name1 == name2) |
| 5245 | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5246 | |
| 5247 | if (name2 == NULL) |
| 5248 | value = -1; |
| 5249 | else if (name1 == NULL) |
| 5250 | value = 1; |
| 5251 | else |
| 5252 | value = mame_stricmp(name1, name2); |
| 5253 | break; |
| 5254 | |
| 5255 | default : |
| 5256 | return GamePicker_Compare(hwndPicker, index1, index2, COLUMN_GAMES); |
| 5257 | } |
| 5258 | |
| 5259 | #ifdef DEBUG |
| 5260 | if ((strcmp(drivers[index1]->name,"1941") == 0 && strcmp(drivers[index2]->name,"1942") == 0) || |
| 5261 | (strcmp(drivers[index1]->name,"1942") == 0 && strcmp(drivers[index2]->name,"1941") == 0)) |
| 5262 | dprintf("result: %i",value); |
| 5263 | #endif |
| 5264 | |
| 5265 | return value; |
| 5266 | } |
| 5267 | |
| 5268 | int GetSelectedPick() |
| 5269 | { |
| 5270 | /* returns index of listview selected item */ |
| 5271 | /* This will return -1 if not found */ |
| 5272 | return ListView_GetNextItem(hwndList, -1, LVIS_SELECTED | LVIS_FOCUSED); |
| 5273 | } |
| 5274 | |
| 5275 | static HICON GetSelectedPickItemIcon() |
| 5276 | { |
| 5277 | LV_ITEM lvi; |
| 5278 | |
| 5279 | lvi.iItem = GetSelectedPick(); |
| 5280 | lvi.iSubItem = 0; |
| 5281 | lvi.mask = LVIF_IMAGE; |
| 5282 | ListView_GetItem(hwndList, &lvi); |
| 5283 | |
| 5284 | return ImageList_GetIcon(hLarge, lvi.iImage, ILD_TRANSPARENT); |
| 5285 | } |
| 5286 | |
| 5287 | static void SetRandomPickItem() |
| 5288 | { |
| 5289 | int nListCount; |
| 5290 | |
| 5291 | nListCount = ListView_GetItemCount(hwndList); |
| 5292 | |
| 5293 | if (nListCount > 0) |
| 5294 | { |
| 5295 | Picker_SetSelectedPick(hwndList, rand() % nListCount); |
| 5296 | } |
| 5297 | } |
| 5298 | |
| 5299 | BOOL CommonFileDialog(common_file_dialog_proc cfd, char *filename, int filetype) |
| 5300 | { |
| 5301 | BOOL success; |
| 5302 | OPENFILENAME of; |
| 5303 | TCHAR* t_filename; |
| 5304 | TCHAR* t_statedir = 0; |
| 5305 | TCHAR* t_artdir = 0; |
| 5306 | TCHAR t_filename_buffer[MAX_PATH] = {0, }; |
| 5307 | char *utf8_filename; |
| 5308 | |
| 5309 | // convert the filename to UTF-8 and copy into buffer |
| 5310 | t_filename = tstring_from_utf8(filename); |
| 5311 | if (t_filename != NULL) |
| 5312 | { |
| 5313 | _sntprintf(t_filename_buffer, ARRAY_LENGTH(t_filename_buffer), TEXT("%s"), t_filename); |
| 5314 | free(t_filename); |
| 5315 | } |
| 5316 | |
| 5317 | of.lStructSize = sizeof(of); |
| 5318 | of.hwndOwner = hMain; |
| 5319 | of.hInstance = NULL; |
| 5320 | switch (filetype) |
| 5321 | { |
| 5322 | case FILETYPE_INPUT_FILES : |
| 5323 | of.lpstrFilter = TEXT(MAMENAME " input files (*.inp,*.zip)\0*.inp;*.zip\0All files (*.*)\0*.*\0"); |
| 5324 | break; |
| 5325 | case FILETYPE_SAVESTATE_FILES : |
| 5326 | of.lpstrFilter = TEXT(MAMENAME " savestate files (*.sta)\0*.sta;\0All files (*.*)\0*.*\0"); |
| 5327 | break; |
| 5328 | case FILETYPE_WAVE_FILES : |
| 5329 | of.lpstrFilter = TEXT("sounds (*.wav)\0*.wav;\0All files (*.*)\0*.*\0"); |
| 5330 | break; |
| 5331 | case FILETYPE_MNG_FILES : |
| 5332 | of.lpstrFilter = TEXT("videos (*.mng)\0*.mng;\0All files (*.*)\0*.*\0"); |
| 5333 | break; |
| 5334 | case FILETYPE_EFFECT_FILES : |
| 5335 | of.lpstrFilter = TEXT("effects (*.png)\0*.png;\0All files (*.*)\0*.*\0"); |
| 5336 | break; |
| 5337 | } |
| 5338 | of.lpstrCustomFilter = NULL; |
| 5339 | of.nMaxCustFilter = 0; |
| 5340 | of.nFilterIndex = 1; |
| 5341 | of.lpstrFile = t_filename_buffer; |
| 5342 | of.nMaxFile = ARRAY_LENGTH(t_filename_buffer); |
| 5343 | of.lpstrFileTitle = NULL; |
| 5344 | of.nMaxFileTitle = 0; |
| 5345 | if (filetype == FILETYPE_SAVESTATE_FILES) |
| 5346 | { |
| 5347 | t_statedir = tstring_from_utf8(GetStateDir()); |
| 5348 | if( !t_statedir ) |
| 5349 | return FALSE; |
| 5350 | |
| 5351 | of.lpstrInitialDir = t_statedir; |
| 5352 | } |
| 5353 | else |
| 5354 | { |
| 5355 | if (filetype == FILETYPE_EFFECT_FILES) |
| 5356 | { |
| 5357 | t_artdir = tstring_from_utf8(GetArtDir()); |
| 5358 | if( !t_artdir ) |
| 5359 | return FALSE; |
| 5360 | |
| 5361 | of.lpstrInitialDir = t_artdir; |
| 5362 | } |
| 5363 | else |
| 5364 | of.lpstrInitialDir = last_directory; |
| 5365 | } |
| 5366 | of.lpstrTitle = NULL; |
| 5367 | of.Flags = OFN_EXPLORER | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY; |
| 5368 | of.nFileOffset = 0; |
| 5369 | of.nFileExtension = 0; |
| 5370 | switch (filetype) |
| 5371 | { |
| 5372 | case FILETYPE_INPUT_FILES : |
| 5373 | of.lpstrDefExt = TEXT("inp"); |
| 5374 | break; |
| 5375 | case FILETYPE_SAVESTATE_FILES : |
| 5376 | of.lpstrDefExt = TEXT("sta"); |
| 5377 | break; |
| 5378 | case FILETYPE_WAVE_FILES : |
| 5379 | of.lpstrDefExt = TEXT("wav"); |
| 5380 | break; |
| 5381 | case FILETYPE_MNG_FILES : |
| 5382 | of.lpstrDefExt = TEXT("mng"); |
| 5383 | break; |
| 5384 | case FILETYPE_EFFECT_FILES : |
| 5385 | of.lpstrDefExt = TEXT("png"); |
| 5386 | break; |
| 5387 | } |
| 5388 | of.lCustData = 0; |
| 5389 | of.lpfnHook = NULL; |
| 5390 | of.lpTemplateName = NULL; |
| 5391 | |
| 5392 | success = cfd(&of); |
| 5393 | if (success) |
| 5394 | { |
| 5395 | //dprintf("got filename %s nFileExtension %u\n",filename,of.nFileExtension); |
| 5396 | /*GetDirectory(filename,last_directory,sizeof(last_directory));*/ |
| 5397 | } |
| 5398 | |
| 5399 | if( t_artdir ) |
| 5400 | free(t_artdir); |
| 5401 | if( t_statedir ) |
| 5402 | free(t_statedir); |
| 5403 | |
| 5404 | utf8_filename = utf8_from_tstring(t_filename_buffer); |
| 5405 | if (utf8_filename != NULL) |
| 5406 | { |
| 5407 | snprintf(filename, MAX_PATH, "%s", utf8_filename); |
| 5408 | } |
| 5409 | |
| 5410 | return success; |
| 5411 | } |
| 5412 | |
| 5413 | static BOOL SelectLanguageFile(HWND hWnd, TCHAR* filename) |
| 5414 | { |
| 5415 | OPENFILENAME of; |
| 5416 | |
| 5417 | of.lStructSize = sizeof(of); |
| 5418 | of.hwndOwner = hWnd; |
| 5419 | of.hInstance = NULL; |
| 5420 | of.lpstrFilter = TEXT(MAMENAME " Language files (*.lng)\0*.lng\0"); |
| 5421 | of.lpstrCustomFilter = NULL; |
| 5422 | of.nMaxCustFilter = 0; |
| 5423 | of.nFilterIndex = 1; |
| 5424 | of.lpstrFile = filename; |
| 5425 | of.nMaxFile = MAX_PATH; |
| 5426 | of.lpstrFileTitle = NULL; |
| 5427 | of.nMaxFileTitle = 0; |
| 5428 | of.lpstrInitialDir = NULL; |
| 5429 | of.lpstrTitle = NULL; |
| 5430 | of.Flags = OFN_EXPLORER | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST; |
| 5431 | of.nFileOffset = 0; |
| 5432 | of.nFileExtension = 0; |
| 5433 | of.lpstrDefExt = TEXT("lng"); |
| 5434 | of.lCustData = 0; |
| 5435 | of.lpfnHook = NULL; |
| 5436 | of.lpTemplateName = NULL; |
| 5437 | |
| 5438 | return GetOpenFileName(&of); |
| 5439 | } |
| 5440 | |
| 5441 | static INT_PTR CALLBACK LanguageDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) |
| 5442 | { |
| 5443 | TCHAR pLangFile[MAX_PATH]; |
| 5444 | DWORD dwHelpIDs[] = { IDC_LANGUAGECHECK, HIDC_LANGUAGECHECK, |
| 5445 | IDC_LANGUAGEEDIT, HIDC_LANGUAGEEDIT, |
| 5446 | 0, 0}; |
| 5447 | char* utf8_LangFile; |
| 5448 | |
| 5449 | switch (Msg) |
| 5450 | { |
| 5451 | case WM_INITDIALOG: |
| 5452 | { |
| 5453 | const char* pLang = GetLanguage(); |
| 5454 | if (pLang == NULL || *pLang == '\0') |
| 5455 | { |
| 5456 | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_LANGUAGEEDIT), ""); |
| 5457 | Button_SetCheck(GetDlgItem(hDlg, IDC_LANGUAGECHECK), FALSE); |
| 5458 | EnableWindow(GetDlgItem(hDlg, IDC_LANGUAGEEDIT), FALSE); |
| 5459 | EnableWindow(GetDlgItem(hDlg, IDC_LANGUAGEBROWSE), FALSE); |
| 5460 | } |
| 5461 | else |
| 5462 | { |
| 5463 | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_LANGUAGEEDIT), pLang); |
| 5464 | Button_SetCheck(GetDlgItem(hDlg, IDC_LANGUAGECHECK), TRUE); |
| 5465 | EnableWindow(GetDlgItem(hDlg, IDC_LANGUAGEEDIT), TRUE); |
| 5466 | EnableWindow(GetDlgItem(hDlg, IDC_LANGUAGEBROWSE), TRUE); |
| 5467 | } |
| 5468 | |
| 5469 | return TRUE; |
| 5470 | } |
| 5471 | |
| 5472 | case WM_HELP: |
| 5473 | HelpFunction(((LPHELPINFO)lParam)->hItemHandle, MAME32CONTEXTHELP, HH_TP_HELP_WM_HELP, (DWORD)dwHelpIDs); |
| 5474 | break; |
| 5475 | |
| 5476 | case WM_CONTEXTMENU: |
| 5477 | HelpFunction((HWND)wParam, MAME32CONTEXTHELP, HH_TP_HELP_CONTEXTMENU, (DWORD)dwHelpIDs); |
| 5478 | break; |
| 5479 | |
| 5480 | case WM_COMMAND: |
| 5481 | switch (GET_WM_COMMAND_ID(wParam, lParam)) |
| 5482 | { |
| 5483 | case IDOK: |
| 5484 | Edit_GetText(GetDlgItem(hDlg, IDC_LANGUAGEEDIT), pLangFile, MAX_PATH); |
| 5485 | utf8_LangFile = utf8_from_tstring(pLangFile); |
| 5486 | if( !utf8_LangFile ) |
| 5487 | return FALSE; |
| 5488 | SetLanguage(utf8_LangFile); |
| 5489 | free(utf8_LangFile); |
| 5490 | |
| 5491 | case IDCANCEL: |
| 5492 | EndDialog(hDlg, 0); |
| 5493 | return TRUE; |
| 5494 | |
| 5495 | case IDC_LANGUAGECHECK: |
| 5496 | { |
| 5497 | BOOL bCheck = Button_GetCheck(GetDlgItem(hDlg, IDC_LANGUAGECHECK)); |
| 5498 | EnableWindow(GetDlgItem(hDlg, IDC_LANGUAGEEDIT), bCheck); |
| 5499 | EnableWindow(GetDlgItem(hDlg, IDC_LANGUAGEBROWSE), bCheck); |
| 5500 | if (bCheck == FALSE) |
| 5501 | Edit_SetText(GetDlgItem(hDlg, IDC_LANGUAGEEDIT), TEXT("")); |
| 5502 | return TRUE; |
| 5503 | } |
| 5504 | |
| 5505 | case IDC_LANGUAGEBROWSE: |
| 5506 | Edit_GetText(GetDlgItem(hDlg, IDC_LANGUAGEEDIT), pLangFile, MAX_PATH); |
| 5507 | if (SelectLanguageFile(hDlg, pLangFile) == TRUE) |
| 5508 | Edit_SetText(GetDlgItem(hDlg, IDC_LANGUAGEEDIT), pLangFile); |
| 5509 | break; |
| 5510 | } |
| 5511 | break; |
| 5512 | } |
| 5513 | return 0; |
| 5514 | } |
| 5515 | |
| 5516 | void SetStatusBarText(int part_index, const char *message) |
| 5517 | { |
| 5518 | TCHAR* t_message = tstring_from_utf8(message); |
| 5519 | if( !t_message ) |
| 5520 | return; |
| 5521 | SendMessage(hStatusBar, SB_SETTEXT, (WPARAM) part_index, (LPARAM)(LPCTSTR) win_tstring_strdup(t_message)); |
| 5522 | free(t_message); |
| 5523 | } |
| 5524 | |
| 5525 | void SetStatusBarTextF(int part_index, const char *fmt, ...) |
| 5526 | { |
| 5527 | char buf[256]; |
| 5528 | va_list va; |
| 5529 | |
| 5530 | va_start(va, fmt); |
| 5531 | vsprintf(buf, fmt, va); |
| 5532 | va_end(va); |
| 5533 | |
| 5534 | SetStatusBarText(part_index, buf); |
| 5535 | } |
| 5536 | |
| 5537 | static void CLIB_DECL MameMessageBox(const char *fmt, ...) |
| 5538 | { |
| 5539 | char buf[2048]; |
| 5540 | va_list va; |
| 5541 | |
| 5542 | va_start(va, fmt); |
| 5543 | vsprintf(buf, fmt, va); |
| 5544 | win_message_box_utf8(GetMainWindow(), buf, MAME32NAME, MB_OK | MB_ICONERROR); |
| 5545 | va_end(va); |
| 5546 | } |
| 5547 | |
| 5548 | static void MamePlayBackGame() |
| 5549 | { |
| 5550 | int nGame; |
| 5551 | char filename[MAX_PATH]; |
| 5552 | |
| 5553 | *filename = 0; |
| 5554 | |
| 5555 | nGame = Picker_GetSelectedItem(hwndList); |
| 5556 | if (nGame != -1) |
| 5557 | strcpy(filename, drivers[nGame]->name); |
| 5558 | |
| 5559 | if (CommonFileDialog(GetOpenFileName, filename, FILETYPE_INPUT_FILES)) |
| 5560 | { |
| 5561 | file_error fileerr; |
| 5562 | mame_file* pPlayBack; |
| 5563 | char drive[_MAX_DRIVE]; |
| 5564 | char dir[_MAX_DIR]; |
| 5565 | char bare_fname[_MAX_FNAME]; |
| 5566 | char ext[_MAX_EXT]; |
| 5567 | |
| 5568 | char path[MAX_PATH]; |
| 5569 | char fname[MAX_PATH]; |
| 5570 | play_options playopts; |
| 5571 | |
| 5572 | _splitpath(filename, drive, dir, bare_fname, ext); |
| 5573 | |
| 5574 | sprintf(path,"%s%s",drive,dir); |
| 5575 | sprintf(fname,"%s%s",bare_fname,ext); |
| 5576 | if (path[strlen(path)-1] == '\\') |
| 5577 | path[strlen(path)-1] = 0; // take off trailing back slash |
| 5578 | |
| 5579 | fileerr = mame_fopen_options(Mame32Global(), SEARCHPATH_INPUTLOG, fname, OPEN_FLAG_READ, &pPlayBack); |
| 5580 | if (fileerr != FILERR_NONE) |
| 5581 | { |
| 5582 | MameMessageBox("Could not open '%s' as a valid input file.", filename); |
| 5583 | return; |
| 5584 | } |
| 5585 | |
| 5586 | // check for game name embedded in .inp header |
| 5587 | if (pPlayBack) |
| 5588 | { |
| 5589 | inp_header input_header; |
| 5590 | |
| 5591 | // read playback header |
| 5592 | mame_fread(pPlayBack, &input_header, sizeof(inp_header)); |
| 5593 | |
| 5594 | if (!isalnum(input_header.name[0])) // If first byte is not alpha-numeric |
| 5595 | mame_fseek(pPlayBack, 0, SEEK_SET); // old .inp file - no header |
| 5596 | else |
| 5597 | { |
| 5598 | int i; |
| 5599 | for (i = 0; drivers[i] != 0; i++) // find game and play it |
| 5600 | { |
| 5601 | if (strcmp(drivers[i]->name, input_header.name) == 0) |
| 5602 | { |
| 5603 | nGame = i; |
| 5604 | break; |
| 5605 | } |
| 5606 | } |
| 5607 | } |
| 5608 | } |
| 5609 | mame_fclose(pPlayBack); |
| 5610 | |
| 5611 | memset(&playopts, 0, sizeof(playopts)); |
| 5612 | playopts.playback = fname; |
| 5613 | MamePlayGameWithOptions(nGame, &playopts); |
| 5614 | } |
| 5615 | } |
| 5616 | |
| 5617 | static void MameLoadState() |
| 5618 | { |
| 5619 | int nGame; |
| 5620 | char filename[MAX_PATH]; |
| 5621 | char selected_filename[MAX_PATH]; |
| 5622 | play_options playopts; |
| 5623 | |
| 5624 | *filename = 0; |
| 5625 | |
| 5626 | nGame = Picker_GetSelectedItem(hwndList); |
| 5627 | if (nGame != -1) |
| 5628 | { |
| 5629 | strcpy(filename, drivers[nGame]->name); |
| 5630 | strcpy(selected_filename, drivers[nGame]->name); |
| 5631 | } |
| 5632 | if (CommonFileDialog(GetOpenFileName, filename, FILETYPE_SAVESTATE_FILES)) |
| 5633 | { |
| 5634 | mame_file* pSaveState; |
| 5635 | char drive[_MAX_DRIVE]; |
| 5636 | char dir[_MAX_DIR]; |
| 5637 | char ext[_MAX_EXT]; |
| 5638 | |
| 5639 | char path[MAX_PATH]; |
| 5640 | char fname[MAX_PATH]; |
| 5641 | char bare_fname[_MAX_FNAME]; |
| 5642 | char *state_fname; |
| 5643 | int rc; |
| 5644 | |
| 5645 | _splitpath(filename, drive, dir, bare_fname, ext); |
| 5646 | |
| 5647 | // parse path |
| 5648 | sprintf(path,"%s%s",drive,dir); |
| 5649 | sprintf(fname,"%s%s",bare_fname,ext); |
| 5650 | if (path[strlen(path)-1] == '\\') |
| 5651 | path[strlen(path)-1] = 0; // take off trailing back slash |
| 5652 | |
| 5653 | #ifdef MESS |
| 5654 | { |
| 5655 | state_fname = filename; |
| 5656 | } |
| 5657 | #else // !MESS |
| 5658 | { |
| 5659 | char *cPos=0; |
| 5660 | int iPos=0; |
| 5661 | char romname[MAX_PATH]; |
| 5662 | |
| 5663 | cPos = strchr(bare_fname, '-' ); |
| 5664 | iPos = cPos ? cPos - bare_fname : strlen(bare_fname); |
| 5665 | strncpy(romname, bare_fname, iPos ); |
| 5666 | romname[iPos] = '\0'; |
| 5667 | if( strcmp(selected_filename,romname) != 0 ) |
| 5668 | { |
| 5669 | MameMessageBox("'%s' is not a valid savestate file for game '%s'.", filename, selected_filename); |
| 5670 | return; |
| 5671 | } |
| 5672 | state_fname = fname; |
| 5673 | } |
| 5674 | #endif // MESS |
| 5675 | |
| 5676 | mame_fopen_options(Mame32Global(), SEARCHPATH_STATE, state_fname, OPEN_FLAG_READ, &pSaveState); |
| 5677 | if (pSaveState == NULL) |
| 5678 | { |
| 5679 | MameMessageBox("Could not open '%s' as a valid savestate file.", filename); |
| 5680 | return; |
| 5681 | } |
| 5682 | |
| 5683 | // call the MAME core function to check the save state file |
| 5684 | rc = state_save_check_file(pSaveState, selected_filename, TRUE, MameMessageBox); |
| 5685 | mame_fclose(pSaveState); |
| 5686 | if (rc) |
| 5687 | return; |
| 5688 | |
| 5689 | memset(&playopts, 0, sizeof(playopts)); |
| 5690 | #ifdef MESS |
| 5691 | playopts.state = state_fname; |
| 5692 | #else |
| 5693 | { |
| 5694 | char *cPos; |
| 5695 | cPos = strrchr(bare_fname, '-' ); |
| 5696 | cPos = cPos+1; |
| 5697 | if( strlen(cPos) >0) |
| 5698 | { |
| 5699 | playopts.state = cPos; |
| 5700 | } |
| 5701 | } |
| 5702 | #endif |
| 5703 | |
| 5704 | MamePlayGameWithOptions(nGame, &playopts); |
| 5705 | } |
| 5706 | } |
| 5707 | |
| 5708 | static void MamePlayRecordGame() |
| 5709 | { |
| 5710 | int nGame; |
| 5711 | char filename[MAX_PATH]; |
| 5712 | *filename = 0; |
| 5713 | |
| 5714 | nGame = Picker_GetSelectedItem(hwndList); |
| 5715 | strcpy(filename, drivers[nGame]->name); |
| 5716 | |
| 5717 | if (CommonFileDialog(GetSaveFileName, filename, FILETYPE_INPUT_FILES)) |
| 5718 | { |
| 5719 | char drive[_MAX_DRIVE]; |
| 5720 | char dir[_MAX_DIR]; |
| 5721 | char fname[_MAX_FNAME]; |
| 5722 | char ext[_MAX_EXT]; |
| 5723 | char path[MAX_PATH]; |
| 5724 | play_options playopts; |
| 5725 | |
| 5726 | _splitpath(filename, drive, dir, fname, ext); |
| 5727 | |
| 5728 | sprintf(path,"%s%s",drive,dir); |
| 5729 | if (path[strlen(path)-1] == '\\') |
| 5730 | path[strlen(path)-1] = 0; // take off trailing back slash |
| 5731 | |
| 5732 | memset(&playopts, 0, sizeof(playopts)); |
| 5733 | playopts.record = fname; |
| 5734 | MamePlayGameWithOptions(nGame, &playopts); |
| 5735 | } |
| 5736 | } |
| 5737 | |
| 5738 | void MamePlayGame(void) |
| 5739 | { |
| 5740 | int nGame; |
| 5741 | play_options playopts; |
| 5742 | |
| 5743 | nGame = Picker_GetSelectedItem(hwndList); |
| 5744 | |
| 5745 | memset(&playopts, 0, sizeof(playopts)); |
| 5746 | MamePlayGameWithOptions(nGame, &playopts); |
| 5747 | } |
| 5748 | |
| 5749 | static void MamePlayRecordWave() |
| 5750 | { |
| 5751 | int nGame; |
| 5752 | char filename[MAX_PATH]; |
| 5753 | play_options playopts; |
| 5754 | |
| 5755 | nGame = Picker_GetSelectedItem(hwndList); |
| 5756 | strcpy(filename, drivers[nGame]->name); |
| 5757 | |
| 5758 | if (CommonFileDialog(GetSaveFileName, filename, FILETYPE_WAVE_FILES)) |
| 5759 | { |
| 5760 | memset(&playopts, 0, sizeof(playopts)); |
| 5761 | playopts.wavwrite = filename; |
| 5762 | MamePlayGameWithOptions(nGame, &playopts); |
| 5763 | } |
| 5764 | } |
| 5765 | |
| 5766 | static void MamePlayRecordMNG() |
| 5767 | { |
| 5768 | int nGame; |
| 5769 | char filename[MAX_PATH] = { 0, }; |
| 5770 | play_options playopts; |
| 5771 | |
| 5772 | nGame = Picker_GetSelectedItem(hwndList); |
| 5773 | strcpy(filename, drivers[nGame]->name); |
| 5774 | |
| 5775 | if (CommonFileDialog(GetSaveFileName, filename, FILETYPE_MNG_FILES)) |
| 5776 | { |
| 5777 | memset(&playopts, 0, sizeof(playopts)); |
| 5778 | playopts.mngwrite = filename; |
| 5779 | MamePlayGameWithOptions(nGame, &playopts); |
| 5780 | } |
| 5781 | } |
| 5782 | |
| 5783 | static void MamePlayGameWithOptions(int nGame, const play_options *playopts) |
| 5784 | { |
| 5785 | DWORD dwExitCode; |
| 5786 | |
| 5787 | #ifdef MESS |
| 5788 | if (!MessApproveImageList(hMain, nGame)) |
| 5789 | return; |
| 5790 | #endif |
| 5791 | |
| 5792 | if (g_pJoyGUI != NULL) |
| 5793 | KillTimer(hMain, JOYGUI_TIMER); |
| 5794 | if (GetCycleScreenshot() > 0) |
| 5795 | KillTimer(hMain, SCREENSHOT_TIMER); |
| 5796 | |
| 5797 | in_emulation = TRUE; |
| 5798 | |
| 5799 | dwExitCode = RunMAME(nGame, playopts); |
| 5800 | if (dwExitCode == 0) |
| 5801 | { |
| 5802 | IncrementPlayCount(nGame); |
| 5803 | ListView_RedrawItems(hwndList, GetSelectedPick(), GetSelectedPick()); |
| 5804 | } |
| 5805 | else |
| 5806 | { |
| 5807 | ShowWindow(hMain, SW_SHOW); |
| 5808 | } |
| 5809 | |
| 5810 | in_emulation = FALSE; |
| 5811 | |
| 5812 | // re-sort if sorting on # of times played |
| 5813 | if (GetSortColumn() == COLUMN_PLAYED) |
| 5814 | Picker_Sort(hwndList); |
| 5815 | |
| 5816 | UpdateStatusBar(); |
| 5817 | |
| 5818 | ShowWindow(hMain, SW_SHOW); |
| 5819 | SetFocus(hwndList); |
| 5820 | |
| 5821 | if (g_pJoyGUI != NULL) |
| 5822 | SetTimer(hMain, JOYGUI_TIMER, JOYGUI_MS, NULL); |
| 5823 | if (GetCycleScreenshot() > 0) |
| 5824 | SetTimer(hMain, SCREENSHOT_TIMER, GetCycleScreenshot()*1000, NULL); //scale to seconds |
| 5825 | } |
| 5826 | |
| 5827 | /* Toggle ScreenShot ON/OFF */ |
| 5828 | static void ToggleScreenShot(void) |
| 5829 | { |
| 5830 | BOOL showScreenShot = GetShowScreenShot(); |
| 5831 | |
| 5832 | SetShowScreenShot((showScreenShot) ? FALSE : TRUE); |
| 5833 | UpdateScreenShot(); |
| 5834 | |
| 5835 | /* Redraw list view */ |
| 5836 | if (hBackground != NULL && showScreenShot) |
| 5837 | InvalidateRect(hwndList, NULL, FALSE); |
| 5838 | } |
| 5839 | |
| 5840 | static void AdjustMetrics(void) |
| 5841 | { |
| 5842 | HDC hDC; |
| 5843 | TEXTMETRIC tm; |
| 5844 | int xtraX, xtraY; |
| 5845 | AREA area; |
| 5846 | int offX, offY; |
| 5847 | int maxX, maxY; |
| 5848 | COLORREF textColor; |
| 5849 | TCHAR szClass[128]; |
| 5850 | HWND hWnd; |
| 5851 | |
| 5852 | /* WM_SETTINGCHANGE also */ |
| 5853 | xtraX = GetSystemMetrics(SM_CXFIXEDFRAME); /* Dialog frame width */ |
| 5854 | xtraY = GetSystemMetrics(SM_CYFIXEDFRAME); /* Dialog frame height */ |
| 5855 | xtraY += GetSystemMetrics(SM_CYMENUSIZE); /* Menu height */ |
| 5856 | xtraY += GetSystemMetrics(SM_CYCAPTION); /* Caption Height */ |
| 5857 | maxX = GetSystemMetrics(SM_CXSCREEN); /* Screen Width */ |
| 5858 | maxY = GetSystemMetrics(SM_CYSCREEN); /* Screen Height */ |
| 5859 | |
| 5860 | hDC = GetDC(hMain); |
| 5861 | GetTextMetrics (hDC, &tm); |
| 5862 | |
| 5863 | /* Convert MIN Width/Height from Dialog Box Units to pixels. */ |
| 5864 | MIN_WIDTH = (int)((tm.tmAveCharWidth / 4.0) * DBU_MIN_WIDTH) + xtraX; |
| 5865 | MIN_HEIGHT = (int)((tm.tmHeight / 8.0) * DBU_MIN_HEIGHT) + xtraY; |
| 5866 | ReleaseDC(hMain, hDC); |
| 5867 | |
| 5868 | if ((textColor = GetListFontColor()) == RGB(255, 255, 255)) |
| 5869 | textColor = RGB(240, 240, 240); |
| 5870 | |
| 5871 | hWnd = GetWindow(hMain, GW_CHILD); |
| 5872 | while(hWnd) |
| 5873 | { |
| 5874 | if (GetClassName(hWnd, szClass, sizeof(szClass) / sizeof(szClass[0]))) |
| 5875 | { |
| 5876 | if (!_tcscmp(szClass, TEXT("SysListView32"))) |
| 5877 | { |
| 5878 | ListView_SetBkColor(hWnd, GetSysColor(COLOR_WINDOW)); |
| 5879 | ListView_SetTextColor(hWnd, textColor); |
| 5880 | } |
| 5881 | else if (!_tcscmp(szClass, TEXT("SysTreeView32"))) |
| 5882 | { |
| 5883 | TreeView_SetBkColor(hTreeView, GetSysColor(COLOR_WINDOW)); |
| 5884 | TreeView_SetTextColor(hTreeView, textColor); |
| 5885 | } |
| 5886 | } |
| 5887 | hWnd = GetWindow(hWnd, GW_HWNDNEXT); |
| 5888 | } |
| 5889 | |
| 5890 | GetWindowArea(&area); |
| 5891 | |
| 5892 | offX = area.x + area.width; |
| 5893 | offY = area.y + area.height; |
| 5894 | |
| 5895 | if (offX > maxX) |
| 5896 | { |
| 5897 | offX = maxX; |
| 5898 | area.x = (offX - area.width > 0) ? (offX - area.width) : 0; |
| 5899 | } |
| 5900 | if (offY > maxY) |
| 5901 | { |
| 5902 | offY = maxY; |
| 5903 | area.y = (offY - area.height > 0) ? (offY - area.height) : 0; |
| 5904 | } |
| 5905 | |
| 5906 | SetWindowArea(&area); |
| 5907 | SetWindowPos(hMain, 0, area.x, area.y, area.width, area.height, SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE); |
| 5908 | } |
| 5909 | |
| 5910 | |
| 5911 | /* Adjust options - tune them to the currently selected game */ |
| 5912 | static void EnablePlayOptions(int nIndex, core_options *o) |
| 5913 | { |
| 5914 | } |
| 5915 | |
| 5916 | int FindIconIndex(int nIconResource) |
| 5917 | { |
| 5918 | int i; |
| 5919 | for(i = 0; g_iconData[i].icon_name; i++) |
| 5920 | { |
| 5921 | if (g_iconData[i].resource == nIconResource) |
| 5922 | return i; |
| 5923 | } |
| 5924 | return -1; |
| 5925 | } |
| 5926 | |
| 5927 | int FindIconIndexByName(const char *icon_name) |
| 5928 | { |
| 5929 | int i; |
| 5930 | for (i = 0; g_iconData[i].icon_name; i++) |
| 5931 | { |
| 5932 | if (!strcmp(g_iconData[i].icon_name, icon_name)) |
| 5933 | return i; |
| 5934 | } |
| 5935 | return -1; |
| 5936 | } |
| 5937 | |
| 5938 | static int GetIconForDriver(int nItem) |
| 5939 | { |
| 5940 | int iconRoms = 1; |
| 5941 | |
| 5942 | if (DriverUsesRoms(nItem)) |
| 5943 | { |
| 5944 | int audit_result = GetRomAuditResults(nItem); |
| 5945 | if (IsAuditResultKnown(audit_result) == FALSE) |
| 5946 | return 2; |
| 5947 | #ifdef SHOW_MISSING_ROMS_ICON |
| 5948 | if (IsAuditResultYes(audit_result)) |
| 5949 | iconRoms = 1; |
| 5950 | else |
| 5951 | iconRoms = 0; |
| 5952 | #endif |
| 5953 | } |
| 5954 | |
| 5955 | // iconRoms is now either 0 (no roms), 1 (roms), or 2 (unknown) |
| 5956 | |
| 5957 | /* these are indices into icon_names, which maps into our image list |
| 5958 | * also must match IDI_WIN_NOROMS + iconRoms |
| 5959 | */ |
| 5960 | |
| 5961 | // Show Red-X if the ROMs are present and flagged as NOT WORKING |
| 5962 | if (iconRoms == 1 && DriverIsBroken(nItem)) |
| 5963 | iconRoms = FindIconIndex(IDI_WIN_REDX); |
| 5964 | |
| 5965 | // show clone icon if we have roms and game is working |
| 5966 | if (iconRoms == 1 && DriverIsClone(nItem)) |
| 5967 | iconRoms = FindIconIndex(IDI_WIN_CLONE); |
| 5968 | |
| 5969 | // if we have the roms, then look for a custom per-game icon to override |
| 5970 | if (iconRoms == 1 || iconRoms == 3) |
| 5971 | { |
| 5972 | if (icon_index[nItem] == 0) |
| 5973 | AddDriverIcon(nItem,iconRoms); |
| 5974 | iconRoms = icon_index[nItem]; |
| 5975 | } |
| 5976 | |
| 5977 | return iconRoms; |
| 5978 | } |
| 5979 | |
| 5980 | static BOOL HandleTreeContextMenu(HWND hWnd, WPARAM wParam, LPARAM lParam) |
| 5981 | { |
| 5982 | HMENU hTreeMenu; |
| 5983 | HMENU hMenu; |
| 5984 | TVHITTESTINFO hti; |
| 5985 | POINT pt; |
| 5986 | |
| 5987 | if ((HWND)wParam != GetDlgItem(hWnd, IDC_TREE)) |
| 5988 | return FALSE; |
| 5989 | |
| 5990 | pt.x = GET_X_LPARAM(lParam); |
| 5991 | pt.y = GET_Y_LPARAM(lParam); |
| 5992 | if (pt.x < 0 && pt.y < 0) |
| 5993 | GetCursorPos(&pt); |
| 5994 | |
| 5995 | /* select the item that was right clicked or shift-F10'ed */ |
| 5996 | hti.pt = pt; |
| 5997 | ScreenToClient(hTreeView,&hti.pt); |
| 5998 | (void)TreeView_HitTest(hTreeView,&hti); |
| 5999 | if ((hti.flags & TVHT_ONITEM) != 0) |
| 6000 | TreeView_SelectItem(hTreeView,hti.hItem); |
| 6001 | |
| 6002 | hTreeMenu = LoadMenu(hInst,MAKEINTRESOURCE(IDR_CONTEXT_TREE)); |
| 6003 | |
| 6004 | InitTreeContextMenu(hTreeMenu); |
| 6005 | |
| 6006 | hMenu = GetSubMenu(hTreeMenu, 0); |
| 6007 | |
| 6008 | UpdateMenu(hMenu); |
| 6009 | |
| 6010 | TrackPopupMenu(hMenu,TPM_LEFTALIGN | TPM_RIGHTBUTTON,pt.x,pt.y,0,hWnd,NULL); |
| 6011 | |
| 6012 | DestroyMenu(hTreeMenu); |
| 6013 | |
| 6014 | return TRUE; |
| 6015 | } |
| 6016 | |
| 6017 | |
| 6018 | |
| 6019 | static void GamePicker_OnBodyContextMenu(POINT pt) |
| 6020 | { |
| 6021 | HMENU hMenuLoad; |
| 6022 | HMENU hMenu; |
| 6023 | |
| 6024 | hMenuLoad = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT_MENU)); |
| 6025 | hMenu = GetSubMenu(hMenuLoad, 0); |
| 6026 | InitBodyContextMenu(hMenu); |
| 6027 | |
| 6028 | UpdateMenu(hMenu); |
| 6029 | |
| 6030 | TrackPopupMenu(hMenu,TPM_LEFTALIGN | TPM_RIGHTBUTTON,pt.x,pt.y,0,hMain,NULL); |
| 6031 | |
| 6032 | DestroyMenu(hMenuLoad); |
| 6033 | } |
| 6034 | |
| 6035 | |
| 6036 | |
| 6037 | static BOOL HandleScreenShotContextMenu(HWND hWnd, WPARAM wParam, LPARAM lParam) |
| 6038 | { |
| 6039 | HMENU hMenuLoad; |
| 6040 | HMENU hMenu; |
| 6041 | POINT pt; |
| 6042 | |
| 6043 | if ((HWND)wParam != GetDlgItem(hWnd, IDC_SSPICTURE) && (HWND)wParam != GetDlgItem(hWnd, IDC_SSFRAME)) |
| 6044 | return FALSE; |
| 6045 | |
| 6046 | pt.x = GET_X_LPARAM(lParam); |
| 6047 | pt.y = GET_Y_LPARAM(lParam); |
| 6048 | if (pt.x < 0 && pt.y < 0) |
| 6049 | GetCursorPos(&pt); |
| 6050 | |
| 6051 | hMenuLoad = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT_SCREENSHOT)); |
| 6052 | hMenu = GetSubMenu(hMenuLoad, 0); |
| 6053 | |
| 6054 | UpdateMenu(hMenu); |
| 6055 | |
| 6056 | TrackPopupMenu(hMenu,TPM_LEFTALIGN | TPM_RIGHTBUTTON,pt.x,pt.y,0,hWnd,NULL); |
| 6057 | |
| 6058 | DestroyMenu(hMenuLoad); |
| 6059 | |
| 6060 | return TRUE; |
| 6061 | } |
| 6062 | |
| 6063 | static void UpdateMenu(HMENU hMenu) |
| 6064 | { |
| 6065 | TCHAR buf[200]; |
| 6066 | MENUITEMINFO mItem; |
| 6067 | int nGame = Picker_GetSelectedItem(hwndList); |
| 6068 | LPTREEFOLDER lpFolder = GetCurrentFolder(); |
| 6069 | int i; |
| 6070 | const char *pParent; |
| 6071 | TCHAR* t_description; |
| 6072 | |
| 6073 | if (have_selection) |
| 6074 | { |
| 6075 | t_description = tstring_from_utf8(ConvertAmpersandString(ModifyThe(drivers[nGame]->description))); |
| 6076 | if( !t_description ) |
| 6077 | return; |
| 6078 | |
| 6079 | _sntprintf(buf, ARRAY_LENGTH(buf), g_szPlayGameString, t_description); |
| 6080 | |
| 6081 | mItem.cbSize = sizeof(mItem); |
| 6082 | mItem.fMask = MIIM_TYPE; |
| 6083 | mItem.fType = MFT_STRING; |
| 6084 | mItem.dwTypeData = buf; |
| 6085 | mItem.cch = _tcslen(mItem.dwTypeData); |
| 6086 | |
| 6087 | SetMenuItemInfo(hMenu, ID_FILE_PLAY, FALSE, &mItem); |
| 6088 | |
| 6089 | EnableMenuItem(hMenu, ID_CONTEXT_SELECT_RANDOM, MF_ENABLED); |
| 6090 | |
| 6091 | free(t_description); |
| 6092 | } |
| 6093 | else |
| 6094 | { |
| 6095 | EnableMenuItem(hMenu, ID_FILE_PLAY, MF_GRAYED); |
| 6096 | EnableMenuItem(hMenu, ID_FILE_PLAY_RECORD, MF_GRAYED); |
| 6097 | EnableMenuItem(hMenu, ID_GAME_PROPERTIES, MF_GRAYED); |
| 6098 | EnableMenuItem(hMenu, ID_CONTEXT_SELECT_RANDOM, MF_GRAYED); |
| 6099 | } |
| 6100 | |
| 6101 | if (oldControl) |
| 6102 | { |
| 6103 | EnableMenuItem(hMenu, ID_CUSTOMIZE_FIELDS, MF_GRAYED); |
| 6104 | EnableMenuItem(hMenu, ID_GAME_PROPERTIES, MF_GRAYED); |
| 6105 | EnableMenuItem(hMenu, ID_OPTIONS_DEFAULTS, MF_GRAYED); |
| 6106 | } |
| 6107 | |
| 6108 | if (lpFolder->m_dwFlags & F_CUSTOM) |
| 6109 | { |
| 6110 | EnableMenuItem(hMenu,ID_CONTEXT_REMOVE_CUSTOM,MF_ENABLED); |
| 6111 | EnableMenuItem(hMenu,ID_CONTEXT_RENAME_CUSTOM,MF_ENABLED); |
| 6112 | } |
| 6113 | else |
| 6114 | { |
| 6115 | EnableMenuItem(hMenu,ID_CONTEXT_REMOVE_CUSTOM,MF_GRAYED); |
| 6116 | EnableMenuItem(hMenu,ID_CONTEXT_RENAME_CUSTOM,MF_GRAYED); |
| 6117 | } |
| 6118 | pParent = GetFolderNameByID(lpFolder->m_nParent+1); |
| 6119 | |
| 6120 | if (lpFolder->m_dwFlags & F_INIEDIT) |
| 6121 | EnableMenuItem(hMenu,ID_FOLDER_PROPERTIES,MF_ENABLED); |
| 6122 | else |
| 6123 | EnableMenuItem(hMenu,ID_FOLDER_PROPERTIES,MF_GRAYED); |
| 6124 | |
| 6125 | CheckMenuRadioItem(hMenu, ID_VIEW_TAB_SCREENSHOT, ID_VIEW_TAB_HISTORY, |
| 6126 | ID_VIEW_TAB_SCREENSHOT + TabView_GetCurrentTab(hTabCtrl), MF_BYCOMMAND); |
| 6127 | |
| 6128 | // set whether we're showing the tab control or not |
| 6129 | if (bShowTabCtrl) |
| 6130 | CheckMenuItem(hMenu,ID_VIEW_PAGETAB,MF_BYCOMMAND | MF_CHECKED); |
| 6131 | else |
| 6132 | CheckMenuItem(hMenu,ID_VIEW_PAGETAB,MF_BYCOMMAND | MF_UNCHECKED); |
| 6133 | |
| 6134 | |
| 6135 | for (i=0;i<MAX_TAB_TYPES;i++) |
| 6136 | { |
| 6137 | // disable menu items for tabs we're not currently showing |
| 6138 | if (GetShowTab(i)) |
| 6139 | EnableMenuItem(hMenu,ID_VIEW_TAB_SCREENSHOT + i,MF_BYCOMMAND | MF_ENABLED); |
| 6140 | else |
| 6141 | EnableMenuItem(hMenu,ID_VIEW_TAB_SCREENSHOT + i,MF_BYCOMMAND | MF_GRAYED); |
| 6142 | |
| 6143 | // check toggle menu items |
| 6144 | if (GetShowTab(i)) |
| 6145 | CheckMenuItem(hMenu, ID_TOGGLE_TAB_SCREENSHOT + i,MF_BYCOMMAND | MF_CHECKED); |
| 6146 | else |
| 6147 | CheckMenuItem(hMenu, ID_TOGGLE_TAB_SCREENSHOT + i,MF_BYCOMMAND | MF_UNCHECKED); |
| 6148 | } |
| 6149 | |
| 6150 | for (i=0;i<MAX_FOLDERS;i++) |
| 6151 | { |
| 6152 | if (GetShowFolder(i)) |
| 6153 | CheckMenuItem(hMenu,ID_CONTEXT_SHOW_FOLDER_START + i,MF_BYCOMMAND | MF_CHECKED); |
| 6154 | else |
| 6155 | CheckMenuItem(hMenu,ID_CONTEXT_SHOW_FOLDER_START + i,MF_BYCOMMAND | MF_UNCHECKED); |
| 6156 | } |
| 6157 | |
| 6158 | } |
| 6159 | |
| 6160 | void InitTreeContextMenu(HMENU hTreeMenu) |
| 6161 | { |
| 6162 | MENUITEMINFO mii; |
| 6163 | HMENU hMenu; |
| 6164 | int i; |
| 6165 | extern FOLDERDATA g_folderData[]; |
| 6166 | |
| 6167 | ZeroMemory(&mii,sizeof(mii)); |
| 6168 | mii.cbSize = sizeof(mii); |
| 6169 | |
| 6170 | mii.wID = -1; |
| 6171 | mii.fMask = MIIM_SUBMENU | MIIM_ID; |
| 6172 | |
| 6173 | hMenu = GetSubMenu(hTreeMenu, 0); |
| 6174 | |
| 6175 | if (GetMenuItemInfo(hMenu,3,TRUE,&mii) == FALSE) |
| 6176 | { |
| 6177 | dprintf("can't find show folders context menu"); |
| 6178 | return; |
| 6179 | } |
| 6180 | |
| 6181 | if (mii.hSubMenu == NULL) |
| 6182 | { |
| 6183 | dprintf("can't find submenu for show folders context menu"); |
| 6184 | return; |
| 6185 | } |
| 6186 | |
| 6187 | hMenu = mii.hSubMenu; |
| 6188 | |
| 6189 | for (i=0;g_folderData[i].m_lpTitle != NULL;i++) |
| 6190 | { |
| 6191 | TCHAR* t_title = tstring_from_utf8(g_folderData[i].m_lpTitle); |
| 6192 | if( !t_title ) |
| 6193 | return; |
| 6194 | |
| 6195 | mii.fMask = MIIM_TYPE | MIIM_ID; |
| 6196 | mii.fType = MFT_STRING; |
| 6197 | mii.dwTypeData = t_title; |
| 6198 | mii.cch = _tcslen(mii.dwTypeData); |
| 6199 | mii.wID = ID_CONTEXT_SHOW_FOLDER_START + g_folderData[i].m_nFolderId; |
| 6200 | |
| 6201 | |
| 6202 | // menu in resources has one empty item (needed for the submenu to setup properly) |
| 6203 | // so overwrite this one, append after |
| 6204 | if (i == 0) |
| 6205 | SetMenuItemInfo(hMenu,ID_CONTEXT_SHOW_FOLDER_START,FALSE,&mii); |
| 6206 | else |
| 6207 | InsertMenuItem(hMenu,i,FALSE,&mii); |
| 6208 | |
| 6209 | free(t_title); |
| 6210 | } |
| 6211 | |
| 6212 | } |
| 6213 | |
| 6214 | void InitBodyContextMenu(HMENU hBodyContextMenu) |
| 6215 | { |
| 6216 | LPTREEFOLDER lpFolder; |
| 6217 | TCHAR tmp[30]; |
| 6218 | MENUITEMINFO mii; |
| 6219 | ZeroMemory(&mii,sizeof(mii)); |
| 6220 | mii.cbSize = sizeof(mii); |
| 6221 | |
| 6222 | if (GetMenuItemInfo(hBodyContextMenu,ID_FOLDER_SOURCEPROPERTIES,FALSE,&mii) == FALSE) |
| 6223 | { |
| 6224 | dprintf("can't find show folders context menu"); |
| 6225 | return; |
| 6226 | } |
| 6227 | lpFolder = GetFolderByName(FOLDER_SOURCE, GetDriverFilename(Picker_GetSelectedItem(hwndList)) ); |
| 6228 | _sntprintf(tmp,ARRAY_LENGTH(tmp),TEXT("Properties for %s"),lpFolder->m_lptTitle ); |
| 6229 | mii.fMask = MIIM_TYPE | MIIM_ID; |
| 6230 | mii.fType = MFT_STRING; |
| 6231 | mii.dwTypeData = tmp; |
| 6232 | mii.cch = _tcslen(mii.dwTypeData); |
| 6233 | mii.wID = ID_FOLDER_SOURCEPROPERTIES; |
| 6234 | |
| 6235 | |
| 6236 | // menu in resources has one default item |
| 6237 | // so overwrite this one |
| 6238 | SetMenuItemInfo(hBodyContextMenu,ID_FOLDER_SOURCEPROPERTIES,FALSE,&mii); |
| 6239 | if( ! DriverIsVector(Picker_GetSelectedItem(hwndList) ) ) |
| 6240 | EnableMenuItem(hBodyContextMenu, ID_FOLDER_VECTORPROPERTIES, MF_GRAYED); |
| 6241 | } |
| 6242 | |
| 6243 | |
| 6244 | void ToggleShowFolder(int folder) |
| 6245 | { |
| 6246 | int current_id = GetCurrentFolderID(); |
| 6247 | |
| 6248 | SetWindowRedraw(hwndList,FALSE); |
| 6249 | |
| 6250 | SetShowFolder(folder,!GetShowFolder(folder)); |
| 6251 | |
| 6252 | ResetTreeViewFolders(); |
| 6253 | SelectTreeViewFolder(current_id); |
| 6254 | |
| 6255 | SetWindowRedraw(hwndList,TRUE); |
| 6256 | } |
| 6257 | |
| 6258 | static LRESULT CALLBACK HistoryWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 6259 | { |
| 6260 | if (hBackground) |
| 6261 | { |
| 6262 | switch (uMsg) |
| 6263 | { |
| 6264 | case WM_MOUSEMOVE: |
| 6265 | { |
| 6266 | if (MouseHasBeenMoved()) |
| 6267 | ShowCursor(TRUE); |
| 6268 | break; |
| 6269 | } |
| 6270 | |
| 6271 | case WM_ERASEBKGND: |
| 6272 | return TRUE; |
| 6273 | case WM_PAINT: |
| 6274 | { |
| 6275 | POINT p = { 0, 0 }; |
| 6276 | |
| 6277 | /* get base point of background bitmap */ |
| 6278 | MapWindowPoints(hWnd,hTreeView,&p,1); |
| 6279 | PaintBackgroundImage(hWnd, NULL, p.x, p.y); |
| 6280 | /* to ensure our parent procedure repaints the whole client area */ |
| 6281 | InvalidateRect(hWnd, NULL, FALSE); |
| 6282 | break; |
| 6283 | } |
| 6284 | } |
| 6285 | } |
| 6286 | return CallWindowProc(g_lpHistoryWndProc, hWnd, uMsg, wParam, lParam); |
| 6287 | } |
| 6288 | |
| 6289 | static LRESULT CALLBACK PictureFrameWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 6290 | { |
| 6291 | switch (uMsg) |
| 6292 | { |
| 6293 | case WM_MOUSEMOVE: |
| 6294 | { |
| 6295 | if (MouseHasBeenMoved()) |
| 6296 | ShowCursor(TRUE); |
| 6297 | break; |
| 6298 | } |
| 6299 | |
| 6300 | case WM_NCHITTEST : |
| 6301 | { |
| 6302 | POINT pt; |
| 6303 | RECT rect; |
| 6304 | HWND hHistory = GetDlgItem(hMain, IDC_HISTORY); |
| 6305 | |
| 6306 | pt.x = LOWORD(lParam); |
| 6307 | pt.y = HIWORD(lParam); |
| 6308 | GetWindowRect(hHistory, &rect); |
| 6309 | // check if they clicked on the picture area (leave 6 pixel no man's land |
| 6310 | // by the history window to reduce mistaken clicks) |
| 6311 | // no more no man's land, the Cursor changes when Edit control is left, should be enough feedback |
| 6312 | if (have_history && |
| 6313 | ( ( (TabView_GetCurrentTab(hTabCtrl) == TAB_HISTORY) || |
| 6314 | (TabView_GetCurrentTab(hTabCtrl) == GetHistoryTab() && GetShowTab(TAB_HISTORY) == FALSE) || |
| 6315 | (TAB_ALL == GetHistoryTab() && GetShowTab(TAB_HISTORY) == FALSE) ) && |
| 6316 | // (rect.top - 6) < pt.y && pt.y < (rect.bottom + 6) ) ) |
| 6317 | PtInRect( &rect, pt ) ) ) |
| 6318 | |
| 6319 | { |
| 6320 | return HTTRANSPARENT; |
| 6321 | } |
| 6322 | else |
| 6323 | { |
| 6324 | return HTCLIENT; |
| 6325 | } |
| 6326 | } |
| 6327 | break; |
| 6328 | case WM_CONTEXTMENU: |
| 6329 | if ( HandleScreenShotContextMenu(hWnd, wParam, lParam)) |
| 6330 | return FALSE; |
| 6331 | break; |
| 6332 | } |
| 6333 | |
| 6334 | if (hBackground) |
| 6335 | { |
| 6336 | switch (uMsg) |
| 6337 | { |
| 6338 | case WM_ERASEBKGND : |
| 6339 | return TRUE; |
| 6340 | case WM_PAINT : |
| 6341 | { |
| 6342 | RECT rect,nodraw_rect; |
| 6343 | HRGN region,nodraw_region; |
| 6344 | POINT p = { 0, 0 }; |
| 6345 | |
| 6346 | /* get base point of background bitmap */ |
| 6347 | MapWindowPoints(hWnd,hTreeView,&p,1); |
| 6348 | |
| 6349 | /* get big region */ |
| 6350 | GetClientRect(hWnd,&rect); |
| 6351 | region = CreateRectRgnIndirect(&rect); |
| 6352 | |
| 6353 | if (IsWindowVisible(GetDlgItem(hMain,IDC_HISTORY))) |
| 6354 | { |
| 6355 | /* don't draw over this window */ |
| 6356 | GetWindowRect(GetDlgItem(hMain,IDC_HISTORY),&nodraw_rect); |
| 6357 | MapWindowPoints(HWND_DESKTOP,hWnd,(LPPOINT)&nodraw_rect,2); |
| 6358 | nodraw_region = CreateRectRgnIndirect(&nodraw_rect); |
| 6359 | CombineRgn(region,region,nodraw_region,RGN_DIFF); |
| 6360 | DeleteObject(nodraw_region); |
| 6361 | } |
| 6362 | if (IsWindowVisible(GetDlgItem(hMain,IDC_SSPICTURE))) |
| 6363 | { |
| 6364 | /* don't draw over this window */ |
| 6365 | GetWindowRect(GetDlgItem(hMain,IDC_SSPICTURE),&nodraw_rect); |
| 6366 | MapWindowPoints(HWND_DESKTOP,hWnd,(LPPOINT)&nodraw_rect,2); |
| 6367 | nodraw_region = CreateRectRgnIndirect(&nodraw_rect); |
| 6368 | CombineRgn(region,region,nodraw_region,RGN_DIFF); |
| 6369 | DeleteObject(nodraw_region); |
| 6370 | } |
| 6371 | |
| 6372 | PaintBackgroundImage(hWnd,region,p.x,p.y); |
| 6373 | |
| 6374 | DeleteObject(region); |
| 6375 | |
| 6376 | /* to ensure our parent procedure repaints the whole client area */ |
| 6377 | InvalidateRect(hWnd, NULL, FALSE); |
| 6378 | |
| 6379 | break; |
| 6380 | } |
| 6381 | } |
| 6382 | } |
| 6383 | return CallWindowProc(g_lpPictureFrameWndProc, hWnd, uMsg, wParam, lParam); |
| 6384 | } |
| 6385 | |
| 6386 | static LRESULT CALLBACK PictureWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 6387 | { |
| 6388 | switch (uMsg) |
| 6389 | { |
| 6390 | case WM_ERASEBKGND : |
| 6391 | return TRUE; |
| 6392 | case WM_PAINT : |
| 6393 | { |
| 6394 | PAINTSTRUCT ps; |
| 6395 | HDC hdc,hdc_temp; |
| 6396 | RECT rect; |
| 6397 | HBITMAP old_bitmap; |
| 6398 | |
| 6399 | int width,height; |
| 6400 | |
| 6401 | RECT rect2; |
| 6402 | HBRUSH hBrush; |
| 6403 | HBRUSH holdBrush; |
| 6404 | HRGN region1, region2; |
| 6405 | int nBordersize; |
| 6406 | nBordersize = GetScreenshotBorderSize(); |
| 6407 | hBrush = CreateSolidBrush(GetScreenshotBorderColor()); |
| 6408 | |
| 6409 | hdc = BeginPaint(hWnd,&ps); |
| 6410 | |
| 6411 | hdc_temp = CreateCompatibleDC(hdc); |
| 6412 | if (ScreenShotLoaded()) |
| 6413 | { |
| 6414 | width = GetScreenShotWidth(); |
| 6415 | height = GetScreenShotHeight(); |
| 6416 | |
| 6417 | old_bitmap = SelectObject(hdc_temp,GetScreenShotHandle()); |
| 6418 | } |
| 6419 | else |
| 6420 | { |
| 6421 | BITMAP bmp; |
| 6422 | |
| 6423 | GetObject(hMissing_bitmap,sizeof(BITMAP),&bmp); |
| 6424 | width = bmp.bmWidth; |
| 6425 | height = bmp.bmHeight; |
| 6426 | |
| 6427 | old_bitmap = SelectObject(hdc_temp,hMissing_bitmap); |
| 6428 | } |
| 6429 | |
| 6430 | GetClientRect(hWnd,&rect); |
| 6431 | |
| 6432 | rect2 = rect; |
| 6433 | //Configurable Borders around images |
| 6434 | rect.bottom -= nBordersize; |
| 6435 | if( rect.bottom < 0) |
| 6436 | rect.bottom = rect2.bottom; |
| 6437 | rect.right -= nBordersize; |
| 6438 | if( rect.right < 0) |
| 6439 | rect.right = rect2.right; |
| 6440 | rect.top += nBordersize; |
| 6441 | if( rect.top > rect.bottom ) |
| 6442 | rect.top = rect2.top; |
| 6443 | rect.left += nBordersize; |
| 6444 | if( rect.left > rect.right ) |
| 6445 | rect.left = rect2.left; |
| 6446 | region1 = CreateRectRgnIndirect(&rect); |
| 6447 | region2 = CreateRectRgnIndirect(&rect2); |
| 6448 | CombineRgn(region2,region2,region1,RGN_DIFF); |
| 6449 | holdBrush = SelectObject(hdc, hBrush); |
| 6450 | |
| 6451 | FillRgn(hdc,region2, hBrush ); |
| 6452 | SelectObject(hdc, holdBrush); |
| 6453 | DeleteObject(hBrush); |
| 6454 | |
| 6455 | SetStretchBltMode(hdc,STRETCH_HALFTONE); |
| 6456 | StretchBlt(hdc,nBordersize,nBordersize,rect.right-rect.left,rect.bottom-rect.top, |
| 6457 | hdc_temp,0,0,width,height,SRCCOPY); |
| 6458 | SelectObject(hdc_temp,old_bitmap); |
| 6459 | DeleteDC(hdc_temp); |
| 6460 | |
| 6461 | EndPaint(hWnd,&ps); |
| 6462 | |
| 6463 | return TRUE; |
| 6464 | } |
| 6465 | } |
| 6466 | |
| 6467 | return CallWindowProc(g_lpPictureWndProc, hWnd, uMsg, wParam, lParam); |
| 6468 | } |
| 6469 | |
| 6470 | void RemoveCurrentGameCustomFolder(void) |
| 6471 | { |
| 6472 | RemoveGameCustomFolder(Picker_GetSelectedItem(hwndList)); |
| 6473 | } |
| 6474 | |
| 6475 | void RemoveGameCustomFolder(int driver_index) |
| 6476 | { |
| 6477 | int i; |
| 6478 | TREEFOLDER **folders; |
| 6479 | int num_folders; |
| 6480 | |
| 6481 | GetFolders(&folders,&num_folders); |
| 6482 | |
| 6483 | for (i=0;i<num_folders;i++) |
| 6484 | { |
| 6485 | if (folders[i]->m_dwFlags & F_CUSTOM && folders[i]->m_nFolderId == GetCurrentFolderID()) |
| 6486 | { |
| 6487 | int current_pick_index; |
| 6488 | |
| 6489 | RemoveFromCustomFolder(folders[i],driver_index); |
| 6490 | |
| 6491 | if (driver_index == Picker_GetSelectedItem(hwndList)) |
| 6492 | { |
| 6493 | /* if we just removed the current game, |
| 6494 | move the current selection so that when we rebuild the listview it |
| 6495 | leaves the cursor on next or previous one */ |
| 6496 | |
| 6497 | current_pick_index = GetSelectedPick(); |
| 6498 | Picker_SetSelectedPick(hwndList, GetSelectedPick() + 1); |
| 6499 | if (current_pick_index == GetSelectedPick()) /* we must have deleted the last item */ |
| 6500 | Picker_SetSelectedPick(hwndList, GetSelectedPick() - 1); |
| 6501 | } |
| 6502 | |
| 6503 | ResetListView(); |
| 6504 | return; |
| 6505 | } |
| 6506 | } |
| 6507 | MessageBox(GetMainWindow(), TEXT("Error searching for custom folder"), TEXT(MAME32NAME), MB_OK | MB_ICONERROR); |
| 6508 | |
| 6509 | } |
| 6510 | |
| 6511 | |
| 6512 | void BeginListViewDrag(NM_LISTVIEW *pnmv) |
| 6513 | { |
| 6514 | LV_ITEM lvi; |
| 6515 | POINT pt; |
| 6516 | |
| 6517 | lvi.iItem = pnmv->iItem; |
| 6518 | lvi.mask = LVIF_PARAM; |
| 6519 | ListView_GetItem(hwndList, &lvi); |
| 6520 | |
| 6521 | game_dragged = lvi.lParam; |
| 6522 | |
| 6523 | pt.x = 0; |
| 6524 | pt.y = 0; |
| 6525 | |
| 6526 | /* Tell the list view control to create an image to use |
| 6527 | for dragging. */ |
| 6528 | himl_drag = ListView_CreateDragImage(hwndList,pnmv->iItem,&pt); |
| 6529 | |
| 6530 | /* Start the drag operation. */ |
| 6531 | ImageList_BeginDrag(himl_drag, 0, 0, 0); |
| 6532 | |
| 6533 | pt = pnmv->ptAction; |
| 6534 | ClientToScreen(hwndList,&pt); |
| 6535 | ImageList_DragEnter(GetDesktopWindow(),pt.x,pt.y); |
| 6536 | |
| 6537 | /* Hide the mouse cursor, and direct mouse input to the |
| 6538 | parent window. */ |
| 6539 | SetCapture(hMain); |
| 6540 | |
| 6541 | prev_drag_drop_target = NULL; |
| 6542 | |
| 6543 | g_listview_dragging = TRUE; |
| 6544 | |
| 6545 | } |
| 6546 | |
| 6547 | void MouseMoveListViewDrag(POINTS p) |
| 6548 | { |
| 6549 | HTREEITEM htiTarget; |
| 6550 | TV_HITTESTINFO tvht; |
| 6551 | |
| 6552 | POINT pt; |
| 6553 | pt.x = p.x; |
| 6554 | pt.y = p.y; |
| 6555 | |
| 6556 | ClientToScreen(hMain,&pt); |
| 6557 | |
| 6558 | ImageList_DragMove(pt.x,pt.y); |
| 6559 | |
| 6560 | MapWindowPoints(GetDesktopWindow(),hTreeView,&pt,1); |
| 6561 | |
| 6562 | tvht.pt = pt; |
| 6563 | htiTarget = TreeView_HitTest(hTreeView,&tvht); |
| 6564 | |
| 6565 | if (htiTarget != prev_drag_drop_target) |
| 6566 | { |
| 6567 | ImageList_DragShowNolock(FALSE); |
| 6568 | if (htiTarget != NULL) |
| 6569 | TreeView_SelectDropTarget(hTreeView,htiTarget); |
| 6570 | else |
| 6571 | TreeView_SelectDropTarget(hTreeView,NULL); |
| 6572 | ImageList_DragShowNolock(TRUE); |
| 6573 | |
| 6574 | prev_drag_drop_target = htiTarget; |
| 6575 | } |
| 6576 | } |
| 6577 | |
| 6578 | void ButtonUpListViewDrag(POINTS p) |
| 6579 | { |
| 6580 | POINT pt; |
| 6581 | HTREEITEM htiTarget; |
| 6582 | TV_HITTESTINFO tvht; |
| 6583 | TVITEM tvi; |
| 6584 | |
| 6585 | ReleaseCapture(); |
| 6586 | |
| 6587 | ImageList_DragLeave(hwndList); |
| 6588 | ImageList_EndDrag(); |
| 6589 | ImageList_Destroy(himl_drag); |
| 6590 | |
| 6591 | TreeView_SelectDropTarget(hTreeView,NULL); |
| 6592 | |
| 6593 | g_listview_dragging = FALSE; |
| 6594 | |
| 6595 | /* see where the game was dragged */ |
| 6596 | |
| 6597 | pt.x = p.x; |
| 6598 | pt.y = p.y; |
| 6599 | |
| 6600 | MapWindowPoints(hMain,hTreeView,&pt,1); |
| 6601 | |
| 6602 | tvht.pt = pt; |
| 6603 | htiTarget = TreeView_HitTest(hTreeView,&tvht); |
| 6604 | if (htiTarget == NULL) |
| 6605 | { |
| 6606 | LVHITTESTINFO lvhtti; |
| 6607 | LPTREEFOLDER folder; |
| 6608 | RECT rcList; |
| 6609 | |
| 6610 | /* the user dragged a game onto something other than the treeview */ |
| 6611 | /* try to remove if we're in a custom folder */ |
| 6612 | |
| 6613 | /* see if it was dragged within the list view; if so, ignore */ |
| 6614 | |
| 6615 | MapWindowPoints(hTreeView,hwndList,&pt,1); |
| 6616 | lvhtti.pt = pt; |
| 6617 | GetWindowRect(hwndList, &rcList); |
| 6618 | ClientToScreen(hwndList, &pt); |
| 6619 | if( PtInRect(&rcList, pt) != 0 ) |
| 6620 | return; |
| 6621 | |
| 6622 | folder = GetCurrentFolder(); |
| 6623 | if (folder->m_dwFlags & F_CUSTOM) |
| 6624 | { |
| 6625 | /* dragged out of a custom folder, so let's remove it */ |
| 6626 | RemoveCurrentGameCustomFolder(); |
| 6627 | } |
| 6628 | return; |
| 6629 | } |
| 6630 | |
| 6631 | |
| 6632 | tvi.lParam = 0; |
| 6633 | tvi.mask = TVIF_PARAM | TVIF_HANDLE; |
| 6634 | tvi.hItem = htiTarget; |
| 6635 | |
| 6636 | if (TreeView_GetItem(hTreeView, &tvi)) |
| 6637 | { |
| 6638 | LPTREEFOLDER folder = (LPTREEFOLDER)tvi.lParam; |
| 6639 | AddToCustomFolder(folder,game_dragged); |
| 6640 | } |
| 6641 | |
| 6642 | } |
| 6643 | |
| 6644 | static LPTREEFOLDER GetSelectedFolder(void) |
| 6645 | { |
| 6646 | HTREEITEM htree; |
| 6647 | TVITEM tvi; |
| 6648 | htree = TreeView_GetSelection(hTreeView); |
| 6649 | if(htree != NULL) |
| 6650 | { |
| 6651 | tvi.hItem = htree; |
| 6652 | tvi.mask = TVIF_PARAM; |
| 6653 | TreeView_GetItem(hTreeView,&tvi); |
| 6654 | return (LPTREEFOLDER)tvi.lParam; |
| 6655 | } |
| 6656 | return NULL; |
| 6657 | } |
| 6658 | |
| 6659 | static HICON GetSelectedFolderIcon(void) |
| 6660 | { |
| 6661 | HTREEITEM htree; |
| 6662 | TVITEM tvi; |
| 6663 | HIMAGELIST hSmall_icon; |
| 6664 | LPTREEFOLDER folder; |
| 6665 | htree = TreeView_GetSelection(hTreeView); |
| 6666 | |
| 6667 | if (htree != NULL) |
| 6668 | { |
| 6669 | tvi.hItem = htree; |
| 6670 | tvi.mask = TVIF_PARAM; |
| 6671 | TreeView_GetItem(hTreeView,&tvi); |
| 6672 | |
| 6673 | folder = (LPTREEFOLDER)tvi.lParam; |
| 6674 | //hSmall_icon = TreeView_GetImageList(hTreeView,(int)tvi.iImage); |
| 6675 | hSmall_icon = NULL; |
| 6676 | return ImageList_GetIcon(hSmall_icon, tvi.iImage, ILD_TRANSPARENT); |
| 6677 | } |
| 6678 | return NULL; |
| 6679 | } |
| 6680 | |
| 6681 | /* Updates all currently displayed Items in the List with the latest Data*/ |
| 6682 | void UpdateListView(void) |
| 6683 | { |
| 6684 | if( (GetViewMode() == VIEW_GROUPED) || (GetViewMode() == VIEW_DETAILS ) ) |
| 6685 | ListView_RedrawItems(hwndList,ListView_GetTopIndex(hwndList), |
| 6686 | ListView_GetTopIndex(hwndList)+ ListView_GetCountPerPage(hwndList) ); |
| 6687 | } |
| 6688 | |
| 6689 | void CalculateBestScreenShotRect(HWND hWnd, RECT *pRect, BOOL restrict_height) |
| 6690 | { |
| 6691 | int destX, destY; |
| 6692 | int destW, destH; |
| 6693 | int nBorder; |
| 6694 | RECT rect; |
| 6695 | /* for scaling */ |
| 6696 | int x, y; |
| 6697 | int rWidth, rHeight; |
| 6698 | double scale; |
| 6699 | BOOL bReduce = FALSE; |
| 6700 | |
| 6701 | GetClientRect(hWnd, &rect); |
| 6702 | |
| 6703 | // Scale the bitmap to the frame specified by the passed in hwnd |
| 6704 | if (ScreenShotLoaded()) |
| 6705 | { |
| 6706 | x = GetScreenShotWidth(); |
| 6707 | y = GetScreenShotHeight(); |
| 6708 | } |
| 6709 | else |
| 6710 | { |
| 6711 | BITMAP bmp; |
| 6712 | GetObject(hMissing_bitmap,sizeof(BITMAP),&bmp); |
| 6713 | |
| 6714 | x = bmp.bmWidth; |
| 6715 | y = bmp.bmHeight; |
| 6716 | } |
| 6717 | rWidth = (rect.right - rect.left); |
| 6718 | rHeight = (rect.bottom - rect.top); |
| 6719 | |
| 6720 | /* Limit the screen shot to max height of 264 */ |
| 6721 | if (restrict_height == TRUE && rHeight > 264) |
| 6722 | { |
| 6723 | rect.bottom = rect.top + 264; |
| 6724 | rHeight = 264; |
| 6725 | } |
| 6726 | |
| 6727 | /* If the bitmap does NOT fit in the screenshot area */ |
| 6728 | if (x > rWidth - 10 || y > rHeight - 10) |
| 6729 | { |
| 6730 | rect.right -= 10; |
| 6731 | rect.bottom -= 10; |
| 6732 | rWidth -= 10; |
| 6733 | rHeight -= 10; |
| 6734 | bReduce = TRUE; |
| 6735 | /* Try to scale it properly */ |
| 6736 | /* assumes square pixels, doesn't consider aspect ratio */ |
| 6737 | if (x > y) |
| 6738 | scale = (double)rWidth / x; |
| 6739 | else |
| 6740 | scale = (double)rHeight / y; |
| 6741 | |
| 6742 | destW = (int)(x * scale); |
| 6743 | destH = (int)(y * scale); |
| 6744 | |
| 6745 | /* If it's still too big, scale again */ |
| 6746 | if (destW > rWidth || destH > rHeight) |
| 6747 | { |
| 6748 | if (destW > rWidth) |
| 6749 | scale = (double)rWidth / destW; |
| 6750 | else |
| 6751 | scale = (double)rHeight / destH; |
| 6752 | |
| 6753 | destW = (int)(destW * scale); |
| 6754 | destH = (int)(destH * scale); |
| 6755 | } |
| 6756 | } |
| 6757 | else |
| 6758 | { |
| 6759 | if (GetStretchScreenShotLarger()) |
| 6760 | { |
| 6761 | rect.right -= 10; |
| 6762 | rect.bottom -= 10; |
| 6763 | rWidth -= 10; |
| 6764 | rHeight -= 10; |
| 6765 | bReduce = TRUE; |
| 6766 | // Try to scale it properly |
| 6767 | // assumes square pixels, doesn't consider aspect ratio |
| 6768 | if (x < y) |
| 6769 | scale = (double)rWidth / x; |
| 6770 | else |
| 6771 | scale = (double)rHeight / y; |
| 6772 | |
| 6773 | destW = (int)(x * scale); |
| 6774 | destH = (int)(y * scale); |
| 6775 | |
| 6776 | // If it's too big, scale again |
| 6777 | if (destW > rWidth || destH > rHeight) |
| 6778 | { |
| 6779 | if (destW > rWidth) |
| 6780 | scale = (double)rWidth / destW; |
| 6781 | else |
| 6782 | scale = (double)rHeight / destH; |
| 6783 | |
| 6784 | destW = (int)(destW * scale); |
| 6785 | destH = (int)(destH * scale); |
| 6786 | } |
| 6787 | } |
| 6788 | else |
| 6789 | { |
| 6790 | // Use the bitmaps size if it fits |
| 6791 | destW = x; |
| 6792 | destH = y; |
| 6793 | } |
| 6794 | |
| 6795 | } |
| 6796 | |
| 6797 | |
| 6798 | destX = ((rWidth - destW) / 2); |
| 6799 | destY = ((rHeight - destH) / 2); |
| 6800 | |
| 6801 | if (bReduce) |
| 6802 | { |
| 6803 | destX += 5; |
| 6804 | destY += 5; |
| 6805 | } |
| 6806 | nBorder = GetScreenshotBorderSize(); |
| 6807 | if( destX > nBorder+1) |
| 6808 | pRect->left = destX - nBorder; |
| 6809 | else |
| 6810 | pRect->left = 2; |
| 6811 | if( destY > nBorder+1) |
| 6812 | pRect->top = destY - nBorder; |
| 6813 | else |
| 6814 | pRect->top = 2; |
| 6815 | if( rWidth >= destX + destW + nBorder) |
| 6816 | pRect->right = destX + destW + nBorder; |
| 6817 | else |
| 6818 | pRect->right = rWidth - pRect->left; |
| 6819 | if( rHeight >= destY + destH + nBorder) |
| 6820 | pRect->bottom = destY + destH + nBorder; |
| 6821 | else |
| 6822 | pRect->bottom = rHeight - pRect->top; |
| 6823 | } |
| 6824 | |
| 6825 | /* |
| 6826 | Switches to either fullscreen or normal mode, based on the |
| 6827 | current mode. |
| 6828 | |
| 6829 | POSSIBLE BUGS: |
| 6830 | Removing the menu might cause problems later if some |
| 6831 | function tries to poll info stored in the menu. Don't |
| 6832 | know if you've done that, but this was the only way I |
| 6833 | knew to remove the menu dynamically. |
| 6834 | */ |
| 6835 | |
| 6836 | void SwitchFullScreenMode(void) |
| 6837 | { |
| 6838 | LONG lMainStyle; |
| 6839 | |
| 6840 | if (GetRunFullScreen()) |
| 6841 | { |
| 6842 | // Return to normal |
| 6843 | |
| 6844 | // Restore the menu |
| 6845 | SetMenu(hMain, LoadMenu(hInst,MAKEINTRESOURCE(IDR_UI_MENU))); |
| 6846 | |
| 6847 | // Refresh the checkmarks |
| 6848 | CheckMenuItem(GetMenu(hMain), ID_VIEW_FOLDERS, GetShowFolderList() ? MF_CHECKED : MF_UNCHECKED); |
| 6849 | CheckMenuItem(GetMenu(hMain), ID_VIEW_TOOLBARS, GetShowToolBar() ? MF_CHECKED : MF_UNCHECKED); |
| 6850 | CheckMenuItem(GetMenu(hMain), ID_VIEW_STATUS, GetShowStatusBar() ? MF_CHECKED : MF_UNCHECKED); |
| 6851 | CheckMenuItem(GetMenu(hMain), ID_VIEW_PAGETAB, GetShowTabCtrl() ? MF_CHECKED : MF_UNCHECKED); |
| 6852 | |
| 6853 | // Add frame to dialog again |
| 6854 | lMainStyle = GetWindowLong(hMain, GWL_STYLE); |
| 6855 | lMainStyle = lMainStyle | WS_BORDER; |
| 6856 | SetWindowLong(hMain, GWL_STYLE, lMainStyle); |
| 6857 | |
| 6858 | // Show the window maximized |
| 6859 | if( GetWindowState() == SW_MAXIMIZE ) |
| 6860 | { |
| 6861 | ShowWindow(hMain, SW_NORMAL); |
| 6862 | ShowWindow(hMain, SW_MAXIMIZE); |
| 6863 | } |
| 6864 | else |
| 6865 | ShowWindow(hMain, SW_RESTORE); |
| 6866 | |
| 6867 | SetRunFullScreen(FALSE); |
| 6868 | } |
| 6869 | else |
| 6870 | { |
| 6871 | // Set to fullscreen |
| 6872 | |
| 6873 | // Remove menu |
| 6874 | SetMenu(hMain,NULL); |
| 6875 | |
| 6876 | // Frameless dialog (fake fullscreen) |
| 6877 | lMainStyle = GetWindowLong(hMain, GWL_STYLE); |
| 6878 | lMainStyle = lMainStyle & (WS_BORDER ^ 0xffffffff); |
| 6879 | SetWindowLong(hMain, GWL_STYLE, lMainStyle); |
| 6880 | if( IsMaximized(hMain) ) |
| 6881 | { |
| 6882 | ShowWindow(hMain, SW_NORMAL); |
| 6883 | SetWindowState( SW_MAXIMIZE ); |
| 6884 | } |
| 6885 | ShowWindow(hMain, SW_MAXIMIZE); |
| 6886 | |
| 6887 | SetRunFullScreen(TRUE); |
| 6888 | } |
| 6889 | } |
| 6890 | |
| 6891 | /* |
| 6892 | Checks to see if the mouse has been moved since this func |
| 6893 | was first called (which is at startup). The reason for |
| 6894 | storing the startup coordinates of the mouse is that when |
| 6895 | a window is created it generates WM_MOUSEOVER events, even |
| 6896 | though the user didn't actually move the mouse. So we need |
| 6897 | to know when the WM_MOUSEOVER event is user-triggered. |
| 6898 | |
| 6899 | POSSIBLE BUGS: |
| 6900 | Gets polled at every WM_MOUSEMOVE so it might cause lag, |
| 6901 | but there's probably another way to code this that's |
| 6902 | way better? |
| 6903 | |
| 6904 | */ |
| 6905 | |
| 6906 | BOOL MouseHasBeenMoved(void) |
| 6907 | { |
| 6908 | static int mouse_x = -1; |
| 6909 | static int mouse_y = -1; |
| 6910 | POINT p; |
| 6911 | |
| 6912 | GetCursorPos(&p); |
| 6913 | |
| 6914 | if (mouse_x == -1) // First time |
| 6915 | { |
| 6916 | mouse_x = p.x; |
| 6917 | mouse_y = p.y; |
| 6918 | } |
| 6919 | |
| 6920 | return (p.x != mouse_x || p.y != mouse_y); |
| 6921 | } |
| 6922 | |
| 6923 | /* End of source file */ |
src/osd/winui/mame32.rc
| r0 | r996 | |
| 1 | // Microsoft Visual C++ generated resource script. |
| 2 | // |
| 3 | #include "resource.h" |
| 4 | |
| 5 | #ifdef MESS |
| 6 | #include "resourcems.h" |
| 7 | #endif |
| 8 | |
| 9 | // Generated Help ID header file |
| 10 | #define APSTUDIO_HIDDEN_SYMBOLS |
| 11 | #include "resource.hm" |
| 12 | #undef APSTUDIO_HIDDEN_SYMBOLS |
| 13 | |
| 14 | #define APSTUDIO_READONLY_SYMBOLS |
| 15 | ///////////////////////////////////////////////////////////////////////////// |
| 16 | // |
| 17 | // Generated from the TEXTINCLUDE 2 resource. |
| 18 | // |
| 19 | #define NOWINRES |
| 20 | #include "windows.h" |
| 21 | #include "commctrl.h" |
| 22 | |
| 23 | ///////////////////////////////////////////////////////////////////////////// |
| 24 | #undef APSTUDIO_READONLY_SYMBOLS |
| 25 | |
| 26 | ///////////////////////////////////////////////////////////////////////////// |
| 27 | // English (U.S.) resources |
| 28 | |
| 29 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) |
| 30 | #ifdef _WIN32 |
| 31 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US |
| 32 | #pragma code_page(1252) |
| 33 | #endif //_WIN32 |
| 34 | |
| 35 | ///////////////////////////////////////////////////////////////////////////// |
| 36 | // |
| 37 | // Menu |
| 38 | // |
| 39 | |
| 40 | IDR_MAIN_MENU MENU |
| 41 | BEGIN |
| 42 | POPUP "&File" |
| 43 | BEGIN |
| 44 | MENUITEM "&Exit", ID_FILE_EXIT |
| 45 | END |
| 46 | POPUP "&Help" |
| 47 | BEGIN |
| 48 | #ifdef MESS |
| 49 | MENUITEM "&About MESS", ID_ABOUT |
| 50 | #else |
| 51 | MENUITEM "&About MAME32", ID_ABOUT |
| 52 | #endif |
| 53 | END |
| 54 | END |
| 55 | |
| 56 | IDR_UI_MENU MENU |
| 57 | BEGIN |
| 58 | POPUP "&File" |
| 59 | BEGIN |
| 60 | MENUITEM "&Play", ID_FILE_PLAY |
| 61 | MENUITEM SEPARATOR |
| 62 | MENUITEM "Play and &Record Input...", ID_FILE_PLAY_RECORD |
| 63 | MENUITEM "P&layback Input...", ID_FILE_PLAY_BACK |
| 64 | MENUITEM SEPARATOR |
| 65 | MENUITEM "Play and Record &Wave Output...", ID_FILE_PLAY_RECORD_WAVE |
| 66 | MENUITEM SEPARATOR |
| 67 | MENUITEM "Play and Record &MNG Output...", ID_FILE_PLAY_RECORD_MNG |
| 68 | MENUITEM SEPARATOR |
| 69 | MENUITEM "Loa&d Savestate...", ID_FILE_LOADSTATE |
| 70 | MENUITEM SEPARATOR |
| 71 | #ifdef MESS |
| 72 | MENUITEM "&Select Random System", ID_CONTEXT_SELECT_RANDOM |
| 73 | MENUITEM SEPARATOR |
| 74 | MENUITEM "Op&en Other Software...", ID_MESS_OPEN_SOFTWARE |
| 75 | MENUITEM "&Create Image...", ID_MESS_CREATE_SOFTWARE |
| 76 | #ifdef MAME_DEBUG |
| 77 | MENUITEM SEPARATOR |
| 78 | MENUITEM "Run Tests", ID_MESS_RUN_TESTS |
| 79 | #endif |
| 80 | #else /* !MESS */ |
| 81 | MENUITEM "&Select Random Game", ID_CONTEXT_SELECT_RANDOM |
| 82 | #endif /* MESS */ |
| 83 | MENUITEM SEPARATOR |
| 84 | MENUITEM "Pr&operties", ID_GAME_PROPERTIES |
| 85 | MENUITEM SEPARATOR |
| 86 | #ifdef MESS |
| 87 | MENUITEM "&Audit all systems", ID_FILE_AUDIT |
| 88 | #else |
| 89 | MENUITEM "&Audit all games", ID_FILE_AUDIT |
| 90 | #endif /* MESS */ |
| 91 | MENUITEM SEPARATOR |
| 92 | MENUITEM "E&xit", ID_FILE_EXIT |
| 93 | END |
| 94 | POPUP "&View" |
| 95 | BEGIN |
| 96 | MENUITEM "&Toolbar\tAlt+T", ID_VIEW_TOOLBARS |
| 97 | MENUITEM "&Status bar\tAlt+S", ID_VIEW_STATUS |
| 98 | MENUITEM "Fold&er List\tAlt+D", ID_VIEW_FOLDERS |
| 99 | MENUITEM "&Picture Area\tAlt+P", ID_VIEW_PICTURE_AREA |
| 100 | MENUITEM "Screenshot Ta&b\tAlt+B", ID_VIEW_PAGETAB |
| 101 | MENUITEM SEPARATOR |
| 102 | MENUITEM "&Fullscreen\tF11", ID_VIEW_FULLSCREEN |
| 103 | MENUITEM SEPARATOR |
| 104 | POPUP "S&how Pictures" |
| 105 | BEGIN |
| 106 | MENUITEM "&Snapshot", ID_TOGGLE_TAB_SCREENSHOT |
| 107 | MENUITEM "&Flyer", ID_TOGGLE_TAB_FLYER |
| 108 | MENUITEM "&Cabinet", ID_TOGGLE_TAB_CABINET |
| 109 | MENUITEM "&Marquee", ID_TOGGLE_TAB_MARQUEE |
| 110 | MENUITEM "&Title", ID_TOGGLE_TAB_TITLE |
| 111 | MENUITEM "Control &Panel", ID_TOGGLE_TAB_CONTROL_PANEL |
| 112 | MENUITEM "PC&B", ID_TOGGLE_TAB_PCB |
| 113 | |
| 114 | MENUITEM "&History", ID_TOGGLE_TAB_HISTORY |
| 115 | END |
| 116 | MENUITEM SEPARATOR |
| 117 | MENUITEM "L&arge Icons", ID_VIEW_LARGE_ICON |
| 118 | MENUITEM "S&mall Icons", ID_VIEW_SMALL_ICON |
| 119 | MENUITEM "&List", ID_VIEW_LIST_MENU |
| 120 | MENUITEM "&Details", ID_VIEW_DETAIL |
| 121 | MENUITEM "&Grouped", ID_VIEW_GROUPED |
| 122 | MENUITEM SEPARATOR |
| 123 | POPUP "Arrange &Icons" |
| 124 | BEGIN |
| 125 | MENUITEM "by &Name", ID_VIEW_BYGAME |
| 126 | MENUITEM "by D&irectory", ID_VIEW_BYDIRECTORY |
| 127 | MENUITEM "by &Manufacturer", ID_VIEW_BYMANUFACTURER |
| 128 | MENUITEM "by Times &Played", ID_VIEW_BYTIMESPLAYED |
| 129 | MENUITEM "by &Type", ID_VIEW_BYTYPE |
| 130 | MENUITEM "by &Date", ID_VIEW_BYYEAR |
| 131 | END |
| 132 | MENUITEM "Line &Up Icons", ID_VIEW_LINEUPICONS |
| 133 | MENUITEM SEPARATOR |
| 134 | MENUITEM "&Refresh\tF5", ID_UPDATE_GAMELIST |
| 135 | MENUITEM "&Custom Filters...\tCtrl+F", ID_CONTEXT_FILTERS |
| 136 | MENUITEM "Customi&ze Fields...", ID_CUSTOMIZE_FIELDS |
| 137 | END |
| 138 | POPUP "&Options" |
| 139 | BEGIN |
| 140 | #ifdef MESS |
| 141 | MENUITEM "System List &Font...", ID_OPTIONS_FONT |
| 142 | MENUITEM "System List &Clone Color...", ID_OPTIONS_CLONE_COLOR |
| 143 | MENUITEM "&Directories...", ID_OPTIONS_DIR |
| 144 | MENUITEM "Default System &Options...", ID_OPTIONS_DEFAULTS |
| 145 | #else |
| 146 | MENUITEM "Game List &Font...", ID_OPTIONS_FONT |
| 147 | MENUITEM "Game List &Clone Color...", ID_OPTIONS_CLONE_COLOR |
| 148 | MENUITEM "&Directories...", ID_OPTIONS_DIR |
| 149 | MENUITEM "Default Game &Options...", ID_OPTIONS_DEFAULTS |
| 150 | #endif |
| 151 | MENUITEM "&Reset to Default...", ID_OPTIONS_RESET_DEFAULTS |
| 152 | MENUITEM "&Interface Options...", ID_OPTIONS_INTERFACE |
| 153 | MENUITEM "&Background Image...", ID_OPTIONS_BG |
| 154 | END |
| 155 | POPUP "&Help" |
| 156 | BEGIN |
| 157 | #ifdef MESS |
| 158 | MENUITEM "&Mess Release Notes", ID_HELP_RELEASE |
| 159 | MENUITEM "&New Mess Features", ID_HELP_WHATS_NEW |
| 160 | #else |
| 161 | MENUITEM "&Contents\tF1", ID_HELP_CONTENTS |
| 162 | MENUITEM "&Troubleshooting", ID_HELP_TROUBLE |
| 163 | MENUITEM SEPARATOR |
| 164 | MENUITEM "&New Game Changes", ID_HELP_WHATS_NEW32 |
| 165 | MENUITEM "&Mame Release Notes", ID_HELP_WHATS_NEW |
| 166 | #endif |
| 167 | MENUITEM SEPARATOR |
| 168 | MENUITEM "&About", ID_HELP_ABOUT |
| 169 | END |
| 170 | END |
| 171 | |
| 172 | IDR_CONTEXT_MENU MENU |
| 173 | BEGIN |
| 174 | POPUP "Context Menu" |
| 175 | BEGIN |
| 176 | MENUITEM "&Play", ID_FILE_PLAY |
| 177 | MENUITEM SEPARATOR |
| 178 | MENUITEM "Play and &Record Input...", ID_FILE_PLAY_RECORD |
| 179 | MENUITEM SEPARATOR |
| 180 | MENUITEM "&Add to Custom Folder...", ID_CONTEXT_ADD_CUSTOM |
| 181 | MENUITEM "R&emove From This Folder", ID_CONTEXT_REMOVE_CUSTOM |
| 182 | MENUITEM "&Custom Filters...", ID_CONTEXT_FILTERS |
| 183 | MENUITEM SEPARATOR |
| 184 | #ifdef MESS |
| 185 | MENUITEM "&Select Random System", ID_CONTEXT_SELECT_RANDOM |
| 186 | #else |
| 187 | MENUITEM "&Select Random Game", ID_CONTEXT_SELECT_RANDOM |
| 188 | #endif |
| 189 | MENUITEM SEPARATOR |
| 190 | MENUITEM "Rese&t Playcount", ID_CONTEXT_RESET_PLAYCOUNT |
| 191 | MENUITEM "Reset Pla&y Time", ID_CONTEXT_RESET_PLAYTIME |
| 192 | MENUITEM SEPARATOR |
| 193 | MENUITEM "A&udit", ID_GAME_AUDIT |
| 194 | MENUITEM SEPARATOR |
| 195 | MENUITEM "Pr&operties", ID_GAME_PROPERTIES |
| 196 | MENUITEM "Source propert&ies", ID_FOLDER_SOURCEPROPERTIES |
| 197 | MENUITEM "&Vector properties", ID_FOLDER_VECTORPROPERTIES |
| 198 | END |
| 199 | END |
| 200 | |
| 201 | IDR_CONTEXT_HEADER MENU |
| 202 | BEGIN |
| 203 | POPUP "Header Context Menu" |
| 204 | BEGIN |
| 205 | MENUITEM "Sort &Ascending", ID_SORT_ASCENDING |
| 206 | MENUITEM "Sort &Descending", ID_SORT_DESCENDING |
| 207 | MENUITEM SEPARATOR |
| 208 | MENUITEM "Customi&ze Fields...", ID_CUSTOMIZE_FIELDS |
| 209 | END |
| 210 | END |
| 211 | |
| 212 | IDR_CONTEXT_TREE MENU |
| 213 | BEGIN |
| 214 | POPUP "Context Menu Tree" |
| 215 | BEGIN |
| 216 | MENUITEM "&Rename", ID_CONTEXT_RENAME_CUSTOM |
| 217 | MENUITEM "&Custom Filters...", ID_CONTEXT_FILTERS |
| 218 | MENUITEM SEPARATOR |
| 219 | POPUP "&Show Folders" |
| 220 | BEGIN |
| 221 | MENUITEM "overridden by code", ID_CONTEXT_SHOW_FOLDER_START |
| 222 | |
| 223 | END |
| 224 | MENUITEM SEPARATOR |
| 225 | MENUITEM "&Audit", ID_FOLDER_AUDIT |
| 226 | MENUITEM SEPARATOR |
| 227 | MENUITEM "&Properties", ID_FOLDER_PROPERTIES |
| 228 | END |
| 229 | END |
| 230 | |
| 231 | IDR_CONTEXT_SCREENSHOT MENU |
| 232 | BEGIN |
| 233 | POPUP "Context Screen Shot" |
| 234 | BEGIN |
| 235 | MENUITEM "Show Tab &Control", ID_VIEW_PAGETAB |
| 236 | MENUITEM SEPARATOR |
| 237 | POPUP "S&how Pictures" |
| 238 | BEGIN |
| 239 | MENUITEM "&Snapshot", ID_TOGGLE_TAB_SCREENSHOT |
| 240 | MENUITEM "&Flyer", ID_TOGGLE_TAB_FLYER |
| 241 | MENUITEM "&Cabinet", ID_TOGGLE_TAB_CABINET |
| 242 | MENUITEM "&Marquee", ID_TOGGLE_TAB_MARQUEE |
| 243 | MENUITEM "&Title", ID_TOGGLE_TAB_TITLE |
| 244 | MENUITEM "Control &Panel", ID_TOGGLE_TAB_CONTROL_PANEL |
| 245 | MENUITEM "PC&B", ID_TOGGLE_TAB_PCB |
| 246 | |
| 247 | MENUITEM "&History", ID_TOGGLE_TAB_HISTORY |
| 248 | END |
| 249 | MENUITEM SEPARATOR |
| 250 | MENUITEM "&Snapshot", ID_VIEW_TAB_SCREENSHOT |
| 251 | MENUITEM "&Flyer", ID_VIEW_TAB_FLYER |
| 252 | MENUITEM "&Cabinet", ID_VIEW_TAB_CABINET |
| 253 | MENUITEM "&Marquee", ID_VIEW_TAB_MARQUEE |
| 254 | MENUITEM "&Title", ID_VIEW_TAB_TITLE |
| 255 | MENUITEM "Control &Panel", ID_VIEW_TAB_CONTROL_PANEL |
| 256 | MENUITEM "PC&B", ID_VIEW_TAB_PCB |
| 257 | MENUITEM "&History", ID_VIEW_TAB_HISTORY |
| 258 | END |
| 259 | END |
| 260 | |
| 261 | |
| 262 | #ifdef APSTUDIO_INVOKED |
| 263 | ///////////////////////////////////////////////////////////////////////////// |
| 264 | // |
| 265 | // TEXTINCLUDE |
| 266 | // |
| 267 | |
| 268 | 1 TEXTINCLUDE |
| 269 | BEGIN |
| 270 | "resource.h\0" |
| 271 | END |
| 272 | |
| 273 | 2 TEXTINCLUDE |
| 274 | BEGIN |
| 275 | "#define NOWINRES\r\n" |
| 276 | "#include ""windows.h""\r\n" |
| 277 | "#include ""commctrl.h""\r\n" |
| 278 | "\0" |
| 279 | END |
| 280 | |
| 281 | 3 TEXTINCLUDE |
| 282 | BEGIN |
| 283 | "#include ""mamevers.rc"" // Version block\r\n" |
| 284 | "\r\n" |
| 285 | "\0" |
| 286 | END |
| 287 | |
| 288 | #endif // APSTUDIO_INVOKED |
| 289 | |
| 290 | |
| 291 | ///////////////////////////////////////////////////////////////////////////// |
| 292 | // |
| 293 | // Icon |
| 294 | // |
| 295 | |
| 296 | // Icon with lowest ID value placed first to ensure application icon |
| 297 | // remains consistent on all systems. |
| 298 | #ifdef MESS |
| 299 | IDI_MAME32_ICON ICON "res/mess.ico" |
| 300 | #else |
| 301 | IDI_MAME32_ICON ICON "res\\mame32.ico" |
| 302 | #endif |
| 303 | IDI_WIN_ROMS ICON "res\\win_roms.ico" |
| 304 | IDI_WIN_NOROMS ICON "res\\win_noro.ico" |
| 305 | IDI_WIN_UNKNOWN ICON "res\\win_unkn.ico" |
| 306 | IDI_WIN_CLONE ICON "res\\win_clone.ico" |
| 307 | IDI_WIN_REDX ICON "res\\win_redx.ico" |
| 308 | IDI_FOLDER_AVAILABLE ICON "res\\foldavail.ico" |
| 309 | IDI_FOLDER ICON "res\\folder.ico" |
| 310 | IDI_FOLDER_MANUFACTURER ICON "res\\foldmanu.ico" |
| 311 | IDI_FOLDER_OPEN ICON "res\\foldopen.ico" |
| 312 | IDI_FOLDER_UNAVAILABLE ICON "res\\foldunav.ico" |
| 313 | IDI_FOLDER_HORIZONTAL ICON "res\\horz.ico" |
| 314 | IDI_FOLDER_VERTICAL ICON "res\\vert.ico" |
| 315 | IDI_MANUFACTURER ICON "res\\manufact.ico" |
| 316 | IDI_FOLDER_YEAR ICON "res\\foldyear.ico" |
| 317 | IDI_FOLDER_SOURCE ICON "res\\foldsrc.ico" |
| 318 | IDI_WORKING ICON "res\\working.ico" |
| 319 | IDI_NONWORKING ICON "res\\nonwork.ico" |
| 320 | IDI_YEAR ICON "res\\year.ico" |
| 321 | IDI_KEYBOARD ICON "res\\keyboard.ico" |
| 322 | IDI_JOYSTICK ICON "res\\joystick.ico" |
| 323 | IDI_CPU ICON "res\\cpu.ico" |
| 324 | IDI_SOUND ICON "res\\samples.ico" |
| 325 | IDI_SOUNDTAB ICON "res\\sound.ico" |
| 326 | IDI_SOURCE ICON "res\\source.ico" |
| 327 | IDI_HARDDISK ICON "res\\harddisk.ico" |
| 328 | IDI_DISPLAY ICON "res\\display.ico" |
| 329 | IDI_CHECKMARK ICON "res\\checkmark.ico" |
| 330 | IDI_HEADER_UP ICON "res\\header_up.ico" |
| 331 | IDI_HEADER_DOWN ICON "res\\header_down.ico" |
| 332 | |
| 333 | #ifdef MESS |
| 334 | IDI_WIN_NOROMSNEEDED ICON "res/win_nrnd.ico" |
| 335 | IDI_WIN_MISSINGOPTROM ICON "res/win_noor.ico" |
| 336 | IDI_WIN_FLOP ICON "res/win_flop.ico" |
| 337 | IDI_WIN_CASS ICON "res/win_cass.ico" |
| 338 | IDI_WIN_SERL ICON "res/win_serl.ico" |
| 339 | IDI_WIN_SNAP ICON "res/win_snap.ico" |
| 340 | IDI_WIN_PRIN ICON "res/win_prin.ico" |
| 341 | IDI_WIN_HARD ICON "res/win_hard.ico" |
| 342 | IDI_WIN_CYLN ICON "res/win_cyln.ico" |
| 343 | IDI_WIN_PTAP ICON "res/win_ptap.ico" |
| 344 | IDI_WIN_PCRD ICON "res/win_pcrd.ico" |
| 345 | |
| 346 | #endif |
| 347 | |
| 348 | ///////////////////////////////////////////////////////////////////////////// |
| 349 | // |
| 350 | // Dialog |
| 351 | // |
| 352 | |
| 353 | IDD_ABOUT DIALOG 0, 0, 296, 129 |
| 354 | STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU |
| 355 | #ifdef MESS |
| 356 | CAPTION "About MESS" |
| 357 | #else |
| 358 | CAPTION "About MAME32" |
| 359 | #endif |
| 360 | FONT 8, "MS Shell Dlg" |
| 361 | BEGIN |
| 362 | DEFPUSHBUTTON "&OK",IDOK,200,109,50,14,WS_GROUP |
| 363 | #ifdef MESS |
| 364 | CTEXT "Multi Emulator Super System",IDC_STATIC,147,7,142, |
| 365 | 11,NOT WS_GROUP |
| 366 | CTEXT "Version 0",IDC_VERSION,147,18,142,11,NOT WS_GROUP |
| 367 | CTEXT "Copyright (C) 1998-2005 The MESS Team",IDC_STATIC,147, |
| 368 | 29,142,10,NOT WS_GROUP |
| 369 | CTEXT "MESS GUI based on MAME32 version by",IDC_STATIC,147,51,142,10,NOT |
| 370 | WS_GROUP |
| 371 | CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,147,44,142,1 |
| 372 | CTEXT "Additional MAME32 code by",IDC_STATIC,147,74,142,9 |
| 373 | CTEXT "Robert Schlabbach, Dan Miller (Help file)",IDC_STATIC, |
| 374 | 147,96,142,9 |
| 375 | CTEXT "Michael Soderstrom and Christopher Kirmse",IDC_STATIC, |
| 376 | 147,62,142,9,NOT WS_GROUP |
| 377 | CTEXT "Mike Haaland, Andrew Kirmse, Jeff Miller",IDC_STATIC, |
| 378 | 147,85,142,9 |
| 379 | #else |
| 380 | CTEXT "Multiple Arcade Machine Emulator",IDC_STATIC,147,7,142, |
| 381 | 11,NOT WS_GROUP |
| 382 | CTEXT "Version 0",IDC_VERSION,147,18,142,11,NOT WS_GROUP |
| 383 | CTEXT "Copyright (C) 1997-2007 The MAME Team",IDC_STATIC,147, |
| 384 | 29,142,10,NOT WS_GROUP |
| 385 | CTEXT "MAME32 version by",IDC_STATIC,147,51,142,10,NOT |
| 386 | WS_GROUP |
| 387 | CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,147,44,142,1 |
| 388 | CTEXT "Additional MAME32 code by",IDC_STATIC,147,74,142,9 |
| 389 | CTEXT "Christopher Kirmse and Michael Soderstrom",IDC_STATIC, |
| 390 | 147,62,142,9,NOT WS_GROUP |
| 391 | CTEXT "Mike Haaland, Andrew Kirmse, Jeff Miller",IDC_STATIC, |
| 392 | 147,85,142,9 |
| 393 | CTEXT "and John Hardy IV",IDC_STATIC,147,96,142,9 |
| 394 | #endif |
| 395 | CONTROL "",IDC_ABOUT,"Static",SS_BITMAP | SS_SUNKEN,7,7,16,14 |
| 396 | END |
| 397 | |
| 398 | IDD_DIRECTX DIALOG 0, 0, 236, 69 |
| 399 | STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU |
| 400 | #ifdef MESS |
| 401 | CAPTION "MESS" |
| 402 | #else |
| 403 | CAPTION "MAME32" |
| 404 | #endif |
| 405 | FONT 8, "MS Shell Dlg" |
| 406 | BEGIN |
| 407 | DEFPUSHBUTTON "Go to Microsoft's DirectX Web Page",IDB_WEB_PAGE,48,52, |
| 408 | 140,14 |
| 409 | EDITTEXT IDC_DIRECTX_HELP,7,0,222,48,ES_MULTILINE | |
| 410 | ES_AUTOHSCROLL | ES_READONLY |
| 411 | END |
| 412 | |
| 413 | IDD_AUDIT DIALOG 0, 0, 283, 188 |
| 414 | STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU |
| 415 | CAPTION "File Audit" |
| 416 | FONT 8, "MS Shell Dlg" |
| 417 | BEGIN |
| 418 | PUSHBUTTON "&Pause",IDPAUSE,98,168,40,14 |
| 419 | PUSHBUTTON "&Cancel",IDCANCEL,144,168,40,14 |
| 420 | GROUPBOX "ROMs",IDC_STATIC,6,4,132,65 |
| 421 | LTEXT "Correct:",IDC_STATIC,51,28,32,8 |
| 422 | CONTROL "Progress1",IDC_ROMS_PROGRESS,"msctls_progress32", |
| 423 | WS_BORDER | 0x1,14,16,116,8 |
| 424 | LTEXT "Incorrect:",IDC_STATIC,51,42,32,8 |
| 425 | LTEXT "Total:",IDC_STATIC,51,56,32,8 |
| 426 | LTEXT "0",IDC_ROMS_CORRECT,87,28,20,8 |
| 427 | LTEXT "0",IDC_ROMS_INCORRECT,87,42,20,8 |
| 428 | LTEXT "0",IDC_ROMS_TOTAL,87,56,20,8 |
| 429 | GROUPBOX "Samples",IDC_STATIC,145,4,132,65 |
| 430 | CONTROL "Progress1",IDC_SAMPLES_PROGRESS,"msctls_progress32", |
| 431 | WS_BORDER | 0x1,153,16,116,8 |
| 432 | LTEXT "Correct:",IDC_STATIC,191,28,33,8 |
| 433 | LTEXT "Incorrect:",IDC_STATIC,191,42,33,8 |
| 434 | LTEXT "Total:",IDC_STATIC,191,56,33,8 |
| 435 | LTEXT "0",IDC_SAMPLES_CORRECT,227,28,20,8 |
| 436 | LTEXT "0",IDC_SAMPLES_INCORRECT,227,42,20,8 |
| 437 | LTEXT "0",IDC_SAMPLES_TOTAL,227,56,20,8 |
| 438 | GROUPBOX "Details",IDC_STATIC,6,72,271,90 |
| 439 | EDITTEXT IDC_AUDIT_DETAILS,12,82,259,74,ES_MULTILINE | |
| 440 | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_HSCROLL | |
| 441 | NOT WS_TABSTOP |
| 442 | END |
| 443 | |
| 444 | IDD_DIRECTORIES DIALOG 0, 0, 230, 107 |
| 445 | STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU |
| 446 | CAPTION "Directories" |
| 447 | FONT 8, "MS Shell Dlg" |
| 448 | BEGIN |
| 449 | LTEXT "Show directories for:",IDC_STATIC,6,6,67,10 |
| 450 | COMBOBOX IDC_DIR_COMBO,6,18,160,79,CBS_DROPDOWNLIST | CBS_SORT | |
| 451 | WS_VSCROLL | WS_TABSTOP |
| 452 | LTEXT "Directories:",IDC_STATIC,6,38,38,10 |
| 453 | CONTROL "List1",IDC_DIR_LIST,"SysListView32",LVS_REPORT | |
| 454 | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_EDITLABELS | |
| 455 | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | WS_BORDER | |
| 456 | WS_TABSTOP,6,50,160,51 |
| 457 | DEFPUSHBUTTON "OK",IDOK,173,8,50,14 |
| 458 | PUSHBUTTON "Cancel",IDCANCEL,173,26,50,14 |
| 459 | PUSHBUTTON "Browse...",IDC_DIR_BROWSE,173,50,50,14 |
| 460 | PUSHBUTTON "Insert",IDC_DIR_INSERT,173,68,50,14 |
| 461 | PUSHBUTTON "Delete",IDC_DIR_DELETE,173,87,50,14 |
| 462 | END |
| 463 | |
| 464 | IDD_COLUMNS DIALOG 0, 0, 302, 145 |
| 465 | STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU |
| 466 | CAPTION "Customize Fields" |
| 467 | FONT 8, "MS Shell Dlg" |
| 468 | BEGIN |
| 469 | LTEXT "Available fields:",IDC_STATIC,6,6,80,10,SS_CENTERIMAGE |
| 470 | CONTROL "List1",IDC_LISTAVAILABLECOLUMNS,"SysListView32", |
| 471 | LVS_LIST | LVS_SINGLESEL | LVS_NOCOLUMNHEADER | |
| 472 | LVS_NOSORTHEADER | WS_BORDER | WS_HSCROLL | WS_TABSTOP,6, |
| 473 | 18,90,100 |
| 474 | PUSHBUTTON "Add ->",IDC_BUTTONADD,102,18,46,14,WS_DISABLED |
| 475 | PUSHBUTTON "<- Remove",IDC_BUTTONREMOVE,102,36,46,14,WS_DISABLED |
| 476 | LTEXT "Show these fields in this order:",IDC_STATIC,154,6,96, |
| 477 | 10,SS_CENTERIMAGE |
| 478 | CONTROL "List1",IDC_LISTSHOWCOLUMNS,"SysListView32",LVS_LIST | |
| 479 | LVS_SINGLESEL | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | |
| 480 | WS_BORDER | WS_HSCROLL | WS_TABSTOP,154,18,90,100 |
| 481 | PUSHBUTTON "Move Up",IDC_BUTTONMOVEUP,250,18,46,14,WS_DISABLED |
| 482 | PUSHBUTTON "Move Down",IDC_BUTTONMOVEDOWN,250,36,46,14,WS_DISABLED |
| 483 | DEFPUSHBUTTON "OK",IDOK,105,124,44,14 |
| 484 | PUSHBUTTON "Cancel",IDCANCEL,155,124,44,14 |
| 485 | END |
| 486 | |
| 487 | IDD_PROP_CONTROLLER DIALOGEX 0, 0, 220, 240 |
| 488 | STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION |
| 489 | CAPTION "Controller Mapping" |
| 490 | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 491 | BEGIN |
| 492 | ICON IDI_JOYSTICK,IDC_STATIC,20,10,20,20 |
| 493 | LTEXT "Title\nDirectory\nExtra",IDC_PROP_TITLE,52,9,161,25, |
| 494 | SS_NOPREFIX |
| 495 | GROUPBOX "Paddle device",IDC_STATIC,4,40,102,28 |
| 496 | COMBOBOX IDC_PADDLE,10,50,91,62,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 497 | WS_TABSTOP,0,HIDC_PADDLE |
| 498 | GROUPBOX "ADStick device",IDC_STATIC,4,71,102,28 |
| 499 | COMBOBOX IDC_ADSTICK,10,80,91,62,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 500 | WS_TABSTOP,0,HIDC_ADSTICK |
| 501 | GROUPBOX "Pedal device",IDC_STATIC,4,102,102,28 |
| 502 | COMBOBOX IDC_PEDAL,10,112,91,62,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 503 | WS_TABSTOP,0,HIDC_PEDAL |
| 504 | GROUPBOX "Mouse device",IDC_STATIC,4,133,102,28 |
| 505 | COMBOBOX IDC_MOUSE,10,142,90,62,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 506 | WS_TABSTOP,0,HIDC_MOUSE |
| 507 | GROUPBOX "Dial device",IDC_STATIC,113,40,102,28 |
| 508 | COMBOBOX IDC_DIAL,119,50,90,62,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 509 | WS_TABSTOP,0,HIDC_DIAL |
| 510 | GROUPBOX "Trackball device",IDC_STATIC,113,71,102,28 |
| 511 | COMBOBOX IDC_TRACKBALL,119,80,90,62,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 512 | WS_TABSTOP,0,HIDC_TRACKBALL |
| 513 | GROUPBOX "Lightgun device",IDC_STATIC,113,102,102,28 |
| 514 | COMBOBOX IDC_LIGHTGUNDEVICE,119,112,90,62,CBS_DROPDOWNLIST | |
| 515 | WS_VSCROLL | WS_TABSTOP,0,HIDC_LIGHTGUNDEVICE |
| 516 | GROUPBOX "Positional device",IDC_STATIC,113,133,102,28 |
| 517 | COMBOBOX IDC_POSITIONAL,119,142,90,62,CBS_DROPDOWNLIST | |
| 518 | WS_VSCROLL | WS_TABSTOP,0,HIDC_POSITIONAL |
| 519 | PUSHBUTTON "Reset",IDC_PROP_RESET,4,222,97,14,0,0,HIDC_PROP_RESET |
| 520 | PUSHBUTTON "Restore Default Settings",IDC_USE_DEFAULT,118,222,97,14, |
| 521 | 0,0,HIDC_USE_DEFAULT |
| 522 | END |
| 523 | |
| 524 | IDD_PROP_SCREEN DIALOGEX 0, 0, 220, 240 |
| 525 | STYLE DS_SETFONT | WS_CHILD | WS_CAPTION |
| 526 | CAPTION "Screen" |
| 527 | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 528 | BEGIN |
| 529 | ICON IDI_DISPLAY,IDC_STATIC,20,10,21,20 |
| 530 | LTEXT "Title\nDirectory\nExtra",IDC_PROP_TITLE,52,9,161,25, |
| 531 | SS_NOPREFIX |
| 532 | GROUPBOX "Number of screens",IDC_STATIC,4,40,103,24 |
| 533 | CONTROL "GammaSlider",IDC_NUMSCREENS,"msctls_trackbar32", |
| 534 | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,10,50,75,10,0, |
| 535 | HIDC_NUMSCREENS |
| 536 | RTEXT "1",IDC_NUMSCREENSDISP,84,49,14,10,SS_CENTERIMAGE | NOT |
| 537 | WS_GROUP |
| 538 | GROUPBOX "Screen",IDC_STATIC,4,66,103,29 |
| 539 | COMBOBOX IDC_SCREEN,10,76,91,64,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 540 | WS_TABSTOP,0,HIDC_SCREEN |
| 541 | GROUPBOX "",IDC_STATIC,4,97,103,28 |
| 542 | CONTROL "Autoselect aspect",IDC_ASPECT,"Button",BS_AUTOCHECKBOX | |
| 543 | WS_TABSTOP,10,97,73,10,0,HIDC_ASPECT |
| 544 | LTEXT "Aspect ratio",IDC_ASPECTRATIOTEXT,17,108,40,11, |
| 545 | SS_CENTERIMAGE | NOT WS_GROUP |
| 546 | EDITTEXT IDC_ASPECTRATION,60,108,14,12,ES_RIGHT | ES_AUTOHSCROLL | |
| 547 | ES_NUMBER,0,HIDC_ASPECTRATION |
| 548 | LTEXT ":",IDC_STATIC,76,108,8,10,SS_CENTERIMAGE | NOT WS_GROUP |
| 549 | EDITTEXT IDC_ASPECTRATIOD,80,108,14,12,ES_RIGHT | ES_AUTOHSCROLL | |
| 550 | ES_NUMBER,0,HIDC_ASPECTRATIOD |
| 551 | GROUPBOX "View",IDC_STATIC,4,128,103,28 |
| 552 | COMBOBOX IDC_VIEW,10,137,91,64,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 553 | WS_TABSTOP,0,HIDC_VIEW |
| 554 | GROUPBOX "Screennumber",IDC_SCREENSELECTTEXT,113,40,102,28 |
| 555 | COMBOBOX IDC_SCREENSELECT,119,50,90,64,CBS_DROPDOWNLIST | |
| 556 | WS_VSCROLL | WS_TABSTOP,0,HIDC_SCREENSELECT |
| 557 | GROUPBOX "Resolution",IDC_STATIC,113,71,102,76,WS_GROUP |
| 558 | GROUPBOX "Size",IDC_STATIC,119,81,90,28,WS_GROUP |
| 559 | COMBOBOX IDC_SIZES,126,91,77,70,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 560 | WS_TABSTOP,0,HIDC_SIZES |
| 561 | GROUPBOX "Refresh",IDC_REFRESHTEXT,119,112,90,28,WS_GROUP |
| 562 | COMBOBOX IDC_REFRESH,126,121,77,76,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 563 | WS_TABSTOP,0,HIDC_REFRESH |
| 564 | CONTROL "Switch resolutions to fit",IDC_SWITCHRES,"Button", |
| 565 | BS_AUTOCHECKBOX | WS_TABSTOP,119,151,93,10,0, |
| 566 | HIDC_SWITCHRES |
| 567 | PUSHBUTTON "Reset",IDC_PROP_RESET,4,222,97,14,0,0,HIDC_PROP_RESET |
| 568 | PUSHBUTTON "Restore Default Settings",IDC_USE_DEFAULT,118,222,97,14, |
| 569 | 0,0,HIDC_USE_DEFAULT |
| 570 | END |
| 571 | |
| 572 | IDD_PROP_GAME DIALOG 0, 0, 220, 240 |
| 573 | STYLE DS_SETFONT | WS_CHILD | WS_CAPTION |
| 574 | CAPTION "General" |
| 575 | FONT 8, "MS Shell Dlg" |
| 576 | BEGIN |
| 577 | ICON IDI_MAME32_ICON,IDC_GAME_ICON,20,10,20,20 |
| 578 | LTEXT "Title\nDirectory\nExtra",IDC_PROP_TITLE,52,9,161,25, |
| 579 | SS_NOPREFIX |
| 580 | CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,20,38,178,1 |
| 581 | LTEXT "Manufactured:",IDC_STATIC,18,45,47,8 |
| 582 | LTEXT "Static",IDC_PROP_MANUFACTURED,75,45,139,9,SS_NOPREFIX |
| 583 | LTEXT "Status:",IDC_STATIC,18,55,47,8 |
| 584 | LTEXT "Static",IDC_PROP_STATUS,75,55,139,30 |
| 585 | CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,18,85,178,1 |
| 586 | LTEXT "CPU:",IDC_STATIC,18,90,47,8 |
| 587 | LTEXT "Static\nStatic\nStatic\nStatic\nStatic",IDC_PROP_CPU,75, |
| 588 | 90,139,40 |
| 589 | CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,18,130,178,1 |
| 590 | LTEXT "Sound:",IDC_STATIC,18,135,47,8 |
| 591 | LTEXT "Static\nStatic\nStatic\nStatic\nStatic",IDC_PROP_SOUND, |
| 592 | 75,135,139,45 |
| 593 | CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,18,181,178,1 |
| 594 | LTEXT "Screen:",IDC_STATIC,18,188,47,8 |
| 595 | LTEXT "Static",IDC_PROP_SCREEN,75,188,139,8 |
| 596 | LTEXT "Colors:",IDC_STATIC,18,198,47,8 |
| 597 | LTEXT "Static",IDC_PROP_COLORS,75,198,139,8 |
| 598 | LTEXT "Clone of:",IDC_PROP_CLONEOF_TEXT,18,218,50,8 |
| 599 | LTEXT "Static",IDC_PROP_CLONEOF,75,218,130,18 |
| 600 | LTEXT "Source:",IDC_STATIC,18,208,47,8 |
| 601 | LTEXT "Static",IDC_PROP_SOURCE,75,208,139,8 |
| 602 | END |
| 603 | |
| 604 | IDD_PROP_AUDIT DIALOG 0, 0, 220, 240 |
| 605 | STYLE DS_SETFONT | WS_CHILD | WS_CAPTION |
| 606 | CAPTION "Audit" |
| 607 | FONT 8, "MS Shell Dlg" |
| 608 | BEGIN |
| 609 | ICON IDI_CHECKMARK,IDC_STATIC,20,10,20,20 |
| 610 | LTEXT "Title\nDirectory\nExtra",IDC_PROP_TITLE,52,9,161,25, |
| 611 | SS_NOPREFIX |
| 612 | LTEXT "ROM check:",IDC_STATIC,10,40,50,8 |
| 613 | LTEXT "Checking...",IDC_PROP_ROMS,66,40,139,8 |
| 614 | LTEXT "Sample check:",IDC_STATIC,10,52,50,8 |
| 615 | LTEXT "Checking...",IDC_PROP_SAMPLES,66,52,139,8 |
| 616 | GROUPBOX "Details",IDC_STATIC,4,64,211,171 |
| 617 | EDITTEXT IDC_AUDIT_DETAILS_PROP,10,74,199,155,ES_MULTILINE | |
| 618 | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_HSCROLL | |
| 619 | NOT WS_TABSTOP |
| 620 | END |
| 621 | |
| 622 | IDD_PROP_DISPLAY DIALOGEX 0, 0, 220, 240 |
| 623 | STYLE DS_SETFONT | WS_CHILD | WS_CAPTION |
| 624 | CAPTION "Display" |
| 625 | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 626 | BEGIN |
| 627 | ICON IDI_DISPLAY,IDC_STATIC,20,10,20,20 |
| 628 | LTEXT "Title\nDirectory\nExtra",IDC_PROP_TITLE,52,9,169,25, |
| 629 | SS_NOPREFIX |
| 630 | CONTROL "Run in a window",IDC_WINDOWED,"Button",BS_AUTOCHECKBOX | |
| 631 | WS_TABSTOP,10,40,69,10,0,HIDC_WINDOWED |
| 632 | CONTROL "Start out maximized",IDC_MAXIMIZE,"Button", |
| 633 | BS_AUTOCHECKBOX | WS_TABSTOP,10,52,74,10,0,HIDC_MAXIMIZE |
| 634 | CONTROL "Enforce aspect ratio",IDC_KEEPASPECT,"Button", |
| 635 | BS_AUTOCHECKBOX | WS_TABSTOP,10,64,77,10,0, |
| 636 | HIDC_KEEPASPECT |
| 637 | CONTROL "Throttle",IDC_THROTTLE,"Button",BS_AUTOCHECKBOX | |
| 638 | WS_TABSTOP,10,76,39,10,0,HIDC_THROTTLE |
| 639 | GROUPBOX "Bitmap prescaling",IDC_STATIC,4,89,103,24 |
| 640 | CONTROL "GammaSlider",IDC_PRESCALE,"msctls_trackbar32",TBS_BOTH | |
| 641 | TBS_NOTICKS | WS_TABSTOP,10,99,71,10,0,HIDC_PRESCALE |
| 642 | RTEXT "1.00",IDC_PRESCALEDISP,84,98,14,11,SS_CENTERIMAGE | NOT |
| 643 | WS_GROUP |
| 644 | GROUPBOX "Gamma Correction",IDC_STATIC,4,115,103,24 |
| 645 | CONTROL "GammaSlider",IDC_GAMMA,"msctls_trackbar32",TBS_BOTH | |
| 646 | TBS_NOTICKS | WS_TABSTOP,10,125,71,10,0,HIDC_GAMMA |
| 647 | RTEXT "2.00",IDC_GAMMADISP,84,124,14,10,SS_CENTERIMAGE | NOT |
| 648 | WS_GROUP |
| 649 | GROUPBOX "Brightness Correction",IDC_STATIC,4,141,103,24 |
| 650 | CONTROL "GammaSlider",IDC_BRIGHTCORRECT,"msctls_trackbar32", |
| 651 | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,10,151,71,10,0, |
| 652 | HIDC_BRIGHTCORRECT |
| 653 | RTEXT "1.00",IDC_BRIGHTCORRECTDISP,84,150,14,10,SS_CENTERIMAGE | |
| 654 | NOT WS_GROUP |
| 655 | GROUPBOX "Contrast Correction",IDC_STATIC,4,167,103,24 |
| 656 | CONTROL "GammaSlider",IDC_CONTRAST,"msctls_trackbar32",TBS_BOTH | |
| 657 | TBS_NOTICKS | WS_TABSTOP,10,176,71,10,0,HIDC_CONTRAST |
| 658 | RTEXT "1.00",IDC_CONTRASTDISP,84,175,14,11,SS_CENTERIMAGE | |
| 659 | NOT WS_GROUP |
| 660 | GROUPBOX "Pause Brightness",IDC_STATIC,4,193,103,24 |
| 661 | CONTROL "Slider1",IDC_PAUSEBRIGHT,"msctls_trackbar32",TBS_BOTH | |
| 662 | TBS_NOTICKS | WS_TABSTOP,10,203,71,10,0,HIDC_PAUSEBRIGHT |
| 663 | RTEXT "0.65",IDC_PAUSEBRIGHTDISP,84,202,14,11,SS_CENTERIMAGE | |
| 664 | NOT WS_GROUP |
| 665 | GROUPBOX "Videomode",IDC_STATIC,113,40,102,28 |
| 666 | COMBOBOX IDC_VIDEO_MODE,119,50,90,50,CBS_DROPDOWNLIST | CBS_SORT | |
| 667 | WS_VSCROLL | WS_TABSTOP,0,HIDC_VIDEO_MODE |
| 668 | GROUPBOX "Rotation",IDC_STATIC,113,71,102,55 |
| 669 | COMBOBOX IDC_ROTATE,119,81,90,57,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 670 | WS_TABSTOP,0,HIDC_ROTATE |
| 671 | CONTROL "Flip screen upside-down",IDC_FLIPY,"Button", |
| 672 | BS_AUTOCHECKBOX | WS_TABSTOP,119,98,91,10,0,HIDC_FLIPY |
| 673 | CONTROL "Flip screen left-right",IDC_FLIPX,"Button", |
| 674 | BS_AUTOCHECKBOX | WS_TABSTOP,119,110,77,10,0,HIDC_FLIPX |
| 675 | GROUPBOX "Direct3D",IDC_STATIC,113,128,102,57 |
| 676 | CONTROL "Use Bilinear filtering",IDC_D3D_FILTER,"Button", |
| 677 | BS_AUTOCHECKBOX | WS_TABSTOP,119,138,85,10,0, |
| 678 | HIDC_D3D_FILTER |
| 679 | GROUPBOX "Version",IDC_STATIC,119,150,90,28 |
| 680 | COMBOBOX IDC_D3D_VERSION,125,160,78,95,CBS_DROPDOWNLIST | |
| 681 | WS_VSCROLL | WS_TABSTOP,0,HIDC_D3D_VERSION |
| 682 | GROUPBOX "DirectDraw",IDC_STATIC,113,187,102,26 |
| 683 | CONTROL "Stretch using hardware",IDC_HWSTRETCH,"Button", |
| 684 | BS_AUTOCHECKBOX | WS_TABSTOP,119,197,85,10,0, |
| 685 | HIDC_HWSTRETCH |
| 686 | PUSHBUTTON "Reset",IDC_PROP_RESET,4,222,97,14,0,0,HIDC_PROP_RESET |
| 687 | PUSHBUTTON "Restore Default Settings",IDC_USE_DEFAULT,118,222,97,14, |
| 688 | 0,0,HIDC_USE_DEFAULT |
| 689 | END |
| 690 | |
| 691 | IDD_PROP_SOUND DIALOGEX 0, 0, 220, 240 |
| 692 | STYLE DS_SETFONT | WS_CHILD | WS_CAPTION |
| 693 | CAPTION "Sound" |
| 694 | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 695 | BEGIN |
| 696 | ICON IDI_SOUNDTAB,IDC_STATIC,20,10,20,20 |
| 697 | LTEXT "Title\nDirectory\nExtra",IDC_PROP_TITLE,52,9,161,25, |
| 698 | SS_NOPREFIX |
| 699 | GROUPBOX "",IDC_STATIC,4,40,211,122 |
| 700 | CONTROL "Enable sound and sound CPUs",IDC_USE_SOUND,"Button", |
| 701 | BS_AUTOCHECKBOX | WS_TABSTOP,10,40,112,10,0, |
| 702 | HIDC_USE_SOUND |
| 703 | CONTROL "Use samples",IDC_SAMPLES,"Button",BS_AUTOCHECKBOX | |
| 704 | WS_TABSTOP,10,52,55,10,0,HIDC_SAMPLES |
| 705 | GROUPBOX "Sample rate",IDC_RATETEXT,60,65,100,28 |
| 706 | COMBOBOX IDC_SAMPLERATE,66,75,88,60,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 707 | WS_TABSTOP,0,HIDC_SAMPLERATE |
| 708 | GROUPBOX "Volume attenuation",IDC_STATIC,60,96,100,28 |
| 709 | CONTROL "Slider1",IDC_VOLUME,"msctls_trackbar32",TBS_BOTH | |
| 710 | TBS_NOTICKS | WS_TABSTOP,66,108,68,10,0,HIDC_VOLUME |
| 711 | RTEXT "0dB",IDC_VOLUMEDISP,132,107,20,11,SS_CENTERIMAGE |
| 712 | GROUPBOX "Audio latency",IDC_AUDIO_LATENCY_TEXT,60,127,100,28 |
| 713 | CONTROL "Slider1",IDC_AUDIO_LATENCY,"msctls_trackbar32",TBS_BOTH | |
| 714 | TBS_NOTICKS | WS_TABSTOP,66,139,68,10,0, |
| 715 | HIDC_AUDIO_LATENCY |
| 716 | RTEXT "1/5",IDC_AUDIO_LATENCY_DISP,132,138,20,11, |
| 717 | SS_CENTERIMAGE |
| 718 | PUSHBUTTON "Reset",IDC_PROP_RESET,4,222,97,14,0,0,HIDC_PROP_RESET |
| 719 | PUSHBUTTON "Restore Default Settings",IDC_USE_DEFAULT,118,222,97,14, |
| 720 | 0,0,HIDC_USE_DEFAULT |
| 721 | END |
| 722 | |
| 723 | IDD_PROP_ADVANCED DIALOGEX 0, 0, 220, 240 |
| 724 | STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_CAPTION |
| 725 | CAPTION "Advanced" |
| 726 | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 727 | BEGIN |
| 728 | ICON IDI_DISPLAY,IDC_STATIC,20,10,20,20 |
| 729 | LTEXT "Title\nDirectory\nExtra",IDC_PROP_TITLE,52,9,161,25, |
| 730 | SS_NOPREFIX |
| 731 | CONTROL "Triple buffering",IDC_TRIPLE_BUFFER,"Button", |
| 732 | BS_AUTOCHECKBOX | WS_TABSTOP,10,40,93,10,0, |
| 733 | HIDC_TRIPLE_BUFFER |
| 734 | CONTROL "Sync to monitor refresh",IDC_SYNCREFRESH,"Button", |
| 735 | BS_AUTOCHECKBOX | WS_TABSTOP,10,52,93,10,0, |
| 736 | HIDC_SYNCREFRESH |
| 737 | CONTROL "Wait for vertical sync",IDC_WAITVSYNC,"Button", |
| 738 | BS_AUTOCHECKBOX | WS_TABSTOP,10,64,93,10,0, |
| 739 | HIDC_WAITVSYNC |
| 740 | CONTROL "Refresh speed",IDC_REFRESHSPEED,"Button", |
| 741 | BS_AUTOCHECKBOX | WS_TABSTOP,10,76,93,10,0, |
| 742 | HIDC_REFRESHSPEED |
| 743 | GROUPBOX "Frame skipping",IDC_STATIC,4,88,103,42 |
| 744 | CONTROL "Automatic",IDC_AUTOFRAMESKIP,"Button",BS_AUTOCHECKBOX | |
| 745 | WS_TABSTOP,10,98,77,10,0,HIDC_AUTOFRAMESKIP |
| 746 | COMBOBOX IDC_FRAMESKIP,10,111,91,88,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 747 | WS_TABSTOP,0,HIDC_FRAMESKIP |
| 748 | GROUPBOX "Full screen gamma",IDC_FSGAMMATEXT,113,40,102,24 |
| 749 | CONTROL "Slider1",IDC_FSGAMMA,"msctls_trackbar32",TBS_BOTH | |
| 750 | TBS_NOTICKS | WS_TABSTOP,119,50,71,10,0,HIDC_FSGAMMA |
| 751 | RTEXT "2.00",IDC_FSGAMMADISP,193,49,16,10,SS_CENTERIMAGE | NOT |
| 752 | WS_GROUP |
| 753 | GROUPBOX "Full screen brightness",IDC_FSBRIGHTNESSTEXT,113,67,102, |
| 754 | 24 |
| 755 | CONTROL "Slider1",IDC_FSBRIGHTNESS,"msctls_trackbar32",TBS_BOTH | |
| 756 | TBS_NOTICKS | WS_TABSTOP,119,77,71,10,0, |
| 757 | HIDC_FSBRIGHTNESS |
| 758 | RTEXT "2.00",IDC_FSBRIGHTNESSDISP,193,76,16,10,SS_CENTERIMAGE | |
| 759 | NOT WS_GROUP |
| 760 | GROUPBOX "Full screen contrast",IDC_FSCONTRASTTEXT,113,94,102,24 |
| 761 | CONTROL "Slider1",IDC_FSCONTRAST,"msctls_trackbar32",TBS_BOTH | |
| 762 | TBS_NOTICKS | WS_TABSTOP,119,104,71,10,0,HIDC_FSCONTRAST |
| 763 | RTEXT "2.00",IDC_FSCONTRASTDISP,193,103,16,11,SS_CENTERIMAGE | |
| 764 | NOT WS_GROUP |
| 765 | GROUPBOX "Emulation speed",IDC_SPEEDTEXT,4,133,211,24 |
| 766 | CONTROL "Slider1",IDC_SPEED,"msctls_trackbar32",TBS_BOTH | |
| 767 | TBS_NOTICKS | WS_TABSTOP,10,143,180,10,0,HIDC_SPEED |
| 768 | RTEXT "1.00",IDC_SPEEDDISP,189,142,20,11,SS_CENTERIMAGE | NOT |
| 769 | WS_GROUP |
| 770 | GROUPBOX "Effect",IDC_STATIC,4,160,211,50 |
| 771 | EDITTEXT IDC_EFFECT,10,170,200,14,ES_AUTOHSCROLL | WS_DISABLED |
| 772 | PUSHBUTTON "Select Effect",IDC_SELECT_EFFECT,10,189,60,14,0,0, |
| 773 | HIDC_SELECT_EFFECT |
| 774 | PUSHBUTTON "Reset Effect",IDC_RESET_EFFECT,150,189,60,14,0,0, |
| 775 | HIDC_RESET_EFFECT |
| 776 | PUSHBUTTON "Reset",IDC_PROP_RESET,4,222,97,14,0,0,HIDC_PROP_RESET |
| 777 | PUSHBUTTON "Restore Default Settings",IDC_USE_DEFAULT,118,222,97,14, |
| 778 | 0,0,HIDC_USE_DEFAULT |
| 779 | END |
| 780 | |
| 781 | IDD_PROP_INPUT DIALOGEX 0, 0, 220, 240 |
| 782 | STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_CAPTION |
| 783 | CAPTION "Controllers" |
| 784 | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 785 | BEGIN |
| 786 | ICON IDI_JOYSTICK,IDC_STATIC,20,10,20,20 |
| 787 | LTEXT "Title\nDirectory\nExtra",IDC_PROP_TITLE,52,9,161,25, |
| 788 | SS_NOPREFIX |
| 789 | CONTROL "Enable mouse input",IDC_USE_MOUSE,"Button", |
| 790 | BS_AUTOCHECKBOX | WS_TABSTOP,10,40,86,10,0, |
| 791 | HIDC_USE_MOUSE |
| 792 | CONTROL "Enable steadykey support",IDC_STEADYKEY,"Button", |
| 793 | BS_AUTOCHECKBOX | WS_TABSTOP,10,52,95,10,0, |
| 794 | HIDC_STEADYKEY |
| 795 | GROUPBOX "",IDC_STATIC,4,64,103,74 |
| 796 | CONTROL "Enable joystick input",IDC_JOYSTICK,"Button", |
| 797 | BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,10,64,78,10,0, |
| 798 | HIDC_JOYSTICK |
| 799 | GROUPBOX "Joystick deadzone",IDC_JDZTEXT,10,76,91,28 |
| 800 | CONTROL "IntensitySlider",IDC_JDZ,"msctls_trackbar32",TBS_BOTH | |
| 801 | TBS_NOTICKS | WS_TABSTOP,15,88,60,10,0,HIDC_JDZ |
| 802 | RTEXT "0.3",IDC_JDZDISP,76,87,16,11,SS_CENTERIMAGE | NOT |
| 803 | WS_GROUP |
| 804 | GROUPBOX "Default input layout",IDC_STATIC,113,40,102,28 |
| 805 | COMBOBOX IDC_DEFAULT_INPUT,119,50,90,53,CBS_DROPDOWNLIST | |
| 806 | WS_VSCROLL | WS_TABSTOP,0,HIDC_DEFAULT_INPUT |
| 807 | GROUPBOX "",IDC_STATIC,113,71,102,66 |
| 808 | CONTROL "Enable lightgun input",IDC_LIGHTGUN,"Button", |
| 809 | BS_AUTOCHECKBOX | WS_TABSTOP,119,71,80,10,0, |
| 810 | HIDC_LIGHTGUN |
| 811 | CONTROL "Offscreen shots reload",IDC_RELOAD,"Button", |
| 812 | BS_AUTOCHECKBOX | WS_TABSTOP,119,83,86,10,0,HIDC_RELOAD |
| 813 | CONTROL "Dual lightguns",IDC_DUAL_LIGHTGUN,"Button", |
| 814 | BS_AUTOCHECKBOX | WS_TABSTOP,119,96,86,10,0, |
| 815 | HIDC_DUAL_LIGHTGUN |
| 816 | CONTROL "Multiple keyboards",IDC_MULTIKEYBOARD,"Button", |
| 817 | BS_AUTOCHECKBOX | WS_TABSTOP,119,109,75,10,0, |
| 818 | HIDC_MULTIKEYBOARD |
| 819 | CONTROL "Multiple mice",IDC_MULTIMOUSE,"Button",BS_AUTOCHECKBOX | |
| 820 | WS_TABSTOP,119,122,56,10,0,HIDC_MULTIMOUSE |
| 821 | GROUPBOX "Joystick saturation",IDC_JSATTEXT,10,106,91,28 |
| 822 | CONTROL "IntensitySlider",IDC_JSAT,"msctls_trackbar32",TBS_BOTH | |
| 823 | TBS_NOTICKS | WS_TABSTOP,16,118,60,10,0,HIDC_JSAT |
| 824 | RTEXT "0.85",IDC_JSATDISP,76,116,16,11,SS_CENTERIMAGE | NOT |
| 825 | WS_GROUP |
| 826 | PUSHBUTTON "Reset",IDC_PROP_RESET,4,222,97,14,0,0,HIDC_PROP_RESET |
| 827 | PUSHBUTTON "Restore Default Settings",IDC_USE_DEFAULT,118,222,97,14, |
| 828 | 0,0,HIDC_USE_DEFAULT |
| 829 | END |
| 830 | |
| 831 | IDD_PROP_MISC DIALOGEX 0, 0, 220, 240 |
| 832 | STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_CAPTION |
| 833 | CAPTION "Miscellaneous" |
| 834 | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 835 | BEGIN |
| 836 | ICON IDI_MAME32_ICON,IDC_STATIC,20,10,20,20 |
| 837 | LTEXT "Title\nDirectory\nExtra",IDC_PROP_TITLE,52,9,161,25, |
| 838 | SS_NOPREFIX |
| 839 | #ifdef MESS |
| 840 | CONTROL "Enable system cheats",IDC_CHEAT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,40,86,10,0,HIDC_CHEAT |
| 841 | #else |
| 842 | CONTROL "Enable game cheats",IDC_CHEAT,"Button",BS_AUTOCHECKBOX | |
| 843 | WS_TABSTOP,10,40,86,10,0,HIDC_CHEAT |
| 844 | #endif |
| 845 | CONTROL "Error log (for developers)",IDC_LOG,"Button", |
| 846 | BS_AUTOCHECKBOX | WS_TABSTOP,10,52,96,10,0,HIDC_LOG |
| 847 | CONTROL "Sleep when possible",IDC_SLEEP,"Button",BS_AUTOCHECKBOX | |
| 848 | WS_TABSTOP,10,64,86,10,0,HIDC_SLEEP |
| 849 | CONTROL "Enable game debugger",IDC_DEBUG,"Button", |
| 850 | BS_AUTOCHECKBOX | WS_TABSTOP,10,76,86,10,0,HIDC_DEBUG |
| 851 | #ifdef MESS |
| 852 | CONTROL "Skip system info",IDC_SKIP_GAME_INFO,"Button", |
| 853 | BS_AUTOCHECKBOX | WS_TABSTOP,10,88,96,10,0, |
| 854 | HIDC_SKIP_GAME_INFO |
| 855 | #else |
| 856 | CONTROL "Skip game info",IDC_SKIP_GAME_INFO,"Button", |
| 857 | BS_AUTOCHECKBOX | WS_TABSTOP,10,88,96,10,0, |
| 858 | HIDC_SKIP_GAME_INFO |
| 859 | #endif |
| 860 | CONTROL "Save game state on exit",IDC_ENABLE_AUTOSAVE,"Button", |
| 861 | BS_AUTOCHECKBOX | WS_TABSTOP,10,100,96,10,0, |
| 862 | HIDC_ENABLE_AUTOSAVE |
| 863 | CONTROL "Multi-threaded rendering",IDC_MULTITHREAD_RENDERING, |
| 864 | "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,112,96,10,0, |
| 865 | HIDC_MULTITHREAD_RENDERING |
| 866 | GROUPBOX "Thread Priority",IDC_HIGH_PRIORITY_TEXT,4,124,103,34 |
| 867 | CONTROL "Slider1",IDC_HIGH_PRIORITY,"msctls_trackbar32",TBS_BOTH | |
| 868 | TBS_NOTICKS | WS_TABSTOP,10,135,75,10,0, |
| 869 | HIDC_HIGH_PRIORITY |
| 870 | LTEXT "idle",IDC_STATIC,13,144,12,8 |
| 871 | RTEXT "-15",IDC_HIGH_PRIORITYTXT,84,134,14,10,SS_CENTERIMAGE |
| 872 | RTEXT "real-time",IDC_STATIC,53,144,28,8 |
| 873 | GROUPBOX "Artwork options",IDC_STATIC,113,40,102,61 |
| 874 | CONTROL "Backdrops",IDC_BACKDROPS,"Button",BS_AUTOCHECKBOX | |
| 875 | WS_TABSTOP,119,50,86,10,0,HIDC_BACKDROPS |
| 876 | CONTROL "Bezels",IDC_BEZELS,"Button",BS_AUTOCHECKBOX | |
| 877 | WS_TABSTOP,119,62,86,10,0,HIDC_BEZELS |
| 878 | CONTROL "Overlays",IDC_OVERLAYS,"Button",BS_AUTOCHECKBOX | |
| 879 | WS_TABSTOP,119,74,84,10,0,HIDC_OVERLAYS |
| 880 | CONTROL "Crop artwork",IDC_ARTWORK_CROP,"Button",BS_AUTOCHECKBOX | |
| 881 | WS_TABSTOP,119,86,53,10,0,HIDC_ARTWORK_CROP |
| 882 | GROUPBOX "BIOS",IDC_STATIC,113,104,102,28 |
| 883 | COMBOBOX IDC_BIOS,119,114,90,60,CBS_DROPDOWNLIST | WS_VSCROLL | |
| 884 | WS_TABSTOP,0,HIDC_BIOS |
| 885 | PUSHBUTTON "Reset",IDC_PROP_RESET,4,222,97,14,0,0,HIDC_PROP_RESET |
| 886 | PUSHBUTTON "Restore Default Settings",IDC_USE_DEFAULT,118,222,97,14, |
| 887 | 0,0,HIDC_USE_DEFAULT |
| 888 | #ifdef MESS |
| 889 | CONTROL "Skip warnings",IDC_SKIP_WARNINGS,"Button", |
| 890 | BS_AUTOCHECKBOX | WS_TABSTOP,10,180,86,10,0 |
| 891 | CONTROL "Use New UI",IDC_USE_NEW_UI,"Button", |
| 892 | BS_AUTOCHECKBOX | WS_TABSTOP,10,192,86,10,0 |
| 893 | #endif |
| 894 | END |
| 895 | |
| 896 | IDD_PROP_VECTOR DIALOGEX 0, 0, 220, 240 |
| 897 | STYLE DS_SETFONT | WS_CHILD | WS_CAPTION |
| 898 | CAPTION "Vector" |
| 899 | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 900 | BEGIN |
| 901 | ICON IDI_MAME32_ICON,IDC_STATIC,20,10,20,20 |
| 902 | LTEXT "Title\nDirectory\nExtra",IDC_PROP_TITLE,52,9,161,25, |
| 903 | SS_NOPREFIX |
| 904 | CONTROL "Draw antialiased vectors",IDC_ANTIALIAS,"Button", |
| 905 | BS_AUTOCHECKBOX | WS_TABSTOP,10,40,92,10,0, |
| 906 | HIDC_ANTIALIAS |
| 907 | GROUPBOX "Beam width",IDC_BEAMTEXT,60,53,100,28 |
| 908 | CONTROL "BeamSlider",IDC_BEAM,"msctls_trackbar32",TBS_BOTH | |
| 909 | TBS_NOTICKS | WS_TABSTOP,66,65,64,10,0,HIDC_BEAM |
| 910 | RTEXT "16.00",IDC_BEAMDISP,132,64,20,11,SS_CENTERIMAGE |
| 911 | GROUPBOX "Flicker",IDC_FLICKERTEXT,60,84,100,28 |
| 912 | CONTROL "FlickerSlider",IDC_FLICKER,"msctls_trackbar32",TBS_BOTH | |
| 913 | TBS_NOTICKS | WS_TABSTOP,66,96,64,10,0,HIDC_FLICKER |
| 914 | RTEXT "100.00",IDC_FLICKERDISP,128,95,24,11,SS_CENTERIMAGE | |
| 915 | NOT WS_GROUP |
| 916 | PUSHBUTTON "Reset",IDC_PROP_RESET,4,222,97,14,0,0,HIDC_PROP_RESET |
| 917 | PUSHBUTTON "Restore Default Settings",IDC_USE_DEFAULT,118,222,97,14, |
| 918 | 0,0,HIDC_USE_DEFAULT |
| 919 | END |
| 920 | |
| 921 | |
| 922 | #ifdef MESS |
| 923 | IDD_MAIN DIALOGEX 0, 0, 364, 206 |
| 924 | #else |
| 925 | IDD_MAIN DIALOGEX 0, 0, 304, 206 |
| 926 | #endif |
| 927 | STYLE DS_SETFONT | DS_3DLOOK | DS_NOFAILCREATE | WS_MINIMIZEBOX | |
| 928 | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME |
| 929 | EXSTYLE WS_EX_CONTROLPARENT |
| 930 | CAPTION "MAME32 - overwritten at runtime" |
| 931 | CLASS "MainClass" |
| 932 | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 933 | BEGIN |
| 934 | CONTROL "",IDC_DIVIDER,"Static",SS_ETCHEDHORZ,0,5,304,1 |
| 935 | CONTROL "Tree1",IDC_TREE,"SysTreeView32",TVS_HASBUTTONS | |
| 936 | TVS_HASLINES | TVS_LINESATROOT | TVS_EDITLABELS | |
| 937 | TVS_SHOWSELALWAYS | TVS_FULLROWSELECT | WS_BORDER | |
| 938 | WS_TABSTOP,5,28,48,172 |
| 939 | CONTROL "List1",IDC_LIST,"SysListView32",LVS_REPORT | |
| 940 | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_AUTOARRANGE | |
| 941 | LVS_OWNERDRAWFIXED | WS_BORDER | WS_TABSTOP,65,28,42,172 |
| 942 | GROUPBOX "",IDC_SPLITTER,55,28,8,172,BS_NOTIFY | NOT WS_VISIBLE |
| 943 | GROUPBOX "",IDC_SPLITTER2,109,28,8,172,BS_NOTIFY | NOT WS_VISIBLE |
| 944 | #ifdef MESS |
| 945 | CONTROL "",IDC_SSTAB,"SysTabControl32",TCS_HOTTRACK,121,0,181,18 |
| 946 | CONTROL "",IDC_SWTAB,"SysTabControl32",TCS_HOTTRACK,119,0,200,100 |
| 947 | CONTROL "List2",IDC_SWLIST,"SysListView32",LVS_REPORT | |
| 948 | LVS_SHOWSELALWAYS | LVS_OWNERDRAWFIXED | WS_BORDER | |
| 949 | WS_TABSTOP,119,60,42,140 |
| 950 | CONTROL "",IDC_SWDEVVIEW,"MessSoftwareDevView",WS_VISIBLE,119,0,200,100 |
| 951 | GROUPBOX "",IDC_SPLITTER3,163,28,8,172,BS_NOTIFY | NOT WS_VISIBLE |
| 952 | CONTROL "",IDC_SSFRAME,"Static",SS_ETCHEDFRAME,175,11,181,194 |
| 953 | CONTROL "",IDC_SSPICTURE,"Static",SS_BITMAP | SS_NOTIFY | |
| 954 | SS_CENTERIMAGE | NOT WS_VISIBLE,195,18,141,127 |
| 955 | EDITTEXT IDC_HISTORY,183,150,167,49,ES_MULTILINE | ES_READONLY | |
| 956 | WS_VSCROLL,WS_EX_STATICEDGE,HIDC_HISTORY |
| 957 | #else |
| 958 | CONTROL "",IDC_SSFRAME,"Static",SS_ETCHEDFRAME | SS_NOTIFY,121, |
| 959 | 11,181,194 |
| 960 | CONTROL "",IDC_SSTAB,"SysTabControl32",TCS_HOTTRACK,121,0,181,18 |
| 961 | CONTROL "",IDC_SSPICTURE,"Static",SS_BITMAP | NOT WS_VISIBLE,141, |
| 962 | 18,141,127 |
| 963 | EDITTEXT IDC_HISTORY,129,150,167,49,ES_MULTILINE | ES_READONLY | |
| 964 | NOT WS_BORDER | WS_VSCROLL | NOT WS_TABSTOP,0, |
| 965 | HIDC_HISTORY |
| 966 | #endif |
| 967 | END |
| 968 | |
| 969 | IDD_FILTERS DIALOGEX 0, 0, 190, 182 |
| 970 | STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_CAPTION | |
| 971 | WS_SYSMENU |
| 972 | EXSTYLE WS_EX_CONTEXTHELP |
| 973 | #ifdef MESS |
| 974 | CAPTION "System Filters" |
| 975 | #else |
| 976 | CAPTION "Game Filters" |
| 977 | #endif |
| 978 | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 979 | BEGIN |
| 980 | #ifdef MESS |
| 981 | GROUPBOX "System filters",IDC_STATIC,6,4,178,85 |
| 982 | #else |
| 983 | GROUPBOX "Game filters",IDC_STATIC,6,4,178,85 |
| 984 | #endif |
| 985 | CONTROL "&Vector Graphics",IDC_FILTER_VECTOR,"Button", |
| 986 | BS_AUTOCHECKBOX | WS_TABSTOP,14,16,70,10,0, |
| 987 | HIDC_FILTER_VECTOR |
| 988 | CONTROL "C&lones",IDC_FILTER_CLONES,"Button",BS_AUTOCHECKBOX | |
| 989 | WS_TABSTOP,14,30,41,10,0,HIDC_FILTER_CLONES |
| 990 | CONTROL "Non-Wor&king",IDC_FILTER_NONWORKING,"Button", |
| 991 | BS_AUTOCHECKBOX | WS_TABSTOP,14,44,61,10,0, |
| 992 | HIDC_FILTER_NONWORKING |
| 993 | CONTROL "&Horizontal",IDC_FILTER_HORIZONTAL,"Button", |
| 994 | BS_AUTOCHECKBOX | WS_TABSTOP,14,58,57,10,0, |
| 995 | HIDC_FILTER_HORIZONTAL |
| 996 | CONTROL "&Unavailable",IDC_FILTER_UNAVAILABLE,"Button", |
| 997 | BS_AUTOCHECKBOX | WS_TABSTOP,14,72,57,10,0, |
| 998 | HIDC_FILTER_UNAVAILABLE |
| 999 | #ifdef MESS |
| 1000 | CONTROL "&Computers",IDC_FILTER_COMPUTER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,72,57,10,0,HIDC_FILTER_UNAVAILABLE |
| 1001 | CONTROL "C&onsoles",IDC_FILTER_CONSOLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,100,58,57,10,0,HIDC_FILTER_UNAVAILABLE |
| 1002 | #endif |
| 1003 | CONTROL "&Raster Graphics",IDC_FILTER_RASTER,"Button", |
| 1004 | BS_AUTOCHECKBOX | WS_TABSTOP,100,16,70,10,0, |
| 1005 | HIDC_FILTER_RASTER |
| 1006 | CONTROL "Ori&ginals",IDC_FILTER_ORIGINALS,"Button", |
| 1007 | BS_AUTOCHECKBOX | WS_TABSTOP,100,30,47,10,0, |
| 1008 | HIDC_FILTER_ORIGINALS |
| 1009 | CONTROL "&Working",IDC_FILTER_WORKING,"Button",BS_AUTOCHECKBOX | |
| 1010 | WS_TABSTOP,100,44,47,10,0,HIDC_FILTER_WORKING |
| 1011 | CONTROL "&Vertical",IDC_FILTER_VERTICAL,"Button",BS_AUTOCHECKBOX | |
| 1012 | WS_TABSTOP,100,58,47,10,0,HIDC_FILTER_VERTICAL |
| 1013 | LTEXT "(*) = inherited from parent folder",IDC_INHERITED,14,72, |
| 1014 | 99,10 |
| 1015 | #ifdef MESS |
| 1016 | CTEXT "System filters allow customizing the systems that are displayed in each folder by hiding games that match the filters applied.",IDC_STATIC,6,94,178,27 |
| 1017 | #else |
| 1018 | CTEXT "Game filters allow customizing the games that are displayed in each folder by hiding games that match the filters applied.", |
| 1019 | IDC_STATIC,6,94,178,27 |
| 1020 | #endif |
| 1021 | GROUPBOX "&Description filter",IDC_STATIC,6,122,178,33 |
| 1022 | EDITTEXT IDC_FILTER_EDIT,14,134,162,13,ES_AUTOHSCROLL,0, |
| 1023 | HIDC_FILTER_EDIT |
| 1024 | DEFPUSHBUTTON "&OK",IDOK,42,161,50,14 |
| 1025 | PUSHBUTTON "&Cancel",IDCANCEL,98,161,50,14 |
| 1026 | END |
| 1027 | |
| 1028 | IDD_RESET DIALOGEX 0, 0, 190, 122 |
| 1029 | STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_CAPTION | |
| 1030 | WS_SYSMENU |
| 1031 | EXSTYLE WS_EX_CONTEXTHELP |
| 1032 | CAPTION "Reset Options" |
| 1033 | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 1034 | BEGIN |
| 1035 | GROUPBOX "Categories",IDC_STATIC,6,4,178,70 |
| 1036 | CONTROL "&User Interface (Fonts, Colors, Sizes)",IDC_RESET_UI, |
| 1037 | "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,16,146,10,0, |
| 1038 | HIDC_RESET_UI |
| 1039 | #ifdef MESS |
| 1040 | CONTROL "&Default system options",IDC_RESET_DEFAULT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,30,146,10,0,HIDC_RESET_DEFAULT |
| 1041 | CONTROL "&All systems to use default options",IDC_RESET_GAMES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,44,146,10,0,HIDC_RESET_GAMES |
| 1042 | #else |
| 1043 | CONTROL "&Default game options",IDC_RESET_DEFAULT,"Button", |
| 1044 | BS_AUTOCHECKBOX | WS_TABSTOP,14,30,146,10,0, |
| 1045 | HIDC_RESET_DEFAULT |
| 1046 | CONTROL "&All games to use default options",IDC_RESET_GAMES, |
| 1047 | "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,44,146,10,0, |
| 1048 | HIDC_RESET_GAMES |
| 1049 | #endif |
| 1050 | CONTROL "&Folder 'filters'",IDC_RESET_FILTERS,"Button", |
| 1051 | BS_AUTOCHECKBOX | WS_TABSTOP,14,58,146,10,0, |
| 1052 | HIDC_RESET_FILTERS |
| 1053 | CTEXT "Select the options to be restored to the default settings.", |
| 1054 | IDC_STATIC,6,79,178,20 |
| 1055 | DEFPUSHBUTTON "&OK",IDOK,42,101,50,14 |
| 1056 | PUSHBUTTON "&Cancel",IDCANCEL,98,101,50,14 |
| 1057 | END |
| 1058 | |
| 1059 | IDD_LOAD_PROGRESS DIALOGEX 0, 0, 260, 187 |
| 1060 | STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | |
| 1061 | WS_SYSMENU |
| 1062 | EXSTYLE WS_EX_CONTROLPARENT |
| 1063 | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 1064 | BEGIN |
| 1065 | CONTROL "Progress1",IDC_LOAD_PROGRESS,"msctls_progress32", |
| 1066 | WS_BORDER | 0x1,6,7,248,12 |
| 1067 | CTEXT "",IDC_LOAD_ROMNAME,6,21,248,10,SS_CENTERIMAGE | NOT |
| 1068 | WS_GROUP |
| 1069 | EDITTEXT IDC_LOAD_STATUS,6,32,248,116,ES_MULTILINE | ES_READONLY | |
| 1070 | WS_VSCROLL |
| 1071 | CTEXT "",IDC_ERROR_TEXT,6,150,248,13,SS_NOPREFIX | |
| 1072 | SS_CENTERIMAGE |
| 1073 | PUSHBUTTON "&OK",IDOK,77,166,50,14,WS_DISABLED |
| 1074 | PUSHBUTTON "&Cancel",IDCANCEL,133,166,50,14 |
| 1075 | END |
| 1076 | |
| 1077 | IDD_INTERFACE_OPTIONS DIALOGEX 0, 0, 378, 225 |
| 1078 | STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_CAPTION | |
| 1079 | WS_SYSMENU |
| 1080 | EXSTYLE WS_EX_CONTEXTHELP |
| 1081 | CAPTION "Interface Options" |
| 1082 | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 1083 | BEGIN |
| 1084 | #ifdef MESS |
| 1085 | GROUPBOX "System Selection",IDC_STATIC,6,4,189,194 |
| 1086 | CONTROL "&Search for new systems on start",IDC_START_GAME_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,16,112,10,0,HIDC_START_GAME_CHECK |
| 1087 | CONTROL "Allow system selection by a &joystick (requires restart)",IDC_JOY_GUI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,30,178,10,0,HIDC_JOY_GUI |
| 1088 | CONTROL "Allow system selection by custom &key sequences",IDC_KEY_GUI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,44,166,10 |
| 1089 | #else |
| 1090 | GROUPBOX "Game Selection",IDC_STATIC,6,4,189,194 |
| 1091 | CONTROL "&Search for new games on start",IDC_START_GAME_CHECK, |
| 1092 | "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,16,111,10,0, |
| 1093 | HIDC_START_GAME_CHECK |
| 1094 | CONTROL "Allow game selection by a &joystick (requires restart)", |
| 1095 | IDC_JOY_GUI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,30, |
| 1096 | 174,10,0,HIDC_JOY_GUI |
| 1097 | CONTROL "Allow game selection by custom &key sequences", |
| 1098 | IDC_KEY_GUI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,44, |
| 1099 | 166,10 |
| 1100 | #endif |
| 1101 | CONTROL "Select &random background image",IDC_RANDOM_BG,"Button", |
| 1102 | BS_AUTOCHECKBOX | WS_TABSTOP,14,58,122,10,0, |
| 1103 | HIDC_RANDOM_BG |
| 1104 | CONTROL "&Broadcast selected game to all windows",IDC_BROADCAST, |
| 1105 | "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,72,141,10,0, |
| 1106 | HIDC_BROADCAST |
| 1107 | CONTROL "Hide &mouse cursor (requires restart)",IDC_HIDE_MOUSE, |
| 1108 | "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,86,126,10,0, |
| 1109 | HIDC_HIDE_MOUSE |
| 1110 | CONTROL "Inheritable Filters",IDC_FILTER_INHERIT,"Button", |
| 1111 | BS_AUTOCHECKBOX | WS_TABSTOP,14,100,68,10 |
| 1112 | CONTROL "No offset for clones missing parent in view", |
| 1113 | IDC_NOOFFSET_CLONES,"Button",BS_AUTOCHECKBOX | |
| 1114 | WS_TABSTOP,14,114,148,10 |
| 1115 | GROUPBOX "Show History on Tab",IDC_STATIC,14,128,173,28 |
| 1116 | COMBOBOX IDC_HISTORY_TAB,57,138,88,50,CBS_DROPDOWNLIST | |
| 1117 | WS_VSCROLL | WS_TABSTOP |
| 1118 | GROUPBOX "Emulation",IDC_STATIC,202,4,170,28 |
| 1119 | #ifdef MESS |
| 1120 | CONTROL "Show System Ca&ption",IDC_GAME_CAPTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,210,16,81,10 |
| 1121 | #else |
| 1122 | CONTROL "Show Game Ca&ption",IDC_GAME_CAPTION,"Button", |
| 1123 | BS_AUTOCHECKBOX | WS_TABSTOP,210,16,80,10,0, |
| 1124 | HIDC_GAME_CAPTION |
| 1125 | #endif |
| 1126 | GROUPBOX "Bookkeeping",IDC_STATIC,202,36,170,43 |
| 1127 | CONTROL "Reset all Playcounts",IDC_RESET_PLAYCOUNT,"Button", |
| 1128 | BS_AUTOCHECKBOX | WS_TABSTOP,210,48,80,10 |
| 1129 | CONTROL "Reset all Play Times",IDC_RESET_PLAYTIME,"Button", |
| 1130 | BS_AUTOCHECKBOX | WS_TABSTOP,210,62,79,10 |
| 1131 | GROUPBOX "Screenshot Area",IDC_STATIC,202,83,170,115 |
| 1132 | CONTROL "S&tretch screenshot larger than natural size", |
| 1133 | IDC_STRETCH_SCREENSHOT_LARGER,"Button",BS_AUTOCHECKBOX | |
| 1134 | WS_TABSTOP,210,95,148,10,0, |
| 1135 | HIDC_STRETCH_SCREENSHOT_LARGER |
| 1136 | GROUPBOX "Screenshot Cycletime in Seconds",IDC_STATIC,210,109,154, |
| 1137 | 28 |
| 1138 | CONTROL "Slider1",IDC_CYCLETIMESEC,"msctls_trackbar32",TBS_BOTH | |
| 1139 | TBS_NOTICKS | WS_TABSTOP,218,121,120,10,0, |
| 1140 | HIDC_CYCLETIMESEC |
| 1141 | RTEXT "60",IDC_CYCLETIMESECTXT,340,120,13,10,SS_CENTERIMAGE |
| 1142 | GROUPBOX "Screenshot Bordersize",IDC_STATIC,210,141,154,28 |
| 1143 | CONTROL "Slider1",IDC_SCREENSHOT_BORDERSIZE,"msctls_trackbar32", |
| 1144 | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,218,153,120,10 |
| 1145 | RTEXT "100",IDC_SCREENSHOT_BORDERSIZETXT,340,152,13,10, |
| 1146 | SS_CENTERIMAGE |
| 1147 | PUSHBUTTON "Set Screenshot Border Color",IDC_SCREENSHOT_BORDERCOLOR, |
| 1148 | 210,176,154,14 |
| 1149 | DEFPUSHBUTTON "&OK",IDOK,136,204,50,14 |
| 1150 | PUSHBUTTON "&Cancel",IDCANCEL,192,204,50,14 |
| 1151 | END |
| 1152 | |
| 1153 | IDD_LANGUAGE DIALOGEX 0, 0, 190, 66 |
| 1154 | STYLE DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_CAPTION | |
| 1155 | WS_SYSMENU |
| 1156 | EXSTYLE WS_EX_CONTEXTHELP |
| 1157 | CAPTION "Language" |
| 1158 | FONT 8, "MS Shell Dlg", 0, 0, 0x1 |
| 1159 | BEGIN |
| 1160 | GROUPBOX "",IDC_STATIC,6,4,178,34 |
| 1161 | CONTROL "Use language file",IDC_LANGUAGECHECK,"Button", |
| 1162 | BS_AUTOCHECKBOX | WS_TABSTOP,12,4,66,10,0, |
| 1163 | HIDC_LANGUAGECHECK |
| 1164 | EDITTEXT IDC_LANGUAGEEDIT,14,17,142,13,ES_AUTOHSCROLL,0, |
| 1165 | HIDC_LANGUAGEEDIT |
| 1166 | PUSHBUTTON "...",IDC_LANGUAGEBROWSE,162,17,14,13 |
| 1167 | DEFPUSHBUTTON "OK",IDOK,42,45,50,14 |
| 1168 | PUSHBUTTON "Cancel",IDCANCEL,98,45,50,14 |
| 1169 | END |
| 1170 | |
| 1171 | IDD_CUSTOM_FILE DIALOG 0, 0, 190, 135 |
| 1172 | STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU |
| 1173 | CAPTION "Add Game To Custom Folder" |
| 1174 | FONT 8, "MS Shell Dlg" |
| 1175 | BEGIN |
| 1176 | LTEXT "",IDC_CUSTOMFILE_GAME,6,6,175,10,SS_NOPREFIX | |
| 1177 | SS_CENTERIMAGE |
| 1178 | CONTROL "CustomTree",IDC_CUSTOM_TREE,"SysTreeView32", |
| 1179 | TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | |
| 1180 | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | |
| 1181 | TVS_FULLROWSELECT | WS_BORDER | WS_TABSTOP,6,18,178,90 |
| 1182 | DEFPUSHBUTTON "OK",IDOK,42,114,50,14 |
| 1183 | PUSHBUTTON "Cancel",IDCANCEL,98,114,50,14 |
| 1184 | END |
| 1185 | |
| 1186 | |
| 1187 | ///////////////////////////////////////////////////////////////////////////// |
| 1188 | // |
| 1189 | // Accelerator |
| 1190 | // |
| 1191 | |
| 1192 | IDA_TAB_KEYS ACCELERATORS |
| 1193 | BEGIN |
| 1194 | "1", ID_VIEW_TAB_SCREENSHOT, VIRTKEY, ALT, NOINVERT |
| 1195 | "2", ID_VIEW_TAB_FLYER, VIRTKEY, ALT, NOINVERT |
| 1196 | "3", ID_VIEW_TAB_CABINET, VIRTKEY, ALT, NOINVERT |
| 1197 | "4", ID_VIEW_TAB_MARQUEE, VIRTKEY, ALT, NOINVERT |
| 1198 | "5", ID_VIEW_TAB_TITLE, VIRTKEY, ALT, NOINVERT |
| 1199 | "6", ID_VIEW_TAB_CONTROL_PANEL, VIRTKEY, ALT, NOINVERT |
| 1200 | "7", ID_VIEW_TAB_PCB, VIRTKEY, ALT, NOINVERT |
| 1201 | "8", ID_VIEW_TAB_HISTORY, VIRTKEY, ALT, NOINVERT |
| 1202 | "A", ID_GAME_AUDIT, VIRTKEY, ALT, NOINVERT |
| 1203 | "B", ID_VIEW_PAGETAB, VIRTKEY, ALT, NOINVERT |
| 1204 | "D", ID_VIEW_FOLDERS, VIRTKEY, ALT, NOINVERT |
| 1205 | "F", ID_CONTEXT_FILTERS, VIRTKEY, CONTROL, NOINVERT |
| 1206 | "U", ID_FOLDER_AUDIT, VIRTKEY, ALT, NOINVERT |
| 1207 | "P", ID_VIEW_PICTURE_AREA, VIRTKEY, ALT, NOINVERT |
| 1208 | "R", ID_CONTEXT_SELECT_RANDOM, VIRTKEY, CONTROL, NOINVERT |
| 1209 | "S", ID_VIEW_STATUS, VIRTKEY, ALT, NOINVERT |
| 1210 | "T", ID_VIEW_TOOLBARS, VIRTKEY, ALT, NOINVERT |
| 1211 | VK_F1, ID_HELP_CONTENTS, VIRTKEY, NOINVERT |
| 1212 | VK_F11, ID_VIEW_FULLSCREEN, VIRTKEY, NOINVERT |
| 1213 | VK_F5, ID_UPDATE_GAMELIST, VIRTKEY, NOINVERT |
| 1214 | VK_NEXT, ID_UI_HISTORY_DOWN, VIRTKEY, CONTROL, NOINVERT |
| 1215 | VK_PRIOR, ID_UI_HISTORY_UP, VIRTKEY, CONTROL, NOINVERT |
| 1216 | VK_RETURN, ID_GAME_PROPERTIES, VIRTKEY, ALT, NOINVERT |
| 1217 | END |
| 1218 | |
| 1219 | |
| 1220 | ///////////////////////////////////////////////////////////////////////////// |
| 1221 | // |
| 1222 | // DESIGNINFO |
| 1223 | // |
| 1224 | |
| 1225 | #ifdef APSTUDIO_INVOKED |
| 1226 | GUIDELINES DESIGNINFO |
| 1227 | BEGIN |
| 1228 | IDD_ABOUT, DIALOG |
| 1229 | BEGIN |
| 1230 | LEFTMARGIN, 7 |
| 1231 | RIGHTMARGIN, 289 |
| 1232 | TOPMARGIN, 7 |
| 1233 | BOTTOMMARGIN, 123 |
| 1234 | END |
| 1235 | |
| 1236 | IDD_DIRECTX, DIALOG |
| 1237 | BEGIN |
| 1238 | LEFTMARGIN, 7 |
| 1239 | RIGHTMARGIN, 229 |
| 1240 | TOPMARGIN, 7 |
| 1241 | BOTTOMMARGIN, 62 |
| 1242 | END |
| 1243 | |
| 1244 | IDD_AUDIT, DIALOG |
| 1245 | BEGIN |
| 1246 | LEFTMARGIN, 7 |
| 1247 | RIGHTMARGIN, 280 |
| 1248 | TOPMARGIN, 7 |
| 1249 | BOTTOMMARGIN, 187 |
| 1250 | HORZGUIDE, 19 |
| 1251 | END |
| 1252 | |
| 1253 | IDD_DIRECTORIES, DIALOG |
| 1254 | BEGIN |
| 1255 | LEFTMARGIN, 7 |
| 1256 | RIGHTMARGIN, 224 |
| 1257 | TOPMARGIN, 7 |
| 1258 | BOTTOMMARGIN, 98 |
| 1259 | END |
| 1260 | |
| 1261 | IDD_COLUMNS, DIALOG |
| 1262 | BEGIN |
| 1263 | LEFTMARGIN, 7 |
| 1264 | RIGHTMARGIN, 301 |
| 1265 | TOPMARGIN, 7 |
| 1266 | BOTTOMMARGIN, 143 |
| 1267 | END |
| 1268 | |
| 1269 | IDD_PROP_CONTROLLER, DIALOG |
| 1270 | BEGIN |
| 1271 | RIGHTMARGIN, 210 |
| 1272 | BOTTOMMARGIN, 154 |
| 1273 | END |
| 1274 | |
| 1275 | IDD_PROP_SCREEN, DIALOG |
| 1276 | BEGIN |
| 1277 | LEFTMARGIN, 4 |
| 1278 | VERTGUIDE, 7 |
| 1279 | VERTGUIDE, 123 |
| 1280 | BOTTOMMARGIN, 199 |
| 1281 | HORZGUIDE, 179 |
| 1282 | END |
| 1283 | |
| 1284 | IDD_PROP_GAME, DIALOG |
| 1285 | BEGIN |
| 1286 | LEFTMARGIN, 7 |
| 1287 | RIGHTMARGIN, 213 |
| 1288 | VERTGUIDE, 19 |
| 1289 | VERTGUIDE, 66 |
| 1290 | VERTGUIDE, 74 |
| 1291 | VERTGUIDE, 201 |
| 1292 | BOTTOMMARGIN, 232 |
| 1293 | END |
| 1294 | |
| 1295 | IDD_PROP_AUDIT, DIALOG |
| 1296 | BEGIN |
| 1297 | LEFTMARGIN, 7 |
| 1298 | RIGHTMARGIN, 213 |
| 1299 | VERTGUIDE, 12 |
| 1300 | VERTGUIDE, 208 |
| 1301 | BOTTOMMARGIN, 198 |
| 1302 | HORZGUIDE, 38 |
| 1303 | END |
| 1304 | |
| 1305 | IDD_PROP_DISPLAY, DIALOG |
| 1306 | BEGIN |
| 1307 | LEFTMARGIN, 4 |
| 1308 | VERTGUIDE, 7 |
| 1309 | VERTGUIDE, 123 |
| 1310 | HORZGUIDE, 179 |
| 1311 | END |
| 1312 | |
| 1313 | IDD_PROP_SOUND, DIALOG |
| 1314 | BEGIN |
| 1315 | LEFTMARGIN, 7 |
| 1316 | RIGHTMARGIN, 213 |
| 1317 | VERTGUIDE, 50 |
| 1318 | BOTTOMMARGIN, 198 |
| 1319 | END |
| 1320 | |
| 1321 | IDD_PROP_ADVANCED, DIALOG |
| 1322 | BEGIN |
| 1323 | LEFTMARGIN, 10 |
| 1324 | BOTTOMMARGIN, 211 |
| 1325 | END |
| 1326 | |
| 1327 | IDD_PROP_INPUT, DIALOG |
| 1328 | BEGIN |
| 1329 | LEFTMARGIN, 4 |
| 1330 | RIGHTMARGIN, 215 |
| 1331 | VERTGUIDE, 50 |
| 1332 | VERTGUIDE, 170 |
| 1333 | END |
| 1334 | |
| 1335 | IDD_PROP_MISC, DIALOG |
| 1336 | BEGIN |
| 1337 | LEFTMARGIN, 7 |
| 1338 | RIGHTMARGIN, 213 |
| 1339 | VERTGUIDE, 25 |
| 1340 | VERTGUIDE, 40 |
| 1341 | VERTGUIDE, 104 |
| 1342 | VERTGUIDE, 114 |
| 1343 | VERTGUIDE, 204 |
| 1344 | BOTTOMMARGIN, 183 |
| 1345 | END |
| 1346 | |
| 1347 | IDD_PROP_VECTOR, DIALOG |
| 1348 | BEGIN |
| 1349 | LEFTMARGIN, 7 |
| 1350 | RIGHTMARGIN, 213 |
| 1351 | VERTGUIDE, 50 |
| 1352 | BOTTOMMARGIN, 198 |
| 1353 | END |
| 1354 | |
| 1355 | IDD_FILTERS, DIALOG |
| 1356 | BEGIN |
| 1357 | LEFTMARGIN, 7 |
| 1358 | TOPMARGIN, 7 |
| 1359 | BOTTOMMARGIN, 178 |
| 1360 | END |
| 1361 | |
| 1362 | IDD_RESET, DIALOG |
| 1363 | BEGIN |
| 1364 | LEFTMARGIN, 7 |
| 1365 | RIGHTMARGIN, 175 |
| 1366 | VERTGUIDE, 18 |
| 1367 | VERTGUIDE, 164 |
| 1368 | TOPMARGIN, 7 |
| 1369 | END |
| 1370 | |
| 1371 | IDD_LANGUAGE, DIALOG |
| 1372 | BEGIN |
| 1373 | LEFTMARGIN, 7 |
| 1374 | RIGHTMARGIN, 179 |
| 1375 | TOPMARGIN, 7 |
| 1376 | BOTTOMMARGIN, 59 |
| 1377 | END |
| 1378 | END |
| 1379 | #endif // APSTUDIO_INVOKED |
| 1380 | |
| 1381 | |
| 1382 | ///////////////////////////////////////////////////////////////////////////// |
| 1383 | // |
| 1384 | // Bitmap |
| 1385 | // |
| 1386 | |
| 1387 | #ifdef MESS |
| 1388 | IDB_ABOUT BITMAP "res\\about_mess.bmp" |
| 1389 | #else |
| 1390 | IDB_ABOUT BITMAP "res\\about.bmp" |
| 1391 | #endif |
| 1392 | IDB_TOOLBAR BITMAP "res\\toolbar.bmp" |
| 1393 | |
| 1394 | ///////////////////////////////////////////////////////////////////////////// |
| 1395 | // |
| 1396 | // Cursor |
| 1397 | // |
| 1398 | |
| 1399 | IDC_CURSOR_HSPLIT CURSOR "Res\\Splith.cur" |
| 1400 | |
| 1401 | ///////////////////////////////////////////////////////////////////////////// |
| 1402 | // |
| 1403 | // RT_MANIFEST |
| 1404 | // |
| 1405 | |
| 1406 | 1 RT_MANIFEST "res\\mame32.manifest" |
| 1407 | |
| 1408 | ///////////////////////////////////////////////////////////////////////////// |
| 1409 | // |
| 1410 | // String Table |
| 1411 | // |
| 1412 | |
| 1413 | STRINGTABLE |
| 1414 | BEGIN |
| 1415 | IDS_UI_FILE "Contains commands for working with the selected items" |
| 1416 | IDS_UI_VIEW "Contains commands for manupulating the view" |
| 1417 | IDS_UI_OPTIONS "Contains commands for user interface options" |
| 1418 | END |
| 1419 | |
| 1420 | STRINGTABLE |
| 1421 | BEGIN |
| 1422 | IDS_UI_HELP "Contains commands for displaying help" |
| 1423 | IDS_VIEW_TOOLBAR "Show or hide the toolbar" |
| 1424 | IDS_VIEW_STATUSBAR "Show or hide the status bar" |
| 1425 | IDS_VIEW_FOLDERLIST "Show or hide the folder list" |
| 1426 | IDS_VIEW_SCREENSHOT "Show or hide the screen shot" |
| 1427 | IDS_VIEW_PICTURETABS "Show or hide tabs in the picture area" |
| 1428 | IDS_VIEW_SPACER1 "Spacer" |
| 1429 | IDS_VIEW_FULLSCREEN "Toggle full screen mode" |
| 1430 | IDS_VIEW_SPACER2 "Spacer" |
| 1431 | IDS_VIEW_SHOWPICTURES "Contains commands to select tabs shown in the picture area" |
| 1432 | IDS_VIEW_SPACER3 "Spacer" |
| 1433 | END |
| 1434 | |
| 1435 | STRINGTABLE |
| 1436 | BEGIN |
| 1437 | IDS_VIEW_LARGEICONS "Display items by using large icons." |
| 1438 | IDS_VIEW_SMALLICONS "Display items by using small icons." |
| 1439 | IDS_VIEW_LIST "Displays items in a list." |
| 1440 | IDS_VIEW_DETAILS "Displays detailed information about each item in the window." |
| 1441 | IDS_VIEW_GROUPED "Displays items grouped by parent game" |
| 1442 | IDS_VIEW_SPACER4 "Spacer" |
| 1443 | IDS_VIEW_ARRANGE "Contains commands for sorting by various columns" |
| 1444 | IDS_VIEW_LINEUPICONS "Arranges icons in a grid" |
| 1445 | IDS_VIEW_SPACER5 "Spacer" |
| 1446 | IDS_VIEW_REFRESH "Refresh game list" |
| 1447 | IDS_VIEW_CONTEXTFILTERS "Allows filtering out games from a folder" |
| 1448 | IDS_VIEW_CUSTOMIZEFIELDS |
| 1449 | "Customize which columns are used in the game list" |
| 1450 | END |
| 1451 | |
| 1452 | STRINGTABLE |
| 1453 | BEGIN |
| 1454 | ID_FILE_EXIT "Exit the application" |
| 1455 | #ifdef MESS |
| 1456 | ID_FILE_PLAY "Play currently selected system" |
| 1457 | #else |
| 1458 | ID_FILE_PLAY "Play currently selected game" |
| 1459 | #endif |
| 1460 | ID_HELP_ABOUT "Displays program and copyright information" |
| 1461 | ID_VIEW_LARGE_ICON "Display items by using large icons." |
| 1462 | ID_VIEW_SMALL_ICON "Display items by using small icons." |
| 1463 | ID_VIEW_LIST_MENU "Displays items in a list." |
| 1464 | ID_VIEW_DETAIL "Displays detailed information about each item in the window." |
| 1465 | #ifdef MESS |
| 1466 | ID_OPTIONS_FONT "Set system list and folder list font" |
| 1467 | ID_OPTIONS_DIR "Set directory configuration" |
| 1468 | ID_OPTIONS_DEFAULTS "Set default system options" |
| 1469 | #else |
| 1470 | ID_VIEW_GROUPED "Show items grouped by parent game" |
| 1471 | ID_OPTIONS_FONT "Set game list and folder list font" |
| 1472 | ID_OPTIONS_CLONE_COLOR "Set the clone font color" |
| 1473 | ID_OPTIONS_DIR "Set directory configuration" |
| 1474 | ID_OPTIONS_DEFAULTS "Set default game options" |
| 1475 | #endif |
| 1476 | END |
| 1477 | |
| 1478 | STRINGTABLE |
| 1479 | BEGIN |
| 1480 | ID_OPTIONS_RESET_DEFAULTS "Allow restoring options to 'sane' values." |
| 1481 | ID_OPTIONS_INTERFACE "Customize interface options." |
| 1482 | ID_FILE_AUDIT "Audit ROM and samples sets" |
| 1483 | #ifdef MESS |
| 1484 | ID_FILE_PLAY_RECORD "Record a system for later playback" |
| 1485 | ID_FILE_PLAY_BACK "Playback a recorded system" |
| 1486 | ID_FILE_PLAY_RECORD_WAVE "Record the sound output of a system" |
| 1487 | #else |
| 1488 | ID_FILE_PLAY_RECORD "Record a game for later playback" |
| 1489 | ID_FILE_PLAY_BACK "Playback a recorded game" |
| 1490 | ID_FILE_PLAY_RECORD_WAVE "Record the audio output of a game" |
| 1491 | ID_FILE_PLAY_RECORD_MNG "Record the video output of a game" |
| 1492 | #endif |
| 1493 | ID_VIEW_PICTURE_AREA "Show or hide the picture area" |
| 1494 | ID_HELP_CONTENTS "Display help contents" |
| 1495 | #ifdef MESS |
| 1496 | ID_HELP_WHATS_NEW32 "Recent changes" |
| 1497 | ID_HELP_TROUBLE "Troubleshooting Documentation" |
| 1498 | ID_HELP_RELEASE "MESS release notes" |
| 1499 | ID_HELP_WHATS_NEW "What's new in MESS" |
| 1500 | ID_HELP_CHEATS "How cheats work" |
| 1501 | #else |
| 1502 | ID_HELP_WHATS_NEW32 "New game changes" |
| 1503 | ID_HELP_TROUBLE "Troubleshooting Documentation" |
| 1504 | ID_HELP_RELEASE "MAME release notes" |
| 1505 | ID_HELP_WHATS_NEW "What's new in MAME" |
| 1506 | ID_HELP_CHEATS "How cheats work" |
| 1507 | #endif |
| 1508 | END |
| 1509 | |
| 1510 | STRINGTABLE |
| 1511 | BEGIN |
| 1512 | ID_CONTEXT_RESET_PLAYTIME "Reset time played for selected item" |
| 1513 | ID_CONTEXT_RESET_PLAYCOUNT "Reset number of plays for selected item" |
| 1514 | ID_FOLDER_PROPERTIES "Display folder properties" |
| 1515 | ID_FOLDER_AUDIT "Audit itmes in this folder" |
| 1516 | #ifdef MESS |
| 1517 | ID_FILE_LOADSTATE "Run a system starting with the given savestate" |
| 1518 | #else |
| 1519 | ID_FILE_LOADSTATE "Play a game starting with the given savestate" |
| 1520 | #endif |
| 1521 | END |
| 1522 | |
| 1523 | STRINGTABLE |
| 1524 | BEGIN |
| 1525 | ID_VIEW_TAB_CABINET "Select Cabinet tab" |
| 1526 | ID_VIEW_TAB_MARQUEE "Select Marquee tab" |
| 1527 | ID_VIEW_TAB_TITLE "Select Title tab" |
| 1528 | ID_VIEW_TAB_CONTROL_PANEL "Select Control panel tab" |
| 1529 | ID_VIEW_TAB_HISTORY "Select History tab" |
| 1530 | ID_OPTIONS_BG "Set the bacground image" |
| 1531 | ID_TOGGLE_TAB_SCREENSHOT "Enable the screenshot tab" |
| 1532 | ID_TOGGLE_TAB_FLYER "Enable the flyer tab" |
| 1533 | ID_TOGGLE_TAB_CABINET "Enable the cabinet tab" |
| 1534 | ID_TOGGLE_TAB_MARQUEE "Enable the marquee tab" |
| 1535 | ID_TOGGLE_TAB_TITLE "Enable the title tab" |
| 1536 | ID_TOGGLE_TAB_CONTROL_PANEL "Enable the control panel tab" |
| 1537 | ID_TOGGLE_TAB_PCB "Enable the PCB tab" |
| 1538 | ID_TOGGLE_TAB_HISTORY "Enable the history tab" |
| 1539 | ID_VIEW_FULLSCREEN "Toggle Fullscreen mode" |
| 1540 | END |
| 1541 | |
| 1542 | STRINGTABLE |
| 1543 | BEGIN |
| 1544 | #ifdef MESS |
| 1545 | ID_CUSTOMIZE_FIELDS "Customize which columns are used in the system list" |
| 1546 | #else |
| 1547 | ID_CUSTOMIZE_FIELDS "Customize which columns are used in the game list" |
| 1548 | #endif |
| 1549 | ID_GAME_PROPERTIES "Display the properties of the selected item" |
| 1550 | ID_VIEW_PAGETAB "Show or hide the tabs in the picture area" |
| 1551 | ID_VIEW_FOLDERS "Show or hide the folder list" |
| 1552 | ID_VIEW_TOOLBARS "Show or hide the toolbar" |
| 1553 | ID_VIEW_STATUS "Show or hide the status bar" |
| 1554 | #ifdef MESS |
| 1555 | ID_CONTEXT_FILTERS "Allows filtering out systems from a folder" |
| 1556 | ID_CONTEXT_RENAME_CUSTOM "Rename this folder" |
| 1557 | ID_CONTEXT_ADD_CUSTOM "Add selected item to custom folder" |
| 1558 | ID_CONTEXT_REMOVE_CUSTOM "Remove selected item from this folder" |
| 1559 | ID_GAME_AUDIT "Audit the selected item" |
| 1560 | ID_CONTEXT_SELECT_RANDOM "Randomly select a system." |
| 1561 | #else |
| 1562 | ID_CONTEXT_FILTERS "Allows filtering out games from a folder" |
| 1563 | ID_CONTEXT_RENAME_CUSTOM "Rename this folder" |
| 1564 | ID_CONTEXT_ADD_CUSTOM "Add selected item to custom folder" |
| 1565 | ID_CONTEXT_REMOVE_CUSTOM "Remove selected item from this folder" |
| 1566 | ID_GAME_AUDIT "Audit the selected item" |
| 1567 | ID_CONTEXT_SELECT_RANDOM "Randomly select a game." |
| 1568 | #endif |
| 1569 | ID_VIEW_TAB_SCREENSHOT "Select Screenshot tab" |
| 1570 | ID_VIEW_TAB_FLYER "Select Flyer tab" |
| 1571 | END |
| 1572 | |
| 1573 | STRINGTABLE |
| 1574 | BEGIN |
| 1575 | #ifdef MESS |
| 1576 | ID_VIEW_BYGAME "Sort items by system" |
| 1577 | #else |
| 1578 | ID_VIEW_BYGAME "Sort items by game" |
| 1579 | #endif |
| 1580 | ID_VIEW_BYDIRECTORY "Sort items by directories" |
| 1581 | ID_VIEW_BYMANUFACTURER "Sort items by manufacturer" |
| 1582 | ID_VIEW_BYYEAR "Sort items by year" |
| 1583 | ID_VIEW_BYTYPE "Sort items by type" |
| 1584 | ID_VIEW_BYTIMESPLAYED "Sort by number of plays" |
| 1585 | ID_VIEW_LINEUPICONS "Arranges icons in a grid" |
| 1586 | #ifdef MESS |
| 1587 | ID_UPDATE_GAMELIST "Refresh system list" |
| 1588 | #else |
| 1589 | ID_UPDATE_GAMELIST "Refresh game list" |
| 1590 | #endif |
| 1591 | ID_SORT_ASCENDING "Sort column in ascending (A-Z) order" |
| 1592 | ID_SORT_DESCENDING "Sort column in descending (Z-A) order" |
| 1593 | END |
| 1594 | |
| 1595 | STRINGTABLE |
| 1596 | BEGIN |
| 1597 | ID_FOLDER_SOURCEPROPERTIES |
| 1598 | "Display properties for all games in this source file" |
| 1599 | ID_FOLDER_VECTORPROPERTIES "Display properties for all vector based games" |
| 1600 | END |
| 1601 | |
| 1602 | #endif // English (U.S.) resources |
| 1603 | ///////////////////////////////////////////////////////////////////////////// |
| 1604 | |
| 1605 | |
| 1606 | |
| 1607 | #ifndef APSTUDIO_INVOKED |
| 1608 | ///////////////////////////////////////////////////////////////////////////// |
| 1609 | // |
| 1610 | // Generated from the TEXTINCLUDE 3 resource. |
| 1611 | // |
| 1612 | #include "mamevers.rc" // Version block |
| 1613 | |
| 1614 | |
| 1615 | ///////////////////////////////////////////////////////////////////////////// |
| 1616 | #endif // not APSTUDIO_INVOKED |
| 1617 | |
src/osd/winui/picker.c
| r0 | r996 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | M.A.M.E.32 - Multiple Arcade Machine Emulator for Win32 |
| 4 | Win32 Portions Copyright (C) 1997-2003 Michael Soderstrom and Chris Kirmse |
| 5 | |
| 6 | This file is part of MAME32, and may only be used, modified and |
| 7 | distributed under the terms of the MAME license, in "readme.txt". |
| 8 | By continuing to use, modify or distribute this file you indicate |
| 9 | that you have read the license and understand and accept it fully. |
| 10 | |
| 11 | ***************************************************************************/ |
| 12 | |
| 13 | #define WIN32_LEAN_AND_MEAN |
| 14 | #define _WIN32_IE 0x0500 |
| 15 | #include <windows.h> |
| 16 | #include <windowsx.h> |
| 17 | #include <shellapi.h> |
| 18 | #include <stdio.h> |
| 19 | #include <ctype.h> |
| 20 | #include <commctrl.h> |
| 21 | #include <commdlg.h> |
| 22 | #include <string.h> |
| 23 | #include <sys/stat.h> |
| 24 | #include <wingdi.h> |
| 25 | #include <time.h> |
| 26 | #include <tchar.h> |
| 27 | |
| 28 | #include "picker.h" |
| 29 | #include "resource.h" |
| 30 | #include "screenshot.h" |
| 31 | #include "win32ui.h" |
| 32 | #include "bitmask.h" |
| 33 | #include "m32util.h" |
| 34 | #include "m32opts.h" |
| 35 | |
| 36 | |
| 37 | // fix warning: cast does not match function type |
| 38 | #if defined(__GNUC__) && defined(ListView_GetHeader) |
| 39 | #undef ListView_GetHeader |
| 40 | #endif |
| 41 | #if defined(__GNUC__) && defined(ListView_GetImageList) |
| 42 | #undef ListView_GetImageList |
| 43 | #undef ListView_GetItemRect |
| 44 | #endif |
| 45 | |
| 46 | #ifndef ListView_GetItemRect |
| 47 | #define ListView_GetItemRect(w,i,p,c) \ |
| 48 | (BOOL)SNDMSG((w),LVM_GETITEMRECT,i,((p != NULL)?(((LPRECT)(p))->left=(c),(LPARAM)(LPRECT)(p)):0)) |
| 49 | #endif |
| 50 | |
| 51 | #ifndef ListView_GetImageList |
| 52 | #define ListView_GetImageList(w,i) (HIMAGELIST)(LRESULT)(int)SendMessage((w),LVM_GETIMAGELIST,(i),0) |
| 53 | #endif // ListView_GetImageList |
| 54 | |
| 55 | #ifndef ListView_GetHeader |
| 56 | #define ListView_GetHeader(w) (HWND)(LRESULT)(int)SNDMSG((w),LVM_GETHEADER,0,0) |
| 57 | #endif // ListView_GetHeader |
| 58 | |
| 59 | #ifndef HDM_SETIMAGELIST |
| 60 | #define HDM_SETIMAGELIST (HDM_FIRST + 8) |
| 61 | #endif // HDM_SETIMAGELIST |
| 62 | |
| 63 | #ifndef Header_SetImageList |
| 64 | #define Header_SetImageList(h,i) (HIMAGELIST)(LRESULT)(int)SNDMSG((h), HDM_SETIMAGELIST, 0, (LPARAM)i) |
| 65 | #endif // Header_SetImageList |
| 66 | |
| 67 | #ifndef HDF_SORTUP |
| 68 | #define HDF_SORTUP 0x400 |
| 69 | #endif |
| 70 | |
| 71 | #ifndef HDF_SORTDOWN |
| 72 | #define HDF_SORTDOWN 0x200 |
| 73 | #endif |
| 74 | |
| 75 | |
| 76 | |
| 77 | struct PickerInfo |
| 78 | { |
| 79 | const struct PickerCallbacks *pCallbacks; |
| 80 | WNDPROC pfnParentWndProc; |
| 81 | int nCurrentViewID; |
| 82 | int nLastItem; |
| 83 | int nColumnCount; |
| 84 | int *pnColumnsShown; |
| 85 | int *pnColumnsOrder; |
| 86 | UINT_PTR nTimer; |
| 87 | LPCTSTR *ppszColumnNames; |
| 88 | }; |
| 89 | |
| 90 | |
| 91 | static struct PickerInfo *GetPickerInfo(HWND hWnd) |
| 92 | { |
| 93 | LONG_PTR l; |
| 94 | l = GetWindowLongPtr(hWnd, GWLP_USERDATA); |
| 95 | return (struct PickerInfo *) l; |
| 96 | } |
| 97 | |
| 98 | |
| 99 | |
| 100 | static LRESULT CallParentWndProc(WNDPROC pfnParentWndProc, |
| 101 | HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) |
| 102 | { |
| 103 | LRESULT rc; |
| 104 | |
| 105 | if (!pfnParentWndProc) |
| 106 | pfnParentWndProc = GetPickerInfo(hWnd)->pfnParentWndProc; |
| 107 | |
| 108 | if (IsWindowUnicode(hWnd)) |
| 109 | rc = CallWindowProcW(pfnParentWndProc, hWnd, message, wParam, lParam); |
| 110 | else |
| 111 | rc = CallWindowProcA(pfnParentWndProc, hWnd, message, wParam, lParam); |
| 112 | return rc; |
| 113 | } |
| 114 | |
| 115 | static BOOL ListViewOnErase(HWND hWnd, HDC hDC) |
| 116 | { |
| 117 | RECT rcClient; |
| 118 | HRGN rgnBitmap; |
| 119 | HPALETTE hPAL; |
| 120 | |
| 121 | int i, j; |
| 122 | HDC htempDC; |
| 123 | POINT ptOrigin; |
| 124 | POINT pt = {0,0}; |
| 125 | HBITMAP hOldBitmap; |
| 126 | MYBITMAPINFO *pbmDesc = GetBackgroundInfo(); |
| 127 | HBITMAP hBackground = GetBackgroundBitmap(); |
| 128 | HPALETTE hPALbg = GetBackgroundPalette(); |
| 129 | |
| 130 | // this does not draw the background properly in report view |
| 131 | |
| 132 | GetClientRect(hWnd, &rcClient); |
| 133 | |
| 134 | htempDC = CreateCompatibleDC(hDC); |
| 135 | hOldBitmap = SelectObject(htempDC, hBackground); |
| 136 | |
| 137 | rgnBitmap = CreateRectRgnIndirect(&rcClient); |
| 138 | SelectClipRgn(hDC, rgnBitmap); |
| 139 | DeleteObject(rgnBitmap); |
| 140 | |
| 141 | hPAL = (!hPALbg) ? CreateHalftonePalette(hDC) : hPALbg; |
| 142 | |
| 143 | if (GetDeviceCaps(htempDC, RASTERCAPS) & RC_PALETTE && hPAL != NULL) |
| 144 | { |
| 145 | SelectPalette(htempDC, hPAL, FALSE); |
| 146 | RealizePalette(htempDC); |
| 147 | } |
| 148 | |
| 149 | // Get x and y offset |
| 150 | MapWindowPoints(hWnd, GetTreeView(), &pt, 1); |
| 151 | GetDCOrgEx(hDC, &ptOrigin); |
| 152 | ptOrigin.x -= pt.x; |
| 153 | ptOrigin.y -= pt.y; |
| 154 | ptOrigin.x = -GetScrollPos(hWnd, SB_HORZ); |
| 155 | ptOrigin.y = -GetScrollPos(hWnd, SB_VERT); |
| 156 | |
| 157 | if (pbmDesc->bmWidth && pbmDesc->bmHeight) |
| 158 | { |
| 159 | for (i = ptOrigin.x; i < rcClient.right; i += pbmDesc->bmWidth) |
| 160 | for (j = ptOrigin.y; j < rcClient.bottom; j += pbmDesc->bmHeight) |
| 161 | BitBlt(hDC, i, j, pbmDesc->bmWidth, pbmDesc->bmHeight, htempDC, 0, 0, SRCCOPY); |
| 162 | } |
| 163 | |
| 164 | SelectObject(htempDC, hOldBitmap); |
| 165 | DeleteDC(htempDC); |
| 166 | |
| 167 | if (!pbmDesc->bmColors) |
| 168 | { |
| 169 | DeleteObject(hPAL); |
| 170 | hPAL = 0; |
| 171 | } |
| 172 | |
| 173 | return TRUE; |
| 174 | } |
| 175 | |
| 176 | |
| 177 | |
| 178 | static BOOL ListViewNotify(HWND hWnd, LPNMHDR lpNmHdr) |
| 179 | { |
| 180 | RECT rcClient; |
| 181 | DWORD dwPos; |
| 182 | POINT pt; |
| 183 | |
| 184 | // This code is for using bitmap in the background |
| 185 | // Invalidate the right side of the control when a column is resized |
| 186 | if (lpNmHdr->code == HDN_ITEMCHANGINGA || lpNmHdr->code == HDN_ITEMCHANGINGW) |
| 187 | { |
| 188 | dwPos = GetMessagePos(); |
| 189 | pt.x = LOWORD(dwPos); |
| 190 | pt.y = HIWORD(dwPos); |
| 191 | |
| 192 | GetClientRect(hWnd, &rcClient); |
| 193 | ScreenToClient(hWnd, &pt); |
| 194 | rcClient.left = pt.x; |
| 195 | InvalidateRect(hWnd, &rcClient, FALSE); |
| 196 | } |
| 197 | return FALSE; |
| 198 | } |
| 199 | |
| 200 | |
| 201 | |
| 202 | static BOOL ListViewContextMenu(HWND hwndPicker, LPARAM lParam) |
| 203 | { |
| 204 | struct PickerInfo *pPickerInfo; |
| 205 | POINT pt, headerPt; |
| 206 | int i, nViewID, nColumn = -1; |
| 207 | HWND hwndHeader; |
| 208 | RECT rcCol; |
| 209 | |
| 210 | pPickerInfo = GetPickerInfo(hwndPicker); |
| 211 | |
| 212 | // Extract the point out of the lparam |
| 213 | pt.x = GET_X_LPARAM(lParam); |
| 214 | pt.y = GET_Y_LPARAM(lParam); |
| 215 | if (pt.x < 0 && pt.y < 0) |
| 216 | GetCursorPos(&pt); |
| 217 | |
| 218 | // Figure out which header column was clicked, if at all |
| 219 | nViewID = Picker_GetViewID(hwndPicker); |
| 220 | if ((nViewID == VIEW_REPORT) || (nViewID == VIEW_GROUPED)) |
| 221 | { |
| 222 | hwndHeader = ListView_GetHeader(hwndPicker); |
| 223 | headerPt = pt; |
| 224 | ScreenToClient(hwndHeader, &headerPt); |
| 225 | |
| 226 | for (i = 0; Header_GetItemRect(hwndHeader, i, &rcCol); i++) |
| 227 | { |
| 228 | if (PtInRect(&rcCol, headerPt)) |
| 229 | { |
| 230 | nColumn = i; |
| 231 | break; |
| 232 | } |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | if (nColumn >= 0) |
| 237 | { |
| 238 | // A column header was clicked |
| 239 | if (pPickerInfo->pCallbacks->pfnOnHeaderContextMenu) |
| 240 | pPickerInfo->pCallbacks->pfnOnHeaderContextMenu(pt, nColumn); |
| 241 | } |
| 242 | else |
| 243 | { |
| 244 | // The body was clicked |
| 245 | if (pPickerInfo->pCallbacks->pfnOnBodyContextMenu) |
| 246 | pPickerInfo->pCallbacks->pfnOnBodyContextMenu(pt); |
| 247 | } |
| 248 | return TRUE; |
| 249 | } |
| 250 | |
| 251 | |
| 252 | |
| 253 | static void Picker_Free(struct PickerInfo *pPickerInfo) |
| 254 | { |
| 255 | // Free up all resources associated with this picker structure |
| 256 | if (pPickerInfo->pnColumnsShown) |
| 257 | free(pPickerInfo->pnColumnsShown); |
| 258 | if (pPickerInfo->pnColumnsOrder) |
| 259 | free(pPickerInfo->pnColumnsOrder); |
| 260 | free(pPickerInfo); |
| 261 | } |
| 262 | |
| 263 | |
| 264 | |
| 265 | static LRESULT CALLBACK ListViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) |
| 266 | { |
| 267 | struct PickerInfo *pPickerInfo; |
| 268 | LRESULT rc = 0; |
| 269 | BOOL bHandled = FALSE; |
| 270 | WNDPROC pfnParentWndProc; |
| 271 | HWND hwndHeaderCtrl = NULL; |
| 272 | HFONT hHeaderCtrlFont = NULL; |
| 273 | |
| 274 | pPickerInfo = GetPickerInfo(hWnd); |
| 275 | pfnParentWndProc = pPickerInfo->pfnParentWndProc; |
| 276 | |
| 277 | switch(message) |
| 278 | { |
| 279 | case WM_MOUSEMOVE: |
| 280 | if (MouseHasBeenMoved()) |
| 281 | ShowCursor(TRUE); |
| 282 | break; |
| 283 | |
| 284 | case WM_ERASEBKGND: |
| 285 | if (GetBackgroundBitmap()) |
| 286 | { |
| 287 | rc = ListViewOnErase(hWnd, (HDC) wParam); |
| 288 | bHandled = TRUE; |
| 289 | } |
| 290 | break; |
| 291 | |
| 292 | case WM_NOTIFY: |
| 293 | bHandled = ListViewNotify(hWnd, (LPNMHDR) lParam); |
| 294 | break; |
| 295 | |
| 296 | case WM_SETFONT: |
| 297 | hwndHeaderCtrl = ListView_GetHeader(hWnd); |
| 298 | if (hwndHeaderCtrl) |
| 299 | hHeaderCtrlFont = GetWindowFont(hwndHeaderCtrl); |
| 300 | break; |
| 301 | |
| 302 | case WM_CONTEXTMENU: |
| 303 | bHandled = ListViewContextMenu(hWnd, lParam); |
| 304 | break; |
| 305 | |
| 306 | case WM_DESTROY: |
| 307 | // Received WM_DESTROY; time to clean up |
| 308 | if (pPickerInfo->pCallbacks->pfnSetViewMode) |
| 309 | pPickerInfo->pCallbacks->pfnSetViewMode(pPickerInfo->nCurrentViewID); |
| 310 | Picker_Free(pPickerInfo); |
| 311 | SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR) pfnParentWndProc); |
| 312 | SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) NULL); |
| 313 | break; |
| 314 | } |
| 315 | |
| 316 | if (!bHandled) |
| 317 | rc = CallParentWndProc(pfnParentWndProc, hWnd, message, wParam, lParam); |
| 318 | |
| 319 | // If we received WM_SETFONT, reset header ctrl font back to original font |
| 320 | if (hwndHeaderCtrl) |
| 321 | SetWindowFont(hwndHeaderCtrl, hHeaderCtrlFont, TRUE); |
| 322 | |
| 323 | return rc; |
| 324 | } |
| 325 | |
| 326 | |
| 327 | |
| 328 | // Re/initialize the ListControl Columns |
| 329 | static void Picker_InternalResetColumnDisplay(HWND hWnd, BOOL bFirstTime) |
| 330 | { |
| 331 | LV_COLUMN lvc; |
| 332 | int i; |
| 333 | int nColumn; |
| 334 | int *widths; |
| 335 | int *order; |
| 336 | int *shown; |
| 337 | int shown_columns; |
| 338 | LVCOLUMN col; |
| 339 | struct PickerInfo *pPickerInfo; |
| 340 | |
| 341 | pPickerInfo = GetPickerInfo(hWnd); |
| 342 | |
| 343 | widths = malloc(pPickerInfo->nColumnCount * sizeof(*widths)); |
| 344 | order = malloc(pPickerInfo->nColumnCount * sizeof(*order)); |
| 345 | shown = malloc(pPickerInfo->nColumnCount * sizeof(*shown)); |
| 346 | if (!widths || !order || !shown) |
| 347 | goto done; |
| 348 | |
| 349 | memset(widths, 0, pPickerInfo->nColumnCount * sizeof(*widths)); |
| 350 | memset(order, 0, pPickerInfo->nColumnCount * sizeof(*order)); |
| 351 | memset(shown, 0, pPickerInfo->nColumnCount * sizeof(*shown)); |
| 352 | pPickerInfo->pCallbacks->pfnGetColumnWidths(widths); |
| 353 | pPickerInfo->pCallbacks->pfnGetColumnOrder(order); |
| 354 | pPickerInfo->pCallbacks->pfnGetColumnShown(shown); |
| 355 | |
| 356 | if (!bFirstTime) |
| 357 | { |
| 358 | DWORD style = GetWindowLong(hWnd, GWL_STYLE); |
| 359 | |
| 360 | // switch the list view to LVS_REPORT style so column widths reported correctly |
| 361 | SetWindowLong(hWnd, GWL_STYLE, |
| 362 | (GetWindowLong(hWnd, GWL_STYLE) & ~LVS_TYPEMASK) | LVS_REPORT); |
| 363 | |
| 364 | // Retrieve each of the column widths |
| 365 | i = 0; |
| 366 | memset(&col, 0, sizeof(col)); |
| 367 | col.mask = LVCF_WIDTH; |
| 368 | while(ListView_GetColumn(hWnd, 0, &col)) |
| 369 | { |
| 370 | nColumn = Picker_GetRealColumnFromViewColumn(hWnd, i++); |
| 371 | widths[nColumn] = col.cx; |
| 372 | ListView_DeleteColumn(hWnd, 0); |
| 373 | } |
| 374 | |
| 375 | pPickerInfo->pCallbacks->pfnSetColumnWidths(widths); |
| 376 | |
| 377 | // restore old style |
| 378 | SetWindowLong(hWnd, GWL_STYLE, style); |
| 379 | } |
| 380 | |
| 381 | nColumn = 0; |
| 382 | for (i = 0; i < pPickerInfo->nColumnCount; i++) |
| 383 | { |
| 384 | if (shown[order[i]]) |
| 385 | { |
| 386 | lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT; |
| 387 | lvc.pszText = (LPTSTR) pPickerInfo->ppszColumnNames[order[i]]; |
| 388 | lvc.iSubItem = nColumn; |
| 389 | lvc.cx = widths[order[i]]; |
| 390 | lvc.fmt = LVCFMT_LEFT; |
| 391 | ListView_InsertColumn(hWnd, nColumn, &lvc); |
| 392 | pPickerInfo->pnColumnsOrder[nColumn] = order[i]; |
| 393 | |
| 394 | dprintf("Visible column %d: Logical column %d; Width=%d\n", nColumn, order[i], widths[order[i]]); |
| 395 | |
| 396 | nColumn++; |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | shown_columns = nColumn; |
| 401 | |
| 402 | /* Fill this in so we can still sort on columns NOT shown */ |
| 403 | for (i = 0; i < pPickerInfo->nColumnCount && nColumn < pPickerInfo->nColumnCount; i++) |
| 404 | { |
| 405 | if (!shown[order[i]]) |
| 406 | { |
| 407 | pPickerInfo->pnColumnsOrder[nColumn] = order[i]; |
| 408 | nColumn++; |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | if (GetListFontColor() == RGB(255, 255, 255)) |
| 413 | ListView_SetTextColor(hWnd, RGB(240, 240, 240)); |
| 414 | else |
| 415 | ListView_SetTextColor(hWnd, GetListFontColor()); |
| 416 | |
| 417 | done: |
| 418 | if (widths) |
| 419 | free(widths); |
| 420 | if (order) |
| 421 | free(order); |
| 422 | if (shown) |
| 423 | free(shown); |
| 424 | } |
| 425 | |
| 426 | |
| 427 | |
| 428 | void Picker_ResetColumnDisplay(HWND hWnd) |
| 429 | { |
| 430 | Picker_InternalResetColumnDisplay(hWnd, FALSE); |
| 431 | } |
| 432 | |
| 433 | |
| 434 | |
| 435 | void Picker_ClearIdle(HWND hwndPicker) |
| 436 | { |
| 437 | struct PickerInfo *pPickerInfo; |
| 438 | |
| 439 | pPickerInfo = GetPickerInfo(hwndPicker); |
| 440 | if (pPickerInfo->nTimer) |
| 441 | { |
| 442 | KillTimer(hwndPicker, 0); |
| 443 | pPickerInfo->nTimer = 0; |
| 444 | } |
| 445 | } |
| 446 | |
| 447 | |
| 448 | |
| 449 | static void CALLBACK Picker_TimerProc(HWND hwndPicker, UINT uMsg, |
| 450 | UINT_PTR idEvent, DWORD dwTime) |
| 451 | { |
| 452 | struct PickerInfo *pPickerInfo; |
| 453 | BOOL bContinueIdle; |
| 454 | DWORD nTickCount, nBaseTickCount; |
| 455 | DWORD nMaxIdleTicks = 50; |
| 456 | |
| 457 | pPickerInfo = GetPickerInfo(hwndPicker); |
| 458 | bContinueIdle = FALSE; |
| 459 | nBaseTickCount = GetTickCount(); |
| 460 | |
| 461 | // This idle procedure will loop until either idling is over, or until |
| 462 | // a specified amount of time elapses (in this case, 50ms). This frees |
| 463 | // idle callbacks of any responsibility for balancing their workloads; the |
| 464 | // picker code will |
| 465 | do |
| 466 | { |
| 467 | if (pPickerInfo->pCallbacks->pfnOnIdle) |
| 468 | bContinueIdle = pPickerInfo->pCallbacks->pfnOnIdle(hwndPicker); |
| 469 | nTickCount = GetTickCount(); |
| 470 | } |
| 471 | while(bContinueIdle && ((nTickCount - nBaseTickCount) < nMaxIdleTicks)); |
| 472 | |
| 473 | if (!bContinueIdle) |
| 474 | Picker_ClearIdle(hwndPicker); |
| 475 | } |
| 476 | |
| 477 | |
| 478 | |
| 479 | // Instructs this picker to reset idling; idling will continue until the |
| 480 | // idle function returns FALSE |
| 481 | void Picker_ResetIdle(HWND hwndPicker) |
| 482 | { |
| 483 | struct PickerInfo *pPickerInfo; |
| 484 | |
| 485 | pPickerInfo = GetPickerInfo(hwndPicker); |
| 486 | |
| 487 | Picker_ClearIdle(hwndPicker); |
| 488 | if (pPickerInfo->pCallbacks->pfnOnIdle) |
| 489 | pPickerInfo->nTimer = SetTimer(hwndPicker, 0, 0, Picker_TimerProc); |
| 490 | } |
| 491 | |
| 492 | |
| 493 | |
| 494 | BOOL Picker_IsIdling(HWND hwndPicker) |
| 495 | { |
| 496 | struct PickerInfo *pPickerInfo; |
| 497 | pPickerInfo = GetPickerInfo(hwndPicker); |
| 498 | return pPickerInfo->nTimer != 0; |
| 499 | } |
| 500 | |
| 501 | |
| 502 | |
| 503 | BOOL SetupPicker(HWND hwndPicker, const struct PickerOptions *pOptions) |
| 504 | { |
| 505 | struct PickerInfo *pPickerInfo; |
| 506 | int i; |
| 507 | LONG_PTR l; |
| 508 | |
| 509 | assert(hwndPicker); |
| 510 | |
| 511 | // Allocate the list view struct |
| 512 | pPickerInfo = (struct PickerInfo *) malloc(sizeof(struct PickerInfo)); |
| 513 | if (!pPickerInfo) |
| 514 | return FALSE; |
| 515 | |
| 516 | // And fill it out |
| 517 | memset(pPickerInfo, 0, sizeof(*pPickerInfo)); |
| 518 | pPickerInfo->pCallbacks = pOptions->pCallbacks; |
| 519 | pPickerInfo->nColumnCount = pOptions->nColumnCount; |
| 520 | pPickerInfo->ppszColumnNames = pOptions->ppszColumnNames; |
| 521 | pPickerInfo->nLastItem = -1; |
| 522 | |
| 523 | if (pPickerInfo->nColumnCount) |
| 524 | { |
| 525 | // Allocate space for the column order and columns shown array |
| 526 | pPickerInfo->pnColumnsOrder = malloc(pPickerInfo->nColumnCount * |
| 527 | sizeof(*pPickerInfo->pnColumnsOrder)); |
| 528 | pPickerInfo->pnColumnsShown = malloc(pPickerInfo->nColumnCount * |
| 529 | sizeof(*pPickerInfo->pnColumnsShown)); |
| 530 | if (!pPickerInfo->pnColumnsOrder || !pPickerInfo->pnColumnsShown) |
| 531 | goto error; |
| 532 | |
| 533 | // set up initial values |
| 534 | for (i = 0; i < pPickerInfo->nColumnCount; i++) |
| 535 | { |
| 536 | pPickerInfo->pnColumnsOrder[i] = i; |
| 537 | pPickerInfo->pnColumnsShown[i] = TRUE; |
| 538 | } |
| 539 | |
| 540 | if (GetUseOldControl()) |
| 541 | { |
| 542 | if (pPickerInfo->pCallbacks->pfnSetColumnOrder) |
| 543 | pPickerInfo->pCallbacks->pfnSetColumnOrder(pPickerInfo->pnColumnsOrder); |
| 544 | if (pPickerInfo->pCallbacks->pfnSetColumnShown) |
| 545 | pPickerInfo->pCallbacks->pfnSetColumnShown(pPickerInfo->pnColumnsShown); |
| 546 | } |
| 547 | else |
| 548 | { |
| 549 | if (pPickerInfo->pCallbacks->pfnGetColumnOrder) |
| 550 | pPickerInfo->pCallbacks->pfnGetColumnOrder(pPickerInfo->pnColumnsOrder); |
| 551 | if (pPickerInfo->pCallbacks->pfnGetColumnShown) |
| 552 | pPickerInfo->pCallbacks->pfnGetColumnShown(pPickerInfo->pnColumnsShown); |
| 553 | } |
| 554 | } |
| 555 | |
| 556 | // Hook in our wndproc and userdata pointer |
| 557 | l = GetWindowLongPtr(hwndPicker, GWLP_WNDPROC); |
| 558 | pPickerInfo->pfnParentWndProc = (WNDPROC) l; |
| 559 | SetWindowLongPtr(hwndPicker, GWLP_USERDATA, (LONG_PTR) pPickerInfo); |
| 560 | SetWindowLongPtr(hwndPicker, GWLP_WNDPROC, (LONG_PTR) ListViewWndProc); |
| 561 | |
| 562 | ListView_SetExtendedListViewStyle(hwndPicker, LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP | |
| 563 | LVS_EX_UNDERLINEHOT | LVS_EX_UNDERLINECOLD | LVS_EX_LABELTIP); |
| 564 | |
| 565 | Picker_InternalResetColumnDisplay(hwndPicker, TRUE); |
| 566 | Picker_ResetIdle(hwndPicker); |
| 567 | return TRUE; |
| 568 | |
| 569 | error: |
| 570 | if (pPickerInfo) |
| 571 | Picker_Free(pPickerInfo); |
| 572 | return FALSE; |
| 573 | } |
| 574 | |
| 575 | |
| 576 | |
| 577 | int Picker_GetViewID(HWND hwndPicker) |
| 578 | { |
| 579 | struct PickerInfo *pPickerInfo; |
| 580 | pPickerInfo = GetPickerInfo(hwndPicker); |
| 581 | return pPickerInfo->nCurrentViewID; |
| 582 | } |
| 583 | |
| 584 | |
| 585 | |
| 586 | void Picker_SetViewID(HWND hwndPicker, int nViewID) |
| 587 | { |
| 588 | struct PickerInfo *pPickerInfo; |
| 589 | LONG_PTR nListViewStyle; |
| 590 | DWORD dwStyle; |
| 591 | |
| 592 | pPickerInfo = GetPickerInfo(hwndPicker); |
| 593 | |
| 594 | // Change the nCurrentViewID member |
| 595 | pPickerInfo->nCurrentViewID = nViewID; |
| 596 | if (pPickerInfo->pCallbacks->pfnSetViewMode) |
| 597 | pPickerInfo->pCallbacks->pfnSetViewMode(pPickerInfo->nCurrentViewID); |
| 598 | |
| 599 | // Change the ListView flags in accordance |
| 600 | switch(nViewID) |
| 601 | { |
| 602 | case VIEW_LARGE_ICONS: |
| 603 | nListViewStyle = LVS_ICON; |
| 604 | break; |
| 605 | case VIEW_SMALL_ICONS: |
| 606 | nListViewStyle = LVS_SMALLICON; |
| 607 | break; |
| 608 | case VIEW_INLIST: |
| 609 | nListViewStyle = LVS_LIST; |
| 610 | break; |
| 611 | case VIEW_GROUPED: |
| 612 | case VIEW_REPORT: |
| 613 | default: |
| 614 | nListViewStyle = LVS_REPORT; |
| 615 | break; |
| 616 | } |
| 617 | |
| 618 | dwStyle = GetWindowLong(hwndPicker, GWL_STYLE); |
| 619 | if (GetUseXPControl()) |
| 620 | { |
| 621 | // RS Microsoft must have changed something in the Ownerdraw handling with Version 6 of the Common Controls |
| 622 | // as on all other OSes it works without this... |
| 623 | if (nViewID == VIEW_LARGE_ICONS || nViewID == VIEW_SMALL_ICONS) |
| 624 | { |
| 625 | // remove Ownerdraw style for Icon views |
| 626 | dwStyle &= ~LVS_OWNERDRAWFIXED; |
| 627 | if( nViewID == VIEW_SMALL_ICONS ) |
| 628 | { |
| 629 | // to properly get them to arrange, otherwise the entries might overlap |
| 630 | // we have to call SetWindowLong to get it into effect !! |
| 631 | // It's no use just setting the Style, as it's changed again further down... |
| 632 | SetWindowLong(hwndPicker, GWL_STYLE, (GetWindowLong(hwndPicker, GWL_STYLE) |
| 633 | & ~LVS_TYPEMASK) | LVS_ICON); |
| 634 | } |
| 635 | } |
| 636 | else |
| 637 | { |
| 638 | // add again.. |
| 639 | dwStyle |= LVS_OWNERDRAWFIXED; |
| 640 | } |
| 641 | } |
| 642 | |
| 643 | dwStyle &= ~LVS_TYPEMASK; |
| 644 | dwStyle |= nListViewStyle; |
| 645 | SetWindowLong(hwndPicker, GWL_STYLE, dwStyle); |
| 646 | RedrawWindow(hwndPicker, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME); |
| 647 | } |
| 648 | |
| 649 | |
| 650 | |
| 651 | static BOOL PickerHitTest(HWND hWnd) |
| 652 | { |
| 653 | RECT rect; |
| 654 | POINTS p; |
| 655 | DWORD res = GetMessagePos(); |
| 656 | LVHITTESTINFO htInfo; |
| 657 | |
| 658 | memset(&htInfo, 0, sizeof(htInfo)); |
| 659 | p = MAKEPOINTS(res); |
| 660 | GetWindowRect(hWnd, &rect); |
| 661 | htInfo.pt.x = p.x - rect.left; |
| 662 | htInfo.pt.y = p.y - rect.top; |
| 663 | ListView_HitTest(hWnd, &htInfo); |
| 664 | |
| 665 | return (! (htInfo.flags & LVHT_NOWHERE)); |
| 666 | } |
| 667 | |
| 668 | |
| 669 | |
| 670 | int Picker_GetSelectedItem(HWND hWnd) |
| 671 | { |
| 672 | int nItem; |
| 673 | LV_ITEM lvi; |
| 674 | |
| 675 | nItem = ListView_GetNextItem(hWnd, -1, LVIS_SELECTED | LVIS_FOCUSED); |
| 676 | if (nItem < 0) |
| 677 | return 0; |
| 678 | |
| 679 | memset(&lvi, 0, sizeof(lvi)); |
| 680 | lvi.iItem = nItem; |
| 681 | lvi.mask = LVIF_PARAM; |
| 682 | ListView_GetItem(hWnd, &lvi); |
| 683 | return lvi.lParam; |
| 684 | } |
| 685 | |
| 686 | |
| 687 | |
| 688 | void Picker_SetSelectedPick(HWND hWnd, int nIndex) |
| 689 | { |
| 690 | if (nIndex < 0) |
| 691 | nIndex = 0; |
| 692 | |
| 693 | ListView_SetItemState(hWnd, nIndex, LVIS_FOCUSED | LVIS_SELECTED, |
| 694 | LVIS_FOCUSED | LVIS_SELECTED); |
| 695 | ListView_EnsureVisible(hWnd, nIndex, FALSE); |
| 696 | } |
| 697 | |
| 698 | |
| 699 | |
| 700 | void Picker_SetSelectedItem(HWND hWnd, int nItem) |
| 701 | { |
| 702 | int i; |
| 703 | LV_FINDINFO lvfi; |
| 704 | |
| 705 | if (nItem < 0) |
| 706 | return; |
| 707 | |
| 708 | lvfi.flags = LVFI_PARAM; |
| 709 | lvfi.lParam = nItem; |
| 710 | i = ListView_FindItem(hWnd, -1, &lvfi); |
| 711 | if (i == -1) |
| 712 | { |
| 713 | POINT p = {0,0}; |
| 714 | lvfi.flags = LVFI_NEARESTXY; |
| 715 | lvfi.pt = p; |
| 716 | i = ListView_FindItem(hWnd, -1, &lvfi); |
| 717 | } |
| 718 | Picker_SetSelectedPick(hWnd, (i == -1) ? 0 : i); |
| 719 | } |
| 720 | |
| 721 | |
| 722 | |
| 723 | static const TCHAR *Picker_CallGetItemString(HWND hwndPicker, |
| 724 | int nItem, int nColumn, TCHAR *pszBuffer, UINT nBufferLength) |
| 725 | { |
| 726 | // this call wraps the pfnGetItemString callback to properly set up the |
| 727 | // buffers, and normalize the results |
| 728 | struct PickerInfo *pPickerInfo; |
| 729 | const TCHAR *s; |
| 730 | |
| 731 | pPickerInfo = GetPickerInfo(hwndPicker); |
| 732 | pszBuffer[0] = '\0'; |
| 733 | s = NULL; |
| 734 | |
| 735 | if (pPickerInfo->pCallbacks->pfnGetItemString) |
| 736 | { |
| 737 | s = pPickerInfo->pCallbacks->pfnGetItemString(hwndPicker, |
| 738 | nItem, nColumn, pszBuffer, nBufferLength); |
| 739 | } |
| 740 | if (!s) |
| 741 | s = pszBuffer; |
| 742 | return s; |
| 743 | } |
| 744 | |
| 745 | |
| 746 | |
| 747 | // put the arrow on the new sort column |
| 748 | static void Picker_ResetHeaderSortIcon(HWND hwndPicker) |
| 749 | { |
| 750 | struct PickerInfo *pPickerInfo; |
| 751 | HWND hwndHeader; |
| 752 | HD_ITEM hdi; |
| 753 | int i, nViewColumn; |
| 754 | |
| 755 | pPickerInfo = GetPickerInfo(hwndPicker); |
| 756 | |
| 757 | hwndHeader = ListView_GetHeader(hwndPicker); |
| 758 | |
| 759 | // take arrow off non-current columns |
| 760 | hdi.mask = HDI_FORMAT; |
| 761 | hdi.fmt = HDF_STRING; |
| 762 | for (i = 0; i < pPickerInfo->nColumnCount; i++) |
| 763 | { |
| 764 | if (i != pPickerInfo->pCallbacks->pfnGetSortColumn()) |
| 765 | Header_SetItem(hwndHeader, Picker_GetViewColumnFromRealColumn(hwndPicker, i), &hdi); |
| 766 | } |
| 767 | |
| 768 | if (GetUseXPControl()) |
| 769 | { |
| 770 | // use built in sort arrows |
| 771 | hdi.mask = HDI_FORMAT; |
| 772 | hdi.fmt = HDF_STRING | (pPickerInfo->pCallbacks->pfnGetSortReverse() ? HDF_SORTDOWN : HDF_SORTUP); |
| 773 | } |
| 774 | else |
| 775 | { |
| 776 | // put our arrow icon next to the text |
| 777 | hdi.mask = HDI_FORMAT | HDI_IMAGE; |
| 778 | hdi.fmt = HDF_STRING | HDF_IMAGE | HDF_BITMAP_ON_RIGHT; |
| 779 | hdi.iImage = pPickerInfo->pCallbacks->pfnGetSortReverse() ? 1 : 0; |
| 780 | } |
| 781 | |
| 782 | nViewColumn = Picker_GetViewColumnFromRealColumn(hwndPicker, pPickerInfo->pCallbacks->pfnGetSortColumn()); |
| 783 | Header_SetItem(hwndHeader, nViewColumn, &hdi); |
| 784 | } |
| 785 | |
| 786 | |
| 787 | |
| 788 | struct CompareProcParams |
| 789 | { |
| 790 | HWND hwndPicker; |
| 791 | struct PickerInfo *pPickerInfo; |
| 792 | int nSortColumn; |
| 793 | int nViewMode; |
| 794 | BOOL bReverse; |
| 795 | }; |
| 796 | |
| 797 | |
| 798 | |
| 799 | static void Picker_PopulateCompareProcParams(HWND hwndPicker, |
| 800 | struct CompareProcParams *pParams) |
| 801 | { |
| 802 | struct PickerInfo *pPickerInfo; |
| 803 | |
| 804 | pPickerInfo = GetPickerInfo(hwndPicker); |
| 805 | |
| 806 | // populate the CompareProcParams structure |
| 807 | memset(pParams, 0, sizeof(*pParams)); |
| 808 | pParams->hwndPicker = hwndPicker; |
| 809 | pParams->pPickerInfo = pPickerInfo; |
| 810 | pParams->nViewMode = pPickerInfo->pCallbacks->pfnGetViewMode(); |
| 811 | if (pPickerInfo->pCallbacks->pfnGetSortColumn) |
| 812 | pParams->nSortColumn = pPickerInfo->pCallbacks->pfnGetSortColumn(); |
| 813 | if (pPickerInfo->pCallbacks->pfnGetSortReverse) |
| 814 | pParams->bReverse = pPickerInfo->pCallbacks->pfnGetSortReverse(); |
| 815 | } |
| 816 | |
| 817 | |
| 818 | |
| 819 | static int CALLBACK Picker_CompareProc(LPARAM index1, LPARAM index2, LPARAM nParamSort) |
| 820 | { |
| 821 | struct CompareProcParams *pcpp = (struct CompareProcParams *) nParamSort; |
| 822 | struct PickerInfo *pPickerInfo = pcpp->pPickerInfo; |
| 823 | BOOL bCallCompare = TRUE; |
| 824 | int nResult = 0, nParent1, nParent2; |
| 825 | TCHAR szBuffer1[256], szBuffer2[256]; |
| 826 | const TCHAR *s1, *s2; |
| 827 | |
| 828 | if (pcpp->nViewMode == VIEW_GROUPED) |
| 829 | { |
| 830 | // do our fancy compare, with clones grouped under parents |
| 831 | // first thing we need to do is identify both item's parents |
| 832 | if (pPickerInfo->pCallbacks->pfnFindItemParent) |
| 833 | { |
| 834 | nParent1 = pPickerInfo->pCallbacks->pfnFindItemParent(pcpp->hwndPicker, index1); |
| 835 | nParent2 = pPickerInfo->pCallbacks->pfnFindItemParent(pcpp->hwndPicker, index2); |
| 836 | } |
| 837 | else |
| 838 | { |
| 839 | nParent1 = nParent2 = -1; |
| 840 | } |
| 841 | |
| 842 | if ((nParent1 < 0) && (nParent2 < 0)) |
| 843 | { |
| 844 | // if both entries are both parents, we just do a basic sort |
| 845 | } |
| 846 | else if ((nParent1 >= 0) && (nParent2 >= 0)) |
| 847 | { |
| 848 | // if both entries are children and the parents are different, |
| 849 | // sort on their parents |
| 850 | if (nParent1 != nParent2) |
| 851 | { |
| 852 | index1 = nParent1; |
| 853 | index2 = nParent2; |
| 854 | } |
| 855 | } |
| 856 | else |
| 857 | { |
| 858 | // one parent, one child |
| 859 | if (nParent1 >= 0) |
| 860 | { |
| 861 | // first one is a child |
| 862 | if (nParent1 == index2) |
| 863 | { |
| 864 | // if this is a child and its parent, put child after |
| 865 | nResult = 1; |
| 866 | bCallCompare = FALSE; |
| 867 | } |
| 868 | else |
| 869 | { |
| 870 | // sort on parent |
| 871 | index1 = nParent1; |
| 872 | } |
| 873 | } |
| 874 | else |
| 875 | { |
| 876 | // second one is a child |
| 877 | if (nParent2 == index1) |
| 878 | { |
| 879 | // if this is a child and its parent, put child after |
| 880 | nResult = -1; |
| 881 | bCallCompare = FALSE; |
| 882 | } |
| 883 | else |
| 884 | { |
| 885 | // sort on parent |
| 886 | index2 = nParent2; |
| 887 | } |
| 888 | } |
| 889 | } |
| 890 | } |
| 891 | |
| 892 | if (bCallCompare) |
| 893 | { |
| 894 | if (pPickerInfo->pCallbacks->pfnCompare) |
| 895 | { |
| 896 | nResult = pPickerInfo->pCallbacks->pfnCompare(pcpp->hwndPicker, |
| 897 | index1, index2, pcpp->nSortColumn); |
| 898 | } |
| 899 | else |
| 900 | { |
| 901 | // no default sort proc, just get the string and compare them |
| 902 | s1 = Picker_CallGetItemString(pcpp->hwndPicker, index1, pcpp->nSortColumn, |
| 903 | szBuffer1, sizeof(szBuffer1) / sizeof(szBuffer1[0])); |
| 904 | s2 = Picker_CallGetItemString(pcpp->hwndPicker, index2, pcpp->nSortColumn, |
| 905 | szBuffer2, sizeof(szBuffer2) / sizeof(szBuffer2[0])); |
| 906 | nResult = _tcsicmp(s1, s2); |
| 907 | } |
| 908 | |
| 909 | if (pcpp->bReverse) |
| 910 | nResult = -nResult; |
| 911 | } |
| 912 | return nResult; |
| 913 | } |
| 914 | |
| 915 | |
| 916 | |
| 917 | void Picker_Sort(HWND hwndPicker) |
| 918 | { |
| 919 | LV_FINDINFO lvfi; |
| 920 | struct PickerInfo *pPickerInfo; |
| 921 | struct CompareProcParams params; |
| 922 | int nItem; |
| 923 | |
| 924 | pPickerInfo = GetPickerInfo(hwndPicker); |
| 925 | |
| 926 | // populate the CompareProcParams structure |
| 927 | Picker_PopulateCompareProcParams(hwndPicker, ¶ms); |
| 928 | |
| 929 | ListView_SortItems(hwndPicker, Picker_CompareProc, (LPARAM) ¶ms); |
| 930 | |
| 931 | Picker_ResetHeaderSortIcon(hwndPicker); |
| 932 | |
| 933 | memset(&lvfi, 0, sizeof(lvfi)); |
| 934 | lvfi.flags = LVFI_PARAM; |
| 935 | lvfi.lParam = Picker_GetSelectedItem(hwndPicker); |
| 936 | nItem = ListView_FindItem(hwndPicker, -1, &lvfi); |
| 937 | |
| 938 | ListView_EnsureVisible(hwndPicker, nItem, FALSE); |
| 939 | } |
| 940 | |
| 941 | |
| 942 | |
| 943 | int Picker_InsertItemSorted(HWND hwndPicker, int nParam) |
| 944 | { |
| 945 | struct PickerInfo *pPickerInfo; |
| 946 | int nHigh, nLow, nMid; |
| 947 | struct CompareProcParams params; |
| 948 | int nCompareResult; |
| 949 | LVITEM lvi; |
| 950 | |
| 951 | pPickerInfo = GetPickerInfo(hwndPicker); |
| 952 | |
| 953 | nLow = 0; |
| 954 | nHigh = ListView_GetItemCount(hwndPicker); |
| 955 | |
| 956 | // populate the CompareProcParams structure |
| 957 | Picker_PopulateCompareProcParams(hwndPicker, ¶ms); |
| 958 | |
| 959 | while(nLow < nHigh) |
| 960 | { |
| 961 | nMid = (nHigh + nLow) / 2; |
| 962 | |
| 963 | memset(&lvi, 0, sizeof(lvi)); |
| 964 | lvi.mask = LVIF_PARAM; |
| 965 | lvi.iItem = nMid; |
| 966 | ListView_GetItem(hwndPicker, &lvi); |
| 967 | |
| 968 | nCompareResult = Picker_CompareProc(nParam, lvi.lParam, (LPARAM) ¶ms); |
| 969 | |
| 970 | if (nCompareResult > 0) |
| 971 | nLow = nMid + 1; |
| 972 | else if (nCompareResult < 0) |
| 973 | nHigh = nMid; |
| 974 | else |
| 975 | { |
| 976 | nLow = nMid; |
| 977 | break; |
| 978 | } |
| 979 | } |
| 980 | |
| 981 | memset(&lvi, 0, sizeof(lvi)); |
| 982 | lvi.mask = LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM; |
| 983 | lvi.iItem = nLow; |
| 984 | lvi.iSubItem = 0; |
| 985 | lvi.lParam = nParam; |
| 986 | lvi.pszText = LPSTR_TEXTCALLBACK; |
| 987 | lvi.iImage = I_IMAGECALLBACK; |
| 988 | |
| 989 | return ListView_InsertItem(hwndPicker, &lvi); |
| 990 | } |
| 991 | |
| 992 | |
| 993 | |
| 994 | int Picker_GetRealColumnFromViewColumn(HWND hWnd, int nViewColumn) |
| 995 | { |
| 996 | struct PickerInfo *pPickerInfo; |
| 997 | int nRealColumn = 0; |
| 998 | |
| 999 | pPickerInfo = GetPickerInfo(hWnd); |
| 1000 | if (nViewColumn >= 0 && nViewColumn < pPickerInfo->nColumnCount) |
| 1001 | nRealColumn = pPickerInfo->pnColumnsOrder[nViewColumn]; |
| 1002 | return nRealColumn; |
| 1003 | } |
| 1004 | |
| 1005 | |
| 1006 | |
| 1007 | int Picker_GetViewColumnFromRealColumn(HWND hWnd, int nRealColumn) |
| 1008 | { |
| 1009 | struct PickerInfo *pPickerInfo; |
| 1010 | int i; |
| 1011 | |
| 1012 | pPickerInfo = GetPickerInfo(hWnd); |
| 1013 | for (i = 0; i < pPickerInfo->nColumnCount; i++) |
| 1014 | { |
| 1015 | if (pPickerInfo->pnColumnsOrder[i] == nRealColumn) |
| 1016 | return i; |
| 1017 | } |
| 1018 | |
| 1019 | // major error, shouldn't be possible, but no good way to warn |
| 1020 | return 0; |
| 1021 | } |
| 1022 | |
| 1023 | |
| 1024 | |
| 1025 | BOOL Picker_HandleNotify(LPNMHDR lpNmHdr) |
| 1026 | { |
| 1027 | struct PickerInfo *pPickerInfo; |
| 1028 | HWND hWnd; |
| 1029 | BOOL bResult = FALSE; |
| 1030 | NM_LISTVIEW *pnmv; |
| 1031 | LV_DISPINFO *pDispInfo; |
| 1032 | int nItem, nColumn; |
| 1033 | const TCHAR *s; |
| 1034 | BOOL bReverse; |
| 1035 | |
| 1036 | hWnd = lpNmHdr->hwndFrom; |
| 1037 | pPickerInfo = GetPickerInfo(hWnd); |
| 1038 | pnmv = (NM_LISTVIEW *) lpNmHdr; |
| 1039 | |
| 1040 | switch(lpNmHdr->code) |
| 1041 | { |
| 1042 | case NM_RCLICK: |
| 1043 | case NM_CLICK: |
| 1044 | case NM_DBLCLK: |
| 1045 | // don't allow selection of blank spaces in the listview |
| 1046 | if (!PickerHitTest(hWnd)) |
| 1047 | { |
| 1048 | // we have no current item selected |
| 1049 | if (pPickerInfo->nLastItem != -1) |
| 1050 | { |
| 1051 | Picker_SetSelectedItem(hWnd, pPickerInfo->nLastItem); |
| 1052 | } |
| 1053 | bResult = TRUE; |
| 1054 | } |
| 1055 | else if ((lpNmHdr->code == NM_DBLCLK) && (pPickerInfo->pCallbacks->pfnDoubleClick)) |
| 1056 | { |
| 1057 | // double click! |
| 1058 | pPickerInfo->pCallbacks->pfnDoubleClick(); |
| 1059 | bResult = TRUE; |
| 1060 | } |
| 1061 | break; |
| 1062 | |
| 1063 | case LVN_GETDISPINFO: |
| 1064 | pDispInfo = (LV_DISPINFO *) lpNmHdr; |
| 1065 | nItem = (int) pDispInfo->item.lParam; |
| 1066 | |
| 1067 | if (pDispInfo->item.mask & LVIF_IMAGE) |
| 1068 | { |
| 1069 | // retrieve item image |
| 1070 | if (pPickerInfo->pCallbacks->pfnGetItemImage) |
| 1071 | pDispInfo->item.iImage = pPickerInfo->pCallbacks->pfnGetItemImage(hWnd, nItem); |
| 1072 | else |
| 1073 | pDispInfo->item.iImage = 0; |
| 1074 | bResult = TRUE; |
| 1075 | } |
| 1076 | |
| 1077 | if (pDispInfo->item.mask & LVIF_STATE) |
| 1078 | { |
| 1079 | pDispInfo->item.state = 0; |
| 1080 | bResult = TRUE; |
| 1081 | } |
| 1082 | |
| 1083 | if (pDispInfo->item.mask & LVIF_TEXT) |
| 1084 | { |
| 1085 | // retrieve item text |
| 1086 | nColumn = Picker_GetRealColumnFromViewColumn(hWnd, pDispInfo->item.iSubItem); |
| 1087 | |
| 1088 | s = Picker_CallGetItemString(hWnd, nItem, nColumn, |
| 1089 | pDispInfo->item.pszText, pDispInfo->item.cchTextMax); |
| 1090 | |
| 1091 | pDispInfo->item.pszText = (TCHAR *) s; |
| 1092 | bResult = TRUE; |
| 1093 | } |
| 1094 | break; |
| 1095 | |
| 1096 | case LVN_ITEMCHANGED: |
| 1097 | if ((pnmv->uOldState & LVIS_SELECTED) |
| 1098 | && !(pnmv->uNewState & LVIS_SELECTED)) |
| 1099 | { |
| 1100 | if (pnmv->lParam != -1) |
| 1101 | pPickerInfo->nLastItem = pnmv->lParam; |
| 1102 | if (pPickerInfo->pCallbacks->pfnLeavingItem) |
| 1103 | pPickerInfo->pCallbacks->pfnLeavingItem(hWnd, pnmv->lParam); |
| 1104 | } |
| 1105 | if (!(pnmv->uOldState & LVIS_SELECTED) |
| 1106 | && (pnmv->uNewState & LVIS_SELECTED)) |
| 1107 | { |
| 1108 | if (pPickerInfo->pCallbacks->pfnEnteringItem) |
| 1109 | pPickerInfo->pCallbacks->pfnEnteringItem(hWnd, pnmv->lParam); |
| 1110 | } |
| 1111 | bResult = TRUE; |
| 1112 | break; |
| 1113 | |
| 1114 | case LVN_COLUMNCLICK: |
| 1115 | // if clicked on the same column we're sorting by, reverse it |
| 1116 | if (pPickerInfo->pCallbacks->pfnGetSortColumn() == Picker_GetRealColumnFromViewColumn(hWnd, pnmv->iSubItem)) |
| 1117 | bReverse = !pPickerInfo->pCallbacks->pfnGetSortReverse(); |
| 1118 | else |
| 1119 | bReverse = FALSE; |
| 1120 | pPickerInfo->pCallbacks->pfnSetSortReverse(bReverse); |
| 1121 | pPickerInfo->pCallbacks->pfnSetSortColumn(Picker_GetRealColumnFromViewColumn(hWnd, pnmv->iSubItem)); |
| 1122 | Picker_Sort(hWnd); |
| 1123 | bResult = TRUE; |
| 1124 | break; |
| 1125 | |
| 1126 | case LVN_BEGINDRAG: |
| 1127 | if (pPickerInfo->pCallbacks->pfnBeginListViewDrag) |
| 1128 | pPickerInfo->pCallbacks->pfnBeginListViewDrag(pnmv); |
| 1129 | break; |
| 1130 | } |
| 1131 | return bResult; |
| 1132 | } |
| 1133 | |
| 1134 | |
| 1135 | |
| 1136 | int Picker_GetNumColumns(HWND hWnd) |
| 1137 | { |
| 1138 | int nColumnCount = 0; |
| 1139 | int i; |
| 1140 | HWND hwndHeader; |
| 1141 | int *shown; |
| 1142 | struct PickerInfo *pPickerInfo; |
| 1143 | |
| 1144 | pPickerInfo = GetPickerInfo(hWnd); |
| 1145 | |
| 1146 | shown = malloc(pPickerInfo->nColumnCount * sizeof(*shown)); |
| 1147 | if (!shown) |
| 1148 | return -1; |
| 1149 | |
| 1150 | pPickerInfo->pCallbacks->pfnGetColumnShown(shown); |
| 1151 | hwndHeader = ListView_GetHeader(hWnd); |
| 1152 | |
| 1153 | if (GetUseOldControl() || (nColumnCount = Header_GetItemCount(hWnd)) < 1) |
| 1154 | { |
| 1155 | nColumnCount = 0; |
| 1156 | for (i = 0; i < pPickerInfo->nColumnCount ; i++ ) |
| 1157 | { |
| 1158 | if (shown[i]) |
| 1159 | nColumnCount++; |
| 1160 | } |
| 1161 | } |
| 1162 | |
| 1163 | free(shown); |
| 1164 | return nColumnCount; |
| 1165 | } |
| 1166 | |
| 1167 | |
| 1168 | |
| 1169 | /* Add ... to Items in ListView if needed */ |
| 1170 | static LPCTSTR MakeShortString(HDC hDC, LPCTSTR lpszLong, int nColumnLen, int nOffset) |
| 1171 | { |
| 1172 | static const TCHAR szThreeDots[] = TEXT("..."); |
| 1173 | static TCHAR szShort[MAX_PATH]; |
| 1174 | int nStringLen = lstrlen(lpszLong); |
| 1175 | int nAddLen; |
| 1176 | SIZE size; |
| 1177 | int i; |
| 1178 | |
| 1179 | GetTextExtentPoint32(hDC, lpszLong, nStringLen, &size); |
| 1180 | if (nStringLen == 0 || size.cx + nOffset <= nColumnLen) |
| 1181 | return lpszLong; |
| 1182 | |
| 1183 | lstrcpy(szShort, lpszLong); |
| 1184 | GetTextExtentPoint32(hDC, szThreeDots, sizeof(szThreeDots), &size); |
| 1185 | nAddLen = size.cx; |
| 1186 | |
| 1187 | for (i = nStringLen - 1; i > 0; i--) |
| 1188 | { |
| 1189 | szShort[i] = 0; |
| 1190 | GetTextExtentPoint32(hDC, szShort, i, &size); |
| 1191 | if (size.cx + nOffset + nAddLen <= nColumnLen) |
| 1192 | break; |
| 1193 | } |
| 1194 | |
| 1195 | lstrcat(szShort, szThreeDots); |
| 1196 | |
| 1197 | return szShort; |
| 1198 | } |
| 1199 | |
| 1200 | |
| 1201 | |
| 1202 | void Picker_HandleDrawItem(HWND hWnd, LPDRAWITEMSTRUCT lpDrawItemStruct) |
| 1203 | { |
| 1204 | struct PickerInfo *pPickerInfo; |
| 1205 | HDC hDC = lpDrawItemStruct->hDC; |
| 1206 | RECT rcItem = lpDrawItemStruct->rcItem; |
| 1207 | UINT uiFlags = ILD_TRANSPARENT; |
| 1208 | HIMAGELIST hImageList; |
| 1209 | int nItem = lpDrawItemStruct->itemID; |
| 1210 | COLORREF clrTextSave = 0; |
| 1211 | COLORREF clrBkSave = 0; |
| 1212 | COLORREF clrImage = GetSysColor(COLOR_WINDOW); |
| 1213 | static TCHAR szBuff[MAX_PATH]; |
| 1214 | BOOL bFocus = (GetFocus() == hWnd); |
| 1215 | LPCTSTR pszText; |
| 1216 | UINT nStateImageMask; |
| 1217 | BOOL bSelected; |
| 1218 | LV_COLUMN lvc; |
| 1219 | LV_ITEM lvi; |
| 1220 | RECT rcAllLabels; |
| 1221 | RECT rcLabel; |
| 1222 | RECT rcIcon; |
| 1223 | int offset; |
| 1224 | SIZE size; |
| 1225 | int i, j; |
| 1226 | int nColumn; |
| 1227 | int nColumnMax = 0; |
| 1228 | int *order; |
| 1229 | BOOL bDrawAsChild; |
| 1230 | int indent_space; |
| 1231 | BOOL bColorChild = FALSE; |
| 1232 | BOOL bParentFound = FALSE; |
| 1233 | int nParent; |
| 1234 | HBITMAP hBackground = GetBackgroundBitmap(); |
| 1235 | MYBITMAPINFO *pbmDesc = GetBackgroundInfo(); |
| 1236 | |
| 1237 | pPickerInfo = GetPickerInfo(hWnd); |
| 1238 | |
| 1239 | order = malloc(pPickerInfo->nColumnCount * sizeof(*order)); |
| 1240 | if (!order) |
| 1241 | return; |
| 1242 | nColumnMax = Picker_GetNumColumns(hWnd); |
| 1243 | |
| 1244 | if (GetUseOldControl()) |
| 1245 | { |
| 1246 | pPickerInfo->pCallbacks->pfnGetColumnOrder(order); |
| 1247 | } |
| 1248 | else |
| 1249 | { |
| 1250 | /* Get the Column Order and save it */ |
| 1251 | ListView_GetColumnOrderArray(hWnd, nColumnMax, order); |
| 1252 | |
| 1253 | /* Disallow moving column 0 */ |
| 1254 | if (order[0] != 0) |
| 1255 | { |
| 1256 | for (i = 0; i < nColumnMax; i++) |
| 1257 | { |
| 1258 | if (order[i] == 0) |
| 1259 | { |
| 1260 | order[i] = order[0]; |
| 1261 | order[0] = 0; |
| 1262 | } |
| 1263 | } |
| 1264 | ListView_SetColumnOrderArray(hWnd, nColumnMax, order); |
| 1265 | } |
| 1266 | } |
| 1267 | |
| 1268 | /* Labels are offset by a certain amount */ |
| 1269 | /* This offset is related to the width of a space character */ |
| 1270 | GetTextExtentPoint32(hDC, TEXT(" "), 1 , &size); |
| 1271 | offset = size.cx; |
| 1272 | |
| 1273 | lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_PARAM; |
| 1274 | lvi.iItem = nItem; |
| 1275 | lvi.iSubItem = order[0]; |
| 1276 | lvi.pszText = szBuff; |
| 1277 | lvi.cchTextMax = sizeof(szBuff) / sizeof(szBuff[0]); |
| 1278 | lvi.stateMask = 0xFFFF; /* get all state flags */ |
| 1279 | ListView_GetItem(hWnd, &lvi); |
| 1280 | |
| 1281 | bSelected = ((lvi.state & LVIS_DROPHILITED) || ( (lvi.state & LVIS_SELECTED) |
| 1282 | && ((bFocus) || (GetWindowLong(hWnd, GWL_STYLE) & LVS_SHOWSELALWAYS)))); |
| 1283 | |
| 1284 | /* figure out if we indent and draw grayed */ |
| 1285 | if (pPickerInfo->pCallbacks->pfnFindItemParent) |
| 1286 | nParent = pPickerInfo->pCallbacks->pfnFindItemParent(hWnd, lvi.lParam); |
| 1287 | else |
| 1288 | nParent = -1; |
| 1289 | bDrawAsChild = (pPickerInfo->pCallbacks->pfnGetViewMode() == VIEW_GROUPED && (nParent >= 0)); |
| 1290 | |
| 1291 | /* only indent if parent is also in this view */ |
| 1292 | if ((nParent >= 0) && bDrawAsChild) |
| 1293 | { |
| 1294 | for (i = 0; i < ListView_GetItemCount(hWnd); i++) |
| 1295 | { |
| 1296 | lvi.mask = LVIF_PARAM; |
| 1297 | lvi.iItem = i; |
| 1298 | ListView_GetItem(hWnd, &lvi); |
| 1299 | |
| 1300 | if (lvi.lParam == nParent) |
| 1301 | { |
| 1302 | bParentFound = TRUE; |
| 1303 | break; |
| 1304 | } |
| 1305 | } |
| 1306 | } |
| 1307 | |
| 1308 | if (pPickerInfo->pCallbacks->pfnGetOffsetChildren && pPickerInfo->pCallbacks->pfnGetOffsetChildren()) |
| 1309 | { |
| 1310 | if (!bParentFound && bDrawAsChild) |
| 1311 | { |
| 1312 | /*Reset it, as no Parent is there*/ |
| 1313 | bDrawAsChild = FALSE; |
| 1314 | bColorChild = TRUE; |
| 1315 | } |
| 1316 | else |
| 1317 | { |
| 1318 | nParent = -1; |
| 1319 | bParentFound = FALSE; |
| 1320 | } |
| 1321 | } |
| 1322 | |
| 1323 | ListView_GetItemRect(hWnd, nItem, &rcAllLabels, LVIR_BOUNDS); |
| 1324 | ListView_GetItemRect(hWnd, nItem, &rcLabel, LVIR_LABEL); |
| 1325 | |
| 1326 | rcAllLabels.left = rcLabel.left; |
| 1327 | |
| 1328 | if (hBackground != NULL) |
| 1329 | { |
| 1330 | RECT rcClient; |
| 1331 | HRGN rgnBitmap; |
| 1332 | RECT rcTmpBmp = rcItem; |
| 1333 | RECT rcFirstItem; |
| 1334 | HPALETTE hPAL; |
| 1335 | HDC htempDC; |
| 1336 | HBITMAP oldBitmap; |
| 1337 | |
| 1338 | htempDC = CreateCompatibleDC(hDC); |
| 1339 | |
| 1340 | oldBitmap = SelectObject(htempDC, hBackground); |
| 1341 | |
| 1342 | GetClientRect(hWnd, &rcClient); |
| 1343 | rcTmpBmp.right = rcClient.right; |
| 1344 | /* We also need to check whether it is the last item |
| 1345 | The update region has to be extended to the bottom if it is */ |
| 1346 | if (nItem == ListView_GetItemCount(hWnd) - 1) |
| 1347 | rcTmpBmp.bottom = rcClient.bottom; |
| 1348 | |
| 1349 | rgnBitmap = CreateRectRgnIndirect(&rcTmpBmp); |
| 1350 | SelectClipRgn(hDC, rgnBitmap); |
| 1351 | DeleteObject(rgnBitmap); |
| 1352 | |
| 1353 | hPAL = GetBackgroundPalette(); |
| 1354 | if (hPAL == NULL) |
| 1355 | hPAL = CreateHalftonePalette(hDC); |
| 1356 | |
| 1357 | if (GetDeviceCaps(htempDC, RASTERCAPS) & RC_PALETTE && hPAL != NULL) |
| 1358 | { |
| 1359 | SelectPalette(htempDC, hPAL, FALSE); |
| 1360 | RealizePalette(htempDC); |
| 1361 | } |
| 1362 | |
| 1363 | ListView_GetItemRect(hWnd, 0, &rcFirstItem, LVIR_BOUNDS); |
| 1364 | |
| 1365 | for (i = rcFirstItem.left; i < rcClient.right; i += pbmDesc->bmWidth) |
| 1366 | for (j = rcFirstItem.top; j < rcClient.bottom; j += pbmDesc->bmHeight) |
| 1367 | BitBlt(hDC, i, j, pbmDesc->bmWidth, pbmDesc->bmHeight, htempDC, 0, 0, SRCCOPY); |
| 1368 | |
| 1369 | SelectObject(htempDC, oldBitmap); |
| 1370 | DeleteDC(htempDC); |
| 1371 | |
| 1372 | if (GetBackgroundPalette() == NULL) |
| 1373 | { |
| 1374 | DeleteObject(hPAL); |
| 1375 | hPAL = NULL; |
| 1376 | } |
| 1377 | } |
| 1378 | |
| 1379 | indent_space = 0; |
| 1380 | |
| 1381 | if (bDrawAsChild) |
| 1382 | { |
| 1383 | RECT rect; |
| 1384 | |
| 1385 | ListView_GetItemRect(hWnd, nItem, &rect, LVIR_ICON); |
| 1386 | |
| 1387 | /* indent width of icon + the space between the icon and text |
| 1388 | * so left of clone icon starts at text of parent |
| 1389 | */ |
| 1390 | indent_space = rect.right - rect.left + offset; |
| 1391 | } |
| 1392 | |
| 1393 | rcAllLabels.left += indent_space; |
| 1394 | |
| 1395 | if (bSelected) |
| 1396 | { |
| 1397 | HBRUSH hBrush; |
| 1398 | HBRUSH hOldBrush; |
| 1399 | |
| 1400 | if (bFocus) |
| 1401 | { |
| 1402 | clrTextSave = SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); |
| 1403 | clrBkSave = SetBkColor(hDC, GetSysColor(COLOR_HIGHLIGHT)); |
| 1404 | hBrush = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT)); |
| 1405 | } |
| 1406 | else |
| 1407 | { |
| 1408 | clrTextSave = SetTextColor(hDC, GetSysColor(COLOR_BTNTEXT)); |
| 1409 | clrBkSave = SetBkColor(hDC, GetSysColor(COLOR_BTNFACE)); |
| 1410 | hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); |
| 1411 | } |
| 1412 | |
| 1413 | hOldBrush = SelectObject(hDC, hBrush); |
| 1414 | FillRect(hDC, &rcAllLabels, hBrush); |
| 1415 | SelectObject(hDC, hOldBrush); |
| 1416 | DeleteObject(hBrush); |
| 1417 | } |
| 1418 | else |
| 1419 | { |
| 1420 | if (hBackground == NULL) |
| 1421 | { |
| 1422 | HBRUSH hBrush; |
| 1423 | |
| 1424 | hBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW)); |
| 1425 | FillRect(hDC, &rcAllLabels, hBrush); |
| 1426 | DeleteObject(hBrush); |
| 1427 | } |
| 1428 | |
| 1429 | if (pPickerInfo->pCallbacks->pfnGetOffsetChildren && pPickerInfo->pCallbacks->pfnGetOffsetChildren()) |
| 1430 | { |
| 1431 | if (bDrawAsChild || bColorChild) |
| 1432 | clrTextSave = SetTextColor(hDC, GetListCloneColor()); |
| 1433 | else |
| 1434 | clrTextSave = SetTextColor(hDC, GetListFontColor()); |
| 1435 | } |
| 1436 | else |
| 1437 | { |
| 1438 | if (bDrawAsChild) |
| 1439 | clrTextSave = SetTextColor(hDC, GetListCloneColor()); |
| 1440 | else |
| 1441 | clrTextSave = SetTextColor(hDC, GetListFontColor()); |
| 1442 | } |
| 1443 | |
| 1444 | clrBkSave = SetBkColor(hDC, GetSysColor(COLOR_WINDOW)); |
| 1445 | } |
| 1446 | |
| 1447 | |
| 1448 | if (lvi.state & LVIS_CUT) |
| 1449 | { |
| 1450 | clrImage = GetSysColor(COLOR_WINDOW); |
| 1451 | uiFlags |= ILD_BLEND50; |
| 1452 | } |
| 1453 | else if (bSelected) |
| 1454 | { |
| 1455 | if (bFocus) |
| 1456 | clrImage = GetSysColor(COLOR_HIGHLIGHT); |
| 1457 | else |
| 1458 | clrImage = GetSysColor(COLOR_BTNFACE); |
| 1459 | |
| 1460 | uiFlags |= ILD_BLEND50; |
| 1461 | } |
| 1462 | |
| 1463 | nStateImageMask = lvi.state & LVIS_STATEIMAGEMASK; |
| 1464 | |
| 1465 | if (nStateImageMask) |
| 1466 | { |
| 1467 | int nImage = (nStateImageMask >> 12) - 1; |
| 1468 | hImageList = ListView_GetImageList(hWnd, LVSIL_STATE); |
| 1469 | if (hImageList) |
| 1470 | ImageList_Draw(hImageList, nImage, hDC, rcItem.left, rcItem.top, ILD_TRANSPARENT); |
| 1471 | } |
| 1472 | |
| 1473 | ListView_GetItemRect(hWnd, nItem, &rcIcon, LVIR_ICON); |
| 1474 | |
| 1475 | rcIcon.left += indent_space; |
| 1476 | |
| 1477 | ListView_GetItemRect(hWnd, nItem, &rcItem, LVIR_LABEL); |
| 1478 | |
| 1479 | hImageList = ListView_GetImageList(hWnd, LVSIL_SMALL); |
| 1480 | if (hImageList) |
| 1481 | { |
| 1482 | UINT nOvlImageMask = lvi.state & LVIS_OVERLAYMASK; |
| 1483 | if (rcIcon.left + 16 + indent_space < rcItem.right) |
| 1484 | { |
| 1485 | ImageList_DrawEx(hImageList, lvi.iImage, hDC, rcIcon.left, rcIcon.top, 16, 16, |
| 1486 | GetSysColor(COLOR_WINDOW), clrImage, uiFlags | nOvlImageMask); |
| 1487 | } |
| 1488 | } |
| 1489 | |
| 1490 | ListView_GetItemRect(hWnd, nItem, &rcItem, LVIR_LABEL); |
| 1491 | |
| 1492 | pszText = MakeShortString(hDC, szBuff, rcItem.right - rcItem.left, 2*offset + indent_space); |
| 1493 | |
| 1494 | rcLabel = rcItem; |
| 1495 | rcLabel.left += offset + indent_space; |
| 1496 | rcLabel.right -= offset; |
| 1497 | |
| 1498 | DrawText(hDC, pszText, -1, &rcLabel, |
| 1499 | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER); |
| 1500 | |
| 1501 | for (nColumn = 1; nColumn < nColumnMax; nColumn++) |
| 1502 | { |
| 1503 | int nRetLen; |
| 1504 | UINT nJustify; |
| 1505 | LV_ITEM lvItem; |
| 1506 | |
| 1507 | lvc.mask = LVCF_FMT | LVCF_WIDTH; |
| 1508 | ListView_GetColumn(hWnd, order[nColumn], &lvc); |
| 1509 | |
| 1510 | lvItem.mask = LVIF_TEXT; |
| 1511 | lvItem.iItem = nItem; |
| 1512 | lvItem.iSubItem = order[nColumn]; |
| 1513 | lvItem.pszText = szBuff; |
| 1514 | lvItem.cchTextMax = sizeof(szBuff) / sizeof(szBuff[0]); |
| 1515 | |
| 1516 | if (ListView_GetItem(hWnd, &lvItem) == FALSE) |
| 1517 | continue; |
| 1518 | |
| 1519 | rcItem.left = rcItem.right; |
| 1520 | rcItem.right += lvc.cx; |
| 1521 | |
| 1522 | nRetLen = _tcslen(szBuff); |
| 1523 | if (nRetLen == 0) |
| 1524 | continue; |
| 1525 | |
| 1526 | pszText = MakeShortString(hDC, szBuff, rcItem.right - rcItem.left, 2 * offset); |
| 1527 | |
| 1528 | nJustify = DT_LEFT; |
| 1529 | |
| 1530 | if (pszText == szBuff) |
| 1531 | { |
| 1532 | switch (lvc.fmt & LVCFMT_JUSTIFYMASK) |
| 1533 | { |
| 1534 | case LVCFMT_RIGHT: |
| 1535 | nJustify = DT_RIGHT; |
| 1536 | break; |
| 1537 | |
| 1538 | case LVCFMT_CENTER: |
| 1539 | nJustify = DT_CENTER; |
| 1540 | break; |
| 1541 | |
| 1542 | default: |
| 1543 | break; |
| 1544 | } |
| 1545 | } |
| 1546 | |
| 1547 | rcLabel = rcItem; |
| 1548 | rcLabel.left += offset; |
| 1549 | rcLabel.right -= offset; |
| 1550 | DrawText(hDC, pszText, -1, &rcLabel, |
| 1551 | nJustify | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER); |
| 1552 | } |
| 1553 | |
| 1554 | if (lvi.state & LVIS_FOCUSED && bFocus) |
| 1555 | DrawFocusRect(hDC, &rcAllLabels); |
| 1556 | |
| 1557 | SetTextColor(hDC, clrTextSave); |
| 1558 | SetBkColor(hDC, clrBkSave); |
| 1559 | free(order); |
| 1560 | } |
| 1561 | |
| 1562 | |
| 1563 | |
| 1564 | const struct PickerCallbacks *Picker_GetCallbacks(HWND hwndPicker) |
| 1565 | { |
| 1566 | struct PickerInfo *pPickerInfo; |
| 1567 | pPickerInfo = GetPickerInfo(hwndPicker); |
| 1568 | return pPickerInfo->pCallbacks; |
| 1569 | } |
| 1570 | |
| 1571 | |
| 1572 | |
| 1573 | int Picker_GetColumnCount(HWND hwndPicker) |
| 1574 | { |
| 1575 | struct PickerInfo *pPickerInfo; |
| 1576 | pPickerInfo = GetPickerInfo(hwndPicker); |
| 1577 | return pPickerInfo->nColumnCount; |
| 1578 | } |
| 1579 | |
| 1580 | |
| 1581 | |
| 1582 | LPCTSTR *Picker_GetColumnNames(HWND hwndPicker) |
| 1583 | { |
| 1584 | struct PickerInfo *pPickerInfo; |
| 1585 | pPickerInfo = GetPickerInfo(hwndPicker); |
| 1586 | return pPickerInfo->ppszColumnNames; |
| 1587 | } |
| 1588 | |
| 1589 | |
| 1590 | |
| 1591 | void Picker_SetHeaderImageList(HWND hwndPicker, HIMAGELIST hHeaderImages) |
| 1592 | { |
| 1593 | HWND hwndHeader; |
| 1594 | hwndHeader = ListView_GetHeader(hwndPicker); |
| 1595 | SendMessage(hwndHeader, HDM_SETIMAGELIST, 0, (LPARAM) (void *) hHeaderImages); |
| 1596 | } |
| 1597 | |
| 1598 | |
| 1599 | |
| 1600 | BOOL Picker_SaveColumnWidths(HWND hwndPicker) |
| 1601 | { |
| 1602 | struct PickerInfo *pPickerInfo; |
| 1603 | int *widths; |
| 1604 | int *order; |
| 1605 | int *tmpOrder; |
| 1606 | int nColumnMax, i; |
| 1607 | BOOL bSuccess = FALSE; |
| 1608 | |
| 1609 | pPickerInfo = GetPickerInfo(hwndPicker); |
| 1610 | |
| 1611 | /* allocate space for the column info */ |
| 1612 | widths = malloc(pPickerInfo->nColumnCount * sizeof(*widths)); |
| 1613 | order = malloc(pPickerInfo->nColumnCount * sizeof(*order)); |
| 1614 | tmpOrder = malloc(pPickerInfo->nColumnCount * sizeof(*tmpOrder)); |
| 1615 | if (!widths || !order || !tmpOrder) |
| 1616 | goto done; |
| 1617 | |
| 1618 | /* retrieve the values */ |
| 1619 | memset(widths, 0, pPickerInfo->nColumnCount * sizeof(*widths)); |
| 1620 | memset(order, 0, pPickerInfo->nColumnCount * sizeof(*order)); |
| 1621 | pPickerInfo->pCallbacks->pfnGetColumnWidths(widths); |
| 1622 | pPickerInfo->pCallbacks->pfnGetColumnOrder(order); |
| 1623 | |
| 1624 | /* switch the list view to LVS_REPORT style so column widths reported correctly */ |
| 1625 | SetWindowLong(hwndPicker, GWL_STYLE, |
| 1626 | (GetWindowLong(hwndPicker, GWL_STYLE) & ~LVS_TYPEMASK) | LVS_REPORT); |
| 1627 | |
| 1628 | nColumnMax = Picker_GetNumColumns(hwndPicker); |
| 1629 | |
| 1630 | if (GetUseOldControl()) |
| 1631 | { |
| 1632 | for (i = 0; i < nColumnMax; i++) |
| 1633 | { |
| 1634 | widths[Picker_GetRealColumnFromViewColumn(hwndPicker, i)] = |
| 1635 | ListView_GetColumnWidth(hwndPicker, i); |
| 1636 | } |
| 1637 | } |
| 1638 | else |
| 1639 | { |
| 1640 | /* Get the Column Order and save it */ |
| 1641 | ListView_GetColumnOrderArray(hwndPicker, nColumnMax, tmpOrder); |
| 1642 | |
| 1643 | for (i = 0; i < nColumnMax; i++) |
| 1644 | { |
| 1645 | widths[Picker_GetRealColumnFromViewColumn(hwndPicker, i)] |
| 1646 | = ListView_GetColumnWidth(hwndPicker, i); |
| 1647 | order[i] = Picker_GetRealColumnFromViewColumn(hwndPicker, tmpOrder[i]); |
| 1648 | } |
| 1649 | } |
| 1650 | |
| 1651 | pPickerInfo->pCallbacks->pfnSetColumnWidths(widths); |
| 1652 | pPickerInfo->pCallbacks->pfnSetColumnOrder(order); |
| 1653 | bSuccess = TRUE; |
| 1654 | |
| 1655 | done: |
| 1656 | if (widths) |
| 1657 | free(widths); |
| 1658 | if (order) |
| 1659 | free(order); |
| 1660 | if (tmpOrder) |
| 1661 | free(tmpOrder); |
| 1662 | return bSuccess; |
| 1663 | } |
src/osd/winui/m32opts.c
| r0 | r996 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | M.A.M.E.32 - Multiple Arcade Machine Emulator for Win32 |
| 4 | Win32 Portions Copyright (C) 1997-2003 Michael Soderstrom and Chris Kirmse |
| 5 | |
| 6 | This file is part of MAME32, and may only be used, modified and |
| 7 | distributed under the terms of the MAME license, in "readme.txt". |
| 8 | By continuing to use, modify or distribute this file you indicate |
| 9 | that you have read the license and understand and accept it fully. |
| 10 | |
| 11 | ***************************************************************************/ |
| 12 | |
| 13 | /*************************************************************************** |
| 14 | |
| 15 | m32opts.c |
| 16 | |
| 17 | Stores global options and per-game options; |
| 18 | |
| 19 | ***************************************************************************/ |
| 20 | |
| 21 | #define WIN32_LEAN_AND_MEAN |
| 22 | |
| 23 | #include <windows.h> |
| 24 | #include <windowsx.h> |
| 25 | #include <winreg.h> |
| 26 | #include <commctrl.h> |
| 27 | #include <assert.h> |
| 28 | #include <stdio.h> |
| 29 | #include <sys/stat.h> |
| 30 | #include <math.h> |
| 31 | #include <direct.h> |
| 32 | #include <driver.h> |
| 33 | #include <stddef.h> |
| 34 | #include <tchar.h> |
| 35 | |
| 36 | #include "screenshot.h" |
| 37 | #include "bitmask.h" |
| 38 | #include "mame32.h" |
| 39 | #include "m32util.h" |
| 40 | #include "resource.h" |
| 41 | #include "treeview.h" |
| 42 | #include "file.h" |
| 43 | #include "splitters.h" |
| 44 | #include "dijoystick.h" |
| 45 | #include "audit.h" |
| 46 | #include "m32opts.h" |
| 47 | #include "picker.h" |
| 48 | #include "winmain.h" |
| 49 | #include "windows/winutf8.h" |
| 50 | #include "windows/strconv.h" |
| 51 | #include "astring.h" |
| 52 | |
| 53 | #ifdef MESS |
| 54 | #include "optionsms.h" |
| 55 | #endif // MESS |
| 56 | |
| 57 | #ifdef _MSC_VER |
| 58 | #define snprintf _snprintf |
| 59 | #endif |
| 60 | |
| 61 | /*************************************************************************** |
| 62 | Internal function prototypes |
| 63 | ***************************************************************************/ |
| 64 | |
| 65 | // static void LoadFolderFilter(int folder_index,int filters); |
| 66 | |
| 67 | static file_error LoadSettingsFile(core_options *opts, const char *filename); |
| 68 | static file_error SaveSettingsFile(core_options *opts, const char *filename); |
| 69 | |
| 70 | static void LoadOptionsAndSettings(void); |
| 71 | |
| 72 | static void CusColorEncodeString(const COLORREF *value, char* str); |
| 73 | static void CusColorDecodeString(const char* str, COLORREF *value); |
| 74 | |
| 75 | static void SplitterEncodeString(const int *value, char* str); |
| 76 | static void SplitterDecodeString(const char *str, int *value); |
| 77 | |
| 78 | static void FontEncodeString(const LOGFONT *f, char *str); |
| 79 | static void FontDecodeString(const char* str, LOGFONT *f); |
| 80 | |
| 81 | static void TabFlagsEncodeString(int data, char *str); |
| 82 | static void TabFlagsDecodeString(const char *str, int *data); |
| 83 | |
| 84 | static DWORD DecodeFolderFlags(const char *buf); |
| 85 | static const char * EncodeFolderFlags(DWORD value); |
| 86 | |
| 87 | static void ResetToDefaults(core_options *opts, int priority); |
| 88 | |
| 89 | static void ui_parse_ini_file(core_options *opts, const char *name); |
| 90 | static BOOL add_options_entry(core_options *opts, const options_entry *entry); |
| 91 | static core_options * options_prune(core_options *opts1, core_options *opts2); |
| 92 | static void remove_all_source_options(void); |
| 93 | |
| 94 | |
| 95 | #ifdef _MSC_VER |
| 96 | #define snprintf _snprintf |
| 97 | #endif |
| 98 | |
| 99 | /*************************************************************************** |
| 100 | Internal defines |
| 101 | ***************************************************************************/ |
| 102 | |
| 103 | #define UI_INI_FILENAME MAME32NAME "ui.ini" |
| 104 | #define DEFAULT_OPTIONS_INI_FILENAME CONFIGNAME ".ini" |
| 105 | |
| 106 | #define M32OPTION_LIST_MODE "list_mode" |
| 107 | #define M32OPTION_CHECK_GAME "check_game" |
| 108 | #define M32OPTION_JOYSTICK_IN_INTERFACE "joystick_in_interface" |
| 109 | #define M32OPTION_KEYBOARD_IN_INTERFACE "keyboard_in_interface" |
| 110 | #define M32OPTION_CYCLE_SCREENSHOT "cycle_screenshot" |
| 111 | #define M32OPTION_STRETCH_SCREENSHOT_LARGER "stretch_screenshot_larger" |
| 112 | #define M32OPTION_SCREENSHOT_BORDER_SIZE "screenshot_bordersize" |
| 113 | #define M32OPTION_SCREENSHOT_BORDER_COLOR "screenshot_bordercolor" |
| 114 | #define M32OPTION_INHERIT_FILTER "inherit_filter" |
| 115 | #define M32OPTION_OFFSET_CLONES "offset_clones" |
| 116 | #define M32OPTION_GAME_CAPTION "game_caption" |
| 117 | #define M32OPTION_BROADCAST_GAME_NAME "broadcast_game_name" |
| 118 | #define M32OPTION_RANDOM_BACKGROUND "random_background" |
| 119 | #define M32OPTION_DEFAULT_FOLDER_ID "default_folder_id" |
| 120 | #define M32OPTION_SHOW_IMAGE_SECTION "show_image_section" |
| 121 | #define M32OPTION_SHOW_FOLDER_SECTION "show_folder_section" |
| 122 | #define M32OPTION_HIDE_FOLDERS "hide_folders" |
| 123 | #define M32OPTION_SHOW_STATUS_BAR "show_status_bar" |
| 124 | #define M32OPTION_SHOW_TABS "show_tabs" |
| 125 | #define M32OPTION_SHOW_TOOLBAR "show_tool_bar" |
| 126 | #define M32OPTION_CURRENT_TAB "current_tab" |
| 127 | #define M32OPTION_WINDOW_X "window_x" |
| 128 | #define M32OPTION_WINDOW_Y "window_y" |
| 129 | #define M32OPTION_WINDOW_WIDTH "window_width" |
| 130 | #define M32OPTION_WINDOW_HEIGHT "window_height" |
| 131 | #define M32OPTION_WINDOW_STATE "window_state" |
| 132 | #define M32OPTION_CUSTOM_COLOR "custom_color" |
| 133 | #define M32OPTION_LIST_FONT "list_font" |
| 134 | #define M32OPTION_TEXT_COLOR "text_color" |
| 135 | #define M32OPTION_CLONE_COLOR "clone_color" |
| 136 | #define M32OPTION_HIDE_TABS "hide_tabs" |
| 137 | #define M32OPTION_HISTORY_TAB "history_tab" |
| 138 | #define M32OPTION_COLUMN_WIDTHS "column_widths" |
| 139 | #define M32OPTION_COLUMN_ORDER "column_order" |
| 140 | #define M32OPTION_COLUMN_SHOWN "column_shown" |
| 141 | #define M32OPTION_SPLITTERS "splitters" |
| 142 | #define M32OPTION_SORT_COLUMN "sort_column" |
| 143 | #define M32OPTION_SORT_REVERSED "sort_reversed" |
| 144 | #define M32OPTION_LANGUAGE "language" |
| 145 | #define M32OPTION_FLYER_DIRECTORY "flyer_directory" |
| 146 | #define M32OPTION_CABINET_DIRECTORY "cabinet_directory" |
| 147 | #define M32OPTION_MARQUEE_DIRECTORY "marquee_directory" |
| 148 | #define M32OPTION_TITLE_DIRECTORY "title_directory" |
| 149 | #define M32OPTION_CPANEL_DIRECTORY "cpanel_directory" |
| 150 | #define M32OPTION_PCB_DIRECTORY "pcb_directory" |
| 151 | #define M32OPTION_ICONS_DIRECTORY "icons_directory" |
| 152 | #define M32OPTION_BACKGROUND_DIRECTORY "background_directory" |
| 153 | #define M32OPTION_FOLDER_DIRECTORY "folder_directory" |
| 154 | #define M32OPTION_UI_KEY_UP "ui_key_up" |
| 155 | #define M32OPTION_UI_KEY_DOWN "ui_key_down" |
| 156 | #define M32OPTION_UI_KEY_LEFT "ui_key_left" |
| 157 | #define M32OPTION_UI_KEY_RIGHT "ui_key_right" |
| 158 | #define M32OPTION_UI_KEY_START "ui_key_start" |
| 159 | #define M32OPTION_UI_KEY_PGUP "ui_key_pgup" |
| 160 | #define M32OPTION_UI_KEY_PGDWN "ui_key_pgdwn" |
| 161 | #define M32OPTION_UI_KEY_HOME "ui_key_home" |
| 162 | #define M32OPTION_UI_KEY_END "ui_key_end" |
| 163 | #define M32OPTION_UI_KEY_SS_CHANGE "ui_key_ss_change" |
| 164 | #define M32OPTION_UI_KEY_HISTORY_UP "ui_key_history_up" |
| 165 | #define M32OPTION_UI_KEY_HISTORY_DOWN "ui_key_history_down" |
| 166 | #define M32OPTION_UI_KEY_CONTEXT_FILTERS "ui_key_context_filters" |
| 167 | #define M32OPTION_UI_KEY_SELECT_RANDOM "ui_key_select_random" |
| 168 | #define M32OPTION_UI_KEY_GAME_AUDIT "ui_key_game_audit" |
| 169 | #define M32OPTION_UI_KEY_GAME_PROPERTIES "ui_key_game_properties" |
| 170 | #define M32OPTION_UI_KEY_HELP_CONTENTS "ui_key_help_contents" |
| 171 | #define M32OPTION_UI_KEY_UPDATE_GAMELIST "ui_key_update_gamelist" |
| 172 | #define M32OPTION_UI_KEY_VIEW_FOLDERS "ui_key_view_folders" |
| 173 | #define M32OPTION_UI_KEY_VIEW_FULLSCREEN "ui_key_view_fullscreen" |
| 174 | #define M32OPTION_UI_KEY_VIEW_PAGETAB "ui_key_view_pagetab" |
| 175 | #define M32OPTION_UI_KEY_VIEW_PICTURE_AREA "ui_key_view_picture_area" |
| 176 | #define M32OPTION_UI_KEY_VIEW_STATUS "ui_key_view_status" |
| 177 | #define M32OPTION_UI_KEY_VIEW_TOOLBARS "ui_key_view_toolbars" |
| 178 | #define M32OPTION_UI_KEY_VIEW_TAB_CABINET "ui_key_view_tab_cabinet" |
| 179 | #define M32OPTION_UI_KEY_VIEW_TAB_CPANEL "ui_key_view_tab_cpanel" |
| 180 | #define M32OPTION_UI_KEY_VIEW_TAB_FLYER "ui_key_view_tab_flyer" |
| 181 | #define M32OPTION_UI_KEY_VIEW_TAB_HISTORY "ui_key_view_tab_history" |
| 182 | #define M32OPTION_UI_KEY_VIEW_TAB_MARQUEE "ui_key_view_tab_marquee" |
| 183 | #define M32OPTION_UI_KEY_VIEW_TAB_SCREENSHOT "ui_key_view_tab_screenshot" |
| 184 | #define M32OPTION_UI_KEY_VIEW_TAB_TITLE "ui_key_view_tab_title" |
| 185 | #define M32OPTION_UI_KEY_VIEW_TAB_PCB "ui_key_view_tab_pcb" |
| 186 | #define M32OPTION_UI_KEY_QUIT "ui_key_quit" |
| 187 | #define M32OPTION_UI_JOY_UP "ui_joy_up" |
| 188 | #define M32OPTION_UI_JOY_DOWN "ui_joy_down" |
| 189 | #define M32OPTION_UI_JOY_LEFT "ui_joy_left" |
| 190 | #define M32OPTION_UI_JOY_RIGHT "ui_joy_right" |
| 191 | #define M32OPTION_UI_JOY_START "ui_joy_start" |
| 192 | #define M32OPTION_UI_JOY_PGUP "ui_joy_pgup" |
| 193 | #define M32OPTION_UI_JOY_PGDWN "ui_joy_pgdwn" |
| 194 | #define M32OPTION_UI_JOY_HOME "ui_joy_home" |
| 195 | #define M32OPTION_UI_JOY_END "ui_joy_end" |
| 196 | #define M32OPTION_UI_JOY_SS_CHANGE "ui_joy_ss_change" |
| 197 | #define M32OPTION_UI_JOY_HISTORY_UP "ui_joy_history_up" |
| 198 | #define M32OPTION_UI_JOY_HISTORY_DOWN "ui_joy_history_down" |
| 199 | #define M32OPTION_UI_JOY_EXEC "ui_joy_exec" |
| 200 | #define M32OPTION_EXEC_COMMAND "exec_command" |
| 201 | #define M32OPTION_EXEC_WAIT "exec_wait" |
| 202 | #define M32OPTION_HIDE_MOUSE "hide_mouse" |
| 203 | #define M32OPTION_FULL_SCREEN "full_screen" |
| 204 | |
| 205 | #ifdef MESS |
| 206 | // Options names |
| 207 | #define M32OPTION_DEFAULT_GAME "default_system" |
| 208 | #define M32OPTION_HISTORY_FILE "sysinfo_file" |
| 209 | #define M32OPTION_MAMEINFO_FILE "messinfo_file" |
| 210 | // Option values |
| 211 | #define M32DEFAULT_SELECTION "nes" |
| 212 | #define M32DEFAULT_SPLITTERS "152,310,468" |
| 213 | #define M32HISTORY_FILE "sysinfo.dat" |
| 214 | #define M32MAMEINFO_FILE "messinfo.dat" |
| 215 | #else |
| 216 | // Options names |
| 217 | #define M32OPTION_DEFAULT_GAME "default_game" |
| 218 | #define M32OPTION_HISTORY_FILE "history_file" |
| 219 | #define M32OPTION_MAMEINFO_FILE "mameinfo_file" |
| 220 | // Options values |
| 221 | #define M32DEFAULT_SELECTION "puckman" |
| 222 | #define M32DEFAULT_SPLITTERS "152,362" |
| 223 | #define M32HISTORY_FILE "history.dat" |
| 224 | #define M32MAMEINFO_FILE "mameinfo.dat" |
| 225 | #endif |
| 226 | |
| 227 | |
| 228 | |
| 229 | /*************************************************************************** |
| 230 | Internal structures |
| 231 | ***************************************************************************/ |
| 232 | |
| 233 | #if 0 |
| 234 | typedef struct |
| 235 | { |
| 236 | int folder_index; |
| 237 | int filters; |
| 238 | } folder_filter_type; |
| 239 | #endif |
| 240 | |
| 241 | /*************************************************************************** |
| 242 | Internal variables |
| 243 | ***************************************************************************/ |
| 244 | |
| 245 | static object_pool *options_memory_pool; |
| 246 | |
| 247 | static core_options *settings; |
| 248 | |
| 249 | static core_options *global = NULL; // Global 'default' options |
| 250 | |
| 251 | // UI options in mame32ui.ini |
| 252 | static const options_entry regSettings[] = |
| 253 | { |
| 254 | // UI options |
| 255 | { NULL, NULL, OPTION_HEADER, "DISPLAY STATE OPTIONS" }, |
| 256 | { M32OPTION_DEFAULT_GAME, M32DEFAULT_SELECTION, 0, NULL }, |
| 257 | { M32OPTION_DEFAULT_GAME, "puckman", 0, NULL }, |
| 258 | { M32OPTION_DEFAULT_FOLDER_ID, "0", 0, NULL }, |
| 259 | { M32OPTION_SHOW_IMAGE_SECTION, "1", OPTION_BOOLEAN, NULL }, |
| 260 | { M32OPTION_FULL_SCREEN, "0", OPTION_BOOLEAN, NULL }, |
| 261 | { M32OPTION_CURRENT_TAB, "0", 0, NULL }, |
| 262 | { M32OPTION_SHOW_TOOLBAR, "1", OPTION_BOOLEAN, NULL }, |
| 263 | { M32OPTION_SHOW_STATUS_BAR, "1", OPTION_BOOLEAN, NULL }, |
| 264 | { M32OPTION_HIDE_FOLDERS, "", 0, NULL }, |
| 265 | #ifdef MESS |
| 266 | { M32OPTION_SHOW_FOLDER_SECTION, "0", OPTION_BOOLEAN, NULL }, |
| 267 | { M32OPTION_SHOW_TABS, "0", OPTION_BOOLEAN, NULL }, |
| 268 | { M32OPTION_HIDE_TABS, "flyer, cabinet, marquee, title, cpanel, pcb", 0, NULL }, |
| 269 | { M32OPTION_HISTORY_TAB, "1", 0, NULL }, |
| 270 | #else |
| 271 | { M32OPTION_SHOW_FOLDER_SECTION, "1", OPTION_BOOLEAN, NULL }, |
| 272 | { M32OPTION_SHOW_TABS, "1", OPTION_BOOLEAN, NULL }, |
| 273 | { M32OPTION_HIDE_TABS, "marquee, title, cpanel, pcb, history", 0, NULL }, |
| 274 | { M32OPTION_HISTORY_TAB, "0", 0, NULL }, |
| 275 | #endif |
| 276 | |
| 277 | { M32OPTION_SORT_COLUMN, "0", 0, NULL }, |
| 278 | { M32OPTION_SORT_REVERSED, "0", OPTION_BOOLEAN, NULL }, |
| 279 | { M32OPTION_WINDOW_X, "0", 0, NULL }, |
| 280 | { M32OPTION_WINDOW_Y, "0", 0, NULL }, |
| 281 | { M32OPTION_WINDOW_WIDTH, "640", 0, NULL }, |
| 282 | { M32OPTION_WINDOW_HEIGHT, "400", 0, NULL }, |
| 283 | { M32OPTION_WINDOW_STATE, "1", 0, NULL }, |
| 284 | |
| 285 | { M32OPTION_TEXT_COLOR, "-1", 0, NULL }, |
| 286 | { M32OPTION_CLONE_COLOR, "-1", 0, NULL }, |
| 287 | { M32OPTION_CUSTOM_COLOR, "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0", 0, NULL }, |
| 288 | /* ListMode needs to be before ColumnWidths settings */ |
| 289 | { M32OPTION_LIST_MODE, "5", 0, NULL }, |
| 290 | { M32OPTION_SPLITTERS, M32DEFAULT_SPLITTERS, 0, NULL }, |
| 291 | { M32OPTION_LIST_FONT, "-8,0,0,0,400,0,0,0,0,0,0,0,0,MS Sans Serif", 0, NULL }, |
| 292 | { M32OPTION_COLUMN_WIDTHS, "185,78,84,84,64,88,74,108,60,144,84,60", 0, NULL }, |
| 293 | { M32OPTION_COLUMN_ORDER, "0,2,3,4,5,6,7,8,9,1,10,11", 0, NULL }, |
| 294 | { M32OPTION_COLUMN_SHOWN, "1,0,1,1,1,1,1,1,1,1,0,0", 0, NULL }, |
| 295 | |
| 296 | { NULL, NULL, OPTION_HEADER, "INTERFACE OPTIONS" }, |
| 297 | { M32OPTION_LANGUAGE, "english", 0, NULL }, |
| 298 | { M32OPTION_CHECK_GAME, "1", OPTION_BOOLEAN, NULL }, |
| 299 | { M32OPTION_JOYSTICK_IN_INTERFACE, "0", OPTION_BOOLEAN, NULL }, |
| 300 | { M32OPTION_KEYBOARD_IN_INTERFACE, "0", OPTION_BOOLEAN, NULL }, |
| 301 | { M32OPTION_RANDOM_BACKGROUND, "0", OPTION_BOOLEAN, NULL }, |
| 302 | { M32OPTION_BROADCAST_GAME_NAME, "0", OPTION_BOOLEAN, NULL }, |
| 303 | { M32OPTION_HIDE_MOUSE, "0", OPTION_BOOLEAN, NULL }, |
| 304 | { M32OPTION_INHERIT_FILTER, "0", OPTION_BOOLEAN, NULL }, |
| 305 | { M32OPTION_OFFSET_CLONES, "0", OPTION_BOOLEAN, NULL }, |
| 306 | { M32OPTION_GAME_CAPTION, "1", OPTION_BOOLEAN, NULL }, |
| 307 | { M32OPTION_STRETCH_SCREENSHOT_LARGER, "0", OPTION_BOOLEAN, NULL }, |
| 308 | { M32OPTION_CYCLE_SCREENSHOT, "0", 0, NULL }, |
| 309 | { M32OPTION_SCREENSHOT_BORDER_SIZE, "11", 0, NULL }, |
| 310 | { M32OPTION_SCREENSHOT_BORDER_COLOR, "-1", 0, NULL }, |
| 311 | { M32OPTION_EXEC_COMMAND, "", 0, NULL }, |
| 312 | { M32OPTION_EXEC_WAIT, "0", 0, NULL }, |
| 313 | |
| 314 | { NULL, NULL, OPTION_HEADER, "SEARCH PATH OPTIONS" }, |
| 315 | { M32OPTION_FLYER_DIRECTORY, "flyers", 0, NULL }, |
| 316 | { M32OPTION_CABINET_DIRECTORY, "cabinets", 0, NULL }, |
| 317 | { M32OPTION_MARQUEE_DIRECTORY, "marquees", 0, NULL }, |
| 318 | { M32OPTION_TITLE_DIRECTORY, "titles", 0, NULL }, |
| 319 | { M32OPTION_CPANEL_DIRECTORY, "cpanel", 0, NULL }, |
| 320 | { M32OPTION_PCB_DIRECTORY, "pcb", 0, NULL }, |
| 321 | { M32OPTION_BACKGROUND_DIRECTORY, "bkground", 0, NULL }, |
| 322 | { M32OPTION_FOLDER_DIRECTORY, "folders", 0, NULL }, |
| 323 | { M32OPTION_ICONS_DIRECTORY, "icons", 0, NULL }, |
| 324 | |
| 325 | |
| 326 | { NULL, NULL, OPTION_HEADER, "FILENAME OPTIONS" }, |
| 327 | { M32OPTION_HISTORY_FILE, M32HISTORY_FILE, 0, NULL }, |
| 328 | { M32OPTION_MAMEINFO_FILE, M32MAMEINFO_FILE, 0, NULL }, |
| 329 | |
| 330 | { NULL, NULL, OPTION_HEADER, "NAVIGATION KEY CODES" }, |
| 331 | { M32OPTION_UI_KEY_UP, "KEYCODE_UP", 0, NULL }, |
| 332 | { M32OPTION_UI_KEY_DOWN, "KEYCODE_DOWN", 0, NULL }, |
| 333 | { M32OPTION_UI_KEY_LEFT, "KEYCODE_LEFT", 0, NULL }, |
| 334 | { M32OPTION_UI_KEY_RIGHT, "KEYCODE_RIGHT", 0, NULL }, |
| 335 | { M32OPTION_UI_KEY_START, "KEYCODE_ENTER NOT KEYCODE_LALT", 0, NULL }, |
| 336 | { M32OPTION_UI_KEY_PGUP, "KEYCODE_PGUP", 0, NULL }, |
| 337 | { M32OPTION_UI_KEY_PGDWN, "KEYCODE_PGDN", 0, NULL }, |
| 338 | { M32OPTION_UI_KEY_HOME, "KEYCODE_HOME", 0, NULL }, |
| 339 | { M32OPTION_UI_KEY_END, "KEYCODE_END", 0, NULL }, |
| 340 | { M32OPTION_UI_KEY_SS_CHANGE, "KEYCODE_INSERT", 0, NULL }, |
| 341 | { M32OPTION_UI_KEY_HISTORY_UP, "KEYCODE_DEL", 0, NULL }, |
| 342 | { M32OPTION_UI_KEY_HISTORY_DOWN, "KEYCODE_LALT KEYCODE_0", 0, NULL }, |
| 343 | |
| 344 | { M32OPTION_UI_KEY_CONTEXT_FILTERS, "KEYCODE_LCONTROL KEYCODE_F", 0, NULL }, |
| 345 | { M32OPTION_UI_KEY_SELECT_RANDOM, "KEYCODE_LCONTROL KEYCODE_R", 0, NULL }, |
| 346 | { M32OPTION_UI_KEY_GAME_AUDIT, "KEYCODE_LALT KEYCODE_A", 0, NULL }, |
| 347 | { M32OPTION_UI_KEY_GAME_PROPERTIES, "KEYCODE_LALT KEYCODE_ENTER", 0, NULL }, |
| 348 | { M32OPTION_UI_KEY_HELP_CONTENTS, "KEYCODE_F1", 0, NULL }, |
| 349 | { M32OPTION_UI_KEY_UPDATE_GAMELIST, "KEYCODE_F5", 0, NULL }, |
| 350 | { M32OPTION_UI_KEY_VIEW_FOLDERS, "KEYCODE_LALT KEYCODE_D", 0, NULL }, |
| 351 | { M32OPTION_UI_KEY_VIEW_FULLSCREEN, "KEYCODE_F11", 0, NULL }, |
| 352 | { M32OPTION_UI_KEY_VIEW_PAGETAB, "KEYCODE_LALT KEYCODE_B", 0, NULL }, |
| 353 | { M32OPTION_UI_KEY_VIEW_PICTURE_AREA, "KEYCODE_LALT KEYCODE_P", 0, NULL }, |
| 354 | { M32OPTION_UI_KEY_VIEW_STATUS, "KEYCODE_LALT KEYCODE_S", 0, NULL }, |
| 355 | { M32OPTION_UI_KEY_VIEW_TOOLBARS, "KEYCODE_LALT KEYCODE_T", 0, NULL }, |
| 356 | |
| 357 | { M32OPTION_UI_KEY_VIEW_TAB_CABINET, "KEYCODE_LALT KEYCODE_3", 0, NULL }, |
| 358 | { M32OPTION_UI_KEY_VIEW_TAB_CPANEL, "KEYCODE_LALT KEYCODE_6", 0, NULL }, |
| 359 | { M32OPTION_UI_KEY_VIEW_TAB_FLYER, "KEYCODE_LALT KEYCODE_2", 0, NULL }, |
| 360 | { M32OPTION_UI_KEY_VIEW_TAB_HISTORY, "KEYCODE_LALT KEYCODE_8", 0, NULL }, |
| 361 | { M32OPTION_UI_KEY_VIEW_TAB_MARQUEE, "KEYCODE_LALT KEYCODE_4", 0, NULL }, |
| 362 | { M32OPTION_UI_KEY_VIEW_TAB_SCREENSHOT, "KEYCODE_LALT KEYCODE_1", 0, NULL }, |
| 363 | { M32OPTION_UI_KEY_VIEW_TAB_TITLE, "KEYCODE_LALT KEYCODE_5", 0, NULL }, |
| 364 | { M32OPTION_UI_KEY_VIEW_TAB_PCB, "KEYCODE_LALT KEYCODE_7", 0, NULL }, |
| 365 | { M32OPTION_UI_KEY_QUIT, "KEYCODE_LALT KEYCODE_Q", 0, NULL }, |
| 366 | |
| 367 | { NULL, NULL, OPTION_HEADER, "NAVIGATION JOYSTICK CODES" }, |
| 368 | { M32OPTION_UI_JOY_UP, "", 0, NULL }, |
| 369 | { M32OPTION_UI_JOY_DOWN, "", 0, NULL }, |
| 370 | { M32OPTION_UI_JOY_LEFT, "", 0, NULL }, |
| 371 | { M32OPTION_UI_JOY_RIGHT, "", 0, NULL }, |
| 372 | { M32OPTION_UI_JOY_START, "", 0, NULL }, |
| 373 | { M32OPTION_UI_JOY_PGUP, "", 0, NULL }, |
| 374 | { M32OPTION_UI_JOY_PGDWN, "", 0, NULL }, |
| 375 | { M32OPTION_UI_JOY_HOME, "0,0,0,0", 0, NULL }, |
| 376 | { M32OPTION_UI_JOY_END, "0,0,0,0", 0, NULL }, |
| 377 | { M32OPTION_UI_JOY_SS_CHANGE, "", 0, NULL }, |
| 378 | { M32OPTION_UI_JOY_HISTORY_UP, "", 0, NULL }, |
| 379 | { M32OPTION_UI_JOY_HISTORY_DOWN, "", 0, NULL }, |
| 380 | { M32OPTION_UI_JOY_EXEC, "0,0,0,0", 0, NULL }, |
| 381 | |
| 382 | #ifndef MESS |
| 383 | { NULL, NULL, OPTION_HEADER, "GAME STATISTICS" }, |
| 384 | #endif |
| 385 | { NULL } |
| 386 | }; |
| 387 | |
| 388 | static const options_entry perGameOptions[] = |
| 389 | { |
| 390 | // per game options |
| 391 | { "_play_count", "0", 0, NULL }, |
| 392 | { "_play_time", "0", 0, NULL }, |
| 393 | { "_rom_audit", "-1", 0, NULL }, |
| 394 | { "_samples_audit", "-1", 0, NULL }, |
| 395 | #ifdef MESS |
| 396 | { "_extra_software", "", 0, NULL }, |
| 397 | #endif |
| 398 | { NULL } |
| 399 | }; |
| 400 | |
| 401 | static const options_entry filterOptions[] = |
| 402 | { |
| 403 | // filters |
| 404 | { "_filters", "0", 0, NULL }, |
| 405 | { NULL } |
| 406 | }; |
| 407 | |
| 408 | |
| 409 | |
| 410 | // Screen shot Page tab control text |
| 411 | // these must match the order of the options flags in options.h |
| 412 | // (TAB_...) |
| 413 | const char* image_tabs_long_name[MAX_TAB_TYPES] = |
| 414 | { |
| 415 | "Snapshot ", |
| 416 | "Flyer ", |
| 417 | "Cabinet ", |
| 418 | "Marquee", |
| 419 | "Title", |
| 420 | "Control Panel", |
| 421 | "PCB", |
| 422 | "History ", |
| 423 | }; |
| 424 | |
| 425 | const char* image_tabs_short_name[MAX_TAB_TYPES] = |
| 426 | { |
| 427 | "snapshot", |
| 428 | "flyer", |
| 429 | "cabinet", |
| 430 | "marquee", |
| 431 | "title", |
| 432 | "cpanel", |
| 433 | "pcb", |
| 434 | "history" |
| 435 | }; |
| 436 | |
| 437 | |
| 438 | static BOOL save_gui_settings = TRUE; |
| 439 | static BOOL save_default_options = TRUE; |
| 440 | |
| 441 | #if 0 |
| 442 | folder_filter_type *folder_filters; |
| 443 | int size_folder_filters; |
| 444 | int num_folder_filters; |
| 445 | #endif |
| 446 | |
| 447 | /*************************************************************************** |
| 448 | External functions |
| 449 | ***************************************************************************/ |
| 450 | |
| 451 | static void memory_error(const char *message) |
| 452 | { |
| 453 | win_message_box_utf8(NULL, message, NULL, MB_OK); |
| 454 | exit(-1); |
| 455 | } |
| 456 | |
| 457 | |
| 458 | |
| 459 | void AddOptions(core_options *opts, const options_entry *entrylist, BOOL is_global) |
| 460 | { |
| 461 | static const char *blacklist[] = |
| 462 | { |
| 463 | WINOPTION_SCREEN, |
| 464 | WINOPTION_ASPECT, |
| 465 | WINOPTION_RESOLUTION, |
| 466 | WINOPTION_VIEW |
| 467 | }; |
| 468 | options_entry entries[2]; |
| 469 | BOOL good_option; |
| 470 | int i; |
| 471 | |
| 472 | for ( ; entrylist->name != NULL || (entrylist->flags & OPTION_HEADER); entrylist++) |
| 473 | { |
| 474 | good_option = TRUE; |
| 475 | |
| 476 | // check blacklist |
| 477 | if (entrylist->name != NULL) |
| 478 | { |
| 479 | for (i = 0; i < ARRAY_LENGTH(blacklist); i++) |
| 480 | { |
| 481 | if (!strcmp(entrylist->name, blacklist[i])) |
| 482 | { |
| 483 | good_option = FALSE; |
| 484 | break; |
| 485 | } |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | // if is_global is FALSE, blacklist global options |
| 490 | if (entrylist->name && !is_global && IsGlobalOption(entrylist->name)) |
| 491 | good_option = FALSE; |
| 492 | |
| 493 | if (good_option) |
| 494 | { |
| 495 | memcpy(entries, entrylist, sizeof(options_entry)); |
| 496 | memset(&entries[1], 0, sizeof(entries[1])); |
| 497 | options_add_entries(opts, entries); |
| 498 | } |
| 499 | } |
| 500 | } |
| 501 | |
| 502 | |
| 503 | |
| 504 | core_options *CreateGameOptions(int driver_index) |
| 505 | { |
| 506 | core_options *opts; |
| 507 | BOOL is_global = (driver_index == OPTIONS_TYPE_GLOBAL); |
| 508 | extern const options_entry mame_win_options[]; |
| 509 | |
| 510 | // create the options |
| 511 | opts = options_create(memory_error); |
| 512 | |
| 513 | // add the options |
| 514 | AddOptions(opts, mame_core_options, is_global); |
| 515 | AddOptions(opts, mame_win_options, is_global); |
| 516 | |
| 517 | // customize certain options |
| 518 | if (is_global) |
| 519 | options_set_option_default_value(opts, OPTION_INIPATH, "ini"); |
| 520 | |
| 521 | #ifdef MESS |
| 522 | MessSetupGameOptions(opts, driver_index); |
| 523 | #endif // MESS |
| 524 | |
| 525 | return opts; |
| 526 | } |
| 527 | |
| 528 | |
| 529 | |
| 530 | BOOL OptionsInit() |
| 531 | { |
| 532 | // create a memory pool for our data |
| 533 | options_memory_pool = pool_alloc(memory_error); |
| 534 | if (!options_memory_pool) |
| 535 | return FALSE; |
| 536 | |
| 537 | // set up the MAME32 settings (these get placed in MAME32ui.ini |
| 538 | settings = options_create(memory_error); |
| 539 | options_add_entries(settings, regSettings); |
| 540 | #ifdef MESS |
| 541 | MessSetupSettings(settings); |
| 542 | #endif |
| 543 | |
| 544 | // set up per game options |
| 545 | { |
| 546 | char buffer[128]; |
| 547 | int i, j; |
| 548 | int game_option_count = 0; |
| 549 | options_entry *driver_per_game_options; |
| 550 | options_entry *ent; |
| 551 | |
| 552 | while(perGameOptions[game_option_count].name) |
| 553 | game_option_count++; |
| 554 | |
| 555 | driver_per_game_options = (options_entry *) pool_malloc(options_memory_pool, |
| 556 | (game_option_count * driver_list_get_count(drivers) + 1) * sizeof(*driver_per_game_options)); |
| 557 | |
| 558 | for (i = 0; i < driver_list_get_count(drivers); i++) |
| 559 | { |
| 560 | for (j = 0; j < game_option_count; j++) |
| 561 | { |
| 562 | ent = &driver_per_game_options[i * game_option_count + j]; |
| 563 | |
| 564 | snprintf(buffer, ARRAY_LENGTH(buffer), "%s%s", drivers[i]->name, perGameOptions[j].name); |
| 565 | |
| 566 | memset(ent, 0, sizeof(*ent)); |
| 567 | ent->name = pool_strdup(options_memory_pool, buffer); |
| 568 | ent->defvalue = perGameOptions[j].defvalue; |
| 569 | ent->flags = perGameOptions[j].flags; |
| 570 | ent->description = perGameOptions[j].description; |
| 571 | } |
| 572 | } |
| 573 | ent = &driver_per_game_options[driver_list_get_count(drivers) * game_option_count]; |
| 574 | memset(ent, 0, sizeof(*ent)); |
| 575 | options_add_entries(settings, driver_per_game_options); |
| 576 | } |
| 577 | |
| 578 | // set up global options |
| 579 | global = CreateGameOptions(OPTIONS_TYPE_GLOBAL); |
| 580 | #if 0 |
| 581 | // set up folders |
| 582 | size_folder_filters = 1; |
| 583 | num_folder_filters = 0; |
| 584 | folder_filters = (folder_filter_type *) pool_malloc(options_memory_pool, size_folder_filters * sizeof(*folder_filters)); |
| 585 | #endif |
| 586 | // now load the options and settings |
| 587 | LoadOptionsAndSettings(); |
| 588 | |
| 589 | return TRUE; |
| 590 | |
| 591 | } |
| 592 | |
| 593 | void OptionsExit(void) |
| 594 | { |
| 595 | // free global options |
| 596 | options_free(global); |
| 597 | global = NULL; |
| 598 | |
| 599 | // free settings |
| 600 | options_free(settings); |
| 601 | settings = NULL; |
| 602 | |
| 603 | // free the memory pool |
| 604 | pool_free(options_memory_pool); |
| 605 | options_memory_pool = NULL; |
| 606 | } |
| 607 | |
| 608 | core_options * Mame32Settings(void) |
| 609 | { |
| 610 | return settings; |
| 611 | } |
| 612 | |
| 613 | core_options * Mame32Global(void) |
| 614 | { |
| 615 | return global; |
| 616 | } |
| 617 | |
| 618 | #if 0 |
| 619 | static void LoadFolderFilter(int folder_index,int filters) |
| 620 | { |
| 621 | //dprintf("loaded folder filter %i %i",folder_index,filters); |
| 622 | |
| 623 | if (num_folder_filters == size_folder_filters) |
| 624 | { |
| 625 | size_folder_filters *= 2; |
| 626 | folder_filters = (folder_filter_type *)realloc( |
| 627 | folder_filters,size_folder_filters * sizeof(folder_filter_type)); |
| 628 | } |
| 629 | folder_filters[num_folder_filters].folder_index = folder_index; |
| 630 | folder_filters[num_folder_filters].filters = filters; |
| 631 | |
| 632 | num_folder_filters++; |
| 633 | } |
| 634 | #endif |
| 635 | |
| 636 | // Restore ui settings to factory |
| 637 | void ResetGUI(void) |
| 638 | { |
| 639 | ResetToDefaults(settings, OPTION_PRIORITY_NORMAL); |
| 640 | // Save the new MAME32ui.ini |
| 641 | SaveOptions(); |
| 642 | save_gui_settings = FALSE; |
| 643 | } |
| 644 | |
| 645 | const char * GetImageTabLongName(int tab_index) |
| 646 | { |
| 647 | assert(0 <= tab_index < ARRAY_LENGTH(image_tabs_long_name)); |
| 648 | return image_tabs_long_name[tab_index]; |
| 649 | } |
| 650 | |
| 651 | const char * GetImageTabShortName(int tab_index) |
| 652 | { |
| 653 | assert(0 <= tab_index < ARRAY_LENGTH(image_tabs_short_name)); |
| 654 | return image_tabs_short_name[tab_index]; |
| 655 | } |
| 656 | |
| 657 | //============================================================ |
| 658 | // OPTIONS WRAPPERS |
| 659 | //============================================================ |
| 660 | |
| 661 | static COLORREF options_get_color(core_options *opts, const char *name) |
| 662 | { |
| 663 | const char *value_str; |
| 664 | unsigned int r, g, b; |
| 665 | COLORREF value; |
| 666 | |
| 667 | value_str = options_get_string(opts, name); |
| 668 | |
| 669 | if (sscanf(value_str, "%u,%u,%u", &r, &g, &b) == 3) |
| 670 | value = RGB(r,g,b); |
| 671 | else |
| 672 | value = (COLORREF) - 1; |
| 673 | return value; |
| 674 | } |
| 675 | |
| 676 | static void options_set_color(core_options *opts, const char *name, COLORREF value) |
| 677 | { |
| 678 | char value_str[32]; |
| 679 | |
| 680 | if (value == (COLORREF) -1) |
| 681 | { |
| 682 | snprintf(value_str, ARRAY_LENGTH(value_str), "%d", (int) value); |
| 683 | } |
| 684 | else |
| 685 | { |
| 686 | snprintf(value_str, ARRAY_LENGTH(value_str), "%d,%d,%d", |
| 687 | (((int) value) >> 0) & 0xFF, |
| 688 | (((int) value) >> 8) & 0xFF, |
| 689 | (((int) value) >> 16) & 0xFF); |
| 690 | } |
| 691 | options_set_string(opts, name, value_str, OPTION_PRIORITY_CMDLINE); |
| 692 | } |
| 693 | |
| 694 | static COLORREF options_get_color_default(core_options *opts, const char *name, int default_color) |
| 695 | { |
| 696 | COLORREF value = options_get_color(opts, name); |
| 697 | if (value == (COLORREF) -1) |
| 698 | value = GetSysColor(default_color); |
| 699 | return value; |
| 700 | } |
| 701 | |
| 702 | static void options_set_color_default(core_options *opts, const char *name, COLORREF value, int default_color) |
| 703 | { |
| 704 | if (value == GetSysColor(default_color)) |
| 705 | options_set_color(settings, name, (COLORREF) -1); |
| 706 | else |
| 707 | options_set_color(settings, name, value); |
| 708 | } |
| 709 | |
| 710 | static input_seq *options_get_input_seq(core_options *opts, const char *name) |
| 711 | { |
| 712 | static input_seq seq; |
| 713 | const char *seq_string; |
| 714 | |
| 715 | seq_string = options_get_string(opts, name); |
| 716 | input_seq_from_tokens(seq_string, &seq); |
| 717 | return &seq; |
| 718 | } |
| 719 | |
| 720 | |
| 721 | |
| 722 | //============================================================ |
| 723 | // OPTIONS CALLS |
| 724 | //============================================================ |
| 725 | |
| 726 | void SetViewMode(int val) |
| 727 | { |
| 728 | options_set_int(settings, M32OPTION_LIST_MODE, val, OPTION_PRIORITY_CMDLINE); |
| 729 | } |
| 730 | |
| 731 | int GetViewMode(void) |
| 732 | { |
| 733 | return options_get_int(settings, M32OPTION_LIST_MODE); |
| 734 | } |
| 735 | |
| 736 | void SetGameCheck(BOOL game_check) |
| 737 | { |
| 738 | options_set_bool(settings, M32OPTION_CHECK_GAME, game_check, OPTION_PRIORITY_CMDLINE); |
| 739 | } |
| 740 | |
| 741 | BOOL GetGameCheck(void) |
| 742 | { |
| 743 | return options_get_bool(settings,M32OPTION_CHECK_GAME); |
| 744 | } |
| 745 | |
| 746 | void SetJoyGUI(BOOL use_joygui) |
| 747 | { |
| 748 | options_set_bool(settings, M32OPTION_JOYSTICK_IN_INTERFACE, use_joygui, OPTION_PRIORITY_CMDLINE); |
| 749 | } |
| 750 | |
| 751 | BOOL GetJoyGUI(void) |
| 752 | { |
| 753 | return options_get_bool(settings, M32OPTION_JOYSTICK_IN_INTERFACE); |
| 754 | } |
| 755 | |
| 756 | void SetKeyGUI(BOOL use_keygui) |
| 757 | { |
| 758 | options_set_bool(settings, M32OPTION_KEYBOARD_IN_INTERFACE, use_keygui, OPTION_PRIORITY_CMDLINE); |
| 759 | } |
| 760 | |
| 761 | BOOL GetKeyGUI(void) |
| 762 | { |
| 763 | return options_get_bool(settings, M32OPTION_KEYBOARD_IN_INTERFACE); |
| 764 | } |
| 765 | |
| 766 | void SetCycleScreenshot(int cycle_screenshot) |
| 767 | { |
| 768 | options_set_int(settings, M32OPTION_CYCLE_SCREENSHOT, cycle_screenshot, OPTION_PRIORITY_CMDLINE); |
| 769 | } |
| 770 | |
| 771 | int GetCycleScreenshot(void) |
| 772 | { |
| 773 | return options_get_int(settings, M32OPTION_CYCLE_SCREENSHOT); |
| 774 | } |
| 775 | |
| 776 | void SetStretchScreenShotLarger(BOOL stretch) |
| 777 | { |
| 778 | options_set_bool(settings, M32OPTION_STRETCH_SCREENSHOT_LARGER, stretch, OPTION_PRIORITY_CMDLINE); |
| 779 | } |
| 780 | |
| 781 | BOOL GetStretchScreenShotLarger(void) |
| 782 | { |
| 783 | return options_get_bool(settings, M32OPTION_STRETCH_SCREENSHOT_LARGER); |
| 784 | } |
| 785 | |
| 786 | void SetScreenshotBorderSize(int size) |
| 787 | { |
| 788 | options_set_int(settings, M32OPTION_SCREENSHOT_BORDER_SIZE, size, OPTION_PRIORITY_CMDLINE); |
| 789 | } |
| 790 | |
| 791 | int GetScreenshotBorderSize(void) |
| 792 | { |
| 793 | return options_get_int(settings, M32OPTION_SCREENSHOT_BORDER_SIZE); |
| 794 | } |
| 795 | |
| 796 | void SetScreenshotBorderColor(COLORREF uColor) |
| 797 | { |
| 798 | options_set_color_default(settings, M32OPTION_SCREENSHOT_BORDER_COLOR, uColor, COLOR_3DFACE); |
| 799 | } |
| 800 | |
| 801 | COLORREF GetScreenshotBorderColor(void) |
| 802 | { |
| 803 | return options_get_color_default(settings, M32OPTION_SCREENSHOT_BORDER_COLOR, COLOR_3DFACE); |
| 804 | } |
| 805 | |
| 806 | void SetFilterInherit(BOOL inherit) |
| 807 | { |
| 808 | options_set_bool(settings, M32OPTION_INHERIT_FILTER, inherit, OPTION_PRIORITY_CMDLINE); |
| 809 | } |
| 810 | |
| 811 | BOOL GetFilterInherit(void) |
| 812 | { |
| 813 | return options_get_bool(settings, M32OPTION_INHERIT_FILTER); |
| 814 | } |
| 815 | |
| 816 | void SetOffsetClones(BOOL offset) |
| 817 | { |
| 818 | options_set_bool(settings, M32OPTION_OFFSET_CLONES, offset, OPTION_PRIORITY_CMDLINE); |
| 819 | } |
| 820 | |
| 821 | BOOL GetOffsetClones(void) |
| 822 | { |
| 823 | return options_get_bool(settings, M32OPTION_OFFSET_CLONES); |
| 824 | } |
| 825 | |
| 826 | void SetGameCaption(BOOL caption) |
| 827 | { |
| 828 | options_set_bool(settings, M32OPTION_GAME_CAPTION, caption, OPTION_PRIORITY_CMDLINE); |
| 829 | } |
| 830 | |
| 831 | BOOL GetGameCaption(void) |
| 832 | { |
| 833 | return options_get_bool(settings, M32OPTION_GAME_CAPTION); |
| 834 | } |
| 835 | |
| 836 | void SetBroadcast(BOOL broadcast) |
| 837 | { |
| 838 | options_set_bool(settings, M32OPTION_BROADCAST_GAME_NAME, broadcast, OPTION_PRIORITY_CMDLINE); |
| 839 | } |
| 840 | |
| 841 | BOOL GetBroadcast(void) |
| 842 | { |
| 843 | return options_get_bool(settings, M32OPTION_BROADCAST_GAME_NAME); |
| 844 | } |
| 845 | |
| 846 | void SetRandomBackground(BOOL random_bg) |
| 847 | { |
| 848 | options_set_bool(settings, M32OPTION_RANDOM_BACKGROUND, random_bg, OPTION_PRIORITY_CMDLINE); |
| 849 | } |
| 850 | |
| 851 | BOOL GetRandomBackground(void) |
| 852 | { |
| 853 | return options_get_bool(settings, M32OPTION_RANDOM_BACKGROUND); |
| 854 | } |
| 855 | |
| 856 | void SetSavedFolderID(UINT val) |
| 857 | { |
| 858 | options_set_int(settings, M32OPTION_DEFAULT_FOLDER_ID, (int) val, OPTION_PRIORITY_CMDLINE); |
| 859 | } |
| 860 | |
| 861 | UINT GetSavedFolderID(void) |
| 862 | { |
| 863 | return (UINT) options_get_int(settings, M32OPTION_DEFAULT_FOLDER_ID); |
| 864 | } |
| 865 | |
| 866 | void SetShowScreenShot(BOOL val) |
| 867 | { |
| 868 | options_set_bool(settings, M32OPTION_SHOW_IMAGE_SECTION, val, OPTION_PRIORITY_CMDLINE); |
| 869 | } |
| 870 | |
| 871 | BOOL GetShowScreenShot(void) |
| 872 | { |
| 873 | return options_get_bool(settings, M32OPTION_SHOW_IMAGE_SECTION); |
| 874 | } |
| 875 | |
| 876 | void SetShowFolderList(BOOL val) |
| 877 | { |
| 878 | options_set_bool(settings, M32OPTION_SHOW_FOLDER_SECTION, val, OPTION_PRIORITY_CMDLINE); |
| 879 | } |
| 880 | |
| 881 | BOOL GetShowFolderList(void) |
| 882 | { |
| 883 | return options_get_bool(settings, M32OPTION_SHOW_FOLDER_SECTION); |
| 884 | } |
| 885 | |
| 886 | static void GetsShowFolderFlags(LPBITS bits) |
| 887 | { |
| 888 | char s[2000]; |
| 889 | extern FOLDERDATA g_folderData[]; |
| 890 | char *token; |
| 891 | |
| 892 | snprintf(s, ARRAY_LENGTH(s), "%s", options_get_string(settings, M32OPTION_HIDE_FOLDERS)); |
| 893 | |
| 894 | SetAllBits(bits, TRUE); |
| 895 | |
| 896 | token = strtok(s,", \t"); |
| 897 | while (token != NULL) |
| 898 | { |
| 899 | int j; |
| 900 | |
| 901 | for (j=0;g_folderData[j].m_lpTitle != NULL;j++) |
| 902 | { |
| 903 | if (strcmp(g_folderData[j].short_name,token) == 0) |
| 904 | { |
| 905 | ClearBit(bits, g_folderData[j].m_nFolderId); |
| 906 | break; |
| 907 | } |
| 908 | } |
| 909 | token = strtok(NULL,", \t"); |
| 910 | } |
| 911 | } |
| 912 | |
| 913 | BOOL GetShowFolder(int folder) |
| 914 | { |
| 915 | BOOL result; |
| 916 | LPBITS show_folder_flags = NewBits(MAX_FOLDERS); |
| 917 | GetsShowFolderFlags(show_folder_flags); |
| 918 | result = TestBit(show_folder_flags, folder); |
| 919 | DeleteBits(show_folder_flags); |
| 920 | return result; |
| 921 | } |
| 922 | |
| 923 | void SetShowFolder(int folder,BOOL show) |
| 924 | { |
| 925 | LPBITS show_folder_flags = NewBits(MAX_FOLDERS); |
| 926 | int i; |
| 927 | int num_saved = 0; |
| 928 | char str[10000]; |
| 929 | extern FOLDERDATA g_folderData[]; |
| 930 | |
| 931 | GetsShowFolderFlags(show_folder_flags); |
| 932 | |
| 933 | if (show) |
| 934 | SetBit(show_folder_flags, folder); |
| 935 | else |
| 936 | ClearBit(show_folder_flags, folder); |
| 937 | |
| 938 | strcpy(str, ""); |
| 939 | |
| 940 | // we save the ones that are NOT displayed, so we can add new ones |
| 941 | // and upgraders will see them |
| 942 | for (i=0;i<MAX_FOLDERS;i++) |
| 943 | { |
| 944 | if (TestBit(show_folder_flags, i) == FALSE) |
| 945 | { |
| 946 | int j; |
| 947 | |
| 948 | if (num_saved != 0) |
| 949 | strcat(str,", "); |
| 950 | |
| 951 | for (j=0;g_folderData[j].m_lpTitle != NULL;j++) |
| 952 | { |
| 953 | if (g_folderData[j].m_nFolderId == i) |
| 954 | { |
| 955 | strcat(str,g_folderData[j].short_name); |
| 956 | num_saved++; |
| 957 | break; |
| 958 | } |
| 959 | } |
| 960 | } |
| 961 | } |
| 962 | options_set_string(settings, M32OPTION_HIDE_FOLDERS, str, OPTION_PRIORITY_CMDLINE); |
| 963 | DeleteBits(show_folder_flags); |
| 964 | } |
| 965 | |
| 966 | void SetShowStatusBar(BOOL val) |
| 967 | { |
| 968 | options_set_bool(settings, M32OPTION_SHOW_STATUS_BAR, val, OPTION_PRIORITY_CMDLINE); |
| 969 | } |
| 970 | |
| 971 | BOOL GetShowStatusBar(void) |
| 972 | { |
| 973 | return options_get_bool(settings, M32OPTION_SHOW_STATUS_BAR); |
| 974 | } |
| 975 | |
| 976 | void SetShowTabCtrl (BOOL val) |
| 977 | { |
| 978 | options_set_bool(settings, M32OPTION_SHOW_TABS, val, OPTION_PRIORITY_CMDLINE); |
| 979 | } |
| 980 | |
| 981 | BOOL GetShowTabCtrl (void) |
| 982 | { |
| 983 | return options_get_bool(settings, M32OPTION_SHOW_TABS); |
| 984 | } |
| 985 | |
| 986 | void SetShowToolBar(BOOL val) |
| 987 | { |
| 988 | options_set_bool(settings, M32OPTION_SHOW_TOOLBAR, val, OPTION_PRIORITY_CMDLINE); |
| 989 | } |
| 990 | |
| 991 | BOOL GetShowToolBar(void) |
| 992 | { |
| 993 | return options_get_bool(settings, M32OPTION_SHOW_TOOLBAR); |
| 994 | } |
| 995 | |
| 996 | void SetCurrentTab(const char *shortname) |
| 997 | { |
| 998 | options_set_string(settings, M32OPTION_CURRENT_TAB, shortname, OPTION_PRIORITY_CMDLINE); |
| 999 | } |
| 1000 | |
| 1001 | const char *GetCurrentTab(void) |
| 1002 | { |
| 1003 | return options_get_string(settings, M32OPTION_CURRENT_TAB); |
| 1004 | } |
| 1005 | |
| 1006 | void SetDefaultGame(const char *name) |
| 1007 | { |
| 1008 | options_set_string(settings, M32OPTION_DEFAULT_GAME, name, OPTION_PRIORITY_CMDLINE); |
| 1009 | } |
| 1010 | |
| 1011 | const char *GetDefaultGame(void) |
| 1012 | { |
| 1013 | return options_get_string(settings, M32OPTION_DEFAULT_GAME); |
| 1014 | } |
| 1015 | |
| 1016 | void SetWindowArea(const AREA *area) |
| 1017 | { |
| 1018 | options_set_int(settings, M32OPTION_WINDOW_X, area->x, OPTION_PRIORITY_CMDLINE); |
| 1019 | options_set_int(settings, M32OPTION_WINDOW_Y, area->y, OPTION_PRIORITY_CMDLINE); |
| 1020 | options_set_int(settings, M32OPTION_WINDOW_WIDTH, area->width, OPTION_PRIORITY_CMDLINE); |
| 1021 | options_set_int(settings, M32OPTION_WINDOW_HEIGHT, area->height, OPTION_PRIORITY_CMDLINE); |
| 1022 | } |
| 1023 | |
| 1024 | void GetWindowArea(AREA *area) |
| 1025 | { |
| 1026 | area->x = options_get_int(settings, M32OPTION_WINDOW_X); |
| 1027 | area->y = options_get_int(settings, M32OPTION_WINDOW_Y); |
| 1028 | area->width = options_get_int(settings, M32OPTION_WINDOW_WIDTH); |
| 1029 | area->height = options_get_int(settings, M32OPTION_WINDOW_HEIGHT); |
| 1030 | } |
| 1031 | |
| 1032 | void SetWindowState(UINT state) |
| 1033 | { |
| 1034 | options_set_int(settings, M32OPTION_WINDOW_STATE, state, OPTION_PRIORITY_CMDLINE); |
| 1035 | } |
| 1036 | |
| 1037 | UINT GetWindowState(void) |
| 1038 | { |
| 1039 | return options_get_int(settings, M32OPTION_WINDOW_STATE); |
| 1040 | } |
| 1041 | |
| 1042 | void SetCustomColor(int iIndex, COLORREF uColor) |
| 1043 | { |
| 1044 | const char *custom_color_string; |
| 1045 | COLORREF custom_color[256]; |
| 1046 | char buffer[10000]; |
| 1047 | |
| 1048 | custom_color_string = options_get_string(settings, M32OPTION_CUSTOM_COLOR); |
| 1049 | CusColorDecodeString(custom_color_string, custom_color); |
| 1050 | |
| 1051 | custom_color[iIndex] = uColor; |
| 1052 | |
| 1053 | CusColorEncodeString(custom_color, buffer); |
| 1054 | options_set_string(settings, M32OPTION_CUSTOM_COLOR, buffer, OPTION_PRIORITY_CMDLINE); |
| 1055 | } |
| 1056 | |
| 1057 | COLORREF GetCustomColor(int iIndex) |
| 1058 | { |
| 1059 | const char *custom_color_string; |
| 1060 | COLORREF custom_color[256]; |
| 1061 | |
| 1062 | custom_color_string = options_get_string(settings, M32OPTION_CUSTOM_COLOR); |
| 1063 | CusColorDecodeString(custom_color_string, custom_color); |
| 1064 | |
| 1065 | if (custom_color[iIndex] == (COLORREF)-1) |
| 1066 | return (COLORREF)RGB(0,0,0); |
| 1067 | |
| 1068 | return custom_color[iIndex]; |
| 1069 | } |
| 1070 | |
| 1071 | void SetListFont(const LOGFONT *font) |
| 1072 | { |
| 1073 | char font_string[10000]; |
| 1074 | FontEncodeString(font, font_string); |
| 1075 | options_set_string(settings, M32OPTION_LIST_FONT, font_string, OPTION_PRIORITY_CMDLINE); |
| 1076 | } |
| 1077 | |
| 1078 | void GetListFont(LOGFONT *font) |
| 1079 | { |
| 1080 | const char *font_string = options_get_string(settings, M32OPTION_LIST_FONT); |
| 1081 | FontDecodeString(font_string, font); |
| 1082 | } |
| 1083 | |
| 1084 | void SetListFontColor(COLORREF uColor) |
| 1085 | { |
| 1086 | options_set_color_default(settings, M32OPTION_TEXT_COLOR, uColor, COLOR_WINDOWTEXT); |
| 1087 | } |
| 1088 | |
| 1089 | COLORREF GetListFontColor(void) |
| 1090 | { |
| 1091 | return options_get_color_default(settings, M32OPTION_TEXT_COLOR, COLOR_WINDOWTEXT); |
| 1092 | } |
| 1093 | |
| 1094 | void SetListCloneColor(COLORREF uColor) |
| 1095 | { |
| 1096 | options_set_color_default(settings, M32OPTION_CLONE_COLOR, uColor, COLOR_WINDOWTEXT); |
| 1097 | } |
| 1098 | |
| 1099 | COLORREF GetListCloneColor(void) |
| 1100 | { |
| 1101 | return options_get_color_default(settings, M32OPTION_CLONE_COLOR, COLOR_WINDOWTEXT); |
| 1102 | } |
| 1103 | |
| 1104 | int GetShowTab(int tab) |
| 1105 | { |
| 1106 | const char *show_tabs_string; |
| 1107 | int show_tab_flags; |
| 1108 | |
| 1109 | show_tabs_string = options_get_string(settings, M32OPTION_HIDE_TABS); |
| 1110 | TabFlagsDecodeString(show_tabs_string, &show_tab_flags); |
| 1111 | return (show_tab_flags & (1 << tab)) != 0; |
| 1112 | } |
| 1113 | |
| 1114 | void SetShowTab(int tab,BOOL show) |
| 1115 | { |
| 1116 | const char *show_tabs_string; |
| 1117 | int show_tab_flags; |
| 1118 | char buffer[10000]; |
| 1119 | |
| 1120 | show_tabs_string = options_get_string(settings, M32OPTION_HIDE_TABS); |
| 1121 | TabFlagsDecodeString(show_tabs_string, &show_tab_flags); |
| 1122 | |
| 1123 | if (show) |
| 1124 | show_tab_flags |= 1 << tab; |
| 1125 | else |
| 1126 | show_tab_flags &= ~(1 << tab); |
| 1127 | |
| 1128 | TabFlagsEncodeString(show_tab_flags, buffer); |
| 1129 | options_set_string(settings, M32OPTION_HIDE_TABS, buffer, OPTION_PRIORITY_CMDLINE); |
| 1130 | } |
| 1131 | |
| 1132 | // don't delete the last one |
| 1133 | BOOL AllowedToSetShowTab(int tab,BOOL show) |
| 1134 | { |
| 1135 | const char *show_tabs_string; |
| 1136 | int show_tab_flags; |
| 1137 | |
| 1138 | if (show == TRUE) |
| 1139 | return TRUE; |
| 1140 | |
| 1141 | show_tabs_string = options_get_string(settings, M32OPTION_HIDE_TABS); |
| 1142 | TabFlagsDecodeString(show_tabs_string, &show_tab_flags); |
| 1143 | |
| 1144 | show_tab_flags &= ~(1 << tab); |
| 1145 | return show_tab_flags != 0; |
| 1146 | } |
| 1147 | |
| 1148 | int GetHistoryTab(void) |
| 1149 | { |
| 1150 | return options_get_int(settings, M32OPTION_HISTORY_TAB); |
| 1151 | } |
| 1152 | |
| 1153 | void SetHistoryTab(int tab, BOOL show) |
| 1154 | { |
| 1155 | if (show) |
| 1156 | options_set_int(settings, M32OPTION_HISTORY_TAB, tab, OPTION_PRIORITY_CMDLINE); |
| 1157 | else |
| 1158 | options_set_int(settings, M32OPTION_HISTORY_TAB, TAB_NONE, OPTION_PRIORITY_CMDLINE); |
| 1159 | } |
| 1160 | |
| 1161 | void SetColumnWidths(int width[]) |
| 1162 | { |
| 1163 | char column_width_string[10000]; |
| 1164 | ColumnEncodeStringWithCount(width, column_width_string, COLUMN_MAX); |
| 1165 | options_set_string(settings, M32OPTION_COLUMN_WIDTHS, column_width_string, OPTION_PRIORITY_CMDLINE); |
| 1166 | } |
| 1167 | |
| 1168 | void GetColumnWidths(int width[]) |
| 1169 | { |
| 1170 | const char *column_width_string; |
| 1171 | column_width_string = options_get_string(settings, M32OPTION_COLUMN_WIDTHS); |
| 1172 | ColumnDecodeStringWithCount(column_width_string, width, COLUMN_MAX); |
| 1173 | } |
| 1174 | |
| 1175 | void SetSplitterPos(int splitterId, int pos) |
| 1176 | { |
| 1177 | const char *splitter_string; |
| 1178 | int *splitter; |
| 1179 | char buffer[10000]; |
| 1180 | |
| 1181 | if (splitterId < GetSplitterCount()) |
| 1182 | { |
| 1183 | splitter_string = options_get_string(settings, M32OPTION_SPLITTERS); |
| 1184 | splitter = (int *) alloca(GetSplitterCount() * sizeof(*splitter)); |
| 1185 | SplitterDecodeString(splitter_string, splitter); |
| 1186 | |
| 1187 | splitter[splitterId] = pos; |
| 1188 | |
| 1189 | SplitterEncodeString(splitter, buffer); |
| 1190 | options_set_string(settings, M32OPTION_SPLITTERS, buffer, OPTION_PRIORITY_CMDLINE); |
| 1191 | } |
| 1192 | } |
| 1193 | |
| 1194 | int GetSplitterPos(int splitterId) |
| 1195 | { |
| 1196 | const char *splitter_string; |
| 1197 | int *splitter; |
| 1198 | |
| 1199 | splitter_string = options_get_string(settings, M32OPTION_SPLITTERS); |
| 1200 | splitter = (int *) alloca(GetSplitterCount() * sizeof(*splitter)); |
| 1201 | SplitterDecodeString(splitter_string, splitter); |
| 1202 | |
| 1203 | if (splitterId < GetSplitterCount()) |
| 1204 | return splitter[splitterId]; |
| 1205 | |
| 1206 | return -1; /* Error */ |
| 1207 | } |
| 1208 | |
| 1209 | void SetColumnOrder(int order[]) |
| 1210 | { |
| 1211 | char column_order_string[10000]; |
| 1212 | ColumnEncodeStringWithCount(order, column_order_string, COLUMN_MAX); |
| 1213 | options_set_string(settings, M32OPTION_COLUMN_ORDER, column_order_string, OPTION_PRIORITY_CMDLINE); |
| 1214 | } |
| 1215 | |
| 1216 | void GetColumnOrder(int order[]) |
| 1217 | { |
| 1218 | const char *column_order_string; |
| 1219 | column_order_string = options_get_string(settings, M32OPTION_COLUMN_ORDER); |
| 1220 | ColumnDecodeStringWithCount(column_order_string, order, COLUMN_MAX); |
| 1221 | } |
| 1222 | |
| 1223 | void SetColumnShown(int shown[]) |
| 1224 | { |
| 1225 | char column_shown_string[10000]; |
| 1226 | ColumnEncodeStringWithCount(shown, column_shown_string, COLUMN_MAX); |
| 1227 | options_set_string(settings, M32OPTION_COLUMN_SHOWN, column_shown_string, OPTION_PRIORITY_CMDLINE); |
| 1228 | } |
| 1229 | |
| 1230 | void GetColumnShown(int shown[]) |
| 1231 | { |
| 1232 | const char *column_shown_string; |
| 1233 | column_shown_string = options_get_string(settings, M32OPTION_COLUMN_SHOWN); |
| 1234 | ColumnDecodeStringWithCount(column_shown_string, shown, COLUMN_MAX); |
| 1235 | } |
| 1236 | |
| 1237 | void SetSortColumn(int column) |
| 1238 | { |
| 1239 | options_set_int(settings, M32OPTION_SORT_COLUMN, column, OPTION_PRIORITY_CMDLINE); |
| 1240 | } |
| 1241 | |
| 1242 | int GetSortColumn(void) |
| 1243 | { |
| 1244 | return options_get_int(settings, M32OPTION_SORT_COLUMN); |
| 1245 | } |
| 1246 | |
| 1247 | void SetSortReverse(BOOL reverse) |
| 1248 | { |
| 1249 | options_set_bool(settings, M32OPTION_SORT_REVERSED, reverse, OPTION_PRIORITY_CMDLINE); |
| 1250 | } |
| 1251 | |
| 1252 | BOOL GetSortReverse(void) |
| 1253 | { |
| 1254 | return options_get_bool(settings, M32OPTION_SORT_REVERSED); |
| 1255 | } |
| 1256 | |
| 1257 | const char* GetLanguage(void) |
| 1258 | { |
| 1259 | return options_get_string(settings, M32OPTION_LANGUAGE); |
| 1260 | } |
| 1261 | |
| 1262 | void SetLanguage(const char* lang) |
| 1263 | { |
| 1264 | options_set_string(settings, M32OPTION_LANGUAGE, lang, OPTION_PRIORITY_CMDLINE); |
| 1265 | } |
| 1266 | |
| 1267 | const char* GetRomDirs(void) |
| 1268 | { |
| 1269 | return options_get_string(global, OPTION_ROMPATH); |
| 1270 | } |
| 1271 | |
| 1272 | void SetRomDirs(const char* paths) |
| 1273 | { |
| 1274 | options_set_string(global, OPTION_ROMPATH, paths, OPTION_PRIORITY_CMDLINE); |
| 1275 | } |
| 1276 | |
| 1277 | const char* GetSampleDirs(void) |
| 1278 | { |
| 1279 | return options_get_string(global, OPTION_SAMPLEPATH); |
| 1280 | } |
| 1281 | |
| 1282 | void SetSampleDirs(const char* paths) |
| 1283 | { |
| 1284 | options_set_string(global, OPTION_SAMPLEPATH, paths, OPTION_PRIORITY_CMDLINE); |
| 1285 | } |
| 1286 | |
| 1287 | const char * GetIniDir(void) |
| 1288 | { |
| 1289 | const char *ini_dir; |
| 1290 | const char *s; |
| 1291 | |
| 1292 | ini_dir = options_get_string(global, OPTION_INIPATH); |
| 1293 | while((s = strchr(ini_dir, ';')) != NULL) |
| 1294 | { |
| 1295 | ini_dir = s + 1; |
| 1296 | } |
| 1297 | return ini_dir; |
| 1298 | |
| 1299 | } |
| 1300 | |
| 1301 | void SetIniDir(const char *path) |
| 1302 | { |
| 1303 | options_set_string(global, OPTION_INIPATH, path, OPTION_PRIORITY_CMDLINE); |
| 1304 | } |
| 1305 | |
| 1306 | const char* GetCtrlrDir(void) |
| 1307 | { |
| 1308 | return options_get_string(global, OPTION_CTRLRPATH); |
| 1309 | } |
| 1310 | |
| 1311 | void SetCtrlrDir(const char* path) |
| 1312 | { |
| 1313 | options_set_string(global, OPTION_CTRLRPATH, path, OPTION_PRIORITY_CMDLINE); |
| 1314 | } |
| 1315 | |
| 1316 | const char* GetCommentDir(void) |
| 1317 | { |
| 1318 | return options_get_string(global, OPTION_COMMENT_DIRECTORY); |
| 1319 | } |
| 1320 | |
| 1321 | void SetCommentDir(const char* path) |
| 1322 | { |
| 1323 | options_set_string(global, OPTION_COMMENT_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1324 | } |
| 1325 | |
| 1326 | const char* GetCfgDir(void) |
| 1327 | { |
| 1328 | return options_get_string(global, OPTION_CFG_DIRECTORY); |
| 1329 | } |
| 1330 | |
| 1331 | void SetCfgDir(const char* path) |
| 1332 | { |
| 1333 | options_set_string(global, OPTION_CFG_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1334 | } |
| 1335 | |
| 1336 | const char* GetNvramDir(void) |
| 1337 | { |
| 1338 | return options_get_string(global, OPTION_NVRAM_DIRECTORY); |
| 1339 | } |
| 1340 | |
| 1341 | void SetNvramDir(const char* path) |
| 1342 | { |
| 1343 | options_set_string(global, OPTION_NVRAM_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1344 | } |
| 1345 | |
| 1346 | const char* GetInpDir(void) |
| 1347 | { |
| 1348 | return options_get_string(global, OPTION_INPUT_DIRECTORY); |
| 1349 | } |
| 1350 | |
| 1351 | void SetInpDir(const char* path) |
| 1352 | { |
| 1353 | options_set_string(global, OPTION_INPUT_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1354 | } |
| 1355 | |
| 1356 | const char* GetImgDir(void) |
| 1357 | { |
| 1358 | return options_get_string(global, OPTION_SNAPSHOT_DIRECTORY); |
| 1359 | } |
| 1360 | |
| 1361 | void SetImgDir(const char* path) |
| 1362 | { |
| 1363 | options_set_string(global, OPTION_SNAPSHOT_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1364 | } |
| 1365 | |
| 1366 | const char* GetStateDir(void) |
| 1367 | { |
| 1368 | return options_get_string(global, OPTION_STATE_DIRECTORY); |
| 1369 | } |
| 1370 | |
| 1371 | void SetStateDir(const char* path) |
| 1372 | { |
| 1373 | options_set_string(global, OPTION_STATE_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1374 | } |
| 1375 | |
| 1376 | const char* GetArtDir(void) |
| 1377 | { |
| 1378 | return options_get_string(global, OPTION_ARTPATH); |
| 1379 | } |
| 1380 | |
| 1381 | void SetArtDir(const char* path) |
| 1382 | { |
| 1383 | options_set_string(global, OPTION_ARTPATH, path, OPTION_PRIORITY_CMDLINE); |
| 1384 | } |
| 1385 | |
| 1386 | const char* GetMemcardDir(void) |
| 1387 | { |
| 1388 | return options_get_string(global, OPTION_MEMCARD_DIRECTORY); |
| 1389 | } |
| 1390 | |
| 1391 | void SetMemcardDir(const char* path) |
| 1392 | { |
| 1393 | options_set_string(global, OPTION_MEMCARD_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1394 | } |
| 1395 | |
| 1396 | const char* GetFlyerDir(void) |
| 1397 | { |
| 1398 | return options_get_string(settings, M32OPTION_FLYER_DIRECTORY); |
| 1399 | } |
| 1400 | |
| 1401 | void SetFlyerDir(const char* path) |
| 1402 | { |
| 1403 | options_set_string(settings, M32OPTION_FLYER_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1404 | } |
| 1405 | |
| 1406 | const char* GetCabinetDir(void) |
| 1407 | { |
| 1408 | return options_get_string(settings, M32OPTION_CABINET_DIRECTORY); |
| 1409 | } |
| 1410 | |
| 1411 | void SetCabinetDir(const char* path) |
| 1412 | { |
| 1413 | options_set_string(settings, M32OPTION_CABINET_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1414 | } |
| 1415 | |
| 1416 | const char* GetMarqueeDir(void) |
| 1417 | { |
| 1418 | return options_get_string(settings, M32OPTION_MARQUEE_DIRECTORY); |
| 1419 | } |
| 1420 | |
| 1421 | void SetMarqueeDir(const char* path) |
| 1422 | { |
| 1423 | options_set_string(settings, M32OPTION_MARQUEE_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1424 | } |
| 1425 | |
| 1426 | const char* GetTitlesDir(void) |
| 1427 | { |
| 1428 | return options_get_string(settings, M32OPTION_TITLE_DIRECTORY); |
| 1429 | } |
| 1430 | |
| 1431 | void SetTitlesDir(const char* path) |
| 1432 | { |
| 1433 | options_set_string(settings, M32OPTION_TITLE_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1434 | } |
| 1435 | |
| 1436 | const char * GetControlPanelDir(void) |
| 1437 | { |
| 1438 | return options_get_string(settings, M32OPTION_CPANEL_DIRECTORY); |
| 1439 | } |
| 1440 | |
| 1441 | void SetControlPanelDir(const char *path) |
| 1442 | { |
| 1443 | options_set_string(settings, M32OPTION_CPANEL_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1444 | } |
| 1445 | |
| 1446 | const char * GetPcbDir(void) |
| 1447 | { |
| 1448 | return options_get_string(settings, M32OPTION_PCB_DIRECTORY); |
| 1449 | } |
| 1450 | |
| 1451 | void SetPcbDir(const char *path) |
| 1452 | { |
| 1453 | options_set_string(settings, M32OPTION_PCB_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1454 | } |
| 1455 | |
| 1456 | const char * GetDiffDir(void) |
| 1457 | { |
| 1458 | return options_get_string(global, OPTION_DIFF_DIRECTORY); |
| 1459 | } |
| 1460 | |
| 1461 | void SetDiffDir(const char* path) |
| 1462 | { |
| 1463 | options_set_string(global, OPTION_DIFF_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1464 | } |
| 1465 | |
| 1466 | const char* GetIconsDir(void) |
| 1467 | { |
| 1468 | return options_get_string(settings, M32OPTION_ICONS_DIRECTORY); |
| 1469 | } |
| 1470 | |
| 1471 | void SetIconsDir(const char* path) |
| 1472 | { |
| 1473 | options_set_string(settings, M32OPTION_ICONS_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1474 | } |
| 1475 | |
| 1476 | const char* GetBgDir (void) |
| 1477 | { |
| 1478 | return options_get_string(settings, M32OPTION_BACKGROUND_DIRECTORY); |
| 1479 | } |
| 1480 | |
| 1481 | void SetBgDir (const char* path) |
| 1482 | { |
| 1483 | options_set_string(settings, M32OPTION_BACKGROUND_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1484 | } |
| 1485 | |
| 1486 | const char* GetFolderDir(void) |
| 1487 | { |
| 1488 | return options_get_string(settings, M32OPTION_FOLDER_DIRECTORY); |
| 1489 | } |
| 1490 | |
| 1491 | void SetFolderDir(const char* path) |
| 1492 | { |
| 1493 | options_set_string(settings, M32OPTION_FOLDER_DIRECTORY, path, OPTION_PRIORITY_CMDLINE); |
| 1494 | } |
| 1495 | |
| 1496 | const char* GetCheatFileName(void) |
| 1497 | { |
| 1498 | return options_get_string(global, OPTION_CHEAT_FILE); |
| 1499 | } |
| 1500 | |
| 1501 | void SetCheatFileName(const char* path) |
| 1502 | { |
| 1503 | options_set_string(global, OPTION_CHEAT_FILE, path, OPTION_PRIORITY_CMDLINE); |
| 1504 | } |
| 1505 | |
| 1506 | const char* GetHistoryFileName(void) |
| 1507 | { |
| 1508 | return options_get_string(settings, M32OPTION_HISTORY_FILE); |
| 1509 | } |
| 1510 | |
| 1511 | void SetHistoryFileName(const char* path) |
| 1512 | { |
| 1513 | options_set_string(settings, M32OPTION_HISTORY_FILE, path, OPTION_PRIORITY_CMDLINE); |
| 1514 | } |
| 1515 | |
| 1516 | |
| 1517 | const char* GetMAMEInfoFileName(void) |
| 1518 | { |
| 1519 | return options_get_string(settings, M32OPTION_MAMEINFO_FILE); |
| 1520 | } |
| 1521 | |
| 1522 | void SetMAMEInfoFileName(const char* path) |
| 1523 | { |
| 1524 | options_set_string(settings, M32OPTION_MAMEINFO_FILE, path, OPTION_PRIORITY_CMDLINE); |
| 1525 | } |
| 1526 | |
| 1527 | void ResetGameOptions(int driver_index) |
| 1528 | { |
| 1529 | assert(0 <= driver_index && driver_index < driver_list_get_count(drivers)); |
| 1530 | |
| 1531 | save_options(OPTIONS_GAME, NULL, driver_index); |
| 1532 | } |
| 1533 | |
| 1534 | void ResetGameDefaults(void) |
| 1535 | { |
| 1536 | // Walk the global settings and reset everything to defaults; |
| 1537 | ResetToDefaults(global, OPTION_PRIORITY_CMDLINE); |
| 1538 | save_options(OPTIONS_GLOBAL, global, 1); |
| 1539 | save_default_options = FALSE; |
| 1540 | } |
| 1541 | |
| 1542 | /* |
| 1543 | * Reset all game, vector and source options to defaults. |
| 1544 | * No reason to reboot if this is done. |
| 1545 | */ |
| 1546 | void ResetAllGameOptions(void) |
| 1547 | { |
| 1548 | int i; |
| 1549 | |
| 1550 | for (i = 0; i < driver_list_get_count(drivers); i++) |
| 1551 | { |
| 1552 | ResetGameOptions(i); |
| 1553 | } |
| 1554 | |
| 1555 | /* Walk the ini/source folder deleting all ini's. */ |
| 1556 | remove_all_source_options(); |
| 1557 | |
| 1558 | /* finally vector.ini */ |
| 1559 | save_options(OPTIONS_VECTOR, NULL, 0); |
| 1560 | } |
| 1561 | |
| 1562 | static void GetDriverOptionName(int driver_index, const char *option_name, char *buffer, size_t buffer_len) |
| 1563 | { |
| 1564 | assert(0 <= driver_index && driver_index < driver_list_get_count(drivers)); |
| 1565 | snprintf(buffer, buffer_len, "%s_%s", drivers[driver_index]->name, option_name); |
| 1566 | } |
| 1567 | |
| 1568 | int GetRomAuditResults(int driver_index) |
| 1569 | { |
| 1570 | char buffer[128]; |
| 1571 | GetDriverOptionName(driver_index, "rom_audit", buffer, ARRAY_LENGTH(buffer)); |
| 1572 | return options_get_int(settings, buffer); |
| 1573 | } |
| 1574 | |
| 1575 | void SetRomAuditResults(int driver_index, int audit_results) |
| 1576 | { |
| 1577 | char buffer[128]; |
| 1578 | GetDriverOptionName(driver_index, "rom_audit", buffer, ARRAY_LENGTH(buffer)); |
| 1579 | options_set_int(settings, buffer, audit_results, OPTION_PRIORITY_CMDLINE); |
| 1580 | } |
| 1581 | |
| 1582 | int GetSampleAuditResults(int driver_index) |
| 1583 | { |
| 1584 | char buffer[128]; |
| 1585 | GetDriverOptionName(driver_index, "samples_audit", buffer, ARRAY_LENGTH(buffer)); |
| 1586 | return options_get_int(settings, buffer); |
| 1587 | } |
| 1588 | |
| 1589 | void SetSampleAuditResults(int driver_index, int audit_results) |
| 1590 | { |
| 1591 | char buffer[128]; |
| 1592 | GetDriverOptionName(driver_index, "samples_audit", buffer, ARRAY_LENGTH(buffer)); |
| 1593 | options_set_int(settings, buffer, audit_results, OPTION_PRIORITY_CMDLINE); |
| 1594 | } |
| 1595 | |
| 1596 | static void IncrementPlayVariable(int driver_index, const char *play_variable, int increment) |
| 1597 | { |
| 1598 | char buffer[128]; |
| 1599 | int count; |
| 1600 | |
| 1601 | GetDriverOptionName(driver_index, play_variable, buffer, ARRAY_LENGTH(buffer)); |
| 1602 | count = options_get_int(settings, buffer); |
| 1603 | options_set_int(settings, buffer, count + increment, OPTION_PRIORITY_CMDLINE); |
| 1604 | } |
| 1605 | |
| 1606 | void IncrementPlayCount(int driver_index) |
| 1607 | { |
| 1608 | IncrementPlayVariable(driver_index, "play_count", 1); |
| 1609 | } |
| 1610 | |
| 1611 | int GetPlayCount(int driver_index) |
| 1612 | { |
| 1613 | char buffer[128]; |
| 1614 | GetDriverOptionName(driver_index, "play_count", buffer, ARRAY_LENGTH(buffer)); |
| 1615 | return options_get_int(settings, buffer); |
| 1616 | } |
| 1617 | |
| 1618 | static void ResetPlayVariable(int driver_index, const char *play_variable) |
| 1619 | { |
| 1620 | int i; |
| 1621 | if (driver_index < 0) |
| 1622 | { |
| 1623 | /* all games */ |
| 1624 | for (i = 0; i< driver_list_get_count(drivers); i++) |
| 1625 | { |
| 1626 | /* 20070808 MSH - Was passing in driver_index instead of i. Doh! */ |
| 1627 | ResetPlayVariable(i, play_variable); |
| 1628 | } |
| 1629 | } |
| 1630 | else |
| 1631 | { |
| 1632 | char buffer[128]; |
| 1633 | GetDriverOptionName(driver_index, play_variable, buffer, ARRAY_LENGTH(buffer)); |
| 1634 | options_set_int(settings, buffer, 0, OPTION_PRIORITY_CMDLINE); |
| 1635 | } |
| 1636 | } |
| 1637 | |
| 1638 | void ResetPlayCount(int driver_index) |
| 1639 | { |
| 1640 | ResetPlayVariable(driver_index, "play_count"); |
| 1641 | } |
| 1642 | |
| 1643 | void ResetPlayTime(int driver_index) |
| 1644 | { |
| 1645 | ResetPlayVariable(driver_index, "play_time"); |
| 1646 | } |
| 1647 | |
| 1648 | int GetPlayTime(int driver_index) |
| 1649 | { |
| 1650 | char buffer[128]; |
| 1651 | GetDriverOptionName(driver_index, "play_time", buffer, ARRAY_LENGTH(buffer)); |
| 1652 | return options_get_int(settings, buffer); |
| 1653 | } |
| 1654 | |
| 1655 | void IncrementPlayTime(int driver_index,int playtime) |
| 1656 | { |
| 1657 | IncrementPlayVariable(driver_index, "play_time", playtime); |
| 1658 | } |
| 1659 | |
| 1660 | void GetTextPlayTime(int driver_index,char *buf) |
| 1661 | { |
| 1662 | int hour, minute, second; |
| 1663 | int temp = GetPlayTime(driver_index); |
| 1664 | |
| 1665 | assert(0 <= driver_index && driver_index < driver_list_get_count(drivers)); |
| 1666 | |
| 1667 | hour = temp / 3600; |
| 1668 | temp = temp - 3600*hour; |
| 1669 | minute = temp / 60; //Calc Minutes |
| 1670 | second = temp - 60*minute; |
| 1671 | |
| 1672 | if (hour == 0) |
| 1673 | sprintf(buf, "%d:%02d", minute, second ); |
| 1674 | else |
| 1675 | sprintf(buf, "%d:%02d:%02d", hour, minute, second ); |
| 1676 | } |
| 1677 | |
| 1678 | input_seq* Get_ui_key_up(void) |
| 1679 | { |
| 1680 | return options_get_input_seq(settings, M32OPTION_UI_KEY_UP); |
| 1681 | } |
| 1682 | input_seq* Get_ui_key_down(void) |
| 1683 | { |
| 1684 | return options_get_input_seq(settings, M32OPTION_UI_KEY_DOWN); |
| 1685 | } |
| 1686 | input_seq* Get_ui_key_left(void) |
| 1687 | { |
| 1688 | return options_get_input_seq(settings, M32OPTION_UI_KEY_LEFT); |
| 1689 | } |
| 1690 | input_seq* Get_ui_key_right(void) |
| 1691 | { |
| 1692 | return options_get_input_seq(settings, M32OPTION_UI_KEY_RIGHT); |
| 1693 | } |
| 1694 | input_seq* Get_ui_key_start(void) |
| 1695 | { |
| 1696 | return options_get_input_seq(settings, M32OPTION_UI_KEY_START); |
| 1697 | } |
| 1698 | input_seq* Get_ui_key_pgup(void) |
| 1699 | { |
| 1700 | return options_get_input_seq(settings, M32OPTION_UI_KEY_PGUP); |
| 1701 | } |
| 1702 | input_seq* Get_ui_key_pgdwn(void) |
| 1703 | { |
| 1704 | return options_get_input_seq(settings, M32OPTION_UI_KEY_PGDWN); |
| 1705 | } |
| 1706 | input_seq* Get_ui_key_home(void) |
| 1707 | { |
| 1708 | return options_get_input_seq(settings, M32OPTION_UI_KEY_HOME); |
| 1709 | } |
| 1710 | input_seq* Get_ui_key_end(void) |
| 1711 | { |
| 1712 | return options_get_input_seq(settings, M32OPTION_UI_KEY_END); |
| 1713 | } |
| 1714 | input_seq* Get_ui_key_ss_change(void) |
| 1715 | { |
| 1716 | return options_get_input_seq(settings, M32OPTION_UI_KEY_SS_CHANGE); |
| 1717 | } |
| 1718 | input_seq* Get_ui_key_history_up(void) |
| 1719 | { |
| 1720 | return options_get_input_seq(settings, M32OPTION_UI_KEY_HISTORY_UP); |
| 1721 | } |
| 1722 | input_seq* Get_ui_key_history_down(void) |
| 1723 | { |
| 1724 | return options_get_input_seq(settings, M32OPTION_UI_KEY_HISTORY_DOWN); |
| 1725 | } |
| 1726 | |
| 1727 | |
| 1728 | input_seq* Get_ui_key_context_filters(void) |
| 1729 | { |
| 1730 | return options_get_input_seq(settings, M32OPTION_UI_KEY_CONTEXT_FILTERS); |
| 1731 | } |
| 1732 | input_seq* Get_ui_key_select_random(void) |
| 1733 | { |
| 1734 | return options_get_input_seq(settings, M32OPTION_UI_KEY_SELECT_RANDOM); |
| 1735 | } |
| 1736 | input_seq* Get_ui_key_game_audit(void) |
| 1737 | { |
| 1738 | return options_get_input_seq(settings, M32OPTION_UI_KEY_GAME_AUDIT); |
| 1739 | } |
| 1740 | input_seq* Get_ui_key_game_properties(void) |
| 1741 | { |
| 1742 | return options_get_input_seq(settings, M32OPTION_UI_KEY_GAME_PROPERTIES); |
| 1743 | } |
| 1744 | input_seq* Get_ui_key_help_contents(void) |
| 1745 | { |
| 1746 | return options_get_input_seq(settings, M32OPTION_UI_KEY_HELP_CONTENTS); |
| 1747 | } |
| 1748 | input_seq* Get_ui_key_update_gamelist(void) |
| 1749 | { |
| 1750 | return options_get_input_seq(settings, M32OPTION_UI_KEY_UPDATE_GAMELIST); |
| 1751 | } |
| 1752 | input_seq* Get_ui_key_view_folders(void) |
| 1753 | { |
| 1754 | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_FOLDERS); |
| 1755 | } |
| 1756 | input_seq* Get_ui_key_view_fullscreen(void) |
| 1757 | { |
| 1758 | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_FULLSCREEN); |
| 1759 | } |
| 1760 | input_seq* Get_ui_key_view_pagetab(void) |
| 1761 | { |
| 1762 | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_PAGETAB); |
| 1763 | } |
| 1764 | input_seq* Get_ui_key_view_picture_area(void) |
| 1765 | { |
| 1766 | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_PICTURE_AREA); |
| 1767 | } |
| 1768 | input_seq* Get_ui_key_view_status(void) |
| 1769 | { |
| 1770 | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_STATUS); |
| 1771 | } |
| 1772 | input_seq* Get_ui_key_view_toolbars(void) |
| 1773 | { |
| 1774 | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_TOOLBARS); |
| 1775 | } |
| 1776 | |
| 1777 | input_seq* Get_ui_key_view_tab_cabinet(void) |
| 1778 | { |
| 1779 | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_TAB_CABINET); |
| 1780 | } |
| 1781 | input_seq* Get_ui_key_view_tab_cpanel(void) |
| 1782 | { |
| 1783 | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_TAB_CPANEL); |
| 1784 | } |
| 1785 | input_seq* Get_ui_key_view_tab_flyer(void) |
| 1786 | { |
| 1787 | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_TAB_FLYER); |
| 1788 | } |
| 1789 | input_seq* Get_ui_key_view_tab_history(void) |
| 1790 | { |
| 1791 | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_TAB_HISTORY); |
| 1792 | } |
| 1793 | input_seq* Get_ui_key_view_tab_marquee(void) |
| 1794 | { |
| 1795 | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_TAB_MARQUEE); |
| 1796 | } |
| 1797 | input_seq* Get_ui_key_view_tab_screenshot(void) |
| 1798 | { |
| 1799 | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_TAB_SCREENSHOT); |
| 1800 | } |
| 1801 | input_seq* Get_ui_key_view_tab_title(void) |
| 1802 | { |
| 1803 | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_TAB_TITLE); |
| 1804 | } |
| 1805 | input_seq* Get_ui_key_view_tab_pcb(void) |
| 1806 | { |
| 1807 | return options_get_input_seq(settings, M32OPTION_UI_KEY_VIEW_TAB_PCB); |
| 1808 | } |
| 1809 | input_seq* Get_ui_key_quit(void) |
| 1810 | { |
| 1811 | return options_get_input_seq(settings, M32OPTION_UI_KEY_QUIT); |
| 1812 | } |
| 1813 | |
| 1814 | |
| 1815 | |
| 1816 | static int GetUIJoy(const char *option_name, int joycodeIndex) |
| 1817 | { |
| 1818 | const char *joycodes_string; |
| 1819 | int joycodes[4]; |
| 1820 | |
| 1821 | assert(0 <= joycodeIndex && joycodeIndex < 4); |
| 1822 | joycodes_string = options_get_string(settings, option_name); |
| 1823 | ColumnDecodeStringWithCount(joycodes_string, joycodes, ARRAY_LENGTH(joycodes)); |
| 1824 | return joycodes[joycodeIndex]; |
| 1825 | } |
| 1826 | |
| 1827 | static void SetUIJoy(const char *option_name, int joycodeIndex, int val) |
| 1828 | { |
| 1829 | const char *joycodes_string; |
| 1830 | int joycodes[4]; |
| 1831 | char buffer[1024]; |
| 1832 | |
| 1833 | assert(0 <= joycodeIndex && joycodeIndex < 4); |
| 1834 | joycodes_string = options_get_string(settings, option_name); |
| 1835 | ColumnDecodeStringWithCount(joycodes_string, joycodes, ARRAY_LENGTH(joycodes)); |
| 1836 | |
| 1837 | joycodes[joycodeIndex] = val; |
| 1838 | ColumnEncodeStringWithCount(joycodes, buffer, ARRAY_LENGTH(joycodes)); |
| 1839 | options_set_string(settings, option_name, buffer, OPTION_PRIORITY_CMDLINE); |
| 1840 | |
| 1841 | |
| 1842 | } |
| 1843 | |
| 1844 | int GetUIJoyUp(int joycodeIndex) |
| 1845 | { |
| 1846 | return GetUIJoy(M32OPTION_UI_JOY_UP, joycodeIndex); |
| 1847 | } |
| 1848 | |
| 1849 | void SetUIJoyUp(int joycodeIndex, int val) |
| 1850 | { |
| 1851 | SetUIJoy(M32OPTION_UI_JOY_UP, joycodeIndex, val); |
| 1852 | } |
| 1853 | |
| 1854 | int GetUIJoyDown(int joycodeIndex) |
| 1855 | { |
| 1856 | return GetUIJoy(M32OPTION_UI_JOY_DOWN, joycodeIndex); |
| 1857 | } |
| 1858 | |
| 1859 | void SetUIJoyDown(int joycodeIndex, int val) |
| 1860 | { |
| 1861 | SetUIJoy(M32OPTION_UI_JOY_DOWN, joycodeIndex, val); |
| 1862 | } |
| 1863 | |
| 1864 | int GetUIJoyLeft(int joycodeIndex) |
| 1865 | { |
| 1866 | return GetUIJoy(M32OPTION_UI_JOY_LEFT, joycodeIndex); |
| 1867 | } |
| 1868 | |
| 1869 | void SetUIJoyLeft(int joycodeIndex, int val) |
| 1870 | { |
| 1871 | SetUIJoy(M32OPTION_UI_JOY_LEFT, joycodeIndex, val); |
| 1872 | } |
| 1873 | |
| 1874 | int GetUIJoyRight(int joycodeIndex) |
| 1875 | { |
| 1876 | return GetUIJoy(M32OPTION_UI_JOY_RIGHT, joycodeIndex); |
| 1877 | } |
| 1878 | |
| 1879 | void SetUIJoyRight(int joycodeIndex, int val) |
| 1880 | { |
| 1881 | SetUIJoy(M32OPTION_UI_JOY_RIGHT, joycodeIndex, val); |
| 1882 | } |
| 1883 | |
| 1884 | int GetUIJoyStart(int joycodeIndex) |
| 1885 | { |
| 1886 | return GetUIJoy(M32OPTION_UI_JOY_START, joycodeIndex); |
| 1887 | } |
| 1888 | |
| 1889 | void SetUIJoyStart(int joycodeIndex, int val) |
| 1890 | { |
| 1891 | SetUIJoy(M32OPTION_UI_JOY_START, joycodeIndex, val); |
| 1892 | } |
| 1893 | |
| 1894 | int GetUIJoyPageUp(int joycodeIndex) |
| 1895 | { |
| 1896 | return GetUIJoy(M32OPTION_UI_JOY_PGUP, joycodeIndex); |
| 1897 | } |
| 1898 | |
| 1899 | void SetUIJoyPageUp(int joycodeIndex, int val) |
| 1900 | { |
| 1901 | SetUIJoy(M32OPTION_UI_JOY_PGUP, joycodeIndex, val); |
| 1902 | } |
| 1903 | |
| 1904 | int GetUIJoyPageDown(int joycodeIndex) |
| 1905 | { |
| 1906 | return GetUIJoy(M32OPTION_UI_JOY_PGDWN, joycodeIndex); |
| 1907 | } |
| 1908 | |
| 1909 | void SetUIJoyPageDown(int joycodeIndex, int val) |
| 1910 | { |
| 1911 | SetUIJoy(M32OPTION_UI_JOY_PGDWN, joycodeIndex, val); |
| 1912 | } |
| 1913 | |
| 1914 | int GetUIJoyHome(int joycodeIndex) |
| 1915 | { |
| 1916 | return GetUIJoy(M32OPTION_UI_JOY_HOME, joycodeIndex); |
| 1917 | } |
| 1918 | |
| 1919 | void SetUIJoyHome(int joycodeIndex, int val) |
| 1920 | { |
| 1921 | SetUIJoy(M32OPTION_UI_JOY_HOME, joycodeIndex, val); |
| 1922 | } |
| 1923 | |
| 1924 | int GetUIJoyEnd(int joycodeIndex) |
| 1925 | { |
| 1926 | return GetUIJoy(M32OPTION_UI_JOY_END, joycodeIndex); |
| 1927 | } |
| 1928 | |
| 1929 | void SetUIJoyEnd(int joycodeIndex, int val) |
| 1930 | { |
| 1931 | SetUIJoy(M32OPTION_UI_JOY_END, joycodeIndex, val); |
| 1932 | } |
| 1933 | |
| 1934 | int GetUIJoySSChange(int joycodeIndex) |
| 1935 | { |
| 1936 | return GetUIJoy(M32OPTION_UI_JOY_SS_CHANGE, joycodeIndex); |
| 1937 | } |
| 1938 | |
| 1939 | void SetUIJoySSChange(int joycodeIndex, int val) |
| 1940 | { |
| 1941 | SetUIJoy(M32OPTION_UI_JOY_SS_CHANGE, joycodeIndex, val); |
| 1942 | } |
| 1943 | |
| 1944 | int GetUIJoyHistoryUp(int joycodeIndex) |
| 1945 | { |
| 1946 | return GetUIJoy(M32OPTION_UI_JOY_HISTORY_UP, joycodeIndex); |
| 1947 | } |
| 1948 | |
| 1949 | void SetUIJoyHistoryUp(int joycodeIndex, int val) |
| 1950 | { |
| 1951 | SetUIJoy(M32OPTION_UI_JOY_HISTORY_UP, joycodeIndex, val); |
| 1952 | } |
| 1953 | |
| 1954 | int GetUIJoyHistoryDown(int joycodeIndex) |
| 1955 | { |
| 1956 | return GetUIJoy(M32OPTION_UI_JOY_HISTORY_DOWN, joycodeIndex); |
| 1957 | } |
| 1958 | |
| 1959 | void SetUIJoyHistoryDown(int joycodeIndex, int val) |
| 1960 | { |
| 1961 | SetUIJoy(M32OPTION_UI_JOY_HISTORY_DOWN, joycodeIndex, val); |
| 1962 | } |
| 1963 | |
| 1964 | void SetUIJoyExec(int joycodeIndex, int val) |
| 1965 | { |
| 1966 | SetUIJoy(M32OPTION_UI_JOY_EXEC, joycodeIndex, val); |
| 1967 | } |
| 1968 | |
| 1969 | int GetUIJoyExec(int joycodeIndex) |
| 1970 | { |
| 1971 | return GetUIJoy(M32OPTION_UI_JOY_EXEC, joycodeIndex); |
| 1972 | } |
| 1973 | |
| 1974 | const char * GetExecCommand(void) |
| 1975 | { |
| 1976 | return options_get_string(settings, M32OPTION_EXEC_COMMAND); |
| 1977 | } |
| 1978 | |
| 1979 | void SetExecCommand(char *cmd) |
| 1980 | { |
| 1981 | options_set_string(settings, M32OPTION_EXEC_COMMAND, cmd, OPTION_PRIORITY_CMDLINE); |
| 1982 | } |
| 1983 | |
| 1984 | int GetExecWait(void) |
| 1985 | { |
| 1986 | return options_get_int(settings, M32OPTION_EXEC_WAIT); |
| 1987 | } |
| 1988 | |
| 1989 | void SetExecWait(int wait) |
| 1990 | { |
| 1991 | options_set_int(settings, M32OPTION_EXEC_WAIT, wait, OPTION_PRIORITY_CMDLINE); |
| 1992 | } |
| 1993 | |
| 1994 | BOOL GetHideMouseOnStartup(void) |
| 1995 | { |
| 1996 | return options_get_bool(settings, M32OPTION_HIDE_MOUSE); |
| 1997 | } |
| 1998 | |
| 1999 | void SetHideMouseOnStartup(BOOL hide) |
| 2000 | { |
| 2001 | options_set_bool(settings, M32OPTION_HIDE_MOUSE, hide, OPTION_PRIORITY_CMDLINE); |
| 2002 | } |
| 2003 | |
| 2004 | BOOL GetRunFullScreen(void) |
| 2005 | { |
| 2006 | return options_get_bool(settings, M32OPTION_FULL_SCREEN); |
| 2007 | } |
| 2008 | |
| 2009 | void SetRunFullScreen(BOOL fullScreen) |
| 2010 | { |
| 2011 | options_set_bool(settings, M32OPTION_FULL_SCREEN, fullScreen, OPTION_PRIORITY_CMDLINE); |
| 2012 | } |
| 2013 | |
| 2014 | /*************************************************************************** |
| 2015 | Internal functions |
| 2016 | ***************************************************************************/ |
| 2017 | |
| 2018 | static void CusColorEncodeString(const COLORREF *value, char* str) |
| 2019 | { |
| 2020 | int i; |
| 2021 | char tmpStr[256]; |
| 2022 | |
| 2023 | sprintf(tmpStr, "%u", (int) value[0]); |
| 2024 | |
| 2025 | strcpy(str, tmpStr); |
| 2026 | |
| 2027 | for (i = 1; i < 16; i++) |
| 2028 | { |
| 2029 | sprintf(tmpStr, ",%u", (unsigned) value[i]); |
| 2030 | strcat(str, tmpStr); |
| 2031 | } |
| 2032 | } |
| 2033 | |
| 2034 | static void CusColorDecodeString(const char* str, COLORREF *value) |
| 2035 | { |
| 2036 | int i; |
| 2037 | char *s, *p; |
| 2038 | char tmpStr[256]; |
| 2039 | |
| 2040 | strcpy(tmpStr, str); |
| 2041 | p = tmpStr; |
| 2042 | |
| 2043 | for (i = 0; p && i < 16; i++) |
| 2044 | { |
| 2045 | s = p; |
| 2046 | |
| 2047 | if ((p = strchr(s,',')) != NULL && *p == ',') |
| 2048 | { |
| 2049 | *p = '\0'; |
| 2050 | p++; |
| 2051 | } |
| 2052 | value[i] = atoi(s); |
| 2053 | } |
| 2054 | } |
| 2055 | |
| 2056 | |
| 2057 | void ColumnEncodeStringWithCount(const int *value, char *str, int count) |
| 2058 | { |
| 2059 | int i; |
| 2060 | char buffer[100]; |
| 2061 | |
| 2062 | snprintf(buffer,sizeof(buffer),"%d",value[0]); |
| 2063 | |
| 2064 | strcpy(str,buffer); |
| 2065 | |
| 2066 | for (i = 1; i < count; i++) |
| 2067 | { |
| 2068 | snprintf(buffer,sizeof(buffer),",%d",value[i]); |
| 2069 | strcat(str,buffer); |
| 2070 | } |
| 2071 | } |
| 2072 | |
| 2073 | void ColumnDecodeStringWithCount(const char* str, int *value, int count) |
| 2074 | { |
| 2075 | int i; |
| 2076 | char *s, *p; |
| 2077 | char tmpStr[100]; |
| 2078 | |
| 2079 | if (str == NULL) |
| 2080 | return; |
| 2081 | |
| 2082 | strcpy(tmpStr, str); |
| 2083 | p = tmpStr; |
| 2084 | |
| 2085 | for (i = 0; p && i < count; i++) |
| 2086 | { |
| 2087 | s = p; |
| 2088 | |
| 2089 | if ((p = strchr(s,',')) != NULL && *p == ',') |
| 2090 | { |
| 2091 | *p = '\0'; |
| 2092 | p++; |
| 2093 | } |
| 2094 | value[i] = atoi(s); |
| 2095 | } |
| 2096 | } |
| 2097 | |
| 2098 | static void SplitterEncodeString(const int *value, char* str) |
| 2099 | { |
| 2100 | int i; |
| 2101 | char tmpStr[100]; |
| 2102 | |
| 2103 | sprintf(tmpStr, "%d", value[0]); |
| 2104 | |
| 2105 | strcpy(str, tmpStr); |
| 2106 | |
| 2107 | for (i = 1; i < GetSplitterCount(); i++) |
| 2108 | { |
| 2109 | sprintf(tmpStr, ",%d", value[i]); |
| 2110 | strcat(str, tmpStr); |
| 2111 | } |
| 2112 | } |
| 2113 | |
| 2114 | static void SplitterDecodeString(const char *str, int *value) |
| 2115 | { |
| 2116 | int i; |
| 2117 | char *s, *p; |
| 2118 | char tmpStr[100]; |
| 2119 | |
| 2120 | strcpy(tmpStr, str); |
| 2121 | p = tmpStr; |
| 2122 | |
| 2123 | for (i = 0; p && i < GetSplitterCount(); i++) |
| 2124 | { |
| 2125 | s = p; |
| 2126 | |
| 2127 | if ((p = strchr(s,',')) != NULL && *p == ',') |
| 2128 | { |
| 2129 | *p = '\0'; |
| 2130 | p++; |
| 2131 | } |
| 2132 | value[i] = atoi(s); |
| 2133 | } |
| 2134 | } |
| 2135 | |
| 2136 | /* Parse the given comma-delimited string into a LOGFONT structure */ |
| 2137 | static void FontDecodeString(const char* str, LOGFONT *f) |
| 2138 | { |
| 2139 | char* ptr; |
| 2140 | TCHAR* t_ptr; |
| 2141 | |
| 2142 | sscanf(str, "%li,%li,%li,%li,%li,%i,%i,%i,%i,%i,%i,%i,%i", |
| 2143 | &f->lfHeight, |
| 2144 | &f->lfWidth, |
| 2145 | &f->lfEscapement, |
| 2146 | &f->lfOrientation, |
| 2147 | &f->lfWeight, |
| 2148 | (int*)&f->lfItalic, |
| 2149 | (int*)&f->lfUnderline, |
| 2150 | (int*)&f->lfStrikeOut, |
| 2151 | (int*)&f->lfCharSet, |
| 2152 | (int*)&f->lfOutPrecision, |
| 2153 | (int*)&f->lfClipPrecision, |
| 2154 | (int*)&f->lfQuality, |
| 2155 | (int*)&f->lfPitchAndFamily); |
| 2156 | ptr = strrchr(str, ','); |
| 2157 | if (ptr != NULL) { |
| 2158 | t_ptr = tstring_from_utf8(ptr + 1); |
| 2159 | if( !t_ptr ) |
| 2160 | return; |
| 2161 | _tcscpy(f->lfFaceName, t_ptr); |
| 2162 | free(t_ptr); |
| 2163 | } |
| 2164 | } |
| 2165 | |
| 2166 | /* Encode the given LOGFONT structure into a comma-delimited string */ |
| 2167 | static void FontEncodeString(const LOGFONT *f, char *str) |
| 2168 | { |
| 2169 | char* utf8_FaceName = utf8_from_tstring(f->lfFaceName); |
| 2170 | if( !utf8_FaceName ) |
| 2171 | return; |
| 2172 | |
| 2173 | sprintf(str, "%li,%li,%li,%li,%li,%i,%i,%i,%i,%i,%i,%i,%i,%s", |
| 2174 | f->lfHeight, |
| 2175 | f->lfWidth, |
| 2176 | f->lfEscapement, |
| 2177 | f->lfOrientation, |
| 2178 | f->lfWeight, |
| 2179 | f->lfItalic, |
| 2180 | f->lfUnderline, |
| 2181 | f->lfStrikeOut, |
| 2182 | f->lfCharSet, |
| 2183 | f->lfOutPrecision, |
| 2184 | f->lfClipPrecision, |
| 2185 | f->lfQuality, |
| 2186 | f->lfPitchAndFamily, |
| 2187 | utf8_FaceName); |
| 2188 | |
| 2189 | free(utf8_FaceName); |
| 2190 | } |
| 2191 | |
| 2192 | static void TabFlagsEncodeString(int data, char *str) |
| 2193 | { |
| 2194 | int i; |
| 2195 | int num_saved = 0; |
| 2196 | |
| 2197 | strcpy(str,""); |
| 2198 | |
| 2199 | // we save the ones that are NOT displayed, so we can add new ones |
| 2200 | // and upgraders will see them |
| 2201 | for (i=0;i<MAX_TAB_TYPES;i++) |
| 2202 | { |
| 2203 | if (((data & (1 << i)) == 0) && GetImageTabShortName(i)) |
| 2204 | { |
| 2205 | if (num_saved != 0) |
| 2206 | strcat(str, ", "); |
| 2207 | |
| 2208 | strcat(str,GetImageTabShortName(i)); |
| 2209 | num_saved++; |
| 2210 | } |
| 2211 | } |
| 2212 | } |
| 2213 | |
| 2214 | static void TabFlagsDecodeString(const char *str, int *data) |
| 2215 | { |
| 2216 | char s[2000]; |
| 2217 | char *token; |
| 2218 | |
| 2219 | snprintf(s, ARRAY_LENGTH(s), "%s", str); |
| 2220 | |
| 2221 | // simple way to set all tab bits "on" |
| 2222 | *data = (1 << MAX_TAB_TYPES) - 1; |
| 2223 | |
| 2224 | token = strtok(s,", \t"); |
| 2225 | while (token != NULL) |
| 2226 | { |
| 2227 | int j; |
| 2228 | |
| 2229 | for (j=0;j<MAX_TAB_TYPES;j++) |
| 2230 | { |
| 2231 | if (!GetImageTabShortName(j) || (strcmp(GetImageTabShortName(j), token) == 0)) |
| 2232 | { |
| 2233 | // turn off this bit |
| 2234 | *data &= ~(1 << j); |
| 2235 | break; |
| 2236 | } |
| 2237 | } |
| 2238 | token = strtok(NULL,", \t"); |
| 2239 | } |
| 2240 | |
| 2241 | if (*data == 0) |
| 2242 | { |
| 2243 | // not allowed to hide all tabs, because then why even show the area? |
| 2244 | *data = (1 << TAB_SCREENSHOT); |
| 2245 | } |
| 2246 | } |
| 2247 | |
| 2248 | static file_error LoadSettingsFile(core_options *opts, const char *filename) |
| 2249 | { |
| 2250 | core_file *file; |
| 2251 | file_error filerr; |
| 2252 | |
| 2253 | filerr = core_fopen(filename, OPEN_FLAG_READ, &file); |
| 2254 | if (filerr == FILERR_NONE) |
| 2255 | { |
| 2256 | options_parse_ini_file(opts, file, OPTION_PRIORITY_CMDLINE); |
| 2257 | core_fclose(file); |
| 2258 | } |
| 2259 | return filerr; |
| 2260 | } |
| 2261 | |
| 2262 | |
| 2263 | static file_error SaveSettingsFile(core_options *opts, const char *filename) |
| 2264 | { |
| 2265 | core_file *file; |
| 2266 | file_error filerr; |
| 2267 | |
| 2268 | if (opts != NULL) |
| 2269 | { |
| 2270 | filerr = core_fopen(filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file); |
| 2271 | if (filerr == FILERR_NONE) |
| 2272 | { |
| 2273 | options_output_ini_file(opts, file); |
| 2274 | core_fclose(file); |
| 2275 | } |
| 2276 | } |
| 2277 | else |
| 2278 | { |
| 2279 | filerr = osd_rmfile(filename); |
| 2280 | } |
| 2281 | |
| 2282 | return filerr; |
| 2283 | } |
| 2284 | |
| 2285 | |
| 2286 | |
| 2287 | static void GetGlobalOptionsFileName(char *filename, size_t filename_size) |
| 2288 | { |
| 2289 | // copy INI directory |
| 2290 | snprintf(filename, filename_size, "%s\\%s.ini", GetIniDir(), CONFIGNAME); |
| 2291 | } |
| 2292 | |
| 2293 | /* Register access functions below */ |
| 2294 | static void LoadOptionsAndSettings(void) |
| 2295 | { |
| 2296 | char buffer[MAX_PATH]; |
| 2297 | |
| 2298 | // parse MAME32ui.ini - always in the current directory. |
| 2299 | LoadSettingsFile(settings, UI_INI_FILENAME); |
| 2300 | |
| 2301 | // parse global options ini/mame32.ini |
| 2302 | GetGlobalOptionsFileName(buffer, ARRAY_LENGTH(buffer)); |
| 2303 | LoadSettingsFile(global, buffer); |
| 2304 | } |
| 2305 | |
| 2306 | const char * GetFolderNameByID(UINT nID) |
| 2307 | { |
| 2308 | UINT i; |
| 2309 | extern FOLDERDATA g_folderData[]; |
| 2310 | extern LPEXFOLDERDATA ExtraFolderData[]; |
| 2311 | |
| 2312 | for (i = 0; i < MAX_EXTRA_FOLDERS * MAX_EXTRA_SUBFOLDERS; i++) |
| 2313 | { |
| 2314 | if( ExtraFolderData[i] ) |
| 2315 | { |
| 2316 | if (ExtraFolderData[i]->m_nFolderId == nID) |
| 2317 | { |
| 2318 | return ExtraFolderData[i]->m_szTitle; |
| 2319 | } |
| 2320 | } |
| 2321 | } |
| 2322 | for( i = 0; i < MAX_FOLDERS; i++) |
| 2323 | { |
| 2324 | if (g_folderData[i].m_nFolderId == nID) |
| 2325 | { |
| 2326 | |
| 2327 | return g_folderData[i].m_lpTitle; |
| 2328 | } |
| 2329 | } |
| 2330 | return NULL; |
| 2331 | } |
| 2332 | |
| 2333 | |
| 2334 | DWORD GetFolderFlags(int folder_index) |
| 2335 | { |
| 2336 | LPTREEFOLDER lpFolder = GetFolder(folder_index); |
| 2337 | |
| 2338 | if (lpFolder) |
| 2339 | return lpFolder->m_dwFlags & F_MASK; |
| 2340 | |
| 2341 | return 0; |
| 2342 | #if 0 |
| 2343 | int i; |
| 2344 | |
| 2345 | for (i=0;i<num_folder_filters;i++) |
| 2346 | { |
| 2347 | if (folder_filters[i].folder_index == folder_index) |
| 2348 | { |
| 2349 | //dprintf("found folder filter %i %i",folder_index,folder_filters[i].filters); |
| 2350 | return folder_filters[i].filters; |
| 2351 | } |
| 2352 | } |
| 2353 | return 0; |
| 2354 | #endif |
| 2355 | } |
| 2356 | |
| 2357 | |
| 2358 | /* Decode the flags into a DWORD */ |
| 2359 | static DWORD DecodeFolderFlags(const char *buf) |
| 2360 | { |
| 2361 | DWORD flags = 0; |
| 2362 | int shift = 0; |
| 2363 | const char *ptr = buf; |
| 2364 | |
| 2365 | while (*ptr && (1 << shift) & F_MASK) |
| 2366 | { |
| 2367 | if (*ptr++ == '1') |
| 2368 | { |
| 2369 | flags |= (1 << shift); |
| 2370 | } |
| 2371 | shift++; |
| 2372 | } |
| 2373 | return flags; |
| 2374 | } |
| 2375 | |
| 2376 | /* Encode the flags into a string */ |
| 2377 | static const char * EncodeFolderFlags(DWORD value) |
| 2378 | { |
| 2379 | static char buf[40]; |
| 2380 | int shift = 0; |
| 2381 | |
| 2382 | memset(buf,'\0', sizeof(buf)); |
| 2383 | |
| 2384 | while ((1 << shift) & F_MASK) { |
| 2385 | buf[shift] = (value & (1 << shift)) ? '1' : '0'; |
| 2386 | shift++; |
| 2387 | } |
| 2388 | |
| 2389 | return buf; |
| 2390 | } |
| 2391 | |
| 2392 | /* MSH 20080813 |
| 2393 | * Read the folder filters from MAME32ui.ini. This must only |
| 2394 | * be called AFTER the folders have all been created. |
| 2395 | */ |
| 2396 | void LoadFolderFlags(void) |
| 2397 | { |
| 2398 | core_options *opts; |
| 2399 | int numFolders; |
| 2400 | LPTREEFOLDER lpFolder; |
| 2401 | int i; |
| 2402 | options_entry entries[2]; |
| 2403 | |
| 2404 | memcpy(entries, filterOptions, sizeof(filterOptions)); |
| 2405 | |
| 2406 | opts = options_create(memory_error); |
| 2407 | |
| 2408 | if (NULL == opts) |
| 2409 | { |
| 2410 | return; |
| 2411 | } |
| 2412 | |
| 2413 | numFolders = GetNumFolders(); |
| 2414 | |
| 2415 | for (i = 0; i < numFolders; i++) |
| 2416 | { |
| 2417 | lpFolder = GetFolder(i); |
| 2418 | |
| 2419 | if (lpFolder) |
| 2420 | { |
| 2421 | char folder_name[80]; |
| 2422 | char *ptr; |
| 2423 | astring *option_name; |
| 2424 | |
| 2425 | // Convert spaces to underscores |
| 2426 | strcpy(folder_name, lpFolder->m_lpTitle); |
| 2427 | ptr = folder_name; |
| 2428 | while (*ptr && *ptr != '\0') |
| 2429 | { |
| 2430 | if (*ptr == ' ') |
| 2431 | { |
| 2432 | *ptr = '_'; |
| 2433 | } |
| 2434 | ptr++; |
| 2435 | } |
| 2436 | |
| 2437 | option_name = astring_assemble_2(astring_alloc(), folder_name, "_filters"); |
| 2438 | // create entry |
| 2439 | entries[0].name = astring_c(option_name); |
| 2440 | options_add_entries(opts, entries); |
| 2441 | astring_free(option_name); |
| 2442 | } |
| 2443 | } |
| 2444 | |
| 2445 | // These are overlayed at the end of our UI ini |
| 2446 | // The normal read will skip them. |
| 2447 | LoadSettingsFile(opts, UI_INI_FILENAME); |
| 2448 | |
| 2449 | // retrive the stored values |
| 2450 | for (i = 0; i < numFolders; i++) |
| 2451 | { |
| 2452 | lpFolder = GetFolder(i); |
| 2453 | |
| 2454 | if (lpFolder) |
| 2455 | { |
| 2456 | char folder_name[80]; |
| 2457 | char *ptr; |
| 2458 | astring *option_name; |
| 2459 | const char *value; |
| 2460 | |
| 2461 | // Convert spaces to underscores |
| 2462 | strcpy(folder_name, lpFolder->m_lpTitle); |
| 2463 | ptr = folder_name; |
| 2464 | while (*ptr && *ptr != '\0') |
| 2465 | { |
| 2466 | if (*ptr == ' ') |
| 2467 | { |
| 2468 | *ptr = '_'; |
| 2469 | } |
| 2470 | ptr++; |
| 2471 | } |
| 2472 | option_name = astring_assemble_2(astring_alloc(), folder_name, "_filters" ); |
| 2473 | // get entry and decode it |
| 2474 | value = options_get_string(opts, astring_c(option_name)); |
| 2475 | astring_free(option_name); |
| 2476 | |
| 2477 | if (value) |
| 2478 | { |
| 2479 | lpFolder->m_dwFlags |= DecodeFolderFlags(value) & F_MASK; |
| 2480 | } |
| 2481 | } |
| 2482 | } |
| 2483 | // fee the options |
| 2484 | options_free(opts); |
| 2485 | } |
| 2486 | |
| 2487 | |
| 2488 | |
| 2489 | // Copy options, if entry doesn't exist in the dest, create it. |
| 2490 | static void copy_options_ex(core_options *pDestOpts, core_options *pSourceOpts) |
| 2491 | { |
| 2492 | options_enumerator *enumerator; |
| 2493 | const char *option_name; |
| 2494 | const char *option_value; |
| 2495 | options_entry entries[2]; |
| 2496 | |
| 2497 | memcpy(entries, filterOptions, sizeof(filterOptions)); |
| 2498 | |
| 2499 | enumerator = options_enumerator_begin(pSourceOpts); |
| 2500 | |
| 2501 | if (enumerator != NULL) |
| 2502 | { |
| 2503 | while((option_name = options_enumerator_next(enumerator)) != NULL) |
| 2504 | { |
| 2505 | option_value = options_get_string(pSourceOpts, option_name); |
| 2506 | { |
| 2507 | const char *existing = options_get_string(pDestOpts, option_name); |
| 2508 | if (NULL == existing || *existing == '\0') |
| 2509 | { |
| 2510 | entries[0].name = option_name; |
| 2511 | // create entry |
| 2512 | options_add_entries(pDestOpts, entries); |
| 2513 | } |
| 2514 | if (strcmp(option_value, existing) != 0) |
| 2515 | options_set_string(pDestOpts, option_name, option_value, OPTION_PRIORITY_CMDLINE); |
| 2516 | } |
| 2517 | } |
| 2518 | options_enumerator_free(enumerator); |
| 2519 | } |
| 2520 | } |
| 2521 | |
| 2522 | // Adds our folder flags to a temporarty core_options, for saving. |
| 2523 | static core_options * AddFolderFlags(core_options *settings) |
| 2524 | { |
| 2525 | core_options *opts; |
| 2526 | int numFolders; |
| 2527 | int i; |
| 2528 | LPTREEFOLDER lpFolder; |
| 2529 | int num_entries = 0; |
| 2530 | options_entry entries[2]; |
| 2531 | |
| 2532 | opts = options_create(memory_error); |
| 2533 | |
| 2534 | if (NULL == opts) |
| 2535 | { |
| 2536 | return NULL; |
| 2537 | } |
| 2538 | |
| 2539 | options_add_entries(opts, regSettings); |
| 2540 | copy_options_ex(opts, settings); |
| 2541 | |
| 2542 | memcpy(entries, filterOptions, sizeof(filterOptions)); |
| 2543 | entries[0].name = NULL; |
| 2544 | entries[0].defvalue = NULL; |
| 2545 | entries[0].flags = OPTION_HEADER; |
| 2546 | entries[0].description = "FOLDER FILTERS"; |
| 2547 | options_add_entries(opts, entries); |
| 2548 | |
| 2549 | memcpy(entries, filterOptions, sizeof(filterOptions)); |
| 2550 | |
| 2551 | numFolders = GetNumFolders(); |
| 2552 | |
| 2553 | for (i = 0; i < numFolders; i++) |
| 2554 | { |
| 2555 | lpFolder = GetFolder(i); |
| 2556 | if (lpFolder && (lpFolder->m_dwFlags & F_MASK) != 0) |
| 2557 | { |
| 2558 | char folder_name[80]; |
| 2559 | char *ptr; |
| 2560 | astring *option_name; |
| 2561 | |
| 2562 | // Convert spaces to underscores |
| 2563 | strcpy(folder_name, lpFolder->m_lpTitle); |
| 2564 | ptr = folder_name; |
| 2565 | while (*ptr && *ptr != '\0') |
| 2566 | { |
| 2567 | if (*ptr == ' ') |
| 2568 | { |
| 2569 | *ptr = '_'; |
| 2570 | } |
| 2571 | ptr++; |
| 2572 | } |
| 2573 | |
| 2574 | option_name = astring_assemble_2(astring_alloc(), folder_name, "_filters" ); |
| 2575 | |
| 2576 | // create entry |
| 2577 | entries[0].name = astring_c(option_name); |
| 2578 | options_add_entries(opts, entries); |
| 2579 | |
| 2580 | // store entry |
| 2581 | options_set_string(opts, astring_c(option_name), EncodeFolderFlags(lpFolder->m_dwFlags), OPTION_PRIORITY_CMDLINE); |
| 2582 | astring_free(option_name); |
| 2583 | |
| 2584 | // increment counter |
| 2585 | num_entries++; |
| 2586 | } |
| 2587 | } |
| 2588 | if (num_entries == 0) { |
| 2589 | options_free(opts); |
| 2590 | opts = NULL; |
| 2591 | } |
| 2592 | return opts; |
| 2593 | } |
| 2594 | |
| 2595 | // Save the UI ini |
| 2596 | void SaveOptions(void) |
| 2597 | { |
| 2598 | if (save_gui_settings) |
| 2599 | { |
| 2600 | // Add the folder flag to settings. |
| 2601 | core_options *opts = AddFolderFlags(settings); |
| 2602 | // Save opts if it is non-null, else save settings. |
| 2603 | // It will be null if there are no filters set. |
| 2604 | SaveSettingsFile((opts == NULL) ? settings : opts, UI_INI_FILENAME); |
| 2605 | // Free up the opts allocated by AddFolderFlags. |
| 2606 | if (opts) |
| 2607 | { |
| 2608 | options_free(opts); |
| 2609 | } |
| 2610 | } |
| 2611 | } |
| 2612 | |
| 2613 | |
| 2614 | void SaveDefaultOptions(void) |
| 2615 | { |
| 2616 | char buffer[MAX_PATH]; |
| 2617 | GetGlobalOptionsFileName(buffer, ARRAY_LENGTH(buffer)); |
| 2618 | SaveSettingsFile(global, buffer); |
| 2619 | } |
| 2620 | |
| 2621 | char * GetVersionString(void) |
| 2622 | { |
| 2623 | return build_version; |
| 2624 | } |
| 2625 | |
| 2626 | |
| 2627 | BOOL IsGlobalOption(const char *option_name) |
| 2628 | { |
| 2629 | static const char *global_options[] = |
| 2630 | { |
| 2631 | OPTION_ROMPATH, |
| 2632 | #ifdef MESS |
| 2633 | OPTION_HASHPATH, |
| 2634 | #endif // MESS |
| 2635 | OPTION_SAMPLEPATH, |
| 2636 | OPTION_ARTPATH, |
| 2637 | OPTION_CTRLRPATH, |
| 2638 | OPTION_INIPATH, |
| 2639 | OPTION_FONTPATH, |
| 2640 | OPTION_CFG_DIRECTORY, |
| 2641 | OPTION_NVRAM_DIRECTORY, |
| 2642 | OPTION_MEMCARD_DIRECTORY, |
| 2643 | OPTION_INPUT_DIRECTORY, |
| 2644 | OPTION_STATE_DIRECTORY, |
| 2645 | OPTION_SNAPSHOT_DIRECTORY, |
| 2646 | OPTION_DIFF_DIRECTORY, |
| 2647 | OPTION_COMMENT_DIRECTORY |
| 2648 | }; |
| 2649 | int i; |
| 2650 | char command_name[128]; |
| 2651 | char *s; |
| 2652 | |
| 2653 | // determine command name |
| 2654 | snprintf(command_name, ARRAY_LENGTH(command_name), "%s", option_name); |
| 2655 | s = strchr(command_name, ';'); |
| 2656 | if (s) |
| 2657 | *s = '\0'; |
| 2658 | |
| 2659 | for (i = 0; i < ARRAY_LENGTH(global_options); i++) |
| 2660 | { |
| 2661 | if (!strcmp(command_name, global_options[i])) |
| 2662 | return TRUE; |
| 2663 | } |
| 2664 | return FALSE; |
| 2665 | } |
| 2666 | |
| 2667 | |
| 2668 | /* ui_parse_ini_file - parse a single INI file */ |
| 2669 | static void ui_parse_ini_file(core_options *opts, const char *name) |
| 2670 | { |
| 2671 | astring *fname; |
| 2672 | |
| 2673 | /* open the file; if we fail, that's ok */ |
| 2674 | fname = astring_assemble_4(astring_alloc(), GetIniDir(), PATH_SEPARATOR, name, ".ini"); |
| 2675 | LoadSettingsFile(opts, astring_c(fname)); |
| 2676 | astring_free(fname); |
| 2677 | } |
| 2678 | |
| 2679 | |
| 2680 | /* get options, based on passed in option level. */ |
| 2681 | core_options * load_options(OPTIONS_TYPE opt_type, int game_num) |
| 2682 | { |
| 2683 | core_options *opts; |
| 2684 | const game_driver *driver = NULL; |
| 2685 | |
| 2686 | |
| 2687 | opts = options_create(memory_error); |
| 2688 | |
| 2689 | if (opts == NULL) |
| 2690 | { |
| 2691 | return NULL; |
| 2692 | } |
| 2693 | |
| 2694 | /* add the options */ |
| 2695 | AddOptions(opts, mame_core_options, (GLOBAL_OPTIONS == game_num)); |
| 2696 | AddOptions(opts, mame_win_options, (GLOBAL_OPTIONS == game_num)); |
| 2697 | |
| 2698 | /* Copy over the defaults */ |
| 2699 | options_copy(opts, global); |
| 2700 | |
| 2701 | if (opt_type == OPTIONS_GLOBAL) |
| 2702 | { |
| 2703 | return opts; |
| 2704 | } |
| 2705 | |
| 2706 | /* debug builds: parse "debug.ini" as well */ |
| 2707 | #ifdef MAME_DEBUG |
| 2708 | ui_parse_ini_file(opts, "debug"); |
| 2709 | #endif |
| 2710 | if (game_num >= 0) |
| 2711 | { |
| 2712 | driver = drivers[game_num]; |
| 2713 | } |
| 2714 | |
| 2715 | /* if we have a valid game driver, parse game-specific INI files */ |
| 2716 | if (driver != NULL) |
| 2717 | { |
| 2718 | const game_driver *parent = driver_get_clone(driver); |
| 2719 | const game_driver *gparent = (parent != NULL) ? driver_get_clone(parent) : NULL; |
| 2720 | astring *basename; |
| 2721 | astring *srcname; |
| 2722 | machine_config drv; |
| 2723 | |
| 2724 | /* expand the machine driver to look at the info */ |
| 2725 | expand_machine_driver(driver->drv, &drv); |
| 2726 | |
| 2727 | /* parse "vector.ini" for vector games */ |
| 2728 | if (drv.video_attributes & VIDEO_TYPE_VECTOR) |
| 2729 | ui_parse_ini_file(opts, "vector"); |
| 2730 | |
| 2731 | if (opt_type == OPTIONS_VECTOR) |
| 2732 | { |
| 2733 | return opts; |
| 2734 | } |
| 2735 | |
| 2736 | /* then parse "<sourcefile>.ini" */ |
| 2737 | basename = core_filename_extract_base(astring_alloc(), driver->source_file, TRUE); |
| 2738 | srcname = astring_assemble_3(astring_alloc(), "source", PATH_SEPARATOR, astring_c(basename)); |
| 2739 | ui_parse_ini_file(opts, astring_c(srcname)); |
| 2740 | astring_free(srcname); |
| 2741 | astring_free(basename); |
| 2742 | |
| 2743 | if (opt_type == OPTIONS_SOURCE) |
| 2744 | { |
| 2745 | return opts; |
| 2746 | } |
| 2747 | |
| 2748 | /* then parent the grandparent, parent, and game-specific INIs */ |
| 2749 | if (gparent != NULL) |
| 2750 | ui_parse_ini_file(opts, gparent->name); |
| 2751 | if (parent != NULL) |
| 2752 | ui_parse_ini_file(opts, parent->name); |
| 2753 | |
| 2754 | if (opt_type == OPTIONS_PARENT) |
| 2755 | { |
| 2756 | return opts; |
| 2757 | } |
| 2758 | |
| 2759 | ui_parse_ini_file(opts, driver->name); |
| 2760 | |
| 2761 | if (opt_type == OPTIONS_GAME) |
| 2762 | { |
| 2763 | return opts; |
| 2764 | } |
| 2765 | } |
| 2766 | options_free(opts); |
| 2767 | return NULL; |
| 2768 | } |
| 2769 | |
| 2770 | |
| 2771 | |
| 2772 | /* Add an entry to a core_options */ |
| 2773 | static BOOL add_options_entry(core_options *opts, const options_entry *entry) |
| 2774 | { |
| 2775 | options_entry entries[2]; |
| 2776 | |
| 2777 | if (NULL != entry) |
| 2778 | { |
| 2779 | // Add the entry to our opts |
| 2780 | memcpy(entries, entry, sizeof(options_entry)); |
| 2781 | memset(&entries[1], 0, sizeof(options_entry)); |
| 2782 | options_add_entries(opts, entries); |
| 2783 | return TRUE; |
| 2784 | } |
| 2785 | return FALSE; |
| 2786 | } |
| 2787 | |
| 2788 | /* |
| 2789 | * return new core_options with only the differences contained in opts |
| 2790 | * different from the values in defaults. |
| 2791 | */ |
| 2792 | static core_options * options_prune(core_options *opts1, core_options *opts2) |
| 2793 | { |
| 2794 | const options_entry *entry; |
| 2795 | core_options *pruned_options = options_create(memory_error); |
| 2796 | int changes = 0; |
| 2797 | char name[40]; |
| 2798 | |
| 2799 | // walk the core options |
| 2800 | entry = mame_core_options; |
| 2801 | while (entry->name != NULL || (entry->flags & OPTION_HEADER)) |
| 2802 | { |
| 2803 | if (entry->name != NULL) |
| 2804 | { |
| 2805 | char *ptr; |
| 2806 | const char *value1, *value2; |
| 2807 | |
| 2808 | strcpy(name, entry->name); |
| 2809 | // Trim off from ;altname |
| 2810 | if ((ptr = strchr(name, ';')) != NULL) |
| 2811 | *ptr = '\0'; |
| 2812 | // Trim off from (min-max) |
| 2813 | if ((ptr = strchr(name, '(')) != NULL) |
| 2814 | *ptr = '\0'; |
| 2815 | |
| 2816 | value1 = options_get_string(opts1, name); |
| 2817 | value2 = options_get_string(opts2, name); |
| 2818 | |
| 2819 | if (value1 != NULL && value2 != NULL) |
| 2820 | { |
| 2821 | if (strcmp(value1, value2) != 0) |
| 2822 | { |
| 2823 | if (add_options_entry(pruned_options, entry)) |
| 2824 | { |
| 2825 | options_set_string(pruned_options, name, value1, OPTION_PRIORITY_CMDLINE); |
| 2826 | changes++; |
| 2827 | } |
| 2828 | } |
| 2829 | } |
| 2830 | } |
| 2831 | entry++; |
| 2832 | } |
| 2833 | |
| 2834 | // walk the win options |
| 2835 | entry = mame_win_options; |
| 2836 | while (entry->name != NULL || (entry->flags & OPTION_HEADER)) |
| 2837 | { |
| 2838 | if (entry->name != NULL) |
| 2839 | { |
| 2840 | char *ptr; |
| 2841 | const char *value1, *value2; |
| 2842 | |
| 2843 | strcpy(name, entry->name); |
| 2844 | // Trim off from ;altname |
| 2845 | if ((ptr = strchr(name, ';')) != NULL) |
| 2846 | *ptr = '\0'; |
| 2847 | // Trim off from (min-max) |
| 2848 | if ((ptr = strchr(name, '(')) != NULL) |
| 2849 | *ptr = '\0'; |
| 2850 | |
| 2851 | value1 = options_get_string(opts1, name); |
| 2852 | value2 = options_get_string(opts2, name); |
| 2853 | |
| 2854 | if (value1 != NULL && value2 != NULL) |
| 2855 | { |
| 2856 | if (strcmp(value1, value2) != 0) |
| 2857 | { |
| 2858 | if (add_options_entry(pruned_options, entry)) |
| 2859 | { |
| 2860 | options_set_string(pruned_options, name, value1, OPTION_PRIORITY_CMDLINE); |
| 2861 | changes++; |
| 2862 | } |
| 2863 | } |
| 2864 | } |
| 2865 | } |
| 2866 | entry++; |
| 2867 | } |
| 2868 | |
| 2869 | // no changes made |
| 2870 | if (0 == changes) |
| 2871 | { |
| 2872 | options_free(pruned_options); |
| 2873 | pruned_options = NULL; |
| 2874 | } |
| 2875 | return pruned_options; |
| 2876 | } |
| 2877 | |
| 2878 | /* |
| 2879 | * Save ini file based on game_num and passed in opt_type. If opts are |
| 2880 | * NULL, the ini wiil be removed. |
| 2881 | * |
| 2882 | * game_num must be valid or the driver cannot be expanded and anything |
| 2883 | * with a higher priority than OPTIONS_VECTOR will not be saved. |
| 2884 | */ |
| 2885 | void save_options(OPTIONS_TYPE opt_type, core_options *opts, int game_num) |
| 2886 | { |
| 2887 | |
| 2888 | const game_driver *driver = NULL; |
| 2889 | astring *filename = NULL; |
| 2890 | core_options *save_options = NULL; |
| 2891 | BOOL use_opts = TRUE; |
| 2892 | |
| 2893 | if (OPTIONS_GLOBAL != opt_type && NULL != opts && !options_equal(opts, global)) |
| 2894 | { |
| 2895 | core_options *default_options = load_options(opt_type - 1, game_num); |
| 2896 | save_options = options_prune(opts, default_options); |
| 2897 | options_free(default_options); |
| 2898 | use_opts = FALSE; |
| 2899 | } |
| 2900 | |
| 2901 | if (game_num >= 0) |
| 2902 | { |
| 2903 | driver = drivers[game_num]; |
| 2904 | } |
| 2905 | |
| 2906 | if (opt_type == OPTIONS_GLOBAL) |
| 2907 | { |
| 2908 | /* Don't try to save a null global options file, or it will be erased. */ |
| 2909 | if (NULL == opts) |
| 2910 | return; |
| 2911 | options_copy(global, opts); |
| 2912 | filename = astring_cpyc(astring_alloc(), CONFIGNAME); |
| 2913 | } else if (opt_type == OPTIONS_VECTOR) |
| 2914 | { |
| 2915 | filename = astring_cpyc(astring_alloc(), "vector"); |
| 2916 | } else if (driver != NULL) |
| 2917 | { |
| 2918 | astring *basename, *srcname; |
| 2919 | machine_config drv; |
| 2920 | |
| 2921 | /* expand the machine driver to look at the info */ |
| 2922 | expand_machine_driver(driver->drv, &drv); |
| 2923 | |
| 2924 | switch (opt_type) |
| 2925 | { |
| 2926 | case OPTIONS_SOURCE: |
| 2927 | /* determine the <sourcefile> */ |
| 2928 | basename = core_filename_extract_base(astring_alloc(), driver->source_file, TRUE); |
| 2929 | srcname = astring_assemble_3(astring_alloc(), "source", PATH_SEPARATOR, astring_c(basename)); |
| 2930 | filename = astring_cpyc(astring_alloc(),astring_c(srcname)); |
| 2931 | astring_free(srcname); |
| 2932 | astring_free(basename); |
| 2933 | break; |
| 2934 | case OPTIONS_GAME: |
| 2935 | filename = astring_cpyc(astring_alloc(), driver->name); |
| 2936 | break; |
| 2937 | default: |
| 2938 | break; |
| 2939 | } |
| 2940 | } |
| 2941 | if (filename != NULL) |
| 2942 | { |
| 2943 | astring *filepath = NULL; |
| 2944 | filepath = astring_assemble_4(astring_alloc(), GetIniDir(), PATH_SEPARATOR, astring_c(filename), ".ini"); |
| 2945 | astring_free(filename); |
| 2946 | |
| 2947 | SaveSettingsFile((use_opts) ? opts : save_options, astring_c(filepath)); |
| 2948 | astring_free(filepath); |
| 2949 | } |
| 2950 | if (NULL != save_options) |
| 2951 | { |
| 2952 | options_free(save_options); |
| 2953 | } |
| 2954 | } |
| 2955 | |
| 2956 | /* Remove all the srcname.ini files from inipath/source directory. */ |
| 2957 | static void remove_all_source_options(void) { |
| 2958 | WIN32_FIND_DATA findFileData; |
| 2959 | HANDLE hFindFile; |
| 2960 | astring *pathname, *match; |
| 2961 | |
| 2962 | /* |
| 2963 | * Easiest to just open the ini/source folder if it exists, |
| 2964 | * then remove all the files in it that end in ini. |
| 2965 | */ |
| 2966 | pathname = astring_assemble_3(astring_alloc(), GetIniDir(), PATH_SEPARATOR, "source"); |
| 2967 | match = astring_assemble_3(astring_alloc(), astring_c(pathname), PATH_SEPARATOR, "*.ini"); |
| 2968 | if ((hFindFile = FindFirstFile(astring_c(match), &findFileData)) != INVALID_HANDLE_VALUE) |
| 2969 | { |
| 2970 | astring_free(match); |
| 2971 | match = astring_assemble_3(astring_alloc(), astring_c(pathname), PATH_SEPARATOR, findFileData.cFileName ); |
| 2972 | osd_rmfile(astring_c(match)); |
| 2973 | astring_free(match); |
| 2974 | |
| 2975 | while (0 != FindNextFile(hFindFile, &findFileData)) |
| 2976 | { |
| 2977 | match = astring_assemble_3(astring_alloc(), astring_c(pathname), PATH_SEPARATOR, findFileData.cFileName ); |
| 2978 | osd_rmfile(astring_c(match)); |
| 2979 | astring_free(match); |
| 2980 | } |
| 2981 | |
| 2982 | FindClose(hFindFile); |
| 2983 | |
| 2984 | } |
| 2985 | else |
| 2986 | { |
| 2987 | astring_free(match); |
| 2988 | } |
| 2989 | astring_free(pathname); |
| 2990 | |
| 2991 | } |
| 2992 | |
| 2993 | // Reset the given core_options to their default settings. |
| 2994 | static void ResetToDefaults(core_options *opts, int priority) |
| 2995 | { |
| 2996 | // iterate through the options setting each one back to the default value. |
| 2997 | options_revert(opts, priority); |
| 2998 | } |
| 2999 | |
| 3000 | |
| 3001 | |
src/osd/winui/treeview.c
| r0 | r996 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | M.A.M.E.32 - Multiple Arcade Machine Emulator for Win32 |
| 4 | Win32 Portions Copyright (C) 1997-2003 Michael Soderstrom and Chris Kirmse |
| 5 | |
| 6 | This file is part of MAME32, and may only be used, modified and |
| 7 | distributed under the terms of the MAME license, in "readme.txt". |
| 8 | By continuing to use, modify or distribute this file you indicate |
| 9 | that you have read the license and understand and accept it fully. |
| 10 | |
| 11 | ***************************************************************************/ |
| 12 | |
| 13 | /*************************************************************************** |
| 14 | |
| 15 | TreeView.c |
| 16 | |
| 17 | TreeView support routines - MSH 11/19/1998 |
| 18 | |
| 19 | ***************************************************************************/ |
| 20 | |
| 21 | #define WIN32_LEAN_AND_MEAN |
| 22 | #include <windows.h> |
| 23 | #include <windowsx.h> |
| 24 | #include <shellapi.h> |
| 25 | #include <commctrl.h> |
| 26 | #include <stdio.h> /* for sprintf */ |
| 27 | #include <stdlib.h> /* For malloc and free */ |
| 28 | #include <ctype.h> /* For tolower */ |
| 29 | #include <string.h> |
| 30 | #include <sys/stat.h> |
| 31 | #include <sys/types.h> |
| 32 | #ifdef _MSC_VER |
| 33 | #include <direct.h> |
| 34 | #endif |
| 35 | #include <tchar.h> |
| 36 | |
| 37 | #include <io.h> |
| 38 | #include <driver.h> |
| 39 | #include "hash.h" |
| 40 | #include "m32util.h" |
| 41 | #include "bitmask.h" |
| 42 | #include "screenshot.h" |
| 43 | #include "mame32.h" |
| 44 | #include "treeview.h" |
| 45 | #include "resource.h" |
| 46 | #include "m32opts.h" |
| 47 | #include "properties.h" |
| 48 | #include "help.h" |
| 49 | #include "dialogs.h" |
| 50 | #include "winutf8.h" |
| 51 | #include "strconv.h" |
| 52 | |
| 53 | #ifdef _MSC_VER |
| 54 | #define snprintf _snprintf |
| 55 | #endif |
| 56 | |
| 57 | #define MAX_EXTRA_FOLDERS 256 |
| 58 | |
| 59 | /*************************************************************************** |
| 60 | public structures |
| 61 | ***************************************************************************/ |
| 62 | |
| 63 | #define ICON_MAX (sizeof(treeIconNames) / sizeof(treeIconNames[0])) |
| 64 | |
| 65 | /* Name used for user-defined custom icons */ |
| 66 | /* external *.ico file to look for. */ |
| 67 | |
| 68 | typedef struct |
| 69 | { |
| 70 | int nResourceID; |
| 71 | LPCSTR lpName; |
| 72 | } TREEICON; |
| 73 | |
| 74 | static TREEICON treeIconNames[] = |
| 75 | { |
| 76 | { IDI_FOLDER_OPEN, "foldopen" }, |
| 77 | { IDI_FOLDER, "folder" }, |
| 78 | { IDI_FOLDER_AVAILABLE, "foldavail" }, |
| 79 | { IDI_FOLDER_MANUFACTURER, "foldmanu" }, |
| 80 | { IDI_FOLDER_UNAVAILABLE, "foldunav" }, |
| 81 | { IDI_FOLDER_YEAR, "foldyear" }, |
| 82 | { IDI_FOLDER_SOURCE, "foldsrc" }, |
| 83 | { IDI_FOLDER_HORIZONTAL, "horz" }, |
| 84 | { IDI_FOLDER_VERTICAL, "vert" }, |
| 85 | { IDI_MANUFACTURER, "manufact" }, |
| 86 | { IDI_WORKING, "working" }, |
| 87 | { IDI_NONWORKING, "nonwork" }, |
| 88 | { IDI_YEAR, "year" }, |
| 89 | { IDI_SOUND, "sound" }, |
| 90 | { IDI_CPU, "cpu" }, |
| 91 | { IDI_HARDDISK, "harddisk" }, |
| 92 | { IDI_SOURCE, "source" } |
| 93 | }; |
| 94 | |
| 95 | /*************************************************************************** |
| 96 | private variables |
| 97 | ***************************************************************************/ |
| 98 | |
| 99 | /* this has an entry for every folder eventually in the UI, including subfolders */ |
| 100 | static TREEFOLDER **treeFolders = 0; |
| 101 | static UINT numFolders = 0; /* Number of folder in the folder array */ |
| 102 | static UINT next_folder_id = MAX_FOLDERS; |
| 103 | static UINT folderArrayLength = 0; /* Size of the folder array */ |
| 104 | static LPTREEFOLDER lpCurrentFolder = 0; /* Currently selected folder */ |
| 105 | static UINT nCurrentFolder = 0; /* Current folder ID */ |
| 106 | static WNDPROC g_lpTreeWndProc = 0; /* for subclassing the TreeView */ |
| 107 | static HIMAGELIST hTreeSmall = 0; /* TreeView Image list of icons */ |
| 108 | |
| 109 | /* this only has an entry for each TOP LEVEL extra folder + SubFolders*/ |
| 110 | LPEXFOLDERDATA ExtraFolderData[MAX_EXTRA_FOLDERS * MAX_EXTRA_SUBFOLDERS]; |
| 111 | int numExtraFolders = 0; |
| 112 | static int numExtraIcons = 0; |
| 113 | static char *ExtraFolderIcons[MAX_EXTRA_FOLDERS]; |
| 114 | |
| 115 | // built in folders and filters |
| 116 | static LPFOLDERDATA g_lpFolderData; |
| 117 | static LPFILTER_ITEM g_lpFilterList; |
| 118 | |
| 119 | /*************************************************************************** |
| 120 | private function prototypes |
| 121 | ***************************************************************************/ |
| 122 | |
| 123 | extern BOOL InitFolders(void); |
| 124 | static BOOL CreateTreeIcons(void); |
| 125 | static void TreeCtrlOnPaint(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 126 | static const char* ParseManufacturer(const char *s, int *pParsedChars ); |
| 127 | static const char* TrimManufacturer(const char *s); |
| 128 | static void CreateAllChildFolders(void); |
| 129 | static BOOL AddFolder(LPTREEFOLDER lpFolder); |
| 130 | static LPTREEFOLDER NewFolder(const char *lpTitle, |
| 131 | UINT nFolderId, int nParent, UINT nIconId, |
| 132 | DWORD dwFlags); |
| 133 | static void DeleteFolder(LPTREEFOLDER lpFolder); |
| 134 | |
| 135 | static LRESULT CALLBACK TreeWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 136 | |
| 137 | static int InitExtraFolders(void); |
| 138 | static void FreeExtraFolders(void); |
| 139 | static void SetExtraIcons(char *name, int *id); |
| 140 | static BOOL TryAddExtraFolderAndChildren(int parent_index); |
| 141 | |
| 142 | static BOOL TrySaveExtraFolder(LPTREEFOLDER lpFolder); |
| 143 | |
| 144 | /*************************************************************************** |
| 145 | public functions |
| 146 | ***************************************************************************/ |
| 147 | |
| 148 | /************************************************************************** |
| 149 | * ci_strncmp - case insensitive character array compare |
| 150 | * |
| 151 | * Returns zero if the first n characters of s1 and s2 are equal, |
| 152 | * ignoring case. |
| 153 | * stolen from datafile.c |
| 154 | **************************************************************************/ |
| 155 | static int ci_strncmp (const char *s1, const char *s2, int n) |
| 156 | { |
| 157 | int c1, c2; |
| 158 | |
| 159 | while (n) |
| 160 | { |
| 161 | if ((c1 = tolower (*s1)) != (c2 = tolower (*s2))) |
| 162 | return (c1 - c2); |
| 163 | else if (!c1) |
| 164 | break; |
| 165 | --n; |
| 166 | |
| 167 | s1++; |
| 168 | s2++; |
| 169 | } |
| 170 | return 0; |
| 171 | } |
| 172 | |
| 173 | |
| 174 | |
| 175 | /* De-allocate all folder memory */ |
| 176 | void FreeFolders(void) |
| 177 | { |
| 178 | int i = 0; |
| 179 | |
| 180 | if (treeFolders != NULL) |
| 181 | { |
| 182 | if (numExtraFolders) |
| 183 | { |
| 184 | FreeExtraFolders(); |
| 185 | numFolders -= numExtraFolders; |
| 186 | } |
| 187 | |
| 188 | for (i = numFolders - 1; i >= 0; i--) |
| 189 | { |
| 190 | DeleteFolder(treeFolders[i]); |
| 191 | treeFolders[i] = NULL; |
| 192 | numFolders--; |
| 193 | } |
| 194 | free(treeFolders); |
| 195 | treeFolders = NULL; |
| 196 | } |
| 197 | numFolders = 0; |
| 198 | } |
| 199 | |
| 200 | /* Reset folder filters */ |
| 201 | void ResetFilters(void) |
| 202 | { |
| 203 | int i = 0; |
| 204 | |
| 205 | if (treeFolders != 0) |
| 206 | { |
| 207 | for (i = 0; i < (int)numFolders; i++) |
| 208 | { |
| 209 | treeFolders[i]->m_dwFlags &= ~F_MASK; |
| 210 | } |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | void InitTree(LPFOLDERDATA lpFolderData, LPFILTER_ITEM lpFilterList) |
| 215 | { |
| 216 | g_lpFolderData = lpFolderData; |
| 217 | g_lpFilterList = lpFilterList; |
| 218 | |
| 219 | InitFolders(); |
| 220 | |
| 221 | /* this will subclass the treeview (where WM_DRAWITEM gets sent for |
| 222 | the header control) */ |
| 223 | g_lpTreeWndProc = (WNDPROC)(LONG)(int)GetWindowLong(GetTreeView(), GWL_WNDPROC); |
| 224 | SetWindowLong(GetTreeView(), GWL_WNDPROC, (LONG)TreeWndProc); |
| 225 | } |
| 226 | |
| 227 | void DestroyTree(HWND hWnd) |
| 228 | { |
| 229 | if ( hTreeSmall ) |
| 230 | { |
| 231 | ImageList_Destroy( hTreeSmall ); |
| 232 | hTreeSmall = NULL; |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | void SetCurrentFolder(LPTREEFOLDER lpFolder) |
| 237 | { |
| 238 | lpCurrentFolder = (lpFolder == 0) ? treeFolders[0] : lpFolder; |
| 239 | nCurrentFolder = (lpCurrentFolder) ? lpCurrentFolder->m_nFolderId : 0; |
| 240 | } |
| 241 | |
| 242 | LPTREEFOLDER GetCurrentFolder(void) |
| 243 | { |
| 244 | return lpCurrentFolder; |
| 245 | } |
| 246 | |
| 247 | UINT GetCurrentFolderID(void) |
| 248 | { |
| 249 | return nCurrentFolder; |
| 250 | } |
| 251 | |
| 252 | int GetNumFolders(void) |
| 253 | { |
| 254 | return numFolders; |
| 255 | } |
| 256 | |
| 257 | LPTREEFOLDER GetFolder(UINT nFolder) |
| 258 | { |
| 259 | return (nFolder < numFolders) ? treeFolders[nFolder] : NULL; |
| 260 | } |
| 261 | |
| 262 | LPTREEFOLDER GetFolderByID(UINT nID) |
| 263 | { |
| 264 | UINT i; |
| 265 | |
| 266 | for (i = 0; i < numFolders; i++) |
| 267 | { |
| 268 | if (treeFolders[i]->m_nFolderId == nID) |
| 269 | { |
| 270 | return treeFolders[i]; |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | return (LPTREEFOLDER)0; |
| 275 | } |
| 276 | |
| 277 | void AddGame(LPTREEFOLDER lpFolder, UINT nGame) |
| 278 | { |
| 279 | if (lpFolder) |
| 280 | SetBit(lpFolder->m_lpGameBits, nGame); |
| 281 | } |
| 282 | |
| 283 | void RemoveGame(LPTREEFOLDER lpFolder, UINT nGame) |
| 284 | { |
| 285 | ClearBit(lpFolder->m_lpGameBits, nGame); |
| 286 | } |
| 287 | |
| 288 | int FindGame(LPTREEFOLDER lpFolder, int nGame) |
| 289 | { |
| 290 | return FindBit(lpFolder->m_lpGameBits, nGame, TRUE); |
| 291 | } |
| 292 | |
| 293 | // Called to re-associate games with folders |
| 294 | void ResetWhichGamesInFolders(void) |
| 295 | { |
| 296 | UINT i, jj, k; |
| 297 | BOOL b; |
| 298 | int nGames = driver_list_get_count(drivers); |
| 299 | |
| 300 | for (i = 0; i < numFolders; i++) |
| 301 | { |
| 302 | LPTREEFOLDER lpFolder = treeFolders[i]; |
| 303 | |
| 304 | // setup the games in our built-in folders |
| 305 | for (k = 0; g_lpFolderData[k].m_lpTitle; k++) |
| 306 | { |
| 307 | if (lpFolder->m_nFolderId == g_lpFolderData[k].m_nFolderId) |
| 308 | { |
| 309 | if (g_lpFolderData[k].m_pfnQuery || g_lpFolderData[k].m_bExpectedResult) |
| 310 | { |
| 311 | SetAllBits(lpFolder->m_lpGameBits, FALSE); |
| 312 | for (jj = 0; jj < nGames; jj++) |
| 313 | { |
| 314 | // invoke the query function |
| 315 | b = g_lpFolderData[k].m_pfnQuery ? g_lpFolderData[k].m_pfnQuery(jj) : TRUE; |
| 316 | |
| 317 | // if we expect FALSE, flip the result |
| 318 | if (!g_lpFolderData[k].m_bExpectedResult) |
| 319 | b = !b; |
| 320 | |
| 321 | // if we like what we hear, add the game |
| 322 | if (b) |
| 323 | AddGame(lpFolder, jj); |
| 324 | } |
| 325 | } |
| 326 | break; |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | |
| 333 | /* Used to build the GameList */ |
| 334 | BOOL GameFiltered(int nGame, DWORD dwMask) |
| 335 | { |
| 336 | int i; |
| 337 | LPTREEFOLDER lpFolder = GetCurrentFolder(); |
| 338 | LPTREEFOLDER lpParent = NULL; |
| 339 | |
| 340 | //Filter out the Bioses on all Folders, except for the Bios Folder |
| 341 | if( lpFolder->m_nFolderId != FOLDER_BIOS ) |
| 342 | { |
| 343 | if( !( (drivers[nGame]->flags & GAME_IS_BIOS_ROOT ) == 0) ) |
| 344 | return TRUE; |
| 345 | } |
| 346 | // Filter games--return TRUE if the game should be HIDDEN in this view |
| 347 | if( GetFilterInherit() ) |
| 348 | { |
| 349 | if( lpFolder ) |
| 350 | { |
| 351 | lpParent = GetFolder( lpFolder->m_nParent ); |
| 352 | if( lpParent ) |
| 353 | { |
| 354 | /* Check the Parent Filters and inherit them on child, |
| 355 | * The inherited filters don't display on the custom Filter Dialog for the Child folder |
| 356 | * No need to promote all games to parent folder, works as is */ |
| 357 | dwMask |= lpParent->m_dwFlags; |
| 358 | } |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | if (strlen(GetSearchText()) && _stricmp(GetSearchText(), SEARCH_PROMPT)) |
| 363 | { |
| 364 | if (MyStrStrI(drivers[nGame]->description,GetSearchText()) == NULL && |
| 365 | MyStrStrI(drivers[nGame]->name,GetSearchText()) == NULL) |
| 366 | return TRUE; |
| 367 | } |
| 368 | /*Filter Text is already global*/ |
| 369 | if (MyStrStrI(drivers[nGame]->description,GetFilterText()) == NULL && |
| 370 | MyStrStrI(drivers[nGame]->name,GetFilterText()) == NULL && |
| 371 | MyStrStrI(drivers[nGame]->source_file,GetFilterText()) == NULL && |
| 372 | MyStrStrI(drivers[nGame]->manufacturer,GetFilterText()) == NULL) |
| 373 | { |
| 374 | return TRUE; |
| 375 | } |
| 376 | // Are there filters set on this folder? |
| 377 | if ((dwMask & F_MASK) == 0) |
| 378 | return FALSE; |
| 379 | |
| 380 | // Filter out clones? |
| 381 | if (dwMask & F_CLONES && DriverIsClone(nGame)) |
| 382 | return TRUE; |
| 383 | |
| 384 | for (i = 0; g_lpFilterList[i].m_dwFilterType; i++) |
| 385 | { |
| 386 | if (dwMask & g_lpFilterList[i].m_dwFilterType) |
| 387 | { |
| 388 | if (g_lpFilterList[i].m_pfnQuery(nGame) == g_lpFilterList[i].m_bExpectedResult) |
| 389 | return TRUE; |
| 390 | } |
| 391 | } |
| 392 | return FALSE; |
| 393 | } |
| 394 | |
| 395 | /* Get the parent of game in this view */ |
| 396 | BOOL GetParentFound(int nGame) |
| 397 | { |
| 398 | int nParentIndex = -1; |
| 399 | LPTREEFOLDER lpFolder = GetCurrentFolder(); |
| 400 | |
| 401 | if( lpFolder ) |
| 402 | { |
| 403 | nParentIndex = GetParentIndex(drivers[nGame]); |
| 404 | |
| 405 | /* return FALSE if no parent is there in this view */ |
| 406 | if( nParentIndex == -1) |
| 407 | return FALSE; |
| 408 | |
| 409 | /* return FALSE if the folder should be HIDDEN in this view */ |
| 410 | if (TestBit(lpFolder->m_lpGameBits, nParentIndex) == 0) |
| 411 | return FALSE; |
| 412 | |
| 413 | /* return FALSE if the game should be HIDDEN in this view */ |
| 414 | if (GameFiltered(nParentIndex, lpFolder->m_dwFlags)) |
| 415 | return FALSE; |
| 416 | |
| 417 | return TRUE; |
| 418 | } |
| 419 | |
| 420 | return FALSE; |
| 421 | } |
| 422 | |
| 423 | LPFILTER_ITEM GetFilterList(void) |
| 424 | { |
| 425 | return g_lpFilterList; |
| 426 | } |
| 427 | |
| 428 | /*************************************************************************** |
| 429 | private functions |
| 430 | ***************************************************************************/ |
| 431 | |
| 432 | void CreateSourceFolders(int parent_index) |
| 433 | { |
| 434 | int i,jj, k=0; |
| 435 | int nGames = driver_list_get_count(drivers); |
| 436 | int start_folder = numFolders; |
| 437 | LPTREEFOLDER lpFolder = treeFolders[parent_index]; |
| 438 | |
| 439 | // no games in top level folder |
| 440 | SetAllBits(lpFolder->m_lpGameBits,FALSE); |
| 441 | for (jj = 0; jj < nGames; jj++) |
| 442 | { |
| 443 | const char *s = GetDriverFilename(jj); |
| 444 | |
| 445 | if (s == NULL || s[0] == '\0') |
| 446 | continue; |
| 447 | |
| 448 | // look for an existant source treefolder for this game |
| 449 | // (likely to be the previous one, so start at the end) |
| 450 | for (i=numFolders-1;i>=start_folder;i--) |
| 451 | { |
| 452 | if (strcmp(treeFolders[i]->m_lpTitle,s) == 0) |
| 453 | { |
| 454 | AddGame(treeFolders[i],jj); |
| 455 | break; |
| 456 | } |
| 457 | } |
| 458 | if (i == start_folder-1) |
| 459 | { |
| 460 | // nope, it's a source file we haven't seen before, make it. |
| 461 | LPTREEFOLDER lpTemp; |
| 462 | lpTemp = NewFolder(s, next_folder_id, parent_index, IDI_SOURCE, |
| 463 | GetFolderFlags(numFolders)); |
| 464 | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 465 | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 466 | |
| 467 | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 468 | ExtraFolderData[next_folder_id]->m_nIconId = IDI_SOURCE; |
| 469 | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 470 | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 471 | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, s ); |
| 472 | ExtraFolderData[next_folder_id]->m_dwFlags = 0; |
| 473 | |
| 474 | // Increment next_folder_id here in case code is added above |
| 475 | next_folder_id++; |
| 476 | |
| 477 | AddFolder(lpTemp); |
| 478 | AddGame(lpTemp,jj); |
| 479 | } |
| 480 | } |
| 481 | SetNumOptionFolders(k-1); |
| 482 | } |
| 483 | |
| 484 | void CreateManufacturerFolders(int parent_index) |
| 485 | { |
| 486 | int i,jj; |
| 487 | int nGames = driver_list_get_count(drivers); |
| 488 | int start_folder = numFolders; |
| 489 | LPTREEFOLDER lpFolder = treeFolders[parent_index]; |
| 490 | LPTREEFOLDER lpTemp; |
| 491 | |
| 492 | // no games in top level folder |
| 493 | SetAllBits(lpFolder->m_lpGameBits,FALSE); |
| 494 | |
| 495 | for (jj = 0; jj < nGames; jj++) |
| 496 | { |
| 497 | const char *manufacturer = drivers[jj]->manufacturer; |
| 498 | int iChars = 0; |
| 499 | while( manufacturer != NULL && manufacturer[0] != '\0' ) |
| 500 | { |
| 501 | const char *s = ParseManufacturer(manufacturer, &iChars); |
| 502 | manufacturer += iChars; |
| 503 | //shift to next start char |
| 504 | if( s != NULL && strlen(s) > 0 ) |
| 505 | { |
| 506 | const char *t = TrimManufacturer(s); |
| 507 | for (i=numFolders-1;i>=start_folder;i--) |
| 508 | { |
| 509 | //RS Made it case insensitive |
| 510 | if (ci_strncmp(treeFolders[i]->m_lpTitle,t,20) == 0 ) |
| 511 | { |
| 512 | AddGame(treeFolders[i],jj); |
| 513 | break; |
| 514 | } |
| 515 | } |
| 516 | if (i == start_folder-1) |
| 517 | { |
| 518 | // nope, it's a manufacturer we haven't seen before, make it. |
| 519 | lpTemp = NewFolder(t, next_folder_id, parent_index, IDI_MANUFACTURER, |
| 520 | GetFolderFlags(numFolders)); |
| 521 | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 522 | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 523 | |
| 524 | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 525 | ExtraFolderData[next_folder_id]->m_nIconId = IDI_MANUFACTURER; |
| 526 | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 527 | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 528 | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, s ); |
| 529 | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 530 | AddFolder(lpTemp); |
| 531 | AddGame(lpTemp,jj); |
| 532 | } |
| 533 | } |
| 534 | } |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | /* Make a reasonable name out of the one found in the driver array */ |
| 539 | static const char* ParseManufacturer(const char *s, int *pParsedChars ) |
| 540 | { |
| 541 | static char tmp[256]; |
| 542 | char* ptmp; |
| 543 | char *t; |
| 544 | *pParsedChars= 0; |
| 545 | |
| 546 | if ( *s == '?' || *s == '<' || s[3] == '?' ) |
| 547 | { |
| 548 | (*pParsedChars) = strlen(s); |
| 549 | return "<unknown>"; |
| 550 | } |
| 551 | |
| 552 | ptmp = tmp; |
| 553 | /*if first char is a space, skip it*/ |
| 554 | if( *s == ' ' ) |
| 555 | { |
| 556 | (*pParsedChars)++; |
| 557 | ++s; |
| 558 | } |
| 559 | while( *s ) |
| 560 | { |
| 561 | /* combinations where to end string */ |
| 562 | |
| 563 | if ( |
| 564 | ( (*s == ' ') && ( s[1] == '(' || s[1] == '/' || s[1] == '+' ) ) || |
| 565 | ( *s == ']' ) || |
| 566 | ( *s == '/' ) || |
| 567 | ( *s == '?' ) |
| 568 | ) |
| 569 | { |
| 570 | (*pParsedChars)++; |
| 571 | if( s[1] == '/' || s[1] == '+' ) |
| 572 | (*pParsedChars)++; |
| 573 | break; |
| 574 | } |
| 575 | if( s[0] == ' ' && s[1] == '?' ) |
| 576 | { |
| 577 | (*pParsedChars) += 2; |
| 578 | s+=2; |
| 579 | } |
| 580 | |
| 581 | /* skip over opening braces*/ |
| 582 | |
| 583 | if ( *s != '[' ) |
| 584 | { |
| 585 | *ptmp++ = *s; |
| 586 | } |
| 587 | (*pParsedChars)++; |
| 588 | /*for "distributed by" and "supported by" handling*/ |
| 589 | if( ( (s[1] == ',') && (s[2] == ' ') && ( (s[3] == 's') || (s[3] == 'd') ) ) ) |
| 590 | { |
| 591 | //*ptmp++ = *s; |
| 592 | ++s; |
| 593 | break; |
| 594 | } |
| 595 | ++s; |
| 596 | } |
| 597 | *ptmp = '\0'; |
| 598 | t = tmp; |
| 599 | if( tmp[0] == '(' || tmp[strlen(tmp)-1] == ')' || tmp[0] == ',') |
| 600 | { |
| 601 | ptmp = strchr( tmp,'(' ); |
| 602 | if ( ptmp == NULL ) |
| 603 | { |
| 604 | ptmp = strchr( tmp,',' ); |
| 605 | if( ptmp != NULL) |
| 606 | { |
| 607 | //parse the new "supported by" and "distributed by" |
| 608 | ptmp++; |
| 609 | |
| 610 | if (ci_strncmp(ptmp, " supported by", 13) == 0) |
| 611 | { |
| 612 | ptmp += 13; |
| 613 | } |
| 614 | else if (ci_strncmp(ptmp, " distributed by", 15) == 0) |
| 615 | { |
| 616 | ptmp += 15; |
| 617 | } |
| 618 | else |
| 619 | { |
| 620 | return NULL; |
| 621 | } |
| 622 | } |
| 623 | else |
| 624 | { |
| 625 | ptmp = tmp; |
| 626 | if ( ptmp == NULL ) |
| 627 | { |
| 628 | return NULL; |
| 629 | } |
| 630 | } |
| 631 | } |
| 632 | if( tmp[0] == '(' || tmp[0] == ',') |
| 633 | { |
| 634 | ptmp++; |
| 635 | } |
| 636 | if (ci_strncmp(ptmp, "licensed from ", 14) == 0) |
| 637 | { |
| 638 | ptmp += 14; |
| 639 | } |
| 640 | // for the licenced from case |
| 641 | if (ci_strncmp(ptmp, "licenced from ", 14) == 0) |
| 642 | { |
| 643 | ptmp += 14; |
| 644 | } |
| 645 | |
| 646 | while ( (*ptmp != ')' ) && (*ptmp != '/' ) && *ptmp != '\0') |
| 647 | { |
| 648 | if (*ptmp == ' ' && ci_strncmp(ptmp, " license", 8) == 0) |
| 649 | { |
| 650 | break; |
| 651 | } |
| 652 | if (*ptmp == ' ' && ci_strncmp(ptmp, " licence", 8) == 0) |
| 653 | { |
| 654 | break; |
| 655 | } |
| 656 | *t++ = *ptmp++; |
| 657 | } |
| 658 | |
| 659 | *t = '\0'; |
| 660 | } |
| 661 | |
| 662 | *ptmp = '\0'; |
| 663 | return tmp; |
| 664 | } |
| 665 | |
| 666 | /* Analyze Manufacturer Names for typical patterns, that don't distinguish between companies (e.g. Co., Ltd., Inc., etc. */ |
| 667 | static const char* TrimManufacturer(const char *s) |
| 668 | { |
| 669 | //Also remove Country specific suffixes (e.g. Japan, Italy, America, USA, ...) |
| 670 | int i=0; |
| 671 | char strTemp[256]; |
| 672 | static char strTemp2[256]; |
| 673 | int j=0; |
| 674 | int k=0; |
| 675 | int l = 0; |
| 676 | memset(strTemp, '\0', 256 ); |
| 677 | memset(strTemp2, '\0', 256 ); |
| 678 | //start analyzing from the back, as these are usually suffixes |
| 679 | for(i=strlen(s)-1; i>=0;i-- ) |
| 680 | { |
| 681 | |
| 682 | l = strlen(strTemp); |
| 683 | for(k=l;k>=0; k--) |
| 684 | strTemp[k+1] = strTemp[k]; |
| 685 | strTemp[0] = s[i]; |
| 686 | strTemp[++l] = '\0'; |
| 687 | switch (l) |
| 688 | { |
| 689 | case 2: |
| 690 | if( ci_strncmp(strTemp, "co", 2) == 0 ) |
| 691 | { |
| 692 | j=l; |
| 693 | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 694 | { |
| 695 | j++; |
| 696 | } |
| 697 | if( j!=l) |
| 698 | { |
| 699 | memset(strTemp2, '\0', 256 ); |
| 700 | strncpy(strTemp2, s, strlen(s)-j ); |
| 701 | } |
| 702 | } |
| 703 | break; |
| 704 | case 3: |
| 705 | if( ci_strncmp(strTemp, "co.", 3) == 0 || ci_strncmp(strTemp, "ltd", 3) == 0 || ci_strncmp(strTemp, "inc", 3) == 0 || ci_strncmp(strTemp, "SRL", 3) == 0 || ci_strncmp(strTemp, "USA", 3) == 0) |
| 706 | { |
| 707 | j=l; |
| 708 | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 709 | { |
| 710 | j++; |
| 711 | } |
| 712 | if( j!=l) |
| 713 | { |
| 714 | memset(strTemp2, '\0', 256 ); |
| 715 | strncpy(strTemp2, s, strlen(s)-j ); |
| 716 | } |
| 717 | } |
| 718 | break; |
| 719 | case 4: |
| 720 | if( ci_strncmp(strTemp, "inc.", 4) == 0 || ci_strncmp(strTemp, "ltd.", 4) == 0 || ci_strncmp(strTemp, "corp", 4) == 0 || ci_strncmp(strTemp, "game", 4) == 0) |
| 721 | { |
| 722 | j=l; |
| 723 | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 724 | { |
| 725 | j++; |
| 726 | } |
| 727 | if( j!=l) |
| 728 | { |
| 729 | memset(strTemp2, '\0', 256 ); |
| 730 | strncpy(strTemp2, s, strlen(s)-j ); |
| 731 | } |
| 732 | } |
| 733 | break; |
| 734 | case 5: |
| 735 | if( ci_strncmp(strTemp, "corp.", 5) == 0 || ci_strncmp(strTemp, "Games", 5) == 0 || ci_strncmp(strTemp, "Italy", 5) == 0 || ci_strncmp(strTemp, "Japan", 5) == 0) |
| 736 | { |
| 737 | j=l; |
| 738 | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 739 | { |
| 740 | j++; |
| 741 | } |
| 742 | if( j!=l) |
| 743 | { |
| 744 | memset(strTemp2, '\0', 256 ); |
| 745 | strncpy(strTemp2, s, strlen(s)-j ); |
| 746 | } |
| 747 | } |
| 748 | break; |
| 749 | case 6: |
| 750 | if( ci_strncmp(strTemp, "co-ltd", 6) == 0 || ci_strncmp(strTemp, "S.R.L.", 6) == 0) |
| 751 | { |
| 752 | j=l; |
| 753 | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 754 | { |
| 755 | j++; |
| 756 | } |
| 757 | if( j!=l) |
| 758 | { |
| 759 | memset(strTemp2, '\0', 256 ); |
| 760 | strncpy(strTemp2, s, strlen(s)-j ); |
| 761 | } |
| 762 | } |
| 763 | break; |
| 764 | case 7: |
| 765 | if( ci_strncmp(strTemp, "co. ltd", 7) == 0 || ci_strncmp(strTemp, "America", 7) == 0) |
| 766 | { |
| 767 | j=l; |
| 768 | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 769 | { |
| 770 | j++; |
| 771 | } |
| 772 | if( j!=l) |
| 773 | { |
| 774 | memset(strTemp2, '\0', 256 ); |
| 775 | strncpy(strTemp2, s, strlen(s)-j ); |
| 776 | } |
| 777 | } |
| 778 | break; |
| 779 | case 8: |
| 780 | if( ci_strncmp(strTemp, "co. ltd.", 8) == 0 ) |
| 781 | { |
| 782 | j=l; |
| 783 | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 784 | { |
| 785 | j++; |
| 786 | } |
| 787 | if( j!=l) |
| 788 | { |
| 789 | memset(strTemp2, '\0', 256 ); |
| 790 | strncpy(strTemp2, s, strlen(s)-j ); |
| 791 | } |
| 792 | } |
| 793 | break; |
| 794 | case 9: |
| 795 | if( ci_strncmp(strTemp, "co., ltd.", 9) == 0 || ci_strncmp(strTemp, "gmbh & co", 9) == 0 ) |
| 796 | { |
| 797 | j=l; |
| 798 | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 799 | { |
| 800 | j++; |
| 801 | } |
| 802 | if( j!=l) |
| 803 | { |
| 804 | memset(strTemp2, '\0', 256 ); |
| 805 | strncpy(strTemp2, s, strlen(s)-j ); |
| 806 | } |
| 807 | } |
| 808 | break; |
| 809 | case 10: |
| 810 | if( ci_strncmp(strTemp, "corp, ltd.", 10) == 0 || ci_strncmp(strTemp, "industries", 10) == 0 || ci_strncmp(strTemp, "of America", 10) == 0) |
| 811 | { |
| 812 | j=l; |
| 813 | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 814 | { |
| 815 | j++; |
| 816 | } |
| 817 | if( j!=l) |
| 818 | { |
| 819 | memset(strTemp2, '\0', 256 ); |
| 820 | strncpy(strTemp2, s, strlen(s)-j ); |
| 821 | } |
| 822 | } |
| 823 | break; |
| 824 | case 11: |
| 825 | if( ci_strncmp(strTemp, "corporation", 11) == 0 || ci_strncmp(strTemp, "enterprises", 11) == 0 ) |
| 826 | { |
| 827 | j=l; |
| 828 | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 829 | { |
| 830 | j++; |
| 831 | } |
| 832 | if( j!=l) |
| 833 | { |
| 834 | memset(strTemp2, '\0', 256 ); |
| 835 | strncpy(strTemp2, s, strlen(s)-j ); |
| 836 | } |
| 837 | } |
| 838 | break; |
| 839 | case 16: |
| 840 | if( ci_strncmp(strTemp, "industries japan", 16) == 0 ) |
| 841 | { |
| 842 | j=l; |
| 843 | while( s[strlen(s)-j-1] == ' ' || s[strlen(s)-j-1] == ',' ) |
| 844 | { |
| 845 | j++; |
| 846 | } |
| 847 | if( j!=l) |
| 848 | { |
| 849 | memset(strTemp2, '\0', 256 ); |
| 850 | strncpy(strTemp2, s, strlen(s)-j ); |
| 851 | } |
| 852 | } |
| 853 | break; |
| 854 | default: |
| 855 | break; |
| 856 | } |
| 857 | } |
| 858 | if( strlen(strTemp2) == 0 ) |
| 859 | return s; |
| 860 | return strTemp2; |
| 861 | } |
| 862 | |
| 863 | |
| 864 | |
| 865 | void CreateCPUFolders(int parent_index) |
| 866 | { |
| 867 | int i,jj; |
| 868 | int nGames = driver_list_get_count(drivers); |
| 869 | int nFolder = numFolders; |
| 870 | LPTREEFOLDER lpFolder = treeFolders[parent_index]; |
| 871 | LPTREEFOLDER map[CPU_COUNT]; |
| 872 | |
| 873 | ZeroMemory(map, sizeof(map)); |
| 874 | cpuintrf_init(NULL); |
| 875 | |
| 876 | // no games in top level folder |
| 877 | SetAllBits(lpFolder->m_lpGameBits,FALSE); |
| 878 | |
| 879 | for (i=1;i<CPU_COUNT;i++) |
| 880 | { |
| 881 | LPTREEFOLDER lpTemp; |
| 882 | |
| 883 | for (jj = 1; jj < i; jj++) |
| 884 | if (!strcmp(cputype_name(i), cputype_name(jj))) |
| 885 | break; |
| 886 | |
| 887 | if (i != jj) |
| 888 | { |
| 889 | map[i] = map[jj]; |
| 890 | continue; |
| 891 | } |
| 892 | if( strlen( cputype_name(i) ) <=0 ) |
| 893 | continue; |
| 894 | lpTemp = NewFolder(cputype_name(i), next_folder_id, parent_index, IDI_CPU, |
| 895 | GetFolderFlags(numFolders)); |
| 896 | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 897 | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 898 | |
| 899 | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 900 | ExtraFolderData[next_folder_id]->m_nIconId = IDI_CPU; |
| 901 | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 902 | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 903 | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, cputype_name(i) ); |
| 904 | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 905 | AddFolder(lpTemp); |
| 906 | map[i] = treeFolders[nFolder++]; |
| 907 | } |
| 908 | |
| 909 | for (jj = 0; jj < nGames; jj++) |
| 910 | { |
| 911 | int n; |
| 912 | machine_config drv; |
| 913 | expand_machine_driver(drivers[jj]->drv,&drv); |
| 914 | for (n = 0; n < MAX_CPU; n++) |
| 915 | if (drv.cpu[n].cpu_type != CPU_DUMMY) |
| 916 | { |
| 917 | // cpu type #'s are one-based |
| 918 | AddGame(map[drv.cpu[n].cpu_type],jj); |
| 919 | } |
| 920 | } |
| 921 | } |
| 922 | |
| 923 | void CreateSoundFolders(int parent_index) |
| 924 | { |
| 925 | int i,jj; |
| 926 | int nGames = driver_list_get_count(drivers); |
| 927 | int nFolder = numFolders; |
| 928 | LPTREEFOLDER lpFolder = treeFolders[parent_index]; |
| 929 | LPTREEFOLDER map[SOUND_COUNT]; |
| 930 | |
| 931 | sndintrf_init(NULL); |
| 932 | |
| 933 | // no games in top level folder |
| 934 | SetAllBits(lpFolder->m_lpGameBits,FALSE); |
| 935 | |
| 936 | for (i = 1 ; i < MAX_SOUND ; i++) |
| 937 | { |
| 938 | LPTREEFOLDER lpTemp; |
| 939 | // Init to NULL here in case it doesn't get assigned below. |
| 940 | map[i] = NULL; |
| 941 | // empty fields get filled in with SOUND_DUMMY, so check for this and |
| 942 | // don't add it |
| 943 | if (strcmp(sndtype_name(SOUND_DUMMY),sndtype_name(i)) == 0) |
| 944 | continue; |
| 945 | |
| 946 | //dprintf("%i %s\n",i,sndtype_name(i)); |
| 947 | lpTemp = NewFolder(sndtype_name(i), next_folder_id, parent_index, IDI_SOUND, |
| 948 | GetFolderFlags(numFolders)); |
| 949 | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 950 | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 951 | |
| 952 | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 953 | ExtraFolderData[next_folder_id]->m_nIconId = IDI_SOUND; |
| 954 | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 955 | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 956 | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, sndtype_name(i) ); |
| 957 | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 958 | AddFolder(lpTemp); |
| 959 | map[i] = treeFolders[nFolder++]; |
| 960 | } |
| 961 | for (jj = 0; jj < nGames; jj++) |
| 962 | { |
| 963 | int n; |
| 964 | machine_config drv; |
| 965 | expand_machine_driver(drivers[jj]->drv,&drv); |
| 966 | // Additional range and null checking. |
| 967 | for (n = 0; n < MAX_SOUND ; n++) |
| 968 | if (drv.sound[n].sound_type > SOUND_DUMMY && |
| 969 | drv.sound[n].sound_type < MAX_SOUND) |
| 970 | { |
| 971 | if (map[drv.sound[n].sound_type] != NULL) { |
| 972 | // sound type #'s are one-based, though that doesn't affect us here |
| 973 | AddGame(map[drv.sound[n].sound_type],jj); |
| 974 | } |
| 975 | } |
| 976 | } |
| 977 | |
| 978 | } |
| 979 | |
| 980 | void CreateDeficiencyFolders(int parent_index) |
| 981 | { |
| 982 | int jj; |
| 983 | int nGames = driver_list_get_count(drivers); |
| 984 | LPTREEFOLDER lpFolder = treeFolders[parent_index]; |
| 985 | |
| 986 | // create our two subfolders |
| 987 | LPTREEFOLDER lpProt, lpWrongCol, lpImpCol, lpImpGraph, lpMissSnd, lpImpSnd, lpFlip; |
| 988 | lpProt = NewFolder("Unemulated Protection", next_folder_id, parent_index, IDI_FOLDER, |
| 989 | GetFolderFlags(numFolders)); |
| 990 | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 991 | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 992 | |
| 993 | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 994 | ExtraFolderData[next_folder_id]->m_nIconId = IDI_FOLDER; |
| 995 | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 996 | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 997 | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, "Unemulated Protection" ); |
| 998 | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 999 | AddFolder(lpProt); |
| 1000 | lpWrongCol = NewFolder("Wrong Colors", next_folder_id, parent_index, IDI_FOLDER, |
| 1001 | GetFolderFlags(numFolders)); |
| 1002 | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1003 | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1004 | |
| 1005 | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1006 | ExtraFolderData[next_folder_id]->m_nIconId = IDI_FOLDER; |
| 1007 | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1008 | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1009 | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, "Wrong Colors" ); |
| 1010 | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1011 | AddFolder(lpWrongCol); |
| 1012 | |
| 1013 | lpImpCol = NewFolder("Imperfect Colors", next_folder_id, parent_index, IDI_FOLDER, |
| 1014 | GetFolderFlags(numFolders)); |
| 1015 | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1016 | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1017 | |
| 1018 | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1019 | ExtraFolderData[next_folder_id]->m_nIconId = IDI_FOLDER; |
| 1020 | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1021 | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1022 | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, "Imperfect Colors" ); |
| 1023 | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1024 | AddFolder(lpImpCol); |
| 1025 | |
| 1026 | lpImpGraph = NewFolder("Imperfect Graphics", next_folder_id, parent_index, IDI_FOLDER, |
| 1027 | GetFolderFlags(numFolders)); |
| 1028 | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1029 | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1030 | |
| 1031 | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1032 | ExtraFolderData[next_folder_id]->m_nIconId = IDI_FOLDER; |
| 1033 | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1034 | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1035 | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, "Imperfect Graphics" ); |
| 1036 | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1037 | AddFolder(lpImpGraph); |
| 1038 | |
| 1039 | lpMissSnd = NewFolder("Missing Sound", next_folder_id, parent_index, IDI_FOLDER, |
| 1040 | GetFolderFlags(numFolders)); |
| 1041 | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1042 | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1043 | |
| 1044 | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1045 | ExtraFolderData[next_folder_id]->m_nIconId = IDI_FOLDER; |
| 1046 | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1047 | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1048 | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, "Missing Sound" ); |
| 1049 | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1050 | AddFolder(lpMissSnd); |
| 1051 | |
| 1052 | lpImpSnd = NewFolder("Imperfect Sound", next_folder_id, parent_index, IDI_FOLDER, |
| 1053 | GetFolderFlags(numFolders)); |
| 1054 | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1055 | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1056 | |
| 1057 | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1058 | ExtraFolderData[next_folder_id]->m_nIconId = IDI_FOLDER; |
| 1059 | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1060 | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1061 | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, "Imperfect Sound" ); |
| 1062 | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1063 | AddFolder(lpImpSnd); |
| 1064 | |
| 1065 | lpFlip = NewFolder("No Cocktail", next_folder_id, parent_index, IDI_FOLDER, |
| 1066 | GetFolderFlags(numFolders)); |
| 1067 | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1068 | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1069 | |
| 1070 | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1071 | ExtraFolderData[next_folder_id]->m_nIconId = IDI_FOLDER; |
| 1072 | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1073 | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1074 | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, "No Cocktail" ); |
| 1075 | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1076 | AddFolder(lpFlip); |
| 1077 | |
| 1078 | // no games in top level folder |
| 1079 | SetAllBits(lpFolder->m_lpGameBits,FALSE); |
| 1080 | |
| 1081 | for (jj = 0; jj < nGames; jj++) |
| 1082 | { |
| 1083 | if (drivers[jj]->flags & GAME_WRONG_COLORS) |
| 1084 | { |
| 1085 | AddGame(lpWrongCol,jj); |
| 1086 | } |
| 1087 | if (drivers[jj]->flags & GAME_UNEMULATED_PROTECTION) |
| 1088 | { |
| 1089 | AddGame(lpProt,jj); |
| 1090 | } |
| 1091 | if (drivers[jj]->flags & GAME_IMPERFECT_COLORS) |
| 1092 | { |
| 1093 | AddGame(lpImpCol,jj); |
| 1094 | } |
| 1095 | if (drivers[jj]->flags & GAME_IMPERFECT_GRAPHICS) |
| 1096 | { |
| 1097 | AddGame(lpImpGraph,jj); |
| 1098 | } |
| 1099 | if (drivers[jj]->flags & GAME_NO_SOUND) |
| 1100 | { |
| 1101 | AddGame(lpMissSnd,jj); |
| 1102 | } |
| 1103 | if (drivers[jj]->flags & GAME_IMPERFECT_SOUND) |
| 1104 | { |
| 1105 | AddGame(lpImpSnd,jj); |
| 1106 | } |
| 1107 | if (drivers[jj]->flags & GAME_NO_COCKTAIL) |
| 1108 | { |
| 1109 | AddGame(lpFlip,jj); |
| 1110 | } |
| 1111 | } |
| 1112 | } |
| 1113 | |
| 1114 | void CreateDumpingFolders(int parent_index) |
| 1115 | { |
| 1116 | int jj; |
| 1117 | BOOL bBadDump = FALSE; |
| 1118 | BOOL bNoDump = FALSE; |
| 1119 | int nGames = driver_list_get_count(drivers); |
| 1120 | LPTREEFOLDER lpFolder = treeFolders[parent_index]; |
| 1121 | const rom_entry *region, *rom; |
| 1122 | const char *name; |
| 1123 | const game_driver *gamedrv; |
| 1124 | |
| 1125 | // create our two subfolders |
| 1126 | LPTREEFOLDER lpBad, lpNo; |
| 1127 | lpBad = NewFolder("Bad Dump", next_folder_id, parent_index, IDI_FOLDER, |
| 1128 | GetFolderFlags(numFolders)); |
| 1129 | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1130 | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1131 | |
| 1132 | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1133 | ExtraFolderData[next_folder_id]->m_nIconId = IDI_FOLDER; |
| 1134 | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1135 | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1136 | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, "Bad Dump" ); |
| 1137 | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1138 | AddFolder(lpBad); |
| 1139 | lpNo = NewFolder("No Dump", next_folder_id, parent_index, IDI_FOLDER, |
| 1140 | GetFolderFlags(numFolders)); |
| 1141 | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1142 | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1143 | |
| 1144 | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1145 | ExtraFolderData[next_folder_id]->m_nIconId = IDI_FOLDER; |
| 1146 | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1147 | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1148 | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, "No Dump" ); |
| 1149 | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1150 | AddFolder(lpNo); |
| 1151 | |
| 1152 | // no games in top level folder |
| 1153 | SetAllBits(lpFolder->m_lpGameBits,FALSE); |
| 1154 | |
| 1155 | for (jj = 0; jj < nGames; jj++) |
| 1156 | { |
| 1157 | gamedrv = drivers[jj]; |
| 1158 | |
| 1159 | if (!gamedrv->rom) |
| 1160 | continue; |
| 1161 | bBadDump = FALSE; |
| 1162 | bNoDump = FALSE; |
| 1163 | for (region = rom_first_region(gamedrv); region; region = rom_next_region(region)) |
| 1164 | { |
| 1165 | for (rom = rom_first_file(region); rom; rom = rom_next_file(rom)) |
| 1166 | { |
| 1167 | if (ROMREGION_ISROMDATA(region) || ROMREGION_ISDISKDATA(region) ) |
| 1168 | { |
| 1169 | name = ROM_GETNAME(rom); |
| 1170 | if (hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_BAD_DUMP)) |
| 1171 | bBadDump = TRUE; |
| 1172 | if (hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_NO_DUMP)) |
| 1173 | bNoDump = TRUE; |
| 1174 | } |
| 1175 | } |
| 1176 | } |
| 1177 | if (bBadDump) |
| 1178 | { |
| 1179 | AddGame(lpBad,jj); |
| 1180 | } |
| 1181 | if (bNoDump) |
| 1182 | { |
| 1183 | AddGame(lpNo,jj); |
| 1184 | } |
| 1185 | } |
| 1186 | } |
| 1187 | |
| 1188 | |
| 1189 | void CreateYearFolders(int parent_index) |
| 1190 | { |
| 1191 | int i,jj; |
| 1192 | int nGames = driver_list_get_count(drivers); |
| 1193 | int start_folder = numFolders; |
| 1194 | LPTREEFOLDER lpFolder = treeFolders[parent_index]; |
| 1195 | |
| 1196 | // no games in top level folder |
| 1197 | SetAllBits(lpFolder->m_lpGameBits,FALSE); |
| 1198 | |
| 1199 | for (jj = 0; jj < nGames; jj++) |
| 1200 | { |
| 1201 | char s[100]; |
| 1202 | strcpy(s,drivers[jj]->year); |
| 1203 | |
| 1204 | if (s[0] == '\0' || s[0] == '?') |
| 1205 | continue; |
| 1206 | |
| 1207 | if (s[4] == '?') |
| 1208 | s[4] = '\0'; |
| 1209 | |
| 1210 | // look for an extant year treefolder for this game |
| 1211 | // (likely to be the previous one, so start at the end) |
| 1212 | for (i=numFolders-1;i>=start_folder;i--) |
| 1213 | { |
| 1214 | if (strncmp(treeFolders[i]->m_lpTitle,s,4) == 0) |
| 1215 | { |
| 1216 | AddGame(treeFolders[i],jj); |
| 1217 | break; |
| 1218 | } |
| 1219 | } |
| 1220 | if (i == start_folder-1) |
| 1221 | { |
| 1222 | // nope, it's a year we haven't seen before, make it. |
| 1223 | LPTREEFOLDER lpTemp; |
| 1224 | lpTemp = NewFolder(s, next_folder_id, parent_index, IDI_YEAR, |
| 1225 | GetFolderFlags(numFolders)); |
| 1226 | ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 1227 | memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA)); |
| 1228 | |
| 1229 | ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id; |
| 1230 | ExtraFolderData[next_folder_id]->m_nIconId = IDI_YEAR; |
| 1231 | ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId; |
| 1232 | ExtraFolderData[next_folder_id]->m_nSubIconId = -1; |
| 1233 | strcpy( ExtraFolderData[next_folder_id]->m_szTitle, s ); |
| 1234 | ExtraFolderData[next_folder_id++]->m_dwFlags = 0; |
| 1235 | AddFolder(lpTemp); |
| 1236 | AddGame(lpTemp,jj); |
| 1237 | } |
| 1238 | } |
| 1239 | } |
| 1240 | |
| 1241 | // creates child folders of all the top level folders, including custom ones |
| 1242 | void CreateAllChildFolders(void) |
| 1243 | { |
| 1244 | int num_top_level_folders = numFolders; |
| 1245 | int i, j; |
| 1246 | |
| 1247 | for (i = 0; i < num_top_level_folders; i++) |
| 1248 | { |
| 1249 | LPTREEFOLDER lpFolder = treeFolders[i]; |
| 1250 | LPFOLDERDATA lpFolderData = NULL; |
| 1251 | |
| 1252 | for (j = 0; g_lpFolderData[j].m_lpTitle; j++) |
| 1253 | { |
| 1254 | if (g_lpFolderData[j].m_nFolderId == lpFolder->m_nFolderId) |
| 1255 | { |
| 1256 | lpFolderData = &g_lpFolderData[j]; |
| 1257 | break; |
| 1258 | } |
| 1259 | } |
| 1260 | |
| 1261 | if (lpFolderData != NULL) |
| 1262 | { |
| 1263 | //dprintf("Found built-in-folder id %i %i",i,lpFolder->m_nFolderId); |
| 1264 | if (lpFolderData->m_pfnCreateFolders != NULL) |
| 1265 | lpFolderData->m_pfnCreateFolders(i); |
| 1266 | } |
| 1267 | else |
| 1268 | { |
| 1269 | if ((lpFolder->m_dwFlags & F_CUSTOM) == 0) |
| 1270 | { |
| 1271 | dprintf("Internal inconsistency with non-built-in folder, but not custom"); |
| 1272 | continue; |
| 1273 | } |
| 1274 | |
| 1275 | //dprintf("Loading custom folder %i %i",i,lpFolder->m_nFolderId); |
| 1276 | |
| 1277 | // load the extra folder files, which also adds children |
| 1278 | if (TryAddExtraFolderAndChildren(i) == FALSE) |
| 1279 | { |
| 1280 | lpFolder->m_nFolderId = FOLDER_NONE; |
| 1281 | } |
| 1282 | } |
| 1283 | } |
| 1284 | } |
| 1285 | |
| 1286 | // adds these folders to the treeview |
| 1287 | void ResetTreeViewFolders(void) |
| 1288 | { |
| 1289 | HWND hTreeView = GetTreeView(); |
| 1290 | int i; |
| 1291 | TVITEM tvi; |
| 1292 | TVINSERTSTRUCT tvs; |
| 1293 | |
| 1294 | HTREEITEM shti; // for current child branches |
| 1295 | |
| 1296 | // currently "cached" parent |
| 1297 | HTREEITEM hti_parent = NULL; |
| 1298 | int index_parent = -1; |
| 1299 | |
| 1300 | TreeView_DeleteAllItems(hTreeView); |
| 1301 | |
| 1302 | //dprintf("Adding folders to tree ui indices %i to %i",start_index,end_index); |
| 1303 | |
| 1304 | tvs.hInsertAfter = TVI_SORT; |
| 1305 | |
| 1306 | for (i=0;i<numFolders;i++) |
| 1307 | { |
| 1308 | LPTREEFOLDER lpFolder = treeFolders[i]; |
| 1309 | |
| 1310 | if (lpFolder->m_nParent == -1) |
| 1311 | { |
| 1312 | if (lpFolder->m_nFolderId < MAX_FOLDERS) |
| 1313 | { |
| 1314 | // it's a built in folder, let's see if we should show it |
| 1315 | if (GetShowFolder(lpFolder->m_nFolderId) == FALSE) |
| 1316 | { |
| 1317 | continue; |
| 1318 | } |
| 1319 | } |
| 1320 | |
| 1321 | tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; |
| 1322 | tvs.hParent = TVI_ROOT; |
| 1323 | tvi.pszText = lpFolder->m_lptTitle; |
| 1324 | tvi.lParam = (LPARAM)lpFolder; |
| 1325 | tvi.iImage = GetTreeViewIconIndex(lpFolder->m_nIconId); |
| 1326 | tvi.iSelectedImage = 0; |
| 1327 | |
| 1328 | #if defined(__GNUC__) /* bug in commctrl.h */ |
| 1329 | tvs.item = tvi; |
| 1330 | #else |
| 1331 | tvs.item = tvi; |
| 1332 | #endif |
| 1333 | |
| 1334 | // Add root branch |
| 1335 | hti_parent = TreeView_InsertItem(hTreeView, &tvs); |
| 1336 | |
| 1337 | continue; |
| 1338 | } |
| 1339 | |
| 1340 | // not a top level branch, so look for parent |
| 1341 | if (treeFolders[i]->m_nParent != index_parent) |
| 1342 | { |
| 1343 | |
| 1344 | hti_parent = TreeView_GetRoot(hTreeView); |
| 1345 | while (1) |
| 1346 | { |
| 1347 | if (hti_parent == NULL) |
| 1348 | { |
| 1349 | // couldn't find parent folder, so it's a built-in but |
| 1350 | // not shown folder |
| 1351 | break; |
| 1352 | } |
| 1353 | |
| 1354 | tvi.hItem = hti_parent; |
| 1355 | tvi.mask = TVIF_PARAM; |
| 1356 | TreeView_GetItem(hTreeView,&tvi); |
| 1357 | if (((LPTREEFOLDER)tvi.lParam) == treeFolders[treeFolders[i]->m_nParent]) |
| 1358 | break; |
| 1359 | |
| 1360 | hti_parent = TreeView_GetNextSibling(hTreeView,hti_parent); |
| 1361 | } |
| 1362 | |
| 1363 | // if parent is not shown, then don't show the child either obviously! |
| 1364 | if (hti_parent == NULL) |
| 1365 | continue; |
| 1366 | |
| 1367 | index_parent = treeFolders[i]->m_nParent; |
| 1368 | } |
| 1369 | |
| 1370 | tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; |
| 1371 | tvs.hParent = hti_parent; |
| 1372 | tvi.iImage = GetTreeViewIconIndex(treeFolders[i]->m_nIconId); |
| 1373 | tvi.iSelectedImage = 0; |
| 1374 | tvi.pszText = treeFolders[i]->m_lptTitle; |
| 1375 | tvi.lParam = (LPARAM)treeFolders[i]; |
| 1376 | |
| 1377 | #if defined(__GNUC__) /* bug in commctrl.h */ |
| 1378 | tvs.item = tvi; |
| 1379 | #else |
| 1380 | tvs.item = tvi; |
| 1381 | #endif |
| 1382 | // Add it to this tree branch |
| 1383 | shti = TreeView_InsertItem(hTreeView, &tvs); |
| 1384 | |
| 1385 | } |
| 1386 | } |
| 1387 | |
| 1388 | void SelectTreeViewFolder(int folder_id) |
| 1389 | { |
| 1390 | HWND hTreeView = GetTreeView(); |
| 1391 | HTREEITEM hti; |
| 1392 | TVITEM tvi; |
| 1393 | |
| 1394 | memset(&tvi,0,sizeof(tvi)); |
| 1395 | |
| 1396 | hti = TreeView_GetRoot(hTreeView); |
| 1397 | |
| 1398 | while (hti != NULL) |
| 1399 | { |
| 1400 | HTREEITEM hti_next; |
| 1401 | |
| 1402 | tvi.hItem = hti; |
| 1403 | tvi.mask = TVIF_PARAM; |
| 1404 | TreeView_GetItem(hTreeView,&tvi); |
| 1405 | |
| 1406 | if (((LPTREEFOLDER)tvi.lParam)->m_nFolderId == folder_id) |
| 1407 | { |
| 1408 | TreeView_SelectItem(hTreeView,tvi.hItem); |
| 1409 | SetCurrentFolder((LPTREEFOLDER)tvi.lParam); |
| 1410 | return; |
| 1411 | } |
| 1412 | |
| 1413 | hti_next = TreeView_GetChild(hTreeView,hti); |
| 1414 | if (hti_next == NULL) |
| 1415 | { |
| 1416 | hti_next = TreeView_GetNextSibling(hTreeView,hti); |
| 1417 | if (hti_next == NULL) |
| 1418 | { |
| 1419 | hti_next = TreeView_GetParent(hTreeView,hti); |
| 1420 | if (hti_next != NULL) |
| 1421 | hti_next = TreeView_GetNextSibling(hTreeView,hti_next); |
| 1422 | } |
| 1423 | } |
| 1424 | hti = hti_next; |
| 1425 | } |
| 1426 | |
| 1427 | // could not find folder to select |
| 1428 | // make sure we select something |
| 1429 | tvi.hItem = TreeView_GetRoot(hTreeView); |
| 1430 | tvi.mask = TVIF_PARAM; |
| 1431 | TreeView_GetItem(hTreeView,&tvi); |
| 1432 | |
| 1433 | TreeView_SelectItem(hTreeView,tvi.hItem); |
| 1434 | SetCurrentFolder((LPTREEFOLDER)tvi.lParam); |
| 1435 | |
| 1436 | } |
| 1437 | |
| 1438 | /* |
| 1439 | * Does this folder have an INI associated with it? |
| 1440 | * Currently only TRUE for FOLDER_VECTOR and children |
| 1441 | * of FOLDER_SOURCE. |
| 1442 | */ |
| 1443 | static BOOL FolderHasIni(LPTREEFOLDER lpFolder) { |
| 1444 | if (FOLDER_VECTOR == lpFolder->m_nFolderId) { |
| 1445 | return TRUE; |
| 1446 | } |
| 1447 | if (lpFolder->m_nParent != -1 |
| 1448 | && FOLDER_SOURCE == treeFolders[lpFolder->m_nParent]->m_nFolderId) { |
| 1449 | return TRUE; |
| 1450 | } |
| 1451 | return FALSE; |
| 1452 | } |
| 1453 | |
| 1454 | /* Add a folder to the list. Does not allocate */ |
| 1455 | static BOOL AddFolder(LPTREEFOLDER lpFolder) |
| 1456 | { |
| 1457 | if (numFolders + 1 >= folderArrayLength) |
| 1458 | { |
| 1459 | folderArrayLength += 500; |
| 1460 | treeFolders = realloc(treeFolders,sizeof(TREEFOLDER **) * folderArrayLength); |
| 1461 | } |
| 1462 | |
| 1463 | /* Is there an folder.ini that can be edited? */ |
| 1464 | if (FolderHasIni(lpFolder)) { |
| 1465 | lpFolder->m_dwFlags |= F_INIEDIT; |
| 1466 | } |
| 1467 | |
| 1468 | treeFolders[numFolders] = lpFolder; |
| 1469 | numFolders++; |
| 1470 | |
| 1471 | return TRUE; |
| 1472 | } |
| 1473 | |
| 1474 | /* Allocate and initialize a NEW TREEFOLDER */ |
| 1475 | static LPTREEFOLDER NewFolder(const char *lpTitle, |
| 1476 | UINT nFolderId, int nParent, UINT nIconId, DWORD dwFlags) |
| 1477 | { |
| 1478 | LPTREEFOLDER lpFolder = (LPTREEFOLDER)malloc(sizeof(TREEFOLDER)); |
| 1479 | |
| 1480 | memset(lpFolder, '\0', sizeof (TREEFOLDER)); |
| 1481 | lpFolder->m_lpTitle = (LPSTR)malloc(strlen(lpTitle) + 1); |
| 1482 | strcpy((char *)lpFolder->m_lpTitle,lpTitle); |
| 1483 | lpFolder->m_lptTitle = tstring_from_utf8(lpFolder->m_lpTitle); |
| 1484 | lpFolder->m_lpGameBits = NewBits(driver_list_get_count(drivers)); |
| 1485 | lpFolder->m_nFolderId = nFolderId; |
| 1486 | lpFolder->m_nParent = nParent; |
| 1487 | lpFolder->m_nIconId = nIconId; |
| 1488 | lpFolder->m_dwFlags = dwFlags; |
| 1489 | |
| 1490 | return lpFolder; |
| 1491 | } |
| 1492 | |
| 1493 | /* Deallocate the passed in LPTREEFOLDER */ |
| 1494 | static void DeleteFolder(LPTREEFOLDER lpFolder) |
| 1495 | { |
| 1496 | if (lpFolder) |
| 1497 | { |
| 1498 | if (lpFolder->m_lpGameBits) |
| 1499 | { |
| 1500 | DeleteBits(lpFolder->m_lpGameBits); |
| 1501 | lpFolder->m_lpGameBits = 0; |
| 1502 | } |
| 1503 | free(lpFolder->m_lptTitle); |
| 1504 | lpFolder->m_lptTitle = 0; |
| 1505 | free(lpFolder->m_lpTitle); |
| 1506 | lpFolder->m_lpTitle = 0; |
| 1507 | free(lpFolder); |
| 1508 | lpFolder = 0; |
| 1509 | } |
| 1510 | } |
| 1511 | |
| 1512 | /* Can be called to re-initialize the array of treeFolders */ |
| 1513 | BOOL InitFolders(void) |
| 1514 | { |
| 1515 | int i = 0; |
| 1516 | DWORD dwFolderFlags; |
| 1517 | LPFOLDERDATA fData = 0; |
| 1518 | |
| 1519 | if (treeFolders != NULL) |
| 1520 | { |
| 1521 | for (i = numFolders - 1; i >= 0; i--) |
| 1522 | { |
| 1523 | DeleteFolder(treeFolders[i]); |
| 1524 | treeFolders[i] = 0; |
| 1525 | numFolders--; |
| 1526 | } |
| 1527 | } |
| 1528 | numFolders = 0; |
| 1529 | if (folderArrayLength == 0) |
| 1530 | { |
| 1531 | folderArrayLength = 200; |
| 1532 | treeFolders = (TREEFOLDER **)malloc(sizeof(TREEFOLDER **) * folderArrayLength); |
| 1533 | if (!treeFolders) |
| 1534 | { |
| 1535 | folderArrayLength = 0; |
| 1536 | return 0; |
| 1537 | } |
| 1538 | else |
| 1539 | { |
| 1540 | memset(treeFolders,'\0', sizeof(TREEFOLDER **) * folderArrayLength); |
| 1541 | } |
| 1542 | } |
| 1543 | // built-in top level folders |
| 1544 | for (i = 0; g_lpFolderData[i].m_lpTitle; i++) |
| 1545 | { |
| 1546 | fData = &g_lpFolderData[i]; |
| 1547 | /* get the saved folder flags */ |
| 1548 | dwFolderFlags = GetFolderFlags(numFolders); |
| 1549 | /* create the folder */ |
| 1550 | AddFolder(NewFolder(fData->m_lpTitle, fData->m_nFolderId, -1, |
| 1551 | fData->m_nIconId, dwFolderFlags)); |
| 1552 | } |
| 1553 | |
| 1554 | numExtraFolders = InitExtraFolders(); |
| 1555 | |
| 1556 | for (i = 0; i < numExtraFolders; i++) |
| 1557 | { |
| 1558 | LPEXFOLDERDATA fExData = ExtraFolderData[i]; |
| 1559 | |
| 1560 | // OR in the saved folder flags |
| 1561 | dwFolderFlags = fExData->m_dwFlags | GetFolderFlags(numFolders); |
| 1562 | // create the folder |
| 1563 | //dprintf("creating top level custom folder with icon %i",fExData->m_nIconId); |
| 1564 | AddFolder(NewFolder(fExData->m_szTitle,fExData->m_nFolderId,fExData->m_nParent, |
| 1565 | fExData->m_nIconId,dwFolderFlags)); |
| 1566 | } |
| 1567 | |
| 1568 | CreateAllChildFolders(); |
| 1569 | |
| 1570 | CreateTreeIcons(); |
| 1571 | |
| 1572 | ResetWhichGamesInFolders(); |
| 1573 | |
| 1574 | ResetTreeViewFolders(); |
| 1575 | |
| 1576 | SelectTreeViewFolder(GetSavedFolderID()); |
| 1577 | |
| 1578 | LoadFolderFlags(); |
| 1579 | |
| 1580 | return TRUE; |
| 1581 | } |
| 1582 | |
| 1583 | // create iconlist and Treeview control |
| 1584 | static BOOL CreateTreeIcons() |
| 1585 | { |
| 1586 | HICON hIcon; |
| 1587 | INT i; |
| 1588 | HINSTANCE hInst = GetModuleHandle(0); |
| 1589 | |
| 1590 | int numIcons = ICON_MAX + numExtraIcons; |
| 1591 | |
| 1592 | hTreeSmall = ImageList_Create (16, 16, ILC_COLORDDB | ILC_MASK, numIcons, numIcons); |
| 1593 | |
| 1594 | //dprintf("Trying to load %i normal icons",ICON_MAX); |
| 1595 | for (i = 0; i < ICON_MAX; i++) |
| 1596 | { |
| 1597 | hIcon = LoadIconFromFile(treeIconNames[i].lpName); |
| 1598 | if (!hIcon) |
| 1599 | hIcon = LoadIcon(hInst, MAKEINTRESOURCE(treeIconNames[i].nResourceID)); |
| 1600 | |
| 1601 | if (ImageList_AddIcon (hTreeSmall, hIcon) == -1) |
| 1602 | { |
| 1603 | ErrorMsg("Error creating icon on regular folder, %i %i",i,hIcon != NULL); |
| 1604 | return FALSE; |
| 1605 | } |
| 1606 | } |
| 1607 | |
| 1608 | //dprintf("Trying to load %i extra custom-folder icons",numExtraIcons); |
| 1609 | for (i = 0; i < numExtraIcons; i++) |
| 1610 | { |
| 1611 | if ((hIcon = LoadIconFromFile(ExtraFolderIcons[i])) == 0) |
| 1612 | hIcon = LoadIcon (hInst, MAKEINTRESOURCE(IDI_FOLDER)); |
| 1613 | |
| 1614 | if (ImageList_AddIcon(hTreeSmall, hIcon) == -1) |
| 1615 | { |
| 1616 | ErrorMsg("Error creating icon on extra folder, %i %i",i,hIcon != NULL); |
| 1617 | return FALSE; |
| 1618 | } |
| 1619 | } |
| 1620 | |
| 1621 | // Be sure that all the small icons were added. |
| 1622 | if (ImageList_GetImageCount(hTreeSmall) < numIcons) |
| 1623 | { |
| 1624 | ErrorMsg("Error with icon list--too few images. %i %i", |
| 1625 | ImageList_GetImageCount(hTreeSmall),numIcons); |
| 1626 | return FALSE; |
| 1627 | } |
| 1628 | |
| 1629 | // Be sure that all the small icons were added. |
| 1630 | |
| 1631 | if (ImageList_GetImageCount (hTreeSmall) < ICON_MAX) |
| 1632 | { |
| 1633 | ErrorMsg("Error with icon list--too few images. %i < %i", |
| 1634 | ImageList_GetImageCount(hTreeSmall),ICON_MAX); |
| 1635 | return FALSE; |
| 1636 | } |
| 1637 | |
| 1638 | // Associate the image lists with the list view control. |
| 1639 | (void)TreeView_SetImageList(GetTreeView(), hTreeSmall, TVSIL_NORMAL); |
| 1640 | |
| 1641 | return TRUE; |
| 1642 | } |
| 1643 | |
| 1644 | |
| 1645 | static void TreeCtrlOnPaint(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 1646 | { |
| 1647 | PAINTSTRUCT ps; |
| 1648 | HDC hDC; |
| 1649 | RECT rcClip, rcClient; |
| 1650 | HDC memDC; |
| 1651 | HBITMAP bitmap; |
| 1652 | HBITMAP hOldBitmap; |
| 1653 | |
| 1654 | HBITMAP hBackground = GetBackgroundBitmap(); |
| 1655 | MYBITMAPINFO *bmDesc = GetBackgroundInfo(); |
| 1656 | |
| 1657 | hDC = BeginPaint(hWnd, &ps); |
| 1658 | |
| 1659 | GetClipBox(hDC, &rcClip); |
| 1660 | GetClientRect(hWnd, &rcClient); |
| 1661 | |
| 1662 | // Create a compatible memory DC |
| 1663 | memDC = CreateCompatibleDC(hDC); |
| 1664 | |
| 1665 | // Select a compatible bitmap into the memory DC |
| 1666 | bitmap = CreateCompatibleBitmap(hDC, rcClient.right - rcClient.left, |
| 1667 | rcClient.bottom - rcClient.top); |
| 1668 | hOldBitmap = SelectObject(memDC, bitmap); |
| 1669 | |
| 1670 | // First let the control do its default drawing. |
| 1671 | CallWindowProc(g_lpTreeWndProc, hWnd, uMsg, (WPARAM)memDC, 0); |
| 1672 | |
| 1673 | // Draw bitmap in the background |
| 1674 | |
| 1675 | { |
| 1676 | HPALETTE hPAL; |
| 1677 | HDC maskDC; |
| 1678 | HBITMAP maskBitmap; |
| 1679 | HDC tempDC; |
| 1680 | HDC imageDC; |
| 1681 | HBITMAP bmpImage; |
| 1682 | HBITMAP hOldBmpImage; |
| 1683 | HBITMAP hOldMaskBitmap; |
| 1684 | HBITMAP hOldHBitmap; |
| 1685 | int i, j; |
| 1686 | RECT rcRoot; |
| 1687 | |
| 1688 | // Now create a mask |
| 1689 | maskDC = CreateCompatibleDC(hDC); |
| 1690 | |
| 1691 | // Create monochrome bitmap for the mask |
| 1692 | maskBitmap = CreateBitmap(rcClient.right - rcClient.left, |
| 1693 | rcClient.bottom - rcClient.top, |
| 1694 | 1, 1, NULL); |
| 1695 | |
| 1696 | hOldMaskBitmap = SelectObject(maskDC, maskBitmap); |
| 1697 | SetBkColor(memDC, GetSysColor(COLOR_WINDOW)); |
| 1698 | |
| 1699 | // Create the mask from the memory DC |
| 1700 | BitBlt(maskDC, 0, 0, rcClient.right - rcClient.left, |
| 1701 | rcClient.bottom - rcClient.top, memDC, |
| 1702 | rcClient.left, rcClient.top, SRCCOPY); |
| 1703 | |
| 1704 | tempDC = CreateCompatibleDC(hDC); |
| 1705 | hOldHBitmap = SelectObject(tempDC, hBackground); |
| 1706 | |
| 1707 | imageDC = CreateCompatibleDC(hDC); |
| 1708 | bmpImage = CreateCompatibleBitmap(hDC, |
| 1709 | rcClient.right - rcClient.left, |
| 1710 | rcClient.bottom - rcClient.top); |
| 1711 | hOldBmpImage = SelectObject(imageDC, bmpImage); |
| 1712 | |
| 1713 | hPAL = GetBackgroundPalette(); |
| 1714 | if (hPAL == NULL) |
| 1715 | hPAL = CreateHalftonePalette(hDC); |
| 1716 | |
| 1717 | if (GetDeviceCaps(hDC, RASTERCAPS) & RC_PALETTE && hPAL != NULL) |
| 1718 | { |
| 1719 | SelectPalette(hDC, hPAL, FALSE); |
| 1720 | RealizePalette(hDC); |
| 1721 | SelectPalette(imageDC, hPAL, FALSE); |
| 1722 | } |
| 1723 | |
| 1724 | // Get x and y offset |
| 1725 | TreeView_GetItemRect(hWnd, TreeView_GetRoot(hWnd), &rcRoot, FALSE); |
| 1726 | rcRoot.left = -GetScrollPos(hWnd, SB_HORZ); |
| 1727 | |
| 1728 | // Draw bitmap in tiled manner to imageDC |
| 1729 | for (i = rcRoot.left; i < rcClient.right; i += bmDesc->bmWidth) |
| 1730 | for (j = rcRoot.top; j < rcClient.bottom; j += bmDesc->bmHeight) |
| 1731 | BitBlt(imageDC, i, j, bmDesc->bmWidth, bmDesc->bmHeight, |
| 1732 | tempDC, 0, 0, SRCCOPY); |
| 1733 | |
| 1734 | // Set the background in memDC to black. Using SRCPAINT with black and any other |
| 1735 | // color results in the other color, thus making black the transparent color |
| 1736 | SetBkColor(memDC, RGB(0,0,0)); |
| 1737 | SetTextColor(memDC, RGB(255,255,255)); |
| 1738 | BitBlt(memDC, rcClip.left, rcClip.top, rcClip.right - rcClip.left, |
| 1739 | rcClip.bottom - rcClip.top, |
| 1740 | maskDC, rcClip.left, rcClip.top, SRCAND); |
| 1741 | |
| 1742 | // Set the foreground to black. See comment above. |
| 1743 | SetBkColor(imageDC, RGB(255,255,255)); |
| 1744 | SetTextColor(imageDC, RGB(0,0,0)); |
| 1745 | BitBlt(imageDC, rcClip.left, rcClip.top, rcClip.right - rcClip.left, |
| 1746 | rcClip.bottom - rcClip.top, |
| 1747 | maskDC, rcClip.left, rcClip.top, SRCAND); |
| 1748 | |
| 1749 | // Combine the foreground with the background |
| 1750 | BitBlt(imageDC, rcClip.left, rcClip.top, rcClip.right - rcClip.left, |
| 1751 | rcClip.bottom - rcClip.top, |
| 1752 | memDC, rcClip.left, rcClip.top, SRCPAINT); |
| 1753 | |
| 1754 | // Draw the final image to the screen |
| 1755 | BitBlt(hDC, rcClip.left, rcClip.top, rcClip.right - rcClip.left, |
| 1756 | rcClip.bottom - rcClip.top, |
| 1757 | imageDC, rcClip.left, rcClip.top, SRCCOPY); |
| 1758 | |
| 1759 | SelectObject(maskDC, hOldMaskBitmap); |
| 1760 | SelectObject(tempDC, hOldHBitmap); |
| 1761 | SelectObject(imageDC, hOldBmpImage); |
| 1762 | |
| 1763 | DeleteDC(maskDC); |
| 1764 | DeleteDC(imageDC); |
| 1765 | DeleteDC(tempDC); |
| 1766 | DeleteObject(bmpImage); |
| 1767 | DeleteObject(maskBitmap); |
| 1768 | |
| 1769 | if (GetBackgroundPalette() == NULL) |
| 1770 | { |
| 1771 | DeleteObject(hPAL); |
| 1772 | hPAL = 0; |
| 1773 | } |
| 1774 | } |
| 1775 | |
| 1776 | SelectObject(memDC, hOldBitmap); |
| 1777 | DeleteObject(bitmap); |
| 1778 | DeleteDC(memDC); |
| 1779 | EndPaint(hWnd, &ps); |
| 1780 | ReleaseDC(hWnd, hDC); |
| 1781 | } |
| 1782 | |
| 1783 | /* Header code - Directional Arrows */ |
| 1784 | static LRESULT CALLBACK TreeWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 1785 | { |
| 1786 | if (GetBackgroundBitmap() != NULL) |
| 1787 | { |
| 1788 | switch (uMsg) |
| 1789 | { |
| 1790 | case WM_MOUSEMOVE: |
| 1791 | { |
| 1792 | if (MouseHasBeenMoved()) |
| 1793 | ShowCursor(TRUE); |
| 1794 | break; |
| 1795 | } |
| 1796 | |
| 1797 | case WM_KEYDOWN : |
| 1798 | if (wParam == VK_F2) |
| 1799 | { |
| 1800 | if (lpCurrentFolder->m_dwFlags & F_CUSTOM) |
| 1801 | { |
| 1802 | TreeView_EditLabel(hWnd,TreeView_GetSelection(hWnd)); |
| 1803 | return TRUE; |
| 1804 | } |
| 1805 | } |
| 1806 | break; |
| 1807 | |
| 1808 | case WM_ERASEBKGND: |
| 1809 | return TRUE; |
| 1810 | break; |
| 1811 | |
| 1812 | case WM_PAINT: |
| 1813 | TreeCtrlOnPaint(hWnd, uMsg, wParam, lParam); |
| 1814 | UpdateWindow(hWnd); |
| 1815 | break; |
| 1816 | } |
| 1817 | } |
| 1818 | |
| 1819 | /* message not handled */ |
| 1820 | return CallWindowProc(g_lpTreeWndProc, hWnd, uMsg, wParam, lParam); |
| 1821 | } |
| 1822 | |
| 1823 | /* |
| 1824 | * Filter code - should be moved to filter.c/filter.h |
| 1825 | * Added 01/09/99 - MSH <mhaaland@hypertech.com> |
| 1826 | */ |
| 1827 | |
| 1828 | /* find a FOLDERDATA by folderID */ |
| 1829 | LPFOLDERDATA FindFilter(DWORD folderID) |
| 1830 | { |
| 1831 | int i; |
| 1832 | |
| 1833 | for (i = 0; g_lpFolderData[i].m_lpTitle; i++) |
| 1834 | { |
| 1835 | if (g_lpFolderData[i].m_nFolderId == folderID) |
| 1836 | return &g_lpFolderData[i]; |
| 1837 | } |
| 1838 | return (LPFOLDERDATA) 0; |
| 1839 | } |
| 1840 | |
| 1841 | /*************************************************************************** |
| 1842 | private structures |
| 1843 | ***************************************************************************/ |
| 1844 | |
| 1845 | /*************************************************************************** |
| 1846 | private functions prototypes |
| 1847 | ***************************************************************************/ |
| 1848 | |
| 1849 | /*************************************************************************** |
| 1850 | private functions |
| 1851 | ***************************************************************************/ |
| 1852 | |
| 1853 | /**************************************************************************/ |
| 1854 | |
| 1855 | LPTREEFOLDER GetFolderByName(int nParentId, const char *pszFolderName) |
| 1856 | { |
| 1857 | int i = 0, nParent; |
| 1858 | |
| 1859 | //First Get the Parent TreeviewItem |
| 1860 | //Enumerate Children |
| 1861 | for(i = 0; i < numFolders/* ||treeFolders[i] != NULL*/; i++) |
| 1862 | { |
| 1863 | if (!strcmp(treeFolders[i]->m_lpTitle, pszFolderName)) |
| 1864 | { |
| 1865 | nParent = treeFolders[i]->m_nParent; |
| 1866 | if ((nParent >= 0) && treeFolders[nParent]->m_nFolderId == nParentId) |
| 1867 | return treeFolders[i]; |
| 1868 | } |
| 1869 | } |
| 1870 | return NULL; |
| 1871 | } |
| 1872 | |
| 1873 | static int InitExtraFolders(void) |
| 1874 | { |
| 1875 | struct stat stat_buffer; |
| 1876 | struct _finddata_t files; |
| 1877 | int i, count = 0; |
| 1878 | long hLong; |
| 1879 | char* ext; |
| 1880 | char buf[256]; |
| 1881 | char curdir[MAX_PATH]; |
| 1882 | const char* dir = GetFolderDir(); |
| 1883 | |
| 1884 | memset(ExtraFolderData, 0, (MAX_EXTRA_FOLDERS * MAX_EXTRA_SUBFOLDERS)* sizeof(LPEXFOLDERDATA)); |
| 1885 | |
| 1886 | /* NPW 9-Feb-2003 - MSVC stat() doesn't like stat() called with an empty |
| 1887 | * string |
| 1888 | */ |
| 1889 | if (dir[0] == '\0') |
| 1890 | dir = "."; |
| 1891 | |
| 1892 | // Why create the directory if it doesn't exist, just return 0 folders. |
| 1893 | if (stat(dir, &stat_buffer) != 0) |
| 1894 | { |
| 1895 | return 0; // _mkdir(dir); |
| 1896 | } |
| 1897 | |
| 1898 | _getcwd(curdir, MAX_PATH); |
| 1899 | |
| 1900 | _chdir(dir); |
| 1901 | |
| 1902 | hLong = _findfirst("*", &files); |
| 1903 | |
| 1904 | for (i = 0; i < MAX_EXTRA_FOLDERS; i++) |
| 1905 | { |
| 1906 | ExtraFolderIcons[i] = NULL; |
| 1907 | } |
| 1908 | |
| 1909 | numExtraIcons = 0; |
| 1910 | |
| 1911 | while (!_findnext(hLong, &files)) |
| 1912 | { |
| 1913 | if ((files.attrib & _A_SUBDIR) == 0) |
| 1914 | { |
| 1915 | FILE *fp; |
| 1916 | |
| 1917 | fp = fopen(files.name, "r"); |
| 1918 | if (fp != NULL) |
| 1919 | { |
| 1920 | int icon[2] = { 0, 0 }; |
| 1921 | char *p, *name; |
| 1922 | |
| 1923 | while (fgets(buf, 256, fp)) |
| 1924 | { |
| 1925 | if (buf[0] == '[') |
| 1926 | { |
| 1927 | p = strchr(buf, ']'); |
| 1928 | if (p == NULL) |
| 1929 | continue; |
| 1930 | |
| 1931 | *p = '\0'; |
| 1932 | name = &buf[1]; |
| 1933 | if (!strcmp(name, "FOLDER_SETTINGS")) |
| 1934 | { |
| 1935 | while (fgets(buf, 256, fp)) |
| 1936 | { |
| 1937 | name = strtok(buf, " =\r\n"); |
| 1938 | if (name == NULL) |
| 1939 | break; |
| 1940 | |
| 1941 | if (!strcmp(name, "RootFolderIcon")) |
| 1942 | { |
| 1943 | name = strtok(NULL, " =\r\n"); |
| 1944 | if (name != NULL) |
| 1945 | SetExtraIcons(name, &icon[0]); |
| 1946 | } |
| 1947 | if (!strcmp(name, "SubFolderIcon")) |
| 1948 | { |
| 1949 | name = strtok(NULL, " =\r\n"); |
| 1950 | if (name != NULL) |
| 1951 | SetExtraIcons(name, &icon[1]); |
| 1952 | } |
| 1953 | } |
| 1954 | break; |
| 1955 | } |
| 1956 | } |
| 1957 | } |
| 1958 | fclose(fp); |
| 1959 | |
| 1960 | strcpy(buf, files.name); |
| 1961 | ext = strrchr(buf, '.'); |
| 1962 | |
| 1963 | if (ext && *(ext + 1) && !mame_stricmp(ext + 1, "ini")) |
| 1964 | { |
| 1965 | ExtraFolderData[count] = malloc(sizeof(EXFOLDERDATA)); |
| 1966 | if (ExtraFolderData[count]) |
| 1967 | { |
| 1968 | *ext = '\0'; |
| 1969 | |
| 1970 | memset(ExtraFolderData[count], 0, sizeof(EXFOLDERDATA)); |
| 1971 | |
| 1972 | strncpy(ExtraFolderData[count]->m_szTitle, buf, 63); |
| 1973 | ExtraFolderData[count]->m_nFolderId = next_folder_id++; |
| 1974 | ExtraFolderData[count]->m_nParent = -1; |
| 1975 | ExtraFolderData[count]->m_dwFlags = F_CUSTOM; |
| 1976 | ExtraFolderData[count]->m_nIconId = icon[0] ? -icon[0] : IDI_FOLDER; |
| 1977 | ExtraFolderData[count]->m_nSubIconId = icon[1] ? -icon[1] : IDI_FOLDER; |
| 1978 | //dprintf("extra folder with icon %i, subicon %i", |
| 1979 | //ExtraFolderData[count]->m_nIconId, |
| 1980 | //ExtraFolderData[count]->m_nSubIconId); |
| 1981 | count++; |
| 1982 | } |
| 1983 | } |
| 1984 | } |
| 1985 | } |
| 1986 | } |
| 1987 | |
| 1988 | _chdir(curdir); |
| 1989 | return count; |
| 1990 | } |
| 1991 | |
| 1992 | void FreeExtraFolders(void) |
| 1993 | { |
| 1994 | int i; |
| 1995 | |
| 1996 | for (i = 0; i < numExtraFolders; i++) |
| 1997 | { |
| 1998 | if (ExtraFolderData[i]) |
| 1999 | { |
| 2000 | free(ExtraFolderData[i]); |
| 2001 | ExtraFolderData[i] = NULL; |
| 2002 | } |
| 2003 | } |
| 2004 | |
| 2005 | for (i = 0; i < numExtraIcons; i++) |
| 2006 | { |
| 2007 | free(ExtraFolderIcons[i]); |
| 2008 | } |
| 2009 | |
| 2010 | numExtraIcons = 0; |
| 2011 | |
| 2012 | } |
| 2013 | |
| 2014 | |
| 2015 | static void SetExtraIcons(char *name, int *id) |
| 2016 | { |
| 2017 | char *p = strchr(name, '.'); |
| 2018 | |
| 2019 | if (p != NULL) |
| 2020 | *p = '\0'; |
| 2021 | |
| 2022 | ExtraFolderIcons[numExtraIcons] = malloc(strlen(name) + 1); |
| 2023 | if (ExtraFolderIcons[numExtraIcons]) |
| 2024 | { |
| 2025 | *id = ICON_MAX + numExtraIcons; |
| 2026 | strcpy(ExtraFolderIcons[numExtraIcons], name); |
| 2027 | numExtraIcons++; |
| 2028 | } |
| 2029 | } |
| 2030 | |
| 2031 | |
| 2032 | // Called to add child folders of the top level extra folders already created |
| 2033 | BOOL TryAddExtraFolderAndChildren(int parent_index) |
| 2034 | { |
| 2035 | FILE* fp = NULL; |
| 2036 | char fname[MAX_PATH]; |
| 2037 | char readbuf[256]; |
| 2038 | char* p; |
| 2039 | char* name; |
| 2040 | int id, current_id, i; |
| 2041 | LPTREEFOLDER lpTemp = NULL; |
| 2042 | LPTREEFOLDER lpFolder = treeFolders[parent_index]; |
| 2043 | |
| 2044 | current_id = lpFolder->m_nFolderId; |
| 2045 | |
| 2046 | id = lpFolder->m_nFolderId - MAX_FOLDERS; |
| 2047 | |
| 2048 | /* "folder\title.ini" */ |
| 2049 | |
| 2050 | sprintf( fname, "%s\\%s.ini", |
| 2051 | GetFolderDir(), |
| 2052 | ExtraFolderData[id]->m_szTitle); |
| 2053 | |
| 2054 | fp = fopen(fname, "r"); |
| 2055 | if (fp == NULL) |
| 2056 | return FALSE; |
| 2057 | |
| 2058 | while ( fgets(readbuf, 256, fp) ) |
| 2059 | { |
| 2060 | /* do we have [...] ? */ |
| 2061 | |
| 2062 | if (readbuf[0] == '[') |
| 2063 | { |
| 2064 | p = strchr(readbuf, ']'); |
| 2065 | if (p == NULL) |
| 2066 | { |
| 2067 | continue; |
| 2068 | } |
| 2069 | |
| 2070 | *p = '\0'; |
| 2071 | name = &readbuf[1]; |
| 2072 | |
| 2073 | /* is it [FOLDER_SETTINGS]? */ |
| 2074 | |
| 2075 | if (strcmp(name, "FOLDER_SETTINGS") == 0) |
| 2076 | { |
| 2077 | current_id = -1; |
| 2078 | continue; |
| 2079 | } |
| 2080 | else |
| 2081 | { |
| 2082 | /* it it [ROOT_FOLDER]? */ |
| 2083 | |
| 2084 | if (!strcmp(name, "ROOT_FOLDER")) |
| 2085 | { |
| 2086 | current_id = lpFolder->m_nFolderId; |
| 2087 | lpTemp = lpFolder; |
| 2088 | |
| 2089 | } |
| 2090 | else |
| 2091 | { |
| 2092 | /* must be [folder name] */ |
| 2093 | |
| 2094 | current_id = next_folder_id++; |
| 2095 | /* create a new folder with this name, |
| 2096 | and the flags for this folder as read from the registry */ |
| 2097 | lpTemp = NewFolder(name,current_id,parent_index, |
| 2098 | ExtraFolderData[id]->m_nSubIconId, |
| 2099 | GetFolderFlags(numFolders) | F_CUSTOM); |
| 2100 | ExtraFolderData[current_id] = malloc(sizeof(EXFOLDERDATA) ); |
| 2101 | memset(ExtraFolderData[current_id], 0, sizeof(EXFOLDERDATA)); |
| 2102 | |
| 2103 | ExtraFolderData[current_id]->m_nFolderId = current_id - MAX_EXTRA_FOLDERS; |
| 2104 | ExtraFolderData[current_id]->m_nIconId = ExtraFolderData[id]->m_nSubIconId; |
| 2105 | ExtraFolderData[current_id]->m_nParent = ExtraFolderData[id]->m_nFolderId; |
| 2106 | ExtraFolderData[current_id]->m_nSubIconId = -1; |
| 2107 | strcpy( ExtraFolderData[current_id]->m_szTitle, name ); |
| 2108 | ExtraFolderData[current_id]->m_dwFlags = ExtraFolderData[id]->m_dwFlags; |
| 2109 | AddFolder(lpTemp); |
| 2110 | } |
| 2111 | } |
| 2112 | } |
| 2113 | else if (current_id != -1) |
| 2114 | { |
| 2115 | /* string on a line by itself -- game name */ |
| 2116 | |
| 2117 | name = strtok(readbuf, " \t\r\n"); |
| 2118 | if (name == NULL) |
| 2119 | { |
| 2120 | current_id = -1; |
| 2121 | continue; |
| 2122 | } |
| 2123 | |
| 2124 | /* IMPORTANT: This assumes that all driver names are lowercase! */ |
| 2125 | for (i = 0; name[i]; i++) |
| 2126 | name[i] = tolower(name[i]); |
| 2127 | |
| 2128 | if (lpTemp == NULL) |
| 2129 | { |
| 2130 | ErrorMsg("Error parsing %s: missing [folder name] or [ROOT_FOLDER]", |
| 2131 | fname); |
| 2132 | current_id = lpFolder->m_nFolderId; |
| 2133 | lpTemp = lpFolder; |
| 2134 | } |
| 2135 | AddGame(lpTemp,GetGameNameIndex(name)); |
| 2136 | } |
| 2137 | } |
| 2138 | |
| 2139 | if ( fp ) |
| 2140 | { |
| 2141 | fclose( fp ); |
| 2142 | } |
| 2143 | |
| 2144 | return TRUE; |
| 2145 | } |
| 2146 | |
| 2147 | |
| 2148 | void GetFolders(TREEFOLDER ***folders,int *num_folders) |
| 2149 | { |
| 2150 | *folders = treeFolders; |
| 2151 | *num_folders = numFolders; |
| 2152 | } |
| 2153 | |
| 2154 | BOOL TryRenameCustomFolderIni(LPTREEFOLDER lpFolder,const char *old_name,const char *new_name) |
| 2155 | { |
| 2156 | char filename[MAX_PATH]; |
| 2157 | char new_filename[MAX_PATH]; |
| 2158 | LPTREEFOLDER lpParent = NULL; |
| 2159 | if (lpFolder->m_nParent >= 0) |
| 2160 | { |
| 2161 | //it is a custom SubFolder |
| 2162 | lpParent = GetFolder( lpFolder->m_nParent ); |
| 2163 | if( lpParent ) |
| 2164 | { |
| 2165 | snprintf(filename,ARRAY_LENGTH(filename),"%s\\%s\\%s.ini",GetIniDir(),lpParent->m_lpTitle, old_name ); |
| 2166 | snprintf(new_filename,ARRAY_LENGTH(new_filename),"%s\\%s\\%s.ini",GetIniDir(),lpParent->m_lpTitle, new_name ); |
| 2167 | win_move_file_utf8(filename,new_filename); |
| 2168 | } |
| 2169 | } |
| 2170 | else |
| 2171 | { |
| 2172 | //Rename the File, if it exists |
| 2173 | snprintf(filename,ARRAY_LENGTH(filename),"%s\\%s.ini",GetIniDir(),old_name ); |
| 2174 | snprintf(new_filename,ARRAY_LENGTH(new_filename),"%s\\%s.ini",GetIniDir(), new_name ); |
| 2175 | win_move_file_utf8(filename,new_filename); |
| 2176 | //Rename the Directory, if it exists |
| 2177 | snprintf(filename,ARRAY_LENGTH(filename),"%s\\%s",GetIniDir(),old_name ); |
| 2178 | snprintf(new_filename,ARRAY_LENGTH(new_filename),"%s\\%s",GetIniDir(), new_name ); |
| 2179 | win_move_file_utf8(filename,new_filename); |
| 2180 | } |
| 2181 | return TRUE; |
| 2182 | } |
| 2183 | |
| 2184 | BOOL TryRenameCustomFolder(LPTREEFOLDER lpFolder, const char *new_name) |
| 2185 | { |
| 2186 | BOOL retval; |
| 2187 | char filename[MAX_PATH]; |
| 2188 | char new_filename[MAX_PATH]; |
| 2189 | |
| 2190 | if (lpFolder->m_nParent >= 0) |
| 2191 | { |
| 2192 | // a child extra folder was renamed, so do the rename and save the parent |
| 2193 | |
| 2194 | // save old title |
| 2195 | char *old_title = lpFolder->m_lpTitle; |
| 2196 | |
| 2197 | // set new title |
| 2198 | lpFolder->m_lpTitle = (char *)malloc(strlen(new_name) + 1); |
| 2199 | strcpy(lpFolder->m_lpTitle,new_name); |
| 2200 | |
| 2201 | // try to save |
| 2202 | if (TrySaveExtraFolder(lpFolder) == FALSE) |
| 2203 | { |
| 2204 | // failed, so free newly allocated title and restore old |
| 2205 | free(lpFolder->m_lpTitle); |
| 2206 | lpFolder->m_lpTitle = old_title; |
| 2207 | return FALSE; |
| 2208 | } |
| 2209 | TryRenameCustomFolderIni(lpFolder, old_title, new_name); |
| 2210 | // successful, so free old title |
| 2211 | free(old_title); |
| 2212 | return TRUE; |
| 2213 | } |
| 2214 | |
| 2215 | // a parent extra folder was renamed, so rename the file |
| 2216 | |
| 2217 | snprintf(new_filename,ARRAY_LENGTH(new_filename),"%s\\%s.ini",GetFolderDir(),new_name); |
| 2218 | snprintf(filename,ARRAY_LENGTH(filename),"%s\\%s.ini",GetFolderDir(),lpFolder->m_lpTitle); |
| 2219 | |
| 2220 | retval = win_move_file_utf8(filename,new_filename); |
| 2221 | |
| 2222 | if (retval) |
| 2223 | { |
| 2224 | TryRenameCustomFolderIni(lpFolder, lpFolder->m_lpTitle, new_name); |
| 2225 | free(lpFolder->m_lpTitle); |
| 2226 | lpFolder->m_lpTitle = (char *)malloc(strlen(new_name) + 1); |
| 2227 | strcpy(lpFolder->m_lpTitle,new_name); |
| 2228 | } |
| 2229 | else |
| 2230 | { |
| 2231 | char buf[500]; |
| 2232 | snprintf(buf,ARRAY_LENGTH(buf),"Error while renaming custom file %s to %s", |
| 2233 | filename,new_filename); |
| 2234 | win_message_box_utf8(GetMainWindow(), buf, MAME32NAME, MB_OK | MB_ICONERROR); |
| 2235 | } |
| 2236 | return retval; |
| 2237 | } |
| 2238 | |
| 2239 | void AddToCustomFolder(LPTREEFOLDER lpFolder,int driver_index) |
| 2240 | { |
| 2241 | if ((lpFolder->m_dwFlags & F_CUSTOM) == 0) |
| 2242 | { |
| 2243 | win_message_box_utf8(GetMainWindow(),"Unable to add game to non-custom folder", |
| 2244 | MAME32NAME,MB_OK | MB_ICONERROR); |
| 2245 | return; |
| 2246 | } |
| 2247 | |
| 2248 | if (TestBit(lpFolder->m_lpGameBits,driver_index) == 0) |
| 2249 | { |
| 2250 | AddGame(lpFolder,driver_index); |
| 2251 | if (TrySaveExtraFolder(lpFolder) == FALSE) |
| 2252 | RemoveGame(lpFolder,driver_index); // undo on error |
| 2253 | } |
| 2254 | } |
| 2255 | |
| 2256 | void RemoveFromCustomFolder(LPTREEFOLDER lpFolder,int driver_index) |
| 2257 | { |
| 2258 | if ((lpFolder->m_dwFlags & F_CUSTOM) == 0) |
| 2259 | { |
| 2260 | win_message_box_utf8(GetMainWindow(),"Unable to remove game from non-custom folder", |
| 2261 | MAME32NAME,MB_OK | MB_ICONERROR); |
| 2262 | return; |
| 2263 | } |
| 2264 | |
| 2265 | if (TestBit(lpFolder->m_lpGameBits,driver_index) != 0) |
| 2266 | { |
| 2267 | RemoveGame(lpFolder,driver_index); |
| 2268 | if (TrySaveExtraFolder(lpFolder) == FALSE) |
| 2269 | AddGame(lpFolder,driver_index); // undo on error |
| 2270 | } |
| 2271 | } |
| 2272 | |
| 2273 | BOOL TrySaveExtraFolder(LPTREEFOLDER lpFolder) |
| 2274 | { |
| 2275 | char fname[MAX_PATH]; |
| 2276 | FILE *fp; |
| 2277 | BOOL error = FALSE; |
| 2278 | int i,j; |
| 2279 | |
| 2280 | LPTREEFOLDER root_folder = NULL; |
| 2281 | LPEXFOLDERDATA extra_folder = NULL; |
| 2282 | |
| 2283 | for (i=0;i<numExtraFolders;i++) |
| 2284 | { |
| 2285 | if (ExtraFolderData[i]->m_nFolderId == lpFolder->m_nFolderId) |
| 2286 | { |
| 2287 | root_folder = lpFolder; |
| 2288 | extra_folder = ExtraFolderData[i]; |
| 2289 | break; |
| 2290 | } |
| 2291 | |
| 2292 | if (lpFolder->m_nParent >= 0 && |
| 2293 | ExtraFolderData[i]->m_nFolderId == treeFolders[lpFolder->m_nParent]->m_nFolderId) |
| 2294 | { |
| 2295 | root_folder = treeFolders[lpFolder->m_nParent]; |
| 2296 | extra_folder = ExtraFolderData[i]; |
| 2297 | break; |
| 2298 | } |
| 2299 | } |
| 2300 | |
| 2301 | if (extra_folder == NULL || root_folder == NULL) |
| 2302 | { |
| 2303 | MessageBox(GetMainWindow(), TEXT("Error finding custom file name to save"), TEXT(MAME32NAME), MB_OK | MB_ICONERROR); |
| 2304 | return FALSE; |
| 2305 | } |
| 2306 | /* "folder\title.ini" */ |
| 2307 | |
| 2308 | snprintf( fname, sizeof(fname), "%s\\%s.ini", GetFolderDir(), extra_folder->m_szTitle); |
| 2309 | |
| 2310 | fp = fopen(fname, "wt"); |
| 2311 | if (fp == NULL) |
| 2312 | error = TRUE; |
| 2313 | else |
| 2314 | { |
| 2315 | TREEFOLDER *folder_data; |
| 2316 | |
| 2317 | |
| 2318 | fprintf(fp,"[FOLDER_SETTINGS]\n"); |
| 2319 | // negative values for icons means it's custom, so save 'em |
| 2320 | if (extra_folder->m_nIconId < 0) |
| 2321 | { |
| 2322 | fprintf(fp, "RootFolderIcon %s\n", |
| 2323 | ExtraFolderIcons[(-extra_folder->m_nIconId) - ICON_MAX]); |
| 2324 | } |
| 2325 | if (extra_folder->m_nSubIconId < 0) |
| 2326 | { |
| 2327 | fprintf(fp,"SubFolderIcon %s\n", |
| 2328 | ExtraFolderIcons[(-extra_folder->m_nSubIconId) - ICON_MAX]); |
| 2329 | } |
| 2330 | |
| 2331 | /* need to loop over all our TREEFOLDERs--first the root one, then each child. |
| 2332 | start with the root */ |
| 2333 | |
| 2334 | folder_data = root_folder; |
| 2335 | |
| 2336 | fprintf(fp,"\n[ROOT_FOLDER]\n"); |
| 2337 | |
| 2338 | for (i=0;i<driver_list_get_count(drivers);i++) |
| 2339 | { |
| 2340 | int driver_index = GetIndexFromSortedIndex(i); |
| 2341 | if (TestBit(folder_data->m_lpGameBits,driver_index)) |
| 2342 | { |
| 2343 | fprintf(fp,"%s\n",drivers[driver_index]->name); |
| 2344 | } |
| 2345 | } |
| 2346 | |
| 2347 | /* look through the custom folders for ones with our root as parent */ |
| 2348 | for (j=0;j<numFolders;j++) |
| 2349 | { |
| 2350 | folder_data = treeFolders[j]; |
| 2351 | |
| 2352 | if (folder_data->m_nParent >= 0 && |
| 2353 | treeFolders[folder_data->m_nParent] == root_folder) |
| 2354 | { |
| 2355 | fprintf(fp,"\n[%s]\n",folder_data->m_lpTitle); |
| 2356 | |
| 2357 | for (i=0;i<driver_list_get_count(drivers);i++) |
| 2358 | { |
| 2359 | int driver_index = GetIndexFromSortedIndex(i); |
| 2360 | if (TestBit(folder_data->m_lpGameBits,driver_index)) |
| 2361 | { |
| 2362 | fprintf(fp,"%s\n",drivers[driver_index]->name); |
| 2363 | } |
| 2364 | } |
| 2365 | } |
| 2366 | } |
| 2367 | if (fclose(fp) != 0) |
| 2368 | error = TRUE; |
| 2369 | } |
| 2370 | |
| 2371 | if (error) |
| 2372 | { |
| 2373 | char buf[500]; |
| 2374 | snprintf(buf,ARRAY_LENGTH(buf),"Error while saving custom file %s",fname); |
| 2375 | win_message_box_utf8(GetMainWindow(), buf, MAME32NAME, MB_OK | MB_ICONERROR); |
| 2376 | } |
| 2377 | return !error; |
| 2378 | } |
| 2379 | |
| 2380 | HIMAGELIST GetTreeViewIconList(void) |
| 2381 | { |
| 2382 | return hTreeSmall; |
| 2383 | } |
| 2384 | |
| 2385 | int GetTreeViewIconIndex(int icon_id) |
| 2386 | { |
| 2387 | int i; |
| 2388 | |
| 2389 | if (icon_id < 0) |
| 2390 | return -icon_id; |
| 2391 | |
| 2392 | for (i = 0; i < sizeof(treeIconNames) / sizeof(treeIconNames[0]); i++) |
| 2393 | { |
| 2394 | if (icon_id == treeIconNames[i].nResourceID) |
| 2395 | return i; |
| 2396 | } |
| 2397 | |
| 2398 | return -1; |
| 2399 | } |
| 2400 | |
| 2401 | /* End of source file */ |
src/osd/winui/properties.c
| r0 | r996 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | M.A.M.E.32 - Multiple Arcade Machine Emulator for Win32 |
| 4 | Win32 Portions Copyright (C) 1997-2003 Michael Soderstrom and Chris Kirmse |
| 5 | |
| 6 | This file is part of MAME32, and may only be used, modified and |
| 7 | distributed under the terms of the MAME license, in "readme.txt". |
| 8 | By continuing to use, modify or distribute this file you indicate |
| 9 | that you have read the license and understand and accept it fully. |
| 10 | |
| 11 | ***************************************************************************/ |
| 12 | |
| 13 | /*************************************************************************** |
| 14 | |
| 15 | Properties.c |
| 16 | |
| 17 | Properties Popup and Misc UI support routines. |
| 18 | |
| 19 | Created 8/29/98 by Mike Haaland (mhaaland@hypertech.com) |
| 20 | |
| 21 | ***************************************************************************/ |
| 22 | |
| 23 | /*************************************************************************** |
| 24 | |
| 25 | MSH - 20070809 |
| 26 | -- |
| 27 | Notes on properties and ini files, reset and reset to default. |
| 28 | ---------------------------------------------------------------------------- |
| 29 | Each ini contains a complete option set. |
| 30 | |
| 31 | Priority order for option sets (Lowest to Highest): |
| 32 | |
| 33 | built-in defaults |
| 34 | program ini (executable root filename ini) |
| 35 | debug ini (if running a debug build) |
| 36 | vector ini (really is vector.ini!) |
| 37 | driver ini (source code root filename in which this driver is found) |
| 38 | granparent ini (grandparent, not sure these exist, but it is possible) |
| 39 | parent ini (where parent is the name of the parent driver) |
| 40 | game ini (where game is the driver name for this game) |
| 41 | |
| 42 | To determine which option set to use, start at the top level (lowest |
| 43 | priority), and overlay all higher priority ini's until the desired level |
| 44 | is reached. |
| 45 | |
| 46 | The 'default' option set is the next priority higher up the list from |
| 47 | the desired level. For the default (program.ini) level, it is also the |
| 48 | default. |
| 49 | |
| 50 | When MAME is run, the desired level is game ini. |
| 51 | |
| 52 | Expected Code behavior: |
| 53 | ---------------------------------------------------------------------------- |
| 54 | This approach requires 3 option sets, 'current', 'original' and 'default'. |
| 55 | |
| 56 | 'current': used to populate the property pages, and to initialize the |
| 57 | 'original' set. |
| 58 | |
| 59 | 'original': used to evaluate if the 'Reset' button is enabled. |
| 60 | If 'current' matches 'original', the 'Reset' button is disabled, |
| 61 | otherwise it is enabled. |
| 62 | |
| 63 | 'default': used to evaluate if the 'Restore to Defaults' button is enabled. |
| 64 | If 'current' matches 'default', the 'Restore to Defaults' button is disabled, |
| 65 | otherwise it is enabled. |
| 66 | |
| 67 | When editing any option set, the desired level is set to the one being |
| 68 | edited, the default set for that level, is the next lower priority set found. |
| 69 | |
| 70 | Upon entering the properties dialog: |
| 71 | a) 'current' is initialized |
| 72 | b) 'original' is initialized by 'current' |
| 73 | c) 'default' is initialized |
| 74 | d) Populate Property pages with 'current' |
| 75 | e) 'Reset' and 'Restore to Defaults' buttons are evaluated. |
| 76 | |
| 77 | After any change: |
| 78 | a) 'current' is updated |
| 79 | b) 'Reset' and 'Restore to Defaults' buttons are re-evaluated. |
| 80 | |
| 81 | Reset: |
| 82 | a) 'current' is reinitialized to 'original' |
| 83 | b) Re-populate Property pages with 'current' |
| 84 | c) 'Reset' and 'Restore to Defaults' buttons are re-evaluated. |
| 85 | |
| 86 | Restore to Defaults: |
| 87 | a) 'current' is reinitialized to 'default' |
| 88 | b) Re-populate Property pages with 'current' |
| 89 | b) 'Reset' and 'Restore to Defaults' buttons are re-evaluated. |
| 90 | |
| 91 | Apply: |
| 92 | a) 'original' is reinitialized to 'current' |
| 93 | b) 'Reset' and 'Restore to defaults' are re-evaluated. |
| 94 | c) If they 'current' matches 'default', remove the ini from disk. |
| 95 | Otherwise, write the ini to disk. |
| 96 | |
| 97 | Cancel: |
| 98 | a) Exit the dialog. |
| 99 | |
| 100 | OK: |
| 101 | a) If they 'current' matches 'default', remove the ini from disk. |
| 102 | Otherwise, write the ini to disk. |
| 103 | b) Exit the dialog. |
| 104 | |
| 105 | |
| 106 | ***************************************************************************/ |
| 107 | |
| 108 | #define WIN32_LEAN_AND_MEAN |
| 109 | #include <windows.h> |
| 110 | #include <windowsx.h> |
| 111 | #include <commctrl.h> |
| 112 | #include <commdlg.h> |
| 113 | #include <ddraw.h> |
| 114 | #include <stdio.h> |
| 115 | #include <string.h> |
| 116 | #include <sys/stat.h> |
| 117 | #include <tchar.h> |
| 118 | |
| 119 | #include <driver.h> |
| 120 | #include <info.h> |
| 121 | #include "audit.h" |
| 122 | #include "audit32.h" |
| 123 | #include "bitmask.h" |
| 124 | #include "m32opts.h" |
| 125 | #include "file.h" |
| 126 | #include "resource.h" |
| 127 | #include "dijoystick.h" /* For DIJoystick avalibility. */ |
| 128 | #include "m32util.h" |
| 129 | #include "directdraw.h" |
| 130 | #include "properties.h" |
| 131 | #include "treeview.h" |
| 132 | #include "win32ui.h" |
| 133 | #include "screenshot.h" |
| 134 | #include "mame32.h" |
| 135 | #include "datamap.h" |
| 136 | #include "help.h" |
| 137 | #include "resource.hm" |
| 138 | #include "winmain.h" |
| 139 | #include "strconv.h" |
| 140 | #include "winutf8.h" |
| 141 | #include "m32util.h" |
| 142 | |
| 143 | typedef HANDLE HTHEME; |
| 144 | |
| 145 | #ifdef _MSC_VER |
| 146 | #define snprintf _snprintf |
| 147 | #endif |
| 148 | |
| 149 | #ifdef MESS |
| 150 | // done like this until I figure out a better idea |
| 151 | #include "messopts.h" |
| 152 | #include "resourcems.h" |
| 153 | #include "propertiesms.h" |
| 154 | #endif |
| 155 | |
| 156 | // missing win32 api defines |
| 157 | #ifndef TBCD_TICS |
| 158 | #define TBCD_TICS 1 |
| 159 | #endif |
| 160 | #ifndef TBCD_THUMB |
| 161 | #define TBCD_THUMB 2 |
| 162 | #endif |
| 163 | #ifndef TBCD_CHANNEL |
| 164 | #define TBCD_CHANNEL 3 |
| 165 | #endif |
| 166 | |
| 167 | #if defined(__GNUC__) |
| 168 | /* fix warning: cast does not match function type */ |
| 169 | #undef PropSheet_GetTabControl |
| 170 | #define PropSheet_GetTabControl(d) (HWND)(LRESULT)(int)SendMessage((d),PSM_GETTABCONTROL,0,0) |
| 171 | #endif /* defined(__GNUC__) */ |
| 172 | |
| 173 | /*************************************************************** |
| 174 | * Imported function prototypes |
| 175 | ***************************************************************/ |
| 176 | |
| 177 | /************************************************************** |
| 178 | * Local function prototypes |
| 179 | **************************************************************/ |
| 180 | |
| 181 | static void SetStereoEnabled(HWND hWnd, int nIndex); |
| 182 | static void SetYM3812Enabled(HWND hWnd, int nIndex); |
| 183 | static void SetSamplesEnabled(HWND hWnd, int nIndex, BOOL bSoundEnabled); |
| 184 | static void InitializeOptions(HWND hDlg); |
| 185 | static void InitializeMisc(HWND hDlg); |
| 186 | static void OptOnHScroll(HWND hWnd, HWND hwndCtl, UINT code, int pos); |
| 187 | static void NumScreensSelectionChange(HWND hwnd); |
| 188 | static void RefreshSelectionChange(HWND hWnd, HWND hWndCtrl); |
| 189 | static void InitializeSoundUI(HWND hwnd); |
| 190 | static void InitializeSkippingUI(HWND hwnd); |
| 191 | static void InitializeRotateUI(HWND hwnd); |
| 192 | static void UpdateSelectScreenUI(HWND hwnd); |
| 193 | static void InitializeSelectScreenUI(HWND hwnd); |
| 194 | static void InitializeD3DVersionUI(HWND hwnd); |
| 195 | static void InitializeVideoUI(HWND hwnd); |
| 196 | static void InitializeEffectUI(HWND hWnd); |
| 197 | static void InitializeBIOSUI(HWND hwnd); |
| 198 | static void InitializeControllerMappingUI(HWND hwnd); |
| 199 | static void UpdateOptions(HWND hDlg, datamap *properties_datamap, core_options *opts); |
| 200 | static void UpdateProperties(HWND hDlg, datamap *properties_datamap, core_options *opts); |
| 201 | static void PropToOptions(HWND hWnd, core_options *o); |
| 202 | static void OptionsToProp(HWND hWnd, core_options *o); |
| 203 | static void SetPropEnabledControls(HWND hWnd); |
| 204 | static BOOL SelectEffect(HWND hWnd); |
| 205 | static BOOL ResetEffect(HWND hWnd); |
| 206 | |
| 207 | static void BuildDataMap(void); |
| 208 | static void ResetDataMap(HWND hWnd); |
| 209 | |
| 210 | static BOOL IsControlOptionValue(HWND hDlg,HWND hwnd_ctrl, core_options *opts ); |
| 211 | |
| 212 | static void UpdateBackgroundBrush(HWND hwndTab); |
| 213 | HBRUSH hBkBrush; |
| 214 | |
| 215 | /************************************************************** |
| 216 | * Local private variables |
| 217 | **************************************************************/ |
| 218 | |
| 219 | static core_options *pOrigOpts, *pDefaultOpts; |
| 220 | static BOOL orig_uses_defaults; |
| 221 | static core_options *pCurrentOpts = NULL; |
| 222 | static datamap *properties_datamap; |
| 223 | |
| 224 | static int g_nGame = 0; |
| 225 | static int g_nFolder = 0; |
| 226 | static int g_nFolderGame = 0; |
| 227 | static int g_nPropertyMode = 0; |
| 228 | static BOOL g_bUseDefaults = FALSE; |
| 229 | static BOOL g_bReset = FALSE; |
| 230 | static BOOL g_bAutoAspect[MAX_SCREENS] = {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}; |
| 231 | static HICON g_hIcon = NULL; |
| 232 | |
| 233 | /* Property sheets */ |
| 234 | |
| 235 | #define HIGHLIGHT_COLOR RGB(0,196,0) |
| 236 | HBRUSH highlight_brush = NULL; |
| 237 | HBRUSH background_brush = NULL; |
| 238 | #define VECTOR_COLOR RGB( 190, 0, 0) //DARK RED |
| 239 | #define FOLDER_COLOR RGB( 0, 128, 0 ) // DARK GREEN |
| 240 | #define PARENT_COLOR RGB( 190, 128, 192 ) // PURPLE |
| 241 | #define GAME_COLOR RGB( 0, 128, 192 ) // DARK BLUE |
| 242 | |
| 243 | BOOL PropSheetFilter_Vector(const machine_config *drv, const game_driver *gamedrv) |
| 244 | { |
| 245 | return (drv->video_attributes & VIDEO_TYPE_VECTOR) != 0; |
| 246 | } |
| 247 | |
| 248 | /* Help IDs - moved to auto-generated helpids.c */ |
| 249 | extern const DWORD dwHelpIDs[]; |
| 250 | |
| 251 | static struct ComboBoxVideo |
| 252 | { |
| 253 | const TCHAR* m_pText; |
| 254 | const char* m_pData; |
| 255 | } g_ComboBoxVideo[] = |
| 256 | { |
| 257 | { TEXT("GDI"), "gdi" }, |
| 258 | { TEXT("DirectDraw"), "ddraw" }, |
| 259 | { TEXT("Direct3D"), "d3d" }, |
| 260 | }; |
| 261 | #define NUMVIDEO (sizeof(g_ComboBoxVideo) / sizeof(g_ComboBoxVideo[0])) |
| 262 | |
| 263 | static struct ComboBoxD3DVersion |
| 264 | { |
| 265 | const TCHAR* m_pText; |
| 266 | const int m_pData; |
| 267 | } g_ComboBoxD3DVersion[] = |
| 268 | { |
| 269 | { TEXT("Version 9"), 9 }, |
| 270 | { TEXT("Version 8"), 8 }, |
| 271 | }; |
| 272 | |
| 273 | #define NUMD3DVERSIONS (sizeof(g_ComboBoxD3DVersion) / sizeof(g_ComboBoxD3DVersion[0])) |
| 274 | |
| 275 | static struct ComboBoxSelectScreen |
| 276 | { |
| 277 | const TCHAR* m_pText; |
| 278 | const int m_pData; |
| 279 | } g_ComboBoxSelectScreen[] = |
| 280 | { |
| 281 | { TEXT("Screen 0"), 0 }, |
| 282 | { TEXT("Screen 1"), 1 }, |
| 283 | { TEXT("Screen 2"), 2 }, |
| 284 | { TEXT("Screen 3"), 3 }, |
| 285 | }; |
| 286 | #define NUMSELECTSCREEN (sizeof(g_ComboBoxSelectScreen) / sizeof(g_ComboBoxSelectScreen[0])) |
| 287 | |
| 288 | static struct ComboBoxView |
| 289 | { |
| 290 | const TCHAR* m_pText; |
| 291 | const char* m_pData; |
| 292 | } g_ComboBoxView[] = |
| 293 | { |
| 294 | { TEXT("Auto"), "auto" }, |
| 295 | { TEXT("Standard"), "standard" }, |
| 296 | { TEXT("Pixel Aspect"), "pixel" }, |
| 297 | { TEXT("Cocktail"), "cocktail" }, |
| 298 | }; |
| 299 | #define NUMVIEW (sizeof(g_ComboBoxView) / sizeof(g_ComboBoxView[0])) |
| 300 | |
| 301 | |
| 302 | |
| 303 | static struct ComboBoxDevices |
| 304 | { |
| 305 | const TCHAR* m_pText; |
| 306 | const char* m_pData; |
| 307 | } g_ComboBoxDevice[] = |
| 308 | { |
| 309 | { TEXT("None"), "none" }, |
| 310 | { TEXT("Keyboard"), "keyboard" }, |
| 311 | { TEXT("Mouse"), "mouse" }, |
| 312 | { TEXT("Joystick"), "joystick" }, |
| 313 | { TEXT("Lightgun"), "lightgun" }, |
| 314 | }; |
| 315 | |
| 316 | #define NUMDEVICES (sizeof(g_ComboBoxDevice) / sizeof(g_ComboBoxDevice[0])) |
| 317 | |
| 318 | /*************************************************************** |
| 319 | * Public functions |
| 320 | ***************************************************************/ |
| 321 | |
| 322 | // Called by MESS, to avoid MESS specific hacks in properties.c |
| 323 | int PropertiesCurrentGame(HWND hDlg) |
| 324 | { |
| 325 | return g_nGame; |
| 326 | } |
| 327 | |
| 328 | DWORD GetHelpIDs(void) |
| 329 | { |
| 330 | return (DWORD) (LPSTR) dwHelpIDs; |
| 331 | } |
| 332 | |
| 333 | // This function (and the code that use it) is a gross hack - but at least the vile |
| 334 | // and disgusting global variables are gone, making it less gross than what came before |
| 335 | static int GetSelectedScreen(HWND hWnd) |
| 336 | { |
| 337 | int nSelectedScreen = 0; |
| 338 | HWND hCtrl = GetDlgItem(hWnd, IDC_SCREENSELECT); |
| 339 | if (hCtrl) |
| 340 | nSelectedScreen = ComboBox_GetCurSel(hCtrl); |
| 341 | if ((nSelectedScreen < 0) || (nSelectedScreen >= MAX_SCREENS)) |
| 342 | nSelectedScreen = 0; |
| 343 | return nSelectedScreen; |
| 344 | |
| 345 | } |
| 346 | |
| 347 | static PROPSHEETPAGE *CreatePropSheetPages(HINSTANCE hInst, BOOL bOnlyDefault, |
| 348 | const game_driver *gamedrv, UINT *pnMaxPropSheets, BOOL isGame ) |
| 349 | { |
| 350 | PROPSHEETPAGE *pspages; |
| 351 | int maxPropSheets; |
| 352 | int possiblePropSheets; |
| 353 | int i; |
| 354 | machine_config drv; |
| 355 | |
| 356 | if (gamedrv) |
| 357 | expand_machine_driver(gamedrv->drv, &drv); |
| 358 | |
| 359 | i = ( isGame ) ? 0 : 2; |
| 360 | |
| 361 | for (; g_propSheets[i].pfnDlgProc; i++) |
| 362 | ; |
| 363 | |
| 364 | possiblePropSheets = (isGame) ? i + 1 : i - 1; |
| 365 | |
| 366 | pspages = malloc(sizeof(PROPSHEETPAGE) * possiblePropSheets); |
| 367 | if (!pspages) |
| 368 | return NULL; |
| 369 | |
| 370 | memset(pspages, 0, sizeof(PROPSHEETPAGE) * possiblePropSheets); |
| 371 | |
| 372 | maxPropSheets = 0; |
| 373 | |
| 374 | i = ( isGame ) ? 0 : 2; |
| 375 | |
| 376 | for (; g_propSheets[i].pfnDlgProc; i++) |
| 377 | { |
| 378 | if ((gamedrv != NULL) || g_propSheets[i].bOnDefaultPage) |
| 379 | { |
| 380 | if (!gamedrv || !g_propSheets[i].pfnFilterProc || g_propSheets[i].pfnFilterProc(&drv, gamedrv)) |
| 381 | { |
| 382 | pspages[maxPropSheets].dwSize = sizeof(PROPSHEETPAGE); |
| 383 | pspages[maxPropSheets].dwFlags = 0; |
| 384 | pspages[maxPropSheets].hInstance = hInst; |
| 385 | pspages[maxPropSheets].pszTemplate = MAKEINTRESOURCE(g_propSheets[i].dwDlgID); |
| 386 | pspages[maxPropSheets].pfnCallback = NULL; |
| 387 | pspages[maxPropSheets].lParam = 0; |
| 388 | pspages[maxPropSheets].pfnDlgProc = g_propSheets[i].pfnDlgProc; |
| 389 | maxPropSheets++; |
| 390 | } |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | if (pnMaxPropSheets) |
| 395 | *pnMaxPropSheets = maxPropSheets; |
| 396 | |
| 397 | return pspages; |
| 398 | } |
| 399 | |
| 400 | void InitDefaultPropertyPage(HINSTANCE hInst, HWND hWnd) |
| 401 | { |
| 402 | PROPSHEETHEADER pshead; |
| 403 | PROPSHEETPAGE *pspage; |
| 404 | |
| 405 | // clear globals |
| 406 | pCurrentOpts = NULL; |
| 407 | |
| 408 | g_nGame = GLOBAL_OPTIONS; |
| 409 | |
| 410 | /* Get default options to populate property sheets */ |
| 411 | pCurrentOpts = load_options(OPTIONS_GLOBAL, g_nGame); //GetDefaultOptions(-1, FALSE); |
| 412 | pDefaultOpts = load_options(OPTIONS_GLOBAL, g_nGame); |
| 413 | g_bUseDefaults = FALSE; |
| 414 | /* Stash the result for comparing later */ |
| 415 | pOrigOpts = CreateGameOptions(OPTIONS_TYPE_GLOBAL); |
| 416 | options_copy(pOrigOpts, pCurrentOpts); |
| 417 | orig_uses_defaults = FALSE; |
| 418 | g_bReset = FALSE; |
| 419 | g_nPropertyMode = OPTIONS_GLOBAL; |
| 420 | BuildDataMap(); |
| 421 | |
| 422 | ZeroMemory(&pshead, sizeof(pshead)); |
| 423 | |
| 424 | pspage = CreatePropSheetPages(hInst, TRUE, NULL, &pshead.nPages, FALSE); |
| 425 | if (!pspage) |
| 426 | return; |
| 427 | |
| 428 | /* Fill in the property sheet header */ |
| 429 | pshead.hwndParent = hWnd; |
| 430 | pshead.dwSize = sizeof(PROPSHEETHEADER); |
| 431 | pshead.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_PROPTITLE; |
| 432 | pshead.hInstance = hInst; |
| 433 | pshead.pszCaption = TEXT("Default Game"); |
| 434 | pshead.nStartPage = 0; |
| 435 | pshead.pszIcon = MAKEINTRESOURCE(IDI_MAME32_ICON); |
| 436 | pshead.ppsp = pspage; |
| 437 | |
| 438 | /* Create the Property sheet and display it */ |
| 439 | if (PropertySheet(&pshead) == -1) |
| 440 | { |
| 441 | char temp[100]; |
| 442 | DWORD dwError = GetLastError(); |
| 443 | sprintf(temp, "Propery Sheet Error %d %X", (int)dwError, (int)dwError); |
| 444 | win_message_box_utf8(0, temp, "Error", IDOK); |
| 445 | } |
| 446 | |
| 447 | free(pspage); |
| 448 | } |
| 449 | |
| 450 | /* Initilize the property pages for anything but the Default option set */ |
| 451 | void InitPropertyPage(HINSTANCE hInst, HWND hWnd, HICON hIcon, OPTIONS_TYPE opt_type, int folder_id, int game_num) |
| 452 | { |
| 453 | InitPropertyPageToPage(hInst, hWnd, hIcon, opt_type, folder_id, game_num, PROPERTIES_PAGE); |
| 454 | } |
| 455 | |
| 456 | void InitPropertyPageToPage(HINSTANCE hInst, HWND hWnd, HICON hIcon, OPTIONS_TYPE opt_type, int folder_id, int game_num, int start_page ) |
| 457 | { |
| 458 | PROPSHEETHEADER pshead; |
| 459 | PROPSHEETPAGE *pspage; |
| 460 | TCHAR* t_description = 0; |
| 461 | OPTIONS_TYPE default_type = opt_type; |
| 462 | |
| 463 | if (highlight_brush == NULL) |
| 464 | highlight_brush = CreateSolidBrush(HIGHLIGHT_COLOR); |
| 465 | |
| 466 | if (background_brush == NULL) |
| 467 | background_brush = CreateSolidBrush(GetSysColor(COLOR_3DFACE)); |
| 468 | |
| 469 | // Initialize the options |
| 470 | |
| 471 | // Load the current options, this will pickup the highest priority option set. |
| 472 | pCurrentOpts = load_options(opt_type, game_num); |
| 473 | |
| 474 | // Load the default options, pickup the next lower options set than the current level. |
| 475 | if (opt_type > OPTIONS_GLOBAL) |
| 476 | { |
| 477 | default_type -= 1; |
| 478 | } |
| 479 | pDefaultOpts = load_options(default_type, game_num); |
| 480 | |
| 481 | // Copy current_options to original options |
| 482 | pOrigOpts = CreateGameOptions(OPTIONS_TYPE_GLOBAL); |
| 483 | options_copy(pOrigOpts, pCurrentOpts); |
| 484 | |
| 485 | // Copy icon to use for the property pages |
| 486 | g_hIcon = CopyIcon(hIcon); |
| 487 | |
| 488 | // These MUST be valid, they are used as indicies |
| 489 | g_nGame = game_num; |
| 490 | g_nFolder = folder_id; |
| 491 | |
| 492 | // Keep track of OPTIONS_TYPE that was passed in. |
| 493 | g_nPropertyMode = opt_type; |
| 494 | |
| 495 | // Evaluate if the current set uses the Default set |
| 496 | g_bUseDefaults = options_equal(pCurrentOpts, pDefaultOpts); |
| 497 | g_bReset = FALSE; |
| 498 | BuildDataMap(); |
| 499 | |
| 500 | ZeroMemory(&pshead, sizeof(PROPSHEETHEADER)); |
| 501 | |
| 502 | // Set the game to audio to this game |
| 503 | InitGameAudit(game_num); |
| 504 | |
| 505 | // Create the propery sheets |
| 506 | if( OPTIONS_GAME == opt_type ) |
| 507 | { |
| 508 | pspage = CreatePropSheetPages(hInst, FALSE, drivers[game_num], &pshead.nPages, TRUE); |
| 509 | } |
| 510 | else |
| 511 | { |
| 512 | pspage = CreatePropSheetPages(hInst, FALSE, NULL, &pshead.nPages, FALSE); |
| 513 | } |
| 514 | if (!pspage) |
| 515 | return; |
| 516 | |
| 517 | |
| 518 | // Get the description use as the dialog caption. |
| 519 | switch( opt_type ) |
| 520 | { |
| 521 | case OPTIONS_GAME: |
| 522 | t_description = tstring_from_utf8(ModifyThe(drivers[g_nGame]->description)); |
| 523 | break; |
| 524 | case OPTIONS_VECTOR: |
| 525 | case OPTIONS_SOURCE: |
| 526 | t_description = tstring_from_utf8(GetFolderNameByID(g_nFolder)); |
| 527 | break; |
| 528 | case OPTIONS_GLOBAL: |
| 529 | t_description = tstring_from_utf8("Default Settings"); |
| 530 | break; |
| 531 | default: |
| 532 | return; |
| 533 | } |
| 534 | // If we have no descrption, return. |
| 535 | if( !t_description ) |
| 536 | return; |
| 537 | |
| 538 | /* Fill in the property sheet header */ |
| 539 | pshead.pszCaption = t_description; |
| 540 | pshead.hwndParent = hWnd; |
| 541 | pshead.dwSize = sizeof(PROPSHEETHEADER); |
| 542 | pshead.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_PROPTITLE; |
| 543 | pshead.hInstance = hInst; |
| 544 | pshead.nStartPage = start_page; |
| 545 | pshead.pszIcon = MAKEINTRESOURCE(IDI_MAME32_ICON); |
| 546 | pshead.ppsp = pspage; |
| 547 | |
| 548 | /* Create the Property sheet and display it */ |
| 549 | if (PropertySheet(&pshead) == -1) |
| 550 | { |
| 551 | char temp[100]; |
| 552 | DWORD dwError = GetLastError(); |
| 553 | sprintf(temp, "Propery Sheet Error %d %X", (int)dwError, (int)dwError); |
| 554 | win_message_box_utf8(0, temp, "Error", IDOK); |
| 555 | } |
| 556 | |
| 557 | free(t_description); |
| 558 | free(pspage); |
| 559 | } |
| 560 | |
| 561 | |
| 562 | /********************************************************************* |
| 563 | * Local Functions |
| 564 | *********************************************************************/ |
| 565 | |
| 566 | /* Build CPU info string */ |
| 567 | static char *GameInfoCPU(UINT nIndex) |
| 568 | { |
| 569 | int i; |
| 570 | static char buf[1024] = ""; |
| 571 | machine_config drv; |
| 572 | expand_machine_driver(drivers[nIndex]->drv,&drv); |
| 573 | |
| 574 | ZeroMemory(buf, sizeof(buf)); |
| 575 | |
| 576 | cpuintrf_init(NULL); |
| 577 | |
| 578 | i = 0; |
| 579 | while (i < MAX_CPU && drv.cpu[i].cpu_type) |
| 580 | { |
| 581 | if (drv.cpu[i].cpu_clock >= 1000000) |
| 582 | sprintf(&buf[strlen(buf)], "%s %d.%06d MHz", |
| 583 | cputype_name(drv.cpu[i].cpu_type), |
| 584 | drv.cpu[i].cpu_clock / 1000000, |
| 585 | drv.cpu[i].cpu_clock % 1000000); |
| 586 | else |
| 587 | sprintf(&buf[strlen(buf)], "%s %d.%03d kHz", |
| 588 | cputype_name(drv.cpu[i].cpu_type), |
| 589 | drv.cpu[i].cpu_clock / 1000, |
| 590 | drv.cpu[i].cpu_clock % 1000); |
| 591 | |
| 592 | strcat(buf, "\n"); |
| 593 | |
| 594 | i++; |
| 595 | } |
| 596 | |
| 597 | return buf; |
| 598 | } |
| 599 | |
| 600 | /* Build Sound system info string */ |
| 601 | static char *GameInfoSound(UINT nIndex) |
| 602 | { |
| 603 | int i; |
| 604 | static char buf[1024]; |
| 605 | machine_config drv; |
| 606 | expand_machine_driver(drivers[nIndex]->drv,&drv); |
| 607 | |
| 608 | buf[0] = 0; |
| 609 | |
| 610 | i = 0; |
| 611 | while (i < MAX_SOUND && drv.sound[i].sound_type) |
| 612 | { |
| 613 | int clock,sound_type,count; |
| 614 | |
| 615 | sound_type = drv.sound[i].sound_type; |
| 616 | clock = drv.sound[i].clock; |
| 617 | |
| 618 | count = 1; |
| 619 | i++; |
| 620 | |
| 621 | while (i < MAX_SOUND |
| 622 | && drv.sound[i].sound_type == sound_type |
| 623 | && drv.sound[i].clock == clock) |
| 624 | { |
| 625 | count++; |
| 626 | i++; |
| 627 | } |
| 628 | |
| 629 | if (count > 1) |
| 630 | sprintf(&buf[strlen(buf)],"%dx",count); |
| 631 | |
| 632 | sprintf(&buf[strlen(buf)],"%s",sndtype_name(sound_type)); |
| 633 | |
| 634 | if (clock) |
| 635 | { |
| 636 | if (clock >= 1000000) |
| 637 | sprintf(&buf[strlen(buf)]," %d.%06d MHz", |
| 638 | clock / 1000000, |
| 639 | clock % 1000000); |
| 640 | else |
| 641 | sprintf(&buf[strlen(buf)]," %d.%03d kHz", |
| 642 | clock / 1000, |
| 643 | clock % 1000); |
| 644 | } |
| 645 | |
| 646 | strcat(buf,"\n"); |
| 647 | } |
| 648 | |
| 649 | return buf; |
| 650 | } |
| 651 | |
| 652 | /* Build Display info string */ |
| 653 | static char *GameInfoScreen(UINT nIndex) |
| 654 | { |
| 655 | static char buf[1024]; |
| 656 | machine_config drv; |
| 657 | expand_machine_driver(drivers[nIndex]->drv,&drv); |
| 658 | |
| 659 | if (drv.video_attributes & VIDEO_TYPE_VECTOR) |
| 660 | strcpy(buf, "Vector Game"); |
| 661 | else |
| 662 | { |
| 663 | if (drivers[nIndex]->flags & ORIENTATION_SWAP_XY) |
| 664 | sprintf(buf,"%d x %d (V) %f Hz", |
| 665 | drv.screen[0].defstate.visarea.max_y - drv.screen[0].defstate.visarea.min_y + 1, |
| 666 | drv.screen[0].defstate.visarea.max_x - drv.screen[0].defstate.visarea.min_x + 1, |
| 667 | SUBSECONDS_TO_HZ(drv.screen[0].defstate.refresh)); |
| 668 | else |
| 669 | sprintf(buf,"%d x %d (H) %f Hz", |
| 670 | drv.screen[0].defstate.visarea.max_x - drv.screen[0].defstate.visarea.min_x + 1, |
| 671 | drv.screen[0].defstate.visarea.max_y - drv.screen[0].defstate.visarea.min_y + 1, |
| 672 | SUBSECONDS_TO_HZ(drv.screen[0].defstate.refresh)); |
| 673 | } |
| 674 | return buf; |
| 675 | } |
| 676 | |
| 677 | /* Build color information string */ |
| 678 | static char *GameInfoColors(UINT nIndex) |
| 679 | { |
| 680 | static char buf[1024]; |
| 681 | machine_config drv; |
| 682 | expand_machine_driver(drivers[nIndex]->drv,&drv); |
| 683 | |
| 684 | ZeroMemory(buf, sizeof(buf)); |
| 685 | sprintf(buf, "%d colors ", drv.total_colors); |
| 686 | |
| 687 | return buf; |
| 688 | } |
| 689 | |
| 690 | /* Build game status string */ |
| 691 | const char *GameInfoStatus(int driver_index, BOOL bRomStatus) |
| 692 | { |
| 693 | static char buffer[1024]; |
| 694 | int audit_result = GetRomAuditResults(driver_index); |
| 695 | memset(buffer,0,sizeof(char)*1024); |
| 696 | if ( bRomStatus ) |
| 697 | { |
| 698 | if (IsAuditResultKnown(audit_result) == FALSE) |
| 699 | { |
| 700 | strcpy(buffer, "Unknown"); |
| 701 | } |
| 702 | else if (IsAuditResultYes(audit_result)) |
| 703 | { |
| 704 | if (DriverIsBroken(driver_index)) |
| 705 | { |
| 706 | strcpy(buffer, "Not working"); |
| 707 | |
| 708 | if (drivers[driver_index]->flags & GAME_UNEMULATED_PROTECTION) |
| 709 | { |
| 710 | if (*buffer != '\0') |
| 711 | strcat(buffer, "\r\n"); |
| 712 | strcat(buffer, "Game protection isn't fully emulated"); |
| 713 | } |
| 714 | if (drivers[driver_index]->flags & GAME_WRONG_COLORS) |
| 715 | { |
| 716 | if (*buffer != '\0') |
| 717 | strcat(buffer, "\r\n"); |
| 718 | strcat(buffer, "Colors are completely wrong"); |
| 719 | } |
| 720 | if (drivers[driver_index]->flags & GAME_IMPERFECT_COLORS) |
| 721 | { |
| 722 | if (*buffer != '\0') |
| 723 | strcat(buffer, "\r\n"); |
| 724 | strcat(buffer, "Colors aren't 100% accurate"); |
| 725 | } |
| 726 | if (drivers[driver_index]->flags & GAME_IMPERFECT_GRAPHICS) |
| 727 | { |
| 728 | if (*buffer != '\0') |
| 729 | strcat(buffer, "\r\n"); |
| 730 | strcat(buffer, "Video emulation isn't 100% accurate"); |
| 731 | } |
| 732 | if (drivers[driver_index]->flags & GAME_NO_SOUND) |
| 733 | { |
| 734 | if (*buffer != '\0') |
| 735 | strcat(buffer, "\r\n"); |
| 736 | strcat(buffer, "Game lacks sound"); |
| 737 | } |
| 738 | if (drivers[driver_index]->flags & GAME_IMPERFECT_SOUND) |
| 739 | { |
| 740 | if (*buffer != '\0') |
| 741 | strcat(buffer, "\r\n"); |
| 742 | strcat(buffer, "Sound emulation isn't 100% accurate"); |
| 743 | } |
| 744 | if (drivers[driver_index]->flags & GAME_NO_COCKTAIL) |
| 745 | { |
| 746 | if (*buffer != '\0') |
| 747 | strcat(buffer, "\r\n"); |
| 748 | strcat(buffer, "Screen flipping is not supported"); |
| 749 | } |
| 750 | } |
| 751 | else |
| 752 | { |
| 753 | strcpy(buffer, "Working"); |
| 754 | |
| 755 | if (drivers[driver_index]->flags & GAME_UNEMULATED_PROTECTION) |
| 756 | { |
| 757 | if (*buffer != '\0') |
| 758 | strcat(buffer, "\r\n"); |
| 759 | strcat(buffer, "Game protection isn't fully emulated"); |
| 760 | } |
| 761 | if (drivers[driver_index]->flags & GAME_WRONG_COLORS) |
| 762 | { |
| 763 | if (*buffer != '\0') |
| 764 | strcat(buffer, "\r\n"); |
| 765 | strcat(buffer, "Colors are completely wrong"); |
| 766 | } |
| 767 | if (drivers[driver_index]->flags & GAME_IMPERFECT_COLORS) |
| 768 | { |
| 769 | if (*buffer != '\0') |
| 770 | strcat(buffer, "\r\n"); |
| 771 | strcat(buffer, "Colors aren't 100% accurate"); |
| 772 | } |
| 773 | if (drivers[driver_index]->flags & GAME_IMPERFECT_GRAPHICS) |
| 774 | { |
| 775 | if (*buffer != '\0') |
| 776 | strcat(buffer, "\r\n"); |
| 777 | strcat(buffer, "Video emulation isn't 100% accurate"); |
| 778 | } |
| 779 | if (drivers[driver_index]->flags & GAME_NO_SOUND) |
| 780 | { |
| 781 | if (*buffer != '\0') |
| 782 | strcat(buffer, "\r\n"); |
| 783 | strcat(buffer, "Game lacks sound"); |
| 784 | } |
| 785 | if (drivers[driver_index]->flags & GAME_IMPERFECT_SOUND) |
| 786 | { |
| 787 | if (*buffer != '\0') |
| 788 | strcat(buffer, "\r\n"); |
| 789 | strcat(buffer, "Sound emulation isn't 100% accurate"); |
| 790 | } |
| 791 | if (drivers[driver_index]->flags & GAME_NO_COCKTAIL) |
| 792 | { |
| 793 | if (*buffer != '\0') |
| 794 | strcat(buffer, "\r\n"); |
| 795 | strcat(buffer, "Screen flipping is not supported"); |
| 796 | } |
| 797 | } |
| 798 | } |
| 799 | else |
| 800 | { |
| 801 | // audit result is no |
| 802 | #ifdef MESS |
| 803 | strcpy(buffer, "BIOS missing"); |
| 804 | #else |
| 805 | strcpy(buffer, "ROMs missing"); |
| 806 | #endif |
| 807 | } |
| 808 | } |
| 809 | else |
| 810 | { |
| 811 | //Just show the emulation flags |
| 812 | if (DriverIsBroken(driver_index)) |
| 813 | { |
| 814 | strcpy(buffer, "Not working"); |
| 815 | } |
| 816 | else |
| 817 | { |
| 818 | strcpy(buffer, "Working"); |
| 819 | } |
| 820 | if (drivers[driver_index]->flags & GAME_UNEMULATED_PROTECTION) |
| 821 | { |
| 822 | if (*buffer != '\0') |
| 823 | strcat(buffer, "\r\n"); |
| 824 | strcat(buffer, "Game protection isn't fully emulated"); |
| 825 | } |
| 826 | if (drivers[driver_index]->flags & GAME_WRONG_COLORS) |
| 827 | { |
| 828 | if (*buffer != '\0') |
| 829 | strcat(buffer, "\r\n"); |
| 830 | strcat(buffer, "Colors are completely wrong"); |
| 831 | } |
| 832 | if (drivers[driver_index]->flags & GAME_IMPERFECT_COLORS) |
| 833 | { |
| 834 | if (*buffer != '\0') |
| 835 | strcat(buffer, "\r\n"); |
| 836 | strcat(buffer, "Colors aren't 100% accurate"); |
| 837 | } |
| 838 | if (drivers[driver_index]->flags & GAME_IMPERFECT_GRAPHICS) |
| 839 | { |
| 840 | if (*buffer != '\0') |
| 841 | strcat(buffer, "\r\n"); |
| 842 | strcat(buffer, "Video emulation isn't 100% accurate"); |
| 843 | } |
| 844 | if (drivers[driver_index]->flags & GAME_NO_SOUND) |
| 845 | { |
| 846 | if (*buffer != '\0') |
| 847 | strcat(buffer, "\r\n"); |
| 848 | strcat(buffer, "Game lacks sound"); |
| 849 | } |
| 850 | if (drivers[driver_index]->flags & GAME_IMPERFECT_SOUND) |
| 851 | { |
| 852 | if (*buffer != '\0') |
| 853 | strcat(buffer, "\r\n"); |
| 854 | strcat(buffer, "Sound emulation isn't 100% accurate"); |
| 855 | } |
| 856 | if (drivers[driver_index]->flags & GAME_NO_COCKTAIL) |
| 857 | { |
| 858 | if (*buffer != '\0') |
| 859 | strcat(buffer, "\r\n"); |
| 860 | strcat(buffer, "Screen flipping is not supported"); |
| 861 | } |
| 862 | } |
| 863 | return buffer; |
| 864 | } |
| 865 | |
| 866 | /* Build game manufacturer string */ |
| 867 | static char *GameInfoManufactured(UINT nIndex) |
| 868 | { |
| 869 | static char buffer[1024]; |
| 870 | |
| 871 | snprintf(buffer,sizeof(buffer),"%s %s",drivers[nIndex]->year,drivers[nIndex]->manufacturer); |
| 872 | return buffer; |
| 873 | } |
| 874 | |
| 875 | /* Build Game title string */ |
| 876 | char *GameInfoTitle(OPTIONS_TYPE opt_type, UINT nIndex) |
| 877 | { |
| 878 | static char buf[1024]; |
| 879 | |
| 880 | if (OPTIONS_GLOBAL == opt_type) |
| 881 | strcpy(buf, "Global game options\nDefault options used by all games"); |
| 882 | else if (OPTIONS_SOURCE == opt_type || OPTIONS_VECTOR == opt_type) |
| 883 | strcpy(buf, "Global folder options\nDefault options used by all games in the folder"); |
| 884 | else |
| 885 | sprintf(buf, "%s\n\"%s\"", ModifyThe(drivers[nIndex]->description), drivers[nIndex]->name); |
| 886 | return buf; |
| 887 | } |
| 888 | |
| 889 | /* Build game clone infromation string */ |
| 890 | static char *GameInfoCloneOf(UINT nIndex) |
| 891 | { |
| 892 | static char buf[1024]; |
| 893 | int nParentIndex= -1; |
| 894 | |
| 895 | buf[0] = '\0'; |
| 896 | |
| 897 | if (DriverIsClone(nIndex)) |
| 898 | { |
| 899 | nParentIndex = GetParentIndex(drivers[nIndex]); |
| 900 | sprintf(buf, "%s - \"%s\"", |
| 901 | ConvertAmpersandString(ModifyThe(drivers[nParentIndex]->description)), |
| 902 | drivers[nParentIndex]->name); |
| 903 | } |
| 904 | |
| 905 | return buf; |
| 906 | } |
| 907 | |
| 908 | static const char * GameInfoSource(UINT nIndex) |
| 909 | { |
| 910 | return GetDriverFilename(nIndex); |
| 911 | } |
| 912 | |
| 913 | /* Handle the information property page */ |
| 914 | INT_PTR CALLBACK GamePropertiesDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) |
| 915 | { |
| 916 | HWND hWnd; |
| 917 | switch (Msg) |
| 918 | { |
| 919 | case WM_INITDIALOG: |
| 920 | if (g_hIcon) |
| 921 | SendDlgItemMessage(hDlg, IDC_GAME_ICON, STM_SETICON, (WPARAM) g_hIcon, 0); |
| 922 | #if defined(USE_SINGLELINE_TABCONTROL) |
| 923 | { |
| 924 | HWND hWnd = PropSheet_GetTabControl(GetParent(hDlg)); |
| 925 | DWORD tabStyle = (GetWindowLong(hWnd,GWL_STYLE) & ~TCS_MULTILINE); |
| 926 | SetWindowLong(hWnd,GWL_STYLE,tabStyle | TCS_SINGLELINE); |
| 927 | } |
| 928 | #endif |
| 929 | |
| 930 | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_TITLE), GameInfoTitle(g_nPropertyMode, g_nGame)); |
| 931 | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_MANUFACTURED), GameInfoManufactured(g_nGame)); |
| 932 | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_STATUS), GameInfoStatus(g_nGame, FALSE)); |
| 933 | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_CPU), GameInfoCPU(g_nGame)); |
| 934 | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_SOUND), GameInfoSound(g_nGame)); |
| 935 | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_SCREEN), GameInfoScreen(g_nGame)); |
| 936 | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_COLORS), GameInfoColors(g_nGame)); |
| 937 | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_CLONEOF), GameInfoCloneOf(g_nGame)); |
| 938 | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_SOURCE), GameInfoSource(g_nGame)); |
| 939 | |
| 940 | if (DriverIsClone(g_nGame)) |
| 941 | { |
| 942 | ShowWindow(GetDlgItem(hDlg, IDC_PROP_CLONEOF_TEXT), SW_SHOW); |
| 943 | } |
| 944 | else |
| 945 | { |
| 946 | ShowWindow(GetDlgItem(hDlg, IDC_PROP_CLONEOF_TEXT), SW_HIDE); |
| 947 | } |
| 948 | hWnd = PropSheet_GetTabControl(GetParent(hDlg)); |
| 949 | UpdateBackgroundBrush(hWnd); |
| 950 | ShowWindow(hDlg, SW_SHOW); |
| 951 | return 1; |
| 952 | |
| 953 | } |
| 954 | return 0; |
| 955 | } |
| 956 | |
| 957 | /* Handle all options property pages */ |
| 958 | INT_PTR CALLBACK GameOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) |
| 959 | { |
| 960 | // RECT rc; |
| 961 | // int nParentIndex = -1; |
| 962 | switch (Msg) |
| 963 | { |
| 964 | case WM_INITDIALOG: |
| 965 | /* Fill in the Game info at the top of the sheet */ |
| 966 | win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_TITLE), GameInfoTitle(g_nPropertyMode, g_nGame)); |
| 967 | InitializeOptions(hDlg); |
| 968 | InitializeMisc(hDlg); |
| 969 | |
| 970 | UpdateProperties(hDlg, properties_datamap, pCurrentOpts); |
| 971 | |
| 972 | g_bUseDefaults = options_equal(pCurrentOpts, pDefaultOpts); |
| 973 | g_bReset = options_equal(pCurrentOpts, pOrigOpts) ? FALSE : TRUE; |
| 974 | |
| 975 | if (g_nGame == GLOBAL_OPTIONS) |
| 976 | ShowWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), SW_HIDE); |
| 977 | else |
| 978 | EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), (g_bUseDefaults) ? FALSE : TRUE); |
| 979 | #ifndef _DEBUG |
| 980 | ShowWindow(GetDlgItem(hDlg, IDC_DEBUG), SW_HIDE); |
| 981 | #endif |
| 982 | EnableWindow(GetDlgItem(hDlg, IDC_PROP_RESET), g_bReset); |
| 983 | ShowWindow(hDlg, SW_SHOW); |
| 984 | |
| 985 | return 1; |
| 986 | |
| 987 | case WM_HSCROLL: |
| 988 | /* slider changed */ |
| 989 | HANDLE_WM_HSCROLL(hDlg, wParam, lParam, OptOnHScroll); |
| 990 | //g_bUseDefaults = FALSE; |
| 991 | //g_bReset = TRUE; |
| 992 | EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), TRUE); |
| 993 | PropSheet_Changed(GetParent(hDlg), hDlg); |
| 994 | |
| 995 | // make sure everything's copied over, to determine what's changed |
| 996 | UpdateOptions(hDlg, properties_datamap, pCurrentOpts); |
| 997 | |
| 998 | // redraw it, it might be a new color now |
| 999 | InvalidateRect((HWND)lParam,NULL,TRUE); |
| 1000 | |
| 1001 | break; |
| 1002 | |
| 1003 | case WM_COMMAND: |
| 1004 | { |
| 1005 | /* Below, 'changed' is used to signify the 'Apply' |
| 1006 | * button should be enabled. |
| 1007 | */ |
| 1008 | WORD wID = GET_WM_COMMAND_ID(wParam, lParam); |
| 1009 | HWND hWndCtrl = GET_WM_COMMAND_HWND(wParam, lParam); |
| 1010 | WORD wNotifyCode = GET_WM_COMMAND_CMD(wParam, lParam); |
| 1011 | BOOL changed = FALSE; |
| 1012 | int nCurSelection = 0; |
| 1013 | TCHAR szClass[256]; |
| 1014 | |
| 1015 | switch (wID) |
| 1016 | { |
| 1017 | case IDC_REFRESH: |
| 1018 | if (wNotifyCode == LBN_SELCHANGE) |
| 1019 | { |
| 1020 | RefreshSelectionChange(hDlg, hWndCtrl); |
| 1021 | changed = TRUE; |
| 1022 | } |
| 1023 | break; |
| 1024 | |
| 1025 | case IDC_ASPECT: |
| 1026 | nCurSelection = Button_GetCheck( GetDlgItem(hDlg, IDC_ASPECT)); |
| 1027 | if( g_bAutoAspect[GetSelectedScreen(hDlg)] != nCurSelection ) |
| 1028 | { |
| 1029 | changed = TRUE; |
| 1030 | g_bAutoAspect[GetSelectedScreen(hDlg)] = nCurSelection; |
| 1031 | } |
| 1032 | break; |
| 1033 | |
| 1034 | case IDC_SELECT_EFFECT: |
| 1035 | changed = SelectEffect(hDlg); |
| 1036 | break; |
| 1037 | |
| 1038 | case IDC_RESET_EFFECT: |
| 1039 | changed = ResetEffect(hDlg); |
| 1040 | break; |
| 1041 | |
| 1042 | case IDC_PROP_RESET: |
| 1043 | if (wNotifyCode != BN_CLICKED) |
| 1044 | break; |
| 1045 | |
| 1046 | options_copy(pCurrentOpts, pOrigOpts); |
| 1047 | UpdateProperties(hDlg, properties_datamap, pCurrentOpts); |
| 1048 | |
| 1049 | g_bUseDefaults = options_equal(pCurrentOpts, pDefaultOpts); |
| 1050 | g_bReset = FALSE; |
| 1051 | PropSheet_UnChanged(GetParent(hDlg), hDlg); |
| 1052 | EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), (g_bUseDefaults) ? FALSE : TRUE); |
| 1053 | break; |
| 1054 | |
| 1055 | case IDC_USE_DEFAULT: |
| 1056 | // Copy the pDefaultOpts into pCurrentOpts |
| 1057 | options_copy(pCurrentOpts, pDefaultOpts); |
| 1058 | // repopulate the controls with the new data |
| 1059 | UpdateProperties(hDlg, properties_datamap, pCurrentOpts); |
| 1060 | |
| 1061 | g_bUseDefaults = options_equal(pCurrentOpts, pDefaultOpts); |
| 1062 | // This evaluates properly |
| 1063 | g_bReset = options_equal(pCurrentOpts, pOrigOpts) ? FALSE : TRUE; |
| 1064 | // Enable/Dispable the Reset to Defaults button |
| 1065 | EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), (g_bUseDefaults) ? FALSE : TRUE); |
| 1066 | // Tell the dialog to enable/disable the apply button. |
| 1067 | if (g_nGame != GLOBAL_OPTIONS) |
| 1068 | { |
| 1069 | if (g_bReset) |
| 1070 | { |
| 1071 | PropSheet_Changed(GetParent(hDlg), hDlg); |
| 1072 | } |
| 1073 | else |
| 1074 | { |
| 1075 | PropSheet_UnChanged(GetParent(hDlg), hDlg); |
| 1076 | } |
| 1077 | } |
| 1078 | break; |
| 1079 | |
| 1080 | // MSH 20070813 - Update all related controls |
| 1081 | case IDC_SCREENSELECT: |
| 1082 | case IDC_SCREEN: |
| 1083 | // NPW 3-Apr-2007: Ugh I'm only perpetuating the vile hacks in this code |
| 1084 | if ((wNotifyCode == CBN_SELCHANGE) || (wNotifyCode == CBN_SELENDOK)) |
| 1085 | { |
| 1086 | changed = datamap_read_control(properties_datamap, hDlg, pCurrentOpts, wID); |
| 1087 | datamap_populate_control(properties_datamap, hDlg, pCurrentOpts, IDC_SIZES); |
| 1088 | //MSH 20070814 - Hate to do this, but its either this, or update each individual |
| 1089 | // control on the SCREEN tab. |
| 1090 | UpdateProperties(hDlg, properties_datamap, pCurrentOpts); |
| 1091 | changed = TRUE; |
| 1092 | /* |
| 1093 | datamap_populate_control(properties_datamap, hDlg, pCurrentOpts, IDC_SCREENSELECT); |
| 1094 | datamap_populate_control(properties_datamap, hDlg, pCurrentOpts, IDC_SCREEN); |
| 1095 | datamap_populate_control(properties_datamap, hDlg, pCurrentOpts, IDC_REFRESH); |
| 1096 | datamap_populate_control(properties_datamap, hDlg, pCurrentOpts, IDC_SIZES); |
| 1097 | datamap_populate_control(properties_datamap, hDlg, pCurrentOpts, IDC_VIEW); |
| 1098 | datamap_populate_control(properties_datamap, hDlg, pCurrentOpts, IDC_SWITCHRES); |
| 1099 | |
| 1100 | if (strcmp(options_get_string(pCurrentOpts, "screen0"), options_get_string(pOrigOpts, "screen0")) || |
| 1101 | strcmp(options_get_string(pCurrentOpts, "screen1"), options_get_string(pOrigOpts, "screen1")) || |
| 1102 | strcmp(options_get_string(pCurrentOpts, "screen2"), options_get_string(pOrigOpts, "screen2")) || |
| 1103 | strcmp(options_get_string(pCurrentOpts, "screen3"), options_get_string(pOrigOpts, "screen3"))) |
| 1104 | { |
| 1105 | changed = TRUE; |
| 1106 | } |
| 1107 | */ |
| 1108 | } |
| 1109 | break; |
| 1110 | default: |
| 1111 | #ifdef MESS |
| 1112 | if (MessPropertiesCommand(hDlg, wNotifyCode, wID, &changed)) |
| 1113 | break; |
| 1114 | #endif // MESS |
| 1115 | |
| 1116 | // use default behavior; try to get the result out of the datamap if |
| 1117 | // appropriate |
| 1118 | GetClassName(hWndCtrl, szClass, ARRAY_LENGTH(szClass)); |
| 1119 | if (!_tcscmp(szClass, WC_COMBOBOX)) |
| 1120 | { |
| 1121 | // combo box |
| 1122 | if ((wNotifyCode == CBN_SELCHANGE) || (wNotifyCode == CBN_SELENDOK)) |
| 1123 | { |
| 1124 | changed = datamap_read_control(properties_datamap, hDlg, pCurrentOpts, wID); |
| 1125 | } |
| 1126 | } |
| 1127 | else if (!_tcscmp(szClass, WC_BUTTON) && (GetWindowLong(hWndCtrl, GWL_STYLE) & BS_CHECKBOX)) |
| 1128 | { |
| 1129 | // check box |
| 1130 | changed = datamap_read_control(properties_datamap, hDlg, pCurrentOpts, wID); |
| 1131 | } |
| 1132 | break; |
| 1133 | } |
| 1134 | |
| 1135 | if (changed == TRUE) |
| 1136 | { |
| 1137 | // make sure everything's copied over, to determine what's changed |
| 1138 | UpdateOptions(hDlg, properties_datamap, pCurrentOpts); |
| 1139 | // enable the apply button |
| 1140 | PropSheet_Changed(GetParent(hDlg), hDlg); |
| 1141 | g_bUseDefaults = options_equal(pCurrentOpts, pDefaultOpts); |
| 1142 | g_bReset = options_equal(pCurrentOpts, pOrigOpts) ? FALSE : TRUE; |
| 1143 | EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), (g_bUseDefaults) ? FALSE : TRUE); |
| 1144 | } |
| 1145 | |
| 1146 | // If we are closing, pCurrentOpts may be null |
| 1147 | if (NULL != pCurrentOpts) |
| 1148 | { |
| 1149 | // make sure everything's copied over, to determine what's changed |
| 1150 | UpdateOptions(hDlg, properties_datamap, pCurrentOpts); |
| 1151 | SetPropEnabledControls(hDlg); |
| 1152 | // redraw it, it might be a new color now |
| 1153 | if (GetDlgItem(hDlg,wID)) |
| 1154 | InvalidateRect(GetDlgItem(hDlg,wID),NULL,FALSE); |
| 1155 | } |
| 1156 | } |
| 1157 | break; |
| 1158 | |
| 1159 | case WM_NOTIFY: |
| 1160 | { |
| 1161 | // Set to true if we are exiting the properites dialog |
| 1162 | BOOL bClosing = ((LPPSHNOTIFY) lParam)->lParam; |
| 1163 | |
| 1164 | switch (((NMHDR *) lParam)->code) |
| 1165 | { |
| 1166 | //We'll need to use a CheckState Table |
| 1167 | //Because this one gets called for all kinds of other things too, and not only if a check is set |
| 1168 | case PSN_SETACTIVE: |
| 1169 | /* Initialize the controls. */ |
| 1170 | UpdateProperties(hDlg, properties_datamap, pCurrentOpts); |
| 1171 | g_bUseDefaults = options_equal(pCurrentOpts, pDefaultOpts); |
| 1172 | g_bReset = options_equal(pCurrentOpts, pOrigOpts) ? FALSE : TRUE; |
| 1173 | |
| 1174 | // Sync RESET TO DEFAULTS buttons. |
| 1175 | EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), (g_bUseDefaults) ? FALSE : TRUE); |
| 1176 | break; |
| 1177 | |
| 1178 | case PSN_APPLY: |
| 1179 | // Handle more than one PSN_APPLY, since this proc handles more tha one |
| 1180 | // property sheet and can be called multiple times when it's time to exit, |
| 1181 | // and we may have already freed the core_options. |
| 1182 | if (bClosing) |
| 1183 | { |
| 1184 | if (NULL == pCurrentOpts) |
| 1185 | return TRUE; |
| 1186 | } |
| 1187 | |
| 1188 | // Read the datamap |
| 1189 | UpdateOptions(hDlg, properties_datamap, pCurrentOpts); |
| 1190 | |
| 1191 | // Copy current options to orignal options. |
| 1192 | options_copy(pOrigOpts, pCurrentOpts); |
| 1193 | |
| 1194 | // Repopulate the controls? WTF? We just read them, they should be fine. |
| 1195 | UpdateProperties(hDlg, properties_datamap, pCurrentOpts); |
| 1196 | |
| 1197 | // Determine button states. |
| 1198 | g_bUseDefaults = options_equal(pCurrentOpts, pDefaultOpts); |
| 1199 | g_bReset = FALSE; |
| 1200 | |
| 1201 | orig_uses_defaults = g_bUseDefaults; |
| 1202 | |
| 1203 | // Sync RESET and RESET TO DEFAULTS buttons. |
| 1204 | EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), (g_bUseDefaults) ? FALSE : TRUE); |
| 1205 | EnableWindow(GetDlgItem(hDlg, IDC_PROP_RESET), g_bReset); |
| 1206 | |
| 1207 | // Save or remove the current options |
| 1208 | save_options(g_nPropertyMode, (g_bUseDefaults) ? NULL : pCurrentOpts, g_nGame); |
| 1209 | |
| 1210 | // Disable apply button |
| 1211 | PropSheet_UnChanged(GetParent(hDlg), hDlg); |
| 1212 | SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR); |
| 1213 | |
| 1214 | // If we a closing, free the core_options |
| 1215 | if (bClosing) |
| 1216 | { |
| 1217 | if (pCurrentOpts) options_free(pCurrentOpts); |
| 1218 | if (pOrigOpts) options_free(pOrigOpts); |
| 1219 | if (pDefaultOpts) options_free(pDefaultOpts); |
| 1220 | pCurrentOpts = pOrigOpts = pDefaultOpts = NULL; |
| 1221 | } |
| 1222 | return TRUE; |
| 1223 | |
| 1224 | case PSN_KILLACTIVE: |
| 1225 | /* Save Changes to the options here. */ |
| 1226 | UpdateOptions(hDlg, properties_datamap, pCurrentOpts); |
| 1227 | // Determine button states. |
| 1228 | g_bUseDefaults = options_equal(pCurrentOpts, pDefaultOpts); |
| 1229 | |
| 1230 | ResetDataMap(hDlg); |
| 1231 | SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); |
| 1232 | return 1; |
| 1233 | |
| 1234 | case PSN_RESET: |
| 1235 | // Reset to the original values. Disregard changes |
| 1236 | options_copy(pCurrentOpts, pOrigOpts); |
| 1237 | SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); |
| 1238 | break; |
| 1239 | |
| 1240 | case PSN_HELP: |
| 1241 | // User wants help for this property page |
| 1242 | break; |
| 1243 | } |
| 1244 | } |
| 1245 | break; |
| 1246 | #if 0 |
| 1247 | /* FIXME - Not sure what to do here. */ |
| 1248 | case WM_CTLCOLORSTATIC : |
| 1249 | case WM_CTLCOLOREDIT : |
| 1250 | |
| 1251 | if( g_nGame >= 0 ) |
| 1252 | { |
| 1253 | if( DriverIsClone(g_nGame) ) |
| 1254 | { |
| 1255 | nParentIndex = GetParentIndex( drivers[g_nGame] ); |
| 1256 | } |
| 1257 | } |
| 1258 | //Set the Coloring of the elements |
| 1259 | if (GetWindowLong((HWND)lParam, GWL_ID) < 0) |
| 1260 | break; |
| 1261 | if (IsControlOptionValue(hDlg,(HWND)lParam, GetDefaultOptions( -1, FALSE) ) ) |
| 1262 | { |
| 1263 | //Normal Black case |
| 1264 | SetTextColor((HDC)wParam,COLOR_WINDOWTEXT); |
| 1265 | } |
| 1266 | else if (IsControlOptionValue(hDlg,(HWND)lParam, GetVectorOptions() ) && DriverIsVector(g_nFolderGame) ) |
| 1267 | { |
| 1268 | SetTextColor((HDC)wParam,VECTOR_COLOR); |
| 1269 | } |
| 1270 | else if (IsControlOptionValue(hDlg,(HWND)lParam, GetSourceOptions(g_nFolderGame ) ) ) |
| 1271 | { |
| 1272 | SetTextColor((HDC)wParam,FOLDER_COLOR); |
| 1273 | } |
| 1274 | else if ((nParentIndex >=0) && (IsControlOptionValue(hDlg,(HWND)lParam, GetGameOptions(nParentIndex, g_nFolder ) ) ) ) |
| 1275 | { |
| 1276 | SetTextColor((HDC)wParam,PARENT_COLOR); |
| 1277 | } |
| 1278 | // else if ( (g_nGame >= 0) && (IsControlOptionValue(hDlg,(HWND)lParam, GetGameOptions(g_nGame, g_nFolder) ) ) ) |
| 1279 | else if ( (g_nGame >= 0) && (IsControlOptionValue(hDlg,(HWND)lParam, pOrigOpts ) ) ) |
| 1280 | { |
| 1281 | SetTextColor((HDC)wParam,GAME_COLOR); |
| 1282 | } |
| 1283 | else |
| 1284 | { |
| 1285 | switch ( g_nPropertyMode ) |
| 1286 | { |
| 1287 | case OPTIONS_GAME: |
| 1288 | SetTextColor((HDC)wParam,GAME_COLOR); |
| 1289 | break; |
| 1290 | case OPTIONS_SOURCE: |
| 1291 | SetTextColor((HDC)wParam,FOLDER_COLOR); |
| 1292 | break; |
| 1293 | case OPTIONS_VECTOR: |
| 1294 | SetTextColor((HDC)wParam,VECTOR_COLOR); |
| 1295 | break; |
| 1296 | default: |
| 1297 | case OPTIONS_GLOBAL: |
| 1298 | SetTextColor((HDC)wParam,COLOR_WINDOWTEXT); |
| 1299 | break; |
| 1300 | } |
| 1301 | } |
| 1302 | if( Msg == WM_CTLCOLORSTATIC ) |
| 1303 | { |
| 1304 | if (SafeIsAppThemed()) |
| 1305 | { |
| 1306 | HWND hWnd = PropSheet_GetTabControl(GetParent(hDlg)); |
| 1307 | // Set the background mode to transparent |
| 1308 | SetBkMode((HDC)wParam, TRANSPARENT); |
| 1309 | |
| 1310 | // Get the controls window dimensions |
| 1311 | GetWindowRect((HWND)lParam, &rc); |
| 1312 | |
| 1313 | // Map the coordinates to coordinates with the upper left corner of dialog control as base |
| 1314 | MapWindowPoints(NULL, hWnd, (LPPOINT)(&rc), 2); |
| 1315 | |
| 1316 | // Adjust the position of the brush for this control (else we see the top left of the brush as background) |
| 1317 | SetBrushOrgEx((HDC)wParam, -rc.left, -rc.top, NULL); |
| 1318 | |
| 1319 | // Return the brush |
| 1320 | return (INT_PTR)(hBkBrush); |
| 1321 | } |
| 1322 | else |
| 1323 | { |
| 1324 | SetBkColor((HDC) wParam,GetSysColor(COLOR_3DFACE) ); |
| 1325 | } |
| 1326 | } |
| 1327 | else |
| 1328 | SetBkColor((HDC)wParam,RGB(255,255,255) ); |
| 1329 | UnrealizeObject(background_brush); |
| 1330 | return (DWORD)background_brush; |
| 1331 | break; |
| 1332 | #endif // 0 Not sure what to do here |
| 1333 | |
| 1334 | case WM_HELP: |
| 1335 | /* User clicked the ? from the upper right on a control */ |
| 1336 | HelpFunction(((LPHELPINFO)lParam)->hItemHandle, MAME32CONTEXTHELP, HH_TP_HELP_WM_HELP, GetHelpIDs()); |
| 1337 | break; |
| 1338 | |
| 1339 | case WM_CONTEXTMENU: |
| 1340 | HelpFunction((HWND)wParam, MAME32CONTEXTHELP, HH_TP_HELP_CONTEXTMENU, GetHelpIDs()); |
| 1341 | break; |
| 1342 | |
| 1343 | } |
| 1344 | EnableWindow(GetDlgItem(hDlg, IDC_PROP_RESET), g_bReset); |
| 1345 | |
| 1346 | return 0; |
| 1347 | } |
| 1348 | |
| 1349 | /* Read controls that are not handled in the DataMap */ |
| 1350 | static void PropToOptions(HWND hWnd, core_options *o) |
| 1351 | { |
| 1352 | HWND hCtrl; |
| 1353 | HWND hCtrl2; |
| 1354 | HWND hCtrl3; |
| 1355 | |
| 1356 | // It appears these are here to clear the global struct we are removing! |
| 1357 | // FIXME |
| 1358 | //if (g_nGame > -1) |
| 1359 | // SetGameUsesDefaults(g_nGame,g_bUseDefaults); |
| 1360 | |
| 1361 | /* aspect ratio */ |
| 1362 | hCtrl = GetDlgItem(hWnd, IDC_ASPECTRATION); |
| 1363 | hCtrl2 = GetDlgItem(hWnd, IDC_ASPECTRATIOD); |
| 1364 | hCtrl3 = GetDlgItem(hWnd, IDC_ASPECT); |
| 1365 | if (hCtrl && hCtrl2 && hCtrl3) |
| 1366 | { |
| 1367 | char aspect_option[32]; |
| 1368 | snprintf(aspect_option, ARRAY_LENGTH(aspect_option), "aspect%d", GetSelectedScreen(hWnd)); |
| 1369 | |
| 1370 | if (Button_GetCheck(hCtrl3)) |
| 1371 | { |
| 1372 | options_set_string(o, aspect_option, "auto", OPTION_PRIORITY_CMDLINE); |
| 1373 | } |
| 1374 | else |
| 1375 | { |
| 1376 | int n = 0; |
| 1377 | int d = 0; |
| 1378 | TCHAR buffer[200]; |
| 1379 | char buffer2[200]; |
| 1380 | |
| 1381 | Edit_GetText(hCtrl,buffer,sizeof(buffer)); |
| 1382 | _stscanf(buffer,TEXT("%d"),&n); |
| 1383 | |
| 1384 | Edit_GetText(hCtrl2,buffer,sizeof(buffer)); |
| 1385 | _stscanf(buffer,TEXT("%d"),&d); |
| 1386 | |
| 1387 | if (n == 0 || d == 0) |
| 1388 | { |
| 1389 | n = 4; |
| 1390 | d = 3; |
| 1391 | } |
| 1392 | |
| 1393 | snprintf(buffer2,sizeof(buffer2),"%d:%d",n,d); |
| 1394 | options_set_string(o, aspect_option, buffer2, OPTION_PRIORITY_CMDLINE); |
| 1395 | } |
| 1396 | } |
| 1397 | } |
| 1398 | |
| 1399 | /* Update options from the dialog */ |
| 1400 | static void UpdateOptions(HWND hDlg, datamap *properties_datamap, core_options *opts) |
| 1401 | { |
| 1402 | /* These are always called together, so make one conveniece function. */ |
| 1403 | datamap_read_all_controls(properties_datamap, hDlg, opts); |
| 1404 | PropToOptions(hDlg, opts); |
| 1405 | } |
| 1406 | |
| 1407 | /* Update the dialog from the options */ |
| 1408 | static void UpdateProperties(HWND hDlg, datamap *properties_datamap, core_options *opts) |
| 1409 | { |
| 1410 | /* These are always called together, so make one conviniece function. */ |
| 1411 | datamap_populate_all_controls(properties_datamap, hDlg, opts); |
| 1412 | OptionsToProp(hDlg, opts); |
| 1413 | SetPropEnabledControls(hDlg); |
| 1414 | } |
| 1415 | |
| 1416 | /* Populate controls that are not handled in the DataMap */ |
| 1417 | static void OptionsToProp(HWND hWnd, core_options* o) |
| 1418 | { |
| 1419 | HWND hCtrl; |
| 1420 | HWND hCtrl2; |
| 1421 | TCHAR buf[100]; |
| 1422 | int n = 0; |
| 1423 | int d = 0; |
| 1424 | |
| 1425 | /* video */ |
| 1426 | |
| 1427 | /* Setup refresh list based on depth. */ |
| 1428 | datamap_update_control(properties_datamap, hWnd, pCurrentOpts, IDC_REFRESH); |
| 1429 | /* Setup Select screen*/ |
| 1430 | UpdateSelectScreenUI(hWnd ); |
| 1431 | |
| 1432 | hCtrl = GetDlgItem(hWnd, IDC_ASPECT); |
| 1433 | if (hCtrl) |
| 1434 | { |
| 1435 | Button_SetCheck(hCtrl, g_bAutoAspect[GetSelectedScreen(hWnd)] ) ; |
| 1436 | } |
| 1437 | |
| 1438 | /* Bios select list */ |
| 1439 | hCtrl = GetDlgItem(hWnd, IDC_BIOS); |
| 1440 | if (hCtrl) |
| 1441 | { |
| 1442 | const char* cBuffer; |
| 1443 | int i = 0; |
| 1444 | int iCount = ComboBox_GetCount( hCtrl ); |
| 1445 | for( i=0; i< iCount; i++ ) |
| 1446 | { |
| 1447 | cBuffer = (const char*)ComboBox_GetItemData( hCtrl, i ); |
| 1448 | if (strcmp(cBuffer, options_get_string(pCurrentOpts, OPTION_BIOS) ) == 0) |
| 1449 | { |
| 1450 | (void)ComboBox_SetCurSel(hCtrl, i); |
| 1451 | break; |
| 1452 | } |
| 1453 | |
| 1454 | } |
| 1455 | } |
| 1456 | |
| 1457 | |
| 1458 | hCtrl = GetDlgItem(hWnd, IDC_ASPECT); |
| 1459 | if (hCtrl) |
| 1460 | { |
| 1461 | char aspect_option[32]; |
| 1462 | snprintf(aspect_option, ARRAY_LENGTH(aspect_option), "aspect%d", GetSelectedScreen(hWnd)); |
| 1463 | if( strcmp(options_get_string(o, aspect_option), "auto") == 0) |
| 1464 | { |
| 1465 | Button_SetCheck(hCtrl, TRUE); |
| 1466 | g_bAutoAspect[GetSelectedScreen(hWnd)] = TRUE; |
| 1467 | } |
| 1468 | else |
| 1469 | { |
| 1470 | Button_SetCheck(hCtrl, FALSE); |
| 1471 | g_bAutoAspect[GetSelectedScreen(hWnd)] = FALSE; |
| 1472 | } |
| 1473 | } |
| 1474 | |
| 1475 | /* aspect ratio */ |
| 1476 | hCtrl = GetDlgItem(hWnd, IDC_ASPECTRATION); |
| 1477 | hCtrl2 = GetDlgItem(hWnd, IDC_ASPECTRATIOD); |
| 1478 | if (hCtrl && hCtrl2) |
| 1479 | { |
| 1480 | char aspect_option[32]; |
| 1481 | snprintf(aspect_option, ARRAY_LENGTH(aspect_option), "aspect%d", GetSelectedScreen(hWnd)); |
| 1482 | |
| 1483 | n = 0; |
| 1484 | d = 0; |
| 1485 | if (options_get_string(o, aspect_option)) |
| 1486 | { |
| 1487 | if (sscanf(options_get_string(o, aspect_option), "%d:%d", &n, &d) == 2 && n != 0 && d != 0) |
| 1488 | { |
| 1489 | _stprintf(buf, TEXT("%d"), n); |
| 1490 | Edit_SetText(hCtrl, buf); |
| 1491 | _stprintf(buf, TEXT("%d"), d); |
| 1492 | Edit_SetText(hCtrl2, buf); |
| 1493 | } |
| 1494 | else |
| 1495 | { |
| 1496 | Edit_SetText(hCtrl, TEXT("4")); |
| 1497 | Edit_SetText(hCtrl2, TEXT("3")); |
| 1498 | } |
| 1499 | } |
| 1500 | else |
| 1501 | { |
| 1502 | Edit_SetText(hCtrl, TEXT("4")); |
| 1503 | Edit_SetText(hCtrl2, TEXT("3")); |
| 1504 | } |
| 1505 | } |
| 1506 | hCtrl = GetDlgItem(hWnd, IDC_EFFECT); |
| 1507 | if (hCtrl) { |
| 1508 | const char* effect = options_get_string(o, WINOPTION_EFFECT); |
| 1509 | if (effect == NULL) { |
| 1510 | effect = "none"; |
| 1511 | options_set_string(o, WINOPTION_EFFECT, effect, OPTION_PRIORITY_CMDLINE); |
| 1512 | } |
| 1513 | win_set_window_text_utf8(hCtrl, effect); |
| 1514 | } |
| 1515 | } |
| 1516 | |
| 1517 | /* Adjust controls - tune them to the currently selected game */ |
| 1518 | static void SetPropEnabledControls(HWND hWnd) |
| 1519 | { |
| 1520 | HWND hCtrl; |
| 1521 | int nIndex; |
| 1522 | int sound; |
| 1523 | BOOL ddraw = FALSE; |
| 1524 | BOOL d3d = FALSE; |
| 1525 | BOOL gdi = FALSE; |
| 1526 | BOOL useart = TRUE; |
| 1527 | BOOL multimon = (DirectDraw_GetNumDisplays() >= 2); |
| 1528 | int joystick_attached = 0; |
| 1529 | int in_window = 0; |
| 1530 | |
| 1531 | nIndex = g_nGame; |
| 1532 | |
| 1533 | d3d = !mame_stricmp(options_get_string(pCurrentOpts, WINOPTION_VIDEO), "d3d"); |
| 1534 | ddraw = !mame_stricmp(options_get_string(pCurrentOpts, WINOPTION_VIDEO), "ddraw"); |
| 1535 | gdi = !d3d && !ddraw; |
| 1536 | |
| 1537 | in_window = options_get_bool(pCurrentOpts, WINOPTION_WINDOW); |
| 1538 | Button_SetCheck(GetDlgItem(hWnd, IDC_ASPECT), g_bAutoAspect[GetSelectedScreen(hWnd)] ); |
| 1539 | |
| 1540 | EnableWindow(GetDlgItem(hWnd, IDC_WAITVSYNC), !gdi); |
| 1541 | EnableWindow(GetDlgItem(hWnd, IDC_TRIPLE_BUFFER), !gdi); |
| 1542 | EnableWindow(GetDlgItem(hWnd, IDC_PRESCALE), !gdi); |
| 1543 | EnableWindow(GetDlgItem(hWnd, IDC_PRESCALEDISP), !gdi); |
| 1544 | EnableWindow(GetDlgItem(hWnd, IDC_HWSTRETCH), ddraw && DirectDraw_HasHWStretch()); |
| 1545 | EnableWindow(GetDlgItem(hWnd, IDC_SWITCHRES), TRUE); |
| 1546 | EnableWindow(GetDlgItem(hWnd, IDC_SYNCREFRESH), TRUE); |
| 1547 | EnableWindow(GetDlgItem(hWnd, IDC_REFRESH), !in_window ); |
| 1548 | EnableWindow(GetDlgItem(hWnd, IDC_REFRESHTEXT), !in_window ); |
| 1549 | EnableWindow(GetDlgItem(hWnd, IDC_FSGAMMA), !in_window); |
| 1550 | EnableWindow(GetDlgItem(hWnd, IDC_FSGAMMATEXT), !in_window); |
| 1551 | EnableWindow(GetDlgItem(hWnd, IDC_FSGAMMADISP), !in_window); |
| 1552 | EnableWindow(GetDlgItem(hWnd, IDC_FSBRIGHTNESS), !in_window); |
| 1553 | EnableWindow(GetDlgItem(hWnd, IDC_FSBRIGHTNESSTEXT), !in_window); |
| 1554 | EnableWindow(GetDlgItem(hWnd, IDC_FSBRIGHTNESSDISP), !in_window); |
| 1555 | EnableWindow(GetDlgItem(hWnd, IDC_FSCONTRAST), !in_window); |
| 1556 | EnableWindow(GetDlgItem(hWnd, IDC_FSCONTRASTTEXT), !in_window); |
| 1557 | EnableWindow(GetDlgItem(hWnd, IDC_FSCONTRASTDISP), !in_window); |
| 1558 | |
| 1559 | EnableWindow(GetDlgItem(hWnd, IDC_ASPECTRATIOTEXT), !g_bAutoAspect[GetSelectedScreen(hWnd)]); |
| 1560 | EnableWindow(GetDlgItem(hWnd, IDC_ASPECTRATION), !g_bAutoAspect[GetSelectedScreen(hWnd)]); |
| 1561 | EnableWindow(GetDlgItem(hWnd, IDC_ASPECTRATIOD), !g_bAutoAspect[GetSelectedScreen(hWnd)]); |
| 1562 | |
| 1563 | EnableWindow(GetDlgItem(hWnd,IDC_D3D_FILTER),d3d); |
| 1564 | EnableWindow(GetDlgItem(hWnd,IDC_D3D_VERSION),d3d); |
| 1565 | |
| 1566 | //Switchres and D3D or ddraw enable the per screen parameters |
| 1567 | |
| 1568 | EnableWindow(GetDlgItem(hWnd, IDC_NUMSCREENS), (ddraw || d3d) && multimon); |
| 1569 | EnableWindow(GetDlgItem(hWnd, IDC_NUMSCREENSDISP), (ddraw || d3d) && multimon); |
| 1570 | EnableWindow(GetDlgItem(hWnd, IDC_SCREENSELECT), (ddraw || d3d) && multimon); |
| 1571 | EnableWindow(GetDlgItem(hWnd, IDC_SCREENSELECTTEXT), (ddraw || d3d) && multimon); |
| 1572 | |
| 1573 | EnableWindow(GetDlgItem(hWnd, IDC_ARTWORK_CROP), useart); |
| 1574 | EnableWindow(GetDlgItem(hWnd, IDC_BACKDROPS), useart); |
| 1575 | EnableWindow(GetDlgItem(hWnd, IDC_BEZELS), useart); |
| 1576 | EnableWindow(GetDlgItem(hWnd, IDC_OVERLAYS), useart); |
| 1577 | EnableWindow(GetDlgItem(hWnd, IDC_ARTMISCTEXT), useart); |
| 1578 | |
| 1579 | /* Joystick options */ |
| 1580 | joystick_attached = DIJoystick.Available(); |
| 1581 | |
| 1582 | Button_Enable(GetDlgItem(hWnd,IDC_JOYSTICK), joystick_attached); |
| 1583 | EnableWindow(GetDlgItem(hWnd, IDC_JDZTEXT), joystick_attached); |
| 1584 | EnableWindow(GetDlgItem(hWnd, IDC_JDZDISP), joystick_attached); |
| 1585 | EnableWindow(GetDlgItem(hWnd, IDC_JDZ), joystick_attached); |
| 1586 | EnableWindow(GetDlgItem(hWnd, IDC_JSATTEXT), joystick_attached); |
| 1587 | EnableWindow(GetDlgItem(hWnd, IDC_JSATDISP), joystick_attached); |
| 1588 | EnableWindow(GetDlgItem(hWnd, IDC_JSAT), joystick_attached); |
| 1589 | /* Trackball / Mouse options */ |
| 1590 | if (nIndex <= -1 || DriverUsesTrackball(nIndex) || DriverUsesLightGun(nIndex)) |
| 1591 | Button_Enable(GetDlgItem(hWnd,IDC_USE_MOUSE),TRUE); |
| 1592 | else |
| 1593 | Button_Enable(GetDlgItem(hWnd,IDC_USE_MOUSE),FALSE); |
| 1594 | |
| 1595 | if (!in_window && (nIndex <= -1 || DriverUsesLightGun(nIndex))) |
| 1596 | { |
| 1597 | // on WinXP the Lightgun and Dual Lightgun switches are no longer supported use mouse instead |
| 1598 | OSVERSIONINFOEX osvi; |
| 1599 | BOOL bOsVersionInfoEx; |
| 1600 | // Try calling GetVersionEx using the OSVERSIONINFOEX structure. |
| 1601 | // If that fails, try using the OSVERSIONINFO structure. |
| 1602 | |
| 1603 | ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); |
| 1604 | osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); |
| 1605 | |
| 1606 | if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) ) |
| 1607 | { |
| 1608 | osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); |
| 1609 | bOsVersionInfoEx = GetVersionEx ( (OSVERSIONINFO *) &osvi); |
| 1610 | } |
| 1611 | |
| 1612 | if( bOsVersionInfoEx && (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) && (osvi.dwMajorVersion >= 5) ) |
| 1613 | { |
| 1614 | BOOL use_lightgun; |
| 1615 | //XP and above... |
| 1616 | Button_Enable(GetDlgItem(hWnd,IDC_LIGHTGUN),FALSE); |
| 1617 | use_lightgun = Button_GetCheck(GetDlgItem(hWnd,IDC_USE_MOUSE)); |
| 1618 | Button_Enable(GetDlgItem(hWnd,IDC_DUAL_LIGHTGUN),FALSE); |
| 1619 | Button_Enable(GetDlgItem(hWnd,IDC_RELOAD),use_lightgun); |
| 1620 | } |
| 1621 | else |
| 1622 | { |
| 1623 | BOOL use_lightgun; |
| 1624 | // Older than XP |
| 1625 | Button_Enable(GetDlgItem(hWnd,IDC_LIGHTGUN),TRUE); |
| 1626 | use_lightgun = Button_GetCheck(GetDlgItem(hWnd,IDC_LIGHTGUN)); |
| 1627 | Button_Enable(GetDlgItem(hWnd,IDC_DUAL_LIGHTGUN),use_lightgun); |
| 1628 | Button_Enable(GetDlgItem(hWnd,IDC_RELOAD),use_lightgun); |
| 1629 | } |
| 1630 | } |
| 1631 | else |
| 1632 | { |
| 1633 | Button_Enable(GetDlgItem(hWnd,IDC_LIGHTGUN),FALSE); |
| 1634 | Button_Enable(GetDlgItem(hWnd,IDC_DUAL_LIGHTGUN),FALSE); |
| 1635 | Button_Enable(GetDlgItem(hWnd,IDC_RELOAD),FALSE); |
| 1636 | } |
| 1637 | |
| 1638 | |
| 1639 | /* Sound options */ |
| 1640 | hCtrl = GetDlgItem(hWnd, IDC_USE_SOUND); |
| 1641 | if (hCtrl) |
| 1642 | { |
| 1643 | sound = Button_GetCheck(hCtrl); |
| 1644 | ComboBox_Enable(GetDlgItem(hWnd, IDC_SAMPLERATE), (sound != 0)); |
| 1645 | |
| 1646 | EnableWindow(GetDlgItem(hWnd,IDC_VOLUME),sound); |
| 1647 | EnableWindow(GetDlgItem(hWnd,IDC_RATETEXT),sound); |
| 1648 | EnableWindow(GetDlgItem(hWnd,IDC_VOLUMEDISP),sound); |
| 1649 | EnableWindow(GetDlgItem(hWnd,IDC_VOLUMETEXT),sound); |
| 1650 | EnableWindow(GetDlgItem(hWnd,IDC_AUDIO_LATENCY),sound); |
| 1651 | EnableWindow(GetDlgItem(hWnd,IDC_AUDIO_LATENCY_DISP),sound); |
| 1652 | EnableWindow(GetDlgItem(hWnd,IDC_AUDIO_LATENCY_TEXT),sound); |
| 1653 | SetSamplesEnabled(hWnd, nIndex, sound); |
| 1654 | SetStereoEnabled(hWnd, nIndex); |
| 1655 | SetYM3812Enabled(hWnd, nIndex); |
| 1656 | } |
| 1657 | |
| 1658 | if (Button_GetCheck(GetDlgItem(hWnd, IDC_AUTOFRAMESKIP))) |
| 1659 | EnableWindow(GetDlgItem(hWnd, IDC_FRAMESKIP), FALSE); |
| 1660 | else |
| 1661 | EnableWindow(GetDlgItem(hWnd, IDC_FRAMESKIP), TRUE); |
| 1662 | |
| 1663 | if (nIndex <= -1 || DriverHasOptionalBIOS(nIndex)) |
| 1664 | EnableWindow(GetDlgItem(hWnd,IDC_BIOS),TRUE); |
| 1665 | else |
| 1666 | EnableWindow(GetDlgItem(hWnd,IDC_BIOS),FALSE); |
| 1667 | |
| 1668 | } |
| 1669 | |
| 1670 | //============================================================ |
| 1671 | // CONTROL HELPER FUNCTIONS FOR DATA EXCHANGE |
| 1672 | //============================================================ |
| 1673 | |
| 1674 | static BOOL RotateReadControl(datamap *map, HWND dialog, HWND control, core_options *opts, const char *option_name) |
| 1675 | { |
| 1676 | int selected_index = ComboBox_GetCurSel(control); |
| 1677 | int original_selection = 0; |
| 1678 | |
| 1679 | // Figure out what the original selection value is |
| 1680 | if (options_get_bool(opts, OPTION_ROR) && !options_get_bool(opts, OPTION_ROL)) |
| 1681 | original_selection = 1; |
| 1682 | else if (!options_get_bool(opts, OPTION_ROR) && options_get_bool(opts, OPTION_ROL)) |
| 1683 | original_selection = 2; |
| 1684 | else if (!options_get_bool(opts, OPTION_ROTATE)) |
| 1685 | original_selection = 3; |
| 1686 | else if (options_get_bool(opts, OPTION_AUTOROR)) |
| 1687 | original_selection = 4; |
| 1688 | else if (options_get_bool(opts, OPTION_AUTOROL)) |
| 1689 | original_selection = 5; |
| 1690 | |
| 1691 | // Any work to do? If so, make the changes and return TRUE. |
| 1692 | if (selected_index != original_selection) |
| 1693 | { |
| 1694 | // Set the options based on the new selection. |
| 1695 | options_set_bool(opts, OPTION_ROR, selected_index == 1, OPTION_PRIORITY_CMDLINE); |
| 1696 | options_set_bool(opts, OPTION_ROL, selected_index == 2, OPTION_PRIORITY_CMDLINE); |
| 1697 | options_set_bool(opts, OPTION_ROTATE, selected_index != 3, OPTION_PRIORITY_CMDLINE); |
| 1698 | options_set_bool(opts, OPTION_AUTOROR, selected_index == 4, OPTION_PRIORITY_CMDLINE); |
| 1699 | options_set_bool(opts, OPTION_AUTOROL, selected_index == 5, OPTION_PRIORITY_CMDLINE); |
| 1700 | return TRUE; |
| 1701 | } |
| 1702 | |
| 1703 | // No changes |
| 1704 | return FALSE; |
| 1705 | } |
| 1706 | |
| 1707 | |
| 1708 | |
| 1709 | static BOOL RotatePopulateControl(datamap *map, HWND dialog, HWND control, core_options *opts, const char *option_name) |
| 1710 | { |
| 1711 | int selected_index = 0; |
| 1712 | if (options_get_bool(opts, OPTION_ROR) && !options_get_bool(opts, OPTION_ROL)) |
| 1713 | selected_index = 1; |
| 1714 | else if (!options_get_bool(opts, OPTION_ROR) && options_get_bool(opts, OPTION_ROL)) |
| 1715 | selected_index = 2; |
| 1716 | else if (!options_get_bool(opts, OPTION_ROTATE)) |
| 1717 | selected_index = 3; |
| 1718 | else if (options_get_bool(opts, OPTION_AUTOROR)) |
| 1719 | selected_index = 4; |
| 1720 | else if (options_get_bool(opts, OPTION_AUTOROL)) |
| 1721 | selected_index = 5; |
| 1722 | |
| 1723 | (void)ComboBox_SetCurSel(control, selected_index); |
| 1724 | return FALSE; |
| 1725 | } |
| 1726 | |
| 1727 | |
| 1728 | |
| 1729 | static BOOL ScreenReadControl(datamap *map, HWND dialog, HWND control, core_options *opts, const char *option_name) |
| 1730 | { |
| 1731 | char screen_option_name[32]; |
| 1732 | const char *screen_option_value; |
| 1733 | int selected_screen; |
| 1734 | int screen_option_index; |
| 1735 | |
| 1736 | selected_screen = GetSelectedScreen(dialog); |
| 1737 | screen_option_index = ComboBox_GetCurSel(control); |
| 1738 | screen_option_value = (const char *) ComboBox_GetItemData(control, screen_option_index); |
| 1739 | snprintf(screen_option_name, ARRAY_LENGTH(screen_option_name), "screen%d", selected_screen); |
| 1740 | options_set_string(opts, screen_option_name, screen_option_value, OPTION_PRIORITY_CMDLINE); |
| 1741 | return FALSE; |
| 1742 | } |
| 1743 | |
| 1744 | |
| 1745 | |
| 1746 | static BOOL ScreenPopulateControl(datamap *map, HWND dialog, HWND control, core_options *opts, const char *option_name) |
| 1747 | { |
| 1748 | int iMonitors; |
| 1749 | DISPLAY_DEVICE dd; |
| 1750 | int i = 0; |
| 1751 | int nSelection = 0; |
| 1752 | TCHAR* t_option = 0; |
| 1753 | |
| 1754 | /* Remove all items in the list. */ |
| 1755 | (void)ComboBox_ResetContent(control); |
| 1756 | (void)ComboBox_InsertString(control, 0, TEXT("Auto")); |
| 1757 | (void)ComboBox_SetItemData(control, 0, (const char*)mame_strdup("auto")); |
| 1758 | |
| 1759 | //Dynamically populate it, by enumerating the Monitors |
| 1760 | iMonitors = GetSystemMetrics(SM_CMONITORS); // this gets the count of monitors attached |
| 1761 | ZeroMemory(&dd, sizeof(dd)); |
| 1762 | dd.cb = sizeof(dd); |
| 1763 | for(i=0; EnumDisplayDevices(NULL, i, &dd, 0); i++) |
| 1764 | { |
| 1765 | if( !(dd.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) ) |
| 1766 | { |
| 1767 | char screen_option[32]; |
| 1768 | |
| 1769 | //we have to add 1 to account for the "auto" entry |
| 1770 | (void)ComboBox_InsertString(control, i+1, win_tstring_strdup(dd.DeviceName)); |
| 1771 | (void)ComboBox_SetItemData(control, i+1, (void*)win_tstring_strdup(dd.DeviceName)); |
| 1772 | |
| 1773 | snprintf(screen_option, ARRAY_LENGTH(screen_option), "screen%d", GetSelectedScreen(dialog)); |
| 1774 | t_option = tstring_from_utf8(options_get_string(opts, screen_option)); |
| 1775 | if( !t_option ) |
| 1776 | return FALSE; |
| 1777 | if (_tcscmp(t_option, dd.DeviceName) == 0) |
| 1778 | nSelection = i+1; |
| 1779 | free(t_option); |
| 1780 | } |
| 1781 | } |
| 1782 | (void)ComboBox_SetCurSel(control, nSelection); |
| 1783 | return FALSE; |
| 1784 | } |
| 1785 | |
| 1786 | |
| 1787 | |
| 1788 | static void ViewSetOptionName(datamap *map, HWND dialog, HWND control, char *buffer, size_t buffer_size) |
| 1789 | { |
| 1790 | snprintf(buffer, buffer_size, "view%d", GetSelectedScreen(dialog)); |
| 1791 | } |
| 1792 | |
| 1793 | |
| 1794 | |
| 1795 | static BOOL ViewPopulateControl(datamap *map, HWND dialog, HWND control, core_options *opts, const char *option_name) |
| 1796 | { |
| 1797 | int i; |
| 1798 | int selected_index = 0; |
| 1799 | char view_option[32]; |
| 1800 | const char *view; |
| 1801 | |
| 1802 | // determine the view option value |
| 1803 | snprintf(view_option, ARRAY_LENGTH(view_option), "view%d", GetSelectedScreen(dialog)); |
| 1804 | view = options_get_string(opts, view_option); |
| 1805 | |
| 1806 | (void)ComboBox_ResetContent(control); |
| 1807 | for (i = 0; i < NUMVIEW; i++) |
| 1808 | { |
| 1809 | (void)ComboBox_InsertString(control, i, g_ComboBoxView[i].m_pText); |
| 1810 | (void)ComboBox_SetItemData(control, i, g_ComboBoxView[i].m_pData); |
| 1811 | |
| 1812 | if (!strcmp(view, g_ComboBoxView[i].m_pData)) |
| 1813 | selected_index = i; |
| 1814 | } |
| 1815 | (void)ComboBox_SetCurSel(control, selected_index); |
| 1816 | return FALSE; |
| 1817 | } |
| 1818 | |
| 1819 | |
| 1820 | static BOOL DefaultInputPopulateControl(datamap *map, HWND dialog, HWND control, core_options *opts, const char *option_name) |
| 1821 | { |
| 1822 | WIN32_FIND_DATA FindFileData; |
| 1823 | HANDLE hFind; |
| 1824 | TCHAR *ext; |
| 1825 | TCHAR root[256]; |
| 1826 | TCHAR path[256]; |
| 1827 | int selected = 0; |
| 1828 | int index = 0; |
| 1829 | LPCTSTR t_ctrlr_option = 0; |
| 1830 | LPTSTR buf = 0; |
| 1831 | const char *ctrlr_option; |
| 1832 | TCHAR* t_ctrldir; |
| 1833 | |
| 1834 | // determine the ctrlr option |
| 1835 | ctrlr_option = options_get_string(opts, OPTION_CTRLR); |
| 1836 | if( ctrlr_option != NULL ) |
| 1837 | { |
| 1838 | buf = tstring_from_utf8(ctrlr_option); |
| 1839 | if( !buf ) |
| 1840 | return FALSE; |
| 1841 | t_ctrlr_option = buf; |
| 1842 | } |
| 1843 | else |
| 1844 | { |
| 1845 | t_ctrlr_option = TEXT(""); |
| 1846 | } |
| 1847 | |
| 1848 | // reset the controllers dropdown |
| 1849 | (void)ComboBox_ResetContent(control); |
| 1850 | (void)ComboBox_InsertString(control, index, TEXT("Standard")); |
| 1851 | (void)ComboBox_SetItemData(control, index, ""); |
| 1852 | index++; |
| 1853 | |
| 1854 | t_ctrldir = tstring_from_utf8(GetCtrlrDir()); |
| 1855 | if( !t_ctrldir ) |
| 1856 | { |
| 1857 | if( buf ) |
| 1858 | free(buf); |
| 1859 | return FALSE; |
| 1860 | } |
| 1861 | |
| 1862 | _stprintf (path, TEXT("%s\\*.*"), t_ctrldir); |
| 1863 | |
| 1864 | free(t_ctrldir); |
| 1865 | |
| 1866 | hFind = FindFirstFile(path, &FindFileData); |
| 1867 | |
| 1868 | if (hFind != INVALID_HANDLE_VALUE) |
| 1869 | { |
| 1870 | do |
| 1871 | { |
| 1872 | // copy the filename |
| 1873 | _tcscpy (root,FindFileData.cFileName); |
| 1874 | |
| 1875 | // find the extension |
| 1876 | ext = _tcsrchr (root,'.'); |
| 1877 | if (ext) |
| 1878 | { |
| 1879 | // check if it's a cfg file |
| 1880 | if (_tcscmp (ext, TEXT(".cfg")) == 0) |
| 1881 | { |
| 1882 | // and strip off the extension |
| 1883 | *ext = 0; |
| 1884 | |
| 1885 | // set the option? |
| 1886 | if (!_tcscmp(root, t_ctrlr_option)) |
| 1887 | selected = index; |
| 1888 | |
| 1889 | // add it as an option |
| 1890 | (void)ComboBox_InsertString(control, index, root); |
| 1891 | (void)ComboBox_SetItemData(control, index, (void*)win_tstring_strdup(root)); // FIXME - leaks memory! |
| 1892 | index++; |
| 1893 | } |
| 1894 | } |
| 1895 | } |
| 1896 | while (FindNextFile (hFind, &FindFileData) != 0); |
| 1897 | |
| 1898 | FindClose (hFind); |
| 1899 | } |
| 1900 | |
| 1901 | (void)ComboBox_SetCurSel(control, selected); |
| 1902 | |
| 1903 | if( buf ) |
| 1904 | free(buf); |
| 1905 | |
| 1906 | return FALSE; |
| 1907 | } |
| 1908 | |
| 1909 | |
| 1910 | |
| 1911 | static void ResolutionSetOptionName(datamap *map, HWND dialog, HWND control, char *buffer, size_t buffer_size) |
| 1912 | { |
| 1913 | snprintf(buffer, buffer_size, "resolution%d", GetSelectedScreen(dialog)); |
| 1914 | } |
| 1915 | |
| 1916 | |
| 1917 | static BOOL ResolutionReadControl(datamap *map, HWND dialog, HWND control, core_options *opts, const char *option_name) |
| 1918 | { |
| 1919 | HWND refresh_control = GetDlgItem(dialog, IDC_REFRESH); |
| 1920 | HWND sizes_control = GetDlgItem(dialog, IDC_SIZES); |
| 1921 | int refresh_index, refresh_value, width, height; |
| 1922 | char option_value[256]; |
| 1923 | TCHAR buffer[256]; |
| 1924 | |
| 1925 | if (refresh_control && sizes_control) |
| 1926 | { |
| 1927 | (void)ComboBox_GetText(sizes_control, buffer, ARRAY_LENGTH(buffer) - 1); |
| 1928 | if (_stscanf(buffer, TEXT("%d x %d"), &width, &height) == 2) |
| 1929 | { |
| 1930 | refresh_index = ComboBox_GetCurSel(refresh_control); |
| 1931 | refresh_value = ComboBox_GetItemData(refresh_control, refresh_index); |
| 1932 | snprintf(option_value, ARRAY_LENGTH(option_value), "%dx%d@%d", width, height, refresh_value); |
| 1933 | } |
| 1934 | else |
| 1935 | { |
| 1936 | snprintf(option_value, ARRAY_LENGTH(option_value), "auto"); |
| 1937 | } |
| 1938 | options_set_string(opts, option_name, option_value, OPTION_PRIORITY_CMDLINE); |
| 1939 | } |
| 1940 | return FALSE; |
| 1941 | } |
| 1942 | |
| 1943 | |
| 1944 | |
| 1945 | static BOOL ResolutionPopulateControl(datamap *map, HWND dialog, HWND control_, core_options *opts, const char *option_name) |
| 1946 | { |
| 1947 | HWND sizes_control = GetDlgItem(dialog, IDC_SIZES); |
| 1948 | HWND refresh_control = GetDlgItem(dialog, IDC_REFRESH); |
| 1949 | int width, height, refresh; |
| 1950 | const char *option_value; |
| 1951 | int sizes_index = 0; |
| 1952 | int refresh_index = 0; |
| 1953 | int sizes_selection = 0; |
| 1954 | int refresh_selection = 0; |
| 1955 | char screen_option[32]; |
| 1956 | const char *screen; |
| 1957 | LPTSTR t_screen; |
| 1958 | TCHAR buf[16]; |
| 1959 | int i; |
| 1960 | DEVMODE devmode; |
| 1961 | |
| 1962 | if (sizes_control && refresh_control) |
| 1963 | { |
| 1964 | // determine the resolution |
| 1965 | option_value = options_get_string(opts, option_name); |
| 1966 | if (sscanf(option_value, "%dx%d@%d", &width, &height, &refresh) != 3) |
| 1967 | { |
| 1968 | width = 0; |
| 1969 | height = 0; |
| 1970 | refresh = 0; |
| 1971 | } |
| 1972 | |
| 1973 | // reset sizes control |
| 1974 | (void)ComboBox_ResetContent(sizes_control); |
| 1975 | (void)ComboBox_InsertString(sizes_control, sizes_index, TEXT("Auto")); |
| 1976 | (void)ComboBox_SetItemData(sizes_control, sizes_index, 0); |
| 1977 | sizes_index++; |
| 1978 | |
| 1979 | // reset refresh control |
| 1980 | (void)ComboBox_ResetContent(refresh_control); |
| 1981 | (void)ComboBox_InsertString(refresh_control, refresh_index, TEXT("Auto")); |
| 1982 | (void)ComboBox_SetItemData(refresh_control, refresh_index, 0); |
| 1983 | refresh_index++; |
| 1984 | |
| 1985 | // determine which screen we're using |
| 1986 | snprintf(screen_option, ARRAY_LENGTH(screen_option), "screen%d", GetSelectedScreen(dialog)); |
| 1987 | screen = options_get_string(opts, screen_option); |
| 1988 | t_screen = tstring_from_utf8(screen); |
| 1989 | |
| 1990 | // retrieve screen information |
| 1991 | devmode.dmSize = sizeof(devmode); |
| 1992 | for (i = 0; EnumDisplaySettings(t_screen, i, &devmode); i++) |
| 1993 | { |
| 1994 | if ((devmode.dmBitsPerPel == 32 ) // Only 32 bit depth supported by core |
| 1995 | &&(devmode.dmDisplayFrequency == refresh || refresh == 0)) |
| 1996 | { |
| 1997 | _sntprintf(buf, ARRAY_LENGTH(buf), TEXT("%li x %li"), |
| 1998 | devmode.dmPelsWidth, devmode.dmPelsHeight); |
| 1999 | |
| 2000 | if (ComboBox_FindString(sizes_control, 0, buf) == CB_ERR) |
| 2001 | { |
| 2002 | (void)ComboBox_InsertString(sizes_control, sizes_index, buf); |
| 2003 | |
| 2004 | if ((width == devmode.dmPelsWidth) && (height == devmode.dmPelsHeight)) |
| 2005 | sizes_selection = sizes_index; |
| 2006 | sizes_index++; |
| 2007 | |
| 2008 | } |
| 2009 | } |
| 2010 | if (devmode.dmDisplayFrequency >= 10 ) |
| 2011 | { |
| 2012 | // I have some devmode "vga" which specifes 1 Hz, which is probably bogus, so we filter it out |
| 2013 | |
| 2014 | _sntprintf(buf, ARRAY_LENGTH(buf), TEXT("%li Hz"), devmode.dmDisplayFrequency); |
| 2015 | |
| 2016 | if (ComboBox_FindString(refresh_control, 0, buf) == CB_ERR) |
| 2017 | { |
| 2018 | (void)ComboBox_InsertString(refresh_control, refresh_index, buf); |
| 2019 | (void)ComboBox_SetItemData(refresh_control, refresh_index, devmode.dmDisplayFrequency); |
| 2020 | |
| 2021 | if (refresh == devmode.dmDisplayFrequency) |
| 2022 | refresh_selection = refresh_index; |
| 2023 | |
| 2024 | refresh_index++; |
| 2025 | } |
| 2026 | } |
| 2027 | } |
| 2028 | free(t_screen); |
| 2029 | |
| 2030 | (void)ComboBox_SetCurSel(sizes_control, sizes_selection); |
| 2031 | (void)ComboBox_SetCurSel(refresh_control, refresh_selection); |
| 2032 | } |
| 2033 | return FALSE; |
| 2034 | } |
| 2035 | |
| 2036 | |
| 2037 | |
| 2038 | //============================================================ |
| 2039 | |
| 2040 | /************************************************************ |
| 2041 | * DataMap initializers |
| 2042 | ************************************************************/ |
| 2043 | |
| 2044 | /* Initialize local helper variables */ |
| 2045 | static void ResetDataMap(HWND hWnd) |
| 2046 | { |
| 2047 | char screen_option[32]; |
| 2048 | |
| 2049 | snprintf(screen_option, ARRAY_LENGTH(screen_option), "screen%d", GetSelectedScreen(hWnd)); |
| 2050 | |
| 2051 | if (options_get_string(pCurrentOpts, screen_option) == NULL |
| 2052 | || (mame_stricmp(options_get_string(pCurrentOpts, screen_option), "") == 0 ) |
| 2053 | || (mame_stricmp(options_get_string(pCurrentOpts, screen_option), "auto") == 0 ) ) |
| 2054 | { |
| 2055 | options_set_string(pCurrentOpts, screen_option, "auto", OPTION_PRIORITY_CMDLINE); |
| 2056 | } |
| 2057 | } |
| 2058 | |
| 2059 | |
| 2060 | /* Build the control mapping by adding all needed information to the DataMap */ |
| 2061 | static void BuildDataMap(void) |
| 2062 | { |
| 2063 | properties_datamap = datamap_create(); |
| 2064 | |
| 2065 | // core state options |
| 2066 | datamap_add(properties_datamap, IDC_ENABLE_AUTOSAVE, DM_BOOL, OPTION_AUTOSAVE); |
| 2067 | |
| 2068 | // core performance options |
| 2069 | datamap_add(properties_datamap, IDC_AUTOFRAMESKIP, DM_BOOL, OPTION_AUTOFRAMESKIP); |
| 2070 | datamap_add(properties_datamap, IDC_FRAMESKIP, DM_INT, OPTION_FRAMESKIP); |
| 2071 | // Missing -seconds_to_run OPTION_SECONDS_TO_RUN |
| 2072 | datamap_add(properties_datamap, IDC_THROTTLE, DM_BOOL, OPTION_THROTTLE); |
| 2073 | datamap_add(properties_datamap, IDC_SLEEP, DM_BOOL, OPTION_SLEEP); |
| 2074 | datamap_add(properties_datamap, IDC_SPEED, DM_FLOAT, OPTION_SPEED); |
| 2075 | datamap_add(properties_datamap, IDC_SPEEDDISP, DM_FLOAT, OPTION_SPEED); |
| 2076 | datamap_add(properties_datamap, IDC_REFRESHSPEED, DM_BOOL, OPTION_REFRESHSPEED); |
| 2077 | |
| 2078 | // Ccore retation options |
| 2079 | datamap_add(properties_datamap, IDC_ROTATE, DM_INT, NULL); |
| 2080 | // ror, rol, autoror, autorol handled by callback |
| 2081 | datamap_add(properties_datamap, IDC_FLIPX, DM_BOOL, OPTION_FLIPX); |
| 2082 | datamap_add(properties_datamap, IDC_FLIPY, DM_BOOL, OPTION_FLIPY); |
| 2083 | |
| 2084 | // core artwork options |
| 2085 | datamap_add(properties_datamap, IDC_ARTWORK_CROP, DM_BOOL, OPTION_ARTWORK_CROP); |
| 2086 | datamap_add(properties_datamap, IDC_BACKDROPS, DM_BOOL, OPTION_USE_BACKDROPS); |
| 2087 | datamap_add(properties_datamap, IDC_OVERLAYS, DM_BOOL, OPTION_USE_OVERLAYS); |
| 2088 | datamap_add(properties_datamap, IDC_BEZELS, DM_BOOL, OPTION_USE_BEZELS); |
| 2089 | |
| 2090 | // core screen options |
| 2091 | datamap_add(properties_datamap, IDC_BRIGHTCORRECT, DM_FLOAT, OPTION_BRIGHTNESS); |
| 2092 | datamap_add(properties_datamap, IDC_BRIGHTCORRECTDISP, DM_FLOAT, OPTION_BRIGHTNESS); |
| 2093 | datamap_add(properties_datamap, IDC_CONTRAST, DM_FLOAT, OPTION_CONTRAST); |
| 2094 | datamap_add(properties_datamap, IDC_CONTRASTDISP, DM_FLOAT, OPTION_CONTRAST); |
| 2095 | datamap_add(properties_datamap, IDC_GAMMA, DM_FLOAT, OPTION_GAMMA); |
| 2096 | datamap_add(properties_datamap, IDC_GAMMADISP, DM_FLOAT, OPTION_GAMMA); |
| 2097 | datamap_add(properties_datamap, IDC_PAUSEBRIGHT, DM_FLOAT, OPTION_PAUSE_BRIGHTNESS); |
| 2098 | datamap_add(properties_datamap, IDC_PAUSEBRIGHTDISP, DM_FLOAT, OPTION_PAUSE_BRIGHTNESS); |
| 2099 | |
| 2100 | // core vector options |
| 2101 | datamap_add(properties_datamap, IDC_ANTIALIAS, DM_BOOL, OPTION_ANTIALIAS); |
| 2102 | datamap_add(properties_datamap, IDC_BEAM, DM_FLOAT, OPTION_BEAM); |
| 2103 | datamap_add(properties_datamap, IDC_BEAMDISP, DM_FLOAT, OPTION_BEAM); |
| 2104 | datamap_add(properties_datamap, IDC_FLICKER, DM_FLOAT, OPTION_FLICKER); |
| 2105 | datamap_add(properties_datamap, IDC_FLICKERDISP, DM_FLOAT, OPTION_FLICKER); |
| 2106 | |
| 2107 | // core sound options |
| 2108 | datamap_add(properties_datamap, IDC_SAMPLERATE, DM_INT, OPTION_SAMPLERATE); |
| 2109 | datamap_add(properties_datamap, IDC_SAMPLES, DM_BOOL, OPTION_SAMPLES); |
| 2110 | datamap_add(properties_datamap, IDC_USE_SOUND, DM_BOOL, OPTION_SOUND); |
| 2111 | datamap_add(properties_datamap, IDC_VOLUME, DM_INT, OPTION_VOLUME); |
| 2112 | datamap_add(properties_datamap, IDC_VOLUMEDISP, DM_INT, OPTION_VOLUME); |
| 2113 | |
| 2114 | // core input options |
| 2115 | datamap_add(properties_datamap, IDC_DEFAULT_INPUT, DM_STRING, OPTION_CTRLR); |
| 2116 | datamap_add(properties_datamap, IDC_USE_MOUSE, DM_BOOL, OPTION_MOUSE); |
| 2117 | datamap_add(properties_datamap, IDC_JOYSTICK, DM_BOOL, OPTION_JOYSTICK); |
| 2118 | datamap_add(properties_datamap, IDC_LIGHTGUN, DM_BOOL, OPTION_LIGHTGUN); |
| 2119 | datamap_add(properties_datamap, IDC_STEADYKEY, DM_BOOL, OPTION_STEADYKEY); |
| 2120 | datamap_add(properties_datamap, IDC_MULTIKEYBOARD, DM_BOOL, OPTION_MULTIKEYBOARD); |
| 2121 | datamap_add(properties_datamap, IDC_MULTIMOUSE, DM_BOOL, OPTION_MULTIMOUSE); |
| 2122 | datamap_add(properties_datamap, IDC_RELOAD, DM_BOOL, OPTION_OFFSCREEN_RELOAD); |
| 2123 | // missing joystick_map |
| 2124 | datamap_add(properties_datamap, IDC_JDZ, DM_FLOAT, OPTION_JOYSTICK_DEADZONE); |
| 2125 | datamap_add(properties_datamap, IDC_JDZDISP, DM_FLOAT, OPTION_JOYSTICK_DEADZONE); |
| 2126 | datamap_add(properties_datamap, IDC_JSAT, DM_FLOAT, OPTION_JOYSTICK_SATURATION); |
| 2127 | datamap_add(properties_datamap, IDC_JSATDISP, DM_FLOAT, OPTION_JOYSTICK_SATURATION); |
| 2128 | |
| 2129 | // core input automatic enable options |
| 2130 | datamap_add(properties_datamap, IDC_PADDLE, DM_STRING, OPTION_PADDLE_DEVICE); |
| 2131 | datamap_add(properties_datamap, IDC_ADSTICK, DM_STRING, OPTION_ADSTICK_DEVICE); |
| 2132 | datamap_add(properties_datamap, IDC_PEDAL, DM_STRING, OPTION_PEDAL_DEVICE); |
| 2133 | datamap_add(properties_datamap, IDC_DIAL, DM_STRING, OPTION_DIAL_DEVICE); |
| 2134 | datamap_add(properties_datamap, IDC_TRACKBALL, DM_STRING, OPTION_TRACKBALL_DEVICE); |
| 2135 | datamap_add(properties_datamap, IDC_LIGHTGUNDEVICE, DM_STRING, OPTION_LIGHTGUN_DEVICE); |
| 2136 | datamap_add(properties_datamap, IDC_POSITIONAL, DM_STRING, OPTION_POSITIONAL_DEVICE); |
| 2137 | datamap_add(properties_datamap, IDC_MOUSE, DM_STRING, OPTION_MOUSE_DEVICE); |
| 2138 | |
| 2139 | // core debugging options |
| 2140 | datamap_add(properties_datamap, IDC_LOG, DM_BOOL, OPTION_LOG); |
| 2141 | #ifdef _DEBUG |
| 2142 | datamap_add(properties_datamap, IDC_DEBUG, DM_BOOL, OPTION_DEBUG); |
| 2143 | #endif |
| 2144 | |
| 2145 | // core misc options |
| 2146 | datamap_add(properties_datamap, IDC_BIOS, DM_STRING, OPTION_BIOS); |
| 2147 | datamap_add(properties_datamap, IDC_CHEAT, DM_BOOL, OPTION_CHEAT); |
| 2148 | datamap_add(properties_datamap, IDC_SKIP_GAME_INFO, DM_BOOL, OPTION_SKIP_GAMEINFO); |
| 2149 | |
| 2150 | // windows debuggin options |
| 2151 | // oslog? missing |
| 2152 | |
| 2153 | // windows performance options |
| 2154 | datamap_add(properties_datamap, IDC_HIGH_PRIORITY, DM_INT, WINOPTION_PRIORITY); |
| 2155 | datamap_add(properties_datamap, IDC_HIGH_PRIORITYTXT, DM_INT, WINOPTION_PRIORITY); |
| 2156 | datamap_add(properties_datamap, IDC_MULTITHREAD_RENDERING, DM_BOOL, WINOPTION_MULTITHREADING); |
| 2157 | |
| 2158 | // windows video options |
| 2159 | datamap_add(properties_datamap, IDC_VIDEO_MODE, DM_STRING, WINOPTION_VIDEO); |
| 2160 | datamap_add(properties_datamap, IDC_NUMSCREENS, DM_INT, WINOPTION_NUMSCREENS); |
| 2161 | datamap_add(properties_datamap, IDC_NUMSCREENSDISP, DM_INT, WINOPTION_NUMSCREENS); |
| 2162 | datamap_add(properties_datamap, IDC_WINDOWED, DM_BOOL, WINOPTION_WINDOW); |
| 2163 | datamap_add(properties_datamap, IDC_MAXIMIZE, DM_BOOL, WINOPTION_MAXIMIZE); |
| 2164 | datamap_add(properties_datamap, IDC_KEEPASPECT, DM_BOOL, WINOPTION_KEEPASPECT); |
| 2165 | datamap_add(properties_datamap, IDC_PRESCALE, DM_INT, WINOPTION_PRESCALE); |
| 2166 | datamap_add(properties_datamap, IDC_PRESCALEDISP, DM_INT, WINOPTION_PRESCALE); |
| 2167 | // datamap_add(properties_datamap, IDC_EFFECT, DM_STRING, WINOPTION_EFFECT); |
| 2168 | datamap_add(properties_datamap, IDC_WAITVSYNC, DM_BOOL, WINOPTION_WAITVSYNC); |
| 2169 | datamap_add(properties_datamap, IDC_SYNCREFRESH, DM_BOOL, WINOPTION_SYNCREFRESH); |
| 2170 | |
| 2171 | // DirectDraw specific options |
| 2172 | datamap_add(properties_datamap, IDC_HWSTRETCH, DM_BOOL, WINOPTION_HWSTRETCH); |
| 2173 | |
| 2174 | // Direct3D specific options |
| 2175 | datamap_add(properties_datamap, IDC_D3D_VERSION, DM_INT, WINOPTION_D3DVERSION); |
| 2176 | datamap_add(properties_datamap, IDC_D3D_FILTER, DM_BOOL, WINOPTION_FILTER); |
| 2177 | |
| 2178 | // per window video options |
| 2179 | datamap_add(properties_datamap, IDC_SCREEN, DM_STRING, NULL); |
| 2180 | datamap_add(properties_datamap, IDC_SCREENSELECT, DM_STRING, NULL); |
| 2181 | datamap_add(properties_datamap, IDC_VIEW, DM_STRING, NULL); |
| 2182 | datamap_add(properties_datamap, IDC_ASPECTRATIOD, DM_STRING, NULL); |
| 2183 | datamap_add(properties_datamap, IDC_ASPECTRATION, DM_STRING, NULL); |
| 2184 | datamap_add(properties_datamap, IDC_REFRESH, DM_STRING, NULL); |
| 2185 | datamap_add(properties_datamap, IDC_SIZES, DM_STRING, NULL); |
| 2186 | |
| 2187 | // full screen options |
| 2188 | datamap_add(properties_datamap, IDC_TRIPLE_BUFFER, DM_BOOL, WINOPTION_TRIPLEBUFFER); |
| 2189 | datamap_add(properties_datamap, IDC_SWITCHRES, DM_BOOL, WINOPTION_SWITCHRES); |
| 2190 | datamap_add(properties_datamap, IDC_FSBRIGHTNESS, DM_FLOAT, WINOPTION_FULLSCREENBRIGHTNESS); |
| 2191 | datamap_add(properties_datamap, IDC_FSBRIGHTNESSDISP, DM_FLOAT, WINOPTION_FULLSCREENBRIGHTNESS); |
| 2192 | datamap_add(properties_datamap, IDC_FSCONTRAST, DM_FLOAT, WINOPTION_FULLLSCREENCONTRAST); |
| 2193 | datamap_add(properties_datamap, IDC_FSCONTRASTDISP, DM_FLOAT, WINOPTION_FULLLSCREENCONTRAST); |
| 2194 | datamap_add(properties_datamap, IDC_FSGAMMA, DM_FLOAT, WINOPTION_FULLSCREENGAMMA); |
| 2195 | datamap_add(properties_datamap, IDC_FSGAMMADISP, DM_FLOAT, WINOPTION_FULLSCREENGAMMA); |
| 2196 | |
| 2197 | // windows sound options |
| 2198 | datamap_add(properties_datamap, IDC_AUDIO_LATENCY, DM_INT, WINOPTION_AUDIO_LATENCY); |
| 2199 | datamap_add(properties_datamap, IDC_AUDIO_LATENCY_DISP, DM_INT, WINOPTION_AUDIO_LATENCY); |
| 2200 | |
| 2201 | // input device options |
| 2202 | datamap_add(properties_datamap, IDC_DUAL_LIGHTGUN, DM_BOOL, WINOPTION_DUAL_LIGHTGUN); |
| 2203 | |
| 2204 | // set up callbacks |
| 2205 | datamap_set_callback(properties_datamap, IDC_ROTATE, DCT_READ_CONTROL, RotateReadControl); |
| 2206 | datamap_set_callback(properties_datamap, IDC_ROTATE, DCT_POPULATE_CONTROL, RotatePopulateControl); |
| 2207 | datamap_set_callback(properties_datamap, IDC_SCREEN, DCT_READ_CONTROL, ScreenReadControl); |
| 2208 | datamap_set_callback(properties_datamap, IDC_SCREEN, DCT_POPULATE_CONTROL, ScreenPopulateControl); |
| 2209 | datamap_set_callback(properties_datamap, IDC_VIEW, DCT_POPULATE_CONTROL, ViewPopulateControl); |
| 2210 | datamap_set_callback(properties_datamap, IDC_REFRESH, DCT_READ_CONTROL, ResolutionReadControl); |
| 2211 | datamap_set_callback(properties_datamap, IDC_REFRESH, DCT_POPULATE_CONTROL, ResolutionPopulateControl); |
| 2212 | datamap_set_callback(properties_datamap, IDC_SIZES, DCT_READ_CONTROL, ResolutionReadControl); |
| 2213 | datamap_set_callback(properties_datamap, IDC_SIZES, DCT_POPULATE_CONTROL, ResolutionPopulateControl); |
| 2214 | datamap_set_callback(properties_datamap, IDC_DEFAULT_INPUT, DCT_POPULATE_CONTROL, DefaultInputPopulateControl); |
| 2215 | |
| 2216 | datamap_set_option_name_callback(properties_datamap, IDC_VIEW, ViewSetOptionName); |
| 2217 | datamap_set_option_name_callback(properties_datamap, IDC_REFRESH, ResolutionSetOptionName); |
| 2218 | datamap_set_option_name_callback(properties_datamap, IDC_SIZES, ResolutionSetOptionName); |
| 2219 | |
| 2220 | // formats |
| 2221 | datamap_set_int_format(properties_datamap, IDC_VOLUMEDISP, "%ddB"); |
| 2222 | datamap_set_int_format(properties_datamap, IDC_AUDIO_LATENCY_DISP, "%d/5"); |
| 2223 | datamap_set_float_format(properties_datamap, IDC_BEAMDISP, "%03.2f"); |
| 2224 | datamap_set_float_format(properties_datamap, IDC_FLICKERDISP, "%03.2f"); |
| 2225 | datamap_set_float_format(properties_datamap, IDC_GAMMADISP, "%03.2f"); |
| 2226 | datamap_set_float_format(properties_datamap, IDC_BRIGHTCORRECTDISP, "%03.2f"); |
| 2227 | datamap_set_float_format(properties_datamap, IDC_CONTRASTDISP, "%03.2f"); |
| 2228 | datamap_set_float_format(properties_datamap, IDC_PAUSEBRIGHTDISP, "%03.2f"); |
| 2229 | datamap_set_float_format(properties_datamap, IDC_FSGAMMADISP, "%03.2f"); |
| 2230 | datamap_set_float_format(properties_datamap, IDC_FSBRIGHTNESSDISP, "%03.2f"); |
| 2231 | datamap_set_float_format(properties_datamap, IDC_FSCONTRASTDISP, "%03.2f"); |
| 2232 | datamap_set_float_format(properties_datamap, IDC_JDZDISP, "%03.2f"); |
| 2233 | datamap_set_float_format(properties_datamap, IDC_JSATDISP, "%03.2f"); |
| 2234 | datamap_set_float_format(properties_datamap, IDC_SPEEDDISP, "%03.2f"); |
| 2235 | |
| 2236 | // trackbar ranges |
| 2237 | datamap_set_trackbar_range(properties_datamap, IDC_PRESCALE, 1, 10, 1); |
| 2238 | datamap_set_trackbar_range(properties_datamap, IDC_JDZ, 0.00, 1.00, 0.05); |
| 2239 | datamap_set_trackbar_range(properties_datamap, IDC_JSAT, 0.00, 1.00, 0.05); |
| 2240 | datamap_set_trackbar_range(properties_datamap, IDC_SPEED, 0.00, 3.00, 0.01); |
| 2241 | |
| 2242 | #ifdef MESS |
| 2243 | // MESS specific stuff |
| 2244 | MessBuildDataMap(properties_datamap); |
| 2245 | #endif // MESS |
| 2246 | } |
| 2247 | |
| 2248 | BOOL IsControlOptionValue(HWND hDlg,HWND hwnd_ctrl, core_options *opts ) |
| 2249 | { |
| 2250 | int control_id = GetWindowLong(hwnd_ctrl, GWL_ID); |
| 2251 | |
| 2252 | // certain controls we need to handle specially |
| 2253 | switch (control_id) |
| 2254 | { |
| 2255 | case IDC_ASPECTRATION : |
| 2256 | { |
| 2257 | char aspect_option[32]; |
| 2258 | int n1 = 0, n2 = 0; |
| 2259 | int d1 = 0, d2 = 0; |
| 2260 | |
| 2261 | snprintf(aspect_option, ARRAY_LENGTH(aspect_option), "aspect%d", GetSelectedScreen(hDlg)); |
| 2262 | |
| 2263 | sscanf(options_get_string(pCurrentOpts, aspect_option), "%d:%d", &n1, &d1); |
| 2264 | sscanf(options_get_string(opts, aspect_option), "%d:%d", &n2, &d2); |
| 2265 | |
| 2266 | return n1 == n2; |
| 2267 | } |
| 2268 | case IDC_ASPECTRATIOD : |
| 2269 | { |
| 2270 | char aspect_option[32]; |
| 2271 | int n1 = 0, n2 = 0; |
| 2272 | int d1 = 0, d2 = 0; |
| 2273 | |
| 2274 | snprintf(aspect_option, ARRAY_LENGTH(aspect_option), "aspect%d", GetSelectedScreen(hDlg)); |
| 2275 | |
| 2276 | sscanf(options_get_string(pCurrentOpts, aspect_option), "%d:%d", &n1, &d1); |
| 2277 | sscanf(options_get_string(opts, aspect_option), "%d:%d", &n2, &d2); |
| 2278 | |
| 2279 | return d1 == d2; |
| 2280 | } |
| 2281 | case IDC_SIZES : |
| 2282 | { |
| 2283 | char resolution_option[32]; |
| 2284 | int x1=0,y1=0,x2=0,y2=0; |
| 2285 | |
| 2286 | snprintf(resolution_option, ARRAY_LENGTH(resolution_option), "resolution%d", GetSelectedScreen(hDlg)); |
| 2287 | |
| 2288 | if ((strcmp(options_get_string(pCurrentOpts, resolution_option), "auto") == 0) && |
| 2289 | (strcmp(options_get_string(opts, resolution_option), "auto") == 0)) |
| 2290 | return TRUE; |
| 2291 | |
| 2292 | sscanf(options_get_string(pCurrentOpts, resolution_option),"%d x %d",&x1,&y1); |
| 2293 | sscanf(options_get_string(opts, resolution_option),"%d x %d",&x2,&y2); |
| 2294 | |
| 2295 | return x1 == x2 && y1 == y2; |
| 2296 | } |
| 2297 | case IDC_ROTATE : |
| 2298 | { |
| 2299 | datamap_read_control(properties_datamap, hDlg, pCurrentOpts, control_id); |
| 2300 | |
| 2301 | return (options_get_bool(pCurrentOpts, OPTION_ROR) == options_get_bool(opts, OPTION_ROR)) |
| 2302 | || (options_get_bool(pCurrentOpts, OPTION_ROL) == options_get_bool(opts, OPTION_ROL)) |
| 2303 | || (options_get_bool(pCurrentOpts, OPTION_AUTOROR) == options_get_bool(opts, OPTION_AUTOROR)) |
| 2304 | || (options_get_bool(pCurrentOpts, OPTION_AUTOROL) == options_get_bool(opts, OPTION_AUTOROL)); |
| 2305 | } |
| 2306 | } |
| 2307 | |
| 2308 | // most options we can compare using data in the data map |
| 2309 | //if (IsControlDifferent(hDlg,hwnd_ctrl,pCurrentOpts,opts)) |
| 2310 | // return FALSE; |
| 2311 | |
| 2312 | return TRUE; |
| 2313 | } |
| 2314 | |
| 2315 | |
| 2316 | static void SetStereoEnabled(HWND hWnd, int nIndex) |
| 2317 | { |
| 2318 | BOOL enabled = FALSE; |
| 2319 | HWND hCtrl; |
| 2320 | machine_config drv; |
| 2321 | int speakernum, num_speakers; |
| 2322 | |
| 2323 | num_speakers = 0; |
| 2324 | |
| 2325 | if ( nIndex > -1) |
| 2326 | { |
| 2327 | expand_machine_driver(drivers[nIndex]->drv,&drv); |
| 2328 | for (speakernum = 0; speakernum < MAX_SPEAKER; speakernum++) |
| 2329 | if (drv.speaker[speakernum].tag != NULL) |
| 2330 | num_speakers++; |
| 2331 | } |
| 2332 | |
| 2333 | hCtrl = GetDlgItem(hWnd, IDC_STEREO); |
| 2334 | if (hCtrl) |
| 2335 | { |
| 2336 | if (nIndex <= -1 || num_speakers == 2) |
| 2337 | enabled = TRUE; |
| 2338 | |
| 2339 | EnableWindow(hCtrl, enabled); |
| 2340 | } |
| 2341 | } |
| 2342 | |
| 2343 | static void SetYM3812Enabled(HWND hWnd, int nIndex) |
| 2344 | { |
| 2345 | int i; |
| 2346 | BOOL enabled; |
| 2347 | HWND hCtrl; |
| 2348 | machine_config drv; |
| 2349 | |
| 2350 | if (nIndex > -1) |
| 2351 | expand_machine_driver(drivers[nIndex]->drv,&drv); |
| 2352 | |
| 2353 | hCtrl = GetDlgItem(hWnd, IDC_USE_FM_YM3812); |
| 2354 | if (hCtrl) |
| 2355 | { |
| 2356 | enabled = FALSE; |
| 2357 | for (i = 0; i < MAX_SOUND; i++) |
| 2358 | { |
| 2359 | if (nIndex <= -1 |
| 2360 | #if HAS_YM3812 |
| 2361 | || drv.sound[i].sound_type == SOUND_YM3812 |
| 2362 | #endif |
| 2363 | #if HAS_YM3526 |
| 2364 | || drv.sound[i].sound_type == SOUND_YM3526 |
| 2365 | #endif |
| 2366 | #if HAS_YM2413 |
| 2367 | || drv.sound[i].sound_type == SOUND_YM2413 |
| 2368 | #endif |
| 2369 | ) |
| 2370 | enabled = TRUE; |
| 2371 | } |
| 2372 | |
| 2373 | EnableWindow(hCtrl, enabled); |
| 2374 | } |
| 2375 | } |
| 2376 | |
| 2377 | static void SetSamplesEnabled(HWND hWnd, int nIndex, BOOL bSoundEnabled) |
| 2378 | { |
| 2379 | #if (HAS_SAMPLES == 1) || (HAS_VLM5030 == 1) |
| 2380 | int i; |
| 2381 | BOOL enabled = FALSE; |
| 2382 | HWND hCtrl; |
| 2383 | machine_config drv; |
| 2384 | |
| 2385 | hCtrl = GetDlgItem(hWnd, IDC_SAMPLES); |
| 2386 | |
| 2387 | if ( nIndex > -1 ) |
| 2388 | expand_machine_driver(drivers[nIndex]->drv,&drv); |
| 2389 | |
| 2390 | if (hCtrl) |
| 2391 | { |
| 2392 | for (i = 0; i < MAX_SOUND; i++) |
| 2393 | { |
| 2394 | if (nIndex <= -1 |
| 2395 | || drv.sound[i].sound_type == SOUND_SAMPLES |
| 2396 | #if HAS_VLM5030 |
| 2397 | || drv.sound[i].sound_type == SOUND_VLM5030 |
| 2398 | #endif |
| 2399 | ) |
| 2400 | enabled = TRUE; |
| 2401 | } |
| 2402 | enabled = enabled && bSoundEnabled; |
| 2403 | EnableWindow(hCtrl, enabled); |
| 2404 | } |
| 2405 | #endif |
| 2406 | } |
| 2407 | |
| 2408 | /* Moved here cause it's called in a few places */ |
| 2409 | static void InitializeOptions(HWND hDlg) |
| 2410 | { |
| 2411 | InitializeSoundUI(hDlg); |
| 2412 | InitializeSkippingUI(hDlg); |
| 2413 | InitializeRotateUI(hDlg); |
| 2414 | InitializeSelectScreenUI(hDlg); |
| 2415 | InitializeEffectUI(hDlg); |
| 2416 | InitializeBIOSUI(hDlg); |
| 2417 | InitializeControllerMappingUI(hDlg); |
| 2418 | InitializeD3DVersionUI(hDlg); |
| 2419 | InitializeVideoUI(hDlg); |
| 2420 | } |
| 2421 | |
| 2422 | /* Moved here because it is called in several places */ |
| 2423 | static void InitializeMisc(HWND hDlg) |
| 2424 | { |
| 2425 | Button_Enable(GetDlgItem(hDlg, IDC_JOYSTICK), DIJoystick.Available()); |
| 2426 | } |
| 2427 | |
| 2428 | static void OptOnHScroll(HWND hwnd, HWND hwndCtl, UINT code, int pos) |
| 2429 | { |
| 2430 | if (hwndCtl == GetDlgItem(hwnd, IDC_NUMSCREENS)) |
| 2431 | { |
| 2432 | NumScreensSelectionChange(hwnd); |
| 2433 | } |
| 2434 | } |
| 2435 | |
| 2436 | /* Handle changes to the Numscreens slider */ |
| 2437 | static void NumScreensSelectionChange(HWND hwnd) |
| 2438 | { |
| 2439 | //Also Update the ScreenSelect Combo with the new number of screens |
| 2440 | UpdateSelectScreenUI(hwnd ); |
| 2441 | } |
| 2442 | |
| 2443 | /* Handle changes to the Refresh drop down */ |
| 2444 | static void RefreshSelectionChange(HWND hWnd, HWND hWndCtrl) |
| 2445 | { |
| 2446 | int nCurSelection; |
| 2447 | |
| 2448 | nCurSelection = ComboBox_GetCurSel(hWndCtrl); |
| 2449 | if (nCurSelection != CB_ERR) |
| 2450 | { |
| 2451 | datamap_populate_control(properties_datamap, hWnd, pCurrentOpts, IDC_SIZES); |
| 2452 | } |
| 2453 | } |
| 2454 | |
| 2455 | /* Initialize the sound options */ |
| 2456 | static void InitializeSoundUI(HWND hwnd) |
| 2457 | { |
| 2458 | HWND hCtrl; |
| 2459 | int i = 0; |
| 2460 | |
| 2461 | hCtrl = GetDlgItem(hwnd, IDC_SAMPLERATE); |
| 2462 | if (hCtrl) |
| 2463 | { |
| 2464 | (void)ComboBox_AddString(hCtrl, TEXT("11025")); |
| 2465 | (void)ComboBox_SetItemData(hCtrl, i++, 11025); |
| 2466 | (void)ComboBox_AddString(hCtrl, TEXT("22050")); |
| 2467 | (void)ComboBox_SetItemData(hCtrl, i++, 22050); |
| 2468 | (void)ComboBox_AddString(hCtrl, TEXT("44100")); |
| 2469 | (void)ComboBox_SetItemData(hCtrl, i++, 44100); |
| 2470 | (void)ComboBox_AddString(hCtrl, TEXT("48000")); |
| 2471 | (void)ComboBox_SetItemData(hCtrl, i++, 48000); |
| 2472 | (void)ComboBox_SetCurSel(hCtrl, 1); |
| 2473 | } |
| 2474 | } |
| 2475 | |
| 2476 | /* Populate the Frame Skipping drop down */ |
| 2477 | static void InitializeSkippingUI(HWND hwnd) |
| 2478 | { |
| 2479 | HWND hCtrl = GetDlgItem(hwnd, IDC_FRAMESKIP); |
| 2480 | int i = 0; |
| 2481 | |
| 2482 | if (hCtrl) |
| 2483 | { |
| 2484 | (void)ComboBox_AddString(hCtrl, TEXT("Draw every frame")); |
| 2485 | (void)ComboBox_SetItemData(hCtrl, i++, 0); |
| 2486 | (void)ComboBox_AddString(hCtrl, TEXT("Skip 1 of 12 frames")); |
| 2487 | (void)ComboBox_SetItemData(hCtrl, i++, 1); |
| 2488 | (void)ComboBox_AddString(hCtrl, TEXT("Skip 2 of 12 frames")); |
| 2489 | (void)ComboBox_SetItemData(hCtrl, i++, 2); |
| 2490 | (void)ComboBox_AddString(hCtrl, TEXT("Skip 3 of 12 frames")); |
| 2491 | (void)ComboBox_SetItemData(hCtrl, i++, 3); |
| 2492 | (void)ComboBox_AddString(hCtrl, TEXT("Skip 4 of 12 frames")); |
| 2493 | (void)ComboBox_SetItemData(hCtrl, i++, 4); |
| 2494 | (void)ComboBox_AddString(hCtrl, TEXT("Skip 5 of 12 frames")); |
| 2495 | (void)ComboBox_SetItemData(hCtrl, i++, 5); |
| 2496 | (void)ComboBox_AddString(hCtrl, TEXT("Skip 6 of 12 frames")); |
| 2497 | (void)ComboBox_SetItemData(hCtrl, i++, 6); |
| 2498 | (void)ComboBox_AddString(hCtrl, TEXT("Skip 7 of 12 frames")); |
| 2499 | (void)ComboBox_SetItemData(hCtrl, i++, 7); |
| 2500 | (void)ComboBox_AddString(hCtrl, TEXT("Skip 8 of 12 frames")); |
| 2501 | (void)ComboBox_SetItemData(hCtrl, i++, 8); |
| 2502 | (void)ComboBox_AddString(hCtrl, TEXT("Skip 9 of 12 frames")); |
| 2503 | (void)ComboBox_SetItemData(hCtrl, i++, 9); |
| 2504 | (void)ComboBox_AddString(hCtrl, TEXT("Skip 10 of 12 frames")); |
| 2505 | (void)ComboBox_SetItemData(hCtrl, i++, 10); |
| 2506 | (void)ComboBox_AddString(hCtrl, TEXT("Skip 11 of 12 frames")); |
| 2507 | (void)ComboBox_SetItemData(hCtrl, i++, 11); |
| 2508 | } |
| 2509 | } |
| 2510 | |
| 2511 | /* Populate the Rotate drop down */ |
| 2512 | static void InitializeRotateUI(HWND hwnd) |
| 2513 | { |
| 2514 | HWND hCtrl = GetDlgItem(hwnd, IDC_ROTATE); |
| 2515 | |
| 2516 | if (hCtrl) |
| 2517 | { |
| 2518 | (void)ComboBox_AddString(hCtrl, TEXT("Default")); // 0 |
| 2519 | (void)ComboBox_AddString(hCtrl, TEXT("Clockwise")); // 1 |
| 2520 | (void)ComboBox_AddString(hCtrl, TEXT("Anti-clockwise")); // 2 |
| 2521 | (void)ComboBox_AddString(hCtrl, TEXT("None")); // 3 |
| 2522 | (void)ComboBox_AddString(hCtrl, TEXT("Auto clockwise")); // 4 |
| 2523 | (void)ComboBox_AddString(hCtrl, TEXT("Auto anti-clockwise")); // 5 |
| 2524 | } |
| 2525 | } |
| 2526 | |
| 2527 | /* Populate the Video Mode drop down */ |
| 2528 | static void InitializeVideoUI(HWND hwnd) |
| 2529 | { |
| 2530 | HWND hCtrl; |
| 2531 | |
| 2532 | hCtrl = GetDlgItem(hwnd, IDC_VIDEO_MODE); |
| 2533 | if (hCtrl) |
| 2534 | { |
| 2535 | int i; |
| 2536 | for (i = 0; i < NUMVIDEO; i++) |
| 2537 | { |
| 2538 | (void)ComboBox_InsertString(hCtrl, i, g_ComboBoxVideo[i].m_pText); |
| 2539 | (void)ComboBox_SetItemData( hCtrl, i, g_ComboBoxVideo[i].m_pData); |
| 2540 | } |
| 2541 | } |
| 2542 | } |
| 2543 | |
| 2544 | /* Populate the D3D Version drop down */ |
| 2545 | static void InitializeD3DVersionUI(HWND hwnd) |
| 2546 | { |
| 2547 | HWND hCtrl = GetDlgItem(hwnd, IDC_D3D_VERSION); |
| 2548 | if (hCtrl) |
| 2549 | { |
| 2550 | int i; |
| 2551 | for (i = 0; i < NUMD3DVERSIONS; i++) |
| 2552 | { |
| 2553 | (void)ComboBox_InsertString(hCtrl, i, g_ComboBoxD3DVersion[i].m_pText); |
| 2554 | (void)ComboBox_SetItemData( hCtrl, i, g_ComboBoxD3DVersion[i].m_pData); |
| 2555 | } |
| 2556 | } |
| 2557 | } |
| 2558 | |
| 2559 | static void UpdateSelectScreenUI(HWND hwnd) |
| 2560 | { |
| 2561 | HWND hCtrl = GetDlgItem(hwnd, IDC_SCREENSELECT); |
| 2562 | if (hCtrl) |
| 2563 | { |
| 2564 | int i, curSel; |
| 2565 | curSel = ComboBox_GetCurSel(hCtrl); |
| 2566 | if ((curSel < 0) || (curSel >= MAX_SCREENS)) |
| 2567 | curSel = 0; |
| 2568 | (void)ComboBox_ResetContent(hCtrl ); |
| 2569 | for (i = 0; i < NUMSELECTSCREEN && i < options_get_int(pCurrentOpts, WINOPTION_NUMSCREENS) ; i++) |
| 2570 | { |
| 2571 | (void)ComboBox_InsertString(hCtrl, i, g_ComboBoxSelectScreen[i].m_pText); |
| 2572 | (void)ComboBox_SetItemData( hCtrl, i, g_ComboBoxSelectScreen[i].m_pData); |
| 2573 | } |
| 2574 | // Smaller Amount of screens was selected, so use 0 |
| 2575 | if( i< curSel ) |
| 2576 | (void)ComboBox_SetCurSel(hCtrl, 0 ); |
| 2577 | else |
| 2578 | (void)ComboBox_SetCurSel(hCtrl, curSel ); |
| 2579 | } |
| 2580 | } |
| 2581 | |
| 2582 | /* Populate the Select Screen drop down */ |
| 2583 | static void InitializeSelectScreenUI(HWND hwnd) |
| 2584 | { |
| 2585 | UpdateSelectScreenUI(hwnd); |
| 2586 | } |
| 2587 | |
| 2588 | static void InitializeEffectUI(HWND hwnd) |
| 2589 | { |
| 2590 | } |
| 2591 | |
| 2592 | static void InitializeControllerMappingUI(HWND hwnd) |
| 2593 | { |
| 2594 | int i; |
| 2595 | HWND hCtrl = GetDlgItem(hwnd,IDC_PADDLE); |
| 2596 | HWND hCtrl1 = GetDlgItem(hwnd,IDC_ADSTICK); |
| 2597 | HWND hCtrl2 = GetDlgItem(hwnd,IDC_PEDAL); |
| 2598 | HWND hCtrl3 = GetDlgItem(hwnd,IDC_MOUSE); |
| 2599 | HWND hCtrl4 = GetDlgItem(hwnd,IDC_DIAL); |
| 2600 | HWND hCtrl5 = GetDlgItem(hwnd,IDC_TRACKBALL); |
| 2601 | HWND hCtrl6 = GetDlgItem(hwnd,IDC_LIGHTGUNDEVICE); |
| 2602 | HWND hCtrl7 = GetDlgItem(hwnd,IDC_POSITIONAL); |
| 2603 | |
| 2604 | if (hCtrl) |
| 2605 | { |
| 2606 | for (i = 0; i < NUMDEVICES; i++) |
| 2607 | { |
| 2608 | (void)ComboBox_InsertString(hCtrl, i, g_ComboBoxDevice[i].m_pText); |
| 2609 | (void)ComboBox_SetItemData( hCtrl, i, g_ComboBoxDevice[i].m_pData); |
| 2610 | } |
| 2611 | } |
| 2612 | if (hCtrl1) |
| 2613 | { |
| 2614 | for (i = 0; i < NUMDEVICES; i++) |
| 2615 | { |
| 2616 | (void)ComboBox_InsertString(hCtrl1, i, g_ComboBoxDevice[i].m_pText); |
| 2617 | (void)ComboBox_SetItemData( hCtrl1, i, g_ComboBoxDevice[i].m_pData); |
| 2618 | } |
| 2619 | } |
| 2620 | if (hCtrl2) |
| 2621 | { |
| 2622 | for (i = 0; i < NUMDEVICES; i++) |
| 2623 | { |
| 2624 | (void)ComboBox_InsertString(hCtrl2, i, g_ComboBoxDevice[i].m_pText); |
| 2625 | (void)ComboBox_SetItemData( hCtrl2, i, g_ComboBoxDevice[i].m_pData); |
| 2626 | } |
| 2627 | } |
| 2628 | if (hCtrl3) |
| 2629 | { |
| 2630 | for (i = 0; i < NUMDEVICES; i++) |
| 2631 | { |
| 2632 | (void)ComboBox_InsertString(hCtrl3, i, g_ComboBoxDevice[i].m_pText); |
| 2633 | (void)ComboBox_SetItemData( hCtrl3, i, g_ComboBoxDevice[i].m_pData); |
| 2634 | } |
| 2635 | } |
| 2636 | if (hCtrl4) |
| 2637 | { |
| 2638 | for (i = 0; i < NUMDEVICES; i++) |
| 2639 | { |
| 2640 | (void)ComboBox_InsertString(hCtrl4, i, g_ComboBoxDevice[i].m_pText); |
| 2641 | (void)ComboBox_SetItemData( hCtrl4, i, g_ComboBoxDevice[i].m_pData); |
| 2642 | } |
| 2643 | } |
| 2644 | if (hCtrl5) |
| 2645 | { |
| 2646 | for (i = 0; i < NUMDEVICES; i++) |
| 2647 | { |
| 2648 | (void)ComboBox_InsertString(hCtrl5, i, g_ComboBoxDevice[i].m_pText); |
| 2649 | (void)ComboBox_SetItemData( hCtrl5, i, g_ComboBoxDevice[i].m_pData); |
| 2650 | } |
| 2651 | } |
| 2652 | if (hCtrl6) |
| 2653 | { |
| 2654 | for (i = 0; i < NUMDEVICES; i++) |
| 2655 | { |
| 2656 | (void)ComboBox_InsertString(hCtrl6, i, g_ComboBoxDevice[i].m_pText); |
| 2657 | (void)ComboBox_SetItemData( hCtrl6, i, g_ComboBoxDevice[i].m_pData); |
| 2658 | } |
| 2659 | } |
| 2660 | if (hCtrl7) |
| 2661 | { |
| 2662 | for (i = 0; i < NUMDEVICES; i++) |
| 2663 | { |
| 2664 | (void)ComboBox_InsertString(hCtrl7, i, g_ComboBoxDevice[i].m_pText); |
| 2665 | (void)ComboBox_SetItemData( hCtrl7, i, g_ComboBoxDevice[i].m_pData); |
| 2666 | } |
| 2667 | } |
| 2668 | } |
| 2669 | |
| 2670 | |
| 2671 | static void InitializeBIOSUI(HWND hwnd) |
| 2672 | { |
| 2673 | HWND hCtrl = GetDlgItem(hwnd,IDC_BIOS); |
| 2674 | int i = 0; |
| 2675 | TCHAR* t_s; |
| 2676 | if (hCtrl) |
| 2677 | { |
| 2678 | const game_driver *gamedrv = drivers[g_nGame]; |
| 2679 | const rom_entry *rom; |
| 2680 | |
| 2681 | if (g_nGame == GLOBAL_OPTIONS) |
| 2682 | { |
| 2683 | (void)ComboBox_InsertString(hCtrl, i, TEXT("None")); |
| 2684 | (void)ComboBox_SetItemData( hCtrl, i++, "none"); |
| 2685 | return; |
| 2686 | } |
| 2687 | if (g_nGame == FOLDER_OPTIONS) //Folder Options |
| 2688 | { |
| 2689 | gamedrv = drivers[g_nFolderGame]; |
| 2690 | if (DriverHasOptionalBIOS(g_nFolderGame) == FALSE) |
| 2691 | { |
| 2692 | (void)ComboBox_InsertString(hCtrl, i, TEXT("None")); |
| 2693 | (void)ComboBox_SetItemData( hCtrl, i++, "default"); |
| 2694 | return; |
| 2695 | } |
| 2696 | (void)ComboBox_InsertString(hCtrl, i, TEXT("Default")); |
| 2697 | (void)ComboBox_SetItemData( hCtrl, i++, "default"); |
| 2698 | |
| 2699 | if (gamedrv->rom != NULL) |
| 2700 | { |
| 2701 | for (rom = gamedrv->rom; !ROMENTRY_ISEND(rom); rom++) |
| 2702 | { |
| 2703 | if (ROMENTRY_ISSYSTEM_BIOS(rom)) |
| 2704 | { |
| 2705 | const char *name = ROM_GETHASHDATA(rom); |
| 2706 | t_s = tstring_from_utf8(name); |
| 2707 | if( !t_s ) |
| 2708 | return; |
| 2709 | (void)ComboBox_InsertString(hCtrl, i, win_tstring_strdup(t_s)); |
| 2710 | (void)ComboBox_SetItemData( hCtrl, i++, name); |
| 2711 | free(t_s); |
| 2712 | } |
| 2713 | } |
| 2714 | } |
| 2715 | return; |
| 2716 | } |
| 2717 | |
| 2718 | if (DriverHasOptionalBIOS(g_nGame) == FALSE) |
| 2719 | { |
| 2720 | (void)ComboBox_InsertString(hCtrl, i, TEXT("None")); |
| 2721 | (void)ComboBox_SetItemData( hCtrl, i++, "none"); |
| 2722 | return; |
| 2723 | } |
| 2724 | (void)ComboBox_InsertString(hCtrl, i, TEXT("Default")); |
| 2725 | (void)ComboBox_SetItemData( hCtrl, i++, "default"); |
| 2726 | |
| 2727 | if (gamedrv->rom != NULL) |
| 2728 | { |
| 2729 | for (rom = gamedrv->rom; !ROMENTRY_ISEND(rom); rom++) |
| 2730 | { |
| 2731 | if (ROMENTRY_ISSYSTEM_BIOS(rom)) |
| 2732 | { |
| 2733 | const char *name = ROM_GETHASHDATA(rom); |
| 2734 | t_s = tstring_from_utf8(name); |
| 2735 | if( !t_s ) |
| 2736 | return; |
| 2737 | (void)ComboBox_InsertString(hCtrl, i, win_tstring_strdup(t_s)); |
| 2738 | (void)ComboBox_SetItemData( hCtrl, i++, name); |
| 2739 | free(t_s); |
| 2740 | } |
| 2741 | } |
| 2742 | } |
| 2743 | } |
| 2744 | } |
| 2745 | |
| 2746 | static BOOL SelectEffect(HWND hWnd) |
| 2747 | { |
| 2748 | char filename[MAX_PATH]; |
| 2749 | BOOL changed = FALSE; |
| 2750 | |
| 2751 | *filename = 0; |
| 2752 | if (CommonFileDialog(GetOpenFileName, filename, FILETYPE_EFFECT_FILES)) |
| 2753 | { |
| 2754 | //strip Path and extension |
| 2755 | char buff[MAX_PATH]; |
| 2756 | int i, j = 0, k = 0, l = 0; |
| 2757 | for(i=0; i<strlen(filename); i++ ) |
| 2758 | { |
| 2759 | if( filename[i] == '\\' ) |
| 2760 | j = i; |
| 2761 | if( filename[i] == '.' ) |
| 2762 | k = i; |
| 2763 | } |
| 2764 | for(i=j+1;i<k;i++) |
| 2765 | { |
| 2766 | buff[l++] = filename[i]; |
| 2767 | } |
| 2768 | buff[l] = '\0'; |
| 2769 | |
| 2770 | if (strcmp(buff, options_get_string(pCurrentOpts, WINOPTION_EFFECT))) |
| 2771 | { |
| 2772 | HWND control = GetDlgItem(hWnd, IDC_EFFECT); |
| 2773 | options_set_string(pCurrentOpts, WINOPTION_EFFECT, buff, OPTION_PRIORITY_CMDLINE); |
| 2774 | win_set_window_text_utf8(control, buff); |
| 2775 | // datamap_populate_control(properties_datamap, hWnd, pCurrentOpts, IDC_EFFECT); |
| 2776 | changed = TRUE; |
| 2777 | } |
| 2778 | } |
| 2779 | return changed; |
| 2780 | } |
| 2781 | |
| 2782 | static BOOL ResetEffect(HWND hWnd) |
| 2783 | { |
| 2784 | BOOL changed = FALSE; |
| 2785 | const char *new_value = "none"; |
| 2786 | |
| 2787 | if (strcmp(new_value, options_get_string(pCurrentOpts, WINOPTION_EFFECT))) |
| 2788 | { |
| 2789 | HWND control = GetDlgItem(hWnd, IDC_EFFECT); |
| 2790 | options_set_string(pCurrentOpts, WINOPTION_EFFECT, new_value, OPTION_PRIORITY_CMDLINE); |
| 2791 | win_set_window_text_utf8(control, new_value); |
| 2792 | // datamap_populate_control(properties_datamap, hWnd, pCurrentOpts, IDC_EFFECT); |
| 2793 | changed = TRUE; |
| 2794 | } |
| 2795 | return changed; |
| 2796 | } |
| 2797 | |
| 2798 | |
| 2799 | void UpdateBackgroundBrush(HWND hwndTab) |
| 2800 | { |
| 2801 | // Destroy old brush |
| 2802 | if (hBkBrush) |
| 2803 | DeleteObject(hBkBrush); |
| 2804 | |
| 2805 | hBkBrush = NULL; |
| 2806 | |
| 2807 | // Only do this if the theme is active |
| 2808 | if (SafeIsAppThemed()) |
| 2809 | { |
| 2810 | RECT rc; |
| 2811 | HDC hDC, hDCMem; |
| 2812 | HBITMAP hBmp, hBmpOld; |
| 2813 | // Get tab control dimensions |
| 2814 | GetWindowRect( hwndTab, &rc); |
| 2815 | |
| 2816 | // Get the tab control DC |
| 2817 | hDC = GetDC(hwndTab); |
| 2818 | |
| 2819 | // Create a compatible DC |
| 2820 | hDCMem = CreateCompatibleDC(hDC); |
| 2821 | hBmp = CreateCompatibleBitmap(hDC, |
| 2822 | rc.right - rc.left, rc.bottom - rc.top); |
| 2823 | hBmpOld = (HBITMAP)(SelectObject(hDCMem, hBmp)); |
| 2824 | |
| 2825 | // Tell the tab control to paint in our DC |
| 2826 | SendMessage(hwndTab, WM_PRINTCLIENT, (WPARAM)(hDCMem), |
| 2827 | (LPARAM)(PRF_ERASEBKGND | PRF_CLIENT | PRF_NONCLIENT)); |
| 2828 | |
| 2829 | // Create a pattern brush from the bitmap selected in our DC |
| 2830 | hBkBrush = CreatePatternBrush(hBmp); |
| 2831 | |
| 2832 | // Restore the bitmap |
| 2833 | SelectObject(hDCMem, hBmpOld); |
| 2834 | |
| 2835 | // Cleanup |
| 2836 | DeleteObject(hBmp); |
| 2837 | DeleteDC(hDCMem); |
| 2838 | ReleaseDC(hwndTab, hDC); |
| 2839 | } |
| 2840 | } |
| 2841 | |
| 2842 | |
| 2843 | /* End of source file */ |